tbx  0.7.6
openwindowlistener.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 OPENWINDOWLISTENER_H_
26 #define OPENWINDOWLISTENER_H_
27 
28 #include "bbox.h"
29 #include "handles.h"
30 #include "listener.h"
31 #include "eventinfo.h"
32 #include "window.h"
33 
34 namespace tbx
35 {
40  {
41  public:
49  EventInfo(id_block, poll_block) {}
50 
54  Window window() const {return id_block().self_object();}
55 
59  WindowHandle handle() const {return _data.word[0];}
60 
64  const BBox &visible_area() const {return *reinterpret_cast<const BBox *>(&_data.word[1]);}
65 
69  void visible_area(const BBox &area) {_data.word[1] = area.min.x; _data.word[2] = area.min.y; _data.word[3] = area.max.x; _data.word[4] = area.max.y;}
70 
74  const Point &scroll() const {return *reinterpret_cast<const Point *>(&_data.word[5]);}
75 
79  void scroll(const Point &offsets) {_data.word[5] = offsets.x; _data.word[6] = offsets.y;}
80 
84  WindowHandle behind() const {return _data.word[7];}
85 
89  void behind(WindowHandle h) {_data.word[7] = h;}
90 
91  //TODO: Methods or constants for specific places like on top.
92  };
93 
98  {
99  public:
110  virtual void open_window(OpenWindowEvent &event) = 0;
111  };
112 }
113 
114 #endif /* WINDOWOPENLISTENER_H_ */
tbx::Point::x
int x
Definition: point.h:59
tbx::OpenWindowEvent::visible_area
void visible_area(const BBox &area)
Set visible area on screen.
Definition: openwindowlistener.h:69
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::OpenWindowEvent::window
Window window() const
Get Window that generated this event.
Definition: openwindowlistener.h:54
tbx::EventInfo::id_block
const IdBlock & id_block() const
IdBlock for the current event.
Definition: eventinfo.h:71
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::EventInfo::_data
PollBlock & _data
raw data from the event
Definition: eventinfo.h:53
tbx::PollBlock
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:72
tbx::OpenWindowEvent::scroll
void scroll(const Point &offsets)
Set scroll offsets in work area.
Definition: openwindowlistener.h:79
tbx::OpenWindowEvent::handle
WindowHandle handle() const
Wimp window handle of window being opened.
Definition: openwindowlistener.h:59
tbx::OpenWindowEvent::scroll
const Point & scroll() const
Get scroll offsets in work area.
Definition: openwindowlistener.h:74
tbx::BBox::min
Point min
Minimum coordinate of the bounding box.
Definition: bbox.h:68
tbx::Point::y
int y
Definition: point.h:60
tbx::OpenWindowEvent
Event data for open window request listener.
Definition: openwindowlistener.h:40
tbx::IdBlock
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:42
tbx::OpenWindowEvent::behind
WindowHandle behind() const
Get WIMP Window handle opened behind.
Definition: openwindowlistener.h:84
tbx::BBox
Class to represent a two dimensional bounding box.
Definition: bbox.h:38
tbx::WindowHandle
int WindowHandle
Type for WIMP windows handle.
Definition: handles.h:35
tbx::OpenWindowListener::open_window
virtual void open_window(OpenWindowEvent &event)=0
virtual function called when the application receives the open window request for the window.
tbx::OpenWindowEvent::visible_area
const BBox & visible_area() const
Get visible area on screen.
Definition: openwindowlistener.h:64
tbx::OpenWindowListener
Listener for Wimp Open Window Request events.
Definition: openwindowlistener.h:98
tbx::IdBlock::self_object
Object self_object() const
Get the object the event occured on.
Definition: eventrouter.cc:1647
tbx::BBox::max
Point max
Maximum coordinate of the bounding box.
Definition: bbox.h:72
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::OpenWindowEvent::OpenWindowEvent
OpenWindowEvent(IdBlock &id_block, PollBlock &poll_block)
Constructs the event from the information returned by the WIMP.
Definition: openwindowlistener.h:48
tbx::PollBlock::word
int word[64]
Array containing information return from Wimp_Poll.
Definition: pollinfo.h:76
tbx::OpenWindowEvent::behind
void behind(WindowHandle h)
Set WIMP Window handle to open behind.
Definition: openwindowlistener.h:89
tbx::EventInfo
Class to provide information on a toolbox event.
Definition: eventinfo.h:49