tbx  0.7.6
caret.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2021 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_CARET_H_
26 #define TBX_CARET_H_
27 
28 #include "window.h"
29 
30 namespace tbx
31 {
43  class Caret
44  {
45 
46  public:
47  Caret(bool get_current = false);
48  Caret(const Caret &other);
49  Caret(WindowHandle window, IconHandle icon, int x, int y, int height_and_flags, int index);
51  Caret(tbx::Window window, int x, int y);
52  Caret(tbx::Window window, int x, int y, int height, bool vdu = false);
53  Caret(tbx::Window window, int x, int y, int height, int colour, bool untranslated = false, bool vdu = false);
54 
55  Caret& operator=(const Caret &other);
56 
57  void get();
58  void set();
59  void move(int x, int y);
60  static void turn_off();
61 
67 
73  WindowHandle window_handle() const {return _window;}
74 
80  IconHandle icon_handle() const {return _icon;}
81 
86  int x_offset() const {return _x_offset;}
87 
92  int y_offset() const {return _y_offset;}
93 
97  int height() const { return (_height_and_flags & 0xFFFF); }
98 
102  int colour() const {return (_height_and_flags >> 16) & 0xFF;}
103 
108  bool vdu() const {return (_height_and_flags & (1<<24))!=0;}
109 
113  bool invisible() const {return (_height_and_flags & (1<<25));}
114 
118  bool uses_colour() const {return (_height_and_flags & (1<<26));}
119 
123  bool colour_untranslated() const {return (_height_and_flags & (1<<27));}
124 
129  int index() const {return _index;}
130  private:
131  WindowHandle _window;
132  IconHandle _icon;
133  int _x_offset;
134  int _y_offset;
135  int _height_and_flags;
136  int _index;
137  };
138 
139 }
140 
141 #endif /* TBX_CARET_H_ */
tbx::Caret::colour_untranslated
bool colour_untranslated() const
Colour is untranslated, otherwise they are a Wimp colour.
Definition: caret.h:123
tbx::Caret::invisible
bool invisible() const
Invisible caret.
Definition: caret.h:113
tbx::Caret::Caret
Caret(bool get_current=false)
Create an uninitialised caret.
Definition: caret.cc:38
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::Caret::colour
int colour() const
Get caret colour - if colour set.
Definition: caret.h:102
tbx::Caret::window_handle
WindowHandle window_handle() const
Get Wimp window handle for the caret.
Definition: caret.h:73
tbx::Caret::operator=
Caret & operator=(const Caret &other)
Assignment operator.
Definition: caret.cc:175
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::Caret::x_offset
int x_offset() const
Get the current x offset of the caret relative to the window work area origin.
Definition: caret.h:86
tbx::Caret::vdu
bool vdu() const
Is it a vdu caret.
Definition: caret.h:108
tbx::Caret::turn_off
static void turn_off()
Turn off and disown the caret.
Definition: caret.cc:229
tbx::WindowHandle
int WindowHandle
Type for WIMP windows handle.
Definition: handles.h:35
tbx::Caret::y_offset
int y_offset() const
Get the current y offset of the caret relative to the window work area origin.
Definition: caret.h:92
tbx::Caret::height
int height() const
Get the height of the caret.
Definition: caret.h:97
tbx::Caret::move
void move(int x, int y)
Move the caret class and the WIMP caret to a new location.
Definition: caret.cc:219
tbx::Caret::index
int index() const
The index of the caret into the writeable field or -1 if not in a writeable field.
Definition: caret.h:129
tbx::Caret::window
tbx::Window window() const
Get toolbox window for Caret (if possible)
tbx::Caret
Definition: caret.h:44
tbx::IconHandle
int IconHandle
Type for WIMP icon handle.
Definition: handles.h:37
tbx::Caret::icon_handle
IconHandle icon_handle() const
Get the Wimp icon that contains the caret.
Definition: caret.h:80
tbx::Caret::uses_colour
bool uses_colour() const
caret_color is used for the colour otherwise caret is Wimp colour 11
Definition: caret.h:118
tbx::Caret::get
void get()
Update this object with the current location and state of the WIMP caret.
Definition: caret.cc:189
tbx::Caret::set
void set()
Update the WIMP caret location and appearance to the settings in this class.
Definition: caret.cc:200