KiCad PCB EDA Suite
cursor_store.cpp File Reference
#include <cursor_store.h>
#include <wx/bitmap.h>
#include <wx/debug.h>

Go to the source code of this file.

Functions

wxCursor constructCursor (const CURSOR_STORE::CURSOR_DEF &aDef)
 Construct a cursor for the given definition. More...
 

Function Documentation

◆ constructCursor()

wxCursor constructCursor ( const CURSOR_STORE::CURSOR_DEF aDef)

Construct a cursor for the given definition.

How to do this depends on the platform, see http://docs.wxwidgets.org/trunk/classwx_cursor.html

Parameters
aDefthe cursor definition
Returns
a newly constructed cursor if the platform is supported, else wxNullCursor

Definition at line 40 of file cursor_store.cpp.

41 {
42 #if defined( __WXMSW__ ) or defined( __WXMAC__ )
43 
44  wxBitmap img_bitmap(
45  reinterpret_cast<const char*>( aDef.m_image_data ), aDef.m_size.x, aDef.m_size.y );
46  wxBitmap msk_bitmap(
47  reinterpret_cast<const char*>( aDef.m_mask_data ), aDef.m_size.x, aDef.m_size.y );
48  img_bitmap.SetMask( new wxMask( msk_bitmap ) );
49 
50  wxImage image( img_bitmap.ConvertToImage() );
51 
52 #if defined( __WXMSW__ )
53  image.SetMaskColour( 255, 255, 255 );
54 #endif
55 
56  image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, aDef.m_hotspot.x );
57  image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, aDef.m_hotspot.y );
58 
59  return wxCursor{ image };
60 
61 #elif defined( __WXGTK__ ) or defined( __WXMOTIF__ )
62 
63  return wxCursor{
64  reinterpret_cast<const char*>( aDef.m_image_data ),
65  aDef.m_size.x,
66  aDef.m_size.y,
67  aDef.m_hotspot.x,
68  aDef.m_hotspot.y,
69  reinterpret_cast<const char*>( aDef.m_mask_data ),
70  };
71 
72 #else
73  wxASSERT_MSG( false, "Unknown platform for cursor construction." );
74  return wxNullCursor;
75 #endif
76 }
const unsigned char * m_mask_data
The mask data bitmap
Definition: cursor_store.h:54
const unsigned char * m_image_data
The image data bitmap
Definition: cursor_store.h:51
wxSize m_size
The image size in pixels
Definition: cursor_store.h:57
wxPoint m_hotspot
The "hotspot" where the cursor "is" in the image
Definition: cursor_store.h:60

References CURSOR_STORE::CURSOR_DEF::m_hotspot, CURSOR_STORE::CURSOR_DEF::m_image_data, CURSOR_STORE::CURSOR_DEF::m_mask_data, and CURSOR_STORE::CURSOR_DEF::m_size.

Referenced by CURSOR_STORE::CURSOR_STORE().