Example #1
0
 def test_constructor(self):
     attribute = Gdk.WindowAttr()
     attribute.window_type = Gdk.WindowType.CHILD
     attributes_mask = Gdk.WindowAttributesType.X | \
         Gdk.WindowAttributesType.Y
     window = Gdk.Window(None, attribute, attributes_mask)
     self.assertEqual(window.get_window_type(), Gdk.WindowType.CHILD)
Example #2
0
    def do_realize(self):
        self.set_realized(True)

        allocation = self.get_allocation()
        if self._spammy_debug:
            log.debug("allocation={x=%r, y=%r, w=%r, h=%r}",
                      allocation.x, allocation.y,
                      allocation.width, allocation.height)

        attributes = Gdk.WindowAttr()
        attributes.window_type = Gdk.WindowType.CHILD
        attributes.x = allocation.x
        attributes.y = allocation.y
        attributes.width = allocation.width
        attributes.height = allocation.height
        attributes.wclass = Gdk.WindowWindowClass.INPUT_OUTPUT
        attributes.visual = self.get_visual()
        attributes.event_mask = self.get_events() | Gdk.EventMask.EXPOSURE_MASK

        window = Gdk.Window.new(self.get_parent_window(), attributes,
                                Gdk.WindowAttributesType.VISUAL |
                                Gdk.WindowAttributesType.X |
                                Gdk.WindowAttributesType.Y)
        self.register_window(window)
        self.set_window(window)
Example #3
0
    def do_realize(self):
        """ Called when the widget should create all of its
        windowing resources.  We will create our window here """
        self.set_realized(True)
        allocation = self.get_allocation()
        attr = Gdk.WindowAttr()
        attr.window_type = Gdk.WindowType.CHILD
        attr.wclass = Gdk.WindowWindowClass.INPUT_OUTPUT
        attr.width = allocation.width
        attr.height = allocation.height
        attr.x = allocation.x
        attr.y = allocation.y
        attr.visual = self.get_visual()
        attr.event_mask = (
            self.get_events() |
            Gdk.EventMask.EXPOSURE_MASK |
            Gdk.EventMask.BUTTON_PRESS_MASK)
        wat = Gdk.WindowAttributesType
        mask = wat.X | wat.Y | wat.VISUAL
        window = Gdk.Window(self.get_parent_window(), attr, mask)
        # Associate the gdk.Window with ourselves,
        # Gtk+ needs a reference between the widget and the gdk window
        window.set_user_data(self)

        display = Gdk.Display.get_default()
        cursor = Gdk.Cursor.new_for_display(display, Gdk.CursorType.HAND2)
        window.set_cursor(cursor)

        self.set_window(window)
Example #4
0
    def do_realize(self):
        self.set_realized(True)

        allocation = self.get_allocation()

        attr = Gdk.WindowAttr()
        attr.window_type = Gdk.WindowType.CHILD
        attr.wclass = Gdk.WindowWindowClass.INPUT_OUTPUT
        attr.event_mask = self.get_events(
        ) | Gdk.EventMask.EXPOSURE_MASK | Gdk.EventMask.BUTTON_PRESS_MASK
        attr.x = 0
        attr.y = 0
        attr.width = allocation.width
        attr.height = allocation.height

        mask = Gdk.WindowAttributesType.X | Gdk.WindowAttributesType.Y
        window = Gdk.Window.new(self.get_parent_window(), attr, mask)
        self.set_window(window)

        window.set_user_data(self)
        self.style = self.get_style()
        self.style.set_background(window, Gtk.StateFlags.NORMAL)

        self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.BOTTOM_SIDE))
        self.connect("draw", self.onDraw)
Example #5
0
    def realize(self, widget):
        attr = Gdk.WindowAttr()
        attr.window_type = Gdk.WindowType.CHILD
        attr.x = self._area_x
        attr.y = self._area_y
        attr.width = self._area_width
        attr.height = self._area_height
        attr.wclass = Gdk.WindowWindowClass.INPUT_OUTPUT
        attr.event_mask = (widget.get_events() |
                           Gdk.EventMask.BUTTON_PRESS_MASK |
                           Gdk.EventMask.BUTTON_RELEASE_MASK |
                           Gdk.EventMask.ENTER_NOTIFY_MASK |
                           Gdk.EventMask.LEAVE_NOTIFY_MASK |
                           Gdk.EventMask.POINTER_MOTION_MASK)
        attr.cursor = Gdk.Cursor.new_for_display(widget.get_display(),
                                                 Gdk.CursorType.
                                                 SB_H_DOUBLE_ARROW)
        attr_mask = (Gdk.WindowAttributesType.X |
                     Gdk.WindowAttributesType.Y |
                     Gdk.WindowAttributesType.CURSOR)

        parent = widget.get_parent_window()
        self._window = Gdk.Window(parent, attr, attr_mask)
        self._window.handle = self
        self._widget = widget
        self._widget.register_window(self._window)
