コード例 #1
0
ファイル: emailpanels.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self):
        self.padding    = wx.Point(4, 4)

        self.headerfont = skin.get('infobox.fonts.header',lambda: default_font())
        self.linkfont   = CopyFont(skin.get('infobox.fonts.link',lambda: default_font()), underline=True)
        self.elinkfont  = CopyFont(self.linkfont, weight=wx.FONTWEIGHT_BOLD)
        self.headerfc=skin.get('infobox.fontcolors.navbarheader', lambda: wx.BLACK)
        self.linkfc=skin.get('infobox.fontcolors.navbarlink', lambda: wx.BLUE)

        linkposx = self.padding[0]*2 + 16
        linkposy = self.headerfont.Height+2*self.padding[1]
        self.linkage.SetPosition((linkposx,linkposy))


        for link in self.linkage:
            link.NormalColour=link.HoverColour=link.VisitedColour=self.linkfc
            link.Font=self.linkfont
        self.linkage.Layout()


        elink = self.extralinkage
        if elink:
            elink.NormalColour = elink.HoverColour = elink.VisitedColour = self.linkfc
            elink.Font = self.elinkfont

            elink.Size = elink.BestSize
            elinkposx = self.Size.width - self.padding[0] - elink.BestSize.width
            elink.SetPosition((elinkposx, linkposy))


        self.bg   = skin.get('infobox.backgrounds.header', lambda: SkinColor(wx.Color(225, 255, 225)))
#        self.sep  = skin.get('infobox.longseparatorimage', None)
        self.Size = self.MinSize = wx.Size(-1, self.headerfont.Height + self.linkfont.Height + self.padding.y * 4)# + self.sep.Size.height
コード例 #2
0
ファイル: UberProgressBar.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self):
        """
            Updates all the local skin references
        """
        key = self.skinkey

        s = lambda k, default = sentinel: skin.get(key + '.' + k, default)

        mode = try_this(lambda: str(s('mode', '')), '')
        if config.platformName != "mac" and key and mode.lower() != 'native':
            self.native=False

            self.repeat   = try_this(lambda: str(s('style',  '')).lower(), '') == 'repeat'
            self.padding  = s('padding', 0)
            self.Font     = s('font', lambda: default_font())

            self.bg       = s('backgrounds.normal', None)
            self.fg       = s('backgrounds.fill',   lambda: SkinColor(wx.BLUE))

            self.normalfc = s('fontcolors.normal', wx.BLACK)
            self.fillfc   = s('fontcolors.fill',   wx.WHITE)

        else:
            self.native   = True

        self.OnSize()
コード例 #3
0
    def UpdateSkin(self):

        g = skin.get
        self.buttonbarskin = g('SendBar.ToolBarSkin', None)
        self.subjectskin = g('EmailSubjectBar.ToolBarSkin', None)

        self.subjectfont = g('EmailSubjectBar.Fonts.SubjectLabel',
                             lambda: default_font())
        self.subjectfc = g('EmailSubjectBar.FontColors.SubjectLabel', wx.BLACK)

        self.buttonbarfont = g('SendBar.Font', default_font)
        self.buttonnarfc = g('SendBar.FontColor', wx.BLACK)

        if self.gui_constructed:

            self.subject_bar.SetSkinKey(self.subjectskin)
            self.email_buttons.SetSkinKey(self.buttonbarskin)

            ept = self.email_progress_text
            ept.SetFont(self.buttonbarfont)
            ept.SetFontColor(self.buttonnarfc)

            sl = self.subject_label
            sl.SetFont(self.subjectfont)
            sl.SetFontColor(self.subjectfc)
コード例 #4
0
    def __init__(
        self,
        parent,
        list2sort,
        prettynames=None,
        listcallback=None,
        ischecked=None  # if given, a function of one argument that determines if an argument is checked
    ):

        wx.VListBox.__init__(self, parent)
        self.Font = default_font()
        self.item_height = self.Font.Height + 12

        self.oldlist = None
        self.prettynames = prettynames or {}
        self.listcallback = listcallback

        self.SetList(list2sort)
        self.setup_checkboxes(ischecked)
        self.BackgroundColour = wx.WHITE
        self._hovered = -1

        Bind = self.Bind
        Bind(wx.EVT_MOTION, self.OnMotion)
        Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        Bind(wx.EVT_LEFT_UP, self.OnLeftUp)

        Bind(wx.EVT_PAINT, self.OnPaint)
コード例 #5
0
    def UpdateSkin(self):
        """
            Updates all the local skin references
        """
        key = self.skinkey

        s = lambda k, default=sentinel: skin.get(key + '.' + k, default)

        mode = try_this(lambda: str(s('mode', '')), '')
        if config.platformName != "mac" and key and mode.lower() != 'native':
            self.native = False

            self.repeat = try_this(lambda: str(s('style', '')).lower(),
                                   '') == 'repeat'
            self.padding = s('padding', 0)
            self.Font = s('font', lambda: default_font())

            self.bg = s('backgrounds.normal', None)
            self.fg = s('backgrounds.fill', lambda: SkinColor(wx.BLUE))

            self.normalfc = s('fontcolors.normal', wx.BLACK)
            self.fillfc = s('fontcolors.fill', wx.WHITE)

        else:
            self.native = True

        self.OnSize()
コード例 #6
0
 def __init__(self, service_provider, font_adjust = 0, *a, **k):
     self.service_provider = IServiceProviderGUIMetaData(service_provider)
     super(ServiceProviderBubble, self).__init__((0,0), *a, **k)
     self.Font = default_font()
     self.font_adjust = font_adjust
     self._service_provider = None
     self.recalcsize()
コード例 #7
0
ファイル: visuallisteditor.py プロジェクト: AlexUlrich/digsby
    def __init__(self,
                 parent,
                 list2sort,
                 prettynames = None,
                 listcallback = None,
                 ischecked = None          # if given, a function of one argument that determines if an argument is checked
        ):

        wx.VListBox.__init__(self, parent)
        self.Font = default_font()
        self.item_height = self.Font.Height + 12

        self.oldlist = None
        self.prettynames = prettynames or {}
        self.listcallback = listcallback

        self.SetList(list2sort)
        self.setup_checkboxes(ischecked)
        self.BackgroundColour = wx.WHITE
        self._hovered = -1

        Bind = self.Bind
        Bind(wx.EVT_MOTION, self.OnMotion)
        Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        Bind(wx.EVT_LEFT_UP, self.OnLeftUp)

        Bind(wx.EVT_PAINT,self.OnPaint)
