/[thuban]/trunk/thuban/Thuban/UI/classifier.py
ViewVC logotype

Diff of /trunk/thuban/Thuban/UI/classifier.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 496 by jonathan, Mon Mar 10 10:54:50 2003 UTC revision 560 by jonathan, Wed Mar 26 11:05:47 2003 UTC
# Line 70  class ClassGrid(wxGrid): Line 70  class ClassGrid(wxGrid):
70    
71          #wxGrid.__init__(self, parent, ID_CLASS_TABLE, size = (340, 160))          #wxGrid.__init__(self, parent, ID_CLASS_TABLE, size = (340, 160))
72          wxGrid.__init__(self, parent, ID_CLASS_TABLE)          wxGrid.__init__(self, parent, ID_CLASS_TABLE)
73          #self.SetTable(ClassTable(fieldData, layer.ShapeType(), self), true)          #self.SetTable(ClassTable(fieldData, layer.ShapeType(), self), True)
74    
75          EVT_GRID_CELL_LEFT_DCLICK(self, self._OnCellDClick)          EVT_GRID_CELL_LEFT_DCLICK(self, self._OnCellDClick)
76          EVT_GRID_RANGE_SELECT(self, self._OnSelectedRange)          EVT_GRID_RANGE_SELECT(self, self._OnSelectedRange)
# Line 85  class ClassGrid(wxGrid): Line 85  class ClassGrid(wxGrid):
85          self.shapeType = shapeType          self.shapeType = shapeType
86          table = self.GetTable()          table = self.GetTable()
87          if table is None:          if table is None:
88              self.SetTable(ClassTable(clazz, self.shapeType, self), true)              w = self.GetDefaultColSize() * 3 + self.GetDefaultRowLabelSize()
89                h = self.GetDefaultRowSize() * 4 + self.GetDefaultColLabelSize()
90                self.SetDimensions(-1, -1, w, h)
91                self.SetSizeHints(w, h, -1, -1)
92                self.SetTable(ClassTable(clazz, self.shapeType, self), True)
93          else:          else:
94              table.Reset(clazz, self.shapeType)              table.Reset(clazz, self.shapeType)
95    
# Line 279  class ClassTable(wxPyGridTableBase): Line 283  class ClassTable(wxPyGridTableBase):
283    
284          self.__NotifyRowChanges(old_len, len(self.tdata))          self.__NotifyRowChanges(old_len, len(self.tdata))
285    
         view = self.GetView()  
         w = view.GetDefaultColSize() * 3 + view.GetDefaultRowLabelSize()  
         h = view.GetDefaultRowSize() * 4 + view.GetDefaultColLabelSize()  
         view.SetDimensions(-1, -1, w, h)  
         view.SetSizeHints(w, h, -1, -1)  
