]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/caret.h
simpler implementation
[wxWidgets.git] / include / wx / generic / caret.h
... / ...
CommitLineData
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
17class WXDLLIMPEXP_CORE wxCaret;
18
19class WXDLLEXPORT wxCaretTimer : public wxTimer
20{
21public:
22 wxCaretTimer(wxCaret *caret);
23 virtual void Notify();
24
25private:
26 wxCaret *m_caret;
27};
28
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
41class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase
42{
43public:
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
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();
65
66protected:
67 virtual void DoShow();
68 virtual void DoHide();
69 virtual void DoMove();
70 virtual void DoSize();
71
72 // blink the caret once
73 void Blink();
74
75 // refresh the caret
76 void Refresh();
77
78 // draw the caret on the given DC
79 void DoDraw(wxDC *dc);
80
81private:
82 // GTK specific initialization
83 void InitGeneric();
84
85#if wxUSE_OVERLAY
86 // the overlay for displaying the caret
87 wxOverlay m_overlay;
88#else
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;
94#endif
95
96 wxCaretTimer m_timer;
97 bool m_blinkedOut, // true => caret hidden right now
98 m_hasFocus; // true => our window has focus
99};
100
101#endif // _WX_CARET_H_