tbx  0.7.6
reslabel.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_RESLABEL_H
26 #define TBX_RES_RESLABEL_H
27 
28 #include "resgadget.h"
29 #include "resjustification.h"
30 
31 namespace tbx {
32 namespace res {
33 
37 class ResLabel : public ResGadget
38 {
39 
40 public:
41  enum {TYPE_ID = 320 };
42 
49  ResLabel(const ResGadget &other) : ResGadget(other)
50  {
51  check_type(TYPE_ID);
52  }
53 
59  ResLabel(const ResLabel &other) : ResGadget(other)
60  {
61  }
62 
63  virtual ~ResLabel() {}
64 
71  ResLabel &operator=(const ResGadget &other)
72  {
73  other.check_type(TYPE_ID);
74  ResBase::operator=(other);
75  return *this;
76  }
77 
83  ResLabel &operator=(const ResLabel &other)
84  {
85  ResBase::operator=(other);
86  return *this;
87  }
88 
95  : ResGadget(320,40)
96  {
97  init_message(36,0); // label
98  }
99 
105  bool omit_bounding_box() const {return flag(0, 1<<0);}
111  void omit_bounding_box(bool value) {flag(0,1<<0,value);}
112 
124  void justification(ResJustification value) {flag_value(0, 6, (int)value<<1);}
125 
131  const char *label() const {return message(36);}
137  void label(const char *value) {message(36, value);}
143  void label(const std::string &value) {message(36, value);}
144 };
145 
146 }
147 }
148 
149 #endif // TBX_RES_RESLABEL_H
150 
tbx::res::ResLabel::justification
void justification(ResJustification value)
Set the horizontal position of the text of the label in its bounding box.
Definition: reslabel.h:124
tbx::res::ResLabel::label
const char * label() const
Get the label text.
Definition: reslabel.h:131
tbx::res::ResLabel::ResLabel
ResLabel(const ResLabel &other)
Construct an label gadget resource.
Definition: reslabel.h:59
tbx::res::ResBase::operator=
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::res::ResGadget
Base class for gadget memory resources.
Definition: resgadget.h:43
tbx::res::ResLabel
Class for Label gadget template.
Definition: reslabel.h:38
tbx::res::ResLabel::label
void label(const std::string &value)
Set the label text.
Definition: reslabel.h:143
tbx::res::ResLabel::operator=
ResLabel & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: reslabel.h:71
tbx::res::ResLabel::operator=
ResLabel & operator=(const ResLabel &other)
Assign from another label gadget resource.
Definition: reslabel.h:83
tbx::res::ResBase::init_message
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736
tbx::res::ResBase::flag_value
int flag_value(int offset, int mask) const
Get the bits for the given mask.
Definition: resbase.h:362
tbx::res::ResBase::flag
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
tbx::res::ResLabel::justification
ResJustification justification() const
Get the horizontal position of the text of the label in its bounding box.
Definition: reslabel.h:118
tbx::res::ResLabel::omit_bounding_box
void omit_bounding_box(bool value)
Set if the bounding box for the label should be omitted.
Definition: reslabel.h:111
tbx::res::ResJustification
ResJustification
Standard justification of resource gadget flags.
Definition: resjustification.h:11
tbx::res::ResLabel::label
void label(const char *value)
Set the label text.
Definition: reslabel.h:137
tbx::res::ResLabel::ResLabel
ResLabel()
Construct a label gadget resource.
Definition: reslabel.h:94
tbx::res::ResLabel::ResLabel
ResLabel(const ResGadget &other)
Construct an label gadget resource.
Definition: reslabel.h:49
tbx::res::ResGadget::check_type
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
tbx::res::ResLabel::omit_bounding_box
bool omit_bounding_box() const
Check if the bounding box for the label should be omitted.
Definition: reslabel.h:105
tbx::res::ResBase::message
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602