[66] | 1 | // Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
|
---|
| 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
| 4 | // This file is part of NV Libraries.
|
---|
| 5 | // For conditions of distribution and use, see copyright notice in nv.hh
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * @file gui_element.hh
|
---|
| 9 | * @author Kornel Kisielewicz
|
---|
| 10 | * @brief GUI Element
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef NV_GUI_ELEMENT_HH
|
---|
| 14 | #define NV_GUI_ELEMENT_HH
|
---|
| 15 |
|
---|
| 16 | #include <nv/object.hh>
|
---|
| 17 | #include <nv/position.hh>
|
---|
[69] | 18 | #include <nv/io_event.hh>
|
---|
| 19 | #include <nv/gui/gui_common.hh>
|
---|
[66] | 20 |
|
---|
| 21 | namespace nv
|
---|
| 22 | {
|
---|
| 23 | namespace gui
|
---|
| 24 | {
|
---|
| 25 | class element : public object
|
---|
| 26 | {
|
---|
| 27 | public:
|
---|
| 28 | element() : object() {}
|
---|
| 29 | element( root* aroot, const rectangle r );
|
---|
| 30 | element* get_element( const position& p );
|
---|
| 31 | virtual void on_update( uint32 elapsed );
|
---|
| 32 | virtual void on_draw();
|
---|
[69] | 33 | virtual bool on_event( const io_event& event );
|
---|
| 34 | virtual bool contains( const position& p ) const;
|
---|
[66] | 35 | virtual void set_relative( const rectangle& r );
|
---|
| 36 | virtual void set_relative( const position& p );
|
---|
| 37 | virtual const rectangle& get_relative() const { return m_relative; }
|
---|
| 38 | virtual const rectangle& get_absolute() const { return m_absolute; }
|
---|
| 39 | virtual element* get_parent() const { return (element*)m_parent; }
|
---|
| 40 | virtual bool is_enabled() const { return m_enabled; }
|
---|
| 41 | virtual bool is_visible() const { return m_visible; }
|
---|
[69] | 42 | virtual bool is_dirty() const { return m_dirty; }
|
---|
[66] | 43 | virtual void set_enabled( bool value ) { m_enabled = value; }
|
---|
| 44 | virtual void set_visible( bool value ) { m_visible = value; }
|
---|
[69] | 45 | virtual void set_dirty( bool value ) { m_dirty = value; }
|
---|
| 46 | virtual const string& get_text() const { return m_text; }
|
---|
| 47 | virtual void set_text( const string& text ) { m_text = text; m_dirty = true; }
|
---|
| 48 | virtual const string& get_class() const { return m_class; }
|
---|
| 49 | virtual void set_class( const string& class_ ) { m_class = class_; m_dirty = true; }
|
---|
[66] | 50 | virtual void recalculate_absolute();
|
---|
| 51 | protected:
|
---|
[69] | 52 | string m_class;
|
---|
| 53 | string m_text;
|
---|
[66] | 54 | rectangle m_relative;
|
---|
| 55 | rectangle m_absolute;
|
---|
| 56 | bool m_enabled;
|
---|
| 57 | bool m_visible;
|
---|
[69] | 58 | bool m_dirty;
|
---|
| 59 | render_data* m_render_data;
|
---|
[66] | 60 | };
|
---|
| 61 |
|
---|
| 62 | } // namespace gui
|
---|
| 63 |
|
---|
| 64 | } // namespace nv
|
---|
| 65 |
|
---|
| 66 | #endif // NV_GUI_ELEMENT_HH
|
---|