Beispiel #1
0
class TextEditor(BaseLogic):
    
    def __init__(self):
        BaseLogic.__init__(self)
        
        # setting new logic for a sheet if viewer already exists
        self.__viewer = TextViewer()
        self.__viewer._createArea = self._createEditText
          
    def __del__(self):
        BaseLogic.__del__(self)
        
    def delete(self):
        BaseLogic.delete(self)
        
        self.__viewer.delete()
        
    def _setSheet(self, _sheet):
        BaseLogic._setSheet(self, _sheet)
        
        self.__viewer._setSheet(_sheet)
        
        _sheet.eventRootChanged = self._onRootChanged
        _sheet.eventUpdate = self._onUpdate
        
        
    def _onRootChanged(self, _isRoot):
        """Root changing event callback
        """
        self.__viewer._onRootChanged(_isRoot)
    
    def _onUpdate(self, _timeSinceLastFrame):
        BaseLogic._update(self, _timeSinceLastFrame)
        
        self.__viewer._onUpdate(_timeSinceLastFrame)
        
    def _onContentUpdate(self):
        
        import suit.core.keynodes as keynodes
        import suit.core.sc_utils as sc_utils
        sheet = self._getSheet()
        
        sheet.content_type = objects.ObjectSheet.CT_String
        #sheet.content_data = str(self.__viewer.widget.getOnlyText())
        sheet.content_data = unicode(self.__viewer.widget.getCaption()).encode('cp1251')
        sheet.content_format = keynodes.ui.format_string        
        
    def _createEditText(self):
        """Create widget to edit text value
        """
        self.__viewer.widget = render_engine.Gui.createWidgetT("Edit", "Edit",
                                                          mygui.IntCoord(0, 0, 91, 91),
                                                          mygui.Align(mygui.ALIGN_VSTRETCH),
                                                          "Main")
        self.__viewer.widget.setVisible(False)
        self.__viewer.widget.setTextColour(mygui.Colour(0.0, 0.0, 0.0, 1.0))
        self.__viewer.widget.setEditMultiLine(True)
Beispiel #2
0
 def __init__(self):
     BaseLogic.__init__(self)
     
     # setting new logic for a sheet if viewer already exists
     self.__viewer = TextViewer()
     self.__viewer._createArea = self._createEditText