| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Shoes
Revision:
Author:
Date: 17 Mar 2008 12:36:04
Diff at Trac: http://code.whytheluckystiff.net/shoes/changeset/492
Changes:* shoes/canvas.c: introducing `start` and `finish` which are sort of like html's `load` and `unload`.
Files:| ... | ...@@ -364,6 +364,8 @@ | |
| 364 | 364 | rb_gc_mark_maybe(canvas->release); |
| 365 | 365 | rb_gc_mark_maybe(canvas->motion); |
| 366 | 366 | rb_gc_mark_maybe(canvas->keypress); |
| 367 | rb_gc_mark_maybe(canvas->start); | |
| 368 | rb_gc_mark_maybe(canvas->finish); | |
| 367 | 369 | rb_gc_mark_maybe(canvas->attr); |
| 368 | 370 | rb_gc_mark_maybe(canvas->parent); |
| 369 | 371 | } |
| ... | ...@@ -381,6 +383,7 @@ | |
| 381 | 383 | shoes_canvas *canvas = SHOE_ALLOC(shoes_canvas); |
| 382 | 384 | SHOE_MEMZERO(canvas, shoes_canvas, 1); |
| 383 | 385 | canvas->app = NULL; |
| 386 | canvas->stage = CANVAS_NADA; | |
| 384 | 387 | canvas->width = 0; |
| 385 | 388 | canvas->height = 0; |
| 386 | 389 | canvas->grl = 1; |
| ... | ...@@ -440,6 +443,8 @@ | |
| 440 | 443 | canvas->motion = Qnil; |
| 441 | 444 | canvas->release = Qnil; |
| 442 | 445 | canvas->keypress = Qnil; |
| 446 | canvas->start = Qnil; | |
| 447 | canvas->finish = Qnil; | |
| 443 | 448 | #ifdef SHOES_GTK |
| 444 | 449 | canvas->radios = NULL; |
| 445 | 450 | canvas->layout = NULL; |
| ... | ...@@ -1432,7 +1437,17 @@ | |
| 1432 | 1437 | { |
| 1433 | 1438 | if (self_t->cr == canvas->cr) |
| 1434 | 1439 | self_t->cr = NULL; |
| 1440 | ||
| 1441 | if (canvas->stage == CANVAS_NADA) | |
| 1442 | { | |
| 1443 | canvas->stage = CANVAS_STARTED; | |
| 1444 | if (!NIL_P(self_t->start)) | |
| 1445 | { | |
| 1446 | shoes_safe_block(self, self_t->start, rb_ary_new()); | |
| 1447 | } | |
| 1448 | } | |
| 1435 | 1449 | } |
| 1450 | ||
| 1436 | 1451 | return self; |
| 1437 | 1452 | } |
| 1438 | 1453 | |
| ... | ...@@ -1681,6 +1696,8 @@ | |
| 1681 | 1696 | EVENT_HANDLER(release); |
| 1682 | 1697 | EVENT_HANDLER(motion); |
| 1683 | 1698 | EVENT_HANDLER(keypress); |
| 1699 | EVENT_HANDLER(start); | |
| 1700 | EVENT_HANDLER(finish); | |
| 1684 | 1701 | |
| 1685 | 1702 | static VALUE |
| 1686 | 1703 | shoes_canvas_send_click2(VALUE self, int button, int x, int y, VALUE *clicked) |
| ... | ...@@ -207,6 +207,10 @@ | |
| 207 | 207 | #endif |
| 208 | 208 | } shoes_timer; |
| 209 | 209 | |
| 210 | #define CANVAS_NADA 0 | |
| 211 | #define CANVAS_STARTED 1 | |
| 212 | #define CANVAS_REMOVED 2 | |
| 213 | ||
| 210 | 214 | // |
| 211 | 215 | // temporary canvas (used internally for painting) |
| 212 | 216 | // |
| ... | ...@@ -223,7 +227,9 @@ | |
| 223 | 227 | VALUE parent; |
| 224 | 228 | VALUE attr; |
| 225 | 229 | VALUE click, release, // canvas-level event handlers |
| 226 | motion, keypress; | |
| 230 | motion, keypress, | |
| 231 | start, finish; | |
| 232 | unsigned char stage; | |
| 227 | 233 | double sw; // current stroke-width |
| 228 | 234 | int cx, cy; // cursor x and y (stored in absolute coords) |
| 229 | 235 | int endx, endy; // jump points if the cursor spills over |
| ... | ...@@ -348,6 +354,8 @@ | |
| 348 | 354 | VALUE shoes_canvas_show(VALUE); |
| 349 | 355 | VALUE shoes_canvas_toggle(VALUE); |
| 350 | 356 | VALUE shoes_canvas_mouse(VALUE); |
| 357 | VALUE shoes_canvas_start(int, VALUE *, VALUE); | |
| 358 | VALUE shoes_canvas_finish(int, VALUE *, VALUE); | |
| 351 | 359 | VALUE shoes_canvas_click(int, VALUE *, VALUE); |
| 352 | 360 | VALUE shoes_canvas_release(int, VALUE *, VALUE); |
| 353 | 361 | VALUE shoes_canvas_motion(int, VALUE *, VALUE); |
| ... | ...@@ -171,6 +171,8 @@ | |
| 171 | 171 | f("hide", hide, 0); \ |
| 172 | 172 | f("show", show, 0); \ |
| 173 | 173 | f("toggle", toggle, 0); \ |
| 174 | f("start", start, -1); \ | |
| 175 | f("finish", finish, -1); \ | |
| 174 | 176 | f("click", click, -1); \ |
| 175 | 177 | f("release", release, -1); \ |
| 176 | 178 | f("motion", motion, -1); \ |
| ... | ...@@ -78,13 +78,16 @@ | |
| 78 | 78 | title "", :size => 12, :weight => "bold", :margin => 0 |
| 79 | 79 | para "", :size => 10, :margin => 0, :margin_top => 8, :width => 220 |
| 80 | 80 | progress :width => 1.0, :top => 80 |
| 81 | end | |
| 82 | Thread.start(self) do |app| | |
| 83 | begin | |
| 84 | sleep(1) until app.started? | |
| 85 | setup.start | |
| 86 | rescue => e | |
| 87 | puts e.message | |
| 81 | ||
| 82 | start do | |
| 83 | Thread.start(self) do |app| | |
| 84 | begin | |
| 85 | sleep(1) until app.started? | |
| 86 | setup.start | |
| 87 | rescue => e | |
| 88 | puts e.message | |
| 89 | end | |
| 90 | end | |
| 88 | 91 | end |
| 89 | 92 | end |
| 90 | 93 | end |