Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

ui_window.cpp

Go to the documentation of this file.
00001 // OMICRON ENGINE HEADER FILE
00002 //
00003 // --------------------------------------------------------------------------
00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de>
00005 //
00006 // This file is part of the Omicron Engine.
00007 //
00008 // The Omicron Engine is free software; you can redistribute it and/or modify
00009 // it under the terms of the  GNU General Public License  as published by the
00010 // Free Software Foundation;  either version  2  of the License,  or (at your
00011 // option) any later version.
00012 //
00013 // The Omicron Engine  is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or  FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
00016 // for more details.
00017 //
00018 // You should have  received a copy of the  GNU General Public License  along
00019 // with The Omicron Engine;  if not,  write to the  Free Software Foundation,
00020 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021 //
00022 // --------------------------------------------------------------------------
00023 // Last modified:       $Date: 2002/12/07 19:02:03 $
00024 // By           :       $Author: kolrabi $
00025 // $Id: ui_window.cpp,v 1.1.1.1 2002/12/07 19:02:03 kolrabi Exp $ 
00026 
00027 /*
00028 
00029   $Log: ui_window.cpp,v $
00030   Revision 1.1.1.1  2002/12/07 19:02:03  kolrabi
00031   initial release
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             // if (resizable)
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 }

Generated on Wed Dec 18 15:48:48 2002 for omicron engine by doxygen1.2.18