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