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