- tools panel

- menu IDs separated from PullDownMenu in ID_NEW class

- some icons changed

- button size for panel is calculated dinamically

- some menu command rearranged, static bitmap added

- status bar shows ctrl and shift state

- refresh bug (double-refreshing) fixed

- after tree selection changes, focus is set to tree control


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Roman Rolinsky
2003-03-20 20:01:51 +00:00
parent fe84bd4bdc
commit c9569d2308
8 changed files with 1357 additions and 249 deletions

View File

@@ -1,3 +1,16 @@
0.1.0
-----
Finally implemented tools panel for almost all controls (except
wxHtmlWindow, wxCalendarCtrl and wxGenericDirCtrl - they are too
rarely used).
Changed some sizes in panel to better work with different fonts.
Fixed double-refreshing after Ctrl+R.
Maybe something else that I've forgot. It's been a looong day... :)
0.0.9-6
-------

View File

@@ -9,15 +9,18 @@ from wxPython.xrc import *
# Global constants
sysFont = wxSystemSettings_GetFont(wxSYS_SYSTEM_FONT)
if wxPlatform == '__WXGTK__':
labelFont = wxFont(12, wxDEFAULT, wxNORMAL, wxBOLD)
modernFont = wxFont(12, wxMODERN, wxNORMAL, wxNORMAL)
labelFont = wxFont(sysFont.GetPointSize(), wxDEFAULT, wxNORMAL, wxBOLD)
modernFont = wxFont(sysFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL)
smallerFont = wxFont(sysFont.GetPointSize() - 2, wxDEFAULT, wxNORMAL, wxNORMAL)
else:
labelFont = wxFont(10, wxDEFAULT, wxNORMAL, wxBOLD)
modernFont = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL)
smallerFont = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL)
progname = 'XRCed'
version = '0.0.9-6'
version = '0.1.0'
# Global variables
@@ -25,6 +28,7 @@ class Globals:
panel = None
tree = None
frame = None
tools = None
undoMan = None
testWin = None
testWinPos = wxDefaultPosition

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,10 @@ class Panel(wxNotebook):
g.panel = panel = self
self.modified = False
# Set common button size for parameter buttons
import params
params.buttonSize = self.DLG_SZE(buttonSize)
# List of child windows
self.pages = []
# Create scrolled windows for pages
@@ -160,6 +164,7 @@ class ParamPage(wxPanel):
self.checks = {}
self.controls = {} # save python objects
self.controlName = None
def OnCheckParams(self, evt):
xxx = self.xxx
param = evt.GetEventObject().GetName()
@@ -249,11 +254,12 @@ class PropPage(ParamPage):
box.SetFont(labelFont)
topSizer = wxStaticBoxSizer(box, wxVERTICAL)
sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
sizer.AddGrowableCol(1)
if xxx.hasName:
label = wxStaticText(self, -1, 'XML ID:', size=(100,-1))
control = ParamText(self, name='XML_name')
control = ParamText(self, 'XML_name', 200)
sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
(control, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 5) ])
(control, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM | wxGROW, 5) ])
self.controlName = control
for param in xxx.allParams:
present = xxx.params.has_key(param)
@@ -279,7 +285,7 @@ class PropPage(ParamPage):
control = typeClass(self, param)
control.Enable(present)
sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
(control, 0, wxALIGN_CENTER_VERTICAL) ])
(control, 0, wxALIGN_CENTER_VERTICAL | wxGROW) ])
self.controls[param] = control
topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)
self.SetAutoLayout(True)
@@ -321,6 +327,7 @@ class StylePage(ParamPage):
box.SetFont(labelFont)
topSizer = wxStaticBoxSizer(box, wxVERTICAL)
sizer = wxFlexGridSizer(len(xxx.styles), 2, 1, 1)
sizer.AddGrowableCol(1)
for param in xxx.styles:
present = xxx.params.has_key(param)
check = wxCheckBox(self, paramIDs[param],
@@ -329,7 +336,7 @@ class StylePage(ParamPage):
control = paramDict[param](self, name = param)
control.Enable(present)
sizer.AddMany([ (check, 0, wxALIGN_CENTER_VERTICAL),
(control, 0, wxALIGN_CENTER_VERTICAL) ])
(control, 0, wxALIGN_CENTER_VERTICAL | wxGROW) ])
self.checks[param] = check
self.controls[param] = control
topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)

View File

@@ -16,7 +16,7 @@ genericStyles = ['wxSIMPLE_BORDER', 'wxDOUBLE_BORDER',
'wxTRANSPARENT_WINDOW', 'wxWANTS_CHARS',
'wxNO_FULL_REPAINT_ON_RESIZE']
buttonSize = (55,-1)
buttonSize = (30,-1) # in dialog units, transformed to pixels in panel ctor
# Class that can properly disable children
class PPanel(wxPanel):
@@ -351,14 +351,16 @@ class ParamUnit(PPanel):
self.Change(-1)
class ParamText(PPanel):
def __init__(self, parent, name, textWidth=260):
def __init__(self, parent, name, textWidth=-1):
PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId()
# We use sizer even here to have the same size of text control
sizer = wxBoxSizer()
self.SetBackgroundColour(g.panel.GetBackgroundColour())
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(textWidth,-1))
sizer.Add(self.text, 0, wxALIGN_CENTER_VERTICAL)
if textWidth == -1: option = 1
else: option = 0
sizer.Add(self.text, option, wxALIGN_CENTER_VERTICAL)
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
@@ -372,12 +374,20 @@ class ParamText(PPanel):
class ParamAccel(ParamText):
def __init__(self, parent, name):
ParamText.__init__(self, parent, name, 50)
ParamText.__init__(self, parent, name, 100)
class ParamPosSize(ParamText):
def __init__(self, parent, name):
ParamText.__init__(self, parent, name, 80)
class ParamLabel(ParamText):
def __init__(self, parent, name):
ParamText.__init__(self, parent, name, 200)
class ParamEncoding(ParamText):
def __init__(self, parent, name):
ParamText.__init__(self, parent, name, 100)
class ContentDialog(wxDialogPtr):
def __init__(self, parent, value):
# Load from resource
@@ -815,12 +825,13 @@ paramDict = {
'pos': ParamPosSize, 'size': ParamPosSize,
'border': ParamUnit, 'cols': ParamInt, 'rows': ParamInt,
'vgap': ParamUnit, 'hgap': ParamUnit,
'checkable': ParamBool, 'accel': ParamAccel,
'checkable': ParamBool, 'checked': ParamBool, 'radio': ParamBool,
'accel': ParamAccel,
'label': ParamText, 'title': ParamText, 'value': ParamText,
'content': ParamContent, 'selection': ParamInt,
'min': ParamInt, 'max': ParamInt,
'fg': ParamColour, 'bg': ParamColour, 'font': ParamFont,
'enabled': ParamBool, 'focused': ParamBool, 'hidden': ParamBool,
'tooltip': ParamText, 'bitmap': ParamBitmap, 'icon': ParamBitmap,
'label': ParamLabel, 'encoding': ParamEncoding
}