286                            
287          self.GetView().EndBatch()          self.GetView().EndBatch()
288    
# Line 297  class ClassTable(wxPyGridTableBase): Line 296  class ClassTable(wxPyGridTableBase):
296                          wxGRIDTABLE_NOTIFY_ROWS_APPENDED,                          wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
297                          newRows - curRows)    # how many                          newRows - curRows)    # how many
298              self.GetView().ProcessTableMessage(msg)              self.GetView().ProcessTableMessage(msg)
299                self.GetView().FitInside()
300          elif newRows < curRows:          elif newRows < curRows:
301              msg = wxGridTableMessage(self,              msg = wxGridTableMessage(self,
302                          wxGRIDTABLE_NOTIFY_ROWS_DELETED,                          wxGRIDTABLE_NOTIFY_ROWS_DELETED,
303                          curRows - newRows,    # position                          curRows - newRows,    # position
304                          curRows - newRows)    # how many                          curRows - newRows)    # how many
305              self.GetView().ProcessTableMessage(msg)              self.GetView().ProcessTableMessage(msg)
306                self.GetView().FitInside()
307    
308      def __SetRow(self, row, group):      def __SetRow(self, row, group):
309          """Set a row's data to that of the group.          """Set a row's data to that of the group.
# Line 579  class ClassTable(wxPyGridTableBase): Line 580  class ClassTable(wxPyGridTableBase):
580    
581    
582  class Classifier(NonModalDialog):  class Classifier(NonModalDialog):
583        
584      def __init__(self, parent, interactor, name, layer):      def __init__(self, parent, name, layer):
585          NonModalDialog.__init__(self, parent, interactor, name,          NonModalDialog.__init__(self, parent, name,
586                                  _("Classifier: %s") % layer.Title())                                  _("Classifier: %s") % layer.Title())
587    
588            panel = wxPanel(self, -1, size=(100, 100))
589    
590          self.layer = layer          self.layer = layer
591    
592          self.originalClass = self.layer.GetClassification()          self.originalClass = self.layer.GetClassification()
# Line 591  class Classifier(NonModalDialog): Line 594  class Classifier(NonModalDialog):
594          fieldType = self.originalClass.GetFieldType()          fieldType = self.originalClass.GetFieldType()
595    
596          topBox = wxBoxSizer(wxVERTICAL)          topBox = wxBoxSizer(wxVERTICAL)
597            panelBox = wxBoxSizer(wxVERTICAL)
598    
599          #topBox.Add(wxStaticText(self, -1, _("Layer: %s") % layer.Title()),          #panelBox.Add(wxStaticText(panel, -1, _("Layer: %s") % layer.Title()),
600              #0, wxALIGN_LEFT | wxALL, 4)              #0, wxALIGN_LEFT | wxALL, 4)
601          topBox.Add(wxStaticText(self, -1,          panelBox.Add(wxStaticText(panel, -1,
602                                  _("Layer Type: %s") % layer.ShapeType()),                                  _("Layer Type: %s") % layer.ShapeType()),
603              0, wxALIGN_LEFT | wxALL, 4)              0, wxALIGN_LEFT | wxALL, 4)
604    
# Line 602  class Classifier(NonModalDialog): Line 606  class Classifier(NonModalDialog):
606          #          #
607          # make field combo box          # make field combo box
608          #          #
609          self.fields = wxComboBox(self, ID_PROPERTY_SELECT, "",          self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "",
610                                       style = wxCB_READONLY)                                       style = wxCB_READONLY)
611    
612          self.num_cols = layer.table.field_count()          self.num_cols = layer.table.field_count()
# Line 624  class Classifier(NonModalDialog): Line 628  class Classifier(NonModalDialog):
628                  self.fields.SetClientData(i + 1, None)                  self.fields.SetClientData(i + 1, None)
629    
630    
631          #          ###########
         #  
         #  
   
         self.fieldTypeText = wxStaticText(self, -1, "")  
         self.__SetFieldTypeText(self.__cur_field)  
632    
633          topBox.Add(self.fieldTypeText, 0, wxALIGN_LEFT | wxALL, 4)          self.fieldTypeText = wxStaticText(panel, -1, "")
634          #self.fieldTypeText.SetLabel("asdfadsfs")          panelBox.Add(self.fieldTypeText, 0,
635                         wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4)
636    
637          propertyBox = wxBoxSizer(wxHORIZONTAL)          propertyBox = wxBoxSizer(wxHORIZONTAL)
638          propertyBox.Add(wxStaticText(self, -1, _("Field: ")),          propertyBox.Add(wxStaticText(panel, -1, _("Field: ")),
639              0, wxALIGN_CENTER | wxALL, 4)              0, wxALIGN_LEFT | wxALL, 4)
640          propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4)          propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4)
641          EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect)          EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect)
642    
643          topBox.Add(propertyBox, 0, wxGROW, 4)          panelBox.Add(propertyBox, 0, wxGROW, 4)
644    
645            ###########
646          #          #
647          # Classification data table          # Classification data table
648          #          #
649    
650          controlBox = wxBoxSizer(wxHORIZONTAL)          controlBox = wxBoxSizer(wxHORIZONTAL)
651    
652          self.classGrid = ClassGrid(self)          self.classGrid = ClassGrid(panel)
653          self.__SetGridTable(self.__cur_field)          self.__SetGridTable(self.__cur_field)
654    
655          controlBox.Add(self.classGrid, 1, wxGROW, 0)          controlBox.Add(self.classGrid, 1, wxGROW, 0)
656    
657          controlButtonBox = wxBoxSizer(wxVERTICAL)          ###########
   
