X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ffa3d6b8a38a13b84b727697b59cc8742174cdc0..c1d8296a78d1f630952fc5395e4072c8a654b8ef:/src/motif/cursor.cpp diff --git a/src/motif/cursor.cpp b/src/motif/cursor.cpp index 3c5f636840..deddb7a41c 100644 --- a/src/motif/cursor.cpp +++ b/src/motif/cursor.cpp @@ -1,17 +1,16 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: cursor.cpp +// Name: src/motif/cursor.cpp // Purpose: wxCursor class // Author: Julian Smart // Modified by: // Created: 17/09/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "cursor.h" -#endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" #include "wx/cursor.h" #include "wx/app.h" @@ -20,7 +19,7 @@ #include "wx/window.h" #if wxUSE_IMAGE #include "wx/image.h" -#endif +#endif #ifdef __VMS__ #pragma message disable nosimpint @@ -44,7 +43,7 @@ public: WX_DECLARE_LIST(wxXCursor, wxXCursorList); #include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxXCursorList); +WX_DEFINE_LIST(wxXCursorList) class WXDLLEXPORT wxCursorRefData: public wxObjectRefData { @@ -52,9 +51,9 @@ class WXDLLEXPORT wxCursorRefData: public wxObjectRefData public: wxCursorRefData(); ~wxCursorRefData(); - + wxXCursorList m_cursors; // wxXCursor objects, one per display - wxStockCursor m_cursorId; // wxWindows standard cursor id + wxStockCursor m_cursorId; // wxWidgets standard cursor id }; #define M_CURSORDATA ((wxCursorRefData *)m_refData) @@ -69,7 +68,7 @@ wxCursorRefData::wxCursorRefData() wxCursorRefData::~wxCursorRefData() { - wxXCursorList::Node* node = m_cursors.GetFirst(); + wxXCursorList::compatibility_iterator node = m_cursors.GetFirst(); while (node) { wxXCursor* c = node->GetData(); @@ -95,7 +94,8 @@ wxCursor::wxCursor(const wxImage & image) unsigned char * bits = new unsigned char [imagebitcount]; unsigned char * maskBits = new unsigned char [imagebitcount]; - int i, j, i8; unsigned char c, cMask; + int i, j, i8; + unsigned char c, cMask; for (i=0; i mid grey + c = (unsigned char)(rgbBits[(i8+j)*3]/3 + rgbBits[(i8+j)*3+1]/3 + rgbBits[(i8+j)*3+2]/3); + // if average value is > mid grey if (c>127) bits[i] = bits[i] & cMask; - cMask = (cMask << 1) | 1; + cMask = (unsigned char)((cMask << 1) | 1); } } @@ -130,7 +130,7 @@ wxCursor::wxCursor(const wxImage & image) { if (rgbBits[(i8+j)*3] != r || rgbBits[(i8+j)*3+1] != g || rgbBits[(i8+j)*3+2] != b) maskBits[i] = maskBits[i] | cMask; - cMask = (cMask << 1); + cMask = (unsigned char)(cMask << 1); } } } @@ -143,13 +143,13 @@ wxCursor::wxCursor(const wxImage & image) int hotSpotX; int hotSpotY; - if (image.HasOption(wxCUR_HOTSPOT_X)) - hotSpotX = image.GetOptionInt(wxCUR_HOTSPOT_X); + if (image.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_X)) + hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X); else hotSpotX = 0; - if (image.HasOption(wxCUR_HOTSPOT_Y)) - hotSpotY = image.GetOptionInt(wxCUR_HOTSPOT_Y); + if (image.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y)) + hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y); else hotSpotY = 0; @@ -220,7 +220,7 @@ void wxCursor::Create(WXPixmap pixmap, WXPixmap mask_pixmap, (Pixmap)mask_pixmap, &foreground_color, &background_color, - hotSpotX , + hotSpotX , hotSpotY); if (cursor) @@ -295,11 +295,11 @@ bool wxCursor::Ok() const } // Motif-specific: create/get a cursor for the current display -WXCursor wxCursor::GetXCursor(WXDisplay* display) +WXCursor wxCursor::GetXCursor(WXDisplay* display) const { if (!M_CURSORDATA) return (WXCursor) 0; - wxXCursorList::Node* node = M_CURSORDATA->m_cursors.GetFirst(); + wxXCursorList::compatibility_iterator node = M_CURSORDATA->m_cursors.GetFirst(); while (node) { wxXCursor* c = node->GetData(); @@ -330,7 +330,7 @@ WXCursor wxCursor::GetXCursor(WXDisplay* display) } // Make a cursor from standard id -WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id) +WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id) const { Display* dpy = (Display*) display; Cursor cursor = (Cursor) 0; @@ -338,17 +338,18 @@ WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id) switch (id) { + case wxCURSOR_CHAR: return (WXCursor)cursor; + case wxCURSOR_WAIT: x_cur = XC_watch; break; - case wxCURSOR_CROSS: x_cur = XC_crosshair; break; - case wxCURSOR_CHAR: return (WXCursor)cursor; break; + case wxCURSOR_CROSS: x_cur = XC_crosshair; break; case wxCURSOR_HAND: x_cur = XC_hand1; break; case wxCURSOR_BULLSEYE: x_cur = XC_target; break; - case wxCURSOR_PENCIL: x_cur = XC_pencil; break; - case wxCURSOR_MAGNIFIER: x_cur = XC_sizing; break; - case wxCURSOR_IBEAM: x_cur = XC_xterm; break; + case wxCURSOR_PENCIL: x_cur = XC_pencil; break; + case wxCURSOR_MAGNIFIER: x_cur = XC_sizing; break; + case wxCURSOR_IBEAM: x_cur = XC_xterm; break; case wxCURSOR_NO_ENTRY: x_cur = XC_pirate; break; - case wxCURSOR_LEFT_BUTTON: x_cur = XC_leftbutton; break; - case wxCURSOR_RIGHT_BUTTON: x_cur = XC_rightbutton; break; + case wxCURSOR_LEFT_BUTTON: x_cur = XC_leftbutton; break; + case wxCURSOR_RIGHT_BUTTON: x_cur = XC_rightbutton; break; case wxCURSOR_MIDDLE_BUTTON: x_cur = XC_middlebutton; break; case wxCURSOR_QUESTION_ARROW: x_cur = XC_question_arrow; break; case wxCURSOR_SIZING: x_cur = XC_sizing; break; @@ -452,7 +453,7 @@ wxXSetBusyCursor (wxWindow * win, wxCursor * cursor) XFlush (display); - for(wxWindowList::Node *node = win->GetChildren().GetFirst (); node; + for(wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst (); node; node = node->GetNext()) { wxWindow *child = node->GetData (); @@ -466,7 +467,7 @@ void wxBeginBusyCursor(wxCursor *cursor) wxBusyCursorCount++; if (wxBusyCursorCount == 1) { - for(wxWindowList::Node *node = wxTopLevelWindows.GetFirst (); node; + for(wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst (); node; node = node->GetNext()) { wxWindow *win = node->GetData (); @@ -484,7 +485,7 @@ void wxEndBusyCursor() wxBusyCursorCount--; if (wxBusyCursorCount == 0) { - for(wxWindowList::Node *node = wxTopLevelWindows.GetFirst (); node; + for(wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst (); node; node = node->GetNext()) { wxWindow *win = node->GetData (); @@ -493,7 +494,7 @@ void wxEndBusyCursor() } } -// TRUE if we're between the above two calls +// true if we're between the above two calls bool wxIsBusy() { return (wxBusyCursorCount > 0);