예제 #1
0
 def __init__(self, parent, **kwargs):
     MetaWidget.__init__(self, parent)
     self.surface = None
     self.visible = 0
     # data
     self.title = None
     self.closeButton = 1
     # flags
     self.looseFocusClose = 0
     self.alwaysInBackground = 0
     self.alwaysOnTop = 0
     self.modal = 0
     self.rightButtonClose = 0
     self.escKeyClose = 0
     self.decorated = 1
     self.titleOnly = 0
     self.movable = 1
     self.acceptButton = None
     self._dragging = 0
     self._fullUpdate = True
     self.tabChange = False
     self.callEventHandler = False
     # register
     self.app.registerWindow(self)
     self.processKWArguments(kwargs)
예제 #2
0
	def __init__(self, parent, **kwargs):
		MetaWidget.__init__(self, parent)
		self.surface = None
		self.visible = 0
		# data
		self.title = None
		self.closeButton = 1
		# flags
		self.looseFocusClose = 0
		self.alwaysInBackground = 0
		self.alwaysOnTop = 0
		self.modal = 0
		self.rightButtonClose = 0
		self.escKeyClose = 0
		self.decorated = 1
		self.titleOnly = 0
		self.movable = 1
		self.acceptButton = None
		self._dragging = 0
		self._fullUpdate = True
		self.tabChange = False
		self.callEventHandler = False
		# register
		self.app.registerWindow(self)
		self.processKWArguments(kwargs)
예제 #3
0
	def __init__(self, parent, **kwargs):
		MetaWidget.__init__(self, parent)
		# data
		self.action = None
		# flags
		self.processKWArguments(kwargs)
		parent.registerWidget(self)
		# create widgets
		self.button1 = ArrowButton(self, action = 'onButton1')
		self.button1.subscribeAction('*', self)
		self.button2 = ArrowButton(self, action = 'onButton2')
		self.button2.subscribeAction('*', self)
		self.slider = ScrollSlider(self, action = 'onSlider')
		self.slider.subscribeAction('*', self)
예제 #4
0
 def __init__(self, parent, **kwargs):
     MetaWidget.__init__(self, parent)
     # data
     self.action = None
     # flags
     self.processKWArguments(kwargs)
     parent.registerWidget(self)
     # create widgets
     self.button1 = ArrowButton(self, action='onButton1')
     self.button1.subscribeAction('*', self)
     self.button2 = ArrowButton(self, action='onButton2')
     self.button2.subscribeAction('*', self)
     self.slider = ScrollSlider(self, action='onSlider')
     self.slider.subscribeAction('*', self)
예제 #5
0
 def processMB1Down(self, evt):
     pos = (evt.pos[0] - self.rect.left, evt.pos[1] - self.rect.top)
     if self._widgetArea and not self._widgetArea.collidepoint(
             pos) and self.movable:
         self._dragging = 1
         return Const.NoEvent
     else:
         return MetaWidget.processMB1Down(self, evt)
예제 #6
0
    def __init__(self, parent, **kwargs):
        MetaWidget.__init__(self, parent)
        # data
        self.__dict__["items"] = []
        self.__dict__["labels"] = []
        self.__dict__["action"] = None
        self.__dict__["rmbAction"] = None
        self.__dict__["hoverAction"] = None
        self.__dict__["multiselection"] = 0
        self.__dict__["selection"] = []
        self.__dict__["highlight"] = None
        self.__dict__["columns"] = [('Item', 'text', 0, Const.ALIGN_W)]
        self.__dict__["columnLabels"] = 0
        self.__dict__["scrollBar"] = 1
        self.__dict__["sortedBy"] = (None, 1)
        self.__dict__["sortable"] = 1
        self.__dict__["_labels"] = []
        self.__dict__["_buttons"] = []
        self.__dict__["_entries"] = []
        # flags
        self.processKWArguments(kwargs)
        parent.registerWidget(self)

        # create widgets
        self.bar = Scrollbar(self, action='onScroll')
        self.bar.subscribeAction('*', self)
        if not self.scrollBar:
            self.bar.visible = 0

        # precreate some objects
        # guess number of rows (TODO Enable it)
        # rows = self.layout[3] - 1
        rows = 0
        for item in self.columns:
            label = Button(self, action='onSortByColumn')
            label.subscribeAction('*', self)
            self._buttons.append(label)
            for i in xrange(0, rows):
                label = Button(self,
                               action='onItemSelect',
                               rmbAction="onRmbItemSelect",
                               hoverAction="onItemHighlight",
                               style="listitem",
                               toggle=1)
                label.subscribeAction('*', self)
                self._labels.append(label)
