Beispiel #1
0
    def __init__(self, parent, wxId, id, style):
        # Create a wxButton of the appropriate type.
        if style != Button.STYLE_MINI:
            widget = wx.Button(parent, wxId,
                               uniConv(language.translate(id)))
        else:
            widget = wx.ToggleButton(parent, wxId,
                                     uniConv(language.translate(id)))

        # Default buttons are usually a bit different visually.
        if style == Button.STYLE_DEFAULT:
            widget.SetDefault()

        base.Widget.__init__(self, widget)
        self.widgetId = id

        if style == Button.STYLE_MINI:
            # The mini buttons use the small style.
            self.setSmallStyle()
            # The size of the mini buttons is configurable.
            bestSize = widget.GetBestSize()
            width = 30
            height = bestSize[1]
            try:
                width = st.getSystemInteger('button-mini-width')
                if st.getSystemInteger('button-mini-height'):
                    height = st.getSystemInteger('button-mini-height')
            except:
                pass
            widget.SetMinSize((width, height))

        if style != Button.STYLE_MINI:
            # We will handle the click event ourselves.
            wx.EVT_BUTTON(parent, wxId, self.onClick)
            #self.updateDefaultSize()
        else:
            # Pop back up when toggled down.
            wx.EVT_TOGGLEBUTTON(parent, wxId, self.onToggle)
Beispiel #2
0
    def __init__(self, parent, wxId, id, style):
        # Create a wxButton of the appropriate type.
        if style != Button.STYLE_MINI:
            widget = wx.Button(parent, wxId, uniConv(language.translate(id)))
        else:
            widget = wx.ToggleButton(parent, wxId,
                                     uniConv(language.translate(id)))

        # Default buttons are usually a bit different visually.
        if style == Button.STYLE_DEFAULT:
            widget.SetDefault()

        base.Widget.__init__(self, widget)
        self.widgetId = id

        if style == Button.STYLE_MINI:
            # The mini buttons use the small style.
            self.setSmallStyle()
            # The size of the mini buttons is configurable.
            bestSize = widget.GetBestSize()
            width = 30
            height = bestSize[1]
            try:
                width = st.getSystemInteger('button-mini-width')
                if st.getSystemInteger('button-mini-height'):
                    height = st.getSystemInteger('button-mini-height')
            except:
                pass
            widget.SetMinSize((width, height))

        if style != Button.STYLE_MINI:
            # We will handle the click event ourselves.
            wx.EVT_BUTTON(parent, wxId, self.onClick)
            #self.updateDefaultSize()
        else:
            # Pop back up when toggled down.
            wx.EVT_TOGGLEBUTTON(parent, wxId, self.onToggle)
Beispiel #3
0
    def setStyle(self, textStyle):
        """Set a new style for the text label.
        @param style One of the constants:
        - Widget.NORMAL: default style
        - Widget.BOLD: bold typeface
        - Widget.ITALIC: italic typeface
        - Widget.HEADING: large bold typeface
        - Widget.TITLE: largest bold typeface
        """
        weight = wx.NORMAL
        style = wx.NORMAL
        styleName = 'style-' + \
                    ['normal', 'bold', 'italic', 'heading', 'title', 
                     'small'][textStyle] + '-'

        try:
            size = st.getSystemInteger(styleName + 'size')
        except:
            size = 11

        try:
            font = st.getSystemString(styleName + 'font')
        except:
            font = ''

        try:
            w = st.getSystemString(styleName + 'weight')
            if w == 'bold':
                weight = wx.BOLD
        except:
            pass

        try:
            s = st.getSystemString(styleName + 'slant')
            if s == 'italic':
                style = wx.ITALIC
        except:
            pass

        newFont = wx.Font(size, wx.DEFAULT, style, weight, faceName=font)
        w = self.getWxWidget()
        w.SetFont(newFont)

        #w.SetSize(w.GetBestSize())
        #bestSize = w.GetBestSize()
        #w.SetMinSize((0,bestSize[1]))

        self.updateDefaultSize()
    def setStyle(self, textStyle):
        """Set a new style for the text label.
        @param style One of the constants:
        - Widget.NORMAL: default style
        - Widget.BOLD: bold typeface
        - Widget.ITALIC: italic typeface
        - Widget.HEADING: large bold typeface
        - Widget.TITLE: largest bold typeface
        """
        weight = wx.NORMAL
        style = wx.NORMAL
        styleName = 'style-' + \
                    ['normal', 'bold', 'italic', 'heading', 'title',
                     'small'][textStyle] + '-'

        try:
            size = st.getSystemInteger(styleName + 'size')
        except:
            size = 11

        try:
            font = st.getSystemString(styleName + 'font')
        except:
            font = ''

        try:
            w = st.getSystemString(styleName + 'weight')
            if w == 'bold':
                weight = wx.BOLD
        except:
            pass

        try:
            s = st.getSystemString(styleName + 'slant')
            if s == 'italic':
                style = wx.ITALIC
        except:
            pass

        newFont = wx.Font(size, wx.DEFAULT, style, weight, faceName=font)
        w = self.getWxWidget()
        w.SetFont(newFont)

        #w.SetSize(w.GetBestSize())
        #bestSize = w.GetBestSize()
        #w.SetMinSize((0,bestSize[1]))

        self.updateDefaultSize()
