diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-08-20 11:31:32 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-08-20 11:31:32 +0000 |
commit | fd21e0949968595a68760b4c9666802fde117cf8 (patch) | |
tree | d73e19d6aa1ca4820136633b143c10b7d9127a79 /examples | |
parent | 96d455885d959ac862cfc5fd778397918809b2ed (diff) | |
download | fpGUI-fd21e0949968595a68760b4c9666802fde117cf8.tar.xz |
* Applied patch from Michael van Canneyt improving file dialog handling in UI Designer.
* I fixed a minor bug in StringGrid Columns property editor. Issue was caused by new behaviour of Edit.OnChange firing more often.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/apps/uidesigner/vfdforms.pas | 81 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdmain.pas | 22 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdpropeditgrid.pas | 38 |
3 files changed, 100 insertions, 41 deletions
diff --git a/examples/apps/uidesigner/vfdforms.pas b/examples/apps/uidesigner/vfdforms.pas index d7fc4657..576b65c7 100644 --- a/examples/apps/uidesigner/vfdforms.pas +++ b/examples/apps/uidesigner/vfdforms.pas @@ -117,6 +117,8 @@ type cbFullPath: TfpgCheckBox; lblName1: TfpgLabel; lblName2: TfpgLabel; + eDefaultExt: TfpgEdit; + lblName3: TfpgLabel; {@VFD_HEAD_END: frmVFDSetup} procedure AfterCreate; override; procedure BeforeDestruction; override; @@ -242,71 +244,79 @@ procedure TWidgetOrderForm.AfterCreate; begin inherited AfterCreate; {@VFD_BODY_BEGIN: WidgetOrderForm} - SetPosition(100, 100, 312, 258); + Name := 'WidgetOrderForm'; + SetPosition(534, 173, 312, 258); WindowTitle := 'Widget order'; WindowPosition := wpScreenCenter; l1 := TfpgLabel.Create(self); with l1 do begin + Name := 'l1'; SetPosition(4, 4, 108, 16); - Text := 'Form widget order:'; FontDesc := '#Label1'; + Text := 'Form widget order:'; end; list := TfpgListBox.Create(self); with list do begin + Name := 'list'; SetPosition(4, 24, 220, 228); Anchors := [anLeft,anRight,anTop,anBottom]; FontDesc := '#List'; + TabOrder := 1; end; btnOK := TfpgButton.Create(self); with btnOK do begin + Name := 'btnOK'; SetPosition(232, 24, 75, 24); Anchors := [anRight,anTop]; Text := 'OK'; FontDesc := '#Label1'; ImageName := 'stdimg.ok'; - ModalResult := 0; + TabOrder := 2; OnClick := @OnButtonClick; end; btnCancel := TfpgButton.Create(self); with btnCancel do begin + Name := 'btnCancel'; SetPosition(232, 52, 75, 24); Anchors := [anRight,anTop]; Text := 'Cancel'; FontDesc := '#Label1'; ImageName := 'stdimg.cancel'; - ModalResult := 0; + TabOrder := 3; OnClick := @OnButtonClick; end; btnUp := TfpgButton.Create(self); with btnUp do begin + Name := 'btnUp'; SetPosition(232, 108, 75, 24); Anchors := [anRight,anTop]; Text := 'Up'; FontDesc := '#Label1'; ImageName := ''; - ModalResult := 0; + TabOrder := 4; OnClick := @OnButtonClick; end; btnDown := TfpgButton.Create(self); with btnDown do begin + Name := 'btnDown'; SetPosition(232, 136, 75, 24); Anchors := [anRight,anTop]; Text := 'Down'; FontDesc := '#Label1'; ImageName := ''; - ModalResult := 0; + TabOrder := 5; OnClick := @OnButtonClick; end; @@ -405,6 +415,7 @@ begin chlGrid.FocusItem := gINI.ReadInteger('Options', 'GridResolution', 2); tbMRUFileCount.Position := gINI.ReadInteger('Options', 'MRUFileCount', 4); cbFullPath.Checked := gINI.ReadBool('Options', 'ShowFullPath', True); + eDefaultExt.Text:=gINI.ReadString('Options','DefaultFileExt','.pas'); end; procedure TfrmVFDSetup.SaveSettings; @@ -412,6 +423,7 @@ begin gINI.WriteInteger('Options', 'GridResolution', chlGrid.FocusItem); gINI.WriteInteger('Options', 'MRUFileCount', tbMRUFileCount.Position); gINI.WriteBool('Options', 'ShowFullPath', cbFullPath.Checked); + gINI.WriteString('Options','DefaultFileExt',eDefaultExt.Text); end; procedure TfrmVFDSetup.btnOKClick(Sender: TObject); @@ -424,7 +436,7 @@ procedure TfrmVFDSetup.AfterCreate; begin {@VFD_BODY_BEGIN: frmVFDSetup} Name := 'frmVFDSetup'; - SetPosition(394, 399, 252, 184); + SetPosition(394, 399, 252, 217); WindowTitle := 'General settings'; WindowPosition := wpScreenCenter; gINI.ReadFormState(self); @@ -432,88 +444,117 @@ begin lb1 := TfpgLabel.Create(self); with lb1 do begin + Name := 'lb1'; SetPosition(28, 28, 116, 16); - Text := 'Grid resolution:'; FontDesc := '#Label1'; + Text := 'Grid resolution:'; end; chlGrid := TfpgComboBox.Create(self); with chlGrid do begin + Name := 'chlGrid'; SetPosition(140, 24, 88, 22); + FontDesc := '#List'; Items.Add('1'); Items.Add('4'); Items.Add('8'); - FontDesc := '#List'; + TabOrder := 1; FocusItem := 0; end; btnOK := TfpgButton.Create(self); with btnOK do begin - SetPosition(92, 154, 75, 24); + Name := 'btnOK'; + SetPosition(92, 187, 75, 24); Anchors := [anRight,anBottom]; Text := 'OK'; FontDesc := '#Label1'; ImageName := 'stdimg.ok'; - ModalResult := 0; - ShowImage := True; + TabOrder := 2; OnClick := @btnOKClick; end; btnCancel := TfpgButton.Create(self); with btnCancel do begin - SetPosition(171, 154, 75, 24); + Name := 'btnCancel'; + SetPosition(171, 187, 75, 24); Anchors := [anRight,anBottom]; Text := 'Cancel'; FontDesc := '#Label1'; ImageName := 'stdimg.cancel'; ModalResult := -1; - ShowImage := True; + TabOrder := 3; end; lblRecentFiles := TfpgLabel.Create(self); with lblRecentFiles do begin + Name := 'lblRecentFiles'; SetPosition(28, 88, 136, 16); - Text := 'Recent files count:'; FontDesc := '#Label1'; + Text := 'Recent files count:'; end; tbMRUFileCount := TfpgTrackBar.Create(self); with tbMRUFileCount do begin + Name := 'tbMRUFileCount'; SetPosition(156, 80, 76, 30); - Min := 2; Max := 10; + Min := 2; Position := 4; - Orientation := orHorizontal; ShowPosition := True; + TabOrder := 5; end; cbFullPath := TfpgCheckBox.Create(self); with cbFullPath do begin + Name := 'cbFullPath'; SetPosition(24, 108, 204, 20); - Text := 'Show the full file path'; FontDesc := '#Label1'; + TabOrder := 6; + Text := 'Show the full file path'; end; lblName1 := TfpgLabel.Create(self); with lblName1 do begin + Name := 'lblName1'; SetPosition(8, 8, 176, 16); - Text := 'Form designer'; FontDesc := '#Label2'; + Text := 'Form designer'; end; lblName2 := TfpgLabel.Create(self); with lblName2 do begin + Name := 'lblName2'; SetPosition(8, 64, 232, 16); - Text := 'Open Recent menu settings'; FontDesc := '#Label2'; + Text := 'Open Recent menu settings'; + end; + + eDefaultExt := TfpgEdit.Create(self); + with eDefaultExt do + begin + Name := 'eDefaultExt'; + SetPosition(28, 152, 120, 20); + TabOrder := 9; + Text := ''; + FontDesc := '#Edit1'; + end; + + lblName3 := TfpgLabel.Create(self); + with lblName3 do + begin + Name := 'lblName3'; + SetPosition(12, 132, 152, 14); + FontDesc := '#Label1'; + Text := 'Default file extension:'; end; {@VFD_BODY_END: frmVFDSetup} diff --git a/examples/apps/uidesigner/vfdmain.pas b/examples/apps/uidesigner/vfdmain.pas index d7d2482b..4713b7c8 100644 --- a/examples/apps/uidesigner/vfdmain.pas +++ b/examples/apps/uidesigner/vfdmain.pas @@ -39,7 +39,7 @@ type TMainDesigner = class(TObject) private procedure SetEditedFileName(const Value: string); - procedure LoadGridResolution; + procedure LoadDefaults; protected FDesigners: TList; FFile: TVFDFile; @@ -85,6 +85,9 @@ uses gui_iniutils, gfx_utils; +Var + DefaultPasExt : String = '.pas'; + { TMainDesigner } procedure TMainDesigner.OnNewFile(Sender: TObject); @@ -116,7 +119,7 @@ begin afiledialog := TfpgFileDialog.Create(nil); afiledialog.Filename := EditedFilename; afiledialog.WindowTitle := 'Open form file'; - afiledialog.Filter := 'Pascal source files (*.pas;*.inc;*.dpr;*.lpr)|*.pas;*.inc;*.dpr;*.lpr|All Files (*)|*'; + afiledialog.Filter := 'Pascal source files (*.pp;*.pas;*.inc;*.dpr;*.lpr)|*.pp;*.pas;*.inc;*.dpr;*.lpr|All Files (*)|*'; if afiledialog.RunOpenFile then begin EditedFileName := aFileDialog.Filename; @@ -180,11 +183,13 @@ begin afiledialog := TfpgFileDialog.Create(nil); afiledialog.Filename := EditedFilename; afiledialog.WindowTitle := 'Save form source'; - afiledialog.Filter := 'Pascal source files (*.pas;*.inc;*.dpr;*.lpr)|*.pas;*.inc;*.dpr;*.lpr|All Files (*)|*'; + afiledialog.Filter := 'Pascal source files (*.pp;*.pas;*.inc;*.dpr;*.lpr)|*.pp;*.pas;*.inc;*.dpr;*.lpr|All Files (*)|*'; if afiledialog.RunSaveFile then begin - EditedFileName := aFileDialog.Filename; - fname := EditedFilename; + fname:=aFileDialog.Filename; + if (ExtractFileExt(fname)='') then + fname:=fname+DefaultPasExt; + EditedFileName := fname; end else fname := ''; @@ -300,7 +305,7 @@ begin // options SaveComponentNames := True; - LoadGridResolution; + LoadDefaults; FEditedFileName := ''; end; @@ -404,7 +409,7 @@ begin try if frm.ShowModal = 1 then begin - LoadGridResolution; + LoadDefaults; frmMain.mru.MaxItems := gINI.ReadInteger('Options', 'MRUFileCount', 4); frmMain.mru.ShowFullPath := gINI.ReadBool('Options', 'ShowFullPath', True); end; @@ -424,13 +429,14 @@ begin frmMain.WindowTitle := 'fpGUI Designer v' + program_version + ' - ' + s; end; -procedure TMainDesigner.LoadGridResolution; +procedure TMainDesigner.LoadDefaults; begin case gINI.ReadInteger('Options', 'GridResolution', 1) of 0: GridResolution := 2; 1: GridResolution := 4; 2: GridResolution := 8; end; + DefaultPasExt:=gINI.ReadString('Options','DefaultFileExt', '.pas'); end; end. diff --git a/examples/apps/uidesigner/vfdpropeditgrid.pas b/examples/apps/uidesigner/vfdpropeditgrid.pas index d31f7f5b..209b1d59 100644 --- a/examples/apps/uidesigner/vfdpropeditgrid.pas +++ b/examples/apps/uidesigner/vfdpropeditgrid.pas @@ -54,6 +54,7 @@ type end; + // A normal grid's column information now become rows of data. TColumnsGrid = class(TfpgCustomGrid) protected function GetRowCount: Integer; override; @@ -293,18 +294,30 @@ begin if c = nil then Exit; - lbCOLNO.Text := IntToStr(row); - edTITLE.Text := c.Title; - edCOLWIDTH.Text := IntToStr(c.Width); - case c.Alignment of - taRightJustify: - i := 1; - taCenter: - i := 2 - else - i := 0; + try + // disable event handlers + edTITLE.OnChange := nil; + edCOLWIDTH.OnChange := nil; + chlALIGN.OnChange := nil; + + lbCOLNO.Text := IntToStr(row); + edTITLE.Text := c.Title; + edCOLWIDTH.Text := IntToStr(c.Width); + case c.Alignment of + taRightJustify: + i := 1; + taCenter: + i := 2 + else + i := 0; + end; + chlALIGN.FocusItem := i; + finally + // enable event handlers again. + edTITLE.OnChange := @EditChange; + edCOLWIDTH.OnChange := @EditChange; + chlALIGN.OnChange := @EditChange; end; - chlALIGN.FocusItem := i; end; procedure TColumnEditForm.SaveColumn(row: integer); @@ -332,8 +345,7 @@ procedure TColumnEditForm.EditChange(Sender: TObject); begin if grid.FocusRow < 0 then Exit; - - SaveColumn(grid.FocusRow); + SaveColumn(grid.FocusRow) end; procedure TColumnEditForm.NewButtonClick(Sender: TObject); |