コード例 #8
0
ファイル: formatprefsmixin.py プロジェクト: AlexUlrich/digsby
def StyleFromPref(prefname):

    try:
        stylepref = pref(prefname)

        if isinstance(stylepref, basestring):
            style = dict(Font = makeFont(stylepref))
        else:
            style = dict(stylepref)
    except Exception:
        print_exc()
        style = {}

    if type(style['Font']) is tuple:
        try:
            font = TupleToFont(style['Font'])
        except Exception:
            print_exc()
            font = try_this(lambda: makeFont('Arial 10'), default_font())
    else:
        font = style['Font']
    fgc  = try_this(lambda: wx.Colour(*style['TextColour']), None) or wx.BLACK #@UndefinedVariable
    bgc  = try_this(lambda: wx.Colour(*style['BackgroundColour']), None) or wx.WHITE #@UndefinedVariable

    return wx.TextAttr(fgc, bgc, font)
コード例 #9
0
ファイル: winfonts.py プロジェクト: sgricci/digsby
def main():
    import wx
    dc = wx.MemoryDC()
    dc.SetFont(default_font())

    size = GetFontUnicodeRanges(dc.GetHDC(), 0)
    if not size: raise Exception(GFURerror)

    numRanges = (size - sizeof(DWORD) * 4) / sizeof(WCRANGE)

    class GLYPHSET(WinStruct):
        _fields_ = [('cbThis', DWORD),
                    ('flAccel', DWORD),
                    ('cGlyphsSupported', DWORD),
                    ('cRanges', DWORD),
                    ('ranges', WCRANGE * numRanges),
                    ]

    g = GLYPHSET(cbThis = size, ranges = [WCRANGE() for x in xrange(numRanges)])


    if not GetFontUnicodeRanges(dc, glyphset.ptr):
        raise Exception(GFURerror)

    print g
コード例 #10
0
ファイル: formatprefsmixin.py プロジェクト: sgricci/digsby
def StyleFromPref(prefname):

    try:
        stylepref = pref(prefname)

        if isinstance(stylepref, basestring):
            style = dict(Font=makeFont(stylepref))
        else:
            style = dict(stylepref)
    except Exception:
        print_exc()
        style = {}

    if type(style['Font']) is tuple:
        try:
            font = TupleToFont(style['Font'])
        except Exception:
            print_exc()
            font = try_this(lambda: makeFont('Arial 10'), default_font())
    else:
        font = style['Font']
    fgc = try_this(lambda: wx.Colour(*style['TextColour']),
                   None) or wx.BLACK  #@UndefinedVariable
    bgc = try_this(lambda: wx.Colour(*style['BackgroundColour']),
                   None) or wx.WHITE  #@UndefinedVariable

    return wx.TextAttr(fgc, bgc, font)
コード例 #11
0
ファイル: filetransferlist.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self, first = False):
        skin_get = skin.get

        def g(k, default = sentinel):
            elem = skin_get('FileTransfers.Fonts.%s' % k, default)
            if elem is None: return default()
            else:            return elem

        fonts = self.fonts = S()
        fonts.filename = g('filename', lambda: default_font())
        fonts.other    = g('other', lambda: fonts.filename)
        fonts.link     = g('link', lambda: fonts.filename)

        g = lambda k, default = sentinel: (skin_get('FileTransfers.FontColors.%s' % k, default) or default())

        fontcolors = self.fontcolors = S()
        fontcolors.filename = g('filename', lambda: wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
        fontcolors.other    = g('other', lambda: fontcolors.filename)
        fontcolors.link     = g('link', lambda: wx.BLUE)

        fontcolors.filenameselected = g('filenameselected', lambda: wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))
        fontcolors.otherselected    = g('otherselected', lambda: fontcolors.filenameselected)
        fontcolors.linkselected     = g('linkselected', lambda: fontcolors.filenameselected)

        self.filetype_icon_size = 32

        self.bg = skin_get('filetransfers.backgrounds.list', lambda: SkinColor(wx.WHITE))

        if not first: wx.CallAfter(self.Layout)
コード例 #12
0
    def paint(e):
        dc = wx.AutoBufferedPaintDC(f)
        gc = wx.GraphicsContext.Create(dc)
        r = f.ClientRect
        x1, y1 = r.TopLeft
        x2, y2 = r.BottomRight

        br = gc.CreateLinearGradientBrush(x1, y1, x2, y2, wx.BLACK, wx.WHITE)
        gc.SetBrush(br)
        gc.DrawRectangle(*r)
        dc.TextForeground = wx.WHITE
        dc.Font = default_font()

        j = int(ceil(sqrt(len(bitmaps))))

        i = 0
        for y in xrange(j):
            for x in xrange(j):
                w, h   = r.Width / j, r.Height / j
                xx, yy = w * x, h * y

                if len(bitmaps) > i:
                    dc.DrawBitmap(bitmaps[i].Resized(min((w, h))), xx, yy)


                    dc.DrawText(str(bitmaps[i].GetRefData()), xx, yy)

                i += 1
コード例 #13
0
    def UpdateSkin(self):
        'Tells the subbars what skins they should load.'

        sget = skin.get
        self.capabilitiesskin = sget('actionsbar.toolbarskin', None)
        self.tofromskin = sget('tofrombar.toolbarskin', None)

        self.menuskin = sget('%s.menuskin' % self.capabilitiesskin, None)

        self.tofromcomboskin = sget("tofrombar.comboboxskin", None)

        self.iconsize = sget('ActionsBar.IconSize')
        self.icons = sget('ActionsBar.Icons')

        if hasattr(self, 'to_label'):
            tofrom_font = sget('tofrombar.font', lambda: default_font())
            tofrom_color = sget('tofrombar.fontcolor', lambda: wx.BLACK)

            self.to_label.Font = self.from_label.Font = tofrom_font
            self.to_label.FontColor = self.from_label.FontColor = tofrom_color

        if hasattr(self, 'cbar'): self.cbar.SetSkinKey(self.capabilitiesskin)
        if hasattr(self, 'tfbar'): self.tfbar.SetSkinKey(self.tofromskin)
        if hasattr(self, 'cto'): self.cto.SetSkinKey(self.tofromcomboskin)
        if hasattr(self, 'cfrom'): self.cfrom.SetSkinKey(self.tofromcomboskin)

        self.UpdateIcons()
コード例 #14
0
ファイル: imwin_email.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self):

        g = skin.get
        self.buttonbarskin = g('SendBar.ToolBarSkin', None)
        self.subjectskin = g('EmailSubjectBar.ToolBarSkin',None)

        self.subjectfont = g('EmailSubjectBar.Fonts.SubjectLabel',lambda: default_font())
        self.subjectfc = g('EmailSubjectBar.FontColors.SubjectLabel', wx.BLACK)

        self.buttonbarfont = g('SendBar.Font', default_font)
        self.buttonnarfc = g('SendBar.FontColor', wx.BLACK)


        if self.gui_constructed:

            self.subject_bar.SetSkinKey(self.subjectskin)
            self.email_buttons.SetSkinKey(self.buttonbarskin)

            ept = self.email_progress_text
            ept.SetFont(self.buttonbarfont)
            ept.SetFontColor(self.buttonnarfc)

            sl = self.subject_label
            sl.SetFont(self.subjectfont)
            sl.SetFontColor(self.subjectfc)
