Version: 3.1.1
wxCaret Class Reference

#include <wx/caret.h>

Detailed Description

A caret is a blinking cursor showing the position where the typed text will appear.

Text controls usually have their own caret but wxCaret provides a way to use a caret in other windows.

Currently, the caret appears as a rectangle of the given size. In the future, it will be possible to specify a bitmap to be used for the caret shape.

A caret is always associated with a window and the current caret can be retrieved using wxWindow::GetCaret(). The same caret can't be reused in two different windows.

Library:  wxCore
Category:  Miscellaneous

Public Member Functions

 wxCaret ()
 Default constructor. More...
 
wxWindowGetWindow () const
 Get the window the caret is associated with. More...
 
virtual void Hide ()
 Hides the caret, same as Show(false). More...
 
bool IsOk () const
 Returns true if the caret was created successfully. More...
 
bool IsVisible () const
 Returns true if the caret is visible and false if it is permanently hidden (if it is blinking and not shown currently but will be after the next blink, this method still returns true). More...
 
virtual void Show (bool show=true)
 Shows or hides the caret. More...
 
 wxCaret (wxWindow *window, int width, int height)
 Creates a caret with the given size (in pixels) and associates it with the window. More...
 
 wxCaret (wxWindow *window, const wxSize &size)
 Creates a caret with the given size (in pixels) and associates it with the window. More...
 
bool Create (wxWindow *window, int width, int height)
 Creates a caret with the given size (in pixels) and associates it with the window (same as the equivalent constructors). More...
 
bool Create (wxWindow *window, const wxSize &size)
 Creates a caret with the given size (in pixels) and associates it with the window (same as the equivalent constructors). More...
 
void GetPosition (int *x, int *y) const
 Get the caret position (in pixels). More...
 
wxPoint GetPosition () const
 Get the caret position (in pixels). More...
 
void GetSize (int *width, int *height) const
 Get the caret size. More...
 
wxSize GetSize () const
 Get the caret size. More...
 
void Move (int x, int y)
 Move the caret to given position (in logical coordinates). More...
 
void Move (const wxPoint &pt)
 Move the caret to given position (in logical coordinates). More...
 
void SetSize (int width, int height)
 Changes the size of the caret. More...
 
void SetSize (const wxSize &size)
 Changes the size of the caret. More...
 

Static Public Member Functions

static int GetBlinkTime ()
 Returns the blink time which is measured in milliseconds and is the time elapsed between 2 inversions of the caret (blink time of the caret is the same for all carets, so this functions is static). More...
 
static void SetBlinkTime (int milliseconds)
 Sets the blink time for all the carets. More...
 

Constructor & Destructor Documentation

wxCaret::wxCaret ( )

Default constructor.

wxCaret::wxCaret ( wxWindow window,
int  width,
int  height 
)

Creates a caret with the given size (in pixels) and associates it with the window.

wxCaret::wxCaret ( wxWindow window,
const wxSize size 
)

Creates a caret with the given size (in pixels) and associates it with the window.

Member Function Documentation

bool wxCaret::Create ( wxWindow window,
int  width,
int  height 
)

Creates a caret with the given size (in pixels) and associates it with the window (same as the equivalent constructors).

bool wxCaret::Create ( wxWindow window,
const wxSize size 
)

Creates a caret with the given size (in pixels) and associates it with the window (same as the equivalent constructors).

static int wxCaret::GetBlinkTime ( )
static

Returns the blink time which is measured in milliseconds and is the time elapsed between 2 inversions of the caret (blink time of the caret is the same for all carets, so this functions is static).

void wxCaret::GetPosition ( int *  x,
int *  y 
) const

Get the caret position (in pixels).

wxPerl Note: In wxPerl there are two methods instead of a single overloaded method:

  • GetPosition(): returns a Wx::Point object.
  • GetPositionXY(): returns a 2-element list (x, y).
wxPoint wxCaret::GetPosition ( ) const

Get the caret position (in pixels).

wxPerl Note: In wxPerl there are two methods instead of a single overloaded method:

  • GetPosition(): returns a Wx::Point object.
  • GetPositionXY(): returns a 2-element list (x, y).
void wxCaret::GetSize ( int *  width,
int *  height 
) const

Get the caret size.

wxPerl Note: In wxPerl there are two methods instead of a single overloaded method:

  • GetSize(): returns a Wx::Size object.
  • GetSizeWH(): returns a 2-element list (width, height).
wxSize wxCaret::GetSize ( ) const

Get the caret size.

wxPerl Note: In wxPerl there are two methods instead of a single overloaded method:

  • GetSize(): returns a Wx::Size object.
  • GetSizeWH(): returns a 2-element list (width, height).
wxWindow* wxCaret::GetWindow ( ) const

Get the window the caret is associated with.

virtual void wxCaret::Hide ( )
virtual

Hides the caret, same as Show(false).

bool wxCaret::IsOk ( ) const

Returns true if the caret was created successfully.

bool wxCaret::IsVisible ( ) const

Returns true if the caret is visible and false if it is permanently hidden (if it is blinking and not shown currently but will be after the next blink, this method still returns true).

void wxCaret::Move ( int  x,
int  y 
)

Move the caret to given position (in logical coordinates).

void wxCaret::Move ( const wxPoint pt)

Move the caret to given position (in logical coordinates).

static void wxCaret::SetBlinkTime ( int  milliseconds)
static

Sets the blink time for all the carets.

Warning
Under Windows, this function will change the blink time for all carets permanently (until the next time it is called), even for carets in other applications.
See also
GetBlinkTime()
void wxCaret::SetSize ( int  width,
int  height 
)

Changes the size of the caret.

void wxCaret::SetSize ( const wxSize size)

Changes the size of the caret.

virtual void wxCaret::Show ( bool  show = true)
virtual

Shows or hides the caret.

Notice that if the caret was hidden N times, it must be shown N times as well to reappear on the screen.