istereo2

view libs/goatkit/widget.h @ 8:661bf09db398

- replaced Quartz timer with cross-platform timer code - protected goatkit builtin theme function from being optimized out
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 24 Sep 2015 07:09:37 +0300
parents
children 018f997dc646
line source
1 /*
2 GoatKit - a themable/animated widget toolkit for games
3 Copyright (C) 2014 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef GOATKIT_WIDGET_H_
19 #define GOATKIT_WIDGET_H_
21 #include "vec.h"
22 #include "event.h"
24 namespace goatkit {
26 struct BBox {
27 Vec2 bmin, bmax;
28 };
30 class Screen;
31 class Widget;
32 struct WidgetImpl;
34 typedef void (*EventCallback)(Widget*, const Event &ev, void *cls);
36 class Widget {
37 protected:
38 WidgetImpl *widget;
40 virtual void set_screen(Screen *scr);
41 Screen *get_screen() const;
43 public:
44 Widget();
45 virtual ~Widget();
47 virtual const char *get_type_name() const;
49 virtual void set_name(const char *name);
50 virtual const char *get_name() const;
52 virtual void set_text(const char *text);
53 virtual const char *get_text() const;
55 virtual void show();
56 virtual void hide();
57 virtual float get_visibility() const;
58 virtual bool is_visible() const;
60 virtual void activate();
61 virtual void deactivate();
62 virtual float get_active() const;
63 virtual bool is_active() const;
65 virtual void press();
66 virtual void release();
67 virtual float get_pressed() const;
68 virtual bool is_pressed() const;
70 virtual void mousein();
71 virtual void mouseout();
72 virtual float get_under_mouse() const;
73 virtual bool is_under_mouse() const;
75 // input focus, managed by the screen
76 virtual bool can_focus() const;
77 virtual void focusin();
78 virtual void focusout();
79 virtual float get_focus() const;
80 virtual bool is_focused() const;
82 virtual void set_position(float x, float y);
83 virtual void set_position(const Vec2 &pos);
84 virtual const Vec2 &get_position() const;
86 virtual void set_size(float x, float y);
87 virtual void set_size(const Vec2 &size);
88 virtual const Vec2 get_size() const;
90 virtual const BBox &get_box() const;
92 virtual bool hit_test(const Vec2 &pt) const;
94 virtual void draw() const;
96 // low level events
97 virtual void on_mouse_button(const ButtonEvent &ev);
98 virtual void on_mouse_motion(const MotionEvent &ev);
99 virtual void on_mouse_focus(const FocusEvent &ev);
100 virtual void on_key(const KeyEvent &ev);
102 // high level events
103 virtual void on_click();
104 virtual void on_double_click();
105 virtual void on_change();
106 //virtual void on_drag_move(int bn, const Vec2 &pt);
107 //virtual void on_drag_release(int bn, const Vec2 &pt);
109 // event dispatcher
110 virtual void handle_event(const Event &ev);
112 // external callback setting
113 virtual void set_callback(EventType evtype, EventCallback func, void *cls = 0);
115 friend class Screen;
116 };
118 }
120 #endif // GOATKIT_WIDGET_H_