source: rtems-graphics-toolkit/fltk-1.3.0/test/preferences.fl @ 46c28a1

Last change on this file since 46c28a1 was f5c9e9c, checked in by Alexandru-Sever Horin <alex.sever.h@…>, on 07/05/12 at 09:33:03

Aded FLTK 1.3.0

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