1 |
bh |
535 |
# Copyright (c) 2001, 2003 by Intevation GmbH |
2 |
bh |
28 |
# Authors: |
3 |
|
|
# Bernhard Herzog <[email protected]> |
4 |
frank |
1057 |
# Frank Koormann <[email protected]> |
5 |
bh |
28 |
# |
6 |
|
|
# This program is free software under the GPL (>=v2) |
7 |
|
|
# Read the file COPYING coming with Thuban for details. |
8 |
|
|
|
9 |
|
|
"""Base classes for dialogs""" |
10 |
|
|
|
11 |
|
|
__version__ = "$Revision$" |
12 |
|
|
|
13 |
dpinte |
2700 |
import wx |
14 |
jonathan |
814 |
|
15 |
dpinte |
2700 |
class ThubanFrame(wx.Frame): |
16 |
jonathan |
1198 |
|
17 |
|
|
def __init__(self, parent, name, title): |
18 |
dpinte |
2700 |
wx.Frame.__init__(self, parent, -1, title, |
19 |
|
|
style = wx.DEFAULT_FRAME_STYLE ) |
20 |
jonathan |
1198 |
self.parent = parent |
21 |
|
|
self.name = name |
22 |
dpinte |
2700 |
self.Bind(wx.EVT_CLOSE, self.OnClose) |
23 |
|
|
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) |
24 |
jonathan |
1198 |
|
25 |
|
|
def OnClose(self, event): |
26 |
bh |
1891 |
# FIXME: Shouldn't this really be in OnDestroy? |
27 |
jonathan |
1198 |
if self.parent.dialogs.has_key(self.name): |
28 |
|
|
self.parent.remove_dialog(self.name) |
29 |
|
|
self.Destroy() |
30 |
|
|
|
31 |
bh |
1891 |
def OnDestroy(self, event): |
32 |
|
|
"""Implement in derived classes for resource cleanup, etc.""" |
33 |
|
|
|
34 |
|
|
|
35 |
dpinte |
2700 |
class NonModalDialog(wx.Dialog): |
36 |
bh |
535 |
def __init__(self, parent, name, title): |
37 |
dpinte |
2700 |
wx.Dialog.__init__(self, parent, -1, title, |
38 |
|
|
style = wx.DEFAULT_DIALOG_STYLE |
39 |
|
|
| wx.SYSTEM_MENU |
40 |
|
|
| wx.MINIMIZE_BOX |
41 |
|
|
| wx.MAXIMIZE_BOX |
42 |
|
|
| wx.RESIZE_BORDER |
43 |
frank |
1057 |
) |
44 |
bh |
28 |
self.parent = parent |
45 |
|
|
self.name = name |
46 |
dpinte |
2700 |
self.Bind(wx.EVT_CLOSE, self.OnClose) |
47 |
bh |
28 |
|
48 |
|
|
def OnClose(self, event): |
49 |
frank |
1057 |
if self.parent.dialogs.has_key(self.name): |
50 |
|
|
self.parent.remove_dialog(self.name) |
51 |
bh |
28 |
self.Destroy() |
52 |
frank |
1057 |
|
53 |
dpinte |
2700 |
class NonModalNonParentDialog(wx.Dialog): |
54 |
frank |
1057 |
def __init__(self, parent, name, title): |
55 |
dpinte |
2700 |
wx.Dialog.__init__(self, None, -1, title, |
56 |
|
|
style = wx.DEFAULT_DIALOG_STYLE |
57 |
|
|
| wx.SYSTEM_MENU |
58 |
|
|
| wx.MINIMIZE_BOX |
59 |
|
|
| wx.MAXIMIZE_BOX |
60 |
|
|
| wx.RESIZE_BORDER |
61 |
|
|
| wx.DIALOG_NO_PARENT |
62 |
frank |
1057 |
) |
63 |
|
|
self.parent = parent |
64 |
|
|
self.name = name |
65 |
dpinte |
2700 |
self.Bind(wx.EVT_CLOSE, self.OnClose) |
66 |
frank |
1057 |
|
67 |
|
|
def OnClose(self, event): |
68 |
|
|
if self.parent.dialogs.has_key(self.name): |
69 |
|
|
self.parent.remove_dialog(self.name) |
70 |
|
|
self.Destroy() |