Menu designer: Remove useless info about RadioItems, prevent the GUI position jumping with long MenuItem names.

git-svn-id: trunk@54373 -
This commit is contained in:
juha 2017-03-08 20:33:55 +00:00
parent 0a7346f015
commit 13a7fe6856
4 changed files with 86 additions and 106 deletions

View File

@ -15,6 +15,8 @@ uses
type
TByteArray = Array of Byte;
{ TShadowItemBase }
TShadowItemBase = class(TCustomControl)
@ -32,8 +34,7 @@ type
TShadowBoxBase = class(TCustomControl)
private
function GetHasRadioItems: boolean;
function GetRadioGroupsString: string;
function GetRadioGroupValues: TByteArray;
protected
FLevel: integer;
FLastRIValue: boolean;
@ -49,8 +50,7 @@ type
property ParentMenuItem: TMenuItem read FParentMenuItem;
property ShadowList: TFPList read FShadowList;
property ShadowCount: integer read GetShadowCount;
property HasRadioItems: boolean read GetHasRadioItems;
property RadioGroupsString: string read GetRadioGroupsString;
property RadioGroupValues: TByteArray read GetRadioGroupValues;
end;
{ TShadowMenuBase }
@ -141,18 +141,7 @@ begin
inherited Destroy;
end;
function TShadowBoxBase.GetHasRadioItems: boolean;
var
p: pointer;
si: TShadowItemBase absolute p;
begin
for p in FShadowList do
if si.RealItem.RadioItem then
Exit(True);
Result:=False;
end;
function TShadowBoxBase.GetRadioGroupsString: string;
function TShadowBoxBase.GetRadioGroupValues: TByteArray;
var
rgSet: set of byte = [];
g: byte;
@ -160,18 +149,19 @@ var
si: TShadowItemBase absolute p;
mi: TMenuItem;
begin
Result:='';
for p in FShadowList do begin
SetLength(Result, 0);
for p in FShadowList do
begin
mi:=si.RealItem;
if mi.RadioItem then begin
g:=mi.GroupIndex;
if not (g in rgSet) then begin
Include(rgSet, g);
AppendStr(Result, IntToStr(g) + ', ');
SetLength(Result, Length(Result)+1);
Result[Length(Result)-1] := g;
end;
end;
end;
Delete(Result, Pred(Length(Result)), 2);
end;
function TShadowBoxBase.GetShadowCount: integer;

View File