658          #          #
659          # Control buttons:          # Control buttons:
660          #          #
661          self.controlButtons = []          self.controlButtons = []
662    
663          button = wxButton(self, ID_CLASSIFY_ADD, _("Add"))          controlButtonBox = wxBoxSizer(wxVERTICAL)
664    
665            button = wxButton(panel, ID_CLASSIFY_ADD, _("Add"))
666          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
667          self.controlButtons.append(button)          self.controlButtons.append(button)
668    
669          #button = wxButton(self, ID_CLASSIFY_GENRANGE, _("Generate Ranges"))          #button = wxButton(panel, ID_CLASSIFY_GENRANGE, _("Generate Ranges"))
670          #controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          #controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
671          #self.controlButtons.append(button)          #self.controlButtons.append(button)
672    
673          button = wxButton(self, ID_CLASSIFY_MOVEUP, _("Move Up"))          button = wxButton(panel, ID_CLASSIFY_MOVEUP, _("Move Up"))
674          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
675          self.controlButtons.append(button)          self.controlButtons.append(button)
676    
677          button = wxButton(self, ID_CLASSIFY_MOVEDOWN, _("Move Down"))          button = wxButton(panel, ID_CLASSIFY_MOVEDOWN, _("Move Down"))
678          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
679          self.controlButtons.append(button)          self.controlButtons.append(button)
680    
681          controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)          controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)
682    
683          button = wxButton(self, ID_CLASSIFY_REMOVE, _("Remove"))          button = wxButton(panel, ID_CLASSIFY_REMOVE, _("Remove"))
684          controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)
685          self.controlButtons.append(button)          self.controlButtons.append(button)
686    
687          controlBox.Add(controlButtonBox, 0, wxGROW, 10)          controlBox.Add(controlButtonBox, 0, wxGROW, 10)
688          topBox.Add(controlBox, 1, wxGROW, 10)          panelBox.Add(controlBox, 1, wxGROW, 10)
689    
690          EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd)          EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd)
691          EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove)          EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove)
# Line 691  class Classifier(NonModalDialog): Line 693  class Classifier(NonModalDialog):
693          EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp)          EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp)
694          EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown)          EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown)
695    
696            ###########
697    
698          buttonBox = wxBoxSizer(wxHORIZONTAL)          buttonBox = wxBoxSizer(wxHORIZONTAL)
699          buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")),          buttonBox.Add(wxButton(panel, ID_CLASSIFY_OK, _("OK")),
700                        0, wxALL, 4)                        0, wxALL, 4)
701          buttonBox.Add(60, 20, 0, wxALL, 4)          buttonBox.Add(60, 20, 0, wxALL, 4)
702          buttonBox.Add(wxButton(self, ID_CLASSIFY_APPLY, _("Apply")),          buttonBox.Add(wxButton(panel, ID_CLASSIFY_APPLY, _("Apply")),
703                        0, wxALL, 4)                        0, wxALL, 4)
704          buttonBox.Add(60, 20, 0, wxALL, 4)          buttonBox.Add(60, 20, 0, wxALL, 4)
705          buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")),          buttonBox.Add(wxButton(panel, ID_CLASSIFY_CANCEL, _("Cancel")),
706                        0, wxALL, 4)                        0, wxALL, 4)
707          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)          panelBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0)
708    
709          EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK)          EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK)
710          EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply)          EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply)
711          EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel)          EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel)
712    
713            ###########
714    
715          self.fields.SetSelection(self.__cur_field)          self.fields.SetSelection(self.__cur_field)
716          self.__SelectField(self.__cur_field)          self.__SelectField(self.__cur_field)
717    
718          self.SetAutoLayout(true)          panel.SetAutoLayout(True)
719            panel.SetSizer(panelBox)
720            panelBox.SetSizeHints(panel)
721    
722            topBox.Add(panel, 1, wxGROW, 0)
723            panelBox.SetSizeHints(self)
724            self.SetAutoLayout(True)
725          self.SetSizer(topBox)          self.SetSizer(topBox)
         topBox.Fit(self)  
         topBox.SetSizeHints(self)  