コード例 #15
0
ファイル: status.py プロジェクト: sgricci/digsby
    def __init__(self, parent, excpetionlist):
        SimplePanel.__init__(self, parent, wx.FULL_REPAINT_ON_RESIZE)

        self.Font = default_font()

        self.exceptionlist = excpetionlist
        self.MinSize = (-1, self.Font.Height + 10 + self.Font.Descent)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
コード例 #16
0
ファイル: errorpanel.py プロジェクト: sgricci/digsby
    def UpdateSkin(self):
        """
            The Usual
        """
        key = 'infobox'

        if skin.get(key,False):
            s = lambda k,d: skin.get('%s.%s'%(key,k),d)
        else:
            s = lambda k,d: d

        self.padding = s('padding', lambda: wx.Point(2, 2))
        self.labelf = s('fonts.title',lambda: default_font())
        self.labelfc = s('fontcolors.title', wx.BLACK)
        self.linkf = CopyFont(s('fonts.link',lambda: default_font()), underline=True)
        self.linkfc = s('fontcolors.link', wx.BLUE)
        self.bg = s('backgrounds.email', lambda: SkinColor(wx.WHITE))
コード例 #17
0
ファイル: tab.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self):
        key = self.skinkey
        s = lambda k, default = sentinel,mode=0: skin.get('%s%s.%s' % ('side'*mode,key, k), default)

        self.mode = pref('tabs.side_tabs',False)

        self.maxtabwidth = s('maxwidth',pref('tabs.max_width',100))#TODO: Completly remove pref?

        padd = s('padding', lambda: Point(0, 0))
        marg = s('margins', lambda: Margins([0,0,0,0]))
        icsz = s('iconsize', 16)
        font = s('font', lambda: default_font())
        spad = s('padding', padd, 1)
        smar = s('margins', marg, 1)
        sico = s('iconsize', icsz, 1)
        sfnt = s('font', font, 1)

        self.padding = (padd,spad)
        self.margins = (marg,smar)
        self.iconsize = (icsz,sico)
        self.font = (font,sfnt)

        states = self.states
        states[0][0] = s('backgrounds.normal')
        states[0][1] = s('backgrounds.active')
        states[0][2] = s('backgrounds.hover',       states[0][0])
        states[0][3] = s('backgrounds.activehover', states[0][2])
        states[0][4] = s('backgrounds.notify',      states[0][0])

        states[1][0] = s('backgrounds.normal',      states[0][0],1)
        states[1][1] = s('backgrounds.active',      states[0][1],1)
        states[1][2] = s('backgrounds.hover',       states[0][2],1)
        states[1][3] = s('backgrounds.activehover', states[0][3],1)
        states[1][4] = s('backgrounds.notify',      states[0][4],1)

        fc = self.fontcolors
        fc[0][0] = s('fontcolors.normal',      BLACK)
        fc[0][1] = s('fontcolors.active',      BLACK)
        fc[0][2] = s('fontcolors.hover',       fc[0][0])
        fc[0][3] = s('fontcolors.activehover', fc[0][2])
        fc[0][4] = s('fontcolors.notify',      fc[0][0])

        fc[1][0] = s('fontcolors.normal',      fc[0][0],1)
        fc[1][1] = s('fontcolors.active',      fc[0][1],1)
        fc[1][2] = s('fontcolors.hover',       fc[1][0],1)
        fc[1][3] = s('fontcolors.activehover', fc[1][2],1)
        fc[1][4] = s('fontcolors.notify',      fc[1][0],1)

        if pref('tabs.style', 2) and not hasattr(self, 'closebutton'):
            self.GenCloseButton()

        if hasattr(self, 'closebutton'):
            self.closebutton.SetSkinKey(self.Parent.closebuttonskin)
            self.closebutton.SetIcon(self.Parent.closeicon)

        self.Calcumalate()
        self.Refresh(False)
コード例 #18
0
    def __init__(self, parent, data, *a, **k):
        self.data = data
        self._base_color_tuple = (128,128,128)
        self._name_color_tuple = (0,0,0)
        ret = super(ServiceProviderRow, self).__init__(parent=parent, data=data, *a, **k)
#        self.SetToolTipString(IServiceProviderGUIMetaData(data).provider_name +\
#                              ': ' + IServiceProviderInstanceGUIMetaData(data).account_name)
        self.Font = default_font()
        return ret
コード例 #19
0
ファイル: vista.py プロジェクト: sgricci/digsby
 def newinit(self, *a, **k):
     try:
         oldinit(self, *a, **k)
     except:
         # WXPYHACK
         from util import funcinfo
         import sys
         print >> sys.stderr, '_change_font failed at %s' % funcinfo(oldinit)
         raise
     self.SetFont(default_font())
コード例 #20
0
ファイル: renderers.py プロジェクト: sgricci/digsby
def safefont(name, size, bold = False):
    weight = FONTWEIGHT_BOLD if bold else FONTWEIGHT_NORMAL

    try:
        return Font(size, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, weight, False, name)
    except:
        print_exc()

        font = default_font()
        font.SetPointSize(size)
        font.SetWeight(weight)
        return font
コード例 #21
0
ファイル: roomlist.py プロジェクト: AlexUlrich/digsby
    def __init__(self, *a, **k):
        wx.VListBox.__init__(self, *a, **k)
        syscol = wx.SystemSettings.GetColour

        self.colors = Storage(textfg=Storage(selected=syscol(wx.SYS_COLOUR_HIGHLIGHTTEXT),
                                               normal=syscol(wx.SYS_COLOUR_WINDOWTEXT)))

        self.bg = Storage(selected=SkinColor(syscol(wx.SYS_COLOUR_HIGHLIGHT)),
                              normal=SkinColor(syscol(wx.SYS_COLOUR_LISTBOX)))

        self.fonts = Storage(text=default_font())

        self.BBind(LEFT_DOWN=self._OnLeftDown)
コード例 #22
0
    def OnDrawItem(self, dc, rect, n):
        selected = self.GetSelection() == n

        font = default_font()
        if selected:
            font.SetWeight(wx.FONTWEIGHT_BOLD)

        fh = font.Height
        dc.Font = font
        dc.TextForeground = wx.BLACK

        pt = wx.Point(*rect[:2]) + (5, self.item_height / 2 - fh / 2)
        dc.DrawText(self.tabname(n), *pt)
