tbx  0.7.6
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_ */
tbx::PrintDbox::add_has_been_hidden_listener
void add_has_been_hidden_listener(HasBeenHiddenListener *listener)
This event is raised after the PrintDbox dialog has been completed.
Definition: printdbox.cc:89
tbx::PrintDbox::add_setup_listener
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
tbx::PrintDbox::remove_setup_about_to_be_shown_listener
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
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::res::ResPrintDbox
Class for PrintDbox object template.
Definition: resprintdbox.h:37
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::PrintDboxSetupAboutToBeShownEvent::ShowType
ShowType
Enumeration describing how the setup box is about to be shown.
Definition: printdbox.h:268
tbx::PrintDbox::add_print_listener
void add_print_listener(PrintDboxPrintListener *listener)
Add listener for when print is selected on the print dialogue.
Definition: printdbox.cc:159
tbx::Object::handle
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93
tbx::PrintDboxSetupAboutToBeShownEvent::SHOW_FULL_SPEC
@ SHOW_FULL_SPEC
Full details of window used.
Definition: printdbox.h:270
tbx::PrintDbox::title_length
int title_length() const
Return title length.
Definition: printdbox.h:214
tbx::PrintDboxSetupAboutToBeShownEvent::show_type
ShowType show_type() const
Get how the setup windows was shown.
Definition: printdbox.h:279
tbx::PrintDboxSetupAboutToBeShownEvent::SHOW_DEFAULT
@ SHOW_DEFAULT
Shown in default place.
Definition: printdbox.h:269
tbx::PrintDboxSaveEvent
PrintDboxPrintEvent PrintDboxSaveEvent
Event information for the save listener.
Definition: printdbox.h:365
tbx::Object::_handle
ObjectId _handle
Handle for toolbox object.
Definition: object.h:175
tbx::EventInfo::id_block
const IdBlock & id_block() const
IdBlock for the current event.
Definition: eventinfo.h:71
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::PrintDbox::PrintDbox
PrintDbox(const PrintDbox &other)
Construct a PrintDbox from another PrintDbox.
Definition: printdbox.h:79
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::PrintDboxSetupAboutToBeShownEvent::full_spec
ShowFullSpec & full_spec()
Get reference to the full specification for the show so it can be modified.
Definition: printdbox.h:302
tbx::EventInfo::_data
PollBlock & _data
raw data from the event
Definition: eventinfo.h:53
tbx::PrintDbox::title
std::string title() const
Return title.
Definition: printdbox.h:209
tbx::PrintDbox::draft
bool draft() const
Get draft mode.
Definition: printdbox.h:225
tbx::PrintDbox
Class to show a toolbox PrintDbox object.
Definition: printdbox.h:61
tbx::PrintDbox::copies
int copies() const
Get number of copies.
Definition: printdbox.h:183
tbx::PrintDboxPrintListener
Listener for Print selected on PrintDbox.
Definition: printdbox.h:371
tbx::PrintDbox::draft
void draft(bool value)
Set draft mode.
Definition: printdbox.h:220
tbx::PrintDbox::add_about_to_be_shown_listener
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
tbx::PrintDboxSetupAboutToBeShownEvent::PrintDboxSetupAboutToBeShownEvent
PrintDboxSetupAboutToBeShownEvent(IdBlock &id_block, PollBlock &data)
Construct setup about to be shown event from Toolbox and WIMP information.
Definition: printdbox.h:254
tbx::PollBlock
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:72
tbx::PrintDbox::remove_setup_listener
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
tbx::PrintDboxSaveListener
Listener for Save selected on PrintDbox.
Definition: printdbox.h:387
tbx::PrintDbox::PrintDbox
PrintDbox(const std::string &template_name)
Create a PrintDbox from the named template.
Definition: printdbox.h:98
tbx::HasBeenHiddenListener
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
tbx::PrintDbox::all_pages
void all_pages()
Set to all pages.
Definition: printdbox.cc:53
tbx::PrintDbox::PrintDbox
PrintDbox()
Construct creates an unassigned PrintDbox.
Definition: printdbox.h:70
tbx::PrintDbox::scale
void scale(int pc)
Set percentage to scale by.
Definition: printdbox.h:188
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::PrintDboxPrintEvent::start
int start() const
Start page or -1 for all.
Definition: printdbox.h:344
tbx::IdBlock
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:42
tbx::PrintDboxPrintEvent
Print button has been pressed event.
Definition: printdbox.h:325
tbx::PrintDboxSetupAboutToBeShownEvent::top_left
Point & top_left() const
Get top left coordinate of where the window will be shown.
Definition: printdbox.h:286
tbx::PrintDbox::copies
void copies(int number)
Set number of copies.
Definition: printdbox.h:178
tbx::PrintDbox::sideways
void sideways(bool value)
Set orientation sideways.
Definition: printdbox.h:199
tbx::PrintDboxPrintListener::printdbox_print
virtual void printdbox_print(const PrintDboxPrintEvent &event)=0
Method called when the print button is selected.
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::PrintDbox::sideways
bool sideways() const
Get orientation sideways.
Definition: printdbox.h:204
tbx::PrintDboxPrintEvent::PrintDboxPrintEvent
PrintDboxPrintEvent(IdBlock &id_block, PollBlock &data)
Construct the PrintDboxEvent from the information returned by the Toolbox/WIMP.
Definition: printdbox.h:333
tbx::PrintDboxPrintEvent::sideways
bool sideways() const
true if orientation was set to sideway, false for upright
Definition: printdbox.h:339
tbx::PrintDbox::remove_has_been_hidden_listener
void remove_has_been_hidden_listener(HasBeenHiddenListener *listener)
Remove has been hidden listener.
Definition: printdbox.cc:97
tbx::AboutToBeShownListener
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:77
tbx::PrintDboxPrintEvent::scale
int scale() const
Scale percentage.
Definition: printdbox.h:359
tbx::PrintDbox::operator==
bool operator==(const Object &other) const
Check if this PrintDbox refers to the same underlying toolbox object as another.
Definition: printdbox.h:135
tbx::Object
Class to manipulate a toolbox object.
Definition: object.h:51
tbx::Point
Class to represent a position in two dimensional space.
Definition: point.h:37
tbx::Listener
Base class for all toolbox event listeners.
Definition: listener.h:34
tbx::PrintDboxSetupAboutToBeShownEvent::setup_window
Window setup_window() const
Setup window that is about to be shown.
Definition: printdbox.h:262
tbx::PrintDboxSetupAboutToBeShownListener::printdbox_setup_about_to_be_shown
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.
tbx::PrintDboxPrintEvent::end
int end() const
End page.
Definition: printdbox.h:349
tbx::PrintDboxSetupAboutToBeShownEvent::top_left
Point & top_left()
Get reference to top left coordinate so it can be changed in the event.
Definition: printdbox.h:294
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::PrintDbox::remove_print_listener
void remove_print_listener(PrintDboxPrintListener *listener)
Remove listener for when print is selected on the print dialogue.
Definition: printdbox.cc:167
tbx::PrintDbox::scale
int scale() const
Get percentage to scale by.
Definition: printdbox.h:193
tbx::PrintDboxSetupAboutToBeShownListener
Setup dialog is about to be shown listener.
Definition: printdbox.h:309
tbx::PrintDboxSetupListener::printdbox_setup
virtual void printdbox_setup(const EventInfo &setup_event)=0
Method called when setup is clicked if there is no dialogue.
tbx::ObjectId
unsigned int ObjectId
Type for underlying toolbox object id.
Definition: handles.h:31
tbx::PrintDbox::window
Window window() const
Return the underlying toolbox window used to implement the PrintDbox object.
Definition: printdbox.h:150
tbx::PrintDboxSetupAboutToBeShownEvent
The dialog box associated with the setup button is about to be shown event.
Definition: printdbox.h:246
tbx::PrintDboxSaveListener::printdbox_save
virtual void printdbox_save(const PrintDboxPrintEvent &event)=0
Method called when the save button is selected.
tbx::ShowFullSpec
Structure used to specify exact position and size for an object derived from tbx::ShowFullObject.
Definition: showfullspec.h:46
tbx::Object::bool_property
bool bool_property(int property_id) const
Get a boolean property from the toolbox Cobject.
Definition: object.cc:595
tbx::PrintDbox::add_save_listener
void add_save_listener(PrintDboxSaveListener *listener)
Add listener for save button on print dialogue.
Definition: printdbox.cc:182
tbx::PrintDbox::page_range
void page_range(int start, int end)
Set range of pages.
Definition: printdbox.cc:45
tbx::PollBlock::word
int word[64]
Array containing information return from Wimp_Poll.
Definition: pollinfo.h:76
tbx::PrintDboxSetupListener
Listener for Setup presses when there is not dialogue associated with the button.
Definition: printdbox.h:403
tbx::PrintDboxPrintEvent::copies
int copies() const
Number of copies.
Definition: printdbox.h:354
tbx::PrintDbox::add_setup_about_to_be_shown_listener
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
tbx::PrintDbox::remove_save_listener
void remove_save_listener(PrintDboxSaveListener *listener)
Remove listener for save button on print dialogue.
Definition: printdbox.cc:190
tbx::PrintDbox::operator!=
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
tbx::EventInfo
Class to provide information on a toolbox event.
Definition: eventinfo.h:49
tbx::PrintDbox::operator=
PrintDbox & operator=(const Object &other)
Assign this PrintDbox from an Object that refers to a PrintDbox.
Definition: printdbox.h:127
tbx::PrintDbox::operator=
PrintDbox & operator=(const PrintDbox &other)
Assign this PrintDbox from another.
Definition: printdbox.h:115
tbx::PrintDbox::PrintDbox
PrintDbox(const Object &other)
Construct a PrintDbox from an Object that refers to a PrintDbox.
Definition: printdbox.h:90
tbx::PrintDbox::remove_about_to_be_shown_listener
void remove_about_to_be_shown_listener(AboutToBeShownListener *listener)
Remove about to be shown listener.
Definition: printdbox.cc:81