Rebuild autotool system
[construo.git] / gui_buttons.hxx
blob8b89f006690caddca9151907983a067459084f4c
1 // $Id: gui_buttons.hxx,v 1.7 2003/01/10 20:44:09 grumbel Exp $
2 //
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_CONSTRUO_GUI_BUTTONS_HXX
21 #define HEADER_CONSTRUO_GUI_BUTTONS_HXX
23 #include "colors.hxx"
24 #include "gui_component.hxx"
26 /** */
27 class GUIButton : public GUIComponent
29 protected:
30 std::string title;
32 bool mouse_over;
33 bool pressed;
35 public:
36 GUIButton (const std::string& title, int x_pos_, int y_pos_, int width_, int height_);
38 void draw_border_hover(GraphicContext*);
39 void draw_border_pressed(GraphicContext*);
40 void draw_border_normal(GraphicContext*);
42 void on_mouse_enter ();
43 void on_mouse_leave ();
45 void on_primary_button_press (int x, int y);
46 void on_primary_button_release (int x, int y);
48 void draw (GraphicContext*);
50 virtual void draw_content (GraphicContext*);
51 virtual void on_click ();
54 class GUIRunButton : public GUIButton
56 public:
57 GUIRunButton ();
58 void draw_content (GraphicContext*);
59 void on_click();
62 class GUISlowMoButton : public GUIButton
64 public:
65 GUISlowMoButton ();
66 void draw_content (GraphicContext*);
67 void on_click();
70 class GUIZoomInButton : public GUIButton
72 public:
73 GUIZoomInButton ();
74 void on_click();
77 class GUIZoomOutButton : public GUIButton
79 public:
80 GUIZoomOutButton ();
81 void on_click();
85 class GUIQuitButton : public GUIButton
87 public:
88 GUIQuitButton ();
89 void on_click();
92 class GUILoadButton : public GUIButton
94 public:
95 GUILoadButton ();
96 void on_click();
99 inline bool always_false()
101 return false;
104 class GUIGenericButton : public GUIButton
106 private:
107 typedef void (*Func)();
108 typedef bool (*HighlightFunc)();
109 Func func;
110 HighlightFunc hfunc;
111 public:
112 GUIGenericButton (const std::string& title, int x, int y, int width, int height,
113 Func f, HighlightFunc h = always_false)
114 : GUIButton (title, x, y, width, height),
115 func (f),
116 hfunc(h)
120 void on_click ()
122 func ();
125 void draw_content (GraphicContext* gc)
127 if (hfunc())
128 gc->draw_fill_rect (x_pos, y_pos,
129 x_pos + width, y_pos + height, Colors::button_bg_active);
131 GUIButton::draw_content (gc);
135 #endif
137 /* EOF */