fxruby-enhancement 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,10 +13,17 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
13
 
14
14
  SOURCES = File.expand_path("../fxruby/rdoc-sources", File.dirname(__FILE__))
15
15
  SRC_DEFS = File.expand_path("../fxruby/fox-includes/fxdefs.h", File.dirname(__FILE__))
16
+
16
17
  TARGET = File.expand_path("../lib/fxruby-enhancement/api-mapper.rb", File.dirname(__FILE__))
17
18
  TEMPLATE = File.expand_path("api-mapper.rb.erb", File.dirname(TARGET))
19
+
20
+ TARGET_RGB = File.expand_path("../lib/fxruby-enhancement/color-mapper.rb", File.dirname(__FILE__))
21
+ TEMPLATE_RGB = File.expand_path("color-mapper.rb.erb", File.dirname(TARGET_RGB))
22
+
18
23
  File.delete TARGET unless not File.exists? TARGET
24
+ File.delete TARGET_RGB unless not File.exists? TARGET_RGB
19
25
  File.open(TARGET, 'w') {}
26
+ File.open(TARGET_RGB, 'w') {}
20
27
 
21
28
  require 'fxruby-enhancement'
22
29
  require 'erb'
@@ -118,3 +125,284 @@ File.open(TEMPLATE, 'r') do |template|
118
125
  target.write ERB.new(template.read).result(binding)
119
126
  end
120
127
  end
