Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

gui_buttons.hxx Source File
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

gui_buttons.hxx

Go to the documentation of this file.
00001 //  $Id: gui_buttons.hxx,v 1.7 2003/01/10 20:44:09 grumbel Exp $
00002 // 
00003 //  Construo - A wire-frame construction game
00004 //  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 // 
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_CONSTRUO_GUI_BUTTONS_HXX
00021 #define HEADER_CONSTRUO_GUI_BUTTONS_HXX
00022 
00023 #include "colors.hxx"
00024 #include "gui_component.hxx"
00025 
00027 class GUIButton : public GUIComponent
00028 {
00029 protected:
00030   std::string title;
00031 
00032   bool mouse_over;
00033   bool pressed;
00034 
00035 public:
00036   GUIButton (const std::string& title, int x_pos_, int y_pos_, int width_, int height_);
00037 
00038   void draw_border_hover(GraphicContext*);
00039   void draw_border_pressed(GraphicContext*);
00040   void draw_border_normal(GraphicContext*);
00041   
00042   void on_mouse_enter ();
00043   void on_mouse_leave ();
00044 
00045   void on_primary_button_press (int x, int y);
00046   void on_primary_button_release (int x, int y);
00047 
00048   void draw (GraphicContext*);
00049 
00050   virtual void draw_content (GraphicContext*);
00051   virtual void on_click ();
00052 };
00053 
00054 class GUIRunButton : public GUIButton
00055 {
00056 public:
00057   GUIRunButton ();
00058   void draw_content (GraphicContext*);
00059   void on_click();
00060 };
00061 
00062 class GUISlowMoButton : public GUIButton
00063 {
00064 public:
00065   GUISlowMoButton ();
00066   void draw_content (GraphicContext*);
00067   void on_click();
00068 };
00069 
00070 class GUIZoomInButton : public GUIButton
00071 {
00072 public:
00073   GUIZoomInButton ();
00074   void on_click();
00075 };
00076 
00077 class GUIZoomOutButton : public GUIButton
00078 {
00079 public:
00080   GUIZoomOutButton ();
00081   void on_click();
00082 };
00083 
00084 
00085 class GUIQuitButton : public GUIButton
00086 {
00087 public:
00088   GUIQuitButton ();
00089   void on_click();
00090 };
00091 
00092 class GUILoadButton : public GUIButton
00093 {
00094 public:
00095   GUILoadButton ();
00096   void on_click();
00097 };
00098 
00099 inline bool always_false()
00100 {
00101   return false;
00102 }
00103 
00104 class GUIGenericButton : public GUIButton
00105 {
00106 private:
00107   typedef void (*Func)();
00108   typedef bool (*HighlightFunc)();
00109   Func func;
00110   HighlightFunc hfunc;
00111 public:
00112   GUIGenericButton (const std::string& title, int x, int y, int width, int height, 
00113                     Func f, HighlightFunc h = always_false)
00114     : GUIButton (title, x, y, width, height),
00115       func (f),
00116       hfunc(h)
00117   {
00118   }
00119 
00120   void on_click () 
00121   {
00122     func ();
00123   }
00124 
00125   void draw_content (GraphicContext* gc)
00126   {
00127     if (hfunc())
00128       gc->draw_fill_rect (x_pos, y_pos,
00129                           x_pos + width, y_pos + height, Colors::button_bg_active);
00130 
00131     GUIButton::draw_content (gc);
00132   }
00133 };
00134 
00135 #endif
00136 
00137 /* EOF */

Generated on Thu Jul 24 10:24:29 2003 for Construo by doxygen1.3-rc3