コード例 #23
0
    def UpdateSkin(self):
        self.padding = wx.Point(4, 4)

        self.headerfont = skin.get('infobox.fonts.header',
                                   lambda: default_font())
        self.linkfont = CopyFont(skin.get('infobox.fonts.link',
                                          lambda: default_font()),
                                 underline=True)
        self.elinkfont = CopyFont(self.linkfont, weight=wx.FONTWEIGHT_BOLD)
        self.headerfc = skin.get('infobox.fontcolors.navbarheader',
                                 lambda: wx.BLACK)
        self.linkfc = skin.get('infobox.fontcolors.navbarlink',
                               lambda: wx.BLUE)

        linkposx = self.padding[0] * 2 + 16
        linkposy = self.headerfont.Height + 2 * self.padding[1]
        self.linkage.SetPosition((linkposx, linkposy))

        for link in self.linkage:
            link.NormalColour = link.HoverColour = link.VisitedColour = self.linkfc
            link.Font = self.linkfont
        self.linkage.Layout()

        elink = self.extralinkage
        if elink:
            elink.NormalColour = elink.HoverColour = elink.VisitedColour = self.linkfc
            elink.Font = self.elinkfont

            elink.Size = elink.BestSize
            elinkposx = self.Size.width - self.padding[0] - elink.BestSize.width
            elink.SetPosition((elinkposx, linkposy))

        self.bg = skin.get('infobox.backgrounds.header',
                           lambda: SkinColor(wx.Color(225, 255, 225)))
        #        self.sep  = skin.get('infobox.longseparatorimage', None)
        self.Size = self.MinSize = wx.Size(
            -1, self.headerfont.Height + self.linkfont.Height +
            self.padding.y * 4)  # + self.sep.Size.height
コード例 #24
0
ファイル: prefsdialog.py プロジェクト: AlexUlrich/digsby
    def OnDrawItem(self, dc, rect, n):
        selected = self.GetSelection() == n


        font = default_font()
        if selected:
            font.SetWeight( wx.FONTWEIGHT_BOLD )

        fh = font.Height
        dc.Font = font
        dc.TextForeground = wx.BLACK

        pt = wx.Point(*rect[:2]) + (5, self.item_height / 2 - fh / 2)
        dc.DrawText(self.tabname(n), *pt)
コード例 #25
0
ファイル: roomlist.py プロジェクト: sgricci/digsby
    def __init__(self, *a, **k):
        wx.VListBox.__init__(self, *a, **k)
        syscol = wx.SystemSettings.GetColour

        self.colors = Storage(
            textfg=Storage(selected=syscol(wx.SYS_COLOUR_HIGHLIGHTTEXT),
                           normal=syscol(wx.SYS_COLOUR_WINDOWTEXT)))

        self.bg = Storage(selected=SkinColor(syscol(wx.SYS_COLOUR_HIGHLIGHT)),
                          normal=SkinColor(syscol(wx.SYS_COLOUR_LISTBOX)))

        self.fonts = Storage(text=default_font())

        self.BBind(LEFT_DOWN=self._OnLeftDown)
コード例 #26
0
ファイル: vista.py プロジェクト: sgricci/digsby
    def paint(e):
        dc = wx.PaintDC(f)
        dc.Brush, dc.Pen = wx.BLACK_BRUSH, wx.TRANSPARENT_PEN
        #dc.DrawRectangle(0,0,*f.Size)

        bmap = TransparentBitmap(f.Size)
        dc2  = wx.MemoryDC()
        dc2.SelectObject(bmap)
        dc2.Font = default_font()
        dc2.TextForeground = wx.RED
        dc2.DrawText('hello', 0, 0)

        #DrawThemeTextEx(f, dc2.GetHDC(), u'Hello World')
        dc.DrawBitmap(bmap, 0, 0)
        e.Skip(True)
コード例 #27
0
ファイル: treelist.py プロジェクト: sgricci/digsby
    def default_draw(self, dc, rect, n):
        '''
        If a subclass has not provided a "better" way to draw this item, use
        a default method of drawing here--which is just to str(the object) and
        draw an exapander arrow if the object is iterable.
        '''
        # decide on a text color
        if self.IsSelected(n): fg = wx.SYS_COLOUR_HIGHLIGHTTEXT
        else: fg = wx.SYS_COLOUR_WINDOWTEXT
        dc.SetTextForeground(wx.SystemSettings_GetColour(fg))

        # use GUI font
        font = default_font()
        dc.SetFont(font)

        # choose an expanded or collapsed triangle
        if self.model.is_expanded(n): tri = self.expandedTri
        else: tri = self.collapsedTri

        # triangles will be black
        dc.SetPen(wx.BLACK_PEN)
        dc.SetBrush(wx.BLACK_BRUSH)

        obj = self.model[n]
        xoffset = self.indent * self.model.depths[idfunc(obj)][0]

        yy = rect.y + (rect.height / 2) - (3)
        if hasattr(obj, 'expandable'):
            if obj.expandable():
                dc.DrawPolygon([(x + rect.x + xoffset, y + yy)
                                for (x, y) in tri])
        else:
            if hasChildren(obj):
                dc.DrawPolygon([(x + rect.x + xoffset, y + yy)
                                for (x, y) in tri])

        icon = getattr(obj, 'icon', None)
        x = rect.x + 20 + xoffset
        if icon:
            dc.DrawBitmap(icon, rect.x + 20,
                          rect.y + (rect.Height / 2 - icon.GetHeight() / 2))
            x += icon.GetWidth() + 10

        dc.DrawText(unicode(obj), x,
                    rect.y + (rect.Height / 2 - GetFontHeight(font, dc) / 2))
コード例 #28
0
ファイル: umenu.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self):
        self.SetMargins(wx.Point(0, 0))
        s = self.skin = self.menu.skin
        self.sepheight = s.separatorimage.Size.height

        try: self.font = s.font
        except KeyError: self.font = default_font()

        self.fontheight = s.font.Height

        try:
            self.padding = s.padding
            assert isinstance(self.padding.x, int) and isinstance(self.padding.y, int)
        except Exception:
            self.padding = wx.Point(3, 3)

        self.itemheight = int(self.fontheight + self.padding.y * 2)

        self.Background = s.backgrounds.menu
コード例 #29
0
ファイル: cleartext.py プロジェクト: AlexUlrich/digsby
    def __init__(self, parent, label = '', alignment = default_alignment):
        BoxSizer.__init__(self, HORIZONTAL)

        self.parent    = parent
        self.label     = self.flabel = label
        self.fontcolor = wx.BLACK
        self.font      = default_font()
        self.alignment = alignment

        #Child used to hook into drawing events
        self.anchor = wx.Window(parent, -1 ,size=(1, 1),
                                style = wx.BORDER_NONE | wx.TRANSPARENT_WINDOW)
        self.anchor.Bind(wx.EVT_ERASE_BACKGROUND, Null)

        if hasattr(parent, 'ChildPaints'):
            parent.ChildPaints += self.PaintSlave
        else:
            self.anchor.Bind(wx.EVT_PAINT,self.OnPaint)

        self.CalcSize()