128
+
129
+ FXC = {
130
+ GhostWhite: "Fox.FXRGB(248, 248, 255)",
131
+ WhiteSmoke: "Fox.FXRGB(245, 245, 245)",
132
+ FloralWhite: "Fox.FXRGB(255, 250, 240)",
133
+ OldLace: "Fox.FXRGB(253, 245, 230)",
134
+ AntiqueWhite: "Fox.FXRGB(250, 235, 215)",
135
+ PapayaWhip: "Fox.FXRGB(255, 239, 213)",
136
+ BlanchedAlmond: "Fox.FXRGB(255, 235, 205)",
137
+ PeachPuff: "Fox.FXRGB(255, 218, 185)",
138
+ NavajoWhite: "Fox.FXRGB(255, 222, 173)",
139
+ LemonChiffon: "Fox.FXRGB(255, 250, 205)",
140
+ MintCream: "Fox.FXRGB(245, 255, 250)",
141
+ AliceBlue: "Fox.FXRGB(240, 248, 255)",
142
+ LavenderBlush: "Fox.FXRGB(255, 240, 245)",
143
+ MistyRose: "Fox.FXRGB(255, 228, 225)",
144
+ DarkSlateGray: "Fox.FXRGB( 47, 79, 79)",
145
+ DarkSlateGrey: "Fox.FXRGB( 47, 79, 79)",
146
+ DimGray: "Fox.FXRGB(105, 105, 105)",
147
+ DimGrey: "Fox.FXRGB(105, 105, 105)",
148
+ SlateGray: "Fox.FXRGB(112, 128, 144)",
149
+ SlateGrey: "Fox.FXRGB(112, 128, 144)",
150
+ LightSlateGrey: "Fox.FXRGB(119, 136, 153)",
151
+ LightGray: "Fox.FXRGB(211, 211, 211)",
152
+ MidnightBlue: "Fox.FXRGB( 25, 25, 112)",
153
+ NavyBlue: "Fox.FXRGB( 0, 0, 128)",
154
+ CornflowerBlue: "Fox.FXRGB(100, 149, 237)",
155
+ DarkSlateBlue: "Fox.FXRGB( 72, 61, 139)",
156
+ SlateBlue: "Fox.FXRGB(106, 90, 205)",
157
+ MediumSlateBlue: "Fox.FXRGB(123, 104, 238)",
158
+ LightSlateBlue: "Fox.FXRGB(132, 112, 255)",
159
+ MediumBlue: "Fox.FXRGB( 0, 0, 205)",
160
+ RoyalBlue: "Fox.FXRGB( 65, 105, 225)",
161
+ DodgerBlue: "Fox.FXRGB( 30, 144, 255)",
162
+ DeepSkyBlue: "Fox.FXRGB( 0, 191, 255)",
163
+ SkyBlue: "Fox.FXRGB(135, 206, 235)",
164
+ LightSkyBlue: "Fox.FXRGB(135, 206, 250)",
165
+ SteelBlue: "Fox.FXRGB( 70, 130, 180)",
166
+ LightSteelBlue: "Fox.FXRGB(176, 196, 222)",
167
+ LightBlue: "Fox.FXRGB(173, 216, 230)",
168
+ PowderBlue: "Fox.FXRGB(176, 224, 230)",
169
+ PaleTurquoise: "Fox.FXRGB(175, 238, 238)",
170
+ DarkTurquoise: "Fox.FXRGB( 0, 206, 209)",
171
+ MediumTurquoise: "Fox.FXRGB( 72, 209, 204)",
172
+ LightCyan: "Fox.FXRGB(224, 255, 255)",
173
+ CadetBlue: "Fox.FXRGB( 95, 158, 160)",
174
+ MediumAquamarine: "Fox.FXRGB(102, 205, 170)",
175
+ DarkGreen: "Fox.FXRGB( 0, 100, 0)",
176
+ DarkOliveGreen: "Fox.FXRGB( 85, 107, 47)",
177
+ DarkSeaGreen: "Fox.FXRGB(143, 188, 143)",
178
+ SeaGreen: "Fox.FXRGB( 46, 139, 87)",
179
+ MediumSeaGreen: "Fox.FXRGB( 60, 179, 113)",
180
+ LightSeaGreen: "Fox.FXRGB( 32, 178, 170)",
181
+ PaleGreen: "Fox.FXRGB(152, 251, 152)",
182
+ SpringGreen: "Fox.FXRGB( 0, 255, 127)",
183
+ LawnGreen: "Fox.FXRGB(124, 252, 0)",
184
+ MediumSpringGreen: "Fox.FXRGB( 0, 250, 154)",
185
+ GreenYellow: "Fox.FXRGB(173, 255, 47)",
186
+ LimeGreen: "Fox.FXRGB( 50, 205, 50)",
187
+ YellowGreen: "Fox.FXRGB(154, 205, 50)",
188
+ ForestGreen: "Fox.FXRGB( 34, 139, 34)",
189
+ OliveDrab: "Fox.FXRGB(107, 142, 35)",
190
+ DarkKhaki: "Fox.FXRGB(189, 183, 107)",
191
+ PaleGoldenrod: "Fox.FXRGB(238, 232, 170)",
192
+ LightGoldenrodYellow: "Fox.FXRGB(250, 250, 210)",
193
+ LightYellow: "Fox.FXRGB(255, 255, 224)",
194
+ LightGoldenrod: "Fox.FXRGB(238, 221, 130)",
195
+ DarkGoldenrod: "Fox.FXRGB(184, 134, 11)",
196
+ RosyBrown: "Fox.FXRGB(188, 143, 143)",
197
+ IndianRed: "Fox.FXRGB(205, 92, 92)",
198
+ SaddleBrown: "Fox.FXRGB(139, 69, 19)",
199
+ SandyBrown: "Fox.FXRGB(244, 164, 96)",
200
+ DarkSalmon: "Fox.FXRGB(233, 150, 122)",
201
+ LightSalmon: "Fox.FXRGB(255, 160, 122)",
202
+ DarkOrange: "Fox.FXRGB(255, 140, 0)",
203
+ LightCoral: "Fox.FXRGB(240, 128, 128)",
204
+ OrangeRed: "Fox.FXRGB(255, 69, 0)",
205
+ HotPink: "Fox.FXRGB(255, 105, 180)",
206
+ DeepPink: "Fox.FXRGB(255, 20, 147)",
207
+ LightPink: "Fox.FXRGB(255, 182, 193)",
208
+ PaleVioletRed: "Fox.FXRGB(219, 112, 147)",
209
+ MediumVioletRed: "Fox.FXRGB(199, 21, 133)",
210
+ VioletRed: "Fox.FXRGB(208, 32, 144)",
211
+ MediumOrchid: "Fox.FXRGB(186, 85, 211)",
212
+ DarkOrchid: "Fox.FXRGB(153, 50, 204)",
213
+ DarkViolet: "Fox.FXRGB(148, 0, 211)",
214
+ BlueViolet: "Fox.FXRGB(138, 43, 226)",
215
+ MediumPurple: "Fox.FXRGB(147, 112, 219)",
216
+ AntiqueWhite1: "Fox.FXRGB(255, 239, 219)",
217
+ AntiqueWhite2: "Fox.FXRGB(238, 223, 204)",
218
+ AntiqueWhite3: "Fox.FXRGB(205, 192, 176)",
219
+ AntiqueWhite4: "Fox.FXRGB(139, 131, 120)",
220
+ PeachPuff1: "Fox.FXRGB(255, 218, 185)",
221
+ PeachPuff2: "Fox.FXRGB(238, 203, 173)",
222
+ PeachPuff3: "Fox.FXRGB(205, 175, 149)",
223
+ PeachPuff4: "Fox.FXRGB(139, 119, 101)",
224
+ NavajoWhite1: "Fox.FXRGB(255, 222, 173)",
225
+ NavajoWhite2: "Fox.FXRGB(238, 207, 161)",
226
+ NavajoWhite3: "Fox.FXRGB(205, 179, 139)",
227
+ NavajoWhite4: "Fox.FXRGB(139, 121, 94)",
228
+ LemonChiffon1: "Fox.FXRGB(255, 250, 205)",
229
+ LemonChiffon2: "Fox.FXRGB(238, 233, 191)",
230
+ LemonChiffon3: "Fox.FXRGB(205, 201, 165)",
231
+ LemonChiffon4: "Fox.FXRGB(139, 137, 112)",
232
+ LavenderBlush1: "Fox.FXRGB(255, 240, 245)",
233
+ LavenderBlush2: "Fox.FXRGB(238, 224, 229)",
234
+ LavenderBlush3: "Fox.FXRGB(205, 193, 197)",
235
+ LavenderBlush4: "Fox.FXRGB(139, 131, 134)",
236
+ MistyRose1: "Fox.FXRGB(255, 228, 225)",
237
+ MistyRose2: "Fox.FXRGB(238, 213, 210)",
238
+ MistyRose3: "Fox.FXRGB(205, 183, 181)",
239
+ MistyRose4: "Fox.FXRGB(139, 125, 123)",
240
+ SlateBlue1: "Fox.FXRGB(131, 111, 255)",
241
+ SlateBlue2: "Fox.FXRGB(122, 103, 238)",
242
+ SlateBlue3: "Fox.FXRGB(105, 89, 205)",
243
+ SlateBlue4: "Fox.FXRGB( 71, 60, 139)",
244
+ RoyalBlue1: "Fox.FXRGB( 72, 118, 255)",
245
+ RoyalBlue2: "Fox.FXRGB( 67, 110, 238)",
246
+ RoyalBlue3: "Fox.FXRGB( 58, 95, 205)",
247
+ RoyalBlue4: "Fox.FXRGB( 39, 64, 139)",
248
+ DodgerBlue1: "Fox.FXRGB( 30, 144, 255)",
249
+ DodgerBlue2: "Fox.FXRGB( 28, 134, 238)",
250
+ DodgerBlue3: "Fox.FXRGB( 24, 116, 205)",
251
+ DodgerBlue4: "Fox.FXRGB( 16, 78, 139)",
252
+ SteelBlue1: "Fox.FXRGB( 99, 184, 255)",
253
+ SteelBlue2: "Fox.FXRGB( 92, 172, 238)",
254
+ SteelBlue3: "Fox.FXRGB( 79, 148, 205)",
255
+ SteelBlue4: "Fox.FXRGB( 54, 100, 139)",
256
+ DeepSkyBlue1: "Fox.FXRGB( 0, 191, 255)",
257
+ DeepSkyBlue2: "Fox.FXRGB( 0, 178, 238)",
258
+ DeepSkyBlue3: "Fox.FXRGB( 0, 154, 205)",
259
+ DeepSkyBlue4: "Fox.FXRGB( 0, 104, 139)",
260
+ SkyBlue1: "Fox.FXRGB(135, 206, 255)",
261
+ SkyBlue2: "Fox.FXRGB(126, 192, 238)",
262
+ SkyBlue3: "Fox.FXRGB(108, 166, 205)",
263
+ SkyBlue4: "Fox.FXRGB( 74, 112, 139)",
264
+ LightSkyBlue1: "Fox.FXRGB(176, 226, 255)",
265
+ LightSkyBlue2: "Fox.FXRGB(164, 211, 238)",
266
+ LightSkyBlue3: "Fox.FXRGB(141, 182, 205)",
267
+ LightSkyBlue4: "Fox.FXRGB( 96, 123, 139)",
268
+ SlateGray1: "Fox.FXRGB(198, 226, 255)",
269
+ SlateGray2: "Fox.FXRGB(185, 211, 238)",
270
+ SlateGray3: "Fox.FXRGB(159, 182, 205)",
271
+ SlateGray4: "Fox.FXRGB(108, 123, 139)",
272
+ LightSteelBlue1: "Fox.FXRGB(202, 225, 255)",
273
+ LightSteelBlue2: "Fox.FXRGB(188, 210, 238)",
274
+ LightSteelBlue3: "Fox.FXRGB(162, 181, 205)",
275
+ LightSteelBlue4: "Fox.FXRGB(110, 123, 139)",
276
+ LightBlue1: "Fox.FXRGB(191, 239, 255)",
277
+ LightBlue2: "Fox.FXRGB(178, 223, 238)",
278
+ LightBlue3: "Fox.FXRGB(154, 192, 205)",
279
+ LightBlue4: "Fox.FXRGB(104, 131, 139)",
280
+ LightCyan1: "Fox.FXRGB(224, 255, 255)",
281
+ LightCyan2: "Fox.FXRGB(209, 238, 238)",
282
+ LightCyan3: "Fox.FXRGB(180, 205, 205)",
283
+ LightCyan4: "Fox.FXRGB(122, 139, 139)",
284
+ PaleTurquoise1: "Fox.FXRGB(187, 255, 255)",
285
+ PaleTurquoise2: "Fox.FXRGB(174, 238, 238)",
286
+ PaleTurquoise3: "Fox.FXRGB(150, 205, 205)",
287
+ PaleTurquoise4: "Fox.FXRGB(102, 139, 139)",
288
+ CadetBlue1: "Fox.FXRGB(152, 245, 255)",
289
+ CadetBlue2: "Fox.FXRGB(142, 229, 238)",
290
+ CadetBlue3: "Fox.FXRGB(122, 197, 205)",
291
+ CadetBlue4: "Fox.FXRGB( 83, 134, 139)",
292
+ DarkSlateGray1: "Fox.FXRGB(151, 255, 255)",
293
+ DarkSlateGray2: "Fox.FXRGB(141, 238, 238)",
294
+ DarkSlateGray3: "Fox.FXRGB(121, 205, 205)",
295
+ DarkSlateGray4: "Fox.FXRGB( 82, 139, 139)",
296
+ DarkSeaGreen1: "Fox.FXRGB(193, 255, 193)",
297
+ DarkSeaGreen2: "Fox.FXRGB(180, 238, 180)",
298
+ DarkSeaGreen3: "Fox.FXRGB(155, 205, 155)",
299
+ DarkSeaGreen4: "Fox.FXRGB(105, 139, 105)",
300
+ SeaGreen1: "Fox.FXRGB( 84, 255, 159)",
301
+ SeaGreen2: "Fox.FXRGB( 78, 238, 148)",
302
+ SeaGreen3: "Fox.FXRGB( 67, 205, 128)",
303
+ SeaGreen4: "Fox.FXRGB( 46, 139, 87)",
304
+ PaleGreen1: "Fox.FXRGB(154, 255, 154)",
305
+ PaleGreen2: "Fox.FXRGB(144, 238, 144)",
306
+ PaleGreen3: "Fox.FXRGB(124, 205, 124)",
307
+ PaleGreen4: "Fox.FXRGB( 84, 139, 84)",
308
+ SpringGreen1: "Fox.FXRGB( 0, 255, 127)",
309
+ SpringGreen2: "Fox.FXRGB( 0, 238, 118)",
310
+ SpringGreen3: "Fox.FXRGB( 0, 205, 102)",
311
+ SpringGreen4: "Fox.FXRGB( 0, 139, 69)",
312
+ OliveDrab1: "Fox.FXRGB(192, 255, 62)",
313
+ OliveDrab2: "Fox.FXRGB(179, 238, 58)",
314
+ OliveDrab3: "Fox.FXRGB(154, 205, 50)",
315
+ OliveDrab4: "Fox.FXRGB(105, 139, 34)",
316
+ DarkOliveGreen1: "Fox.FXRGB(202, 255, 112)",
317
+ DarkOliveGreen2: "Fox.FXRGB(188, 238, 104)",
318
+ DarkOliveGreen3: "Fox.FXRGB(162, 205, 90)",
319
+ DarkOliveGreen4: "Fox.FXRGB(110, 139, 61)",
320
+ LightGoldenrod1: "Fox.FXRGB(255, 236, 139)",
321
+ LightGoldenrod2: "Fox.FXRGB(238, 220, 130)",
322
+ LightGoldenrod3: "Fox.FXRGB(205, 190, 112)",
323
+ LightGoldenrod4: "Fox.FXRGB(139, 129, 76)",
324
+ LightYellow1: "Fox.FXRGB(255, 255, 224)",
325
+ LightYellow2: "Fox.FXRGB(238, 238, 209)",
326
+ LightYellow3: "Fox.FXRGB(205, 205, 180)",
327
+ LightYellow4: "Fox.FXRGB(139, 139, 122)",
328
+ DarkGoldenrod1: "Fox.FXRGB(255, 185, 15)",
329
+ DarkGoldenrod2: "Fox.FXRGB(238, 173, 14)",
330
+ DarkGoldenrod3: "Fox.FXRGB(205, 149, 12)",
331
+ DarkGoldenrod4: "Fox.FXRGB(139, 101, 8)",
332
+ RosyBrown1: "Fox.FXRGB(255, 193, 193)",
333
+ RosyBrown2: "Fox.FXRGB(238, 180, 180)",
334
+ RosyBrown3: "Fox.FXRGB(205, 155, 155)",
335
+ RosyBrown4: "Fox.FXRGB(139, 105, 105)",
336
+ IndianRed1: "Fox.FXRGB(255, 106, 106)",
337
+ IndianRed2: "Fox.FXRGB(238, 99, 99)",
338
+ IndianRed3: "Fox.FXRGB(205, 85, 85)",
339
+ IndianRed4: "Fox.FXRGB(139, 58, 58)",
340
+ LightSalmon1: "Fox.FXRGB(255, 160, 122)",
341
+ LightSalmon2: "Fox.FXRGB(238, 149, 114)",
342
+ LightSalmon3: "Fox.FXRGB(205, 129, 98)",
343
+ LightSalmon4: "Fox.FXRGB(139, 87, 66)",
344
+ DarkOrange1: "Fox.FXRGB(255, 127, 0)",
345
+ DarkOrange2: "Fox.FXRGB(238, 118, 0)",
346
+ DarkOrange3: "Fox.FXRGB(205, 102, 0)",
347
+ DarkOrange4: "Fox.FXRGB(139, 69, 0)",
348
+ OrangeRed1: "Fox.FXRGB(255, 69, 0)",
349
+ OrangeRed2: "Fox.FXRGB(238, 64, 0)",
350
+ OrangeRed3: "Fox.FXRGB(205, 55, 0)",
351
+ OrangeRed4: "Fox.FXRGB(139, 37, 0)",
352
+ DeepPink1: "Fox.FXRGB(255, 20, 147)",
353
+ DeepPink2: "Fox.FXRGB(238, 18, 137)",
354
+ DeepPink3: "Fox.FXRGB(205, 16, 118)",
355
+ DeepPink4: "Fox.FXRGB(139, 10, 80)",
356
+ HotPink1: "Fox.FXRGB(255, 110, 180)",
357
+ HotPink2: "Fox.FXRGB(238, 106, 167)",
358
+ HotPink3: "Fox.FXRGB(205, 96, 144)",
359
+ HotPink4: "Fox.FXRGB(139, 58, 98)",
360
+ LightPink1: "Fox.FXRGB(255, 174, 185)",
361
+ LightPink2: "Fox.FXRGB(238, 162, 173)",
362
+ LightPink3: "Fox.FXRGB(205, 140, 149)",
363
+ LightPink4: "Fox.FXRGB(139, 95, 101)",
364
+ PaleVioletRed1: "Fox.FXRGB(255, 130, 171)",
365
+ PaleVioletRed2: "Fox.FXRGB(238, 121, 159)",
366
+ PaleVioletRed3: "Fox.FXRGB(205, 104, 137)",
367
+ PaleVioletRed4: "Fox.FXRGB(139, 71, 93)",
368
+ VioletRed1: "Fox.FXRGB(255, 62, 150)",
369
+ VioletRed2: "Fox.FXRGB(238, 58, 140)",
370
+ VioletRed3: "Fox.FXRGB(205, 50, 120)",
371
+ VioletRed4: "Fox.FXRGB(139, 34, 82)",
372
+ MediumOrchid1: "Fox.FXRGB(224, 102, 255)",
373
+ MediumOrchid2: "Fox.FXRGB(209, 95, 238)",
374
+ MediumOrchid3: "Fox.FXRGB(180, 82, 205)",
375
+ MediumOrchid4: "Fox.FXRGB(122, 55, 139)",
376
+ DarkOrchid1: "Fox.FXRGB(191, 62, 255)",
377
+ DarkOrchid2: "Fox.FXRGB(178, 58, 238)",
378
+ DarkOrchid3: "Fox.FXRGB(154, 50, 205)",
379
+ DarkOrchid4: "Fox.FXRGB(104, 34, 139)",
380
+ MediumPurple1: "Fox.FXRGB(171, 130, 255)",
381
+ MediumPurple2: "Fox.FXRGB(159, 121, 238)",
382
+ MediumPurple3: "Fox.FXRGB(137, 104, 205)",
383
+ MediumPurple4: "Fox.FXRGB( 93, 71, 139)",
384
+ DarkGrey: "Fox.FXRGB(169, 169, 169)",
385
+ DarkGray: "Fox.FXRGB(169, 169, 169)",
386
+ DarkBlue: "Fox.FXRGB(0 , 0, 139)",
387
+ DarkCyan: "Fox.FXRGB(0 , 139, 139)",
388
+ DarkMagenta: "Fox.FXRGB(139, 0, 139)",
389
+ DarkRed: "Fox.FXRGB(139, 0, 0)",
390
+ LightGreen: "Fox.FXRGB(144, 238, 144)",
391
+ White: "Fox.FXRGB(255, 255, 255)",
392
+ Black: "Fox.FXRGB(0, 0, 0)",
393
+ Red: "Fox.FXRGB(255, 0, 0)",
394
+ Pink: "Fox.FXRGB(255, 175, 175)",
395
+ Orange: "Fox.FXRGB(255, 200, 0)",
396
+ Yellow: "Fox.FXRGB(255, 255, 0)",
397
+ Green: "Fox.FXRGB(0, 255, 0)",
398
+ Magenta: "Fox.FXRGB(255, 0, 255)",
399
+ Cyan: "Fox.FXRGB(0, 255, 255)",
400
+ Blue: "Fox.FXRGB(0, 0, 255) ",
401
+ }
402
+
403
+ File.open(TEMPLATE_RGB, 'r') do |template|
404
+ File.open(TARGET_RGB, 'w') do |target|
405
+ @fxc = FXC
406
+ target.write ERB.new(template.read).result(binding)
407
+ end
408
+ end
@@ -80,14 +80,16 @@ end
80
80
  fx_app :app do
