[Mvpmc-cvs] mvplib/libwidget widget.c,1.16,1.17
Status: Alpha
Brought to you by:
gettler
From: Jon G. <ge...@us...> - 2005-09-29 02:45:31
|
Update of /cvsroot/mvpmc/mvplib/libwidget In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1489/libwidget Modified Files: widget.c Log Message: Change mvpw_keystroke_callback() so that the callback returns the key pressed, and add mvpw_read_area(). Index: widget.c =================================================================== RCS file: /cvsroot/mvpmc/mvplib/libwidget/widget.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** widget.c 20 Jun 2005 04:04:26 -0000 1.16 --- widget.c 29 Sep 2005 02:45:21 -0000 1.17 *************** *** 44,48 **** static void (*idle)(void); ! static void (*keystroke_callback)(void); static mvp_widget_t* --- 44,48 ---- static void (*idle)(void); ! static void (*keystroke_callback)(char); static mvp_widget_t* *************** *** 546,550 **** if (keystroke_callback) ! keystroke_callback(); if ((widget=find_widget(key->wid)) == NULL) --- 546,550 ---- if (keystroke_callback) ! keystroke_callback(key->ch); if ((widget=find_widget(key->wid)) == NULL) *************** *** 687,693 **** --- 687,697 ---- mvpw_init(void) { + GR_SCREEN_INFO si; + if (GrOpen() < 0) return -1; + GrGetScreenInfo(&si); + root = malloc(sizeof(*root)); memset(root, 0, sizeof(*root)); *************** *** 695,698 **** --- 699,704 ---- root->type = MVPW_ROOT; root->wid = GR_ROOT_WINDOW_ID; + root->width = si.cols; + root->height = si.rows; add_widget(root); *************** *** 785,789 **** int ! mvpw_keystroke_callback(void (*callback)(void)) { keystroke_callback = callback; --- 791,795 ---- int ! mvpw_keystroke_callback(void (*callback)(char)) { keystroke_callback = callback; *************** *** 826,827 **** --- 832,853 ---- GrReparentWindow(child->wid, parent->wid, 0, 0); } + + int + mvpw_read_area(mvp_widget_t *widget, int x, int y, int w, int h, + unsigned long *pixels) + { + if ((widget == NULL) || (pixels == NULL)) + return -1; + if ((x < 0) || (x >= widget->width)) + return -1; + if ((y < 0) || (y >= widget->height)) + return -1; + if ((w < 0) || (w > widget->width)) + return -1; + if ((h < 0) || (h > widget->height)) + return -1; + + GrReadArea(widget->wid, x, y, w, h, pixels); + + return 0; + } |