X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/31f043529189a36c11b4b2df8757f4712a84f45d..3d2d9036037d9ee51f47d878c3dcef4af4a6ef41:/wxPython/wx/tools/XRCed/params.py?ds=sidebyside diff --git a/wxPython/wx/tools/XRCed/params.py b/wxPython/wx/tools/XRCed/params.py index dfb34de69e..2c3e02d278 100644 --- a/wxPython/wx/tools/XRCed/params.py +++ b/wxPython/wx/tools/XRCed/params.py @@ -10,11 +10,25 @@ from globals import * from types import * from wxPython.xrc import * -genericStyles = ['wxSIMPLE_BORDER', 'wxDOUBLE_BORDER', - 'wxSUNKEN_BORDER', 'wxRAISED_BORDER', - 'wxSTATIC_BORDER', 'wxNO_BORDER', - 'wxTRANSPARENT_WINDOW', 'wxWANTS_CHARS', - 'wxNO_FULL_REPAINT_ON_RESIZE'] +genericStyles = [ + 'wxSIMPLE_BORDER', 'wxDOUBLE_BORDER', 'wxSUNKEN_BORDER', + 'wxRAISED_BORDER', 'wxSTATIC_BORDER', 'wxNO_BORDER', + 'wxTRANSPARENT_WINDOW', 'wxTAB_TRAVERSAL', + 'wxWANTS_CHARS', + 'wxNO_FULL_REPAINT_ON_RESIZE', + 'wxVSCROLL', 'wxHSCROLL', 'wxALWAYS_SHOW_SB', + 'wxCLIP_CHILDREN', + 'wxFULL_REPAINT_ON_RESIZE' + ] + +genericExStyles = [ + 'wxWS_EX_VALIDATE_RECURSIVELY', + 'wxWS_EX_BLOCK_EVENTS', + 'wxWS_EX_TRANSIENT', + 'wxFRAME_EX_CONTEXTHELP', + 'wxWS_EX_PROCESS_IDLE', + 'wxWS_EX_PROCESS_UI_UPDATES' + ] buttonSize = (35,-1) # in dialog units, transformed to pixels in panel ctor @@ -22,6 +36,8 @@ buttonSize = (35,-1) # in dialog units, transformed to pixels in panel ctor class PPanel(wxPanel): def __init__(self, parent, name): wxPanel.__init__(self, parent, -1, name=name) + self.SetBackgroundColour(parent.GetBackgroundColour()) + self.SetForegroundColour(parent.GetForegroundColour()) self.modified = self.freeze = False def Enable(self, value): # Something strange is going on with enable so we make sure... @@ -42,7 +58,6 @@ class ParamBinaryOr(PPanel): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_BUTTON_CHOICES = wxNewId() - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) @@ -60,9 +75,9 @@ class ParamBinaryOr(PPanel): self.text.SetValue(value) self.freeze = False def OnButtonChoices(self, evt): - dlg = wxDialog(self, -1, 'Choices') - topSizer = wxBoxSizer(wxVERTICAL) - listBox = wxCheckListBox(dlg, -1, choices=self.values, size=(250,200)) + dlg = g.frame.res.LoadDialog(self, 'DIALOG_CHOICES') + listBox = XRCCTRL(dlg, 'CHECK_LIST') + listBox.InsertItems(self.values, 0) value = map(string.strip, self.text.GetValue().split('|')) if value == ['']: value = [] ignored = [] @@ -76,18 +91,6 @@ class ParamBinaryOr(PPanel): else: print 'WARNING: unknown flag: %s: ignored.' % i ignored.append(i) - topSizer.Add(listBox, 1, wxEXPAND) - sizer = wxBoxSizer() - buttonOk = wxButton(dlg, wxID_OK, 'OK') - buttonOk.SetDefault() - sizer.Add(buttonOk, 0, wxRIGHT, 10) - sizer.Add((0, 0), 1) - sizer.Add(wxButton(dlg, wxID_CANCEL, 'Cancel')) - topSizer.Add(sizer, 0, wxALL | wxEXPAND, 10) - dlg.SetAutoLayout(True) - dlg.SetSizer(topSizer) - topSizer.Fit(dlg) - dlg.Center() if dlg.ShowModal() == wxID_OK: value = [] for i in range(listBox.GetCount()): @@ -105,8 +108,10 @@ class ParamBinaryOr(PPanel): class ParamFlag(ParamBinaryOr): values = ['wxTOP', 'wxBOTTOM', 'wxLEFT', 'wxRIGHT', 'wxALL', 'wxEXPAND', 'wxGROW', 'wxSHAPED', 'wxALIGN_CENTRE', 'wxALIGN_RIGHT', + 'wxFIXED_MINSIZE', 'wxALIGN_BOTTOM', 'wxALIGN_CENTRE_VERTICAL', - 'wxALIGN_CENTRE_HORIZONTAL'] + 'wxALIGN_CENTRE_HORIZONTAL', + ] equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE', 'wxALIGN_CENTER_VERTICAL': 'wxALIGN_CENTRE_VERTICAL', 'wxALIGN_CENTER_HORIZONTAL': 'wxALIGN_CENTRE_HORIZONTAL'} @@ -127,7 +132,7 @@ class ParamNonGenericStyle(ParamBinaryOr): class ParamExStyle(ParamBinaryOr): def __init__(self, parent, name): if g.currentXXX: - self.values = g.currentXXX.exStyles # constant at the moment + self.values = g.currentXXX.exStyles + genericExStyles else: self.values = [] ParamBinaryOr.__init__(self, parent, name) @@ -137,7 +142,6 @@ class ParamColour(PPanel): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_BUTTON = wxNewId() - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(65,-1)) sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) @@ -166,7 +170,7 @@ class ParamColour(PPanel): if self.IsEnabled(): dc.SetPen(wxBLACK_PEN) else: dc.SetPen(wxGREY_PEN) size = self.button.GetSize() - dc.DrawRectangle((0, 0), size) + dc.DrawRectangle(0, 0, size.width, size.height) def OnLeftDown(self, evt): data = wxColourData() data.SetColour(self.GetValue()) @@ -197,7 +201,6 @@ class ParamFont(PPanel): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_BUTTON_SELECT = wxNewId() - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(200,-1)) sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) @@ -247,20 +250,21 @@ class ParamFont(PPanel): error = False try: try: size = int(self.value[0]) - except ValueError: error = True + except ValueError: error = True; wxLogError('Invalid size specification') try: family = fontFamiliesXml2wx[self.value[1]] - except KeyError: error = True + except KeyError: error = True; wxLogError('Invalid family specification') try: style = fontStylesXml2wx[self.value[2]] - except KeyError: error = True + except KeyError: error = True; wxLogError('Invalid style specification') try: weight = fontWeightsXml2wx[self.value[3]] - except KeyError: error = True - try: underlined = int(self.value[4]) - except ValueError: error = True + except KeyError: error = True; wxLogError('Invalid weight specification') + try: underlined = bool(self.value[4]) + except ValueError: error = True; wxLogError('Invalid underlined flag specification') face = self.value[5] - mapper = wxFontMapper() - if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6]) except IndexError: error = True + mapper = wxFontMapper() + if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6]) + if error: wxLogError('Invalid font specification') if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM font = wxFont(size, family, style, weight, underlined, face, enc) @@ -269,13 +273,18 @@ class ParamFont(PPanel): dlg = wxFontDialog(self, data) if dlg.ShowModal() == wxID_OK: font = dlg.GetFontData().GetChosenFont() + print font.GetEncoding() + if font.GetEncoding() == wxFONTENCODING_SYSTEM: + encName = '' + else: + encName = wxFontMapper_GetEncodingName(font.GetEncoding()).encode() value = [str(font.GetPointSize()), fontFamiliesWx2Xml.get(font.GetFamily(), "default"), fontStylesWx2Xml.get(font.GetStyle(), "normal"), fontWeightsWx2Xml.get(font.GetWeight(), "normal"), - str(font.GetUnderlined()), + str(int(font.GetUnderlined())), font.GetFaceName().encode(), - wxFontMapper_GetEncodingName(font.GetEncoding()).encode() + encName ] # Add ignored flags self.SetValue(value) @@ -291,7 +300,6 @@ class ParamInt(PPanel): self.ID_SPIN_CTRL = wxNewId() sizer = wxBoxSizer() self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(50,-1)) - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer.Add(self.spin) self.SetAutoLayout(True) self.SetSizer(sizer) @@ -315,7 +323,6 @@ class ParamUnit(PPanel): self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(35,-1)) self.spin = wxSpinButton(self, self.ID_SPIN_BUTTON, style = wxSP_VERTICAL, size=(-1,1)) self.spin.SetRange(-10000, 10000) - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer.Add(self.text, 0, wxEXPAND | wxRIGHT, 2) sizer.Add(self.spin, 0, wxEXPAND) self.SetAutoLayout(True) @@ -350,28 +357,12 @@ class ParamUnit(PPanel): def OnSpinDown(self, evt): self.Change(-1) -# Dialog for editing multi-line text -class TextDialog(wxDialog): - def __init__(self, parent, value): - pre = wxPreDialog() - g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_TEXT') - self.this = pre.this - self._setOORInfo(self) - self.text = self.FindWindowByName('TEXT') - self.text.SetValue(value) - self.SetAutoLayout(True) - self.SetSize((300,200)) - def GetValue(self): - return self.text.GetValue() - class ParamMultilineText(PPanel): def __init__(self, parent, name, textWidth=-1): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_BUTTON_EDIT = wxNewId() - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer = wxBoxSizer() - self.SetBackgroundColour(g.panel.GetBackgroundColour()) self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) @@ -388,9 +379,11 @@ class ParamMultilineText(PPanel): self.text.SetValue(value) self.freeze = False # disable other handlers def OnButtonEdit(self, evt): - dlg = TextDialog(self, self.text.GetValue()) + dlg = g.frame.res.LoadDialog(self, 'DIALOG_TEXT') + textCtrl = XRCCTRL(dlg, 'TEXT') + textCtrl.SetValue(self.text.GetValue()) if dlg.ShowModal() == wxID_OK: - self.text.SetValue(dlg.GetValue()) + self.text.SetValue(textCtrl.GetValue()) self.SetModified() dlg.Destroy() @@ -400,7 +393,6 @@ class ParamText(PPanel): 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)) if textWidth == -1: option = 1 else: option = 0 @@ -435,11 +427,11 @@ class ParamEncoding(ParamText): class ContentDialog(wxDialog): def __init__(self, parent, value): # Load from resource - pre = wxPreDialog() + pre = wxPreDialog() g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT') self.this = pre.this - self._setOORInfo(self) - self.list = self.FindWindowByName('LIST') + self._setOORInfo(self) + self.list = XRCCTRL(self, 'LIST') # Set list items for v in value: self.list.Append(v) @@ -485,11 +477,11 @@ class ContentDialog(wxDialog): class ContentCheckListDialog(wxDialog): def __init__(self, parent, value): - pre = wxPreDialog() + pre = wxPreDialog() g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECK_LIST') self.this = pre.this - self._setOORInfo(self) - self.list = self.FindWindowByName('CHECK_LIST') + self._setOORInfo(self) + self.list = XRCCTRL(self, 'CHECK_LIST') # Set list items i = 0 for v,ch in value: @@ -547,7 +539,6 @@ class ParamContent(PPanel): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_BUTTON_EDIT = wxNewId() - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) @@ -618,11 +609,11 @@ class ParamContentCheckList(ParamContent): class IntListDialog(wxDialog): def __init__(self, parent, value): - pre = wxPreDialog() + pre = wxPreDialog() g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_INTLIST') self.this = pre.this - self._setOORInfo(self) - self.list = self.FindWindowByName('LIST') + self._setOORInfo(self) + self.list = XRCCTRL(self, 'LIST') # Set list items value.sort() for v in value: @@ -690,7 +681,6 @@ class RadioBox(PPanel): def __init__(self, parent, id, choices, pos=wxDefaultPosition, name='radiobox'): PPanel.__init__(self, parent, name) - self.SetBackgroundColour(g.panel.GetBackgroundColour()) self.choices = choices topSizer = wxBoxSizer() for i in choices: @@ -718,7 +708,7 @@ class ParamBool(RadioBox): values = {'yes': '1', 'no': '0'} seulav = {'1': 'yes', '0': 'no'} def __init__(self, parent, name): - RadioBox.__init__(self, parent, -1, choices = self.values.keys(), name=name) + RadioBox.__init__(self, parent, -1, choices=self.values.keys(), name=name) def GetValue(self): return self.values[self.GetStringSelection()] def SetValue(self, value): @@ -729,19 +719,29 @@ class ParamOrient(RadioBox): values = {'horizontal': 'wxHORIZONTAL', 'vertical': 'wxVERTICAL'} seulav = {'wxHORIZONTAL': 'horizontal', 'wxVERTICAL': 'vertical'} def __init__(self, parent, name): - RadioBox.__init__(self, parent, -1, choices = self.values.keys(), name=name) + RadioBox.__init__(self, parent, -1, choices=self.values.keys(), name=name) def GetValue(self): return self.values[self.GetStringSelection()] def SetValue(self, value): if not value: value = 'wxHORIZONTAL' self.SetStringSelection(self.seulav[value]) +class ParamOrientation(RadioBox): + values = {'horizontal': 'horizontal', 'vertical': 'vertical'} + seulav = {'horizontal': 'horizontal', 'vertical': 'vertical'} + def __init__(self, parent, name): + RadioBox.__init__(self, parent, -1, choices=self.values.keys(), name=name) + def GetValue(self): + return self.values[self.GetStringSelection()] + def SetValue(self, value): + if not value: value = 'vertical' + self.SetStringSelection(self.seulav[value]) + class ParamFile(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_BUTTON_BROWSE = wxNewId() - self.SetBackgroundColour(g.panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) @@ -785,17 +785,22 @@ class ParamFile(PPanel): class ParamBitmap(PPanel): def __init__(self, parent, name): - pre = wxPrePanel() + pre = wxPrePanel() g.frame.res.LoadOnPanel(pre, parent, 'PANEL_BITMAP') self.this = pre.this - self._setOORInfo(self) + self._setOORInfo(self) + self.SetBackgroundColour(parent.GetBackgroundColour()) + self.SetForegroundColour(parent.GetForegroundColour()) self.modified = self.freeze = False - self.SetBackgroundColour(g.panel.GetBackgroundColour()) - self.radio_std = self.FindWindowByName('RADIO_STD') - self.radio_file = self.FindWindowByName('RADIO_FILE') - self.combo = self.FindWindowByName('COMBO_STD') - self.text = self.FindWindowByName('TEXT_FILE') - self.button = self.FindWindowByName('BUTTON_BROWSE') + self.radio_std = XRCCTRL(self, 'RADIO_STD') + self.radio_std.SetBackgroundColour(parent.GetBackgroundColour()) + self.radio_std.SetForegroundColour(parent.GetForegroundColour()) + self.radio_file = XRCCTRL(self, 'RADIO_FILE') + self.radio_file.SetBackgroundColour(parent.GetBackgroundColour()) + self.radio_file.SetForegroundColour(parent.GetForegroundColour()) + self.combo = XRCCTRL(self, 'COMBO_STD') + self.text = XRCCTRL(self, 'TEXT_FILE') + self.button = XRCCTRL(self, 'BUTTON_BROWSE') self.textModified = False self.SetAutoLayout(True) self.GetSizer().SetMinSize((260, -1)) @@ -867,6 +872,7 @@ paramDict = { 'flag': ParamFlag, 'style': ParamStyle, 'exstyle': ParamExStyle, 'pos': ParamPosSize, 'size': ParamPosSize, + 'cellpos': ParamPosSize, 'cellspan': ParamPosSize, 'border': ParamUnit, 'cols': ParamInt, 'rows': ParamInt, 'vgap': ParamUnit, 'hgap': ParamUnit, 'checkable': ParamBool, 'checked': ParamBool, 'radio': ParamBool, @@ -879,5 +885,3 @@ paramDict = { 'tooltip': ParamText, 'bitmap': ParamBitmap, 'icon': ParamBitmap, 'encoding': ParamEncoding } - -