Exemplo n.º 1
0
    def present(self, client, pos):
        client = client or self.root
        self.topleft = client.local_to_global(pos)
        focus = self.handler or get_focus()
        font = self.font
        h = font.get_linesize()
        items = self._items
        margin = self.margin
        if self.scrolling:
            height = h * self.scroll_items + h
        else:
            height = h * len(items) + h
        w1 = w2 = 0
        for item in items:
            item.enabled = self.command_is_enabled(item, focus)
            w1 = max(w1, font.size(item.text)[0])
            w2 = max(w2, font.size(item.keyname)[0])
        width = w1 + 2 * margin
        self._key_margin = width
        if w2 > 0:
            width += w2 + margin
        if self.scrolling:
            width += self.scroll_button_size
        self.size = (width, height)
        self._hilited = None

        self.rect.clamp_ip(self.root.rect)

        return Dialog.present(self, centered=False)
Exemplo n.º 2
0
    def present(self, client, pos):
        client = client or get_root()
        self.topleft = client.local_to_global(pos)
        focus = get_focus()
        font = self.font
        h = font.get_linesize()
        items = self._items
        margin = self.margin
        if self.scrolling:
            height = h * self.scroll_items + h
        else:
            height = h * len(items) + h
        w1 = w2 = 0
        for item in items:
            item.enabled = self.command_is_enabled(item, focus)
            w1 = max(w1, font.size(item.text)[0])
            w2 = max(w2, font.size(item.keyname)[0])
        width = w1 + 2 * margin
        self._key_margin = width
        if w2 > 0:
            width += w2 + margin
        if self.scrolling:
            width += self.scroll_button_size
        self.size = (width, height)
        self._hilited = None

        root = get_root()
        self.rect.clamp_ip(root.rect)

        return Dialog.present(self, centered=False)
Exemplo n.º 3
0
 def find_item_for_key(self, e):
     for item in self._items:
         if item.keycode == e.key \
                 and item.shift == e.shift and item.alt == e.alt:
             focus = get_focus()
             if self.command_is_enabled(item, focus):
                 return self._items.index(item)
             else:
                 return -1
     return -1
Exemplo n.º 4
0
 def find_item_for_key(self, e):
     for item in self._items:
         if item.keycode == e.key \
                 and item.shift == e.shift and item.alt == e.alt:
             focus = get_focus()
             if self.command_is_enabled(item, focus):
                 return self._items.index(item)
             else:
                 return -1
     return -1
Exemplo n.º 5
0
	def present(self, client, pos):
		client = client or get_root()
		self.topleft = client.local_to_global(pos)
		focus = get_focus()
		font = self.font
		h = font.get_linesize()
		items = self._items
		margin = self.margin
		height = h * len(items) + h
		w1 = w2 = 0
		for item in items:
			item.enabled = self.command_is_enabled(item, focus)
			w1 = max(w1, font.size(item.text)[0])
			w2 = max(w2, font.size(item.keyname)[0])
		width = w1 + 2 * margin
		self._key_margin = width
		if w2 > 0:
			width += w2 + margin
		self.size = (width, height)
		self._hilited = None
		return Dialog.present(self, centered = False)
Exemplo n.º 6
0
 def invoke_item(self, i):
     cmd = self.get_command(i)
     if cmd:
         get_focus().handle_command(cmd)
Exemplo n.º 7
0
 def invoke_item(self, i):
     cmd = self.get_command(i)
     if cmd:
         get_focus().handle_command(cmd)