tbx  0.7.5
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_ */
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
int x
Definition: point.h:59
WindowHandle behind() const
Get WIMP Window handle opened behind.
Definition: openwindowlistener.h:84
PollBlock & _data
raw data from the event
Definition: eventinfo.h:53
const BBox & visible_area() const
Get visible area on screen.
Definition: openwindowlistener.h:64
Class to represent a two dimensional bounding box.
Definition: bbox.h:37
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:71
Object self_object() const
Get the object the event occured on.
Definition: eventrouter.cc:1615
OpenWindowEvent(IdBlock &id_block, PollBlock &poll_block)
Constructs the event from the information returned by the WIMP.
Definition: openwindowlistener.h:48
int WindowHandle
Type for WIMP windows handle.
Definition: handles.h:35
void behind(WindowHandle h)
Set WIMP Window handle to open behind.
Definition: openwindowlistener.h:89
Point min
Minimum coordinate of the bounding box.
Definition: bbox.h:68
const IdBlock & id_block() const
IdBlock for the current event.
Definition: eventinfo.h:71
int y
Definition: point.h:60
Class to represent a position in two dimensional space.
Definition: point.h:36
void visible_area(const BBox &area)
Set visible area on screen.
Definition: openwindowlistener.h:69
Window window() const
Get Window that generated this event.
Definition: openwindowlistener.h:54
Point max
Maximum coordinate of the bounding box.
Definition: bbox.h:72
The Window object represents a toolbox window.
Definition: window.h:69
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
const Point & scroll() const
Get scroll offsets in work area.
Definition: openwindowlistener.h:74
Base class for all toolbox event listeners.
Definition: listener.h:33
int word[64]
Array containing information return from Wimp_Poll.
Definition: pollinfo.h:76
void scroll(const Point &offsets)
Set scroll offsets in work area.
Definition: openwindowlistener.h:79
Listener for Wimp Open Window Request events.
Definition: openwindowlistener.h:97
Event data for open window request listener.
Definition: openwindowlistener.h:39
WindowHandle handle() const
Wimp window handle of window being opened.
Definition: openwindowlistener.h:59
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:41