Пример #1
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)
Пример #2
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)
Пример #3
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)
Пример #4
0
    def do_realize(self):
        anid = self.get_anid()
        if anid:
            self.window = Gdk.window_foreign_new(anid)
            self.window.set_events(Gdk.EventMask.EXPOSURE_MASK
                                   | Gdk.EventMask.STRUCTURE_MASK)
        else:
            self.window = Gdk.Window(self.get_parent_window(),
                                     width=self.allocation.width,
                                     height=self.allocation.height,
                                     window_type=Gdk.WINDOW_TOPLEVEL,
                                     wclass=Gdk.INPUT_OUTPUT,
                                     event_mask=self.get_events()
                                     | Gdk.EventMask.EXPOSURE_MASK)

        self.window.set_user_data(self)
        x, y, self.w, self.h, depth = self.window.get_geometry()
        self.size_allocate(Gdk.Rectangle(x=x, y=y, width=self.w,
                                         height=self.h))
        self.set_default_size(self.w, self.h)

        self.set_flags(self.flags() | Gtk.REALIZED)
        self.set_decorated(False)
        self.style.attach(self.window)
        self.style.set_background(self.window, Gtk.StateType.NORMAL)
        self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("black"))
Пример #5
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)
Пример #6
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]))
Пример #7
0
    def do_realize(self):
        # The do_realize method is responsible for creating GDK (windowing system)
        # resources. In this example we will create a new Gdk.Window which we
        # then draw on

        # First set an internal flag telling that we're realized
        self.set_flags(Gtk.REALIZED)

        # Create a new Gdk.Window which we can draw on.
        # Also say that we want to receive exposure events by setting
        # the event_mask
        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)

        # Associate the Gdk.Window with ourselves, Gtk+ needs a reference
        # between the widget and the gdk window
        self.window.set_user_data(self)

        # Attach the style to the Gdk.Window, a style contains colors and
        # GC contextes used for drawing
        self.style.attach(self.window)

        # The default color of the background should be what
        # the style (theme engine) tells us.
        self.style.set_background(self.window, Gtk.StateType.NORMAL)
        self.window.move_resize(*self.allocation)
Пример #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()
Пример #9
0
 def __init__(self, icon):
     Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL)
     self.set_icon(icon)
     self.set_size_request(128, 128)
     self.connect("delete_event", self.quit_cb)
     self.realize()
     self.leader = Gdk.Window(None,
                              1,
                              1,
                              gdk.WINDOW_TOPLEVEL,
                              event_mask=0,
                              wclass=gdk.INPUT_ONLY)
     self.leader.set_icon_list([icon])
     #self.leader.realize()
     self.get_window().set_group(self.leader)
     self.show_all()
Пример #10
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)
Пример #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)
Пример #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)
Пример #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)