]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/tools/XRCed/params.py
changed hand cursor to look like Windows' hand cursor
[wxWidgets.git] / wxPython / wx / tools / XRCed / params.py
index d8c4b56f8bca74af72641242c81bc685299137ac..7a1b4b75a99ac7b77068662853135a556ea5ee60 100644 (file)
@@ -22,6 +22,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 +44,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 +61,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,21 +77,9 @@ 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.Number()):
+            for i in range(listBox.GetCount()):
                 if listBox.IsChecked(i):
                     value.append(self.values[i])
             # Add ignored flags
@@ -105,8 +94,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'}
@@ -137,7 +128,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)
@@ -197,7 +187,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)
@@ -291,7 +280,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 +303,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 +337,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 +359,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 +373,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
@@ -439,17 +411,17 @@ class ContentDialog(wxDialog):
         g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT')
         self.this = pre.this
        self._setOORInfo(self)
-        self.list = self.FindWindowByName('LIST')
+        self.list = XRCCTRL(self, 'LIST')
         # Set list items
         for v in value:
             self.list.Append(v)
         self.SetAutoLayout(True)
         self.GetSizer().Fit(self)
         # Callbacks
-        self.ID_BUTTON_APPEND = XMLID('BUTTON_APPEND')
-        self.ID_BUTTON_REMOVE = XMLID('BUTTON_REMOVE')
-        self.ID_BUTTON_UP = XMLID('BUTTON_UP')
-        self.ID_BUTTON_DOWN = XMLID('BUTTON_DOWN')
+        self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND')
+        self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
+        self.ID_BUTTON_UP = XRCID('BUTTON_UP')
+        self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN')
         EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
         EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
         EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
@@ -481,7 +453,7 @@ class ContentDialog(wxDialog):
             evt.Enable(self.list.GetSelection() > 0)
         elif evt.GetId() == self.ID_BUTTON_DOWN:
             evt.Enable(self.list.GetSelection() != -1 and \
-                       self.list.GetSelection() < self.list.Number() - 1)
+                       self.list.GetSelection() < self.list.GetCount() - 1)
 
 class ContentCheckListDialog(wxDialog):
     def __init__(self, parent, value):
@@ -489,7 +461,7 @@ class ContentCheckListDialog(wxDialog):
         g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECK_LIST')
         self.this = pre.this
        self._setOORInfo(self)
-        self.list = self.FindWindowByName('CHECK_LIST')
+        self.list = XRCCTRL(self, 'CHECK_LIST')
         # Set list items
         i = 0
         for v,ch in value:
@@ -499,10 +471,10 @@ class ContentCheckListDialog(wxDialog):
         self.SetAutoLayout(True)
         self.GetSizer().Fit(self)
         # Callbacks
-        self.ID_BUTTON_APPEND = XMLID('BUTTON_APPEND')
-        self.ID_BUTTON_REMOVE = XMLID('BUTTON_REMOVE')
-        self.ID_BUTTON_UP = XMLID('BUTTON_UP')
-        self.ID_BUTTON_DOWN = XMLID('BUTTON_DOWN')
+        self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND')
+        self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
+        self.ID_BUTTON_UP = XRCID('BUTTON_UP')
+        self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN')
         EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck)
         EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
         EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
@@ -540,14 +512,13 @@ class ContentCheckListDialog(wxDialog):
             evt.Enable(self.list.GetSelection() > 0)
         elif evt.GetId() == self.ID_BUTTON_DOWN:
             evt.Enable(self.list.GetSelection() != -1 and \
-                       self.list.GetSelection() < self.list.Number() - 1)
+                       self.list.GetSelection() < self.list.GetCount() - 1)
 
 class ParamContent(PPanel):
     def __init__(self, parent, name):
         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)
@@ -586,7 +557,7 @@ class ParamContent(PPanel):
         dlg = ContentDialog(self, self.value)
         if dlg.ShowModal() == wxID_OK:
             value = []
-            for i in range(dlg.list.Number()):
+            for i in range(dlg.list.GetCount()):
                 value.append(dlg.list.GetString(i))
             # Add ignored flags
             self.SetValue(value)
