IDE: started editor for conditional compiler option nodes

git-svn-id: trunk@17964 -
This commit is contained in:
mattias 2008-12-27 14:50:43 +00:00
parent 52ee00706e
commit ed41f24c10
9 changed files with 414 additions and 1 deletions

4
.gitattributes vendored
View File

@ -2481,6 +2481,10 @@ ide/componentlist.lfm svneol=native#text/pascal
ide/componentlist.lrs svneol=native#text/pascal
ide/componentlist.pas svneol=native#text/pascal
ide/componentpalette.pas svneol=native#text/pascal
ide/compoptcondpropsdlg.lfm svneol=native#text/plain
ide/compoptcondpropsdlg.lrs svneol=native#text/plain
ide/compoptcondpropsdlg.lrt svneol=native#text/plain
ide/compoptcondpropsdlg.pas svneol=native#text/plain
ide/compoptsmodes.pas svneol=native#text/plain
ide/condef.lfm svneol=native#text/plain
ide/condef.lrs svneol=native#text/pascal

145
ide/compoptcondpropsdlg.lfm Normal file
View File

@ -0,0 +1,145 @@
object CompOptCondPropsDialog: TCompOptCondPropsDialog
Left = 370
Height = 205
Top = 280
Width = 635
ActiveControl = NodeTypeComboBox
Caption = 'CompOptCondPropsDialog'
ClientHeight = 205
ClientWidth = 635
OnCreate = FormCreate
LCLVersion = '0.9.27'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 50
Top = 155
Width = 623
Align = alBottom
AutoSize = True
TabOrder = 0
ShowButtons = [pbOK, pbCancel, pbHelp]
end
object PropsGroupBox: TGroupBox
Left = 0
Height = 155
Top = 0
Width = 635
Align = alClient
Caption = 'PropsGroupBox'
ClientHeight = 136
ClientWidth = 631
Ctl3D = False
TabOrder = 1
object NodeTypeLabel: TLabel
AnchorSideLeft.Control = PropsGroupBox
AnchorSideTop.Control = NodeTypeComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 11
Width = 97
BorderSpacing.Around = 6
Caption = 'NodeTypeLabel'
ParentColor = False
end
object ValueTypeLabel: TLabel
AnchorSideLeft.Control = PropsGroupBox
AnchorSideTop.Control = ValueTypeComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 46
Width = 98
BorderSpacing.Around = 6
Caption = 'ValueTypeLabel'
ParentColor = False
end
object ValueLabel: TLabel
AnchorSideLeft.Control = PropsGroupBox
AnchorSideTop.Control = ValueEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 80
Width = 106
BorderSpacing.Around = 6
Caption = 'ValueLabel.........'
ParentColor = False
end
object NodeTypeComboBox: TComboBox
AnchorSideLeft.Control = ValueLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PropsGroupBox
AnchorSideRight.Control = PropsGroupBox
AnchorSideRight.Side = asrBottom
Left = 118
Height = 29
Top = 6
Width = 507
Anchors = [akTop, akLeft, akRight]
AutoComplete = False
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Ctl3D = False
ItemHeight = 0
ItemWidth = 0
OnEditingDone = NodeTypeComboBoxEditingDone
TabOrder = 0
Text = 'NodeTypeComboBox'
end
object ValueTypeComboBox: TComboBox
AnchorSideLeft.Control = NodeTypeComboBox
AnchorSideTop.Control = NodeTypeComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PropsGroupBox
AnchorSideRight.Side = asrBottom
Left = 118
Height = 29
Top = 41
Width = 507
Anchors = [akTop, akLeft, akRight]
AutoComplete = False
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Ctl3D = False
ItemHeight = 0
ItemWidth = 0
OnEditingDone = ValueTypeComboBoxEditingDone
TabOrder = 1
Text = 'ValueTypeComboBox'
end
object ValueEdit: TEdit
AnchorSideLeft.Control = NodeTypeComboBox
AnchorSideTop.Control = ValueTypeComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ValueButton
Left = 118
Height = 27
Top = 76
Width = 483
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
OnEditingDone = ValueEditEditingDone
TabOrder = 2
Text = 'ValueEdit'
end
object ValueButton: TButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ValueEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = PropsGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 601
Height = 29
Top = 75
Width = 24
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
TabOrder = 3
end
end
end

