BeRTOS
|
00001 00045 /*#* 00046 *#* $Log$ 00047 *#* Revision 1.2 2006/08/01 17:26:04 batt 00048 *#* Update docs. 00049 *#* 00050 *#* Revision 1.1 2006/08/01 15:43:01 batt 00051 *#* Add in board_kd current edited channel visualization. 00052 *#* 00053 *#* Revision 1.4 2006/07/19 12:56:26 bernie 00054 *#* Convert to new Doxygen style. 00055 *#* 00056 *#* Revision 1.3 2006/02/10 12:25:41 bernie 00057 *#* Add missing header. 00058 *#* 00059 *#* Revision 1.2 2006/01/26 00:36:48 bernie 00060 *#* Const correctness for some new functions. 00061 *#* 00062 *#* Revision 1.1 2006/01/23 23:14:29 bernie 00063 *#* Implement simple, but impressive windowing system. 00064 *#* 00065 *#*/ 00066 00067 #include "win.h" 00068 #include <struct/list.h> 00069 00076 void win_compose(Window *w) 00077 { 00078 Window *child; 00079 00080 /* 00081 * Walk over all children, in back to front order and tell them 00082 * to compose into us. 00083 */ 00084 REVERSE_FOREACH_NODE(child, &w->children) 00085 { 00086 /* Recursively compose child first. */ 00087 win_compose(child); 00088 00089 /* Draw child into our bitmap. */ 00090 if (w->bitmap) 00091 gfx_blit(w->bitmap, &child->geom, child->bitmap, 0, 0); 00092 } 00093 } 00094 00104 void win_open(Window *w, Window *parent) 00105 { 00106 ASSERT(!w->parent); 00107 w->parent = parent; 00108 ADDHEAD(&parent->children, &w->link); 00109 } 00110 00123 void win_close(Window *w) 00124 { 00125 ASSERT(w->parent); 00126 REMOVE(&w->link); 00127 w->parent = NULL; 00128 } 00129 00135 void win_raise(Window *w) 00136 { 00137 ASSERT(w->parent); 00138 REMOVE(&w->link); 00139 ADDHEAD(&w->parent->children, &w->link); 00140 } 00141 00155 void win_setGeometry(Window *w, const Rect *new_geom) 00156 { 00157 // requires C99? 00158 // memcpy(&w->geom, new_geom, sizeof(w->geom)); 00159 w->geom = *new_geom; 00160 } 00161 00173 void win_move(Window *w, coord_t left, coord_t top) 00174 { 00175 Rect r; 00176 00177 r.xmin = left; 00178 r.ymin = top; 00179 r.xmax = r.xmin + RECT_WIDTH(&w->geom); 00180 r.ymax = r.ymin + RECT_WIDTH(&w->geom); 00181 00182 win_setGeometry(w, &r); 00183 } 00184 00195 void win_resize(Window *w, coord_t width, coord_t height) 00196 { 00197 Rect r; 00198 00199 r.xmin = w->geom.xmin; 00200 r.ymin = w->geom.ymin; 00201 r.xmax = r.xmin + width; 00202 r.ymax = r.ymin + height; 00203 00204 win_setGeometry(w, &r); 00205 } 00206 00218 void win_create(Window *w, Bitmap *bm) 00219 { 00220 w->parent = NULL; 00221 w->bitmap = bm; 00222 w->geom.xmin = 0; 00223 w->geom.ymin = 0; 00224 if (bm) 00225 { 00226 w->geom.xmax = bm->width; 00227 w->geom.ymax = bm->height; 00228 } 00229 LIST_INIT(&w->children); 00230 } 00231