]>
Commit | Line | Data |
---|---|---|
0290598f VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: generic/caret.h | |
3 | // Purpose: generic wxCaret class | |
4 | // Author: Vadim Zeitlin (original code by Robert Roebling) | |
5 | // Modified by: | |
6 | // Created: 25.05.99 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
0290598f VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
0290598f VZ |
12 | #ifndef _WX_CARET_H_ |
13 | #define _WX_CARET_H_ | |
14 | ||
15 | #include "wx/timer.h" | |
16 | ||
968eb2ef | 17 | class WXDLLIMPEXP_CORE wxCaret; |
e4628635 | 18 | |
0887f88e | 19 | class WXDLLEXPORT wxCaretTimer : public wxTimer |
e4628635 RR |
20 | { |
21 | public: | |
22 | wxCaretTimer(wxCaret *caret); | |
23 | virtual void Notify(); | |
24 | ||
25 | private: | |
26 | wxCaret *m_caret; | |
27 | }; | |
28 | ||
86141022 SC |
29 | #ifndef wxUSE_OVERLAY |
30 | #if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS | |
31 | #define wxUSE_OVERLAY 1 | |
32 | #else | |
33 | #define wxUSE_OVERLAY 0 | |
34 | #endif | |
35 | #endif | |
36 | ||
37 | #if wxUSE_OVERLAY | |
38 | #include "wx/dc.h" | |
39 | #endif | |
40 | ||
968eb2ef | 41 | class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase |
0290598f VZ |
42 | { |
43 | public: | |
44 | // ctors | |
45 | // ----- | |
46 | // default - use Create() | |
47 | wxCaret() : m_timer(this) { InitGeneric(); } | |
48 | // creates a block caret associated with the given window | |
49 | wxCaret(wxWindowBase *window, int width, int height) | |
50 | : wxCaretBase(window, width, height), m_timer(this) { InitGeneric(); } | |
51 | wxCaret(wxWindowBase *window, const wxSize& size) | |
52 | : wxCaretBase(window, size), m_timer(this) { InitGeneric(); } | |
53 | ||
54 | virtual ~wxCaret(); | |
55 | ||
56 | // implementation | |
57 | // -------------- | |
58 | ||
f6bcfd97 BP |
59 | // called by wxWindow (not using the event tables) |
60 | virtual void OnSetFocus(); | |
61 | virtual void OnKillFocus(); | |
62 | ||
63 | // called by wxCaretTimer | |
64 | void OnTimer(); | |
0290598f VZ |
65 | |
66 | protected: | |
67 | virtual void DoShow(); | |
68 | virtual void DoHide(); | |
69 | virtual void DoMove(); | |
c328d0ad | 70 | virtual void DoSize(); |
0290598f | 71 | |
f6bcfd97 BP |
72 | // blink the caret once |
73 | void Blink(); | |
74 | ||
75 | // refresh the caret | |
76 | void Refresh(); | |
77 | ||
0290598f VZ |
78 | // draw the caret on the given DC |
79 | void DoDraw(wxDC *dc); | |
ca65c044 | 80 | |
0290598f VZ |
81 | private: |
82 | // GTK specific initialization | |
83 | void InitGeneric(); | |
84 | ||
86141022 SC |
85 | #if wxUSE_OVERLAY |
86 | // the overlay for displaying the caret | |
87 | wxOverlay m_overlay; | |
88 | #else | |
f4b8bf2f VZ |
89 | // the bitmap holding the part of window hidden by the caret when it was |
90 | // at (m_xOld, m_yOld) | |
91 | wxBitmap m_bmpUnderCaret; | |
92 | int m_xOld, | |
93 | m_yOld; | |
86141022 | 94 | #endif |
f4b8bf2f | 95 | |
e4628635 | 96 | wxCaretTimer m_timer; |
ca65c044 WS |
97 | bool m_blinkedOut, // true => caret hidden right now |
98 | m_hasFocus; // true => our window has focus | |
0290598f VZ |
99 | }; |
100 | ||
101 | #endif // _WX_CARET_H_ |