xtd 1.0.0
Loading...
Searching...
No Matches
xtd::forms::cursor Class Reference
Inheritance diagram for xtd::forms::cursor:
xtd::object xtd::iequatable< cursor > xtd::interface xtd::extensions::equality_operators< cursor, iequatable< cursor > >

Definition

Represents the image used to paint the mouse pointer.

Header
#include <xtd/forms/cursor>
Namespace
xtd::forms
Library
xtd.forms
Remarks
A cursor is a small picture whose location on the screen is controlled by a pointing device, such as a mouse, pen, or trackball. When the user moves the pointing device, the operating system moves the cursor accordingly.
Different cursor shapes are used to inform the user what operation the mouse will have. For example, when editing or selecting text, a cursors::ibeam cursor is typically displayed. A wait cursor is commonly used to inform the user that a process is currently running. Examples of processes you might have the user wait for are opening a file, saving a file, or filling a control such as a data_grid, list_box or tree_view with a large amount of data.
All controls that derive from the Control class have a Cursor property. To change the cursor displayed by the mouse pointer when it is within the bounds of the control, assign a Cursor to the Cursor property of the control. Alternatively, you can display cursors at the application level by assigning a Cursor to the Current property. For example, if the purpose of your application is to edit a text file, you might set the Current property to Cursors.WaitCursor to display a wait cursor over the application while the file loads or saves to prevent any mouse events from being processed. When the process is complete, set the Current property to Cursors.Default for the application to display the appropriate cursor over each control type.
See also
xtd::forms::cursors
Examples
The following code example demonstrates the use of cursor component.
#include <xtd/xtd>
class form1 : public form {
public:
form1() {
text("Cursor example");
location({200, 200});
client_size({360, 240});
list_box_loading_indicators.parent(*this);
list_box_loading_indicators.bounds({20, 20, 150, 200});
list_box_loading_indicators.anchor(anchor_styles::top | anchor_styles::left | anchor_styles::bottom);
list_box_loading_indicators.items().add_range({{"Default", cursors::default_cursor()}, {"Application Starting", cursors::app_starting()}, {"Arrow", cursors::arrow()}, {"Closed hand", cursors::closed_hand()}, {"Contextual menu", cursors::contextual_menu()}, {"Cell", cursors::cell()}, {"Cross", cursors::cross()}, {"Disappearing item", cursors::disappearing_item()}, {"Drag copy", cursors::drag_copy()}, {"Drag link", cursors::drag_link()}, {"Hand", cursors::hand()}, {"Help", cursors::help()}, {"Horizontal split", cursors::hsplit()}, {"I beam", cursors::ibeam()}, {"No", cursors::no()}, {"No drag", cursors::no_drag()}, {"No move 2d", cursors::no_move_2d()}, {"No move horizontal", cursors::no_move_horiz()}, {"No move vertical", cursors::no_move_vert()}, {"Open hand", cursors::open_hand()}, {"Pan east", cursors::pan_east()}, {"Pan north east", cursors::pan_ne()}, {"Pan north", cursors::pan_north()}, {"Pan north west", cursors::pan_nw()}, {"Pan south east", cursors::pan_se()}, {"Pan south", cursors::pan_south()}, {"Pan south west", cursors::pan_sw()}, {"Pan West", cursors::pan_west()}, {"Size all", cursors::size_all()}, {"Size north-east south-west", cursors::size_nesw()}, {"Size north south", cursors::size_ns()}, {"Size north-west south-east", cursors::size_nwse()}, {"Size west east", cursors::size_we()}, {"Up arrow", cursors::up_arrow()}, {"Vertical I beam", cursors::vibeam()}, {"Vertical split", cursors::vsplit()}, {"Wait", cursors::wait_cursor()}, {"Zoom in", cursors::zoom_in()}, {"Zoom out", cursors::zoom_out()}});
list_box_loading_indicators.selected_index_changed += delegate_ {
loading_indicator_panel.cursor(as<forms::cursor>(list_box_loading_indicators.selected_item().tag()));
};
list_box_loading_indicators.selected_item("Default");
loading_indicator_panel.parent(*this);
loading_indicator_panel.border_style(border_style::fixed_3d);
loading_indicator_panel.back_color(drawing::system_colors::window());
loading_indicator_panel.bounds({190, 20, 150, 200});
loading_indicator_panel.anchor(anchor_styles::top | anchor_styles::left | anchor_styles::bottom | anchor_styles::right);
}
private:
list_box list_box_loading_indicators;
panel loading_indicator_panel;
};
auto main() -> int {
application::run(form1 {});
}
virtual auto text() const noexcept -> const xtd::string &
Gets the text associated with this control.
virtual auto location() const noexcept -> xtd::drawing::point
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
virtual auto client_size() const noexcept -> const xtd::drawing::size &
Gets the height and width of the client area of the control.
static auto disappearing_item() -> xtd::forms::cursor
Gets the disappearing item cursor.
static auto no_move_horiz() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is not moving,...
static auto pan_sw() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto pan_west() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto zoom_out() -> xtd::forms::cursor
Gets the zoom out cursor, typically to zoom out an object.
static auto size_nesw() -> xtd::forms::cursor
Gets the two-headed diagonal (northeast/southwest) sizing cursor.
static auto size_nwse() -> xtd::forms::cursor
Gets the two-headed diagonal (northwest/southeast) sizing cursor.
static auto size_we() -> xtd::forms::cursor
Gets the two-headed diagonal (northwest/southeast) sizing cursor.
static auto vsplit() -> xtd::forms::cursor
Gets the cursor that appears when the mouse is positioned over a vertical splitter bar.
static auto open_hand() -> xtd::forms::cursor
Gets the open hand cursor.
static auto ibeam() -> xtd::forms::cursor
Gets the I-beam cursor, which is used to show where the text cursor appears when the mouse is clicked...
static auto zoom_in() -> xtd::forms::cursor
Gets the zoom_in cursor, typically to zoom in an object.
static auto cross() -> xtd::forms::cursor
Gets the crosshair cursor.
static auto drag_copy() -> xtd::forms::cursor
Gets the drag copy cursor.
static auto up_arrow() -> xtd::forms::cursor
Gets the up arrow cursor, typically used to identify an insertion point.
static auto drag_link() -> xtd::forms::cursor
Gets the drag link cursor.
static auto closed_hand() -> xtd::forms::cursor
Gets the closed hand cursor.
static auto vibeam() -> xtd::forms::cursor
Gets the vertical I-beam cursor, which is used to show where the text cursor appears when the mouse i...
static auto pan_se() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto wait_cursor() -> xtd::forms::cursor
Gets the wait cursor, typically an hourglass shape.
static auto no() -> xtd::forms::cursor
Gets the cursor that indicates that a particular region is invalid for the current operation.
static auto pan_north() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto no_move_2d() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is not moving,...
static auto hand() -> xtd::forms::cursor
Gets the hand cursor, typically used when hovering over a Web link.
static auto hsplit() -> xtd::forms::cursor
Gets the cursor that appears when the mouse is positioned over a horizontal splitter bar.
static auto size_all() -> xtd::forms::cursor
Gets the four-headed sizing cursor, which consists of four joined arrows that point north,...
static auto arrow() -> xtd::forms::cursor
Gets the arrow cursor.
static auto no_move_vert() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is not moving,...
static auto pan_nw() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto help() -> xtd::forms::cursor
Gets the Help cursor, which is a combination of an arrow and a question mark.
static auto pan_south() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto no_drag() -> xtd::forms::cursor
Gets the cursor that indicates that a particular region is invalid for the current drag & drop operat...
static auto cell() -> xtd::forms::cursor
Gets the cell cursor.
static auto contextual_menu() -> xtd::forms::cursor
Gets the contextual menu cursor.
static auto default_cursor() -> xtd::forms::cursor
Gets the default cursor, which is usually an arrow cursor.
static auto size_ns() -> xtd::forms::cursor
Gets the two-headed vertical (north/south) sizing cursor.
static auto pan_east() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto pan_ne() -> xtd::forms::cursor
Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrol...
static auto app_starting() -> xtd::forms::cursor
Gets the cursor that appears when an application starts.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
virtual auto start_position() const noexcept -> xtd::forms::form_start_position
Gets the starting position of the form at run time.
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:1018
xtd::forms::style_sheets::control panel
The panel data allows you to specify the box of a panel control.
Definition panel.hpp:25
@ manual
The position of the form is determined by the Location property.
Definition form_start_position.hpp:24

