commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/designer/src GFDesigner.py Instance.py Tri...


From: Jason Cater
Subject: gnue/designer/src GFDesigner.py Instance.py Tri...
Date: Mon, 14 Jan 2002 01:17:10 -0500

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/01/14 01:17:10

Modified files:
        designer/src   : GFDesigner.py Instance.py TriggerEditor.py 

Log message:
        more modularization of designer; first attempt at using scintilla for 
code editing (to test out the syntax-hilighting, add ColorizeCode=1 to the 
[forms] section of your gnue.conf -- note that this causes a longer startup 
time which is why this isn't set to true by default)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/GFDesigner.py.diff?cvsroot=OldCVS&tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/Instance.py.diff?cvsroot=OldCVS&tr1=1.37&tr2=1.38&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/TriggerEditor.py.diff?cvsroot=OldCVS&tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: gnue/designer/src/GFDesigner.py
diff -c gnue/designer/src/GFDesigner.py:1.29 
gnue/designer/src/GFDesigner.py:1.30
*** gnue/designer/src/GFDesigner.py:1.29        Fri Jan 11 22:59:48 2002
--- gnue/designer/src/GFDesigner.py     Mon Jan 14 01:17:10 2002
***************
*** 62,69 ****
    def OnInit(self):
      if len(self.ARGUMENTS):
        for arg in self.ARGUMENTS:
!         self.SetTopWindow(GFDInstance(self, arg))
      else:
        self.SetTopWindow(GFDInstance(self, None))
  
      return 1
--- 62,74 ----
    def OnInit(self):
      if len(self.ARGUMENTS):
        for arg in self.ARGUMENTS:
!         self.SetTopWindow(self.load(arg))
      else:
+ 
+       # TODO: What to do when no object is specified on command line?
+       # TODO: jcater thinks of some task selector like kword uses,
+       # TODO: or, restore the session to the way it was (same files, etc)
+ 
        self.SetTopWindow(GFDInstance(self, None))
  
      return 1
***************
*** 127,141 ****
  
    def OnOpen(self, event):
  
!     dlg = wxFileDialog(NULL, "Open GNUe Forms...", defaultDir=os.getcwd(),
                             wildcard = self.supportedOpenWildcard,
                             style=wxOPEN)
      if dlg.ShowModal() == wxID_OK:
        if self.isFileOpened(dlg.GetPath()):
          # TODO: Um, something better than this!!!
          print "File is already opened!"
        else:
!         GFDInstance(self, dlg.GetPath())
      dlg.Destroy()
  
  
--- 132,148 ----
  
    def OnOpen(self, event):
  
!     dlg = wxFileDialog(NULL, "Open GNUe File...", defaultDir=os.getcwd(),
                             wildcard = self.supportedOpenWildcard,
                             style=wxOPEN)
+                            
      if dlg.ShowModal() == wxID_OK:
        if self.isFileOpened(dlg.GetPath()):
          # TODO: Um, something better than this!!!
          print "File is already opened!"
        else:
!         self.load(dlg.GetPath())
! 
      dlg.Destroy()
  
  
***************
*** 177,186 ****
--- 184,195 ----
      dlg.Destroy()
  
  
+ 
    def loadToolInformation(self):
  
      self.supportedToolObjects = []
      self.supportedOpenWildcard = ""
+     self.toolExtensionMapping = {}
  
  
      wildcard = ""
***************
*** 194,199 ****
--- 203,209 ----
      for tool in SupportedTools:
        self.supportedToolObjects.append((tool.properties.nickname, tool))
  
+ 
      ##  if len(tool.properties.fileExtensions.keys()) > 1:
      ##
      ##    wildcard += "%s Files (*.%s)|*.%s|" % \
***************
*** 202,212 ****
      ##               string.join(tool.properties.fileExtensions.keys(),';*.') 
)
  
  
        for type in tool.properties.fileExtensions.keys():
!         wildcard += "%s (*.%s)|*.%s|" % \
               ( tool.properties.fileExtensions[type], type, type)
          alltypes.append(type)
  
  
  
      ##  self.supportedOpenWildcard = "All Supported Files (*.%s)|*.%s|" % \
--- 212,233 ----
      ##               string.join(tool.properties.fileExtensions.keys(),';*.') 
)
  
  
+       # Make the "default" file extension for a tool
+       # appear before the other extensions.
+       wildcard += "%s (*.%s)|*.%s|" % \
+        ( tool.properties.fileExtensions[tool.properties.defaultFileExtension],
+          tool.properties.defaultFileExtension,
+          tool.properties.defaultFileExtension)
+ 
        for type in tool.properties.fileExtensions.keys():