@ -20,26 +20,26 @@ object MenuDesignerForm: TMenuDesignerForm
Left = 0
Height = 400
Top = 0
Width = 204
Width = 219
Align = alLeft
AutoSize = True
ClientHeight = 400
ClientWidth = 204
ClientWidth = 219
Constraints.MinHeight = 345
Constraints.MinWidth = 204
TabOrder = 0
object ButtonsGroupBox: TGroupBox
AnchorSideRight.Side = asrBottom
Left = 7
Height = 98
Height = 104
Top = 7
Width = 190
Width = 205
Align = alTop
AutoSize = True
BorderSpacing.Around = 6
Caption = 'ButtonsGroupBox'
ClientHeight = 78
ClientWidth = 186
ClientWidth = 201
TabOrder = 0
object MoveItemUpButton: TSpeedButton
AnchorSideLeft.Control = ButtonsGroupBox
@ -141,15 +141,15 @@ object MenuDesignerForm: TMenuDesignerForm
object StatisticsGroupBox: TGroupBox
AnchorSideRight.Side = asrBottom
Left = 7
Height = 137
Top = 111
Width = 190
Height = 138
Top = 117
Width = 205
Align = alTop
AutoSize = True
BorderSpacing.Around = 6
Caption = 'StatisticsGroupBox'
ClientHeight = 117
ClientWidth = 186
ClientHeight = 112
ClientWidth = 201
Color = clBtnFace
ParentColor = False
TabOrder = 1
@ -159,9 +159,9 @@ object MenuDesignerForm: TMenuDesignerForm
AnchorSideRight.Control = StatisticsGroupBox
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Height = 14
Top = 6
Width = 168
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Around = 6
@ -178,9 +178,9 @@ object MenuDesignerForm: TMenuDesignerForm
AnchorSideRight.Control = StatisticsGroupBox
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Top = 27
Width = 168
Height = 14
Top = 26
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Around = 6
@ -197,9 +197,9 @@ object MenuDesignerForm: TMenuDesignerForm
AnchorSideRight.Control = StatisticsGroupBox
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Top = 48
Width = 168
Height = 14
Top = 46
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Around = 6
@ -216,9 +216,9 @@ object MenuDesignerForm: TMenuDesignerForm
AnchorSideRight.Control = StatisticsGroupBox
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Top = 69
Width = 168
Height = 14
Top = 66
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Around = 6
@ -235,9 +235,9 @@ object MenuDesignerForm: TMenuDesignerForm
AnchorSideRight.Control = StatisticsGroupBox
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Top = 90
Width = 168
Height = 14
Top = 86
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Bottom = 6
@ -266,33 +266,32 @@ object MenuDesignerForm: TMenuDesignerForm
OnClick = HelpButtonClick
TabOrder = 2
end
object SubmenuGroupBox: TGroupBox
object RadioItemGroupBox: TGroupBox
AnchorSideLeft.Control = LeftPanel
AnchorSideTop.Control = StatisticsGroupBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = LeftPanel
AnchorSideRight.Side = asrBottom
Left = 7
Height = 64
Top = 254
Width = 190
Height = 72
Top = 261
Width = 205
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'SubmenuGroupBox'
ClientHeight = 44
ClientWidth = 186
Caption = 'RadioItemGroupBox'
ClientHeight = 46
ClientWidth = 201
TabOrder = 3
object GroupIndexLabel: TLabel
AnchorSideLeft.Control = SubmenuGroupBox
AnchorSideTop.Control = RadioGroupsLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SubmenuGroupBox
AnchorSideLeft.Control = RadioItemGroupBox
AnchorSideTop.Control = RadioItemGroupBox
AnchorSideRight.Control = RadioItemGroupBox
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Top = 27
Width = 168
Height = 14
Top = 6
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Around = 6
@ -300,14 +299,15 @@ object MenuDesignerForm: TMenuDesignerForm
ParentColor = False
end
object RadioGroupsLabel: TLabel
AnchorSideLeft.Control = SubmenuGroupBox
AnchorSideTop.Control = SubmenuGroupBox
AnchorSideRight.Control = SubmenuGroupBox
AnchorSideLeft.Control = RadioItemGroupBox
AnchorSideTop.Control = GroupIndexLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = RadioItemGroupBox
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Top = 6
Width = 168
Height = 14
Top = 26
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Around = 6

View File