コード例 #30
0
ファイル: addcontactdialog.py プロジェクト: AlexUlrich/digsby
    def OnPaint(self,event):
        dc   = wx.AutoBufferedPaintDC(self)
        rect = wx.RectS(self.Size)

        n = self.Parent.Index(self)
        dc.Brush = wx.Brush(bgcolors[n % len(bgcolors)])
        dc.Pen = wx.TRANSPARENT_PEN #@UndefinedVariable

        dc.DrawRectangleRect(rect)

        x = self.checkbox.Rect.Right+3
        w = self.Rect.Width - x - 3
        textrect = wx.Rect(x,0,w,rect.Height)

        dc.Font = default_font()
        dc.DrawLabel(self.name,textrect,ALIGN_LEFT|ALIGN_CENTER_VERTICAL)

        bm = self.bitmap

        dc.DrawBitmap(bm,rect.width-(bm.Size.width+3),3)
コード例 #31
0
ファイル: addcontactdialog.py プロジェクト: sgricci/digsby
    def OnPaint(self, event):
        dc = wx.AutoBufferedPaintDC(self)
        rect = wx.RectS(self.Size)

        n = self.Parent.Index(self)
        dc.Brush = wx.Brush(bgcolors[n % len(bgcolors)])
        dc.Pen = wx.TRANSPARENT_PEN  #@UndefinedVariable

        dc.DrawRectangleRect(rect)

        x = self.checkbox.Rect.Right + 3
        w = self.Rect.Width - x - 3
        textrect = wx.Rect(x, 0, w, rect.Height)

        dc.Font = default_font()
        dc.DrawLabel(self.name, textrect, ALIGN_LEFT | ALIGN_CENTER_VERTICAL)

        bm = self.bitmap

        dc.DrawBitmap(bm, rect.width - (bm.Size.width + 3), 3)
コード例 #32
0
ファイル: treelist.py プロジェクト: AlexUlrich/digsby
    def default_draw(self, dc, rect, n):
        '''
        If a subclass has not provided a "better" way to draw this item, use
        a default method of drawing here--which is just to str(the object) and
        draw an exapander arrow if the object is iterable.
        '''
        # decide on a text color
        if self.IsSelected( n ): fg = wx.SYS_COLOUR_HIGHLIGHTTEXT
        else: fg = wx.SYS_COLOUR_WINDOWTEXT
        dc.SetTextForeground( wx.SystemSettings_GetColour( fg ) )

        # use GUI font
        font = default_font()
        dc.SetFont( font )

        # choose an expanded or collapsed triangle
        if self.model.is_expanded( n ): tri = self.expandedTri
        else: tri = self.collapsedTri

        # triangles will be black
        dc.SetPen( wx.BLACK_PEN )
        dc.SetBrush( wx.BLACK_BRUSH )

        obj = self.model[n]
        xoffset = self.indent * self.model.depths[idfunc(obj)][0]

        yy = rect.y + (rect.height / 2) - (3)
        if hasattr(obj, 'expandable'):
            if obj.expandable():
                dc.DrawPolygon( [( x+rect.x + xoffset, y+yy ) for ( x, y ) in tri] )
        else:
            if hasChildren( obj ):
                dc.DrawPolygon( [( x+rect.x + xoffset, y+yy ) for ( x, y ) in tri] )

        icon = getattr(obj, 'icon', None)
        x = rect.x + 20 + xoffset
        if icon:
            dc.DrawBitmap(icon, rect.x+20, rect.y + (rect.Height / 2 - icon.GetHeight() / 2 ))
            x += icon.GetWidth() + 10

        dc.DrawText( unicode(obj), x, rect.y + (rect.Height / 2 - GetFontHeight(font, dc) / 2) )
コード例 #33
0
    def __init__(self, parent, label='', alignment=default_alignment):
        BoxSizer.__init__(self, HORIZONTAL)

        self.parent = parent
        self.label = self.flabel = label
        self.fontcolor = wx.BLACK
        self.font = default_font()
        self.alignment = alignment

        #Child used to hook into drawing events
        self.anchor = wx.Window(parent,
                                -1,
                                size=(1, 1),
                                style=wx.BORDER_NONE | wx.TRANSPARENT_WINDOW)
        self.anchor.Bind(wx.EVT_ERASE_BACKGROUND, Null)

        if hasattr(parent, 'ChildPaints'):
            parent.ChildPaints += self.PaintSlave
        else:
            self.anchor.Bind(wx.EVT_PAINT, self.OnPaint)

        self.CalcSize()
コード例 #34
0
ファイル: umenu.py プロジェクト: sgricci/digsby
    def UpdateSkin(self):
        self.SetMargins(wx.Point(0, 0))
        s = self.skin = self.menu.skin
        self.sepheight = s.separatorimage.Size.height

        try:
            self.font = s.font
        except KeyError:
            self.font = default_font()

        self.fontheight = s.font.Height

        try:
            self.padding = s.padding
            assert isinstance(self.padding.x, int) and isinstance(
                self.padding.y, int)
        except Exception:
            self.padding = wx.Point(3, 3)

        self.itemheight = int(self.fontheight + self.padding.y * 2)

        self.Background = s.backgrounds.menu
コード例 #35
0
    def __init__(self, parent, skinkey, id = -1, label = '',
                 pos = wx.DefaultPosition,
                 size = wx.DefaultSize,
                 style = wx.NO_BORDER):

        self.Padding = wx.Size()

        wx.PyControl.__init__(self, parent, id = id, style = style)

        self.skinkey = skinkey
        self.margins = Margins((0, 0, 0, 0))
        self._native    = False


        self.Font = default_font()

        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
        self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None)
        self.Bind(wx.EVT_PAINT, self.__paint)

        self.SetLabel(label)
        self.SetInitialSize(size)
        self.InheritAttributes()
コード例 #36
0
ファイル: filetransferlist.py プロジェクト: sgricci/digsby
    def UpdateSkin(self, first=False):
        skin_get = skin.get

        def g(k, default=sentinel):
            elem = skin_get('FileTransfers.Fonts.%s' % k, default)
            if elem is None: return default()
            else: return elem

        fonts = self.fonts = S()
        fonts.filename = g('filename', lambda: default_font())
        fonts.other = g('other', lambda: fonts.filename)
        fonts.link = g('link', lambda: fonts.filename)

        g = lambda k, default=sentinel: (skin_get(
            'FileTransfers.FontColors.%s' % k, default) or default())

        fontcolors = self.fontcolors = S()
        fontcolors.filename = g(
            'filename',
            lambda: wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
        fontcolors.other = g('other', lambda: fontcolors.filename)
        fontcolors.link = g('link', lambda: wx.BLUE)

        fontcolors.filenameselected = g(
            'filenameselected',
            lambda: wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))
        fontcolors.otherselected = g('otherselected',
                                     lambda: fontcolors.filenameselected)
        fontcolors.linkselected = g('linkselected',
                                    lambda: fontcolors.filenameselected)

        self.filetype_icon_size = 32

        self.bg = skin_get('filetransfers.backgrounds.list',
                           lambda: SkinColor(wx.WHITE))

        if not first: wx.CallAfter(self.Layout)