View File

@ -0,0 +1,53 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TCompOptCondPropsDialog','FORMDATA',[
'TPF0'#23'TCompOptCondPropsDialog'#22'CompOptCondPropsDialog'#4'Left'#3'r'#1#6
+'Height'#3#205#0#3'Top'#3#24#1#5'Width'#3'{'#2#13'ActiveControl'#7#16'NodeTy'
+'peComboBox'#7'Caption'#6#22'CompOptCondPropsDialog'#12'ClientHeight'#3#205#0
+#11'ClientWidth'#3'{'#2#8'OnCreate'#7#10'FormCreate'#10'LCLVersion'#6#6'0.9.'
+'27'#0#12'TButtonPanel'#12'ButtonPanel1'#4'Left'#2#6#6'Height'#2'2'#3'Top'#3
+#155#0#5'Width'#3'o'#2#5'Align'#7#8'alBottom'#8'AutoSize'#9#8'TabOrder'#2#0
+#11'ShowButtons'#11#4'pbOK'#8'pbCancel'#6'pbHelp'#0#0#0#9'TGroupBox'#13'Prop'
+'sGroupBox'#4'Left'#2#0#6'Height'#3#155#0#3'Top'#2#0#5'Width'#3'{'#2#5'Align'
+#7#8'alClient'#7'Caption'#6#13'PropsGroupBox'#12'ClientHeight'#3#136#0#11'Cl'
+'ientWidth'#3'w'#2#5'Ctl3D'#8#8'TabOrder'#2#1#0#6'TLabel'#13'NodeTypeLabel'
+#22'AnchorSideLeft.Control'#7#13'PropsGroupBox'#21'AnchorSideTop.Control'#7
+#16'NodeTypeComboBox'#18'AnchorSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'He'
+'ight'#2#18#3'Top'#2#11#5'Width'#2'a'#20'BorderSpacing.Around'#2#6#7'Caption'
+#6#13'NodeTypeLabel'#11'ParentColor'#8#0#0#6'TLabel'#14'ValueTypeLabel'#22'A'
+'nchorSideLeft.Control'#7#13'PropsGroupBox'#21'AnchorSideTop.Control'#7#17'V'
+'alueTypeComboBox'#18'AnchorSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'Heigh'
+'t'#2#18#3'Top'#2'.'#5'Width'#2'b'#20'BorderSpacing.Around'#2#6#7'Caption'#6
+#14'ValueTypeLabel'#11'ParentColor'#8#0#0#6'TLabel'#10'ValueLabel'#22'Anchor'
+'SideLeft.Control'#7#13'PropsGroupBox'#21'AnchorSideTop.Control'#7#9'ValueEd'
+'it'#18'AnchorSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#18#3'Top'
+#2'P'#5'Width'#2'j'#20'BorderSpacing.Around'#2#6#7'Caption'#6#19'ValueLabel.'
+'........'#11'ParentColor'#8#0#0#9'TComboBox'#16'NodeTypeComboBox'#22'Anchor'
+'SideLeft.Control'#7#10'ValueLabel'#19'AnchorSideLeft.Side'#7#9'asrBottom'#21
+'AnchorSideTop.Control'#7#13'PropsGroupBox'#23'AnchorSideRight.Control'#7#13
+'PropsGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2'v'#6'Heigh'
+'t'#2#29#3'Top'#2#6#5'Width'#3#251#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRi'
+'ght'#0#12'AutoComplete'#8#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'
+#2#6#5'Ctl3D'#8#10'ItemHeight'#2#0#9'ItemWidth'#2#0#13'OnEditingDone'#7#27'N'
+'odeTypeComboBoxEditingDone'#8'TabOrder'#2#0#4'Text'#6#16'NodeTypeComboBox'#0
+#0#9'TComboBox'#17'ValueTypeComboBox'#22'AnchorSideLeft.Control'#7#16'NodeTy'
+'peComboBox'#21'AnchorSideTop.Control'#7#16'NodeTypeComboBox'#18'AnchorSideT'
+'op.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#13'PropsGroupBox'#20
+'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2'v'#6'Height'#2#29#3'Top'#2')'
+#5'Width'#3#251#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#12'AutoCompl'
+'ete'#8#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#5'Ctl3D'#8#10
+'ItemHeight'#2#0#9'ItemWidth'#2#0#13'OnEditingDone'#7#28'ValueTypeComboBoxEd'
+'itingDone'#8'TabOrder'#2#1#4'Text'#6#17'ValueTypeComboBox'#0#0#5'TEdit'#9'V'
+'alueEdit'#22'AnchorSideLeft.Control'#7#16'NodeTypeComboBox'#21'AnchorSideTo'
+'p.Control'#7#17'ValueTypeComboBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#23
+'AnchorSideRight.Control'#7#11'ValueButton'#4'Left'#2'v'#6'Height'#2#27#3'To'
+'p'#2'L'#5'Width'#3#227#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'Au'
+'toSize'#9#17'BorderSpacing.Top'#2#6#13'OnEditingDone'#7#20'ValueEditEditing'
+'Done'#8'TabOrder'#2#2#4'Text'#6#9'ValueEdit'#0#0#7'TButton'#11'ValueButton'
+#19'AnchorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'#7#9'ValueE'
+'dit'#18'AnchorSideTop.Side'#7#9'asrCenter'#23'AnchorSideRight.Control'#7#13
+'PropsGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'#21'AnchorSideBottom.'
+'Side'#7#9'asrBottom'#4'Left'#3'Y'#2#6'Height'#2#29#3'Top'#2'K'#5'Width'#2#24
+#7'Anchors'#11#5'akTop'#7'akRight'#0#8'AutoSize'#9#19'BorderSpacing.Right'#2
+#6#7'Caption'#6#3'...'#8'TabOrder'#2#3#0#0#0#0
]);

