X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/538a0c0de22cb3ae125038e69b4de095f081147b..52cd0643658c92b11c85e977b8cefd059df509b0:/wxPython/wx/tools/XRCed/params.py diff --git a/wxPython/wx/tools/XRCed/params.py b/wxPython/wx/tools/XRCed/params.py index d08cba4aec..7142449f84 100644 --- a/wxPython/wx/tools/XRCed/params.py +++ b/wxPython/wx/tools/XRCed/params.py @@ -25,7 +25,10 @@ genericExStyles = [ 'wxWS_EX_PROCESS_UI_UPDATES' ] -buttonSize = (35,-1) # in dialog units, transformed to pixels in panel ctor +# Global var initialized in Panel.__init__ for button size in screen pixels +buttonSize = None +# Button size in dialog units +buttonSizeD = (35,-1) # Class that can properly disable children class PPanel(wx.Panel): @@ -33,6 +36,7 @@ class PPanel(wx.Panel): wx.Panel.__init__(self, parent, -1, name=name) self.modified = self.freeze = False def Enable(self, value): + self.enabled = value # Something strange is going on with enable so we make sure... for w in self.GetChildren(): w.Enable(value) @@ -56,8 +60,7 @@ class ParamBinaryOr(PPanel): sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) self.button = wx.Button(self, self.ID_BUTTON_CHOICES, 'Edit...', size=buttonSize) sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) wx.EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoices) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def GetValue(self): @@ -190,8 +193,7 @@ class ParamColour(PPanel): sizer.Add(self.text, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2) self.button = wx.Panel(self, self.ID_BUTTON, wx.DefaultPosition, wx.Size(20, 20)) sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) self.textModified = False wx.EVT_PAINT(self.button, self.OnPaintButton) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) @@ -251,8 +253,7 @@ class ParamFont(PPanel): sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) self.button = wx.Button(self, self.ID_BUTTON_SELECT, 'Select...', size=buttonSize) sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) self.textModified = False wx.EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) @@ -344,8 +345,7 @@ class ParamInt(PPanel): self.spin = wx.SpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) self.spin.SetRange(-2147483648, 2147483647) # min/max integers sizer.Add(self.spin) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) wx.EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) def GetValue(self): return str(self.spin.GetValue()) @@ -364,8 +364,7 @@ class ParamIntNN(PPanel): self.spin = wx.SpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) self.spin.SetRange(0, 10000) # min/max integers sizer.Add(self.spin) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) wx.EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) def GetValue(self): return str(self.spin.GetValue()) @@ -382,14 +381,13 @@ class ParamUnit(PPanel): self.ID_TEXT_CTRL = wx.NewId() self.ID_SPIN_BUTTON = wx.NewId() sizer = wx.BoxSizer(wx.HORIZONTAL) - self.spin = wx.SpinButton(self, self.ID_SPIN_BUTTON, style = wx.SP_VERTICAL) + self.spin = wx.SpinButton(self, self.ID_SPIN_BUTTON, style = wx.SP_VERTICAL, size=(-1,0)) textW = 60 - self.spin.GetSize()[0] self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=(textW,-1)) self.spin.SetRange(-10000, 10000) sizer.Add(self.text, 0, wx.EXPAND) sizer.Add(self.spin, 0, wx.EXPAND) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) self.spin.Bind(wx.EVT_SPIN_UP, self.OnSpinUp) self.spin.Bind(wx.EVT_SPIN_DOWN, self.OnSpinDown) def GetValue(self): @@ -434,7 +432,6 @@ class ParamMultilineText(PPanel): sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) self.button = wx.Button(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) - self.SetAutoLayout(True) self.SetSizerAndFit(sizer) wx.EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) @@ -454,17 +451,16 @@ class ParamMultilineText(PPanel): dlg.Destroy() class ParamText(PPanel): - def __init__(self, parent, name, textWidth=-1): + def __init__(self, parent, name, textWidth=-1, style=0): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wx.NewId() # We use sizer even here to have the same size of text control sizer = wx.BoxSizer() - self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(textWidth,-1)) + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(textWidth,-1), style=style) if textWidth == -1: option = 1 else: option = 0 sizer.Add(self.text, option, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def GetValue(self): return self.text.GetValue() @@ -489,6 +485,11 @@ class ParamEncoding(ParamText): def __init__(self, parent, name): ParamText.__init__(self, parent, name, 100) +class ParamComment(ParamText): + def __init__(self, parent, name): + ParamText.__init__(self, parent, name, 330 + buttonSize[0], + style=wx.TE_PROCESS_ENTER) + class ContentDialog(wx.Dialog): def __init__(self, parent, value): # Load from resource @@ -607,8 +608,7 @@ class ParamContent(PPanel): sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) self.button = wx.Button(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) self.textModified = False wx.EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) @@ -747,8 +747,7 @@ class RadioBox(PPanel): button = wx.RadioButton(self, -1, i, size=(-1,buttonSize[1]), name=i) topSizer.Add(button, 0, wx.RIGHT, 5) wx.EVT_RADIOBUTTON(self, button.GetId(), self.OnRadioChoice) - self.SetAutoLayout(True) - self.SetSizerAndFit(topSizer) + self.SetSizer(topSizer) def SetStringSelection(self, value): self.freeze = True for i in self.choices: @@ -806,8 +805,7 @@ class ParamFile(PPanel): sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) self.button = wx.Button(self, self.ID_BUTTON_BROWSE, 'Browse...',size=buttonSize) sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) - self.SetAutoLayout(True) - self.SetSizerAndFit(sizer) + self.SetSizer(sizer) self.textModified = False wx.EVT_BUTTON(self, self.ID_BUTTON_BROWSE, self.OnButtonBrowse) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) @@ -934,5 +932,6 @@ paramDict = { 'fg': ParamColour, 'bg': ParamColour, 'font': ParamFont, 'enabled': ParamBool, 'focused': ParamBool, 'hidden': ParamBool, 'tooltip': ParamText, 'bitmap': ParamBitmap, 'icon': ParamBitmap, - 'encoding': ParamEncoding, 'borders': ParamUnit + 'encoding': ParamEncoding, 'borders': ParamUnit, + 'comment': ParamComment }