tbx  0.7.6
resdisplayfield.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_RESDISPLAYFIELD_H
26 #define TBX_RES_RESDISPLAYFIELD_H
27 
28 #include "resgadget.h"
29 #include "resjustification.h"
30 
31 namespace tbx {
32 namespace res {
33 
37 class ResDisplayField : public ResGadget
38 {
39 
40 public:
41  enum {TYPE_ID = 448 };
42 
49  ResDisplayField(const ResGadget &other) : ResGadget(other)
50  {
51  check_type(TYPE_ID);
52  }
53 
59  ResDisplayField(const ResDisplayField &other) : ResGadget(other)
60  {
61  }
62 
63  virtual ~ResDisplayField() {}
64 
72  {
73  other.check_type(TYPE_ID);
74  ResBase::operator=(other);
75  return *this;
76  }
77 
84  {
85  ResBase::operator=(other);
86  return *this;
87  }
88 
95  : ResGadget(448,44)
96  {
97  init_message(36,0); // text
98  }
99 
111  void justification(ResJustification value) {flag_value(0,6, (int)value << 1);}
112 
118  const char *text() const {return message(36);}
126  void text(const char *value, int max_length = -1) {message_with_length(36, value, max_length);}
134  void text(const std::string &value, int max_length = -1) {message_with_length(36, value, max_length);}
140  int max_text_len() const {return int_value(40);}
141 };
142 
143 }
144 }
145 
146 #endif // TBX_RES_RESDISPLAYFIELD_H
147 
tbx::res::ResDisplayField::text
void text(const std::string &value, int max_length=-1)
Set the initial text for the display field.
Definition: resdisplayfield.h:134
tbx::res::ResBase::message_with_length
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
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::ResDisplayField::max_text_len
int max_text_len() const
Get the maximum length for the text.
Definition: resdisplayfield.h:140
tbx::res::ResGadget
Base class for gadget memory resources.
Definition: resgadget.h:43
tbx::res::ResBase::int_value
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
tbx::res::ResDisplayField::ResDisplayField
ResDisplayField(const ResGadget &other)
Construct an display field gadget resource.
Definition: resdisplayfield.h:49
tbx::res::ResDisplayField::text
void text(const char *value, int max_length=-1)
Set the initial text for the display field.
Definition: resdisplayfield.h:126
tbx::res::ResDisplayField::ResDisplayField
ResDisplayField()
Construct a display field gadget resource.
Definition: resdisplayfield.h:94
tbx::res::ResDisplayField::ResDisplayField
ResDisplayField(const ResDisplayField &other)
Construct an display field gadget resource.
Definition: resdisplayfield.h:59
tbx::res::ResDisplayField::text
const char * text() const
Get the initial text for the display field.
Definition: resdisplayfield.h:118
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::ResDisplayField
Class for DisplayField gadget template.
Definition: resdisplayfield.h:38
tbx::res::ResDisplayField::operator=
ResDisplayField & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: resdisplayfield.h:71
tbx::res::ResJustification
ResJustification
Standard justification of resource gadget flags.
Definition: resjustification.h:11
tbx::res::ResDisplayField::operator=
ResDisplayField & operator=(const ResDisplayField &other)
Assign from another display field gadget resource.
Definition: resdisplayfield.h:83
tbx::res::ResDisplayField::justification
ResJustification justification() const
Get the justification for the display field.
Definition: resdisplayfield.h:105
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::ResDisplayField::justification
void justification(ResJustification value)
Set the justification for the display field.
Definition: resdisplayfield.h:111
tbx::res::ResBase::message
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602