neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
cursor.hpp
Go to the documentation of this file.
1// cursor.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
24#include <neogfx/core/event.hpp>
27
28namespace neogfx
29{
30 class i_document;
31
32 enum class cursor_style
33 {
35 Xor
36 };
37
38 class cursor
39 {
40 public:
41 define_event(PositionChanged, position_changed)
42 define_event(AnchorChanged, anchor_changed)
43 define_event(AppearanceChanged, appearance_changed)
44 public:
45 enum move_operation_e
46 {
47 None,
48 StartOfDocument,
49 StartOfParagraph,
50 StartOfLine,
51 StartOfWord,
52 EndOfDocument,
53 EndOfParagraph,
54 EndOfLine,
55 EndOfWord,
56 PreviousParagraph,
57 PreviousLine,
58 PreviousWord,
59 PreviousCharacter,
60 NextParagraph,
61 NextLine,
62 NextWord,
63 NextCharacter,
64 Up,
65 Down,
66 Left,
67 Right
68 };
69 typedef std::size_t position_type;
70 public:
71 struct no_document : std::logic_error { no_document() : std::logic_error("neogfx::cursor::no_document") {} };
72 public:
74 cursor(i_document& aDocument);
75 public:
76 bool has_document() const;
78 void move(move_operation_e aMoveOperation);
80 void set_position(position_type aPosition, bool aMoveAnchor = true);
84 const color_or_gradient& color() const;
85 void set_color(const color_or_gradient& aColor);
87 void set_style(cursor_style aStyle);
89 void set_width(dimension aWidth);
90 std::chrono::milliseconds flash_interval() const;
91 void set_flash_interval(std::chrono::milliseconds aInterval);
92 bool visible() const;
93 bool hidden() const;
94 void show();
95 void hide();
96 private:
97 i_document* iDocument;
98 position_type iPosition;
99 position_type iAnchor;
100 color_or_gradient iColor;
101 cursor_style iStyle;
102 dimension iWidth;
103 std::chrono::milliseconds iFlashInterval;
104 bool iVisible = true;
105 };
106}
cursor(i_document &aDocument)
bool anchored_over_entire_document() const
void set_anchor(position_type aAnchor)
anchor_changed define_event(AppearanceChanged, appearance_changed) public typedef std::size_t position_type
Definition cursor.hpp:43
bool hidden() const
void set_flash_interval(std::chrono::milliseconds aInterval)
cursor_style style() const
void move(move_operation_e aMoveOperation)
dimension width() const
void set_width(dimension aWidth)
void set_position(position_type aPosition, bool aMoveAnchor=true)
void set_style(cursor_style aStyle)
bool visible() const
i_document & document() const
define_event(PositionChanged, position_changed) define_event(AnchorChanged
const color_or_gradient & color() const
void set_color(const color_or_gradient &aColor)
bool has_document() const
position_type position() const
std::chrono::milliseconds flash_interval() const
position_type anchor() const
default_geometry_value_type dimension
cursor_style
Definition cursor.hpp:33
#define define_event(name, declName,...)
Definition event.hpp:200