Beispiel #5
0
def entryContent(text, span=1):
    htmlSize = st.getSystemInteger('style-html-size') - 1
    return '<td valign="top" colspan="%i"><font size="%i">%s</font>' \
           % (span, htmlSize, text)
Beispiel #6
0
def entryHeader(text, span=1):
    htmlSize = st.getSystemInteger('style-html-size') - 1
    width = ''
    return '<td %s bgcolor="%s" valign="top" colspan="%i"><font size="%i">%s</font>' % (
        width, bgColor, span, htmlSize, text)
Beispiel #7
0
def entryContent(text, span=1):
    htmlSize = st.getSystemInteger('style-html-size') - 1
    return '<td valign="top" colspan="%i"><font size="%i">%s</font>' \
           % (span, htmlSize, text)
Beispiel #8
0
def entryHeader(text, span=1):
    htmlSize = st.getSystemInteger('style-html-size') - 1
    width = ''
    return '<td %s bgcolor="%s" valign="top" colspan="%i"><font size="%i">%s</font>' % (width, bgColor, span, htmlSize, text)
Beispiel #9
0
    def __init__(self, title):
        """Initialize the main window.

        @param title  Title for the main window.
        """
        from sb.widget.area import Area

        # Commands for the popup menu.
        self.menuCommandMap = {}

        # FIXME: Layout is botched. Way too wide.
        if host.isMac():
            initialSize = (769, 559)
        elif host.isUnix():
            initialSize = (900, 610)
        else:
            initialSize = (733, 527)

        # The configuration may define a window size.
        if st.isDefined('main-width'):
            initialSize = (st.getSystemInteger('main-width'), initialSize[1])
        if st.isDefined('main-height'):
            initialSize = (initialSize[0], st.getSystemInteger('main-height'))

        # The configuration can also specify the window position.
        if st.isDefined('main-x') and st.isDefined('main-y'):
            initialPos = (st.getSystemInteger('main-x'), st.getSystemInteger('main-y'))
        else:
            initialPos = None

        wx.Frame.__init__(self, None, -1, title, size=initialSize)
        #self.SetExtraStyle(wx.FRAME_EX_METAL)
        #self.Create(None, -1, title, size=initialSize)

        if initialPos is not None:
            self.MoveXY(*initialPos)
        else:
            self.Center()

        # Set the icon for the frame.
        icon = wx.Icon('graphics/snowberry.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        #self.Iconize(True)
        #self.Hide()

        SPLITTER_ID = 9501
        PROF_SPLITTER_ID = 9502
        self.splitter = None
        self.profSplitter = None

        # The parentWin is where the profSplitter and the help panel
        # are inside.
        parentWin = self

        if USE_HELP_AREA:
            # The help area is in a splitter.
            self.splitter = wx.SplitterWindow(self, SPLITTER_ID,
                                              style=wx.SP_3DSASH)
            self.splitter.SetMinimumPaneSize(10)
            parentWin = self.splitter

        if not USE_MINIMAL_PROFILE:
            self.profSplitter = wx.SplitterWindow(parentWin, PROF_SPLITTER_ID,
                                                  style=wx.SP_3DSASH)# |
                                                  #wx.SP_NO_XP_THEME)
            self.profSplitter.SetMinimumPaneSize(100)

            # Profile panel.
            profilePanel = wx.Panel(self.profSplitter, -1, style=wx.NO_BORDER
                                    | wx.CLIP_CHILDREN)
            area = Area(PROFILES, profilePanel, ALIGN_VERTICAL, 10)
            _newArea(area)

            # Create panels inside the profile splitter.
            self.mainPanel = MainPanel(self.profSplitter)
        else:
            profilePanel = None

            self.mainPanel = MainPanel(parentWin)

            getArea(TABS).setWeight(0)
            profArea = getArea(TABS).createArea(alignment=ALIGN_HORIZONTAL, border=12)
            profArea.setId(PROFILES)
            _newArea(profArea)
            getArea(TABS).setWeight(1)
            getArea(TABS).setBorderDirs(BORDER_NOT_TOP)

        # Create a TabArea into the TABS area.
        self.mainPanel.tabs = getArea(TABS).createTabArea(
            'tab', style=sb.widget.tab.TabArea.STYLE_BASIC)

        if st.isDefined('main-split-position'):
            self.splitPos = INITIAL_SASH_POS
        else:
            self.splitPos = None
        self.profSplitPos = INITIAL_PROFILE_SASH_POS

        # Create the help area.
        if self.splitter:
            self.helpPanel = wx.Panel(self.splitter, -1, style = wx.NO_BORDER
                                      | wx.CLIP_CHILDREN)
            self.helpPanel.SetBackgroundColour(wx.WHITE)
            _newArea( Area(HELP, self.helpPanel, ALIGN_VERTICAL,
                           border=4) )
            # Init the splitter.
            leftSide = self.profSplitter
            if not leftSide:
                leftSide = self.mainPanel
            self.splitter.SplitVertically(leftSide, self.helpPanel,
                                          -INITIAL_SASH_POS)
        else:
            self.helpPanel = None

        if self.profSplitter:
            self.profSplitter.SplitVertically(profilePanel, self.mainPanel,
                                              self.profSplitPos)

        # Listen for changes in the sash position.
        wx.EVT_SPLITTER_SASH_POS_CHANGED(self, SPLITTER_ID,
                                         self.onSplitChange)
        wx.EVT_SPLITTER_SASH_POS_CHANGED(self, PROF_SPLITTER_ID,
                                         self.onProfSplitChange)

        # The main panel should be globally accessible.
        global mainPanel
        mainPanel = self.mainPanel

        # Intercept the window close event.
        wx.EVT_CLOSE(self, self.onWindowClose)

        # Maintain the splitter position.
        wx.EVT_SIZE(self, self.onWindowSize)

        # Listen to some commands.
        events.addCommandListener(self.handleCommand, ['quit'])

        # Create a menu bar.
        self.menuBar = wx.MenuBar()
Beispiel #10
0
        self.SetAutoLayout(True)

    def getTabs(self):
        """Returns the TabArea widget that contains the main tabbing
        area."""
        return self.tabs

    def updateLayout(self):
        self.verticalSizer.Layout()


INITIAL_SASH_POS = 180
INITIAL_PROFILE_SASH_POS = 190

if st.isDefined('main-split-position'):
    INITIAL_SASH_POS = st.getSystemInteger('main-split-position')

if st.isDefined('main-profile-split-position'):
    INITIAL_PROFILE_SASH_POS = st.getSystemInteger(
        'main-profile-split-position')


class MainFrame (wx.Frame):
    """The main frame is the main window of Snowberry."""

    def __init__(self, title):
        """Initialize the main window.

        @param title  Title for the main window.
        """
        from sb.widget.area import Area
Beispiel #11
0
    def __init__(self, title):
        """Initialize the main window.

        @param title  Title for the main window.
        """
        from sb.widget.area import Area

        # Commands for the popup menu.
        self.menuCommandMap = {}

        # FIXME: Layout is botched. Way too wide.
        if host.isMac():
            initialSize = (769, 559)
        elif host.isUnix():
            initialSize = (900, 610)
        else:
            initialSize = (733, 527)

        # The configuration may define a window size.
        if st.isDefined('main-width'):
            initialSize = (st.getSystemInteger('main-width'), initialSize[1])
        if st.isDefined('main-height'):
            initialSize = (initialSize[0], st.getSystemInteger('main-height'))

        # The configuration can also specify the window position.
        if st.isDefined('main-x') and st.isDefined('main-y'):
            initialPos = (st.getSystemInteger('main-x'),
                          st.getSystemInteger('main-y'))
        else:
            initialPos = None

        wx.Frame.__init__(self, None, -1, title, size=initialSize)
        #self.SetExtraStyle(wx.FRAME_EX_METAL)
        #self.Create(None, -1, title, size=initialSize)

        if initialPos is not None:
            self.MoveXY(*initialPos)
        else:
            self.Center()

        # Set the icon for the frame.
        icon = wx.Icon('graphics/snowberry.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        #self.Iconize(True)
        #self.Hide()

        SPLITTER_ID = 9501
        PROF_SPLITTER_ID = 9502
        self.splitter = None
        self.profSplitter = None

        # The parentWin is where the profSplitter and the help panel
        # are inside.
        parentWin = self

        if USE_HELP_AREA:
            # The help area is in a splitter.
            self.splitter = wx.SplitterWindow(self,
                                              SPLITTER_ID,
                                              style=wx.SP_3DSASH)
            self.splitter.SetMinimumPaneSize(10)
            parentWin = self.splitter

        if not USE_MINIMAL_PROFILE:
            self.profSplitter = wx.SplitterWindow(parentWin,
                                                  PROF_SPLITTER_ID,
                                                  style=wx.SP_3DSASH)  # |
            #wx.SP_NO_XP_THEME)
            self.profSplitter.SetMinimumPaneSize(100)

            # Profile panel.
            profilePanel = wx.Panel(self.profSplitter,
                                    -1,
                                    style=wx.NO_BORDER
                                    | wx.CLIP_CHILDREN)
            area = Area(PROFILES, profilePanel, ALIGN_VERTICAL, 10)
            _newArea(area)

            # Create panels inside the profile splitter.
            self.mainPanel = MainPanel(self.profSplitter)
        else:
            profilePanel = None

            self.mainPanel = MainPanel(parentWin)

            getArea(TABS).setWeight(0)
            profArea = getArea(TABS).createArea(alignment=ALIGN_HORIZONTAL,
                                                border=12)
            profArea.setId(PROFILES)
            _newArea(profArea)
            getArea(TABS).setWeight(1)
            getArea(TABS).setBorderDirs(BORDER_NOT_TOP)

        # Create a TabArea into the TABS area.
        self.mainPanel.tabs = getArea(TABS).createTabArea(
            'tab', style=sb.widget.tab.TabArea.STYLE_BASIC)

        if st.isDefined('main-split-position'):
            self.splitPos = INITIAL_SASH_POS
        else:
            self.splitPos = None
        self.profSplitPos = INITIAL_PROFILE_SASH_POS

        # Create the help area.
        if self.splitter:
            self.helpPanel = wx.Panel(self.splitter,
                                      -1,
                                      style=wx.NO_BORDER
                                      | wx.CLIP_CHILDREN)
            self.helpPanel.SetBackgroundColour(wx.WHITE)
            _newArea(Area(HELP, self.helpPanel, ALIGN_VERTICAL, border=4))
            # Init the splitter.
            leftSide = self.profSplitter
            if not leftSide:
                leftSide = self.mainPanel
            self.splitter.SplitVertically(leftSide, self.helpPanel,
                                          -INITIAL_SASH_POS)
        else:
            self.helpPanel = None

        if self.profSplitter:
            self.profSplitter.SplitVertically(profilePanel, self.mainPanel,
                                              self.profSplitPos)

        # Listen for changes in the sash position.
        wx.EVT_SPLITTER_SASH_POS_CHANGED(self, SPLITTER_ID, self.onSplitChange)
        wx.EVT_SPLITTER_SASH_POS_CHANGED(self, PROF_SPLITTER_ID,
                                         self.onProfSplitChange)

        # The main panel should be globally accessible.
        global mainPanel
        mainPanel = self.mainPanel

        # Intercept the window close event.
        wx.EVT_CLOSE(self, self.onWindowClose)

        # Maintain the splitter position.
        wx.EVT_SIZE(self, self.onWindowSize)

        # Listen to some commands.
        events.addCommandListener(self.handleCommand, ['quit'])

        # Create a menu bar.
        self.menuBar = wx.MenuBar()
Beispiel #12
0
        self.SetAutoLayout(True)

    def getTabs(self):
        """Returns the TabArea widget that contains the main tabbing
        area."""
        return self.tabs

    def updateLayout(self):
        self.verticalSizer.Layout()


INITIAL_SASH_POS = 180
INITIAL_PROFILE_SASH_POS = 190

if st.isDefined('main-split-position'):
    INITIAL_SASH_POS = st.getSystemInteger('main-split-position')

if st.isDefined('main-profile-split-position'):
    INITIAL_PROFILE_SASH_POS = st.getSystemInteger(
        'main-profile-split-position')


class MainFrame(wx.Frame):
    """The main frame is the main window of Snowberry."""
    def __init__(self, title):
        """Initialize the main window.

        @param title  Title for the main window.
        """
        from sb.widget.area import Area