tbx  0.7.6
iconbar.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef TBX_ICONBAR_H_
26 #define TBX_ICONBAR_H_
27 
28 #include "object.h"
29 #include "menu.h"
30 
31 namespace tbx
32 {
33  class Loader;
34  class IconbarClickListener;
35 
36  namespace res
37  {
38  class ResIconbar;
39  }
40 
44  class Iconbar : public Object
45  {
46  public:
47  enum {TOOLBOX_CLASS = 0x82900};
48 
55  Iconbar() {};
56 
62  Iconbar(const Iconbar &other) : Object(other._handle) {}
63 
70  Iconbar(const Object &other) : Object(other) {check_toolbox_class(Iconbar::TOOLBOX_CLASS);}
71 
77  Iconbar(const char *template_name) : Object(template_name) {check_toolbox_class(Iconbar::TOOLBOX_CLASS);}
78 
84  Iconbar(const res::ResIconbar &object_template);
85 
91  Iconbar &operator=(const Iconbar &other) {_handle = other.handle(); return *this;}
92 
99  Iconbar &operator=(const Object &other) {_handle = other.handle(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
100 
106  bool operator==(const Object &other) const {return (_handle == other.handle());}
107 
113  bool operator!=(const Object &other) const {return (_handle != other.handle());}
114 
115 
116 // Properties
117  int icon_handle() const;
118  void menu(Menu m);
119  Menu menu() const;
120  void help_message(const std::string &value);
121  std::string help_message() const;
122  int help_message_length() const;
123  void text(std::string value);
124  std::string text() const;
125  int text_length() const;
126  void sprite(const std::string &value);
127  std::string sprite() const;
128  int sprite_length() const;
129  void select_show(Object show_object);
131  void adjust_show(Object show_object);
133 
134 //TODO: void show(...) - priority show
135 
136 // Listeners
139  void add_click_command(Command *command);
140  void remove_click_command(Command *command);
141  void add_select_command(Command *command);
142  void remove_select_command(Command *command);
143  void add_adjust_command(Command *command);
144  void remove_adjust_command(Command *command);
145  void add_loader(Loader *loader, int file_type = -2);
146  void remove_loader(Loader *loader, int file_type = -2);
147  };
148 };
149 
150 #endif
tbx::Iconbar::Iconbar
Iconbar(const Iconbar &other)
Construct a Iconbar from another Iconbar.
Definition: iconbar.h:62
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::Object::handle
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93
tbx::Iconbar::remove_adjust_command
void remove_adjust_command(Command *command)
Remove command to be run if the button is selected with the adjust mouse button only.
Definition: iconbar.cc:329
tbx::Iconbar
Class to represent toolbox iconbar icon.
Definition: iconbar.h:45
tbx::Iconbar::remove_loader
void remove_loader(Loader *loader, int file_type=-2)
Remove a file loader.
Definition: iconbar.cc:356
tbx::Object::_handle
ObjectId _handle
Handle for toolbox object.
Definition: object.h:175
tbx::Iconbar::select_show
Object select_show()
Get object shown when the icon bar is clicked with select.
Definition: iconbar.cc:205
tbx::Iconbar::Iconbar
Iconbar()
Construct an uninitiased Iconbar.
Definition: iconbar.h:55
tbx::Iconbar::Iconbar
Iconbar(const Object &other)
Construct a Iconbar from another toolbox object.
Definition: iconbar.h:70
tbx::Loader
Class to handle file/data loading from the filer or an external application.
Definition: loader.h:179
tbx::Iconbar::sprite_length
int sprite_length() const
Get sprite name length.
Definition: iconbar.cc:175
tbx::Iconbar::sprite
std::string sprite() const
Get the sprite used by the icon bar.
Definition: iconbar.cc:167
tbx::Iconbar::help_message_length
int help_message_length() const
Return the length of the current help message.
Definition: iconbar.cc:115
tbx::Iconbar::add_select_command
void add_select_command(Command *command)
Add command to be run if the button is selected with the select mouse button.
Definition: iconbar.cc:297
tbx::Menu
Class representing a toolbox menu.
Definition: menu.h:49
tbx::Iconbar::operator!=
bool operator!=(const Object &other) const
Checks if this Iconbar refers to the same underlying toolbox object as the given object.
Definition: iconbar.h:113
tbx::Iconbar::menu
Menu menu() const
Get the menu from the icon bar.
Definition: iconbar.cc:83
tbx::Iconbar::operator==
bool operator==(const Object &other) const
Checks if this Iconbar refers to the same underlying toolbox object as the given object.
Definition: iconbar.h:106
tbx::Object::check_toolbox_class
void check_toolbox_class(int class_id) const
Check if this objects toolbox class is as specified.
Definition: object.cc:122
tbx::IconbarClickListener
Listener for button selected events.
Definition: iconbarclicklistener.h:59
tbx::Iconbar::add_click_listener
void add_click_listener(IconbarClickListener *listener)
Add listener for button click with the select or adjust mouse buttons.
Definition: iconbar.cc:256
tbx::Object
Class to manipulate a toolbox object.
Definition: object.h:51
tbx::Iconbar::add_loader
void add_loader(Loader *loader, int file_type=-2)
Add a file loader.
Definition: iconbar.cc:342
tbx::Command
Base class for commands in tbx.
Definition: command.h:37
tbx::Iconbar::icon_handle
int icon_handle() const
Return the underling WIMP icon handle of the icon bar.
Definition: iconbar.cc:63
tbx::Iconbar::Iconbar
Iconbar(const char *template_name)
Construct a iconbar creating a toolbox iconbar object.
Definition: iconbar.h:77
tbx::Iconbar::text_length
int text_length() const
Get the length of the icon bar text.
Definition: iconbar.cc:147
tbx::Iconbar::adjust_show
Object adjust_show()
Get object shown when the icon bar is clicked with adjust.
Definition: iconbar.cc:235
tbx::Iconbar::text
std::string text() const
Get the current text of the icon bar for a text & sprite icon bar.
Definition: iconbar.cc:138
tbx::Iconbar::remove_select_command
void remove_select_command(Command *command)
Remove command to be run if the button is selected with the select mouse button.
Definition: iconbar.cc:307
tbx::Iconbar::remove_click_listener
void remove_click_listener(IconbarClickListener *listener)
Remove listener for button click with the select or adjust mouse buttons.
Definition: iconbar.cc:266
tbx::Iconbar::remove_click_command
void remove_click_command(Command *command)
Remove command to be run if the iconbar is clicked with the select or adjust mouse buttons.
Definition: iconbar.cc:287
tbx::Iconbar::operator=
Iconbar & operator=(const Object &other)
Assign a Iconbar to an existing object.
Definition: iconbar.h:99
tbx::Iconbar::add_adjust_command
void add_adjust_command(Command *command)
Add command to be run if the button is selected with the adjust mouse button only.
Definition: iconbar.cc:318
tbx::Iconbar::operator=
Iconbar & operator=(const Iconbar &other)
Assign a Iconbar to an existing Iconbar.
Definition: iconbar.h:91
tbx::Iconbar::help_message
std::string help_message() const
Get the current help message for the icon bar.
Definition: iconbar.cc:104
tbx::res::ResIconbar
Class for Iconbar in memory template.
Definition: resiconbar.h:39
tbx::Iconbar::add_click_command
void add_click_command(Command *command)
Add command to be run if the iconbar is clicked with the select or adjust mouse buttons.
Definition: iconbar.cc:276