1 |
# Copyright (c) 2001 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
|
# Frank Koormann <[email protected]> |
5 |
# |
# |
6 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
7 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
11 |
from wxPython.wx import * |
from wxPython.wx import * |
12 |
from wxPython.grid import * |
from wxPython.grid import * |
13 |
|
|
14 |
import view |
from Thuban import _ |
15 |
|
|
16 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
17 |
from controls import RecordListCtrl |
from controls import RecordListCtrl, RecordGridCtrl |
18 |
from messages import SELECTED_SHAPE |
from messages import SHAPES_SELECTED |
19 |
|
|
20 |
class IdentifyListCtrl(RecordListCtrl): |
class IdentifyListCtrl(RecordListCtrl): |
21 |
|
|
22 |
def selected_shape(self, layer, shape): |
def selected_shape(self, layer, shape): |
23 |
if layer is not None: |
if layer is not None: |
24 |
table = layer.shapetable |
table = layer.table |
25 |
else: |
else: |
26 |
table = None |
table = None |
27 |
self.fill_list(table, shape) |
self.fill_list(table, shape) |
28 |
|
|
29 |
|
class IdentifyGridCtrl(RecordGridCtrl): |
30 |
|
|
31 |
|
def selected_shape(self, layer, shape): |
32 |
|
if layer is not None: |
33 |
|
table = layer.table |
34 |
|
else: |
35 |
|
table = None |
36 |
|
self.SetTableRecord(table, shape) |
37 |
|
|
38 |
class IdentifyView(NonModalDialog): |
class IdentifyView(NonModalDialog): |
39 |
|
|
40 |
def __init__(self, parent, interactor, name): |
def __init__(self, parent, name): |
41 |
NonModalDialog.__init__(self, parent, interactor, name, |
NonModalDialog.__init__(self, parent, name, _("Identify Shape")) |
42 |
"Identify Shape") |
parent.Subscribe(SHAPES_SELECTED, self.selected_shape) |
43 |
self.interactor.Subscribe(SELECTED_SHAPE, self.selected_shape) |
|
44 |
|
top_box = wxBoxSizer(wxVERTICAL) |
45 |
panel = wxPanel(self, -1, style = wxWANTS_CHARS) |
#self.list = IdentifyGridCtrl(panel) |
46 |
self.list = IdentifyListCtrl(panel, -1) |
self.list = IdentifyListCtrl(self, -1) |
47 |
|
self.list.SetSize(wxSize(305,200)) |
48 |
sizer = wxBoxSizer(wxVERTICAL) |
top_box.Add(self.list, 1, wxEXPAND|wxALL, 4) |
49 |
sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0) |
|
50 |
|
box = wxBoxSizer(wxHORIZONTAL) |
51 |
panel.SetAutoLayout(true) |
box.Add(wxButton(self, wxID_CLOSE, _("Close")), 0, wxALL, 4) |
52 |
panel.SetSizer(sizer) |
top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 4) |
53 |
sizer.Fit(panel) |
|
54 |
|
EVT_BUTTON(self, wxID_CLOSE, self.OnClose) |
55 |
|
|
56 |
|
self.SetAutoLayout(True) |
57 |
|
self.SetSizer(top_box) |
58 |
|
top_box.Fit(self) |
59 |
|
top_box.SetSizeHints(self) |
60 |
|
|
61 |
def OnClose(self, event): |
def OnClose(self, event): |
62 |
self.interactor.Unsubscribe(SELECTED_SHAPE, self.selected_shape) |
self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape) |
63 |
NonModalDialog.OnClose(self, event) |
NonModalDialog.OnClose(self, event) |
64 |
|
|
65 |
def selected_shape(self, layer, shape): |
def selected_shape(self, layer, shapes): |
66 |
|
"""Subscribed to the SHAPES_SELECTED messages. |
67 |
|
|
68 |
|
If exatly one shape is selected, pass that shape id to the |
69 |
|
list's selected_shape method. Otherwise pass None as the shape |
70 |
|
id. |
71 |
|
""" |
72 |
|
if len(shapes) == 1: |
73 |
|
shape = shapes[0] |
74 |
|
else: |
75 |
|
shape = None |
76 |
self.list.selected_shape(layer, shape) |
self.list.selected_shape(layer, shape) |