예제 #1
0
 def create_window(self):
     EM = self.xcore.EventMask
     CW = self.xcore.CW
     self.window = DisplayWindow(
         self.xcore.create_toplevel(
             self.bounds,
             klass=self.xcore.WindowClass.InputOutput,
             params={
                 CW.EventMask: EM.Exposure | EM.SubstructureNotify,
                 CW.OverrideRedirect: True,
             }), self.expose)
     self.window.want.size = self.bounds
     di(self).inject(self.window)
     self.dispatcher.register_window(self.window)
     self.window.show()
예제 #2
0
 def create_window(self):
     EM = self.xcore.EventMask
     CW = self.xcore.CW
     self.window = DisplayWindow(self.xcore.create_toplevel(self.bounds,
         klass=self.xcore.WindowClass.InputOutput,
         params={
             CW.EventMask: EM.Exposure | EM.SubstructureNotify,
             CW.OverrideRedirect: True,
         }), self.expose)
     self.window.want.size = self.bounds
     di(self).inject(self.window)
     self.dispatcher.register_window(self.window)
     self.window.show()
예제 #3
0
 def __zorro_di_done__(self):
     wid = self.xcore.create_toplevel(
         Rectangle(0, 0, 1, 1),
         klass=self.xcore.WindowClass.InputOutput,
         params={
             self.xcore.CW.BackPixel: self.theme.menu.background,
             self.xcore.CW.OverrideRedirect: True,
             self.xcore.CW.EventMask: self.xcore.EventMask.Exposure,
         })
     self.window = di(self).inject(DisplayWindow(wid, self.paint))
     self.dispatcher.all_windows[wid] = self.window
     self.window.show()
     if self.screen.group:
         self._group_hook()
     self.commander.events['window'].listen(self._check_redraw)
     Window.any_window_changed.listen(self._check_redraw)
예제 #4
0
 def cmd_show(self):
     if self.window:
         self.cmd_hide()
     self._current_items = self.items()
     show_lines = min(len(self._current_items) + 1, self.max_lines)
     h = self.theme.menu.line_height
     self.height = h * self.max_lines
     bounds = self.commander['screen'].bounds._replace(height=h)
     self._img = self.xcore.pixbuf(bounds.width, h)
     wid = self.xcore.create_toplevel(
         bounds,
         klass=self.xcore.WindowClass.InputOutput,
         params={
             self.xcore.CW.BackPixel:
             self.theme.menu.background,
             self.xcore.CW.OverrideRedirect:
             True,
             self.xcore.CW.EventMask:
             self.xcore.EventMask.FocusChange
             | self.xcore.EventMask.EnterWindow
             | self.xcore.EventMask.LeaveWindow
             | self.xcore.EventMask.KeymapState
             | self.xcore.EventMask.KeyPress,
         })
     self.window = di(self).inject(
         DisplayWindow(wid, self.draw, focus_out=self._close))
     self.dispatcher.all_windows[wid] = self.window
     self.dispatcher.frames[wid] = self.window  # dirty hack
     self.window.show()
     self.window.focus()
     self.text_field = di(self).inject(
         TextField(self.theme.menu,
                   events={
                       'draw': self.redraw,
                       'submit': self.submit_ev,
                       'complete': self.complete,
                       'close': self.close,
                   }))
     self.dispatcher.active_field = self.text_field
     self._redraw()
예제 #5
0
class Bar(object):

    xcore = dependency(Core, 'xcore')
    dispatcher = dependency(EventDispatcher, 'event-dispatcher')
    theme = dependency(Theme, 'theme')

    def __init__(self, widgets, position='top'):
        self.widgets = widgets
        self.position = position
        self.bounds = None
        self.window = None
        self.redraw = Event('bar.redraw')
        self.redraw.listen(self.expose)

    def __zorro_di_done__(self):
        bar = self.theme.bar
        self.height = bar.height
        self.background = bar.background_pat
        inj = di(self).clone()
        inj['bar'] = self
        for w in self.widgets:
            w.height = self.height
            inj.inject(w)

    def set_bounds(self, rect):
        self.bounds = rect
        self.width = rect.width
        stride = self.xcore.bitmap_stride
        self.img = self.xcore.pixbuf(self.width, self.height)
        self.cairo = self.img.context()
        if self.window and not self.window.set_bounds(rect):
            self.redraw.emit()

    def create_window(self):
        EM = self.xcore.EventMask
        CW = self.xcore.CW
        self.window = DisplayWindow(
            self.xcore.create_toplevel(
                self.bounds,
                klass=self.xcore.WindowClass.InputOutput,
                params={
                    CW.EventMask: EM.Exposure | EM.SubstructureNotify,
                    CW.OverrideRedirect: True,
                }), self.expose)
        self.window.want.size = self.bounds
        di(self).inject(self.window)
        self.dispatcher.register_window(self.window)
        self.window.show()

    def expose(self, rect=None):
        # TODO(tailhook) set clip region to specified rectangle
        self.cairo.set_source(self.background)
        self.cairo.rectangle(0, 0, self.width, self.height)
        self.cairo.fill()
        l = 0
        r = self.width
        for i in self.widgets:
            self.cairo.save()
            self.cairo.rectangle(l, 0, r - l, self.height)
            self.cairo.clip()
            l, r = i.draw(self.cairo, l, r)
            self.cairo.restore()
        self.img.draw(self.window)
예제 #6
0
class Bar(object):

    xcore = dependency(Core, 'xcore')
    dispatcher = dependency(EventDispatcher, 'event-dispatcher')
    theme = dependency(Theme, 'theme')


    def __init__(self, widgets, position='top'):
        self.widgets = widgets
        self.position = position
        self.bounds = None
        self.window = None
        self.redraw = Event('bar.redraw')
        self.redraw.listen(self.expose)

    def __zorro_di_done__(self):
        bar = self.theme.bar
        self.height = bar.height
        self.background = bar.background_pat
        inj = di(self).clone()
        inj['bar'] = self
        for w in self.widgets:
            w.height = self.height
            inj.inject(w)

    def set_bounds(self, rect):
        self.bounds = rect
        self.width = rect.width
        stride = self.xcore.bitmap_stride
        self.img = self.xcore.pixbuf(self.width, self.height)
        self.cairo = self.img.context()
        if self.window and not self.window.set_bounds(rect):
            self.redraw.emit()

    def create_window(self):
        EM = self.xcore.EventMask
        CW = self.xcore.CW
        self.window = DisplayWindow(self.xcore.create_toplevel(self.bounds,
            klass=self.xcore.WindowClass.InputOutput,
            params={
                CW.EventMask: EM.Exposure | EM.SubstructureNotify,
                CW.OverrideRedirect: True,
            }), self.expose)
        self.window.want.size = self.bounds
        di(self).inject(self.window)
        self.dispatcher.register_window(self.window)
        self.window.show()

    def expose(self, rect=None):
        # TODO(tailhook) set clip region to specified rectangle
        self.cairo.set_source(self.background)
        self.cairo.rectangle(0, 0, self.width, self.height)
        self.cairo.fill()
        l = 0
        r = self.width
        for i in self.widgets:
            self.cairo.save()
            self.cairo.rectangle(l, 0, r-l, self.height)
            self.cairo.clip()
            l, r = i.draw(self.cairo, l, r)
            self.cairo.restore()
        self.img.draw(self.window)