tbx  0.7.3
restextarea.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_RESTEXTAREA_H
26 #define TBX_RES_RESTEXTAREA_H
27 
28 #include "resgadget.h"
29 
30 namespace tbx {
31 namespace res {
32 
36 class ResTextArea : public ResGadget
37 {
38 
39 public:
40  enum {TYPE_ID = 0x4018 };
41 
48  ResTextArea(const ResGadget &other) : ResGadget(other)
49  {
50  check_type(TYPE_ID);
51  }
52 
58  ResTextArea(const ResTextArea &other) : ResGadget(other)
59  {
60  }
61 
62  virtual ~ResTextArea() {}
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(0x4018,56)
95  {
96  init_message(44,0); // text
97  background(0xffffff00); // white
98  }
99 
105  bool has_vertical_scrollbar() const {return flag(0, 1<<0);}
111  void has_vertical_scrollbar(bool value) {flag(0,1<<0,value);}
117  bool has_horizontal_scrollbar() const {return flag(0, 1<<1);}
123  void has_horizontal_scrollbar(bool value) {flag(0,1<<1,value);}
129  bool wordwrap() const {return flag(0, 1<<2);}
135  void wordwrap(bool value) {flag(0,1<<2,value);}
141  bool allow_selection() const {return flag(0, 1<<3);}
147  void allow_selection(bool value) {flag(0,1<<3,value);}
156  bool allow_save() const {return flag(0, 1<<4);}
165  void allow_save(bool value) {flag(0,1<<4,value);}
171  bool allow_load() const {return flag(0, 1<<5);}
177  void allow_load(bool value) {flag(0,1<<5,value);}
183  bool clipboard() const {return flag(0, 1<<6);}
189  void clipboard(bool value) {flag(0,1<<6,value);}
196  bool auto_scroll() const {return flag(0, 1<<7);}
203  void auto_scroll(bool value) {flag(0,1<<7,value);}
204 
210  int type() const {return int_value(36);}
211  //TODO: Find out what this actually is
217  void type(int value) {int_value(36,value);}
223  int event() const {return int_value(40);}
229  void event(int value) {int_value(40,value);}
235  const char *text() const {return message(44);}
241  void text(const char *value) {message(44, value);}
247  void text(const std::string &value) {message(44, value);}
253  int foreground() const {return int_value(48);}
259  void foreground(int value) {int_value(48,value);}
265  int background() const {return int_value(52);}
271  void background(int value) {int_value(52,value);}
272 
273 };
274 
275 }
276 }
277 
278 #endif // TBX_RES_RESTEXTAREA_H
279 
void type(int value)
Set the type of the text area gadget.
Definition: restextarea.h:217
void background(int value)
Set background colour for the text area.
Definition: restextarea.h:271
Base class for gadget memory resources.
Definition: resgadget.h:42
void event(int value)
Set the event for the text area gadget.
Definition: restextarea.h:229
ResTextArea()
Construct a text area gadget resource.
Definition: restextarea.h:93
void allow_selection(bool value)
Set if text can be selected by the mouse.
Definition: restextarea.h:147
void has_vertical_scrollbar(bool value)
Set if text area has a vertical scroll bar.
Definition: restextarea.h:111
bool auto_scroll() const
Check if the text field will automatically scroll as text is entered.
Definition: restextarea.h:196
bool clipboard() const
Check if clipboard support is enabled.
Definition: restextarea.h:183
ResTextArea & operator=(const ResTextArea &other)
Assign from another text area gadget resource.
Definition: restextarea.h:82
void allow_save(bool value)
Set if text can be saved.
Definition: restextarea.h:165
void auto_scroll(bool value)
Set if the text field will automatically scroll as text is entered.
Definition: restextarea.h:203
bool allow_selection() const
Check if text can be selected by the mouse.
Definition: restextarea.h:141
int foreground() const
Get foreground/text colour for the text area.
Definition: restextarea.h:253
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
bool has_vertical_scrollbar() const
Check if text area has a vertical scroll bar.
Definition: restextarea.h:105
void text(const std::string &value)
Set the initial text for the text area.
Definition: restextarea.h:247
void foreground(int value)
Set foreground/text colour for the text area.
Definition: restextarea.h:259
int type() const
Get the type of the text area gadget.
Definition: restextarea.h:210
Class for TextArea gadget template.
Definition: restextarea.h:36
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
void has_horizontal_scrollbar(bool value)
Set if text area has a horizontal scroll bar.
Definition: restextarea.h:123
bool has_horizontal_scrollbar() const
Check if text area has a horizontal scroll bar.
Definition: restextarea.h:117
void text(const char *value)
Set the initial text for the text area.
Definition: restextarea.h:241
void clipboard(bool value)
Set if clipboard support is enabled.
Definition: restextarea.h:189
void wordwrap(bool value)
Set if text will be word wrapped.
Definition: restextarea.h:135
bool allow_load() const
Check if text can be loaded by dragging it to the text area.
Definition: restextarea.h:171
bool allow_save() const
Check if text can be saved.
Definition: restextarea.h:156
ResTextArea(const ResTextArea &other)
Construct an text area gadget resource.
Definition: restextarea.h:58
bool wordwrap() const
Check if text will be word wrapped.
Definition: restextarea.h:129
int background() const
Get background colour for the text area.
Definition: restextarea.h:265
ResTextArea(const ResGadget &other)
Construct an text area gadget resource.
Definition: restextarea.h:48
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
int event() const
Get the event for the text area gadget.
Definition: restextarea.h:223
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
ResTextArea & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: restextarea.h:70
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
const char * text() const
Get the initial text for the text area.
Definition: restextarea.h:235
void allow_load(bool value)
Set if text can be loaded by dragging it to the text area.
Definition: restextarea.h:177
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736