tbx  0.7.3
mouseclicklistener.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 MOUSECLICKLISTENER_H_
26 #define MOUSECLICKLISTENER_H_
27 
28 #include "gadget.h"
29 #include "listener.h"
30 #include "eventinfo.h"
31 
32 namespace tbx
33 {
42  {
43  unsigned int _click_shift;
44 
45  public:
50  EventInfo(id_block, data)
51  {
52  if (d) _click_shift = 8;
53  else _click_shift = 0;
54  };
55 
59  int x() const {return _data.word[0];}
60 
64  int y() const {return _data.word[1];}
65 
69  Point point() const {return Point(_data.word[0], _data.word[1]);}
70 
80  unsigned int button() const {return _data.word[2];}
81 
85  bool is_adjust() const {return (_data.word[2] & (1 << _click_shift)) != 0;}
86 
90  bool is_menu() const {return (_data.word[2] & 2) != 0;}
91 
95  bool is_select() const {return (_data.word[2] & (4 << _click_shift)) != 0;}
96 
102  bool is_adjust_drag() const {return (_data.word[2] & 0x10) != 0;}
103 
109  bool is_select_drag() const {return (_data.word[2] & 0x40) != 0;}
110 
116  bool is_adjust_double() const {return (_click_shift != 0) && (_data.word[2] & 0x1) != 0;}
117 
123  bool is_select_double() const {return (_click_shift != 0) && (_data.word[2] & 0x4) != 0;}
124  };
125 
130  {
131  public:
133  virtual ~MouseClickListener() {};
134 
141  virtual void mouse_click(MouseClickEvent &event) = 0;
142  };
143 }
144 
145 #endif /* MOUSECLICKLISTENER_H_ */
virtual void mouse_click(MouseClickEvent &event)=0
Override to process the mouse click.
PollBlock & _data
raw data from the event
Definition: eventinfo.h:53
bool is_select_drag() const
Drag start with select.
Definition: mouseclicklistener.h:109
virtual ~MouseClickListener()
Destructor.
Definition: mouseclicklistener.h:133
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:71
bool is_select_double() const
Click is a double select click.
Definition: mouseclicklistener.h:123
bool is_adjust() const
Adjust button has been clicked.
Definition: mouseclicklistener.h:85
bool is_adjust_double() const
Click is a double adjust click.
Definition: mouseclicklistener.h:116
Class to represent a position in two dimensional space.
Definition: point.h:36
bool is_menu() const
Menu button has been clicked.
Definition: mouseclicklistener.h:90
Listener for mouse clicks on a Window.
Definition: mouseclicklistener.h:129
bool is_adjust_drag() const
Drag started with adjust.
Definition: mouseclicklistener.h:102
Point point() const
Point of the click in screen coordinates.
Definition: mouseclicklistener.h:69
MouseClickEvent(IdBlock &id_block, PollBlock &data, bool d)
Constructor.
Definition: mouseclicklistener.h:49
Event for click on a window.
Definition: mouseclicklistener.h:41
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
unsigned int button() const
Button pressed.
Definition: mouseclicklistener.h:80
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
const IdBlock & id_block() const
IdBlock for the current event.
Definition: eventinfo.h:71
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:41
int y() const
y coordinate of click in screen coordinates
Definition: mouseclicklistener.h:64
bool is_select() const
Select button has been clicked.
Definition: mouseclicklistener.h:95
int x() const
x coordinate of click in screen coordinates
Definition: mouseclicklistener.h:59