From 1b335b08eb4347765d9f3bed041b3552d7656a99 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 30 Dec 2008 13:17:45 +0000 Subject: [PATCH] IDE: build modes: implemented move up/down git-svn-id: trunk@17996 - --- ide/compileroptions.pp | 42 ++++--- ide/compileroptionsdlg.pp | 2 +- ide/compoptcondpropsdlg.pas | 31 +++-- ide/frames/options_compiler_buildmodes.lfm | 12 +- ide/frames/options_compiler_buildmodes.lrs | 73 ++++++------ ide/frames/options_compiler_buildmodes.pas | 114 ++++++++++++++++++- ide/frames/options_compiler_conditionals.lfm | 4 +- ide/frames/options_compiler_conditionals.lrs | 4 +- ide/frames/options_compiler_conditionals.pas | 13 ++- ideintf/projectintf.pas | 12 +- 10 files changed, 231 insertions(+), 76 deletions(-) diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index da48f183b9..bd00fb8cd6 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -55,8 +55,8 @@ type TIDEBuildMode = class(TLazBuildMode) protected procedure SetIdentifier(const AValue: string); override; - procedure SetLocalizedName(const AValue: string); override; - procedure SetLocalizedValues(const AValue: TStrings); override; + procedure SetDescription(const AValue: string); override; + procedure SetValueDescriptions(const AValue: TStrings); override; procedure SetValues(const AValue: TStrings); override; public constructor Create; @@ -3258,16 +3258,16 @@ begin FIdentifier:=AValue; end; -procedure TIDEBuildMode.SetLocalizedName(const AValue: string); +procedure TIDEBuildMode.SetDescription(const AValue: string); begin - if FLocalizedName=AValue then exit; - FLocalizedName:=AValue; + if FDescription=AValue then exit; + FDescription:=AValue; end; -procedure TIDEBuildMode.SetLocalizedValues(const AValue: TStrings); +procedure TIDEBuildMode.SetValueDescriptions(const AValue: TStrings); begin - if FLocalizedValues=AValue then exit; - FLocalizedValues.Assign(AValue); + if FValueDescriptions=AValue then exit; + FValueDescriptions.Assign(AValue); end; procedure TIDEBuildMode.SetValues(const AValue: TStrings); @@ -3279,14 +3279,16 @@ end; constructor TIDEBuildMode.Create; begin FValues:=TStringList.Create; - FLocalizedValues:=TStringList.Create; + FValueDescriptions:=TStringList.Create; FDefaultValue:=TCompOptConditionals.Create(BuildModeSet.Evaluator); + FDefaultValue.Root.NodeType:=cocntAddValue; + FDefaultValue.Root.ValueType:=cocvtNone; end; destructor TIDEBuildMode.Destroy; begin FreeAndNil(FValues); - FreeAndNil(FLocalizedValues); + FreeAndNil(FValueDescriptions); FreeAndNil(FDefaultValue); inherited Destroy; end; @@ -3295,8 +3297,8 @@ procedure TIDEBuildMode.Assign(Source: TLazBuildMode); begin FIdentifier:=Source.Identifier; FDefaultValue.Assign(Source.DefaultValue); - FLocalizedName:=Source.LocalizedName; - FLocalizedValues.Assign(Source.LocalizedValues); + FDescription:=Source.Description; + FValueDescriptions.Assign(Source.ValueDescriptions); FValues.Assign(Source.Values); end; @@ -3304,16 +3306,26 @@ procedure TIDEBuildMode.LoadFromXMLConfig(AXMLConfig: TXMLConfig; const Path: string; DoSwitchPathDelims: boolean); begin FIdentifier:=AXMLConfig.GetValue(Path+'Identifier/Value',''); + if not IsValidIdent(FIdentifier) then FIdentifier:=''; + FDescription:=AXMLConfig.GetValue(Path+'Description/Value',''); LoadStringList(AXMLConfig,FValues,Path+'Values/'); + LoadStringList(AXMLConfig,FValueDescriptions,Path+'ValueDescriptions/'); TCompOptConditionals(FDefaultValue).LoadFromXMLConfig(AXMLConfig,Path+'DefaultValue', DoSwitchPathDelims); + + while ValueDescriptions.Count>Values.Count do + ValueDescriptions.Delete(ValueDescriptions.Count-1); + while ValueDescriptions.CountmrYes + then exit; + BuildModes.Delete(i); + ModesListBox.Items.Delete(i); + if i=ModesListBox.Items.Count then + dec(i); + ModesListBox.ItemIndex:=i; +end; + +procedure TCompOptBuildModesFrame.MoveDownSpeedButtonClick(Sender: TObject); +var + i: LongInt; + BuildMode: TIDEBuildMode; +begin + if not GetSelectedBuildMode(BuildMode) then exit; + i:=ModesListBox.ItemIndex; + if i0 then begin + BuildModes.Move(i,i-1); + ModesListBox.Items.Move(i,i-1); + ModesListBox.ItemIndex:=i-1; + end; +end; + procedure TCompOptBuildModesFrame.SetBuildModes(const AValue: TIDEBuildModes); begin if FBuildModes=AValue then exit; @@ -71,24 +127,70 @@ begin end; procedure TCompOptBuildModesFrame.UpdateModes; +var + i: Integer; begin - + ModesListBox.Items.BeginUpdate; + ModesListBox.Items.Clear; + if BuildModes<>nil then begin + for i:=0 to BuildModes.Count-1 do begin + ModesListBox.Items.Add(BuildModes.Items[i].Identifier); + end; + end; + ModesListBox.Items.EndUpdate; UpdateValues; + UpdateButtons; end; procedure TCompOptBuildModesFrame.UpdateValues; +var + BuildMode: TIDEBuildMode; + i: Integer; begin + if not GetSelectedBuildMode(BuildMode) then exit; + ValuesStringGrid.ColCount:=2; + ValuesStringGrid.FixedCols:=0; + ValuesStringGrid.RowCount:=BuildMode.Values.Count+1; + ValuesStringGrid.FixedRows:=1; + ValuesStringGrid.Cells[0,0]:='Value'; + ValuesStringGrid.Cells[1,0]:='Description'; + ValuesStringGrid.ColWidths[0]:=90; + ValuesStringGrid.ColWidths[1]:=120; + for i:=0 to BuildMode.Values.Count-1 do begin + ValuesStringGrid.Cells[0,i+1]:=BuildMode.Values[i]; + if inil; + DeleteSpeedButton.Enabled:=(ModesListBox.ItemIndex>=0); + MoveDownSpeedButton.Enabled:=(ModesListBox.ItemIndex>=0) + and (ModesListBox.ItemIndex0); +end; +function TCompOptBuildModesFrame.GetSelectedBuildMode( + out BuildMode: TIDEBuildMode): boolean; +begin + BuildMode:=nil; + if BuildModes=nil then exit(false); + if ModesListBox.ItemIndex<0 then exit(false); + BuildMode:=TIDEBuildMode(BuildModes.Items[ModesListBox.ItemIndex]); + Result:=true; end; constructor TCompOptBuildModesFrame.Create(TheOwner: TComponent); diff --git a/ide/frames/options_compiler_conditionals.lfm b/ide/frames/options_compiler_conditionals.lfm index d469c21212..9274c3fc1d 100644 --- a/ide/frames/options_compiler_conditionals.lfm +++ b/ide/frames/options_compiler_conditionals.lfm @@ -8,8 +8,8 @@ object CompOptsConditionalsFrame: TCompOptsConditionalsFrame Ctl3D = False TabOrder = 0 Visible = False - DesignLeft = 434 - DesignTop = 329 + DesignLeft = 439 + DesignTop = 353 object COCTreeView: TTreeView Left = 0 Height = 166 diff --git a/ide/frames/options_compiler_conditionals.lrs b/ide/frames/options_compiler_conditionals.lrs index 6f8d51aaa0..3e2174a019 100644 --- a/ide/frames/options_compiler_conditionals.lrs +++ b/ide/frames/options_compiler_conditionals.lrs @@ -1,8 +1,10 @@ +{ This is an automatically generated lazarus resource file } + LazarusResources.Add('TCompOptsConditionalsFrame','FORMDATA',[ 'TPF0'#26'TCompOptsConditionalsFrame'#25'CompOptsConditionalsFrame'#4'Left'#2 +#0#6'Height'#3#170#0#3'Top'#2#0#5'Width'#3#129#1#12'ClientHeight'#3#166#0#11 +'ClientWidth'#3'}'#1#5'Ctl3D'#8#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#3 - +#178#1#9'DesignTop'#3'I'#1#0#9'TTreeView'#11'COCTreeView'#4'Left'#2#0#6'Heig' + +#183#1#9'DesignTop'#3'a'#1#0#9'TTreeView'#11'COCTreeView'#4'Left'#2#0#6'Heig' +'ht'#3#166#0#3'Top'#2#0#5'Width'#3'}'#1#5'Align'#7#8'alClient'#10'AutoExpand' +#9#5'Ctl3D'#8#17'DefaultItemHeight'#2#19#9'PopupMenu'#7#12'COCPopupMenu'#8'R' +'eadOnly'#9#9'RowSelect'#9#8'TabOrder'#2#0#7'Options'#11#13'tvoAutoExpand'#17 diff --git a/ide/frames/options_compiler_conditionals.pas b/ide/frames/options_compiler_conditionals.pas index 3b4d134350..0426735ccb 100644 --- a/ide/frames/options_compiler_conditionals.pas +++ b/ide/frames/options_compiler_conditionals.pas @@ -56,8 +56,10 @@ type procedure MoveUpMenuItemClick(Sender: TObject); procedure PropertiesMenuItemClick(Sender: TObject); private + FAllowedValueTypes: TCOCValueTypes; FConditionals: TCompOptConditionals; FNodeTypeImageIDs: array[TCOCNodeType] of integer; + procedure SetAllowedValueTypes(const AValue: TCOCValueTypes); procedure SetConditionals(const AValue: TCompOptConditionals); procedure FillTreeView; procedure ConsistencyCheck; @@ -68,6 +70,7 @@ type public constructor Create(TheOwner: TComponent); override; property Conditionals: TCompOptConditionals read FConditionals write SetConditionals; + property AllowedValueTypes: TCOCValueTypes read FAllowedValueTypes write SetAllowedValueTypes; end; implementation @@ -188,7 +191,7 @@ var TVNode: TTreeNode; begin if not GetSelectedNode(COCNode,TVNode,false) then exit; - EditCompOptCondProperties(COCNode); + EditCompOptCondProperties(COCNode,AllowedValueTypes); TVNode.Text:=NodeToCaption(COCNode); TVNode.ImageIndex:=FNodeTypeImageIDs[COCNode.NodeType]; TVNode.SelectedIndex:=TVNode.ImageIndex; @@ -202,6 +205,13 @@ begin FillTreeView; end; +procedure TCompOptsConditionalsFrame.SetAllowedValueTypes( + const AValue: TCOCValueTypes); +begin + if FAllowedValueTypes=AValue then exit; + FAllowedValueTypes:=AValue; +end; + procedure TCompOptsConditionalsFrame.FillTreeView; procedure Add(COCNode: TCompOptCondNode; ParentTVNode: TTreeNode); @@ -363,6 +373,7 @@ var nt: TCOCNodeType; begin inherited Create(TheOwner); + FAllowedValueTypes:=[low(TCOCValueType)..high(TCOCValueType)]; COCTreeView.Images := IDEImages.Images_24; diff --git a/ideintf/projectintf.pas b/ideintf/projectintf.pas index 0d404306e3..14ff5416be 100644 --- a/ideintf/projectintf.pas +++ b/ideintf/projectintf.pas @@ -154,19 +154,19 @@ type protected FDefaultValue: TLazCompOptConditionals; FIdentifier: string; - FLocalizedName: string; - FLocalizedValues: TStrings; + FDescription: string; + FValueDescriptions: TStrings; FValues: TStrings; procedure SetIdentifier(const AValue: string); virtual; abstract; - procedure SetLocalizedName(const AValue: string); virtual; abstract; - procedure SetLocalizedValues(const AValue: TStrings); virtual; abstract; + procedure SetDescription(const AValue: string); virtual; abstract; + procedure SetValueDescriptions(const AValue: TStrings); virtual; abstract; procedure SetValues(const AValue: TStrings); virtual; abstract; public procedure Assign(Source: TLazBuildMode); virtual; abstract; property Identifier: string read FIdentifier write SetIdentifier; - property LocalizedName: string read FLocalizedName write SetLocalizedName; + property Description: string read FDescription write SetDescription; property Values: TStrings read FValues write SetValues; - property LocalizedValues: TStrings read FLocalizedValues write SetLocalizedValues; + property ValueDescriptions: TStrings read FValueDescriptions write SetValueDescriptions; property DefaultValue: TLazCompOptConditionals read FDefaultValue; end;