frmnewnode.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. {$mode objfpc}
  2. {$h+}
  3. unit frmnewnode;
  4. interface
  5. uses fpgtk,gtk,classes,sysutils;
  6. Type
  7. TNewNodeForm = Class (TFPGtkWindow)
  8. FTable : TFPGtkTable;
  9. FLENodeName : TFPGtkLabel;
  10. FENodeName : TFPGtkEntry;
  11. FSeparator : TFPGtkHSeparator;
  12. FVBox : TFPgtkVBox;
  13. FOK,
  14. FCancel : TFPGtkButton;
  15. FButtonBox: TFPgtkHBox;
  16. Constructor Create;
  17. Procedure CreateWindow;
  18. Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
  19. end;
  20. Implementation
  21. uses
  22. fpdemsg;
  23. Constructor TNewNodeForm.Create;
  24. begin
  25. Inherited Create(GTK_WINDOW_DIALOG);
  26. CreateWindow;
  27. end;
  28. Procedure TNewNodeForm.CreateWindow;
  29. Var
  30. OH,OV : TgtkAttachOPtions;
  31. begin
  32. FVBox:=TFPGtkVBox.Create;
  33. FVBox.Spacing:=4;
  34. FVBox.Border:=8;
  35. Add(FVBox);
  36. // Table area
  37. FTable:=TFPGtkTable.Create(1,1);
  38. FLENodeName:=TFPGtkLabel.Create(SName);
  39. FLENodeName.Justify:=GTK_JUSTIFY_RIGHT;
  40. FENodeName:=TFPgtkEntry.Create;
  41. FENodeName.GrabFocus;
  42. OH:=GTK_EXPAND or GTK_FILL;
  43. FTable.Attach(FLENodeName,0,1,0,1,0,GTK_FILL,4,4);
  44. FTable.Attach(FENodeName,1,2,0,1,OH,0,4,4);
  45. // button area
  46. FOK:=TFpGtkButton.CreateWithLabel(SOK);
  47. FOK.ConnectClicked(@CloseWithResult,IntToPointer(drOK));
  48. FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
  49. FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
  50. FSeparator:=TFPgtkHSeparator.Create;
  51. FButtonBox:=TfpGtkHBox.Create;
  52. FButtonBox.Spacing:=4;
  53. FButtonBox.PackEnd(FOK,false,false,4);
  54. FButtonBox.PackEnd(FCancel,false,false,4);
  55. // Add to window
  56. FVBox.PackStart(FTable,False,False,0);
  57. FVBox.PackStart(FSeparator,False,False,4);
  58. FVBox.PackStart(FButtonBox,false,false,0);
  59. // Some events;
  60. ConnectShow(@OnShow,Nil);
  61. end;
  62. Procedure TNewNodeForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
  63. begin
  64. FocusedWidget(FENodeName);
  65. end;
  66. end.