tbx  0.7.5
restoolaction.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_RESTOOLACTION_H
26 #define TBX_RES_RESTOOLACTION_H
27 
28 #include "resgadget.h"
29 
30 namespace tbx {
31 namespace res {
32 
36 class ResToolAction : public ResGadget
37 {
38 
39 public:
40  enum {TYPE_ID = 0x4014 };
41 
48  ResToolAction(const ResGadget &other) : ResGadget(other)
49  {
50  check_type(TYPE_ID);
51  }
52 
58  ResToolAction(const ResToolAction &other) : ResGadget(other)
59  {
60  }
61 
62  virtual ~ResToolAction() {}
63 
71  {
72  other.check_type(TYPE_ID);
73  ResBase::operator=(other);
74  return *this;
75  }
76 
83  {
84  ResBase::operator=(other);
85  return *this;
86  }
87 
94  : ResGadget(0x4014,76)
95  {
96  init_string(36,0); // off_text
97  init_string(44,0); // on_text
98  init_string(56,0); // select_show
99  init_string(64,0); // adjust_show
100  init_string(68,0); // fade_text
101  }
102 
108  bool generate_select() const {return flag(0, 1<<0);}
114  void generate_select(bool value) {flag(0,1<<0,value);}
120  bool has_text() const {return flag(0, 1<<1);}
126  void has_text(bool value) {flag(0,1<<1,value);}
132  bool on() const {return flag(0, 1<<2);}
138  void on(bool value) {flag(0,1<<2,value);}
144  bool auto_toggle() const {return flag(0, 1<<3);}
150  void auto_toggle(bool value) {flag(0,1<<3,value);}
156  bool no_pressed_sprite() const {return flag(0, 1<<4);}
162  void no_pressed_sprite(bool value) {flag(0,1<<4,value);}
168  bool auto_repeat() const {return flag(0, 1<<8);}
174  void auto_repeat(bool value) {flag(0,1<<8,value);}
180  bool show_transient() const {return flag(0, 1<<9);}
186  void show_transient(bool value) {flag(0,1<<9,value);}
192  bool show_as_pop_up() const {return flag(0, 1<<10);}
198  void show_as_pop_up(bool value) {flag(0,1<<10,value);}
204  bool has_fade_sprite() const {return flag(0, 1<<11);}
210  void has_fade_sprite(bool value) {flag(0,1<<11,value);}
211 
219  const char *off_ident() const {return string(36);}
230  void off_ident(const char *value, int max_length = -1) {message_with_length(36, value, max_length);}
241  void off_ident(const std::string &value, int max_length = -1) {message_with_length(36, value, max_length);}
245  int max_off_ident() const {return int_value(40);}
253  const char *on_ident() const {return message(44);}
264  void on_ident(const char *value, int max_length = -1) {message_with_length(44, value, max_length);}
275  void on_ident(const std::string &value, int max_length = -1) {message_with_length(44, value, max_length);}
279  int max_on_ident() const {return int_value(48);}
285  int click_event() const {return int_value(52);}
291  void click_event(int value) {int_value(52,value);}
297  const char *select_show() const {return string(56);}
303  void select_show(const char *value) {string(56, value);}
309  void select_show(const std::string &value) {string(56, value);}
315  int adjust_event() const {return int_value(60);}
321  void adjust_event(int value) {int_value(60,value);}
327  const char *adjust_show() const {return string(64);}
333  void adjust_show(const char *value) {string(64,value);}
339  void adjust_show(const std::string &value) {string(64, value);}
347  const char *fade_ident() const {return message(68);}
358  void fade_ident(const char *value, int max_length = -1) {message_with_length(68, value, max_length);}
369  void fade_ident(const std::string &value, int max_length = -1) {message_with_length(68, value, max_length);}
373  int max_fade() const {return int_value(72);}
374 
375 };
376 
377 }
378 }
379 
380 #endif // TBX_RES_RESTOOLACTION_H
381 
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
void select_show(const std::string &value)
Set the name of the object shown when select is clicked.
Definition: restoolaction.h:309
void has_fade_sprite(bool value)
Set if the tool action has a faded sprite provided.
Definition: restoolaction.h:210
void on_ident(const std::string &value, int max_length=-1)
Set the text or sprite name shown when the tool action is on.
Definition: restoolaction.h:275
void off_ident(const std::string &value, int max_length=-1)
Set the text or sprite name shown when the tool action is off.
Definition: restoolaction.h:241
ResToolAction & operator=(const ResToolAction &other)
Assign from another tool action gadget resource.
Definition: restoolaction.h:82
ResToolAction(const ResToolAction &other)
Construct an tool action gadget resource.
Definition: restoolaction.h:58
Base class for gadget memory resources.
Definition: resgadget.h:42
void off_ident(const char *value, int max_length=-1)
Set the text or sprite name shown when the tool action is off.
Definition: restoolaction.h:230
void init_string(int offset, const char *value)
Initialise a string in a constructor helper.
Definition: resbase.cc:1725
const char * fade_ident() const
Get the text or sprite name for the faded tool action.
Definition: restoolaction.h:347
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
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
void show_as_pop_up(bool value)
Set if the select show object will be shown pop up.
Definition: restoolaction.h:198
int max_off_ident() const
Get the maximum length of the off identifier.
Definition: restoolaction.h:245
void click_event(int value)
Set the event that will generated when the tool action is clicked.
Definition: restoolaction.h:291
void adjust_event(int value)
Set the event that will generated when the tool action is clicked with adjust.
Definition: restoolaction.h:321
int click_event() const
Get the event that will generated when the tool action is clicked.
Definition: restoolaction.h:285
Classes to use/edit toolbox resources in memory.
void has_text(bool value)
Set if tool action shows text.
Definition: restoolaction.h:126
const char * on_ident() const
Get the text or sprite name shown when the tool action is on.
Definition: restoolaction.h:253
bool on() const
Check if the tool action starts off in the on state.
Definition: restoolaction.h:132
int max_fade() const
Get the maximum length of the faded identifier.
Definition: restoolaction.h:373
const char * select_show() const
Get the name of the object shown when select is clicked.
Definition: restoolaction.h:297
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
void fade_ident(const char *value, int max_length=-1)
Set the text or sprite name shown when the tool action is faded.
Definition: restoolaction.h:358
int max_on_ident() const
Get the maximum length of the on identifier.
Definition: restoolaction.h:279
int adjust_event() const
Get the event that will generated when the tool action is clicked with adjust.
Definition: restoolaction.h:315
const char * string(int offset) const
Return a string at the given offset.
Definition: resbase.cc:1555
void on_ident(const char *value, int max_length=-1)
Set the text or sprite name shown when the tool action is on.
Definition: restoolaction.h:264
bool show_as_pop_up() const
Check if the select show object will be shown as a pop up.
Definition: restoolaction.h:192
bool auto_toggle() const
Check if the tool action should automatically toggle between states.
Definition: restoolaction.h:144
bool auto_repeat() const
Check if button presses auto repeat.
Definition: restoolaction.h:168
void auto_toggle(bool value)
Set if the tool action should automatically toggle between states.
Definition: restoolaction.h:150
void select_show(const char *value)
Set the name of the object shown when select is clicked.
Definition: restoolaction.h:303
void generate_select(bool value)
Set if the select event will be generated.
Definition: restoolaction.h:114
const char * adjust_show() const
Get the name of the object shown when adjust is clicked.
Definition: restoolaction.h:327
void adjust_show(const char *value)
Set the name of the object shown when adjust is clicked.
Definition: restoolaction.h:333
bool has_text() const
Check if tool action shows text.
Definition: restoolaction.h:120
ResToolAction()
Construct a tool action gadget resource.
Definition: restoolaction.h:93
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
bool no_pressed_sprite() const
Check if there is no sprite for the pressed state.
Definition: restoolaction.h:156
const char * off_ident() const
Get the text or sprite name shown when the tool action is off.
Definition: restoolaction.h:219
ResToolAction & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: restoolaction.h:70
Class for ToolAction gadget template.
Definition: restoolaction.h:36
void show_transient(bool value)
Set if the select show object will be shown transiently.
Definition: restoolaction.h:186
ResToolAction(const ResGadget &other)
Construct an tool action gadget resource.
Definition: restoolaction.h:48
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
bool generate_select() const
Check if the select event will be generated.
Definition: restoolaction.h:108
bool has_fade_sprite() const
Check if the tool action has a faded sprite provided.
Definition: restoolaction.h:204
bool show_transient() const
Check if the select show object will be shown transiently.
Definition: restoolaction.h:180
void adjust_show(const std::string &value)
Set the name of the object shown when adjust is clicked.
Definition: restoolaction.h:339
void no_pressed_sprite(bool value)
Set if there is no sprite for the pressed state.
Definition: restoolaction.h:162
void on(bool value)
Set if the tool action starts off in the on state.
Definition: restoolaction.h:138
void fade_ident(const std::string &value, int max_length=-1)
Set the text or sprite name shown when the tool action is faded.
Definition: restoolaction.h:369
void auto_repeat(bool value)
Set if button presses auto repeat.
Definition: restoolaction.h:174
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97