src/gui/widget.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Widget
00020  *****************************************************************************/
00021 
00022 #include "widget.h"
00023 #include "../tool/point.h"
00024 
00025 Widget::Widget()
00026 {
00027   have_focus = false;
00028   ct = NULL;
00029 
00030   need_redrawing = true;
00031 }
00032 
00033 Widget::Widget(const Rectanglei &rect)
00034 {
00035   position = rect.GetPosition();
00036   size = rect.GetSize();
00037   have_focus = false;
00038   ct = NULL;
00039   
00040   need_redrawing = true;
00041 }
00042 
00043 Widget::~Widget()
00044 {
00045 }
00046 
00047 void Widget::SendKey(SDL_keysym key)
00048 {
00049 }
00050 
00051 Widget* Widget::Clic(const Point2i &mousePosition, uint button)
00052 {
00053   need_redrawing = true;
00054 
00055   return this;
00056 }
00057 
00058 void Widget::StdSetSizePosition(const Rectanglei &rect)
00059 {
00060   position = rect.GetPosition();
00061   size = rect.GetSize();
00062 }
00063 
00064 void Widget::SetContainer( Container * _ct)
00065 {
00066   ct = _ct;
00067 }
00068  
00069 void Widget::Update(const Point2i &mousePosition, 
00070                     const Point2i &lastMousePosition,
00071                     Surface& surf)
00072 {
00073   if ( 
00074       need_redrawing 
00075       || (Contains(mousePosition) && mousePosition != lastMousePosition) 
00076       || (Contains(lastMousePosition) && !Contains(mousePosition))
00077       ) 
00078     {
00079       if (ct != NULL) ct->Redraw(*this, surf);
00080       
00081       Draw(mousePosition, surf);
00082     }
00083   need_redrawing = false;
00084 }
00085 
00086 void Widget::ForceRedraw()
00087 {
00088   need_redrawing = true;
00089 }

Generated on Mon Jan 1 13:10:57 2007 for Wormux by  doxygen 1.4.7