You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
8.2KB

  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0300
  3. header_name {.h}
  4. code_name {.cxx}
  5. decl {\#include <FL/Fl_Preferences.H>} {public local
  6. }
  7. decl {\#include <stdio.h>} {public local
  8. }
  9. decl {\#include <stdlib.h>} {private local
  10. }
  11. decl {\#include <FL/filename.H>} {private local
  12. }
  13. decl {\#include <FL/fl_ask.H>} {private local
  14. }
  15. decl {void readPrefs();} {public local
  16. }
  17. decl {void writePrefs();} {public local
  18. }
  19. Function {closeWindowCB( Fl_Widget*, void* )} {open private return_type void
  20. } {
  21. code {Fl::delete_widget(myWindow);} {}
  22. }
  23. Function {saveAndCloseWindowCB( Fl_Widget*, void* )} {open private return_type void
  24. } {
  25. code {writePrefs();
  26. Fl::delete_widget(myWindow);} {}
  27. }
  28. Function {} {open return_type int
  29. } {
  30. Fl_Window myWindow {
  31. label {My Preferences}
  32. callback closeWindowCB open
  33. xywh {394 64 298 311} type Double visible
  34. } {
  35. Fl_Button {} {
  36. label Cancel
  37. callback closeWindowCB
  38. xywh {210 275 75 25}
  39. }
  40. Fl_Button {} {
  41. label OK
  42. callback saveAndCloseWindowCB
  43. xywh {125 275 75 25}
  44. }
  45. Fl_Group {} {
  46. label {Get Up:} open
  47. xywh {20 30 115 225} box ENGRAVED_FRAME align 5
  48. } {
  49. Fl_Input wAlarm {
  50. label {Alarm at:}
  51. xywh {25 55 45 20} align 5
  52. }
  53. Fl_Choice wAmPm {open
  54. xywh {75 55 55 20} down_box BORDER_BOX
  55. } {
  56. MenuItem {} {
  57. label {a.m.}
  58. xywh {0 0 100 20}
  59. }
  60. MenuItem {} {
  61. label {p.m.}
  62. xywh {0 0 100 20}
  63. }
  64. }
  65. Fl_Choice wWear {
  66. label {Wear:} open
  67. xywh {25 100 105 20} down_box BORDER_BOX align 5
  68. } {
  69. MenuItem {} {
  70. label shoes
  71. xywh {0 0 100 20}
  72. }
  73. MenuItem {} {
  74. label sandals
  75. xywh {0 0 100 20}
  76. }
  77. MenuItem {} {
  78. label {flip flops}
  79. xywh {0 0 100 20}
  80. }
  81. MenuItem {} {
  82. label {bare foot}
  83. xywh {0 0 100 20}
  84. }
  85. }
  86. Fl_Group {} {open
  87. xywh {35 120 98 60}
  88. } {
  89. Fl_Round_Button wLeft {
  90. label {left side}
  91. xywh {35 120 95 25} type Radio down_box ROUND_DOWN_BOX
  92. }
  93. Fl_Round_Button wRight {
  94. label {right side}
  95. xywh {35 140 95 25} type Radio down_box ROUND_DOWN_BOX
  96. }
  97. Fl_Box {} {
  98. label {of the bed}
  99. xywh {38 160 95 20}
  100. }
  101. }
  102. Fl_Check_Button wShower {
  103. label shower
  104. xywh {25 180 105 25} down_box DOWN_BOX
  105. }
  106. Fl_Check_Button wShave {
  107. label shave
  108. xywh {25 200 105 25} down_box DOWN_BOX
  109. }
  110. Fl_Check_Button wBrush {
  111. label {brush teeth}
  112. xywh {25 220 105 25} down_box DOWN_BOX
  113. }
  114. }
  115. Fl_Group {} {
  116. label {Breakfast::} open
  117. xywh {160 30 115 225} box ENGRAVED_FRAME align 5
  118. } {
  119. Fl_Choice wDrink {
  120. label {Drink:} open
  121. xywh {165 50 105 20} down_box BORDER_BOX align 5
  122. } {
  123. MenuItem {} {
  124. label coffee
  125. xywh {10 10 100 20}
  126. }
  127. MenuItem {} {
  128. label tea
  129. xywh {10 10 100 20}
  130. }
  131. MenuItem {} {
  132. label juice
  133. xywh {10 10 100 20}
  134. }
  135. }
  136. Fl_Check_Button wMilk {
  137. label {with milk}
  138. xywh {170 70 100 25} down_box DOWN_BOX
  139. }
  140. Fl_Choice wBread {
  141. label {Bread:} open
  142. xywh {165 110 105 20} down_box BORDER_BOX align 5
  143. } {
  144. MenuItem {} {
  145. label wheat
  146. xywh {0 0 100 20}
  147. }
  148. MenuItem {} {
  149. label white
  150. xywh {0 0 100 20}
  151. }
  152. MenuItem {} {
  153. label rye
  154. xywh {0 0 100 20}
  155. }
  156. MenuItem {} {
  157. label {sour doh}
  158. xywh {0 0 100 20}
  159. }
  160. }
  161. Fl_Check_Button wButter {
  162. label {with butter}
  163. xywh {170 130 100 25} down_box DOWN_BOX
  164. }
  165. Fl_Input wEggs {
  166. label eggs
  167. xywh {165 163 30 20} type Int align 8
  168. }
  169. Fl_Value_Slider wMinutes {
  170. label {min.}
  171. xywh {175 185 70 20} type Horizontal align 8 minimum 2 maximum 6 value 3.1
  172. }
  173. Fl_Input wPaper {
  174. label {Newspaper:}
  175. xywh {165 225 105 20} align 5
  176. }
  177. }
  178. }
  179. code {readPrefs();} {}
  180. }
  181. Function {readPrefs()} {open return_type void
  182. } {
  183. code {int boolValue;
  184. int intValue;
  185. char buffer[80];
  186. double doubleValue;
  187. Fl_Preferences app( Fl_Preferences::USER, "fltk.org", "test/preferences" );
  188. char path[ FL_PATH_MAX ];
  189. app.getUserdataPath( path, sizeof(path) );
  190. Fl_Preferences bed( app, "Bed" );
  191. bed.get( "alarm", buffer, "8:00", 79 );
  192. wAlarm->value( buffer );
  193. bed.get( "ampm", intValue, 0 );
  194. wAmPm->value( intValue );
  195. bed.get( "wear", intValue, 1 );
  196. wWear->value( intValue );
  197. int side;
  198. bed.get( "side", side, 2 );
  199. if ( side == 1 ) wLeft->value( 1 );
  200. if ( side == 2 ) wRight->value( 1 );
  201. int tasks;
  202. bed.get( "taskFlags", tasks, 0x05 );
  203. if ( tasks & 0x01 ) wShower->value( 1 );
  204. if ( tasks & 0x02 ) wShave->value( 1 );
  205. if ( tasks & 0x04 ) wBrush->value( 1 );
  206. Fl_Preferences eat( app, "Breakfast" );
  207. eat.get( "drink", intValue, 1 );
  208. wDrink->value( intValue );
  209. eat.get( "wMilk", boolValue, 0 );
  210. wMilk->value( boolValue );
  211. eat.get( "bread", intValue, 0 );
  212. wBread->value( intValue );
  213. eat.get( "wButter", boolValue, 1 );
  214. wButter->value( boolValue );
  215. eat.get( "nEggs", intValue, 2 );
  216. sprintf( buffer, "%d", intValue );
  217. wEggs->value( buffer );
  218. eat.get( "minutes", doubleValue, 3.2 );
  219. wMinutes->value( doubleValue );
  220. char *flexBuffer;
  221. eat.get( "newspaper", flexBuffer, "NY Tymes" );
  222. wPaper->value( flexBuffer );
  223. if ( flexBuffer ) free( flexBuffer );
  224. eat.get( "foo", buffer, "bar", 80 );
  225. /** sample code only:
  226. Fl_Preferences prev( app, "PreviousStarts" );
  227. {
  228. int i, n;
  229. prev.get( "n", n, 0 );
  230. for ( i=0; i<n; i++ )
  231. prev.get( Fl_Preferences::Name( i ), flexBuffer, "" );
  232. }
  233. unsigned int hex;
  234. eat.get( "binFoo", (void*)&hex, 0, 0, sizeof( unsigned int ) );
  235. void *data;
  236. eat.get( "binFoo2", data, 0, 0 );
  237. **/} {}
  238. }
  239. Function {writePrefs()} {open return_type void
  240. } {
  241. code {Fl_Preferences app( Fl_Preferences::USER, "fltk.org", "test/preferences" );
  242. Fl_Preferences bed( app, "Bed" );
  243. bed.set( "alarm", wAlarm->value() );
  244. bed.set( "ampm", wAmPm->value() );
  245. bed.set( "wear", wWear->value() );
  246. int side = 0;
  247. if ( wLeft->value() ) side = 1;
  248. if ( wRight->value() ) side = 2;
  249. bed.set( "side", side );
  250. int tasks = 0;
  251. if ( wShower->value() ) tasks |= 0x01;
  252. if ( wShave->value() ) tasks |= 0x02;
  253. if ( wBrush->value() ) tasks |= 0x04;
  254. bed.set( "taskFlags", tasks );
  255. Fl_Preferences eat( app, "Breakfast" );
  256. eat.set( "drink", wDrink->value() );
  257. eat.set( "wMilk", wMilk->value() );
  258. eat.set( "bread", wBread->value() );
  259. eat.set( "wButter", wButter->value() );
  260. eat.set( "nEggs", wEggs->value() );
  261. eat.set( "minutes", wMinutes->value() );
  262. eat.set( "newspaper", wPaper->value() );
  263. eat.set( "foo", "bar\\nfly\\rBackslash: \\\\ and bell: \\007 and delete: \\177\\n" );
  264. eat.set( Fl_Preferences::Name( 3 ), "Test3" );
  265. /* sample: create a sub-sub-group */
  266. Fl_Preferences eatMore( eat, "More" );
  267. eatMore.set( "more", "stuff" );
  268. /* all the following searches should return 1 */
  269. int sum = 0;
  270. sum += app.groupExists( "Breakfast" ); /* find 'eat' relative to 'app' */
  271. sum += app.groupExists( "Breakfast/More" ); /* find 'eat.eatMore' relative to 'app' */
  272. sum += app.groupExists( "./Breakfast/More" ); /* find 'eat.eatMore' relative to Preferences */
  273. sum += eat.groupExists( "More" ); /* find 'eatMore' relative to 'eat' */
  274. sum += eat.groupExists( "./Breakfast/More" ); /* find 'eat.eatMore' relative to Preferences */
  275. sum += eat.groupExists( "." ); /* find myself ('eat') */
  276. sum += eat.groupExists( "./" ); /* find the topmost group ('app') */
  277. if ( sum != 7 )
  278. fl_message( "Assertion failed:\\nNot all group entries were found!" );
  279. /* sample code only: */
  280. unsigned int hex = 0x2387efcd;
  281. eat.set( "binFoo", (void*)&hex, sizeof( unsigned int ) );
  282. eat.set( "binFoo2", (void*)&bed, 256 );} {selected
  283. }
  284. }