Beispiel #1
0
	def _domenu(self):
		if not self._menus:
			return None
		if len(self._menus) == 1:
			pup = self._menus[0]._makepup(0)
			val = gl.dopup(pup)
			gl.freepup(pup)
			if val < 0:
				return None
			return WE_MENU, self, (self._menus[0], val)
		#
		# More than one menu: use nested menus.
		#
		pups = []
		firstitem = 0
		for menu in self._menus:
			pups.append(menu._makepup(firstitem))
			firstitem = firstitem + 100
		pup = gl.newpup()
		for i in range(len(self._menus)):
			gl.addtopup(pup, self._menus[i]._title + '%m', pups[i])
		val = gl.dopup(pup)
		gl.freepup(pup)
		for pup in pups:
			gl.freepup(pup)
		if val < 0:
			return None
		i_menu, i_item = divmod(val, 100)
		return WE_MENU, self, (self._menus[i_menu], i_item)
Beispiel #2
0
 def _domenu(self):
     if not self._menus:
         return None
     if len(self._menus) == 1:
         pup = self._menus[0]._makepup(0)
         val = gl.dopup(pup)
         gl.freepup(pup)
         if val < 0:
             return None
         return WE_MENU, self, (self._menus[0], val)
     #
     # More than one menu: use nested menus.
     #
     pups = []
     firstitem = 0
     for menu in self._menus:
         pups.append(menu._makepup(firstitem))
         firstitem = firstitem + 100
     pup = gl.newpup()
     for i in range(len(self._menus)):
         gl.addtopup(pup, self._menus[i]._title + '%m', pups[i])
     val = gl.dopup(pup)
     gl.freepup(pup)
     for pup in pups:
         gl.freepup(pup)
     if val < 0:
         return None
     i_menu, i_item = divmod(val, 100)
     return WE_MENU, self, (self._menus[i_menu], i_item)
Beispiel #3
0
	def _makepup(self, firstitem):
		pup = gl.newpup()
		if self._title:
			gl.addtopup(pup, self._title + '%t', 0)
		for item in self._items:
			text = item[0]
			if not item[2]: # Disabled
				text = ' ( ' + text + ' )%x-1'
			else:
				if item[3]: # Check mark
					text = '-> ' + text
				else:
					text = '    ' + text
				if key2code.has_key(item[1]):
					text = text + '  [Alt-' + item[1] + ']'
				text = text + '%x' + `firstitem`
			gl.addtopup(pup, text, 0)
			firstitem = firstitem + 1
		return pup