IDE: converted menu template from to lfm from Maxim Ganetsky

git-svn-id: trunk@14191 -
This commit is contained in:
vincents 2008-02-19 12:01:07 +00:00
parent e0c523e862
commit 64eefe417c
4 changed files with 273 additions and 169 deletions

2
.gitattributes vendored
View File

@ -1199,6 +1199,8 @@ designer/changeclassdialog.lrs svneol=native#text/pascal
designer/changeclassdialog.pas svneol=native#text/pascal
designer/controlselection.pp svneol=native#text/pascal
designer/designer.pp svneol=native#text/pascal
designer/designermenu.lfm svneol=native#text/plain
designer/designermenu.lrs svneol=native#text/plain
designer/designermenu.pp svneol=native#text/pascal
designer/designerprocs.pas svneol=native#text/pascal
designer/filesystem.pp svneol=native#text/pascal

128
designer/designermenu.lfm Normal file
View File

@ -0,0 +1,128 @@
object TemplateMenuForm: TTemplateMenuForm
Left = 537
Height = 240
Top = 199
Width = 520
HorzScrollBar.Page = 519
VertScrollBar.Page = 239
Caption = 'TemplateMenuForm'
ClientHeight = 240
ClientWidth = 520
Constraints.MinHeight = 100
Constraints.MinWidth = 350
OnCreate = FormCreate
OnResize = FormResize
Position = poScreenCenter
object Label_template_description: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 6
Height = 14
Top = 6
Width = 132
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'Label_template_description'
ParentColor = False
end
object Label_template_view: TLabel
AnchorSideLeft.Control = ListBoxView
AnchorSideTop.Control = Owner
Left = 262
Height = 14
Top = 6
Width = 102
BorderSpacing.Top = 6
Caption = 'Label_template_view'
ParentColor = False
end
object TemplatesListBox: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label_template_description
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = ListBoxView
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 176
Top = 26
Width = 244
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
OnClick = TemplatesListBoxClick
TabOrder = 0
end
object ListBoxView: TListBox
AnchorSideLeft.Control = TemplatesListBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label_template_view
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CancelBitBtn
Left = 262
Height = 176
Top = 26
Width = 252
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Around = 6
TabOrder = 1
end
object Edit_template_description: TEdit
AnchorSideLeft.Control = TemplatesListBox
AnchorSideTop.Control = TemplatesListBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TemplatesListBox
AnchorSideRight.Side = asrBottom
Left = 6
Height = 23
Top = 208
Width = 244
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
TabOrder = 2
Text = 'Edit_template_description'
Visible = False
end
object OKBitBtn: TBitBtn
AnchorSideRight.Control = CancelBitBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 364
Height = 26
Top = 208
Width = 60
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
Caption = '&ÎÊ'
Default = True
Kind = bkOK
ModalResult = 1
NumGlyphs = 0
OnClick = OKBitBtnClick
TabOrder = 3
end
object CancelBitBtn: TBitBtn
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 430
Height = 26
Top = 208
Width = 84
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Cancel = True
Caption = 'Îòìåíà'
Kind = bkCancel
ModalResult = 2
NumGlyphs = 0
OnClick = CancelBitBtnClick
TabOrder = 4
end
end

49
designer/designermenu.lrs Normal file
View File