コード例 #37
0
ファイル: cml.py プロジェクト: sgricci/digsby
    if wxMSW:
        ReleaseCapture_win32()


#===============================================================================
wxEVT_ENTER_WINDOW = 10032
wxEVT_LEAVE_WINDOW = 10033

MenuSkinDefaults = {
    'framesize': lambda: Margins([0, 0, 0, 0]),
    'frame': lambda: SkinColor(wx.BLACK),  #@UndefinedVariable
    'padding': lambda: wx.Point(2, 2),
    'backgrounds.menu': lambda: SkinColor(wx.WHITE),  #@UndefinedVariable
    'backgrounds.item': lambda: None,
    'backgrounds.selection': lambda: SkinColor(wx.BLACK),  #@UndefinedVariable
    'font': lambda: default_font(),
    'fontcolors.normal': lambda: wx.BLACK,  #@UndefinedVariable
    'fontcolors.selection': lambda: wx.WHITE,  #@UndefinedVariable
    'separatorimage': lambda: None
}


class CustomMenuFrame(wx.PopupTransientWindow, NewSkinModule):
    def __init__(self, parent):
        wx.PopupTransientWindow.__init__(self, parent)
        self.SetPosition((-50000, -50000))
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.content = None

    def SetContent(self, content):
        self.content = content
コード例 #38
0
ファイル: fontdropdown.py プロジェクト: AlexUlrich/digsby
FontDropDownSkinDefaults = {
    'padding'           : lambda: wx.Point(2,2),
    'margins'           : lambda: Margins([0,0,0,0]),
    'framesize'         : lambda: Margins([0,0,0,0]),
    'frame'             : lambda: SkinColor(wx.BLACK), #@UndefinedVariable
    'backgrounds.normal': lambda: SkinColor(wx.WHITE), #@UndefinedVariable
    'backgrounds.hover' : lambda: SkinColor(wx.BLACK), #@UndefinedVariable
    'backgrounds.down'  : lambda: SkinColor(wx.BLACK), #@UndefinedVariable
    'backgrounds.active': lambda: SkinColor(wx.BLACK), #@UndefinedVariable
    'fontcolors.normal' : lambda: wx.BLACK, #@UndefinedVariable
    'fontcolors.hover'  : lambda: wx.WHITE, #@UndefinedVariable
    'fontcolors.down'   : lambda: wx.WHITE, #@UndefinedVariable
    'fontcolors.active' : lambda: wx.WHITE, #@UndefinedVariable
#    'fontcolors.hint'   : lambda: wx.Color(128,128,128),
    'font'              : lambda: default_font(),
    'menuskin'          : lambda: None,
    'menuicon'          : lambda: skin.get('appdefaults.dropdownicon')
}

menuobjects = {}


class SharedFontDropDownData(BasicMenuData):
    '''
    Extension on the BasicMenuData provider to be shared among all font menus saving memory
    '''
    def __init__(self):
        BasicMenuData.__init__(self)

        global fontnames
コード例 #39
0
ファイル: windowfx.py プロジェクト: sgricci/digsby
 def OnDrawItem(self, dc, rect, n):
     dc.Pen = wx.BLACK_PEN
     dc.Brush = wx.WHITE_BRUSH
     dc.Font = default_font()
     dc.DrawText(str(n), rect.x, rect.y)
コード例 #40
0
ファイル: windowfx.py プロジェクト: AlexUlrich/digsby
 def OnDrawItem(self, dc, rect, n):
     dc.Pen = wx.BLACK_PEN
     dc.Brush = wx.WHITE_BRUSH
     dc.Font = default_font()
     dc.DrawText(str(n), rect.x, rect.y)
コード例 #41
0
ファイル: anylists.py プロジェクト: AlexUlrich/digsby
    def __init__(self, parent, data,
                 row_control = None,
                 multiselect = False,
                 edit_buttons = None,
                 draggable_items = True,
                 style = 0,
                 velocity=None):
        super(AnyList, self).__init__(parent, -1, style = wx.FULL_REPAINT_ON_RESIZE|style)

        self.data_format = wx.CustomDataFormat('AnyList-%s'%id(self))

        self.SetSizer(self.create_sizer())
        self.Font = default_font()

        if edit_buttons is not None:
            edit = dict((child.Id, child) for child in edit_buttons)

            if not hasattr(self, 'OnNew') or not hasattr(self, 'OnDelete'):
                raise AssertionError('to use the edit_buttons parameter you must implement OnNew and OnDelete (in class %s)' % self.__class__.__name__)

            edit[wx.ID_NEW].Bind(wx.EVT_BUTTON, self.OnNew )
            edit[wx.ID_DELETE].Bind(wx.EVT_BUTTON, self.OnDelete)

            self.delete_button = edit[wx.ID_DELETE]
            self.delete_button.Enable(False)
        else:
            self.delete_button = None

        self.velocity = velocity or self.default_velocity

        # List set up
        self.show_selected = True
        self.rows = []
        self.DraggableItems = draggable_items
        self._selection = set()
        self._hovered = -1

        if row_control is None: self.row_control = self.default_row_control
        else: self.row_control = row_control

        # Check to make sure data is observable
        self.data = data
        if hasattr(data, 'add_observer') and callable(data.add_observer):
            # Watch the observable list for changes.
            data.add_observer(self.on_data_changed)

        self.on_data_changed()

        self.multiselect = multiselect

        self.SetAutoLayout(True)
        self.SetupScrolling(False, True, *self.scroll_sizes)

        Bind = self.Bind
        Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
        self.BindWheel(self)
        Bind(wx.EVT_KILL_FOCUS, self.on_lost_focus)
        Bind(wx.EVT_KEY_DOWN, self.on_key)
        Bind(wx.EVT_CHILD_FOCUS, Null) # to nullify bad effects of ScrolledPanel
        Bind(wx.EVT_SCROLLWIN_LINEDOWN, lambda e: self.Scroll(0, self.ViewStart[1] + SCROLL_RATE))
        Bind(wx.EVT_SCROLLWIN_LINEUP, lambda e: self.Scroll(0, self.ViewStart[1] - SCROLL_RATE))

        self.drag = -1
        self.dragging = False
