tbx  0.7.6
tabs.h
1 #ifndef TABS_H
2 #define TABS_H
3 
4 
5 #include "../gadget.h"
6 #include "../listener.h"
7 
8 namespace tbx
9 {
10 namespace ext
11 {
12 
13 class TabsSelectionListener;
14 
18 class Tabs : public tbx::Gadget
19 {
20  public:
21  enum {TOOLBOX_CLASS = 0x402c };
22 
23  Tabs() {}
24 
29  ~Tabs() {}
30 
36  Tabs(const Tabs &other) : Gadget(other) {}
37 
47  Tabs(const Gadget &other) : Gadget(other) {check_toolbox_class(Tabs::TOOLBOX_CLASS);}
48 
55  Tabs(const tbx::Component &other) : tbx::Gadget(other) {tbx::Window check(other.handle()); check_toolbox_class(Tabs::TOOLBOX_CLASS);}
56 
61  Tabs &operator=(const Tabs &other) {_handle = other._handle; _id = other._id; return *this;}
62 
69  Tabs &operator=(const tbx::Gadget &other) {_handle = other.handle(); _id = other.id(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
70 
78  Tabs &operator=(const tbx::Component &other) {tbx::Window check(other.handle()); _handle = other.handle(); _id = other.id(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
79 
85  bool operator==(const tbx::Gadget &other) const {return (_handle == other.handle() && _id == other.id());}
86 
92  bool operator!=(const tbx::Gadget &other) const {return (_handle != other.handle() || _id != other.id());}
93 
97  void state(int value) {int_property(16428, value);}
98 
103  int state() const {return int_property(16429);}
104 
110  void selected(int index) {int_property(16430);}
111 
117  int selected() const {return int_property(16431);}
118 
124  int tab_from_window(const tbx::Window &window);
125 
131  tbx::Window window_from_tab(int index);
132 
137  void label(int index, const std::string &text);
138 
142  std::string label(int index) const;
143 
144  void hide_tab(int index, bool hide);
145 
146  void add_selection_listener(TabsSelectionListener *listener);
147  void remove_selection_listener(TabsSelectionListener *listener);
148 };
149 
150 }
151 }
152 
153 #endif
tbx::ext::Tabs::selected
void selected(int index)
Set selected tab.
Definition: tabs.h:110
tbx::ext::Tabs::operator=
Tabs & operator=(const tbx::Gadget &other)
Assign a Tabs gadget to refer to the same underlying toolbox gadget as an existing Gadget.
Definition: tabs.h:69
tbx::ext::Tabs::label
void label(int index, const std::string &text)
Set the label for the tab.
Definition: tabs.cc:56
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::ext::Tabs::tab_from_window
int tab_from_window(const tbx::Window &window)
Get tab index from Window.
Definition: tabs.cc:19
tbx::Component::handle
ObjectId handle() const
Return the object handle for his component.
Definition: component.h:95
tbx::ext::Tabs::Tabs
Tabs()
Construct an uninitialised Tabs gadget.
Definition: tabs.h:23
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::ext::Tabs::operator=
Tabs & operator=(const Tabs &other)
Assign a Tabs gadget to refer to the same underlying toolbox gadget as another.
Definition: tabs.h:61
tbx::Component::int_property
int int_property(int property_id) const
Get an integer property from the toolbox Component.
Definition: component.cc:165
tbx::ext::Tabs::selected
int selected() const
Get selected tab.
Definition: tabs.h:117
tbx::ext::Tabs::operator=
Tabs & operator=(const tbx::Component &other)
Assign a Tabs gadget to refer to the same underlying toolbox component as an existing Gadget.
Definition: tabs.h:78
tbx::Component
Base class for components in an object.
Definition: component.h:42
tbx::Component::_handle
ObjectId _handle
Underlying toolbox handle.
Definition: component.h:45
tbx::Gadget::window
Window window()
Get the window that contains this gadget.
Definition: gadget.h:83
tbx::Component::id
ComponentId id() const
Get the component ID of this component.
Definition: component.h:103
tbx::ext::Tabs::operator==
bool operator==(const tbx::Gadget &other) const
Check if this Tabs gadget refers to the same underlying toolbox gadget as another gadget.
Definition: tabs.h:85
tbx::ext::Tabs::Tabs
Tabs(const tbx::Component &other)
Construct a Tabs gadget from a gadget.
Definition: tabs.h:55
tbx::ext::Tabs::operator!=
bool operator!=(const tbx::Gadget &other) const
Check if this Tabs gadget refers to the same underlying toolbox gadget as another gadget.
Definition: tabs.h:92
tbx::ext::TabsSelectionListener
Listener for change of tab.
Definition: tabsselectionlistener.h:41
tbx::ext::Tabs::Tabs
Tabs(const Tabs &other)
Construct a Tabs gadget from another Tabs gadget.
Definition: tabs.h:36
tbx::ext::Tabs::window_from_tab
tbx::Window window_from_tab(int index)
Get Window from tab index.
Definition: tabs.cc:38
tbx::ext::Tabs::state
void state(int value)
Set the state.
Definition: tabs.h:97
tbx::ext::Tabs::hide_tab
void hide_tab(int index, bool hide)
Hide or show a tab.
Definition: tabs.cc:108
tbx::ext::Tabs::state
int state() const
Get the state of the Tabs gadget.
Definition: tabs.h:103
tbx::ext::Tabs::~Tabs
~Tabs()
Destroy a Tabs gadget.
Definition: tabs.h:29
tbx::Component::_id
int _id
Underlying toolbox component id.
Definition: component.h:46
tbx::ext::Tabs
Class for Rick Griffins Tabs Gadget.
Definition: tabs.h:19
tbx::Gadget
This is the base class for all Gadgets.
Definition: gadget.h:49
tbx::ext::Tabs::Tabs
Tabs(const Gadget &other)
Construct a Tabs gadget from another gadget.
Definition: tabs.h:47
tbx::Gadget::check_toolbox_class
void check_toolbox_class(int class_id) const
Check the underlying gadget class for this object has the given class id.
Definition: gadget.cc:47