diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/apps/uidesigner/aanewform.pas | 227 | ||||
-rw-r--r-- | examples/apps/uidesigner/icons.inc | 882 | ||||
-rw-r--r-- | examples/apps/uidesigner/newformdesigner.pas | 745 | ||||
-rw-r--r-- | examples/apps/uidesigner/uidesigner.lpi | 122 | ||||
-rw-r--r-- | examples/apps/uidesigner/uidesigner.lpr | 68 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfddesigner.pas | 1590 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdeditors.pas | 84 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdfile.pas | 381 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdformparser.pas | 537 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdforms.pas | 636 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdmain.pas | 438 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdprops.pas | 508 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdresizer.pas | 140 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdutils.pas | 82 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdwidgetclass.pas | 224 | ||||
-rw-r--r-- | examples/apps/uidesigner/vfdwidgets.pas | 263 |
16 files changed, 6927 insertions, 0 deletions
diff --git a/examples/apps/uidesigner/aanewform.pas b/examples/apps/uidesigner/aanewform.pas new file mode 100644 index 00000000..688a1cd1 --- /dev/null +++ b/examples/apps/uidesigner/aanewform.pas @@ -0,0 +1,227 @@ +unit aanewform; + +{$ifdef FPC} +{$mode objfpc}{$H+} +{$endif} + +interface + +uses + SysUtils, Classes, gfxbase, wgedit, unitkeys, schar16, gfxstyle, + gfxwidget, gfxform, wglabel, wgbutton, + wglistbox, wgmemo, wgchoicelist, wggrid, sqldb, sqluis, + wgdbgrid, gfxdialogs, wgcheckbox; + +type + + TfrmValami = class(TGfxForm) + public + {@VFD_HEAD_BEGIN: frmValami} + ed1 : TwgEdit; + btn1 : TwgButton; + chl1 : TwgChoiceList; + wg1 : Twg; + lst1 : TwgTextListBox; + memo1 : TwgMemo; + grid1 : TwgDBGrid; + panel1 : TwgBevel; + lb1 : TwgLabel; + ed2 : TwgEdit; + panel2 : TwgBevel; + lb2 : TwgLabel; + {@VFD_HEAD_END: frmValami} + + procedure AfterCreate; override; + end; + + TfrmVFDSetup = class(TGfxForm) + public + {@VFD_HEAD_BEGIN: frmVFDSetup} + panel1 : TwgBevel; + lb1 : TwgLabel; + chl1 : TwgChoiceList; + btnOK : TwgButton; + btnCancel : TwgButton; + {@VFD_HEAD_END: frmVFDSetup} + + procedure AfterCreate; override; + end; + +{@VFD_NEWFORM_DECL} + +implementation + +{@VFD_NEWFORM_IMPL} + +procedure TfrmVFDSetup.AfterCreate; +begin + {@VFD_BODY_BEGIN: frmVFDSetup} + SetDimensions(331,481,237,103); + WindowTitle8 := 'General settings'; + + panel1 := TwgBevel.Create(self); + with panel1 do + begin + SetDimensions(8,12,220,52); + shape := bsBox; + style := bsRaised; + end; + + lb1 := TwgLabel.Create(panel1); + with lb1 do + begin + SetDimensions(8,16,92,16); + Text := u8('Grid resolution:'); + FontName := '#Label1'; + end; + + chl1 := TwgChoiceList.Create(panel1); + with chl1 do + begin + SetDimensions(116,14,56,22); + Items.Add(u8('1')); + Items.Add(u8('4')); + Items.Add(u8('5')); + FontName := '#List'; + FocusItem := 2; + end; + + btnOK := TwgButton.Create(self); + with btnOK do + begin + SetDimensions(8,72,96,24); + Text := u8('OK'); + FontName := '#Label1'; + ImageName := 'stdimg.ok'; + ModalResult := 1; + end; + + btnCancel := TwgButton.Create(self); + with btnCancel do + begin + SetDimensions(132,72,96,24); + Text := u8('Cancel'); + FontName := '#Label1'; + ImageName := 'stdimg.cancel'; + ModalResult := -1; + end; + + {@VFD_BODY_END: frmVFDSetup} +end; + + +procedure TfrmValami.AfterCreate; +begin + {@VFD_BODY_BEGIN: frmValami} + SetDimensions(310,122,491,340); + WindowTitle8 := 'frmValami'; + + ed1 := TwgEdit.Create(self); + with ed1 do + begin + SetDimensions(12,48,120,22); + Text := u8(''); + FontName := '#Edit1'; + end; + + btn1 := TwgButton.Create(self); + with btn1 do + begin + SetDimensions(12,76,96,24); + Text := u8('Button'); + FontName := '#Label1'; + ImageName := 'stdimg.ok'; + ModalResult := 0; + end; + + chl1 := TwgChoiceList.Create(self); + with chl1 do + begin + SetDimensions(148,40,120,22); + Items.Add(u8('egy')); + Items.Add(u8('ketto')); + Items.Add(u8('harom')); + FontName := '#List'; + end; + + wg1 := Twg.Create(self); + with wg1 do + begin + SetDimensions(148,84,120,32); + end; + + lst1 := TwgTextListBox.Create(self); + with lst1 do + begin + SetDimensions(12,116,104,92); + Items.Add(u8('as')); + Items.Add(u8('asdf')); + Items.Add(u8('asd')); + Items.Add(u8('f as')); + FontName := '#List'; + end; + + memo1 := TwgMemo.Create(self); + with memo1 do + begin + SetDimensions(136,124,120,72); + Lines.Add(u8('valami szoveg')); + Lines.Add(u8('masodik sor')); + FontName := '#Edit1'; + end; + + grid1 := TwgDBGrid.Create(self); + with grid1 do + begin + SetDimensions(16,216,180,104); + AddColumn8('ID','',50,alLeft); + AddColumn8('NAME','',70,alLeft); + FontName := '#Grid'; + HeaderFontName := '#GridHeader'; + end; + + panel1 := TwgBevel.Create(self); + with panel1 do + begin + SetDimensions(276,156,192,148); + shape := bsBox; + style := bsRaised; + end; + + lb1 := TwgLabel.Create(panel1); + with lb1 do + begin + SetDimensions(16,8,80,16); + Text := u8('Label'); + FontName := '#Label1'; + end; + + ed2 := TwgEdit.Create(panel1); + with ed2 do + begin + SetDimensions(8,32,120,22); + Text := u8(''); + FontName := '#Edit1'; + end; + + panel2 := TwgBevel.Create(panel1); + with panel2 do + begin + SetDimensions(40,64,124,56); + shape := bsFrame; + style := bsLowered; + end; + + lb2 := TwgLabel.Create(panel2); + with lb2 do + begin + SetDimensions(32,24,80,16); + Text := u8('Label'); + FontName := '#Label1'; + end; + + {@VFD_BODY_END: frmValami} +end; + + +end. diff --git a/examples/apps/uidesigner/icons.inc b/examples/apps/uidesigner/icons.inc new file mode 100644 index 00000000..7c9ed3d5 --- /dev/null +++ b/examples/apps/uidesigner/icons.inc @@ -0,0 +1,882 @@ + +Const + stdimg_vfd_checkbox : Array[0..773] of byte = ( + 66, 77, 6, 3, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 15, 0, 0, 0, 15, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 208, 2, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, + 27, 55,229, 27, 55,229,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, 27, 55,229, 0, 0, 0, 27, 55,229, + 128,128,128, 0, 0, 0,200,208,212,200,208,212,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,255,255,255, 27, 55,229, 0, 0, 0, 27, 55,229,128,128,128, + 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,200,208,212,255, + 255,255, 27, 55,229, 0, 0, 0, 27, 55,229,128,128,128, 0, 0, 0, + 255,255,255, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255,255,255, + 255, 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, 27, + 55,229, 0, 0, 0, 27, 55,229,128,128,128, 0, 0, 0,255,255,255, + 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0, + 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, 27, 55,229, 0, + 0, 0, 27, 55,229,128,128,128, 0, 0, 0,255,255,255,255,255,255, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255, + 255,255,255,255,200,208,212,255,255,255, 27, 55,229, 0, 0, 0, 27, + 55,229,128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255,255,255, + 255,200,208,212,255,255,255, 27, 55,229, 0, 0, 0, 27, 55,229,128, + 128,128, 0, 0, 0,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255,200,208, + 212,255,255,255, 27, 55,229, 0, 0, 0, 27, 55,229,128,128,128, 0, + 0, 0,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255, + 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255, + 255, 27, 55,229, 0, 0, 0, 27, 55,229,128,128,128, 0, 0, 0,255, + 255,255, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, 27, 55, + 229, 0, 0, 0, 27, 55,229,128,128,128, 0, 0, 0,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,200,208,212,255,255,255, 27, 55,229, 0, 0, + 0, 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,200,208,212,255,255,255, 27, 55,229, 0, 0, 0, 27, 55, + 229,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128, 27, 55,229, 27, 55,229, 0, 0, 0, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 0, 0, 0); + +Const + stdimg_vfd_edit : Array[0..1421] of byte = ( + 66, 77,142, 5, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 25, 0, 0, 0, 18, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 88, 5, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 27, 55,229,128,128,128, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 27, 55, + 229, 0, 27, 55,229,128,128,128, 0, 0, 0,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,255,255,255, 27, 55,229, 0, 27, 55,229,128,128,128, 0, + 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,200,208,212,255,255,255, 27, 55,229, + 0, 27, 55,229,128,128,128, 0, 0, 0,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0, 0,255,255,255,200, + 208,212,255,255,255, 27, 55,229, 0, 27, 55,229,128,128,128, 0, 0, + 0,255,255,255,255,255,255,255,255,255,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,255,255,255,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,200,208,212,255,255,255, 27, 55,229, 0, + 27, 55,229,128,128,128, 0, 0, 0,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,255,255,255,128, 0, 0,128, 0, 0,255,255,255,128, + 0, 0,128, 0, 0,255,255,255,128, 0, 0,128, 0, 0,255,255,255, + 255,255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208, + 212,255,255,255, 27, 55,229, 0, 27, 55,229,128,128,128, 0, 0, 0, + 255,255,255,255,255,255,128, 0, 0,128, 0, 0,255,255,255,128, 0, + 0,128, 0, 0,255,255,255,128, 0, 0,128, 0, 0,255,255,255,128, + 0, 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0,255,255,255, + 255,255,255,255,255,255,200,208,212,255,255,255, 27, 55,229, 0, 27, + 55,229,128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,255,255,255,128, 0, + 0,128, 0, 0,255,255,255,128, 0, 0,128, 0, 0,255,255,255,255, + 255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212, + 255,255,255, 27, 55,229, 0, 27, 55,229,128,128,128, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,128, 0, 0, + 128, 0, 0,255,255,255,128, 0, 0,128, 0, 0,255,255,255,128, 0, + 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255, 27, 55,229, 0, 27, 55, + 229,128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255,128, + 0, 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255,128, 0, 0, + 128, 0, 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255,255,255, + 255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255, + 255,255, 27, 55,229, 0, 27, 55,229,128,128,128, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,128, 0, 0,128, 0, 0,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255, 0, 0, 0,255,255,255,255,255, + 255,255,255,255,200,208,212,255,255,255, 27, 55,229, 0, 27, 55,229, + 128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,128, 0, 0,128, + 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255,255, + 255, 27, 55,229, 0, 27, 55,229,128,128,128, 0, 0, 0,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255, 0, 0, 0, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0, 0, + 255,255,255,200,208,212,255,255,255, 27, 55,229, 0, 27, 55,229,128, + 128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,200,208,212,255,255,255, + 27, 55,229, 0, 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0,255,255,255, 27, 55,229, 0, 27, 55,229,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 27, + 55,229, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 0); + +Const + stdimg_vfd_memo : Array[0..1173] of byte = ( + 66, 77,150, 4, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 18, 0, 0, 0, 20, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 96, 4, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 0, 0, 27, 55,229,128,128,128, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 55,229, 0, 0, 27, 55,229,128, + 128,128,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55,229, 0, + 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 27, 55,229, 0, 0, 27, 55,229,128,128,128,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 255,255,255, 0, 0, 0, 27, 55,229, 0, 0, 27, 55,229,128,128,128, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55,229, 0, 0, 27, + 55,229,128,128,128,255,255,255,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, + 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0, 27, + 55,229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255, 0, 0, 0, 27, 55,229, 0, 0, 27, 55,229,128,128,128,255,255, + 255,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,255,255,255, 0, 0, 0, 27, 55,229, 0, 0, 27, 55,229, + 128,128,128,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55,229, + 0, 0, 27, 55,229,128,128,128,255,255,255,128, 0, 0,128, 0, 0, + 128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255, 0, + 0, 0, 27, 55,229, 0, 0, 27, 55,229,128,128,128,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255, 0, 0, 0, 27, 55,229, 0, 0, 27, 55,229,128,128, + 128,255,255,255,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,128, 0, 0,255,255,255, 0, 0, 0, 27, 55,229, 0, 0, + 27, 55,229,128,128,128,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 27, 55,229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255, 0, 0, 0, 27, 55,229, 0, 0, 27, 55,229,128,128,128,255, + 255,255,128, 0, 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255, 0, 0, 0, 27, 55,229, 0, 0, 27, 55, + 229,128,128,128,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 0, 0, 0, 27, 55,229, 0, 0, 27, 55,229,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128, 27, 55,229, 0, 0, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, + 0); + +Const + stdimg_vfd_button : Array[0..1005] of byte = ( + 66, 77,238, 3, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 22, 0, 0, 0, 14, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 184, 3, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212, 0, 0, 0, 0, 0, 0,200, + 208,212,200,208,212, 0, 0, 0,200,208,212, 0, 0, 0,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212, 0, 0, 0,200,208,212,200,208,212, 0, + 0, 0,200,208,212, 0, 0, 0,200,208,212, 0, 0, 0,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212, 0, 0, 0,200,208,212,200,208,212, 0, + 0, 0,200,208,212, 0, 0, 0,200,208,212, 0, 0, 0,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212, 0, 0, 0,200,208,212,200,208,212, 0, + 0, 0,200,208,212, 0, 0, 0, 0, 0, 0,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212, 0, 0, 0,200,208,212,200,208,212, 0, + 0, 0,200,208,212, 0, 0, 0,200,208,212, 0, 0, 0,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212, 0, 0, 0, 0, 0, 0,200, + 208,212,200,208,212, 0, 0, 0,200,208,212, 0, 0, 0,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0); + +Const + stdimg_vfd_choicelist : Array[0..1413] of byte = ( + 66, 77,134, 5, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 22, 0, 0, 0, 20, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 80, 5, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,128, 0, + 0,128, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,128, 0, 0,128, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, + 128, 0, 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,128,128,128,128,128,128,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,128, 0, 0,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,255,255,255, 0, 0, 0, + 255,255,255, 0, 0, 0, 0, 0, 0,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,255,255,255,255,255,255,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0); + +Const + stdimg_vfd_listbox : Array[0..1481] of byte = ( + 66, 77,202, 5, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 22, 0, 0, 0, 21, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 148, 5, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,128,128,128,128,128,128,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255, 0, 0, 0, 0, 0, 0,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,255,255,255,255,255,255,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,200,208,212,255,255,255,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,128, 0, 0,128, 0, 0,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, 0, 0, 0, + 200,208,212,255,255,255,200,208,212,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,128, 0, 0,128, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,128, 0, 0,128, 0, 0, 0, 0, 0, + 255,255,255,200,208,212,255,255,255,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,128, 0, 0,128, 0, 0,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0, 0, 0, 0, + 200,208,212,255,255,255,200,208,212,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,200,208,212,255,255,255,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 200,208,212,255,255,255,200,208,212,255,255,255, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,200,208,212,255,255,255,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255, 0, 0, 0, 0, 0, 0,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,128, 0, + 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, 0, 0,128, + 0, 0,128, 0, 0,128, 0, 0,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,128,128,128,128,128,128,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 255,255,255,255,255,255,255,255,255,200,208,212, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0); + +Const + stdimg_vfd_panel : Array[0..1549] of byte = ( + 66, 77, 14, 6, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 22, 0, 0, 0, 22, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 216, 5, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,200,208,212,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,128,128,128,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,200,208,212,255,255,255, 27, 55, + 229, 0, 0, 27, 55,229,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0); + +Const + stdimg_vfd_label : Array[0..837] of byte = ( + 66, 77, 70, 3, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 18, 0, 0, 0, 14, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 16, 3, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 0, 0, 27, 55,229, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0,128,128,128, 27, 55,229, 0, 0, 27, 55,229, 27, + 55,229, 0, 0, 0, 0, 0, 0,128,128,128, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229,128,128, + 128, 0, 0, 0, 0, 0, 0,128,128,128, 27, 55,229, 27, 55,229, 0, + 0, 27, 55,229, 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55, + 229, 27, 55,229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, + 0, 0, 0, 0,128,128,128, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128, + 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 27, 55,229, 27, 55,229, + 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, 0, 0, 0, + 128,128,128, 27, 55,229, 27, 55,229, 27, 55,229,128,128,128, 0, 0, + 0, 0, 0, 0,128,128,128, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229,128, + 128,128, 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 0, 0, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 0, 0, 0, 0, 0, 0,128,128,128, 27, + 55,229,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229,128,128,128, 0, 0, + 0, 0, 0, 0, 27, 55,229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0,128,128,128, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229,128,128,128, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,128,128,128, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 0, 0); + +Const + stdimg_vfd_scrollbar : Array[0..773] of byte = ( + 66, 77, 6, 3, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 24, 0, 0, 0, 10, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 208, 2, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55, + 229,128,128,128,200,208,212,200,208,212,200,208,212,200,208,212, 0, + 0, 0,200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, 0, + 255,255,255,200,208,212,255,255,255,200,208,212,255,255,255, 0, 0, + 0,200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, 0, 27, + 55,229, 27, 55,229,128,128,128,255,255,255,128,128,128,128,128,128, + 200,208,212, 0, 0, 0,255,255,255,200,208,212,200,208,212,200,208, + 212, 0, 0, 0,200,208,212,255,255,255,200,208,212,255,255,255,200, + 208,212, 0, 0, 0,255,255,255,128,128,128,128,128,128,200,208,212, + 0, 0, 0, 27, 55,229, 27, 55,229,128,128,128,255,255,255, 0, 0, + 0, 0, 0, 0,200,208,212, 0, 0, 0,255,255,255,200,208,212,200, + 208,212,200,208,212, 0, 0, 0,255,255,255,200,208,212,255,255,255, + 200,208,212,255,255,255, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0, + 0,200,208,212, 0, 0, 0, 27, 55,229, 27, 55,229,128,128,128,255, + 255,255,255,255,255,255,255,255,200,208,212, 0, 0, 0,255,255,255, + 255,255,255,255,255,255,200,208,212, 0, 0, 0,200,208,212,255,255, + 255,200,208,212,255,255,255,200,208,212, 0, 0, 0,255,255,255,255, + 255,255,255,255,255,200,208,212, 0, 0, 0, 27, 55,229, 27, 55,229, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229); + +Const + stdimg_vfd_arrow : Array[0..701] of byte = ( + 66, 77,190, 2, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 12, 0, 0, 0, 18, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 136, 2, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255,255,255,255,255, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255,255,255, + 255,255, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0, + 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255,255,255,255, + 255, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, + 0, 0, 0, 0, 0, 27, 55,229, 27, 55,229, 0, 0, 0,255,255,255, + 255,255,255, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0, 0,255,255,255,255, + 255,255, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255, 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 27, 55,229, 27, 55,229, 0, 0, 0,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, + 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 0, 0, + 0,255,255,255,255,255,255,255,255,255, 0, 0, 0, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 0, 0, 0,255,255,255,255,255,255, 0, 0, 0, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 0, 0, 0,255,255,255, 0, 0, 0, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 0, 0, 0, 0, 0, 0, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229); + +Const + stdimg_vfd_dbgrid : Array[0..1549] of byte = ( + 66, 77, 14, 6, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 22, 0, 0, 0, 22, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 216, 5, 0, 0, 18, 11, 0, 0, 18, 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,200,208,212, 0, 0, 0,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,255,255,255, 0, 0, 0,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,200,208,212, 0, 0, 0,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,255,255,255, 0, 0, 0,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,200,208,212, 0, 0, 0,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,255,255,255, 0, 0, 0,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,200,208,212, 0, 0, 0,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,255,255,255, 0, 0, 0,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0,200,208,212, 0, 0, 0,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, + 0,200,208,212, 0, 0, 0,255,255,255,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,255,255,255,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, 0, 0, + 0, 0, 0,128,128,128,200,208,212,128,128,128,255,255,255, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,128,128,128,255,255,255,128,128,128,255,255,255,200,208, + 212,200,208,212,255,255,255,200,208,212,255,255,255,200,208,212,200, + 208,212,200,208,212,200,208,212,255,255,255,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,200,208,212,128,128,128,255,255,255,255,255, + 255,255,255,255,255,255,255,200,208,212,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,255,255,255,128,128,128,255,255,255,200,208, + 212,200,208,212,255,255,255,200,208,212,255,255,255,200,208,212,200, + 208,212,200,208,212,255,255,255,255,255,255,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,200,208,212,128,128,128,255,255,255,255,255, + 255,255,255,255,255,255,255,200,208,212,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,255,255,255,128,128,128,255,255,255,200,208, + 212,200,208,212,255,255,255,200,208,212,255,255,255,200,208,212,200, + 208,212,200,208,212,200,208,212,255,255,255,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,200,208,212,128,128,128,255,255,255,255,255, + 255,255,255,255,255,255,255,200,208,212,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,200,208,212,128,128,128,255,255,255,200,208, + 212,200,208,212,200,208,212,200,208,212,255,255,255,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128, 34, 34,217, + 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34,217, 34, 34, + 217, 0, 0); + +Const + stdimg_vfd_other : Array[0..1549] of byte = ( + 66, 77, 14, 6, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 22, 0, 0, 0, 22, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 216, 5, 0, 0,195, 10, 0, 0,195, 10, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, 0, + 0, 0, 0, 0, 0,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, 0, + 0, 0, 0, 0, 0,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, 0, + 0, 0, 0, 0, 0,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, 0, + 0, 0, 0, 0, 0,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192, 10, 25, 10, 0, 0, 0,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192, 19, 47, 19, 0, 0, 0,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192, 0, 0, 0, 15, 39, 15,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192, 0, 0, 0, 1, 4, 1,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192, 21, 53, 21,192,224,192,192, + 224,192,192,224,192, 34, 85, 34, 0, 0, 0, 8, 20, 8,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192, 19, 47, 19, 4, + 10, 4, 1, 4, 1, 13, 34, 13,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0,192,224,192,192,224,192,192,224, + 192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192,192, + 224,192,192,224,192,192,224,192,192,224,192,192,224,192,192,224,192, + 192,224,192,192,224,192,192,224,192,192,224,192, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, + 229, 0, 0, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, + 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, + 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55,229, 27, 55, + 229, 0, 0); diff --git a/examples/apps/uidesigner/newformdesigner.pas b/examples/apps/uidesigner/newformdesigner.pas new file mode 100644 index 00000000..751ed3de --- /dev/null +++ b/examples/apps/uidesigner/newformdesigner.pas @@ -0,0 +1,745 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Essential classes used by the uiDesigner +} + +unit newformdesigner; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, + Classes, + gfxbase, + gfx_widget, + gui_form, + gui_label, + gui_button, + gui_edit, + gui_listbox, + gui_memo, + gui_combobox, + gui_menu, + vfdwidgetclass, + vfdwidgets; + +type + + TwgPaletteButton = class(TfpgButton) + public + VFDWidget: TVFDWidgetClass; + end; + + + TwgPalette = class(TfpgWidget) + protected + procedure HandlePaint; override; + end; + + + TfrmMain = class(TfpgForm) + public + {@VFD_HEAD_BEGIN: frmMain} + btnOpen: TfpgButton; + MainMenu: TfpgMenuBar; + btnSave: TfpgButton; + wgpalette: TwgPalette; + chlPalette: TfpgComboBox; + {@VFD_HEAD_END: frmMain} + + FileMenu: TfpgPopupMenu; + FormMenu: TfpgPopupMenu; + SetMenu: TfpgPopupMenu; + function GetSelectedWidget: TVFDWidgetClass; + procedure SetSelectedWidget(wgc: TVFDWidgetClass); + procedure AfterCreate; override; + procedure OnPaletteClick(Sender: TObject); + property SelectedWidget: TVFDWidgetClass read GetSelectedWidget write SetSelectedWidget; + end; + + + TPropertyList = class(TObject) + private + FList: TList; + public + Widget: TfpgWidget; + constructor Create; + destructor Destroy; override; + function GetCount: integer; + procedure Clear; + property Count: integer read GetCount; + procedure AddItem(aProp: TVFDWidgetProperty); + function GetItem(index: integer): TVFDWidgetProperty; + end; + + + TwgPropertyList = class(TfpgListBox) + protected + procedure DrawItem(num: integer; rect: TfpgRect; flags: integer); override; + procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); override; + procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; + procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; + procedure HandleSetFocus; override; + procedure HandleKillFocus; override; + procedure OnRowChange(Sender: TObject); + procedure OnUpdateProperty(Sender: TObject); + public + Props: TPropertyList; + NameWidth: integer; + editor: TVFDPropertyEditor; + NameDrag: boolean; + NameDragPos: integer; + BackgroundColor: TfpgColor; + procedure ReleaseEditor; + procedure AllocateEditor; + constructor Create(AOwner: TComponent); override; + function ItemCount: integer; override; + function RowHeight: integer; override; + procedure RealignEditor; + end; + + + TfrmProperties = class(TfpgForm) + protected + procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + public + l1, l2, l3, l4, l5, l6, l7, l8: TfpgLabel; + lbClass: TfpgLabel; + edName: TfpgEdit; + edOther: TfpgMemo; + btnTop, btnLeft, btnWidth, btnHeight: TfpgButton; + btnAnLeft, btnAnTop, btnAnRight, btnAnBottom: TfpgButton; + lstProps: TwgPropertyList; + procedure AfterCreate; override; + end; + +{@VFD_NEWFORM_DECL} + +var + frmProperties: TfrmProperties; + frmMain: TfrmMain; + + PropList: TPropertyList; + +implementation + +uses + fpgfx, + vfdmain; + +const + vfd_anchorbottom: array[0..121] of byte = ( + 66, 77, 122, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 40, 0, 0, + 0, 15, 0, 0, 0, 15, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 235, 10, 0, 0, 235, 10, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 254, 0, 0, 128, 2, + 0, 0, 254, 254, 0, 0, 252, 126, 0, 0, 248, 62, 0, 0, 240, 30, 0, + 0, 255, 254, 0, 0, 255, 254, 0, 0, 255, 254, 0, 0, 255, 254, 0, 0, + 255, 254, 0, 0, 255, 254, 0, 0, 255, 254, 0, 0, 255, 254, 0, 0, 255, + 254, 0, 0); + + vfd_anchorleft: array[0..121] of byte = ( + 66, 77, 122, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 40, 0, 0, + 0, 15, 0, 0, 0, 15, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 235, 10, 0, 0, 235, 10, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 254, 0, 0, 191, 254, + 0, 0, 191, 254, 0, 0, 191, 254, 0, 0, 187, 254, 0, 0, 179, 254, 0, + 0, 163, 254, 0, 0, 131, 254, 0, 0, 163, 254, 0, 0, 179, 254, 0, 0, + 187, 254, 0, 0, 191, 254, 0, 0, 191, 254, 0, 0, 191, 254, 0, 0, 255, + 254, 0, 0); + + vfd_anchorright: array[0..121] of byte = ( + 66, 77, 122, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 40, 0, 0, + 0, 15, 0, 0, 0, 15, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 235, 10, 0, 0, 235, 10, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 254, 0, 0, 255, 250, + 0, 0, 255, 250, 0, 0, 255, 250, 0, 0, 255, 186, 0, 0, 255, 154, 0, + 0, 255, 138, 0, 0, 255, 130, 0, 0, 255, 138, 0, 0, 255, 154, 0, 0, + 255, 186, 0, 0, 255, 250, 0, 0, 255, 250, 0, 0, 255, 250, 0, 0, 255, + 254, 0, 0); + + vfd_anchortop: array[0..121] of byte = ( + 66, 77, 122, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 40, 0, 0, + 0, 15, 0, 0, 0, 15, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 235, 10, 0, 0, 235, 10, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 254, 0, 0, 255, 254, + 0, 0, 255, 254, 0, 0, 255, 254, 0, 0, 255, 254, 0, 0, 255, 254, 0, + 0, 255, 254, 0, 0, 255, 254, 0, 0, 255, 254, 0, 0, 240, 30, 0, 0, + 248, 62, 0, 0, 252, 126, 0, 0, 254, 254, 0, 0, 128, 2, 0, 0, 255, + 254, 0, 0); + +{@VFD_NEWFORM_IMPL} + +procedure TfrmMain.AfterCreate; +var + n: integer; + x: integer; + wgc: TVFDWidgetClass; + btn: TwgPaletteButton; + mi: TfpgMenuItem; +begin + {@VFD_BODY_BEGIN: frmMain} + WindowPosition := wpUser; + WindowTitle := 'frmMain'; + SetPosition(0, 0, 506, 87); + + MainMenu := TfpgMenuBar.Create(self); + with MainMenu do + SetPosition(0, 0, 500, 24); + + btnOpen := TfpgButton.Create(self); + with btnOpen do + begin + SetPosition(4, 40, 25, 24); + Text := ''; + ImageName := 'stdimg.open'; + ShowImage := True; + Focusable := False; + OnClick := @(maindsgn.OnLoadFile); + end; + + btnSave := TfpgButton.Create(self); + with btnSave do + begin + SetPosition(32, 40, 25, 24); + Text := ''; + ImageName := 'stdimg.save'; + ShowImage := True; + Focusable := False; + OnClick := @(maindsgn.OnSaveFile); + end; + + wgpalette := TwgPalette.Create(self); + with wgpalette do + SetPosition(116, 28, 384, 28); + + chlPalette := TfpgComboBox.Create(self); + with chlPalette do + begin + SetPosition(116, 60, 386, 22); + Items.Add('-'); + end; + + {@VFD_BODY_END: frmMain} + + + wgpalette.Focusable := False; + + x := 0; + for n := 1 to VFDWidgetCount do + begin + wgc := VFDWidget(n); + btn := TwgPaletteButton.Create(wgpalette); + btn.VFDWidget := wgc; + btn.SetPosition(x, 0, 30, 28); + btn.ImageName := wgc.WidgetIconName; + btn.ImageMargin := -1; + btn.Text := ''; + btn.Focusable := False; + btn.OnClick := @OnPaletteClick; + btn.GroupIndex := 1; + btn.AllowAllUp := True; + chlPalette.Items.AddObject(wgc.WidgetClass.ClassName, wgc); + + Inc(x, 32); + end; + + filemenu := TfpgPopupMenu.Create(self); + with filemenu do + begin + mi := AddMenuItem('New', '', nil); + mi.OnClick := @(maindsgn.OnNewFile); + mi := AddMenuItem('Open', '', nil); + mi.OnClick := @(maindsgn.OnLoadFile); + mi := AddMenuItem('Save', '', nil); + mi.OnClick := @(maindsgn.OnSaveFile); + AddMenuItem('-', '', nil); + mi := AddMenuItem('New Form...', '', nil); + mi.OnClick := @(maindsgn.OnNewForm); + AddMenuItem('-', '', nil); + mi := AddMenuItem('Exit', '', nil); + mi.OnClick := @(maindsgn.OnExit); + end; + + formmenu := TfpgPopupMenu.Create(self); + with formmenu do + begin + mi := AddMenuItem('Widget Order...', '', nil); + mi.OnClick := @(maindsgn.OnEditWidgetOrder); + AddMenuItem('-', '', nil); + AddMenuItem('Edit special...', '', nil); + end; + + setmenu := TfpgPopupMenu.Create(self); + with setmenu do + begin + mi := AddMenuItem('General options ...', '', nil); + mi.OnClick := @(maindsgn.OnOptionsClick); + end; + + MainMenu.AddMenuItem('&File', nil).SubMenu := filemenu; + MainMenu.AddMenuItem('&Settings', nil).SubMenu := setmenu; + MainMenu.AddMenuItem('Fo&rm', nil).SubMenu := formmenu; +end; + +procedure TfrmMain.OnPaletteClick(Sender: TObject); +var + s: string; + i: integer; +begin + if TwgPaletteButton(Sender).Down then + begin + s := TwgPaletteButton(Sender).VFDWidget.WidgetClass.ClassName; + i := chlPalette.Items.IndexOf(s); + if i >= 0 then + chlPalette.FocusItem := i + 1; + end + else + chlPalette.FocusItem := 1; +end; + +{ TfrmProperties } + +procedure TfrmProperties.AfterCreate; +var + x, x2, w, y, gap: integer; +begin + inherited; + + fpgImages.AddBMP( + 'vfd.anchorleft', @vfd_anchorleft, + sizeof(vfd_anchorleft) + ); + + fpgImages.AddBMP( + 'vfd.anchorright', @vfd_anchorright, + sizeof(vfd_anchorright) + ); + + fpgImages.AddBMP( + 'vfd.anchortop', @vfd_anchortop, + sizeof(vfd_anchortop) + ); + + fpgImages.AddBMP( + 'vfd.anchorbottom', @vfd_anchorbottom, + sizeof(vfd_anchorbottom) + ); + + + WindowPosition := wpUser; + WindowTitle := 'Properties'; + SetPosition(0, 120, 250, 450); + + x := 3; + x2 := x + 50; + gap := 20; + w := Width - x2; + y := 3; + + l1 := CreateLabel(self, 0, y, 'Class:'); + lbClass := CreateLabel(self, x2, y, 'CLASS'); + lbClass.Width := w; + lbClass.FontDesc := '#Label2'; + lbClass.Anchors := [anLeft, anRight, anTop]; + Inc(y, gap); + + l2 := CreateLabel(self, 0, y + 1, 'Name:'); + edName := CreateEdit(self, x2, y, w, 0); + edName.Text := 'NAME'; + edName.Anchors := [anLeft, anRight, anTop]; + edName.OnChange := @(maindsgn.OnPropNameChange); + + Inc(y, gap + 5); + + lstProps := TwgPropertyList.Create(self); + lstProps.SetPosition(0, y, Width, self.Height - y - 220); + lstProps.Anchors := AllAnchors; + lstProps.Props := PropList; + lstProps.Props.Widget := edName; + + y := lstProps.Bottom + 5; + + //inc(y, gap+5); + + l3 := CreateLabel(self, 3, y + 1, 'Left:'); + l3.Anchors := [anLeft, anBottom]; + btnLeft := CreateButton(self, 50, y - 2, 48, '1234', @(maindsgn.OnPropPosEdit)); + with btnLeft do + begin + Height := 22; + btnLeft.Anchors := [anLeft, anBottom]; + Focusable := False; + end; + l4 := CreateLabel(self, 110, y, 'Top:'); + l4.Anchors := [anLeft, anBottom]; + btnTop := CreateButton(self, 160, y - 2, 48, '45', @(maindsgn.OnPropPosEdit)); + with btnTop do + begin + Height := 22; + btnLeft.Anchors := [anLeft, anBottom]; + Focusable := False; + end; + Inc(y, gap + 5); + l5 := CreateLabel(self, 3, y + 1, 'Width:'); + l5.Anchors := [anLeft, anBottom]; + btnWidth := CreateButton(self, 50, y - 2, 48, '1234', @(maindsgn.OnPropPosEdit)); + with btnWidth do + begin + Height := 22; + btnLeft.Anchors := [anLeft, anBottom]; + Focusable := False; + end; + l6 := CreateLabel(self, 110, y, 'Height:'); + l6.Anchors := [anLeft, anBottom]; + btnHeight := CreateButton(self, 160, y - 2, 48, '45', @(maindsgn.OnPropPosEdit)); + with btnHeight do + begin + Height := 22; + btnLeft.Anchors := [anLeft, anBottom]; + Focusable := False; + end; + Inc(y, gap + 5); + + l8 := CreateLabel(self, 3, y + 1, 'Anchors:'); + l8.Anchors := [anLeft, anBottom]; + + x := 64; + + btnAnLeft := CreateButton(self, x, y - 2, 28, '', nil); + with btnAnLeft do + begin + ImageName := 'vfd.anchorleft'; + ShowImage := True; + AllowAllUp := True; + GroupIndex := 1; + Focusable := False; + Anchors := [anLeft, anBottom]; + OnClick := @(maindsgn.OnAnchorChange); + end; + + Inc(x, 30); + btnAnTop := CreateButton(self, x, y - 2, 26, '', nil); + with btnAnTop do + begin + ImageName := 'vfd.anchortop'; + ShowImage := True; + AllowAllUp := True; + GroupIndex := 2; + Focusable := False; + Anchors := [anLeft, anBottom]; + OnClick := @(maindsgn.OnAnchorChange); + end; + + Inc(x, 30); + btnAnBottom := CreateButton(self, x, y - 2, 26, '', nil); + with btnAnBottom do + begin + ImageName := 'vfd.anchorbottom'; + ShowImage := True; + AllowAllUp := True; + GroupIndex := 3; + Focusable := False; + Anchors := [anLeft, anBottom]; + OnClick := @(maindsgn.OnAnchorChange); + end; + + Inc(x, 30); + btnAnRight := CreateButton(self, x, y - 2, 26, '', nil); + with btnAnRight do + begin + ImageName := 'vfd.anchorright'; + ShowImage := True; + AllowAllUp := True; + GroupIndex := 4; + Focusable := False; + Anchors := [anLeft, anBottom]; + OnClick := @(maindsgn.OnAnchorChange); + end; + + y := btnAnRight.Bottom + 5; + + l7 := CreateLabel(self, 0, y, 'Unknown lines:'); + l7.Anchors := [anLeft, anBottom]; + Inc(y, 16); + + edOther := TfpgMemo.Create(self); + edOther.SetPosition(0, y, self.Width, self.Height - y); + edOther.Anchors := [anLeft, anRight, anBottom]; + edOther.FontDesc := '#Edit2'; + edOther.OnChange := @(maindsgn.OnOtherChange); +end; + +procedure TfrmProperties.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); +begin + if (keycode = keyEnter) or (keycode = keyF11) then + begin + if maindsgn.selectedform <> nil then + maindsgn.selectedform.Form.SetFocus; +// GfxActivateWindow(maindsgn.selectedform.Form.WinHandle); + consumed := True; + end + else + inherited; +end; + +{ TPropertyList } + +procedure TPropertyList.AddItem(aProp: TVFDWidgetProperty); +begin + { + result := TPropertyLine.Create; + result.name := aPropName; + result.propclass := apropclass; + result.value := aPropName; +} + FList.Add(aProp); +end; + +procedure TPropertyList.Clear; + //var + // n : integer; +begin + //for n:=0 to FList.Count-1 do TObject(FList[n]).Free; + FList.Clear; +end; + +constructor TPropertyList.Create; +begin + FList := TList.Create; + Widget := nil; +end; + +destructor TPropertyList.Destroy; +begin + Clear; + FList.Free; + inherited; +end; + +function TPropertyList.GetCount: integer; +begin + Result := FList.Count; +end; + +function TPropertyList.GetItem(index: integer): TVFDWidgetProperty; +begin + if (index < 1) or (index > Count) then + Result := nil + else + Result := TVFDWidgetProperty(FList[index - 1]); +end; + +{ TwgPropertyList } + +constructor TwgPropertyList.Create(AOwner: TComponent); +begin + inherited; + NameWidth := 80; + editor := nil; + OnChange := @OnRowChange; + BackgroundColor := clWindowBackground; + NameDrag := False; + //FontName := 'arial-10:antialias=false'; +end; + +procedure TwgPropertyList.OnRowChange(Sender: TObject); +begin + AllocateEditor; +end; + +procedure TwgPropertyList.DrawItem(num: integer; rect: TfpgRect; flags: integer); +var + x, + y, + fy: integer; + s: string; + prop: TVFDWidgetProperty; + r: TfpgRect; +begin + //inherited; + prop := Props.GetItem(num); + if prop = nil then + Exit; + + x := rect.left; + y := rect.top; + fy := y + rect.Height div 2 - FFont.Height div 2; + + s := prop.Name; + Canvas.DrawString(x + 1, fy, s); + + Inc(x, NameWidth); + Canvas.SetColor(clShadow1); + Canvas.DrawLine(x, rect.top, x, rect.bottom); + Inc(x); + // Drawing the contents + r.SetRect(x, y, rect.right - x, rect.Height); + Canvas.SetColor(FBackgroundColor); + Canvas.FillRectangle(r); + Canvas.SetTextColor(clText1); + Inc(r.left, 2); + Dec(r.Width, 2); + prop.DrawValue(props.Widget, Canvas, r, flags); + + Canvas.SetColor(clShadow1); + Canvas.DrawLine(0, rect.bottom, rect.right, rect.bottom); +end; + +function TwgPropertyList.ItemCount: integer; +begin + Result := Props.Count; +end; + +function TwgPropertyList.RowHeight: integer; +begin + Result := 22; +end; + +procedure TwgPropertyList.OnUpdateProperty(Sender: TObject); +begin +// writeln('updating property...'); + editor.StoreValue(props.Widget); + props.Widget.UpdateWindowPosition; +end; + +procedure TwgPropertyList.HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); +begin + if not NameDrag then + begin + if (x >= FMargin + NameWidth - 2) and (x <= FMargin + NameWidth + 2) then + MouseCursor := mcSizeEW + else + MouseCursor := mcDefault; + end + else + begin + NameWidth := x - FMargin; + ReAlignEditor; + RePaint; + end; + inherited; +end; + +procedure TwgPropertyList.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); +begin + if MouseCursor = mcSizeEW then + NameDrag := True + //NameDragPos := x; + else + inherited; +end; + +procedure TwgPropertyList.HandleLMouseUp(x, y: integer; shiftstate: TShiftState); +begin + if NameDrag then + NameDrag := False + else + inherited; +end; + +procedure TwgPropertyList.HandleSetFocus; +begin + inherited HandleSetFocus; + if Editor <> nil then + Editor.Visible := True + else + AllocateEditor; +end; + +procedure TwgPropertyList.HandleKillFocus; +begin + inherited HandleKillFocus; + Editor.Visible := True; +end; + +procedure TwgPropertyList.RealignEditor; +var + x: integer; +begin + if editor = nil then + Exit; + x := 3 + NameWidth; + editor.SetPosition(x, editor.Top, Width - ScrollBarWidth - x, editor.Height); +end; + +function TfrmMain.GetSelectedWidget: TVFDWidgetClass; +begin + if chlPalette.FocusItem > 1 then + Result := TVFDWidgetClass(chlPalette.Items.Objects[chlPalette.FocusItem - 1]) + else + Result := nil; +end; + +procedure TfrmMain.SetSelectedWidget(wgc: TVFDWidgetClass); +var + n: integer; +begin + if wgc = nil then + begin + chlPalette.FocusItem := 1; + for n := 0 to wgpalette.ComponentCount - 1 do + if wgpalette.Components[n] is TwgPaletteButton then + TwgPaletteButton(wgpalette.Components[n]).Down := False; + end; +end; + +procedure TwgPropertyList.ReleaseEditor; +begin + self.ActiveWidget := nil; + if editor <> nil then + editor.Free; + editor := nil; +end; + +procedure TwgPropertyList.AllocateEditor; +var + x, y: integer; + prop: TVFDWidgetProperty; +begin + prop := Props.GetItem(FFocusItem); + if prop = nil then + Exit; + + self.ActiveWidget := nil; + if editor <> nil then + editor.Free; + + editor := prop.CreateEditor(Self); + x := 3 + NameWidth; + y := FMargin + (FFocusItem - FFirstItem) * RowHeight; + editor.SetPosition(x, y - 1, Width - ScrollBarWidth - x, RowHeight); + editor.CreateLayout; + editor.OnUpdate := @OnUpdateProperty; + editor.LoadValue(Props.Widget); + editor.Visible := True; + + self.ActiveWidget := editor; +end; + +{ TwgPalette } + +procedure TwgPalette.HandlePaint; +begin +// inherited HandlePaint; + Canvas.BeginDraw; + Canvas.Clear(clWindowBackground); + Canvas.EndDraw; +end; + +end. + diff --git a/examples/apps/uidesigner/uidesigner.lpi b/examples/apps/uidesigner/uidesigner.lpi new file mode 100644 index 00000000..7ddc1083 --- /dev/null +++ b/examples/apps/uidesigner/uidesigner.lpi @@ -0,0 +1,122 @@ +<?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="uiDesigner"/> + </General> + <VersionInfo> + <ProjectVersion Value=""/> + </VersionInfo> + <PublishOptions> + <Version Value="2"/> + <IgnoreBinaries Value="False"/> + <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="13"> + <Unit0> + <Filename Value="uidesigner.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="uidesigner"/> + </Unit0> + <Unit1> + <Filename Value="vfdmain.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdmain"/> + </Unit1> + <Unit2> + <Filename Value="vfdresizer.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdresizer"/> + </Unit2> + <Unit3> + <Filename Value="vfdforms.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdforms"/> + </Unit3> + <Unit4> + <Filename Value="vfddesigner.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfddesigner"/> + </Unit4> + <Unit5> + <Filename Value="vfdfile.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdfile"/> + </Unit5> + <Unit6> + <Filename Value="newformdesigner.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="newformdesigner"/> + </Unit6> + <Unit7> + <Filename Value="vfdwidgets.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdwidgets"/> + </Unit7> + <Unit8> + <Filename Value="vfdwidgetclass.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdwidgetclass"/> + </Unit8> + <Unit9> + <Filename Value="vfdeditors.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdeditors"/> + </Unit9> + <Unit10> + <Filename Value="vfdformparser.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdformparser"/> + </Unit10> + <Unit11> + <Filename Value="vfdprops.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdprops"/> + </Unit11> + <Unit12> + <Filename Value="vfdutils.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="vfdutils"/> + </Unit12> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <Parsing> + <SyntaxOptions> + <AllowLabel Value="False"/> + <CPPInline Value="False"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CustomOptions Value="-FUunits +"/> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/apps/uidesigner/uidesigner.lpr b/examples/apps/uidesigner/uidesigner.lpr new file mode 100644 index 00000000..87df7bd2 --- /dev/null +++ b/examples/apps/uidesigner/uidesigner.lpr @@ -0,0 +1,68 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + The starting unit for the uiDesigner project. +} + +program uidesigner; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, SysUtils, fpgfx, vfdmain, vfdresizer, vfdforms, vfddesigner, + vfdfile, newformdesigner, vfdwidgets, vfdformparser, vfdeditors, + vfdwidgetclass, vfdutils, vfdprops; + + +procedure MainProc; +begin + fpgApplication.Initialize; + + RegisterWidgets; + PropList := TPropertyList.Create; + maindsgn := TMainDesigner.Create; + maindsgn.CreateWindows; + maindsgn.EditedFileName := ParamStr(1); + if FileExists(maindsgn.EditedFileName) then + maindsgn.OnLoadFile(maindsgn); + + // Note: This needs improving!! + fpgApplication.ProcessMessages; + repeat + fpgWaitWindowMessage; + until (not frmMain.Visible); + +{ + repeat + try + fpgDoMessageLoop; + break; + except + on e: Exception do + ShowMessage(e.message, 'Exception'); + end; + until False; +} + +// fpgApplication.Run; +end; + +begin + MainProc; +end. + + diff --git a/examples/apps/uidesigner/vfddesigner.pas b/examples/apps/uidesigner/vfddesigner.pas new file mode 100644 index 00000000..c094c8c0 --- /dev/null +++ b/examples/apps/uidesigner/vfddesigner.pas @@ -0,0 +1,1590 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + A lot of the main code is here. +} + + +unit vfddesigner; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfxbase, + fpgfx, + gfx_widget, + gui_form, + gui_dialogs, + gui_label, + gui_edit, + gui_button, + gui_listbox, + gui_memo, + gui_combobox, + gui_checkbox, + vfdresizer, + vfdforms, + vfdeditors, + vfdwidgetclass, + vfdwidgets, + newformdesigner; + +type + + TOtherWidget = class(TfpgWidget) + protected + FFont: TfpgFont; + FBackgroundColor: TfpgColor; + procedure HandlePaint; override; + public + wgClassName: string; + constructor Create(AOwner: TComponent); override; + end; + + + TFormDesigner = class; + + + TDesignedForm = class(TfpgForm) + public + procedure AfterCreate; override; + FormDesigner: TFormDesigner; + end; + + + TWidgetDesigner = class(TObject) + private + procedure SetSelected(const AValue: boolean); + public + FFormDesigner: TFormDesigner; + FWidget: TfpgWidget; + FVFDClass: TVFDWidgetClass; + FSelected: boolean; + resizer: array[1..8] of TwgResizer; + other: TStringList; + constructor Create(AFormDesigner: TFormDesigner; wg: TfpgWidget; wgc: TVFDWidgetClass); + destructor Destroy; override; + property Selected: boolean read FSelected write SetSelected; + property Widget: TfpgWidget read FWidget; + procedure UpdateResizerPositions; + property FormDesigner: TFormDesigner read FFormDesigner; + end; + + + TFormDesigner = class(TObject) + protected + FWidgets: TList; + FForm: TDesignedForm; + FFormOther: string; + FDragging: boolean; + FDragPosX, + FDragPosY: TfpgCoord; + FWasDrag: boolean; + protected + // messages of the designed widgets + procedure MsgMouseDown(var msg: TfpgMessageRec); message FPGM_MOUSEDOWN; + procedure MsgMouseUp(var msg: TfpgMessageRec); message FPGM_MOUSEUP; + procedure MsgMouseMove(var msg: TfpgMessageRec); message FPGM_MOUSEMOVE; + procedure MsgKeyPress(var msg: TfpgMessageRec); message FPGM_KEYPRESS; + procedure MsgMove(var msg: TfpgMessageRec); message FPGM_MOVE; + procedure MsgResize(var msg: TfpgMessageRec); message FPGM_RESIZE; + procedure MsgActivate(var msg: TfpgMessageRec); message FPGM_ACTIVATE; + public + OneClickMove: boolean; // the widgets can be selected and dragged within one click + constructor Create; + destructor Destroy; override; + procedure ClearForm; + procedure DefaultHandler(var msg); override; + procedure Show; + procedure InitTest; + function AddWidget(wg: TfpgWidget; wgc: TVFDWidgetClass): TWidgetDesigner; + function WidgetDesigner(wg: TfpgWidget): TWidgetDesigner; + function FindWidgetByName(const wgname: string): TfpgWidget; + procedure DeSelectAll; + procedure SelectAll; + procedure SelectNextWidget(fw: boolean); + procedure MoveResizeWidgets(dx, dy, dw, dh: integer); + procedure DeleteWidgets; + procedure EditWidgetOrder; + procedure DesignerKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); + procedure PutControlByName(x, y: integer; cname: string); + procedure InsertWidget(pwg: TfpgWidget; x, y: integer; wgc: TVFDWidgetClass); + procedure OnPaletteChange(Sender: TObject); + procedure UpdatePropWin; + procedure OnPropTextChange(Sender: TObject); + procedure OnPropNameChange(Sender: TObject); + procedure OnPropPosEdit(Sender: TObject); + procedure OnOtherChange(Sender: TObject); + procedure OnAnchorChange(Sender: TObject); + procedure OnEditWidget(Sender: TObject); + function GenerateNewName(namebase: string): string; + procedure RunWidgetEditor(wgd: TWidgetDesigner; wg: TfpgWidget); + public + function GetFormSourceDecl: string; + function GetFormSourceImpl: string; + function GetWidgetSourceImpl(wd: TWidgetDesigner; ident: string): string; + property Form: TDesignedForm read FForm; + property FormOther: string read FFormOther write FFormOther; + end; + + +implementation + +uses + vfdmain; + +{ TWidgetDesigner } + +procedure TWidgetDesigner.SetSelected(const AValue: boolean); +var + n: integer; +begin + if FSelected = AValue then + Exit; + FSelected := AValue; + + if FSelected then + Widget.MouseCursor := mcMove + else + Widget.MouseCursor := mcDefault; + + for n := 1 to 8 do + if FSelected then + resizer[n] := TwgResizer.Create(self, n) + else + begin + if resizer[n] <> nil then + resizer[n].Free; + resizer[n] := nil; + end; + + UpdateResizerPositions; + + if FSelected and (Widget.Parent.WinHandle > 0) then + for n := 1 to 8 do + resizer[n].Show; +end; + +constructor TWidgetDesigner.Create(AFormDesigner: TFormDesigner; wg: TfpgWidget; wgc: TVFDWidgetClass); +var + n: integer; +begin + FFormDesigner := AFormDesigner; + FWidget := wg; + FVFDClass := wgc; + for n := 1 to 8 do + resizer[n] := nil; + FSelected := False; + wg.MouseCursor := mcDefault; + other := TStringList.Create; +end; + +destructor TWidgetDesigner.Destroy; +var + n: integer; +begin + for n := 1 to 8 do + if resizer[n] <> nil then + resizer[n].Free; + other.Free; + inherited Destroy; +end; + +procedure TWidgetDesigner.UpdateResizerPositions; +var + n: integer; + rs: TwgResizer; +begin + if not FSelected then + Exit; + + for n := 1 to 8 do + begin + rs := resizer[n]; + + if rs <> nil then + begin + case n of + 1: + begin + rs.left := Widget.left - 2; + rs.Top := Widget.Top - 2; + end; + 2: + begin + rs.Top := Widget.Top - 2; + rs.left := Widget.left + Widget.Width div 2 - 2; + end; + 3: + begin + rs.Top := Widget.Top - 2; + rs.left := Widget.left + Widget.Width - 1 - 2; + end; + 4: + begin + rs.Top := Widget.Top + Widget.Height div 2 - 2; + rs.left := Widget.left + Widget.Width - 1 - 2; + end; + 5: + begin + rs.Top := Widget.Top + Widget.Height - 1 - 2; + rs.left := Widget.left + Widget.Width - 1 - 2; + end; + 6: + begin + rs.Top := Widget.Top + Widget.Height - 1 - 2; + rs.left := Widget.left + Widget.Width div 2 - 2; + end; + 7: + begin + rs.Top := Widget.Top + Widget.Height - 1 - 2; + rs.left := Widget.left - 2; + end; + 8: + begin + rs.Top := Widget.Top + Widget.Height div 2 - 2; + rs.left := Widget.left - 2; + end; + end; // case + if rs.HasHandle then + rs.UpdateWindowPosition; + end; + end; + +end; + +{ TFormDesigner } + +procedure TFormDesigner.MsgMouseDown(var msg: TfpgMessageRec); +var + wgd: TWidgetDesigner; + shift: boolean; +begin + FDragging := True; + FWasDrag := False; + FDragPosX := msg.Params.mouse.x; + FDragPosy := msg.Params.mouse.y; + + if msg.dest = FForm then + Exit; + + wgd := WidgetDesigner(TfpgWidget(msg.dest)); + if wgd = nil then + Exit; + + if not OneClickMove then + Exit; // this Exit disables one click move + + shift := (ssShift in msg.Params.mouse.shiftstate); + + if shift then + Exit; + + if not wgd.Selected then + begin + DeSelectAll; + wgd.Selected := True; + UpdatePropWin; + end; +end; + +procedure TFormDesigner.MsgMouseUp(var msg: TfpgMessageRec); +var + wgd: TWidgetDesigner; + wgc: TVFDWidgetClass; + pwg: TfpgWidget; + shift: boolean; + x, y: integer; +begin + FDragging := False; + + shift := (ssShift in msg.Params.mouse.shiftstate); + + wgc := frmMain.SelectedWidget; + pwg := TfpgWidget(msg.dest); + wgd := WidgetDesigner(TfpgWidget(msg.dest)); + if wgd = nil then + pwg := FForm + else if not wgd.FVFDClass.Container then + wgc := nil; + + if wgc <> nil then + begin + DeSelectAll; + + if wgc <> nil then + begin + x := msg.Params.mouse.x; + y := msg.Params.mouse.y; + + if GridResolution > 1 then + begin + x := x - x mod GridResolution; + y := y - y mod GridResolution; + end; + + InsertWidget(pwg, x, y, wgc); + + if not shift then + begin + FForm.MouseCursor := mcDefault; + frmMain.SelectedWidget := nil; + end; + end; + end + else + begin + wgd := WidgetDesigner(TfpgWidget(msg.dest)); + if wgd = nil then + begin + DeSelectAll; + UpdatePropWin; + Exit; + end; + + if not shift then + begin + if not wgd.Selected then + DeSelectAll; + wgd.Selected := True; + end + else + wgd.Selected := not wgd.Selected; + end; + + UpdatePropWin; +end; + +procedure TFormDesigner.MsgMouseMove(var msg: TfpgMessageRec); +var + dx, dy: integer; + wgd: TWidgetDesigner; +begin + if not FDragging then + Exit; + + FWasDrag := True; + + dx := msg.Params.mouse.x - FDragPosX; + dy := msg.Params.mouse.y - FDragPosY; + + wgd := WidgetDesigner(TfpgWidget(msg.dest)); + if (wgd = nil) or (not wgd.Selected) then + Exit; + + if GridResolution > 1 then + begin + dx := dx - (dx mod GridResolution); + dy := dy - (dy mod GridResolution); + end; + + MoveResizeWidgets(dx, dy, 0, 0); +end; + +procedure TFormDesigner.MsgKeyPress(var msg: TfpgMessageRec); +var + key: word; + ss: TShiftState; + consumed: boolean; +begin + key := msg.params.keyboard.keycode; + ss := msg.params.keyboard.shiftstate; + + consumed := False; + + DesignerKeyPress(key, ss, consumed); +end; + +procedure TFormDesigner.MsgMove(var msg: TfpgMessageRec); +begin + if msg.dest = FForm then + UpdatePropWin; +end; + +procedure TFormDesigner.MsgResize(var msg: TfpgMessageRec); +begin + if msg.dest = FForm then + begin + DeSelectAll; // because of the anchorings + UpdatePropWin; + end; +end; + +constructor TFormDesigner.Create; +begin + FWidgets := TList.Create; + FWasDrag := False; + + OneClickMove := True; //false; + + FForm := TDesignedForm.Create(nil); + FForm.FormDesigner := self; + FForm.Name := maindsgn.NewFormName; + FForm.WindowTitle := FForm.Name; + FFormOther := ''; +end; + +destructor TFormDesigner.Destroy; +var + n: integer; +begin + for n := 0 to FWidgets.Count - 1 do + TObject(FWidgets.Items[n]).Free; + FWidgets.Free; + + if FForm <> nil then + FForm.Free; + inherited Destroy; +end; + +procedure TFormDesigner.ClearForm; +var + n: integer; +begin + for n := 0 to FWidgets.Count - 1 do + begin + TWidgetDesigner(FWidgets.Items[n]).Widget.Free; + TObject(FWidgets.Items[n]).Free; + end; + FWidgets.Clear; +end; + +procedure TFormDesigner.DefaultHandler(var msg); +begin + //Writeln('Designer message: ',TMessageRec(msg).msgcode,' from ',TMessageRec(msg).dest.ClassName); +end; + +procedure TFormDesigner.Show; +begin + FForm.Show; + UpdatePropWin; +end; + +procedure TFormDesigner.InitTest; +var + l1: TfpgLabel; + ed1: TfpgEdit; +begin + Exit; + + l1 := CreateLabel(FForm, 10, 10, 'Test Label'); + ed1 := CreateEdit(FForm, 10, 50, 150, 0); + + AddWidget(l1, nil); + AddWidget(ed1, nil); +end; + +function TFormDesigner.AddWidget(wg: TfpgWidget; wgc: TVFDWidgetClass): TWidgetDesigner; +var + cd: TWidgetDesigner; +begin + cd := TWidgetDesigner.Create(self, wg, wgc); + FWidgets.Add(cd); + //cd.Selected := true; + if wg is TDesignedForm then + TDesignedForm(wg).FormDesigner := self; + Result := cd; +end; + +function TFormDesigner.WidgetDesigner(wg: TfpgWidget): TWidgetDesigner; +var + n: integer; + cd: TWidgetDesigner; +begin + Result := nil; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Widget = wg then + begin + Result := cd; + Exit; + end; + end; +end; + +procedure TFormDesigner.DeSelectAll; +var + n: integer; + cd: TWidgetDesigner; +begin + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + cd.Selected := False; + end; +end; + +procedure TFormDesigner.SelectAll; +var + n: integer; + cd: TWidgetDesigner; +begin + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + cd.Selected := True; + end; +end; + +procedure TFormDesigner.SelectNextWidget(fw: boolean); +var + n, dir: integer; + cd, scd: TWidgetDesigner; +begin + if FWidgets.Count < 1 then + Exit; + + if fw then + begin + n := 0; + dir := 1; + end + else + begin + dir := -1; + n := FWidgets.Count - 1; + end; + + scd := TWidgetDesigner(FWidgets.Items[n]); + + while (n >= 0) and (n < FWidgets.Count) do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + if fw then + begin + if n < FWidgets.Count - 1 then + scd := TWidgetDesigner(FWidgets.Items[n + 1]); + end + else if n > 0 then + scd := TWidgetDesigner(FWidgets.Items[n - 1]); + break; + end; + n := n + dir; + end; + DeSelectAll; + scd.Selected := True; + UpdatePropWin; +end; + +procedure TFormDesigner.MoveResizeWidgets(dx, dy, dw, dh: integer); +var + n: integer; + cd: TWidgetDesigner; +begin + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + if GridResolution > 1 then + ; + cd.Widget.MoveAndResizeBy(dx, dy, dw, dh); + cd.UpdateResizerPositions; + end; + end; + UpdatePropWin; +end; + +procedure TFormDesigner.DeleteWidgets; +var + n: integer; + cd: TWidgetDesigner; +begin + n := 0; + while n < FWidgets.Count do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + cd.Widget.Free; + cd.Free; + FWidgets.Delete(n); + end + else + Inc(n); + end; +end; + + +procedure TFormDesigner.EditWidgetOrder; +var + frm: TWidgetOrderForm; + n, fi: integer; + cd: TWidgetDesigner; + identlevel: integer; + + procedure AddChildWidgets(pwg: TfpgWidget; slist: TStrings); + var + f: integer; + fcd: TWidgetDesigner; + begin + for f := 0 to FWidgets.Count - 1 do + begin + fcd := TWidgetDesigner(FWidgets.Items[f]); + + if fcd.Widget.Parent = pwg then + begin + frm.list.Items.AddObject(StringOfChar(' ', identlevel) + fcd.Widget.Name + ' : ' + fcd.Widget.ClassName, fcd); + Inc(identlevel); + AddChildWidgets(fcd.Widget, slist); + Dec(identlevel); + end; + + if fcd.Selected then + fi := f + 1; + end; + end; + +begin + frm := TWidgetOrderForm.Create(nil); + fi := 1; + + identlevel := 0; + + AddChildWidgets(FForm, frm.list.Items); + + if fi <= frm.list.ItemCount then + frm.list.FocusItem := fi; + + if frm.ShowModal = 1 then + begin + for n := 0 to FWidgets.Count - 1 do + TWidgetDesigner(FWidgets.Items[n]).Widget.Visible := False; + + for n := 0 to FWidgets.Count - 1 do + FWidgets.Items[n] := frm.List.Items.Objects[n]; + + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + cd.Widget.Visible := True; + end; + + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + // re-creating the resizers + cd.Selected := False; + cd.Selected := True; + end; + end; + + end; + frm.Free; +end; + +procedure TFormDesigner.DesignerKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); +var + dx, + dy: integer; +begin + dx := 0; + dy := 0; + consumed := True; + + case keycode of + keyLeft: dx := -1; + keyRight: dx := +1; + keyUp: dy := -1; + keyDown: dy := +1; + + keyDelete: DeleteWidgets; + + keyTab: SelectNextWidget(True); +// KEY_STAB: SelectNextWidget(False); + + keyF1: ShowMessage('ENTER, F11: switch to Properties' + LineEnding + + 'TAB, SHIFT+TAB: select next widget' + LineEnding + + 'F2: edit widget order' + LineEnding + + 'F4: edit items' + LineEnding + , 'Small help'); + + keyF2: EditWidgetOrder; + + //KEY_F4: if PropertyForm.btnEdit.Visible then PropertyForm.btnEdit.Click; + + keyF11, + keyEnter: + frmProperties.SetFocus; +// GfxActivateWindow(frmProperties.WinHandle); + else + consumed := False; + end; + + if (dx <> 0) or (dy <> 0) then + if (ssShift in shiftstate) then + MoveResizeWidgets(0, 0, dx, dy) + else + MoveResizeWidgets(dx, dy, 0, 0); +end; + +procedure TFormDesigner.PutControlByName(x, y: integer; cname: string); +var + wg: TfpgWidget; + wgd: TWidgetDesigner; + wgcname: string; + newname: string; + cfrm: TInsertCustomForm; +begin + wgcname := UpperCase(cname); + + Writeln('Putting control: ', wgcname); + + wg := nil; + newname := 'Widget'; + if wgcname = 'LABEL' then + begin + newname := GenerateNewName('lbLabel'); + wg := CreateLabel(FForm, x, y, newname); + end + else if wgcname = 'EDIT' then + begin + newname := GenerateNewName('edEdit'); + wg := CreateEdit(FForm, x, y, 150, 0); + TfpgEdit(wg).Text := newname; + end + else if wgcname = 'BUTTON' then + begin + newname := GenerateNewName('btnButton'); + wg := CreateButton(FForm, x, y, 105, newname, nil); + end + else if wgcname = 'CHECKBOX' then + begin + newname := GenerateNewName('cbCheck'); + wg := CreateCheckBox(FForm, x, y, newname); + end + else if wgcname = 'MEMO' then + begin + newname := GenerateNewName('edMemo'); + wg := TfpgMemo.Create(FForm); + wg.SetPosition(x, y, 120, 80); + TfpgMemo(wg).Text := newname; + end + else if wgcname = 'TEXTLISTBOX' then + begin + newname := GenerateNewName('lstList'); + wg := TfpgListBox.Create(FForm); + wg.SetPosition(x, y, 160, 200); + TfpgListBox(wg).Items.Add(newname); + end + else if wgcname = 'CHOICELIST' then + begin + newname := GenerateNewName('cbChoice'); + wg := CreateComboBox(FForm, x, y, 150, nil); + TfpgComboBox(wg).Items.Add(newname); + end + else + begin + // custom component + cfrm := TInsertCustomForm.Create(nil); + if cfrm.ShowModal = 1 then + begin + newname := cfrm.edName.Text; + if newname = '' then + newname := GenerateNewName(cfrm.edClass.Text); + wg := TOtherWidget.Create(FForm); + TOtherWidget(wg).wgClassName := cfrm.edClass.Text; + wg.SetPosition(x, y, 200, 24); + end; + cfrm.Free; + + end; + + if wg <> nil then + begin + wg.Name := newname; + wgd := AddWidget(wg, nil); + wg.Visible := True; + DeSelectAll; + wgd.Selected := True; + UpdatePropWin; + end; +end; + +procedure TFormDesigner.OnPaletteChange(Sender: TObject); +begin + if PaletteForm.clist.FocusItem > 1 then + FForm.MouseCursor := mcCross + else + FForm.MouseCursor := mcDefault; +end; + +procedure TFormDesigner.UpdatePropWin; +var + n, i: integer; + cd, scd: TWidgetDesigner; + wg: TfpgWidget; + + wgcnt: integer; + //btxt : boolean; + //bedit : boolean; + + lastpropname: string; + + wgc: TVFDWidgetClass; +begin + wgcnt := 0; + wg := FForm; + wgc := VFDFormWidget; + scd := nil; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + Inc(wgcnt); + if wgcnt < 2 then + begin + wg := cd.Widget; + scd := cd; + end; + end; + end; + + if scd <> nil then + wgc := scd.FVFDClass; + + n := frmProperties.lstProps.FocusItem; + if (n > 0) and (PropList.GetItem(n) <> nil) then + lastpropname := PropList.GetItem(n).Name + else + lastpropname := ''; + + i := 0; + + if PropList.Widget <> wg then + begin + frmProperties.lstProps.ReleaseEditor; + PropList.Clear; + for n := 1 to wgc.PropertyCount do + begin + PropList.AddItem(wgc.GetProperty(n)); + if UpperCase(wgc.GetProperty(n).Name) = UpperCase(lastPropName) then + i := n; + end; + PropList.Widget := wg; + frmProperties.lstProps.Update; + if i > 0 then + frmProperties.lstProps.FocusItem := i; + end; + + with frmProperties do + begin + if wg is TOtherWidget then + lbClass.Text := TOtherWidget(wg).wgClassName + else + lbClass.Text := wg.ClassName; + edName.Text := wg.Name; + + if scd <> nil then + edOther.Text := scd.other.Text + else + edOther.Text := FFormOther; + + edName.Visible := (wgcnt < 2); + edOther.Visible := (wgcnt < 2); + + lstProps.Update; + end; + + with frmProperties do + begin + btnLeft.Text := IntToStr(wg.Left); + btnTop.Text := IntToStr(wg.Top); + btnWidth.Text := IntToStr(wg.Width); + btnHeight.Text := IntToStr(wg.Height); + + btnAnLeft.Down := anLeft in wg.Anchors; + btnAnTop.Down := anTop in wg.Anchors; + btnAnRight.Down := anRight in wg.Anchors; + btnAnBottom.Down := anBottom in wg.Anchors; + end; + + Exit; + { + with PropertyForm do + begin + if wg is TOtherWidget then lbClass.Text8 := TOtherWidget(wg).wgClassName + else lbClass.Text8 := wg.ClassName; + + edName.Text8 := wg.Name; + + lbLeft.Text8 := IntToStr(wg.Left); + lbTop.Text8 := IntToStr(wg.Top); + lbWidth.Text8 := IntToStr(wg.Width); + lbHeight.Text8 := IntToStr(wg.Height); + + cbAL.Checked := anLeft in wg.Anchors; + cbAT.Checked := anTop in wg.Anchors; + cbAR.Checked := anRight in wg.Anchors; + cbAB.Checked := anBottom in wg.Anchors; + + btxt := true; + bedit := false; + lbText.Text := u8('Text:'); + + if wg is TGfxForm then edText.Text := TGfxForm(wg).WindowTitle + else if wg is TwgLabel then edText.Text := TwgLabel(wg).Text + else if wg is TwgEdit then edText.Text := TwgEdit(wg).Text + else if wg is TwgButton then edText.Text := TwgButton(wg).Text + else if wg is TwgCheckBox then edText.Text := TwgCheckBox(wg).Text + else btxt := false; + + if not btxt and ((wg is TwgMemo) or (wg is TwgChoiceList) or (wg is TwgTextListBox)) + then + begin + bedit := true; + lbText.Text := u8('Items:'); + btnEdit.Text := u8('Edit items...'); + end + else if (wg is TwgDBGrid) then + begin + bedit := true; + //lbText.Text := u8('Items:'); + btnEdit.Text := u8('Edit columns...'); + end; + + if scd <> nil then + begin + edOther.Text := str8to16(scd.other.Text); + end + else + begin + edOther.Text := str8to16(FFormOther); + end; + + edText.Visible := btxt; + lbText.Visible := btxt; + btnEdit.Visible := bedit; + edName.Visible := (wgcnt < 2); + edOther.Visible := (wgcnt < 2); + + end; // with PropertyForm +} +end; + +procedure TFormDesigner.OnPropTextChange(Sender: TObject); +{ +var + n : integer; + cd : TWidgetDesigner; + wg : TWidget; + s : string16; +} +begin + { + s := PropertyForm.edText.Text; + wg := nil; + for n:=0 to FWidgets.Count-1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + wg := cd.Widget; + SetWidgetText(wg,s); + if wg is TwgLabel then + with TwgLabel(wg) do + begin + if Font.TextWidth16(Text) > width then + begin + Width := Font.TextWidth16(Text); + UpdateWindowPosition; + cd.UpdateResizerPositions; + end; + end; + end; + end; + + if wg = nil then + begin + FForm.WindowTitle := s; + end; +} +end; + +procedure TFormDesigner.OnPropNameChange(Sender: TObject); +var + n: integer; + cd: TWidgetDesigner; + wg: TfpgWidget; + s: string; +begin + // writeln('namechange'); + s := frmProperties.edName.Text; + wg := nil; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + wg := cd.Widget; +{ + if GetWidgetText(wg,s) and (wg.Name = str16to8(s)) then + begin + PropertyForm.edText.Text8 := s8; + OnPropTextChange(sender); + end; +} + end; + + if wg = nil then + wg := FForm{ + if FForm.Name = FForm.WindowTitle8 then + begin + FForm.WindowTitle8 := s8; + PropertyForm.edText.Text8 := s8; + end; +}; + + try + wg.Name := s; + except + // invalid name... + end; +end; + +procedure TFormDesigner.OnPropPosEdit(Sender: TObject); +var + frm: TEditPositionForm; + btn: TfpgButton; + ax, + ay: TfpgCoord; + wg: TfpgWidget; + n: integer; + cd: TWidgetDesigner; + posval: integer; + pt: TPoint; + + procedure SetNewPos(awg: TfpgWidget; pval: integer); + begin + if Sender = frmProperties.btnLeft then + awg.Left := pval + else if Sender = frmProperties.btnTop then + awg.Top := pval + else if Sender = frmProperties.btnWidth then + awg.Width := pval + else if Sender = frmProperties.btnHeight then + awg.Height := pval; + end; + +begin + wg := nil; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + wg := cd.Widget; + break; + end; + end; + + if wg = nil then + wg := Form; + + btn := TfpgButton(Sender); + frm := TEditPositionForm.Create(nil); + btn.WindowToScreen(btn, pt); +// GfxGetAbsolutePosition(btn.WinHandle, btn.Width, 0, ax, ay); + ax := pt.X; + ay := pt.Y; + frm.Left := ax; + frm.Top := ay; + if Sender = frmProperties.btnLeft then + begin + frm.lbPos.Text := 'Left:'; + frm.edPos.Text := IntToStr(wg.Left); + end + else if Sender = frmProperties.btnTop then + begin + frm.lbPos.Text := 'Top:'; + frm.edPos.Text := IntToStr(wg.Top); + end + else if Sender = frmProperties.btnWidth then + begin + frm.lbPos.Text := 'Width:'; + frm.edPos.Text := IntToStr(wg.Width); + end + else if Sender = frmProperties.btnHeight then + begin + frm.lbPos.Text := 'Height:'; + frm.edPos.Text := IntToStr(wg.Height); + end; + + posval := -9999; + if frm.ShowModal = 1 then + posval := StrToIntDef(frm.edPos.Text, -9999); + frm.Free; + + if posval > -999 then + begin + wg := nil; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + wg := cd.Widget; + SetNewPos(wg, posval); + wg.UpdateWindowPosition; + cd.UpdateResizerPositions; + end; + end; + + if wg = nil then + begin + SetNewPos(FForm, posval); + FForm.UpdateWindowPosition; + end; + + end; + + UpdatePropWin; +end; + +procedure TFormDesigner.OnOtherChange(Sender: TObject); +var + n: integer; + cd: TWidgetDesigner; + s: string; + sc: integer; +begin + sc := 0; + s := frmProperties.edOther.Text; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + cd.other.Text := s; + Inc(sc); + end; + end; + + if sc < 1 then + FFormOther := s; +end; + +procedure TFormDesigner.OnAnchorChange(Sender: TObject); +var + n: integer; + cd: TWidgetDesigner; + wg: TfpgWidget; +begin + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + wg := cd.Widget; + + wg.Anchors := []; + if frmProperties.btnAnLeft.Down then + wg.Anchors := wg.Anchors + [anLeft]; + if frmProperties.btnAnTop.Down then + wg.Anchors := wg.Anchors + [anTop]; + if frmProperties.btnAnRight.Down then + wg.Anchors := wg.Anchors + [anRight]; + if frmProperties.btnAnBottom.Down then + wg.Anchors := wg.Anchors + [anBottom]; + end; + end; +end; + +function TFormDesigner.GenerateNewName(namebase: string): string; +var + nind, n: integer; + cd: TWidgetDesigner; + newname: string; + bok: boolean; +begin + nind := 1; + repeat + newname := namebase + IntToStr(nind); + bok := True; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Widget.Name = newname then + begin + bok := False; + break; + end; + end; + Inc(nind); + until bok; + Result := newname; +end; + + +procedure TFormDesigner.MsgActivate(var msg: TfpgMessageRec); +begin + maindsgn.SelectForm(self); +end; + +function TFormDesigner.GetFormSourceDecl: string; +var + n: integer; + wd: TWidgetDesigner; + wgclass: string; +begin + Result := ''; + for n := 0 to FWidgets.Count - 1 do + begin + wd := TWidgetDesigner(FWidgets.Items[n]); + if wd.Widget is TOtherWidget then + wgclass := TOtherWidget(wd.Widget).wgClassName + else + wgclass := wd.Widget.ClassName; + Result := Result + ' ' + wd.Widget.Name + ' : ' + wgclass + ';'#10; + end; +end; + +function TFormDesigner.GetFormSourceImpl: string; +var + s: string; + sl: TStringList; + n: integer; + wd: TWidgetDesigner; + wg: TfpgWidget; + wgclass, pwgname: string; +begin + s := ''; + + if maindsgn.SaveComponentNames then + s := s + ' Name := ' + QuotedStr(FForm.Name) + ';' + LineEnding; + + s := s + ' SetPosition(' + IntToStr(FForm.Left) + ',' + IntToStr(FForm.Top) + ',' + IntToStr( + FForm.Width) + ',' + IntToStr(FForm.Height) + ');' + LineEnding; + s := s + ' WindowTitle := ' + QuotedStr(FForm.WindowTitle) + ';' + LineEnding; + + //adding other form properties, idented + sl := TStringList.Create; + sl.Text := FFormOther; + for n := 0 to sl.Count - 1 do + s := s + ' ' + sl.Strings[n] + LineEnding; + sl.Free; + + s := s + LineEnding; + + // FORM WIDGETS + + for n := 0 to FWidgets.Count - 1 do + begin + wd := TWidgetDesigner(FWidgets.Items[n]); + wg := wd.Widget; + if wg.Parent = FForm then + pwgname := 'self' + else + pwgname := wg.Parent.Name; + if wg is TOtherWidget then + wgclass := TOtherWidget(wg).wgClassName + else + wgclass := wg.ClassName; + + s := s + ' ' + wg.Name + ' := ' + wgclass + '.Create(' + pwgname + ');' + LineEnding + + ' with ' + wg.Name + ' do' + LineEnding + ' begin' + LineEnding + GetWidgetSourceImpl(wd, ' ') + + ' end;' + LineEnding + LineEnding; + end; + + Result := s; +end; + +function TFormDesigner.GetWidgetSourceImpl(wd: TWidgetDesigner; ident: string): string; +var + ts, cs: string; + s: string; + wg: TfpgWidget; + wgc: TVFDWidgetClass; + n: integer; + + procedure SaveItems(Name: string; sl: TStringList); + var + f: integer; + begin + for f := 0 to sl.Count - 1 do + s := s + ident + Name + '.Add(' + QuotedStr(sl.Strings[f]) + ');' + LineEnding; + end; + + { procedure SaveColumns(grid : TwgDBGrid); + var + f : integer; + c : TDBColumn; + alstr : string; + begin + for f := 0 to grid.ColumnCount - 1 do + begin + c := grid.Columns[f]; + case c.Alignment of + alRight : alstr := 'alRight'; + alCenter : alstr := 'alCenter'; + else + alstr := 'alLeft'; + end; + s := s + ident + 'AddColumn8('+QuotedStr(u16u8safe(c.Title))+','+QuotedStr(c.FieldName8) + +','+IntToStr(c.Width)+','+alstr+');'#10; + end; + end; +} +begin + wg := wd.Widget; + wgc := wd.FVFDClass; + s := ''; + + if maindsgn.SaveComponentNames then + s := s + ident + 'Name := ' + QuotedStr(wg.Name) + ';' + LineEnding; + + s := s + ident + 'SetPosition(' + IntToStr(wg.Left) + ',' + IntToStr(wg.Top) + ',' + + IntToStr(wg.Width) + ',' + IntToStr(wg.Height) + ');' + LineEnding; + + if wg.Anchors <> [anLeft, anTop] then + begin + ts := '['; + cs := ''; + if anLeft in wg.Anchors then + begin + ts := ts + cs + 'anLeft'; + cs := ','; + end; + if anRight in wg.Anchors then + begin + ts := ts + cs + 'anRight'; + cs := ','; + end; + if anTop in wg.Anchors then + begin + ts := ts + cs + 'anTop'; + cs := ','; + end; + if anBottom in wg.Anchors then + begin + ts := ts + cs + 'anBottom'; + cs := ','; + end; + ts := ts + '];'; + s := s + ident + 'Anchors := ' + ts + LineEnding; + end; + + for n := 1 to wgc.PropertyCount do + s := s + wgc.GetProperty(n).GetPropertySource(wg, ident); + + { + if wg is TwgMemo then + begin + SaveItems('Lines',TwgMemo(wg).Lines); + end + else if wg is TwgChoiceList then + begin + SaveItems('Items',TwgChoiceList(wg).Items); + end + else if wg is TwgTextListBox then + begin + SaveItems('Items',TwgTextListBox(wg).Items); + end + else if wg is TwgDBGrid then + begin + SaveColumns(TwgDBGrid(wg)); + end + else + if GetWidgetText(wg, ts) then + begin + s := s + ident + 'Text := u8('+QuotedStr(u8encode(ts))+');'#10; // encoding with all printable characters + end; +} + + for n := 0 to wd.other.Count - 1 do + if trim(wd.other.Strings[n]) <> '' then + s := s + ident + wd.other.Strings[n] + LineEnding; + + Result := s; +end; + +procedure TFormDesigner.OnEditWidget(Sender: TObject); +var + n: integer; + cd: TWidgetDesigner; + wg: TfpgWidget; +begin + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if cd.Selected then + begin + wg := cd.Widget; + + // Running widget editor; + RunWidgetEditor(cd, wg); + + Exit; + end; + end; +end; + +procedure EditItems(sl: TStringList); +var + frmie: TItemEditorForm; + //ax,ay : integer; +begin + frmie := TItemEditorForm.Create(nil); + //GfxGetAbsolutePosition(PropertyForm.btnEdit.WinHandle, PropertyForm.btnEdit.width, 0, ax,ay); + //frmie.Left := ax; + //frmie.Top := ay; + + frmie.edItems.Lines.Assign(sl); + if frmie.ShowModal = 1 then + begin +// Writeln('OK'); + sl.Assign(frmie.edItems.Lines); + end; + frmie.Free; +end; + +procedure TFormDesigner.RunWidgetEditor(wgd: TWidgetDesigner; wg: TfpgWidget); +begin + if wg is TfpgMemo then + begin + EditItems(TfpgMemo(wg).Lines); + wg.Invalidate; + end + else if wg is TfpgComboBox then + begin + EditItems(TfpgComboBox(wg).Items); + wg.Invalidate; + end + else if wg is TfpgListBox then + begin + EditItems(TfpgListBox(wg).Items); + wg.Invalidate; + end; +end; + +procedure TFormDesigner.InsertWidget(pwg: TfpgWidget; x, y: integer; wgc: TVFDWidgetClass); +var + cfrm: TInsertCustomForm; + newname, newclassname: string; + wg: TfpgWidget; + wgd: TWidgetDesigner; +begin + if wgc = nil then + Exit; + + newname := ''; + + if wgc.WidgetClass = TOtherWidget then + begin + newclassname := ''; + cfrm := TInsertCustomForm.Create(nil); + cfrm.edName.Text := GenerateNewName(wgc.NameBase); + cfrm.edClass.Text := 'Tfpg'; + if cfrm.ShowModal = 1 then + begin + newname := cfrm.edName.Text; + newClassName := cfrm.edClass.Text; + end; + cfrm.Free; + if (newname = '') or (newclassname = '') then + Exit; + end; + + wg := wgc.CreateWidget(pwg); + if wg <> nil then + begin + wg.Left := x; + wg.Top := y; + if newname = '' then + newname := GenerateNewName(wgc.NameBase); + wg.Name := newname; + if wgc.WidgetClass = TOtherWidget then + TOtherWidget(wg).wgClassName := newclassname; + wgd := AddWidget(wg, wgc); + wg.Visible := True; + DeSelectAll; + wgd.Selected := True; + UpdatePropWin; + end; +end; + +function TFormDesigner.FindWidgetByName(const wgname: string): TfpgWidget; +var + n: integer; + wgnameuc: string; + cd: TWidgetDesigner; +begin + wgnameuc := UpperCase(wgname); + Result := nil; + for n := 0 to FWidgets.Count - 1 do + begin + cd := TWidgetDesigner(FWidgets.Items[n]); + if UpperCase(cd.Widget.Name) = wgnameuc then + begin + Result := cd.Widget; + Exit; + end; + end; +end; + +{ TDesignedForm } + +procedure TDesignedForm.AfterCreate; +begin + inherited AfterCreate; + WindowPosition := wpUser; + WindowTitle := 'New Form'; + SetPosition(300, 100, 300, 250); +end; + + +{ TOtherWidget } + +procedure TOtherWidget.HandlePaint; +var + s: string; +begin + inherited HandlePaint; + if not HasHandle then + Exit; + + Canvas.BeginDraw; + + Canvas.Clear(FBackgroundColor); + Canvas.SetFont(FFont); + Canvas.SetColor(clWidgetFrame); + Canvas.DrawRectangle(0, 0, Width, Height); + Canvas.SetTextColor(clText1); + s := Name + ' : ' + wgClassName; + Canvas.DrawString(2, 2, s); + + Canvas.EndDraw; +end; + +constructor TOtherWidget.Create(AOwner: TComponent); +begin + inherited; + wgClassName := 'TfpgWidget'; + FBackgroundColor := $C0E0C0; + FFont := fpgStyle.DefaultFont; + FWidth := 120; + FHeight := 32; +end; + +end. + diff --git a/examples/apps/uidesigner/vfdeditors.pas b/examples/apps/uidesigner/vfdeditors.pas new file mode 100644 index 00000000..400e97ec --- /dev/null +++ b/examples/apps/uidesigner/vfdeditors.pas @@ -0,0 +1,84 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Some property editors. +} + +unit vfdeditors; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfx_widget, + gui_label, + gui_button, + gui_memo, + vfdforms; + +type + TItemEditorForm = class(TVFDDialog) + public + l1: TfpgLabel; + edItems: TfpgMemo; + btnOK, + btnCancel: TfpgButton; + procedure AfterCreate; override; + procedure OnButtonClick(Sender: TObject); + end; + + +implementation + +uses + fpgfx; + +{ TItemEditorForm } + +procedure TItemEditorForm.AfterCreate; +begin + inherited; +// WindowPosition := wpUser; + WindowTitle := 'Items'; + SetPosition(0, 0, 360, 230); + + l1 := CreateLabel(self, 8, 4, 'Items:'); + + edItems := TfpgMemo.Create(self); + with edItems do + begin + SetPosition(8, 24, 344, 168); + Anchors := [anLeft, anTop, anRight, anBottom]; + end; + + btnOK := CreateButton(self, 8, 200, 105, 'OK', @OnButtonClick); + btnOK.Anchors := [anLeft, anBottom]; + btnCancel := CreateButton(self, 244, 200, 105, 'Cancel', @OnButtonClick); + btnCancel.Anchors := [anRight, anBottom]; +end; + +procedure TItemEditorForm.OnButtonClick(Sender: TObject); +begin + if Sender = btnOK then + ModalResult := 1 + else + ModalResult := 2; +end; + + +end. + diff --git a/examples/apps/uidesigner/vfdfile.pas b/examples/apps/uidesigner/vfdfile.pas new file mode 100644 index 00000000..f31f82da --- /dev/null +++ b/examples/apps/uidesigner/vfdfile.pas @@ -0,0 +1,381 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + This unit handles the load, save and merge functions. Doing + marker searching. +} + +unit vfdfile; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, + Classes; + +type + TVFDFileBlock = class + public + BlockID: string; + FormName: string; + Position: integer; + Data: string; + end; + + TVFDFile = class + protected + FFileData: string; + FParsedData: string; + + FBlocks: TList; + + public + NewFormsDecl: string; + NewFormsImpl: string; + + constructor Create; + destructor Destroy; override; + + function LoadFile(fname: string): boolean; + + procedure AddBlock(aposition: integer; ablockid, aformname, ablockdata: string); + function BlockCount: integer; + function Block(index: integer): TVFDFileBlock; + + procedure FreeBlocks; + + function GetBlocks: integer; // parse file + function MergeBlocks: string; // store file + + procedure AddNewFormDecl(formname, formheadblock: string); + procedure AddNewFormImpl(formname, formbody: string); + + function FindFormBlock(blockid, formname: string): TVFDFileBlock; + + procedure SetFormData(formname, headblock, bodyblock: string); + + procedure NewFileSkeleton(unitname: string); + end; + +implementation + +{ TVFDFile } + +procedure TVFDFile.AddBlock(aposition: integer; ablockid, aformname, ablockdata: string); +var + fb: TVFDFileBlock; +begin + fb := TVFDFileBlock.Create; + fb.Position := aposition; + fb.BlockID := ablockid; + fb.FormName := aformname; + fb.Data := ablockdata; + FBlocks.Add(fb); +end; + +procedure TVFDFile.AddNewFormDecl(formname, formheadblock: string); +var + s: string; +begin + s := + ' T' + formname + ' = class(TGfxForm)'#10 + ' public'#10 + ' {@VFD_HEAD_BEGIN: ' + formname + '}'#10 + + formheadblock + ' {@VFD_HEAD_END: ' + formname + '}'#10 + #10 + ' procedure AfterCreate; override;'#10 + + ' end;'#10 + ''#10; + NewFormsDecl := NewFormsDecl + s; +end; + +procedure TVFDFile.AddNewFormImpl(formname, formbody: string); +var + s: string; +begin + s := #10#10 + 'procedure T' + formname + '.AfterCreate;'#10 + 'begin'#10 + ' {@VFD_BODY_BEGIN: ' + formname + '}'#10 + + formbody + ' {@VFD_BODY_END: ' + formname + '}'#10 + 'end;'#10; + NewFormsImpl := NewFormsImpl + s; +end; + +function TVFDFile.Block(index: integer): TVFDFileBlock; +begin + Result := nil; + if (index < 1) or (index > FBlocks.Count) then + Exit; + Result := TVFDFileBlock(FBlocks[index - 1]); +end; + +function TVFDFile.BlockCount: integer; +begin + Result := FBlocks.Count; +end; + +constructor TVFDFile.Create; +begin + FFileData := ''; + FParsedData := ''; + NewFormsDecl := ''; + NewFormsImpl := ''; + FBlocks := TList.Create; +end; + +destructor TVFDFile.Destroy; +begin + FreeBlocks; + FBlocks.Free; + inherited; +end; + +function TVFDFile.FindFormBlock(blockid, formname: string): TVFDFileBlock; +var + n: integer; + fb: TVFDFileBlock; +begin + Result := nil; + for n := 1 to BlockCount do + begin + fb := Block(n); + if (fb.BlockID = blockid) and (UpperCase(fb.FormName) = UpperCase(formname)) then + begin + Result := fb; + Exit; + end; + end; +end; + +procedure TVFDFile.FreeBlocks; +var + n: integer; +begin + for n := 0 to FBlocks.Count - 1 do + TVFDFileBlock(FBlocks[n]).Free; + FBlocks.Clear; + NewFormsDecl := ''; + NewFormsImpl := ''; +end; + +function TVFDFile.GetBlocks: integer; +var + n: integer; + + s: string; + + startp, endp: integer; + formname: string; + bname, startmarker, endmarker: string; + datablock: string; + deletelen: integer; + + dropmarker: boolean; +begin + FreeBlocks; + + FParsedData := FFileData; + + // searching blocks: + + repeat + + bname := ''; + formname := ''; + datablock := ''; + + s := '{@VFD_'; + startp := pos(s, FParsedData); + if startp > 0 then + begin + // marker found + n := startp + 2; + while (n < length(FParsedData)) and (FParsedData[n] in ['_', 'A'..'Z']) do + begin + bname := bname + FParsedData[n]; + Inc(n); + end; + + if FParsedData[n] = ':' then + Inc(n, 2); + + while (n < length(FParsedData)) and (FParsedData[n] <> '}') do + begin + formname := formname + FParsedData[n]; + Inc(n); + end; + + startmarker := copy(FParsedData, startp, n - startp + 1); + deletelen := length(startmarker); + dropmarker := False; + + Writeln('marker: ', startmarker); + + // block marker ? + + endmarker := ''; + if bname = 'VFD_HEAD_BEGIN' then //or (bname = 'VFD_BODY_BEGIN') then + endmarker := '{@VFD_HEAD_END: ' + formname + '}' + else if bname = 'VFD_BODY_BEGIN' then + endmarker := '{@VFD_BODY_END: ' + formname + '}'; + + if endmarker <> '' then + begin + //Writeln('Block: ',bname,' form: ',formname); + // find the end of the block + endp := pos(endmarker, FParsedData); + if endp > 0 then + begin + //Writeln('end marker found.'); + datablock := copy(FParsedData, startp + length(startmarker), endp - startp - length(startmarker)); + //Writeln('data block:'); + //writeln(datablock); + //writeln('.'); + deletelen := endp - startp + length(endmarker); + end + else + dropmarker := True// error: end marker did not found + //Writeln('file error: ',endmarker,' marker wasn''t found.'); + // block length = 0 + ; + end; + + Delete(FParsedData, startp, deletelen); + + if not dropmarker then + AddBlock(startp, bname, formname, datablock); + + end; + + until startp <= 0; + + //writeln(FParsedData); + + Result := BlockCount; +end; + +function TVFDFile.LoadFile(fname: string): boolean; +var + ff: file; + s: string; + cnt: integer; +begin + Result := False; + AssignFile(ff, fname); + try + Reset(ff, 1); + except + Exit; + end; + + FFileData := ''; + try + while not EOF(ff) do + begin + SetLength(s, 4096); + BlockRead(ff, s[1], length(s), cnt); + FFileData := FFileData + copy(s, 1, cnt); + if cnt < length(s) then + break; + end; + Result := True; + finally + CloseFile(ff); + end; + //Writeln('data length: ',length(FFileData)); +end; + +function TVFDFile.MergeBlocks: string; +var + rs: string; + n: integer; + iofs, startp: integer; + fb: TVFDFileBlock; + startmarker, endmarker: string; + iblock: string; + + newsaved: boolean; + +begin + // Writeln('merging blocks: '); + newsaved := False; + rs := FParsedData; + iofs := 0; + for n := 0 to FBlocks.Count - 1 do + begin + fb := TVFDFileBlock(FBlocks[n]); + startmarker := '{@' + fb.BlockID; + if fb.formname <> '' then + startmarker := startmarker + ': ' + fb.FormName; + startmarker := startmarker + '}'; + if fb.BlockID = 'VFD_HEAD_BEGIN' then + endmarker := ' {@VFD_HEAD_END: ' + fb.FormName + '}' + else if fb.BlockID = 'VFD_BODY_BEGIN' then + endmarker := ' {@VFD_BODY_END: ' + fb.FormName + '}' + else + endmarker := ''; + + iblock := startmarker; + if endmarker <> '' then + iblock := iblock + #10 + fb.Data + endmarker; + + if fb.BlockID = 'VFD_NEWFORM_DECL' then + iblock := NewFormsDecl + iblock + else if fb.BlockID = 'VFD_NEWFORM_IMPL' then + begin + iblock := iblock + NewFormsImpl; + newsaved := True; + end; + + startp := fb.Position + iofs; + insert(iblock, rs, startp); + Inc(iofs, length(iblock)); + end; + + if not newsaved and (NewFormsImpl <> '') then + rs := rs + NewFormsImpl// do not loose new form data. + ; + + //writeln(rs); + Result := rs; +end; + +procedure TVFDFile.NewFileSkeleton(unitname: string); +begin + FFileData := + 'unit ' + unitname + ';'#10 + #10 + '{$ifdef FPC}'#10 + '{$mode objfpc}{$H+}'#10 + + '{$endif}'#10 + ''#10 + 'interface'#10 + ''#10 + 'uses'#10 + + ' SysUtils, Classes, gfxbase, wgedit, unitkeys, schar16, gfxstyle,'#10 + + ' gfxwidget, gfxform, wglabel, wgbutton,'#10 + ' wglistbox, wgmemo, wgchoicelist, wggrid, sqldb, sqluis,'#10 + + ' wgdbgrid, gfxdialogs, wgcheckbox;'#10 + ''#10 + 'type'#10 + ''#10 + + '{@VFD_NEWFORM_DECL}'#10 + ''#10 + 'implementation'#10 + ''#10 + '{@VFD_NEWFORM_IMPL}'#10 + + ''#10 + 'end.'#10; + + GetBlocks; +end; + +procedure TVFDFile.SetFormData(formname, headblock, bodyblock: string); +var + fb: TVFDFileBlock; +begin + fb := FindFormBlock('VFD_HEAD_BEGIN', formname); + if fb <> nil then + fb.Data := HeadBlock + else + AddNewFormDecl(formname, headblock); + + fb := FindFormBlock('VFD_BODY_BEGIN', formname); + if fb <> nil then + fb.Data := bodyblock + else + AddNewFormImpl(formname, bodyblock); +end; + + +end. + diff --git a/examples/apps/uidesigner/vfdformparser.pas b/examples/apps/uidesigner/vfdformparser.pas new file mode 100644 index 00000000..334b4199 --- /dev/null +++ b/examples/apps/uidesigner/vfdformparser.pas @@ -0,0 +1,537 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Some Pascal source code parsing functionality. +} + +unit vfdformparser; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + fpgfx, + gfx_widget, + gui_form, + vfddesigner, + vfdwidgetclass, + vfdwidgets; + +type + TVFDFormParser = class(TObject) + protected + ffd: TFormDesigner; + fformname: string; + BodyLines: TStringList; + eob: boolean; + line: string; + lineindex: integer; + public + procedure nextline; + public + constructor Create(const FormName, FormHead, FormBody: string); + destructor Destroy; override; + function ParseForm: TFormDesigner; + procedure ParseFormProperties; + procedure ParseFormWidgets; + function ReadWGProperty(propline: string; wg: TfpgWidget; wgc: TVFDWidgetClass): boolean; + end; + + +function GetIdentifier(var s: string): string; +function GetStringValue(var s: string): string; +procedure SkipSpaces(var s: string); +function CheckSymbol(var s: string; const sym: string): boolean; +function GetIntValue(var s: string): integer; + +implementation + +{ TVFDFormParser } + +constructor TVFDFormParser.Create(const FormName, FormHead, FormBody: string); +begin + fformname := FormName; + ffd := nil; + BodyLines := TStringList.Create; + BodyLines.Text := FormBody; + lineindex := 0; +end; + +destructor TVFDFormParser.Destroy; +begin + BodyLines.Free; + inherited; +end; + +procedure TVFDFormParser.nextline; +begin + repeat + Inc(lineindex); + eob := (lineindex > BodyLines.Count); + if not eob then + line := trim(bodylines.Strings[lineindex - 1]) + else + line := ''; + until eob or (line <> ''); +end; + +function TVFDFormParser.ParseForm: TFormDesigner; +begin + ffd := TFormDesigner.Create; + ffd.Form.Name := fformname; + + // parsing line by line + // the unknown lines will be "other properties" + lineindex := 0; + nextline; + + ParseFormProperties; + + ParseFormWidgets; + + Result := ffd; +end; + +procedure SkipSpaces(var s: string); +begin + while (s <> '') and (s[1] in [' ', #9, #13, #10]) do + Delete(s, 1, 1); +end; + +function CheckSymbol(var s: string; const sym: string): boolean; +begin + SkipSpaces(s); + Result := (pos(sym, s) = 1); + if Result then + Delete(s, 1, length(sym)); +end; + +function GetIntValue(var s: string): integer; +var + n: integer; + ns: string; +begin + SkipSpaces(s); + ns := ''; + n := 1; + while (n <= length(s)) and (s[n] in ['0'..'9', '-']) do + begin + ns := ns + s[n]; + Inc(n); + end; + Result := StrToIntDef(ns, 0); + Delete(s, 1, length(ns)); +end; + +function GetStringValue(var s: string): string; +var + n: integer; + quot: boolean; + c, prevc: char; + ccode: string; + ids: string; +begin + Result := ''; + ids := GetIdentifier(s); + if ids <> '' then +{ if ids = 'u8' then + begin + if not CheckSymbol(s, '(') then + Exit; + end + else + Exit; +} + SkipSpaces(s); + prevc := #0; + n := 1; + quot := False; + while n <= length(s) do + begin + c := s[n]; + if c = '''' then + begin + quot := not quot; + if quot and (prevc = '''') then + Result := Result + c; + end + else if not quot then + begin + if not (c in ['+', ' ', #9, #13, #10]) then + if (c = '#') then + begin + Inc(n); + ccode := ''; + while (n <= length(s)) and (s[n] in ['0'..'9']) do + begin + ccode := ccode + s[n]; + Inc(n); + end; + c := chr(StrToIntDef(ccode, Ord('?')) and $FF); + Result := Result + c; + end + else + break; + end + else + Result := Result + c; + prevc := c; + Inc(n); + end; + if (n - 1) > 0 then + Delete(s, 1, n - 1); + + SkipSpaces(s); +// if ids <> '' then +// CheckSymbol(s, ')'); +// if ids = 'u8' then +// Result := u8(Result); +end; + +function GetIdentifier(var s: string): string; +var + n: integer; +begin + SkipSpaces(s); + Result := ''; + n := 1; + while n <= length(s) do + begin + if s[n] in ['_', 'a'..'z', 'A'..'Z', '0'..'9'] then + Result := Result + s[n] + else + Break; + Inc(n); + end; + if length(Result) > 0 then + Delete(s, 1, length(Result)); +end; + +procedure TVFDFormParser.ParseFormProperties; +var + lok: boolean; +begin + while not eob and (pos('.CREATE(', UpperCase(line)) = 0) do + begin + lok := ReadWGProperty(line, ffd.Form, VFDFormWidget); + + if not lok then + ffd.FormOther := ffd.FormOther + line + LineEnding; + + NextLine; + end; +end; + +procedure TVFDFormParser.ParseFormWidgets; +var + n: integer; + lok: boolean; + s: string; + ident: string; + wgname, wgclass, wgclassuc, wgparent: string; + pwg, wg: TfpgWidget; + wgother: string; + wd: TWidgetDesigner; + wgc: TVFDWidgetClass; +begin + while not eob do + begin + //s := UpperCase(line); + s := line; + + wgname := GetIdentifier(s); + //writeln('wg: ',wgname); + lok := CheckSymbol(s, ':='); + if lok then + wgclass := GetIdentifier(s); + lok := lok and CheckSymbol(s, '.'); + lok := lok and (UpperCase(GetIdentifier(s)) = 'CREATE'); + lok := lok and CheckSymbol(s, '('); + if lok then + wgparent := GetIdentifier(s); + lok := lok and CheckSymbol(s, ')'); + lok := lok and CheckSymbol(s, ';'); + + if lok then + begin + //writeln('wg create: ',wgname,' (',wgclass,') - ',wgparent); + + // searching for the parent ... + pwg := nil; + if UpperCase(wgparent) <> 'SELF' then + begin + pwg := ffd.FindWidgetByName(wgparent); + if pwg = nil then + Writeln('Warning! Parent object "' + wgparent + '" not found for "' + wgname + '"'); + end; + if pwg = nil then + pwg := ffd.Form; + + wgclassuc := UpperCase(wgclass); + + wg := nil; + wgc := nil; + for n := 1 to VFDWidgetCount do + begin + wgc := VFDWidget(n); + if wgclassuc = UpperCase(wgc.WidgetClass.ClassName) then + begin + wg := wgc.CreateWidget(pwg); + break; + end; + end; + + { + if wgclassuc = 'TWGLABEL' then wg := TwgLabel.Create(pwg) + else if wgclassuc = 'TWGEDIT' then wg := TwgEdit.Create(pwg) + else if wgclassuc = 'TWGCHECKBOX' then wg := TwgCheckBox.Create(pwg) + else if wgclassuc = 'TWGBUTTON' then wg := TwgButton.Create(pwg) + else if wgclassuc = 'TWGMEMO' then wg := TwgMemo.Create(pwg) + else if wgclassuc = 'TWGCHOICELIST' then wg := TwgChoiceList.Create(pwg) + else if wgclassuc = 'TWGDBGRID' then wg := TwgDBGrid.Create(pwg) + else if wgclassuc = 'TWGTEXTLISTBOX' then wg := TwgTextListBox.Create(pwg) + else +} + if wg = nil then + begin + wgc := VFDOtherWidget; + wg := TOtherWidget.Create(pwg); + TOtherWidget(wg).wgClassName := wgclass; + end; + + wg.Name := wgname; + + NextLine; + s := UpperCase(line); + ident := GetIdentifier(s); + if ident = 'WITH' then + begin + // skip with line... + NextLine; + + s := UpperCase(line); + ident := GetIdentifier(s); + if ident = 'BEGIN' then + NextLine; + + // reading widget properties... + wgother := ''; + + while (not eob) and (pos('END;', UpperCase(line)) <> 1) do + begin + lok := ReadWGProperty(line, wg, wgc); + if not lok then + wgother := wgother + line + LineEnding; + nextline; + end; + + if (pos('END;', UpperCase(line)) = 1) then + nextline; + + end; + + wd := ffd.AddWidget(wg, nil); + wd.FVFDClass := wgc; + wd.other.Text := wgother; + + end + else + begin + ffd.FormOther := ffd.FormOther + line + LineEnding; + NextLine; + end; + + end; +end; + +function TVFDFormParser.ReadWGProperty(propline: string; wg: TfpgWidget; wgc: TVFDWidgetClass): boolean; +var + s: string; + n: integer; + ident: string; + lok: boolean; + sval: string; + wga: TAnchors; +begin + s := propline; + + ident := UpperCase(GetIdentifier(s)); + //writeln('ident: ',ident); + sval := ''; + + lok := False; + + if ident = 'NAME' then + begin + lok := CheckSymbol(s, ':='); + if lok then + begin + sval := GetStringValue(s); + lok := CheckSymbol(s, ';'); + end; + if lok then + wg.Name := sval; + end + { + else if ident = 'TEXT' then + begin + lok := CheckSymbol(s, ':='); + if lok then + begin + sval := GetStringValue(s); + lok := CheckSymbol(s, ';'); + end; + if lok then + begin + if wg is TwgLabel then TwgLabel(wg).Text := sval + else if wg is TwgEdit then TwgEdit(wg).Text := sval + else if wg is TwgButton then TwgButton(wg).Text := sval + else if wg is TwgCheckBox then TwgCheckBox(wg).Text := sval + else + lok := false; + end; + if lok then SetWidgetText(wg, sval); + end + else if (ident = 'LINES') or (ident = 'ITEMS') then + begin + lok := CheckSymbol(s, '.'); + lok := lok and (UpperCase(GetIdentifier(s)) = 'ADD'); + lok := lok and CheckSymbol(s, '('); + if lok then + begin + sval := GetStringValue(s); + lok := lok and CheckSymbol(s, ')'); + lok := lok and CheckSymbol(s, ';'); + end; + if lok then + begin + if wg is TwgMemo then TwgMemo(wg).Lines.Add(sval) + else if wg is TwgChoiceList then TwgChoiceList(wg).Items.Add(sval) + else if wg is TwgTextListBox then TwgTextListBox(wg).Items.Add(sval) + else + lok := false; + end; + end +} + else if ident = 'ANCHORS' then + begin + lok := CheckSymbol(s, ':='); + lok := lok and CheckSymbol(s, '['); + if lok then + begin + wga := []; + repeat + sval := UpperCase(GetIdentifier(s)); + if sval = 'ANLEFT' then + wga := wga + [anLeft] + else if sval = 'ANTOP' then + wga := wga + [anTop] + else if sval = 'ANRIGHT' then + wga := wga + [anRight] + else if sval = 'ANBOTTOM' then + wga := wga + [anBottom]; + until not CheckSymbol(s, ','); + end; + lok := lok and CheckSymbol(s, ']'); + lok := lok and CheckSymbol(s, ';'); + + if lok then + wg.Anchors := wga; + end + else if ident = 'WINDOWTITLE' then + begin + lok := (wg is TfpgForm); + if lok then + begin + lok := CheckSymbol(s, ':='); + if lok then + begin + sval := GetStringValue(s); + lok := CheckSymbol(s, ';'); + end; + if lok then + TfpgForm(wg).WindowTitle := sval; + end; + end + else if ident = 'SETPOSITION' then + begin + lok := CheckSymbol(s, '('); + if lok then + wg.Left := GetIntValue(s); + lok := lok and CheckSymbol(s, ','); + if lok then + wg.Top := GetIntValue(s); + lok := lok and CheckSymbol(s, ','); + if lok then + wg.Width := GetIntValue(s); + lok := lok and CheckSymbol(s, ','); + if lok then + wg.Height := GetIntValue(s); + lok := lok and CheckSymbol(s, ')'); + lok := lok and CheckSymbol(s, ';'); + //if lok then Writeln('sd ok.'); + //writeln('WT: ',sval); + end + { + else if (wg is TwgDBGrid) and (ident = 'ADDCOLUMN8') then + begin + c := TDBColumn.Create; + lok := CheckSymbol(s, '('); + + if lok then c.Title := u8(GetStringValue(s)); + lok := lok and CheckSymbol(s, ','); + if lok then c.FieldName8 := GetStringValue(s); + lok := lok and CheckSymbol(s, ','); + if lok then c.Width := GetIntValue(s); + lok := lok and CheckSymbol(s, ','); + if lok then + begin + sval := UpperCase(GetIdentifier(s)); + if sval = 'ALRIGHT' then c.Alignment := alRight + else if sval = 'ALCENTER' then c.Alignment := alCenter + else c.Alignment := alLeft; + end; + + lok := lok and CheckSymbol(s, ')'); + lok := lok and CheckSymbol(s, ';'); + + if lok then + begin + TwgDBGrid(wg).AddColumn(c.Title, c.FieldName8, c.Width, c.Alignment) + end; + + c.Free; + end; +}; + + if not lok then + if wgc <> nil then + for n := 1 to wgc.PropertyCount do + begin + lok := wgc.GetProperty(n).ParseSourceLine(wg, line); + if lok then + Break; + end; + + if not lok then + Writeln('unknown: ', line); + + Result := lok; +end; + +end. + diff --git a/examples/apps/uidesigner/vfdforms.pas b/examples/apps/uidesigner/vfdforms.pas new file mode 100644 index 00000000..5f337ea3 --- /dev/null +++ b/examples/apps/uidesigner/vfdforms.pas @@ -0,0 +1,636 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + The main uiDesigner forms. +} + +unit vfdforms; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfxbase, + gfx_widget, + gui_form, + gui_label, + gui_edit, + gui_button, + gui_listbox, + gui_memo, + gui_combobox, + gui_checkbox; + +type + + TVFDDialog = class(TfpgForm) + protected + procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + end; + + + TInsertCustomForm = class(TVFDDialog) + public + l1, + l2: TfpgLabel; + edClass: TfpgEdit; + edName: TfpgEdit; + btnOK, + btnCancel: TfpgButton; + procedure AfterCreate; override; + procedure OnButtonClick(Sender: TObject); + end; + + + TNewFormForm = class(TVFDDialog) + public + l1: TfpgLabel; + edName: TfpgEdit; + btnOK, + btnCancel: TfpgButton; + procedure AfterCreate; override; + procedure OnButtonClick(Sender: TObject); + end; + + + TEditPositionForm = class(TVFDDialog) + public + lbPos: TfpgLabel; + edPos: TfpgEdit; + btnOK, + btnCancel: TfpgButton; + procedure AfterCreate; override; + procedure OnButtonClick(Sender: TObject); + end; + + + TWidgetOrderForm = class(TVFDDialog) + public + l1: TfpgLabel; + list: TfpgListBox; + btnUP, + btnDOWN, + btnOK, + btnCancel: TfpgButton; + procedure AfterCreate; override; + procedure OnButtonClick(Sender: TObject); + end; + + + TPaletteForm = class(TfpgForm) + public + clab: TfpgLabel; + clist: TfpgListBox; + procedure AfterCreate; override; + end; + + + TfrmLoadSave = class(TfpgForm) + public + {@VFD_HEAD_BEGIN: frmLoadSave} + lb1: TfpgLabel; + edFileName: TfpgEdit; + btnOK: TfpgButton; + btnCancel: TfpgButton; + {@VFD_HEAD_END: frmLoadSave} + procedure AfterCreate; override; + end; + + + TfrmVFDSetup = class(TfpgForm) + public + {@VFD_HEAD_BEGIN: frmVFDSetup} + lb1: TfpgLabel; + chlGrid: TfpgComboBox; + btnOK: TfpgButton; + btnCancel: TfpgButton; + {@VFD_HEAD_END: frmVFDSetup} + procedure AfterCreate; override; + end; + + + TMainForm = class(TfpgForm) + public + l1: TfpgLabel; + l2: TfpgLabel; + edFormFile: TfpgEdit; + btnSave: TfpgButton; + btnLoad: TfpgButton; + btnNewForm: TfpgButton; + chlGrid: TfpgComboBox; + procedure AfterCreate; override; + end; + + + TPropertyForm = class(TfpgForm) + protected + procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + public + l1, l2, l3, l4, l5, l6, l7, l8: TfpgLabel; + lbClass: TfpgLabel; + edName: TfpgEdit; + lbText: TfpgLabel; + edText: TfpgEdit; + btnEdit: TfpgButton; + lbTop, lbLeft, lbWidth, lbHeight: TfpgLabel; + btnTop, btnLeft, btnWidth, btnHeight: TfpgButton; + cbAL, cbAT, cbAR, cbAB: TfpgCheckBox; + edOther: TfpgMemo; + procedure AfterCreate; override; + end; + + +var + PaletteForm: TPaletteForm; + //MainForm : TMainForm; + //PropertyForm : TPropertyForm; + +function GridResolution: integer; + +implementation + +uses + vfdmain, + fpgfx; + +function GridResolution: integer; +begin + Result := maindsgn.GridResolution; +end; + +{ TPaletteForm } + +procedure TPaletteForm.AfterCreate; +begin + inherited AfterCreate; + WindowPosition := wpUser; + WindowTitle := 'Palette'; + SetPosition(10, 450, 110, 220); + + clab := CreateLabel(self, 3, 3, 'Widget Palette:'); + + clist := TfpgListBox.Create(self); + clist.Left := 1; + clist.Width := Width - 2; + clist.Top := 22; + clist.Height := Height - clist.top - 2; + clist.Anchors := [anLeft, anRight, anTop, anBottom]; + + clist.Items.Add('-'); + clist.Items.Add('Label'); + clist.Items.Add('Edit'); + clist.Items.Add('Button'); + clist.Items.Add('CheckBox'); + clist.Items.Add('ComboBox'); + clist.Items.Add('Memo'); + clist.Items.Add('ListBox'); + clist.Items.Add('[OTHER]'); + + clist.OnChange := @(maindsgn.OnPaletteChange); +end; + +{ TPropertyForm } + +procedure TPropertyForm.AfterCreate; +var + x, x2, w, y, gap: integer; +begin + inherited AfterCreate; + WindowPosition := wpUser; + WindowTitle := 'Properties'; + SetPosition(10, 80, 250, 320); + + x := 3; + x2 := x + 90; + gap := 22; + w := Width - x2 - 3; + y := 3; + + l1 := CreateLabel(self, x, y, 'Class name:'); + lbClass := CreateLabel(self, x2, y, 'CLASS'); + lbClass.Width := w; + lbClass.FontDesc := '#Label2'; + + Inc(y, gap); + + l2 := CreateLabel(self, x, y, 'Name:'); + edName := CreateEdit(self, x2, y, w, 0); + edName.Text := 'NAME'; + edName.Anchors := [anLeft, anRight, anTop]; + + Inc(y, gap); + lbText := CreateLabel(self, x, y, 'Text/Items:'); + edText := CreateEdit(self, x2, y, w, 0); + edText.Text := 'Text'; + edText.Anchors := [anLeft, anRight, anTop]; + + btnEdit := CreateButton(self, x2, y, 100, 'Edit...', nil); + + Inc(y, 2 * gap); + l3 := CreateLabel(self, x, y, 'Left:'); + lbLeft := CreateLabel(self, x2, y, 'Left'); + lbLeft.Width := 50; + btnLeft := CreateButton(self, x2 + 50, y - 2, 30, '...', @maindsgn.OnPropPosEdit); + btnLeft.Height := 20; + Inc(y, gap); + l4 := CreateLabel(self, x, y, 'Top:'); + lbTop := CreateLabel(self, x2, y, 'Top'); + lbTop.Width := 50; + btnTop := CreateButton(self, x2 + 50, y - 2, 30, '...', @maindsgn.OnPropPosEdit); + btnTop.Height := 20; + Inc(y, gap); + l5 := CreateLabel(self, x, y, 'Width:'); + lbWidth := CreateLabel(self, x2, y, 'w'); + lbWidth.Width := 50; + btnWidth := CreateButton(self, x2 + 50, y - 2, 30, '...', @maindsgn.OnPropPosEdit); + btnWidth.Height := 20; + Inc(y, gap); + l6 := CreateLabel(self, x, y, 'Height:'); + lbHeight := CreateLabel(self, x2, y, 'h'); + lbHeight.Width := 50; + btnHeight := CreateButton(self, x2 + 50, y - 2, 30, '...', @maindsgn.OnPropPosEdit); + btnHeight.Height := 20; + + Inc(y, gap); + l6 := CreateLabel(self, x, y, 'Anchors:'); + + cbAL := CreateCheckBox(self, x2, y, 'L'); + cbAT := CreateCheckBox(self, x2 + 36, y, 'T'); + cbAR := CreateCheckBox(self, x2 + 2 * 36, y, 'R'); + cbAB := CreateCheckBox(self, x2 + 3 * 36, y, 'B'); + + Inc(y, gap); + l7 := CreateLabel(self, x, y, 'Other settings:'); + + edOther := TfpgMemo.Create(self); + edOther.SetPosition(x, y + gap, self.Width - 2 * x, self.Height - x - y - gap); + edOther.Anchors := AllAnchors; + edOther.FontDesc := '#Edit2'; + + // lbHeight := CreateLabel(self, x2,y, 'h'); + // lbHeight.Width := w; + + edText.OnChange := @maindsgn.OnPropTextChange; + edName.OnChange := @maindsgn.OnPropNameChange; + + cbAL.OnChange := @maindsgn.OnAnchorChange; + cbAT.OnChange := @maindsgn.OnAnchorChange; + cbAR.OnChange := @maindsgn.OnAnchorChange; + cbAB.OnChange := @maindsgn.OnAnchorChange; + + edOther.OnChange := @maindsgn.OnOtherChange; + btnEdit.OnClick := @maindsgn.OnEditWidget; +end; + +procedure TPropertyForm.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); +begin + if (keycode = keyEnter) or (keycode = keyF11) then + begin + if maindsgn.selectedform <> nil then + maindsgn.selectedform.Form.SetFocus; +// GfxActivateWindow(maindsgn.selectedform.Form.WinHandle); + consumed := True; + end + else + inherited; +end; + +{ TMainForm } + +procedure TMainForm.AfterCreate; +begin + inherited AfterCreate; + WindowPosition := wpUser; + WindowTitle := 'fpGUI Visual Form Designer'; + SetPosition(0, 0, 550, 50); + + l1 := CreateLabel(self, 5, 5, 'File name:'); + + edFormFile := CreateEdit(self, 5, 5 + 20, 250, 0); + edFormFile.Text := './aanewform.pas'; + + btnSave := CreateButton(self, 270, 12, 50, 'Save', nil); + btnLoad := CreateButton(self, 330, 12, 50, 'Load', nil); + + l1 := CreateLabel(self, 400, 5, 'Grid:'); + chlGrid := CreateComboBox(self, 400, 5 + 20, 50, nil); + chlGrid.Items.Add('1'); + chlGrid.Items.Add('4'); + chlGrid.Items.Add('8'); + chlGrid.FocusItem := 2; + + btnNewForm := CreateButton(self, 460, 12, 80, 'New Form', nil); + + btnSave.OnClick := @maindsgn.OnSaveFile; + btnLoad.OnClick := @maindsgn.OnLoadFile; + btnNewForm.OnClick := @ maindsgn.OnNewForm; +end; + +{ TInsertCustomForm } + +procedure TInsertCustomForm.AfterCreate; +begin + inherited; + WindowPosition := wpScreenCenter; + WindowTitle := 'Insert Custom Widget'; + SetPosition(0, 0, 300, 100); + + l1 := CreateLabel(self, 8, 4, 'Class name:'); + edClass := CreateEdit(self, 8, 24, 150, 0); + edClass.Text := 'Tfpg'; + l2 := CreateLabel(self, 8, 48, 'Name:'); + edName := CreateEdit(self, 8, 68, 150, 0); + btnOK := CreateButton(self, 180, 20, 100, 'OK', @OnButtonClick); + btnCancel := CreateButton(self, 180, 52, 100, 'Cancel', @OnButtonClick); +end; + +procedure TInsertCustomForm.OnButtonClick(Sender: TObject); +begin + if Sender = btnOK then + ModalResult := 1 + else + ModalResult := 2; +end; + +{ TNewFormForm } + +procedure TNewFormForm.AfterCreate; +begin + inherited AfterCreate; + WindowPosition := wpScreenCenter; + SetPosition(0, 0, 286, 66); + WindowTitle := 'New Form'; + + l1 := CreateLabel(self, 8, 8, 'Form name:'); + edName := CreateEdit(self, 8, 28, 180, 0); + edName.Text := 'frm'; + btnOK := CreateButton(self, 196, 8, 80, 'OK', @OnButtonClick); + btnCancel := CreateButton(self, 196, 36, 80, 'Cancel', @OnButtonClick); +end; + +procedure TNewFormForm.OnButtonClick(Sender: TObject); +begin + if Sender = btnOK then + ModalResult := 1 + else + ModalResult := 2; +end; + +{ TEditPositionForm } + +procedure TEditPositionForm.AfterCreate; +begin + inherited AfterCreate; + WindowPosition := wpUser; + SetPosition(0, 0, 186, 66); + WindowTitle := 'Position'; + + lbPos := CreateLabel(self, 8, 8, 'Pos: '); + edPos := CreateEdit(self, 8, 28, 80, 0); + btnOK := CreateButton(self, 96, 8, 80, 'OK', @OnButtonClick); + btnCancel := CreateButton(self, 96, 36, 80, 'Cancel', @OnButtonClick); + btnOK.ImageName := 'stdimg.ok'; + btnOK.ShowImage := True; + btnCancel.ImageName := 'stdimg.cancel'; + btnCancel.ShowImage := True; +end; + +procedure TEditPositionForm.OnButtonClick(Sender: TObject); +begin + if Sender = btnOK then + ModalResult := 1 + else + ModalResult := 2; +end; + +{ TWidgetOrderForm } + +procedure TWidgetOrderForm.AfterCreate; +begin + inherited AfterCreate; + WindowPosition := wpScreenCenter; + SetPosition(0, 0, 322, 258); + WindowTitle := 'Widget order'; + + l1 := CreateLabel(self, 4, 4, 'Form widget order:'); + + list := TfpgListBox.Create(self); + list.SetPosition(4, 24, 220, 228); + + btnOK := CreateButton(self, 232, 24, 80, 'OK', @OnButtonClick); + btnOK.ImageName := 'stdimg.ok'; + btnOK.ShowImage := True; + btnCancel := CreateButton(self, 232, 52, 80, 'Cancel', @OnButtonClick); + btnCancel.ImageName := 'stdimg.cancel'; + btnCancel.ShowImage := True; + + btnUP := CreateButton(self, 232, 108, 80, 'UP', @OnButtonClick); + btnDOWN := CreateButton(self, 232, 136, 80, 'DOWN', @OnButtonClick); +end; + +procedure TWidgetOrderForm.OnButtonClick(Sender: TObject); +var + i, + n, + myilev: integer; + + function IdentLevel(astr: string): integer; + var + s: string; + f: integer; + begin + Result := 0; + s := astr; + f := 1; + while (f <= length(s)) and (s[f] = ' ') do + begin + Inc(Result); + Inc(f); + end; + end; + +begin + if Sender = btnOK then + ModalResult := 1 + else if Sender = btnCancel then + ModalResult := 2 + else + begin + // up / down + i := list.FocusItem; + if i < 1 then + Exit; + + myilev := IdentLevel(list.Items[i - 1]); + + if Sender = btnUP then + begin + if (i > 1) and (IdentLevel(list.Items[i - 2]) = myilev) then + begin + list.Items.Move(i - 1, i - 2); + + n := i; + while (n < list.Items.Count) and (IdentLevel(list.Items[n]) > myilev) do + begin + list.Items.Move(n, n - 1); + Inc(n); + end; + + list.FocusItem := i - 1; + end; + end + else if Sender = btnDOWN then + if (i < list.Items.Count) then + begin + //list.Items.Move(i-1,i); + + n := i; + while (n < list.Items.Count) and (IdentLevel(list.Items[n]) > myilev) do + Inc(n)//list.Items.Move(n,n-1); + ; + + if (i = n) and (i < list.Items.Count - 1) and (IdentLevel(list.Items[i + 1]) > myilev) then + Exit; + + if (n > list.Items.Count - 1) then + Exit; + + while (n >= i) do + begin + list.Items.Move(n, n - 1); + Dec(n); + end; + + list.FocusItem := i + 1; + end; + end; +end; + +{ TVFDDialogBase } + +procedure TVFDDialog.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); +begin + if keycode = keyEscape then + begin + ModalResult := 2; + consumed := True; + end + else + inherited HandleKeyPress(keycode, shiftstate, consumed); +end; + +{ TfrmLoadSave } + +procedure TfrmLoadSave.AfterCreate; +begin + {@VFD_BODY_BEGIN: frmLoadSave} + SetPosition(276, 141, 300, 95); + WindowTitle := 'Form file'; + + lb1 := TfpgLabel.Create(self); + with lb1 do + begin + SetPosition(8, 8, 80, 16); + Text := 'File name:'; + FontDesc := '#Label1'; + end; + + edFileName := TfpgEdit.Create(self); + with edFileName do + begin + SetPosition(8, 28, 280, 22); + Anchors := [anLeft, anRight, anTop]; + Text := ''; + FontDesc := '#Edit1'; + end; + + btnOK := TfpgButton.Create(self); + with btnOK do + begin + SetPosition(8, 60, 96, 24); + Anchors := [anLeft, anBottom]; + Text := 'OK'; + FontDesc := '#Label1'; + ImageName := 'stdimg.ok'; + ShowImage := True; + ModalResult := 1; + end; + + btnCancel := TfpgButton.Create(self); + with btnCancel do + begin + SetPosition(192, 60, 96, 24); + Anchors := [anRight, anBottom]; + Text := 'Cancel'; + FontDesc := '#Label1'; + ImageName := 'stdimg.cancel'; + ShowImage := True; + ModalResult := -1; + end; + + {@VFD_BODY_END: frmLoadSave} +end; + +procedure TfrmVFDSetup.AfterCreate; +begin + {@VFD_BODY_BEGIN: frmVFDSetup} + SetPosition(322, 337, 237, 70); + WindowTitle := 'General settings'; + + lb1 := TfpgLabel.Create(self); + with lb1 do + begin + SetPosition(8, 8, 92, 16); + Text := 'Grid resolution:'; + end; + + chlGrid := TfpgComboBox.Create(self); + with chlGrid do + begin + SetPosition(104, 4, 56, 22); + items.Add('1'); + items.Add('4'); + items.Add('8'); + FocusItem := 2; + end; + + btnOK := TfpgButton.Create(self); + with btnOK do + begin + SetPosition(8, 40, 96, 24); + Text := 'OK'; + ImageName := 'stdimg.ok'; + ShowImage := True; + ModalResult := 1; + end; + + btnCancel := TfpgButton.Create(self); + with btnCancel do + begin + SetPosition(132, 40, 96, 24); + Text := 'Cancel'; + ImageName := 'stdimg.cancel'; + ShowImage := True; + ModalResult := -1; + end; + + {@VFD_BODY_END: frmVFDSetup} +end; + + +end. + diff --git a/examples/apps/uidesigner/vfdmain.pas b/examples/apps/uidesigner/vfdmain.pas new file mode 100644 index 00000000..90a3564e --- /dev/null +++ b/examples/apps/uidesigner/vfdmain.pas @@ -0,0 +1,438 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Main window functionality and designer class. +} + +unit vfdmain; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfx_widget, + gui_dialogs, + vfdforms, + vfddesigner, + vfdfile, + newformdesigner; + +const + program_version = '0.10'; + +type + + TMainDesigner = class(TObject) + private + procedure SetEditedFileName(const Value: string); + protected + FDesigners: TList; + FFile: TVFDFile; + FEditedFileName: string; + public + GridResolution: integer; + SaveComponentNames: boolean; + selectedform: TFormDesigner; + constructor Create; + destructor Destroy; override; + procedure CreateWindows; + procedure SelectForm(aform: TFormDesigner); + function Designer(index: integer): TFormDesigner; + function DesignerCount: integer; + function NewFormName: string; + procedure CreateParseForm(const FormName, FormHead, FormBody: string); + procedure OnNewForm(Sender: TObject); + procedure OnNewFile(Sender: TObject); + procedure OnSaveFile(Sender: TObject); + procedure OnLoadFile(Sender: TObject); + procedure OnPaletteChange(Sender: TObject); + procedure OnPropTextChange(Sender: TObject); + procedure OnPropNameChange(Sender: TObject); + procedure OnPropPosEdit(Sender: TObject); + procedure OnOtherChange(Sender: TObject); + procedure OnAnchorChange(Sender: TObject); + procedure OnEditWidget(Sender: TObject); + procedure OnEditWidgetOrder(Sender: TObject); + procedure OnExit(Sender: TObject); + procedure OnOptionsClick(Sender: TObject); + property EditedFileName: string read FEditedFileName write SetEditedFileName; + end; + + +var + maindsgn: TMainDesigner; + + +implementation + +uses + vfdformparser; + +{ TMainDesigner } + +procedure TMainDesigner.OnNewFile(Sender: TObject); +var + n: integer; +begin + EditedFileName := ''; + for n := 0 to FDesigners.Count - 1 do + begin + selectedform := nil; + TFormDesigner(FDesigners[n]).Free; + end; + FDesigners.Clear; + OnNewForm(Sender); +end; + + +procedure TMainDesigner.OnLoadFile(Sender: TObject); +var + n, m: integer; + bl, bl2: TVFDFileBlock; + fname: string; + afiledialog: TfpgFileDialog; +begin + fname := EditedFileName; + + if Sender <> maindsgn then + 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 (*)|*'; + if afiledialog.RunOpenFile then + begin + EditedFileName := aFileDialog.Filename; + fname := EditedFilename; + end + else + fname := ''; + FreeAndNil(aFileDialog); + end; + + if fname = '' then + Exit; + + for n := 0 to FDesigners.Count - 1 do + begin + selectedform := nil; + TFormDesigner(FDesigners[n]).Free; + end; + FDesigners.Clear; + + if not FileExists(fname) then + begin + ShowMessage('File does not exists.', 'Error loading form'); + Exit; + end; + + Writeln('loading file...'); + + FFile.LoadFile(fname); + FFile.GetBlocks; + + for n := 1 to FFile.BlockCount do + begin + bl := FFile.Block(n); + if bl.BlockID = 'VFD_HEAD_BEGIN' then + for m := n + 1 to FFile.BlockCount do + begin + bl2 := FFile.Block(m); + if (bl2.BlockID = 'VFD_BODY_BEGIN') and (bl2.FormName = bl.FormName) then + CreateParseForm(bl.FormName, bl.Data, bl2.Data)// pair has found + //Writeln('Parsing form: ',bl.FormName); + //Writeln(bl.data); + //Writeln(bl2.data); + ; + end; + end; + +end; + +procedure TMainDesigner.OnSaveFile(Sender: TObject); +var + n, i: integer; + fd: TFormDesigner; + fdata: string; + ff: file; + fname, uname: string; + aFileDialog: TfpgFileDialog; +begin + fname := EditedFileName; + + 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 (*)|*'; + if afiledialog.RunSaveFile then + begin + EditedFileName := aFileDialog.Filename; + fname := EditedFilename; + end + else + fname := ''; + aFileDialog.Free; + + if fname = '' then + Exit; + + EditedFileName := fname; + + if FileExists(fname) then + begin + FFile.LoadFile(fname); + FFile.GetBlocks; + end + else + begin + uname := ExtractFileName(fname); + i := pos('.pas', LowerCase(uname)); + if i > 0 then + uname := copy(uname, 1, i - 1); + FFile.NewFileSkeleton(uname); + end; + + for n := 1 to DesignerCount do + begin + fd := Designer(n); + FFile.SetFormData(fd.Form.Name, fd.GetFormSourceDecl, fd.GetFormSourceImpl); + end; + + fdata := FFile.MergeBlocks; + + AssignFile(ff, fname); + try + Rewrite(ff, 1); + try + BlockWrite(ff, fdata[1], length(fdata)); + finally + CloseFile(ff); + end; + writeln('Form saved.'); + + frmMain.WindowTitle := fname + ' - VFD v' + program_version; + + except + Writeln('Form save I/O failure.'); + end; + +end; + +procedure TMainDesigner.OnAnchorChange(Sender: TObject); +begin + if SelectedForm <> nil then + SelectedForm.OnAnchorChange(Sender); +end; + +procedure TMainDesigner.OnOtherChange(Sender: TObject); +begin + if SelectedForm <> nil then + SelectedForm.OnOtherChange(Sender); +end; + +procedure TMainDesigner.OnPropNameChange(Sender: TObject); +begin + if SelectedForm <> nil then + SelectedForm.OnPropNameChange(Sender); +end; + +procedure TMainDesigner.OnPropPosEdit(Sender: TObject); +begin + if SelectedForm <> nil then + SelectedForm.OnPropPosEdit(Sender); +end; + +procedure TMainDesigner.OnPropTextChange(Sender: TObject); +begin + if SelectedForm <> nil then + SelectedForm.OnPropTextChange(Sender); +end; + +procedure TMainDesigner.OnPaletteChange(Sender: TObject); +begin + +end; + +procedure TMainDesigner.OnNewForm(Sender: TObject); +var + fd: TFormDesigner; + nfrm: TNewFormForm; +begin + Writeln('new form'); + nfrm := TNewFormForm.Create(nil); + if nfrm.ShowModal = 1 then + if nfrm.edName.Text <> '' then + begin + fd := TFormDesigner.Create; + fd.Form.Name := nfrm.edName.Text; + fd.Form.WindowTitle := nfrm.edName.Text; + FDesigners.Add(fd); + fd.Show; + end; + nfrm.Free; +end; + +procedure TMainDesigner.CreateWindows; + //var + // fd : TFormDesigner; +begin + frmMain := TfrmMain.Create(nil); + frmMain.WindowTitle := 'fpGUI Form Designer - v' + program_version; + frmMain.Show; + + frmProperties := TfrmProperties.Create(nil); + frmProperties.Show; + + // fd := TFormDesigner.Create; + // fd.Form.Name := 'frmNewForm'; + // fd.Form.WindowTitle := u8('frmNewForm'); + // FDesigners.Add(fd); + // fd.Show; +end; + +constructor TMainDesigner.Create; +begin + FDesigners := TList.Create; + SelectedForm := nil; + FFile := TVFDFile.Create; + + // options + SaveComponentNames := False; + GridResolution := 4; + + FEditedFileName := ''; +end; + +destructor TMainDesigner.Destroy; +var + n: integer; +begin + for n := 0 to FDesigners.Count - 1 do + TFormDesigner(FDesigners[n]).Free; + FDesigners.Free; + FFile.Free; + inherited; +end; + +procedure TMainDesigner.SelectForm(aform: TFormDesigner); +begin + //Writeln('selected...'); + if (SelectedForm <> nil) and (SelectedForm <> aform) then + SelectedForm.DeSelectAll; + SelectedForm := aform; +end; + +function TMainDesigner.Designer(index: integer): TFormDesigner; +begin + Result := nil; + if (index < 1) or (index > FDesigners.Count) then + Exit; + Result := TFormDesigner(FDesigners[index - 1]); +end; + +function TMainDesigner.DesignerCount: integer; +begin + Result := FDesigners.Count; +end; + +function TMainDesigner.NewFormName: string; +var + n, i: integer; + s: string; +begin + i := 0; + repeat + Inc(i); + s := 'Form' + IntToStr(i); + n := 1; + while (n <= DesignerCount) do + begin + if Designer(n).Form.Name = s then + Break; + Inc(n); + end; + until n > DesignerCount; + Result := s; +end; + +procedure TMainDesigner.CreateParseForm(const FormName, FormHead, FormBody: string); +var + fd: TFormDesigner; + fp: TVFDFormParser; +begin + Writeln('CreateParseForm: ', FormName); + + fp := TVFDFormParser.Create(FormName, FormHead, FormBody); + fd := fp.ParseForm; + fp.Free; + + FDesigners.Add(fd); + fd.Show; +end; + +procedure TMainDesigner.OnEditWidget(Sender: TObject); +begin + if SelectedForm <> nil then + SelectedForm.OnEditWidget(Sender); +end; + +procedure TMainDesigner.OnEditWidgetOrder(Sender: TObject); +begin + if SelectedForm <> nil then + SelectedForm.EditWidgetOrder; +end; + +procedure TMainDesigner.OnExit(Sender: TObject); +begin + halt(0); +end; + +procedure TMainDesigner.OnOptionsClick(Sender: TObject); +var + frm: TfrmVFDSetup; +begin + frm := TfrmVFDSetup.Create(nil); + + case GridResolution of + 1: frm.chlGrid.FocusItem := 1; + 4: frm.chlGrid.FocusItem := 2; + 8: frm.chlGrid.FocusItem := 3; + end; + + if frm.ShowModal > 0 then + case frm.chlGrid.FocusItem of + 1: GridResolution := 1; + 2: GridResolution := 4; + 3: GridResolution := 8; + end; + + frm.Free; +end; + +procedure TMainDesigner.SetEditedFileName(const Value: string); +var + s: string; +begin + FEditedFileName := Value; + s := ExtractFileName(FEditedFileName); + if s = '' then + s := '[new]'; + frmMain.WindowTitle := s + ' - fpGUI uiDesigner ' + program_version; +end; + +end. + diff --git a/examples/apps/uidesigner/vfdprops.pas b/examples/apps/uidesigner/vfdprops.pas new file mode 100644 index 00000000..0b39a903 --- /dev/null +++ b/examples/apps/uidesigner/vfdprops.pas @@ -0,0 +1,508 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Property editors. +} + +unit vfdprops; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfxbase, + gfx_widget, + vfdwidgetclass, + gui_edit, + gui_button, + gui_combobox; + +type + + TPropertyString = class(TVFDWidgetProperty) + public + function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override; + function GetPropertySource(wg: TfpgWidget; const ident: string): string; override; + function GetValueText(wg: TfpgWidget): string; override; + function CreateEditor(AOwner: TComponent): TVFDPropertyEditor; override; + end; + + + TPropertyInteger = class(TVFDWidgetProperty) + public + function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override; + function GetPropertySource(wg: TfpgWidget; const ident: string): string; override; + function GetValueText(wg: TfpgWidget): string; override; + function CreateEditor(AOwner: TComponent): TVFDPropertyEditor; override; + end; + + + TPropertyEnum = class(TVFDWidgetProperty) + public + function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override; + function GetPropertySource(wg: TfpgWidget; const ident: string): string; override; + function GetValueText(wg: TfpgWidget): string; override; + function CreateEditor(AOwner: TComponent): TVFDPropertyEditor; override; + end; + + + TPropertyStringList = class(TVFDWidgetProperty) + public + function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override; + function GetPropertySource(wg: TfpgWidget; const ident: string): string; override; + function GetValueText(wg: TfpgWidget): string; override; + function CreateEditor(AOwner: TComponent): TVFDPropertyEditor; override; + procedure OnExternalEdit(wg: TfpgWidget); override; + end; + + + TGPEType = (gptInteger, gptString); + + + TGeneralPropertyEditor = class(TVFDPropertyEditor) + public + etype: TGPEType; + edit: TfpgEdit; + procedure CreateLayout; override; + procedure LoadValue(wg: TfpgWidget); override; + procedure StoreValue(wg: TfpgWidget); override; + procedure LoadIntValue(wg: TfpgWidget); + procedure StoreIntValue(wg: TfpgWidget); + procedure LoadStrValue(wg: TfpgWidget); + procedure StoreStrValue(wg: TfpgWidget); + end; + + + TChoicePropertyEditor = class(TVFDPropertyEditor) + public + chl: TfpgComboBox; + procedure CreateLayout; override; + procedure LoadValue(wg: TfpgWidget); override; + procedure StoreValue(wg: TfpgWidget); override; + end; + + + TExternalPropertyEditor = class(TVFDPropertyEditor) + protected + procedure HandlePaint; override; + public + btnEdit: TfpgButton; + Widget: TfpgWidget; + procedure CreateLayout; override; + procedure LoadValue(wg: TfpgWidget); override; + procedure StoreValue(wg: TfpgWidget); override; + procedure OnEditClick(Sender: TObject); + end; + + +procedure EditStringList(sl: TStringList); +procedure GetEnumPropValueList(wg: TObject; const propname: string; sl: TStringList); + + +implementation + +uses + TypInfo, + vfdformparser, + vfdeditors, + fpgfx; + +procedure EditStringList(sl: TStringList); +var + frmie: TItemEditorForm; +begin + frmie := TItemEditorForm.Create(nil); + //GfxGetAbsolutePosition(PropertyForm.btnEdit.WinHandle, PropertyForm.btnEdit.width, 0, ax,ay); + //frmie.Left := ax; + //frmie.Top := ay; + + frmie.edItems.Lines.Assign(sl); + if frmie.ShowModal = 1 then + sl.Assign(frmie.edItems.Lines); + frmie.Free; +end; + +procedure GetEnumPropValueList(wg: TObject; const propname: string; sl: TStringList); +var + pi: PPropInfo; + P: ^ShortString; + T: PTypeData; + n: integer; +begin + pi := GetPropInfo(wg, propname); +{$ifdef FPC} + T := GetTypeData(pi^.PropType); +{$else} + T := GetTypeData(pi^.PropType^); +{$endif} + P := @T^.NameList; + + for n := 0 to T^.MaxValue do + begin + sl.Add(P^); + Inc(integer(P), Length(P^) + 1); + end; +end; + +{ TPropertyString } + +function TPropertyString.CreateEditor(AOwner: TComponent): TVFDPropertyEditor; +begin + Result := TGeneralPropertyEditor.Create(AOwner, self); + with TGeneralPropertyEditor(Result) do + etype := gptString; +end; + +function TPropertyString.GetPropertySource(wg: TfpgWidget; const ident: string): string; +begin + Result := ident + Name + ' := ' + QuotedStr(GetStrProp(wg, Name)) + ';' + LineEnding; +end; + +function TPropertyString.GetValueText(wg: TfpgWidget): string; +begin + Result := GetStrProp(wg, Name); +end; + +function TPropertyString.ParseSourceLine(wg: TfpgWidget; const line: string): boolean; +var + s, sval: string; +begin + s := line; + Result := False; + if UpperCase(GetIdentifier(s)) <> UpperCase(Name) then + Exit; + + Result := CheckSymbol(s, ':='); + if Result then + begin + sval := GetStringValue(s); + Result := CheckSymbol(s, ';'); + end; + + if Result then + SetStrProp(wg, Name, sval); +end; + + +{ TPropertyInteger } + +function TPropertyInteger.CreateEditor(AOwner: TComponent): TVFDPropertyEditor; +begin + Result := TGeneralPropertyEditor.Create(AOwner, self); + with TGeneralPropertyEditor(Result) do + etype := gptInteger; +end; + +function TPropertyInteger.GetPropertySource(wg: TfpgWidget; const ident: string): string; +begin + Result := ident + Name + ' := ' + IntToStr(GetOrdProp(wg, Name)) + ';' + LineEnding; +end; + +function TPropertyInteger.GetValueText(wg: TfpgWidget): string; +begin + Result := IntToStr(GetOrdProp(wg, Name)); +end; + +function TPropertyInteger.ParseSourceLine(wg: TfpgWidget; const line: string): boolean; +var + s: string; + ival: integer; +begin + s := line; + Result := False; + if UpperCase(GetIdentifier(s)) <> UpperCase(Name) then + Exit; + + Result := CheckSymbol(s, ':='); + if Result then + begin + ival := GetIntValue(s); + Result := CheckSymbol(s, ';'); + end + else + ival := 0; + + if Result then + SetOrdProp(wg, Name, ival); +end; + +{ TGeneralPropertyEditor } + +procedure TGeneralPropertyEditor.CreateLayout; +begin + Anchors := [anTop, anLeft, anRight]; + Edit := TfpgEdit.Create(self); + Edit.SetPosition(0, 0, Width, Height); + Edit.Anchors := Anchors; + Edit.OnChange := @UpdateProperty; +end; + +procedure TGeneralPropertyEditor.LoadIntValue(wg: TfpgWidget); +begin + edit.Text := IntToStr(GetOrdProp(wg, prop.Name)); +end; + +procedure TGeneralPropertyEditor.LoadStrValue(wg: TfpgWidget); +var + s: string; +begin + s := GetStrProp(wg, prop.Name); + if etype = gptString then + edit.Text := s; +end; + +procedure TGeneralPropertyEditor.LoadValue(wg: TfpgWidget); +begin + case etype of + gptInteger: LoadIntValue(wg); + else + LoadStrValue(wg); + end; +end; + +procedure TGeneralPropertyEditor.StoreIntValue(wg: TfpgWidget); +var + i: integer; +begin + try + i := StrToInt(edit.Text); + SetOrdProp(wg, Prop.Name, i); + except + // error + end; +end; + +procedure TGeneralPropertyEditor.StoreStrValue(wg: TfpgWidget); +var + s: string; +begin + if etype = gptString then + s := edit.Text; + SetStrProp(wg, prop.Name, s); +end; + +procedure TGeneralPropertyEditor.StoreValue(wg: TfpgWidget); +begin + case etype of + gptInteger: StoreIntValue(wg); + else + StoreStrValue(wg); + end; +end; + +{ TPropertyStringList } + +function TPropertyStringList.CreateEditor(AOwner: TComponent): TVFDPropertyEditor; +begin + Result := TExternalPropertyEditor.Create(AOwner, self); +end; + +function TPropertyStringList.GetPropertySource(wg: TfpgWidget; const ident: string): string; +var + sl: TStringList; + f: integer; +begin + sl := TStringList(GetObjectProp(wg, Name, TStrings)); + + Result := ''; + + for f := 0 to sl.Count - 1 do + Result := Result + ident + Name + '.Add(' + QuotedStr(sl.Strings[f]) + ');' + LineEnding; +end; + +function TPropertyStringList.GetValueText(wg: TfpgWidget): string; +var + sl: TStringList; +begin + sl := TStringList(GetObjectProp(wg, Name, TStrings)); + Result := '[' + IntToStr(sl.Count) + ' lines]'; +end; + +procedure TPropertyStringList.OnExternalEdit(wg: TfpgWidget); +var + sl: TStringList; +begin + sl := TStringList(GetObjectProp(wg, Name, TStrings)); + EditStringList(sl); +end; + +function TPropertyStringList.ParseSourceLine(wg: TfpgWidget; const line: string): boolean; +var + s: string; + sval: string; + sl: TStringList; +begin + s := line; + Result := False; + if UpperCase(GetIdentifier(s)) <> UpperCase(Name) then + Exit; + + Result := CheckSymbol(s, '.'); + Result := Result and (UpperCase(GetIdentifier(s)) = 'ADD'); + Result := Result and CheckSymbol(s, '('); + if Result then + begin + sval := GetStringValue(s); + Result := Result and CheckSymbol(s, ')'); + Result := Result and CheckSymbol(s, ';'); + end; + + if Result then + begin + sl := TStringList(GetObjectProp(wg, Name, TStrings)); + sl.Add(sval); + end; +end; + +{ TExternalPropertyEditor } + +procedure TExternalPropertyEditor.HandlePaint; +var + r: TfpgRect; +begin +// inherited HandlePaint; +// if not Windowed then +// Exit; + if widget = nil then + Exit; + Canvas.BeginDraw; + Canvas.Clear(clBoxColor); + Canvas.GetWinRect(r); + Canvas.SetTextColor(clText1); + prop.DrawValue(Widget, Canvas, r, 0); + Canvas.EndDraw; +end; + +procedure TExternalPropertyEditor.CreateLayout; +begin + inherited; + Widget := nil; + Anchors := [anTop, anLeft, anRight]; + + btnEdit := TfpgButton.Create(self); + with btnEdit do + begin + Height := self.Height; + Width := 24; + Top := 0; + Left := self.Width - Width; + Text := '...'; + UpdateWindowPosition; + Anchors := [anTop, anRight]; + OnClick := @OnEditClick; + end; +end; + +procedure TExternalPropertyEditor.LoadValue(wg: TfpgWidget); +begin + Widget := wg; + RePaint; +end; + +procedure TExternalPropertyEditor.OnEditClick(Sender: TObject); +begin + if widget = nil then + Exit; + prop.OnExternalEdit(widget); + widget.Invalidate; +end; + +procedure TExternalPropertyEditor.StoreValue(wg: TfpgWidget); +begin + // nothing +end; + +{ TPropertyEnum } + +function TPropertyEnum.CreateEditor(AOwner: TComponent): TVFDPropertyEditor; +begin + Result := TChoicePropertyEditor.Create(AOwner, self); +end; + +function TPropertyEnum.GetValueText(wg: TfpgWidget): string; +begin + Result := GetEnumProp(wg, Name); +end; + +function TPropertyEnum.GetPropertySource(wg: TfpgWidget; const ident: string): string; +begin + Result := ident + Name + ' := ' + GetEnumProp(wg, Name) + ';' + LineEnding; +end; + +function TPropertyEnum.ParseSourceLine(wg: TfpgWidget; const line: string): boolean; +var + s, sval: string; +begin + s := line; + Result := False; + if UpperCase(GetIdentifier(s)) <> UpperCase(Name) then + Exit; + + Result := CheckSymbol(s, ':='); + if Result then + begin + sval := GetIdentifier(s); + Result := CheckSymbol(s, ';'); + end; + + if Result then + try + SetEnumProp(wg, Name, sval); + except + Writeln('invalid enum value: "' + sval + '" for ' + Name); + Result := False; + end; +end; + +{ TChoicePropertyEditor } + +procedure TChoicePropertyEditor.CreateLayout; +begin + Anchors := [anTop, anLeft, anRight]; + chl := TfpgComboBox.Create(self); + chl.SetPosition(0, 0, Width, Height); + chl.Anchors := Anchors; + chl.OnChange := @UpdateProperty; +end; + +procedure TChoicePropertyEditor.LoadValue(wg: TfpgWidget); +var + sv: string; + i, fi: integer; + sl: TStringList; +begin + sv := GetEnumProp(wg, prop.Name); + sl := TStringList.Create; + GetEnumPropValueList(wg, prop.Name, sl); + fi := 1; + for i := 0 to sl.Count - 1 do + begin + chl.Items.Add(sl.Strings[i]); + if UpperCase(sv) = UpperCase(sl.Strings[i]) then + fi := i + 1; + end; + chl.FocusItem := fi; + sl.Free; +end; + +procedure TChoicePropertyEditor.StoreValue(wg: TfpgWidget); +begin + SetEnumProp(wg, prop.Name, chl.Text); +end; + +end. + diff --git a/examples/apps/uidesigner/vfdresizer.pas b/examples/apps/uidesigner/vfdresizer.pas new file mode 100644 index 00000000..f26e0e86 --- /dev/null +++ b/examples/apps/uidesigner/vfdresizer.pas @@ -0,0 +1,140 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + The resizer widget used in the form designer. +} + +unit vfdresizer; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfxbase, + gfx_widget; + +type + TwgResizer = class(TfpgWidget) + protected + wgdesigner: TObject; + FBackgroundColor: TfpgColor; + procedure HandlePaint; override; + procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; + procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; + procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); override; + public + direction: integer; + FDragging: boolean; + FDragPosX, + FDragPosY: TfpgCoord; + constructor Create(ACompDesigner: TObject; adirection: integer); reintroduce; + procedure Show; + end; + +implementation + +uses + vfddesigner, + vfdforms; + +{ TwgResizer } + +procedure TwgResizer.HandlePaint; +begin + inherited HandlePaint; + Canvas.BeginDraw; + Canvas.Clear(FBackgroundColor); + Canvas.EndDraw; +end; + +procedure TwgResizer.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); +begin + inherited HandleLMouseDown(x, y, shiftstate); + FDragging := True; + FDragPosX := x; + FDragPosy := y; +end; + +procedure TwgResizer.HandleLMouseUp(x, y: integer; shiftstate: TShiftState); +begin + inherited HandleLMouseUp(x, y, shiftstate); + FDragging := False; +end; + +procedure TwgResizer.HandleMouseMove(x, y: integer; btnstate: word; + shiftstate: TShiftState); +var + dx, + dy: integer; + gridc: integer; + wgd: TWidgetDesigner; +begin +// inherited HandleMouseMove(x, y, btnstate, shiftstate); + + if not FDragging then + Exit; + dx := x - FDragPosX; + dy := y - FDragPosY; + + wgd := TWidgetDesigner(wgdesigner); + gridc := GridResolution; + + dx := dx - dx mod gridc; + dy := dy - dy mod gridc; + + case direction of + 1: wgd.Widget.MoveAndResizeBy(dx, dy, -dx, -dy); + 2: wgd.Widget.MoveAndResizeBy(0, dy, 0, -dy); + 3: wgd.Widget.MoveAndResizeBy(0, dy, dx, -dy); + 4: wgd.Widget.MoveAndResizeBy(0, 0, dx, 0); + 5: wgd.Widget.MoveAndResizeBy(0, 0, dx, dy); + 6: wgd.Widget.MoveAndResizeBy(0, 0, 0, dy); + 7: wgd.Widget.MoveAndResizeBy(dx, 0, -dx, dy); + 8: wgd.Widget.MoveAndResizeBy(dx, 0, -dx, 0); + end; + wgd.UpdateResizerPositions; + wgd.FormDesigner.UpdatePropWin; +end; + +constructor TwgResizer.Create(ACompDesigner: TObject; adirection: integer); +begin + inherited Create(TWidgetDesigner(aCompDesigner).Widget.Parent); + FBackgroundColor := $404040; + wgdesigner := aCompDesigner; + FDragging := False; + Width := 5; + Height := 5; + direction := adirection; + case direction of + 1: MouseCursor := mcSizeNWSE; + 2: MouseCursor := mcSizeNS; + 3: MouseCursor := mcSizeNESW; + 4: MouseCursor := mcSizeEW; + 5: MouseCursor := mcSizeNWSE; + 6: MouseCursor := mcSizeNS; + 7: MouseCursor := mcSizeNESW; + 8: MouseCursor := mcSizeEW; + end; +end; + +procedure TwgResizer.Show; +begin + HandleShow; +end; + +end. + diff --git a/examples/apps/uidesigner/vfdutils.pas b/examples/apps/uidesigner/vfdutils.pas new file mode 100644 index 00000000..fe60c933 --- /dev/null +++ b/examples/apps/uidesigner/vfdutils.pas @@ -0,0 +1,82 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Some utility functions. +} + +unit vfdutils; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfx_widget, + gui_form, + gui_label, + gui_edit, + gui_button, + gui_memo, + gui_checkbox; + + +procedure SetWidgetText(wg: TfpgWidget; txt: string); +function GetWidgetText(wg: TfpgWidget; out txt: string): boolean; + + +implementation + +procedure SetWidgetText(wg: TfpgWidget; txt: string); +begin + if wg is TfpgForm then + TfpgForm(wg).WindowTitle := txt + else if wg is TfpgLabel then + TfpgLabel(wg).Text := txt + else if wg is TfpgEdit then + TfpgEdit(wg).Text := txt + else if wg is TfpgMemo then + TfpgMemo(wg).Text := txt + else if wg is TfpgButton then + TfpgButton(wg).Text := txt + else if wg is TfpgCheckBox then + TfpgCheckBox(wg).Text := txt; +end; + +function GetWidgetText(wg: TfpgWidget; out txt: string): boolean; +begin + Result := True; + if wg is TfpgForm then + txt := TfpgForm(wg).WindowTitle + else if wg is TfpgLabel then + txt := TfpgLabel(wg).Text + else if wg is TfpgEdit then + txt := TfpgEdit(wg).Text + else if wg is TfpgMemo then + txt := TfpgMemo(wg).Text + else if wg is TfpgButton then + txt := TfpgButton(wg).Text + else if wg is TfpgCheckBox then + txt := TfpgCheckBox(wg).Text + else + begin + Result := False; + txt := ''; + end; +end; + + +end. + diff --git a/examples/apps/uidesigner/vfdwidgetclass.pas b/examples/apps/uidesigner/vfdwidgetclass.pas new file mode 100644 index 00000000..94751810 --- /dev/null +++ b/examples/apps/uidesigner/vfdwidgetclass.pas @@ -0,0 +1,224 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Main window functionality and designer class. +} + +unit vfdwidgetclass; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + gfxbase, + fpgfx, + gfx_widget; + +type + TWidgetClass = class of TfpgWidget; + + + TVFDWidgetProperty = class; + + + TVFDPropertyEditor = class(TfpgWidget) + private + FProp: TVFDWidgetProperty; + public + OnUpdate: TNotifyEvent; + procedure UpdateProperty(Sender: TObject); + property Prop: TVFDWidgetProperty read FProp; + constructor Create(AOwner: TComponent; aprop: TVFDWidgetProperty); reintroduce; + public + // virtuals + procedure CreateLayout; virtual; + procedure LoadValue(wg: TfpgWidget); virtual; + procedure StoreValue(wg: TfpgWidget); virtual; + end; + + + TVFDWidgetProperty = class(TObject) + public + Name: string; + Description: string; + public + // Virtuals + constructor Create(aName: string); virtual; + function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; virtual; + function GetPropertySource(wg: TfpgWidget; const ident: string): string; virtual; + // Property editing + function GetValueText(wg: TfpgWidget): string; virtual; + procedure DrawValue(wg: TfpgWidget; Canvas: TfpgCanvas; rect: TfpgRect; flags: integer); virtual; + function CreateEditor(AOwner: TComponent): TVFDPropertyEditor; virtual; + procedure OnExternalEdit(wg: TfpgWidget); virtual; + end; + + + TVFDPropertyClass = class of TVFDWidgetProperty; + + + TVFDWidgetClass = class(TObject) + private + FProps: TList; + public + WidgetClass: TWidgetClass; + Description: string; + WidgetIconName: string; + NameBase: string; + Container: boolean; + constructor Create(aClass: TWidgetClass); + destructor Destroy; override; + function AddProperty(apropname: string; apropclass: TVFDPropertyClass; desc: string): TVFDWidgetProperty; + function PropertyCount: integer; + function GetProperty(ind: integer): TVFDWidgetProperty; + function CreateWidget(AOwner: TComponent): TfpgWidget; + end; + + +implementation + +uses + TypInfo; + +{ TVFDWidgetClass } + +function TVFDWidgetClass.AddProperty(apropname: string; apropclass: TVFDPropertyClass; + desc: string): TVFDWidgetProperty; +begin + Result := apropclass.Create(apropname); + Result.Description := desc; + FProps.Add(Result); +end; + +constructor TVFDWidgetClass.Create(aClass: TWidgetClass); +begin + WidgetClass := aClass; + FProps := TList.Create; + Description := ''; + NameBase := 'Widget'; + Container := False; +end; + +function TVFDWidgetClass.CreateWidget(AOwner: TComponent): TfpgWidget; +begin + Result := WidgetClass.Create(AOwner); +end; + +destructor TVFDWidgetClass.Destroy; +var + n: integer; +begin + for n := 0 to FProps.Count - 1 do + TVFDWidgetProperty(FProps[n]).Free; + FProps.Free; + inherited; +end; + +function TVFDWidgetClass.GetProperty(ind: integer): TVFDWidgetProperty; +begin + Result := TVFDWidgetProperty(FProps[ind - 1]); +end; + +function TVFDWidgetClass.PropertyCount: integer; +begin + Result := FProps.Count; +end; + +{ TVFDWidgetProperty } + +constructor TVFDWidgetProperty.Create(aName: string); +begin + Name := aName; + Description := ''; +end; + +function TVFDWidgetProperty.GetPropertySource(wg: TfpgWidget; const ident: string): string; +begin + +end; + +function TVFDWidgetProperty.ParseSourceLine(wg: TfpgWidget; const line: string): boolean; +begin + Result := False; +end; + +function TVFDWidgetProperty.CreateEditor(AOwner: TComponent): TVFDPropertyEditor; +begin + Result := nil; +end; + +procedure TVFDWidgetProperty.DrawValue(wg: TfpgWidget; Canvas: TfpgCanvas; rect: TfpgRect; flags: integer); +var + x, y, fy: integer; + s: string; +begin + x := rect.left; + y := rect.top; + fy := y + rect.Height div 2 - Canvas.Font.Height div 2; + + s := GetValueText(wg); + Canvas.BeginDraw; + Canvas.DrawString(x + 1, fy, s); + Canvas.EndDraw; +end; + +function TVFDWidgetProperty.GetValueText(wg: TfpgWidget): string; +begin + Result := '[' + Name + ']'; +end; + +procedure TVFDWidgetProperty.OnExternalEdit(wg: TfpgWidget); +begin + writeln('external edit'); +end; + +{ TVFDPropertyEditor } + +constructor TVFDPropertyEditor.Create(AOwner: TComponent; aprop: TVFDWidgetProperty); +begin + inherited Create(AOwner); + OnUpdate := nil; + FProp := aprop; +end; + +procedure TVFDPropertyEditor.CreateLayout; +begin + //abstract +end; + +procedure TVFDPropertyEditor.LoadValue(wg: TfpgWidget); +begin + Writeln('abstract: editor.LoadValue'); +end; + +procedure TVFDPropertyEditor.UpdateProperty(Sender: TObject); +begin + if Assigned(OnUpdate) then + OnUpdate(self); +end; + +procedure TVFDPropertyEditor.StoreValue(wg: TfpgWidget); +begin + Writeln('abstract: editor.StoreValue'); + // check property type + // the property must be published ! + // PPropInfo := GetPropInfo(object, 'propname'); + // if PPropInfo^.PropType^.name = +end; + +end. + diff --git a/examples/apps/uidesigner/vfdwidgets.pas b/examples/apps/uidesigner/vfdwidgets.pas new file mode 100644 index 00000000..c628ebf0 --- /dev/null +++ b/examples/apps/uidesigner/vfdwidgets.pas @@ -0,0 +1,263 @@ +{ + fpGUI - Free Pascal GUI Library + + Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Setting up of widgets, properties and images. +} + +unit vfdwidgets; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, + Classes, + vfdwidgetclass, + vfdprops, + typinfo; + +procedure RegisterWidgets; +procedure RegisterVFDWidget(awc: TVFDWidgetClass); +function VFDWidgetCount: integer; +function VFDWidget(ind: integer): TVFDWidgetClass; +function VFDFormWidget: TVFDWidgetClass; + +var + VFDOtherWidget: TVFDWidgetClass; + +implementation + +uses + vfddesigner, + gui_form, + gui_label, + gui_edit, + gui_button, + gui_listbox, + gui_memo, + gui_combobox, + gui_grid, + gui_checkbox, + gui_bevel, + fpgfx + ; + +var + FVFDFormWidget: TVFDWidgetClass; + FVFDWidgets: TList; + +function VFDFormWidget: TVFDWidgetClass; +begin + Result := FVFDFormWidget; +end; + +function VFDWidgetCount: integer; +begin + Result := FVFDWidgets.Count; +end; + +function VFDWidget(ind: integer): TVFDWidgetClass; +begin + Result := TVFDWidgetClass(FVFDWidgets[ind - 1]); +end; + +procedure RegisterVFDWidget(awc: TVFDWidgetClass); +begin + FVFDWidgets.Add(awc); +end; + +{$I icons.inc} + +procedure LoadIcons; +begin + fpgImages.AddMaskedBMP( + 'vfd.arrow', @stdimg_vfd_arrow, + sizeof(stdimg_vfd_arrow), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.label', @stdimg_vfd_label, + sizeof(stdimg_vfd_label), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.edit', @stdimg_vfd_edit, + sizeof(stdimg_vfd_edit), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.memo', @stdimg_vfd_memo, + sizeof(stdimg_vfd_memo), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.button', @stdimg_vfd_button, + sizeof(stdimg_vfd_button), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.checkbox', @stdimg_vfd_checkbox, + sizeof(stdimg_vfd_checkbox), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.listbox', @stdimg_vfd_listbox, + sizeof(stdimg_vfd_listbox), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.choicelist', @stdimg_vfd_choicelist, + sizeof(stdimg_vfd_choicelist), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.panel', @stdimg_vfd_panel, + sizeof(stdimg_vfd_panel), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.other', @stdimg_vfd_other, + sizeof(stdimg_vfd_other), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.dbgrid', + @stdimg_vfd_dbgrid, + sizeof(stdimg_vfd_dbgrid), + 15,0 ); + + { + fpgImages.AddMaskedBMP( + 'vfd.', + @stdimg_vfd_, + sizeof(stdimg_vfd_), + 0,0 ); +} +end; + +procedure AddWidgetPosProps(wgc: TVFDWidgetClass); +begin + wgc.AddProperty('Left', TPropertyInteger, ''); + wgc.AddProperty('Top', TPropertyInteger, ''); + wgc.AddProperty('Width', TPropertyInteger, ''); + wgc.AddProperty('Height', TPropertyInteger, ''); +end; + +procedure RegisterWidgets; +var + wc: TVFDWidgetClass; + //wp : TVFDWidgetProperty; +begin + LoadIcons; + + wc := TVFDWidgetClass.Create(TfpgForm); + wc.NameBase := 'frm'; + wc.AddProperty('WindowTitle', TPropertyString, ''); + FVFDFormWidget := wc; + + // Label + wc := TVFDWidgetClass.Create(TfpgLabel); + wc.NameBase := 'lb'; + wc.AddProperty('Text', TPropertyString, 'Label text'); + wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the label text'); + wc.WidgetIconName := 'vfd.label'; + RegisterVFDWidget(wc); + + // Edit + wc := TVFDWidgetClass.Create(TfpgEdit); + wc.NameBase := 'ed'; + wc.AddProperty('Text', TPropertyString, 'Initial text'); + wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text'); + wc.WidgetIconName := 'vfd.edit'; + RegisterVFDWidget(wc); + + // Memo + wc := TVFDWidgetClass.Create(TfpgMemo); + wc.NameBase := 'memo'; + wc.AddProperty('Lines', TPropertyStringList, ''); + wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text'); + wc.WidgetIconName := 'vfd.memo'; + RegisterVFDWidget(wc); + + // Button + wc := TVFDWidgetClass.Create(TfpgButton); + wc.NameBase := 'btn'; + wc.AddProperty('Text', TPropertyString, 'Initial text'); + wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text'); + wc.AddProperty('ImageName', TPropertyString, ''); +// wc.AddProperty('ShowImage', TPropertyEnum, ''); + wc.AddProperty('ModalResult', TPropertyInteger, ''); + wc.WidgetIconName := 'vfd.button'; + RegisterVFDWidget(wc); + + // CheckBox + wc := TVFDWidgetClass.Create(TfpgCheckBox); + wc.NameBase := 'cb'; + wc.AddProperty('Text', TPropertyString, 'Initial text'); + wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text'); + wc.WidgetIconName := 'vfd.checkbox'; + RegisterVFDWidget(wc); + + // ChoiceList + wc := TVFDWidgetClass.Create(TfpgComboBox); + wc.NameBase := 'chl'; + //wc.AddProperty('Text',TPropertyString16,''); + wc.AddProperty('Items', TPropertyStringList, ''); + wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text'); + wc.WidgetIconName := 'vfd.choicelist'; + RegisterVFDWidget(wc); + + // TextListBox + wc := TVFDWidgetClass.Create(TfpgListBox); + wc.NameBase := 'lst'; + //wc.AddProperty('Text',TPropertyString16,''); + wc.AddProperty('Items', TPropertyStringList, ''); + wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text'); + wc.WidgetIconName := 'vfd.listbox'; + RegisterVFDWidget(wc); + + // StringGrid + wc := TVFDWidgetClass.Create(TfpgStringGrid); + wc.NameBase := 'grid'; +// wc.AddProperty('Columns',TPropertyDBColumns,''); + wc.AddProperty('FontDesc',TPropertyString,''); + wc.AddProperty('HeaderFontName',TPropertyString,''); + wc.WidgetIconName := 'vfd.dbgrid'; + RegisterVFDWidget(wc); + + // Panel + wc := TVFDWidgetClass.Create(TfpgBevel); + wc.NameBase := 'panel'; + wc.AddProperty('shape', TPropertyEnum, ''); + wc.AddProperty('style', TPropertyEnum, ''); + wc.WidgetIconName := 'vfd.panel'; + wc.Container := True; + RegisterVFDWidget(wc); + + // Other - do not delete!!! this should be the last... + wc := TVFDWidgetClass.Create(TOtherWidget); + wc.NameBase := 'wg'; + wc.WidgetIconName := 'vfd.other'; + RegisterVFDWidget(wc); + VFDOtherWidget := wc; +end; + +initialization + begin + FVFDWidgets := TList.Create; + end; + +end. + |