76 |
|
|
77 |
self.current = None |
self.current = None |
78 |
|
|
79 |
|
self.tree = tree = TreeCtrl(self, self) |
80 |
self.scroller = scroller = wxSplitterScrolledWindow(self, -1, #(50,50), (350, 250), |
root = tree.AddRoot('Schema') |
|
style=wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL) |
|
|
self.splitter = splitter = wxThinSplitterWindow(scroller, -1, style=wxSP_3DBORDER | wxCLIP_CHILDREN) |
|
|
splitter.SetSashSize(2) |
|
|
|
|
|
print dir(scroller) |
|
|
|
|
|
self.tree = tree = TreeCtrl(splitter, self) |
|
|
root = self.tree.AddRoot('Schema') |
|
81 |
tree.SetItemHasChildren(root, 1) |
tree.SetItemHasChildren(root, 1) |
82 |
tree.SetPyData(root, self) |
tree.SetPyData(root, self) |
83 |
for connection in self.connectionNames: |
for connection in self.connectionNames: |
85 |
tree.Expand(root) |
tree.Expand(root) |
86 |
|
|
87 |
|
|
88 |
valueWindow = ListWindow(splitter) |
# scroller.EnableScrolling(False, False) |
|
|
|
|
splitter.SplitVertically(tree, valueWindow, 150) |
|
|
scroller.SetTargetWindow(tree) |
|
|
scroller.EnableScrolling(False, False) |
|
|
|
|
|
valueWindow.SetTreeCtrl(tree) |
|
|
tree.SetCompanionWindow(valueWindow) |
|
89 |
|
|
90 |
sizer = wxBoxSizer(wxVERTICAL) |
sizer = wxBoxSizer(wxVERTICAL) |
91 |
sizer.Add(scroller, 1, wxEXPAND|wxALL, 0) |
sizer.Add(tree, 1, wxEXPAND|wxALL, 6) |
92 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
93 |
self.SetSizer(sizer) |
self.SetSizer(sizer) |
94 |
|
|
102 |
## }) |
## }) |
103 |
|
|
104 |
self.expanded = 1 |
self.expanded = 1 |
105 |
|
EVT_TREE_SEL_CHANGED(self, self.tree.GetId(), self.OnSelectionChange) |
106 |
EVT_TREE_BEGIN_DRAG(self, self.tree.GetId(), self.OnBeginDrag) |
EVT_TREE_BEGIN_DRAG(self, self.tree.GetId(), self.OnBeginDrag) |
107 |
EVT_TREE_BEGIN_RDRAG(self, self.tree.GetId(), self.OnBeginRDrag) |
EVT_TREE_BEGIN_RDRAG(self, self.tree.GetId(), self.OnBeginRDrag) |
108 |
|
|
109 |
|
self.Layout() |
110 |
|
|
111 |
def createToolbar(self, parent): |
def createToolbar(self, parent): |
112 |
return _SchemaToolbar(parent, self.instance) |
return _SchemaToolbar(parent, self.instance) |
113 |
|
|
114 |
def __OnSize(self, event): |
def __OnSize(self, event): |
115 |
# self.scroll.SetSize(self.GetClientSize()) |
self.scroller.SetSize(self.GetClientSize()) |
116 |
# self.scroller.SetScrollbars(10,10,10,10) |
# self.scroller.SetVirtualSize(self.tree.GetSize()) |
117 |
# This is some hackery since the earlier |
print self.scroller.GetVirtualSize() |
118 |
# SetSashPosition is doing absolutely no good :( |
self.scroller.SetScrollbars(10,10,10,10) |
|
if self.splitter.GetSashPosition() < 30: |
|
|
self.splitter.SetSashPosition(int(self.splitter.GetSizeTuple()[0]*.6)) |
|
|
|
|
119 |
event.Skip() |
event.Skip() |
120 |
|
|
121 |
# Since this class is the root node, we need to |
# Since this class is the root node, we need to |
136 |
def OnBeginRDrag(self, event): |
def OnBeginRDrag(self, event): |
137 |
self.OnBeginDrag(event, right=1) |
self.OnBeginDrag(event, right=1) |
138 |
|
|
139 |
|
def OnSelectionChange(self, event): |
140 |
|
o = self.tree.GetPyData(event.GetItem()) |
141 |
|
if o.getColumn(): |
142 |
|
self.setFeedback(o.getLabel() + ': ' + o.getColumn()) |
143 |
|
else: |
144 |
|
self.setFeedback('') |
145 |
|
|
146 |
def __addTable(self, object): |
def __addTable(self, object): |
147 |
# Find the "connection" node |
# Find the "connection" node |
202 |
return [{'Type': 'SchemaDrop', 'Data': rs, 'ShowMenu': right}] |
return [{'Type': 'SchemaDrop', 'Data': rs, 'ShowMenu': right}] |
203 |
|
|
204 |
|
|
205 |
class TreeCtrl(wxRemotelyScrolledTreeCtrl): |
class TreeCtrl(wxTreeCtrl): |
206 |
|
|
207 |
def __init__(self, parent, tool): |
def __init__(self, parent, tool): |
208 |
wxRemotelyScrolledTreeCtrl.__init__(self, parent, -1, |
wxTreeCtrl.__init__(self, parent, -1, |
209 |
style=wxTR_HAS_BUTTONS|wxTR_NO_LINES| #wxTR_HIDE_ROOT| |
## style=wxTR_HAS_BUTTONS|wxTR_NO_LINES| wxTR_HIDE_ROOT| |
210 |
wxTR_ROW_LINES|wxNO_BORDER|wxTR_MULTIPLE) |
## wxNO_BORDER|wxTR_MULTIPLE|wxTR_ROW_LINES) |
211 |
|
style=wxTR_HAS_BUTTONS|wxTR_HIDE_ROOT|wxTR_LINES_AT_ROOT| |
212 |
|
wxSIMPLE_BORDER|wxTR_MULTIPLE|wxTR_FULL_ROW_HIGHLIGHT ) |
213 |
|
|
214 |
self.tool = tool |
self.tool = tool |
215 |
EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.__OnExpand) |
EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.__OnExpand) |
223 |
node = self.GetPyData(parent) |
node = self.GetPyData(parent) |
224 |
if node and not node.expanded: |
if node and not node.expanded: |
225 |
node.expand() |
node.expand() |
|
self.tool.scroller.AdjustScrollbars() |
|
|
self.tool.splitter.Refresh() |
|
226 |
|
|
227 |
event.Skip() |
event.Skip() |
228 |
|
|
229 |
|
|
230 |
|
|
|
class ListWindow(wxTreeCompanionWindow): |
|
|
def __init__(self, parent): |
|
|
wxTreeCompanionWindow.__init__(self, parent, -1, |
|
|
style=wxNO_BORDER ) |
|
|
self.SetBackgroundColour("WHITE") |
|
|
## EVT_ERASE_BACKGROUND(self, self._OnEraseBackground) |
|
|
|
|
|
def _OnEraseBackground(self, evt): |
|
|
pass |
|
|
|
|
|
|
|
|
# This method is called to draw each item in the value window |
|
|
def DrawItem(self, dc, itemId, rect): |
|
|
tree = self.GetTreeCtrl() |
|
|
if tree: |
|
|
text = tree.GetPyData(itemId).getColumn() |
|
|
pen = wxPen(wxSystemSettings_GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID) |
|
|
dc.SetPen(pen) |
|
|
dc.SetBrush(wxBrush(self.GetBackgroundColour(), wxSOLID)) |
|
|
dc.DrawRectangle(rect.x, rect.y, rect.width+1, rect.height+1) |
|
|
dc.SetTextForeground("BLACK") |
|
|
dc.SetBackgroundMode(wxTRANSPARENT) |
|
|
tw, th = dc.GetTextExtent(text) |
|
|
x = 5 |
|
|
y = rect.y + max(0, (rect.height - th) / 2) |
|
|
dc.DrawText(text, x, y) |
|
|
|
|
|
|
|
231 |
|
|
232 |
###################################################################### |
###################################################################### |
233 |
# |
# |