Version: 3.2.5
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() [1/3]

wxCaret::wxCaret ( )

Default constructor.

◆ wxCaret() [2/3]

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

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

◆ wxCaret() [3/3]

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

◆ Create() [1/2]

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).

◆ Create() [2/2]

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).

◆ GetBlinkTime()

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).

◆ GetPosition() [1/2]

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).

◆ GetPosition() [2/2]

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).

◆ GetSize() [1/2]

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).

◆ GetSize() [2/2]

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).

◆ GetWindow()

wxWindow* wxCaret::GetWindow ( ) const

Get the window the caret is associated with.

◆ Hide()

virtual void wxCaret::Hide ( )
virtual

Hides the caret, same as Show(false).

◆ IsOk()

bool wxCaret::IsOk ( ) const

Returns true if the caret was created successfully.

◆ IsVisible()

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).

◆ Move() [1/2]

void wxCaret::Move ( const wxPoint pt)

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

◆ Move() [2/2]

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

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

◆ SetBlinkTime()

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()

◆ SetSize() [1/2]

void wxCaret::SetSize ( const wxSize size)

Changes the size of the caret.

◆ SetSize() [2/2]

void wxCaret::SetSize ( int  width,
int  height 
)

Changes the size of the caret.

◆ Show()

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.