예제 #7
0
 def layoutWidgets(self):
     gx, gy = self.theme.getGridParams()
     r = self.rect
     if self.rect.width > self.rect.height:
         # horizontal
         self.button1.rect = pygame.Rect(0, 0, gx, gy)
         self.button1.direction = Const.ALIGN_W
         self.button2.rect = pygame.Rect(r.width - gx, 0, gx, gy)
         self.button2.direction = Const.ALIGN_E
         self.slider.rect = pygame.Rect(gx, 0, r.width - 2 * gx, gy)
     else:
         # vertical
         self.button1.rect = pygame.Rect(0, 0, gx, gy)
         self.button1.direction = Const.ALIGN_N
         self.button2.rect = pygame.Rect(0, r.height - gy, gx, gy)
         self.button2.direction = Const.ALIGN_S
         self.slider.rect = pygame.Rect(0, gy, gx, r.height - 2 * gy)
     MetaWidget.layoutWidgets(self)
예제 #8
0
	def layoutWidgets(self):
		gx, gy = self.theme.getGridParams()
		r = self.rect
		if self.rect.width > self.rect.height:
			# horizontal
			self.button1.rect = Rect(0, 0, gx, gy)
			self.button1.direction = ALIGN_W
			self.button2.rect = Rect(r.width - gx, 0, gx, gy)
			self.button2.direction = ALIGN_E
			self.slider.rect = Rect(gx, 0, r.width - 2 * gx, gy)
		else:
			# vertical
			self.button1.rect = Rect(0, 0, gx, gy)
			self.button1.direction = ALIGN_N
			self.button2.rect = Rect(0, r.height - gy, gx, gy)
			self.button2.direction = ALIGN_S
			self.slider.rect = Rect(0, gy, gx, r.height - 2 * gy)
		MetaWidget.layoutWidgets(self)
예제 #9
0
	def processMB1Down(self, evt):
		pos = (
			evt.pos[0] - self.rect.left,
			evt.pos[1] - self.rect.top
		)
		if self._widgetArea and not self._widgetArea.collidepoint(pos) and self.movable:
			self._dragging = 1
			return NoEvent
		else:
			return MetaWidget.processMB1Down(self, evt)
예제 #10
0
	def __init__(self, parent, **kwargs):
		MetaWidget.__init__(self, parent)
		# data
		self.items = []
		self.buttons = []
		self.action = None
		self.rmbAction = None
		self.selected = None
		self.selectedButton = None
		self.buttonSize = (1, 1)
		self.rows = 0
		self.columns = 0
		self.showSlider = 1
		# flags
		self.processKWArguments(kwargs)
		parent.registerWidget(self)
		# create widgets
		self.bar = Scrollbar(self, action = 'onScroll')
		self.bar.subscribeAction('*', self)
예제 #11
0
	def draw(self, surface):
		if not self.surface or self.surface.get_size() != self.rect.size:
			self.surface = pygame.Surface(self.rect.size, self.app.windowSurfaceFlags)
		changed = MetaWidget.draw(self, self.surface)
		if self._fullUpdate:
			changed = self.surface.get_rect()
			self._fullUpdate = False
		if surface and changed:
			surface.blit(self.surface, self.rect.topleft)
			changed.move_ip(self.rect.topleft)
		return changed
