tbx  0.7.3
resiconbar.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_RES_IconBar_H
26 #define TBX_RES_IconBar_H
27 
28 #include "resobject.h"
29 
30 namespace tbx
31 {
32 namespace res
33 {
34 
38 class ResIconbar : public ResObject
39 {
40  public:
41  enum { CLASS_ID = 0x82900};
42 
47  ResIconbar(std::string name) :
48  ResObject(name, CLASS_ID, 100, 36 + 56)
49  {
50  flags(0x60); // generate click events
51  position(-1);
52  init_string(12, 0); // Null sprite name
53  init_message(20, 0); // Null text
54  init_string(28, 0); // Null menu
55  init_string(40, 0); // Null select show
56  init_string(44, 0); // Null adjust show
57  init_message(48, 0); // Null help text
58  }
59 
65  ResIconbar(const ResIconbar &other) : ResObject(other) {}
66 
72  ResIconbar(const ResObject &other) : ResObject(other) {check_class_id(CLASS_ID);}
73 
80  {
81  ResObject::operator=(other);
82  return *this;
83  }
84 
91  {
92  other.check_class_id(CLASS_ID);
93  ResObject::operator =(other);
94  return *this;
95  }
96 
104  unsigned int flags() const {return uint_value(0);}
105 
114  void flags(unsigned int value) {uint_value(0, value);}
115 
123  bool generate_select_about_to_be_shown() const {return flag(0, 1);}
131  void generate_select_about_to_be_shown(bool generate) {flag(0, 1, generate);}
139  bool generate_adjust_about_to_be_shown() const {return flag(0, 2);}
147  void generate_adjust_about_to_be_shown(bool generate) {flag(0, 2, generate);}
148 
155  bool select_show_transient() const {return flag(0, 4);}
162  void select_show_transient(bool transient) {flag(0, 4, transient);}
163 
170  bool adjust_show_transient() const {return flag(0, 8);}
177  void adjust_show_transient(bool transient) {flag(0, 8, transient);}
178 
185  bool generate_clicked_on_select() const {return flag(0, 32);}
192  void generate_clicked_on_select(bool generate) {flag(0, 32, generate);}
193 
200  bool generate_clicked_on_adjust() const {return flag(0, 64);}
207  void generate_clicked_on_adjust(bool generate) {flag(0, 64, generate);}
208 
212  int position() const {return int_value(4);}
218  void position(int value) {int_value(4, value);}
219 
224  int priority() const {return int_value(8);}
228  void priority(int value) {int_value(8, value);}
229 
233  const char *sprite_name() const {return string(12);}
234 
242  void sprite_name(const char *name, int max_length = -1) {string_with_length(12, name, max_length);}
250  void sprite_name(const std::string &name, int max_length = -1) {string_with_length(12, name, max_length);}
251 
255  int max_sprite_name() const {return int_value(16);}
256 
257 
261  const char *text() const {return message(20);}
262 
270  void text(const char *value, int max_length = -1) {message_with_length(20, value, max_length);}
278  void text(const std::string &value, int max_length = -1) {message_with_length(20, value, max_length);}
279 
283  int max_text() const {return int_value(24);}
284 
288  const char *menu() const {return string(28);}
289 
295  void menu(const char *name) {string(28, name);}
301  void menu(std::string name) {string(28, name);}
302 
306  unsigned int select_event() const {return uint_value(32);}
312  void select_event(unsigned int value) {uint_value(32, value);}
313 
317  unsigned int adjust_event() const {return uint_value(36);}
323  void adjust_event(unsigned int value) {uint_value(36, value);}
324 
330  const char *select_show() const {return string(40);}
331 
337  void select_show(const char *name) {string(40, name);}
343  void select_show(std::string name) {string(40, name);}
344 
350  const char *adjust_show() const {return string(44);}
351 
357  void adjust_show(const char *name) {string(44, name);}
363  void adjust_show(std::string name) {string(44, name);}
364 
368  const char *help_message() const {return message(48);}
369 
377  void help_message(const char *value, int max_length = -1) {message_with_length(48, value, max_length);}
385  void help_message(const std::string &value, int max_length = -1) {message_with_length(48, value, max_length);}
386 
390  int max_help_message() const {return int_value(52);}
391 
392 };
393 
394 }
395 
396 }
397 #endif // TBX_RES_IconBar_H
const char * menu() const
Get name of menu to show.
Definition: resiconbar.h:288
ResIconbar(const ResObject &other)
Construct from a ResObject.
Definition: resiconbar.h:72
const char * text() const
Get the iconbar icon text.
Definition: resiconbar.h:261
int max_sprite_name() const
Get the sprite name length.
Definition: resiconbar.h:255
void generate_select_about_to_be_shown(bool generate)
Set if an iconbar select about to be shown event will be generated before the object* which has been ...
Definition: resiconbar.h:131
void init_string(int offset, const char *value)
Initialise a string in a constructor helper.
Definition: resbase.cc:1725
Class for Iconbar in memory template.
Definition: resiconbar.h:38
void menu(const char *name)
Set name of menu to show.
Definition: resiconbar.h:295
void message_with_length(int offset, const char *value, int length=-1)
Assign a message where the length is at offset+4.
Definition: resbase.cc:1639
void select_show(const char *name)
Set name of object to show on select.
Definition: resiconbar.h:337
int priority() const
Get The priority used to position the icon on the iconbar.
Definition: resiconbar.h:224
void generate_clicked_on_select(bool generate)
Set if the iconbar clicked (or client-specified) event is generate when select is clicked...
Definition: resiconbar.h:192
unsigned int select_event() const
Get The event to generate when select is clicked or 0 for the default.
Definition: resiconbar.h:306
const char * sprite_name() const
Get the sprite name.
Definition: resiconbar.h:233
bool generate_adjust_about_to_be_shown() const
Check if an iconbar adjust about to be shown event will be generated before the object* which has bee...
Definition: resiconbar.h:139
void string_with_length(int offset, const char *value, int length=-1)
Assign a string where the length is at offset+4.
Definition: resbase.cc:1591
bool select_show_transient() const
Check if the select show object will be shown transient (i.e.
Definition: resiconbar.h:155
void select_show_transient(bool transient)
Set to show the select show object as a transient (i.e.
Definition: resiconbar.h:162
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
const char * adjust_show() const
Get name of object to show on adjust.
Definition: resiconbar.h:350
unsigned int flags() const
Get all flags as a word raw access.
Definition: resiconbar.h:104
void flags(unsigned int value)
Set all flags as a word.
Definition: resiconbar.h:114
void adjust_event(unsigned int value)
Set The event to generate when adjust is clicked or 0 for the default.
Definition: resiconbar.h:323
ResIconbar(std::string name)
Constructor and empty ResIconBar.
Definition: resiconbar.h:47
unsigned int adjust_event() const
Get The event to generate when adjust is clicked or 0 for the default.
Definition: resiconbar.h:317
void text(const std::string &value, int max_length=-1)
Set the text.
Definition: resiconbar.h:278
void adjust_show_transient(bool transient)
Set to show the adjust object as a transient (i.e.
Definition: resiconbar.h:177
int max_text() const
Get the maximum text length.
Definition: resiconbar.h:283
void adjust_show(const char *name)
Set name of object to show on adjust.
Definition: resiconbar.h:357
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
void select_event(unsigned int value)
Set The event to generate when select is clicked or 0 for the default.
Definition: resiconbar.h:312
const char * help_message() const
Get the iconbar icon help message.
Definition: resiconbar.h:368
void menu(std::string name)
Set name of menu to show.
Definition: resiconbar.h:301
const char * string(int offset) const
Return a string at the given offset.
Definition: resbase.cc:1555
void sprite_name(const std::string &name, int max_length=-1)
Set the spritename.
Definition: resiconbar.h:250
void text(const char *value, int max_length=-1)
Set the text.
Definition: resiconbar.h:270
void position(int value)
Set a negative integer giving the position of this icon on the iconbar.
Definition: resiconbar.h:218
void sprite_name(const char *name, int max_length=-1)
Set the spritename.
Definition: resiconbar.h:242
void priority(int value)
Set The priority used to position the icon on the iconbar.
Definition: resiconbar.h:228
int position() const
Get a negative integer giving the position of this icon on the iconbar.
Definition: resiconbar.h:212
unsigned int uint_value(int offset) const
Get an unsigned integer value.
Definition: resbase.h:324
ResObject & operator=(const ResObject &other)
Assignment.
Definition: resobject.cc:109
bool generate_clicked_on_adjust() const
Check if the iconbar clicked (or client-specified) event is generate when adjust is clicked...
Definition: resiconbar.h:200
void adjust_show(std::string name)
Set name of object to show on adjust.
Definition: resiconbar.h:363
void generate_adjust_about_to_be_shown(bool generate)
Set if an iconbar adjust about to be shown event will be generated before the object* which has been ...
Definition: resiconbar.h:147
void select_show(std::string name)
Set name of object to show on select.
Definition: resiconbar.h:343
Base class for a resource object that can be edited.
Definition: resobject.h:52
const char * select_show() const
Get name of object to show on select.
Definition: resiconbar.h:330
bool generate_clicked_on_select() const
Check if the iconbar clicked (or client-specified) event is generate when select is clicked...
Definition: resiconbar.h:185
bool adjust_show_transient() const
Check if the adjust show object will be shown transient (i.e.
Definition: resiconbar.h:170
ResIconbar(const ResIconbar &other)
Copy constructor.
Definition: resiconbar.h:65
void generate_clicked_on_adjust(bool generate)
Set if the iconbar clicked (or client-specified) event is generate when adjust is clicked...
Definition: resiconbar.h:207
void help_message(const std::string &value, int max_length=-1)
Set the help message.
Definition: resiconbar.h:385
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
int max_help_message() const
Get the maximum help message length.
Definition: resiconbar.h:390
ResIconbar & operator=(const ResObject &other)
Assignment from ResObject.
Definition: resiconbar.h:90
const char * name() const
Return pointer to name of object.
Definition: resobject.h:79
bool generate_select_about_to_be_shown() const
Check if an iconbar select about to be shown event will be generated before the object* which has bee...
Definition: resiconbar.h:123
void check_class_id(int class_id) const
Check if this objects class id is as specified.
Definition: resobject.cc:383
ResIconbar & operator=(const ResIconbar &other)
Assignment.
Definition: resiconbar.h:79
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736
void help_message(const char *value, int max_length=-1)
Set the help message.
Definition: resiconbar.h:377