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