- BidiMode patch from Zaher Dirkey (0008996) part 1

git-svn-id: trunk@11408 -
This commit is contained in:
paul 2007-07-02 07:00:51 +00:00
parent 1aa10e864e
commit d5c7e43700
15 changed files with 257 additions and 43 deletions

View File

@ -422,6 +422,7 @@ type
procedure WMPaint(var message: TLMPaint); message LM_PAINT; procedure WMPaint(var message: TLMPaint); message LM_PAINT;
procedure WMShowWindow(var message: TLMShowWindow); message LM_SHOWWINDOW; procedure WMShowWindow(var message: TLMShowWindow); message LM_SHOWWINDOW;
procedure WMSize(var message: TLMSize); message LM_Size; procedure WMSize(var message: TLMSize); message LM_Size;
procedure CMBiDiModeChanged(var Message: TLMessage); message CM_BIDIMODECHANGED;
procedure AddHandler(HandlerType: TFormHandlerType; procedure AddHandler(HandlerType: TFormHandlerType;
const Handler: TMethod; AsLast: Boolean); const Handler: TMethod; AsLast: Boolean);
procedure RemoveHandler(HandlerType: TFormHandlerType; procedure RemoveHandler(HandlerType: TFormHandlerType;
@ -1800,3 +1801,4 @@ finalization
end. end.

View File

@ -289,6 +289,12 @@ begin
Result:=BorderSpacing.InnerBorder<>2; Result:=BorderSpacing.InnerBorder<>2;
end; end;
function TCustomButton.UseRightToLeftAlignment: Boolean;
begin
//Button always has center alignment
Result := False;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
procedure TCustomButton.DoSendBtnDefault; procedure TCustomButton.DoSendBtnDefault;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -307,3 +313,4 @@ begin
end; end;

View File

@ -574,6 +574,30 @@ begin
end; end;
End; End;
procedure TCustomForm.CMBiDiModeChanged(var Message: TLMessage);
var
i:Integer;
lMessage:TLMessage;
begin
inherited;
//send CM_PARENTBIDIMODECHANGED to All Component owned by Form
{ prefer use IMenu and check it then call IMenu.ParentBidiMode
This way is usefull for other TMenu components that need BidiMode of form changed
Like as TToolbar }
lMessage.msg := CM_PARENTBIDIMODECHANGED;
lMessage.wParam := 0;
lMessage.lParam := 0;
lMessage.Result := 0;
for i := 0 to ComponentCount - 1 do
begin
if not (Components[i] is TCustomControl) then//TCustomControl already has this notification
Components[i].Dispatch(lMessage);
//the old way
// if Components[i] is TMenu then
// TMenu(Components[i]).ParentBiDiModeChanged;
end;
end;
procedure TCustomForm.AddHandler(HandlerType: TFormHandlerType; procedure TCustomForm.AddHandler(HandlerType: TFormHandlerType;
const Handler: TMethod; AsLast: Boolean); const Handler: TMethod; AsLast: Boolean);
begin begin

View File

@ -32,6 +32,9 @@ begin
FItems.FMenu := Self; FItems.FMenu := Self;
FImageChangeLink := TChangeLink.Create; FImageChangeLink := TChangeLink.Create;
FImageChangeLink.OnChange := @ImageListChange; FImageChangeLink.OnChange := @ImageListChange;
FBidiMode := bdLeftToRight;
FParentBidiMode := True;
ParentBidiModeChanged(AOwner);
Inherited Create(AOwner); Inherited Create(AOwner);
end; end;
@ -46,6 +49,55 @@ begin
FImages:=AValue; FImages:=AValue;
end; end;
procedure TMenu.SetBidiMode(const AValue: TBidiMode);
begin
if FBidiMode=AValue then exit;
FBidiMode:=AValue;
FParentBiDiMode := False;
if not (csLoading in ComponentState) then
BidiModeChanged;
end;
procedure TMenu.SetParentBidiMode(const AValue: Boolean);
begin
if FParentBiDiMode = AValue then exit;
FParentBiDiMode := AValue;
if not (csLoading in ComponentState) then
ParentBidiModeChanged;
end;
procedure TMenu.CMParentBiDiModeChanged(var Message: TLMessage);
begin
ParentBidiModeChanged;
end;
procedure TMenu.BidiModeChanged;
begin
if HandleAllocated then
TWSMenuClass(WidgetSetClass).BiDiModeChanged(Self);
end;
procedure TMenu.ParentBidiModeChanged(AOwner: TComponent);
begin
if FParentBidiMode then
begin
//Take the value from the Owner
//i can not use parent because TPopupMenu.Parent = nil
if (AOwner<>nil)
and (AOwner is TCustomForm)
and not (csDestroying in AOwner.ComponentState) then
begin
BiDiMode := TCustomForm(AOwner).BiDiMode;
FParentBiDiMode := True;
end;
end;
end;
procedure TMenu.ParentBidiModeChanged;
begin
ParentBidiModeChanged(Owner);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
procedure TMenu.SetParent(const AValue: TComponent); procedure TMenu.SetParent(const AValue: TComponent);
@ -57,7 +109,7 @@ begin
if (FParent=nil) and (Items<>nil) and Items.HandleAllocated then begin if (FParent=nil) and (Items<>nil) and Items.HandleAllocated then begin
// disconnect from form // disconnect from form
DestroyHandle; DestroyHandle;
end; end
end; end;
procedure TMenu.ImageListChange(Sender: TObject); procedure TMenu.ImageListChange(Sender: TObject);
@ -270,6 +322,11 @@ begin
end; end;
end; end;
function TMenu.IsBiDiModeStored: boolean;
begin
Result := not FParentBidiMode;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TMenu.IsRightToLeft Function: TMenu.IsRightToLeft
Params: Params:
@ -279,8 +336,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TMenu.IsRightToLeft : Boolean; function TMenu.IsRightToLeft : Boolean;
Begin Begin
//TODO: Make sure it should return FALSE!!!!!!!!!! Result := BidiMode <> bdLeftToRight;
Result := False;
end; end;
// included by menus.pp // included by menus.pp

View File

@ -531,6 +531,20 @@ begin
Result := Item.FMenu; Result := Item.FMenu;
end; end;
{------------------------------------------------------------------------------
Function: TMenuItem.GetIsRightToLeft
Returns: Get IsRightToLeft value from Menu
------------------------------------------------------------------------------}
function TMenuItem.GetIsRightToLeft: Boolean;
var
LMenu:TMenu;
begin
LMenu := GetParentMenu;
Result := (LMenu <> nil) and (LMenu.IsRightToLeft);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TMenuItem.HandleAllocated Function: TMenuItem.HandleAllocated
Params: None Params: None

View File

@ -809,7 +809,6 @@ Var
procedure HandleSpinEditChange(ASpinEdit: TCustomFloatSpinEdit); procedure HandleSpinEditChange(ASpinEdit: TCustomFloatSpinEdit);
var var
lWindowInfo: PWindowInfo; lWindowInfo: PWindowInfo;
NewValue: single;
begin begin
lWindowInfo := GetWindowInfo(ASpinEdit.Handle); lWindowInfo := GetWindowInfo(ASpinEdit.Handle);
if lWindowInfo = @DefaultWindowInfo then exit; if lWindowInfo = @DefaultWindowInfo then exit;

View File

@ -493,6 +493,8 @@ begin
begin begin
AWinControl := TWinControl(AMenu.Owner); AWinControl := TWinControl(AMenu.Owner);
Windows.SetMenu(AWinControl.Handle, AMenu.Handle); Windows.SetMenu(AWinControl.Handle, AMenu.Handle);
//Set the right order menu after attach the menu
SetMenuFlag(AMenu.Handle, MFT_RIGHTORDER or MFT_RIGHTJUSTIFY, AMenu.IsRightToLeft);
AddToChangedMenus(AWinControl.Handle); AddToChangedMenus(AWinControl.Handle);
end; end;
end; end;

View File

@ -108,6 +108,7 @@ procedure AddToChangedMenus(Window: HWnd);
procedure RedrawMenus; procedure RedrawMenus;
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean; function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
function GetControlText(AHandle: HWND): string; function GetControlText(AHandle: HWND): string;
procedure SetMenuFlag(const Menu:HMenu; Flag: Integer; Value: boolean);
type type
PDisableWindowsInfo = ^TDisableWindowsInfo; PDisableWindowsInfo = ^TDisableWindowsInfo;
@ -1103,6 +1104,28 @@ begin
ChangedMenus.Clear; ChangedMenus.Clear;
end; end;
{------------------------------------------------------------------------------
Method: SetMenuFlags
Returns: Nothing
Change the menu flags for handle of TMenuItem or TMenu,
added for BidiMode Menus
------------------------------------------------------------------------------}
procedure SetMenuFlag(const Menu:HMenu; Flag: Integer; Value: boolean);
var
MenuInfo: MENUITEMINFO;
begin
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
MenuInfo.cbSize := SizeOf(MENUITEMINFO);
MenuInfo.fMask := MIIM_FTYPE;
GetMenuItemInfo(Menu, 0, True, @MenuInfo);
if Value then
MenuInfo.fType := MenuInfo.fType or Flag
else
MenuInfo.fType := MenuInfo.fType and not Flag;
SetMenuItemInfo(Menu, 0, True, @MenuInfo);
end;
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean; function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
var var
textSize: Windows.SIZE; textSize: Windows.SIZE;

View File

@ -74,6 +74,7 @@ type
class procedure AddControl(const AControl: TControl); override; class procedure AddControl(const AControl: TControl); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetBiDiMode(const AWinControl: TWinControl; const ABiDiMode: TBiDiMode); override;
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override; class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override; class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl; class procedure SetChildZPosition(const AWinControl, AChild: TWinControl;
@ -137,6 +138,10 @@ procedure FinishCreateWindow(const AWinControl: TWinControl; var Params: TCreate
const AlternateCreateWindow: boolean); const AlternateCreateWindow: boolean);
procedure WindowCreateInitBuddy(const AWinControl: TWinControl; procedure WindowCreateInitBuddy(const AWinControl: TWinControl;
var Params: TCreateWindowExParams); var Params: TCreateWindowExParams);
// Must be in win32proc but TCreateWindowExParams declared here
procedure SetStdBiDiModeParams(const AWinControl: TWinControl; var Params:TCreateWindowExParams);
procedure UpdateStdBiDiModeFlags(const AWinControl: TWinControl);
implementation implementation
@ -182,6 +187,7 @@ begin
if AWinControl is TCustomControl then if AWinControl is TCustomControl then
if TCustomControl(AWinControl).BorderStyle = bsSingle then if TCustomControl(AWinControl).BorderStyle = bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE; FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
SetStdBiDiModeParams(AWinControl, Params);
{$IFDEF VerboseSizeMsg} {$IFDEF VerboseSizeMsg}
writeln('TWin32WidgetSet.CreateComponent A ',AWinControl.Name,':',AWinControl.ClassName,' ',Left,',',Top,',',Width,',',Height); writeln('TWin32WidgetSet.CreateComponent A ',AWinControl.Name,':',AWinControl.ClassName,' ',Left,',',Top,',',Width,',',Height);
{$ENDIF} {$ENDIF}
@ -280,6 +286,38 @@ begin
BuddyWindowInfo := nil; BuddyWindowInfo := nil;
end; end;
procedure SetStdBiDiModeParams(const AWinControl: TWinControl; var Params:TCreateWindowExParams);
begin
with Params do
begin
//remove old bidimode ExFlags
FlagsEx := FlagsEx and not(WS_EX_RTLREADING or WS_EX_RIGHT or WS_EX_LEFTSCROLLBAR);
if AWinControl.UseRightToLeftAlignment then
FlagsEx := FlagsEx or WS_EX_LEFTSCROLLBAR or WS_EX_RIGHT;
if AWinControl.UseRightToLeftReading then
FlagsEx := FlagsEx or WS_EX_RTLREADING;
end;
end;
procedure UpdateStdBiDiModeFlags(const AWinControl: TWinControl);
var
FlagsEx: dword;
begin
//UpdateStdBiDiModeFlags must called after form loaded when the BidiMode changed at run time
if not WSCheckHandleAllocated(AWinControl, 'UpdateStdBiDiModeFlags') then Exit;
FlagsEx := GetWindowLong(AWinControl.Handle, GWL_EXSTYLE);
FlagsEx := FlagsEx and not (WS_EX_RTLREADING or WS_EX_RIGHT or WS_EX_LEFTSCROLLBAR);
if AWinControl.UseRightToLeftAlignment then
FlagsEx := FlagsEx or WS_EX_RIGHT;
if AWinControl.UseRightToLeftReading then
FlagsEx := FlagsEx or WS_EX_RTLREADING ;
if AWinControl.UseRightToLeftScrollBar then
FlagsEx := FlagsEx or WS_EX_LEFTSCROLLBAR;
SetWindowLong(AWinControl.Handle, GWL_EXSTYLE, FlagsEx);
end;
{ TWin32WSWinControl } { TWin32WSWinControl }
class function TWin32WSWinControl.CreateHandle(const AWinControl: TWinControl; class function TWin32WSWinControl.CreateHandle(const AWinControl: TWinControl;
@ -332,6 +370,12 @@ begin
Result := false; Result := false;
end; end;
class procedure TWin32WSWinControl.SetBiDiMode(const AWinControl: TWinControl;
const ABiDiMode: TBiDiMode);
begin
UpdateStdBiDiModeFlags(AWinControl);
end;
class procedure TWin32WSWinControl.SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); class procedure TWin32WSWinControl.SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
begin begin
RecreateWnd(AWinControl); RecreateWnd(AWinControl);

View File

@ -245,14 +245,8 @@ begin
( not (csDesigning in lForm.ComponentState) and ( not (csDesigning in lForm.ComponentState) and
(lForm.ShowInTaskBar = stAlways)) then (lForm.ShowInTaskBar = stAlways)) then
Parent := 0; Parent := 0;
with Params do {BidiMode}
begin
if AWinControl.UseRightToLeftAlignment then
FlagsEx := FlagsEx or WS_EX_LEFTSCROLLBAR or WS_EX_RIGHT;
if AWinControl.UseRightToLeftReading then
FlagsEx := FlagsEx or WS_EX_RTLREADING ;
end;
end; end;
SetStdBiDiModeParams(AWinControl, Params);
// create window // create window
FinishCreateWindow(AWinControl, Params, false); FinishCreateWindow(AWinControl, Params, false);
// TODO: proper icon, for now set default icon // TODO: proper icon, for now set default icon

View File

@ -62,6 +62,7 @@ type
protected protected
public public
class function CreateHandle(const AMenu: TMenu): HMENU; override; class function CreateHandle(const AMenu: TMenu): HMENU; override;
class procedure BiDiModeChanged(const AMenu: TMenu); override;
end; end;
{ TWin32WSMainMenu } { TWin32WSMainMenu }
@ -501,7 +502,13 @@ begin
end; end;
dwTypeData := PChar(AMenuItem); dwTypeData := PChar(AMenuItem);
if AMenuItem.RadioItem then fType := fType or MFT_RADIOCHECK; if AMenuItem.RadioItem then fType := fType or MFT_RADIOCHECK;
if AMenuItem.RightJustify then fType := fType or MFT_RIGHTJUSTIFY; if (AMenuItem.GetIsRightToLeft) then
begin
fType := fType or MFT_RIGHTORDER;
//Reverse the RIGHTJUSTIFY to be left
if not AMenuItem.RightJustify then fType := fType or MFT_RIGHTJUSTIFY;
end
else if AMenuItem.RightJustify then fType := fType or MFT_RIGHTJUSTIFY;
end; end;
if dword(InsertMenuItem(ParentMenuHandle, if dword(InsertMenuItem(ParentMenuHandle,
AMenuItem.Parent.VisibleIndexOf(AMenuItem), true, @MenuInfo)) = 0 then AMenuItem.Parent.VisibleIndexOf(AMenuItem), true, @MenuInfo)) = 0 then
@ -557,6 +564,20 @@ begin
Result := CreateMenu; Result := CreateMenu;
end; end;
class procedure TWin32WSMenu.BiDiModeChanged(const AMenu: TMenu);
begin
if AMenu.HandleAllocated then
begin
SetMenuFlag(AMenu.Handle, MFT_RIGHTORDER or MFT_RIGHTJUSTIFY, AMenu.IsRightToLeft);
//TriggerFormUpdate not take TMenu, we repeate the code
if (AMenu<>nil) and (AMenu.Parent<>nil)
and (AMenu.Parent is TCustomForm)
and TCustomForm(AMenu.Parent).HandleAllocated
and not (csDestroying in AMenu.Parent.ComponentState) then
AddToChangedMenus(TCustomForm(AMenu.Parent).Handle);
end;
end;
{ TWin32WSPopupMenu } { TWin32WSPopupMenu }
class function TWin32WSPopupMenu.CreateHandle(const AMenu: TMenu): HMENU; class function TWin32WSPopupMenu.CreateHandle(const AMenu: TMenu): HMENU;
@ -568,11 +589,13 @@ class procedure TWin32WSPopupMenu.Popup(const APopupMenu: TPopupMenu; const X, Y
var var
MenuHandle: HMENU; MenuHandle: HMENU;
AppHandle: HWND; AppHandle: HWND;
const
lAlign: array[Boolean] of Word = (TPM_LEFTALIGN, TPM_RIGHTALIGN);
begin begin
MenuHandle := APopupMenu.Handle; MenuHandle := APopupMenu.Handle;
AppHandle := TWin32WidgetSet(WidgetSet).AppHandle; AppHandle := TWin32WidgetSet(WidgetSet).AppHandle;
GetWindowInfo(AppHandle)^.PopupMenu := APopupMenu; GetWindowInfo(AppHandle)^.PopupMenu := APopupMenu;
TrackPopupMenuEx(MenuHandle, TPM_LEFTALIGN or TPM_LEFTBUTTON or TPM_RIGHTBUTTON, TrackPopupMenuEx(MenuHandle, lAlign[APopupMenu.IsRightToLeft] or TPM_LEFTBUTTON or TPM_RIGHTBUTTON,
X, Y, AppHandle, Nil); X, Y, AppHandle, Nil);
end; end;

View File

@ -62,6 +62,7 @@ type
const AParams: TCreateParams): HWND; override; const AParams: TCreateParams): HWND; override;
class procedure AdaptBounds(const AWinControl: TWinControl; class procedure AdaptBounds(const AWinControl: TWinControl;
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override; var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
class procedure SetBiDiMode(const AWinControl: TWinControl; const ABiDiMode: TBiDiMode); override;
end; end;
{ TWin32WSGroupBox } { TWin32WSGroupBox }
@ -161,7 +162,6 @@ type
class function GetMaxLength(const ACustomEdit: TCustomEdit): integer; {override;} class function GetMaxLength(const ACustomEdit: TCustomEdit): integer; {override;}
class function GetText(const AWinControl: TWinControl; var AText: string): boolean; override; class function GetText(const AWinControl: TWinControl; var AText: string): boolean; override;
class procedure SetBiDiMode(const AWinControl: TWinControl; const ABiDiMode: TBiDiMode); override;
class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override; class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override;
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override; class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
@ -241,7 +241,6 @@ type
public public
class function CreateHandle(const AWinControl: TWinControl; class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override; const AParams: TCreateParams): HWND; override;
class procedure SetBiDiMode(const AWinControl: TWinControl; const ABiDiMode: TBiDiMode); override;
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override; class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
class procedure SetShortCut(const AButton: TCustomButton; const OldKey, NewKey: word); override; class procedure SetShortCut(const AButton: TCustomButton; const OldKey, NewKey: word); override;
end; end;
@ -260,6 +259,7 @@ type
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox; class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); override; const OldShortCut, NewShortCut: TShortCut); override;
class procedure SetBiDiMode(const AWinControl: TWinControl; const ABiDiMode: TBiDiMode); override;
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override; class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override;
end; end;
@ -458,6 +458,12 @@ begin
end; end;
end; end;
class procedure TWin32WSCustomGroupBox.SetBiDiMode(
const AWinControl: TWinControl; const ABiDiMode: TBiDiMode);
begin
RecreateWnd(AWinControl);
end;
{ TWin32WSCustomListBox } { TWin32WSCustomListBox }
class procedure TWin32WSCustomListBox.AdaptBounds( class procedure TWin32WSCustomListBox.AdaptBounds(
@ -887,13 +893,6 @@ begin
pClassName := 'EDIT'; pClassName := 'EDIT';
WindowTitle := StrCaption; WindowTitle := StrCaption;
Flags := Flags or ES_AUTOHSCROLL; Flags := Flags or ES_AUTOHSCROLL;
with Params do {BidiMode}
begin
if AWinControl.UseRightToLeftAlignment then
FlagsEx := FlagsEx or WS_EX_LEFTSCROLLBAR or WS_EX_RIGHT;
if AWinControl.UseRightToLeftReading then
FlagsEx := FlagsEx or WS_EX_RTLREADING ;
end;
end; end;
// create window // create window
FinishCreateWindow(AWinControl, Params, false); FinishCreateWindow(AWinControl, Params, false);
@ -925,12 +924,6 @@ begin
AText := GetControlText(AWinControl.Handle); AText := GetControlText(AWinControl.Handle);
end; end;
class procedure TWin32WSCustomEdit.SetBiDiMode(const AWinControl: TWinControl;
const ABiDiMode: TBiDiMode);
begin
RecreateWnd(AWinControl);
end;
class procedure TWin32WSCustomEdit.SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); class procedure TWin32WSCustomEdit.SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase);
const const
EditStyles: array[TEditCharCase] of integer = (0, ES_UPPERCASE, ES_LOWERCASE); EditStyles: array[TEditCharCase] of integer = (0, ES_UPPERCASE, ES_LOWERCASE);
@ -1121,11 +1114,6 @@ begin
Flags := Flags or BS_DEFPUSHBUTTON Flags := Flags or BS_DEFPUSHBUTTON
else else
Flags := Flags or BS_PUSHBUTTON; Flags := Flags or BS_PUSHBUTTON;
with Params do {BidiMode}
begin
if AWinControl.UseRightToLeftReading then
FlagsEx := FlagsEx or WS_EX_RTLREADING;
end;
pClassName := 'BUTTON'; pClassName := 'BUTTON';
WindowTitle := StrCaption; WindowTitle := StrCaption;
end; end;
@ -1134,12 +1122,6 @@ begin
Result := Params.Window; Result := Params.Window;
end; end;
class procedure TWin32WSButton.SetBiDiMode(const AWinControl: TWinControl;
const ABiDiMode: TBiDiMode);
begin
RecreateWnd(AWinControl);
end;
class procedure TWin32WSButton.SetDefault(const AButton: TCustomButton; ADefault: Boolean); class procedure TWin32WSButton.SetDefault(const AButton: TCustomButton; ADefault: Boolean);
var var
WindowStyle: dword; WindowStyle: dword;
@ -1219,6 +1201,13 @@ begin
// TODO: implement me! // TODO: implement me!
end; end;
class procedure TWin32WSCustomCheckBox.SetBiDiMode(
const AWinControl: TWinControl; const ABiDiMode: TBiDiMode);
begin
// UpdateStdBiDiModeFlags(AWinControl); not worked
RecreateWnd(AWinControl);
end;
class procedure TWin32WSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); class procedure TWin32WSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
var var
Flags: WPARAM; Flags: WPARAM;

View File

@ -189,6 +189,7 @@ type
function GetImageList: TCustomImageList; virtual; function GetImageList: TCustomImageList; virtual;
function GetParentComponent: TComponent; override; function GetParentComponent: TComponent; override;
function GetParentMenu: TMenu; virtual; function GetParentMenu: TMenu; virtual;
function GetIsRightToLeft:Boolean; virtual;
function HandleAllocated : Boolean; function HandleAllocated : Boolean;
function HasIcon: boolean; virtual; function HasIcon: boolean; virtual;
function HasParent: Boolean; override; function HasParent: Boolean; override;
@ -268,25 +269,36 @@ type
TMenu = class(TLCLComponent) TMenu = class(TLCLComponent)
private private
FBiDiMode: TBiDiMode;
FImageChangeLink: TChangeLink; FImageChangeLink: TChangeLink;
FImages: TCustomImageList; FImages: TCustomImageList;
FItems: TMenuItem; FItems: TMenuItem;
FOnChange: TMenuChangeEvent; FOnChange: TMenuChangeEvent;
FParent: TComponent; FParent: TComponent;
FParentBiDiMode: Boolean;
FShortcutHandled: boolean; FShortcutHandled: boolean;
//See TCustomForm.CMBiDiModeChanged
procedure CMParentBiDiModeChanged(var Message: TLMessage); message CM_PARENTBIDIMODECHANGED;
function IsBiDiModeStored: Boolean;
procedure ImageListChange(Sender: TObject);
procedure SetBiDiMode(const AValue: TBiDiMode);
procedure SetImages(const AValue: TCustomImageList); procedure SetImages(const AValue: TCustomImageList);
procedure SetParent(const AValue: TComponent); procedure SetParent(const AValue: TComponent);
procedure ImageListChange(Sender: TObject); procedure SetParentBiDiMode(const AValue: Boolean);
protected protected
procedure BidiModeChanged; virtual;
procedure CreateHandle; virtual; procedure CreateHandle; virtual;
procedure DoChange(Source: TMenuItem; Rebuild: Boolean); virtual; procedure DoChange(Source: TMenuItem; Rebuild: Boolean); virtual;
function GetHandle: HMENU; virtual; function GetHandle: HMENU; virtual;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override; procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
procedure MenuChanged(Sender: TObject; Source: TMenuItem; procedure MenuChanged(Sender: TObject; Source: TMenuItem;
Rebuild: Boolean); virtual; Rebuild: Boolean); virtual;
property OnChange: TMenuChangeEvent read FOnChange write FOnChange; procedure ParentBidiModeChanged;
procedure ParentBidiModeChanged(AOwner:TComponent);//used in Create constructor
procedure SetChildOrder(Child: TComponent; Order: Integer); override; procedure SetChildOrder(Child: TComponent; Order: Integer); override;
procedure UpdateItems; procedure UpdateItems;
property OnChange: TMenuChangeEvent read FOnChange write FOnChange;
public public
FCompStyle: LongInt; FCompStyle: LongInt;
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
@ -295,7 +307,7 @@ type
function FindItem(AValue: PtrInt; Kind: TFindItemKind) : TMenuItem; function FindItem(AValue: PtrInt; Kind: TFindItemKind) : TMenuItem;
function IsShortcut(var Message: TLMKey): boolean; function IsShortcut(var Message: TLMKey): boolean;
function HandleAllocated: Boolean; function HandleAllocated: Boolean;
Function IsRightToLeft: Boolean; function IsRightToLeft: Boolean; virtual;
procedure HandleNeeded; procedure HandleNeeded;
function DispatchCommand(ACommand: Word): Boolean; function DispatchCommand(ACommand: Word): Boolean;
public public
@ -303,6 +315,8 @@ type
property Parent: TComponent read FParent write SetParent; property Parent: TComponent read FParent write SetParent;
property ShortcutHandled: boolean read FShortcutHandled write FShortcutHandled; property ShortcutHandled: boolean read FShortcutHandled write FShortcutHandled;
published published
property BidiMode:TBidiMode read FBidiMode write SetBidiMode stored IsBiDiModeStored default bdLeftToRight;
property ParentBidiMode:Boolean read FParentBidiMode write SetParentBidiMode default True;
property Items: TMenuItem read FItems; property Items: TMenuItem read FItems;
property Images: TCustomImageList read FImages write SetImages; property Images: TCustomImageList read FImages write SetImages;
end; end;

View File

@ -119,6 +119,7 @@ type
published published
property Align; property Align;
property Anchors; property Anchors;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property Constraints; property Constraints;
property Ctl3D; property Ctl3D;
@ -131,6 +132,7 @@ type
property Max; property Max;
property Min; property Min;
property PageSize; property PageSize;
property ParentBidiMode;
property ParentCtl3D; property ParentCtl3D;
property ParentShowHint; property ParentShowHint;
property PopupMenu; property PopupMenu;
@ -170,6 +172,7 @@ type
property Align; property Align;
property Anchors; property Anchors;
property AutoSize; property AutoSize;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property Caption; property Caption;
property ChildSizing; property ChildSizing;
@ -184,6 +187,7 @@ type
property DragMode; property DragMode;
property Enabled; property Enabled;
property Font; property Font;
property ParentBidiMode;
property ParentColor; property ParentColor;
property ParentCtl3D; property ParentCtl3D;
property ParentFont; property ParentFont;
@ -382,6 +386,7 @@ type
property AutoCompleteText; property AutoCompleteText;
property AutoDropDown; property AutoDropDown;
property AutoSelect; property AutoSelect;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property CharCase; property CharCase;
property Color; property Color;
@ -418,6 +423,7 @@ type
property OnMouseUp; property OnMouseUp;
property OnStartDrag; property OnStartDrag;
property OnSelect; property OnSelect;
property ParentBidiMode;
property ParentColor; property ParentColor;
property ParentCtl3D; property ParentCtl3D;
property ParentFont; property ParentFont;
@ -573,6 +579,7 @@ type
published published
property Align; property Align;
property Anchors; property Anchors;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property BorderStyle; property BorderStyle;
property ClickOnSelChange; property ClickOnSelChange;
@ -612,6 +619,7 @@ type
property OnSelectionChange; property OnSelectionChange;
property OnShowHint; property OnShowHint;
property OnStartDrag; property OnStartDrag;
property ParentBidiMode;
property ParentShowHint; property ParentShowHint;
property ParentFont; property ParentFont;
property PopupMenu; property PopupMenu;
@ -903,6 +911,7 @@ type
property Alignment; property Alignment;
property Anchors; property Anchors;
property AutoSize; property AutoSize;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property BorderStyle; property BorderStyle;
property Caption; property Caption;
@ -925,6 +934,7 @@ type
property OnMouseUp; property OnMouseUp;
property OnResize; property OnResize;
property OnStartDrag; property OnStartDrag;
property ParentBidiMode;
property ParentFont; property ParentFont;
property ShowAccelChar; property ShowAccelChar;
property TabOrder; property TabOrder;
@ -999,6 +1009,7 @@ type
function ChildClassAllowed(ChildClass: TClass): boolean; override; function ChildClassAllowed(ChildClass: TClass): boolean; override;
function IsBorderSpacingInnerBorderStored: Boolean; override; function IsBorderSpacingInnerBorderStored: Boolean; override;
property ParentColor default false; property ParentColor default false;
function UseRightToLeftAlignment: Boolean; override;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
procedure ExecuteDefaultAction; override; procedure ExecuteDefaultAction; override;
@ -1108,6 +1119,7 @@ type
property AllowGrayed; property AllowGrayed;
property Anchors; property Anchors;
property AutoSize; property AutoSize;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property Caption; property Caption;
property Checked; property Checked;
@ -1138,6 +1150,7 @@ type
property ParentColor; property ParentColor;
property ParentFont; property ParentFont;
property ParentShowHint; property ParentShowHint;
property ParentBidiMode;
property PopupMenu; property PopupMenu;
property ShowHint; property ShowHint;
property State; property State;
@ -1281,6 +1294,7 @@ type
property AllowGrayed; property AllowGrayed;
property Anchors; property Anchors;
property AutoSize; property AutoSize;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property Caption; property Caption;
property Checked; property Checked;
@ -1306,6 +1320,7 @@ type
property OnMouseUp; property OnMouseUp;
property OnResize; property OnResize;
property OnStartDrag; property OnStartDrag;
property ParentBidiMode;
property ParentFont; property ParentFont;
property ParentShowHint; property ParentShowHint;
property PopupMenu; property PopupMenu;
@ -1383,6 +1398,7 @@ type
property Alignment; property Alignment;
property Anchors; property Anchors;
property AutoSize; property AutoSize;
property BidiMode;
property BorderSpacing; property BorderSpacing;
property Caption; property Caption;
property Color; property Color;
@ -1393,6 +1409,7 @@ type
property FocusControl; property FocusControl;
property Font; property Font;
property Layout; property Layout;
property ParentBidiMode;
property ParentColor; property ParentColor;
property ParentFont; property ParentFont;
property ParentShowHint; property ParentShowHint;
@ -1488,3 +1505,4 @@ end.

View File

@ -70,6 +70,7 @@ type
TWSMenuClass = class of TWSMenu; TWSMenuClass = class of TWSMenu;
TWSMenu = class(TWSLCLComponent) TWSMenu = class(TWSLCLComponent)
class function CreateHandle(const AMenu: TMenu): HMENU; virtual; class function CreateHandle(const AMenu: TMenu): HMENU; virtual;
class procedure BiDiModeChanged(const AMenu: TMenu); virtual;
end; end;
{ TWSMainMenu } { TWSMainMenu }
@ -146,6 +147,10 @@ begin
Result := 0; Result := 0;
end; end;
class procedure TWSMenu.BiDiModeChanged(const AMenu: TMenu);
begin
end;
{ TWSPopupMenu } { TWSPopupMenu }
class procedure TWSPopupMenu.Popup(const APopupMenu: TPopupMenu; const X, Y: integer); class procedure TWSPopupMenu.Popup(const APopupMenu: TPopupMenu; const X, Y: integer);
@ -163,4 +168,4 @@ initialization
// RegisterWSComponent(TMainMenu, TWSMainMenu); // RegisterWSComponent(TMainMenu, TWSMainMenu);
// RegisterWSComponent(TPopupMenu, TWSPopupMenu); // RegisterWSComponent(TPopupMenu, TWSPopupMenu);
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
end. end.