diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2014-10-17 00:06:38 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2014-10-17 00:06:38 +0100 |
commit | 7f1e8fd139e8c79b9d917a67d4418d0eeba8f0d5 (patch) | |
tree | 5684bb3f86401b968b0858c906682cd361e81c2d | |
parent | 8ceffe4943bab8641d6f804b79df4d1f79a41e88 (diff) | |
download | fpGUI-7f1e8fd139e8c79b9d917a67d4418d0eeba8f0d5.tar.xz |
uidesigner: Now has an experimental "visual grid" on designer form.
This grid can be toggled on or off. Because it is experimental and still
a ongoing feature, there are currently some limitations:
- Grid toggle status is not saved between sessions
- Grid color is not yet configurable
- Grid size can only be between 1-10
-rw-r--r-- | uidesigner/anchors.inc | 52 | ||||
-rw-r--r-- | uidesigner/newformdesigner.pas | 31 | ||||
-rw-r--r-- | uidesigner/uidesigner.lpi | 8 | ||||
-rw-r--r-- | uidesigner/vfddesigner.pas | 52 | ||||
-rw-r--r-- | uidesigner/vfdmain.pas | 23 |
5 files changed, 156 insertions, 10 deletions
diff --git a/uidesigner/anchors.inc b/uidesigner/anchors.inc index 0c9b3738..a53b557e 100644 --- a/uidesigner/anchors.inc +++ b/uidesigner/anchors.inc @@ -206,3 +206,55 @@ Const 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 255, 0,255,255, 0,255); + +Const + vfd_grid : Array[0..821] of byte = ( + 66, 77, 54, 3, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 16, 0, 0, 0, 16, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 0, 3, 0, 0,196, 14, 0, 0,196, 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,192,113, 65,255, 0,255,255, 0, + 255,176,105, 65,255, 0,255,255, 0,255,160, 97, 49,255, 0,255,255, + 0,255,160, 89, 49,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,192,121, 81,255, 0,255,255, 0,255,176,105, + 65,255, 0,255,255, 0,255,160, 97, 49,255, 0,255,255, 0,255,160, + 89, 49,255, 0,255,255, 0,255,255, 0,255,255, 0,255,192,129, 81, + 192,129, 81,192,121, 81,192,121, 81,192,113, 65,176,113, 65,176,105, + 65,176,105, 49,176, 97, 49,176, 97, 49,160, 89, 49,160, 89, 49,160, + 89, 49,160, 89, 49,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 192,129, 81,255,255,255,255,255,255,192,113, 65,255,255,255,255,255, + 255,176,105, 65,255,255,255,255,255,255,160, 97, 49,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,192,129, 81, + 255,255,255,255,255,255,192,121, 65,255,255,255,255,255,255,176,105, + 65,255,255,255,255,255,255,176, 97, 49,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,208,144, 97,208,136, 97,208,136, 97,192,129, 81, + 192,129, 81,192,121, 81,192,121, 81,192,113, 65,176,105, 65,176,105, + 65,176,105, 49,176, 97, 49,176, 97, 49,160, 89, 49,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,208,136, 97,255,255,255,255,255,255, + 192,129, 81,255,255,255,255,255,255,192,113, 65,255,255,255,255,255, + 255,176,105, 65,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,208,144, 97,255,255,255,255,255,255,192,129, 81, + 255,255,255,255,255,255,192,121, 81,255,255,255,255,255,255,176,105, + 65,255, 0,255,255, 0,255,255, 0,255,255, 0,255,224,152,113,224, + 152,113,208,144, 97,208,144, 97,208,136, 97,208,136, 97,192,129, 81, + 192,129, 81,192,121, 81,192,121, 65,176,113, 65,176,113, 65,176,105, + 65,176,105, 65,255, 0,255,255, 0,255,255, 0,255,255, 0,255,224, + 152, 97,255,255,255,255,255,255,208,136, 97,255,255,255,255,255,255, + 192,129, 81,255,255,255,255,255,255,192,113, 65,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,224,152,113,255, + 255,255,255,255,255,208,144, 97,255,255,255,255,255,255,192,129, 81, + 255,255,255,255,255,255,192,121, 81,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,224,152,113,224,152,113,224,152,113,224,152,113,224, + 152, 97,208,144, 97,208,144, 97,208,136, 97,208,136, 97,208,129, 81, + 192,129, 81,192,121, 81,192,121, 81,176,113, 65,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,224,152,113,255, 0,255,255, 0,255,224, + 144, 97,255, 0,255,255, 0,255,208,136, 97,255, 0,255,255, 0,255, + 192,129, 81,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,224,152,113,255, 0,255,255, 0,255,224,152,113,255, + 0,255,255, 0,255,208,144, 97,255, 0,255,255, 0,255,208,129, 81, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255); diff --git a/uidesigner/newformdesigner.pas b/uidesigner/newformdesigner.pas index 31b9431d..29962b93 100644 --- a/uidesigner/newformdesigner.pas +++ b/uidesigner/newformdesigner.pas @@ -63,6 +63,7 @@ type procedure miMRUClick(Sender: TObject; const FileName: string); procedure SetupCaptions; procedure BuildThemePreviewMenu; + procedure ToggleDesignerGrid(Sender: TObject); public {@VFD_HEAD_BEGIN: frmMain} MainMenu: TfpgMenuBar; @@ -77,6 +78,7 @@ type miOpenRecentMenu: TfpgPopupMenu; helpmenu: TfpgPopupMenu; previewmenu: TfpgPopupMenu; + btnGrid: TfpgButton; {@VFD_HEAD_END: frmMain} mru: TfpgMRU; constructor Create(AOwner: TComponent); override; @@ -218,7 +220,6 @@ begin WindowTitle := 'Product Information...'; Hint := ''; WindowPosition := wpScreenCenter; - Sizeable := False; OnShow := @FormShow; lblAppName := TfpgLabel.Create(self); @@ -467,6 +468,25 @@ begin SetPosition(324, 36, 120, 20); end; + btnGrid := TfpgButton.Create(self); + with btnGrid do + begin + Name := 'btnGrid'; + SetPosition(103, 28, 25, 24); + Text := ''; + AllowAllUp := True; + FontDesc := '#Label1'; + GroupIndex := 1; + Hint := 'Toggle designer grid'; + ImageMargin := -1; + ImageName := 'vfd.grid'; + ImageSpacing := 0; + TabOrder := 13; + Focusable := False; + AllowDown := True; + OnClick := @ToggleDesignerGrid; + end; + {@VFD_BODY_END: frmMain} {%endregion} @@ -980,9 +1000,18 @@ begin sl.Free; end; +procedure TfrmMain.ToggleDesignerGrid(Sender: TObject); +begin + maindsgn.ShowGrid := btnGrid.Down; +end; + constructor TfrmMain.Create(AOwner: TComponent); begin inherited Create(AOwner); + fpgImages.AddMaskedBMP( + 'vfd.grid', @vfd_grid, + sizeof(vfd_grid), 0, 0); + OnShow := @FormShow; end; diff --git a/uidesigner/uidesigner.lpi b/uidesigner/uidesigner.lpi index be5b651a..fb0afe9c 100644 --- a/uidesigner/uidesigner.lpi +++ b/uidesigner/uidesigner.lpi @@ -36,7 +36,6 @@ <Unit0> <Filename Value="uidesigner.lpr"/> <IsPartOfProject Value="True"/> - <UnitName Value="uidesigner"/> </Unit0> <Unit1> <Filename Value="vfdmain.pas"/> @@ -46,7 +45,6 @@ <Unit2> <Filename Value="vfdresizer.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="vfdresizer"/> </Unit2> <Unit3> <Filename Value="vfdforms.pas"/> @@ -81,7 +79,6 @@ <Unit9> <Filename Value="vfdeditors.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="vfdeditors"/> </Unit9> <Unit10> <Filename Value="vfdformparser.pas"/> @@ -96,12 +93,10 @@ <Unit12> <Filename Value="vfdutils.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="vfdutils"/> </Unit12> <Unit13> <Filename Value="vfdpropeditgrid.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="vfdpropeditgrid"/> </Unit13> <Unit14> <Filename Value="anchors.inc"/> @@ -134,8 +129,5 @@ <OptimizationLevel Value="0"/> </Optimizations> </CodeGeneration> - <Other> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </CONFIG> diff --git a/uidesigner/vfddesigner.pas b/uidesigner/vfddesigner.pas index 420b223b..aff9d543 100644 --- a/uidesigner/vfddesigner.pas +++ b/uidesigner/vfddesigner.pas @@ -59,8 +59,15 @@ type TDesignedForm = class(TfpgForm) + private + FShowGrid: boolean; + procedure SetShowGrid(AValue: boolean); + protected + procedure HandlePaint; override; public + constructor Create(AOwner: TComponent); override; procedure AfterCreate; override; + property ShowGrid: boolean read FShowGrid write SetShowGrid; end; @@ -1466,6 +1473,51 @@ end; { TDesignedForm } +procedure TDesignedForm.SetShowGrid(AValue: boolean); +begin + if FShowGrid = AValue then + Exit; + FShowGrid := AValue; + Invalidate; +end; + +procedure TDesignedForm.HandlePaint; +var + i: integer; +begin + inherited HandlePaint; + if FShowGrid then + begin + Canvas.Clear(TfpgColor($ff3e85cd)); + // horizontal lines + for i := 0 to Height-1 do + begin + if i mod 50 = 0 then + Canvas.SetColor(TfpgColor($ff5492d0)) + else + Canvas.SetColor(TfpgColor($ff488bcf)); + if i mod 10 = 0 then + Canvas.DrawLine(0, i, Width-1, i); + end; + // vertical lines + for i := 0 to Width-1 do + begin + if i mod 50 = 0 then + Canvas.SetColor(TfpgColor($ff5492d0)) + else + Canvas.SetColor(TfpgColor($ff488bcf)); + if i mod 10 = 0 then + Canvas.DrawLine(i, 0, i, Height-1); + end; + end; +end; + +constructor TDesignedForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FShowGrid := False; +end; + procedure TDesignedForm.AfterCreate; begin inherited AfterCreate; diff --git a/uidesigner/vfdmain.pas b/uidesigner/vfdmain.pas index dee6fe62..d94fee05 100644 --- a/uidesigner/vfdmain.pas +++ b/uidesigner/vfdmain.pas @@ -38,8 +38,10 @@ type TMainDesigner = class(TObject) private + FShowGrid: boolean; procedure SetEditedFileName(const Value: string); procedure LoadDefaults; + procedure SetShowGrid(AValue: boolean); protected FDesigners: TList; FFile: TVFDFile; @@ -71,6 +73,7 @@ type procedure OnExit(Sender: TObject); procedure OnOptionsClick(Sender: TObject); property EditedFileName: string read FEditedFileName write SetEditedFileName; + property ShowGrid: boolean read FShowGrid write SetShowGrid; end; @@ -165,7 +168,13 @@ begin CreateParseForm(bl.FormName, bl.Data, bl2.Data); // pair was found end; end; - + + for n := 0 to FDesigners.Count - 1 do + begin + selectedform := nil; + TFormDesigner(FDesigners[n]).Form.ShowGrid := FShowGrid; + end; + frmMain.mru.AddItem(fname); end; @@ -310,6 +319,7 @@ begin if nfrm.edName.Text <> '' then fd.Form.Name := nfrm.edName.Text; fd.Form.WindowTitle := fd.Form.Name; + fd.Form.ShowGrid := FShowGrid; fd.OneClickMove := OneClickMove; FDesigners.Add(fd); SelectedForm := fd; @@ -473,5 +483,16 @@ begin fpgApplication.HintPause := 1000; end; +procedure TMainDesigner.SetShowGrid(AValue: boolean); +var + i: integer; +begin + if FShowGrid = AValue then + Exit; + FShowGrid := AValue; + for i := 0 to FDesigners.Count-1 do + TFormDesigner(FDesigners[i]).Form.ShowGrid := AValue; +end; + end. |