lcl: add BiDi mode support and Alignment for THintWindow (patch by Luiz Americo, issue #0014719)

git-svn-id: trunk@22021 -
This commit is contained in:
paul 2009-10-04 13:00:38 +00:00
parent 696cd2fec3
commit 4f58001501
2 changed files with 38 additions and 9 deletions

View File

@ -753,9 +753,11 @@ type
THintWindow = class(TCustomForm)
private
FActivating: Boolean;
FAutoHide : Boolean;
FAutoHideTimer : TComponent;
FHideInterval : Integer;
FAlignment: TAlignment;
FAutoHide: Boolean;
FAutoHideTimer: TComponent;
FHideInterval: Integer;
function GetDrawTextFlags: Cardinal;
procedure SetAutoHide(Value : Boolean);
procedure AutoHideHint(Sender : TObject);
procedure SetHideInterval(Value : Integer);
@ -774,8 +776,10 @@ type
procedure Paint; override;
class function GetControlClassDefaultSize: TPoint; override;
public
property AutoHide : Boolean read FAutoHide write SetAutoHide;
property HideInterval : Integer read FHideInterval write SetHideInterval;
property Alignment: TAlignment read FAlignment write FAlignment;
property AutoHide: Boolean read FAutoHide write SetAutoHide;
property BiDiMode;
property HideInterval: Integer read FHideInterval write SetHideInterval;
end;
THintWindowClass = class of THintWindow;
@ -1158,7 +1162,7 @@ type
procedure FreeIconHandles;
procedure IconChanged(Sender: TObject);
function GetControlAtMouse: TControl;
procedure SetBidiMode ( const AValue : TBiDiMode ) ;
procedure SetBidiMode(const AValue: TBiDiMode);
procedure SetFlags(const AValue: TApplicationFlags);
procedure SetNavigation(const AValue: TApplicationNavigationOptions);
procedure SetShowButtonGlyphs(const AValue: TApplicationShowGlyphs);

View File

@ -35,6 +35,7 @@ begin
Color := clInfoBk;
Canvas.Font := Screen.HintFont;
Canvas.Brush.Style := bsClear;
FAlignment := taLeftJustify;
BorderStyle := bsNone;
Caption := 'THintWindow';
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
@ -78,6 +79,31 @@ begin
end;
end;
function THintWindow.GetDrawTextFlags: Cardinal;
var
EffectiveAlignment: TAlignment;
begin
Result := DT_NOPREFIX or DT_VCENTER or DT_WORDBREAK;
EffectiveAlignment := FAlignment;
if BiDiMode <> bdLeftToRight then
begin
Result := Result or DT_RTLREADING;
//change alignment if is RTL
if BiDiMode = bdRightToLeft then
begin
case FAlignment of
taLeftJustify: EffectiveAlignment := taRightJustify;
taRightJustify: EffectiveAlignment := taLeftJustify;
end;
end;
end;
case EffectiveAlignment of
taLeftJustify: Result := Result or DT_LEFT;
taCenter: Result := Result or DT_CENTER;
taRightJustify: Result := Result or DT_RIGHT;
end;
end;
procedure THintWindow.SetAutoHide(Value : Boolean);
Begin
FAutoHide := Value;
@ -113,9 +139,8 @@ begin
DrawEdge(Canvas.Handle, ARect, BDR_RAISEDOUTER, BF_RECT);
end;
InflateRect(ARect, - 2 * HintBorderWidth, - 2 * HintBorderWidth);
DrawText(Canvas.GetUpdatedHandle([csFontValid]),
PChar(Caption), Length(Caption), ARect,
DT_NOPREFIX or DT_VCENTER or DT_WORDBREAK); // no DT_CENTER in Delphi according to Luiz
DrawText(Canvas.GetUpdatedHandle([csFontValid]), PChar(Caption),
Length(Caption), ARect, GetDrawTextFlags);
end;
class function THintWindow.GetControlClassDefaultSize: TPoint;