tbx  0.7.5
quit.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  * quit.h
27  *
28  * Created on: 09-Jun-2009
29  * Author: alanb
30  */
31 
32 #ifndef TBX_QUIT_H_
33 #define TBX_QUIT_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 QuitQuitListener;
46 class QuitCancelListener;
47 
48 namespace res
49 {
50  class ResQuit;
51 }
52 
60 class Quit : public tbx::ShowFullObject
61 {
62 public:
63  enum { TOOLBOX_CLASS = 0x82a90 };
64 
70  Quit() {};
79  Quit(const Quit &other) : ShowFullObject(other._handle) {}
90  Quit(const Object &other) : ShowFullObject(other) {check_toolbox_class(Quit::TOOLBOX_CLASS);}
98  Quit(const std::string &template_name) : ShowFullObject(template_name) {check_toolbox_class(Quit::TOOLBOX_CLASS);}
105  Quit(const res::ResQuit &object_template);
106 
115  Quit &operator=(const Quit &other) {_handle = other.handle(); return *this;}
127  Quit &operator=(const Object &other) {_handle = other.handle(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
135  bool operator==(const Object &other) const {return (_handle == other.handle());}
143  bool operator!=(const Object &other) const {return (_handle != other.handle());}
144 
145 
146  // Properties
150  Window window() const {return Window((ObjectId)int_property(0));}
151 
155  void message(std::string msg) {string_property(1, msg);}
156 
160  std::string message() const {return string_property(2);}
164  int message_length() const {return string_property_length(2);}
165 
169  void title(std::string msg) {string_property(3, msg);}
170 
174  std::string title() const {return string_property(4);}
178  int title_length() const {return string_property_length(4);}
179 
180  // Listeners
181  void add_about_to_be_shown_listener(AboutToBeShownListener *listener);
182  void remove_about_to_be_shown_listener(AboutToBeShownListener *listener);
183  void add_has_been_hidden_listener(HasBeenHiddenListener *listener);
184  void remove_has_been_hidden_listener(HasBeenHiddenListener *listener);
185  void add_quit_listener(QuitQuitListener *listener);
186  void remove_quit_listener(QuitQuitListener *listener);
187  void add_cancel_listener(QuitCancelListener *listener);
188  void remove_cancel_listener(QuitCancelListener *listener);
189 };
190 
195 {
196 public:
200  virtual void quit_quit(const EventInfo &quit_event) = 0;
201 };
202 
207 {
208 public:
212  virtual void quit_cancel(const EventInfo &cancel_event) = 0;
213 };
214 
215 
216 }
217 
218 #endif /* TBX_QUIT_H_ */
Quit(const Quit &other)
Construct a Quit from another Quit.
Definition: quit.h:79
void message(std::string msg)
Set message to display in window.
Definition: quit.h:155
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
Listener for when a Quit is selected from the Quit dialog.
Definition: quit.h:194
Quit()
Construct creates an unassigned Quit.
Definition: quit.h:70
Listener for when a cancel is selected from the Quit dialog.
Definition: quit.h:206
Quit(const Object &other)
Construct a Quit from an Object that refers to a Quit.
Definition: quit.h:90
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:76
bool operator==(const Object &other) const
Check if this Quit refers to the same underlying toolbox object as another.
Definition: quit.h:135
int message_length() const
Return length of message.
Definition: quit.h:164
Classes to use/edit toolbox resources in memory.
Quit & operator=(const Object &other)
Assign this Quit from an Object that refers to a Quit.
Definition: quit.h:127
std::string message() const
Return message.
Definition: quit.h:160
Window window() const
Return the underlying toolbox window used to implement the Quit object.
Definition: quit.h:150
void title(std::string msg)
Set title of window.
Definition: quit.h:169
Quit(const std::string &template_name)
Create a Quit from the named template.
Definition: quit.h:98
std::string title() const
Return title.
Definition: quit.h:174
unsigned int ObjectId
Type for underlying toolbox object id.
Definition: handles.h:31
Class for Quit object template.
Definition: resquit.h:36
The Window object represents a toolbox window.
Definition: window.h:69
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
Base class for all toolbox event listeners.
Definition: listener.h:33
Quit & operator=(const Quit &other)
Assign this Quit from another.
Definition: quit.h:115
Class to show a toolbox Quit object that gives the user an option to Quit or Cancel the application...
Definition: quit.h:60
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
int title_length() const
Return length of title.
Definition: quit.h:178
Objects derived from this class can be shown with there full location and size specified as well as t...
Definition: showfullobject.h:40
bool operator!=(const Object &other) const
Check if this Quit does not refers to the same underlying toolbox object as another.
Definition: quit.h:143
Class to manipulate a toolbox object.
Definition: object.h:50
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93