istereo2

diff libs/goatkit/widget.h @ 6:3bccfc7d10fe

goatkit is drawing
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 23 Sep 2015 05:44:58 +0300
parents
children 018f997dc646
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/goatkit/widget.h	Wed Sep 23 05:44:58 2015 +0300
     1.3 @@ -0,0 +1,120 @@
     1.4 +/*
     1.5 +GoatKit - a themable/animated widget toolkit for games
     1.6 +Copyright (C) 2014  John Tsiombikas <nuclear@member.fsf.org>
     1.7 +
     1.8 +This program is free software: you can redistribute it and/or modify
     1.9 +it under the terms of the GNU Lesser General Public License as published by
    1.10 +the Free Software Foundation, either version 3 of the License, or
    1.11 +(at your option) any later version.
    1.12 +
    1.13 +This program is distributed in the hope that it will be useful,
    1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 +GNU Lesser General Public License for more details.
    1.17 +
    1.18 +You should have received a copy of the GNU Lesser General Public License
    1.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 +*/
    1.21 +#ifndef GOATKIT_WIDGET_H_
    1.22 +#define GOATKIT_WIDGET_H_
    1.23 +
    1.24 +#include "vec.h"
    1.25 +#include "event.h"
    1.26 +
    1.27 +namespace goatkit {
    1.28 +
    1.29 +struct BBox {
    1.30 +	Vec2 bmin, bmax;
    1.31 +};
    1.32 +
    1.33 +class Screen;
    1.34 +class Widget;
    1.35 +struct WidgetImpl;
    1.36 +
    1.37 +typedef void (*EventCallback)(Widget*, const Event &ev, void *cls);
    1.38 +
    1.39 +class Widget {
    1.40 +protected:
    1.41 +	WidgetImpl *widget;
    1.42 +
    1.43 +	virtual void set_screen(Screen *scr);
    1.44 +	Screen *get_screen() const;
    1.45 +
    1.46 +public:
    1.47 +	Widget();
    1.48 +	virtual ~Widget();
    1.49 +
    1.50 +	virtual const char *get_type_name() const;
    1.51 +
    1.52 +	virtual void set_name(const char *name);
    1.53 +	virtual const char *get_name() const;
    1.54 +
    1.55 +	virtual void set_text(const char *text);
    1.56 +	virtual const char *get_text() const;
    1.57 +
    1.58 +	virtual void show();
    1.59 +	virtual void hide();
    1.60 +	virtual float get_visibility() const;
    1.61 +	virtual bool is_visible() const;
    1.62 +
    1.63 +	virtual void activate();
    1.64 +	virtual void deactivate();
    1.65 +	virtual float get_active() const;
    1.66 +	virtual bool is_active() const;
    1.67 +
    1.68 +	virtual void press();
    1.69 +	virtual void release();
    1.70 +	virtual float get_pressed() const;
    1.71 +	virtual bool is_pressed() const;
    1.72 +
    1.73 +	virtual void mousein();
    1.74 +	virtual void mouseout();
    1.75 +	virtual float get_under_mouse() const;
    1.76 +	virtual bool is_under_mouse() const;
    1.77 +
    1.78 +	// input focus, managed by the screen
    1.79 +	virtual bool can_focus() const;
    1.80 +	virtual void focusin();
    1.81 +	virtual void focusout();
    1.82 +	virtual float get_focus() const;
    1.83 +	virtual bool is_focused() const;
    1.84 +
    1.85 +	virtual void set_position(float x, float y);
    1.86 +	virtual void set_position(const Vec2 &pos);
    1.87 +	virtual const Vec2 &get_position() const;
    1.88 +
    1.89 +	virtual void set_size(float x, float y);
    1.90 +	virtual void set_size(const Vec2 &size);
    1.91 +	virtual const Vec2 get_size() const;
    1.92 +
    1.93 +	virtual const BBox &get_box() const;
    1.94 +
    1.95 +	virtual bool hit_test(const Vec2 &pt) const;
    1.96 +
    1.97 +	virtual void draw() const;
    1.98 +
    1.99 +	// low level events
   1.100 +	virtual void on_mouse_button(const ButtonEvent &ev);
   1.101 +	virtual void on_mouse_motion(const MotionEvent &ev);
   1.102 +	virtual void on_mouse_focus(const FocusEvent &ev);
   1.103 +	virtual void on_key(const KeyEvent &ev);
   1.104 +
   1.105 +	// high level events
   1.106 +	virtual void on_click();
   1.107 +	virtual void on_double_click();
   1.108 +	virtual void on_change();
   1.109 +	//virtual void on_drag_move(int bn, const Vec2 &pt);
   1.110 +	//virtual void on_drag_release(int bn, const Vec2 &pt);
   1.111 +
   1.112 +	// event dispatcher
   1.113 +	virtual void handle_event(const Event &ev);
   1.114 +
   1.115 +	// external callback setting
   1.116 +	virtual void set_callback(EventType evtype, EventCallback func, void *cls = 0);
   1.117 +
   1.118 +	friend class Screen;
   1.119 +};
   1.120 +
   1.121 +}
   1.122 +
   1.123 +#endif	// GOATKIT_WIDGET_H_