View File

@ -0,0 +1 @@
TFORM1.CAPTION=Form1

166
ide/compoptcondpropsdlg.pas Normal file
View File

@ -0,0 +1,166 @@
{***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
}
unit CompOptCondPropsDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ButtonPanel, StdCtrls,
ProjectIntf,
LazarusIDEStrConsts;
type
{ TCompOptCondPropsDialog }
TCompOptCondPropsDialog = class(TForm)
ValueButton: TButton;
ButtonPanel1: TButtonPanel;
NodeTypeComboBox: TComboBox;
ValueTypeComboBox: TComboBox;
ValueEdit: TEdit;
NodeTypeLabel: TLabel;
ValueTypeLabel: TLabel;
ValueLabel: TLabel;
PropsGroupBox: TGroupBox;
procedure FormCreate(Sender: TObject);
procedure NodeTypeComboBoxEditingDone(Sender: TObject);
procedure ValueEditEditingDone(Sender: TObject);
procedure ValueTypeComboBoxEditingDone(Sender: TObject);
private
FNode: TCompOptCondNode;
procedure SetNode(const AValue: TCompOptCondNode);
procedure NodeChanged;
procedure NodeTypeChanged;
public
property Node: TCompOptCondNode read FNode write SetNode;
end;
function EditCompOptCondProperties(Node: TCompOptCondNode): TModalResult;
implementation
function EditCompOptCondProperties(Node: TCompOptCondNode): TModalResult;
var
CompOptCondPropsDialog: TCompOptCondPropsDialog;
begin
CompOptCondPropsDialog:=TCompOptCondPropsDialog.Create(nil);
try
CompOptCondPropsDialog.Node:=Node;
Result:=CompOptCondPropsDialog.ShowModal;
finally
CompOptCondPropsDialog.Free;
end;
end;
{ TCompOptCondPropsDialog }
procedure TCompOptCondPropsDialog.FormCreate(Sender: TObject);
var
nt: TCOCNodeType;
vt: TCOCValueType;
begin
Caption:='Properties of conditional compiler option';
NodeTypeLabel.Caption:='Type:';
ValueTypeLabel.Caption:='Action:';
ValueLabel.Caption:='Value:';
ValueTypeComboBox.Items.Clear;
NodeTypeComboBox.Items.Clear;
for nt:=Low(TCOCNodeType) to High(TCOCNodeType) do
NodeTypeComboBox.Items.Add(COCNodeTypeLocalizedName(nt));
for vt:=Low(TCOCValueType) to High(TCOCValueType) do
ValueTypeComboBox.Items.Add(COCValueTypeLocalizedName(vt));
end;
procedure TCompOptCondPropsDialog.NodeTypeComboBoxEditingDone(Sender: TObject);
begin
NodeTypeChanged;
end;
procedure TCompOptCondPropsDialog.ValueEditEditingDone(Sender: TObject);
begin
end;
procedure TCompOptCondPropsDialog.ValueTypeComboBoxEditingDone(Sender: TObject);
begin
end;
procedure TCompOptCondPropsDialog.SetNode(const AValue: TCompOptCondNode);
begin
if FNode=AValue then exit;
FNode:=AValue;
NodeChanged;
end;
procedure TCompOptCondPropsDialog.NodeChanged;
var
NodeTypeStr: String;
begin
if Node=nil then begin
NodeTypeLabel.Enabled:=false;
NodeTypeComboBox.Enabled:=false;
ValueTypeLabel.Enabled:=false;
ValueTypeComboBox.Enabled:=false;
ValueLabel.Enabled:=false;
ValueEdit.Enabled:=false;
ValueButton.Enabled:=false;
end else begin
NodeTypeStr:=COCNodeTypeLocalizedName(Node.NodeType);
NodeTypeLabel.Enabled:=true;
NodeTypeComboBox.ItemIndex:=NodeTypeComboBox.Items.IndexOf(NodeTypeStr);
NodeTypeComboBox.Text:=NodeTypeStr;
NodeTypeChanged;
ValueEdit.Text:=Node.Value;
end;
end;
procedure TCompOptCondPropsDialog.NodeTypeChanged;
var
s: String;
begin
if Node=nil then exit;
ValueTypeLabel.Enabled:=Node.NodeType in [cocntAddValue];
ValueTypeComboBox.Enabled:=ValueTypeLabel.Enabled;
s:=COCValueTypeLocalizedName(Node.ValueType);
ValueTypeComboBox.ItemIndex:=ValueTypeComboBox.Items.IndexOf(s);
ValueTypeComboBox.Text:=s;
ValueLabel.Enabled:=Node.NodeType in [cocntNone,cocntIf,
cocntIfdef,cocntIfNdef,cocntElseIf,cocntAddValue];
ValueEdit.Enabled:=ValueLabel.Enabled;
ValueButton.Enabled:=ValueLabel.Enabled;
case Node.NodeType of
cocntNone: ValueLabel.Caption:=lisResult;
cocntIf, cocntElseIf: ValueLabel.Caption:=lisExpression;
cocntIfdef, cocntIfNdef: ValueLabel.Caption:=lisCodeToolsDefsVariable;
cocntAddValue: ValueLabel.Caption:=lisAddValue;
end;
end;
initialization
{$I compoptcondpropsdlg.lrs}
end.

View File

@ -27,7 +27,7 @@ uses
Classes, SysUtils, LCLProc, FileProcs, Controls, LResources, Forms, ComCtrls,
Menus, Dialogs,
ProjectIntf, IDEImagesIntf,
LazarusIDEStrConsts, CompOptsModes;
LazarusIDEStrConsts, CompOptsModes, CompOptCondPropsDlg;
type
@ -183,7 +183,11 @@ begin
end;
procedure TCompOptsConditionalsFrame.PropertiesMenuItemClick(Sender: TObject);
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
begin
if not GetSelectedNode(COCNode,TVNode,false) then exit;
end;

View File

@ -2367,6 +2367,7 @@ resourcestring
lisCodeToolsDefsName = 'Name:';
lisCodeToolsDefsDescription = 'Description:';
lisCodeToolsDefsVariable = 'Variable:';
lisAddValue = 'Add value:';
lisCodeToolsDefsValueAsText = 'Value as Text';
lisCodeToolsDefsValueAsFilePaths = 'Value as File Paths';
lisCodeToolsDefsAction = 'Action: %s';
@ -4006,6 +4007,7 @@ resourcestring
dlgCOCreateNodeAbove = 'Create node above';
dlgCOCreateNodeBelow = 'Create node below';
dlgCOCreateChildNode = 'Create child node';
lisResult = 'Result :=';
implementation

