1 #----------------------------------------------------------------------------
3 # Purpose: Abstract Code Editor for pydocview tbat uses the Styled Text Control
9 # Copyright: (c) 2004-2005 ActiveGrid, Inc.
10 # License: wxWindows License
11 #----------------------------------------------------------------------------
20 class XmlDocument(CodeEditor
.CodeDocument
):
25 class XmlView(CodeEditor
.CodeView
):
28 def GetCtrlClass(self
):
29 """ Used in split window to instantiate new instances """
33 def GetAutoCompleteHint(self
):
34 pos
= self
.GetCtrl().GetCurrentPos()
38 validLetters
= string
.letters
+ string
.digits
+ '_:'
44 char
= chr(self
.GetCtrl().GetCharAt(pos
))
45 if char
not in validLetters
:
52 def GetAutoCompleteDefaultKeywords(self
):
56 class XmlService(CodeEditor
.CodeService
):
60 CodeEditor
.CodeService
.__init
__(self
)
63 class XmlCtrl(CodeEditor
.CodeCtrl
):
66 def __init__(self
, parent
, id=-1, style
=wx
.NO_FULL_REPAINT_ON_RESIZE
):
67 CodeEditor
.CodeCtrl
.__init
__(self
, parent
, id, style
)
68 self
.SetLexer(wx
.stc
.STC_LEX_XML
)
69 self
.SetProperty("fold.html", "1")
72 def GetMatchingBraces(self
):
76 def CanWordWrap(self
):
80 def SetViewDefaults(self
):
81 CodeEditor
.CodeCtrl
.SetViewDefaults(self
, configPrefix
= "Xml", hasWordWrap
= True, hasTabs
= True)
84 def GetFontAndColorFromConfig(self
):
85 return CodeEditor
.CodeCtrl
.GetFontAndColorFromConfig(self
, configPrefix
= "Xml")
88 def UpdateStyles(self
):
89 CodeEditor
.CodeCtrl
.UpdateStyles(self
)
91 if not self
.GetFont():
94 faces
= { 'font' : self
.GetFont().GetFaceName(),
95 'size' : self
.GetFont().GetPointSize(),
96 'size2': self
.GetFont().GetPointSize() - 2,
97 'color' : "%02x%02x%02x" % (self
.GetFontColor().Red(), self
.GetFontColor().Green(), self
.GetFontColor().Blue())
101 self
.StyleSetSpec(wx
.stc
.STC_H_DEFAULT
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
103 self
.StyleSetSpec(wx
.stc
.STC_H_COMMENT
, "face:%(font)s,fore:#007F00,italic,face:%(font)s,size:%(size)d" % faces
)
105 self
.StyleSetSpec(wx
.stc
.STC_H_NUMBER
, "face:%(font)s,fore:#007F7F,size:%(size)d" % faces
)
107 self
.StyleSetSpec(wx
.stc
.STC_H_SINGLESTRING
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
108 self
.StyleSetSpec(wx
.stc
.STC_H_DOUBLESTRING
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
110 self
.StyleSetSpec(wx
.stc
.STC_H_TAG
, "face:%(font)s,fore:#00007F,bold,size:%(size)d" % faces
)
112 self
.StyleSetSpec(wx
.stc
.STC_H_ATTRIBUTE
, "face:%(font)s,fore:#007F7F,bold,size:%(size)d" % faces
)
115 class XmlOptionsPanel(STCTextEditor
.TextOptionsPanel
):
117 def __init__(self
, parent
, id):
118 STCTextEditor
.TextOptionsPanel
.__init
__(self
, parent
, id, configPrefix
= "Xml", label
= "XML", hasWordWrap
= True, hasTabs
= True)
126 "ag:connectionstring", "ag:datasource", "ag:editorBounds", "ag:label", "ag:name", "ag:shortLabel", "ag:type",
127 "element", "fractionDigits", "length", "minOccurs", "name", "objtype", "refer", "schema", "type", "xpath", "xmlns",
128 "xs:complexType", "xs:element", "xs:enumeration", "xs:field", "xs:key", "xs:keyref", "xs:schema", "xs:selector"
131 #----------------------------------------------------------------------------
132 # Icon Bitmaps - generated by encode_bitmaps.py
133 #----------------------------------------------------------------------------
134 from wx
import ImageFromStream
, BitmapFromImage
140 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
141 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
142 \x00\x01\x08IDAT8\x8dc\xdc{\xf6\xde\x7f\x064p\xfb\xd1K\x06\x06\x06\x06\x86\
143 \xd7o\xbf2\xd4\xa5\xb93\xa2\xcb\xa3\x80\xbdg\xef\xfd\xbf\xff\xed?\x1c_\xf9\
144 \x04\xc13\xd6\x1f\xff\xbf\xeb\xf9\xff\xff\xcds\xf6\xfcgdbf\xc0\x85\x99\xb0\
145 \x19\xfa\xe5\x17\x82m\xee\xed\xcc\x90Z\xb7\x08\xc3\x950\xc0\x82\xcc\xf9\xfa\
146 \x07\xc1~\xfd\xf6+\xc3\xeb\xad{\x19\x1e?y\x89\xd7\x07,\xe8\x1aa\xb6\x9b{;300\
147 00(\xfdb`88\x7f\x19N\x03\x98`\x01\x86\xac\xf9\xd3o\xa8+\xa0\xfc\x07\x0f\x1e\
148 \xe3w\x01\xb2\x9f\xd15\xbf\xfa\x8e\xd7\x07\x0cL\xaf\xdf~%[3\xdc\x050\x8d\xa4\
149 jf````LkX\xfa\x7f\x8a\xcdi\xe2T\xe3r\x01\x03\x03\x03\xc3\xa7#\x13H\xd6|\xea1\
150 \x03jB\x12\xae\xffO\x14\x8d\x0cP\x0cx\xdb\xc8\xc8 \\\xff\x9f\xe1m#"\xf9c\xd3\
151 \x84b\xc0\xec\xa68\xb8j\x98fdM\xc8\x86\xc1\xd4 \xcb32213\xfc\xdc\x95\xfb\x9f\
152 \xdc0`A\xe6\x90\x03\x00\x11\x95\x8b;4e.A\x00\x00\x00\x00IEND\xaeB`\x82'
156 return BitmapFromImage(getXMLImage())
159 stream
= cStringIO
.StringIO(getXMLData())
160 return ImageFromStream(stream
)
163 return wx
.IconFromBitmap(getXMLBitmap())