win.c
Go to the documentation of this file.00001
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
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
00082
00083
00084 REVERSE_FOREACH_NODE(child, &w->children)
00085 {
00086
00087 win_compose(child);
00088
00089
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
00158
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