]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: caret.h | |
e54c96f1 | 3 | // Purpose: interface of wxCaret |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxCaret | |
7c913512 | 11 | |
23324ae1 | 12 | A caret is a blinking cursor showing the position where the typed text will |
bfac6166 BP |
13 | appear. Text controls usually have their own caret but wxCaret provides a |
14 | way to use a caret in other windows. | |
7c913512 | 15 | |
bfac6166 BP |
16 | Currently, the caret appears as a rectangle of the given size. In the |
17 | future, it will be possible to specify a bitmap to be used for the caret | |
18 | shape. | |
7c913512 | 19 | |
23324ae1 | 20 | A caret is always associated with a window and the current caret can be |
bfac6166 BP |
21 | retrieved using wxWindow::GetCaret(). The same caret can't be reused in two |
22 | different windows. | |
7c913512 | 23 | |
23324ae1 FM |
24 | @library{wxcore} |
25 | @category{misc} | |
23324ae1 | 26 | */ |
7c913512 | 27 | class wxCaret |
23324ae1 FM |
28 | { |
29 | public: | |
23324ae1 | 30 | /** |
bfac6166 | 31 | Default constructor. |
23324ae1 FM |
32 | */ |
33 | wxCaret(); | |
bfac6166 BP |
34 | |
35 | //@{ | |
36 | /** | |
37 | Creates a caret with the given size (in pixels) and associates it with | |
38 | the @a window. | |
39 | */ | |
7c913512 FM |
40 | wxCaret(wxWindow* window, int width, int height); |
41 | wxCaret(wxWindowBase* window, const wxSize& size); | |
23324ae1 FM |
42 | //@} |
43 | ||
44 | //@{ | |
45 | /** | |
bfac6166 BP |
46 | Creates a caret with the given size (in pixels) and associates it with |
47 | the @a window (same as the equivalent constructors). | |
23324ae1 FM |
48 | */ |
49 | bool Create(wxWindowBase* window, int width, int height); | |
7c913512 | 50 | bool Create(wxWindowBase* window, const wxSize& size); |
23324ae1 FM |
51 | //@} |
52 | ||
53 | /** | |
bfac6166 BP |
54 | Returns the blink time which is measured in milliseconds and is the |
55 | time elapsed between 2 inversions of the caret (blink time of the caret | |
56 | is the same for all carets, so this functions is static). | |
23324ae1 FM |
57 | */ |
58 | static int GetBlinkTime(); | |
59 | ||
60 | //@{ | |
61 | /** | |
62 | Get the caret position (in pixels). | |
23324ae1 | 63 | */ |
328f5751 | 64 | void GetPosition(int* x, int* y) const; |
bfac6166 | 65 | const wxPoint GetPosition() const; |
23324ae1 FM |
66 | //@} |
67 | ||
68 | //@{ | |
69 | /** | |
70 | Get the caret size. | |
23324ae1 | 71 | */ |
328f5751 FM |
72 | void GetSize(int* width, int* height) const; |
73 | const wxSize GetSize() const; | |
23324ae1 FM |
74 | //@} |
75 | ||
76 | /** | |
77 | Get the window the caret is associated with. | |
78 | */ | |
328f5751 | 79 | wxWindow* GetWindow() const; |
23324ae1 FM |
80 | |
81 | /** | |
bfac6166 | 82 | Hides the caret, same as Show(@false). |
23324ae1 | 83 | */ |
9d9c1c24 | 84 | virtual void Hide(); |
23324ae1 FM |
85 | |
86 | /** | |
87 | Returns @true if the caret was created successfully. | |
88 | */ | |
328f5751 | 89 | bool IsOk() const; |
23324ae1 FM |
90 | |
91 | /** | |
92 | Returns @true if the caret is visible and @false if it is permanently | |
bfac6166 BP |
93 | hidden (if it is is blinking and not shown currently but will be after |
94 | the next blink, this method still returns @true). | |
23324ae1 | 95 | */ |
328f5751 | 96 | bool IsVisible() const; |
23324ae1 FM |
97 | |
98 | //@{ | |
99 | /** | |
100 | Move the caret to given position (in logical coordinates). | |
101 | */ | |
102 | void Move(int x, int y); | |
7c913512 | 103 | void Move(const wxPoint& pt); |
23324ae1 FM |
104 | //@} |
105 | ||
106 | /** | |
107 | Sets the blink time for all the carets. | |
3c4f71cc | 108 | |
bfac6166 BP |
109 | @warning Under Windows, this function will change the blink time for |
110 | all carets permanently (until the next time it is called), | |
111 | even for carets in other applications. | |
3c4f71cc | 112 | |
4cc4bfaf | 113 | @see GetBlinkTime() |
23324ae1 FM |
114 | */ |
115 | static void SetBlinkTime(int milliseconds); | |
116 | ||
117 | //@{ | |
118 | /** | |
119 | Changes the size of the caret. | |
120 | */ | |
121 | void SetSize(int width, int height); | |
7c913512 | 122 | void SetSize(const wxSize& size); |
23324ae1 FM |
123 | //@} |
124 | ||
125 | /** | |
bfac6166 BP |
126 | Shows or hides the caret. Notice that if the caret was hidden N times, |
127 | it must be shown N times as well to reappear on the screen. | |
23324ae1 | 128 | */ |
9d9c1c24 | 129 | virtual void Show(bool show = true); |
23324ae1 | 130 | }; |
e54c96f1 | 131 |