Skip to content

Commit

Permalink
Fixed tab background gradients on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 9, 2007
1 parent d2339e3 commit 5d92c6b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 40 deletions.
5 changes: 2 additions & 3 deletions snowberry/sb/widget/area.py
Expand Up @@ -739,9 +739,8 @@ def createPage(self, identifier, align=ui.ALIGN_VERTICAL, border=3):
"""
# Create a new panel for the page.
panel = wx.Panel(self.panel, -1, style=wx.CLIP_CHILDREN)
#if host.isWindows():
# panel.SetBackgroundColour(ui.tabBgColour)
# panel.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)
if host.isWindows():
panel.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)

panel.Hide()

Expand Down
24 changes: 11 additions & 13 deletions snowberry/sb/widget/tab.py
Expand Up @@ -60,7 +60,7 @@ def __init__(self, parent, wxId, id):

def setMultiArea(self, multiArea):
"""Set the MultiArea that will react to the changes in the list.
@param multiArea The ui.MultiArea object to pair up with the
list.
"""
Expand All @@ -85,8 +85,8 @@ def __getPresentation(self, tabId):
else:
imageName = language.translate(tabId + '-icon')

return ('<table width="100%" border=0 cellspacing=3 cellpadding=1>' +
'<tr><td width=35><img width=32 height=32 ' +
return ('<table width="100%" border=0 cellspacing=3 cellpadding=1>' +
'<tr><td width=35><img width=32 height=32 ' +
'src="%s"><td align="left" valign="center">%s</td>' %
(paths.findBitmap(imageName), language.translate(tabId)) +
'</table>')
Expand Down Expand Up @@ -146,7 +146,7 @@ def removeTab(self, id):
"""
if id in self.hiddenTabs:
self.hiddenTabs.remove(id)

self.multi.removePage(id)
self.removeItem(id)

Expand Down Expand Up @@ -182,10 +182,10 @@ def showTab(self, identifier, doShow=True):
#if self.getSelectedTab() == identifier:
# index = min(self.getItemCount() - 1, self.getSelectedIndex() + 1)
# self.selectTab(self.items[index][0])

self.hiddenTabs.append(identifier)
self.removeItem(identifier)

def onItemSelected(self, ev):
FormattedList.onItemSelected(self, ev)

Expand All @@ -204,7 +204,7 @@ def updateIcon(self, identifier):
# #tabs = self.getTabs()
# #self.addItem(




class TabArea (base.Widget):
Expand All @@ -226,7 +226,7 @@ def __init__(self, parent, wxId, id, style):
# The formatted tab area style uses another widget entirely.
if style == TabArea.STYLE_FORMATTED:
raise Exception('not supported here')

# Create the appropriate widget.
if style == TabArea.STYLE_ICON:
w = wx.Listbook(parent, wxId, style=wx.LB_LEFT)
Expand Down Expand Up @@ -269,7 +269,7 @@ def __init__(self, parent, wxId, id, style):
def clear(self):
"""When a TabArea is cleared, it must destroy all of its tabs,
which contain subareas."""

self.removeAllTabs()
base.Widget.clear(self)

Expand Down Expand Up @@ -326,7 +326,6 @@ def addTab(self, id):
tab = wx.Panel(book, -1, style=wx.CLIP_CHILDREN)

if host.isWindows():
tab.SetBackgroundColour(ui.tabBgColour)
tab.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)

# Put the new tab in the page map so that when an event
Expand Down Expand Up @@ -424,7 +423,7 @@ def showTab(self, identifier, doShow=True):
book.SetSelection(index - 1)
elif index < book.GetPageCount() - 1:
book.SetSelection(index + 1)

# This won't destroy the panel or its contents.
book.RemovePage(index)

Expand Down Expand Up @@ -465,7 +464,7 @@ def updateIcons(self):

def retranslate(self):
"""Retranslate the tab labels."""

for identifier, panel in self.panelMap:
pageIndex = self.__getPanelIndex(panel)
if pageIndex != None:
Expand All @@ -487,4 +486,3 @@ def onTabChange(self, ev):
notification = events.SelectNotify(self.widgetId,
self.__lookupPanel(tabPanel))
events.send(notification)

48 changes: 24 additions & 24 deletions snowberry/ui.py
Expand Up @@ -87,7 +87,7 @@
USE_MINIMAL_PROFILE = st.getSystemBoolean('profile-minimal-mode')

