Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Fmx.HintManager;
- interface
- (************************************************** )
- ( )
- ( Copyright (c) 1997-2012 FNS Enterprize's™ )
- ( 2003-2012 himitsu @ Delphi-PRAXiS )
- ( )
- ( Description - )
- ( Filename Fmx.HintManager.pas )
- ( Version v1.3 )
- ( Date 24.10.2012 )
- ( InitialDate 04.08.2012 )
- ( System Fmx )
- ( Personality Delphi XE2, XE3 )
- ( Project FmxHintManager )
- ( Support www.delphipraxis.net/169747-b.html )
- ( )
- ( License MPL v1.1 , GPL v3.0 or LGPL v3.0 )
- ( )
- ( Donation http://geheimniswelten.de/spenden )
- ( )
- (***************************************************)
- {$REGION 'license'}
- //
- // Mozilla Public License (MPL) v1.1
- // GNU General Public License (GPL) v3.0
- // GNU Lesser General Public License (LGPL) v3.0
- //
- //
- //
- // The contents of this file are subject to the Mozilla Public License
- // Version 1.1 (the "License"); you may not use this file except in
- // compliance with the License.
- // You may obtain a copy of the License at http://www.mozilla.org/MPL .
- //
- // Software distributed under the License is distributed on an "AS IS"
- // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- // License for the specific language governing rights and limitations
- // under the License.
- //
- // The Original Code is "FmxHintManager".
- //
- // The Initial Developer of the Original Code is "himitsu".
- // Portions created by Initial Developer are Copyright (C) 2009.
- // All Rights Reserved.
- //
- // Contributor(s): -
- //
- // Alternatively, the contents of this file may be used under the terms
- // of the GNU General Public License Version 3.0 or later (the "GPL"), or the
- // GNU Lesser General Public License Version 3.0 or later (the "LGPL"),
- // in which case the provisions of GPL or the LGPL are applicable instead of
- // those above. If you wish to allow use of your version of this file only
- // under the terms of the GPL or the LGPL and not to allow others to use
- // your version of this file under the MPL, indicate your decision by
- // deleting the provisions above and replace them with the notice and
- // other provisions required by the GPL or the LGPL. If you do not delete
- // the provisions above, a recipient may use your version of this file
- // under either the MPL, the GPL or the LGPL.
- //
- //
- //
- // HTML: PlainText:
- // www.mozilla.org/MPL/MPL-1.1.html www.mozilla.org/MPL/MPL-1.1.txt
- // www.gnu.org/licenses/gpl-3.0.html www.gnu.org/licenses/gpl-3.0.txt
- // www.gnu.org/licenses/lgpl-3.0.html www.gnu.org/licenses/lgpl-3.0.txt
- //
- {$ENDREGION}
- uses
- System.Types, System.SysUtils, System.Classes, System.UITypes, System.Math,
- FMX.Types, FMX.Forms, FMX.Dialogs, FMX.Objects, FMX.Controls, FMX.Effects,
- FMX.Edit, FMX.StdCtrls, FMX.Graphics;
- type
- THintItem = class;
- THintPos = (hpBottom, hpRight, hpTop, hpLeft, hpDefault);
- THintImage = (hiNone, hiImage1, hiImage2, hiImage3, hiDefault);
- THintEvent = function(Sender: TObject; Form: TCustomForm; Position: TRectF; Text: string; Image: THintImage; AssignedComp: TControl = nil): Boolean of object;
- THintManager = class(TFmxObject)
- strict private type
- THintData = record
- Mode: (hmNone, hmPoint, hmRect, hmComp);
- Point: TPointF;
- Rect: TRectF;
- Comp: TControl;
- Hint: string;
- Image: THintImage;
- end;
- THintShow = (hsImmediately, hsShort, hsNormal, hsRefresh);
- strict private
- FNil: TControl;
- FHintForm: TCalloutRectangle;
- FHintImage1: TImage;
- FHintImage2: TImage;
- FHintImage3: TImage;
- FHintLabel: TLabel;
- FHintGlow: TGlowEffect;
- FHintShadow: TShadowEffect;
- FHintShowTimer: TTimer;
- FHintHideTimer: TTimer;
- FHintPause: Integer;
- FHintHidePause: Integer;
- FHintShortPause: Integer;
- //FHintShortCuts: Boolean;
- FHintPos: THintPos;
- FHintImage: THintImage;
- FOnShowHint: THintEvent;
- FOnHideHint: TNotifyEvent;
- FFire: Boolean;
- FFireTimer: TTimer;
- FMaxWidth: Single;
- FNextHint: THintData;
- FCurrentHint: THintData;
- {$IF RTLVersion >= 24}
- FMeasureBitmap: TBitmap;
- {$IFEND}
- procedure AddNewHint (Value: TControl);
- function GetAlignLayout: TAlignLayout;
- procedure SetAlignLayout (Value: TAlignLayout);
- function GetBrBitmap: TBrushBitmap;
- procedure AssignBrBitmap (Value: TBrushBitmap);
- procedure SetHintPos (Value: THintPos);
- function GetFontName: TFontName;
- procedure SetFontName (Value: TFontName);
- function GetFontStyle: TFontStyles;
- procedure SetFontStyle (Value: TFontStyles);
- procedure SetHintImage (Value: THintImage);
- function GetBitmap (I: Integer): TBitmap;
- procedure AssignBitmap (I: Integer; Value: TBitmap);
- function GetBoolean (I: Integer): Boolean;
- procedure SetBoolean (I: Integer; Value: Boolean);
- function GetColor (I: Integer): TAlphaColor;
- procedure SetColor (I: Integer; Value: TAlphaColor);
- function GetGradient (I: Integer): TGradient;
- procedure AssignGradient(I: Integer; Value: TGradient);
- function GetKind (I: Integer): TBrushKind;
- procedure SetKind (I: Integer; Value: TBrushKind);
- function GetSingle (I: Integer): Single;
- procedure SetSingle (I: Integer; Value: Single);
- function GetString (I: Integer): String;
- procedure SetString (I: Integer; Value: String);
- function GetWrapMode (I: Integer): TImageWrapMode;
- procedure SetWrapMode (I: Integer; Value: TImageWrapMode);
- procedure DoShowTimer (Sender: TObject);
- procedure DoHideTimer (Sender: TObject);
- procedure DoFireTimer (Sender: TObject);
- protected
- class procedure ChangeRefVar(var Ref; NewValue, Comp: TComponent);
- class var BeforeNewHint: procedure(Comp: TControl; var Form: TComponent);
- class var AfterNewHint: procedure(Hint: THintItem);
- function LoadText (Comp: TComponent; AutoTranslate: Boolean): string;
- procedure CreateHint;
- procedure InnerShowHint(Mode: THintShow);
- procedure InnerHideHint(CurrentHint, NextHint: Boolean);
- procedure Notification (Component: TComponent; Operation: TOperation); override;
- procedure HintShow (Item: THintItem; Immediately: Boolean = False);
- procedure HintRefresh (Item: THintItem);
- procedure HintHide (Item: THintItem; Immediately: Boolean = False);
- procedure Repaint;
- public
- constructor Create(Owner: TComponent); override;
- destructor Destroy; override;
- procedure ShowHint(const AbsolutePos: TPointF; Hint: string; Image: THintImage = hiDefault; Translate: Boolean = False); overload;
- procedure ShowHint(const AbsolutePos: TRectF; Hint: string; Image: THintImage = hiDefault; Translate: Boolean = False); overload;
- procedure ShowHint( Component: TControl; Hint: string = ''; Image: THintImage = hiDefault; Translate: Boolean = False); overload;
- procedure HideHint;
- function IsHintVisible: Boolean;
- published
- property AddHintToComponent: TControl read FNil write AddNewHint stored False;
- property HintPause: Integer read FHintPause write FHintPause default 500;
- property HintHidePause: Integer read FHintHidePause write FHintHidePause default 2500;
- property HintShortPause: Integer read FHintShortPause write FHintShortPause default 50;
- //property HintShortCuts: Boolean read FHintShortCuts write FHintShortCuts default False;
- //property HintColor: TAlphaColor read GetHintColor write SetHintColor stored False;
- property CalloutPosition: THintPos read FHintPos write SetHintPos default hpTop;
- property CalloutLength: Single index 10 read GetSingle write SetSingle ;//default 10;
- property CalloutOffset: Single index 11 read GetSingle write SetSingle ;//default 15;
- property CalloutWidth: Single index 12 read GetSingle write SetSingle ;//default 20;
- property FillKind: TBrushKind index 20 read GetKind write SetKind default TBrushKind.bkSolid;
- property FillColor: TAlphaColor index 21 read GetColor write SetColor default TAlphaColorRec.Beige;
- property FillGradient: TGradient index 22 read GetGradient write AssignGradient;
- property FillBitmap: TBrushBitmap read GetBrBitmap write AssignBrBitmap;
- property StrokeKind: TBrushKind index 30 read GetKind write SetKind default TBrushKind.bkSolid;
- property StrokeColor: TAlphaColor index 31 read GetColor write SetColor default TAlphaColorRec.Black;
- property StrokeGradient: TGradient index 32 read GetGradient write AssignGradient;
- property StrokeThickness: Single index 33 read GetSingle write SetSingle ;//default ;
- property Image: THintImage read FHintImage write SetHintImage default hiNone;
- property Image1Bitmap: TBitmap index 40 read GetBitmap write AssignBitmap;
- property Image1Width: Single index 41 read GetSingle write SetSingle ;//default ;
- property Image1Height: Single index 42 read GetSingle write SetSingle ;//default ;
- property Image1WrapMode: TImageWrapMode index 43 read GetWrapMode write SetWrapMode default TImageWrapMode.iwFit;
- property Image2Bitmap: TBitmap index 45 read GetBitmap write AssignBitmap;
- property Image2Width: Single index 46 read GetSingle write SetSingle ;//default ;
- property Image2Height: Single index 47 read GetSingle write SetSingle ;//default ;
- property Image2WrapMode: TImageWrapMode index 48 read GetWrapMode write SetWrapMode default TImageWrapMode.iwFit;
- property Image3Bitmap: TBitmap index 50 read GetBitmap write AssignBitmap;
- property Image3Width: Single index 51 read GetSingle write SetSingle ;//default ;
- property Image3Height: Single index 52 read GetSingle write SetSingle ;//default ;
- property Image3WrapMode: TImageWrapMode index 53 read GetWrapMode write SetWrapMode default TImageWrapMode.iwFit;
- property FontFamily: TFontName read GetFontName write SetFontName ;//default ;
- property FontSize: Single index 61 read GetSingle write SetSingle ;//default ;
- property FontStyle: TFontStyles read GetFontStyle write SetFontStyle default [];
- property FontStyleLookup: string index 63 read GetString write SetString ;//default ;
- property FontStyleName: string index 64 read GetString write SetString ;//default ;
- property FontAlign: TAlignLayout read GetAlignLayout write SetAlignLayout default TAlignLayout.alNone;
- property FontWordWrap: Boolean index 66 read GetBoolean write SetBoolean default False;
- property FontMaxWidth: Single index 67 read FMaxWidth write SetSingle ;//default ;
- property GlowEnabled: Boolean index 70 read GetBoolean write SetBoolean default False;
- property GlowColor: TAlphaColor index 71 read GetColor write SetColor default TAlphaColorRec.Gold;
- property GlowOpacity: Single index 72 read GetSingle write SetSingle ;//default ;
- property GlowSoftness: Single index 73 read GetSingle write SetSingle ;//default ;
- property GlowStyleName: string index 74 read GetString write SetString ;//default ;
- property ShadowEnabled: Boolean index 80 read GetBoolean write SetBoolean default True;
- property ShadowColor: TAlphaColor index 81 read GetColor write SetColor default TAlphaColorRec.Black;
- property ShadowDirection: Single index 82 read GetSingle write SetSingle ;//default ;
- property ShadowDistance: Single index 83 read GetSingle write SetSingle ;//default ;
- property ShadowOpacity: Single index 84 read GetSingle write SetSingle ;//default ;
- property ShadowSoftness: Single index 85 read GetSingle write SetSingle ;//default ;
- property ShadowStyleName: string index 86 read GetString write SetString ;//default ;
- property OnShowHint: THintEvent read FOnShowHint write FOnShowHint;
- property OnHideHint: TNotifyEvent read FOnHideHint write FOnHideHint;
- property Fire: Boolean index 90 read GetBoolean write SetBoolean default False;
- end;
- THintItem = class(TFmxObject, IControl)
- strict private
- FManager: THintManager;
- FHintText: string;
- FHintImage: THintImage;
- FHintVisible: Boolean;
- FTranslate: Boolean;
- procedure SetManager (Value: THintManager);
- function GetControl: TControl;
- procedure SetControl (Value: TControl);
- function GetCHitTest: Boolean;
- procedure SetCHitTest (Value: Boolean);
- procedure SetHintText (Value: string);
- procedure SetHintImage (Value: THintImage);
- procedure SetHintVisible(Value: Boolean);
- private
- {IControl}
- function GetObject: TFmxObject;
- procedure SetFocus;
- procedure DoEnter;
- procedure DoExit;
- procedure DoMouseEnter;
- procedure DoMouseLeave;
- function ScreenToLocal(P: TPointF): TPointF;
- function LocalToScreen(P: TPointF): TPointF;
- function ObjectAtPoint(P: TPointF): IControl;
- procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
- procedure MouseMove(Shift: TShiftState; X, Y: Single);
- procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
- procedure MouseWheel(Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean);
- procedure KeyDown(var Key: Word; var KeyChar: WideChar; Shift: TShiftState);
- procedure KeyUp(var Key: Word; var KeyChar: WideChar; Shift: TShiftState);
- procedure DialogKey(var Key: Word; Shift: TShiftState);
- function FindTarget(P: TPointF; const Data: TDragObject): IControl;
- procedure DragEnter(const Data: TDragObject; const Point: TPointF);
- procedure DragOver(const Data: TDragObject; const Point: TPointF; var Accept: Boolean);
- procedure DragDrop(const Data: TDragObject; const Point: TPointF);
- procedure DragLeave;
- procedure DragEnd;
- function CheckForAllowFocus: Boolean;
- function GetTabOrderValue: TTabOrder;
- procedure UpdateTabOrder(Value: TTabOrder);
- procedure Repaint;
- function GetDragMode: TDragMode;
- procedure SetDragMode(const ADragMode: TDragMode);
- procedure BeginAutoDrag;
- function GetParent: TFmxObject;
- function GetLocked: Boolean;
- function GetVisible: Boolean;
- procedure SetVisible(const Value: Boolean);
- function GetHitTest: Boolean;
- function GetCursor: TCursor;
- function GetDesignInteractive: Boolean;
- function GetAcceptsControls: Boolean;
- {$IF RTLVersion >= 24}
- procedure BeginUpdate;
- procedure EndUpdate;
- procedure SetIsChildFocused(const Value: Boolean);
- function GetIsChildFocused: Boolean;
- function GetCanFocus: Boolean;
- function GetCanParentFocus: Boolean;
- function EnterChildren(AObject: TControl): Boolean;
- function ExitChildren(AObject: TControl): Boolean;
- {$IFEND}
- protected
- procedure SetParent (const Value: TFmxObject); override;
- procedure Notification(Component: TComponent; Operation: TOperation); override;
- public
- constructor Create(Owner: TComponent); override;
- procedure ApplyTriggerEffect(Instance: TFmxObject; const Trigger: string); override;
- published
- property Manager: THintManager read FManager write SetManager;
- property Control: TControl read GetControl write SetControl;
- property ControlHitTest: Boolean read GetCHitTest write SetCHitTest stored False default False;
- property HintText: string read FHintText write SetHintText;
- property HintImage: THintImage read FHintImage write SetHintImage default hiNone;
- property HintVisible: Boolean read FHintVisible write SetHintVisible default True;
- property AutoTranslate: Boolean read FTranslate write FTranslate default True;
- property StyleName stored False;
- {$IF RTLVersion < 24}
- property BindingName stored False;
- {$IFEND}
- end;
- implementation
- { THintManager }
- procedure THintManager.AddNewHint(Value: TControl);
- var
- O: TComponent;
- I: THintItem;
- S: string;
- begin
- if not Assigned(Value) then
- Exit;
- if Value.Owner is TForm then
- O := Value.Owner
- else
- O := Value;
- if Assigned(BeforeNewHint) then
- BeforeNewHint(Value, O);
- I := THintItem.Create(O);
- I.Manager := Self;
- I.Control := Value;
- S := Format('%s_Hint', [Value.Name]);
- if (Value.Name <> '') and not Assigned(I.Owner.FindComponent(S)) then
- I.Name := S;
- S := Format('%s_Hint_%p', [Value.Name, Pointer(I)]);
- if (I.Name = '') and (Value.Name <> '') and not Assigned(I.Owner.FindComponent(S)) then
- I.Name := S;
- S := Format('Hint_%p', [Pointer(I)]);
- if (I.Name = '') and (Value.Name <> '') and not Assigned(I.Owner.FindComponent(S)) then
- I.Name := S;
- if Assigned(AfterNewHint) then
- AfterNewHint(I);
- end;
- procedure THintManager.AssignBitmap(I: Integer; Value: TBitmap);
- begin
- InnerHideHint(True, False);
- case I of
- 40: FHintImage1.Bitmap.Assign(Value);
- 45: FHintImage2.Bitmap.Assign(Value);
- 50: FHintImage3.Bitmap.Assign(Value);
- end;
- end;
- procedure THintManager.AssignBrBitmap(Value: TBrushBitmap);
- begin
- InnerHideHint(True, False);
- FHintForm.Fill.Bitmap.Assign(Value);
- end;
- procedure THintManager.AssignGradient(I: Integer; Value: TGradient);
- begin
- InnerHideHint(True, False);
- case I of
- 22: FHintForm.Fill.Gradient.Assign(Value);
- 32: FHintForm.Stroke.Gradient.Assign(Value);
- end;
- end;
- class procedure THintManager.ChangeRefVar(var Ref; NewValue, Comp: TComponent);
- var
- Temp: TComponent;
- RefC: TComponent absolute Ref;
- begin
- if RefC = NewValue then
- Exit;
- Temp := RefC;
- RefC := nil;
- if Assigned(Temp) and not (csDestroying in Temp.ComponentState + Comp.ComponentState) then
- Temp.RemoveFreeNotification(Comp);
- RefC := NewValue;
- if Assigned(NewValue) then
- NewValue.FreeNotification(Comp);
- end;
- constructor THintManager.Create(Owner: TComponent);
- var
- C: TComponent;
- begin
- inherited;
- FHintForm := TCalloutRectangle.Create(Self);
- FHintForm.DesignVisible := False;
- FHintForm.Visible := False;
- FHintForm.CalloutLength := 10;
- FHintForm.CalloutOffset := 15;
- FHintForm.CalloutWidth := 20;
- FHintForm.Fill.Color := TAlphaColorRec.Beige;
- FHintForm.HitTest := False;
- FHintForm.Locked := True;
- FHintForm.StrokeCap := TStrokeCap.scRound;
- FHintImage1 := TImage.Create(Self);
- FHintImage1.Parent := FHintForm;
- FHintImage1.HitTest := False;
- FHintImage1.Locked := True;
- FHintImage2 := TImage.Create(Self);
- FHintImage2.Parent := FHintForm;
- FHintImage2.HitTest := False;
- FHintImage2.Locked := True;
- FHintImage3 := TImage.Create(Self);
- FHintImage3.Parent := FHintForm;
- FHintImage3.HitTest := False;
- FHintImage3.Locked := True;
- FHintLabel := TLabel.Create(Self);
- FHintLabel.Parent := FHintForm;
- FHintLabel.AutoSize := True;
- FHintGlow := TGlowEffect.Create(Self);
- FHintGlow.Parent := FHintForm;
- FHintGlow.Enabled := False;
- FHintShadow := TShadowEffect.Create(Self);
- FHintShadow.Parent := FHintForm;
- FHintShadow.Enabled := True;
- FHintShowTimer := TTimer.Create(Self);
- FHintShowTimer.Enabled := False;
- FHintShowTimer.OnTimer := DoShowTimer;
- FHintHideTimer := TTimer.Create(Self);
- FHintHideTimer.Enabled := False;
- FHintHideTimer.OnTimer := DoHideTimer;
- FHintPause := 500;
- FHintHidePause := 2500;
- FHintShortPause := 50;
- //FHintShortCuts := False;
- FHintPos := hpTop;
- FNextHint.Mode := hmNone;
- FCurrentHint.Mode := hmNone;
- FFireTimer := TTimer.Create(Self);
- FFireTimer.Enabled := False;
- FFireTimer.Interval := 20;
- FFireTimer.OnTimer := DoFireTimer;
- if Assigned(Owner) then
- for C in Owner do
- if (C is THintItem) and not Assigned(THintItem(C).Manager) then
- THintItem(C).Manager := Self;
- end;
- procedure THintManager.CreateHint;
- var
- HImage: THintImage;
- Image: TImage;
- Rect, Size: TRectF;
- Pos: THintPos;
- Offset: Single;
- Form: TCustomForm;
- T: TFmxObject;
- C: TCanvas;
- begin
- if FCurrentHint.Hint = '' then begin
- InnerHideHint(True, False);
- Exit;
- end;
- HImage := FCurrentHint.Image;
- if HImage = hiDefault then
- HImage := FHintImage;
- case HImage of
- hiImage1: Image := FHintImage1;
- hiImage2: Image := FHintImage2;
- hiImage3: Image := FHintImage3;
- else Image := nil;
- end;
- FHintImage1.Visible := HImage = hiImage1;
- FHintImage2.Visible := HImage = hiImage2;
- FHintImage3.Visible := HImage = hiImage3;
- FHintLabel.Text := FCurrentHint.Hint;
- case FCurrentHint.Mode of
- hmPoint: begin
- Rect.TopLeft := FCurrentHint.Point;
- Rect.BottomRight := FCurrentHint.Point;
- end;
- hmRect: Rect := FCurrentHint.Rect;
- hmComp: Rect := FCurrentHint.Comp.AbsoluteRect;
- end;
- Rect.NormalizeRect;
- //FHintShortCuts
- if FCurrentHint.Mode = hmComp then begin
- Form := TCustomForm(FCurrentHint.Comp);
- while Assigned(Form) and not (TObject(Form) is TCustomForm) do
- Form := TCustomForm(TControl(Form).Parent);
- if not Assigned(Form) then
- raise Exception.Create('Hint-ParentForm nicht gefunden.');
- end else begin
- if not (Self.Owner is TCustomForm) then
- raise Exception.Create('Hint-ParentForm nicht gefunden.');
- Form := TCustomForm(Self.Owner);
- end;
- FHintForm.DesignVisible := False;
- FHintForm.Visible := False;
- FHintForm.Parent := Form;
- if Assigned(FOnShowHint) and FOnShowHint(Self, Form, Rect, FCurrentHint.Hint, FCurrentHint.Image, FCurrentHint.Comp) then
- Exit;
- FHintLabel.WordWrap := not FHintLabel.WordWrap;
- FHintLabel.WordWrap := not FHintLabel.WordWrap;
- T := FHintLabel.FindStyleResource('text');
- // if not (T is TText) then
- // raise Exception.Create('unbekannter Fehler');
- // if Assigned(TText(T).Canvas) then
- if (T is TText) and Assigned(TText(T).Canvas) then
- C := TText(T).Canvas
- else
- {$IF RTLVersion >= 24}
- begin
- if not Assigned(FMeasureBitmap) then
- FMeasureBitmap := TBitmap.Create(1, 1);
- C := FMeasureBitmap.Canvas;
- end;
- {$ELSE}
- C := GetMeasureBitmap.Canvas;
- {$ENDIF}
- C.Font.Assign(FHintLabel.Font);
- Size := RectF(0, 0, MaxSingle, MaxSingle);
- if FHintLabel.WordWrap and (FMaxWidth > 5) then
- Size.Right := FMaxWidth;
- C.MeasureText(Size, FCurrentHint.Hint, FHintLabel.WordWrap and (FMaxWidth > 5), [], TTextAlign.taLeading, TTextAlign.taLeading);
- FHintLabel.Width := Size.Right + 4;
- FHintLabel.Height := Size.Bottom + 4;
- if Assigned(Image) then begin
- Size.Right := Size.Right + Image.Width + 5;
- Size.Bottom := Max(Size.Bottom, Image.Height + 4);
- end;
- {$IF RTLVersion >= 24}
- Size.Right := Size.Right + 6 + FHintForm.Stroke.Thickness * 2;
- Size.Bottom := Size.Bottom + 4 + FHintForm.Stroke.Thickness * 2;
- {$ELSE}
- Size.Right := Size.Right + 6 + FHintForm.StrokeThickness * 2;
- Size.Bottom := Size.Bottom + 4 + FHintForm.StrokeThickness * 2;
- {$ENDIF}
- if FHintPos in [hpRight, hpLeft] then
- Size.Right := Size.Right + FHintForm.CalloutLength
- else
- Size.Bottom := Size.Bottom + FHintForm.CalloutLength;
- Pos := FHintPos;
- Offset := FHintForm.CalloutOffset;
- case Pos of
- hpBottom:
- if (Rect.Bottom + Size.Height >= Form.Height) and (Rect.Top - Size.Height >= 0) then
- Pos := hpTop;
- hpRight:
- if (Rect.Right + Size.Width >= Form.Width) and (Rect.Left - Size.Width >= 0) then
- Pos := hpLeft;
- hpTop:
- if (Rect.Top - Size.Height < 0) and (Rect.Bottom + Size.Height < Form.Height) then
- Pos := hpBottom;
- hpLeft:
- if (Rect.Left - Size.Width < 0) and (Rect.Right + Size.Width < Form.Width) then
- Pos := hpRight;
- end;
- FHintForm.CalloutPosition := TCalloutPosition(Pos);
- if Abs(Offset) > 1 then
- if Pos in [hpBottom, hpTop] then begin
- if Offset > 0 then begin
- end else begin
- end;
- end else begin
- if Offset > 0 then begin
- end else begin
- end;
- end;
- {$IF RTLVersion >= 24}
- Size.Offset(FHintForm.Stroke.Thickness, FHintForm.Stroke.Thickness);
- {$ELSE}
- Size.Offset(FHintForm.StrokeThickness, FHintForm.StrokeThickness);
- {$ENDIF}
- case Pos of
- hpBottom: Size.Offset(0, FHintForm.CalloutLength);
- hpRight: Size.Offset(FHintForm.CalloutLength, 0);
- end;
- if Assigned(Image) then begin
- Image.Position.X := Size.Left + 3;
- Image.Position.Y := Size.Top + 2;
- Size.Offset(Image.Width + 3, 0);
- end;
- FHintLabel.Position.X := Size.Left + 3;
- FHintLabel.Position.Y := Size.Top + 1;
- FHintForm.Width := Size.Width;
- FHintForm.Height := Size.Height;
- case Pos of
- hpBottom: FHintForm.Position.Y := Rect.Bottom;
- hpRight: FHintForm.Position.X := Rect.Right;
- hpTop: FHintForm.Position.Y := Rect.Top - Size.Height;
- hpLeft: FHintForm.Position.X := Rect.Left - Size.Width;
- end;
- case Pos of
- hpBottom, hpTop:
- if Offset = 0 then
- FHintForm.Position.X := Rect.CenterPoint.X - Size.Width / 2
- else if Offset > 0 then
- FHintForm.Position.X := Rect.CenterPoint.X - Offset - FHintForm.CalloutWidth / 2
- else
- FHintForm.Position.X := Rect.CenterPoint.X + Offset + FHintForm.CalloutWidth / 2 - Size.Width;
- hpRight, hpLeft:
- if Offset = 0 then
- FHintForm.Position.Y := Rect.CenterPoint.Y - Size.Height / 2
- else if Offset > 0 then
- FHintForm.Position.Y := Rect.CenterPoint.Y - Offset - FHintForm.CalloutWidth / 2
- else
- FHintForm.Position.Y := Rect.CenterPoint.Y + Offset + FHintForm.CalloutWidth / 2 - Size.Height;
- end;
- if FFire and not (csDesigning in ComponentState) then begin
- FFireTimer.Enabled := True;
- FHintShadow.Opacity := 0.6;
- FHintShadow.Softness := 0.8;
- DoFireTimer(nil);
- end;
- FHintHideTimer.Enabled := False;
- FHintHideTimer.Interval := FHintHidePause;
- FHintHideTimer.Enabled := True;
- FHintForm.Parent := Form;
- FHintForm.Visible := True;
- FHintForm.BringToFront;
- if csDesigning in ComponentState then begin
- FHintImage1.DesignVisible := FHintImage1.Visible;
- FHintImage2.DesignVisible := FHintImage2.Visible;
- FHintImage3.DesignVisible := FHintImage3.Visible;
- FHintForm.DesignVisible := True;
- end;
- end;
- destructor THintManager.Destroy;
- begin
- {$IF RTLVersion >= 24}
- FMeasureBitmap.Free;
- {$IFEND}
- inherited;
- end;
- procedure THintManager.DoFireTimer(Sender: TObject);
- begin
- FHintShadow.Direction := 250 + Random(41);
- FHintShadow.Distance := 5 + Random(16);
- case Random(5) of
- 0: FHintShadow.ShadowColor := TAlphaColorRec.Orangered;
- 4: FHintShadow.ShadowColor := TAlphaColorRec.Yellow;
- else FHintShadow.ShadowColor := TAlphaColorRec.Orange;
- end;
- end;
- procedure THintManager.DoHideTimer(Sender: TObject);
- begin
- FHintHideTimer.Enabled := False;
- InnerHideHint(True, False);
- end;
- procedure THintManager.DoShowTimer(Sender: TObject);
- begin
- FHintShowTimer.Enabled := False;
- InnerShowHint(hsImmediately);
- end;
- function THintManager.GetAlignLayout: TAlignLayout;
- begin
- Result := FHintLabel.Align;
- end;
- function THintManager.GetBitmap(I: Integer): TBitmap;
- begin
- InnerHideHint(True, False);
- case I of
- 40: Result := FHintImage1.Bitmap;
- 45: Result := FHintImage2.Bitmap;
- 50: Result := FHintImage3.Bitmap;
- else Result := nil;
- end;
- end;
- function THintManager.GetBoolean(I: Integer): Boolean;
- begin
- case I of
- 66: Result := FHintLabel.WordWrap;
- 70: Result := FHintGlow.Enabled;
- 80: Result := FHintShadow.Enabled;
- 90: Result := FFire;
- else Result := False;
- end;
- end;
- function THintManager.GetBrBitmap: TBrushBitmap;
- begin
- InnerHideHint(True, False);
- Result := FHintForm.Fill.Bitmap;
- end;
- function THintManager.GetColor(I: Integer): TAlphaColor;
- begin
- case I of
- 21: Result := FHintForm.Fill.Color;
- 31: Result := FHintForm.Stroke.Color;
- 71: Result := FHintGlow.GlowColor;
- 81: Result := FHintShadow.ShadowColor;
- else Result := TAlphaColorRec.Null;
- end;
- end;
- function THintManager.GetFontName: TFontName;
- begin
- Result := FHintLabel.Font.Family;
- end;
- function THintManager.GetFontStyle: TFontStyles;
- begin
- Result := FHintLabel.Font.Style;
- end;
- function THintManager.GetGradient(I: Integer): TGradient;
- begin
- InnerHideHint(True, False);
- case I of
- 22: Result := FHintForm.Fill.Gradient;
- 32: Result := FHintForm.Stroke.Gradient;
- else Result := nil;
- end;
- end;
- function THintManager.GetKind(I: Integer): TBrushKind;
- begin
- case I of
- 20: Result := FHintForm.Fill.Kind;
- 30: Result := FHintForm.Stroke.Kind;
- else Result := TBrushKind.bkNone;
- end;
- end;
- function THintManager.GetSingle(I: Integer): Single;
- begin
- case I of
- 10: Result := FHintForm.CalloutLength;
- 11: if FHintForm.CalloutOffset = 0 then
- Result := 0
- else if Abs(FHintForm.CalloutOffset) < 1 then
- Result := Sign(FHintForm.CalloutOffset)
- else
- Result := FHintForm.CalloutOffset - Sign(FHintForm.CalloutOffset);
- 12: Result := FHintForm.CalloutWidth;
- 33: Result := FHintForm.{$IF RTLVersion >= 24}Stroke.Thickness{$ELSE}StrokeThickness{$ENDIF};
- 41: Result := FHintImage1.Width;
- 42: Result := FHintImage1.Height;
- 46: Result := FHintImage2.Width;
- 47: Result := FHintImage2.Height;
- 51: Result := FHintImage3.Width;
- 52: Result := FHintImage3.Height;
- 61: Result := FHintLabel.Font.Size;
- 72: Result := FHintGlow.Opacity;
- 73: Result := FHintGlow.Softness;
- 82: Result := FHintShadow.Direction;
- 83: Result := FHintShadow.Distance;
- 84: Result := FHintShadow.Opacity;
- 85: Result := FHintShadow.Softness;
- else Result := 0;
- end;
- end;
- function THintManager.GetString(I: Integer): String;
- begin
- case I of
- 63: Result := FHintLabel.StyleLookup;
- 64: Result := FHintLabel.StyleName;
- 74: Result := FHintGlow.StyleName;
- 86: Result := FHintShadow.StyleName;
- else Result := '';
- end;
- end;
- function THintManager.GetWrapMode(I: Integer): TImageWrapMode;
- begin
- case I of
- 43: Result := FHintImage1.WrapMode;
- 48: Result := FHintImage2.WrapMode;
- 53: Result := FHintImage3.WrapMode;
- else Result := TImageWrapMode.iwOriginal;
- end;
- end;
- procedure THintManager.HideHint;
- var
- C: TComponent;
- begin
- if Assigned(Owner) then
- for C in Owner do
- if C is THintManager then
- THintManager(C).InnerHideHint(True, True)
- else
- InnerHideHint(True, True);
- end;
- procedure THintManager.HintHide(Item: THintItem; Immediately: Boolean);
- begin
- InnerHideHint(FCurrentHint.Comp = Item.Control, FNextHint.Comp = Item.Control);
- end;
- procedure THintManager.HintRefresh(Item: THintItem);
- begin
- if FCurrentHint.Comp = Item.Control then begin
- FCurrentHint.Hint := LoadText(Item, Item.AutoTranslate
- or ((Item.Control is TStyledControl) and TStyledControl(Item.Control).AutoTranslate));
- FCurrentHint.Image := Item.HintImage;
- InnerShowHint(hsRefresh);
- end;
- if FNextHint.Comp = Item.Control then begin
- FNextHint.Hint := LoadText(Item, Item.AutoTranslate
- or ((Item.Control is TStyledControl) and TStyledControl(Item.Control).AutoTranslate));
- FNextHint.Image := Item.HintImage;
- end;
- end;
- procedure THintManager.HintShow(Item: THintItem; Immediately: Boolean);
- begin
- if (FCurrentHint.Comp = Item.Control) and IsHintVisible then begin
- //FHintHideTimer.UpdateTimer; // Zeit neu starten
- FHintHideTimer.Enabled := not FHintHideTimer.Enabled;
- FHintHideTimer.Enabled := not FHintHideTimer.Enabled;
- Exit;
- end;
- ChangeRefVar(FNextHint.Comp, Item.Control, Self);
- FNextHint.Mode := hmComp;
- FNextHint.Hint := LoadText(Item, Item.AutoTranslate
- or ((Item.Control is TStyledControl) and TStyledControl(Item.Control).AutoTranslate));
- FNextHint.Image := Item.HintImage;
- if Immediately then
- InnerShowHint(hsImmediately)
- else if IsHintVisible then
- InnerShowHint(hsShort)
- else
- InnerShowHint(hsNormal);
- end;
- procedure THintManager.InnerHideHint(CurrentHint, NextHint: Boolean);
- begin
- if CurrentHint and (FCurrentHint.Mode <> hmNone) then begin
- FHintHideTimer.Enabled := False;
- FCurrentHint.Mode := hmNone;
- FHintForm.Visible := False;
- FHintForm.DesignVisible := False;
- if FHintForm.Parent is TControl then
- TControl(FHintForm.Parent).Repaint;
- if csDesigning in ComponentState then
- FHintForm.Parent := nil;
- ChangeRefVar(FCurrentHint.Comp, nil, Self);
- if Assigned(FOnHideHint) then
- FOnHideHint(Self);
- if FFireTimer.Enabled and not (csDesigning in ComponentState) then begin
- FFireTimer.Enabled := False;
- FHintShadow.Opacity := 0.6;
- FHintShadow.Softness := 0.3;
- FHintShadow.Direction := 45;
- FHintShadow.Distance := 1;
- FHintShadow.ShadowColor := TAlphaColorRec.Black;
- end;
- end;
- if NextHint and (FNextHint.Mode <> hmNone) then begin
- FHintShowTimer.Enabled := False;
- FNextHint.Mode := hmNone;
- ChangeRefVar(FNextHint.Comp, nil, Self);
- end;
- end;
- procedure THintManager.InnerShowHint(Mode: THintShow);
- var
- C: TComponent;
- begin
- case Mode of
- hsImmediately: begin
- InnerHideHint(True, False);
- if Assigned(Owner) then
- for C in Owner do
- if (C is THintManager) and (C <> Self) then
- THintManager(C).InnerHideHint(True, False);
- ChangeRefVar(FCurrentHint.Comp, nil, Self);
- FCurrentHint := FNextHint;
- FNextHint.Mode := hmNone;
- FNextHint.Comp := nil;
- CreateHint;
- end;
- hsShort: begin
- if FHintShortPause = 0 then begin
- InnerShowHint(hsImmediately);
- Exit;
- end;
- FHintShowTimer.Enabled := False;
- FHintShowTimer.Interval := FHintShortPause;
- FHintShowTimer.Enabled := True;
- end;
- hsNormal: begin
- FHintShowTimer.Enabled := False;
- FHintShowTimer.Interval := FHintPause;
- FHintShowTimer.Enabled := True;
- end;
- hsRefresh: begin
- if not IsHintVisible then
- Exit;
- CreateHint;
- end;
- end;
- end;
- function THintManager.IsHintVisible: Boolean;
- begin
- Result := FHintForm.Visible or ((csDesigning in ComponentState) and FHintForm.DesignVisible)
- end;
- function THintManager.LoadText(Comp: TComponent; AutoTranslate: Boolean): string;
- begin
- if Comp is THintItem then
- Result := THintItem(Comp).HintText
- else if Comp is TTextControl then
- Result := TTextControl(Comp).Text
- else
- raise EProgrammerNotFound.CreateFmt('%s.Text ist nicht implementiert.', [Comp.ClassName]);
- if Result <> '' then
- Result := Fmx.Types.Translate(Result);
- end;
- procedure THintManager.Notification(Component: TComponent; Operation: TOperation);
- begin
- inherited;
- if (Operation = opRemove) and (Component = FCurrentHint.Comp) then begin
- FCurrentHint.Comp := nil;
- InnerHideHint(True, False);
- end;
- if (Operation = opRemove) and (Component = FNextHint.Comp) then begin
- FNextHint.Comp := nil;
- InnerHideHint(False, True);
- end;
- end;
- procedure THintManager.Repaint;
- begin
- if IsHintVisible then
- FHintForm.Repaint;
- end;
- procedure THintManager.SetAlignLayout(Value: TAlignLayout);
- begin
- InnerHideHint(True, False);
- FHintLabel.Align := Value;
- end;
- procedure THintManager.SetBoolean(I: Integer; Value: Boolean);
- begin
- InnerHideHint(True, False);
- case I of
- 66: FHintLabel.WordWrap := Value;
- 70: begin
- FHintGlow.Enabled := Value;
- if Value then
- FHintShadow.Enabled := False;
- end;
- 80: begin
- FHintShadow.Enabled := Value;
- if Value then
- FHintGlow.Enabled := False;
- end;
- 90: FFire := Value;
- end;
- if FFire then begin
- FHintShadow.Enabled := True;
- FHintGlow.Enabled := False;
- end;
- end;
- procedure THintManager.SetColor(I: Integer; Value: TAlphaColor);
- begin
- InnerHideHint(True, False);
- case I of
- 21: FHintForm.Fill.Color := Value;
- 31: FHintForm.Stroke.Color := Value;
- 71: FHintGlow.GlowColor := Value;
- 81: FHintShadow.ShadowColor := Value;
- end;
- end;
- procedure THintManager.SetFontName(Value: TFontName);
- begin
- InnerHideHint(True, False);
- FHintLabel.Font.Family := Value;
- end;
- procedure THintManager.SetFontStyle(Value: TFontStyles);
- begin
- InnerHideHint(True, False);
- FHintLabel.Font.Style := Value;
- end;
- procedure THintManager.SetHintImage(Value: THintImage);
- begin
- InnerHideHint(True, False);
- if Value = hiDefault then
- Value := hiNone;
- FHintImage := Value;
- end;
- procedure THintManager.SetHintPos(Value: THintPos);
- begin
- InnerHideHint(True, False);
- if Value = hpDefault then
- Value := hpTop;
- FHintPos := Value;
- end;
- procedure THintManager.SetKind(I: Integer; Value: TBrushKind);
- begin
- InnerHideHint(True, False);
- case I of
- 20: FHintForm.Fill.Kind := Value;
- 30: FHintForm.Stroke.Kind := Value;
- end;
- end;
- procedure THintManager.SetSingle(I: Integer; Value: Single);
- begin
- InnerHideHint(True, False);
- case I of
- 10: Value := Min(Max(Value, 5), 50);
- 11: Value := Min(Max(Value, -250), 250);
- 12: Value := Min(Max(Value, 3), 100);
- 33: Value := Min(Max(Value, 1), 30);
- 41..52: Value := Min(Max(Value, 0), 200);
- 61: Value := Min(Max(Value, 8), 100);
- 67: Value := Min(Max(Value, 0), 500);
- 72, 73,
- 84, 85: Value := Min(Max(Value, 0.3), 1.0);
- 82: Value := Min(Max(Value, 0), 360);
- 83: Value := Min(Max(Value, 0.1), 1.0);
- end;
- case I of
- 10: FHintForm.CalloutLength := Value;
- 11: if Value = 0 then
- FHintForm.CalloutOffset := 0
- else if Abs(Value) <= 1.00000001 then
- FHintForm.CalloutOffset := Sign(Value) * 0.000000000000000000001
- else
- FHintForm.CalloutOffset := Value + Sign(Value);
- 12: FHintForm.CalloutWidth := Value;
- 33: FHintForm.{$IF RTLVersion >= 24}Stroke.Thickness{$ELSE}StrokeThickness{$ENDIF} := Value;
- 41: FHintImage1.Width := Value;
- 42: FHintImage1.Height := Value;
- 46: FHintImage1.Width := Value;
- 47: FHintImage1.Height := Value;
- 51: FHintImage1.Width := Value;
- 52: FHintImage1.Height := Value;
- 61: FHintLabel.Font.Size := Value;
- 67: FMaxWidth := Value;
- 72: FHintGlow.Opacity := Value;
- 73: FHintGlow.Softness := Value;
- 82: FHintShadow.Direction := Value;
- 83: FHintShadow.Distance := Value;
- 84: FHintShadow.Opacity := Value;
- 85: FHintShadow.Softness := Value;
- end;
- end;
- procedure THintManager.SetString(I: Integer; Value: String);
- begin
- InnerHideHint(True, False);
- case I of
- 63: FHintLabel.StyleLookup := Value;
- 64: FHintLabel.StyleName := Value;
- 74: FHintGlow.StyleName := Value;
- 86: FHintShadow.StyleName := Value;
- end;
- end;
- procedure THintManager.SetWrapMode(I: Integer; Value: TImageWrapMode);
- begin
- InnerHideHint(True, False);
- case I of
- 43: FHintImage1.WrapMode := Value;
- 48: FHintImage2.WrapMode := Value;
- 53: FHintImage3.WrapMode := Value;
- end;
- end;
- procedure THintManager.ShowHint(const AbsolutePos: TPointF; Hint: string; Image: THintImage; Translate: Boolean);
- begin
- if Translate and (Hint <> '') then
- Hint := Fmx.Types.Translate(Hint);
- ChangeRefVar(FNextHint.Comp, nil, Self);
- FNextHint.Mode := hmPoint;
- FNextHint.Point := AbsolutePos;
- FNextHint.Hint := Hint;
- FNextHint.Image := Image;
- InnerShowHint(hsImmediately);
- end;
- procedure THintManager.ShowHint(const AbsolutePos: TRectF; Hint: string; Image: THintImage; Translate: Boolean);
- begin
- if Translate and (Hint <> '') then
- Hint := Fmx.Types.Translate(Hint);
- ChangeRefVar(FNextHint.Comp, nil, Self);
- FNextHint.Mode := hmRect;
- FNextHint.Rect := AbsolutePos;
- FNextHint.Hint := Hint;
- FNextHint.Image := Image;
- InnerShowHint(hsImmediately);
- end;
- procedure THintManager.ShowHint(Component: TControl; Hint: string; Image: THintImage; Translate: Boolean);
- begin
- if Assigned(Component) then begin
- if Hint = '' then
- Exit;
- //Hint := LoadText(Component, Translate or ((Component is TStyledControl) and TStyledControl(Component).AutoTranslate));
- ChangeRefVar(FNextHint.Comp, Component, Self);
- FNextHint.Mode := hmComp;
- FNextHint.Hint := Hint;
- FNextHint.Image := Image;
- InnerShowHint(hsImmediately);
- end else begin
- ChangeRefVar(FNextHint.Comp, nil, Self);
- FNextHint.Mode := hmNone;
- end;
- end;
- { THintItem }
- type THackControl = class(TControl);
- procedure ApplyTriggerEffect(Instance: TFmxObject; const Trigger: string);
- begin
- inherited;
- if Assigned(Parent) and Assigned(FManager) {and (Instance = Parent)} and (Trigger = 'IsMouseOver') then
- if TControl(Parent).IsMouseOver and FHintVisible then
- FManager.HintShow(Self)
- else
- FManager.HintHide(Self);
- end;
- procedure THintItem.BeginAutoDrag;
- begin
- end;
- {$IF RTLVersion >= 24}
- procedure THintItem.BeginUpdate;
- begin
- end;
- {$IFEND}
- function THintItem.CheckForAllowFocus: Boolean;
- begin
- Result := False;
- end;
- constructor THintItem.Create(Owner: TComponent);
- begin
- inherited;
- FHintVisible := True;
- FTranslate := True;
- end;
- procedure THintItem.DialogKey(var Key: Word; Shift: TShiftState);
- begin
- end;
- procedure THintItem.DoEnter;
- begin
- end;
- procedure THintItem.DoExit;
- begin
- end;
- procedure THintItem.DoMouseEnter;
- begin
- ShowMessage('THintItem.DoMouseEnter');
- end;
- procedure THintItem.DoMouseLeave;
- begin
- ShowMessage('THintItem.DoMouseLeave');
- end;
- procedure THintItem.DragDrop(const Data: TDragObject; const Point: TPointF);
- begin
- end;
- procedure THintItem.DragEnd;
- begin
- end;
- procedure THintItem.DragEnter(const Data: TDragObject; const Point: TPointF);
- begin
- end;
- procedure THintItem.DragLeave;
- begin
- end;
- procedure THintItem.DragOver(const Data: TDragObject; const Point: TPointF; var Accept: Boolean);
- begin
- end;
- {$IF RTLVersion >= 24}
- procedure THintItem.EndUpdate;
- begin
- end;
- function THintItem.EnterChildren(AObject: TControl): Boolean;
- begin
- Result := False;
- end;
- function THintItem.ExitChildren(AObject: TControl): Boolean;
- begin
- Result := False;
- end;
- {$IFEND}
- function THintItem.FindTarget(P: TPointF; const Data: TDragObject): IControl;
- begin
- // if Parent is TControl then
- // Result := THackControl(Parent).FindTarget(P, Data)
- // else
- Result := nil;
- end;
- function THintItem.GetControl: TControl;
- begin
- if Parent is TControl then
- Result := Parent as TControl
- else
- Result := nil;
- end;
- function THintItem.GetAcceptsControls: Boolean;
- begin
- Result := False;
- end;
- function THintItem.GetCursor: TCursor;
- begin
- Result := crNone;
- end;
- function THintItem.GetDesignInteractive: Boolean;
- begin
- Result := False;
- end;
- function THintItem.GetDragMode: TDragMode;
- begin
- Result := TDragMode.dmManual;
- end;
- function THintItem.GetHitTest: Boolean;
- begin
- Result := False;
- end;
- {$IF RTLVersion >= 24}
- function THintItem.GetIsChildFocused: Boolean;
- begin
- Result := False;
- end;
- {$IFEND}
- function THintItem.GetLocked: Boolean;
- begin
- Result := True;
- end;
- function THintItem.GetObject: TFmxObject;
- begin
- Result := Self;
- end;
- function THintItem.GetParent: TFmxObject;
- begin
- Result := Parent;
- end;
- function THintItem.GetTabOrderValue: TTabOrder;
- begin
- Result := -1;
- end;
- function THintItem.GetVisible: Boolean;
- begin
- Result := FHintVisible;
- end;
- procedure THintItem.KeyDown(var Key: Word; var KeyChar: WideChar; Shift: TShiftState);
- begin
- end;
- procedure THintItem.KeyUp(var Key: Word; var KeyChar: WideChar; Shift: TShiftState);
- begin
- end;
- function THintItem.LocalToScreen(P: TPointF): TPointF;
- begin
- // if Parent is TControl then
- // Result := THackControl(Parent).LocalToScreen(P)
- // else
- Result := P;
- end;
- procedure THintItem.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
- begin
- end;
- procedure THintItem.MouseMove(Shift: TShiftState; X, Y: Single);
- begin
- end;
- procedure THintItem.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
- begin
- end;
- procedure THintItem.MouseWheel(Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean);
- begin
- end;
- {$IF RTLVersion >= 24}
- function THintItem.GetCanFocus: Boolean;
- begin
- Result := False;
- end;
- function THintItem.GetCanParentFocus: Boolean;
- begin
- Result := False;
- end;
- {$IFEND}
- function THintItem.GetCHitTest: Boolean;
- begin
- Result := (Parent is TControl) and TControl(Parent).HitTest;
- end;
- procedure THintItem.Notification(Component: TComponent; Operation: TOperation);
- begin
- inherited;
- if (Operation = opRemove) and (Component = Parent) then begin
- Parent := nil;
- if not (csDestroying in ComponentState) then
- Free;
- end;
- if (Operation = opRemove) and (Component = FManager) then
- FManager := nil;
- end;
- function THintItem.ObjectAtPoint(P: TPointF): IControl;
- begin
- // if Parent is TControl then
- // Result := THackControl(Parent).ObjectAtPoint(P)
- // else
- Result := nil;
- end;
- procedure THintItem.Repaint;
- begin
- if Assigned(FManager) then
- FManager.Repaint;
- end;
- procedure THintItem.SetControl(Value: TControl);
- var
- C: TComponent;
- F: TCustomForm;
- begin
- if Parent = Value then
- Exit;
- Parent := Value;
- if not Assigned(FManager) then begin
- F := TCustomForm(Self);
- while Assigned(F) and not (TObject(F) is TCustomForm) do
- F := TCustomForm(TControl(F).Parent);
- if Assigned(F) then
- for C in Owner do
- if C is THintManager then begin
- Manager := THintManager(C);
- Break;
- end;
- end;
- end;
- procedure THintItem.SetDragMode(const ADragMode: TDragMode);
- begin
- end;
- procedure THintItem.SetFocus;
- begin
- end;
- procedure THintItem.SetHintImage(Value: THintImage);
- begin
- FHintImage := Value;
- if Assigned(FManager) then
- FManager.HintRefresh(Self);
- end;
- procedure THintItem.SetHintText(Value: string);
- begin
- FHintText := Value;
- if Assigned(FManager) then
- FManager.HintRefresh(Self);
- end;
- procedure THintItem.SetHintVisible(Value: Boolean);
- begin
- FHintVisible := Value;
- if Assigned(FManager) then
- FManager.HintHide(Self, True);
- end;
- {$IF RTLVersion >= 24}
- procedure THintItem.SetIsChildFocused(const Value: Boolean);
- begin
- end;
- {$IFEND}
- function THintItem.ScreenToLocal(P: TPointF): TPointF;
- begin
- // if Parent is TControl then
- // Result := THackControl(Parent).ScreenToLocal(P)
- // else
- Result := P;
- end;
- procedure THintItem.SetCHitTest(Value: Boolean);
- begin
- if Parent is TControl then
- TControl(Parent).HitTest := Value;
- end;
- procedure THintItem.SetManager(Value: THintManager);
- begin
- if Assigned(FManager) then
- FManager.HintHide(Self, True);
- THintManager.ChangeRefVar(FManager, Value, Self);
- end;
- procedure THintItem.SetParent(const Value: TFmxObject);
- begin
- if Value = inherited Parent then
- Exit;
- if Assigned(FManager) then
- FManager.HintHide(Self, True);
- // if Assigned(inherited Parent) and not (csDestroying in inherited Parent.ComponentState + Self.ComponentState) then
- // inherited Parent.RemoveFreeNotification(Self);
- inherited;
- // if Assigned(Value) then
- // Value.FreeNotification(Self);
- end;
- procedure THintItem.SetVisible(const Value: Boolean);
- begin
- FHintVisible := Value;
- end;
- procedure THintItem.UpdateTabOrder(Value: TTabOrder);
- begin
- end;
- initialization
- RegisterClass(THintItem);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement