From 03c88f6092135d1ea8197a92f415e8fc41b2ee51 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 8 May 2007 02:34:23 +0000 Subject: [PATCH] more backports git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/wx/tools/XRCed/panel.py | 6 +- wxPython/wx/tools/XRCed/params.py | 4 +- wxPython/wx/tools/XRCed/tools.py | 18 +++--- wxPython/wx/tools/XRCed/tree.py | 7 +- wxPython/wx/tools/XRCed/undo.py | 8 +++ wxPython/wx/tools/XRCed/xrced.py | 103 ++++++++++++++++++------------ 6 files changed, 89 insertions(+), 57 deletions(-) diff --git a/wxPython/wx/tools/XRCed/panel.py b/wxPython/wx/tools/XRCed/panel.py index 361ab59b66..cf2a2df711 100644 --- a/wxPython/wx/tools/XRCed/panel.py +++ b/wxPython/wx/tools/XRCed/panel.py @@ -70,7 +70,7 @@ class Panel(wx.Notebook): if g.conf.panic: topSizer.Add(sizer, 1, wx.EXPAND) else: - topSizer.Add(sizer, 0, wx.ALL, 5) + topSizer.Add(sizer, 1, wx.ALL, 5) return sizer def SetData(self, xxx): @@ -281,7 +281,7 @@ class PropPage(ParamPage): def __init__(self, parent, label, xxx): ParamPage.__init__(self, parent, xxx) self.box = wx.StaticBox(self, -1, label) - self.box.SetFont(g.labelFont()) + #self.box.SetFont(g.labelFont()) topSizer = wx.StaticBoxSizer(self.box, wx.VERTICAL) sizer = wx.FlexGridSizer(len(xxx.allParams), 2, 1, 5) sizer.AddGrowableCol(1) @@ -370,7 +370,7 @@ class StylePage(ParamPage): def __init__(self, parent, label, xxx): ParamPage.__init__(self, parent, xxx) box = wx.StaticBox(self, -1, label) - box.SetFont(g.labelFont()) + #box.SetFont(g.labelFont()) topSizer = wx.StaticBoxSizer(box, wx.VERTICAL) sizer = wx.FlexGridSizer(len(xxx.styles), 2, 1, 5) sizer.AddGrowableCol(1) diff --git a/wxPython/wx/tools/XRCed/params.py b/wxPython/wx/tools/XRCed/params.py index c62d3e1f49..fd7601985c 100644 --- a/wxPython/wx/tools/XRCed/params.py +++ b/wxPython/wx/tools/XRCed/params.py @@ -263,7 +263,7 @@ class ParamFont(PPanel): PPanel.OnChange(self, evt) self.textModified = True def _defaultValue(self): - return [`g._sysFont.GetPointSize()`, 'default', 'normal', 'normal', '0', '', ''] + return [`g.sysFont().GetPointSize()`, 'default', 'normal', 'normal', '0', '', ''] def GetValue(self): if self.textModified: # text has newer value try: @@ -287,7 +287,7 @@ class ParamFont(PPanel): self.value = self._defaultValue() # Make initial font # Default values - size = g._sysFont.GetPointSize() + size = g.sysFont().GetPointSize() family = wx.DEFAULT style = weight = wx.NORMAL underlined = 0 diff --git a/wxPython/wx/tools/XRCed/tools.py b/wxPython/wx/tools/XRCed/tools.py index 42f5c7c1f8..abb8297b0c 100644 --- a/wxPython/wx/tools/XRCed/tools.py +++ b/wxPython/wx/tools/XRCed/tools.py @@ -56,7 +56,6 @@ class Tools(wx.Panel): (ID_NEW.STATIC_TEXT, images.getToolStaticTextBitmap()), (ID_NEW.STATIC_BITMAP, images.getToolStaticBitmapBitmap()), (ID_NEW.STATIC_LINE, images.getToolStaticLineBitmap()), - (ID_NEW.BUTTON, images.getToolButtonBitmap()), (ID_NEW.BITMAP_BUTTON, images.getToolBitmapButtonBitmap()), (ID_NEW.STATIC_BOX, images.getToolStaticBoxBitmap()), @@ -99,8 +98,9 @@ class Tools(wx.Panel): wx.wxEVT_COMMAND_BUTTON_CLICKED, g.frame.OnCreate) wx.EVT_KEY_DOWN(self, self.OnKeyDown) wx.EVT_KEY_UP(self, self.OnKeyUp) - self.Bind(wx.EVT_LEFT_DOWN, self.OnClickBox) - + # wxMSW does not generate click events for StaticBox + if wx.Platform == '__WXMSW__': + self.Bind(wx.EVT_LEFT_DOWN, self.OnClickBox) self.drag = None def AddButton(self, id, image, text): @@ -127,9 +127,9 @@ class Tools(wx.Panel): box.gnum = len(self.groups) box.Bind(wx.EVT_LEFT_DOWN, self.OnClickBox) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) - boxSizer.Add((0, 4)) + boxSizer.Add((0, 0)) self.boxes[id] = box - self.curSizer = wx.GridSizer(0, 3) + self.curSizer = wx.GridSizer(0, 3, 3, 3) boxSizer.Add(self.curSizer) self.sizer.Add(boxSizer, 0, wx.TOP | wx.LEFT | wx.RIGHT | wx.EXPAND, 4) self.groups.append((box,{})) @@ -137,7 +137,6 @@ class Tools(wx.Panel): # Enable/disable group def EnableGroup(self, gnum, enable = True): grp = self.groups[gnum] - #grp[0].Enable(enable) for b in grp[1].values(): b.Enable(enable) # Show/hide group @@ -161,11 +160,13 @@ class Tools(wx.Panel): if wx.Platform == '__WXMSW__': box = None for id,b in self.boxes.items(): - # Detect click on label + # How to detect a click on a label? if b.GetRect().Inside(evt.GetPosition()): box = b break - if not box: return + if not box: + evt.Skip() + return else: box = self.boxes[evt.GetId()] # Collapse/restore static box, change label @@ -363,3 +364,4 @@ class Tools(wx.Panel): self.EnableGroupItem(GROUP_MENUS, ID_NEW.MENU_BAR) # Save state self.state = state + self.Refresh() diff --git a/wxPython/wx/tools/XRCed/tree.py b/wxPython/wx/tools/XRCed/tree.py index 1e77eac3a4..5357edb907 100644 --- a/wxPython/wx/tools/XRCed/tree.py +++ b/wxPython/wx/tools/XRCed/tree.py @@ -792,7 +792,7 @@ class XML_Tree(wx.TreeCtrl): self.selection = None g.tools.UpdateUI() wx.TreeCtrl.UnselectAll(self) - wx.Yield() + #wx.Yield() def ChangeSelection(self, item): # Apply changes @@ -1109,8 +1109,9 @@ class XML_Tree(wx.TreeCtrl): n = 0 # index of sibling prev = self.GetPrevSibling(item) while prev.IsOk(): - # MenuBar is not a child - if not isinstance(self.GetPyData(prev), xxxMenuBar): + # MenuBar and sizers are not real children (who else?) + if not isinstance(self.GetPyData(prev), xxxMenuBar) and not \ + isinstance(self.GetPyData(prev), xxxSizer): n += 1 prev = self.GetPrevSibling(prev) return n diff --git a/wxPython/wx/tools/XRCed/undo.py b/wxPython/wx/tools/XRCed/undo.py index f883f88e93..4ad8909b2b 100644 --- a/wxPython/wx/tools/XRCed/undo.py +++ b/wxPython/wx/tools/XRCed/undo.py @@ -210,6 +210,10 @@ class UndoMove: selected = g.tree.InsertNode(self.oldParent, parent, elem, nextItem) g.tree.EnsureVisible(selected) + # Highlight is outdated + if g.testWin and g.testWin.highLight: + g.testWin.highLight.Remove() + g.tree.needUpdate = True g.tree.SelectItem(selected) def redo(self): item = g.tree.GetFirstChild(self.oldParent)[0] @@ -248,6 +252,10 @@ class UndoMove: for i in range(self.newIndex): nextItem = g.tree.GetNextSibling(nextItem) selected = g.tree.InsertNode(self.newParent, parent, elem, nextItem) g.tree.EnsureVisible(selected) + # Highlight is outdated + if g.testWin and g.testWin.highLight: + g.testWin.highLight.Remove() + g.tree.needUpdate = True g.tree.SelectItem(selected) class UndoEdit: diff --git a/wxPython/wx/tools/XRCed/xrced.py b/wxPython/wx/tools/XRCed/xrced.py index 706b547ff7..afc6dd32ff 100644 --- a/wxPython/wx/tools/XRCed/xrced.py +++ b/wxPython/wx/tools/XRCed/xrced.py @@ -92,14 +92,29 @@ class Locator(wx.EvtHandler): def ProcessEvent(self, evt): print evt +class TaskBarIcon(wx.TaskBarIcon): + def __init__(self, frame): + wx.TaskBarIcon.__init__(self) + self.frame = frame + # Set the image + self.SetIcon(images.getIconIcon(), "XRCed") + class Frame(wx.Frame): def __init__(self, pos, size): - wx.Frame.__init__(self, None, -1, '', pos, size) + pre = wx.PreFrame() +# pre.SetExtraStyle(wx.FRAME_EX_METAL) + pre.Create(None, -1, '', pos, size) + self.PostCreate(pre) + #wx.Frame.__init__(self, None, -1, '', pos, size) global frame frame = g.frame = self bar = self.CreateStatusBar(2) bar.SetStatusWidths([-1, 40]) self.SetIcon(images.getIconIcon()) + try: + self.tbicon = TaskBarIcon(self) + except: + self.tbicon = None # Idle flag self.inIdle = False @@ -156,7 +171,6 @@ class Frame(wx.Frame): self.ID_TOOL_PASTE = wx.NewId() menu.Append(self.ID_LOCATE, '&Locate\tCtrl-L', 'Locate control in test window and select it') menuBar.Append(menu, '&Edit') - menu = wx.Menu() self.ID_EMBED_PANEL = wx.NewId() menu.Append(self.ID_EMBED_PANEL, '&Embed Panel', @@ -204,31 +218,35 @@ class Frame(wx.Frame): # Create toolbar tb = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT) - tb.SetToolBitmapSize((24,24)) - new_bmp = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR) - open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR) - save_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR) - undo_bmp = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR) - redo_bmp = wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_TOOLBAR) - cut_bmp = wx.ArtProvider.GetBitmap(wx.ART_CUT, wx.ART_TOOLBAR) - copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR) - paste_bmp= wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR) - tb.AddSimpleTool(wx.ID_NEW, new_bmp, 'New', 'New file') - tb.AddSimpleTool(wx.ID_OPEN, open_bmp, 'Open', 'Open file') - tb.AddSimpleTool(wx.ID_SAVE, save_bmp, 'Save', 'Save file') - tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) - tb.AddSimpleTool(wx.ID_UNDO, undo_bmp, 'Undo', 'Undo') - tb.AddSimpleTool(wx.ID_REDO, redo_bmp, 'Redo', 'Redo') - tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) - tb.AddSimpleTool(wx.ID_CUT, cut_bmp, 'Cut', 'Cut') - tb.AddSimpleTool(wx.ID_COPY, copy_bmp, 'Copy', 'Copy') - tb.AddSimpleTool(self.ID_TOOL_PASTE, paste_bmp, 'Paste', 'Paste') - tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) + # Hide some icons on Mac to reduce the toolbar size, + # and comply more with the Apple LnF, besides + # wxMac icons are ugly + if wx.Platform != '__WXMAC__': + tb.SetToolBitmapSize((24,24)) + new_bmp = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR) + open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR) + save_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR) + undo_bmp = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR) + redo_bmp = wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_TOOLBAR) + cut_bmp = wx.ArtProvider.GetBitmap(wx.ART_CUT, wx.ART_TOOLBAR) + copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR) + paste_bmp= wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR) + tb.AddSimpleTool(wx.ID_NEW, new_bmp, 'New', 'New file') + tb.AddSimpleTool(wx.ID_OPEN, open_bmp, 'Open', 'Open file') + tb.AddSimpleTool(wx.ID_SAVE, save_bmp, 'Save', 'Save file') + tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) + tb.AddSimpleTool(wx.ID_UNDO, undo_bmp, 'Undo', 'Undo') + tb.AddSimpleTool(wx.ID_REDO, redo_bmp, 'Redo', 'Redo') + tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) + tb.AddSimpleTool(wx.ID_CUT, cut_bmp, 'Cut', 'Cut') + tb.AddSimpleTool(wx.ID_COPY, copy_bmp, 'Copy', 'Copy') + tb.AddSimpleTool(self.ID_TOOL_PASTE, paste_bmp, 'Paste', 'Paste') + tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) tb.AddSimpleTool(self.ID_TOOL_LOCATE, images.getLocateBitmap(), #images.getLocateArmedBitmap(), 'Locate', 'Locate control in test window and select it', True) - tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) +# tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL)) tb.AddSimpleTool(self.ID_TEST, images.getTestBitmap(), 'Test', 'Test window') tb.AddSimpleTool(self.ID_REFRESH, images.getRefreshBitmap(), 'Refresh', 'Refresh view') @@ -328,9 +346,7 @@ class Frame(wx.Frame): (conf.panelWidth, conf.panelHeight)) self.miniFrame = miniFrame sizer2 = wx.BoxSizer() - miniFrame.SetAutoLayout(True) miniFrame.SetSizer(sizer2) - wx.EVT_CLOSE(self.miniFrame, self.OnCloseMiniFrame) # Create panel for parameters global panel if conf.embedPanel: @@ -342,7 +358,10 @@ class Frame(wx.Frame): sizer2.Add(panel, 1, wx.EXPAND) miniFrame.Show(True) splitter.Initialize(tree) - sizer1.Add(splitter, 1, wx.EXPAND) + if wx.Platform == '__WXMAC__': + sizer1.Add(splitter, 1, wx.EXPAND|wx.RIGHT, 5) + else: + sizer1.Add(splitter, 1, wx.EXPAND) sizer.Add(sizer1, 1, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(sizer) @@ -762,10 +781,9 @@ class Frame(wx.Frame): # Check compatibility if not self.ItemsAreCompatible(tree.GetPyData(pparent).treeObject(), tree.GetPyData(selected).treeObject()): return - # Remove highlight, update testWin if g.testWin and g.testWin.highLight: g.testWin.highLight.Remove() - tree.needUpdate = True + tree.needUpdate = True # Undo info self.lastOp = 'MOVELEFT' @@ -806,7 +824,6 @@ class Frame(wx.Frame): selected = tree.InsertNode(pparent, tree.GetPyData(pparent).treeObject(), elem, nextItem) newIndex = tree.ItemIndex(selected) - tree.oldItem = None tree.SelectItem(selected) undoMan.RegisterUndo(UndoMove(oldParent, oldIndex, pparent, newIndex)) @@ -832,7 +849,7 @@ class Frame(wx.Frame): # Remove highlight, update testWin if g.testWin and g.testWin.highLight: g.testWin.highLight.Remove() - tree.needUpdate = True + tree.needUpdate = True # Undo info self.lastOp = 'MOVERIGHT' @@ -870,7 +887,6 @@ class Frame(wx.Frame): selected = tree.InsertNode(newParent, tree.GetPyData(newParent).treeObject(), elem, wx.TreeItemId()) newIndex = tree.ItemIndex(selected) - tree.oldItem = None tree.SelectItem(selected) undoMan.RegisterUndo(UndoMove(oldParent, oldIndex, newParent, newIndex)) @@ -1323,8 +1339,11 @@ Homepage: http://xrced.sourceforge.net\ menuId = evt.GetMenuId() if menuId != -1: menu = evt.GetEventObject() - help = menu.GetHelpString(menuId) - self.SetStatusText(help) + try: + help = menu.GetHelpString(menuId) + self.SetStatusText(help) + except: + self.SetStatusText('') else: self.SetStatusText('') @@ -1345,6 +1364,7 @@ Homepage: http://xrced.sourceforge.net\ def OnIdle(self, evt): if self.inIdle: return # Recursive call protection self.inIdle = True + #print 'onidle',tree.needUpdate,tree.pendingHighLight try: if tree.needUpdate: if conf.autoRefresh: @@ -1368,10 +1388,6 @@ Homepage: http://xrced.sourceforge.net\ finally: self.inIdle = False - # We don't let close panel window - def OnCloseMiniFrame(self, evt): - return - def OnIconize(self, evt): if evt.Iconized(): conf.x, conf.y = self.GetPosition() @@ -1381,10 +1397,10 @@ Homepage: http://xrced.sourceforge.net\ else: conf.panelX, conf.panelY = self.miniFrame.GetPosition() conf.panelWidth, conf.panelHeight = self.miniFrame.GetSize() - self.miniFrame.Iconize() + self.miniFrame.Show(False) else: if not conf.embedPanel: - self.miniFrame.Iconize(False) + self.miniFrame.Show(True) evt.Skip() def OnCloseWindow(self, evt): @@ -1397,7 +1413,10 @@ Homepage: http://xrced.sourceforge.net\ panel.RemovePage(1) if not self.IsIconized(): conf.x, conf.y = self.GetPosition() - conf.width, conf.height = self.GetClientSize() + if wx.Platform == '__WXMAC__': + conf.width, conf.height = self.GetClientSize() + else: + conf.width, conf.height = self.GetSize() if conf.embedPanel: conf.sashPos = self.splitter.GetSashPosition() else: @@ -1763,7 +1782,9 @@ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion) wx.FileSystem.AddHandler(wx.MemoryFSHandler()) # Create main frame frame = Frame(pos, size) - frame.SetClientSize(size) + # Mac does not set the correct size + if wx.Platform == '__WXMAC__': + frame.SetClientSize(size) frame.Show(True) # Load plugins