]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/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 | // Copyright: (c) wxWidgets team | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_CARET_H_ | |
12 | #define _WX_CARET_H_ | |
13 | ||
14 | #include "wx/timer.h" | |
15 | #include "wx/dc.h" | |
16 | #include "wx/overlay.h" | |
17 | ||
18 | #ifdef wxHAS_NATIVE_OVERLAY | |
19 | #define wxHAS_CARET_USING_OVERLAYS | |
20 | #endif | |
21 | ||
22 | class WXDLLIMPEXP_FWD_CORE wxCaret; | |
23 | ||
24 | class WXDLLIMPEXP_CORE wxCaretTimer : public wxTimer | |
25 | { | |
26 | public: | |
27 | wxCaretTimer(wxCaret *caret); | |
28 | virtual void Notify(); | |
29 | ||
30 | private: | |
31 | wxCaret *m_caret; | |
32 | }; | |
33 | ||
34 | class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase | |
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 | ||
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(); | |
58 | ||
59 | protected: | |
60 | virtual void DoShow(); | |
61 | virtual void DoHide(); | |
62 | virtual void DoMove(); | |
63 | virtual void DoSize(); | |
64 | ||
65 | // blink the caret once | |
66 | void Blink(); | |
67 | ||
68 | // refresh the caret | |
69 | void Refresh(); | |
70 | ||
71 | // draw the caret on the given DC | |
72 | void DoDraw(wxDC *dc, wxWindow* win); | |
73 | ||
74 | private: | |
75 | // GTK specific initialization | |
76 | void InitGeneric(); | |
77 | ||
78 | #ifdef wxHAS_CARET_USING_OVERLAYS | |
79 | // the overlay for displaying the caret | |
80 | wxOverlay m_overlay; | |
81 | #else | |
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; | |
87 | #endif | |
88 | ||
89 | wxCaretTimer m_timer; | |
90 | bool m_blinkedOut, // true => caret hidden right now | |
91 | m_hasFocus; // true => our window has focus | |
92 | }; | |
93 | ||
94 | #endif // _WX_CARET_H_ |