Public Fields

static cursor none
 Represent none cursor.

Public Constructors

 cursor ()
 Initializes a new instance of the cursor class.
 cursor (intptr handle)
 Initializes a new instance of the Cursor class from the specified Windows handle.

Public Properties

auto handle () const noexcept -> xtd::intptr
 Gets the handle of the cursor.
auto hot_spot () const noexcept -> xtd::drawing::point
 Gets the cursor hot spot.
auto size () const noexcept -> xtd::drawing::size
 Gets the size of the cursor object.
auto tag () const noexcept -> const xtd::any_object &
 Gets the object that contains data about the control.
auto tag (xtd::any_object value) -> cursor &
 Sets the object that contains data about the control.

Methodds

auto copy_handle () const -> xtd::intptr
 Copies the handle of this cursor.
auto equals (const xtd::object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
bool equals (const cursor &value) const noexcept override
 Determines whether the specified object is equal to the current object.
auto get_hash_code () const noexcept -> xtd::usize override
 Serves as a hash function for a particular type.
auto to_string () const noexcept -> xtd::string override
 Returns a string containing the name of the cursor.

Public Static Properties

static auto current () -> cursor
 Gets a cursor object that represents the mouse cursor.
static auto current (const cursor &cursor) -> void
 Sets a cursor object that represents the mouse cursor.
static auto position () -> xtd::drawing::point
 Gets the cursor's position.
static auto position (const xtd::drawing::point &position) -> void
 Sets the cursor's position.

Static methodds

static cursor from_bitmap (const xtd::drawing::bitmap &bitmap, const xtd::drawing::point &hot_spot)
 Create a cursor form a specified bitmap with specified hot spot.
static cursor from_bitmap (const xtd::drawing::bitmap &bitmap)
 Create a cursor form a specified bitmap.
static void hide ()
 Hides the cursor.
static void show ()
 Displays the cursor.

Additional Inherited Members

 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto equals (const cursor &) const noexcept -> bool=0
 Indicates whether the current object is equal to another object of the same type.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.

Constructor & Destructor Documentation

◆ cursor() [1/2]

xtd::forms::cursor::cursor ( )

Initializes a new instance of the cursor class.

◆ cursor() [2/2]

xtd::forms::cursor::cursor ( intptr handle)
explicit

Initializes a new instance of the Cursor class from the specified Windows handle.

Parameters
handleAn IntPtr that represents the Windows handle of the cursor to create.
Remarks
You must free the cursor handle when you are done with it.

Member Function Documentation

◆ handle()

auto xtd::forms::cursor::handle ( ) const -> xtd::intptr
nodiscardnoexcept

Gets the handle of the cursor.

Returns
An intptr that represents the cursor's handle.
Remarks
This is not a copy of the handle; do not destroy it.

◆ hot_spot()

auto xtd::forms::cursor::hot_spot ( ) const -> xtd::drawing::point
nodiscardnoexcept

Gets the cursor hot spot.

Returns
A point representing the cursor hot spot.
Remarks
The hot_spot is the point in the cursor that interacts with other elements on the screen.

◆ size()

auto xtd::forms::cursor::size ( ) const -> xtd::drawing::size
nodiscardnoexcept

Gets the size of the cursor object.

Returns
A size that represents the width and height of the cursor.

◆ tag() [1/2]

auto xtd::forms::cursor::tag ( ) const -> const xtd::any_object &
nodiscardnoexcept

Gets the object that contains data about the control.

Returns
A xtd::any_object that contains data about the control. The default is empty.
Remarks
Any type of class can be assigned to this property.

◆ tag() [2/2]

auto xtd::forms::cursor::tag ( xtd::any_object value) -> cursor &

Sets the object that contains data about the control.

Parameters
valueA xtd::any_object that contains data about the control. The default is empty.
Remarks
Any type of class can be assigned to this property.

◆ current() [1/2]

auto xtd::forms::cursor::current ( ) -> cursor
staticnodiscard

Gets a cursor object that represents the mouse cursor.

Returns
A cursor that represents the mouse cursor. The default is cursor::none.
Remarks
Setting the current property changes the cursor currently displayed. The application may or may not continue to listen for mouse events. To signal that the application should not respond to mouse events during a long-running operation, use the application::use_wait_cursor property. In most cases, however, it's better to use a background thread to manage a long-running operation, and leave your user interface accessible to the user.

◆ current() [2/2]

auto xtd::forms::cursor::current ( const cursor & cursor) -> void
static

Sets a cursor object that represents the mouse cursor.

Parameters
cursorA cursor that represents the mouse cursor. The default is cursor::none.
Remarks
Setting the current property changes the cursor currently displayed. The application may or may not continue to listen for mouse events. To signal that the application should not respond to mouse events during a long-running operation, use the application::use_wait_cursor property. In most cases, however, it's better to use a background thread to manage a long-running operation, and leave your user interface accessible to the user.

◆ position() [1/2]

auto xtd::forms::cursor::position ( ) -> xtd::drawing::point
staticnodiscard

Gets the cursor's position.

Returns
A point that represents the cursor's position in screen coordinates.
Remarks
The position property is identical to the control::mouse_position property.

◆ position() [2/2]

auto xtd::forms::cursor::position ( const xtd::drawing::point & position) -> void
static

Sets the cursor's position.

Parameters
positionA point that represents the cursor's position in screen coordinates.
Remarks
The position property is identical to the control::mouse_position property.

◆ copy_handle()

auto xtd::forms::cursor::copy_handle ( ) const -> xtd::intptr
nodiscard

Copies the handle of this cursor.

Returns
An intptr that represents the cursor's handle.
Remarks
The handle created as a result of calling this method must be deleted of when you are done with it.

◆ equals() [1/2]

auto xtd::forms::cursor::equals ( const xtd::object & obj) const -> bool
nodiscardoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/2]