View File

@ -128,6 +128,12 @@ resourcestring
sccsILEdtransparentColor = 'Transparent Color:';
sccsILEdtAdjustment = 'Adjustment';
sccsILEdtNone = 'None';
liisIf = 'If';
liisIfDef = 'IfDef';
liisIfNDef = 'IfNDef';
liisElseIf = 'ElseIf';
liisElse = 'Else';
liisAddValue = 'Add value';
sccsILEdtStretch = 'Stretch';
sccsILEdtCrop = 'Crop';
sccsILEdtCenter = 'Center';

View File

@ -784,7 +784,9 @@ function StrToProjectSessionStorage(const s: string): TProjectSessionStorage;
function CompilationExecutableTypeNameToType(const s: string
): TCompilationExecutableType;
function COCNodeTypeNameToType(const s: string): TCOCNodeType;
function COCNodeTypeLocalizedName(const nt: TCOCNodeType): string;
function COCValueTypeNameToType(const s: string): TCOCValueType;
function COCValueTypeLocalizedName(const vt: TCOCValueType): string;
procedure RegisterProjectFileDescriptor(FileDesc: TProjectFileDescriptor);
procedure RegisterProjectDescriptor(ProjDesc: TProjectDescriptor);
@ -807,6 +809,20 @@ begin
Result:=cocntNone;
end;
function COCNodeTypeLocalizedName(const nt: TCOCNodeType): string;
begin
case nt of
cocntNone: Result:=sccsILEdtNone;
cocntIf: Result:=liisIf;
cocntIfdef: Result:=liisIfDef;
cocntIfNdef: Result:=liisIfNDef;
cocntElseIf: Result:=liisElseIf;
cocntElse: Result:=liisElse;
cocntAddValue: Result:=liisAddValue;
else Result:='?';
end;
end;
function COCValueTypeNameToType(const s: string): TCOCValueType;
begin
for Result:=Low(TCOCValueType) to High(TCOCValueType) do
@ -814,6 +830,22 @@ begin
Result:=cocvtNone;
end;
function COCValueTypeLocalizedName(const vt: TCOCValueType): string;
begin
case vt of
cocvtNone: Result:='None';
cocvtUnitPath: Result:='unit search path';
cocvtSrcPath: Result:='unit source search path';
cocvtIncludePath: Result:='include search path';
cocvtObjectPath: Result:='object search path';
cocvtLibraryPath: Result:='library search path';
cocvtDebugPath: Result:='debug search path';
cocvtLinkerOptions: Result:='linker options';
cocvtCustomOptions: Result:='custom options';
else Result:='?';
end;
end;
procedure RegisterProjectFileDescriptor(FileDesc: TProjectFileDescriptor);
begin
RegisterProjectFileDescriptor(FileDesc,FileDescGroupName);