Example #1
0
void Cursor::ensurePlatformCursor() const
{
    if (m_platformCursor || m_type == Cursor::Pointer)
        return;

    switch (m_type) {
    case Cursor::Pointer:
        // A null GdkCursor is the default cursor for the window.
        m_platformCursor = 0;
        break;
    case Cursor::Cross:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_CROSS));
        break;
    case Cursor::Hand:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_HAND2));
        break;
    case Cursor::IBeam:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_XTERM));
        break;
    case Cursor::Wait:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_WATCH));
        break;
    case Cursor::Help:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_QUESTION_ARROW));
        break;
    case Cursor::Move:
    case Cursor::MiddlePanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_FLEUR));
        break;
    case Cursor::EastResize:
    case Cursor::EastPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_RIGHT_SIDE));
        break;
    case Cursor::NorthResize:
    case Cursor::NorthPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_TOP_SIDE));
        break;
    case Cursor::NorthEastResize:
    case Cursor::NorthEastPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_LEFT_SIDE));
        break;
    case Cursor::NorthWestResize:
    case Cursor::NorthWestPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_TOP_LEFT_CORNER));
        break;
    case Cursor::SouthResize:
    case Cursor::SouthPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_BOTTOM_SIDE));
        break;
    case Cursor::SouthEastResize:
    case Cursor::SouthEastPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER));
        break;
    case Cursor::SouthWestResize:
    case Cursor::SouthWestPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_BOTTOM_LEFT_CORNER));
        break;
    case Cursor::WestResize:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_LEFT_SIDE));
        break;
    case Cursor::NorthSouthResize:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_TOP_TEE));
        break;
    case Cursor::EastWestResize:
    case Cursor::WestPanning:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_LEFT_SIDE));
        break;
    case Cursor::NorthEastSouthWestResize:
    case Cursor::NorthWestSouthEastResize:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_SIZING));
        break;
    case Cursor::ColumnResize:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW));
        break;
    case Cursor::RowResize:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW));
        break;
    case Cursor::VerticalText:
        m_platformCursor = createNamedCursor(CustomCursorVerticalText);
        break;
    case Cursor::Cell:
        m_platformCursor = adoptGRef(gdk_cursor_new(GDK_PLUS));
        break;
    case Cursor::ContextMenu:
        m_platformCursor = createNamedCursor(CustomCursorContextMenu);
        break;
    case Cursor::Alias:
        m_platformCursor = createNamedCursor(CustomCursorAlias);
        break;
    case Cursor::Progress:
        m_platformCursor = createNamedCursor(CustomCursorProgress);
        break;
    case Cursor::NoDrop:
    case Cursor::NotAllowed:
        m_platformCursor = createNamedCursor(CustomCursorNoDrop);
        break;
    case Cursor::Copy:
        m_platformCursor = createNamedCursor(CustomCursorCopy);
        break;
    case Cursor::None:
        m_platformCursor = createNamedCursor(CustomCursorNone);
        break;
    case Cursor::ZoomIn:
        m_platformCursor = createNamedCursor(CustomCursorZoomIn);
        break;
    case Cursor::ZoomOut:
        m_platformCursor = createNamedCursor(CustomCursorZoomOut);
        break;
    case Cursor::Grab:
        m_platformCursor = createNamedCursor(CustomCursorGrab);
        break;
    case Cursor::Grabbing:
        m_platformCursor = createNamedCursor(CustomCursorGrabbing);
        break;
    case Cursor::Custom:
        m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot);
        break;
    }
}
Example #2
0
void Cursor::ensurePlatformCursor() const
{
    if (m_platformCursor || m_type == Cursor::Pointer)
        return;

    switch (m_type) {
    case Cursor::Pointer:
        // A null GdkCursor is the default cursor for the window.
        m_platformCursor = 0;
        break;
    case Cursor::Cross:
        m_platformCursor = createNamedCursor("crosshair");
        break;
    case Cursor::Hand:
        m_platformCursor = createNamedCursor("pointer");
        break;
    case Cursor::IBeam:
        m_platformCursor = createNamedCursor("text");
        break;
    case Cursor::Wait:
        m_platformCursor = createNamedCursor("wait");
        break;
    case Cursor::Help:
        m_platformCursor = createNamedCursor("help");
        break;
    case Cursor::Move:
    case Cursor::MiddlePanning:
        m_platformCursor = createNamedCursor("move");
        break;
    case Cursor::EastResize:
    case Cursor::EastPanning:
        m_platformCursor = createNamedCursor("e-resize");
        break;
    case Cursor::NorthResize:
    case Cursor::NorthPanning:
        m_platformCursor = createNamedCursor("n-resize");
        break;
    case Cursor::NorthEastResize:
    case Cursor::NorthEastPanning:
        m_platformCursor = createNamedCursor("ne-resize");
        break;
    case Cursor::NorthWestResize:
    case Cursor::NorthWestPanning:
        m_platformCursor = createNamedCursor("nw-resize");
        break;
    case Cursor::SouthResize:
    case Cursor::SouthPanning:
        m_platformCursor = createNamedCursor("s-resize");
        break;
    case Cursor::SouthEastResize:
    case Cursor::SouthEastPanning:
        m_platformCursor = createNamedCursor("se-resize");
        break;
    case Cursor::SouthWestResize:
    case Cursor::SouthWestPanning:
        m_platformCursor = createNamedCursor("sw-resize");
        break;
    case Cursor::WestResize:
    case Cursor::WestPanning:
        m_platformCursor = createNamedCursor("w-resize");
        break;
    case Cursor::NorthSouthResize:
        m_platformCursor = createNamedCursor("ns-resize");
        break;
    case Cursor::EastWestResize:
        m_platformCursor = createNamedCursor("ew-resize");
        break;
    case Cursor::NorthEastSouthWestResize:
        m_platformCursor = createNamedCursor("nesw-resize");
        break;
    case Cursor::NorthWestSouthEastResize:
        m_platformCursor = createNamedCursor("nwse-resize");
        break;
    case Cursor::ColumnResize:
        m_platformCursor = createNamedCursor("col-resize");
        break;
    case Cursor::RowResize:
        m_platformCursor = createNamedCursor("row-resize");
        break;
    case Cursor::VerticalText:
        m_platformCursor = createNamedCursor("vertical-text");
        break;
    case Cursor::Cell:
        m_platformCursor = createNamedCursor("cell");
        break;
    case Cursor::ContextMenu:
        m_platformCursor = createNamedCursor("context-menu");
        break;
    case Cursor::Alias:
        m_platformCursor = createNamedCursor("alias");
        break;
    case Cursor::Progress:
        m_platformCursor = createNamedCursor("progress");
        break;
    case Cursor::NoDrop:
        m_platformCursor = createNamedCursor("no-drop");
        break;
    case Cursor::NotAllowed:
        m_platformCursor = createNamedCursor("not-allowed");
        break;
    case Cursor::Copy:
        m_platformCursor = createNamedCursor("copy");
        break;
    case Cursor::None:
        m_platformCursor = createNamedCursor("none");
        break;
    case Cursor::ZoomIn:
        m_platformCursor = createNamedCursor("zoom-in");
        break;
    case Cursor::ZoomOut:
        m_platformCursor = createNamedCursor("zoom-out");
        break;
    case Cursor::Grab:
        m_platformCursor = createNamedCursor("grab");
        break;
    case Cursor::Grabbing:
        m_platformCursor = createNamedCursor("grabbing");
        break;
    case Cursor::Custom:
        m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot);
        break;
    }
}