예제 #12
0
    def __init__(self, parent, **kwargs):
        MetaWidget.__init__(self, parent)
        # data
        self.__dict__["items"] = []
        self.__dict__["labels"] = []
        self.__dict__["action"] = None
        self.__dict__["rmbAction"] = None
        self.__dict__["hoverAction"] = None
        self.__dict__["multiselection"] = 0
        self.__dict__["selection"] = []
        self.__dict__["highlight"] = None
        self.__dict__["columns"] = [('Item', 'text', 0, Const.ALIGN_W)]
        self.__dict__["columnLabels"] = 0
        self.__dict__["scrollBar"] = 1
        self.__dict__["sortedBy"] = (None, 1)
        self.__dict__["sortable"] = 1
        self.__dict__["_labels"] = []
        self.__dict__["_buttons"] = []
        self.__dict__["_entries"] = []
        # flags
        self.processKWArguments(kwargs)
        parent.registerWidget(self)

        # create widgets
        self.bar = Scrollbar(self, action = 'onScroll')
        self.bar.subscribeAction('*', self)
        if not self.scrollBar:
            self.bar.visible = 0

        # precreate some objects
        # guess number of rows (TODO Enable it)
        # rows = self.layout[3] - 1
        rows = 0
        for item in self.columns:
            label = Button(self, action = 'onSortByColumn')
            label.subscribeAction('*', self)
            self._buttons.append(label)
            for i in xrange(0, rows):
                label = Button(self, action = 'onItemSelect', rmbAction = "onRmbItemSelect", hoverAction = "onItemHighlight", style = "listitem", toggle = 1)
                label.subscribeAction('*', self)
                self._labels.append(label)
예제 #13
0
	def processMMotion(self, evt):
		if self._dragging and evt.buttons[0]:
			self.rect.left += evt.rel[0]
			self.rect.top += evt.rel[1]
			self._fullUpdate = True
			self.parent.redrawWidgets[self] = None
			return NoEvent
		elif self._dragging and not evt.buttons[0]:
			self._dragging = 0
			return NoEvent
		else:
			return MetaWidget.processMMotion(self, evt)
예제 #14
0
 def draw(self, surface):
     if not self.surface or self.surface.get_size() != self.rect.size:
         self.surface = pygame.Surface(self.rect.size,
                                       self.app.windowSurfaceFlags)
     changed = MetaWidget.draw(self, self.surface)
     if self._fullUpdate:
         changed = self.surface.get_rect()
         self._fullUpdate = False
     if surface and changed:
         surface.blit(self.surface, self.rect.topleft)
         changed.move_ip(self.rect.topleft)
     return changed
예제 #15
0
 def processMMotion(self, evt):
     if self._dragging and evt.buttons[0]:
         self.rect.left += evt.rel[0]
         self.rect.top += evt.rel[1]
         self._fullUpdate = True
         self.parent.redrawWidgets[self] = None
         return Const.NoEvent
     elif self._dragging and not evt.buttons[0]:
         self._dragging = 0
         return Const.NoEvent
     else:
         return MetaWidget.processMMotion(self, evt)
예제 #16
0
	def processMB3Down(self, evt):
		if self.rightButtonClose:
			self.hide()
			return NoEvent
		return MetaWidget.processMB3Down(self, evt)
예제 #17
0
	def processMB1UpMissed(self, evt):
		self._dragging = 0
		return MetaWidget.processMB1UpMissed(self, evt)
예제 #18
0
 def processMB1UpMissed(self, evt):
     self._dragging = 0
     return MetaWidget.processMB1UpMissed(self, evt)
예제 #19
0
 def processMB3Down(self, evt):
     if self.rightButtonClose:
         self.hide()
         return Const.NoEvent
     return MetaWidget.processMB3Down(self, evt)