lister.pp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. {$mode objfpc}{$h+}
  2. unit lister;
  3. interface
  4. uses glib, gdk, gtk, FPgtk, classes, fpgtkext, sysutils;
  5. type
  6. TListWindow = class (TFPgtkWindow)
  7. private
  8. pb : TFPgtkProgressBar;
  9. spin : TFPgtkSpinButton;
  10. notebook : TFPgtkNotebook;
  11. bar : TFPgtkStatusbar;
  12. EContext, EMessage : TFPgtkEntry;
  13. IDContext, IDMessage : TFPgtkSpinButton;
  14. List : TFPgtkScrollList;
  15. ListText : TFPgtkScrollText;
  16. CList : TFPgtkScrollCList;
  17. CListText : TFPgtkScrollText;
  18. Key : TFPgtkSpinButton;
  19. ModCtrl, ModAlt, ModShift : TFPgtkToggleButton;
  20. KeyName : TFPgtkEntry;
  21. AKeyName : TFPgtkAccelLabel;
  22. TheAG : guint;
  23. AccelBut : TFPgtkButton;
  24. VButtons, HButtons : TFPgtkButtonBox;
  25. TheLayout : TFPgtkLayout;
  26. LayoutX, LayoutY : integer;
  27. cal : TFPgtkCalendar;
  28. MessageButtons : TMsgDlgButtons;
  29. Msg : TFPgtkEntry;
  30. DialogType : TFPgtkMenu;
  31. procedure AddRemoveButton (Sender:TFPgtkObject; data:pointer);
  32. procedure ShowMessageDialog (Sender:TFPgtkObject; data:pointer);
  33. procedure Calendar_ShowDate (Sender:TFPgtkObject; data:pointer);
  34. procedure Layout_runaway (Sender:TFPgtkObject; data:pointer);
  35. procedure ButBox_AddThem (Sender:TFPgtkObject; data:pointer);
  36. procedure Accel_Parse (Sender : TFPgtkObject; data : pointer);
  37. procedure Accel_AddAccel (Sender : TFPgtkObject; data : pointer);
  38. procedure Accel_ConvertToName (Sender : TFPgtkObject; data : pointer);
  39. procedure ProgressBar_ShowItToMe (Sender : TFPgtkObject; data : pointer);
  40. procedure ProgressBar_SetActivityMode (Sender : TFPgtkObject; data : pointer);
  41. procedure ProgressBar_FormatString (Sender : TFPgtkObject; data : pointer);
  42. procedure Spinbutton_ClimbRate (Sender : TFPgtkObject; data : pointer);
  43. procedure Spinbutton_Digits (Sender : TFPgtkObject; data : pointer);
  44. procedure Spinbutton_UpdatePolicy (Sender : TFPgtkObject; data : pointer);
  45. procedure Spinbutton_Numeric (Sender : TFPgtkObject; data : pointer);
  46. procedure Spinbutton_Wrap (Sender : TFPgtkObject; data : pointer);
  47. procedure Spinbutton_SnapToTicks (Sender : TFPgtkObject; data : pointer);
  48. procedure MemoMessage_Show (Sender : TFPgtkObject; data : pointer);
  49. procedure StatusBar_GetContext (Sender : TFPgtkObject; data : pointer);
  50. procedure StatusBar_Push (Sender : TFPgtkObject; data : pointer);
  51. procedure StatusBar_Pop (Sender : TFPgtkObject; data : pointer);
  52. procedure StatusBar_Remove (Sender : TFPgtkObject; data : pointer);
  53. procedure List_ShowSignal (Sender : TFPgtkObject; data : pointer);
  54. procedure List_ShowWidgetSignal (Sender : TFPgtkObject; Widget:TFPgtkWidget; data : pointer);
  55. procedure List_AddToList (Sender : TFPgtkObject; data : pointer);
  56. procedure List_SelectionMode (Sender : TFPgtkObject; data : pointer);
  57. procedure List_ClearAll (Sender : TFPgtkObject; data : pointer);
  58. procedure List_Clear1_5 (Sender : TFPgtkObject; data : pointer);
  59. procedure List_AddCount (Sender : TFPgtkObject; data : pointer);
  60. procedure CList_AddToList (Sender : TFPgtkObject; data : pointer);
  61. procedure CList_SelectionMode (Sender : TFPgtkObject; data : pointer);
  62. public
  63. constructor create;
  64. end;
  65. implementation
  66. const
  67. Init_ProgressBar_FormatString = '%p%% (%v of %u)';
  68. constructor TListWindow.Create;
  69. var b, h : TFPgtkBox;
  70. but : TFPgtkButton;
  71. tbut : TFPgtkToggleButton;
  72. e : TFPgtkEntry;
  73. sp : TFPgtkSpinButton;
  74. t : TFPgtkScrollText;
  75. f : TFPgtkFrame;
  76. p : TFPgtkPaned;
  77. om : TFPgtkOptionMenu;
  78. bb : TFPgtkButtonBox;
  79. begin
  80. inherited create (gtk_window_dialog);
  81. border := 10;
  82. modal := TRUE;
  83. Position := gtk_win_pos_mouse;
  84. Notebook := TFPgtkNotebook.Create;
  85. Notebook.homogenous := false;
  86. Notebook.scrollable := true;
  87. Add (Notebook);
  88. // ******* MessageDialog
  89. writeln (' MessageDialog');
  90. b := TFPgtkVBox.Create;
  91. Notebook.AppendPage (b, TFPgtkLabel.Create('MessageDialog'));
  92. Msg := TFpgtkEntry.Create;
  93. Msg.Text := 'This is normal message text';
  94. b.packstart (msg, false, false, 0);
  95. om := TFPgtkOptionMenu.Create;
  96. DialogType := NewMenu ('DialogType', [NewMenuItem ('Warning'),NewMenuItem ('Error'),
  97. NewMenuItem ('Information'),NewMenuItem ('Confirmation'),NewMenuItem ('Custom')]);
  98. om.Menu := DialogType;
  99. om.SetHistory (0);
  100. b.Packstart (om, false, false, 0);
  101. bb := TFPgtkHButtonBox.create;
  102. tbut := TFPgtkCheckedButton.CreateWithLabel ('Yes');
  103. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbYes)));
  104. bb.PackStart (tbut);
  105. tbut := TFPgtkCheckedButton.CreateWithLabel ('No');
  106. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbNo)));
  107. bb.PackStart (tbut);
  108. tbut := TFPgtkCheckedButton.CreateWithLabel ('Ok');
  109. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbOk)));
  110. bb.PackStart (tbut);
  111. tbut := TFPgtkCheckedButton.CreateWithLabel ('Cancel');
  112. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbCancel)));
  113. bb.PackStart (tbut);
  114. b.packstart (bb, false, false, 0);
  115. bb := TFPgtkHButtonBox.create;
  116. tbut := TFPgtkCheckedButton.CreateWithLabel ('Abort');
  117. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbAbort)));
  118. bb.PackStart (tbut);
  119. tbut := TFPgtkCheckedButton.CreateWithLabel ('Retry');
  120. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbRetry)));
  121. bb.PackStart (tbut);
  122. tbut := TFPgtkCheckedButton.CreateWithLabel ('Ignore');
  123. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbIgnore)));
  124. bb.PackStart (tbut);
  125. tbut := TFPgtkCheckedButton.CreateWithLabel ('Help');
  126. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbHelp)));
  127. bb.PackStart (tbut);
  128. b.packstart (bb, false, false, 0);
  129. bb := TFPgtkHButtonBox.create;
  130. tbut := TFPgtkCheckedButton.CreateWithLabel ('All');
  131. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbAll)));
  132. bb.PackStart (tbut);
  133. tbut := TFPgtkCheckedButton.CreateWithLabel ('NoToALl');
  134. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbNoToAll)));
  135. bb.PackStart (tbut);
  136. tbut := TFPgtkCheckedButton.CreateWithLabel ('YesToAll');
  137. tbut.connectClicked (@AddRemoveButton, inttopointer(ord(mbYesToAll)));
  138. bb.PackStart (tbut);
  139. b.packstart (bb, false, false, 0);
  140. bb := TFPgtkHButtonBox.create;
  141. but := TFPgtkButton.CreateWithLabel ('Show Message Dialog !!');
  142. but.ConnectClicked (@ShowMessageDialog, nil);
  143. bb.Packstart (but);
  144. b.packstart (bb, false, false, 0);
  145. // ******* Calendar
  146. writeln (' Calendar');
  147. b := TFPgtkVBox.Create;
  148. Notebook.AppendPage (b, TFPgtkLabel.Create('Calendar'));
  149. cal := TFPgtkCalendar.Create;
  150. cal.date := encodeDate (2000,1,1);
  151. b.PackStart (Cal);
  152. but := TFPgtkButton.CreateWithLabel ('Show Date');
  153. but.ConnectClicked (@Calendar_ShowDate, nil);
  154. b.PackEnd (but, false, false, 0);
  155. // ******* Layout
  156. writeln (' Layout');
  157. TheLayout := TFPgtkLayout.Create;
  158. Notebook.AppendPage (TheLayout, TFPgtkLabel.Create('Layout'));
  159. TheLayout.Freeze;
  160. e := TFPgtkEntry.Create;
  161. e.Text := 'Entry on 25,10 to clearly show where the edges end';
  162. TheLayout.Put (e, 25,10);
  163. e := TFPgtkEntry.Create;
  164. e.Text := 'Entry on 5,50';
  165. e.SetUSize (300, 24);
  166. TheLayout.Put (e, 5,30);
  167. but := TFPgtkButton.CreateWithLabel ('Catch me with doubleclick !!');
  168. but.ConnectClicked (@Layout_runaway, nil);
  169. but.CanDefault:= true;
  170. but.SetUSize (200, 50);
  171. TheLayout.put (but, 75, 75);
  172. LayoutY := 75;
  173. LayoutX := 75;
  174. TheLayout.SetSize (350, 400);
  175. TheLayout.Thaw;
  176. // ******* ButtonBox
  177. writeln (' ButtonBox');
  178. b := TFPgtkVBox.Create;
  179. Notebook.AppendPage (b, TFPgtkLabel.Create('Buttonboxes'));
  180. HButtons := TFPgtkHButtonBox.Create;
  181. HButtons.Layout := GTK_BUTTONBOX_end;
  182. HButtons.Spacing := 3;
  183. b.PackEnd (HButtons, false, false, 0);
  184. h := TFPgtkHBox.Create;
  185. b.PackStart (h, true, true, 0);
  186. but := TFPgtkButton.CreateWithLabel ('Add a button');
  187. but.ConnectClicked (@ButBox_AddThem, nil);
  188. h.PackStart (but, false, false, 3);
  189. VButtons := TFPgtkVButtonBox.Create;
  190. VButtons.Layout := GTK_Buttonbox_Start;
  191. VButtons.Spacing := 15;
  192. h.PackEnd (VButtons, false, false,0);
  193. // ******* Accelerator
  194. writeln (' Accelerator');
  195. b := TFPgtkVBox.Create;
  196. Notebook.AppendPage (b, TFPgtkLabel.Create('Accelorators'));
  197. TheAG := AccelGroupNew;
  198. h := TFPgtkHBox.Create;
  199. b.PackStart (h, false, false, 0);
  200. but := TFPgtkButton.CreateWithLabel('Parse');
  201. but.ConnectClicked (@Accel_Parse, nil);
  202. h.PackStart (but, false, false, 0);
  203. Key := TFPgtkSpinButton.Create;
  204. h.PackStart (Key);
  205. Key.adjustment.configure (0, $FFFF, GDK_Delete, 1, 256, 0);
  206. Key.Configure (nil, 100, 0);
  207. h := TFPgtkHBox.Create;
  208. b.PackStart (h, false, false, 0);
  209. h.homogeneous := true;
  210. ModShift := TFPgtkCheckedButton.CreateWithLabel('Shift');
  211. h.PackStart (ModShift);
  212. ModCtrl := TFPgtkCheckedButton.CreateWithLabel('Ctrl');
  213. ModCtrl.active := true;
  214. h.Packstart(ModCtrl);
  215. ModAlt := TFPgtkCheckedButton.CreateWithLabel('Alt');
  216. h.Packstart (ModAlt);
  217. h := TFPgtkHBox.create;
  218. b.PackStart (h, false, false, 0);
  219. AccelBut := TFPgtkButton.createwithLabel ('Show');
  220. Accelbut.ConnectClicked (@Accel_ConvertToName, nil);
  221. //AcceleratorAdd (TheAG, Accelbut, sgClicked, Gdk_S, Gdk_Control_mask, GTK_ACCEL_VISIBLE);
  222. h.PackStart (Accelbut,false,false,0);
  223. KeyName := TFPgtkEntry.Create;
  224. h.Packstart (KeyName);
  225. h := TFPgtkHBox.create;
  226. but := TFPgtkButton.CreateWithLabel ('Add');
  227. but.ConnectClicked (@Accel_AddAccel, nil);
  228. h.PackStart (but, false, false, 0);
  229. but := TFPgtkButton.Create;
  230. AKeyName := TFPgtkAccelLabel.create ('Accellerators');
  231. but.Add (AKeyName);
  232. AKeyName.accelwidget := AccelBut;
  233. AKeyname.refetch;
  234. h.PackStart (but, true, true, 0);
  235. b.PackStart (h, false, false, 0);
  236. // ******* CList
  237. writeln (' CList');
  238. p := TFPgtkVPaned.Create;
  239. Notebook.AppendPage (p, TFPgtkLabel.Create('CList'));
  240. CList := TFPgtkScrollCList.Create (1);
  241. p.Pack1 (CList, true, true);
  242. b := TFPgtkVBox.Create;
  243. p.Pack2 (b, false, true);
  244. p.handleSize := 5;
  245. p.ComputePosition (100, 60, 50);
  246. CListText := TFPgtkScrollText.create;
  247. b.Packstart (CListText);
  248. h := TFPgtkHBox.Create;
  249. b.PackStart (h, false, false, 0);
  250. but := TFPGtkButton.CreateWithLabel('Add');
  251. but.ConnectClicked (@CList_AddToList, CListText.TheText);
  252. h.PackStart (but, false, false, 0);
  253. h := TFPgtkHBox.Create;
  254. h.PackStart (TFPGtkLabel.Create('Selection Mode'), false, false, 2);
  255. om := TFPgtkOptionMenu.Create;
  256. om.Menu := NewMenu ('Selection Mode', [
  257. NewMenuItem ('Single',@CList_SelectionMode, inttopointer(0)),
  258. NewMenuItem ('Browse',@CList_SelectionMode, inttopointer(1)),
  259. NewMenuItem ('Mutiple',@CList_SelectionMode, inttopointer(2)),
  260. NewMenuItem ('Extended',@CList_SelectionMode, inttopointer(3))]);
  261. om.SetHistory (0);
  262. CList.CList.SelectionMode := GTK_SELECTION_SINGLE;
  263. h.Packstart (om, true, true, 0);
  264. b.PackStart (h, false, false, 0);
  265. // ******* List
  266. writeln (' List');
  267. p := TFPgtkVPaned.Create;
  268. Notebook.AppendPage (p, TFPgtkLabel.Create('List'));
  269. List := TFPgtkScrollList.Create;
  270. p.Pack1 (List, true, true);
  271. b := TFPgtkVBox.Create;
  272. p.Pack2 (b, false, true);
  273. p.handleSize := 5;
  274. p.ComputePosition (100, 60, 50);
  275. ListText := TFPgtkScrollText.create;
  276. b.Packstart (ListText);
  277. h := TFPgtkHBox.Create;
  278. b.PackStart (h, false, false, 0);
  279. but := TFPGtkButton.CreateWithLabel('Add');
  280. but.ConnectClicked (@List_AddToList, ListText.TheText);
  281. h.PackStart (but, false, false, 0);
  282. but := TFPGtkButton.CreateWithLabel('Add Count');
  283. but.ConnectClicked (@List_AddCount, ListText.TheText);
  284. h.PackStart (but, false, false, 0);
  285. but := TFPGtkButton.CreateWithLabel('Clear 1-5');
  286. but.ConnectClicked (@List_Clear1_5, ListText.TheText);
  287. h.PackStart (but, false, false, 0);
  288. but := TFPGtkButton.CreateWithLabel('Clear all');
  289. but.ConnectClicked (@List_ClearAll, ListText.TheText);
  290. h.PackStart (but, false, false, 0);
  291. h := TFPgtkHBox.Create;
  292. h.PackStart (TFPGtkLabel.Create('Selection Mode'), false, false, 2);
  293. om := TFPgtkOptionMenu.Create;
  294. om.Menu := NewMenu ('Selection Mode', [
  295. NewMenuItem ('Single','','',@List_SelectionMode, inttopointer(0)),
  296. NewMenuItem ('Browse','','',@List_SelectionMode, inttopointer(1)),
  297. NewMenuItem ('Mutiple','','',@List_SelectionMode, inttopointer(2)),
  298. NewMenuItem ('Extended','','',@List_SelectionMode, inttopointer(3))]);
  299. om.SetHistory (0);
  300. List.List.SelectionMode := GTK_SELECTION_SINGLE;
  301. h.Packstart (om, true, true, 0);
  302. b.PackStart (h, false, false, 0);
  303. // ******* Statusbar
  304. writeln (' Statusbar');
  305. b := TFPgtkVBox.Create;
  306. Notebook.appendPage (b, TFPgtkLabel.Create('Statusbar'));
  307. bar := TFPgtkStatusbar.Create;
  308. b.Packend (bar, false, true, 0);
  309. f := TFPgtkFrame.Create;
  310. f.Text := 'Context';
  311. h := TFPgtkHbox.Create;
  312. IDContext := TFPgtkSpinbutton.Create;
  313. IDContext.configure (nil, 1000, 0);
  314. IDContext.adjustment.configure (-maxint, maxint, 0, 1, 100,0);
  315. EContext := TFPgtkEntry.Create;
  316. EContext.ConnectChanged (@StatusBar_GetContext, IDContext);
  317. h.Packstart (EContext, true, true, 0);
  318. h.packstart (TFPgtkLabel.Create('ID'), false, false, 2);
  319. h.packstart (IDContext, false, false, 0);
  320. f.add (h);
  321. b.Packstart (f, false, true, 0);
  322. f := TFPgtkFrame.Create;
  323. f.Text := 'Message';
  324. h := TFPgtkHbox.Create;
  325. IDMessage := TFPgtkSpinbutton.Create;
  326. IDMessage.configure (nil, 1000, 0);
  327. IDMessage.adjustment.configure (-maxint, maxint, 0, 1, 100,0);
  328. EMessage := TFPgtkEntry.Create;
  329. h.Packstart (EMessage, true, true, 0);
  330. h.packstart (TFPgtkLabel.Create('ID'), false, false, 2);
  331. h.packstart (IDMessage, false, false, 0);
  332. f.add (h);
  333. b.Packstart (f, false, true, 0);
  334. h := TFPgtkHBox.Create;
  335. h.homogeneous := true;
  336. b.Packstart (h, false, false, 2);
  337. but := TFPgtkButton.CreateWithLabel ('Push');
  338. but.ConnectClicked (@statusbar_Push, EMessage);
  339. h.Packstart (but, false, true, 2);
  340. but := TFPgtkButton.CreateWithLabel ('Pop');
  341. but.ConnectClicked (@statusbar_Pop, EMessage);
  342. h.Packstart (but, false, true, 2);
  343. but := TFPgtkButton.CreateWithLabel ('Remove');
  344. but.ConnectClicked (@statusbar_Remove, EMessage);
  345. h.Packstart (but, false, true, 2);
  346. // ******* Memo and ShowMessage
  347. writeln (' Memo / ShowMessage');
  348. b := TFPgtkVBox.Create;
  349. Notebook.appendPageFull (b, TFPgtkLabel.Create('Memo Message'), TFPgtkLabel.Create('Memo and ShowMessage'),true);
  350. t := TFPgtkScrollText.Create;
  351. b.PackStart (t, true, true, 10);
  352. but := TFPgtkButton.CreateWithLabel ('Show text');
  353. but.ConnectClicked (@MemoMessage_Show, t);
  354. b.PackStart (but, false, false, 2);
  355. // ******* File Selection
  356. writeln (' File selection');
  357. b := TFPgtkVBox.Create;
  358. Notebook.appendPageFull (b, TFPgtkLabel.Create('File selection'), TFPgtkLabel.Create('File selection dialog'),true);
  359. b.PackStart (TFPgtkFileEntry.Create, false, true, 10);
  360. // ******* Progress bar page
  361. b := TFPgtkVBox.Create;
  362. Notebook.appendPageFull (b, TFPgtkLabel.Create('Progress'), TFPgtkLabel.Create('The Progressbar'),true);
  363. pb := TFPgtkProgressBar.Create (nil);
  364. with pb do
  365. begin
  366. formatstring := Init_ProgressBar_FormatString;
  367. showText := true;
  368. configure (50.0, 0.0, 500.0);
  369. end;
  370. b.Packstart (pb, false, false, 3);
  371. but := TFPgtkButton.createWithLabel ('Run the bar');
  372. but.ConnectClicked (@ProgressBar_ShowItToMe, nil);
  373. b.PackStart (but, false, false, 3);
  374. but := TFPgtkCheckbutton.CreateWithLabel ('Activity mode');
  375. but.ConnectClicked (@ProgressBar_SetActivityMode, pb);
  376. b.PackStart (but, false, false, 3);
  377. b.Packstart (TFPgtkLabel.Create ('Format text'), false, false, 10);
  378. e := TFPgtkEntry.Create;
  379. e.Text := Init_ProgressBar_FormatString;
  380. e.ConnectChanged (@ProgressBar_FormatString, pb);
  381. b.Packstart(e, false, false, 0);
  382. // ******* Spinbutton
  383. writeln (' page creation');
  384. b := TFPgtkVBox.Create;
  385. Notebook.appendPageFull (b, TFPgtkLabel.Create('SpinButton'), TFPgtkLabel.Create('Spinbuttons'),true);
  386. Spin := TFPgtkSPinButton.Create;
  387. Spin.Configure (nil,0.01,3);
  388. Spin.Adjustment.configure (-100.0, 100.0, 10.25, 0.01, 0.1, 1.0);
  389. Spin.digits := 2;
  390. Spin.numeric := false;
  391. Spin.Wrap := false;
  392. Spin.SnapToTicks := false;
  393. b.PackStart (spin, false, false, 0);
  394. b.PackStart (TFPgtkLabel.Create('Climb rate'), false, false, 0);
  395. sp := TFPgtkSpinButton.Create;
  396. with sp do
  397. begin
  398. with Adjustment do
  399. begin
  400. Configure (0.0, 1.0, 0.01, 0.01, 0.20, 0.0);
  401. ConnectValueChanged (@Spinbutton_ClimbRate, sp);
  402. end;
  403. digits := 3;
  404. ClimbRate := 0.01;
  405. SnapToTicks := False;
  406. end;
  407. b.PackStart (sp, false, false, 0);
  408. b.PackStart (TFPgtkLabel.Create('Digits'), false, false, 0);
  409. sp := TFPgtkSpinButton.Create;
  410. with sp do
  411. begin
  412. with adjustment do
  413. begin
  414. Configure (0.0, 5.0, 2.0, 1.0, 1.0, 0.0);
  415. ConnectValueChanged (@Spinbutton_Digits, sp);
  416. end;
  417. Configure (nil,1,0);
  418. SnapToTicks := True;
  419. end;
  420. b.PackStart (sp, false, false, 0);
  421. tbut := TFPgtkToggleButton.CreateWithLabel ('Numeric');
  422. tbut.ConnectToggled (@SpinButton_numeric, Spin);
  423. b.PackStart (tbut, false, false, 0);
  424. tbut := TFPgtkToggleButton.CreateWithLabel ('Wrap');
  425. tbut.ConnectToggled (@SpinButton_Wrap, Spin);
  426. b.PackStart (tbut, false, false, 0);
  427. tbut := TFPgtkToggleButton.CreateWithLabel ('Snap to ticks');
  428. tbut.ConnectToggled (@SpinButton_SnapToTicks, Spin);
  429. b.PackStart (tbut, false, false, 0);
  430. // ******* Last empty page
  431. writeln (' Empty page');
  432. Notebook.appendPageFull (TFPgtkLabel.Create('This page is left intentionally blank'), TFPgtkLabel.Create('Empty'), nil, true);
  433. Notebook.enablePopup;
  434. end;
  435. // ******* Progressbar
  436. procedure TListWindow.ProgressBar_ShowItToMe (Sender : TFPgtkObject; data : pointer);
  437. var k, r, t : integer;
  438. begin
  439. for r := 0 to 500 do
  440. begin
  441. pb.CurrentValue := (r + 0.1);
  442. for t := 0 to random(5) do
  443. k := random(1000)*5 div 2542 + 15;
  444. end;
  445. end;
  446. procedure TListWindow.ProgressBar_SetActivityMode (Sender : TFPgtkObject; data : pointer);
  447. begin
  448. TFPgtkProgressBar(data).ActivityMode := TFPgtkCheckButton(Sender).Active;
  449. end;
  450. procedure TListWindow.ProgressBar_FormatString (Sender : TFPgtkObject; data : pointer);
  451. begin
  452. TFPgtkProgressBar(data).Formatstring := TFPgtkEntry(Sender).Text;
  453. end;
  454. // ******* Spinbutton
  455. procedure TListWindow.Spinbutton_ClimbRate (Sender : TFPgtkObject; data : pointer);
  456. begin
  457. spin.climbrate := TFPgtkSpinbutton(data).asFloat;
  458. end;
  459. procedure TListWindow.Spinbutton_Digits (Sender : TFPgtkObject; data : pointer);
  460. begin
  461. spin.digits := TFPgtkSpinbutton(data).asinteger;
  462. end;
  463. procedure TListWindow.Spinbutton_UpdatePolicy (Sender : TFPgtkObject; data : pointer);
  464. begin
  465. end;
  466. procedure TListWindow.Spinbutton_Numeric (Sender : TFPgtkObject; data : pointer);
  467. begin
  468. TFPgtkSpinbutton(data).Numeric := (Sender as TFPgtkToggleButton).Active;
  469. end;
  470. procedure TListWindow.Spinbutton_Wrap (Sender : TFPgtkObject; data : pointer);
  471. begin
  472. TFPgtkSpinbutton(data).Wrap := (Sender as TFPgtkToggleButton).Active;
  473. end;
  474. procedure TListWindow.Spinbutton_SnapToTicks (Sender : TFPgtkObject; data : pointer);
  475. begin
  476. TFPgtkSpinbutton(data).SnapToTicks := (Sender as TFPgtkToggleButton).Active;
  477. end;
  478. { Memo and ShowMessage }
  479. procedure TListWindow.MemoMessage_Show (Sender : TFPgtkObject; data : pointer);
  480. begin
  481. ShowMessage ('You typed:', TFPgtkScrollText(data).Text);
  482. end;
  483. { Statusbar }
  484. procedure TListWindow.StatusBar_Push (Sender : TFPgtkObject; data : pointer);
  485. begin
  486. IDMessage.asinteger := bar.push (IDContext.asinteger, EMessage.Text);
  487. end;
  488. procedure TListWindow.StatusBar_Pop (Sender : TFPgtkObject; data : pointer);
  489. begin
  490. bar.pop (IDContext.asinteger);
  491. end;
  492. procedure TListWindow.StatusBar_Remove (Sender : TFPgtkObject; data : pointer);
  493. begin
  494. bar.Remove (IDContext.asinteger, IDMessage.asinteger);
  495. end;
  496. procedure TListWindow.StatusBar_GetContext (Sender : TFPgtkObject; data : pointer);
  497. begin
  498. IDContext.asinteger := bar.GetContextID (EContext.Text);
  499. end;
  500. { List }
  501. const ListSignalNames : array[0..15] of string =
  502. (sgSelectionChanged,sgSelectChild,sgUnselectChild,
  503. sgToggleFocusRow,sgSelectAll,sgUnselectAll,sgUndoSelection,
  504. sgStartSelection,sgEndSelection,sgToggleAddMode,
  505. sgExtendSelection,sgScrollVertical,sgScrollHorizontal,
  506. sgSelect,sgDeselect,sgToggle);
  507. procedure TListWindow.List_ShowSignal (Sender : TFPgtkObject; data : pointer);
  508. var r : integer;
  509. begin
  510. r := PointerToInt (data);
  511. writeln (Sender.Classname, ' emitted signal ',ListSignalNames[r]);
  512. end;
  513. procedure TListWindow.List_ShowWidgetSignal (Sender : TFPgtkObject; widget:TFPgtkWidget; data : pointer);
  514. var r : integer;
  515. begin
  516. r := PointerToInt (data);
  517. writeln (Sender.Classname, ' emitted signal ',ListSignalNames[r]);
  518. end;
  519. procedure TListWindow.List_AddToList (Sender : TFPgtkObject; data : pointer);
  520. var t : TFPgtkText;
  521. l : TFPgtkListItemGroup;
  522. begin
  523. l := TFPgtkListItemGroup.Create;
  524. try
  525. t := TFPgtkText(data);
  526. l.FillFromList (t.Lines);
  527. List.List.AppendItems (l);
  528. finally
  529. l.free;
  530. end;
  531. end;
  532. procedure TListWindow.List_SelectionMode (Sender : TFPgtkObject; data : pointer);
  533. var r : integer;
  534. begin
  535. r := pointertoint(data);
  536. List.List.SelectionMode := TGtkSelectionMode(r);
  537. end;
  538. procedure TListWindow.List_ClearAll (Sender : TFPgtkObject; data : pointer);
  539. begin
  540. List.List.ClearAll;
  541. end;
  542. procedure TListWindow.List_Clear1_5 (Sender : TFPgtkObject; data : pointer);
  543. begin
  544. List.List.ClearItems(1,5);
  545. end;
  546. procedure TListWindow.List_AddCount (Sender : TFPgtkObject; data : pointer);
  547. var li : TFPgtkListItem;
  548. begin
  549. li := TFPgtkListItem.CreateWithLabel ('Count');
  550. List.List.Add (li);
  551. end;
  552. { CList }
  553. procedure TListWindow.CList_AddToList (Sender : TFPgtkObject; data : pointer);
  554. var t : TFPgtkText;
  555. l : TStrings;
  556. r : integer;
  557. begin
  558. t := TFPgtkText(data);
  559. l := t.Lines;
  560. writeln ('Going to add... (',l.commatext,')');
  561. with l do
  562. for r := 0 to count-1 do
  563. CList.CList.Append (l[r],'');
  564. end;
  565. procedure TListWindow.CList_SelectionMode (Sender : TFPgtkObject; data : pointer);
  566. var r : integer;
  567. begin
  568. r := pointertoint(data);
  569. CList.CList.SelectionMode := TGtkSelectionMode(r);
  570. end;
  571. { Accelerators }
  572. procedure Tlistwindow.Accel_ConvertToName (Sender : TFPgtkObject; data : pointer);
  573. var Mods : TGdkModifierType;
  574. begin
  575. Mods := 0;
  576. if ModCtrl.active then
  577. Mods := Mods + Gdk_Control_Mask;
  578. if ModShift.active then
  579. Mods := Mods + Gdk_Shift_Mask;
  580. if ModAlt.active then
  581. Mods := Mods + Gdk_Mod1_Mask;
  582. KeyName.Text := AccelKeyName (Key.asinteger, mods);
  583. end;
  584. procedure TListWindow.Accel_Parse (Sender : TFPgtkObject; data : pointer);
  585. var Mods : TGdkModifierType;
  586. K : guint;
  587. begin
  588. AccelKeyParse (KeyName.Text, K, Mods);
  589. ModCtrl.active := (Mods and Gdk_Control_mask) <> 0;
  590. ModShift.active := (Mods and Gdk_Shift_mask) <> 0;
  591. ModAlt.active := (Mods and Gdk_Mod1_mask) <> 0;
  592. Key.Asinteger := k;
  593. end;
  594. procedure TListWindow.Accel_AddAccel (Sender : TFPgtkObject; data : pointer);
  595. var Mods : TGdkModifierType;
  596. begin
  597. Mods := 0;
  598. if ModCtrl.active then
  599. Mods := Mods + Gdk_Control_Mask;
  600. if ModShift.active then
  601. Mods := Mods + Gdk_Shift_Mask;
  602. if ModAlt.active then
  603. Mods := Mods + Gdk_Mod1_Mask;
  604. AcceleratorAdd (TheAG, AccelBut, sgClicked, Key.Asinteger, mods, GTK_ACCEL_VISIBLE);
  605. AKeyName.refetch;
  606. end;
  607. const ButBoxCount : integer = 0;
  608. procedure TListWindow.ButBox_AddThem (Sender:TFPgtkObject; data:pointer);
  609. begin
  610. inc (ButBoxCount);
  611. VButtons.PackStart (TFPgtkButton.CreateWithLabel (format ('But %d',[ButBoxCount])),false,false,1);
  612. HButtons.PackStart (TFPgtkButton.CreateWithLabel (format ('But %d',[ButBoxCount])),false,false,1);
  613. end;
  614. procedure TListWindow.Layout_runaway (Sender:TFPgtkObject; data:pointer);
  615. begin
  616. randomize;
  617. LayoutX := LayoutX + 100 - random(200);
  618. if LayoutX < 0 then
  619. LayoutX := random(200);
  620. LayoutY := LayoutY + 100 - random(200);
  621. if LayoutY < 0 then
  622. LayoutY := random(200);
  623. TheLayout.move (Sender as TFPgtkWidget, LayoutX, LayoutY);
  624. end;
  625. procedure TListWindow.Calendar_ShowDate (Sender:TFPgtkObject; data:pointer);
  626. begin
  627. ShowMessage ('Calendar', 'Date selected: ' + formatdatetime ('dd/mm/yyyy', cal.date));
  628. end;
  629. procedure TlistWindow.AddRemoveButton (Sender:TFPgtkObject; data:pointer);
  630. var mdb : TMsgDlgBtn;
  631. begin
  632. mdb := TMsgDlgBtn(data);
  633. if (Sender as TFPgtkToggleButton).Active then
  634. MessageButtons := MessageButtons + [mdb]
  635. else
  636. MessageButtons := MessageButtons - [mdb];
  637. end;
  638. procedure TlistWindow.ShowMessageDialog (Sender:TFPgtkObject; data:pointer);
  639. begin
  640. MessageDlg (Msg.Text, TMsgDlgType(DialogType.ActiveIndex), MessageButtons, 0);
  641. end;
  642. end.