wxWidgets: wxCaret Class Reference

| Version: 3.0.2

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
wxCaret Class Reference
Miscellaneous

`#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.
wxWindow * | GetWindow () const
| Get the window the caret is associated with.
virtual void | Hide ()
| Hides the caret, same as Show(false).
bool | IsOk () const
| Returns true if the caret was created successfully.
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).
virtual void | Show (bool show=true)
| Shows or hides the caret.
| wxCaret (wxWindow *window, int width, int height)
| Creates a caret with the given size (in pixels) and associates it with the window.
| wxCaret (wxWindow *window, const wxSize &size)
| Creates a caret with the given size (in pixels) and associates it with the window.
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).
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).
void | GetPosition (int *x, int *y) const
| Get the caret position (in pixels).
wxPoint | GetPosition () const
| Get the caret position (in pixels).
void | GetSize (int *width, int *height) const
| Get the caret size.
wxSize | GetSize () const
| Get the caret size.
void | Move (int x, int y)
| Move the caret to given position (in logical coordinates).
void | Move (const wxPoint &pt)
| Move the caret to given position (in logical coordinates).
void | SetSize (int width, int height)
| Changes the size of the caret.
void | SetSize (const wxSize &size)
| Changes the size of the caret.

## 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).
static void | SetBlinkTime (int milliseconds)
| Sets the blink time for all the carets.

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