tbx  0.7.3
ressaveas.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_RESSAVEAS_H
26 #define TBX_RES_RESSAVEAS_H
27 
28 #include "resobject.h"
29 
30 namespace tbx {
31 namespace res {
32 
36 class ResSaveAs : public ResObject
37 {
38 
39 public:
40  enum {CLASS_ID = 0x82bc0 };
41 
48  ResSaveAs(const ResObject &other) : ResObject(other)
49  {
50  check_class_id(CLASS_ID);
51  }
52 
58  ResSaveAs(const ResSaveAs &other) : ResObject(other)
59  {
60  }
61 
62  virtual ~ResSaveAs() {}
63 
70  ResSaveAs &operator=(const ResObject &other)
71  {
72  other.check_class_id(CLASS_ID);
73  ResBase::operator=(other);
74  return *this;
75  }
76 
82  ResSaveAs &operator=(const ResSaveAs &other)
83  {
84  ResBase::operator=(other);
85  return *this;
86  }
87 
95  ResSaveAs(std::string name)
96  : ResObject(name, CLASS_ID, 100, 36 + 24)
97  {
98  flags(12); // use buffer and no selection
99  init_message(12,0); // title
100  init_message(4, "Untitled"); // file name
101  init_string(20,0); // window
102  }
103 
110  unsigned int flags() const {return uint_value(0);}
111 
118  void flags(unsigned int value) {uint_value(0, value);}
124  bool generate_about_to_be_shown() const {return flag(0, 1<<0);}
130  void generate_about_to_be_shown(bool value) {flag(0,1<<0,value);}
136  bool generate_dialogue_completed() const {return flag(0, 1<<1);}
142  void generate_dialogue_completed(bool value) {flag(0,1<<1,value);}
143 
149  bool no_selection() const {return flag(0, 1<<2);}
155  void no_selection(bool value) {flag(0,1<<2,value);}
161  bool use_buffer() const {return flag(0, 1<<3);}
167  void use_buffer(bool value) {flag(0,1<<3,value);}
173  bool ram_transfer() const {return flag(0, 1<<4);}
179  void ram_transfer(bool value) {flag(0,1<<4,value);}
180 
186  const char *file_name() const {return message(4);}
192  void file_name(const char *value) {message(4, value);}
198  void file_name(const std::string &value) {message(4, value);}
204  int file_type() const {return int_value(8);}
210  void file_type(int value) {int_value(8,value);}
216  const char *title() const {return message(12);}
224  void title(const char *value, int max_length = -1) {message_with_length(12, value, max_length);}
232  void title(const std::string &value, int max_length = -1) {message_with_length(12, value, max_length);}
236  int max_title() const {return int_value(16);}
243  const char *window() const {return string(20);}
250  void window(const char *value) {string(20, value);}
257  void window(const std::string &value) {string(20, value);}
258 
259 };
260 
261 }
262 }
263 
264 #endif // TBX_RES_RESSAVEAS_H
int file_type() const
Get the file type for the dialogue.
Definition: ressaveas.h:204
bool use_buffer() const
Check if the save as will use a single provided buffer.
Definition: ressaveas.h:161
bool ram_transfer() const
Check if save will use the RAM transfer protocol.
Definition: ressaveas.h:173
void file_type(int value)
Set the file type for the dialogue.
Definition: ressaveas.h:210
unsigned int flags() const
Get all flags as a word raw access.
Definition: ressaveas.h:110
void init_string(int offset, const char *value)
Initialise a string in a constructor helper.
Definition: resbase.cc:1725
const char * file_name() const
Get the initial file name for the dialogue.
Definition: ressaveas.h:186
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
ResSaveAs(const ResSaveAs &other)
Construct a save as resource by copying another.
Definition: ressaveas.h:58
ResSaveAs(const ResObject &other)
Construct a save as resource from a ResObject.
Definition: ressaveas.h:48
void file_name(const char *value)
Set the initial file name for the dialogue.
Definition: ressaveas.h:192
void ram_transfer(bool value)
Set if save will use the RAM transfer protocol.
Definition: ressaveas.h:179
void title(const char *value, int max_length=-1)
Set the title of the dialogue.
Definition: ressaveas.h:224
ResSaveAs(std::string name)
Construct a save as resource.
Definition: ressaveas.h:95
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
void file_name(const std::string &value)
Set the initial file name for the dialogue.
Definition: ressaveas.h:198
const char * string(int offset) const
Return a string at the given offset.
Definition: resbase.cc:1555
void no_selection(bool value)
Set if the selection option is omitted from the dialogue.
Definition: ressaveas.h:155
ResSaveAs & operator=(const ResObject &other)
Assign from a ResObject.
Definition: ressaveas.h:70
void window(const char *value)
Set the name of the window template that provides the window for this object.
Definition: ressaveas.h:250
unsigned int uint_value(int offset) const
Get an unsigned integer value.
Definition: resbase.h:324
void generate_about_to_be_shown(bool value)
Set if the about to be shown event should be generated.
Definition: ressaveas.h:130
bool generate_about_to_be_shown() const
Check if the about to be shown event should be generated.
Definition: ressaveas.h:124
void title(const std::string &value, int max_length=-1)
Set the title of the dialogue.
Definition: ressaveas.h:232
const char * window() const
Get the name of the window template that provides the window for this object.
Definition: ressaveas.h:243
void flags(unsigned int value)
Set all flags as a word.
Definition: ressaveas.h:118
void window(const std::string &value)
Set the name of the window template that provides the window for this object.
Definition: ressaveas.h:257
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
Class for SaveAs object template.
Definition: ressaveas.h:36
Base class for a resource object that can be edited.
Definition: resobject.h:52
void generate_dialogue_completed(bool value)
Set if the dialogue completed event should be generated.
Definition: ressaveas.h:142
bool generate_dialogue_completed() const
Check if the dialogue completed event should be generated.
Definition: ressaveas.h:136
const char * title() const
Get the title of the dialogue.
Definition: ressaveas.h:216
bool no_selection() const
Check if the selection option is omitted from the dialogue.
Definition: ressaveas.h:149
void use_buffer(bool value)
Set if the save as will use a single provided buffer.
Definition: ressaveas.h:167
ResSaveAs & operator=(const ResSaveAs &other)
Assign from another save as resource.
Definition: ressaveas.h:82
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
const char * name() const
Return pointer to name of object.
Definition: resobject.h:79
int max_title() const
Get the maximum size the title can be.
Definition: ressaveas.h:236
void check_class_id(int class_id) const
Check if this objects class id is as specified.
Definition: resobject.cc:383
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736