@ -59,7 +59,7 @@ type
RadioGroupsLabel: TLabel;
ShortcutItemsCountLabel: TLabel;
StatisticsGroupBox: TGroupBox;
SubmenuGroupBox: TGroupBox;
RadioItemGroupBox: TGroupBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormHide(Sender: TObject);
@ -242,6 +242,7 @@ begin
Name:='MenuDesignerWindow';
Caption:=lisMenuEditorMenuEditor;
ButtonsGroupBox.Caption:=lisMenuEditorMenuItemActions;
RadioItemGroupBox.Caption:=lisMenuEditorRadioItem;
FGUIEnabled:=False;
LoadFixedButtonGlyphs;
LoadVariableButtonGlyphs(True);
@ -527,7 +528,8 @@ end;
procedure TMenuDesignerForm.DisableGUI;
begin
if FGUIEnabled then begin
if FGUIEnabled then
begin
StatisticsGroupBox.Font.Style:=[];
StatisticsGroupBox.Caption:=lisMenuEditorNoMenuSelected;
CaptionedItemsCountLabel.Caption:=Format(lisMenuEditorCaptionedItemsS,[lisMenuEditorNA]);
@ -639,44 +641,34 @@ begin
StatisticsGroupBox.Invalidate;
end;
function JoinToString(aGroups: TByteArray): String;
var
i: Integer;
begin
for i:=0 to Length(aGroups)-1 do
begin
if i>0 then
Result:=Result+', ';
Result:=Result+IntToStr(aGroups[i]);
end;
end;
procedure TMenuDesignerForm.UpdateSubmenuGroupBox(selMI: TMenuItem;
selBox: TShadowBoxBase; boxIsRoot: boolean);
var
Groups: TByteArray;
begin
if SubmenuGroupBox = nil then
Exit;
if (selMI = nil) then begin
SubmenuGroupBox.Caption:=lisMenuEditorNoMenuSelected;
RadioGroupsLabel.Caption:='';
GroupIndexLabel.Caption:='';
end
else begin
if Assigned(selMI) then
selBox.LastRIValue:=selMI.RadioItem;
if boxIsRoot then
SubmenuGroupBox.Caption:=lisMenuEditorRootMenu
else SubmenuGroupBox.Caption:=Format(lisMenuEditorSSubmenu,[selBox.ParentMenuItem.Name]);
if selMI.RadioItem then begin
GroupIndexLabel.Caption:=Format(lisMenuEditorSGroupIndexD,
[selMI.Name, selMI.GroupIndex]);
GroupIndexLabel.Enabled:=True;
end
else begin
GroupIndexLabel.Caption:=Format(lisMenuEditorSIsNotARadioitem,
[selMI.Name]);
GroupIndexLabel.Enabled:=False;
end;
if selBox.HasRadioItems then begin
RadioGroupsLabel.Caption:=Format(lisMenuEditorGroupIndexValueSS,
[selBox.RadioGroupsString]);
RadioGroupsLabel.Enabled:=True;
end
else begin
RadioGroupsLabel.Caption:=lisMenuEditorNoRadioitemsInThisMenu;
RadioGroupsLabel.Enabled:=False;
RadioGroupsLabel.Invalidate; //for some reason this seems necessary
end;
RadioItemGroupBox.Visible:=Assigned(selMI) and selMI.RadioItem;
if RadioItemGroupBox.Visible then
begin
GroupIndexLabel.Caption:=Format(lisMenuEditorGroupIndexD, [selMI.GroupIndex]);
Groups:=selBox.RadioGroupValues;
RadioGroupsLabel.Visible:=Length(Groups)>1;
if RadioGroupsLabel.Visible then
RadioGroupsLabel.Caption:=Format(lisMenuEditorGroupIndexValuesS, [JoinToString(Groups)]);
RadioItemGroupBox.Visible:=True;
end;
end;

View File

@ -52,10 +52,6 @@ resourcestring
lisChange = 'Change';
lisDelete = 'Delete';
lisBtnDelete = '&Delete';
lisMenuEditorGroupIndexValueSS = 'GroupIndex value(s): %s';
lisMenuEditorNoRadioitemsInThisMenu = 'No radioitems in this menu';
lisMenuEditorSGroupIndexD = '%s.GroupIndex: %d';
lisMenuEditorSIsNotARadioitem = '%s is not a radioitem';
lisRemove = 'Remove';
lisBtnRemove = '&Remove';
lisRename = 'Rename';
@ -67,7 +63,6 @@ resourcestring
lisDlgEdit = 'Edit ...';
lisClear = 'Clear';
lisOpen = 'Open';
lisOpenUnit = 'Open Unit';
lisSave = 'Save';
lisDlgSave = 'Save ...';
lisSaveAs = 'Save As';
@ -4872,7 +4867,9 @@ resourcestring
lisMenuEditorShortcutItemsS = 'Shortcut items: %s';
lisMenuEditorResolveSelectedConflict = 'Resolve selected conflict';
lisMenuEditorResolveShortcutConflicts = '&Resolve shortcut conflicts ...';
lisMenuEditorRootMenu = 'Root menu';
lisMenuEditorGroupIndexValuesS = 'Values in use: %s';
lisMenuEditorGroupIndexD = 'GroupIndex: %d';
lisMenuEditorRadioItem = 'RadioItem';
lisMenuEditorSavedTemplates = 'Saved templates';
lisMenuEditorSaveMenuAsATemplate = '&Save menu as a template ...';
lisMenuEditorSaveMenuAsTemplate = 'Save menu as template';
@ -5977,6 +5974,7 @@ resourcestring
dlgInsertInterface = 'Interface';
dlgInsertImplementation = 'Implementation';
dlgNoAvailableUnits = 'No available units to add.';
lisOpenUnit = 'Open Unit';
lisInsteadOfCompilePackageCreateASimpleMakefile = 'Instead of compile '
+'package create a simple Makefile.';
lisOnlyRegisterTheLazarusPackageFilesLpkDoNotBuild = 'Only register the '