mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-07 09:17:19 +01:00
Show radiobutton, if TMenuItem.RadioItem is checked (issue #1377)
git-svn-id: trunk@8032 -
This commit is contained in:
parent
da78e6e7a4
commit
34bd4ff3a5
@ -539,11 +539,6 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TWidgetSet.RadioMenuItemGroup(hndMenu: HMENU; bRadio: Boolean): Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TWidgetSet.RegroupMenuItem(hndMenu: HMENU; GroupIndex: Integer) : Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
|
||||
@ -365,11 +365,6 @@ begin
|
||||
Result := WidgetSet.RadialPieWithAngles(DC, X,Y,Width,Height,Angle1,Angle2);
|
||||
end;
|
||||
|
||||
function RadioMenuItemGroup(hndMenu: HMENU; bRadio: Boolean): Boolean;
|
||||
begin
|
||||
Result := WidgetSet.RadioMenuItemGroup(hndMenu,bRadio);
|
||||
end;
|
||||
|
||||
function RegroupMenuItem(hndMenu: HMENU; GroupIndex: integer) : Boolean;
|
||||
begin
|
||||
Result := WidgetSet.RegroupMenuItem(hndMenu,GroupIndex);
|
||||
|
||||
@ -102,7 +102,6 @@ function RadialArc(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; {$
|
||||
function RadialChord(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function RadialPie(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function RadialPieWithAngles(DC: HDC; X,Y,Width,Height,Angle1,Angle2: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function RadioMenuItemGroup(hndMenu: HMENU; bRadio: Boolean): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function RegroupMenuItem(hndMenu: HMENU; GroupIndex: integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function ReleaseDesignerDC(hWnd: HWND; DC: HDC): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function ReplaceBitmapMask(var Image, Mask: HBitmap; NewMask: HBitmap): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
||||
@ -1013,7 +1013,7 @@ begin
|
||||
end;
|
||||
if (FParent <> nil) and not (csReading in ComponentState)
|
||||
and (HandleAllocated) then
|
||||
RadioMenuItemGroup(Handle,FRadioItem);
|
||||
TWSMenuItemClass(WidgetSetClass).SetRadioItem(Self, AValue);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -715,12 +715,6 @@ begin
|
||||
Result:=inherited RadialPie(DC, x, y, width, height, sx, sy, ex, ey);
|
||||
end;
|
||||
|
||||
function TCarbonWidgetSet.RadioMenuItemGroup(hndMenu: HMENU; bRadio: Boolean
|
||||
): Boolean;
|
||||
begin
|
||||
Result:=inherited RadioMenuItemGroup(hndMenu, bRadio);
|
||||
end;
|
||||
|
||||
function TCarbonWidgetSet.RealizePalette(DC: HDC): Cardinal;
|
||||
begin
|
||||
Result:=inherited RealizePalette(DC);
|
||||
|
||||
@ -50,6 +50,7 @@ type
|
||||
class procedure SetVisible(const AMenuItem: TMenuItem; const Visible: boolean); override;
|
||||
class function SetCheck(const AMenuItem: TMenuItem; const Checked: boolean): boolean; override;
|
||||
class function SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean; override;
|
||||
class function SetRadioItem(const AMenuItem: TMenuItem; const RadioItem: boolean): boolean; override;
|
||||
class function SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean; override;
|
||||
end;
|
||||
|
||||
@ -225,6 +226,13 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TGtkWSMenuItem.SetRadioItem(const AMenuItem: TMenuItem;
|
||||
const RadioItem: boolean): boolean;
|
||||
begin
|
||||
{TODO: cleanup}
|
||||
Result:=TGTKWidgetSet(WidgetSet).RadioMenuItemGroup(AMenuItem.Handle, RadioItem);
|
||||
end;
|
||||
|
||||
function TGtkWSMenuItem.SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean;
|
||||
var
|
||||
MenuItemWidget: PGtkMenuItem;
|
||||
|
||||
@ -53,8 +53,8 @@ type
|
||||
class procedure SetShortCut(const AMenuItem: TMenuItem; const OldShortCut, NewShortCut: TShortCut); override;
|
||||
class function SetCheck(const AMenuItem: TMenuItem; const Checked: boolean): boolean; override;
|
||||
class function SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean; override;
|
||||
class function SetRadioItem(const AMenuItem: TMenuItem; const RadioItem: boolean): boolean; override;
|
||||
class function SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean; override;
|
||||
|
||||
end;
|
||||
|
||||
{ TWin32WSMenu }
|
||||
@ -101,6 +101,23 @@ begin
|
||||
AddToChangedMenus(TCustomForm(lMenu.Parent).Handle);
|
||||
end;
|
||||
|
||||
function ChangeMenuFlag(const AMenuItem: TMenuItem; Flag: Integer; Value: boolean): boolean;
|
||||
var
|
||||
MenuInfo: MENUITEMINFO;
|
||||
begin
|
||||
MenuInfo.cbSize := sizeof(MenuInfo);
|
||||
MenuInfo.fMask := MIIM_TYPE;
|
||||
MenuInfo.dwTypeData := nil; // don't retrieve caption
|
||||
GetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, false, @MenuInfo);
|
||||
if Value then
|
||||
MenuInfo.fType := MenuInfo.fType or Flag
|
||||
else
|
||||
MenuInfo.fType := MenuInfo.fType and (not Flag);
|
||||
MenuInfo.dwTypeData := LPSTR(AMenuItem.Caption);
|
||||
Result := SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, false, @MenuInfo);
|
||||
TriggerFormUpdate(AMenuItem);
|
||||
end;
|
||||
|
||||
{ TWin32WSMenuItem }
|
||||
|
||||
procedure UpdateCaption(const AMenuItem: TMenuItem; ACaption: String);
|
||||
@ -243,6 +260,7 @@ begin
|
||||
dwTypeData:=nil;
|
||||
cch:=0;
|
||||
end;
|
||||
if AMenuItem.RadioItem then fType := fType or MFT_RADIOCHECK;
|
||||
if AMenuItem.RightJustify then fType := fType or MFT_RIGHTJUSTIFY;
|
||||
if AmenuItem.HasIcon then {adds the menuitem icon}
|
||||
begin
|
||||
@ -298,20 +316,20 @@ function TWin32WSMenuItem.SetCheck(const AMenuItem: TMenuItem; const Checked: bo
|
||||
begin
|
||||
Result := Windows.CheckMenuItem(aMI.Parent.Handle, aMI.Command, CF) <> DWORD($FFFFFFFF);
|
||||
end;
|
||||
|
||||
procedure InterfaceTurnSiblingsOff(aMI: TMenuItem);
|
||||
|
||||
procedure InterfaceTurnSiblingsOff(AMenuItem: TMenuItem);
|
||||
var
|
||||
aParent, aSibling: TMenuItem;
|
||||
i: integer;
|
||||
begin
|
||||
// Just check all siblings that are in the same group
|
||||
// TMenuItem.TurnSiblingsOff should have modified internal flags
|
||||
aParent := aMI.Parent;
|
||||
aParent := AMenuItem.Parent;
|
||||
if aParent <> nil then
|
||||
for i := 0 to aParent.Count-1 do
|
||||
for i := 0 to aParent.Count-1 do
|
||||
begin
|
||||
aSibling := aParent.Items[i];
|
||||
if (aSibling <> aMI) and aSibling.RadioItem and (aSibling.GroupIndex=aMI.GroupIndex) then
|
||||
if (aSibling <> AMenuItem) and aSibling.RadioItem and (aSibling.GroupIndex=AMenuItem.GroupIndex) then
|
||||
doCheckMenuItem(aParent[i], MF_UNCHECKED or MF_BYCOMMAND);
|
||||
end;
|
||||
end;
|
||||
@ -339,18 +357,35 @@ begin
|
||||
TriggerFormUpdate(AMenuItem);
|
||||
end;
|
||||
|
||||
function TWin32WSMenuItem.SetRadioItem(const AMenuItem: TMenuItem;
|
||||
const RadioItem: boolean): boolean;
|
||||
var
|
||||
AParent, ASibling: TMenuItem;
|
||||
i: integer;
|
||||
begin
|
||||
// Change all siblings that are in the same group
|
||||
AParent := AMenuItem.Parent;
|
||||
if AParent <> nil then begin
|
||||
Result := True;
|
||||
for i := 0 to AParent.Count-1 do
|
||||
begin
|
||||
ASibling := AParent.Items[i];
|
||||
if (AMenuItem.GroupIndex<>0) and
|
||||
(ASibling.GroupIndex=AMenuItem.GroupIndex) then begin
|
||||
Result := Result and ChangeMenuFlag(ASibling, MFT_RADIOCHECK, RadioItem);
|
||||
// make sure siblings have same state as the LCL has set them
|
||||
Result := Result and SetCheck(ASibling, ASibling.Checked);
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else Result := False;
|
||||
end;
|
||||
|
||||
function TWin32WSMenuItem.SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean;
|
||||
var
|
||||
MenuInfo: MENUITEMINFO;
|
||||
begin
|
||||
MenuInfo.cbSize := sizeof(MenuInfo);
|
||||
MenuInfo.fMask := MIIM_TYPE;
|
||||
GetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, false, @MenuInfo);
|
||||
if Justified then MenuInfo.fType := MenuInfo.fType or MFT_RIGHTJUSTIFY
|
||||
else MenuInfo.fType := MenuInfo.fType and (not MFT_RIGHTJUSTIFY);
|
||||
MenuInfo.dwTypeData := LPSTR(AMenuItem.Caption);
|
||||
Result := SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, false, @MenuInfo);
|
||||
TriggerFormUpdate(AMenuItem);
|
||||
Result := ChangeMenuFlag(AMenuItem, MFT_RIGHTJUSTIFY, Justified);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
@ -60,7 +60,8 @@ type
|
||||
class procedure SetVisible(const AMenuItem: TMenuItem; const Visible: boolean); virtual;
|
||||
class function SetCheck(const AMenuItem: TMenuItem; const Checked: boolean): boolean; virtual;
|
||||
class function SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean; virtual;
|
||||
class function SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean; virtual;
|
||||
class function SetRadioItem(const AMenuItem: TMenuItem; const RadioItem: boolean): boolean; virtual;
|
||||
class function SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean; virtual;
|
||||
end;
|
||||
TWSMenuItemClass = class of TWSMenuItem;
|
||||
|
||||
@ -125,6 +126,12 @@ begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TWSMenuItem.SetRadioItem(const AMenuItem: TMenuItem;
|
||||
const RadioItem: boolean): boolean;
|
||||
begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TWSMenuItem.SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean;
|
||||
begin
|
||||
Result := false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user