win.c
Go to the documentation of this file.00001
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #include "win.h"
00069 #include <struct/list.h>
00070
00077 void win_compose(Window *w)
00078 {
00079 Window *child;
00080
00081
00082
00083
00084
00085 REVERSE_FOREACH_NODE(child, &w->children)
00086 {
00087
00088 win_compose(child);
00089
00090
00091 if (w->bitmap)
00092 gfx_blit(w->bitmap, &child->geom, child->bitmap, 0, 0);
00093 }
00094 }
00095
00105 void win_open(Window *w, Window *parent)
00106 {
00107 ASSERT(!w->parent);
00108 w->parent = parent;
00109 ADDHEAD(&parent->children, &w->link);
00110 }
00111
00124 void win_close(Window *w)
00125 {
00126 ASSERT(w->parent);
00127 REMOVE(&w->link);
00128 w->parent = NULL;
00129 }
00130
00136 void win_raise(Window *w)
00137 {
00138 ASSERT(w->parent);
00139 REMOVE(&w->link);
00140 ADDHEAD(&w->parent->children, &w->link);
00141 }
00142
00156 void win_setGeometry(Window *w, const Rect *new_geom)
00157 {
00158
00159
00160 w->geom = *new_geom;
00161 }
00162
00174 void win_move(Window *w, coord_t left, coord_t top)
00175 {
00176 Rect r;
00177
00178 r.xmin = left;
00179 r.ymin = top;
00180 r.xmax = r.xmin + RECT_WIDTH(&w->geom);
00181 r.ymax = r.ymin + RECT_WIDTH(&w->geom);
00182
00183 win_setGeometry(w, &r);
00184 }
00185
00196 void win_resize(Window *w, coord_t width, coord_t height)
00197 {
00198 Rect r;
00199
00200 r.xmin = w->geom.xmin;
00201 r.ymin = w->geom.ymin;
00202 r.xmax = r.xmin + width;
00203 r.ymax = r.ymin + height;
00204
00205 win_setGeometry(w, &r);
00206 }
00207
00219 void win_create(Window *w, Bitmap *bm)
00220 {
00221 w->parent = NULL;
00222 w->bitmap = bm;
00223 w->geom.xmin = 0;
00224 w->geom.ymin = 0;
00225 if (bm)
00226 {
00227 w->geom.xmax = bm->width;
00228 w->geom.ymax = bm->height;
00229 }
00230 LIST_INIT(&w->children);
00231 }
00232