Ejemplo n.º 1
0
    def __init__(self, parent, skin):
        'Generic constructor'

        wx.VListBox.__init__(self, parent)
        UberWidget.__init__(self, 'LISTBOX')

        self.MinSize = wx.Size(1, 1)  #fix for small menus

        events = [(wx.EVT_PAINT, self.OnPaint),
                  (wx.EVT_MOUSEWHEEL, self.OnMouseWheel),
                  (wx.EVT_MOTION, self.OnMouseMove),
                  (wx.EVT_LEFT_UP, self.OnLUp),
                  (wx.EVT_LEFT_DOWN, self.OnLDown),
                  (wx.EVT_RIGHT_DOWN, self.OnLDown),
                  (wx.EVT_MIDDLE_DOWN, self.OnLDown),
                  (wx.EVT_LEFT_DCLICK, lambda e: None),
                  (wx.EVT_SCROLLWIN, self.OnScroll),
                  (wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost)]
        do(self.Bind(event, method) for (event, method) in events)

        #TODO: soft code this
        self.itemheight = 20

        self.items = []
        self.ItemCount = len(self.items)

        self.SetSkinKey(skin, True)
Ejemplo n.º 2
0
    def __init__(self, parent, skin):
        'Generic constructor'

        wx.VListBox.__init__(self,parent)
        UberWidget.__init__(self,'LISTBOX')

        self.MinSize = wx.Size(1, 1) #fix for small menus

        events = [
            (wx.EVT_PAINT,       self.OnPaint),
            (wx.EVT_MOUSEWHEEL,  self.OnMouseWheel),
            (wx.EVT_MOTION,      self.OnMouseMove),
            (wx.EVT_LEFT_UP,     self.OnLUp),
            (wx.EVT_LEFT_DOWN,   self.OnLDown),
            (wx.EVT_RIGHT_DOWN,  self.OnLDown),
            (wx.EVT_MIDDLE_DOWN, self.OnLDown),
            (wx.EVT_LEFT_DCLICK, lambda e:None),
            (wx.EVT_SCROLLWIN,   self.OnScroll),
            (wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost)
        ]
        do(self.Bind(event, method) for (event, method) in events)

        #TODO: soft code this
        self.itemheight = 20

        self.items = []
        self.ItemCount = len(self.items)

        self.SetSkinKey(skin,True)
Ejemplo n.º 3
0
    def __init__(self, parent, id = wx.ID_ANY, skinkey = None, overflowmode = False,
                 name = 'UberBar', alignment = None):

        SimplePanel.__init__(self, parent, FULL_REPAINT_ON_RESIZE)
        UberWidget.__init__(self,'toolbar')

        self.ChildPaints = Delegate()

        # Initing variables
        self.alignment = alignment if alignment and not overflowmode else ALIGN_LEFT
        self.overflowmode   = overflowmode
        self.navimode       = False
        self.active         = None
        self.children       = []
        self.staticchildren = []
        self.overflowed     = []
        self.focus          = None
        self.lastheight     = 0


        Bind = self.Bind
        Bind(wx.EVT_PAINT, self.OnBGPaint)
        Bind(wx.EVT_SIZE,  self.OnReSize)

        self.keyletters={}

        self.tlmargins = Size()
        self.brmargins = Size()

        #Start setting up an alternaitve Native Menubar for native mode

        self.SetSkinKey(skinkey,True)

        self.content = wx.BoxSizer(HORIZONTAL)
        sizer = self.Sizer = wx.GridBagSizer()
        sizer.SetEmptyCellSize(wx.Size(0, 0))

        contentFlag = TOP | BOTTOM | (self.alignment | EXPAND if self.alignment == ALIGN_LEFT else self.alignment)

        sizer.Add(self.content,(1,1),flag = contentFlag, border = self.padding.y)
        sizer.Add(Size(self.margins.left,self.margins.top),(0,0))
        sizer.Add(Size(self.margins.right,self.margins.bottom),(2,2))
        sizer.AddGrowableCol(1, 1)
        sizer.AddGrowableRow(1, 1)
#

        #Set up the menu for the overflowed items if overflow mode
        if overflowmode:
            self.overflowmenu   = SimpleMenu(self,self.menuskin)
            self.overflowbutton = UberButton(self, skin=self.buttonskin,type='menu',menu=self.overflowmenu)
            self.content.Add( (self.padding.x, 1), 1, EXPAND )
            self.content.Add(self.overflowbutton,0, RIGHT | EXPAND, self.padding.x)
            self.staticchildren.append(self.overflowbutton)
        else:
            spacersizer = self.spacersizer = wx.BoxSizer(wx.HORIZONTAL)
            spacersizer.Add((self.padding.x, 1),0,EXPAND)
            self.content.Add(spacersizer, 0, EXPAND )

        self.GenWidthRestriction()
