00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00040 #include "omicron/internal.h"
00041 #include "omicron/render.h"
00042 #include "omicron/image.h"
00043 #include "omicron/gui.h"
00044
00045 uiwindow_c::uiwindow_c()
00046 {
00047 classname = "window";
00048
00049 clientarea = new uiobject_c;
00050 uiobject_c::add_child(clientarea);
00051 clientarea->set_bgcolor(0);
00052 clientarea->move(16,16);
00053
00054 statuswindow = new uilabel_c;
00055 add_child(statuswindow);
00056 statuswindow->set_text("");
00057 statuswindow->set_style(UI_BORDER_OUTERSUNKEN);
00058 show_status(false);
00059
00060 movable = true;
00061 }
00062
00063 uiwindow_c::~uiwindow_c()
00064 {
00065 AssertThis;
00066
00067 }
00068
00069 void uiwindow_c::resize(ushort w, ushort h)
00070 {
00071 AssertThis;
00072
00073 if (w<16*3) w = 16*3;
00074 if (h<16*3) h = 16*3;
00075
00076 uiobject_c::resize(w,h);
00077 ushort sh = 0;
00078
00079 if (showstatus)
00080 sh = 16;
00081
00082 clientarea->resize(w-32,h-32-sh);
00083
00084 statuswindow->move(4, h-16);
00085 statuswindow->resize(w-8, 12);
00086 }
00087
00088 void uiwindow_c::paint()
00089 {
00090 AssertThis;
00091
00092 uiobject_c::paint();
00093
00094 img->filled_rectangle(0,0,width,height, color_from_floats(1,1,1,1));
00095 img->rectangle(0,0,width,height, color_from_floats(0.5f,0.5f,0.5f,1));
00096
00097 animation_c *wndimgs = gv.gui->get_image(UII_WINDOW);
00098
00099 ushort imgh = wndimgs->get_height();
00100 ushort imgw = wndimgs->get_width();
00101
00102 sshort i;
00103
00104 for (i=0; i<1+width/imgw; i++)
00105 {
00106 img->blt(wndimgs->set_frame(1), 0, 0, i*imgw, 0, imgw, imgh);
00107 img->blt(wndimgs->set_frame(5), 0, 0, i*imgw, height-imgh, imgw, imgh);
00108 }
00109
00110 for (i=0; i<1+height/imgh; i++)
00111 {
00112 img->blt(wndimgs->set_frame(7), 0, 0, 0, i*imgh, imgw, imgh);
00113 img->blt(wndimgs->set_frame(3), 0, 0, width-imgw, i*imgh, imgw, imgh);
00114 }
00115
00116 img->blt(wndimgs->set_frame(0), 0, 0, 0, 0, imgw, imgh);
00117 img->blt(wndimgs->set_frame(2), 0, 0, width-imgw, 0, imgw, imgh);
00118
00119 img->blt(wndimgs->set_frame(6), 0, 0, 0, height-imgh, imgw, imgh);
00120 img->blt(wndimgs->set_frame(4), 0, 0, width-imgw, height-imgh, imgw, imgh);
00121
00122 if (fnt && text)
00123 {
00124 img->draw_string(5,5,text,fnt, color_from_floats(1,1,1,1));
00125 img->draw_string(4,4,text,fnt, color_from_floats(0,0,0,1));
00126 }
00127 }
00128
00129 void uiwindow_c::event(uievent_s *eve)
00130 {
00131 AssertThis;
00132
00133 AssertReturn1(eve);
00134
00135 switch(eve->event)
00136 {
00137 case UIE_MOUSEMOVE:
00138
00139 {
00140 }
00141 break;
00142
00143 case UIE_MOUSEDOWN:
00144 if (eve->y>15)
00145 return;
00146 break;
00147 }
00148
00149 uiobject_c::event(eve);
00150 }