diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-08-31 17:24:54 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-08-31 17:24:54 +0000 |
commit | 1405e1ecfd53e424c3e96edccdf2e5b0b707257b (patch) | |
tree | e2acb5e89e78a1f229f35d74966577ba0fcb7887 /src/corelib | |
parent | 052d28c91a70678b264fb7772096da6fb6803dc3 (diff) | |
download | fpGUI-1405e1ecfd53e424c3e96edccdf2e5b0b707257b.tar.xz |
* Renamed the hint window to TfpgHintWindow
* Moved F_Hint variable to fpgApplication.HintWindow property. TfpgApplication
now manages the life of HintWindow.
* Moved DisplayHint (now called ActivateHint) and HideHint into TfpgApplication.
* Introduced a new TfpgApplication.HintPause property that will managed the
default delay before a help hint is displayed. Default is 1.5 seconds.
* gui_edit unit has been updated to handle the new changes.
* hintwindow example project has been updated to handle the new changes.
* TfpgHintWindow class now manages the Shadow Window (lifetime, size and
position).
* The Hint Shadow class is now moved to the Implementation section so it's not
accessible to the world, but only via the standard Hint Window class.
* Introduced a HintWindowClass which is a global variable. It defaults to
TfpgHintWindow, but allows the user to change it so a custom hint window
can be used instead.
* TfpgLabel.Text is now of type TfpgString
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/fpgfx.pas | 73 | ||||
-rw-r--r-- | src/corelib/gfx_widget.pas | 2 |
2 files changed, 65 insertions, 10 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas index 7b777a4a..67f10d2d 100644 --- a/src/corelib/fpgfx.pas +++ b/src/corelib/fpgfx.pas @@ -148,8 +148,6 @@ type end; - { TfpgCanvas } - TfpgCanvas = class(TfpgCanvasImpl) private function AddLineBreaks(const s: TfpgString; aMaxLineWidth: integer): string; @@ -198,14 +196,16 @@ type end; - { TfpgApplication } - TfpgApplication = class(TfpgApplicationImpl) private + FHintPause: Integer; FOnException: TExceptionEvent; FStopOnException: Boolean; + FHintWindow: TfpgWindow; + procedure SetHintPause(const AValue: Integer); procedure SetupLocalizationStrings; procedure InternalMsgClose(var msg: TfpgMessageRec); message FPGM_CLOSE; + procedure CreateHintWindow; protected FDisplayParams: string; FScreenWidth: integer; @@ -221,15 +221,19 @@ type constructor Create(const AParams: string = ''); override; destructor Destroy; override; function GetFont(const afontdesc: string): TfpgFont; - procedure Initialize; - procedure Run; + procedure ActivateHint(APos: TPoint; AHint: TfpgString); procedure Flush; + procedure HandleException(Sender: TObject); + procedure HideHint; + procedure Initialize; procedure ProcessMessages; + procedure Run; procedure SetMessageHook(AWidget: TObject; const AMsgCode: integer; AListener: TObject); - procedure UnsetMessageHook(AWidget: TObject; const AMsgCode: integer; AListener: TObject); - procedure HandleException(Sender: TObject); procedure ShowException(E: Exception); + procedure UnsetMessageHook(AWidget: TObject; const AMsgCode: integer; AListener: TObject); property DefaultFont: TfpgFont read FDefaultFont; + property HintPause: Integer read FHintPause write SetHintPause; + property HintWindow: TfpgWindow read FHintWindow; property ScreenWidth: integer read FScreenWidth; property ScreenHeight: integer read FScreenHeight; property StopOnException: Boolean read FStopOnException write FStopOnException; @@ -355,7 +359,8 @@ uses gfx_translations, gfx_constants, gfx_UTF8utils, - gui_dialogs; + gui_dialogs, + gui_hint; var fpgTimers: TList; @@ -781,6 +786,8 @@ begin FScreenHeight := -1; FMessageHookList := TFPList.Create; FStopOnException := False; + FHintWindow := nil; + FHintPause := 1500; // 1.5 seconds try inherited Create(AParams); @@ -803,6 +810,12 @@ var i: integer; frm: TfpgWindowBase; begin + if Assigned(FHintWindow) then + begin + HideHint; + FHintWindow.Free; + end; + DestroyComponents; // while message queue is still active for i := 0 to (fpgNamedFonts.Count - 1) do @@ -881,6 +894,23 @@ begin end; end; +procedure TfpgApplication.ActivateHint(APos: TPoint; AHint: TfpgString); +var + wnd: TfpgHintWindow; + w: Integer; + h: Integer; +begin + wnd := TfpgHintWindow(FHintWindow); + if Assigned(wnd) and wnd.Visible then + Exit; //==> Nothing to do + + wnd.Text := AHint; + w := wnd.Font.TextWidth(AHint) + (wnd.Border * 2) + (wnd.Margin * 2); + h := wnd.Font.Height + (wnd.Border * 2) + (wnd.Margin * 2); + wnd.SetPosition(APos.X, APos.Y, w, h); + wnd.Show; +end; + procedure TfpgApplication.Initialize; begin { TODO : Remember to process parameters!! } @@ -949,6 +979,11 @@ begin end; +procedure TfpgApplication.SetHintPause(const AValue: Integer); +begin + FHintPause := AValue; +end; + procedure TfpgApplication.InternalMsgClose(var msg: TfpgMessageRec); begin // writeln('InternalMsgClose received'); @@ -961,6 +996,16 @@ begin end; end; +procedure TfpgApplication.CreateHintWindow; +begin + if not Assigned(FHintWindow) then + begin + FHintWindow := HintWindowClass.Create(nil); + writeln('HintWindow.Classname=', FHintWindow.ClassName); + TfpgHintWindow(FHintWindow).Visible := False; + end; +end; + procedure TfpgApplication.FreeFontRes(afontres: TfpgFontResource); var n: integer; @@ -986,6 +1031,7 @@ begin // This will process Application and fpGUI Toolkit translation (*.po) files TranslateResourceStrings(ApplicationName, ExtractFilePath(ParamStr(0)), ''); SetupLocalizationStrings; + CreateHintWindow; end; procedure TfpgApplication.Flush; @@ -1056,6 +1102,15 @@ begin Terminated := True; end; +procedure TfpgApplication.HideHint; +begin + {$IFDEF DEBUG} + writeln('HideHint'); + {$ENDIF} + if Assigned(FHintWindow) and TfpgHintWindow(FHintWindow).Visible then + TfpgHintWindow(FHintWindow).Hide; +end; + procedure TfpgApplication.ShowException(E: Exception); begin TfpgMessageDialog.Critical('An unexpected error occurred.', E.Message); diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas index dd2df625..a31815de 100644 --- a/src/corelib/gfx_widget.pas +++ b/src/corelib/gfx_widget.pas @@ -841,7 +841,7 @@ begin writeln('TfpgWidget.HandleMouseExit: ' + ClassName); {$ENDIF} if FShowHint then - HideHint; + fpgApplication.HideHint; end; procedure TfpgWidget.HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); |