tbx  0.7.5
resdraggable.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_RESDRAGGABLE_H
26 #define TBX_RES_RESDRAGGABLE_H
27 
28 #include "resgadget.h"
29 
30 namespace tbx {
31 namespace res {
32 
36 class ResDraggable : public ResGadget
37 {
38 
39 public:
40  enum {TYPE_ID = 640 };
41 
48  ResDraggable(const ResGadget &other) : ResGadget(other)
49  {
50  check_type(TYPE_ID);
51  }
52 
58  ResDraggable(const ResDraggable &other) : ResGadget(other)
59  {
60  }
61 
62  virtual ~ResDraggable() {}
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(640,52)
95  {
96  int_value(0, 0x80); // drop_shadow
97  init_message(36,0); // text
98  init_string(44,0); // sprite
99  }
100 
106  bool generate_drag_started() const {return flag(0, 1<<0);}
112  void generate_drag_started(bool value) {flag(0,1<<0,value);}
118  bool has_sprite() const {return flag(0, 1<<1);}
126  void has_sprite(bool value) {flag(0,1<<1,value);}
132  bool has_text() const {return flag(0, 1<<2);}
140  void has_text(bool value) {flag(0,1<<2,value);}
141 
146  {
150  };
162  void draggable_type(DraggableType value) {flag_value(0,56,((int)value)<<3);}
163 
169  bool deliver_toolbox_ids() const {return flag(0, 1<<6);}
175  void deliver_toolbox_ids(bool value) {flag(0,1<<6,value);}
181  bool drop_shadow() const {return flag(0, 1<<7);}
187  void drop_shadow(bool value) {flag(0,1<<7,value);}
193  bool not_dithered() const {return flag(0, 1<<8);}
199  void not_dithered(bool value) {flag(0,1<<8,value);}
200 
206  const char *text() const {return message(36);}
216  void text(const char *value, int max_length = -1) {message_with_length(36, value, max_length);}
226  void text(const std::string &value, int max_length = -1) {message_with_length(36, value, max_length);}
232  int max_text_len() const {return int_value(40);}
238  const char *sprite() const {return string(44);}
248  void sprite(const char *value, int max_length = -1) {string_with_length(44, value, max_length);}
258  void sprite(const std::string &value, int max_length = -1) {string_with_length(44, value, max_length);}
262  int max_sprite_len() const {return int_value(48);}
263 };
264 
265 }
266 }
267 
268 #endif // TBX_RES_RESDRAGGABLE_H
269 
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
const char * text() const
Get the text for the draggable.
Definition: resdraggable.h:206
bool drop_shadow() const
Check if the draggable will show a drop shadow when dragged.
Definition: resdraggable.h:181
bool deliver_toolbox_ids() const
Check if the draggable will deliver Toolbox IDs on drag completion.
Definition: resdraggable.h:169
const char * sprite() const
Get the sprite name for the draggable.
Definition: resdraggable.h:238
Base class for gadget memory resources.
Definition: resgadget.h:42
bool not_dithered() const
Check if the draggable will be dithered when dragged.
Definition: resdraggable.h:193
void init_string(int offset, const char *value)
Initialise a string in a constructor helper.
Definition: resbase.cc:1725
void has_text(bool value)
Set if the draggable includes text.
Definition: resdraggable.h:140
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
ResDraggable(const ResGadget &other)
Construct an draggable gadget resource.
Definition: resdraggable.h:48
void sprite(const char *value, int max_length=-1)
Set the sprite name for the draggable.
Definition: resdraggable.h:248
int flag_value(int offset, int mask) const
Get the bits for the given mask.
Definition: resbase.h:362
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
void drop_shadow(bool value)
Set if the draggable will show a drop shadow when dragged.
Definition: resdraggable.h:187
int max_text_len() const
Get the maximum length for the text.
Definition: resdraggable.h:232
Classes to use/edit toolbox resources in memory.
DraggableType
Enumerations for mouse actions allowed on the draggable.
Definition: resdraggable.h:145
void draggable_type(DraggableType value)
Set the interaction with the mouse for this draggable.
Definition: resdraggable.h:162
ResDraggable & operator=(const ResDraggable &other)
Assign from another draggable gadget resource.
Definition: resdraggable.h:82
int max_sprite_len() const
Get the maximum length of the sprite name for the draggable.
Definition: resdraggable.h:262
only allows a drag
Definition: resdraggable.h:147
void text(const std::string &value, int max_length=-1)
Set the text for the draggable.
Definition: resdraggable.h:226
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
const char * string(int offset) const
Return a string at the given offset.
Definition: resbase.cc:1555
bool has_sprite() const
Check if the draggable includes a sprite.
Definition: resdraggable.h:118
void not_dithered(bool value)
Set if the draggable will be dithered when dragged.
Definition: resdraggable.h:199
ResDraggable & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: resdraggable.h:70
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
bool generate_drag_started() const
Check if draggable should generate an event when the drag has started.
Definition: resdraggable.h:106
bool has_text() const
Check if the draggable includes text.
Definition: resdraggable.h:132
ResDraggable(const ResDraggable &other)
Construct an draggable gadget resource.
Definition: resdraggable.h:58
void sprite(const std::string &value, int max_length=-1)
Set the sprite name for the draggable.
Definition: resdraggable.h:258
click, drag and double click allowed
Definition: resdraggable.h:148
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
click selects, double click and drag allowed
Definition: resdraggable.h:149
ResDraggable()
Construct a draggable gadget resource.
Definition: resdraggable.h:93
void text(const char *value, int max_length=-1)
Set the text for the draggable.
Definition: resdraggable.h:216
void has_sprite(bool value)
Set if the draggable includes a sprite.
Definition: resdraggable.h:126
void generate_drag_started(bool value)
Set if the draggable should generate an event when the drag has started.
Definition: resdraggable.h:112
DraggableType draggable_type() const
Get the interaction with the mouse for this draggable.
Definition: resdraggable.h:156
Class for Draggable gadget template.
Definition: resdraggable.h:36
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
void deliver_toolbox_ids(bool value)
Set if the draggable will deliver Toolbox IDs on drag completion.
Definition: resdraggable.h:175
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736