summaryrefslogtreecommitdiff
path: root/examples/apps/uidesigner
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-09-08 15:01:34 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-09-08 15:01:34 +0000
commit26cb129aeae6c69b9d5ca670c0ecee67429f0861 (patch)
tree3cc1542516fd4b49f9300d99c86630504a11ff3a /examples/apps/uidesigner
parente6d2ec50bb37d5b92703e1852b814c90dd4d3204 (diff)
downloadfpGUI-26cb129aeae6c69b9d5ca670c0ecee67429f0861.tar.xz
* GUI Designer: Minor changes and removed Boolean property editors for now. Will reinstate them later.
* GUI Designer: Added a sample project to show how you would add a Main Menu using the Designer and the Unknown component on the component palette.
Diffstat (limited to 'examples/apps/uidesigner')
-rw-r--r--examples/apps/uidesigner/tests/frm_menutest.pas82
-rw-r--r--examples/apps/uidesigner/tests/menutest.lpi58
-rw-r--r--examples/apps/uidesigner/tests/menutest.lpr27
-rw-r--r--examples/apps/uidesigner/vfddesigner.pas22
-rw-r--r--examples/apps/uidesigner/vfdforms.pas5
-rw-r--r--examples/apps/uidesigner/vfdwidgets.pas23
6 files changed, 202 insertions, 15 deletions
diff --git a/examples/apps/uidesigner/tests/frm_menutest.pas b/examples/apps/uidesigner/tests/frm_menutest.pas
new file mode 100644
index 00000000..2f145bd3
--- /dev/null
+++ b/examples/apps/uidesigner/tests/frm_menutest.pas
@@ -0,0 +1,82 @@
+unit frm_menutest;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ SysUtils, Classes, gfxbase, fpgfx, gui_edit,
+ gfx_widget, gui_form, gui_label, gui_button,
+ gui_listbox, gui_memo, gui_combobox, gui_grid,
+ gui_dialogs, gui_checkbox, gui_tree, gui_trackbar,
+ gui_progressbar, gui_radiobutton, gui_tab, gui_menu;
+
+type
+
+ TfrmMain = class(TfpgForm)
+ private
+ procedure miExitClicked(Sender: TObject);
+ public
+ {@VFD_HEAD_BEGIN: frmMain}
+ MainMenu: TfpgMenuBar;
+ miFile: TfpgPopupMenu;
+ btnName1: TfpgButton;
+ {@VFD_HEAD_END: frmMain}
+
+ procedure AfterCreate; override;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+implementation
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TfrmMain.miExitClicked(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TfrmMain.AfterCreate;
+begin
+ {@VFD_BODY_BEGIN: frmMain}
+ SetPosition(278, 186, 591, 274);
+ WindowTitle := 'frmMain';
+ WindowPosition := wpScreenCenter;
+
+ MainMenu := TfpgMenuBar.Create(self);
+ with MainMenu do
+ begin
+ SetPosition(0, 0, 592, 23);
+ Anchors := [anLeft,anRight,anTop];
+ end;
+
+ miFile := TfpgPopupMenu.Create(self);
+ with miFile do
+ begin
+ SetPosition(424, 44, 152, 24);
+ AddMenuItem('&New...', 'Ctrl-N', nil);
+ AddMenuItem('&Open...', 'Ctrl-O', nil);
+ AddMenuItem('-', '', nil);
+ AddMenuItem('E&xit', 'Alt+F4', @miExitClicked);
+ end;
+
+ btnName1 := TfpgButton.Create(self);
+ with btnName1 do
+ begin
+ SetPosition(76, 156, 75, 24);
+ Text := 'Button';
+ FontDesc := '#Label1';
+ ImageName := 'stdimg.quit';
+ ModalResult := 0;
+ ShowImage := True;
+ OnClick := @miExitClicked;
+ end;
+
+ {@VFD_BODY_END: frmMain}
+
+ MainMenu.AddMenuItem('&File', nil).SubMenu := miFile;
+end;
+
+
+end.
diff --git a/examples/apps/uidesigner/tests/menutest.lpi b/examples/apps/uidesigner/tests/menutest.lpi
new file mode 100644
index 00000000..63f36c63
--- /dev/null
+++ b/examples/apps/uidesigner/tests/menutest.lpi
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="5"/>
+ <General>
+ <Flags>
+ <SaveOnlyProjectUnits Value="True"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=""/>
+ <Title Value="menutest"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="fpgui_package"/>
+ <MinVersion Minor="5" Valid="True"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="2">
+ <Unit0>
+ <Filename Value="menutest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="menutest"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="frm_menutest.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="frm_menutest"/>
+ </Unit1>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/apps/uidesigner/tests/menutest.lpr b/examples/apps/uidesigner/tests/menutest.lpr
new file mode 100644
index 00000000..80b985be
--- /dev/null
+++ b/examples/apps/uidesigner/tests/menutest.lpr
@@ -0,0 +1,27 @@
+program menutest;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, frm_menutest, fpgfx;
+
+
+
+procedure MainProc;
+var
+ frm: TfrmMain;
+begin
+ fpgApplication.Initialize;
+ frm := TfrmMain.Create(nil);
+ frm.Show;
+ fpgApplication.Run;
+end;
+
+begin
+ MainProc;
+end.
+
+
diff --git a/examples/apps/uidesigner/vfddesigner.pas b/examples/apps/uidesigner/vfddesigner.pas
index 77743a71..11200d97 100644
--- a/examples/apps/uidesigner/vfddesigner.pas
+++ b/examples/apps/uidesigner/vfddesigner.pas
@@ -1286,6 +1286,26 @@ begin
+ IntToStr(FForm.Top) + ', '
+ IntToStr(FForm.Width) + ', '
+ IntToStr(FForm.Height) + ');' + LineEnding;
+
+{
+ // Extend this and the Form Parser to handle WindowPosition, Width and Height
+ case FForm.WindowPosition of
+ wpUser:
+ begin
+ s := s + ' SetPosition('
+ + IntToStr(FForm.Left) + ', '
+ + IntToStr(FForm.Top) + ', '
+ + IntToStr(FForm.Width) + ', '
+ + IntToStr(FForm.Height) + ');' + LineEnding;
+ end;
+ else
+ begin
+ s := s + 'WindowPosition := wpScreenCenter;' + LineEnding;
+ s := s + 'Width := ' + IntToStr(FForm.Width) + ';' + LineEnding
+ + 'Height := ' + IntToStr(FForm.Height) + ';' + LineEnding;
+ end;
+ end;
+}
s := s + ' WindowTitle := ' + QuotedStr(FForm.WindowTitle) + ';' + LineEnding;
//adding other form properties, idented
@@ -1524,8 +1544,6 @@ begin
if wg <> nil then
begin
wg.FormDesigner := self;
-// wg.Left := x;
-// wg.Top := y;
if newname = '' then
newname := GenerateNewName(wgc.NameBase);
wg.Name := newname;
diff --git a/examples/apps/uidesigner/vfdforms.pas b/examples/apps/uidesigner/vfdforms.pas
index 7c8d4801..4e53e18e 100644
--- a/examples/apps/uidesigner/vfdforms.pas
+++ b/examples/apps/uidesigner/vfdforms.pas
@@ -396,8 +396,9 @@ end;
procedure TEditPositionForm.AfterCreate;
begin
inherited AfterCreate;
- WindowPosition := wpUser;
- SetPosition(0, 0, 186, 66);
+ WindowPosition := wpScreenCenter;
+ Width := 186;
+ Height := 66;
WindowTitle := 'Position';
lbPos := CreateLabel(self, 8, 8, 'Pos: ');
diff --git a/examples/apps/uidesigner/vfdwidgets.pas b/examples/apps/uidesigner/vfdwidgets.pas
index 529a3085..59cef2d5 100644
--- a/examples/apps/uidesigner/vfdwidgets.pas
+++ b/examples/apps/uidesigner/vfdwidgets.pas
@@ -211,6 +211,7 @@ begin
wc := TVFDWidgetClass.Create(TfpgForm);
wc.NameBase := 'frm';
wc.AddProperty('WindowTitle', TPropertyString, '');
+// wc.AddProperty('WindowPosition', TPropertyEnum, '');
FVFDFormWidget := wc;
// Label
@@ -243,7 +244,7 @@ begin
wc.AddProperty('Text', TPropertyString, 'Initial text');
wc.AddProperty('FontDesc', TPropertyString, 'The font used for displaying the text');
wc.AddProperty('ImageName', TPropertyString, '');
- wc.AddProperty('ShowImage', TPropertyInteger, 'Boolean value');
+// wc.AddProperty('ShowImage', TPropertyInteger, 'Boolean value');
wc.AddProperty('ModalResult', TPropertyInteger, '');
wc.WidgetIconName := 'vfd.button';
RegisterVFDWidget(wc);
@@ -253,7 +254,7 @@ begin
wc.NameBase := 'cbName';
wc.AddProperty('Text', TPropertyString, 'Initial text');
wc.AddProperty('FontDesc', TPropertyString, 'The font used for displaying the text');
- wc.AddProperty('Checked', TPropertyInteger, 'Boolean value');
+// wc.AddProperty('Checked', TPropertyInteger, 'Boolean value');
// wc.AddProperty('BackgroundColor', TPropertyString, '');
wc.WidgetIconName := 'vfd.checkbox';
RegisterVFDWidget(wc);
@@ -264,7 +265,7 @@ begin
wc.AddProperty('Text', TPropertyString, 'Initial text');
wc.AddProperty('FontDesc', TPropertyString, 'The font used for displaying the text');
wc.AddProperty('GroupIndex', TPropertyInteger, '');
- wc.AddProperty('Checked', TPropertyInteger, 'Boolean value');
+// wc.AddProperty('Checked', TPropertyInteger, 'Boolean value');
// wc.AddProperty('BackgroundColor', TPropertyString, '');
wc.WidgetIconName := 'vfd.radiobutton';
RegisterVFDWidget(wc);
@@ -340,8 +341,8 @@ begin
wc := TVFDWidgetClass.Create(TfpgTreeView);
wc.NameBase := 'tvName';
wc.AddProperty('FontDesc',TPropertyString, '');
- wc.AddProperty('ShowImages',TPropertyInteger, 'Boolean value');
- wc.AddProperty('ShowColumns',TPropertyInteger, 'Boolean value');
+// wc.AddProperty('ShowImages',TPropertyInteger, 'Boolean value');
+// wc.AddProperty('ShowColumns',TPropertyInteger, 'Boolean value');
wc.AddProperty('DefaultColumnWidth',TPropertyInteger, '');
wc.AddProperty('TreeLineStyle', TPropertyEnum, '');
// wc.AddProperty('TreeLineColor', TPropertyString, '');
@@ -355,18 +356,18 @@ begin
wc.AddProperty('ActivePageIndex', TPropertyInteger, '');
// wc.AddProperty('BackgroundColor', TPropertyString, '');
wc.AddProperty('FixedTabWidth', TPropertyInteger, '');
- wc.AddProperty('SortPages', TPropertyInteger, 'Boolean value');
+// wc.AddProperty('SortPages', TPropertyInteger, 'Boolean value');
wc.AddProperty('Style', TPropertyEnum, '');
wc.AddProperty('TabPosition', TPropertyEnum, '');
wc.WidgetIconName := 'vfd.pagecontrol';
RegisterVFDWidget(wc);
// MenuBar
- wc := TVFDWidgetClass.Create(TfpgMenuBar);
- wc.NameBase := 'mnuMain';
-// wc.AddProperty('BackgroundColor', TPropertyString, '');
- wc.WidgetIconName := 'vfd.menubar';
- RegisterVFDWidget(wc);
+// wc := TVFDWidgetClass.Create(TfpgMenuBar);
+// wc.NameBase := 'mnuMain';
+//// wc.AddProperty('BackgroundColor', TPropertyString, '');
+// wc.WidgetIconName := 'vfd.menubar';
+// RegisterVFDWidget(wc);
// Other - do not delete!!! this should be the last...
wc := TVFDWidgetClass.Create(TOtherWidget);