コード例 #42
0
ファイル: UberButton.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self):
        'Simply gets a skin and sets it all up.'

        key = self.skinkey
        native= not key


        if native and self.uxthemeable:
            self.rendernative = True
            self.destroy_native()
            self.OpenNativeTheme()

            skinget = skin.get

            self.menuicon = skinget('appdefaults.dropdownicon')
            self.padding  = (5,5)
            self.margins  = Margins([0,0,0,0])
            self.Font     = default_font()

            self.fontcolors = [wx.BLACK] * 7

            self.backgrounds = NATIVE_BACKGROUNDS
            self.Cut()

        elif native:
            if not self.native:
                self.native = wx.Button(self,style=wx.BU_EXACTFIT)
                self.native.SetLabel(self.label)
                self.Sizer.Add(self.native, 1, wx.EXPAND)
                self.Layout()
                self.Cut()

        else:
            self.rendernative = False
            self.destroy_native()
            skinget = skin.get
            skinroot = skin.get(key)
            #s = lambda k, default = sentinel: skinget('%s.%s' % (key, k), default)

            s = skinroot.get
            self.menuicon = s('menuicon', skinget('appdefaults.dropdownicon'))
            self.padding  = s('padding', (5,5))
            self.margins  = s('margins', Margins([0,0,0,0]))
            self.Font     = s('font',    default_font())


            fc = skinroot.get('fontcolors', {})
            s = fc.get
            self.fontcolors = [s('disabled',    Color(125,125,125)),
                               s('normal',      wx.BLACK),
                               s('active',      wx.BLACK),
                               s('hover',       wx.BLACK),
                               s('activehover', wx.BLACK),
                               s('down',        wx.BLACK),
                               s('notify',      wx.WHITE)]

            bgs = skinroot.get('backgrounds', {})
            def s(key, default):
                try: return bgs[key]
                except: return default()

            disabled    = s('disabled',    lambda: SkinGradient('vertical', [Color(125,125,125), Color(237,237,237)]))
            normal      = s('normal',      lambda: SkinGradient('vertical', [Color(200,255,200), Color(85,255,85)]))
            active      = s('active',      lambda: SkinGradient('vertical', [Color(200,255,238), Color(85,255,238)]))
            hover       = s('hover',       lambda: normal)
            activehover = s('activehover', lambda: active)
            down        = s('down',        lambda: SkinGradient('vertical', [Color(0,125,0),     Color(00,204,00)]))
            notify      = s('notify',      lambda: SkinGradient('vertical', [Color(255,255,200), Color(255,255,85)]))

            self.backgrounds = [disabled,
                                normal,
                                active,
                                hover,
                                activehover,
                                down,
                                notify]

        self.Calcumalate()
        self.Refresh()
コード例 #43
0
ファイル: formattedinput.py プロジェクト: sgricci/digsby
def default_msg_font():
    return try_this(lambda: makeFont('Arial 10'), default_font())
コード例 #44
0
    def UpdateSkin(self):
        """
            This updates the skin elements from the skin provided
            can be used to update skins if the window changes, change the skin,
            or revert to native mode if called with None or no arguments
        """
        key = self.skinkey

        native = self.native = not key

        if native:
            self.padding = Point(2, 2)
            self.margins = Margins([0, 0, 0, 0])
            self.framesize = Margins([0, 0, 0, 0])

            bgc = wx.SystemSettings_GetColour(wx.SYS_COLOUR_LISTBOX)

            self.framebg = SkinColor(wx.BLACK)
            self.normalbg = SkinColor(bgc, border=wx.Pen(wx.BLACK, 1))
            self.activebg = SkinColor(bgc, border=wx.Pen(wx.BLACK, 1))
            self.hoverbg = SkinColor(bgc, border=wx.Pen(wx.BLACK, 1))

            fc = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)

            self.normalfc = fc
            self.activefc = fc
            self.hoverfc = fc

            self.Font = default_font()

            self.menuskin = None
            self.ddbuttonskin = None
            self.dropdownicon = None

        else:

            s = lambda k, default: skin.get('%s.%s' % (key, k), default)

            self.padding = s('padding', Point(2, 2))
            self.margins = s('margins', Margins([0, 0, 0, 0]))
            self.framesize = s('framesize', Margins([0, 0, 0, 0]))

            self.framebg = s('frame', lambda: SkinColor(wx.BLACK))
            self.normalbg = s('backgrounds.normal',
                              lambda: SkinColor(wx.WHITE))
            self.activebg = s('backgrounds.active',
                              lambda: SkinColor(wx.WHITE))
            self.hoverbg = s('backgrounds.hover', lambda: SkinColor(wx.WHITE))

            self.normalfc = s('fontcolors.normal', wx.BLACK)
            self.activefc = s('fontcolors.active', wx.BLACK)
            self.hoverfc = s('fontcolors.hover', wx.BLACK)
            self.hintfc = s('fontcolors.hint',
                            lambda: wx.Colour(128, 128, 128))

            self.Font = s('font', lambda: default_font)

            self.menuskin = s('menuskin', '')
            self.ddbuttonskin = s('dropdownbuttonskin', '')
            self.dropdownicon = s('dropdownbuttonicon', '')

        if getattr(self, 'dbutton', None):
            self.dbutton.SetSkinKey(self.ddbuttonskin)
            self.dbutton.SetIcon(self.dropdownicon)
        if getattr(self, 'menu', None):
            self.menu.SetSkinKey(self.menuskin)

        if self.Sizer:
            self.Sizer.SetMargins(self.framesize)
コード例 #45
0
 def default_attrs(self):
     return wx.TextAttr(wx.BLACK, wx.WHITE, default_font())
