diff options
Diffstat (limited to 'examples/apps')
-rw-r--r-- | examples/apps/docedit/docedit.lpi | 7 | ||||
-rw-r--r-- | examples/apps/docedit/docedit.lpr | 2 | ||||
-rw-r--r-- | examples/apps/docedit/frm_main.pas | 220 | ||||
-rw-r--r-- | examples/apps/docedit/frm_options.pas | 249 |
4 files changed, 393 insertions, 85 deletions
diff --git a/examples/apps/docedit/docedit.lpi b/examples/apps/docedit/docedit.lpi index b2d9eefc..7d1ca058 100644 --- a/examples/apps/docedit/docedit.lpi +++ b/examples/apps/docedit/docedit.lpi @@ -35,7 +35,7 @@ <PackageName Value="FCL"/> </Item2> </RequiredPackages> - <Units Count="2"> + <Units Count="3"> <Unit0> <Filename Value="docedit.lpr"/> <IsPartOfProject Value="True"/> @@ -46,6 +46,11 @@ <IsPartOfProject Value="True"/> <UnitName Value="frm_main"/> </Unit1> + <Unit2> + <Filename Value="frm_options.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="frm_options"/> + </Unit2> </Units> </ProjectOptions> <CompilerOptions> diff --git a/examples/apps/docedit/docedit.lpr b/examples/apps/docedit/docedit.lpr index cb9978d2..4eeff873 100644 --- a/examples/apps/docedit/docedit.lpr +++ b/examples/apps/docedit/docedit.lpr @@ -8,7 +8,7 @@ uses {$ENDIF}{$ENDIF} Classes, fpgfx, - frm_main; + frm_main, frm_options; procedure MainProc; diff --git a/examples/apps/docedit/frm_main.pas b/examples/apps/docedit/frm_main.pas index 80791ad9..c9b4bb0f 100644 --- a/examples/apps/docedit/frm_main.pas +++ b/examples/apps/docedit/frm_main.pas @@ -23,45 +23,46 @@ uses type TMainForm = class(TfpgForm) private - btnQuit: TfpgButton; FDescriptionNode: TDomNode; - lblXMLFile: TfpgLabel; - edXMLFile: TfpgEdit; - btnOpen: TfpgButton; - menubar: TfpgMenuBar; - miFile: TfpgPopupMenu; - miInsert: TfpgPopupMenu; - miExtra: TfpgPopupMenu; - miHelp: TfpgPopupMenu; - FDoc: TXMLDocument; FModified: Boolean; CurrentModule: TDomElement; FModuleTree: TObjectList; FElementTree: TObjectList; - procedure btnQuitClicked(Sender: TObject); procedure btnOpenClicked(Sender: TObject); - procedure InitializeComponents; - procedure SetupMenuBar; procedure miFileQuitClicked(Sender: TObject); procedure miFileOpenClicked(Sender: TObject); procedure miFileSaveAsClicked(Sender: TObject); procedure miHelpAboutClicked(Sender: TObject); + procedure miExtraOptionsClicked(Sender: TObject); procedure ProcessXMLFile(pFilename: string); procedure Refresh; procedure GetElementList(List: TStrings); public + {@VFD_HEAD_BEGIN: MainForm} + menubar: TfpgMenuBar; + miFile: TfpgPopupMenu; + miInsert: TfpgPopupMenu; + miExtra: TfpgPopupMenu; + miHelp: TfpgPopupMenu; + btnQuit: TfpgButton; + lblXMLFile: TfpgLabel; + edXMLFile: TfpgEdit; + btnOpen: TfpgButton; + {@VFD_HEAD_END: MainForm} constructor Create(AOwner: TComponent); override; destructor Destroy; override; + procedure AfterCreate; override; property DescriptionNode: TDomNode read FDescriptionNode write FDescriptionNode; end; +{@VFD_NEWFORM_DECL} implementation uses - gui_dialogs; + gui_dialogs, frm_options; const @@ -81,6 +82,8 @@ type TModuleTreeItem = class(TNodeTreeItem); TTopicTreeItem = class(TNodeTreeItem); TPackageTreeItem = class(TNodeTreeItem); + +{@VFD_NEWFORM_IMPL} { TNodeTreeItem } @@ -108,70 +111,6 @@ begin // open xml file end; -procedure TMainForm.InitializeComponents; -begin - SetupMenuBar; - - btnQuit := CreateButton(self, Width-88, Height-31, 80, 'Quit', @btnQuitClicked); - with btnQuit do - begin - ImageName := 'stdimg.Quit'; - ShowImage := True; - Anchors := [anRight, anBottom]; - end; - - lblXMLFile := CreateLabel(self, 8, 38, 'XML File:'); - edXMLFile := CreateEdit(self, lblXMLFile.Right+8, lblXMLFile.Top+36, 485, 23); - edXMLFile.Text := ''; - - btnOpen := CreateButton(self, edXMLFile.Right+10, edXMLFile.Top, 80, 'Open', @btnOpenClicked); - with btnOpen do - begin - ImageName := 'stdimg.Open'; - ShowImage := True; - end; -end; - -procedure TMainForm.SetupMenuBar; -begin - // create top level menus. - miFile := TfpgPopupMenu.Create(self); - miFile.AddMenuItem('&New...', 'Ctrl-N', nil); - miFile.AddMenuItem('&Open..', 'Ctrl-O', @miFileOpenClicked); - miFile.AddMenuItem('&Save', 'Ctrl-S', nil); - miFile.AddMenuItem('S&ave As..', 'Ctrl+Shift+S', @miFileSaveAsClicked); - miFile.AddMenuItem('-', '', nil); - miFile.AddMenuItem('&Close', 'Ctrl-W', nil); - miFile.AddMenuItem('&Recent', '', nil); - miFile.AddMenuItem('-', '', nil); - miFile.AddMenuItem('&Quit', 'Ctrl-Q', @miFileQuitClicked); - - miInsert := TfpgPopupMenu.Create(self); - miInsert.AddMenuItem('&Package', '', nil); - miInsert.AddMenuItem('&Module', '', nil); - miInsert.AddMenuItem('&Topic', '', nil); - miInsert.AddMenuItem('&Element', '', nil); - miInsert.AddMenuItem('&Link', '', nil); - miInsert.AddMenuItem('T&able', '', nil); - miInsert.AddMenuItem('&Short Desc Link', '', nil); - - miExtra := TfpgPopupMenu.Create(self); - miExtra.AddMenuItem('&Options...', '', nil); - miExtra.AddMenuItem('&Build...', '', nil); - - miHelp := TfpgPopupMenu.Create(self); - miHelp.AddMenuItem('About...', '', @miHelpAboutClicked); - - // create main menu bar - menubar := TfpgMenuBar.Create(self); - menubar.SetPosition(0, 0, Width, menubar.Height); - menubar.Anchors := [anLeft, anTop, anRight]; - menubar.AddMenuItem('&File', nil).SubMenu := miFile; - menubar.AddMenuItem('&Insert', nil).SubMenu := miInsert; - menubar.AddMenuItem('&Extra', nil).SubMenu := miExtra; - menubar.AddMenuItem('&Help', nil).SubMenu := miHelp; -end; - procedure TMainForm.miFileQuitClicked(Sender: TObject); begin Close; @@ -216,6 +155,18 @@ begin ,'About'); end; +procedure TMainForm.miExtraOptionsClicked(Sender: TObject); +var + frm: TfrmOptions; +begin + frm := TfrmOptions.Create(nil); + try + frm.ShowModal; + finally + frm.Free; + end; +end; + procedure TMainForm.ProcessXMLFile(pFilename: string); var dn: TDOMNode; @@ -342,12 +293,7 @@ begin inherited Create(AOwner); WindowTitle := cAppName; Sizeable := False; - // Golden ratio 1.618 - Width := 650; - Height := 402; - InitializeComponents; - FModuleTree := TObjectList.Create; FElementTree := TObjectList.Create; end; @@ -359,5 +305,113 @@ begin inherited Destroy; end; +procedure TMainForm.AfterCreate; +begin + {@VFD_BODY_BEGIN: MainForm} + SetPosition(456, 254, 650, 402); + WindowTitle := 'frmMain'; + WindowPosition := wpScreenCenter; + + menubar := TfpgMenuBar.Create(self); + with menubar do + begin + SetPosition(0, 0, 650, 23); + Anchors := [anLeft,anRight,anTop]; + end; + + miFile := TfpgPopupMenu.Create(self); + with miFile do + begin + SetPosition(464, 169, 160, 24); + AddMenuItem('&New...', 'Ctrl-N', nil); + AddMenuItem('&Open..', 'Ctrl-O', @miFileOpenClicked); + AddMenuItem('&Save', 'Ctrl-S', nil); + AddMenuItem('S&ave As..', 'Ctrl+Shift+S', @miFileSaveAsClicked); + AddMenuItem('-', '', nil); + AddMenuItem('&Close', 'Ctrl-W', nil); + AddMenuItem('&Recent', '', nil); + AddMenuItem('-', '', nil); + AddMenuItem('&Quit', 'Ctrl-Q', @miFileQuitClicked); + end; + + miInsert := TfpgPopupMenu.Create(self); + with miInsert do + begin + SetPosition(464, 190, 160, 24); + AddMenuItem('&Package', '', nil); + AddMenuItem('&Module', '', nil); + AddMenuItem('&Topic', '', nil); + AddMenuItem('&Element', '', nil); + AddMenuItem('&Link', '', nil); + AddMenuItem('T&able', '', nil); + AddMenuItem('&Short Desc Link', '', nil); + end; + + miExtra := TfpgPopupMenu.Create(self); + with miExtra do + begin + SetPosition(464, 211, 160, 24); + AddMenuItem('&Options...', '', @miExtraOptionsClicked); + AddMenuItem('&Build...', '', nil); + end; + + miHelp := TfpgPopupMenu.Create(self); + with miHelp do + begin + SetPosition(464, 232, 160, 24); + AddMenuItem('About...', '', @miHelpAboutClicked); + end; + + btnQuit := TfpgButton.Create(self); + with btnQuit do + begin + SetPosition(566, 370, 75, 23); + Anchors := [anRight,anBottom]; + Text := 'Quit'; + FontDesc := '#Label1'; + ImageName := 'stdimg.Quit'; + ModalResult := 0; + ShowImage := True; + OnClick := @btnQuitClicked; + end; + + lblXMLFile := TfpgLabel.Create(self); + with lblXMLFile do + begin + SetPosition(4, 48, 58, 19); + Text := 'XML File:'; + FontDesc := '#Label1'; + end; + + edXMLFile := TfpgEdit.Create(self); + with edXMLFile do + begin + SetPosition(62, 44, 485, 23); + Anchors := [anLeft,anRight,anTop]; + Text := ''; + FontDesc := '#Edit1'; + end; + + btnOpen := TfpgButton.Create(self); + with btnOpen do + begin + SetPosition(554, 44, 75, 23); + Anchors := [anRight,anTop]; + Text := 'Open'; + FontDesc := '#Label1'; + ImageName := 'stdimg.Open'; + ModalResult := 0; + ShowImage := True; + OnClick := @btnOpenClicked; + end; + + {@VFD_BODY_END: MainForm} + + menubar.AddMenuItem('&File', nil).SubMenu := miFile; + menubar.AddMenuItem('&Insert', nil).SubMenu := miInsert; + menubar.AddMenuItem('&Extra', nil).SubMenu := miExtra; + menubar.AddMenuItem('&Help', nil).SubMenu := miHelp; +end; + end. diff --git a/examples/apps/docedit/frm_options.pas b/examples/apps/docedit/frm_options.pas new file mode 100644 index 00000000..ea955271 --- /dev/null +++ b/examples/apps/docedit/frm_options.pas @@ -0,0 +1,249 @@ +unit frm_options; + +{$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, + gui_bevel; + +type + + TfrmOptions = class(TfpgForm) + public + {@VFD_HEAD_BEGIN: frmOptions} + lblName1: TfpgLabel; + cbConfirmDeletes: TfpgCheckBox; + cbBackups: TfpgCheckBox; + cbSkipNodes: TfpgCheckBox; + edtDftExt: TfpgEdit; + edtBakExt: TfpgEdit; + edtMRU: TfpgEdit; + lblName2: TfpgLabel; + lblName3: TfpgLabel; + lblName4: TfpgLabel; + edtMakeSkel: TfpgEdit; + btnMakeSkel: TfpgButton; + edtFPDoc: TfpgEdit; + btnFPDoc: TfpgButton; + cbShowHints: TfpgCheckBox; + pnlName1: TfpgBevel; + btnOK: TfpgButton; + btnCancel: TfpgButton; + lblName5: TfpgLabel; + lblName6: TfpgLabel; + lblName7: TfpgLabel; + {@VFD_HEAD_END: frmOptions} + + procedure AfterCreate; override; + end; + +{@VFD_NEWFORM_DECL} + +implementation + +{@VFD_NEWFORM_IMPL} + +procedure TfrmOptions.AfterCreate; +begin + {@VFD_BODY_BEGIN: frmOptions} + SetPosition(428, 237, 397, 357); + WindowTitle := 'Options'; + WindowPosition := wpScreenCenter; + + lblName1 := TfpgLabel.Create(self); + with lblName1 do + begin + SetPosition(8, 8, 51, 16); + Text := 'General'; + FontDesc := '#Label2'; + AutoSize := True; + end; + + cbConfirmDeletes := TfpgCheckBox.Create(self); + with cbConfirmDeletes do + begin + SetPosition(24, 28, 120, 20); + Text := 'Confirm deletes'; + FontDesc := '#Label1'; + end; + + cbBackups := TfpgCheckBox.Create(self); + with cbBackups do + begin + SetPosition(24, 52, 120, 20); + Text := 'Create backups'; + FontDesc := '#Label1'; + end; + + cbSkipNodes := TfpgCheckBox.Create(self); + with cbSkipNodes do + begin + SetPosition(24, 76, 216, 20); + Text := 'Skip empty nodes when saving'; + FontDesc := '#Label1'; + end; + + edtDftExt := TfpgEdit.Create(self); + with edtDftExt do + begin + SetPosition(164, 104, 120, 22); + Text := '.xml'; + FontDesc := '#Edit1'; + end; + + edtBakExt := TfpgEdit.Create(self); + with edtBakExt do + begin + SetPosition(164, 128, 120, 22); + Text := '.~xml'; + FontDesc := '#Edit1'; + end; + + edtMRU := TfpgEdit.Create(self); + with edtMRU do + begin + SetPosition(164, 152, 120, 22); + Text := '10'; + FontDesc := '#Edit1'; + end; + + lblName2 := TfpgLabel.Create(self); + with lblName2 do + begin + SetPosition(8, 252, 50, 16); + Text := 'Desktop'; + FontDesc := '#Label2'; + AutoSize := True; + end; + + lblName3 := TfpgLabel.Create(self); + with lblName3 do + begin + SetPosition(24, 108, 104, 16); + Text := 'Default extension:'; + FontDesc := '#Label1'; + end; + + lblName4 := TfpgLabel.Create(self); + with lblName4 do + begin + SetPosition(24, 132, 108, 16); + Text := 'Backup extension:'; + FontDesc := '#Label1'; + end; + + edtMakeSkel := TfpgEdit.Create(self); + with edtMakeSkel do + begin + SetPosition(164, 184, 196, 22); + Anchors := [anLeft,anRight,anTop]; + Text := ''; + FontDesc := '#Edit1'; + end; + + btnMakeSkel := TfpgButton.Create(self); + with btnMakeSkel do + begin + SetPosition(364, 184, 23, 20); + Anchors := [anRight,anTop]; + Text := '...'; + FontDesc := '#Label1'; + ImageName := ''; + ModalResult := 0; + end; + + edtFPDoc := TfpgEdit.Create(self); + with edtFPDoc do + begin + SetPosition(164, 208, 196, 22); + Anchors := [anLeft,anRight,anTop]; + Text := ''; + FontDesc := '#Edit1'; + end; + + btnFPDoc := TfpgButton.Create(self); + with btnFPDoc do + begin + SetPosition(364, 208, 23, 20); + Anchors := [anRight,anTop]; + Text := '...'; + FontDesc := '#Label1'; + ImageName := ''; + ModalResult := 0; + end; + + cbShowHints := TfpgCheckBox.Create(self); + with cbShowHints do + begin + SetPosition(24, 272, 120, 20); + Text := 'Show hints'; + FontDesc := '#Label1'; + end; + + pnlName1 := TfpgBevel.Create(self); + with pnlName1 do + begin + SetPosition(4, 313, 389, 11); + Anchors := [anLeft,anRight,anBottom]; + Shape := bsTopLine; + Style := bsLowered; + Focusable := False; + end; + + btnOK := TfpgButton.Create(self); + with btnOK do + begin + SetPosition(234, 325, 75, 24); + Anchors := [anRight,anBottom]; + Text := 'OK'; + FontDesc := '#Label1'; + ImageName := 'stdimg.ok'; + ModalResult := 1; + end; + + btnCancel := TfpgButton.Create(self); + with btnCancel do + begin + SetPosition(314, 325, 75, 24); + Anchors := [anRight,anBottom]; + Text := 'Cancel'; + FontDesc := '#Label1'; + ImageName := 'stdimg.cancel'; + ModalResult := 2; + end; + + lblName5 := TfpgLabel.Create(self); + with lblName5 do + begin + SetPosition(24, 156, 132, 16); + Text := 'Max. recent used files:'; + FontDesc := '#Label1'; + end; + + lblName6 := TfpgLabel.Create(self); + with lblName6 do + begin + SetPosition(24, 188, 127, 16); + Text := 'makeskel executable:'; + FontDesc := '#Label1'; + end; + + lblName7 := TfpgLabel.Create(self); + with lblName7 do + begin + SetPosition(24, 212, 102, 16); + Text := 'fpdoc executable:'; + FontDesc := '#Label1'; + end; + + {@VFD_BODY_END: frmOptions} +end; + + +end. |