View File

@@ -34,70 +34,202 @@ class MyDocument(minidom.Document):
################################################################################
# Ids for menu commands
class ID_NEW:
PANEL = wxNewId()
DIALOG = wxNewId()
FRAME = wxNewId()
TOOL_BAR = wxNewId()
TOOL = wxNewId()
MENU_BAR = wxNewId()
MENU = wxNewId()
STATIC_TEXT = wxNewId()
TEXT_CTRL = wxNewId()
BUTTON = wxNewId()
BITMAP_BUTTON = wxNewId()
RADIO_BUTTON = wxNewId()
SPIN_BUTTON = wxNewId()
STATIC_BOX = wxNewId()
CHECK_BOX = wxNewId()
RADIO_BOX = wxNewId()
COMBO_BOX = wxNewId()
LIST_BOX = wxNewId()
STATIC_LINE = wxNewId()
STATIC_BITMAP = wxNewId()
CHOICE = wxNewId()
SLIDER = wxNewId()
GAUGE = wxNewId()
SCROLL_BAR = wxNewId()
TREE_CTRL = wxNewId()
LIST_CTRL = wxNewId()
CHECK_LIST = wxNewId()
NOTEBOOK = wxNewId()
HTML_WINDOW = wxNewId()
CALENDAR_CTRL = wxNewId()
GENERIC_DIR_CTRL = wxNewId()
SPIN_CTRL = wxNewId()
UNKNOWN = wxNewId()
BOX_SIZER = wxNewId()
STATIC_BOX_SIZER = wxNewId()
GRID_SIZER = wxNewId()
FLEX_GRID_SIZER = wxNewId()
SPACER = wxNewId()
TOOL_BAR = wxNewId()
TOOL = wxNewId()
MENU = wxNewId()
MENU_ITEM = wxNewId()
SEPARATOR = wxNewId()
LAST = wxNewId()
class PullDownMenu:
ID_NEW_PANEL = wxNewId()
ID_NEW_DIALOG = wxNewId()
ID_NEW_FRAME = wxNewId()
ID_NEW_TOOL_BAR = wxNewId()
ID_NEW_TOOL = wxNewId()
ID_NEW_MENU_BAR = wxNewId()
ID_NEW_MENU = wxNewId()
ID_NEW_STATIC_TEXT = wxNewId()
ID_NEW_TEXT_CTRL = wxNewId()
ID_NEW_BUTTON = wxNewId()
ID_NEW_BITMAP_BUTTON = wxNewId()
ID_NEW_RADIO_BUTTON = wxNewId()
ID_NEW_SPIN_BUTTON = wxNewId()
ID_NEW_STATIC_BOX = wxNewId()
ID_NEW_CHECK_BOX = wxNewId()
ID_NEW_RADIO_BOX = wxNewId()
ID_NEW_COMBO_BOX = wxNewId()
ID_NEW_LIST_BOX = wxNewId()
ID_NEW_STATIC_LINE = wxNewId()
ID_NEW_STATIC_BITMAP = wxNewId()
ID_NEW_CHOICE = wxNewId()
ID_NEW_SLIDER = wxNewId()
ID_NEW_GAUGE = wxNewId()
ID_NEW_SCROLL_BAR = wxNewId()
ID_NEW_TREE_CTRL = wxNewId()
ID_NEW_LIST_CTRL = wxNewId()
ID_NEW_CHECK_LIST = wxNewId()
ID_NEW_NOTEBOOK = wxNewId()
ID_NEW_HTML_WINDOW = wxNewId()
ID_NEW_CALENDAR_CTRL = wxNewId()
ID_NEW_GENERIC_DIR_CTRL = wxNewId()
ID_NEW_SPIN_CTRL = wxNewId()
ID_NEW_UNKNOWN = wxNewId()
ID_NEW_BOX_SIZER = wxNewId()
ID_NEW_STATIC_BOX_SIZER = wxNewId()
ID_NEW_GRID_SIZER = wxNewId()
ID_NEW_FLEX_GRID_SIZER = wxNewId()
ID_NEW_SPACER = wxNewId()
ID_NEW_TOOL_BAR = wxNewId()
ID_NEW_TOOL = wxNewId()
ID_NEW_MENU = wxNewId()
ID_NEW_MENU_ITEM = wxNewId()
ID_NEW_SEPARATOR = wxNewId()
ID_NEW_LAST = wxNewId()
ID_EXPAND = wxNewId()
ID_COLLAPSE = wxNewId()
ID_PASTE_SIBLING = wxNewId()
def __init__(self, parent):
self.ID_DELETE = parent.ID_DELETE
EVT_MENU_RANGE(parent, self.ID_NEW_PANEL,
self.ID_NEW_LAST, parent.OnCreate)
EVT_MENU_RANGE(parent, ID_NEW.PANEL, ID_NEW.LAST, parent.OnCreate)
EVT_MENU(parent, self.ID_COLLAPSE, parent.OnCollapse)
EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand)
EVT_MENU(parent, self.ID_PASTE_SIBLING, parent.OnPaste)
# We connect to tree, but process in frame
EVT_MENU_HIGHLIGHT_ALL(g.tree, parent.OnPullDownHighlight)
# Mapping from IDs to element names
self.createMap = {
ID_NEW.PANEL: 'wxPanel',
ID_NEW.DIALOG: 'wxDialog',
ID_NEW.FRAME: 'wxFrame',
ID_NEW.TOOL_BAR: 'wxToolBar',
ID_NEW.TOOL: 'tool',
ID_NEW.MENU_BAR: 'wxMenuBar',
ID_NEW.MENU: 'wxMenu',
ID_NEW.MENU_ITEM: 'wxMenuItem',
ID_NEW.SEPARATOR: 'separator',
ID_NEW.STATIC_TEXT: 'wxStaticText',
ID_NEW.TEXT_CTRL: 'wxTextCtrl',
ID_NEW.BUTTON: 'wxButton',
ID_NEW.BITMAP_BUTTON: 'wxBitmapButton',
ID_NEW.RADIO_BUTTON: 'wxRadioButton',
ID_NEW.SPIN_BUTTON: 'wxSpinButton',
ID_NEW.STATIC_BOX: 'wxStaticBox',
ID_NEW.CHECK_BOX: 'wxCheckBox',
ID_NEW.RADIO_BOX: 'wxRadioBox',
ID_NEW.COMBO_BOX: 'wxComboBox',
ID_NEW.LIST_BOX: 'wxListBox',
ID_NEW.STATIC_LINE: 'wxStaticLine',
ID_NEW.STATIC_BITMAP: 'wxStaticBitmap',
ID_NEW.CHOICE: 'wxChoice',
ID_NEW.SLIDER: 'wxSlider',
ID_NEW.GAUGE: 'wxGauge',
ID_NEW.SCROLL_BAR: 'wxScrollBar',
ID_NEW.TREE_CTRL: 'wxTreeCtrl',
ID_NEW.LIST_CTRL: 'wxListCtrl',
ID_NEW.CHECK_LIST: 'wxCheckList',
ID_NEW.NOTEBOOK: 'wxNotebook',
ID_NEW.HTML_WINDOW: 'wxHtmlWindow',
ID_NEW.CALENDAR_CTRL: 'wxCalendarCtrl',
ID_NEW.GENERIC_DIR_CTRL: 'wxGenericDirCtrl',
ID_NEW.SPIN_CTRL: 'wxSpinCtrl',
ID_NEW.BOX_SIZER: 'wxBoxSizer',
ID_NEW.STATIC_BOX_SIZER: 'wxStaticBoxSizer',
ID_NEW.GRID_SIZER: 'wxGridSizer',
ID_NEW.FLEX_GRID_SIZER: 'wxFlexGridSizer',
ID_NEW.SPACER: 'spacer',
ID_NEW.UNKNOWN: 'unknown',
}
self.controls = [
['control', 'Various controls',
(ID_NEW.STATIC_TEXT, 'Label', 'Create label'),
(ID_NEW.STATIC_BITMAP, 'Bitmap', 'Create bitmap'),
(ID_NEW.STATIC_LINE, 'Line', 'Create line'),
(ID_NEW.TEXT_CTRL, 'TextBox', 'Create text box'),
(ID_NEW.CHOICE, 'Choice', 'Create choice'),
(ID_NEW.SLIDER, 'Slider', 'Create slider'),
(ID_NEW.GAUGE, 'Gauge', 'Create gauge'),
(ID_NEW.SPIN_CTRL, 'SpinCtrl', 'Create spin'),
(ID_NEW.SCROLL_BAR, 'ScrollBar', 'Create scroll bar'),
(ID_NEW.TREE_CTRL, 'TreeCtrl', 'Create tree'),
(ID_NEW.LIST_CTRL, 'ListCtrl', 'Create list'),
(ID_NEW.CHECK_LIST, 'CheckList', 'Create check list'),
(ID_NEW.HTML_WINDOW, 'HtmlWindow', 'Create HTML window'),
(ID_NEW.CALENDAR_CTRL, 'CalendarCtrl', 'Create calendar control'),
(ID_NEW.GENERIC_DIR_CTRL, 'GenericDirCtrl', 'Create generic dir control'),
(ID_NEW.UNKNOWN, 'Unknown', 'Create custom control placeholder'),
],
['button', 'Buttons',
(ID_NEW.BUTTON, 'Button', 'Create button'),
(ID_NEW.BITMAP_BUTTON, 'BitmapButton', 'Create bitmap button'),
(ID_NEW.RADIO_BUTTON, 'RadioButton', 'Create radio button'),
(ID_NEW.SPIN_BUTTON, 'SpinButton', 'Create spin button'),
],
['box', 'Boxes',
(ID_NEW.STATIC_BOX, 'StaticBox', 'Create static box'),
(ID_NEW.CHECK_BOX, 'CheckBox', 'Create check box'),
(ID_NEW.RADIO_BOX, 'RadioBox', 'Create radio box'),
(ID_NEW.COMBO_BOX, 'ComboBox', 'Create combo box'),
(ID_NEW.LIST_BOX, 'ListBox', 'Create list box'),
],
['container', 'Containers',
(ID_NEW.PANEL, 'Panel', 'Create panel'),
(ID_NEW.NOTEBOOK, 'Notebook', 'Create notebook control'),
(ID_NEW.TOOL_BAR, 'ToolBar', 'Create toolbar'),
],
['sizer', 'Sizers',
(ID_NEW.BOX_SIZER, 'BoxSizer', 'Create box sizer'),
(ID_NEW.STATIC_BOX_SIZER, 'StaticBoxSizer',
'Create static box sizer'),
(ID_NEW.GRID_SIZER, 'GridSizer', 'Create grid sizer'),
(ID_NEW.FLEX_GRID_SIZER, 'FlexGridSizer',
'Create flexgrid sizer'),
(ID_NEW.SPACER, 'Spacer', 'Create spacer'),
]
]
self.menuControls = [
(ID_NEW.MENU, 'Menu', 'Create menu'),
(ID_NEW.MENU_ITEM, 'MenuItem', 'Create menu item'),
(ID_NEW.SEPARATOR, 'Separator', 'Create separator'),
]
self.toolBarControls = [
(ID_NEW.TOOL, 'Tool', 'Create tool'),
(ID_NEW.SEPARATOR, 'Separator', 'Create separator'),
['control', 'Various controls',
(ID_NEW.STATIC_TEXT, 'Label', 'Create label'),
(ID_NEW.STATIC_BITMAP, 'Bitmap', 'Create bitmap'),
(ID_NEW.STATIC_LINE, 'Line', 'Create line'),
(ID_NEW.TEXT_CTRL, 'TextBox', 'Create text box'),
(ID_NEW.CHOICE, 'Choice', 'Create choice'),
(ID_NEW.SLIDER, 'Slider', 'Create slider'),
(ID_NEW.GAUGE, 'Gauge', 'Create gauge'),
(ID_NEW.SCROLL_BAR, 'ScrollBar', 'Create scroll bar'),
(ID_NEW.LIST_CTRL, 'ListCtrl', 'Create list control'),
(ID_NEW.CHECK_LIST, 'CheckList', 'Create check list'),
],
['button', 'Buttons',
(ID_NEW.BUTTON, 'Button', 'Create button'),
(ID_NEW.BITMAP_BUTTON, 'BitmapButton', 'Create bitmap button'),
(ID_NEW.RADIO_BUTTON, 'RadioButton', 'Create radio button'),
(ID_NEW.SPIN_BUTTON, 'SpinButton', 'Create spin button'),
],
['box', 'Boxes',
(ID_NEW.STATIC_BOX, 'StaticBox', 'Create static box'),
(ID_NEW.CHECK_BOX, 'CheckBox', 'Create check box'),
(ID_NEW.RADIO_BOX, 'RadioBox', 'Create radio box'),
(ID_NEW.COMBO_BOX, 'ComboBox', 'Create combo box'),
(ID_NEW.LIST_BOX, 'ListBox', 'Create list box'),
],
]
################################################################################
# Set menu to list items.
@@ -172,8 +304,11 @@ class XML_Tree(wxTreeCtrl):
xxxDialog.image = il.AddIcon(images.getTreeDialogIcon())
xxxFrame.image = il.AddIcon(images.getTreeFrameIcon())
xxxMenuBar.image = il.AddIcon(images.getTreeMenuBarIcon())
xxxToolBar.image = il.AddIcon(images.getTreeToolBarIcon())
xxxMenu.image = il.AddIcon(images.getTreeMenuIcon())
xxxMenuItem.image = il.AddIcon(images.getTreeMenuItemIcon())
xxxToolBar.image = il.AddIcon(images.getTreeToolBarIcon())
xxxTool.image = il.AddIcon(images.getTreeToolIcon())
xxxSeparator.image = il.AddIcon(images.getTreeSeparatorIcon())
xxxSizer.imageH = il.AddIcon(images.getTreeSizerHIcon())
xxxSizer.imageV = il.AddIcon(images.getTreeSizerVIcon())
xxxStaticBoxSizer.imageH = il.AddIcon(images.getTreeStaticBoxSizerHIcon())
@@ -183,9 +318,16 @@ class XML_Tree(wxTreeCtrl):
self.il = il
self.SetImageList(il)
def RegisterKeyEvents(self):
EVT_KEY_DOWN(self, g.tools.OnKeyDown)
EVT_KEY_UP(self, g.tools.OnKeyUp)
EVT_ENTER_WINDOW(self, g.tools.OnMouse)
EVT_LEAVE_WINDOW(self, g.tools.OnMouse)
def Unselect(self):
self.selection = None
wxTreeCtrl.Unselect(self)
g.tools.UpdateUI()
def ExpandAll(self, item):
if self.ItemHasChildren(item):
@@ -377,6 +519,8 @@ class XML_Tree(wxTreeCtrl):
xxx = self.GetPyData(self.selection)
# Update panel
g.panel.SetData(xxx)
# Update tools
g.tools.UpdateUI()
# Hightlighting is done in OnIdle
self.pendingHighLight = self.selection
# Check if item is in testWin subtree
@@ -437,6 +581,7 @@ class XML_Tree(wxTreeCtrl):
def CreateTestWin(self, item):
testWin = g.testWin
wxBeginBusyCursor()
wxYield()
# Create a window with this resource
xxx = self.GetPyData(item).treeObject()
# Close old window, remember where it was
@@ -611,27 +756,27 @@ class XML_Tree(wxTreeCtrl):
menu.Append(g.pullDownMenu.ID_EXPAND, 'Expand', 'Expand tree')
menu.Append(g.pullDownMenu.ID_COLLAPSE, 'Collapse', 'Collapse tree')
else:
self.ctrl = evt.ControlDown() # save Ctrl state
self.shift = evt.ShiftDown() # and Shift too
# self.ctrl = evt.ControlDown() # save Ctrl state
# self.shift = evt.ShiftDown() # and Shift too
m = wxMenu() # create menu
if self.ctrl:
needInsert = True
else:
needInsert = self.NeedInsert(item)
if item == self.root or needInsert and self.GetItemParent(item) == self.root:
m.Append(pullDownMenu.ID_NEW_PANEL, 'Panel', 'Create panel')
m.Append(pullDownMenu.ID_NEW_DIALOG, 'Dialog', 'Create dialog')
m.Append(pullDownMenu.ID_NEW_FRAME, 'Frame', 'Create frame')
m.Append(ID_NEW.PANEL, 'Panel', 'Create panel')
m.Append(ID_NEW.DIALOG, 'Dialog', 'Create dialog')
m.Append(ID_NEW.FRAME, 'Frame', 'Create frame')
m.AppendSeparator()
m.Append(pullDownMenu.ID_NEW_TOOL_BAR, 'ToolBar', 'Create toolbar')
m.Append(pullDownMenu.ID_NEW_MENU_BAR, 'MenuBar', 'Create menubar')
m.Append(pullDownMenu.ID_NEW_MENU, 'Menu', 'Create menu')
m.Append(ID_NEW.TOOL_BAR, 'ToolBar', 'Create toolbar')
m.Append(ID_NEW.MENU_BAR, 'MenuBar', 'Create menubar')
m.Append(ID_NEW.MENU, 'Menu', 'Create menu')
else:
xxx = self.GetPyData(item).treeObject()
# Check parent for possible child nodes if inserting sibling
if needInsert: xxx = xxx.parent
if xxx.__class__ == xxxMenuBar:
m.Append(pullDownMenu.ID_NEW_MENU, 'Menu', 'Create menu')
m.Append(ID_NEW.MENU, 'Menu', 'Create menu')
elif xxx.__class__ in [xxxToolBar, xxxTool] or \
xxx.__class__ == xxxSeparator and xxx.parent.__class__ == xxxToolBar:
SetMenu(m, pullDownMenu.toolBarControls)
@@ -642,7 +787,7 @@ class XML_Tree(wxTreeCtrl):
if xxx.__class__ == xxxNotebook:
m.Enable(m.FindItem('sizer'), False)
elif not (xxx.isSizer or xxx.parent and xxx.parent.isSizer):
m.Enable(pullDownMenu.ID_NEW_SPACER, False)
m.Enable(ID_NEW.SPACER, False)
# Select correct label for create menu
if not needInsert:
if self.shift:
@@ -683,6 +828,9 @@ class XML_Tree(wxTreeCtrl):
xxx = xxx.treeObject()
if xxx.hasName and self.GetItemText(item) != xxx.name:
self.SetItemText(item, xxx.treeName())
# Item width may have changed
# !!! Tric to update tree width (wxGTK, ??)
self.SetIndent(self.GetIndent())
# Change tree icon for sizers
if isinstance(xxx, xxxBoxSizer):
self.SetItemImage(item, xxx.treeImage())