Ejemplo n.º 4
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 skinkey=None,
                 overflowmode=False,
                 name='UberBar',
                 alignment=None):

        SimplePanel.__init__(self, parent, FULL_REPAINT_ON_RESIZE)
        UberWidget.__init__(self, 'toolbar')

        self.ChildPaints = Delegate()

        # Initing variables
        self.alignment = alignment if alignment and not overflowmode else ALIGN_LEFT
        self.overflowmode = overflowmode
        self.navimode = False
        self.active = None
        self.children = []
        self.staticchildren = []
        self.overflowed = []
        self.focus = None
        self.lastheight = 0

        Bind = self.Bind
        Bind(wx.EVT_PAINT, self.OnBGPaint)
        Bind(wx.EVT_SIZE, self.OnReSize)

        self.keyletters = {}

        self.tlmargins = Size()
        self.brmargins = Size()

        #Start setting up an alternaitve Native Menubar for native mode

        self.SetSkinKey(skinkey, True)

        self.content = wx.BoxSizer(HORIZONTAL)
        sizer = self.Sizer = wx.GridBagSizer()
        sizer.SetEmptyCellSize(wx.Size(0, 0))

        contentFlag = TOP | BOTTOM | (self.alignment | EXPAND if self.alignment
                                      == ALIGN_LEFT else self.alignment)

        sizer.Add(self.content, (1, 1),
                  flag=contentFlag,
                  border=self.padding.y)
        sizer.Add(Size(self.margins.left, self.margins.top), (0, 0))
        sizer.Add(Size(self.margins.right, self.margins.bottom), (2, 2))
        sizer.AddGrowableCol(1, 1)
        sizer.AddGrowableRow(1, 1)
        #

        #Set up the menu for the overflowed items if overflow mode
        if overflowmode:
            self.overflowmenu = SimpleMenu(self, self.menuskin)
            self.overflowbutton = UberButton(self,
                                             skin=self.buttonskin,
                                             type='menu',
                                             menu=self.overflowmenu)
            self.content.Add((self.padding.x, 1), 1, EXPAND)
            self.content.Add(self.overflowbutton, 0, RIGHT | EXPAND,
                             self.padding.x)
            self.staticchildren.append(self.overflowbutton)
        else:
            spacersizer = self.spacersizer = wx.BoxSizer(wx.HORIZONTAL)
            spacersizer.Add((self.padding.x, 1), 0, EXPAND)
            self.content.Add(spacersizer, 0, EXPAND)

        self.GenWidthRestriction()
Ejemplo n.º 5
0
    def __init__(self,
                 parent,
                 id=-1,
                 label='',
                 skin=None,
                 icon=None,
                 pos=wx.DefaultPosition,
                 size=None,
                 style=HORIZONTAL,
                 type=None,
                 menu=None,
                 menubarmode=False,
                 onclick=None):
        """
        Usage:
            UberButton(parent,id,label,skin,icon,pos,size,style,type,menu)
            -skin  - instead of detecting skins presence lke most UberGUI
                     this takes the skin as an argument from the parent
                     this allows different skins to be set to different
                     buttons at the same time
                     if not assigned will look OS native

            -icon  - The icon to show up on the button
                     Note: the button resizes to fit the icon, not vice versa

            -pos   - position of the button

            -size  - size of the button, this is actualy ignored and will
                     likely be adjusted to affect restraint size later

            -style - wx.HORIZONTAL - Icon centered over label centered on button
                     wx.VERTICAL - Icon spaced from left with label to the right

            -type  - None - normal button
                     combo - no behavior changes, only changes the drawing code
                             on native butons
                     toggle - button toggles True and False, needs visual
                              notification in native mode
                     menu - does not return an event, adds a dropdown icon
                            to the rightside of the button, when toggled on
                            displays the menu associated to it
            -menu  - the menu to drop down when the button is clicked if
                     type is menu
        """

        wx.PyControl.__init__(self,
                              parent,
                              id=id,
                              pos=pos,
                              style=wx.NO_BORDER | wx.FULL_REPAINT_ON_RESIZE)

        if type == "combo":
            UberWidget.__init__(self, 'COMBOBOX')
        else:
            UberWidget.__init__(self, "button")

        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)

        self.label = label
        if label:
            self.RegAccel(label)

        self.notified = False
        self.active = False
        self.isdown = False
        self.hovered = False

        self.state = 1
        self.menu = menu if type == 'menu' else None
        if menu is not None and hasattr(menu, 'OnDismiss'):
            menu.OnDismiss += lambda: self.AddPendingEvent(
                wx.MenuEvent(wx.wxEVT_MENU_CLOSE, menu.Id))

        if icon:
            self.icon = icon
            self.MakeDicon()
        else:
            self.icon = None

        self.style = style
        self.type = type
        self.menubarmode = menubarmode
        self.ssize = wx.Size(0, 0)
        self.staticwidth = None

        if size:
            self.autoscale = False
        else:
            self.autoscale = True

        self.native = None
        self.Sizer = wx.BoxSizer(HORIZONTAL)

        self.SetSkinKey(skin, True)

        Bind = self.Bind
        Bind(wx.EVT_MOVE, lambda e: self.Refresh()),
        Bind(wx.EVT_PAINT, self.OnPaint),
        Bind(wx.EVT_SET_FOCUS, lambda e: self.Refresh()),
        Bind(wx.EVT_KEY_DOWN, self.OnKeyDown),
        Bind(wx.EVT_KEY_UP, self.OnKeyUp),
        Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus),
        Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown),
        Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown),
        Bind(wx.EVT_LEFT_UP, self.OnLeftUp),
        Bind(wx.EVT_ENTER_WINDOW, self.OnMouseIn),
        Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseOut),
        Bind(wx.EVT_MOTION, self.OnMotion),
        Bind(wx.EVT_MENU_CLOSE, lambda e:
             (self.Active(False), self.OnMouseOut()))
        Bind(wx.EVT_SHOW, self.OnShow)

        if onclick is not None:
            if not hasattr(onclick, '__call__'):
                raise TypeError('onclick must be callable')
            self.Bind(wx.EVT_BUTTON, lambda e: (e.Skip(), onclick()))
