You've already forked lazarus-ccr
RxFPC:new property TRxPopupNotifier.MessageCorner
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6343 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<AutoCreateForms Value="False"/>
|
||||
<Title Value="project1"/>
|
||||
<Title Value="RxPopupNotifier demo"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
|
@ -12,6 +12,7 @@ uses
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Title:='RxPopupNotifier demo';
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Scaled:=True;
|
||||
Application.Initialize;
|
||||
|
@ -3,61 +3,136 @@ object Form1: TForm1
|
||||
Height = 381
|
||||
Top = 449
|
||||
Width = 577
|
||||
Caption = 'Form1'
|
||||
Caption = 'RxPopupNotifier demo'
|
||||
ClientHeight = 381
|
||||
ClientWidth = 577
|
||||
LCLVersion = '1.9.0.0'
|
||||
object Button4: TButton
|
||||
Left = 224
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Button1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 232
|
||||
Height = 36
|
||||
Top = 48
|
||||
Width = 113
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Static message'
|
||||
OnClick = Button4Click
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button5: TButton
|
||||
Left = 216
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Button4
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 225
|
||||
Height = 36
|
||||
Top = 96
|
||||
Top = 90
|
||||
Width = 127
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Dinamic message'
|
||||
OnClick = Button5Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object Button6: TButton
|
||||
Left = 176
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = ColorBox1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 191
|
||||
Height = 36
|
||||
Top = 152
|
||||
Top = 158
|
||||
Width = 195
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Message without auto close'
|
||||
OnClick = Button6Click
|
||||
TabOrder = 2
|
||||
end
|
||||
object Label1: TLabel
|
||||
Left = 384
|
||||
AnchorSideTop.Control = Button4
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 416
|
||||
Height = 20
|
||||
Top = 112
|
||||
Width = 34
|
||||
Caption = 'Color'
|
||||
Top = 90
|
||||
Width = 147
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Dinamic message color'
|
||||
ParentColor = False
|
||||
end
|
||||
object ColorBox1: TColorBox
|
||||
Left = 424
|
||||
AnchorSideLeft.Control = Label1
|
||||
AnchorSideTop.Control = Label1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 422
|
||||
Height = 36
|
||||
Top = 96
|
||||
Width = 100
|
||||
Top = 116
|
||||
Width = 149
|
||||
Selected = clYellow
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
ItemHeight = 0
|
||||
TabOrder = 3
|
||||
end
|
||||
object RadioGroup1: TRadioGroup
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 6
|
||||
Height = 117
|
||||
Top = 6
|
||||
Width = 140
|
||||
AutoFill = True
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Message positon'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 96
|
||||
ClientWidth = 138
|
||||
ItemIndex = 3
|
||||
Items.Strings = (
|
||||
'rpcTopLeft'
|
||||
'rpcTopRight'
|
||||
'rpcBootomLeft'
|
||||
'rpcBottomRight'
|
||||
)
|
||||
OnClick = RadioGroup1Click
|
||||
TabOrder = 4
|
||||
end
|
||||
object Button1: TButton
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 228
|
||||
Height = 36
|
||||
Top = 6
|
||||
Width = 121
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Design message'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 5
|
||||
end
|
||||
object RxPopupNotifier1: TRxPopupNotifier
|
||||
Items = <>
|
||||
Items = <
|
||||
item
|
||||
Active = False
|
||||
Color = clAqua
|
||||
Caption = 'Design message'
|
||||
Message = 'Design time message'
|
||||
end>
|
||||
OnNotifiClick = RxPopupNotifier1NotifiClick
|
||||
Left = 56
|
||||
Top = 38
|
||||
Left = 176
|
||||
Top = 16
|
||||
end
|
||||
end
|
||||
|
@ -13,15 +13,19 @@ type
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Button1: TButton;
|
||||
Button4: TButton;
|
||||
Button5: TButton;
|
||||
Button6: TButton;
|
||||
ColorBox1: TColorBox;
|
||||
Label1: TLabel;
|
||||
RadioGroup1: TRadioGroup;
|
||||
RxPopupNotifier1: TRxPopupNotifier;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button4Click(Sender: TObject);
|
||||
procedure Button5Click(Sender: TObject);
|
||||
procedure Button6Click(Sender: TObject);
|
||||
procedure RadioGroup1Click(Sender: TObject);
|
||||
procedure RxPopupNotifier1NotifiClick(Sender: TRxPopupNotifier;
|
||||
AItem: TRxPopupNotifierItem);
|
||||
private
|
||||
@ -49,6 +53,18 @@ begin
|
||||
FR:=RxPopupNotifier1.AddNotifyItem('Information', 'Static text information');
|
||||
end;
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
var
|
||||
R: TRxPopupNotifierItem;
|
||||
begin
|
||||
if RxPopupNotifier1.Items.Count>0 then
|
||||
begin
|
||||
R:=RxPopupNotifier1.Items[0];
|
||||
R.Active:=true;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button5Click(Sender: TObject);
|
||||
var
|
||||
R1: TRxPopupNotifierItem;
|
||||
@ -70,6 +86,11 @@ begin
|
||||
end
|
||||
end;
|
||||
|
||||
procedure TForm1.RadioGroup1Click(Sender: TObject);
|
||||
begin
|
||||
RxPopupNotifier1.MessageCorner:=TRxPopupNotifierCorner(RadioGroup1.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TForm1.RxPopupNotifier1NotifiClick(Sender: TRxPopupNotifier;
|
||||
AItem: TRxPopupNotifierItem);
|
||||
begin
|
||||
|
@ -42,6 +42,8 @@ type
|
||||
TRxPopupNotifierItem = class;
|
||||
TRxPopupNotifier = class;
|
||||
TRxPopupNotifierState = (rpsInactive, rpsMaximazed, rpsShowing, rpsMinimized);
|
||||
TRxPopupNotifierCorner = (rpcTopLeft, rpcTopRight, rpcBootomLeft, rpcBottomRight);
|
||||
|
||||
TRxPopupNotifierEvent = procedure(Sender:TRxPopupNotifier; AItem:TRxPopupNotifierItem) of object;
|
||||
|
||||
{ TRxNotifierForm }
|
||||
@ -102,10 +104,13 @@ type
|
||||
{ TNotifierCollection }
|
||||
|
||||
TNotifierCollection = class(TOwnedCollection)
|
||||
private
|
||||
function GetItems(AIndex: Integer): TRxPopupNotifierItem;
|
||||
protected
|
||||
procedure Update(Item: TCollectionItem); override;
|
||||
public
|
||||
constructor Create(AOwner: TPersistent);
|
||||
property Items[AIndex:Integer]:TRxPopupNotifierItem read GetItems; default;
|
||||
end;
|
||||
|
||||
{ TRxPopupNotifier }
|
||||
@ -118,6 +123,7 @@ type
|
||||
FDefNotifierFormHeight: Cardinal;
|
||||
FDefNotifierFormWidth: Cardinal;
|
||||
FItems: TNotifierCollection;
|
||||
FMessageCorner: TRxPopupNotifierCorner;
|
||||
FOnNotifiClick: TRxPopupNotifierEvent;
|
||||
FTimer:TTimer;
|
||||
procedure SetActive(AValue: boolean);
|
||||
@ -137,6 +143,7 @@ type
|
||||
published
|
||||
property Active:boolean read FActive write SetActive default True;
|
||||
property Items:TNotifierCollection read FItems write SetItems;
|
||||
property MessageCorner:TRxPopupNotifierCorner read FMessageCorner write FMessageCorner default rpcBottomRight;
|
||||
property DefaultColor:TColor read FDefaultColor write FDefaultColor default clYellow;
|
||||
property DefNotifierFormWidth:Cardinal read FDefNotifierFormWidth write FDefNotifierFormWidth default 0;
|
||||
property DefNotifierFormHeight:Cardinal read FDefNotifierFormHeight write FDefNotifierFormHeight default 0;
|
||||
@ -215,6 +222,11 @@ end;
|
||||
|
||||
{ TNotifierCollection }
|
||||
|
||||
function TNotifierCollection.GetItems(AIndex: Integer): TRxPopupNotifierItem;
|
||||
begin
|
||||
Result:=TRxPopupNotifierItem(GetItem(AIndex));
|
||||
end;
|
||||
|
||||
procedure TNotifierCollection.Update(Item: TCollectionItem);
|
||||
var
|
||||
FActive: Boolean;
|
||||
@ -301,8 +313,33 @@ begin
|
||||
FNotifyForm:=TRxNotifierForm.CreateNotifierForm(Self);
|
||||
FNotifyForm.Width:=TRxPopupNotifier(Collection.Owner).NotifierFormWidth;
|
||||
FNotifyForm.Height:=1;
|
||||
FNotifyForm.Left:=Screen.Width - FNotifyForm.Width - 2;
|
||||
FNotifyForm.Top:=Screen.Height - FNotifyForm.Height - 2;
|
||||
|
||||
case TRxPopupNotifier(Collection.Owner).FMessageCorner of
|
||||
rpcTopLeft:
|
||||
begin
|
||||
//TODO : доделать
|
||||
FNotifyForm.Left := 2;
|
||||
FNotifyForm.Top := 2;
|
||||
end;
|
||||
rpcTopRight:
|
||||
begin
|
||||
//TODO : доделать
|
||||
FNotifyForm.Left := Screen.Width - FNotifyForm.Width - 2;
|
||||
FNotifyForm.Top := 2;
|
||||
end;
|
||||
rpcBootomLeft:
|
||||
begin
|
||||
//TODO : доделать
|
||||
FNotifyForm.Left := 2;
|
||||
FNotifyForm.Top := Screen.Height - FNotifyForm.Height - 2;
|
||||
end;
|
||||
rpcBottomRight:
|
||||
begin
|
||||
FNotifyForm.Left:=Screen.Width - FNotifyForm.Width - 2;
|
||||
FNotifyForm.Top:=Screen.Height - FNotifyForm.Height - 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
FNotifyForm.BorderStyle:=bsNone;
|
||||
FNotifyForm.FormStyle:=fsStayOnTop;
|
||||
FNotifyForm.ShowInTaskBar:=stNever;
|
||||
@ -329,7 +366,12 @@ begin
|
||||
if (TRxPopupNotifier(Collection.Owner).NotifierFormHeight > FNotifyForm.Height) then
|
||||
begin
|
||||
FNotifyForm.Height:=FNotifyForm.Height + 1;
|
||||
FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
case TRxPopupNotifier(Collection.Owner).FMessageCorner of
|
||||
//rpcTopLeft:;
|
||||
//rpcTopRight:;
|
||||
rpcBootomLeft:FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
rpcBottomRight:FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -343,13 +385,21 @@ begin
|
||||
if (FNotifyForm.Height > 1) then
|
||||
begin
|
||||
FNotifyForm.Height:=FNotifyForm.Height - 1;
|
||||
FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
case TRxPopupNotifier(Collection.Owner).FMessageCorner of
|
||||
//rpcTopLeft:;
|
||||
//rpcTopRight:;
|
||||
rpcBootomLeft:FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
rpcBottomRight:FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
end;
|
||||
end
|
||||
else
|
||||
FState:=rpsInactive;
|
||||
end;
|
||||
ATop:=ATop - FNotifyForm.Height;
|
||||
ATop:=ATop - 2;
|
||||
|
||||
if TRxPopupNotifier(Collection.Owner).FMessageCorner in [rpcTopLeft, rpcTopRight] then
|
||||
ATop:=ATop + FNotifyForm.Height + 2
|
||||
else
|
||||
ATop:=ATop - FNotifyForm.Height - 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -357,8 +407,20 @@ procedure TRxPopupNotifierItem.UpdateFormPosition(var ATop: integer);
|
||||
begin
|
||||
if Assigned(FNotifyForm) then
|
||||
begin
|
||||
FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
ATop:=ATop - FNotifyForm.Height - 2;
|
||||
case TRxPopupNotifier(Collection.Owner).FMessageCorner of
|
||||
rpcTopLeft,
|
||||
rpcTopRight:
|
||||
begin
|
||||
FNotifyForm.Top:=ATop;
|
||||
ATop:=ATop + FNotifyForm.Height + 2;
|
||||
end;
|
||||
rpcBootomLeft,
|
||||
rpcBottomRight:
|
||||
begin
|
||||
FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
ATop:=ATop - FNotifyForm.Height - 2;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -398,7 +460,11 @@ var
|
||||
Y, i: Integer;
|
||||
FReposition: Boolean;
|
||||
begin
|
||||
Y:=Screen.Height - 2;
|
||||
if FMessageCorner in [rpcTopLeft, rpcTopRight] then
|
||||
Y:=2
|
||||
else
|
||||
Y:=Screen.Height - 2;
|
||||
|
||||
FReposition:=false;
|
||||
for i:=FItems.Count - 1 downto 0 do
|
||||
begin
|
||||
@ -417,7 +483,18 @@ begin
|
||||
if FReposition then
|
||||
F.UpdateFormPosition(Y)
|
||||
else
|
||||
Y:=Y - F.FNotifyForm.Height - 2;
|
||||
begin
|
||||
if FMessageCorner in [rpcTopLeft, rpcTopRight] then
|
||||
Y:=Y + F.FNotifyForm.Height + 2
|
||||
else
|
||||
Y:=Y - F.FNotifyForm.Height - 2;
|
||||
end;
|
||||
|
||||
if Y<0 then
|
||||
Y:=2
|
||||
else
|
||||
if Y>Screen.Height then
|
||||
Y:=Screen.Height - 2;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -480,6 +557,7 @@ begin
|
||||
inherited Create(AOwner);
|
||||
FDefaultColor:=clYellow;
|
||||
FCloseInterval:=5;
|
||||
FMessageCorner:=rpcBottomRight;
|
||||
FActive:=true;
|
||||
FItems:=TNotifierCollection.Create(Self);
|
||||
FTimer:=TTimer.Create(Self);
|
||||
|
Reference in New Issue
Block a user