FMxGuiLayoutEditor.pas 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //
  2. // The graphics engine GLXEngine. The unit of GXScene for Delphi
  3. //
  4. unit FMxGuiLayoutEditor;
  5. interface
  6. uses
  7. System.SysUtils,
  8. System.Types,
  9. System.UITypes,
  10. System.Classes,
  11. System.Variants,
  12. System.Rtti,
  13. FMX.Types,
  14. FMX.Controls,
  15. FMX.Forms,
  16. FMX.Graphics,
  17. FMX.Dialogs,
  18. FMX.StdCtrls,
  19. FMX.Layouts,
  20. FMX.ListBox,
  21. FMX.Grid,
  22. FMX.Controls.Presentation,
  23. FMX.Edit,
  24. FMX.EditBox,
  25. FMX.SpinBox,
  26. FMX.Objects,
  27. GXS.Gui,
  28. FMX.Grid.Style,
  29. FMX.ScrollBox;
  30. type
  31. TGUILayoutForm = class(TForm)
  32. Panel1: TPanel;
  33. OpenDialog1: TOpenDialog;
  34. SaveDialog1: TSaveDialog;
  35. Panel2: TPanel;
  36. Items_List: TListBox;
  37. Open_Image_Button: TButton;
  38. Open_Button: TButton;
  39. Save_Button: TButton;
  40. Done_Button: TButton;
  41. ButtonZoomIn: TButton;
  42. Add_Button: TButton;
  43. Delete_Button: TButton;
  44. Name_Edit: TEdit;
  45. LabelName: TLabel;
  46. Elements_Grid: TStringGrid;
  47. LabelX: TLabel;
  48. LabelY: TLabel;
  49. LabelHeight: TLabel;
  50. LabelWidth: TLabel;
  51. Left_Edit: TSpinBox;
  52. Top_Edit: TSpinBox;
  53. Width_Edit: TSpinBox;
  54. Height_Edit: TSpinBox;
  55. ScrollBox1: TScrollBox;
  56. PaintBox1: TPaintBox;
  57. Image1: TImage;
  58. Image2: TImage;
  59. X_Label: TLabel;
  60. Y_Label: TLabel;
  61. ImageZoomIn: TImage;
  62. ButtonZoomOut: TButton;
  63. ImageZoomOut: TImage;
  64. ButtonShow: TButton;
  65. ImageShow: TImage;
  66. ImageDone: TImage;
  67. ImageOpen: TImage;
  68. ImageSave: TImage;
  69. ImageLoadSkin: TImage;
  70. ImageAdd: TImage;
  71. ImageDelete: TImage;
  72. procedure Items_ListClick(Sender: TObject);
  73. private
  74. Rect_point1, Rect_point2: TPoint;
  75. Sorted_Elements: array[0..9] of TgxGuiElement;
  76. procedure SyncImages;
  77. procedure DrawCurrentElement;
  78. procedure RefreshComponentBox;
  79. function GetEnabledSpins: Boolean;
  80. procedure SetEnabledSpins(Value: Boolean);
  81. public
  82. end;
  83. var
  84. GUILayoutForm: TGUILayoutForm;
  85. //======================================================================
  86. implementation
  87. //======================================================================
  88. {$R *.fmx}
  89. var
  90. vGUILayoutEditor: TGUILayoutForm;
  91. Zoom: integer = 1;
  92. //---------------------------------------------------------------
  93. // TGUILayoutForm
  94. //---------------------------------------------------------------
  95. procedure TGUILayoutForm.DrawCurrentElement;
  96. begin
  97. with Elements_Grid do
  98. if (Items_List.ItemIndex > -1) and (Sorted_elements[ColumnIndex + 3 * Selected] <> nil)
  99. then
  100. with Sorted_Elements[ColumnIndex + 3 * Selected], Image2.Canvas do
  101. begin
  102. { TODO : E2250 There is no overloaded version of 'FillRect' not enouph arguments }
  103. (*FillRect(ClipRect);*)
  104. Rect(zoom * Round(TopLeft.X), zoom * Round(TopLeft.Y),
  105. zoom * Round(BottomRight.X), zoom * Round(BottomRight.Y));
  106. end;
  107. end;
  108. function TGUILayoutForm.GetEnabledSpins: Boolean;
  109. begin
  110. Result := Left_Edit.Enabled;
  111. end;
  112. procedure TGUILayoutForm.Items_ListClick(Sender: TObject);
  113. var
  114. i, p: integer;
  115. begin
  116. if Items_list.ItemIndex = -1 then
  117. Exit;
  118. { TODO : E2003 Undeclared identifier: 'GuiLayout1' - GXScene not installed}
  119. (*Name_edit.Text := GuiLayout1.GuiComponents[Items_list.ItemIndex].Name;*)
  120. Elements_grid.Selected := 0; //in VCL Row
  121. Elements_grid.ColumnIndex := 0; //in VCL Col
  122. for i := 0 to Length(Sorted_elements) - 1 do
  123. begin
  124. sorted_elements[i] := nil;
  125. if I < 9 then
  126. Elements_grid.Cells[i mod 3, i div 3] := #32;
  127. end;
  128. { TODO : E2003 Undeclared identifier: 'GuiLayout1' - GLScene not installed}
  129. (*
  130. with GuiLayout1.GuiComponents[Items_list.ItemIndex] do
  131. for i := 0 to Elements.Count - 1 do
  132. begin
  133. p := Integer(Elements[i].Align);
  134. Sorted_elements[p] := Elements[i];
  135. Elements_grid.Cells[p mod 3, p div 3] := '+';
  136. end;
  137. Elements_gridClick(nil);
  138. *)
  139. end;
  140. procedure TGUILayoutForm.RefreshComponentBox;
  141. var
  142. i: integer;
  143. begin
  144. Items_List.Clear;
  145. { TODO : E2003 Undeclared identifier: 'GLGuiLayout1' - GLScene not installed}
  146. (*
  147. for i := 0 to GLGuiLayout1.GuiComponents.Count - 1 do
  148. Items_List.Items.Add(GLGuiLayout1.GuiComponents[i].Name);
  149. *)
  150. Items_List.ItemIndex := 0;
  151. Items_ListClick(nil);
  152. end;
  153. procedure TGUILayoutForm.SetEnabledSpins(Value: Boolean);
  154. begin
  155. Left_Edit.Enabled := Value;
  156. Top_Edit.Enabled := Value;
  157. Height_Edit.Enabled := Value;
  158. Width_Edit.Enabled := Value;
  159. end;
  160. procedure TGUILayoutForm.SyncImages;
  161. begin
  162. Image2.Width := Image1.Width;
  163. Image2.Height := Image1.Height;
  164. Image2.Bitmap.Width := Round(Image1.Width);
  165. Image2.Bitmap.Height := Round(Image1.Height);
  166. PaintBox1.Width := Image1.Width;
  167. PaintBox1.Height := Image1.Height;
  168. { TODO : E2003 Undeclared identifier: 'HorzScrollBar' }
  169. (*
  170. ScrollBox1.HorzScrollBar.Range := Image1.Width;
  171. ScrollBox1.VertScrollBar.Range := Image1.Height;
  172. PaintBox1.Canvas.CopyRect(PaintBox1.Canvas.ClipRect,
  173. Image1.Canvas, Image1.Canvas.ClipRect);
  174. *)
  175. end;
  176. end.