Must define a symbol to test its value
[wxWidgets.git] / include / wx / generic / caret.h
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$
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CARET_H_
13 #define _WX_CARET_H_
14
15 #include "wx/timer.h"
16 #include "wx/dc.h"
17 #include "wx/overlay.h"
18
19 #if wxHAS_NATIVE_OVERLAY
20 #define wxHAS_CARET_USING_OVERLAYS 1
21 #else
22 #define wxHAS_CARET_USING_OVERLAYS 0
23 #endif
24
25 class WXDLLIMPEXP_CORE wxCaret;
26
27 class WXDLLEXPORT wxCaretTimer : public wxTimer
28 {
29 public:
30 wxCaretTimer(wxCaret *caret);
31 virtual void Notify();
32
33 private:
34 wxCaret *m_caret;
35 };
36
37 class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase
38 {
39 public:
40 // ctors
41 // -----
42 // default - use Create()
43 wxCaret() : m_timer(this) { InitGeneric(); }
44 // creates a block caret associated with the given window
45 wxCaret(wxWindowBase *window, int width, int height)
46 : wxCaretBase(window, width, height), m_timer(this) { InitGeneric(); }
47 wxCaret(wxWindowBase *window, const wxSize& size)
48 : wxCaretBase(window, size), m_timer(this) { InitGeneric(); }
49
50 virtual ~wxCaret();
51
52 // implementation
53 // --------------
54
55 // called by wxWindow (not using the event tables)
56 virtual void OnSetFocus();
57 virtual void OnKillFocus();
58
59 // called by wxCaretTimer
60 void OnTimer();
61
62 protected:
63 virtual void DoShow();
64 virtual void DoHide();
65 virtual void DoMove();
66 virtual void DoSize();
67
68 // blink the caret once
69 void Blink();
70
71 // refresh the caret
72 void Refresh();
73
74 // draw the caret on the given DC
75 void DoDraw(wxDC *dc);
76
77 private:
78 // GTK specific initialization
79 void InitGeneric();
80
81 #if wxHAS_CARET_USING_OVERLAYS
82 // the overlay for displaying the caret
83 wxOverlay m_overlay;
84 #else
85 // the bitmap holding the part of window hidden by the caret when it was
86 // at (m_xOld, m_yOld)
87 wxBitmap m_bmpUnderCaret;
88 int m_xOld,
89 m_yOld;
90 #endif
91
92 wxCaretTimer m_timer;
93 bool m_blinkedOut, // true => caret hidden right now
94 m_hasFocus; // true => our window has focus
95 };
96
97 #endif // _WX_CARET_H_