summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-04-25 11:52:24 +0200
committerGraeme Geldenhuys <graemeg@gmail.com>2010-04-25 11:52:24 +0200
commit1ddeacd4ec0c394d669ed9d712067b0c6215aaec (patch)
tree89529e936f00efc5a7812979998e842893631b45 /src
parent262edff4cb729ace9f421a9ff6529e52130e0df6 (diff)
downloadfpGUI-1ddeacd4ec0c394d669ed9d712067b0c6215aaec.tar.xz
Introduced new event for TfpgWidget called OnShowHint.
This event will get fired just before a hint is displayed. You can use this this event to adjust the Hint text to make it more dynamic.
Diffstat (limited to 'src')
-rw-r--r--src/corelib/fpg_widget.pas49
1 files changed, 42 insertions, 7 deletions
diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas
index 4a146ada..0aba7204 100644
--- a/src/corelib/fpg_widget.pas
+++ b/src/corelib/fpg_widget.pas
@@ -32,6 +32,8 @@ uses
type
TFocusSearchDirection = (fsdFirst, fsdLast, fsdNext, fsdPrev);
+ THintEvent = procedure(Sender: TObject; var AHint: TfpgString) of object;
+
TfpgWidget = class(TfpgWindow)
private
@@ -49,6 +51,7 @@ type
FOnKeyPress: TKeyPressEvent;
FOnResize: TNotifyEvent;
FOnScreen: boolean;
+ FOnShowHint: THintEvent;
procedure SetActiveWidget(const AValue: TfpgWidget);
function IsShowHintStored: boolean;
procedure SetFormDesigner(const AValue: TObject);
@@ -76,12 +79,14 @@ type
FAnchors: TAnchors;
FActiveWidget: TfpgWidget;
FAlign: TAlign;
- FHint: string;
+ FHint: TfpgString;
FShowHint: boolean;
FParentShowHint: boolean;
FBackgroundColor: TfpgColor;
FTextColor: TfpgColor;
FIsContainer: Boolean;
+ function GetOnShowHint: THintEvent; virtual;
+ procedure SetOnShowHint(const AValue: THintEvent); virtual;
procedure SetBackgroundColor(const AValue: TfpgColor); virtual;
procedure SetTextColor(const AValue: TfpgColor); virtual;
function GetParent: TfpgWidget; reintroduce;
@@ -90,10 +95,12 @@ type
procedure SetVisible(const AValue: boolean); virtual;
procedure SetShowHint(const AValue: boolean); virtual;
procedure SetParentShowHint(const AValue: boolean); virtual;
- procedure SetHint(const AValue: string); virtual;
+ function GetHint: TfpgString; virtual;
+ procedure SetHint(const AValue: TfpgString); virtual;
procedure DoUpdateWindowPosition; override;
procedure DoAlign(AAlign: TAlign);
procedure DoResize;
+ procedure DoShowHint(var AHint: TfpgString);
procedure HandlePaint; virtual;
procedure HandleKeyChar(var AText: TfpgChar; var shiftstate: TShiftState; var consumed: boolean); virtual;
procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); virtual;
@@ -129,6 +136,7 @@ type
property OnMouseUp: TMouseButtonEvent read FOnMouseUp write FOnMouseUp;
property OnPaint: TPaintEvent read FOnPaint write FOnPaint;
property OnResize: TNotifyEvent read FOnResize write FOnResize;
+ property OnShowHint: THintEvent read GetOnShowHint write SetOnShowHint;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@@ -155,7 +163,7 @@ type
property Focused: boolean read FFocused write FFocused default False;
property Anchors: TAnchors read FAnchors write FAnchors;
property Align: TAlign read FAlign write FAlign;
- property Hint: string read FHint write SetHint;
+ property Hint: TfpgString read GetHint write SetHint;
property ShowHint: boolean read FShowHint write SetShowHint stored IsShowHintStored;
property ParentShowHint: boolean read FParentShowHint write SetParentShowHint default True;
property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor default clWindowBackground;
@@ -208,7 +216,7 @@ begin
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TfpgWidget then
- TfpgWidget(Components[i]).Enabled := self.Enabled;
+ TfpgWidget(Components[i]).Enabled := FEnabled;
end;
RePaint;
end;
@@ -227,6 +235,11 @@ begin
FActiveWidget.HandleSetFocus;
end;
+function TfpgWidget.GetHint: TfpgString;
+begin
+ Result := FHint;
+end;
+
function TfpgWidget.IsShowHintStored: boolean;
begin
Result := not ParentShowHint;
@@ -279,7 +292,7 @@ begin
FShowHint := False;
end;
-procedure TfpgWidget.SetHint(const AValue: string);
+procedure TfpgWidget.SetHint(const AValue: TfpgString);
begin
FHint := AValue;
end;
@@ -698,6 +711,16 @@ begin
msg.Params.mouse.shiftstate, msg.Params.mouse.delta);
end;
+function TfpgWidget.GetOnShowHint: THintEvent;
+begin
+ Result := FOnShowHint;
+end;
+
+procedure TfpgWidget.SetOnShowHint(const AValue: THintEvent);
+begin
+ FOnShowHint := AValue;
+end;
+
procedure TfpgWidget.HandleShow;
var
n: integer;
@@ -1007,6 +1030,7 @@ begin
if Components[n] is TfpgWidget then
begin
w := TfpgWidget(Components[n]);
+ begin
if w.Visible and w.Enabled and w.Focusable then
case direction of
@@ -1028,6 +1052,7 @@ begin
if startwg = w then
FoundIt := True
else if w.TabOrder < lasttaborder then
+ begin
if (startwg = nil) or
(w.TabOrder > startwg.TabOrder) or
(FoundIt and (w.TabOrder = startwg.TabOrder)) then
@@ -1035,7 +1060,7 @@ begin
Result := w;
lasttaborder := w.TabOrder;
end;
-
+ end;
fsdPrev:
if startwg = w then
FoundIt := True
@@ -1048,7 +1073,8 @@ begin
lasttaborder := w.TabOrder;
end;
- end;
+ end; { case }
+ end; { if w.Enabled... }
end;
end;
@@ -1253,6 +1279,15 @@ begin
FOnResize(Self);
end;
+procedure TfpgWidget.DoShowHint(var AHint: TfpgString);
+begin
+ AHint := Hint;
+ if Assigned(FOnShowHint) then
+ begin
+ FOnShowHint(self, AHint);
+ end;
+end;
+
procedure TfpgWidget.SetPosition(aleft, atop, awidth, aheight: TfpgCoord);
begin
MoveAndResize(aleft, atop, awidth, aheight);