!         if type != tool.properties.defaultFileExtension:
!           wildcard += "%s (*.%s)|*.%s|" % \
               ( tool.properties.fileExtensions[type], type, type)
          alltypes.append(type)
  
+         # Keep a dict of Extension::Handler mappings
+         self.toolExtensionMapping[type] = tool
+ 
  
  
      ##  self.supportedOpenWildcard = "All Supported Files (*.%s)|*.%s|" % \
***************
*** 214,222 ****
      ##              string.join(alltypes,';*.') ) \
      ##            + wildcard \
      ##            + "All Files (*.*)|*.*"
!       self.supportedOpenWildcard = string.join(alltypes,';*.')  \
!                                  + wildcard \
                                   + "All Files (*.*)|*.*"
  
  
  #
--- 235,264 ----
      ##              string.join(alltypes,';*.') ) \
      ##            + wildcard \
      ##            + "All Files (*.*)|*.*"
!       self.supportedOpenWildcard = wildcard \
                                   + "All Files (*.*)|*.*"
+ 
+ 
+   #
+   # Load a new object from file
+   #
+   def load(self, file):
+ 
+     extension = string.lower(os.path.splitext(file)[1][1:])
+ 
+     if not self.toolExtensionMapping.has_key(extension):
+ 
+       # TODO: This should try to figure out what kind of file this is.
+       # TODO: We maintain a list of opening xml elements in the
+       # TODO: (gnue.designer.SupportedTools).properties object.
+       # TODO: [gnue.designer.SupportedTools is a list]
+ 
+       print "I do not know what to do with a .%s file!" % extension
+       return None
+ 
+     instanceClass = self.toolExtensionMapping[extension].Instance
+     return instanceClass.Instance(self, file)
+ 
  
  
  #
Index: gnue/designer/src/Instance.py
diff -c gnue/designer/src/Instance.py:1.37 gnue/designer/src/Instance.py:1.38
*** gnue/designer/src/Instance.py:1.37  Fri Jan 11 10:49:09 2002
--- gnue/designer/src/Instance.py       Mon Jan 14 01:17:10 2002
***************
*** 29,35 ****
  import sys, os, time
  from wxPython.wx import *
  from gnue.common import GDebug, GConfig
- from gnue.common.GClientApp import GClientApp
  from MenuBar import MainMenuBar
  from PopupMenu import ObjectMenu
  from LayoutEditor import LayoutEditor
--- 29,34 ----
***************
*** 390,396 ****
        fileHandle.write('<?xml version="1.0" encoding="%s"?>\n\n' % \
             (sys.getdefaultencoding()))
  
!     fileHandle.write('<!--  %s (%s)\n      Form saved on: %s  -->\n\n' \
         % (TITLE, VERSION, \
            time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))))
      fileHandle.write(self._form.dumpXML(treeDump=1))
--- 389,395 ----
        fileHandle.write('<?xml version="1.0" encoding="%s"?>\n\n' % \
             (sys.getdefaultencoding()))
  
!     fileHandle.write('<!--  %s (%s)\n      Saved on: %s  -->\n\n' \
         % (TITLE, VERSION, \
            time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))))
      fileHandle.write(self._form.dumpXML(treeDump=1))
***************
*** 455,462 ****
    defaultFileExtension = 'undefined'
  
  
! def load(app, file):
!   pass
  
  
  
--- 454,465 ----
    defaultFileExtension = 'undefined'
  
  
! 
! 
! 
! 
! 
! 
  
  
  
Index: gnue/designer/src/TriggerEditor.py
diff -c gnue/designer/src/TriggerEditor.py:1.10 
gnue/designer/src/TriggerEditor.py:1.11
*** gnue/designer/src/TriggerEditor.py:1.10     Mon Nov 19 21:00:16 2001
--- gnue/designer/src/TriggerEditor.py  Mon Jan 14 01:17:10 2002
***************
*** 28,35 ****
  
  
  from wxPython.wx import *
! from gnue.common import GDebug, GParserHelpers
  from gnue.forms import GFTrigger
  
  
  # What Mode are we in?
--- 28,37 ----
  
  
  from wxPython.wx import *
! from wxPython.stc import *
! from gnue.common import GDebug, GParserHelpers, GConfig
  from gnue.forms import GFTrigger
