tbx  0.7.6
caretlistener.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 TBX_CARETLISTENER_H_
26 #define TBX_CARETLISTENER_H_
27 
28 #include "bbox.h"
29 #include "listener.h"
30 #include "eventinfo.h"
31 #include "window.h"
32 #include "gadget.h"
33 
34 namespace tbx
35 {
39  class CaretEvent : public EventInfo
40  {
41 
42  public:
50  EventInfo(id_block, poll_block)
51  {}
52 
60  Window window() const {return id_block().self_object();}
61 
68  Gadget gadget() const {return id_block().self_component();}
69 
74  int x_offset() const {return _data.word[2];}
75 
80  int y_offset() const {return _data.word[3];}
81 
85  int height() const { return (_data.word[4] & 0xFFFF); }
86 
90  int colour() const {return (_data.word[4] >> 16) & 0xFF;}
91 
96  bool vdu() const {return (_data.word[4] & (1<<24))!=0;}
97 
101  bool invisible() const {return (_data.word[4] & (1<<25));}
102 
106  bool uses_colour() const {return (_data.word[4] & (1<<26));}
107 
111  bool colour_untranslated() const {return (_data.word[4] & (1<<27));}
112 
117  int index() const {return _data.word[5];}
118  };
119 
127  {
128  public:
135  virtual void lose_caret(CaretEvent &event) = 0;
136  };
137 
145  {
146  public:
153  virtual void gain_caret(CaretEvent &event) = 0;
154  };
155 
156 }
157 
158 #endif /* TBX_CARETLISTENER_H_ */
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::GainCaretListener
Listener for gain caret Wimp event.
Definition: caretlistener.h:145
tbx::CaretEvent::gadget
Gadget gadget() const
Get the gadget that is losing (LoseCaretListener) or gaining (GainCaretListener) the focus.
Definition: caretlistener.h:68
tbx::CaretEvent::colour
int colour() const
Get caret colour - if colour set.
Definition: caretlistener.h:90
tbx::EventInfo::id_block
const IdBlock & id_block() const
IdBlock for the current event.
Definition: eventinfo.h:71
tbx::CaretEvent::window
Window window() const
Get Window that is losing (LoseCaretListener) or gaining (GainCaretListener) the caret.
Definition: caretlistener.h:60
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::GainCaretListener::gain_caret
virtual void gain_caret(CaretEvent &event)=0
virtual function called when the application receives the gain caret window event
tbx::LoseCaretListener::lose_caret
virtual void lose_caret(CaretEvent &event)=0
virtual function called when the application receives the lose caret window event
tbx::PollBlock
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:72
tbx::CaretEvent::uses_colour
bool uses_colour() const
caret_color is used for the colour otherwise caret is Wimp colour 11
Definition: caretlistener.h:106
tbx::CaretEvent
Event data for lose or gain caret listener.
Definition: caretlistener.h:40
tbx::CaretEvent::CaretEvent
CaretEvent(IdBlock &id_block, PollBlock &poll_block)
Construct from toolbox event information.
Definition: caretlistener.h:49
tbx::CaretEvent::index
int index() const
The index of the caret into the writeable field or -1 if not in a writeable field.
Definition: caretlistener.h:117
tbx::IdBlock
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:42
tbx::IdBlock::self_component
Component self_component() const
Get the component the event occured on.
Definition: eventrouter.cc:1658
tbx::IdBlock::self_object
Object self_object() const
Get the object the event occured on.
Definition: eventrouter.cc:1647
tbx::CaretEvent::height
int height() const
Get the height of the caret.
Definition: caretlistener.h:85
tbx::Listener
Base class for all toolbox event listeners.
Definition: listener.h:34
tbx::CaretEvent::invisible
bool invisible() const
Invisible caret.
Definition: caretlistener.h:101
tbx::CaretEvent::x_offset
int x_offset() const
Get the current x offset of the caret relative to the window origin.
Definition: caretlistener.h:74
tbx::CaretEvent::y_offset
int y_offset() const
Get the current y offset of the caret relative to the window origin.
Definition: caretlistener.h:80
tbx::Gadget
This is the base class for all Gadgets.
Definition: gadget.h:49
tbx::PollBlock::word
int word[64]
Array containing information return from Wimp_Poll.
Definition: pollinfo.h:76
tbx::LoseCaretListener
Listener for LoseCaret Wimp event.
Definition: caretlistener.h:127
tbx::CaretEvent::vdu
bool vdu() const
Is it a vdu caret.
Definition: caretlistener.h:96
tbx::CaretEvent::colour_untranslated
bool colour_untranslated() const
Colour is untranslated, otherwise they are a Wimp colour.
Definition: caretlistener.h:111
tbx::EventInfo
Class to provide information on a toolbox event.
Definition: eventinfo.h:49