Example #6
0
def GDKWindow(parent=None, width=1, height=1, window_type=Gdk.WindowType.TOPLEVEL,
              event_mask=0, wclass=Gdk.WindowWindowClass.INPUT_OUTPUT, title=None,
              x=None, y=None, override_redirect=False, visual=None) -> Gdk.Window:
    attributes_mask = 0
    attributes = Gdk.WindowAttr()
    if x is not None:
        attributes.x = x
        attributes_mask |= Gdk.WindowAttributesType.X
    if y is not None:
        attributes.y = y
        attributes_mask |= Gdk.WindowAttributesType.Y
    #attributes.type_hint = Gdk.WindowTypeHint.NORMAL
    #attributes_mask |= Gdk.WindowAttributesType.TYPE_HINT
    attributes.width = width
    attributes.height = height
    attributes.window_type = window_type
    if title:
        attributes.title = title
        attributes_mask |= Gdk.WindowAttributesType.TITLE
    if visual:
        attributes.visual = visual
        attributes_mask |= Gdk.WindowAttributesType.VISUAL
    #OR:
    attributes.override_redirect = override_redirect
    attributes_mask |= Gdk.WindowAttributesType.NOREDIR
    #events:
    attributes.event_mask = event_mask
    #wclass:
    attributes.wclass = wclass
    mask = Gdk.WindowAttributesType(attributes_mask)
    return Gdk.Window(parent, attributes, mask)
Example #7
0
    def do_realize(self):
        allocation = self.get_allocation()
        attr = Gdk.WindowAttr()
        attr.window_type = Gdk.WindowType.CHILD
        attr.x = allocation.x
        attr.y = allocation.y
        attr.width = allocation.width
        attr.height = allocation.height
        attr.visual = self.get_visual()
        attr.event_mask = self.get_events() | Gdk.EventMask.EXPOSURE_MASK
        mask = Gdk.WindowAttributesType.X | Gdk.WindowAttributesType.Y | Gdk.WindowAttributesType.VISUAL
        window = Gdk.Window(self.get_parent_window(), attr, mask)
        self.set_window(window)
        self.register_window(window)
        self.set_realized(True)
        window.set_background_pattern(None)
        self.on_notify(None, None)

        print('Widget Properties:')
        for prop in [
                'value', 'offset', 'count', 'big-endian', 'labels', 'colors',
                'columns', 'size'
        ]:
            print('-- {} = {}'.format(prop, self.get_property(prop)))
        print('-- {} = {}'.format('table', [list(row) for row in self.table]))
Example #8
0
def new_gdk_window():
    a = Gdk.WindowAttr()
    a.window_type = Gdk.WindowType.TOPLEVEL
    a.wclass = Gdk.WindowWindowClass.INPUT_OUTPUT
    a.width = 400
    a.height = 400
    w = Gdk.Window(parent=None, attributes=a, attributes_mask=0)
    print("window", w)
    w.show()
Example #9
0
 def do_realize(self):
     allocation = self.get_allocation()
     attr = Gdk.WindowAttr()
     attr.window_type = Gdk.WindowType.CHILD
     attr.x = allocation.x
     attr.y = allocation.y
     attr.width = allocation.width
     attr.height = allocation.height
     attr.visual = self.get_visual()
     attr.event_mask = self.get_events() | Gdk.EventMask.EXPOSURE_MASK
     WAT = Gdk.WindowAttributesType
     mask = WAT.X | WAT.Y | WAT.VISUAL
     window = Gdk.Window(self.get_parent_window(), attr, mask)
     self.set_window(window)
     self.register_window(window)
     self.set_realized(True)
     window.set_background_pattern(None)
Example #10
0
    def do_realize(self):
        self.set_realized(True)

        attr = Gdk.WindowAttr()
        attr.window_type = Gdk.WindowType.CHILD
        attr.wclass = Gdk.WindowWindowClass.INPUT_OUTPUT
        attr.visual = self.get_visual()
        attr.event_mask = self.get_events() | Gdk.EventMask.EXPOSURE_MASK
        mask = (Gdk.WindowAttributesType.VISUAL |
                Gdk.WindowAttributesType.X |
                Gdk.WindowAttributesType.Y)

        attr.x = self.get_allocation().x
        attr.y = self.get_allocation().y
        attr.width = self.get_allocation().width
        attr.height = self.get_allocation().height

        window = Gdk.Window.new(self.get_parent_window(), attr, mask)
        self.set_window(window)
        window.set_user_data(self)

        geo = self._get_under_window_geometry()
        attr.x = geo.x
        attr.y = geo.y
        attr.width = geo.width
        attr.height = geo.height
        self.underWin = Gdk.Window.new(window, attr, mask)
        self.underWin.set_user_data(self)
        if self.underWidget:
            self.underWidget.set_parent_window(self.underWin)
        self.underWin.show()

        geo = self._get_over_window_geometry()
        attr.x = geo.x
        attr.y = geo.y
        attr.width = geo.width
        attr.height = geo.height
        self.overWin = Gdk.Window.new(window, attr, mask)
        self.overWin.set_user_data(self)
        if self.overWidget:
            self.overWidget.set_parent_window(self.overWin)
        self.overWin.show()

        self._set_background()