# A Windows kludge: background colour for tabs and the controls in them.
tabBgColour = wx.Colour(250, 250, 250)
#tabBgColour = wx.Colour(250, 250, 250)
#st.getSystemInteger('tab-background-red'),
# st.getSystemInteger('tab-background-green'),
# st.getSystemInteger('tab-background-blue'))
Expand Down Expand Up @@ -218,7 +218,7 @@ def __init__(self, title):
@param title Title for the main window.
"""
from sb.widget.area import Area

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

Expand Down Expand Up @@ -290,7 +290,7 @@ def __init__(self, title):
self.mainPanel = MainPanel(self.profSplitter)
else:
profilePanel = None

self.mainPanel = MainPanel(parentWin)

getArea(TABS).setWeight(0)
Expand Down Expand Up @@ -463,11 +463,11 @@ def updateMenus(self):
# No menu for this.
self.menus[level] = None
continue

self.menus[level] = wx.Menu()
self.menuBar.Append(self.menus[level],
self.menuBar.Append(self.menus[level],
language.translate("menu-" + str(level)))

# Sort the items based on groups, and append separators where necessary.
menuItems[level].sort(lambda x, y: cmp(x[3], y[3]))
separated = []
Expand All @@ -487,20 +487,20 @@ def updateMenus(self):

if itemSeparate and self.menus[level].GetMenuItemCount() > 0:
self.menus[level].AppendSeparator()

menuItemId = 'menu-' + itemId

accel = ''
if language.isDefined(menuItemId + '-accel'):
accel = "\t" + language.translate(menuItemId + '-accel')

# Generate a new ID for the item.
wxId = wx.NewId()
self.menuCommandMap[wxId] = itemCommand
self.menus[level].Append(wxId,
uniConv(language.translate(menuItemId) + accel))
wx.EVT_MENU(self, wxId, self.onPopupCommand)

if host.isMac():
# Special menu items on Mac.
if itemId == 'about':
Expand All @@ -513,18 +513,18 @@ def updateMenus(self):
if host.isMac():
# Special Help menu on Mac.
wx.App_SetMacHelpMenuTitleName(language.translate('menu-' + str(MENU_HELP)))
self.SetMenuBar(self.menuBar)

self.SetMenuBar(self.menuBar)

def onPopupCommand(self, ev):
"""Called when a selection is made in the popup menu."""
events.send(events.Command(self.menuCommandMap[ev.GetId()]))

def getMenuItem(self, identifier):
"""Finds a menu item.
@param identifier Identifier of the menu item.
@return wxMenuItem, or None."""

for item in self.menuCommandMap.keys():
if self.menuCommandMap[item] == identifier:
return self.menuBar.FindItemById(item)
Expand Down Expand Up @@ -564,9 +564,9 @@ def addMenuCommand(level, identifier, label=None, pos=None, separate=False, grou
@param level Priority level (0, 1, 2).
@param identifier Identifier of the command.
@param label Label for the command. If not specified, the same as the identifier.
@param pos Position in the menu. None will cause the new item to be appended
@param pos Position in the menu. None will cause the new item to be appended
to the end of the menu. The first item in the menu has position 0.
@param separate If True and there are existing items already, add a separator.
@param separate If True and there are existing items already, add a separator.
@param group If specified, items are sorted by this before adding to the menu.
The items without a group are inserted first. Groups are separated
with separators.
Expand All @@ -584,22 +584,22 @@ def addMenuCommand(level, identifier, label=None, pos=None, separate=False, grou
item = (identifier, identifier, separate, group)
else:
item = (identifier, label, separate, group)

if pos is None:
menuItems[level].append(item)
else:
menuItems[level].insert(pos, item)


def isMenuEmpty(level):
"""Determines whether a certain menu is currently empty.
@return True or False."""
return len(menuItems[level]) == 0


def enableMenuCommand(identifier, enable=True):
"""Enables or disables a command in the menu.
@param identifier Identifier of the menu item.
@param enable True, if the item should be enabled. False, if disabled.
"""
Expand All @@ -609,8 +609,8 @@ def enableMenuCommand(identifier, enable=True):
item.Enable(True)
else:
item.Enable(False)


def disableMenuCommand(identifier):
enableMenuCommand(identifier, False)

Expand Down

0 comments on commit 5d92c6b

Please sign in to comment.