81
81
  app_name "Bounce"
82
82
  vendor_name "Example"
83
-
84
- fx_image(:back_buffer) { opts IMAGE_KEEP }
85
83
 
86
84
  fx_main_window(:bounce_window) {
87
85
  title "Bounce Demo"
88
86
  opts DECOR_ALL
89
87
  width 400
90
88
  height 300
89
+
90
+ as (:app) {
91
+ fx_image(:back_buffer) { opts IMAGE_KEEP }
92
+ }
91
93
 
92
94
  instance { |w|
93
95
  def w.ball
File without changes
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ FX_PATH = File.expand_path '..', File.dirname(__FILE__)
4
+ $:.unshift File.join([FX_PATH, 'lib'])
5
+
6
+ load ARGV[0]
7
+
8
+ fox_component :app do |app|
9
+ app.launch
10
+ end
File without changes
File without changes
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ require 'fxruby-enhancement'
4
+
5
+ include Fox
6
+ include Fox::Enhancement::Mapper
7
+
8
+ fx_app :app do
9
+ app_name "Scribble"
10
+ vendor_name "Example"
11
+
12
+ fx_main_window (:scribble_window) {
13
+ title "Scribble Application"
14
+ width 800
15
+ height 600
16
+
17
+ fx_horizontal_frame (:contents) {
18
+ opts LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y
19
+ pad_left 0
20
+ pad_right 0
21
+ pad_top 0
22
+ pad_bottom 0
23
+
24
+ fx_vertical_frame (:canvas_frame) {
25
+ opts FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT
26
+ pad_left 10
27
+ pad_right 10
28
+ pad_top 10
29
+ pad_bottom 10
30
+
31
+ fx_label {
32
+ text "Canvas Frame"
33
+ opts JUSTIFY_CENTER_X|LAYOUT_FILL_X
34
+ }
35
+
36
+ fx_horizontal_separator { opts SEPARATOR_GROOVE|LAYOUT_FILL_X }
37
+ fx_canvas (:canvas) {
38
+ opts LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT
39
+
40
+ instance { |c|
41
+ c.sel_paint { |sender, sel, event|
42
+ fx_dc :canvas, event do |dc|
43
+ dc.foreground = ref(:canvas).backColor
44
+ dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w, event.rect.h)
45
+ end
46
+ }
47
+
48
+ c.sel_leftbuttonpress {
49
+ ref(:canvas).grab
50
+ @mouseDown = true
51
+ }
52
+
53
+ c.sel_motion { |sender, sel, event|
54
+ if @mouseDown
55
+ # Get device context for the canvas
56
+ fx_dc (:canvas) { |dc|
57
+ # Set the foreground color for drawing
58
+ dc.foreground = @drawColor
59
+
60
+ # Draw a line from the previous mouse coordinates to the current ones
61
+ if ref(:mirror_mode).value
62
+ cW = ref(:canvas).width
63
+ cH = ref(:canvas).height
64
+ dc.drawLine(cW-event.last_x, event.last_y, cW-event.win_x, event.win_y)
65
+ dc.drawLine(event.last_x, cH-event.last_y, event.win_x, cH-event.win_y)
66
+ dc.drawLine(cW-event.last_x, cH-event.last_y, cW-event.win_x, cH-event.win_y)
67
+ end
68
+ dc.drawLine(event.last_x, event.last_y, event.win_x, event.win_y)
69
+
70
+ # We have drawn something, so now the canvas is dirty
71
+ @dirty = true
72
+ }
73
+ end
74
+ }
75
+
76
+ c.sel_leftbuttonrelease { |sender, sel, event|
77
+ ref(:canvas).ungrab
78
+ if @mouseDown
79
+ # Get device context for the canvas
80
+ fx_dc (:canvas) { |dc|
81
+ # Set the foreground color for drawing
82
+ dc.foreground = @drawColor
83
+
84
+ # Draw a line from the previous mouse coordinates to the current ones
85
+ dc.drawLine(event.last_x, event.last_y, event.win_x, event.win_y)
86
+
87
+ # We have drawn something, so now the canvas is dirty
88
+ @dirty = true
89
+
90
+ # Mouse no longer down
91
+ @mouseDown = false
92
+ }
93
+ end
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ fx_vertical_frame (:button_frame) {
100
+ opts FRAME_SUNKEN|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT
101
+ pad_left 10
102
+ pad_right 10
103
+ pad_top 10
104
+ pad_bottom 10
105
+
106
+ fx_label {
107
+ text "Button Frame"
108
+ opts JUSTIFY_CENTER_X|LAYOUT_FILL_X
109
+ }
110
+
111
+ fx_horizontal_separator {opts SEPARATOR_RIDGE|LAYOUT_FILL_X }
112
+
113
+ as (:app) {
114
+ fx_data_target (:mirror_mode) { value false }
115
+ }
116
+
117
+ fx_check_button {
118
+ text "Mirror"
119
+ target refc(:mirror_mode)
120
+ selector FXDataTarget::ID_VALUE
121
+ opts CHECKBUTTON_NORMAL|LAYOUT_FILL_X
122
+ }
123
+
124
+ fx_button (:clear_button) {
125
+ text "&Clear"
126
+ opts FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT
127
+ pad_left 10
128
+ pad_right 10
129
+ pad_top 5
130
+ pad_bottom 5
131
+
132
+ instance { |b|
133
+ b.sel_command {
134
+ fx_dc :canvas do |dc|
135
+ dc.foreground = ref(:canvas).backColor
136
+ dc.fillRectangle(0, 0, ref(:canvas).width, ref(:canvas).height)
137
+ @dirty = false
138
+ end
139
+ }
140
+
141
+ b.sel_update { |sender, sel, ptr|
142
+ message = @dirty ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE
143
+ sender.handle(ref(:scribble_window), MKUINT(message, SEL_COMMAND), nil)
144
+ }
145
+ }
146
+ }
147
+
148
+ fx_button {
149
+ text "&Exit"
150
+ selector FXApp::ID_QUIT
151
+ target refc(:app)
152
+ opts FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT
153
+ pad_left 10
154
+ pad_right 10
155
+ pad_top 5
156
+ pad_bottom 5
157
+ }
158
+ }
159
+ }
160
+
161
+ instance { |w|
162
+ @drawColor = "red"
163
+ @mouseDown = false
164
+ @dirty = false
165
+ w.show PLACEMENT_SCREEN
166
+ }
167
+ }
168
+ end
169
+
170
+ if __FILE__ == $0
171
+ # alias for fox_component is fxc
172
+ fox_component :app do |app|
173
+ app.launch
174
+ end
175
+ end