bool xtd::forms::cursor::equals ( const cursor & value) const
nodiscardoverridenoexcept

Determines whether the specified object is equal to the current object.

Parameters
otherThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

◆ get_hash_code()

auto xtd::forms::cursor::get_hash_code ( ) const -> xtd::usize
nodiscardoverridevirtualnoexcept

Serves as a hash function for a particular type.

Returns
A hash code for the current object.

Reimplemented from xtd::object.

◆ to_string()

auto xtd::forms::cursor::to_string ( ) const -> xtd::string
nodiscardoverridevirtualnoexcept

Returns a string containing the name of the cursor.

Returns
A string containing the name of the cursor.

Reimplemented from xtd::object.

◆ from_bitmap() [1/2]

cursor xtd::forms::cursor::from_bitmap ( const xtd::drawing::bitmap & bitmap,
const xtd::drawing::point & hot_spot )
staticnodiscard

Create a cursor form a specified bitmap with specified hot spot.

Parameters
bitmapA xtd::drawing::bitmap image will be use by cursor.
hot_spotA xtd::drawing::point hot spot location.
Returns
A new cursor instance.

◆ from_bitmap() [2/2]

cursor xtd::forms::cursor::from_bitmap ( const xtd::drawing::bitmap & bitmap)
staticnodiscard

Create a cursor form a specified bitmap.

Parameters
bitmapA xtd::drawing::bitmap image will be use by cursor.
Returns
A new cursor instance.
Remarks
The hot spot location is top left (0, 0).

◆ hide()

void xtd::forms::cursor::hide ( )
static

Hides the cursor.

The show and hide method calls must be balanced. For every call to the hide method there must be a corresponding call to the show method.

◆ show()

void xtd::forms::cursor::show ( )
static

Displays the cursor.

The show and hide method calls must be balanced. For every call to the hide method there must be a corresponding call to the show method.

Member Data Documentation

◆ none

cursor xtd::forms::cursor::none
static

Represent none cursor.


The documentation for this class was generated from the following file: