1999-05-25 18:01:48 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2011-03-20 00:14:35 +00:00
|
|
|
// Name: wx/generic/caret.h
|
1999-05-25 18:01:48 +00:00
|
|
|
// Purpose: generic wxCaret class
|
|
|
|
// Author: Vadim Zeitlin (original code by Robert Roebling)
|
|
|
|
// Modified by:
|
|
|
|
// Created: 25.05.99
|
2004-05-23 14:56:36 +00:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-05-25 18:01:48 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_CARET_H_
|
|
|
|
#define _WX_CARET_H_
|
|
|
|
|
|
|
|
#include "wx/timer.h"
|
2006-10-24 12:29:14 +00:00
|
|
|
#include "wx/dc.h"
|
|
|
|
#include "wx/overlay.h"
|
|
|
|
|
2006-10-25 12:12:56 +00:00
|
|
|
#ifdef wxHAS_NATIVE_OVERLAY
|
|
|
|
#define wxHAS_CARET_USING_OVERLAYS
|
2006-10-24 12:29:14 +00:00
|
|
|
#endif
|
1999-05-25 18:01:48 +00:00
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxCaret;
|
1999-08-02 19:06:23 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxCaretTimer : public wxTimer
|
1999-08-02 19:06:23 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxCaretTimer(wxCaret *caret);
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void Notify() wxOVERRIDE;
|
1999-08-02 19:06:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxCaret *m_caret;
|
|
|
|
};
|
|
|
|
|
2005-08-02 18:16:51 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase
|
1999-05-25 18:01:48 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctors
|
|
|
|
// -----
|
|
|
|
// default - use Create()
|
|
|
|
wxCaret() : m_timer(this) { InitGeneric(); }
|
|
|
|
// creates a block caret associated with the given window
|
|
|
|
wxCaret(wxWindowBase *window, int width, int height)
|
|
|
|
: wxCaretBase(window, width, height), m_timer(this) { InitGeneric(); }
|
|
|
|
wxCaret(wxWindowBase *window, const wxSize& size)
|
|
|
|
: wxCaretBase(window, size), m_timer(this) { InitGeneric(); }
|
|
|
|
|
|
|
|
virtual ~wxCaret();
|
|
|
|
|
|
|
|
// implementation
|
|
|
|
// --------------
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// called by wxWindow (not using the event tables)
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void OnSetFocus() wxOVERRIDE;
|
|
|
|
virtual void OnKillFocus() wxOVERRIDE;
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
// called by wxCaretTimer
|
|
|
|
void OnTimer();
|
1999-05-25 18:01:48 +00:00
|
|
|
|
|
|
|
protected:
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void DoShow() wxOVERRIDE;
|
|
|
|
virtual void DoHide() wxOVERRIDE;
|
|
|
|
virtual void DoMove() wxOVERRIDE;
|
|
|
|
virtual void DoSize() wxOVERRIDE;
|
1999-05-25 18:01:48 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// blink the caret once
|
|
|
|
void Blink();
|
|
|
|
|
|
|
|
// refresh the caret
|
|
|
|
void Refresh();
|
|
|
|
|
1999-05-25 18:01:48 +00:00
|
|
|
// draw the caret on the given DC
|
2008-08-22 11:32:23 +00:00
|
|
|
void DoDraw(wxDC *dc, wxWindow* win);
|
2004-06-17 16:22:36 +00:00
|
|
|
|
1999-05-25 18:01:48 +00:00
|
|
|
private:
|
|
|
|
// GTK specific initialization
|
|
|
|
void InitGeneric();
|
|
|
|
|
2006-10-25 12:12:56 +00:00
|
|
|
#ifdef wxHAS_CARET_USING_OVERLAYS
|
2006-10-10 10:28:04 +00:00
|
|
|
// the overlay for displaying the caret
|
|
|
|
wxOverlay m_overlay;
|
|
|
|
#else
|
2000-09-22 22:44:34 +00:00
|
|
|
// the bitmap holding the part of window hidden by the caret when it was
|
|
|
|
// at (m_xOld, m_yOld)
|
|
|
|
wxBitmap m_bmpUnderCaret;
|
|
|
|
int m_xOld,
|
|
|
|
m_yOld;
|
2006-10-10 10:28:04 +00:00
|
|
|
#endif
|
2000-09-22 22:44:34 +00:00
|
|
|
|
1999-08-02 19:06:23 +00:00
|
|
|
wxCaretTimer m_timer;
|
2004-06-17 16:22:36 +00:00
|
|
|
bool m_blinkedOut, // true => caret hidden right now
|
|
|
|
m_hasFocus; // true => our window has focus
|
1999-05-25 18:01:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_CARET_H_
|