summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-09-02 09:04:44 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-09-02 09:04:44 +0000
commit4b60f4597bd1631ec4b4a8c12e04d9d667efd156 (patch)
tree6aea411f69c320327f619e6e9fe60b5499cc7f03 /src/corelib
parent9699b4bca081596e69ad514f1e2a64d65b50baf9 (diff)
downloadfpGUI-4b60f4597bd1631ec4b4a8c12e04d9d667efd156.tar.xz
* Applied Jean-Marc's hint patch which moves hint functionality to TfpgWidget. Soon this will move to TfpgApplication.
* Made a few of my own fixes to Jean-Marc's patch. * Removed a few compiler warnings.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpgfx.pas9
-rw-r--r--src/corelib/gfx_widget.pas60
2 files changed, 62 insertions, 7 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas
index 934ffe4b..0aa582f3 100644
--- a/src/corelib/fpgfx.pas
+++ b/src/corelib/fpgfx.pas
@@ -199,6 +199,7 @@ type
TfpgApplication = class(TfpgApplicationImpl)
private
FHintPause: Integer;
+ FShowHint: boolean;
FOnException: TExceptionEvent;
FStopOnException: Boolean;
FHintWindow: TfpgWindow;
@@ -236,6 +237,7 @@ type
property HintWindow: TfpgWindow read FHintWindow;
property ScreenWidth: integer read FScreenWidth;
property ScreenHeight: integer read FScreenHeight;
+ property ShowHint: boolean read FShowHint write FShowHint default True;
property StopOnException: Boolean read FStopOnException write FStopOnException;
property OnException: TExceptionEvent read FOnException write FOnException;
end;
@@ -597,6 +599,7 @@ var
i: integer;
s: string;
begin
+ s := '';
for i := 0 to iCallTrace+1 do
s := s + ' ';
writeln(s + AMessage);
@@ -788,6 +791,7 @@ begin
FStopOnException := False;
FHintWindow := nil;
FHintPause := 1500; // 1.5 seconds
+ FShowHint := True;
try
inherited Create(AParams);
@@ -808,7 +812,6 @@ end;
destructor TfpgApplication.Destroy;
var
i: integer;
- frm: TfpgWindowBase;
begin
if Assigned(FHintWindow) then
begin
@@ -1458,11 +1461,9 @@ end;
procedure TfpgStyle.DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TFButtonFlags);
var
r: TfpgRect;
- lDoDraw: Boolean;
begin
r.SetRect(x, y, w, h);
- lDoDraw := False;
-
+
if btfIsDefault in AFlags then
begin
ACanvas.SetColor(clBlack);
diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas
index a31815de..898d171c 100644
--- a/src/corelib/gfx_widget.pas
+++ b/src/corelib/gfx_widget.pas
@@ -61,15 +61,20 @@ type
FAlign: TAlign;
FHint: string;
FShowHint: boolean;
+ FParentShowHint: boolean;
+ FHintTimer: TfpgTimer;
FBackgroundColor: TfpgColor;
FTextColor: TfpgColor;
FIsContainer: Boolean;
+ FMousePoint: TPoint;
procedure SetBackgroundColor(const AValue: TfpgColor); virtual;
procedure SetTextColor(const AValue: TfpgColor); virtual;
function GetParent: TfpgWidget; reintroduce;
procedure SetParent(const AValue: TfpgWidget); reintroduce;
procedure SetEnabled(const AValue: boolean); virtual;
procedure SetVisible(const AValue: boolean); virtual;
+ procedure SetShowHint(const AValue: boolean); virtual;
+ procedure SetParentShowHint(const AValue: boolean); virtual;
procedure DoUpdateWindowPosition; override;
procedure DoAlign(AAlign: TAlign);
procedure DoResize;
@@ -95,6 +100,7 @@ type
procedure HandleHide; virtual;
procedure MoveAndResize(ALeft, ATop, AWidth, AHeight: TfpgCoord);
procedure RePaint;
+ procedure HintTimerFired(Sender: TObject);
{ property events }
property OnClick: TNotifyEvent read FOnClick write FOnClick;
property OnDoubleClick: TMouseButtonEvent read FOnDoubleClick write FOnDoubleClick;
@@ -132,7 +138,8 @@ type
property Anchors: TAnchors read FAnchors write FAnchors;
property Align: TAlign read FAlign write FAlign;
property Hint: string read FHint write FHint;
- property ShowHint: boolean read FShowHint write FShowHint default False;
+ property ShowHint: boolean read FShowHint write SetShowHint default False;
+ property ParentShowHint: boolean read FParentShowHint write SetParentShowHint default True;
property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor default clWindowBackground;
property TextColor: TfpgColor read FTextColor write SetTextColor default clText1;
end;
@@ -208,6 +215,20 @@ begin
end;
end;
+procedure TfpgWidget.SetShowHint(const AValue: boolean);
+begin
+ if FShowHint <> AValue then
+ FShowHint := AValue;
+ if FShowHint then
+ FParentShowHint := False;
+end;
+
+procedure TfpgWidget.SetParentShowHint(const AValue: boolean);
+begin
+ if FParentShowHint <> AValue then
+ FParentShowHint := AValue;
+end;
+
procedure TfpgWidget.DoUpdateWindowPosition;
var
dw: integer;
@@ -298,9 +319,14 @@ begin
FAnchors := [anLeft, anTop];
FAlign := alNone;
FHint := '';
+ FShowHint := False;
+ FParentShowHint := True;
FBackgroundColor := clWindowBackground;
FTextColor := clText1;
+ FHintTimer := TfpgTimer.Create(fpgApplication.HintPause);
+ FHintTimer.OnTimer := @HintTimerFired;
+
if (AOwner <> nil) and (AOwner is TfpgWidget) then
begin
Parent := TfpgWidget(AOwner);
@@ -310,7 +336,10 @@ begin
Parent := nil;
if Parent <> nil then
+ begin
FWindowType := wtChild;
+ FShowHint := Parent.ShowHint;
+ end;
inherited Create(AOwner);
@@ -637,6 +666,12 @@ begin
fpgSendMessage(self, self, FPGM_PAINT);
end;
+procedure TfpgWidget.HintTimerFired(Sender: TObject);
+begin
+ fpgApplication.ActivateHint(WindowToScreen(Self, FMousePoint), FHint);
+ FHintTimer.Enabled := False;
+end;
+
procedure TfpgWidget.SetFocus;
begin
HandleSetFocus;
@@ -819,7 +854,21 @@ end;
procedure TfpgWidget.HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState);
begin
- // do nothing yet
+ FMousePoint := Point(x+2, y+2);
+ if Assigned(Parent) then
+ begin
+ if fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.ShowHint)) and (FHint <> '') then
+ if FHintTimer.Enabled then
+ FHintTimer.Reset // keep reseting to prevent hint from showing
+ else
+ fpgApplication.HideHint;
+ end
+ else
+ if fpgApplication.ShowHint and FShowHint and (FHint <> '') then
+ if FHintTimer.Enabled then
+ FHintTimer.Reset // keep reseting to prevent hint from showing
+ else
+ fpgApplication.HideHint;
end;
procedure TfpgWidget.HandleDoubleClick(x, y: integer; button: word; shiftstate: TShiftState);
@@ -832,7 +881,11 @@ begin
{$IFDEF DEBUG}
writeln('TfpgWidget.HandleMouseEnter: ' + ClassName);
{$ENDIF}
- // do nothing yet
+ if Assigned(Parent) then
+ FHintTimer.Enabled := Enabled and fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.ShowHint)) and (FHint <> '')
+ else
+ FHintTimer.Enabled := Enabled and fpgApplication.ShowHint and FShowHint and (FHint <> '');
+writeln('TfpgWidget.HandleMouseEnter: HintTimer.Enabled=', FHintTimer.Enabled);
end;
procedure TfpgWidget.HandleMouseExit;
@@ -840,6 +893,7 @@ begin
{$IFDEF DEBUG}
writeln('TfpgWidget.HandleMouseExit: ' + ClassName);
{$ENDIF}
+ FHintTimer.Enabled := False;
if FShowHint then
fpgApplication.HideHint;
end;