tbx  0.7.6
dcs.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 /*
26  * dcs.h
27  *
28  * Created on: 05-Jun-2009
29  * Author: alanb
30  */
31 
32 #ifndef TBX_DCS_H_
33 #define TBX_DCS_H_
34 
35 #include "showfullobject.h"
36 #include "listener.h"
37 #include "eventinfo.h"
38 #include "window.h"
39 
40 namespace tbx {
41 
42 // Listeners
43 class AboutToBeShownListener;
44 class HasBeenHiddenListener;
45 class DCSDiscardListener;
46 class DCSSaveListener;
47 class DCSCancelListener;
48 
49 namespace res
50 {
51  class ResDCS;
52 }
53 
62 class DCS : public tbx::ShowFullObject
63 {
64 public:
65  enum { TOOLBOX_CLASS = 0x82a80 };
66 
72  DCS() {};
81  DCS(const DCS &other) : ShowFullObject(other._handle) {}
92  DCS(const Object &other) : ShowFullObject(other) {check_toolbox_class(DCS::TOOLBOX_CLASS);}
100  DCS(const std::string &template_name) : ShowFullObject(template_name) {check_toolbox_class(DCS::TOOLBOX_CLASS);}
107  DCS(const res::ResDCS &object_template);
108 
117  DCS &operator=(const DCS &other) {_handle = other.handle(); return *this;}
129  DCS &operator=(const Object &other) {_handle = other.handle(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
137  bool operator==(const Object &other) const {return (_handle == other.handle());}
145  bool operator!=(const Object &other) const {return (_handle != other.handle());}
146 
147 
148  // Properties
152  Window window() const {return Window((ObjectId)int_property(0));}
153 
157  void message(std::string msg) {string_property(1, msg);}
158 
162  std::string message() const {return string_property(2);}
166  int message_length() const {return string_property_length(2);}
167 
171  void title(std::string msg) {string_property(3, msg);}
172 
176  std::string title() const {return string_property(4);}
180  int title_length() const {return string_property_length(4);}
181 
182  // Listeners
189  void add_save_listener(DCSSaveListener *listener);
190  void remove_save_listener(DCSSaveListener *listener);
191  void add_cancel_listener(DCSCancelListener *listener);
193 };
194 
199 {
200 public:
204  virtual void dcs_discard(const EventInfo &discard_event) = 0;
205 };
206 
210 class DCSSaveListener : public Listener
211 {
212 public:
216  virtual void dcs_save(const EventInfo &save_event) = 0;
217 };
218 
223 {
224 public:
228  virtual void dcs_cancel(const EventInfo &cancel_event) = 0;
229 };
230 
231 
232 }
233 
234 #endif /* TBX_DCS_H_ */
tbx::Object::int_property
int int_property(int property_id) const
Return the value of a property that returns an integer.
Definition: object.cc:477
tbx::DCS::remove_about_to_be_shown_listener
void remove_about_to_be_shown_listener(AboutToBeShownListener *listener)
Remove about to be shown listener.
Definition: dcs.cc:57
tbx::DCS::title_length
int title_length() const
Return length of title.
Definition: dcs.h:180
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::DCS::add_save_listener
void add_save_listener(DCSSaveListener *listener)
Add listener to be called when save is selected from the dialogue.
Definition: dcs.cc:123
tbx::DCS::add_about_to_be_shown_listener
void add_about_to_be_shown_listener(AboutToBeShownListener *listener)
This event is raised just before the DCS underlying window is about to be shown.
Definition: dcs.cc:47
tbx::DCS::operator=
DCS & operator=(const DCS &other)
Assign this DCS from another.
Definition: dcs.h:117
tbx::Object::handle
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93
tbx::DCS::remove_discard_listener
void remove_discard_listener(DCSDiscardListener *listener)
Remove listener to be called when discard is selected from the dialogue.
Definition: dcs.cc:105
tbx::Object::_handle
ObjectId _handle
Handle for toolbox object.
Definition: object.h:175
tbx::DCS::title
void title(std::string msg)
Set title of window.
Definition: dcs.h:171
tbx::Object::string_property
std::string string_property(int property_id) const
Return the value of a property that returns text.
Definition: object.cc:519
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::DCSCancelListener::dcs_cancel
virtual void dcs_cancel(const EventInfo &cancel_event)=0
Called when cancel is selected from a DCS dialog.
tbx::res::ResDCS
Class for DCS object template.
Definition: resdcs.h:37
tbx::DCS::operator==
bool operator==(const Object &other) const
Check if this DCS refers to the same underlying toolbox object as another.
Definition: dcs.h:137
tbx::HasBeenHiddenListener
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
tbx::DCS::window
Window window() const
Return the underlying toolbox window used to implement the DCS object.
Definition: dcs.h:152
tbx::DCS::add_has_been_hidden_listener
void add_has_been_hidden_listener(HasBeenHiddenListener *listener)
This event is raised after the DCS dialog has been completed.
Definition: dcs.cc:67
tbx::DCS::message_length
int message_length() const
Return length of message.
Definition: dcs.h:166
tbx::DCS::DCS
DCS(const std::string &template_name)
Create a DCS from the named template.
Definition: dcs.h:100
tbx::Object::string_property_length
int string_property_length(int property_id) const
Gets the size of a string properties buffer.
Definition: object.cc:572
tbx::DCS::remove_cancel_listener
void remove_cancel_listener(DCSCancelListener *listener)
Remove listener to be called when cancel is selected from the dialogue.
Definition: dcs.cc:161
tbx::DCS::operator!=
bool operator!=(const Object &other) const
Check if this DCS does not refers to the same underlying toolbox object as another.
Definition: dcs.h:145
tbx::Object::check_toolbox_class
void check_toolbox_class(int class_id) const
Check if this objects toolbox class is as specified.
Definition: object.cc:122
tbx::DCSDiscardListener::dcs_discard
virtual void dcs_discard(const EventInfo &discard_event)=0
Called when discard is selected from a DCS dialog.
tbx::DCSCancelListener
Listener for when a cancel is selected from the DCS dialog.
Definition: dcs.h:223
tbx::DCS::remove_has_been_hidden_listener
void remove_has_been_hidden_listener(HasBeenHiddenListener *listener)
Remove has been hidden listener.
Definition: dcs.cc:77
tbx::AboutToBeShownListener
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:77
tbx::DCS::message
void message(std::string msg)
Set message to display in window.
Definition: dcs.h:157
tbx::DCS
Class to show a toolbox DCS object that gives the user an option to Discard, Cancel or Save a file.
Definition: dcs.h:63
tbx::Object
Class to manipulate a toolbox object.
Definition: object.h:51
tbx::DCS::DCS
DCS()
Construct creates an unassigned DCS.
Definition: dcs.h:72
tbx::Listener
Base class for all toolbox event listeners.
Definition: listener.h:34
tbx::DCSSaveListener
Listener for when a save is selected from the DCS dialog.
Definition: dcs.h:211
tbx::DCS::message
std::string message() const
Return message.
Definition: dcs.h:162
tbx::ShowFullObject
Objects derived from this class can be shown with there full location and size specified as well as t...
Definition: showfullobject.h:41
tbx::DCSDiscardListener
Listener for when a discard is selected from the DCS dialog.
Definition: dcs.h:199
tbx::DCS::operator=
DCS & operator=(const Object &other)
Assign this DCS from an Object that refers to a DCS.
Definition: dcs.h:129
tbx::DCS::add_cancel_listener
void add_cancel_listener(DCSCancelListener *listener)
Add listener to be called when cancel is selected from the dialogue.
Definition: dcs.cc:151
tbx::ObjectId
unsigned int ObjectId
Type for underlying toolbox object id.
Definition: handles.h:31
tbx::DCS::title
std::string title() const
Return title.
Definition: dcs.h:176
tbx::DCS::DCS
DCS(const DCS &other)
Construct a DCS from another DCS.
Definition: dcs.h:81
tbx::DCSSaveListener::dcs_save
virtual void dcs_save(const EventInfo &save_event)=0
Called when save is selected from a DCS dialog.
tbx::DCS::remove_save_listener
void remove_save_listener(DCSSaveListener *listener)
Remove listener to be called when save is selected from the dialogue.
Definition: dcs.cc:133
tbx::DCS::DCS
DCS(const Object &other)
Construct a DCS from an Object that refers to a DCS.
Definition: dcs.h:92
tbx::EventInfo
Class to provide information on a toolbox event.
Definition: eventinfo.h:49
tbx::DCS::add_discard_listener
void add_discard_listener(DCSDiscardListener *listener)
Add listener to be called when discard is selected from the dialogue.
Definition: dcs.cc:95