+ import keyword
  
  
  # What Mode are we in?
***************
*** 43,50 ****
      height = int(wxSystemSettings_GetSystemMetric( wxSYS_SCREEN_Y )/3)
  
      wxPanel.__init__(self, parent, -1)
!     self.editor = 
wxTextCtrl(self,-1,style=wxTE_PROCESS_TAB|wxTE_MULTILINE|wxHSCROLL,
!       pos=wxPoint(0,32))
      self.SetSize(parent.GetClientSize())
      self.editor.SetSize(self.GetClientSize())
      self.object = None
--- 45,51 ----
      height = int(wxSystemSettings_GetSystemMetric( wxSYS_SCREEN_Y )/3)
  
      wxPanel.__init__(self, parent, -1)
!     self.editor = PythonEditorControl(self,-1, pos=wxPoint(0,32))
      self.SetSize(parent.GetClientSize())
      self.editor.SetSize(self.GetClientSize())
      self.object = None
***************
*** 54,60 ****
      self.parent = parent
      self.instance = instance
      self.form = form
!     self.editor.SetEditable(0)
      self.triggerList = []
      EVT_SIZE(self, self._onSize)
  # This isn't working! Argh!!!!!
--- 55,61 ----
      self.parent = parent
      self.instance = instance
      self.form = form
!     self.editor.SetReadOnly(1)
      self.triggerList = []
      EVT_SIZE(self, self._onSize)
  # This isn't working! Argh!!!!!
***************
*** 91,150 ****
  
      if isinstance(object, GFTrigger.GFTrigger):
        self.__ignoreevent = 1
-       self.editor.SetValue(object.getChildrenAsContent())
        self.__ignoreevent = 0
        self.object = object
!       if not len(self.object._children): 
          GParserHelpers.GContent(object, "")
        elif len(self.object._children) > 1:
          content = self.object.getChildrenAsContent()
          self.object._children = []
!         GParserHelpers.GContent(self.object, "")
!       self.editor.SetEditable(1)
  
!       if object.type == 'NAMED': 
          self.mode = NAMED_TRIGGER
          i = 0
!         while self.namedTriggerList[i] != object: 
            i = i + 1
          self.namedTriggerCombo.SetSelection(i)
!       else: 
          self.mode = EVENT_TRIGGER
  
!   def inventoryObject(self, object): 
!     if isinstance(object, GFTrigger.GFTrigger): 
        if object.type == 'NAMED':
          self.namedTriggerList.append(object)
          self.namedTriggerCombo.Append(object.name)
  
!   def OnKillFocus(self, event): 
!     if self.object != None and not self.__ignoreevent: 
        self.object._children[0]._content = self.editor.GetValue()
  
    def onCreateObject (self, object, handler):
!     if object == None: 
        return
  
!     self.inventoryObject(object)      
  
    def onModifyObject (self, object, handler, modifications):
!     if object == None: 
        return
      if handler != __name__:
!       for modification in modifications: 
          attribute, value = modification
  
    def onDeleteObject (self, object, handler):
!     if object == None: 
        return
  
      if isinstance(object, GFTrigger.GFTrigger):
!       if object.type == 'NAMED': 
  
!         i = 0 
!         while self.namedTriggerList[i] != object: 
            i = i + 1
  
          self.namedTriggerList.pop(i)
          self.namedComboBox.Delete(i)
  
--- 92,443 ----
  
      if isinstance(object, GFTrigger.GFTrigger):
        self.__ignoreevent = 1
        self.__ignoreevent = 0
+ 
        self.object = object
!       self.editor.SetReadOnly(0)
! 
!       if not len(self.object._children):
          GParserHelpers.GContent(object, "")
        elif len(self.object._children) > 1:
          content = self.object.getChildrenAsContent()
          self.object._children = []
!         GParserHelpers.GContent(self.object, content)
  
!       self.editor.SetText(object.getChildrenAsContent())
!       self.editor.EmptyUndoBuffer()
!       self.editor.Colourise(0, -1)
! 
!       if object.type == 'NAMED':
          self.mode = NAMED_TRIGGER
          i = 0
!         while self.namedTriggerList[i] != object:
            i = i + 1
          self.namedTriggerCombo.SetSelection(i)
!       else:
          self.mode = EVENT_TRIGGER
  
!   def inventoryObject(self, object):
!     if isinstance(object, GFTrigger.GFTrigger):
        if object.type == 'NAMED':
          self.namedTriggerList.append(object)
          self.namedTriggerCombo.Append(object.name)
  