View File

@@ -29,6 +29,7 @@ import os, sys, getopt, re, traceback
# Local modules
from tree import * # imports xxx which imports params
from panel import *
from tools import *
# Cleanup recursive import sideeffects, otherwise we can't create undoMan
import undo
undo.ParamPage = ParamPage
@@ -82,7 +83,8 @@ class Frame(wxFrame):
wxFrame.__init__(self, None, -1, '', pos, size)
global frame
frame = g.frame = self
self.CreateStatusBar()
bar = self.CreateStatusBar(2)
bar.SetStatusWidths([-1, 40])
self.SetIcon(images.getIconIcon())
# Idle flag
@@ -119,6 +121,9 @@ class Frame(wxFrame):
menu.Append(self.ID_EMBED_PANEL, '&Embed Panel',
'Toggle embedding properties panel in the main window', True)
menu.Check(self.ID_EMBED_PANEL, conf.embedPanel)
self.ID_SHOW_TOOLS = wxNewId()
menu.Append(self.ID_SHOW_TOOLS, 'Show &Tools', 'Toggle tools', True)
menu.Check(self.ID_SHOW_TOOLS, conf.showTools)
menu.AppendSeparator()
self.ID_TEST = wxNewId()
menu.Append(self.ID_TEST, '&Test\tF5', 'Test window')
@@ -185,6 +190,7 @@ class Frame(wxFrame):
EVT_MENU(self, ID_SELECT, self.OnSelect)
# View
EVT_MENU(self, self.ID_EMBED_PANEL, self.OnEmbedPanel)
EVT_MENU(self, self.ID_SHOW_TOOLS, self.OnShowTools)
EVT_MENU(self, self.ID_TEST, self.OnTest)
EVT_MENU(self, self.ID_REFRESH, self.OnRefresh)
EVT_MENU(self, self.ID_AUTO_REFRESH, self.OnAutoRefresh)
@@ -205,6 +211,8 @@ class Frame(wxFrame):
# Build interface
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(wxStaticLine(self, -1), 0, wxEXPAND)
# Horizontal sizer for toolbar and splitter
self.toolsSizer = sizer1 = wxBoxSizer()
splitter = wxSplitterWindow(self, -1, style=wxSP_3DSASH)
self.splitter = splitter
splitter.SetMinimumPaneSize(100)
@@ -212,6 +220,17 @@ class Frame(wxFrame):
global tree
g.tree = tree = XML_Tree(splitter, -1)
# Init pull-down menu data
global pullDownMenu
g.pullDownMenu = pullDownMenu = PullDownMenu(self)
# Vertical toolbar for GUI buttons
g.tools = tools = Tools(self)
tools.Show(conf.showTools)
if conf.showTools: sizer1.Add(tools, 0, wxEXPAND)
tree.RegisterKeyEvents()
# !!! frame styles are broken
# Miniframe for not embedded mode
miniFrame = wxFrame(self, -1, 'Properties Panel',
@@ -233,142 +252,11 @@ class Frame(wxFrame):
sizer2.Add(panel, 1, wxEXPAND)
miniFrame.Show(True)
splitter.Initialize(tree)
sizer.Add(splitter, 1, wxEXPAND)
sizer1.Add(splitter, 1, wxEXPAND)
sizer.Add(sizer1, 1, wxEXPAND)
self.SetAutoLayout(True)
self.SetSizer(sizer)
# Init pull-down menu data
global pullDownMenu
pullDownMenu = g.pullDownMenu = PullDownMenu(self)
# Mapping from IDs to element names
self.createMap = {
pullDownMenu.ID_NEW_PANEL: 'wxPanel',
pullDownMenu.ID_NEW_DIALOG: 'wxDialog',
pullDownMenu.ID_NEW_FRAME: 'wxFrame',
pullDownMenu.ID_NEW_TOOL_BAR: 'wxToolBar',
pullDownMenu.ID_NEW_TOOL: 'tool',
pullDownMenu.ID_NEW_MENU_BAR: 'wxMenuBar',
pullDownMenu.ID_NEW_MENU: 'wxMenu',
pullDownMenu.ID_NEW_MENU_ITEM: 'wxMenuItem',
pullDownMenu.ID_NEW_SEPARATOR: 'separator',
pullDownMenu.ID_NEW_STATIC_TEXT: 'wxStaticText',
pullDownMenu.ID_NEW_TEXT_CTRL: 'wxTextCtrl',
pullDownMenu.ID_NEW_BUTTON: 'wxButton',
pullDownMenu.ID_NEW_BITMAP_BUTTON: 'wxBitmapButton',
pullDownMenu.ID_NEW_RADIO_BUTTON: 'wxRadioButton',
pullDownMenu.ID_NEW_SPIN_BUTTON: 'wxSpinButton',
pullDownMenu.ID_NEW_STATIC_BOX: 'wxStaticBox',
pullDownMenu.ID_NEW_CHECK_BOX: 'wxCheckBox',
pullDownMenu.ID_NEW_RADIO_BOX: 'wxRadioBox',
pullDownMenu.ID_NEW_COMBO_BOX: 'wxComboBox',
pullDownMenu.ID_NEW_LIST_BOX: 'wxListBox',
pullDownMenu.ID_NEW_STATIC_LINE: 'wxStaticLine',
pullDownMenu.ID_NEW_STATIC_BITMAP: 'wxStaticBitmap',
pullDownMenu.ID_NEW_CHOICE: 'wxChoice',
pullDownMenu.ID_NEW_SLIDER: 'wxSlider',
pullDownMenu.ID_NEW_GAUGE: 'wxGauge',
pullDownMenu.ID_NEW_SCROLL_BAR: 'wxScrollBar',
pullDownMenu.ID_NEW_TREE_CTRL: 'wxTreeCtrl',
pullDownMenu.ID_NEW_LIST_CTRL: 'wxListCtrl',
pullDownMenu.ID_NEW_CHECK_LIST: 'wxCheckList',
pullDownMenu.ID_NEW_NOTEBOOK: 'wxNotebook',
pullDownMenu.ID_NEW_HTML_WINDOW: 'wxHtmlWindow',
pullDownMenu.ID_NEW_CALENDAR_CTRL: 'wxCalendarCtrl',
pullDownMenu.ID_NEW_GENERIC_DIR_CTRL: 'wxGenericDirCtrl',
pullDownMenu.ID_NEW_SPIN_CTRL: 'wxSpinCtrl',
pullDownMenu.ID_NEW_BOX_SIZER: 'wxBoxSizer',
pullDownMenu.ID_NEW_STATIC_BOX_SIZER: 'wxStaticBoxSizer',
pullDownMenu.ID_NEW_GRID_SIZER: 'wxGridSizer',
pullDownMenu.ID_NEW_FLEX_GRID_SIZER: 'wxFlexGridSizer',
pullDownMenu.ID_NEW_SPACER: 'spacer',
pullDownMenu.ID_NEW_UNKNOWN: 'unknown',
}
pullDownMenu.controls = [
['control', 'Various controls',
(pullDownMenu.ID_NEW_STATIC_TEXT, 'Label', 'Create static label'),
(pullDownMenu.ID_NEW_STATIC_LINE, 'Line', 'Create static line'),
(pullDownMenu.ID_NEW_TEXT_CTRL, 'TextBox', 'Create text box control'),
(pullDownMenu.ID_NEW_CHOICE, 'Choice', 'Create choice control'),
(pullDownMenu.ID_NEW_SLIDER, 'Slider', 'Create slider control'),
(pullDownMenu.ID_NEW_GAUGE, 'Gauge', 'Create gauge control'),
(pullDownMenu.ID_NEW_SPIN_CTRL, 'SpinCtrl', 'Create spin control'),
(pullDownMenu.ID_NEW_SCROLL_BAR, 'ScrollBar', 'Create scroll bar'),
(pullDownMenu.ID_NEW_TREE_CTRL, 'TreeCtrl', 'Create tree control'),
(pullDownMenu.ID_NEW_LIST_CTRL, 'ListCtrl', 'Create list control'),
(pullDownMenu.ID_NEW_HTML_WINDOW, 'HtmlWindow', 'Create HTML window'),
(pullDownMenu.ID_NEW_CALENDAR_CTRL, 'CalendarCtrl', 'Create calendar control'),
(pullDownMenu.ID_NEW_GENERIC_DIR_CTRL, 'GenericDirCtrl', 'Create generic dir control'),
(pullDownMenu.ID_NEW_UNKNOWN, 'Unknown', 'Create custom control placeholder'),
],
['button', 'Buttons',
(pullDownMenu.ID_NEW_BUTTON, 'Button', 'Create button'),
(pullDownMenu.ID_NEW_BITMAP_BUTTON, 'BitmapButton', 'Create bitmap button'),
(pullDownMenu.ID_NEW_RADIO_BUTTON, 'RadioButton', 'Create radio button'),
(pullDownMenu.ID_NEW_SPIN_BUTTON, 'SpinButton', 'Create spin button'),
],
['box', 'Boxes',
(pullDownMenu.ID_NEW_STATIC_BOX, 'StaticBox', 'Create static box'),
(pullDownMenu.ID_NEW_CHECK_BOX, 'CheckBox', 'Create check box'),
(pullDownMenu.ID_NEW_RADIO_BOX, 'RadioBox', 'Create radio box'),
(pullDownMenu.ID_NEW_COMBO_BOX, 'ComboBox', 'Create combo box'),
(pullDownMenu.ID_NEW_LIST_BOX, 'ListBox', 'Create list box'),
(pullDownMenu.ID_NEW_CHECK_LIST, 'CheckListBox', 'Create check list control'),
],
['container', 'Containers',
(pullDownMenu.ID_NEW_PANEL, 'Panel', 'Create panel'),
(pullDownMenu.ID_NEW_NOTEBOOK, 'Notebook', 'Create notebook control'),
(pullDownMenu.ID_NEW_TOOL_BAR, 'ToolBar', 'Create toolbar'),
],
['sizer', 'Sizers',
(pullDownMenu.ID_NEW_BOX_SIZER, 'BoxSizer', 'Create box sizer'),
(pullDownMenu.ID_NEW_STATIC_BOX_SIZER, 'StaticBoxSizer',
'Create static box sizer'),
(pullDownMenu.ID_NEW_GRID_SIZER, 'GridSizer', 'Create grid sizer'),
(pullDownMenu.ID_NEW_FLEX_GRID_SIZER, 'FlexGridSizer',
'Create flexgrid sizer'),
(pullDownMenu.ID_NEW_SPACER, 'Spacer', 'Create spacer'),
]
]
pullDownMenu.menuControls = [
(pullDownMenu.ID_NEW_MENU, 'Menu', 'Create menu'),
(pullDownMenu.ID_NEW_MENU_ITEM, 'MenuItem', 'Create menu item'),
(pullDownMenu.ID_NEW_SEPARATOR, 'Separator', 'Create separator'),
]
pullDownMenu.toolBarControls = [
(pullDownMenu.ID_NEW_TOOL, 'Tool', 'Create tool'),
(pullDownMenu.ID_NEW_SEPARATOR, 'Separator', 'Create separator'),
['control', 'Various controls',
(pullDownMenu.ID_NEW_STATIC_TEXT, 'Label', 'Create static label'),
(pullDownMenu.ID_NEW_STATIC_LINE, 'Line', 'Create static line'),
(pullDownMenu.ID_NEW_TEXT_CTRL, 'TextBox', 'Create text box control'),
(pullDownMenu.ID_NEW_CHOICE, 'Choice', 'Create choice control'),
(pullDownMenu.ID_NEW_SLIDER, 'Slider', 'Create slider control'),
(pullDownMenu.ID_NEW_GAUGE, 'Gauge', 'Create gauge control'),
(pullDownMenu.ID_NEW_SCROLL_BAR, 'ScrollBar', 'Create scroll bar'),
(pullDownMenu.ID_NEW_LIST_CTRL, 'ListCtrl', 'Create list control'),
],
['button', 'Buttons',
(pullDownMenu.ID_NEW_BUTTON, 'Button', 'Create button'),
(pullDownMenu.ID_NEW_BITMAP_BUTTON, 'BitmapButton', 'Create bitmap button'),
(pullDownMenu.ID_NEW_RADIO_BUTTON, 'RadioButton', 'Create radio button'),
(pullDownMenu.ID_NEW_SPIN_BUTTON, 'SpinButton', 'Create spin button'),
],
['box', 'Boxes',
(pullDownMenu.ID_NEW_STATIC_BOX, 'StaticBox', 'Create static box'),
(pullDownMenu.ID_NEW_CHECK_BOX, 'CheckBox', 'Create check box'),
(pullDownMenu.ID_NEW_RADIO_BOX, 'RadioBox', 'Create radio box'),
(pullDownMenu.ID_NEW_COMBO_BOX, 'ComboBox', 'Create combo box'),
(pullDownMenu.ID_NEW_LIST_BOX, 'ListBox', 'Create list box'),
(pullDownMenu.ID_NEW_CHECK_LIST, 'CheckListBox',
'Create check list control'),
],
]
# Initialize
self.clipboard = None
self.Clear()
@@ -377,6 +265,8 @@ class Frame(wxFrame):
EVT_IDLE(self, self.OnIdle)
EVT_CLOSE(self, self.OnCloseWindow)
EVT_LEFT_DOWN(self, self.OnLeftDown)
EVT_KEY_DOWN(self, tools.OnKeyDown)
EVT_KEY_UP(self, tools.OnKeyUp)
def OnNew(self, evt):
self.Clear()
@@ -626,6 +516,15 @@ class Frame(wxFrame):
self.SetDimensions(pos.x, pos.y,
max(size.x - sizePanel.x, self.minWidth), size.y)
def OnShowTools(self, evt):
conf.showTools = evt.IsChecked()
g.tools.Show(conf.showTools)
if conf.showTools:
self.toolsSizer.Prepend(g.tools, 0, wxEXPAND)
else:
self.toolsSizer.Remove(g.tools)
self.toolsSizer.Layout()
def OnTest(self, evt):
if not tree.selection: return # key pressed event
tree.ShowTestWindow(tree.selection)
@@ -640,6 +539,7 @@ class Frame(wxFrame):
if g.testWin:
# (re)create
tree.CreateTestWin(g.testWin.item)
panel.modified = False
tree.needUpdate = False
def OnAutoRefresh(self, evt):
@@ -707,7 +607,7 @@ Homepage: http://xrced.sourceforge.net\
if parent.hasChild: parent = parent.child
# Create element
className = self.createMap[evt.GetId()]
className = pullDownMenu.createMap[evt.GetId()]
xxx = MakeEmptyXXX(parent, className)
# Set default name for top-level windows
@@ -733,6 +633,7 @@ Homepage: http://xrced.sourceforge.net\
tree.pendingHighLight = newItem
else:
tree.pendingHighLight = None
tree.SetFocus()
# Expand/collapse subtree
def OnExpand(self, evt):
@@ -948,6 +849,7 @@ class App(wxApp):
pos = conf.ReadInt('x', -1), conf.ReadInt('y', -1)
size = conf.ReadInt('width', 800), conf.ReadInt('height', 600)
conf.embedPanel = conf.ReadInt('embedPanel', True)
conf.showTools = conf.ReadInt('showTools', True)
conf.sashPos = conf.ReadInt('sashPos', 200)
if not conf.embedPanel:
conf.panelX = conf.ReadInt('panelX', -1)
@@ -984,6 +886,7 @@ class App(wxApp):
wc.WriteInt('width', conf.width)
wc.WriteInt('height', conf.height)
wc.WriteInt('embedPanel', conf.embedPanel)
wc.WriteInt('showTools', conf.showTools)
if not conf.embedPanel:
wc.WriteInt('panelX', conf.panelX)
wc.WriteInt('panelY', conf.panelY)

View File

@@ -23,13 +23,14 @@
<object class="wxButton" name="BUTTON_UP">
<label>Move Up</label>
</object>
<flag>wxBOTTOM</flag>
<flag>wxBOTTOM|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_DOWN">
<label>Move Down</label>
</object>
<flag>wxEXPAND</flag>
</object>
<object class="spacer">
<size>10,20</size>
@@ -39,13 +40,14 @@
<object class="wxButton" name="BUTTON_APPEND">
<label>Append...</label>
</object>
<flag>wxBOTTOM</flag>
<flag>wxBOTTOM|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_REMOVE">
<label>Remove</label>
</object>
<flag>wxEXPAND</flag>
</object>
</object>
<flag>wxALL|wxEXPAND</flag>
@@ -105,13 +107,14 @@
<object class="wxButton" name="BUTTON_UP">
<label>Move Up</label>
</object>
<flag>wxBOTTOM</flag>
<flag>wxBOTTOM|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_DOWN">
<label>Move Down</label>
</object>
<flag>wxEXPAND</flag>
</object>
<object class="spacer">
<size>10,20</size>
@@ -121,13 +124,14 @@
<object class="wxButton" name="BUTTON_APPEND">
<label>Append...</label>
</object>
<flag>wxBOTTOM</flag>
<flag>wxBOTTOM|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_REMOVE">
<label>Remove</label>
</object>
<flag>wxEXPAND</flag>
</object>
</object>
<flag>wxALL|wxEXPAND</flag>
@@ -251,34 +255,34 @@
<item>wxART_ADD_BOOKMARK</item>
<item>wxART_DEL_BOOKMARK</item>
<item>wxART_HELP_SIDE_PANEL</item>
<item>wxART_HELP_SETTINGS</item>
<item>wxART_HELP_BOOK</item>
<item>wxART_HELP_FOLDER</item>
<item>wxART_HELP_PAGE</item>
<item>wxART_GO_BACK</item>
<item>wxART_GO_FORWARD</item>
<item>wxART_GO_UP</item>
<item>wxART_GO_DOWN</item>
<item>wxART_GO_TO_PARENT</item>
<item>wxART_GO_HOME</item>
<item>wxART_FILE_OPEN</item>
<item>wxART_PRINT</item>
<item>wxART_HELP</item>
<item>wxART_TIP</item>
<item>wxART_REPORT_VIEW</item>
<item>wxART_LIST_VIEW</item>
<item>wxART_NEW_DIR</item>
<item>wxART_FOLDER</item>
<item>wxART_GO_DIR_UP</item>
<item>wxART_EXECUTABLE_FILE</item>
<item>wxART_NORMAL_FILE</item>
<item>wxART_TICK_MARK</item>
<item>wxART_CROSS_MARK</item>
<item>wxART_ERROR</item>
<item>wxART_QUESTION</item>
<item>wxART_WARNING</item>
<item>wxART_INFORMATION</item>
<item>wxART_MISSING_IMAGE</item>
<item>wxART_HELP_SETTINGS</item>
<item>wxART_HELP_BOOK</item>
<item>wxART_HELP_FOLDER</item>
<item>wxART_HELP_PAGE</item>
<item>wxART_GO_BACK</item>
<item>wxART_GO_FORWARD</item>
<item>wxART_GO_UP</item>
<item>wxART_GO_DOWN</item>
<item>wxART_GO_TO_PARENT</item>
<item>wxART_GO_HOME</item>
<item>wxART_FILE_OPEN</item>
<item>wxART_PRINT</item>
<item>wxART_HELP</item>
<item>wxART_TIP</item>
<item>wxART_REPORT_VIEW</item>
<item>wxART_LIST_VIEW</item>
<item>wxART_NEW_DIR</item>
<item>wxART_FOLDER</item>
<item>wxART_GO_DIR_UP</item>
<item>wxART_EXECUTABLE_FILE</item>
<item>wxART_NORMAL_FILE</item>
<item>wxART_TICK_MARK</item>
<item>wxART_CROSS_MARK</item>
<item>wxART_ERROR</item>
<item>wxART_QUESTION</item>
<item>wxART_WARNING</item>
<item>wxART_INFORMATION</item>
<item>wxART_MISSING_IMAGE</item>
</content>
</object>
<flag>wxRIGHT|wxEXPAND</flag>
@@ -301,7 +305,7 @@
<object class="sizeritem">
<object class="wxButton" name="BUTTON_BROWSE">
<label>Browse...</label>
<size>55,-1</size>
<size>30,-1d</size>
</object>
</object>
</object>