tbx  0.7.3
pointerinfo.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  * pointerinfo.h
27  *
28  * Created on: 4 Nov 2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_POINTERINFO_H_
33 #define TBX_POINTERINFO_H_
34 
35 #include "gadget.h"
36 
37 namespace tbx {
38 
44 {
45  int _block[5];
46 
47 public:
48  PointerInfo(bool update_now = true, bool get_objects = true);
49  PointerInfo(WindowHandle window_handle, IconHandle icon_handle, int dest_x, int dest_y, int buttons);
50  virtual ~PointerInfo();
51 
52  void Update(bool get_objects = true);
53 
54  // Properties
60  int mouse_x() const {return _block[0];}
66  int mouse_y() const {return _block[1];}
67 
77  int button_state() const {return _block[2];}
78 
79  // More details
85  bool adjust_down() const {return (_block[2] & 1)!=0;}
91  bool menu_down() const {return (_block[2] & 2)!=0;}
97  bool select_down() const {return (_block[2] & 4)!=0;}
98 
99  // Object/component hands
105  bool on_object() const {return (_block[2] & 256)!=0;}
106  Object object() const;
107  Gadget gadget() const;
108 
109  // WIMP window/icon handles
121  WindowHandle window_handle() const {return _block[3];}
130  IconHandle icon_handle() const {return _block[4];}
139  bool user_window() const {return (_block[3] >= 0);}
148  bool on_background() const {return (_block[3] == -1);}
157  bool on_iconbar() const {return (_block[3] == -2);}
158 
167  bool system_icon() const {return (_block[4] < 0);}
168 
169  // TODO: define enum to give system icon numbers
170 
171 };
172 
173 }
174 
175 #endif /* TBX_POINTERINFO_H_ */
Class to store and fetch information about the WIMP mouse pointer.
Definition: pointerinfo.h:43
IconHandle icon_handle() const
Get the WIMP icon handle the pointer was over.
Definition: pointerinfo.h:130
This is the base class for all Gadgets.
Definition: gadget.h:48
int mouse_x() const
Get the x mouse coordinate.
Definition: pointerinfo.h:60
bool on_object() const
Check if pointer is returning object information.
Definition: pointerinfo.h:105
WindowHandle window_handle() const
Get the WIMP window handle the pointer was over.
Definition: pointerinfo.h:121
bool select_down() const
Check if the select button is pressed.
Definition: pointerinfo.h:97
bool user_window() const
Check if the window returned is a user window.
Definition: pointerinfo.h:139
int mouse_y() const
Get the y mouse coordinate.
Definition: pointerinfo.h:66
PointerInfo(bool update_now=true, bool get_objects=true)
Constructor to optionally get the current pointer position.
Definition: pointerinfo.cc:44
int WindowHandle
Type for WIMP windows handle.
Definition: handles.h:35
int button_state() const
Get the button state.
Definition: pointerinfo.h:77
void Update(bool get_objects=true)
Update to current location of mouse.
Definition: pointerinfo.cc:81
bool menu_down() const
Check if then menu button is pressed.
Definition: pointerinfo.h:91
int IconHandle
Type for WIMP icon handle.
Definition: handles.h:37
bool system_icon() const
Check if this is a system icon.
Definition: pointerinfo.h:167
bool adjust_down() const
Check if the adjust button is pressed.
Definition: pointerinfo.h:85
Gadget gadget() const
Return gadget the pointer is over.
Definition: pointerinfo.cc:122
bool on_iconbar() const
Check if the window returned is the iconbar.
Definition: pointerinfo.h:157
Class to manipulate a toolbox object.
Definition: object.h:50
Object object() const
Return object the pointer is over.
Definition: pointerinfo.cc:108
bool on_background() const
Check if the window returned is the desktop background.
Definition: pointerinfo.h:148