tbx  0.7.3
reslabelledbox.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_RESLABELLEDBOX_H
26 #define TBX_RES_RESLABELLEDBOX_H
27 
28 #include "resgadget.h"
29 
30 namespace tbx {
31 namespace res {
32 
36 class ResLabelledBox : public ResGadget
37 {
38 
39 public:
40  enum {TYPE_ID = 256 };
41 
48  ResLabelledBox(const ResGadget &other) : ResGadget(other)
49  {
50  check_type(TYPE_ID);
51  }
52 
58  ResLabelledBox(const ResLabelledBox &other) : ResGadget(other)
59  {
60  }
61 
62  virtual ~ResLabelledBox() {}
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(256,40)
95  {
96  back(true);
97  init_message(36,0); // label
98  }
99 
105  const char *label() const {return message(36);}
111  void label(const char *value) {message(36, value);}
117  void label(const std::string &value) {message(36, value);}
118 
119 };
120 
121 }
122 }
123 
124 #endif // TBX_RES_RESLABELLEDBOX_H
125 
Base class for gadget memory resources.
Definition: resgadget.h:42
void label(const char *value)
Set the text displayed in the labelled box.
Definition: reslabelledbox.h:111
bool back() const
Check if gadget is at the back (created first)
Definition: resgadget.h:119
ResLabelledBox()
Construct a labelled box gadget resource.
Definition: reslabelledbox.h:93
ResLabelledBox & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: reslabelledbox.h:70
ResLabelledBox & operator=(const ResLabelledBox &other)
Assign from another labelled box gadget resource.
Definition: reslabelledbox.h:82
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
ResLabelledBox(const ResLabelledBox &other)
Construct an labelled box gadget resource.
Definition: reslabelledbox.h:58
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
ResLabelledBox(const ResGadget &other)
Construct an labelled box gadget resource.
Definition: reslabelledbox.h:48
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
Class for LabelledBox gadget template.
Definition: reslabelledbox.h:36
void label(const std::string &value)
Set the text displayed in the labelled box.
Definition: reslabelledbox.h:117
const char * label() const
Get the text displayed in the labelled box.
Definition: reslabelledbox.h:105
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736