RxFPC:start work on new component - TRxPopupNotifier
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6328 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
0608517e55
commit
1c2a502b58
@ -3,7 +3,7 @@
|
||||
<ProjectSession>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="9">
|
||||
<Units Count="11">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -17,6 +17,7 @@
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<CursorPos X="23" Y="16"/>
|
||||
@ -26,12 +27,10 @@
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="82"/>
|
||||
<CursorPos X="16" Y="118"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.inc"/>
|
||||
@ -40,19 +39,17 @@
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="7723"/>
|
||||
<CursorPos X="23" Y="7755"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="../../../rxcontrols/rxlclutils.pas"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="675"/>
|
||||
<CursorPos X="29" Y="683"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="/home/install/source/fpcsrc/rtl/objpas/classes/streams.inc"/>
|
||||
@ -75,8 +72,25 @@
|
||||
<CursorPos X="10" Y="64"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="../../../../tachart/numlib_fix/ipf_fix.pas"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="453"/>
|
||||
<CursorPos X="66" Y="467"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="Z:/home/install/source/fpcsrc/packages/numlib/src/typ.pas"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="185"/>
|
||||
<CursorPos X="3" Y="199"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit10>
|
||||
</Units>
|
||||
<JumpHistory Count="27" HistoryIndex="26">
|
||||
<JumpHistory Count="5" HistoryIndex="4">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
</Position1>
|
||||
@ -85,105 +99,17 @@
|
||||
<Caret Line="16" Column="23"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="155" Column="12" TopLine="140"/>
|
||||
<Filename Value="../../../../tachart/numlib_fix/ipf_fix.pas"/>
|
||||
<Caret Line="466" Column="49" TopLine="452"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<Caret Line="308" TopLine="290"/>
|
||||
<Filename Value="Z:/home/install/source/fpcsrc/packages/numlib/src/typ.pas"/>
|
||||
<Caret Line="199" Column="3" TopLine="185"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="177" Column="21" TopLine="164"/>
|
||||
<Filename Value="../../../../tachart/numlib_fix/ipf_fix.pas"/>
|
||||
<Caret Line="467" Column="26" TopLine="452"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="94" Column="17" TopLine="76"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="168" Column="3" TopLine="163"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="71" Column="15" TopLine="54"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<Caret Line="7737" Column="47" TopLine="7725"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<Caret Line="1217" Column="12" TopLine="1198"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<Caret Line="3651" Column="35" TopLine="3619"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<Caret Line="7739" Column="12" TopLine="7706"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="311" Column="20" TopLine="294"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<Caret Line="7755" Column="23" TopLine="7723"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="../../../rxcontrols/rxlclutils.pas"/>
|
||||
<Caret Line="85" Column="10" TopLine="66"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="320" Column="11" TopLine="294"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="../../../rxdb/rxdbgrid.pas"/>
|
||||
<Caret Line="7755" Column="23" TopLine="7723"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="../../../rxcontrols/rxlclutils.pas"/>
|
||||
<Caret Line="85" Column="10" TopLine="66"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="318" TopLine="294"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="319" TopLine="294"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="318" TopLine="294"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="317" Column="41" TopLine="294"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="../../../rxcontrols/rxlclutils.pas"/>
|
||||
<Caret Line="683" Column="29" TopLine="675"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="317" Column="41" TopLine="294"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="319" Column="7" TopLine="294"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="320" Column="12" TopLine="301"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="../../../rxcontrols/rxswitch.pas"/>
|
||||
<Caret Line="194" TopLine="175"/>
|
||||
</Position27>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
@ -39,6 +39,14 @@ msgstr "Izquierdo"
|
||||
msgid "Right"
|
||||
msgstr "Derecho"
|
||||
|
||||
#: rxconst.sclose
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseaftersec
|
||||
msgid "Close after %d sec"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseallexceptthis
|
||||
msgid "Close all except this"
|
||||
msgstr ""
|
||||
|
@ -37,6 +37,14 @@ msgstr ""
|
||||
msgid "Right"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sclose
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseaftersec
|
||||
msgid "Close after %d sec"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseallexceptthis
|
||||
msgid "Close all except this"
|
||||
msgstr ""
|
||||
|
@ -37,6 +37,14 @@ msgstr "Влево"
|
||||
msgid "Right"
|
||||
msgstr "Вправо"
|
||||
|
||||
#: rxconst.sclose
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseaftersec
|
||||
msgid "Close after %d sec"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseallexceptthis
|
||||
msgid "Close all except this"
|
||||
msgstr "Закрыть все окна, за исключением этого"
|
||||
|
@ -48,6 +48,14 @@ msgstr "Ліворуч"
|
||||
msgid "Right"
|
||||
msgstr "Праворуч"
|
||||
|
||||
#: rxconst.sclose
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseaftersec
|
||||
msgid "Close after %d sec"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.scloseallexceptthis
|
||||
msgid "Close all except this"
|
||||
msgstr "Закрити всі вікна, за виключенням цього"
|
||||
|
Binary file not shown.
500
components/rx/trunk/rxcontrols/rxpopupnotifier.pas
Normal file
500
components/rx/trunk/rxcontrols/rxpopupnotifier.pas
Normal file
@ -0,0 +1,500 @@
|
||||
unit rxPopupNotifier;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, ExtCtrls, Forms, Graphics, Controls, StdCtrls;
|
||||
|
||||
type
|
||||
TRxPopupNotifierItem = class;
|
||||
TRxPopupNotifier = class;
|
||||
TRxPopupNotifierState = (rpsInactive, rpsMaximazed, rpsShowing, rpsMinimized);
|
||||
TRxPopupNotifierEvent = procedure(Sender:TRxPopupNotifier; AItem:TRxPopupNotifierItem) of object;
|
||||
|
||||
{ TRxNotifierForm }
|
||||
|
||||
TRxNotifierForm = class(TForm)
|
||||
private
|
||||
FCloseButton:TButton;
|
||||
FCaptionLabel:TLabel;
|
||||
FMessageLabel:TLabel;
|
||||
FTimerLabel:TLabel;
|
||||
FOwnerItem:TRxPopupNotifierItem;
|
||||
procedure CreateCloseButton;
|
||||
procedure CreateCaption(ACaption:string);
|
||||
procedure CreateMessage(AMessage:string);
|
||||
procedure CreateTimerLabel;
|
||||
procedure ButtonCloseClick(Sender: TObject);
|
||||
public
|
||||
constructor CreateNotifierForm(AOwnerItem:TRxPopupNotifierItem);
|
||||
end;
|
||||
|
||||
{ TRxPopupNotifierItem }
|
||||
|
||||
TRxPopupNotifierItem = class(TCollectionItem)
|
||||
private
|
||||
FActive: boolean;
|
||||
FAutoClose: boolean;
|
||||
FCaption: string;
|
||||
FColor: TColor;
|
||||
FMessage: string;
|
||||
FNotifyForm:TRxNotifierForm;
|
||||
FShowCloseButton: boolean;
|
||||
FShowCloseTimer: boolean;
|
||||
FCloseTime:TDateTime;
|
||||
FState: TRxPopupNotifierState;
|
||||
procedure OnNotifyFormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure SetActive(AValue: boolean);
|
||||
procedure SetColor(AValue: TColor);
|
||||
procedure UpdateCloseLabel;
|
||||
procedure CreateNotifierForm;
|
||||
procedure UpdateFormSizes(var ATop:integer);
|
||||
procedure UpdateFormPosition(var ATop:integer);
|
||||
procedure NotifierClick(Sender: TObject);
|
||||
protected
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
public
|
||||
constructor Create(ACollection: TCollection); override;
|
||||
property State:TRxPopupNotifierState read FState;
|
||||
published
|
||||
property Active:boolean read FActive write SetActive;
|
||||
property Color:TColor read FColor write SetColor default clYellow;
|
||||
property AutoClose:boolean read FAutoClose write FAutoClose default true;
|
||||
property ShowCloseTimer:boolean read FShowCloseTimer write FShowCloseTimer default true;
|
||||
property ShowCloseButton:boolean read FShowCloseButton write FShowCloseButton default true;
|
||||
property Caption:string read FCaption write FCaption;
|
||||
property Message:string read FMessage write FMessage;
|
||||
end;
|
||||
|
||||
{ TNotifierCollection }
|
||||
|
||||
TNotifierCollection = class(TOwnedCollection)
|
||||
protected
|
||||
procedure Update(Item: TCollectionItem); override;
|
||||
public
|
||||
constructor Create(AOwner: TPersistent);
|
||||
end;
|
||||
|
||||
{ TRxPopupNotifier }
|
||||
|
||||
TRxPopupNotifier = class(TComponent)
|
||||
private
|
||||
FActive: boolean;
|
||||
FCloseInterval: Cardinal;
|
||||
FDefaultColor: TColor;
|
||||
FDefNotifierFormHeight: Cardinal;
|
||||
FDefNotifierFormWidth: Cardinal;
|
||||
FItems: TNotifierCollection;
|
||||
FOnNotifiClick: TRxPopupNotifierEvent;
|
||||
FTimer:TTimer;
|
||||
procedure SetActive(AValue: boolean);
|
||||
procedure SetItems(AValue: TNotifierCollection);
|
||||
procedure UpdateNotifyFormsPositoon;
|
||||
procedure UpdateTimeState;
|
||||
procedure UpdateClosed;
|
||||
procedure NotifyTimerEvent(Sender: TObject);
|
||||
procedure DoNotifiClick(AItem:TRxPopupNotifierItem);
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function AddNotifyItem(ACaption, AMessage:string):TRxPopupNotifierItem;
|
||||
procedure Clear;
|
||||
function NotifierFormWidth:Cardinal;
|
||||
function NotifierFormHeight:Cardinal;
|
||||
published
|
||||
property Active:boolean read FActive write SetActive default True;
|
||||
property Items:TNotifierCollection read FItems write SetItems;
|
||||
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;
|
||||
property CloseInterval:Cardinal read FCloseInterval write FCloseInterval default 5;
|
||||
property OnNotifiClick:TRxPopupNotifierEvent read FOnNotifiClick write FOnNotifiClick;
|
||||
end;
|
||||
|
||||
implementation
|
||||
uses rxconst;
|
||||
|
||||
{ TRxNotifierForm }
|
||||
|
||||
procedure TRxNotifierForm.CreateCloseButton;
|
||||
begin
|
||||
begin
|
||||
FCloseButton:=TButton.Create(Self);
|
||||
FCloseButton.Parent:=Self;
|
||||
FCloseButton.Caption:=sClose;
|
||||
FCloseButton.AutoSize:=true;
|
||||
FCloseButton.BorderSpacing.Around:=6;
|
||||
FCloseButton.Left:=Width - FCloseButton.Width;
|
||||
FCloseButton.AnchorSideLeft.Control:=nil;
|
||||
FCloseButton.AnchorSideRight.Control:=Self;
|
||||
FCloseButton.AnchorSideRight.Side:=asrRight;
|
||||
FCloseButton.AnchorSideTop.Control:=Self;
|
||||
|
||||
FCloseButton.OnClick:=@ButtonCloseClick;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxNotifierForm.CreateCaption(ACaption: string);
|
||||
begin
|
||||
FCaptionLabel:=TLabel.Create(Self);
|
||||
FCaptionLabel.Parent:=Self;
|
||||
FCaptionLabel.BorderSpacing.Around:=6;
|
||||
FCaptionLabel.Align:=alTop;
|
||||
FCaptionLabel.Caption:=ACaption;
|
||||
FCaptionLabel.Font.Style:=FCaptionLabel.Font.Style + [fsBold];
|
||||
FCaptionLabel.OnClick:=@FOwnerItem.NotifierClick;
|
||||
end;
|
||||
|
||||
procedure TRxNotifierForm.CreateMessage(AMessage: string);
|
||||
begin
|
||||
FMessageLabel:=TLabel.Create(Self);
|
||||
FMessageLabel.Parent:=Self;
|
||||
FMessageLabel.WordWrap:=true;
|
||||
FMessageLabel.BorderSpacing.Around:=6;
|
||||
FMessageLabel.Align:=alClient;
|
||||
FMessageLabel.Caption:=AMessage;
|
||||
FMessageLabel.OnClick:=@FOwnerItem.NotifierClick;
|
||||
end;
|
||||
|
||||
procedure TRxNotifierForm.CreateTimerLabel;
|
||||
begin
|
||||
FTimerLabel:=TLabel.Create(Self);
|
||||
FTimerLabel.Parent:=Self;
|
||||
FTimerLabel.Top:=FCaptionLabel.Height+1;
|
||||
FTimerLabel.Align:=alTop;
|
||||
FTimerLabel.BorderSpacing.Around:=6;
|
||||
FTimerLabel.Font.Style:=FTimerLabel.Font.Style + [fsItalic];
|
||||
FTimerLabel.Caption:=' ';
|
||||
FTimerLabel.OnClick:=@FOwnerItem.NotifierClick;
|
||||
end;
|
||||
|
||||
procedure TRxNotifierForm.ButtonCloseClick(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
constructor TRxNotifierForm.CreateNotifierForm(AOwnerItem: TRxPopupNotifierItem
|
||||
);
|
||||
begin
|
||||
inherited CreateNew(Application);
|
||||
FOwnerItem:=AOwnerItem;
|
||||
end;
|
||||
|
||||
{ TNotifierCollection }
|
||||
|
||||
procedure TNotifierCollection.Update(Item: TCollectionItem);
|
||||
var
|
||||
FActive: Boolean;
|
||||
i: Integer;
|
||||
begin
|
||||
inherited Update(Item);
|
||||
|
||||
FActive:=false;
|
||||
for i:=0 to Count-1 do
|
||||
if TRxPopupNotifierItem(Items[i]).Active then
|
||||
begin
|
||||
FActive:=true;
|
||||
Break;
|
||||
end;
|
||||
|
||||
TRxPopupNotifier(Owner).FTimer.Enabled:=TRxPopupNotifier(Owner).FActive and FActive;
|
||||
end;
|
||||
|
||||
constructor TNotifierCollection.Create(AOwner: TPersistent);
|
||||
begin
|
||||
inherited Create(AOwner, TRxPopupNotifierItem);
|
||||
end;
|
||||
|
||||
{ TRxPopupNotifierItem }
|
||||
|
||||
procedure TRxPopupNotifierItem.OnNotifyFormClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
begin
|
||||
CloseAction:=caFree;
|
||||
FNotifyForm:=nil;
|
||||
FState:=rpsInactive;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.SetActive(AValue: boolean);
|
||||
begin
|
||||
if FActive=AValue then Exit;
|
||||
FActive:=AValue;
|
||||
|
||||
if not AValue then
|
||||
begin
|
||||
FState:=rpsInactive;
|
||||
if Assigned(FNotifyForm) then
|
||||
FNotifyForm.Close;
|
||||
end
|
||||
else
|
||||
begin
|
||||
CreateNotifierForm;
|
||||
FState:=rpsMaximazed;
|
||||
end;
|
||||
|
||||
Changed(false);
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.SetColor(AValue: TColor);
|
||||
begin
|
||||
if FColor=AValue then Exit;
|
||||
FColor:=AValue;
|
||||
if Assigned(FNotifyForm) then
|
||||
FNotifyForm.Color:=FColor;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.UpdateCloseLabel;
|
||||
var
|
||||
D, D1: TDateTime;
|
||||
N: Int64;
|
||||
begin
|
||||
if Assigned(FNotifyForm) and FShowCloseTimer then
|
||||
begin
|
||||
D:=Now;
|
||||
if FCloseTime < D then
|
||||
FState:=rpsMinimized
|
||||
else
|
||||
begin
|
||||
// D1:=;
|
||||
N:=Trunc((FCloseTime - D) * SecsPerDay);
|
||||
FNotifyForm.FTimerLabel.Caption:=Format( sCloseAfterSec, [N]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.CreateNotifierForm;
|
||||
begin
|
||||
if Assigned(FNotifyForm) then exit;
|
||||
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;
|
||||
FNotifyForm.BorderStyle:=bsNone;
|
||||
FNotifyForm.FormStyle:=fsStayOnTop;
|
||||
FNotifyForm.ShowInTaskBar:=stNever;
|
||||
FNotifyForm.Color:=FColor;
|
||||
|
||||
if FShowCloseButton then
|
||||
FNotifyForm.CreateCloseButton;
|
||||
|
||||
FNotifyForm.CreateCaption(FCaption);
|
||||
if FShowCloseTimer then
|
||||
FNotifyForm.CreateTimerLabel;
|
||||
FNotifyForm.CreateMessage(FMessage);
|
||||
|
||||
FNotifyForm.OnClose:=@OnNotifyFormClose;
|
||||
FNotifyForm.Show;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.UpdateFormSizes(var ATop: integer);
|
||||
begin
|
||||
if Assigned(FNotifyForm) then
|
||||
begin
|
||||
if (FState = rpsMaximazed) then
|
||||
begin
|
||||
if (TRxPopupNotifier(Collection.Owner).NotifierFormHeight > FNotifyForm.Height) then
|
||||
begin
|
||||
FNotifyForm.Height:=FNotifyForm.Height + 1;
|
||||
FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FState:=rpsShowing;
|
||||
FCloseTime:=Now + TRxPopupNotifier(Collection.Owner).FCloseInterval / SecsPerDay;
|
||||
end;
|
||||
end
|
||||
else
|
||||
if (FState = rpsMinimized) then
|
||||
begin
|
||||
if (FNotifyForm.Height > 1) then
|
||||
begin
|
||||
FNotifyForm.Height:=FNotifyForm.Height - 1;
|
||||
FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
end
|
||||
else
|
||||
FState:=rpsInactive;
|
||||
end;
|
||||
ATop:=ATop - FNotifyForm.Height;
|
||||
ATop:=ATop - 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.UpdateFormPosition(var ATop: integer);
|
||||
begin
|
||||
if Assigned(FNotifyForm) then
|
||||
begin
|
||||
FNotifyForm.Top:=ATop - FNotifyForm.Height;
|
||||
ATop:=ATop - FNotifyForm.Height - 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.NotifierClick(Sender: TObject);
|
||||
begin
|
||||
TRxPopupNotifier(Collection.Owner).DoNotifiClick(Self);
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifierItem.AssignTo(Dest: TPersistent);
|
||||
begin
|
||||
if Dest is TRxPopupNotifierItem then
|
||||
begin
|
||||
TRxPopupNotifierItem(Dest).FColor:=FColor;
|
||||
TRxPopupNotifierItem(Dest).FAutoClose:=FAutoClose;
|
||||
TRxPopupNotifierItem(Dest).FShowCloseTimer:=FShowCloseTimer;
|
||||
TRxPopupNotifierItem(Dest).FCaption:=FCaption;
|
||||
TRxPopupNotifierItem(Dest).FMessage:=FMessage;
|
||||
TRxPopupNotifierItem(Dest).FShowCloseButton:=FShowCloseButton;
|
||||
end
|
||||
else
|
||||
inherited AssignTo(Dest);
|
||||
end;
|
||||
|
||||
constructor TRxPopupNotifierItem.Create(ACollection: TCollection);
|
||||
begin
|
||||
inherited Create(ACollection);
|
||||
FColor:=TRxPopupNotifier(ACollection.Owner).FDefaultColor;
|
||||
FShowCloseButton:=true;
|
||||
FShowCloseTimer:=true;
|
||||
end;
|
||||
|
||||
{ TRxPopupNotifier }
|
||||
|
||||
procedure TRxPopupNotifier.UpdateNotifyFormsPositoon;
|
||||
var
|
||||
F: TRxPopupNotifierItem;
|
||||
Y, i: Integer;
|
||||
FReposition: Boolean;
|
||||
begin
|
||||
Y:=Screen.Height - 2;
|
||||
FReposition:=false;
|
||||
for i:=FItems.Count - 1 downto 0 do
|
||||
begin
|
||||
F:=FItems.Items[i] as TRxPopupNotifierItem;
|
||||
if F.Active then
|
||||
begin
|
||||
if F.FState in [rpsMaximazed, rpsMinimized] then
|
||||
begin
|
||||
F.UpdateFormSizes(Y);
|
||||
FReposition:=true;
|
||||
end
|
||||
else
|
||||
if F.FState = rpsInactive then
|
||||
FReposition:=true
|
||||
else
|
||||
if FReposition then
|
||||
F.UpdateFormPosition(Y)
|
||||
else
|
||||
Y:=Y - F.FNotifyForm.Height - 2;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifier.UpdateTimeState;
|
||||
var
|
||||
i: Integer;
|
||||
F: TRxPopupNotifierItem;
|
||||
begin
|
||||
for i:=FItems.Count - 1 downto 0 do
|
||||
begin
|
||||
F:=FItems.Items[i] as TRxPopupNotifierItem;
|
||||
if F.Active and (F.State = rpsShowing) and F.ShowCloseTimer then
|
||||
F.UpdateCloseLabel;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifier.UpdateClosed;
|
||||
var
|
||||
F: TRxPopupNotifierItem;
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=FItems.Count - 1 downto 0 do
|
||||
begin
|
||||
F:=FItems.Items[i] as TRxPopupNotifierItem;
|
||||
if F.FState = rpsInactive then
|
||||
F.Active:=false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifier.SetItems(AValue: TNotifierCollection);
|
||||
begin
|
||||
FItems.Assign(AValue);
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifier.SetActive(AValue: boolean);
|
||||
begin
|
||||
if FActive=AValue then Exit;
|
||||
FActive:=AValue;
|
||||
FTimer.Enabled:=false;
|
||||
if not FActive then
|
||||
Clear;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifier.NotifyTimerEvent(Sender: TObject);
|
||||
begin
|
||||
UpdateNotifyFormsPositoon;
|
||||
UpdateClosed;
|
||||
UpdateTimeState;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifier.DoNotifiClick(AItem: TRxPopupNotifierItem);
|
||||
begin
|
||||
if Assigned(FOnNotifiClick) then
|
||||
FOnNotifiClick(Self, AItem)
|
||||
end;
|
||||
|
||||
constructor TRxPopupNotifier.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FDefaultColor:=clYellow;
|
||||
FCloseInterval:=5;
|
||||
FActive:=true;
|
||||
FItems:=TNotifierCollection.Create(Self);
|
||||
FTimer:=TTimer.Create(Self);
|
||||
FTimer.Enabled:=False;
|
||||
FTimer.Interval:=10;
|
||||
FTimer.OnTimer:=@NotifyTimerEvent;
|
||||
end;
|
||||
|
||||
destructor TRxPopupNotifier.Destroy;
|
||||
begin
|
||||
FTimer.Enabled:=false;
|
||||
FreeAndNil(FItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TRxPopupNotifier.AddNotifyItem(ACaption, AMessage: string
|
||||
): TRxPopupNotifierItem;
|
||||
begin
|
||||
Result:=FItems.Add as TRxPopupNotifierItem;
|
||||
Result.Caption:=ACaption;
|
||||
Result.Message:=AMessage;
|
||||
Result.FState:=rpsMaximazed;
|
||||
Result.FColor:=FDefaultColor;
|
||||
Result.Active:=true;
|
||||
end;
|
||||
|
||||
procedure TRxPopupNotifier.Clear;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
function TRxPopupNotifier.NotifierFormWidth: Cardinal;
|
||||
begin
|
||||
if FDefNotifierFormWidth > 0 then
|
||||
Result:=FDefNotifierFormWidth
|
||||
else
|
||||
Result:=Screen.Width div 4;
|
||||
end;
|
||||
|
||||
function TRxPopupNotifier.NotifierFormHeight: Cardinal;
|
||||
begin
|
||||
if FDefNotifierFormHeight > 0 then
|
||||
Result:=FDefNotifierFormHeight
|
||||
else
|
||||
Result:=Screen.Height div 8;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -26,7 +26,7 @@ Copyright (c) 1998 Master-Bank
|
||||
translate to Lazarus by alexs in 2005 - 2018"/>
|
||||
<License Value="LGPL"/>
|
||||
<Version Major="3" Minor="2" Release="1" Build="210"/>
|
||||
<Files Count="73">
|
||||
<Files Count="74">
|
||||
<Item1>
|
||||
<Filename Value="registerrx.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
@ -322,6 +322,10 @@ translate to Lazarus by alexs in 2005 - 2018"/>
|
||||
<Filename Value="rxcontrols\rxswitch.res"/>
|
||||
<Type Value="Binary"/>
|
||||
</Item73>
|
||||
<Item74>
|
||||
<Filename Value="rxcontrols\rxpopupnotifier.pas"/>
|
||||
<UnitName Value="rxPopupNotifier"/>
|
||||
</Item74>
|
||||
</Files>
|
||||
<LazDoc Paths="docs;\usr\local\share\lazarus\components\rxnew\docs"/>
|
||||
<i18n>
|
||||
|
@ -21,7 +21,7 @@ uses
|
||||
RxIniPropStorage, rxlclconst, rxlogin, RxMDI, rxpagemngr, rxpickdate,
|
||||
rxShortCutUnit, rxspin, rxswitch, RxSystemServices, rxtbrsetup, RxTimeEdit,
|
||||
rxtoolbar, rxtooledit, RxDBGrid_PopUpFilterUnit, rxdbverticalgrid,
|
||||
rxlclutils, RxRangeSel, RxXMLPropStorage, LazarusPackageIntf;
|
||||
rxlclutils, RxRangeSel, RxXMLPropStorage, rxPopupNotifier, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -129,6 +129,9 @@ resourcestring
|
||||
sVariableIsNotDT = 'Variable %s is not date/time';
|
||||
sVariableIsNotBoolean = 'Variable %s is not boolean';
|
||||
|
||||
{ TRxNotifierForm }
|
||||
sClose = 'Close';
|
||||
sCloseAfterSec = 'Close after %d sec';
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user