Example #1
0
    def set_mouse_platform_visible(self, platform_visible=None):
        if platform_visible is None:
            platform_visible = (self._mouse_visible and
                                not self._exclusive_mouse and
                                not self._mouse_cursor.drawable) or \
                               (not self._mouse_in_window or
                                not self._has_focus)

        if platform_visible and not self._mouse_cursor.drawable:
            if isinstance(self._mouse_cursor, Win32MouseCursor):
                cursor = self._mouse_cursor.cursor
            else:
                cursor = _user32.LoadCursorW(None, MAKEINTRESOURCE(IDC_ARROW))
            _user32.SetClassLongW(self._view_hwnd, GCL_HCURSOR, cursor)
            _user32.SetCursor(cursor)

        if platform_visible == self._mouse_platform_visible:
            return

        # Avoid calling ShowCursor with the current visibility (which would
        # push the counter too far away from zero).
        global _win32_cursor_visible
        if _win32_cursor_visible != platform_visible:
            _user32.ShowCursor(platform_visible)
            _win32_cursor_visible = platform_visible

        self._mouse_platform_visible = platform_visible
Example #2
0
    def get_system_mouse_cursor(self, name):
        if name == self.CURSOR_DEFAULT:
            return DefaultMouseCursor()

        names = {
            self.CURSOR_CROSSHAIR: IDC_CROSS,
            self.CURSOR_HAND: IDC_HAND,
            self.CURSOR_HELP: IDC_HELP,
            self.CURSOR_NO: IDC_NO,
            self.CURSOR_SIZE: IDC_SIZEALL,
            self.CURSOR_SIZE_UP: IDC_SIZENS,
            self.CURSOR_SIZE_UP_RIGHT: IDC_SIZENESW,
            self.CURSOR_SIZE_RIGHT: IDC_SIZEWE,
            self.CURSOR_SIZE_DOWN_RIGHT: IDC_SIZENWSE,
            self.CURSOR_SIZE_DOWN: IDC_SIZENS,
            self.CURSOR_SIZE_DOWN_LEFT: IDC_SIZENESW,
            self.CURSOR_SIZE_LEFT: IDC_SIZEWE,
            self.CURSOR_SIZE_UP_LEFT: IDC_SIZENWSE,
            self.CURSOR_SIZE_UP_DOWN: IDC_SIZENS,
            self.CURSOR_SIZE_LEFT_RIGHT: IDC_SIZEWE,
            self.CURSOR_TEXT: IDC_IBEAM,
            self.CURSOR_WAIT: IDC_WAIT,
            self.CURSOR_WAIT_ARROW: IDC_APPSTARTING,
        }
        if name not in names:
            raise RuntimeError('Unknown cursor name "%s"' % name)
        cursor = _user32.LoadCursorW(None, MAKEINTRESOURCE(names[name]))
        return Win32MouseCursor(cursor)
Example #3
0
    def set_mouse_platform_visible(self, platform_visible=None):
        if platform_visible is None:
            platform_visible = (self._mouse_visible and
                                not self._exclusive_mouse and
                                (not self._mouse_cursor.gl_drawable or self._mouse_cursor.hw_drawable)) or \
                               (not self._mouse_in_window or
                                not self._has_focus)

        if platform_visible and self._mouse_cursor.hw_drawable:
            if isinstance(self._mouse_cursor, Win32MouseCursor):
                cursor = self._mouse_cursor.cursor
            elif isinstance(self._mouse_cursor, DefaultMouseCursor):
                cursor = _user32.LoadCursorW(None, MAKEINTRESOURCE(IDC_ARROW))
            else:
                cursor = self._create_cursor_from_image(self._mouse_cursor)

            _user32.SetClassLongW(self._view_hwnd, GCL_HCURSOR, cursor)
            _user32.SetCursor(cursor)

        if platform_visible == self._mouse_platform_visible:
            return

        self._set_cursor_visibility(platform_visible)

        self._mouse_platform_visible = platform_visible