Example #11
0
    def _create_panel_window(self):
        display = ClutterGdk.get_default_display()
        root_height = display.get_default_screen().get_root_window(
        ).get_height()

        attr = Gdk.WindowAttr()
        attr.title = "page-panel"
        attr.width = 32
        attr.height = root_height
        attr.x = 0
        attr.y = 0
        attr.event_mask = 0
        attr.window_type = Gdk.WindowType.TOPLEVEL
        attr.visual = display.get_default_screen().get_rgba_visual()
        self.window = Gdk.Window(
            None, attr, Gdk.WindowAttributesType.TITLE
            | Gdk.WindowAttributesType.VISUAL
            | Gdk.WindowAttributesType.X
            | Gdk.WindowAttributesType.Y)
Example #12
0
    def _create_dash_window(self):
        display = ClutterGdk.get_default_display()
        root_height = display.get_default_screen().get_root_window(
        ).get_height()

        attr = Gdk.WindowAttr()
        attr.title = "page-dash"
        attr.width = 32
        attr.height = root_height
        attr.x = 32
        attr.y = 0
        attr.event_mask = 0
        attr.window_type = Gdk.WindowType.TOPLEVEL
        attr.visual = display.get_default_screen().get_rgba_visual()
        attr.override_redirect = True
        attr.type_hint = Gdk.WindowTypeHint.MENU
        self.window = Gdk.Window(
            None, attr, Gdk.WindowAttributesType.TITLE
            | Gdk.WindowAttributesType.VISUAL
            | Gdk.WindowAttributesType.X
            | Gdk.WindowAttributesType.Y
            | Gdk.WindowAttributesType.NOREDIR
            | Gdk.WindowAttributesType.TYPE_HINT)
Example #13
0
    def do_realize(self):


        allocation = self.get_allocation()
        attr = Gdk.WindowAttr()
        attr.window_type = Gdk.WindowType.CHILD
        attr.x = allocation.x
        attr.y = allocation.y
        attr.width = allocation.width
        attr.height = allocation.height
        attr.visual = self.get_visual()
        attr.event_mask = self.get_events() \
                                 | Gdk.EventMask.EXPOSURE_MASK \
                                 | Gdk.EventMask.BUTTON_PRESS_MASK \
                                 | Gdk.EventMask.BUTTON_RELEASE_MASK \
                                 | Gdk.EventMask.BUTTON_MOTION_MASK \
                                 | Gdk.EventMask.POINTER_MOTION_HINT_MASK \
                                 | Gdk.EventMask.ENTER_NOTIFY_MASK \
                                 | Gdk.EventMask.LEAVE_NOTIFY_MASK \
                                 | Gdk.EventMask.KEY_PRESS_MASK \
                                 | Gdk.EventMask.SCROLL_MASK \
                                 
        WAT = Gdk.WindowAttributesType
        mask = WAT.X | WAT.Y | WAT.VISUAL
        window = Gdk.Window(self.get_parent_window(), attr, mask);
        
        """
        # Create GDK window
        self.window = Gdk.Window(self.get_parent_window(),
                                 width=self.allocation.width,
                                 height=self.allocation.height,
                                 window_type=Gdk.WINDOW_CHILD,
                                 wclass=Gdk.INPUT_OUTPUT,
                                 event_mask=self.get_events() 
                                 | Gdk.EventMask.EXPOSURE_MASK 
                                 | Gdk.EventMask.BUTTON_PRESS_MASK
                                 | Gdk.EventMask.BUTTON_RELEASE_MASK
                                 | Gdk.EventMask.BUTTON_MOTION_MASK
                                 | Gdk.EventMask.POINTER_MOTION_HINT_MASK
                                 | Gdk.EventMask.ENTER_NOTIFY_MASK
                                 | Gdk.EventMask.LEAVE_NOTIFY_MASK
                                 | Gdk.EventMask.KEY_PRESS_MASK
                                 | Gdk.EventMask.SCROLL_MASK)
        """
        # Connect motion notify event
        self.connect('motion_notify_event', self._motion_notify_event)
        
        # Connect mouse scroll event
        self.connect("scroll-event", self._mouse_scroll_event)
        
        # Make widget capable of grabbing focus
        self.set_property("can-focus",  True)

        # Check that cairo context can be created
        #if not hasattr(self.window, "cairo_create"):
        #    print "no cairo"
        #    raise SystemExit

        # GTK+ stores the widget that owns a Gdk.Window as user data on it. 
        # Custom widgets should do this too
        #self.window.set_user_data(self)

        # Attach style
        #self.style.attach(self.window)

        # Set background color
        #if(self._use_widget_bg):
        #    self.style.set_background(self.window, Gtk.StateType.NORMAL)

        # Set size and place 
        #self.window.move_resize(self.allocation)
        #self.window.move_resize(self.allocation)
        # Set an internal flag telling that we're realized
        self.set_window(window)
        self.register_window(window)
        self.set_realized(True)
        window.set_background_pattern(None)