lcl: TApplication.BidiMode from Ido with modifications (#0012542)

git-svn-id: trunk@17177 -
This commit is contained in:
paul 2008-11-01 18:11:31 +00:00
parent 9d2926b3f7
commit 69f9aff08a
2 changed files with 28 additions and 2 deletions

View File

@ -40,7 +40,8 @@ uses
Classes, SysUtils, Types, TypInfo, Math, Classes, SysUtils, Types, TypInfo, Math,
AvgLvlTree, Maps, LCLVersion, LCLStrConsts, LCLType, LCLProc, LCLIntf, AvgLvlTree, Maps, LCLVersion, LCLStrConsts, LCLType, LCLProc, LCLIntf,
FileUtil, InterfaceBase, LResources, GraphType, Graphics, Menus, LMessages, FileUtil, InterfaceBase, LResources, GraphType, Graphics, Menus, LMessages,
CustomTimer, ActnList, ClipBrd, CustApp, HelpIntfs, LCLClasses, Controls; CustomTimer, ActnList, ClipBrd, CustApp, HelpIntfs, LCLClasses, Controls,
gettext;
type type
TProcedure = procedure; TProcedure = procedure;
@ -1016,6 +1017,7 @@ type
FLastMousePos: TPoint; FLastMousePos: TPoint;
FLastMouseControl: TControl; FLastMouseControl: TControl;
FLastMouseControlValid: Boolean; FLastMouseControlValid: Boolean;
FBidiMode: TBiDiMode;
procedure DoOnIdleEnd; procedure DoOnIdleEnd;
function GetActive: boolean; function GetActive: boolean;
function GetCurrentHelpFile: string; function GetCurrentHelpFile: string;
@ -1025,6 +1027,7 @@ type
procedure IconChanged(Sender: TObject); procedure IconChanged(Sender: TObject);
function InvokeHelp(Command: Word; Data: Longint): Boolean; function InvokeHelp(Command: Word; Data: Longint): Boolean;
function GetControlAtMouse: TControl; function GetControlAtMouse: TControl;
procedure SetBidiMode ( const AValue : TBiDiMode ) ;
procedure SetFlags(const AValue: TApplicationFlags); procedure SetFlags(const AValue: TApplicationFlags);
procedure SetNavigation(const AValue: TApplicationNavigationOptions); procedure SetNavigation(const AValue: TApplicationNavigationOptions);
procedure UpdateMouseControl(NewMouseControl: TControl); procedure UpdateMouseControl(NewMouseControl: TControl);
@ -1159,6 +1162,7 @@ type
Shift: TShiftState); Shift: TShiftState);
procedure DoTabKey(AControl: TWinControl; var Key: Word;Shift: TShiftState); procedure DoTabKey(AControl: TWinControl; var Key: Word;Shift: TShiftState);
property Active: boolean read GetActive; property Active: boolean read GetActive;
property BidiMode: TBiDiMode read FBidiMode write SetBidiMode;
property CaptureExceptions: boolean read FCaptureExceptions property CaptureExceptions: boolean read FCaptureExceptions
write SetCaptureExceptions; write SetCaptureExceptions;
property FindGlobalComponentEnabled: boolean read FFindGlobalComponentEnabled property FindGlobalComponentEnabled: boolean read FFindGlobalComponentEnabled
@ -1198,7 +1202,6 @@ type
property ApplicationType : TApplicationType read FApplicationType write FApplicationType; property ApplicationType : TApplicationType read FApplicationType write FApplicationType;
end; end;
{ TApplicationProperties } { TApplicationProperties }
TApplicationProperties = class(TLCLComponent) TApplicationProperties = class(TLCLComponent)

View File

@ -89,6 +89,17 @@ end;
TApplication Constructor TApplication Constructor
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
constructor TApplication.Create(AOwner: TComponent); constructor TApplication.Create(AOwner: TComponent);
const
BidiModeMap: array[Boolean] of TBiDiMode = (bdLeftToRight, bdRightToLeft);
function IsRTLLang(ALang: String): Boolean;
begin
Result := (ALang = 'ar') or
(ALang = 'he');
end;
var
LangDefault, LangFallback: String;
begin begin
LCLProc.SendApplicationMessageFunction:=@SendApplicationMsg; LCLProc.SendApplicationMessageFunction:=@SendApplicationMsg;
@ -114,6 +125,12 @@ begin
FFindGlobalComponentEnabled:=true; FFindGlobalComponentEnabled:=true;
RegisterFindGlobalComponentProc(@FindApplicationComponent); RegisterFindGlobalComponentProc(@FindApplicationComponent);
GetLanguageIDs(LangDefault, LangFallback);
if LangDefault <> '' then
FBidiMode := BidiModeMap[IsRTLLang(LangDefault)]
else
FBidiMode := BidiModeMap[IsRTLLang(LangFallback)];
inherited Create(AOwner); inherited Create(AOwner);
CaptureExceptions:=true; CaptureExceptions:=true;
@ -450,6 +467,12 @@ begin
end; end;
end; end;
procedure TApplication.SetBidiMode ( const AValue : TBiDiMode ) ;
begin
if AValue <> FBidiMode then
FBidiMode := AValue;
end;
procedure TApplication.SetFlags(const AValue: TApplicationFlags); procedure TApplication.SetFlags(const AValue: TApplicationFlags);
begin begin
{ Only allow AppNoExceptionMessages to be changed } { Only allow AppNoExceptionMessages to be changed }