/* * This routine behaves a lot like graf_watchbox() - in fact, XaAES's * graf_watchbox calls this. * * The differance here is that we handle colour icons properly (something * that AES4.1 didn't do). * * I've re-used this bit from the WINDIAL module I wrote for the DULIB GEM library. * * This routine assumes that any clipping is going to be done elsewhere * before we get to here. */ global int watch_object(LOCK lock, XA_TREE *wt, int ob, int in_state, int out_state) { OBJECT *dial = wt->tree, *the_object = dial + ob; int pobf = -2, obf = ob; G_i mx, my, mb, x, y, omx, omy; vq_mouse(C.vh, &mb, &omx, &omy); object_offset(dial, ob, wt->dx, wt->dy, &x, &y); x--; y--; if (!mb) /* If mouse button is already released, assume that was just a click, so select */ { (dial + ob)->ob_state = in_state; hidem(); display_object(lock, wt, ob,x - the_object->r.x + 1, y - the_object->r.y + 1, 3); showm(); } else { while (mb) /* This loop contains a pretty busy wait, but I don't think it's to */ { /* much of a problem as the user is interacting with it continuously. */ Syield(); vq_mouse(C.vh, &mb, &mx, &my); if ((mx != omx) or (my != omy)) { omx = mx; omy = my; obf = find_object(dial, ob, 10, mx, my, wt->dx, wt->dy); if (obf == ob) (dial + ob)->ob_state = in_state; else (dial + ob)->ob_state = out_state; if (pobf != obf) { pobf = obf; hidem(); display_object(lock, wt, ob, x - the_object->r.x + 1, y - the_object->r.y + 1, 4); showm(); } } } } f_interior(FIS_SOLID); wr_mode(MD_TRANS); if (obf == ob) return 1; else return 0; }
global void rubber_box(COMPASS cp, RECT r, RECT *dist, int minw, int minh, int maxw, int maxh, RECT *last) { G_i x, y, mb; RECT old = r; l_color(BLACK); wr_mode(MD_XOR); new_box(&r, nil); do { Syield(); vq_mouse(C.vh, &mb, &x, &y); r = widen_rectangle(cp, x, y, r, dist); check_wh(&r, minw, minh, maxw, maxh); new_box(&r, &old); } while(mb); new_box(&r, nil); wr_mode(MD_TRANS); *last = r; }
global void drag_box(RECT r, RECT *bound, RECT *dist, RECT *last ) { G_i mb, x, y; RECT old = r; l_color(BLACK); wr_mode(MD_XOR); new_box(&r, nil); do { Syield(); vq_mouse(C.vh, &mb, &x, &y); r = move_rectangle(x, y, r, dist); keep_inside(&r, bound); /* Ensure we are inside the bounding rectangle */ new_box(&r, &old); } while (mb); new_box(&r,nil); wr_mode(MD_TRANS); *last = r; }
void SDL_Delay (Uint32 ms) { Uint32 now; now = SDL_GetTicks(); while ((SDL_GetTicks()-now)<ms){ if (mint_present) { Syield(); } } }
/* ** Description ** Get a message from an client to the server */ COMM_HANDLE Srv_get(void * in, int max_bytes_in) { PMSG * handle = (PMSG *)Malloc(sizeof(PMSG)); /* FIXME */ int i = 0; int err; while(i++ < 20) { err = Pmsg(MSG_READ | MSG_NOWAIT, SRVBOX, handle); if(err == 0) { break; } (void)Syield(); } if(err == 0) { memcpy(in, handle->par->in, (max_bytes_in < handle->bytes_in) ? max_bytes_in : handle->bytes_in); return (COMM_HANDLE)handle; } else { Mfree(handle); return COMM_HANDLE_NIL; } }