39 |
|
|
40 |
wxPanel.__init__(self, parent.GetCurrentParent(), id) |
wxPanel.__init__(self, parent.GetCurrentParent(), id) |
41 |
|
|
42 |
|
self.parent = parent |
43 |
|
|
44 |
#self.SetDockParent(None) |
#self.SetDockParent(None) |
45 |
parent.SetPanel(self) |
#parent.SetPanel(self) |
46 |
|
|
47 |
|
def Create(self): |
48 |
|
self.parent.SetPanel(self) |
49 |
|
|
50 |
def SetDockParent(self, parent): |
def SetDockParent(self, parent): |
51 |
self.__dockParent = parent |
self.__dockParent = parent |
52 |
|
|
73 |
class DockableWindow(Publisher): |
class DockableWindow(Publisher): |
74 |
|
|
75 |
def __getattr__(self, attr): |
def __getattr__(self, attr): |
|
|
|
|
#print attr |
|
76 |
return getattr(self.__topWindow, attr) |
return getattr(self.__topWindow, attr) |
|
#try: |
|
|
#except AttributeError: |
|
|
#raise |
|
|
#return self.__dict__[attr] |
|
|
#return getattr(self, attr) |
|
|
#pass |
|
77 |
|
|
78 |
def __init__(self, parent, id, name, |
def __init__(self, parent, id, name, title, dockWindow, orient): |
79 |
title, dockWindow, orient): #, panel, docked = False, show = True): |
"""Create the dockable window. |
80 |
|
|
81 |
|
Initially, the window is hidden, but in an undocked state. |
82 |
|
""" |
83 |
|
|
84 |
if not isinstance(parent, DockFrame): raise TypeError("") |
if not isinstance(parent, DockFrame): raise TypeError("") |
85 |
|
|
90 |
self.__orientation = orient |
self.__orientation = orient |
91 |
|
|
92 |
self.__dockWindow = dockWindow |
self.__dockWindow = dockWindow |
|
#self.__floatWindow = NonModalDialog(parent, name, title) |
|
93 |
self.__floatWindow = wxFrame(parent, id, title) |
self.__floatWindow = wxFrame(parent, id, title) |
94 |
|
|
95 |
self.__docked = False |
self.__docked = False |
|
|
|
|
self.__dockPanel = None |
|
|
|
|
96 |
if self.__docked: |
if self.__docked: |
97 |
self.__topWindow = self.__dockWindow |
self.__topWindow = self.__dockWindow |
98 |
else: |
else: |
101 |
self.__floatSize = None |
self.__floatSize = None |
102 |
self.__floatPosition = None |
self.__floatPosition = None |
103 |
|
|
104 |
|
self.__dockPanel = None |
105 |
self.__panel = None |
self.__panel = None |
106 |
|
|
107 |
self.__dockWindow.Hide() |
self.__dockWindow.Hide() |
226 |
|
|
227 |
def SetDockSize(self, rect = None): |
def SetDockSize(self, rect = None): |
228 |
|
|
|
print "---------------" |
|
|
# |
|
|
# adjust the size to get the |
|
229 |
w0, h0 = self.__dockPanel.GetBestSize() |
w0, h0 = self.__dockPanel.GetBestSize() |
|
print w0, h0 |
|
230 |
w, h = self.__panel.GetBestSize() |
w, h = self.__panel.GetBestSize() |
|
print w, h |
|
|
#w0, h0 = self.__dockPanel.GetBestSize() |
|
|
#w0 = h0 = 0 |
|
|
#w, h = self.__dockPanel.GetBestSize() |
|
|
|
|
|
#print (w0, h0), (w, h) |
|
231 |
|
|
232 |
if (w, h) < (w0, h0): |
if (w, h) < (w0, h0): |
233 |
w = w0 |
w = w0 |
234 |
h = h0 |
h = h0 |
235 |
|
|
236 |
if rect is not None: |
if rect is not None: |
237 |
rw = rect.width |
rw = rect.width |
238 |
rh = rect.height |
rh = rect.height |
|
#print " ", (rw, rh) |
|
239 |
if rw < w: rw = w |
if rw < w: rw = w |
240 |
if rh < h: rh = h |
if rh < h: rh = h |
241 |
else: |
else: |
246 |
rw += 8 # XXX: without this the sash isn't visible!?!?!?! |
rw += 8 # XXX: without this the sash isn't visible!?!?!?! |
247 |
rh += 8 # XXX: without this the sash isn't visible!?!?!?! |
rh += 8 # XXX: without this the sash isn't visible!?!?!?! |
248 |
|
|
|
print rw, rh |
|
|
|
|
249 |
self.__dockWindow.SetDefaultSize(wxSize(rw, rh)) |
self.__dockWindow.SetDefaultSize(wxSize(rw, rh)) |
250 |
|
|
251 |
|
|
281 |
|
|
282 |
def __DoShow(self): |
def __DoShow(self): |
283 |
if self.IsShown(): return |
if self.IsShown(): return |
|
#print "__DoShow()", self.IsShown() |
|
284 |
|
|
285 |
self.__topWindow.Show() |
self.__topWindow.Show() |
286 |
|
|
292 |
|
|
293 |
def __DoHide(self): |
def __DoHide(self): |
294 |
if not self.IsShown(): return |
if not self.IsShown(): return |
|
#print "__DoHide()", self.IsShown() |
|
295 |
self.__topWindow.Show(False) |
self.__topWindow.Show(False) |
296 |
|
|
297 |
if self.__topWindow is self.__dockWindow: |
if self.__topWindow is self.__dockWindow: |
303 |
#self.__panel.Reparent(self) # Make sure we hang on to the panel |
#self.__panel.Reparent(self) # Make sure we hang on to the panel |
304 |
|
|
305 |
self.__dockPanel = wxPanel(self.__topWindow, -1, style=wxSUNKEN_BORDER) |
self.__dockPanel = wxPanel(self.__topWindow, -1, style=wxSUNKEN_BORDER) |
|
#self.__dockPanel.SetBackgroundColour(wxColour(255, 0, 0)) |
|
306 |
|
|
307 |
self.__panel.Reparent(self.__dockPanel) |
self.__panel.Reparent(self.__dockPanel) |
308 |
self.__panel.SetId(PANEL_ID) |
self.__panel.SetId(PANEL_ID) |
382 |
headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0) |
headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0) |
383 |
|
|
384 |
sizer.Add(headerBox, 0, wxGROW, 0) |
sizer.Add(headerBox, 0, wxGROW, 0) |
|
|
|
|
|
|
385 |
sizer.Add(self.__panel, 1, wxGROW, 0) |
sizer.Add(self.__panel, 1, wxGROW, 0) |
386 |
|
|
387 |
#sizer.Fit(self.__dockPanel) |
self.__dockPanel.SetAutoLayout(True) |
388 |
|
self.__dockPanel.SetSizer(sizer) |
389 |
self.__panel.SetAutoLayout(True) |
sizer.SetSizeHints(self.__dockPanel) |
|
sizer.SetSizeHints(self.__panel) |
|
390 |
|
|
391 |
self.__dockPanel.SetSizerAndFit(sizer) |
sizer.SetSizeHints(self.__topWindow) |
|
#self.__dockPanel.SetAutoLayout(True) |
|
|
#sizer.SetSizeHints(self.__dockPanel) |
|
392 |
|
|
393 |
EVT_BUTTON(self.__dockPanel, ID_BUTTON_DOCK, self._OnToggleDock) |
EVT_BUTTON(self.__dockPanel, ID_BUTTON_DOCK, self._OnToggleDock) |
394 |
EVT_BUTTON(self.__dockPanel, ID_BUTTON_CLOSE, self._OnButtonClose) |
EVT_BUTTON(self.__dockPanel, ID_BUTTON_CLOSE, self._OnButtonClose) |
445 |
sash = wxSashLayoutWindow(self, id, style=wxNO_BORDER|wxSW_3D) |
sash = wxSashLayoutWindow(self, id, style=wxNO_BORDER|wxSW_3D) |
446 |
sash.SetOrientation(orient) |
sash.SetOrientation(orient) |
447 |
sash.SetAlignment(align) |
sash.SetAlignment(align) |
|
#print align, DockFrame.layout2oppSash[align] |
|
448 |
sash.SetSashVisible(DockFrame.layout2oppSash[align], True) |
sash.SetSashVisible(DockFrame.layout2oppSash[align], True) |
449 |
sash.SetSashBorder(DockFrame.layout2oppSash[align], True) |
sash.SetSashBorder(DockFrame.layout2oppSash[align], True) |
450 |
|
|
467 |
self._UpdateDocks() |
self._UpdateDocks() |
468 |
|
|
469 |
def _UpdateDocks(self): |
def _UpdateDocks(self): |
|
#print "_UpdateDocks()" |
|
470 |
if self.__update_lock == 0: |
if self.__update_lock == 0: |
471 |
wxLayoutAlgorithm().LayoutWindow(self, self.__mainWindow) |
wxLayoutAlgorithm().LayoutWindow(self, self.__mainWindow) |
472 |
|
|
478 |
sash = self.FindWindowById(id) |
sash = self.FindWindowById(id) |
479 |
#assert(isinstance(win, wxPanel)) |
#assert(isinstance(win, wxPanel)) |
480 |
dockPanel = sash.GetChildren()[0] |
dockPanel = sash.GetChildren()[0] |
|
#print dockPanel |
|
481 |
panel = dockPanel.FindWindowById(PANEL_ID) |
panel = dockPanel.FindWindowById(PANEL_ID) |
|
#print panel |
|
482 |
assert isinstance(panel, DockPanel) |
assert isinstance(panel, DockPanel) |
483 |
win = panel.GetDockParent() |
win = panel.GetDockParent() |
|
#print win |
|
484 |
assert isinstance(win, DockableWindow) |
assert isinstance(win, DockableWindow) |
485 |
|
|
486 |
assert win.IsDocked() |
assert win.IsDocked() |