frmlink.pp 2.0 KB

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