tbx  0.7.3
printdbox.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  * printdbox.h
27  *
28  * Created on: 01-Jul-2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_PRINTDBOX_H_
33 #define TBX_PRINTDBOX_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 PrintDboxSetupAboutToBeShownListener;
46 class PrintDboxSetupListener;
47 class PrintDboxPrintListener;
48 class PrintDboxSaveListener;
49 
50 namespace res
51 {
52  class ResPrintDbox;
53 }
54 
61 {
62 public:
63  enum { TOOLBOX_CLASS = 0x82b00 };
64 
70  PrintDbox() {};
79  PrintDbox(const PrintDbox &other) : ShowFullObject(other._handle) {}
90  PrintDbox(const Object &other) : ShowFullObject(other) {check_toolbox_class(PrintDbox::TOOLBOX_CLASS);}
98  PrintDbox(const std::string &template_name) : ShowFullObject(template_name) {check_toolbox_class(PrintDbox::TOOLBOX_CLASS);}
105  PrintDbox(const res::ResPrintDbox &object_template);
106 
115  PrintDbox &operator=(const PrintDbox &other) {_handle = other.handle(); return *this;}
127  PrintDbox &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 
158  void page_range(int start, int end);
159 
163  void all_pages();
164 
173  void page_range(int *start, int *end) const;
174 
178  void copies(int number) {int_property(3, number);}
179 
183  int copies() const {return int_property(4);}
184 
188  void scale(int pc) {int_property(5, pc);}
189 
193  int scale() const {return int_property(6);}
194 
199  void sideways(bool value) {bool_property(7, value);}
200 
204  bool sideways() const {return bool_property(8);}
205 
209  std::string title() const {return string_property(9);}
210 
214  int title_length() const {return string_property_length(9);}
215 
220  void draft(bool value) {bool_property(10, value);}
221 
225  bool draft() const {return bool_property(11);}
226 
227  // Listeners
240 };
241 
246 {
247 public:
255  EventInfo(id_block, data)
256  {
257  }
258 
263 
267  enum ShowType
268  {
271  SHOW_TOP_LEFT = 2 //<! Shown with top left corner as specified point
272  };
273 
279  ShowType show_type() const {return ShowType(_data.word[5]);}
280 
286  Point &top_left() const {return reinterpret_cast<Point &>(_data.word[6]);}
287 
294  Point &top_left() {return reinterpret_cast<Point &>(_data.word[6]);}
295 
302  ShowFullSpec &full_spec() {return reinterpret_cast<ShowFullSpec &>(_data.word[6]);}
303 };
304 
309 {
310 public:
312 
319 };
320 
325 {
326 public:
334  EventInfo(id_block, data) {}
335 
339  bool sideways() const {return ((_data.word[3] & 1) != 0);}
340 
344  int start() const {return _data.word[4];}
345 
349  int end() const {return _data.word[5];}
350 
354  int copies() const {return _data.word[6];}
355 
359  int scale() const {return _data.word[7];}
360 };
361 
366 
371 {
372 public:
373  virtual ~PrintDboxPrintListener() {}
374 
380  virtual void printdbox_print(const PrintDboxPrintEvent &event) = 0;
381 };
382 
387 {
388 public:
389  virtual ~PrintDboxSaveListener() {}
390 
396  virtual void printdbox_save(const PrintDboxPrintEvent &event) = 0;
397 };
398 
403 {
404 public:
405  virtual ~PrintDboxSetupListener() {}
406 
412  virtual void printdbox_setup(const EventInfo &setup_event) = 0;
413 }
414 ;
415 }
416 
417 #endif /* TBX_PRINTDBOX_H_ */
bool operator==(const Object &other) const
Check if this PrintDbox refers to the same underlying toolbox object as another.
Definition: printdbox.h:135
ObjectId _handle
Handle for toolbox object.
Definition: object.h:173
int copies() const
Number of copies.
Definition: printdbox.h:354
void copies(int number)
Set number of copies.
Definition: printdbox.h:178
void sideways(bool value)
Set orientation sideways.
Definition: printdbox.h:199
void remove_has_been_hidden_listener(HasBeenHiddenListener *listener)
Remove has been hidden listener.
Definition: printdbox.cc:97
bool sideways() const
true if orientation was set to sideway, false for upright
Definition: printdbox.h:339
int start() const
Start page or -1 for all.
Definition: printdbox.h:344
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:76
void check_toolbox_class(int class_id) const
Check if this objects toolbox class is as specified.
Definition: object.cc:122
int scale() const
Get percentage to scale by.
Definition: printdbox.h:193
PollBlock & _data
raw data from the event
Definition: eventinfo.h:53
Point & top_left()
Get reference to top left coordinate so it can be changed in the event.
Definition: printdbox.h:294
bool sideways() const
Get orientation sideways.
Definition: printdbox.h:204
void remove_print_listener(PrintDboxPrintListener *listener)
Remove listener for when print is selected on the print dialogue.
Definition: printdbox.cc:167
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:71
virtual void printdbox_setup_about_to_be_shown(const PrintDboxSetupAboutToBeShownEvent &ev)=0
Method called by the listener when the setup dialog is about to be shown.
int string_property_length(int property_id) const
Gets the size of a string properties buffer.
Definition: object.cc:530
int copies() const
Get number of copies.
Definition: printdbox.h:183
bool draft() const
Get draft mode.
Definition: printdbox.h:225
void add_save_listener(PrintDboxSaveListener *listener)
Add listener for save button on print dialogue.
Definition: printdbox.cc:182
Structure used to specify exact position and size for an object derived from tbx::ShowFullObject.
Definition: showfullspec.h:45
Listener for Setup presses when there is not dialogue associated with the button. ...
Definition: printdbox.h:402
void remove_save_listener(PrintDboxSaveListener *listener)
Remove listener for save button on print dialogue.
Definition: printdbox.cc:190
void page_range(int start, int end)
Set range of pages.
Definition: printdbox.cc:45
std::string title() const
Return title.
Definition: printdbox.h:209
Window window() const
Return the underlying toolbox window used to implement the PrintDbox object.
Definition: printdbox.h:150
PrintDbox & operator=(const Object &other)
Assign this PrintDbox from an Object that refers to a PrintDbox.
Definition: printdbox.h:127
bool operator!=(const Object &other) const
Check if this PrintDbox does not refers to the same underlying toolbox object as another.
Definition: printdbox.h:143
void remove_about_to_be_shown_listener(AboutToBeShownListener *listener)
Remove about to be shown listener.
Definition: printdbox.cc:81
PrintDbox(const Object &other)
Construct a PrintDbox from an Object that refers to a PrintDbox.
Definition: printdbox.h:90
void add_setup_about_to_be_shown_listener(PrintDboxSetupAboutToBeShownListener *listener)
Add listener that is called before the dialog associated with the setup button is shown...
Definition: printdbox.cc:112
void add_has_been_hidden_listener(HasBeenHiddenListener *listener)
This event is raised after the PrintDbox dialog has been completed.
Definition: printdbox.cc:89
void add_setup_listener(PrintDboxSetupListener *listener)
Add listener that is called if setup button is pressed and it has no associated window.
Definition: printdbox.cc:136
void remove_setup_about_to_be_shown_listener(PrintDboxSetupAboutToBeShownListener *listener)
Remove listener that is called before the dialog associated with the setup button is shown...
Definition: printdbox.cc:121
Class for PrintDbox object template.
Definition: resprintdbox.h:36
int int_property(int property_id) const
Return the value of a property that returns an integer.
Definition: object.cc:435
std::string string_property(int property_id) const
Return the value of a property that returns text.
Definition: object.cc:477
int scale() const
Scale percentage.
Definition: printdbox.h:359
Class to represent a position in two dimensional space.
Definition: point.h:36
bool bool_property(int property_id) const
Get a boolean property from the toolbox Cobject.
Definition: object.cc:553
unsigned int ObjectId
Type for underlying toolbox object id.
Definition: handles.h:31
PrintDbox & operator=(const PrintDbox &other)
Assign this PrintDbox from another.
Definition: printdbox.h:115
void add_print_listener(PrintDboxPrintListener *listener)
Add listener for when print is selected on the print dialogue.
Definition: printdbox.cc:159
int title_length() const
Return title length.
Definition: printdbox.h:214
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93
virtual void printdbox_setup(const EventInfo &setup_event)=0
Method called when setup is clicked if there is no dialogue.
PrintDbox(const PrintDbox &other)
Construct a PrintDbox from another PrintDbox.
Definition: printdbox.h:79
ShowType
Enumeration describing how the setup box is about to be shown.
Definition: printdbox.h:267
Point & top_left() const
Get top left coordinate of where the window will be shown.
Definition: printdbox.h:286
virtual void printdbox_print(const PrintDboxPrintEvent &event)=0
Method called when the print button is selected.
ShowFullSpec & full_spec()
Get reference to the full specification for the show so it can be modified.
Definition: printdbox.h:302
Window setup_window() const
Setup window that is about to be shown.
Definition: printdbox.h:262
virtual void printdbox_save(const PrintDboxPrintEvent &event)=0
Method called when the save button is selected.
Class to show a toolbox PrintDbox object.
Definition: printdbox.h:60
Shown in default place.
Definition: printdbox.h:269
The Window object represents a toolbox window.
Definition: window.h:69
void draft(bool value)
Set draft mode.
Definition: printdbox.h:220
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
Print button has been pressed event.
Definition: printdbox.h:324
Base class for all toolbox event listeners.
Definition: listener.h:33
PrintDboxPrintEvent PrintDboxSaveEvent
Event information for the save listener.
Definition: printdbox.h:365
void add_about_to_be_shown_listener(AboutToBeShownListener *listener)
This event is raised just before the PrintDbox underlying window is about to be shown.
Definition: printdbox.cc:73
PrintDbox(const std::string &template_name)
Create a PrintDbox from the named template.
Definition: printdbox.h:98
int word[64]
Array containing information return from Wimp_Poll.
Definition: pollinfo.h:76
int end() const
End page.
Definition: printdbox.h:349
void all_pages()
Set to all pages.
Definition: printdbox.cc:53
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
Listener for Save selected on PrintDbox.
Definition: printdbox.h:386
void remove_setup_listener(PrintDboxSetupListener *listener)
Remove listener that is called if setup button is pressed and it has no associated window...
Definition: printdbox.cc:145
Setup dialog is about to be shown listener.
Definition: printdbox.h:308
void scale(int pc)
Set percentage to scale by.
Definition: printdbox.h:188
const IdBlock & id_block() const
IdBlock for the current event.
Definition: eventinfo.h:71
Objects derived from this class can be shown with there full location and size specified as well as t...
Definition: showfullobject.h:40
ShowType show_type() const
Get how the setup windows was shown.
Definition: printdbox.h:279
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:41
PrintDboxSetupAboutToBeShownEvent(IdBlock &id_block, PollBlock &data)
Construct setup about to be shown event from Toolbox and WIMP information.
Definition: printdbox.h:254
Class to manipulate a toolbox object.
Definition: object.h:50
PrintDbox()
Construct creates an unassigned PrintDbox.
Definition: printdbox.h:70
The dialog box associated with the setup button is about to be shown event.
Definition: printdbox.h:245
Listener for Print selected on PrintDbox.
Definition: printdbox.h:370
PrintDboxPrintEvent(IdBlock &id_block, PollBlock &data)
Construct the PrintDboxEvent from the information returned by the Toolbox/WIMP.
Definition: printdbox.h:333
Full details of window used.
Definition: printdbox.h:270