@@ -608,7 +579,7 @@ class ParamContentCheckList(ParamContent):
         dlg = ContentCheckListDialog(self, self.value)
         if dlg.ShowModal() == wxID_OK:
             value = []
-            for i in range(dlg.list.Number()):
+            for i in range(dlg.list.GetCount()):
                 value.append((dlg.list.GetString(i), dlg.list.IsChecked(i)))
             # Add ignored flags
             self.SetValue(value)
@@ -622,7 +593,7 @@ class IntListDialog(wxDialog):
         g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_INTLIST')
         self.this = pre.this
        self._setOORInfo(self)
-        self.list = self.FindWindowByName('LIST')
+        self.list = XRCCTRL(self, 'LIST')
         # Set list items
         value.sort()
         for v in value:
@@ -633,8 +604,8 @@ class IntListDialog(wxDialog):
         self.SetAutoLayout(True)
         self.GetSizer().Fit(self)
         # Callbacks
-        self.ID_BUTTON_ADD = XMLID('BUTTON_ADD')
-        self.ID_BUTTON_REMOVE = XMLID('BUTTON_REMOVE')
+        self.ID_BUTTON_ADD = XRCID('BUTTON_ADD')
+        self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
         EVT_BUTTON(self, self.ID_BUTTON_ADD, self.OnButtonAppend)
         EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
         EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
@@ -649,7 +620,7 @@ class IntListDialog(wxDialog):
             if i == -1:                 # ignore non-unique
                 # Find place to insert
                 found = False
-                for i in range(self.list.Number()):
+                for i in range(self.list.GetCount()):
                     if int(self.list.GetString(i)) > v:
                         found = True
                         break
@@ -677,7 +648,7 @@ class ParamIntList(ParamContent):
         dlg = IntListDialog(self, self.value)
         if dlg.ShowModal() == wxID_OK:
             value = []
-            for i in range(dlg.list.Number()):
+            for i in range(dlg.list.GetCount()):
                 value.append(int(dlg.list.GetString(i)))
             # Add ignored flags
             self.SetValue(value)
@@ -690,7 +661,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 +688,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,7 +699,7 @@ 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):
@@ -741,7 +711,6 @@ class ParamFile(PPanel):
         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)
@@ -789,23 +758,28 @@ class ParamBitmap(PPanel):
         g.frame.res.LoadOnPanel(pre, parent, 'PANEL_BITMAP')
         self.this = pre.this
        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))
         self.GetSizer().Fit(self)
-        EVT_RADIOBUTTON(self, XMLID('RADIO_STD'), self.OnRadioStd)
-        EVT_RADIOBUTTON(self, XMLID('RADIO_FILE'), self.OnRadioFile)
-        EVT_BUTTON(self, XMLID('BUTTON_BROWSE'), self.OnButtonBrowse)
-        EVT_COMBOBOX(self, XMLID('COMBO_STD'), self.OnCombo)
-        EVT_TEXT(self, XMLID('COMBO_STD'), self.OnChange)
-        EVT_TEXT(self, XMLID('TEXT_FILE'), self.OnChange)
+        EVT_RADIOBUTTON(self, XRCID('RADIO_STD'), self.OnRadioStd)
+        EVT_RADIOBUTTON(self, XRCID('RADIO_FILE'), self.OnRadioFile)
+        EVT_BUTTON(self, XRCID('BUTTON_BROWSE'), self.OnButtonBrowse)
+        EVT_COMBOBOX(self, XRCID('COMBO_STD'), self.OnCombo)
+        EVT_TEXT(self, XRCID('COMBO_STD'), self.OnChange)
+        EVT_TEXT(self, XRCID('TEXT_FILE'), self.OnChange)
     def OnRadioStd(self, evt):
         self.SetModified()
         self.SetValue(['wxART_MISSING_IMAGE',''])
@@ -879,5 +853,3 @@ paramDict = {
     'tooltip': ParamText, 'bitmap': ParamBitmap, 'icon': ParamBitmap,
     'encoding': ParamEncoding
     }
-
-