KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gui_button.h
Go to the documentation of this file.
1 /* $Id: gui_button.h 18278 2014-11-25 01:42:10Z ksimek $ */
2 /* {{{=========================================================================== *
3  |
4  | Copyright (c) 1994-2011 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== }}}*/
19 
20 // vim: tabstop=4 shiftwidth=4 foldmethod=marker
21 
22 #ifndef KJB_CPP_GUI_BUTTON_H
23 #define KJB_CPP_GUI_BUTTON_H
24 
25 #ifdef KJB_HAVE_OPENGL
26 
27 #include <gui_cpp/gui_overlay.h>
28 #include <boost/function.hpp>
29 
30 namespace kjb
31 {
32 namespace gui
33 {
34 
41 class Abstract_button : public Overlay
42 {
43 typedef Overlay Base;
44 
45 public:
46  Abstract_button(int x, int y, int width, int height, const boost::function0<void>& callback);
47 
49  virtual void render() const;
50 
51  virtual void render_up() const = 0;
52  virtual void render_down() const = 0;
53 
54  void redisplay();
55 
56  bool motion_event(int cursor_x, int cursor_y);
57 
58  bool mouse_event(int button, int state, int cursor_x, int cursor_y);
59 
60  void set_callback(const boost::function0<void>& callback);
61 
62 protected:
63  bool inside_(int cursor_x, int cursor_y);
64 
65 private:
66  boost::function0<void> click_callback_;
67  bool clicked_;
68  bool over_;
69 };
70 
74 class Simple_button : public Abstract_button
75 {
76 typedef Abstract_button Base;
77 
78 public:
79  Simple_button(int x, int y, int width, int height, const boost::function0<void>& callback);
80 
81  virtual void render_up() const
82  {
83  render_(false);
84  }
85 
86  virtual void render_down() const
87  {
88  render_(true);
89  }
90 
91 protected:
92  void render_(bool down) const;
93 };
94 
95 }
96 }
97 
98 #endif /* have_opengl */
99 #endif
height
Definition: APPgetLargeConnectedEdges.m:33
x
Definition: APPgetLargeConnectedEdges.m:100
void render(const Cuboid &c)
Definition: psi_weighted_box.cpp:56