コード例 #46
0
ファイル: UberButton.py プロジェクト: sgricci/digsby
    def UpdateSkin(self):
        'Simply gets a skin and sets it all up.'

        key = self.skinkey
        native = not key

        if native and self.uxthemeable:
            self.rendernative = True
            self.destroy_native()
            self.OpenNativeTheme()

            skinget = skin.get

            self.menuicon = skinget('appdefaults.dropdownicon')
            self.padding = (5, 5)
            self.margins = Margins([0, 0, 0, 0])
            self.Font = default_font()

            self.fontcolors = [wx.BLACK] * 7

            self.backgrounds = NATIVE_BACKGROUNDS
            self.Cut()

        elif native:
            if not self.native:
                self.native = wx.Button(self, style=wx.BU_EXACTFIT)
                self.native.SetLabel(self.label)
                self.Sizer.Add(self.native, 1, wx.EXPAND)
                self.Layout()
                self.Cut()

        else:
            self.rendernative = False
            self.destroy_native()
            skinget = skin.get
            skinroot = skin.get(key)
            #s = lambda k, default = sentinel: skinget('%s.%s' % (key, k), default)

            s = skinroot.get
            self.menuicon = s('menuicon', skinget('appdefaults.dropdownicon'))
            self.padding = s('padding', (5, 5))
            self.margins = s('margins', Margins([0, 0, 0, 0]))
            self.Font = s('font', default_font())

            fc = skinroot.get('fontcolors', {})
            s = fc.get
            self.fontcolors = [
                s('disabled', Color(125, 125, 125)),
                s('normal', wx.BLACK),
                s('active', wx.BLACK),
                s('hover', wx.BLACK),
                s('activehover', wx.BLACK),
                s('down', wx.BLACK),
                s('notify', wx.WHITE)
            ]

            bgs = skinroot.get('backgrounds', {})

            def s(key, default):
                try:
                    return bgs[key]
                except:
                    return default()

            disabled = s(
                'disabled', lambda: SkinGradient(
                    'vertical', [Color(125, 125, 125),
                                 Color(237, 237, 237)]))
            normal = s(
                'normal', lambda: SkinGradient(
                    'vertical', [Color(200, 255, 200),
                                 Color(85, 255, 85)]))
            active = s(
                'active', lambda: SkinGradient(
                    'vertical', [Color(200, 255, 238),
                                 Color(85, 255, 238)]))
            hover = s('hover', lambda: normal)
            activehover = s('activehover', lambda: active)
            down = s(
                'down', lambda: SkinGradient('vertical', [
                    Color(0, 125, 0), Color(00, 204, 00)
                ]))
            notify = s(
                'notify', lambda: SkinGradient(
                    'vertical', [Color(255, 255, 200),
                                 Color(255, 255, 85)]))

            self.backgrounds = [
                disabled, normal, active, hover, activehover, down, notify
            ]

        self.Calcumalate()
        self.Refresh()
コード例 #47
0
ファイル: skinparse.py プロジェクト: sgricci/digsby
def makeFont(fontdesc, defaultFace=None, defaultSize=None):
    '''
    Returns a wxFont for the following skin syntax:

    Arial 12 bold Underline

    or

    Comic Sans MS 14 italic strikethrough
    '''
    from gui.skin import font_multiply_factor
    system_font = default_font()

    if not fontdesc:
        return system_font
    elif isinstance(fontdesc, int):
        system_font.SetPointSize(int(fontdesc))
        return system_font

    # arguments to wx.Font constructor
    opts = dict(faceName=defaultFace
                if defaultFace is not None else system_font.FaceName,
                pointSize=defaultSize
                if defaultSize is not None else system_font.PointSize,
                style=wx.FONTSTYLE_NORMAL,
                weight=wx.FONTWEIGHT_NORMAL,
                underline=False,
                family=wx.FONTFAMILY_DEFAULT)

    fontdesc = fontdesc.strip()
    elems = fontdesc.split()

    # find the last number -- that will be the size. everything before becomes
    # the face name, and everything after is treated as flags.
    lastsize = -1
    for i, elem in enumerate(elems[::-1]):
        if isint(elem):
            lastsize = len(elems) - i - 1  # since the indices are reversed
            break

    if lastsize == -1:
        flagi = -1
        for i, elem in enumerate(elems):
            if elem in fontweights or elem in fontstyles or elem in (
                    'underline', 'underlined'):
                flagi = i
                break

        size = defaultSize if defaultSize is not None else system_font.PointSize

        if flagi != -1:
            splitpoint = fontdesc.rfind(elems[flagi])
            facename = fontdesc[:splitpoint].strip()
            flags = fontdesc[splitpoint:].strip()
        else:
            facename = fontdesc.strip()
            flags = ''
    else:
        splitpoint = fontdesc.rfind(elems[lastsize])
        facename = fontdesc[:splitpoint].strip()
        size = int(elems[lastsize])
        flags = fontdesc[splitpoint + len(elems[lastsize]):]

    if facename:
        opts['faceName'] = facename

    opts['pointSize'] = int(size)

    # parse remaining flags
    for elem in flags.split():
        elem = elem.lower()

        if elem in fontweights:
            opts['weight'] = getattr(wx, 'FONTWEIGHT_' + elem.upper())
        elif elem in fontstyles:
            opts['style'] = getattr(wx, 'FONTSTYLE_' + elem.upper())
        elif elem in ('underline', 'underlined'):
            opts['underline'] = True

    o = opts
    return wx.Font(o['pointSize'], o['family'], o['style'], o['weight'],
                   o['underline'], o['faceName'])
コード例 #48
0
ファイル: UberCombo.py プロジェクト: AlexUlrich/digsby
    def UpdateSkin(self):
        """
            This updates the skin elements from the skin provided
            can be used to update skins if the window changes, change the skin,
            or revert to native mode if called with None or no arguments
        """
        key = self.skinkey

        native = self.native = not key

        if native:
            self.padding  = Point(2,2)
            self.margins  = Margins([0,0,0,0])
            self.framesize  = Margins([0,0,0,0])


            bgc = wx.SystemSettings_GetColour(wx.SYS_COLOUR_LISTBOX)

            self.framebg  = SkinColor(wx.BLACK)
            self.normalbg = SkinColor(bgc, border=wx.Pen(wx.BLACK, 1))
            self.activebg = SkinColor(bgc, border=wx.Pen(wx.BLACK, 1))
            self.hoverbg  = SkinColor(bgc, border=wx.Pen(wx.BLACK, 1))

            fc = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)

            self.normalfc = fc
            self.activefc = fc
            self.hoverfc  = fc

            self.Font     = default_font()

            self.menuskin     = None
            self.ddbuttonskin = None
            self.dropdownicon = None

        else:

            s = lambda k, default: skin.get('%s.%s' % (key, k), default)

            self.padding  = s('padding', Point(2,2))
            self.margins  = s('margins', Margins([0,0,0,0]))
            self.framesize  = s('framesize', Margins([0,0,0,0]))

            self.framebg  = s('frame',              lambda: SkinColor(wx.BLACK))
            self.normalbg = s('backgrounds.normal', lambda: SkinColor(wx.WHITE))
            self.activebg = s('backgrounds.active', lambda: SkinColor(wx.WHITE))
            self.hoverbg  = s('backgrounds.hover',  lambda: SkinColor(wx.WHITE))

            self.normalfc = s('fontcolors.normal', wx.BLACK)
            self.activefc = s('fontcolors.active', wx.BLACK)
            self.hoverfc  = s('fontcolors.hover',  wx.BLACK)
            self.hintfc   = s('fontcolors.hint',   lambda: wx.Colour(128,128,128))

            self.Font     = s('font', lambda: default_font)

            self.menuskin     = s('menuskin', '')
            self.ddbuttonskin = s('dropdownbuttonskin','')
            self.dropdownicon = s('dropdownbuttonicon','')


        if getattr(self, 'dbutton', None):
            self.dbutton.SetSkinKey(self.ddbuttonskin)
            self.dbutton.SetIcon(self.dropdownicon)
        if getattr(self, 'menu', None):
            self.menu.SetSkinKey(self.menuskin)

        if self.Sizer:
            self.Sizer.SetMargins(self.framesize)