]>
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)
38 m_destroyCursor
= FALSE
;
41 wxCursorRefData::~wxCursorRefData(void)
43 // if ( m_hCursor && m_destroyCursor)
44 // ::DestroyCursor((HICON) m_hCursor);
48 wxCursor::wxCursor(void)
52 wxCursor::wxCursor(const char WXUNUSED(bits
)[], int WXUNUSED(width
), int WXUNUSED(height
),
53 int WXUNUSED(hotSpotX
), int WXUNUSED(hotSpotY
), const char WXUNUSED(maskBits
)[])
57 wxCursor::wxCursor(const wxString
& cursor_file
, long flags
, int hotSpotX
, int hotSpotY
)
59 m_refData
= new wxCursorRefData
;
61 M_CURSORDATA
->m_destroyCursor
= FALSE
;
62 M_CURSORDATA
->m_hCursor
= 0;
65 M_CURSORDATA->m_bOK = FALSE;
66 if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
68 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
69 if (M_CURSORDATA->m_hCursor)
70 M_CURSORDATA->m_ok = TRUE;
72 M_CURSORDATA->m_ok = FALSE;
74 else if (flags & wxBITMAP_TYPE_CUR)
76 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
78 else if (flags & wxBITMAP_TYPE_ICO)
81 else if (flags & wxBITMAP_TYPE_BMP)
87 // Cursors by stock number
88 wxCursor::wxCursor(int cursor_type
)
90 m_refData
= new wxCursorRefData
;
96 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
99 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
102 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
104 case wxCURSOR_SIZENWSE:
105 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
107 case wxCURSOR_SIZENESW:
108 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
110 case wxCURSOR_SIZEWE:
111 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
113 case wxCURSOR_SIZENS:
114 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
118 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
123 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
126 case wxCURSOR_BULLSEYE:
128 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
131 case wxCURSOR_PENCIL:
133 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
136 case wxCURSOR_MAGNIFIER:
138 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
141 case wxCURSOR_NO_ENTRY:
143 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_NO_ENTRY"));
146 case wxCURSOR_LEFT_BUTTON:
148 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
151 case wxCURSOR_RIGHT_BUTTON:
153 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
156 case wxCURSOR_MIDDLE_BUTTON:
158 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
161 case wxCURSOR_SIZING:
163 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
168 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
171 case wxCURSOR_SPRAYCAN:
173 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
176 case wxCURSOR_PAINT_BRUSH:
178 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
181 case wxCURSOR_POINT_LEFT:
183 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
186 case wxCURSOR_POINT_RIGHT:
188 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
191 case wxCURSOR_QUESTION_ARROW:
193 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
198 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
203 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
209 wxCursor::~wxCursor(void)
211 // FreeResource(TRUE);
214 bool wxCursor::FreeResource(bool WXUNUSED(force
))
216 // if (M_CURSORDATA && M_CURSORDATA->m_hCursor && M_CURSORDATA->m_destroyCursor)
218 // DestroyCursor((HCURSOR) M_CURSORDATA->m_hCursor);
219 // M_CURSORDATA->m_hCursor = 0;
224 void wxCursor::SetHCURSOR(WXHCURSOR cursor
)
227 m_refData
= new wxCursorRefData
;
229 M_CURSORDATA
->m_hCursor
= cursor
;
232 // Global cursor setting
233 void wxSetCursor(const wxCursor
& cursor
)
235 extern wxCursor
*g_globalCursor
;
237 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
239 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
241 if ( g_globalCursor
)
242 (*g_globalCursor
) = cursor
;