Ejemplo n.º 6
0
    def __init__(self, parent, id = -1, label='', skin=None, icon=None,
                 pos=wx.DefaultPosition, size=None, style=HORIZONTAL,
                 type=None, menu=None, menubarmode=False, onclick = None):
        """
        Usage:
            UberButton(parent,id,label,skin,icon,pos,size,style,type,menu)
            -skin  - instead of detecting skins presence lke most UberGUI
                     this takes the skin as an argument from the parent
                     this allows different skins to be set to different
                     buttons at the same time
                     if not assigned will look OS native

            -icon  - The icon to show up on the button
                     Note: the button resizes to fit the icon, not vice versa

            -pos   - position of the button

            -size  - size of the button, this is actualy ignored and will
                     likely be adjusted to affect restraint size later

            -style - wx.HORIZONTAL - Icon centered over label centered on button
                     wx.VERTICAL - Icon spaced from left with label to the right

            -type  - None - normal button
                     combo - no behavior changes, only changes the drawing code
                             on native butons
                     toggle - button toggles True and False, needs visual
                              notification in native mode
                     menu - does not return an event, adds a dropdown icon
                            to the rightside of the button, when toggled on
                            displays the menu associated to it
            -menu  - the menu to drop down when the button is clicked if
                     type is menu
        """

        wx.PyControl.__init__(self, parent, id=id, pos=pos, style = wx.NO_BORDER | wx.FULL_REPAINT_ON_RESIZE)

        if type=="combo":
            UberWidget.__init__(self, 'COMBOBOX' )
        else:
            UberWidget.__init__(self, "button" )



        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)

        self.label=label
        if label:
            self.RegAccel(label)

        self.notified = False
        self.active   = False
        self.isdown   = False
        self.hovered  = False

        self.state = 1
        self.menu = menu if type == 'menu' else None
        if menu is not None and hasattr(menu,'OnDismiss'):
            menu.OnDismiss += lambda: self.AddPendingEvent(wx.MenuEvent(wx.wxEVT_MENU_CLOSE, menu.Id))

        if icon:
            self.icon = icon
            self.MakeDicon()
        else:
            self.icon = None

        self.style = style
        self.type  = type
        self.menubarmode = menubarmode
        self.ssize = wx.Size(0,0)
        self.staticwidth = None

        if size:
            self.autoscale = False
        else:
            self.autoscale=True

        self.native = None
        self.Sizer  = wx.BoxSizer(HORIZONTAL)

        self.SetSkinKey(skin,True)

        Bind = self.Bind
        Bind(wx.EVT_MOVE, lambda e: self.Refresh()),
        Bind(wx.EVT_PAINT, self.OnPaint),
        Bind(wx.EVT_SET_FOCUS,lambda e: self.Refresh()),
        Bind(wx.EVT_KEY_DOWN,self.OnKeyDown),
        Bind(wx.EVT_KEY_UP,self.OnKeyUp),
        Bind(wx.EVT_KILL_FOCUS,self.OnKillFocus),
        Bind(wx.EVT_LEFT_DOWN,self.OnLeftDown),
        Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown),
        Bind(wx.EVT_LEFT_UP,self.OnLeftUp),
        Bind(wx.EVT_ENTER_WINDOW,self.OnMouseIn),
        Bind(wx.EVT_LEAVE_WINDOW,self.OnMouseOut),
        Bind(wx.EVT_MOTION,self.OnMotion),
        Bind(wx.EVT_MENU_CLOSE, lambda e: (self.Active(False),self.OnMouseOut()))
        Bind(wx.EVT_SHOW,         self.OnShow)

        if onclick is not None:
            if not hasattr(onclick, '__call__'):
                raise TypeError('onclick must be callable')
            self.Bind(wx.EVT_BUTTON, lambda e: (e.Skip(), onclick()))