frmtable.pp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {$mode objfpc}
  2. {$h+}
  3. unit frmtable;
  4. interface
  5. uses fpgtk,gtk,classes,sysutils;
  6. Type
  7. TTableForm = Class (TFPGtkWindow)
  8. FTable : TFPGtkTable;
  9. FLTableRows,
  10. FLTableCols,
  11. FLUseHeader : TFPGtkLabel;
  12. FTableRows,
  13. FTableCols : TFPGtkSpinButton;
  14. FUseHeader : TFPGtkToggleButton;
  15. FSeparator : TFPGtkHSeparator;
  16. FVBox : TFPgtkVBox;
  17. FHBox : TFPgtkHBox;
  18. FOK,
  19. FCancel : TFPGtkButton;
  20. FButtonBox: TFPgtkHBox;
  21. Constructor Create;
  22. Procedure CreateWindow;
  23. Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
  24. end;
  25. Implementation
  26. uses fpdemsg;
  27. Constructor TTableForm.Create;
  28. begin
  29. Inherited Create(GTK_WINDOW_DIALOG);
  30. CreateWindow;
  31. end;
  32. Procedure TTableForm.CreateWindow;
  33. Var
  34. OH,OV : TgtkAttachOPtions;
  35. begin
  36. FVBox:=TFPGtkVBox.Create;
  37. FVBox.Spacing:=4;
  38. FVBox.Border:=8;
  39. Add(FVBox);
  40. // Table area
  41. FTable:=TFPGtkTable.Create(2,3);
  42. FLTableRows:=TFPGtkLabel.Create(STableRows);
  43. FLTableRows.Justify:=GTK_JUSTIFY_RIGHT;
  44. FLTableCols:=TFPGtkLabel.Create(STableCols);
  45. FLTableCols.Justify:=GTK_JUSTIFY_RIGHT;
  46. FLUseHeader:=TFPGtkLabel.Create(STableHeader);
  47. FLUseHeader.Justify:=GTK_JUSTIFY_RIGHT;
  48. FTableRows:=TFPGtkSpinButton.Create;
  49. FTableCols:=TFPGtkSpinButton.Create;
  50. FUSeHeader:=TFPgtkToggleButton.Create;
  51. FUseHeader.SetUSize(14,14);
  52. FHBox:=TFPgtkHBox.Create;
  53. FHBox.PackStart(FuseHeader,True,False,0);
  54. OH:=GTK_EXPAND or GTK_FILL;
  55. FTable.Attach(FLTableRows,0,1,0,1,0,GTK_FILL,4,4);
  56. FTable.Attach(FLTableCols,0,1,1,2,0,GTK_FILL,4,4);
  57. FTable.Attach(FLUseHeader,0,1,2,3,0,GTK_FILL,4,4);
  58. FTable.Attach(FTableRows,1,2,0,1,OH,0,4,4);
  59. FTable.Attach(FTableCols,1,2,1,2,OH,0,4,4);
  60. FTable.Attach(FHBox,1,2,2,3,0,GTK_FILL,4,4);
  61. // button area
  62. FOK:=TFpGtkButton.CreateWithLabel(SOK);
  63. FOK.ConnectClicked(@CloseWithResult,IntToPointer(drOK));
  64. FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
  65. FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
  66. FSeparator:=TFPgtkHSeparator.Create;
  67. FButtonBox:=TfpGtkHBox.Create;
  68. FButtonBox.Spacing:=4;
  69. FButtonBox.PackEnd(FOK,false,false,4);
  70. FButtonBox.PackEnd(FCancel,false,false,4);
  71. // Add to window
  72. FVBox.PackStart(FTable,False,False,0);
  73. FVBox.PackStart(FSeparator,False,False,4);
  74. FVBox.PackStart(FButtonBox,false,false,0);
  75. // Some events;
  76. ConnectShow(@OnShow,Nil);
  77. end;
  78. Procedure TTableForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
  79. begin
  80. FocusedWidget(FTableRows);
  81. end;
  82. end.