726    
727            ######################
728    
729            self.haveApplied = False
730    
731      def __BuildClassification(self, fieldIndex):      def __BuildClassification(self, fieldIndex):
732    
# Line 759  class Classifier(NonModalDialog): Line 772  class Classifier(NonModalDialog):
772    
773    
774    
775      type2string = {None:             "None",      type2string = {None:             _("None"),
776                     FIELDTYPE_STRING: "Text",                     FIELDTYPE_STRING: _("Text"),
777                     FIELDTYPE_INT:    "Integer",                     FIELDTYPE_INT:    _("Integer"),
778                     FIELDTYPE_DOUBLE: "Decimal"}                     FIELDTYPE_DOUBLE: _("Decimal")}
779    
780      def __SetFieldTypeText(self, fieldIndex):      def __SetFieldTypeText(self, fieldIndex):
781          fieldName = self.fields.GetString(fieldIndex)          fieldName = self.fields.GetString(fieldIndex)
# Line 774  class Classifier(NonModalDialog): Line 787  class Classifier(NonModalDialog):
787    
788          self.fieldTypeText.SetLabel(_("Field Type: %s") % text)          self.fieldTypeText.SetLabel(_("Field Type: %s") % text)
789    
790      def __SelectField(self, fieldIndex):      def __SelectField(self, newIndex, oldIndex = -1):
791          clazz = self.__BuildClassification(fieldIndex)  
792          self.fields.SetClientData(fieldIndex, clazz)          assert(oldIndex >= -1)
793    
794          self.__cur_field = self.fields.GetSelection()          if oldIndex != -1:
795          self.__SetGridTable(fieldIndex)              clazz = self.__BuildClassification(oldIndex)
796                self.fields.SetClientData(oldIndex, clazz)
797    
798          enabled = fieldIndex != 0          self.__SetGridTable(newIndex)
799    
800            enabled = newIndex != 0
801    
802          for b in self.controlButtons:          for b in self.controlButtons:
803              b.Enable(enabled)              b.Enable(enabled)
804    
805          self.__SetFieldTypeText(fieldIndex)          self.__SetFieldTypeText(newIndex)
806    
807    
808      def _OnFieldSelect(self, event):      def _OnFieldSelect(self, event):
809          self.__SelectField(self.__cur_field)          index = self.fields.GetSelection()
810            self.__SelectField(index, self.__cur_field)
811            self.__cur_field = index
812    
813      def _OnApply(self, event):      def _OnApply(self, event):
814          """Put the data from the table into a new Classification and hand          """Put the data from the table into a new Classification and hand
# Line 808  class Classifier(NonModalDialog): Line 826  class Classifier(NonModalDialog):
826    
827          self.layer.SetClassification(clazz)          self.layer.SetClassification(clazz)
828    
829            self.haveApplied = True
830    
831      def _OnOK(self, event):      def _OnOK(self, event):
832          self._OnApply(event)          self._OnApply(event)
833          self.OnClose(event)          self.OnClose(event)
834    
835      def _OnCancel(self, event):      def _OnCancel(self, event):
836          """The layer's current classification stays the same."""          """The layer's current classification stays the same."""
837          self.layer.SetClassification(self.originalClass)          if self.haveApplied:
838                self.layer.SetClassification(self.originalClass)
839    
840          self.OnClose(event)          self.OnClose(event)
841    
842      def _OnAdd(self, event):      def _OnAdd(self, event):
# Line 868  class SelectPropertiesDialog(wxDialog): Line 890  class SelectPropertiesDialog(wxDialog):
890    
891      def __init__(self, parent, prop, shapeType):      def __init__(self, parent, prop, shapeType):
892          wxDialog.__init__(self, parent, -1, _("Select Properties"),          wxDialog.__init__(self, parent, -1, _("Select Properties"),
893                            style = wxRESIZE_BORDER)                            style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
894    
895          self.prop = ClassGroupProperties(prop)          self.prop = ClassGroupProperties(prop)
896    
# Line 880  class SelectPropertiesDialog(wxDialog): Line 902  class SelectPropertiesDialog(wxDialog):
902          previewBox = wxBoxSizer(wxVERTICAL)          previewBox = wxBoxSizer(wxVERTICAL)
903          previewBox.Add(wxStaticText(self, -1, _("Preview:")),          previewBox.Add(wxStaticText(self, -1, _("Preview:")),
904              0, wxALIGN_LEFT | wxALL, 4)              0, wxALIGN_LEFT | wxALL, 4)
905          self.previewer = ClassDataPreviewer(None, self.prop, shapeType,          self.previewWin = ClassDataPreviewWindow(None, self.prop, shapeType,
906                                              self, ID_SELPROP_PREVIEW, (40, 40))                                              self, ID_SELPROP_PREVIEW, (40, 40))
907          previewBox.Add(self.previewer, 1, wxGROW, 15)          previewBox.Add(self.previewWin, 1, wxGROW, 15)
908    
909          itemBox.Add(previewBox, 1, wxALIGN_LEFT | wxALL | wxGROW, 0)          itemBox.Add(previewBox, 1, wxALIGN_LEFT | wxALL | wxGROW, 0)
910    
# Line 891  class SelectPropertiesDialog(wxDialog): Line 913  class SelectPropertiesDialog(wxDialog):
913    
914          lineColorBox = wxBoxSizer(wxHORIZONTAL)          lineColorBox = wxBoxSizer(wxHORIZONTAL)
915          lineColorBox.Add(          lineColorBox.Add(
916              wxButton(self, ID_SELPROP_STROKECLR, "Change Line Color"),              wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")),
917              1, wxALL | wxGROW, 4)              1, wxALL | wxGROW, 4)
918          EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor)          EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor)
919    
920          lineColorBox.Add(          lineColorBox.Add(
921              wxButton(self, ID_SELPROP_STROKECLRTRANS, "Transparent"),              wxButton(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")),
922              1, wxALL | wxGROW, 4)              1, wxALL | wxGROW, 4)
923          EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS,          EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS,
924                     self._OnChangeLineColorTrans)                     self._OnChangeLineColorTrans)
# Line 907  class SelectPropertiesDialog(wxDialog): Line 929  class SelectPropertiesDialog(wxDialog):
929          if shapeType != SHAPETYPE_ARC:          if shapeType != SHAPETYPE_ARC:
930              fillColorBox = wxBoxSizer(wxHORIZONTAL)              fillColorBox = wxBoxSizer(wxHORIZONTAL)
931              fillColorBox.Add(              fillColorBox.Add(
932                  wxButton(self, ID_SELPROP_FILLCLR, "Change Fill Color"),                  wxButton(self, ID_SELPROP_FILLCLR, _("Change Fill Color")),
933                  1, wxALL | wxGROW, 4)                  1, wxALL | wxGROW, 4)
934              EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor)              EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor)
935              fillColorBox.Add(              fillColorBox.Add(
936                  wxButton(self, ID_SELPROP_FILLCLRTRANS, "Transparent"),                  wxButton(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")),
937                  1, wxALL | wxGROW, 4)                  1, wxALL | wxGROW, 4)
938              EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS,              EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS,
939                         self._OnChangeFillColorTrans)                         self._OnChangeFillColorTrans)
# Line 947  class SelectPropertiesDialog(wxDialog): Line 969  class SelectPropertiesDialog(wxDialog):
969          EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK)          EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK)
970          EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)          EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)
971                                                                                                                                                                    
972          self.SetAutoLayout(true)          self.SetAutoLayout(True)
973          self.SetSizer(topBox)          self.SetSizer(topBox)
974          topBox.Fit(self)          topBox.Fit(self)
975          topBox.SetSizeHints(self)          topBox.SetSizeHints(self)
# Line 960  class SelectPropertiesDialog(wxDialog): Line 982  class SelectPropertiesDialog(wxDialog):
982    
983      def _OnSpin(self, event):      def _OnSpin(self, event):
984          self.prop.SetLineWidth(self.spinCtrl.GetValue())          self.prop.SetLineWidth(self.spinCtrl.GetValue())
985          self.previewer.Refresh()          self.previewWin.Refresh()
986    
987      def __GetColor(self, cur):      def __GetColor(self, cur):
988          dialog = wxColourDialog(self)          dialog = wxColourDialog(self)
# Line 977  class SelectPropertiesDialog(wxDialog): Line 999  class SelectPropertiesDialog(wxDialog):
999          clr = self.__GetColor(self.prop.GetLineColor())          clr = self.__GetColor(self.prop.GetLineColor())
1000          if clr is not None:          if clr is not None:
1001              self.prop.SetLineColor(clr)              self.prop.SetLineColor(clr)
1002          self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer          self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer
1003    
1004      def _OnChangeLineColorTrans(self, event):      def _OnChangeLineColorTrans(self, event):
1005          self.prop.SetLineColor(Color.None)          self.prop.SetLineColor(Color.None)
1006          self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer          self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer
1007                    
1008      def _OnChangeFillColor(self, event):      def _OnChangeFillColor(self, event):
1009          clr = self.__GetColor(self.prop.GetFill())          clr = self.__GetColor(self.prop.GetFill())
1010          if clr is not None:          if clr is not None:
1011              self.prop.SetFill(clr)              self.prop.SetFill(clr)
1012          self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer          self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer
1013    
1014      def _OnChangeFillColorTrans(self, event):      def _OnChangeFillColorTrans(self, event):
1015          self.prop.SetFill(Color.None)          self.prop.SetFill(Color.None)
1016          self.previewer.Refresh() # XXX: work around, see ClassDataPreviewer          self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer
1017    
1018      def GetClassGroupProperties(self):      def GetClassGroupProperties(self):
1019          return self.prop          return self.prop
1020    
1021    
1022  class ClassDataPreviewer(wxWindow):  class ClassDataPreviewWindow(wxWindow):
1023    
1024      def __init__(self, rect, prop, shapeType,      def __init__(self, rect, prop, shapeType,
1025                         parent = None, id = -1, size = wxDefaultSize):                         parent = None, id = -1, size = wxDefaultSize):
1026          if parent is not None:          if parent is not None:
1027              wxWindow.__init__(self, parent, id, size=size)              wxWindow.__init__(self, parent, id, (0, 0), size)
1028              EVT_PAINT(self, self._OnPaint)              EVT_PAINT(self, self._OnPaint)
1029    
1030          self.rect = rect          self.rect = rect
1031    
1032          self.prop = prop          self.prop = prop
1033          self.shapeType = shapeType          self.shapeType = shapeType
1034            self.previewer = ClassDataPreviewer()
1035    
1036      def _OnPaint(self, event):      def _OnPaint(self, event):
1037          dc = wxPaintDC(self)          dc = wxPaintDC(self)
# Line 1015  class ClassDataPreviewer(wxWindow): Line 1039  class ClassDataPreviewer(wxWindow):
1039          # XXX: this doesn't seem to be having an effect:          # XXX: this doesn't seem to be having an effect:
1040          dc.DestroyClippingRegion()          dc.DestroyClippingRegion()
1041    
1042          self.Draw(dc, None)          if self.rect is None:
1043                w, h = self.GetSize()
1044                rect = wxRect(0, 0, w, h)
1045            else:
1046                rect = self.rect
1047    
1048            self.previewer.Draw(dc, rect, self.prop, self.shapeType)
1049    
1050    class ClassDataPreviewer:
1051    
1052      def Draw(self, dc, rect, prop = None, shapeType = None):      def Draw(self, dc, rect, prop, shapeType):
1053    
1054          if prop is None: prop = self.prop          assert(dc is not None)
1055          if shapeType is None: shapeType = self.shapeType          assert(isinstance(prop, ClassGroupProperties))
1056    
1057          if rect is None:          if rect is None:
1058              x = y = 0              x = 0
1059              w, h = self.GetClientSizeTuple()              y = 0
1060                w, h = dc.GetSize()
1061          else:          else:
1062              x = rect.GetX()              x = rect.GetX()
1063              y = rect.GetY()              y = rect.GetY()
# Line 1064  class ClassRenderer(wxPyGridCellRenderer Line 1097  class ClassRenderer(wxPyGridCellRenderer
1097    
1098      def __init__(self, shapeType):      def __init__(self, shapeType):
1099          wxPyGridCellRenderer.__init__(self)          wxPyGridCellRenderer.__init__(self)
1100          self.previewer = ClassDataPreviewer(None, None, shapeType)          self.shapeType = shapeType
1101            self.previewer = ClassDataPreviewer()
1102    
1103      def Draw(self, grid, attr, dc, rect, row, col, isSelected):      def Draw(self, grid, attr, dc, rect, row, col, isSelected):
1104          data = grid.GetTable().GetClassGroup(row)          data = grid.GetTable().GetClassGroup(row)
# Line 1077  class ClassRenderer(wxPyGridCellRenderer Line 1111  class ClassRenderer(wxPyGridCellRenderer
1111                           rect.GetWidth(), rect.GetHeight())                           rect.GetWidth(), rect.GetHeight())
1112    
1113          if not isinstance(data, ClassGroupMap):          if not isinstance(data, ClassGroupMap):
1114              self.previewer.Draw(dc, rect, data.GetProperties())              self.previewer.Draw(dc, rect, data.GetProperties(), self.shapeType)
1115    
1116          if isSelected:          if isSelected:
1117              dc.SetPen(wxPen(wxColour(0 * 255, 0 * 255, 0 * 255),              dc.SetPen(wxPen(wxColour(0 * 255, 0 * 255, 0 * 255),

Legend:
Removed from v.496  
changed lines
  Added in v.560

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26