src/gui/widget.h

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 #ifndef GUI_WIDGET_H
00023 #define GUI_WIDGET_H
00024 
00025 #include <SDL_keyboard.h>
00026 #include "../include/base.h"
00027 #include "../tool/rectangle.h"
00028 #include "../tool/point.h"
00029 
00030 #include "container.h"
00031 
00032 class Widget : public Rectanglei
00033 {
00034  protected:
00035   Container * ct;
00036   bool need_redrawing;
00037   void StdSetSizePosition(const Rectanglei &rect);
00038 
00039  public:
00040   bool have_focus;
00041 
00042   Widget();
00043   Widget(const Rectanglei &rect);
00044   virtual ~Widget();
00045 
00046   virtual void Update(const Point2i &mousePosition,
00047                       const Point2i &lastMousePosition,
00048                       Surface& surf); // virtual only for Box !!
00049   virtual void Draw(const Point2i &mousePosition, 
00050                     Surface& surf) const = 0;
00051   virtual void ForceRedraw(); // set need_redrawing to true; -- virtual for widget_list
00052 
00053   virtual void SendKey(SDL_keysym key);
00054   virtual Widget* Clic(const Point2i &mousePosition, uint button);
00055 
00056   void SetContainer(Container * _ct);
00057 
00058   virtual void SetSizePosition(const Rectanglei &rect) = 0;
00059   void SetXY(int _x, int _y){ 
00060           SetSizePosition( Rectanglei(Point2i(_x, _y), size) ); 
00061   };  
00062 };
00063 
00064 #endif
00065 

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