]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/cursor.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxCursor class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/cursor.h"
25 #include "wx/os2/private.h"
29 #if !USE_SHARED_LIBRARIES
30 IMPLEMENT_DYNAMIC_CLASS(wxCursor
, wxBitmap
)
33 wxCursorRefData::wxCursorRefData(void)
35 m_width
= 32; m_height
= 32;
37 m_destroyCursor
= FALSE
;
40 wxCursorRefData::~wxCursorRefData(void)
42 // if ( m_hCursor && m_destroyCursor)
43 // ::DestroyCursor((HICON) m_hCursor);
47 wxCursor::wxCursor(void)
51 wxCursor::wxCursor(const char WXUNUSED(bits
)[], int WXUNUSED(width
), int WXUNUSED(height
),
52 int WXUNUSED(hotSpotX
), int WXUNUSED(hotSpotY
), const char WXUNUSED(maskBits
)[])
56 wxCursor::wxCursor(const wxString
& cursor_file
, long flags
, int hotSpotX
, int hotSpotY
)
58 m_refData
= new wxCursorRefData
;
60 M_CURSORDATA
->m_destroyCursor
= FALSE
;
61 M_CURSORDATA
->m_hCursor
= 0;
62 M_CURSORDATA
->m_ok
= FALSE
;
65 if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
67 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
68 if (M_CURSORDATA->m_hCursor)
69 M_CURSORDATA->m_ok = TRUE;
71 M_CURSORDATA->m_ok = FALSE;
73 else if (flags & wxBITMAP_TYPE_CUR)
75 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
77 else if (flags & wxBITMAP_TYPE_ICO)
80 else if (flags & wxBITMAP_TYPE_BMP)
86 // Cursors by stock number
87 wxCursor::wxCursor(int cursor_type
)
89 m_refData
= new wxCursorRefData
;
95 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
98 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
101 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
103 case wxCURSOR_SIZENWSE:
104 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
106 case wxCURSOR_SIZENESW:
107 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
109 case wxCURSOR_SIZEWE:
110 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
112 case wxCURSOR_SIZENS:
113 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
117 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
122 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
125 case wxCURSOR_BULLSEYE:
127 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
130 case wxCURSOR_PENCIL:
132 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
135 case wxCURSOR_MAGNIFIER:
137 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
140 case wxCURSOR_NO_ENTRY:
142 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_NO_ENTRY"));
145 case wxCURSOR_LEFT_BUTTON:
147 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
150 case wxCURSOR_RIGHT_BUTTON:
152 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
155 case wxCURSOR_MIDDLE_BUTTON:
157 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
160 case wxCURSOR_SIZING:
162 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
167 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
170 case wxCURSOR_SPRAYCAN:
172 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
175 case wxCURSOR_PAINT_BRUSH:
177 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
180 case wxCURSOR_POINT_LEFT:
182 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
185 case wxCURSOR_POINT_RIGHT:
187 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
190 case wxCURSOR_QUESTION_ARROW:
192 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
197 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
202 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
208 wxCursor::~wxCursor(void)
210 // FreeResource(TRUE);
213 bool wxCursor::FreeResource(bool WXUNUSED(force
))
215 // if (M_CURSORDATA && M_CURSORDATA->m_hCursor && M_CURSORDATA->m_destroyCursor)
217 // DestroyCursor((HCURSOR) M_CURSORDATA->m_hCursor);
218 // M_CURSORDATA->m_hCursor = 0;
223 void wxCursor::SetHCURSOR(WXHCURSOR cursor
)
226 m_refData
= new wxCursorRefData
;
228 M_CURSORDATA
->m_hCursor
= cursor
;
231 // Global cursor setting
232 void wxSetCursor(const wxCursor
& cursor
)
234 extern wxCursor
*g_globalCursor
;
236 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
238 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
240 if ( g_globalCursor
)
241 (*g_globalCursor
) = cursor
;