RxFPC: add demo for RxSecretPanel

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6421 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2018-05-16 11:29:59 +00:00
parent 613c96821c
commit 05a358bfd9
12 changed files with 2535 additions and 60 deletions

View File

@ -12,10 +12,10 @@ object Form1: TForm1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Button1 AnchorSideTop.Control = Button1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 232 Left = 235
Height = 36 Height = 23
Top = 48 Top = 35
Width = 113 Width = 106
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'Static message' Caption = 'Static message'
@ -27,10 +27,10 @@ object Form1: TForm1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Button4 AnchorSideTop.Control = Button4
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 225 Left = 229
Height = 36 Height = 23
Top = 90 Top = 64
Width = 127 Width = 118
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'Dinamic message' Caption = 'Dinamic message'
@ -42,10 +42,10 @@ object Form1: TForm1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ColorBox1 AnchorSideTop.Control = ColorBox1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 191 Left = 203
Height = 36 Height = 23
Top = 158 Top = 113
Width = 195 Width = 171
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'Message without auto close' Caption = 'Message without auto close'
@ -56,9 +56,9 @@ object Form1: TForm1
AnchorSideTop.Control = Button4 AnchorSideTop.Control = Button4
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 416 Left = 416
Height = 20 Height = 13
Top = 90 Top = 64
Width = 147 Width = 120
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Dinamic message color' Caption = 'Dinamic message color'
ParentColor = False ParentColor = False
@ -70,22 +70,22 @@ object Form1: TForm1
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 422 Left = 422
Height = 36 Height = 24
Top = 116 Top = 83
Width = 149 Width = 149
Selected = clYellow Selected = clYellow
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 20
TabOrder = 3 TabOrder = 3
end end
object RadioGroup1: TRadioGroup object RadioGroup1: TRadioGroup
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 6 Left = 6
Height = 117 Height = 86
Top = 6 Top = 6
Width = 140 Width = 116
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -97,8 +97,8 @@ object Form1: TForm1
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 96 ClientHeight = 68
ClientWidth = 138 ClientWidth = 112
ItemIndex = 3 ItemIndex = 3
Items.Strings = ( Items.Strings = (
'rpcTopLeft' 'rpcTopLeft'
@ -113,10 +113,10 @@ object Form1: TForm1
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 228 Left = 232
Height = 36 Height = 23
Top = 6 Top = 6
Width = 121 Width = 112
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'Design message' Caption = 'Design message'
@ -134,42 +134,17 @@ object Form1: TForm1
end end
object CheckBox1: TCheckBox object CheckBox1: TCheckBox
Left = 415 Left = 415
Height = 24 Height = 17
Top = 53 Top = 53
Width = 137 Width = 107
Caption = 'Show close timer' Caption = 'Show close timer'
Checked = True Checked = True
State = cbChecked State = cbChecked
TabOrder = 7 TabOrder = 7
end end
object SpeedButton1: TSpeedButton
Left = 422
Height = 26
Top = 7
Width = 26
Glyph.Data = {
1A020000424D1A0200000000000036000000280000000B0000000B0000000100
200000000000E401000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000FF0000
00FF00000000000000000000000000000000000000FF000000FF000000000000
00000000000000000000000000FF000000FF0000000000000000000000FF0000
00FF000000000000000000000000000000000000000000000000000000FF0000
00FF000000FF000000FF00000000000000000000000000000000000000000000
00000000000000000000000000FF000000FF0000000000000000000000000000
000000000000000000000000000000000000000000FF000000FF000000FF0000
00FF000000000000000000000000000000000000000000000000000000FF0000
00FF0000000000000000000000FF000000FF0000000000000000000000000000
0000000000FF000000FF00000000000000000000000000000000000000FF0000
00FF000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
}
end
object BitBtn1: TBitBtn object BitBtn1: TBitBtn
Left = 150 Left = 150
Height = 36 Height = 26
Top = 325 Top = 325
Width = 60 Width = 60
AutoSize = True AutoSize = True

View File

@ -23,7 +23,6 @@ type
Label1: TLabel; Label1: TLabel;
RadioGroup1: TRadioGroup; RadioGroup1: TRadioGroup;
RxPopupNotifier1: TRxPopupNotifier; RxPopupNotifier1: TRxPopupNotifier;
SpeedButton1: TSpeedButton;
TrackBar1: TTrackBar; TrackBar1: TTrackBar;
procedure Button1Click(Sender: TObject); procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject); procedure Button4Click(Sender: TObject);
@ -44,6 +43,7 @@ var
Form1: TForm1; Form1: TForm1;
implementation implementation
uses rxAppUtils;
{$R *.lfm} {$R *.lfm}
@ -94,7 +94,9 @@ begin
begin begin
FRClose:=RxPopupNotifier1.AddNotifyItem('Information', 'Static text information without close'); FRClose:=RxPopupNotifier1.AddNotifyItem('Information', 'Static text information without close');
FRClose.ShowCloseTimer:=false; FRClose.ShowCloseTimer:=false;
end end;
RxMessageBeep(mbsIconExclamation);
end; end;
procedure TForm1.RadioGroup1Click(Sender: TObject); procedure TForm1.RadioGroup1Click(Sender: TObject);

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="SecretPanel demo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="rxnew"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,23 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1, rxnew
{ you can add units after this };
{$R *.res}
begin
Application.Title:='SecretPanel demo';
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, rxctrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
CheckBox1: TCheckBox;
Label1: TLabel;
SecretPanel1: TSecretPanel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SecretPanel1StartPlay(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
uses rxlclutils;
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
SecretPanel1.Cycled:=CheckBox1.Checked;
SecretPanel1.Play;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SecretPanel1.Stop;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SecretPanel1StartPlay(nil);
end;
procedure TForm1.SecretPanel1StartPlay(Sender: TObject);
begin
Button1.Enabled:=not SecretPanel1.Active;
CheckBox1.Enabled:=not SecretPanel1.Active;
Button2.Enabled:=SecretPanel1.Active;
end;
end.

View File

@ -45,6 +45,9 @@ const
AllMask = '*'; AllMask = '*';
{$ENDIF} {$ENDIF}
type
TRxMsgBeepStyle = (mbsBeep, mbsIconAsterisk, mbsIconExclamation, mbsIconError, mbsIconQuestion, mbsIconWarning, mbsOk);
var var
DefCompanyName: string = ''; DefCompanyName: string = '';
RegUseAppTitle: Boolean = False; RegUseAppTitle: Boolean = False;
@ -94,6 +97,8 @@ procedure InitRxLogs;
function RxGetKeyboardLayoutName:string; function RxGetKeyboardLayoutName:string;
function RxMessageBeep(AStyle:TRxMsgBeepStyle):boolean;
implementation implementation
uses uses
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
@ -282,6 +287,29 @@ begin
{$ENDIF WINDOWS} {$ENDIF WINDOWS}
end; end;
function RxMessageBeep(AStyle: TRxMsgBeepStyle): boolean;
{$IFDEF WINDOWS}
var
uType:UINT;
{$ENDIF}
begin
{$IFDEF WINDOWS}
case AStyle of
mbsIconAsterisk:uType:=MB_ICONASTERISK;
mbsIconExclamation:uType:=MB_ICONEXCLAMATION;
mbsIconError:uType:=MB_ICONERROR;
mbsIconQuestion:uType:=MB_ICONQUESTION;
mbsIconWarning:uType:=MB_ICONWARNING;
mbsBeep,
mbsOk:uType:=MB_OK;
else
uType:=0;
end;
MessageBeep(uType);
{$ELSE}
{$ENDIF}
end;
function GetDefaultSection(Component: TComponent): string; function GetDefaultSection(Component: TComponent): string;
var var

View File

@ -3152,9 +3152,8 @@ begin
if not FGlyph.Empty then if not FGlyph.Empty then
begin begin
RecalcDrawRect; RecalcDrawRect;
//alexs Canvas.Draw(FGlyphOrigin.X, FGlyphOrigin.Y, FGlyph);
{ DrawBitmapTransparent(Canvas, FGlyphOrigin.X, FGlyphOrigin.Y, //DrawBitmapTransparent(Canvas, FGlyphOrigin.X, FGlyphOrigin.Y, FGlyph, FGlyph.TransparentColor and not PaletteMask);
FGlyph, FGlyph.TransparentColor and not PaletteMask);}
end; end;
end; end;
@ -3301,9 +3300,10 @@ begin
finally finally
RestoreDC(Canvas.Handle, SaveIndex); RestoreDC(Canvas.Handle, SaveIndex);
end; end;
if Active then begin if Active then
begin
PaintGlyph; PaintGlyph;
{PaintText;} PaintText;
end; end;
end; end;

View File

@ -43,6 +43,11 @@ uses
; ;
const
COLORONCOLOR = 3;
STRETCH_DELETESCANS = COLORONCOLOR;
PaletteMask = $02000000;
type type
TTextOrientation = (toHorizontal, toVertical90, toHorizontal180, toVertical270, toHorizontal360); TTextOrientation = (toHorizontal, toVertical90, toHorizontal180, toVertical270, toHorizontal360);
@ -98,6 +103,7 @@ procedure FreeMemo(var fpBlock: Pointer);
procedure RaiseIndexOutOfBounds(Control: TControl; Items:TStrings; Index: integer); procedure RaiseIndexOutOfBounds(Control: TControl; Items:TStrings; Index: integer);
procedure WriteTextHeader(ACanvas: TCanvas; ARect: TRect; const Text: string; Alignment: TAlignment); procedure WriteTextHeader(ACanvas: TCanvas; ARect: TRect; const Text: string; Alignment: TAlignment);
//procedure DrawBitmapTransparent(Dest: TCanvas; DstX, DstY: Integer; Bitmap: TBitmap; TransparentColor: TColor);
{$IFDEF WIN32} {$IFDEF WIN32}
type type
@ -784,6 +790,150 @@ if (ARect.Left<>ARect.Right) and (ARect.Top<>ARect.Bottom) then
ALIGN_FLAGS_HEADER[Alignment] {or DT_VCENTER or DT_END_ELLIPSIS } or DT_WORDBREAK ALIGN_FLAGS_HEADER[Alignment] {or DT_VCENTER or DT_END_ELLIPSIS } or DT_WORDBREAK
); );
end; end;
(*
function PaletteColor(Color: TColor): Longint;
begin
Result := ColorToRGB(Color) or PaletteMask;
end;
procedure StretchBltTransparent(DstDC: HDC; DstX, DstY, DstW, DstH: Integer;
SrcDC: HDC; SrcX, SrcY, SrcW, Srch: Integer; Palette: HPALETTE;
TransparentColor: TColorRef);
var
Color: TColorRef;
bmAndBack, bmAndObject, bmAndMem, bmSave: HBITMAP;
bmBackOld, bmObjectOld, bmMemOld, bmSaveOld: HBITMAP;
MemDC, BackDC, ObjectDC, SaveDC: HDC;
palDst, palMem, palSave, palObj: HPALETTE;
begin
{ Create some DCs to hold temporary data }
BackDC := CreateCompatibleDC(DstDC);
ObjectDC := CreateCompatibleDC(DstDC);
MemDC := CreateCompatibleDC(DstDC);
SaveDC := CreateCompatibleDC(DstDC);
{ Create a bitmap for each DC }
bmAndObject := CreateBitmap(SrcW, Srch, 1, 1, nil);
bmAndBack := CreateBitmap(SrcW, Srch, 1, 1, nil);
bmAndMem := CreateCompatibleBitmap(DstDC, DstW, DstH);
bmSave := CreateCompatibleBitmap(DstDC, SrcW, Srch);
{ Each DC must select a bitmap object to store pixel data }
bmBackOld := SelectObject(BackDC, bmAndBack);
bmObjectOld := SelectObject(ObjectDC, bmAndObject);
bmMemOld := SelectObject(MemDC, bmAndMem);
bmSaveOld := SelectObject(SaveDC, bmSave);
{ Select palette }
palDst := 0;
palMem := 0;
palSave := 0;
palObj := 0;
if Palette <> 0 then
begin
palDst := SelectPalette(DstDC, Palette, True);
RealizePalette(DstDC);
palSave := SelectPalette(SaveDC, Palette, False);
RealizePalette(SaveDC);
palObj := SelectPalette(ObjectDC, Palette, False);
RealizePalette(ObjectDC);
palMem := SelectPalette(MemDC, Palette, True);
RealizePalette(MemDC);
end;
{ Set proper mapping mode }
SetMapMode(SrcDC, GetMapMode(DstDC));
SetMapMode(SaveDC, GetMapMode(DstDC));
{ Save the bitmap sent here }
BitBlt(SaveDC, 0, 0, SrcW, Srch, SrcDC, SrcX, SrcY, SRCCOPY);
{ Set the background color of the source DC to the color, }
{ contained in the parts of the bitmap that should be transparent }
Color := SetBkColor(SaveDC, PaletteColor(TransparentColor));
{ Create the object mask for the bitmap by performing a BitBlt() }
{ from the source bitmap to a monochrome bitmap }
BitBlt(ObjectDC, 0, 0, SrcW, Srch, SaveDC, 0, 0, SRCCOPY);
{ Set the background color of the source DC back to the original }
SetBkColor(SaveDC, Color);
{ Create the inverse of the object mask }
BitBlt(BackDC, 0, 0, SrcW, Srch, ObjectDC, 0, 0, NOTSRCCOPY);
{ Copy the background of the main DC to the destination }
BitBlt(MemDC, 0, 0, DstW, DstH, DstDC, DstX, DstY, SRCCOPY);
{ Mask out the places where the bitmap will be placed }
StretchBlt(MemDC, 0, 0, DstW, DstH, ObjectDC, 0, 0, SrcW, Srch, SRCAND);
{ Mask out the transparent colored pixels on the bitmap }
BitBlt(SaveDC, 0, 0, SrcW, Srch, BackDC, 0, 0, SRCAND);
{ XOR the bitmap with the background on the destination DC }
StretchBlt(MemDC, 0, 0, DstW, DstH, SaveDC, 0, 0, SrcW, Srch, SRCPAINT);
{ Copy the destination to the screen }
BitBlt(DstDC, DstX, DstY, DstW, DstH, MemDC, 0, 0, SRCCOPY);
{ Restore palette }
if Palette <> 0 then
begin
SelectPalette(MemDC, palMem, False);
SelectPalette(ObjectDC, palObj, False);
SelectPalette(SaveDC, palSave, False);
SelectPalette(DstDC, palDst, True);
end;
{ Delete the memory bitmaps }
DeleteObject(SelectObject(BackDC, bmBackOld));
DeleteObject(SelectObject(ObjectDC, bmObjectOld));
DeleteObject(SelectObject(MemDC, bmMemOld));
DeleteObject(SelectObject(SaveDC, bmSaveOld));
{ Delete the memory DCs }
DeleteDC(MemDC);
DeleteDC(BackDC);
DeleteDC(ObjectDC);
DeleteDC(SaveDC);
end;
procedure StretchBitmapTransparent(Dest: TCanvas; Bitmap: TBitmap;
TransparentColor: TColor; DstX, DstY, DstW, DstH, SrcX, SrcY,
SrcW, Srch: Integer);
var
CanvasChanging: TNotifyEvent;
begin
if DstW <= 0 then
DstW := Bitmap.Width;
if DstH <= 0 then
DstH := Bitmap.Height;
if (SrcW <= 0) or (Srch <= 0) then
begin
SrcX := 0;
SrcY := 0;
SrcW := Bitmap.Width;
Srch := Bitmap.Height;
end;
if not Bitmap.Monochrome then
SetStretchBltMode(Dest.Handle, STRETCH_DELETESCANS);
CanvasChanging := Bitmap.Canvas.OnChanging;
Bitmap.Canvas.Lock;
try
Bitmap.Canvas.OnChanging := nil;
if TransparentColor = clNone then
begin
StretchBlt(Dest.Handle, DstX, DstY, DstW, DstH, Bitmap.Canvas.Handle,
SrcX, SrcY, SrcW, Srch, Cardinal(Dest.CopyMode));
end
else
begin
if TransparentColor = clDefault then
TransparentColor := Bitmap.Canvas.Pixels[0, Bitmap.Height - 1];
if Bitmap.Monochrome then
TransparentColor := clWhite
else
TransparentColor := ColorToRGB(TransparentColor);
StretchBltTransparent(Dest.Handle, DstX, DstY, DstW, DstH,
Bitmap.Canvas.Handle, SrcX, SrcY, SrcW, Srch,
Bitmap.Palette, TransparentColor);
end;
finally
Bitmap.Canvas.OnChanging := CanvasChanging;
Bitmap.Canvas.Unlock;
end;
end;
procedure DrawBitmapTransparent(Dest: TCanvas; DstX, DstY: Integer;
Bitmap: TBitmap; TransparentColor: TColor);
begin
StretchBitmapTransparent(Dest, Bitmap, TransparentColor, DstX, DstY,
Bitmap.Width, Bitmap.Height, 0, 0, Bitmap.Width, Bitmap.Height);
end; *)
initialization initialization
{$IFDEF RX_USE_LAZARUS_RESOURCE} {$IFDEF RX_USE_LAZARUS_RESOURCE}

View File

@ -546,6 +546,8 @@ begin
FNotifyForm.OnClose:=@OnNotifyFormClose; FNotifyForm.OnClose:=@OnNotifyFormClose;
FNotifyForm.Show; FNotifyForm.Show;
if Assigned(FSaveActiveForm) then if Assigned(FSaveActiveForm) then
FSaveActiveForm.BringToFront; FSaveActiveForm.BringToFront;
end; end;