9 |
|
|
10 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
11 |
|
|
12 |
|
import resource |
13 |
|
|
14 |
from Thuban import _ |
from Thuban import _ |
15 |
|
|
16 |
from wxPython.wx import * |
from wxPython.wx import * |
21 |
|
|
22 |
from messages import DOCKABLE_DOCKED, DOCKABLE_UNDOCKED, DOCKABLE_CLOSED |
from messages import DOCKABLE_DOCKED, DOCKABLE_UNDOCKED, DOCKABLE_CLOSED |
23 |
|
|
|
import gc |
|
|
|
|
24 |
ID_BUTTON_DOCK = 4001 |
ID_BUTTON_DOCK = 4001 |
25 |
ID_BUTTON_CLOSE = 4002 |
ID_BUTTON_CLOSE = 4002 |
26 |
|
|
27 |
PANEL_ID = 3141 |
PANEL_ID = 3141 |
28 |
|
|
29 |
|
DOCK_BMP = "dock_12" |
30 |
|
UNDOCK_BMP = "undock_12" |
31 |
|
CLOSE_BMP = "close_12" |
32 |
|
|
33 |
class DockPanel(wxPanel): |
class DockPanel(wxPanel): |
34 |
|
|
35 |
def __init__(self, parent, id): |
def __init__(self, parent, id): |
166 |
self.__topWindow = self.__dockWindow |
self.__topWindow = self.__dockWindow |
167 |
self.__dockPanel.Reparent(self.__topWindow) |
self.__dockPanel.Reparent(self.__topWindow) |
168 |
|
|
169 |
self.__dockButton.SetLabel(_("Undock")) |
if self.bmpUnDock is not None: |
170 |
|
self.__dockButton.SetBitmapLabel(self.bmpUnDock) |
171 |
|
self.__dockButton.SetBitmapFocus(self.bmpUnDock) |
172 |
|
self.__dockButton.SetToolTip(wxToolTip(_("Undock"))) |
173 |
|
else: |
174 |
|
self.__dockButton.SetLabel(_("Undock")) |
175 |
|
|
176 |
self.SetDockSize(self.__dockWindow.GetSize()) |
self.SetDockSize(self.__dockWindow.GetSize()) |
177 |
|
|
196 |
self.__topWindow = self.__floatWindow |
self.__topWindow = self.__floatWindow |
197 |
self.__dockPanel.Reparent(self.__topWindow) |
self.__dockPanel.Reparent(self.__topWindow) |
198 |
|
|
199 |
self.__dockButton.SetLabel(_("Dock")) |
if self.bmpDock is not None: |
200 |
|
self.__dockButton.SetBitmapLabel(self.bmpDock) |
201 |
|
self.__dockButton.SetBitmapFocus(self.bmpDock) |
202 |
|
self.__dockButton.SetToolTip(wxToolTip(_("Dock"))) |
203 |
|
else: |
204 |
|
self.__dockButton.SetLabel(_("Dock")) |
205 |
|
|
206 |
if wasVisible: self.Show() |
if wasVisible: self.Show() |
207 |
|
|
211 |
if self.__floatPosition is not None: self.SetPosition(self.__floatPosition) |
if self.__floatPosition is not None: self.SetPosition(self.__floatPosition) |
212 |
if self.__floatSize is not None: self.SetSize(self.__floatSize) |
if self.__floatSize is not None: self.SetSize(self.__floatSize) |
213 |
|
|
214 |
|
self.__dockPanel.SetSize(self.__topWindow.GetClientSize()) |
215 |
|
|
216 |
self.issue(DOCKABLE_UNDOCKED, self.__id, self) |
self.issue(DOCKABLE_UNDOCKED, self.__id, self) |
217 |
|
|
218 |
def IsDocked(self): |
def IsDocked(self): |
261 |
self.__panel.Destroy() |
self.__panel.Destroy() |
262 |
self.__floatWindow.Destroy() |
self.__floatWindow.Destroy() |
263 |
self.__dockWindow.Destroy() |
self.__dockWindow.Destroy() |
264 |
self.__parent.OnDockClose(self) |
self.__parent.OnDockDestroy(self) |
265 |
|
|
266 |
## |
## |
267 |
# Event handlers |
# Event handlers |
269 |
|
|
270 |
def _OnButtonClose(self, event): |
def _OnButtonClose(self, event): |
271 |
#self.Close() |
#self.Close() |
272 |
self.Destroy() |
self.Show(False) |
273 |
|
|
274 |
def _OnClose(self, force = False): |
def _OnClose(self, force = False): |
275 |
self.Destroy() |
self.Show(False) |
276 |
|
|
277 |
def _OnToggleDock(self, event): |
def _OnToggleDock(self, event): |
278 |
self.__CheckAllGood() |
self.__CheckAllGood() |
326 |
headerBox = wxStaticBoxSizer( |
headerBox = wxStaticBoxSizer( |
327 |
wxStaticBox(self.__dockPanel, -1, ""), headerBoxOrient) |
wxStaticBox(self.__dockPanel, -1, ""), headerBoxOrient) |
328 |
|
|
329 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
#buttonBox = wxBoxSizer(wxHORIZONTAL) |
330 |
|
|
331 |
# |
# |
332 |
# ideally, we should be able to rotate this text depending on |
# ideally, we should be able to rotate this text depending on |
333 |
# our orientation |
# our orientation |
334 |
# |
# |
335 |
text = wxStaticText(self.__dockPanel, -1, self.GetTitle(), |
text = wxStaticText(self.__dockPanel, -1, self.GetTitle(), |
336 |
style = wxSIMPLE_BORDER | wxALIGN_CENTRE) |
style = wxALIGN_CENTRE) |
337 |
|
|
338 |
|
font = text.GetFont() |
339 |
|
font.SetPointSize(10) |
340 |
|
text.SetFont(font) |
341 |
|
|
342 |
# |
# |
343 |
# Perhaps using wxToggleButton would be better, but it's only |
# Perhaps using wxToggleButton would be better, but it's only |
344 |
# supported under wxMSW and wxGTK as of v2.4.0.3 |
# supported under wxMSW and wxGTK as of v2.4.0.3 |
345 |
# |
# |
346 |
self.__dockButton = wxButton(self.__dockPanel, ID_BUTTON_DOCK, "WWWWWW", |
self.bmpDock = \ |
347 |
style = wxBU_EXACTFIT | wxADJUST_MINSIZE) |
resource.GetBitmapResource(DOCK_BMP, wxBITMAP_TYPE_XPM) |
348 |
|
self.bmpUnDock = \ |
349 |
|
resource.GetBitmapResource(UNDOCK_BMP, wxBITMAP_TYPE_XPM) |
350 |
|
|
351 |
|
if self.bmpDock is not None \ |
352 |
|
and self.bmpUnDock is not None: |
353 |
|
self.__dockButton = wxBitmapButton( |
354 |
|
self.__dockPanel, ID_BUTTON_DOCK, |
355 |
|
self.bmpUnDock, |
356 |
|
size = wxSize(self.bmpDock.GetWidth() + 4, |
357 |
|
self.bmpDock.GetHeight() + 4), |
358 |
|
style = wxBU_EXACTFIT | wxADJUST_MINSIZE) |
359 |
|
else: |
360 |
|
self.bmpDock = \ |
361 |
|
self.bmpUnDock = None |
362 |
|
|
363 |
|
self.__dockButton = wxButton( |
364 |
|
self.__dockPanel, ID_BUTTON_DOCK, |
365 |
|
"WW", style = wxBU_EXACTFIT | wxADJUST_MINSIZE) |
366 |
|
|
367 |
|
bmp = resource.GetBitmapResource(CLOSE_BMP, wxBITMAP_TYPE_XPM) |
368 |
|
|
369 |
|
closeX = wxBitmapButton(self.__dockPanel, ID_BUTTON_CLOSE, bmp, |
370 |
|
size = wxSize(bmp.GetWidth() + 4, |
371 |
|
bmp.GetHeight() + 4), |
372 |
|
style = wxBU_EXACTFIT | wxADJUST_MINSIZE) |
373 |
|
closeX.SetToolTip(wxToolTip(_("Close"))) |
374 |
|
|
375 |
|
|
376 |
closeX = wxButton(self.__dockPanel, ID_BUTTON_CLOSE, "X", |
#closeX = wxButton(self.__dockPanel, ID_BUTTON_CLOSE, "X", |
377 |
style = wxBU_EXACTFIT | wxADJUST_MINSIZE) |
#style = wxBU_EXACTFIT | wxADJUST_MINSIZE) |
378 |
|
|
379 |
buttonBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0) |
#buttonBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0) |
380 |
buttonBox.Add(closeX, 0, wxALIGN_RIGHT, 0) |
#buttonBox.Add(closeX, 0, wxALIGN_RIGHT, 0) |
381 |
|
|
382 |
if self.__orientation == wxLAYOUT_VERTICAL: |
if self.__orientation == wxLAYOUT_VERTICAL: |
383 |
headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0) |
headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0) |
384 |
headerBox.Add(1, 20, 1, wxGROW) |
headerBox.Add(1, 5, 1, wxGROW) |
385 |
headerBox.Add(buttonBox, 0, wxGROW | wxALIGN_RIGHT, 0) |
#headerBox.Add(buttonBox, 0, wxGROW | wxALIGN_RIGHT, 0) |
386 |
|
headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0) |
387 |
|
headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxLEFT, 4) |
388 |
else: |
else: |
389 |
headerBox.Add(buttonBox, 0, wxGROW, 0) |
headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxBOTTOM, 4) |
390 |
|
headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0) |
391 |
headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0) |
headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0) |
392 |
|
|
393 |
sizer.Add(headerBox, 0, wxGROW, 0) |
sizer.Add(headerBox, 0, wxGROW, 0) |
473 |
def FindRegisteredDock(self, name): |
def FindRegisteredDock(self, name): |
474 |
return self.openWindows.get(name) |
return self.openWindows.get(name) |
475 |
|
|
476 |
def OnDockClose(self, win): |
def OnDockDestroy(self, win): |
477 |
del self.openWindows[win.GetName()] |
del self.openWindows[win.GetName()] |
478 |
self._UpdateDocks() |
self._UpdateDocks() |
479 |
|
|