frmmakeskel.pp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. {$mode objfpc}
  2. {$h+}
  3. unit frmmakeskel;
  4. interface
  5. uses fpgtk,fpgtkext,gtk,classes,sysutils;
  6. Type
  7. TMakeSkelForm = Class (TFPGtkWindow)
  8. FTable : TFPGtkTable;
  9. FInputFile,
  10. FOutputFile : TFPgtkFileEntry;
  11. FPackageName,
  12. FAdditionalOptions : TFPgtkEntry;
  13. FDisableArguments,
  14. FDisableResults,
  15. FDisableSeeAlso,
  16. FDisableProtected,
  17. FDisablePrivate,
  18. FDisableErrors : TFPGtkToggleButton;
  19. FLInputFile,
  20. FLOutPutfile,
  21. FLPackageName,
  22. FLAdditionalOptions,
  23. FLDisableArguments,
  24. FLDisableResults,
  25. FLDisableSeeAlso,
  26. FLDisableProtected,
  27. FLDisablePrivate,
  28. FLDisableErrors : TFPGtkLabel;
  29. FDisableFrame : TFPgtkFrame;
  30. FDisableTable : TFPgtkTable;
  31. FSeparator : TFPGtkHSeparator;
  32. FVBox : TFPgtkVBox;
  33. FOK,
  34. FCancel : TFPGtkButton;
  35. FButtonBox: TFPgtkHBox;
  36. Constructor Create;
  37. Procedure CreateWindow;
  38. Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
  39. Procedure OnOKClick(Sender : TFpGtkObject;Data : Pointer);
  40. end;
  41. Implementation
  42. resourcestring
  43. SDisableCode = 'Do not generate nodes for';
  44. SArguments = 'Function arguments';
  45. SResults = 'Function results';
  46. SProtected = 'Protected class members';
  47. SPrivate = 'Private class members';
  48. SSeeAlso = 'See also section';
  49. SErrors = 'Errors section';
  50. SInputfile = 'Input file';
  51. SOutputFile = 'Output file';
  52. SPackageName = 'Package name';
  53. SAdditionalOptions = 'Additional options';
  54. SOK = 'OK';
  55. SCancel = 'Cancel';
  56. SNeedInputFileName = 'An input filename is required.';
  57. SNeedOutputFileName = 'An output filename is required.';
  58. SNeedPackageName = 'A package name is required.';
  59. Constructor TMakeSkelForm.Create;
  60. begin
  61. Inherited Create(GTK_WINDOW_DIALOG);
  62. CreateWindow;
  63. end;
  64. Procedure TMakeSkelForm.CreateWindow;
  65. Var
  66. OH,OV : TgtkAttachOPtions;
  67. Function CreateToggle : TFPgtkToggleButton;
  68. begin
  69. Result:=TFPgtkToggleButton.Create;
  70. Result.SetUsize(14,14);
  71. end;
  72. Function CreateLLabel(S : String) : TFPgtkLabel;
  73. begin
  74. Result:=TFPgtkLabel.Create(S);
  75. Result.Justify:=GTK_JUSTIFY_LEFT;
  76. end;
  77. Function CreateRLabel(S : String) : TFPgtkLabel;
  78. begin
  79. Result:=TFPgtkLabel.Create(S);
  80. Result.Justify:=GTK_JUSTIFY_RIGHT;
  81. end;
  82. begin
  83. FVBox:=TFPGtkVBox.Create;
  84. FVBox.Spacing:=4;
  85. FVBox.Border:=8;
  86. Add(FVBox);
  87. // input options table area
  88. FTable:=TFPGtkTable.Create(2,4);
  89. FLInputFile:=CreateRLabel(SInputFile);
  90. FInputFile:=TFPgtkFileEntry.Create;
  91. FLOutputFile:=CreateRLabel(SOutputFile);
  92. FOutputFile:=TFPgtkFileEntry.Create;
  93. FLAdditionalOptions:=CreateRLabel(SAdditionalOptions);
  94. FAdditionalOptions:=TFPgtkEntry.Create;
  95. FLPackageName:=CreateRLabel(SPackageName);
  96. FPackageName:=TFPgtkEntry.Create;
  97. // Pack in table.
  98. OH:=GTK_EXPAND or GTK_FILL;
  99. With FTable do
  100. begin
  101. Attach(FLInputFile,0,1,0,1,GTK_FILL,0,4,4);
  102. Attach(FLOutputFile,0,1,1,2,GTK_FILL,0,4,4);
  103. Attach(FLPackageName,0,1,2,3,GTK_FILL,0,4,4);
  104. Attach(FLAdditionalOptions,0,1,3,4,GTK_FILL,0,4,4);
  105. Attach(FInputFile,1,2,0,1,OH,0,4,4);
  106. Attach(FOutputFile,1,2,1,2,OH,0,4,4);
  107. Attach(FPackageName,1,2,2,3,OH,0,4,4);
  108. Attach(FAdditionalOptions,1,2,3,4,OH,0,4,4);
  109. end;
  110. FDisableArguments:=CreateToggle;
  111. FDisableResults:=CreateToggle;
  112. FDisableSeeAlso:=CreateToggle;
  113. FDisableProtected:=CreateToggle;
  114. FDisablePrivate:=CreateToggle;
  115. FDisableErrors:=CreateToggle;
  116. FLDisableArguments:=CreateLLabel(SArguments);
  117. FLDisableResults:=CreateLLabel(SResults);
  118. FLDisableSeeAlso:=CreateLLabel(SSeeAlso);
  119. FLDisableProtected:=CreateLLabel(SProtected);
  120. FLDisablePrivate:=CreateLLabel(SPrivate);
  121. FLDisableErrors:=CreateLLabel(SErrors);
  122. FDisableTable:=TFPgtkTable.Create(2,6);
  123. With FDisableTable do
  124. begin
  125. // Checks
  126. Attach(FDisableArguments ,0,1,0,1,0,GTK_FILL,4,4);
  127. Attach(FDisableResults ,0,1,1,2,0,GTK_FILL,4,4);
  128. Attach(FDisableProtected ,0,1,2,3,0,GTK_FILL,4,4);
  129. Attach(FDisablePrivate ,0,1,3,4,0,GTK_FILL,4,4);
  130. Attach(FDisableErrors ,0,1,4,5,0,GTK_FILL,4,4);
  131. Attach(FDisableSeeAlso ,0,1,5,6,0,GTK_FILL,4,4);
  132. // Labels
  133. Attach(FLDisableArguments ,1,2,0,1,GTK_FILL,0,4,4);
  134. Attach(FLDisableResults ,1,2,1,2,GTK_FILL,0,4,4);
  135. Attach(FLDisableProtected ,1,2,2,3,GTK_FILL,0,4,4);
  136. Attach(FLDisablePrivate ,1,2,3,4,GTK_FILL,0,4,4);
  137. Attach(FLDisableErrors ,1,2,4,5,GTK_FILL,0,4,4);
  138. Attach(FLDisableSeeAlso ,1,2,5,6,GTK_FILL,0,4,4);
  139. end;
  140. FDisableFrame:=TFpgtkFrame.Create;
  141. FDisableFrame.Text:=SDisableCode;
  142. FDisableFrame.Add(FDisableTable);
  143. // button area
  144. FOK:=TFpGtkButton.CreateWithLabel(SOK);
  145. FOK.ConnectClicked(@OnOkCLick,Nil);
  146. FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
  147. FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
  148. FSeparator:=TFPgtkHSeparator.Create;
  149. FButtonBox:=TfpGtkHBox.Create;
  150. FButtonBox.Spacing:=4;
  151. FButtonBox.PackEnd(FOK,false,false,4);
  152. FButtonBox.PackEnd(FCancel,false,false,4);
  153. // Add to window
  154. FVBox.PackStart(FTable,False,False,0);
  155. FVBox.PackStart(FDisableFrame,False,False,4);
  156. FVBox.PackStart(FSeparator,False,False,4);
  157. FVBox.PackStart(FButtonBox,false,false,0);
  158. // Some events;
  159. ConnectShow(@OnShow,Nil);
  160. end;
  161. Procedure TMakeSkelForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
  162. begin
  163. FocusedWidget(FInputFile.Edit);
  164. end;
  165. Procedure TMakeSkelForm.OnOkClick(Sender : TFpgtkObject; Data : Pointer);
  166. begin
  167. If (FInputFile.FileName='') then
  168. MessageDlg(SNeedInputFileName,mtError,[mbOk],0)
  169. else If (FOutPutFile.FileName='') then
  170. MessageDlg(SNeedOutPutFileName,mtError,[mbOk],0)
  171. Else if (FPackageName.Text='') then
  172. MessageDlg(SNeedPackageName,mtError,[mbOk],0)
  173. else
  174. CloseWithResult(Sender,IntToPointer(drOK));
  175. end;
  176. end.