@ -0,0 +1,49 @@
{ Ýòî - ôàéë ðåñóðñîâ, àâòîìàòè÷åñêè ñîçäàííûé lazarus }
LazarusResources.Add('TTemplateMenuForm','FORMDATA',[
'TPF0'#17'TTemplateMenuForm'#16'TemplateMenuForm'#4'Left'#3#25#2#6'Height'#3
+#240#0#3'Top'#3#199#0#5'Width'#3#8#2#18'HorzScrollBar.Page'#3#7#2#18'VertScr'
+'ollBar.Page'#3#239#0#7'Caption'#6#16'TemplateMenuForm'#12'ClientHeight'#3
+#240#0#11'ClientWidth'#3#8#2#21'Constraints.MinHeight'#2'd'#20'Constraints.M'
+'inWidth'#3'^'#1#8'OnCreate'#7#10'FormCreate'#8'OnResize'#7#10'FormResize'#8
+'Position'#7#14'poScreenCenter'#0#6'TLabel'#26'Label_template_description'#22
+'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#5'Owner'#4'L'
+'eft'#2#6#6'Height'#2#14#3'Top'#2#6#5'Width'#3#132#0#18'BorderSpacing.Left'#2
+#6#17'BorderSpacing.Top'#2#6#7'Caption'#6#26'Label_template_description'#11
+'ParentColor'#8#0#0#6'TLabel'#19'Label_template_view'#22'AnchorSideLeft.Cont'
+'rol'#7#11'ListBoxView'#21'AnchorSideTop.Control'#7#5'Owner'#4'Left'#3#6#1#6
+'Height'#2#14#3'Top'#2#6#5'Width'#2'f'#17'BorderSpacing.Top'#2#6#7'Caption'#6
+#19'Label_template_view'#11'ParentColor'#8#0#0#8'TListBox'#16'TemplatesListB'
+'ox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#26'La'
+'bel_template_description'#18'AnchorSideTop.Side'#7#9'asrBottom'#24'AnchorSi'
+'deBottom.Control'#7#11'ListBoxView'#21'AnchorSideBottom.Side'#7#9'asrBottom'
+#4'Left'#2#6#6'Height'#3#176#0#3'Top'#2#26#5'Width'#3#244#0#7'Anchors'#11#5
+'akTop'#6'akLeft'#8'akBottom'#0#18'BorderSpacing.Left'#2#6#17'BorderSpacing.'
+'Top'#2#6#7'OnClick'#7#21'TemplatesListBoxClick'#8'TabOrder'#2#0#0#0#8'TList'
+'Box'#11'ListBoxView'#22'AnchorSideLeft.Control'#7#16'TemplatesListBox'#19'A'
+'nchorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'#7#19'Label_tem'
+'plate_view'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Contro'
+'l'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.C'
+'ontrol'#7#12'CancelBitBtn'#4'Left'#3#6#1#6'Height'#3#176#0#3'Top'#2#26#5'Wi'
+'dth'#3#252#0#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#18'B'
+'orderSpacing.Left'#2#6#20'BorderSpacing.Around'#2#6#8'TabOrder'#2#1#0#0#5'T'
+'Edit'#25'Edit_template_description'#22'AnchorSideLeft.Control'#7#16'Templat'
+'esListBox'#21'AnchorSideTop.Control'#7#16'TemplatesListBox'#18'AnchorSideTo'
+'p.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#16'TemplatesListBox'#20
+'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#23#3'Top'#3#208
+#0#5'Width'#3#244#0#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#17'BorderS'
+'pacing.Top'#2#6#8'TabOrder'#2#2#4'Text'#6#25'Edit_template_description'#7'V'
+'isible'#8#0#0#7'TBitBtn'#8'OKBitBtn'#23'AnchorSideRight.Control'#7#12'Cance'
+'lBitBtn'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side'#7
+#9'asrBottom'#4'Left'#3'l'#1#6'Height'#2#26#3'Top'#3#208#0#5'Width'#2'<'#7'A'
+'nchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#19'BorderSpacing.Right'#2
+#6#20'BorderSpacing.Bottom'#2#6#7'Caption'#6#3'&'#206#202#7'Default'#9#4'Kin'
+'d'#7#4'bkOK'#11'ModalResult'#2#1#9'NumGlyphs'#2#0#7'OnClick'#7#13'OKBitBtnC'
+'lick'#8'TabOrder'#2#3#0#0#7'TBitBtn'#12'CancelBitBtn'#23'AnchorSideRight.Co'
+'ntrol'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBott'
+'om.Control'#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3
+#174#1#6'Height'#2#26#3'Top'#3#208#0#5'Width'#2'T'#7'Anchors'#11#7'akRight'#8
+'akBottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#6'Cancel'#9#7'Captio'
+'n'#6#6#206#242#236#229#237#224#4'Kind'#7#8'bkCancel'#11'ModalResult'#2#2#9
+'NumGlyphs'#2#0#7'OnClick'#7#17'CancelBitBtnClick'#8'TabOrder'#2#4#0#0#0
]);