!   def OnKillFocus(self, event):
!     if self.object != None and not self.__ignoreevent:
        self.object._children[0]._content = self.editor.GetValue()
  
    def onCreateObject (self, object, handler):
!     if object == None:
        return
  
!     self.inventoryObject(object)
  
    def onModifyObject (self, object, handler, modifications):
!     if object == None:
        return
      if handler != __name__:
!       for modification in modifications:
          attribute, value = modification
  
    def onDeleteObject (self, object, handler):
!     if object == None:
        return
  
      if isinstance(object, GFTrigger.GFTrigger):
!       if object.type == 'NAMED':
  
!         i = 0
!         while self.namedTriggerList[i] != object:
            i = i + 1
  
          self.namedTriggerList.pop(i)
          self.namedComboBox.Delete(i)
+ 
+ 
+ 
+ #
+ # A Python Editor Control using wxPython's Scintilla support.
+ # This class is largely based on demo code from wxPython
+ #
+ 
+ class PythonEditorControl(wxStyledTextCtrl):
+   def __init__(self, *args, **parms):
+     wxStyledTextCtrl.__init__(self, *args, **parms)
+ 
+     self.CmdKeyAssign(ord('B'), wxSTC_SCMOD_CTRL, wxSTC_CMD_ZOOMIN)
+     self.CmdKeyAssign(ord('N'), wxSTC_SCMOD_CTRL, wxSTC_CMD_ZOOMOUT)
+ 
+     self.SetLexer(wxSTC_LEX_PYTHON)
+     self.SetKeyWords(0, string.join(keyword.kwlist))
+ 
+     self.SetProperty("fold", "1")
+     self.SetProperty("tab.timmy.whinge.level", "1")
+     self.SetMargins(0,0)
+ 
+     self.SetViewWhiteSpace(false)
+     #self.SetBufferedDraw(false)
+ 
+     self.SetEdgeMode(wxSTC_EDGE_BACKGROUND)
+     self.SetEdgeColumn(78)
+ 
+     # Setup a margin to hold fold markers
+     #self.SetFoldFlags(16)  ###  WHAT IS THIS VALUE?  WHAT ARE THE OTHER 
FLAGS?  DOES IT MATTER?
+     self.SetMarginType(2, wxSTC_MARGIN_SYMBOL)
+     self.SetMarginMask(2, wxSTC_MASK_FOLDERS)
+     self.SetMarginSensitive(2, true)
+     self.SetMarginWidth(2, 15)
+     self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, "navy", "navy")
+     self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "navy", 
"navy")
+ 
+ 
+     EVT_STC_UPDATEUI(self,    self.GetId(), self.OnUpdateUI)
+     EVT_STC_MARGINCLICK(self, self.GetId(), self.OnMarginClick)
+ 
+ 
+     # Make some styles,  The lexer defines what each style is used for, we
+     # just have to define what each style looks like.  This set is adapted 
from
+     # Scintilla sample property files.
+ 
+     self.StyleClearAll()
+ 
+ 
+     # TODO: A lot of this should be configurable
+ 
+     if int(GConfig.get('ColorizeCode','0')):
+ 
+       # Global default styles for all languages
+       self.StyleSetSpec(wxSTC_STYLE_DEFAULT,     
"face:%(helv)s,size:%(size)d" % faces)
+       self.StyleSetSpec(wxSTC_STYLE_LINENUMBER,  
"back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces)
+       self.StyleSetSpec(wxSTC_STYLE_CONTROLCHAR, "face:%(other)s" % faces)
+       self.StyleSetSpec(wxSTC_STYLE_BRACELIGHT,  
"fore:#FFFFFF,back:#0000FF,bold")
+       self.StyleSetSpec(wxSTC_STYLE_BRACEBAD,    
"fore:#000000,back:#FF0000,bold")
+ 
+       # Python styles
+       # White space
+       self.StyleSetSpec(wxSTC_P_DEFAULT, 
"fore:#808080,face:%(helv)s,size:%(size)d" % faces)
+       # Comment
+       self.StyleSetSpec(wxSTC_P_COMMENTLINE, 
"fore:#007F00,face:%(other)s,size:%(size)d" % faces)
+       # Number
+       self.StyleSetSpec(wxSTC_P_NUMBER, "fore:#007F7F,size:%(size)d" % faces)
+       # String
+       self.StyleSetSpec(wxSTC_P_STRING, 
"fore:#7F007F,italic,face:%(times)s,size:%(size)d" % faces)
+       # Single quoted string
+       self.StyleSetSpec(wxSTC_P_CHARACTER, 
"fore:#7F007F,italic,face:%(times)s,size:%(size)d" % faces)
+       # Keyword
+       self.StyleSetSpec(wxSTC_P_WORD, "fore:#00007F,bold,size:%(size)d" % 
faces)
+       # Triple quotes
+       self.StyleSetSpec(wxSTC_P_TRIPLE, "fore:#7F0000,size:%(size)d" % faces)
+       # Triple double quotes
+       self.StyleSetSpec(wxSTC_P_TRIPLEDOUBLE, "fore:#7F0000,size:%(size)d" % 
faces)
+       # Class name definition
+       self.StyleSetSpec(wxSTC_P_CLASSNAME, 
"fore:#0000FF,bold,underline,size:%(size)d" % faces)
+       # Function or method name definition
+       self.StyleSetSpec(wxSTC_P_DEFNAME, "fore:#007F7F,bold,size:%(size)d" % 
faces)
+       # Operators
+       self.StyleSetSpec(wxSTC_P_OPERATOR, "bold,size:%(size)d" % faces)
+       # Identifiers
+       self.StyleSetSpec(wxSTC_P_IDENTIFIER, 
"fore:#808080,face:%(helv)s,size:%(size)d" % faces)
+       # Comment-blocks
+       self.StyleSetSpec(wxSTC_P_COMMENTBLOCK, "fore:#7F7F7F,size:%(size)d" % 
faces)
+       # End of line where string is not closed
+       self.StyleSetSpec(wxSTC_P_STRINGEOL, 
"fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled,size:%(size)d" % faces)
+ 
+     self.SetCaretForeground("BLUE")
+ 
+     EVT_KEY_DOWN(self, self.OnKeyPressed)
+ 
+ 
+   def OnKeyPressed(self, event):
+     key = event.KeyCode()
+     if key == 32 and event.ControlDown():
+       pos = self.GetCurrentPos()
+       # Tips
+       if event.ShiftDown():
+ 
+         # TODO: Implement ToolTips
+ 
+         self.CallTipSetBackground("yellow")
+         self.CallTipShow(pos, 'param1, param2')
+         # Code completion
+       else:
+ 
+         # TODO: Implement AutoComplete
+ 
+         #lst = []
+         #for x in range(50000):
+           #    lst.append('%05d' % x)
+           #st = string.join(lst)
+           #print len(st)
+           #self.AutoCompShow(0, st)
+ 
+         kw = keyword.kwlist[:]
+         kw.append("zzzzzz")
+         kw.append("aaaaa")
+         kw.append("__init__")
+         kw.append("zzaaaaa")
+         kw.append("zzbaaaa")
+         kw.append("this_is_a_longer_value")
+         kw.append("this_is_a_much_much_much_much_much_much_much_longer_value")
+ 
+         kw.sort()  # Python sorts are case sensitive
+         self.AutoCompSetIgnoreCase(false)  # so this needs to match
+ 
+         self.AutoCompShow(0, string.join(kw))
+     else:
+       event.Skip()
+ 
+ 
+   def OnUpdateUI(self, evt):
+     # check for matching braces
+     braceAtCaret = -1
+     braceOpposite = -1
+     charBefore = None
+     caretPos = self.GetCurrentPos()
+     if caretPos > 0:
+       charBefore = self.GetCharAt(caretPos - 1)
+       styleBefore = self.GetStyleAt(caretPos - 1)
+ 
+     # check before
+     if charBefore and chr(charBefore) in "[]{}()" and styleBefore == 
wxSTC_P_OPERATOR:
+       braceAtCaret = caretPos - 1
+ 
+     # check after
+     if braceAtCaret < 0:
+       charAfter = self.GetCharAt(caretPos)
+       styleAfter = self.GetStyleAt(caretPos)
+       if charAfter and chr(charAfter) in "[]{}()" and styleAfter == 
wxSTC_P_OPERATOR:
+         braceAtCaret = caretPos
+ 
+     if braceAtCaret >= 0:
+       braceOpposite = self.BraceMatch(braceAtCaret)
+ 
+     if braceAtCaret != -1  and braceOpposite == -1:
+       self.BraceBadLight(braceAtCaret)
+     else:
+       self.BraceHighlight(braceAtCaret, braceOpposite)
+       #pt = self.PointFromPosition(braceOpposite)
+       #self.Refresh(true, wxRect(pt.x, pt.y, 5,5))
+       #print pt
+       #self.Refresh(false)
+ 
+ 
+   def OnMarginClick(self, evt):
+     # fold and unfold as needed
+     if evt.GetMargin() == 2:
+       if evt.GetShift() and evt.GetControl():
+         self.FoldAll()
+       else:
+         lineClicked = self.LineFromPosition(evt.GetPosition())
+         if self.GetFoldLevel(lineClicked) & wxSTC_FOLDLEVELHEADERFLAG:
+           if evt.GetShift():
+             self.SetFoldExpanded(lineClicked, true)
+             self.Expand(lineClicked, true, true, 1)
+           elif evt.GetControl():
+             if self.GetFoldExpanded(lineClicked):
+               self.SetFoldExpanded(lineClicked, false)
+               self.Expand(lineClicked, false, true, 0)
+             else:
+               self.SetFoldExpanded(lineClicked, true)
+               self.Expand(lineClicked, true, true, 100)
+           else:
+              self.ToggleFold(lineClicked)
+ 
+ 
+   def FoldAll(self):
+     lineCount = self.GetLineCount()
+     expanding = true
+ 
+     # find out if we are folding or unfolding
+     for lineNum in range(lineCount):
+       if self.GetFoldLevel(lineNum) & wxSTC_FOLDLEVELHEADERFLAG:
+         expanding = not self.GetFoldExpanded(lineNum)
+         break;
+ 
+     lineNum = 0
+     while lineNum < lineCount:
+       level = self.GetFoldLevel(lineNum)
+       if level & wxSTC_FOLDLEVELHEADERFLAG and \
+                (level & wxSTC_FOLDLEVELNUMBERMASK) == wxSTC_FOLDLEVELBASE:
+ 
+         if expanding:
+           self.SetFoldExpanded(lineNum, true)
+           lineNum = self.Expand(lineNum, true)
+           lineNum = lineNum - 1
+         else:
+           lastChild = self.GetLastChild(lineNum, -1)
+           self.SetFoldExpanded(lineNum, false)
+           if lastChild > lineNum:
+             self.HideLines(lineNum+1, lastChild)
+ 
+       lineNum = lineNum + 1
+ 
+ 
+   def Expand(self, line, doExpand, force=false, visLevels=0, level=-1):
+     lastChild = self.GetLastChild(line, level)
+     line = line + 1
+     while line <= lastChild:
+       if force:
+         if visLevels > 0:
+           self.ShowLines(line, line)
+         else:
+           self.HideLines(line, line)
+       else:
+         if doExpand:
+           self.ShowLines(line, line)
+ 
+       if level == -1:
+         level = self.GetFoldLevel(line)
+ 
+       if level & wxSTC_FOLDLEVELHEADERFLAG:
+         if force:
+           if visLevels > 1:
+             self.SetFoldExpanded(line, true)
+           else:
+             self.SetFoldExpanded(line, false)
+           line = self.Expand(line, doExpand, force, visLevels-1)
+ 
+         else:
+           if doExpand and self.GetFoldExpanded(line):
+             line = self.Expand(line, true, force, visLevels-1)
+           else:
+             line = self.Expand(line, false, force, visLevels-1)
+       else:
+         line = line + 1;
+ 
+     return line
+ 
+ 
+   # The old code used SetEnabled, so we emulate that call here
+   def SetEnabled(self, bool):
+     self.SetReadOnly(bool)
+ 
+ 
+ #
+ # <cough>Hack!<cough>
+ #
+ # TODO: A lot of this should be configurable
+ if wxPlatform == '__WXMSW__':
+   faces = { 'times': 'Times New Roman',
+             'mono' : 'Courier New',
+             'helv' : 'Arial',
+             'other': 'Comic Sans MS',
+             'size' : 10,
+             'size2': 8,
+           }
+ else:
+ #  faces = { 'times': 'Times',
+ #            'mono' : 'Courier',
+ #            'helv' : 'Helvetica',
+ #            'other': 'Courier',
+ #            'size' : 10,
+ #            'size2': 8,
+ #          }
+   faces = { 'times': 'Courier',
+             'mono' : 'Courier',
+             'helv' : 'Courier',
+             'other': 'Courier',
+             'size' : 9,
+             'size2': 9,
+           }
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]