+2007-09-12 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Adam.
+
+ Fixing
+ <rdar://problem/5018591> Windows doesn't have a standard vertical text cursor
+ <rdar://problem/5224996> Add zoom in and zoom out cursors
+
+ Added SharedCursor for CursorWin so we can correctly track lifetime of custom/image
+ based cursors, such as the vertical text and zooming cursors.
+
+ * platform/Cursor.h:
+ (WebCore::SharedCursor::SharedCursor):
+ (WebCore::SharedCursor::~SharedCursor):
+ (WebCore::SharedCursor::nativeCursor):
+ * platform/win/CursorWin.cpp:
+ (WebCore::Cursor::Cursor):
+ (WebCore::loadCursorByName):
+ (WebCore::loadSharedCursor):
+ (WebCore::pointerCursor):
+ (WebCore::crossCursor):
+ (WebCore::handCursor):
+ (WebCore::iBeamCursor):
+ (WebCore::waitCursor):
+ (WebCore::helpCursor):
+ (WebCore::eastResizeCursor):
+ (WebCore::northResizeCursor):
+ (WebCore::northEastResizeCursor):
+ (WebCore::northWestResizeCursor):
+ (WebCore::southResizeCursor):
+ (WebCore::southEastResizeCursor):
+ (WebCore::southWestResizeCursor):
+ (WebCore::westResizeCursor):
+ (WebCore::northSouthResizeCursor):
+ (WebCore::eastWestResizeCursor):
+ (WebCore::northEastSouthWestResizeCursor):
+ (WebCore::northWestSouthEastResizeCursor):
+ (WebCore::columnResizeCursor):
+ (WebCore::rowResizeCursor):
+ (WebCore::moveCursor):
+ (WebCore::verticalTextCursor):
+ (WebCore::progressCursor):
+ (WebCore::notAllowedCursor):
+ (WebCore::zoomInCursor):
+ (WebCore::zoomOutCursor):
+ * platform/win/WidgetWin.cpp:
+ (WebCore::Widget::setCursor):
+
2007-09-12 Brady Eidson <beidson@apple.com>
Reviewed by Geoff Garen
ii.hbmMask = hMask;
ii.hbmColor = hCursor;
- m_impl = CreateIconIndirect(&ii);
+ m_impl = new SharedCursor(CreateIconIndirect(&ii));
DeleteObject(hMask);
DeleteObject(hCursor);
icon.yHotspot = hotspot.y();
icon.hbmMask = andMask;
icon.hbmColor = xorMask;
- m_impl = CreateIconIndirect(&icon);
+ m_impl = new SharedCursor(CreateIconIndirect(&icon));
DeleteObject(andMask);
DeleteObject(xorMask);
Cursor::~Cursor()
{
- DestroyIcon(m_impl);
}
Cursor& Cursor::operator=(const Cursor& other)
return *this;
}
-Cursor::Cursor(HCURSOR c)
+Cursor::Cursor(PlatformCursor c)
: m_impl(c)
{
}
+static Cursor loadCursorByName(char *name, int x, int y) {
+ IntPoint hotSpot(x, y);
+ Cursor c;
+ Image *cursorImage = Image::loadPlatformResource(name);
+ if (cursorImage && !cursorImage->isNull()) {
+ c = Cursor(cursorImage, hotSpot);
+ delete cursorImage;
+ } else
+ c = pointerCursor();
+ return c;
+}
+
+static PassRefPtr<SharedCursor> loadSharedCursor(HINSTANCE hInstance, LPCTSTR lpCursorName)
+{
+ return new SharedCursor(LoadCursor(hInstance, lpCursorName));
+}
+
const Cursor& pointerCursor()
{
- static Cursor c = LoadCursor(0, IDC_ARROW);
+ static Cursor c = loadSharedCursor(0, IDC_ARROW);
return c;
}
const Cursor& crossCursor()
{
- static Cursor c = LoadCursor(0, IDC_CROSS);
+ static Cursor c = loadSharedCursor(0, IDC_CROSS);
return c;
}
const Cursor& handCursor()
{
- static Cursor c = LoadCursor(0, IDC_HAND);
+ static Cursor c = loadSharedCursor(0, IDC_HAND);
return c;
}
const Cursor& iBeamCursor()
{
- static Cursor c = LoadCursor(0, IDC_IBEAM);
+ static Cursor c = loadSharedCursor(0, IDC_IBEAM);
return c;
}
const Cursor& waitCursor()
{
- static Cursor c = LoadCursor(0, IDC_WAIT);
+ static Cursor c = loadSharedCursor(0, IDC_WAIT);
return c;
}
const Cursor& helpCursor()
{
- static Cursor c = LoadCursor(0, IDC_HELP);
+ static Cursor c = loadSharedCursor(0, IDC_HELP);
return c;
}
const Cursor& eastResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZEWE);
+ static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
return c;
}
const Cursor& northResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENS);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENS);
return c;
}
const Cursor& northEastResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENESW);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
return c;
}
const Cursor& northWestResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENWSE);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
return c;
}
const Cursor& southResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENS);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENS);
return c;
}
const Cursor& southEastResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENWSE);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
return c;
}
const Cursor& southWestResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENESW);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
return c;
}
const Cursor& westResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZEWE);
+ static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
return c;
}
const Cursor& northSouthResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENS);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENS);
return c;
}
const Cursor& eastWestResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZEWE);
+ static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
return c;
}
const Cursor& northEastSouthWestResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENESW);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
return c;
}
const Cursor& northWestSouthEastResizeCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZENWSE);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
return c;
}
const Cursor& columnResizeCursor()
{
// FIXME: Windows does not have a standard column resize cursor <rdar://problem/5018591>
- static Cursor c = LoadCursor(0, IDC_SIZEWE);
+ static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
return c;
}
const Cursor& rowResizeCursor()
{
// FIXME: Windows does not have a standard row resize cursor <rdar://problem/5018591>
- static Cursor c = LoadCursor(0, IDC_SIZENS);
+ static Cursor c = loadSharedCursor(0, IDC_SIZENS);
return c;
}
const Cursor& moveCursor()
{
- static Cursor c = LoadCursor(0, IDC_SIZEALL);
+ static Cursor c = loadSharedCursor(0, IDC_SIZEALL);
return c;
}
const Cursor& verticalTextCursor()
{
- //FIXME: Windows doesn't have a standard vertical text cursor <rdar://problem/5018591>
- return pointerCursor();
+ static const Cursor c = loadCursorByName("verticalTextCursor", 7, 7);
+ return c;
}
const Cursor& cellCursor()
const Cursor& progressCursor()
{
- static Cursor c = LoadCursor(0, IDC_APPSTARTING);
+ static Cursor c = loadSharedCursor(0, IDC_APPSTARTING);
return c;
}
const Cursor& noDropCursor()
{
- static Cursor c = LoadCursor(0, IDC_NO);
+ static Cursor c = loadSharedCursor(0, IDC_NO);
return c;
}
const Cursor& notAllowedCursor()
{
- static Cursor c = LoadCursor(0, IDC_NO);
+ static Cursor c = loadSharedCursor(0, IDC_NO);
return c;
}
-// FIXME: <rdar://problem/5224996> Add zoom in and zoom out cursors
const Cursor& zoomInCursor()
{
- return pointerCursor();
+ static const Cursor c = loadCursorByName("zoomInCursor", 7, 7);
+ return c;
}
const Cursor& zoomOutCursor()
{
- return pointerCursor();
+ static const Cursor c = loadCursorByName("zoomOutCursor", 7, 7);
+ return c;
}
}