View File

@ -36,34 +36,37 @@ unit DesignerMenu;
interface
uses
Classes, SysUtils, LCLProc, Forms, Controls, Menus, Graphics, GraphType,
Classes, SysUtils, LResources, LCLProc, Forms, Controls, Menus, Graphics, GraphType,
Buttons, StdCtrls, ExtCtrls, ComponentEditors, LazConf, ComCtrls, Arrow,
Laz_XMLCfg, LazarusIDEStrConsts,
PropEdits, IDEProcs;
type
{ TTemplateMenuForm }
TTemplateMenuForm = class(TForm)
private
OKBitBtn: TBitBtn;
CancelBitBtn: TBitBtn;
Edit_template_description: TEdit;
Label_template_description: TLabel;
Label_template_view: TLabel;
TemplatesListBox: TListBox;
Label_template_description: TLabel;
ListBoxView: TListBox;
OkButton: TButton;
CancelButton: TButton;
TemplatesListBox: TListBox;
procedure CancelBitBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure OKBitBtnClick(Sender: TObject);
procedure TemplatesListBoxClick(Sender: TObject);
private
SelectedMenuTemplate: Integer;
Description: string;
subitem_level: Integer;
fAction: Integer;
public
constructor CreateWithAction(AOwner: TComponent; TheAction: Integer);
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
function GetSelectedMenuTemplate: Integer;
function GetDescription: string;
procedure TemplateView(templatemenuitem: string; default_template: Integer);
procedure OnSelectMenuTemplateClick(Sender: TObject);
end;
PDesignerMenuItem = ^TDesignerMenuItem;
@ -192,7 +195,7 @@ const
var
temp_level: Integer;
temp_newitemcounter: Integer;
temp_newitemcounter, TemplateMenuFormCreateAction: Integer;
temp_panel: TPanel;
index_sequence: Array[1..INDEX_SEQUENCE_LENGTH] of Integer;
@ -948,7 +951,9 @@ var
templatemenuitem: string;
temp_designermenuitem: PDesignerMenuItem;
begin
TemplateMenuForm:=TTemplateMenuForm.CreateWithAction(self, 1);
TemplateMenuFormCreateAction:=1;
TemplateMenuForm:=TTemplateMenuForm.Create(self);
if (TemplateMenuForm.ShowModal = mrOK) then
begin
@ -1207,7 +1212,10 @@ begin
i:=1;
Str(i,str_i);
templatemenuitem:='menu_' + str_i;
TemplateMenuForm:=TTemplateMenuForm.CreateWithAction(self, 2);
TemplateMenuFormCreateAction:=2;
TemplateMenuForm:=TTemplateMenuForm.Create(self);
if (TemplateMenuForm.ShowModal = mrOK) then
begin
while (XMLConfig.GetValue(templatemenuitem + '/Name/Value','does_not_exists') <> 'does_not_exists') do
@ -1259,7 +1267,10 @@ begin
//SelectedDesignerMenuItem:=GetSelectedDesignerMenuItem(Root);
i:=1;
j:=1;
TemplateMenuForm:=TTemplateMenuForm.CreateWithAction(self, 3);
TemplateMenuFormCreateAction:=3;
TemplateMenuForm:=TTemplateMenuForm.Create(self);
if (TemplateMenuForm.ShowModal = mrOK) and (TemplateMenuForm.GetSelectedMenuTemplate > 0) then
begin
i:=TemplateMenuForm.GetSelectedMenuTemplate;
@ -1983,104 +1994,22 @@ end;
// ---------------------/
// TTemplateMenuForm ---/
// ---------------------/
constructor TTemplateMenuForm.CreateWithAction(AOwner: TComponent;
TheAction: Integer);
procedure TTemplateMenuForm.FormCreate(Sender: TObject);
var
i: Integer;
templatemenuitem, str_i: string;
begin
inherited Create(AOwner);
fAction:=TheAction;
case fAction of
1: begin
// content of "Caption" is generated from LazarusIDEStrConsts
Caption:=lisMenuEditorInsertFromTemplate;
end;
2: begin
// content of "Caption" is generated from LazarusIDEStrConsts
Caption:=lisMenuEditorSaveAsTemplate;
end;
3: begin
// content of "Caption" is generated from LazarusIDEStrConsts
Caption:=lisMenuEditorDeleteFromTemplate;
end;
end;
Width:=520;
Height:=240;
Position:=poScreenCenter;
fAction:=TemplateMenuFormCreateAction;
subitem_level:=1;
Label_template_description.Caption:=lisMenuEditorSelectTemplate;
Label_template_view.Caption:=lisMenuEditorTemplatePreview;
Edit_template_description.Text:=lisMenuEditorNewTemplateDescription;
Label_template_description:=TLabel.Create(self);
with Label_template_description do
begin
Parent:=self;
Left:=10;
Top:=10;
Width:=240;
Height:=20;
// content of "Text" is generated from LazarusIDEStrConsts
Text:=lisMenuEditorSelectTemplate;
end;
Label_template_view:=TLabel.Create(self);
with Label_template_view do
begin
Parent:=self;
Left:=270;
Top:=10;
Width:=240;
Height:=20;
// content of "Text" is generated from LazarusIDEStrConsts
Text:=lisMenuEditorTemplatePreview;
end;
TemplatesListBox:=TListBox.Create(self);
with TemplatesListBox do
begin
Parent:=self;
Left:=10;
Top:=30;
Width:=240;
Height:=150;
OnClick:=@OnSelectMenuTemplateClick;
end;
ListBoxView:=TListBox.Create(self);
with ListBoxView do
begin
Parent:=self;
Left:=270;
Top:=30;
Width:=240;
Height:=150;
end;
if (fAction = 2) then
begin
Edit_template_description:=TEdit.Create(self);
with Edit_template_description do
begin
Parent:=self;
Left:=10;
Top:=200;
Width:=240;
// content of "Text" is generated from LazarusIDEStrConsts
Text:=lisMenuEditorNewTemplateDescription;
end;
end;
// Default templates
if (fAction = 1) then
begin
TemplatesListBox.Items.Add(lisMenuTemplateDescriptionStandardFileMenu);
TemplatesListBox.Items.Add(lisMenuTemplateDescriptionStandardEditMenu);
TemplatesListBox.Items.Add(lisMenuTemplateDescriptionStandardHelpMenu);
end;
OKBitBtn.Caption:=lisOkBtn;
CancelBitBtn.Caption:=dlgCancel;
// Templates from menutemplates.xml
i:=1;
Str(i,str_i);
@ -2091,47 +2020,49 @@ begin
Inc(i);
Str(i,str_i);
end;
// Select the first menu on list and show it in "Template Preview"
if (TemplatesListBox.Items.Count > 0) then
begin
TemplatesListBox.Selected[0]:=true;
if (fAction = 1) then
TemplateView('', 1)
else
TemplateView('menu_1/subitem_', 0);
case fAction of
1: begin
// content of "Caption" is generated from LazarusIDEStrConsts
Caption:=lisMenuEditorInsertFromTemplate;
TemplatesListBox.Items.Add(lisMenuTemplateDescriptionStandardFileMenu);
TemplatesListBox.Items.Add(lisMenuTemplateDescriptionStandardEditMenu);
TemplatesListBox.Items.Add(lisMenuTemplateDescriptionStandardHelpMenu);
TemplateView('', 1);
end;
2: begin
// content of "Caption" is generated from LazarusIDEStrConsts
Caption:=lisMenuEditorSaveAsTemplate;
Edit_template_description.Visible:=true;
if TemplatesListBox.Items.Count > 0 then
TemplateView('menu_1/subitem_', 0);
end;
3: begin
// content of "Caption" is generated from LazarusIDEStrConsts
Caption:=lisMenuEditorDeleteFromTemplate;
if TemplatesListBox.Items.Count > 0 then
TemplateView('menu_1/subitem_', 0);
end;
end;
OkButton:=TButton.Create(self);
with OkButton do
begin
Parent:=self;
Caption:='OK';
Left:=360;
Top:=200;
Width:=70;
Height:=20;
OnClick:=@OkButtonClick;
end;
CancelButton:=TButton.Create(self);
with CancelButton do
begin
Parent:=self;
// content of "Caption" is generated from LazarusIDEStrConsts
Caption:=lisMenuEditorCancel;
Left:=440;
Top:=200;
Width:=70;
Height:=20;
OnClick:=@CancelButtonClick;
end;
end;
procedure TTemplateMenuForm.OkButtonClick(Sender: TObject);
var
i: Integer;
procedure TTemplateMenuForm.FormResize(Sender: TObject);
begin
TemplatesListBox.Width:=(Width div 2)-14;
end;
procedure TTemplateMenuForm.CancelBitBtnClick(Sender: TObject);
begin
SelectedMenuTemplate:=0;
ModalResult:=mrCancel;
end;
procedure TTemplateMenuForm.OKBitBtnClick(Sender: TObject);
var i: Integer;
begin
for i:=0 to TemplatesListBox.Items.Count-1 do
if TemplatesListBox.Selected[i] then SelectedMenuTemplate:=i + 1;
@ -2147,10 +2078,28 @@ begin
ModalResult:=mrOK;
end;
procedure TTemplateMenuForm.CancelButtonClick(Sender: TObject);
procedure TTemplateMenuForm.TemplatesListBoxClick(Sender: TObject);
var i: Integer;
str_i: string;
begin
SelectedMenuTemplate:=0;
ModalResult:=mrCancel;
ListBoxView.Clear;
for i:=0 to TemplatesListBox.Items.Count-1 do
if TemplatesListBox.Selected[i] then SelectedMenuTemplate:=i + 1;
if (fAction <> 1) then
begin
Str(SelectedMenuTemplate, str_i);
TemplateView('menu_' + str_i + '/subitem_', 0);
end else
begin
if (SelectedMenuTemplate > NUMBER_OF_DEFAULT_TEMPLATES) then
begin
Str(SelectedMenuTemplate - NUMBER_OF_DEFAULT_TEMPLATES, str_i);
TemplateView('menu_' + str_i + '/subitem_', 0);
end else
TemplateView('', SelectedMenuTemplate);
end;
ListBoxView.Selected[0]:=false;
end;
function TTemplateMenuForm.GetSelectedMenuTemplate: Integer;
@ -2230,32 +2179,8 @@ begin
end;
end;
procedure TTemplateMenuForm.OnSelectMenuTemplateClick(Sender: TObject);
var
i: Integer;
str_i: string;
begin
ListBoxView.Clear;
for i:=0 to TemplatesListBox.Items.Count-1 do
if TemplatesListBox.Selected[i] then SelectedMenuTemplate:=i + 1;
if (fAction <> 1) then
begin
Str(SelectedMenuTemplate, str_i);
TemplateView('menu_' + str_i + '/subitem_', 0);
end else
begin
if (SelectedMenuTemplate > NUMBER_OF_DEFAULT_TEMPLATES) then
begin
Str(SelectedMenuTemplate - NUMBER_OF_DEFAULT_TEMPLATES, str_i);
TemplateView('menu_' + str_i + '/subitem_', 0);
end else
TemplateView('', SelectedMenuTemplate);
end;
ListBoxView.Selected[0]:=false;
end;
initialization
{$I designermenu.lrs}
finalization
XMLConfig.Free;