/[thuban]/branches/WIP-pyshapelib-bramz/Extensions/umn_mapserver/mf_handle.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Extensions/umn_mapserver/mf_handle.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2257 - (hide annotations)
Thu Jul 1 14:35:07 2004 UTC (20 years, 8 months ago) by jschuengel
Original Path: trunk/thuban/Extensions/umn_mapserver/mf_handle.py
File MIME type: text/x-python
File size: 26642 byte(s)
This module extents Thuban with the possibility to edit the mapfile content.

1 jschuengel 2257 # -*- coding:latin1 -*-
2     # Copyright (C) 2004 by Intevation GmbH
3     # Authors:
4     # Jan Schüngel <[email protected]>
5     #
6     # This program is free software under the GPL (>=v2)
7     # Read the file COPYING coming with Thuban for details.
8    
9     """
10     This modul extend Thuban with the possibility to handle
11     UMN MapServer mapfiles.
12     """
13    
14     __version__ = "$Revision$"
15     # $Source$
16     # $Id$
17    
18    
19     # ###################################
20     #
21     # import necessary modules
22     #
23     # ###################################
24    
25     import os, sys
26    
27     # mapscript
28     from mapscript import mapObj
29    
30     # wxPython support
31     # TODO: explicitly use from .. import
32     from wxPython.wx import *
33    
34     # Thuban
35     # use _() already now for all strings that may later be translated
36     from Thuban import _
37    
38     # Thuban has named commands which can be registered in the central
39     # instance registry.
40     from Thuban.UI.command import registry, Command
41    
42     # The instance of the main menu of the Thuban application
43     import Thuban.UI.mainwindow
44    
45     # needed to add the new menu
46     from Thuban.UI.mainwindow import main_menu
47    
48     # import Map Object for the Mapfile
49     from mapfile import MF_Map
50    
51     from Thuban.UI.colordialog import ColorDialog
52    
53     from mapfile import unit_type, legend_status_type, legend_position_type, \
54     label_font_type
55    
56     # ###################################
57     #
58     # Mainpart of the Extension
59     #
60     # ###################################
61    
62     ID_COLOR_CHANGE= 8001
63    
64     class Map_Dialog(wxDialog):
65    
66     def __init__(self, parent, ID, title,
67     pos=wxDefaultPosition, size=wxDefaultSize,
68     style=wxDEFAULT_DIALOG_STYLE):
69    
70     # initialize the Dialog
71     wxDialog.__init__(self, parent, ID, title, pos, size, style)
72    
73     # parent.canvas.Map()
74     self.tb_map = parent.canvas.Map()
75     self.tb_map_umn = self.tb_map.extension_umn_mapobj
76    
77     # create name
78     box_name = wxBoxSizer(wxHORIZONTAL)
79     box_name.Add(wxStaticText(self, -1, _("Map-Name:")), 0,
80     wxALL|wxALIGN_CENTER_VERTICAL, 4)
81     box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0,
82     wxALL|wxALIGN_CENTER_VERTICAL, 4)
83    
84     #create size settings
85     try:
86     insidetxt = self.tb_map_umn.get_size()
87     except:
88     insidetxt = (0,0)
89     # create the Size Box
90     staticSize = wxStaticBox(self, 1010, _("Size"), style = 0, name = "staticBox", )
91     box_size = wxStaticBoxSizer(staticSize, wxVERTICAL)
92    
93     box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
94     box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 4)
95     self.text_width = wxTextCtrl(self, -1, str(insidetxt[0]))
96     box_sizepartWidth.Add(self.text_width, 2, wxALL, 4)
97     box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5)
98     box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
99     box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4)
100     self.text_height = wxTextCtrl(self, -1, str(insidetxt[1]))
101     box_sizepartHeight.Add(self.text_height, 2, wxALL, 4)
102     box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5)
103    
104     #get the set unittype
105     insideunit = self.tb_map_umn.get_units()
106    
107     #create the Unittype selector
108     box_unitsStatic = wxStaticBox(self, 1011, _("Unit Type"), style = 0, name = "imagecolor")
109     box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL)
110     sam = []
111     for key in unit_type:
112     sam.append(unit_type[key])
113     self.choice_units = wxChoice(self, 40, (80, 50), choices = sam)
114     self.choice_units.SetStringSelection(insideunit)
115     box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5)
116    
117     # color chouser
118     box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor")
119     box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
120    
121     # preview box
122     self.previewcolor = wxPanel(self,99, name = 'backgroundPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
123     imagecolor = self.tb_map_umn.get_imagecolor()
124     self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(),
125     imagecolor.get_green(), imagecolor.get_blue()))
126     box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
127     # color change button, opens a new color dialog
128     button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
129     button.SetFocus()
130     EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
131     box_color.Add(button, 1, wxEXPAND|wxALL, 5)
132    
133     #buttons
134     box_buttons = wxBoxSizer(wxHORIZONTAL)
135     button = wxButton(self, wxID_OK, _("OK"))
136     box_buttons.Add(button, 0, wxALL, 5)
137     button = wxButton(self, wxID_CANCEL, _("Cancel"))
138     box_buttons.Add(button, 0, wxALL, 5)
139     #set the button funcitons
140     EVT_BUTTON(self, wxID_OK, self.OnOK)
141     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
142    
143     #add all boxes to the box top
144     top = wxBoxSizer(wxVERTICAL)
145     top.Add(box_name, 0, wxEXPAND |wxALL, 5)
146     top.Add(box_size, 0, wxEXPAND |wxALL, 5)
147     top.Add(box_units,0, wxEXPAND |wxALL, 5)
148     top.Add(box_color,0, wxEXPAND |wxALL, 5)
149     top.Add(box_buttons, 0, wxALIGN_RIGHT)
150    
151     # final layout settings
152     self.SetSizer(top)
153     top.Fit(self)
154    
155     def OnChangeColor(self, event):
156     cur = self.tb_map_umn.get_imagecolor().get_thubancolor()
157     dialog = ColorDialog(self)
158     dialog.SetColor(cur)
159     self.retcolor = None
160     if dialog.ShowModal() == wxID_OK:
161     self.retcolor = dialog.GetColor()
162     dialog.Destroy()
163     if self.retcolor:
164     self.redcolor = int(round(self.retcolor.red*255))
165     self.greencolor = int(round(self.retcolor.green*255))
166     self.bluecolor = int(round(self.retcolor.blue*255))
167     self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
168     int(self.greencolor), int(self.bluecolor)))
169     self.tb_map_umn.get_imagecolor().set_rgbcolor(self.redcolor,
170     self.greencolor, self.bluecolor)
171    
172     def RunDialog(self):
173     self.ShowModal()
174     self.Destroy()
175    
176     def end_dialog(self, result):
177     self.result = result
178     if self.result is not None:
179     self.EndModal(wxID_OK)
180     else:
181     self.EndModal(wxID_CANCEL)
182     self.Show(False)
183    
184     def OnOK(self, event):
185     self.tb_map_umn.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue()))
186     self.tb_map_umn.set_units(self.choice_units.GetStringSelection())
187     self.result ="OK"
188     self.end_dialog(self.result)
189    
190     def OnCancel(self, event):
191     self.end_dialog(None)
192    
193    
194     class Web_Dialog(wxDialog):
195    
196     def __init__(self, parent, ID, title,
197     pos=wxDefaultPosition, size=wxDefaultSize,
198     style=wxDEFAULT_DIALOG_STYLE):
199    
200     # initialize the Dialog
201     wxDialog.__init__(self, parent, ID, title, pos, size, style)
202    
203     #add all boxes to this top box
204     top = wxBoxSizer(wxVERTICAL)
205    
206     # get the web object
207     self.tb_map = parent.canvas.Map()
208     self.umn_web = self.tb_map.extension_umn_mapobj.get_web()
209    
210     # create name
211     box_name = wxBoxSizer(wxHORIZONTAL)
212     box_name.Add(wxStaticText(self, -1, _("Map-Name:")), 0,
213     wxALL|wxALIGN_CENTER_VERTICAL, 4)
214     box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0,
215     wxALL|wxALIGN_CENTER_VERTICAL, 4)
216     top.Add(box_name, 0, wxEXPAND |wxALL, 5)
217    
218     # Imagepath
219     box_imagepath = wxBoxSizer(wxHORIZONTAL)
220     box_imagepath.Add(wxStaticText(self, -1, _("Imagepath:")), 0,
221     wxALL|wxALIGN_LEFT, 4)
222     self.text_imagepath = wxTextCtrl(self, -1, str(self.umn_web.get_imagepath()))
223     box_imagepath.Add(self.text_imagepath, 0,
224     wxALL|wxALIGN_CENTER_VERTICAL, 4)
225     top.Add(box_imagepath, 0, wxEXPAND |wxALL, 5)
226    
227     # Imageurl
228     box_imageurl = wxBoxSizer(wxHORIZONTAL)
229     box_imageurl.Add(wxStaticText(self, -1, _("Imageurl:")), 0,
230     wxALL|wxALIGN_LEFT, 4)
231     self.text_imageurl = wxTextCtrl(self, -1, str(self.umn_web.get_imageurl()))
232     box_imageurl.Add(self.text_imageurl, 0,
233     wxALL|wxALIGN_CENTER_VERTICAL, 4)
234     top.Add(box_imageurl, 0, wxEXPAND |wxALL, 5)
235    
236     # queryformat
237     # include from a query dialog later
238     """box_queryformat = wxBoxSizer(wxHORIZONTAL)
239     box_queryformat.Add(wxStaticText(self, -1, _("Queryformat:")), 0,
240     wxALL|wxALIGN_LEFT, 4)
241     self.text_queryformat = wxTextCtrl(self, -1, str(self.umn_web.get_queryformat()))
242     box_queryformat.Add(self.text_queryformat, 0,
243     wxALL|wxALIGN_CENTER_VERTICAL, 4)
244     top.Add(box_queryformat, 0, wxEXPAND |wxALL, 5)
245     """
246    
247     #buttons
248     box_buttons = wxBoxSizer(wxHORIZONTAL)
249     button = wxButton(self, wxID_OK, _("OK"))
250     box_buttons.Add(button, 0, wxALL, 5)
251     button = wxButton(self, wxID_CANCEL, _("Cancel"))
252     box_buttons.Add(button, 0, wxALL, 5)
253     #set the button funcitons
254     EVT_BUTTON(self, wxID_OK, self.OnOK)
255     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
256     top.Add(box_buttons, 0, wxALIGN_RIGHT)
257    
258     # final layout settings
259     self.SetSizer(top)
260     top.Fit(self)
261    
262     def RunDialog(self):
263     self.ShowModal()
264     self.Destroy()
265    
266     def end_dialog(self, result):
267     self.result = result
268     if self.result is not None:
269     self.EndModal(wxID_OK)
270     else:
271     self.EndModal(wxID_CANCEL)
272     self.Show(False)
273    
274     def OnOK(self, event):
275     self.umn_web.set_imagepath(self.text_imagepath.GetValue())
276     self.umn_web.set_imageurl(self.text_imageurl.GetValue())
277     self.umn_web.set_queryformat(self.text_queryformat.GetValue())
278     self.result ="OK"
279     self.end_dialog(self.result)
280    
281     def OnCancel(self, event):
282     self.end_dialog(None)
283    
284    
285    
286     ID_LABEL_CHANGE = 8011
287    
288     class Legend_Dialog(wxDialog):
289    
290     def __init__(self, parent, ID, title,
291     pos=wxDefaultPosition, size=wxDefaultSize,
292     style=wxDEFAULT_DIALOG_STYLE):
293    
294     # initialize the Dialog
295     wxDialog.__init__(self, parent, ID, title, pos, size, style)
296    
297     #add all boxes to this top box
298     top = wxBoxSizer(wxVERTICAL)
299    
300     # get the web object
301     self.tb_map = parent.canvas.Map()
302     self.umn_legend = self.tb_map.extension_umn_mapobj.get_legend()
303    
304     # create the Keysize
305     keySize = wxStaticBox(self, 1010, _("KeySize"), style = 0, name = "KeySize Box", )
306     box_keysize = wxStaticBoxSizer(keySize, wxVERTICAL)
307     umn_legend_keysize = self.umn_legend.get_keysize()
308     box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
309     box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 2)
310     self.text_keysize_width = wxSpinCtrl(self, -1,
311     value=str(umn_legend_keysize[0]), max=100, min=0,
312     name='keywidth', style=wxSP_ARROW_KEYS)
313     box_sizepartWidth.Add(self.text_keysize_width, 2, wxALL, 2)
314     box_keysize.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 2)
315     box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
316     box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 2),
317     self.text_keysize_height = wxSpinCtrl(self, -1,
318     value=str(umn_legend_keysize[1]), max=100, min=0,
319     name='keyheight', style=wxSP_ARROW_KEYS)
320     box_sizepartHeight.Add(self.text_keysize_height, 2, wxALL, 2)
321     box_keysize.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2)
322     top.Add(box_keysize,0, wxEXPAND |wxALL, 5)
323    
324     # create the Keyspacing
325     keySpacing= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", )
326     box_keyspacing = wxStaticBoxSizer(keySpacing, wxVERTICAL)
327     umn_legend_keyspacing = self.umn_legend.get_keyspacing()
328     box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
329     box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 2)
330     self.text_keyspacing_width = wxSpinCtrl(self, -1,
331     value=str(umn_legend_keyspacing[0]), max=100, min=0,
332     name='spacingwidth', style=wxSP_ARROW_KEYS)
333     box_sizepartWidth.Add(self.text_keyspacing_width, 2, wxALL, 2)
334     box_keyspacing.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 2)
335     box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
336     box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 2),
337     self.text_keyspacing_height = wxSpinCtrl(self, -1,
338     value=str(umn_legend_keyspacing[1]), max=100, min=0,
339     name='spacingheight', style=wxSP_ARROW_KEYS)
340     box_sizepartHeight.Add(self.text_keyspacing_height, 2, wxALL, 2)
341     box_keyspacing.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2)
342     top.Add(box_keyspacing,0, wxEXPAND |wxALL, 5)
343    
344     # color chooser
345     box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor")
346     box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
347     # preview box
348     self.previewcolor = wxPanel(self, 99, name = 'imagecolorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
349     imagecolor = self.umn_legend.get_imagecolor()
350     self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(),
351     imagecolor.get_green(), imagecolor.get_blue()))
352     box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
353     # color change button, opens a new color dialog
354     button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
355     button.SetFocus()
356     EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
357     box_color.Add(button, 1, wxEXPAND|wxALL, 5)
358     top.Add(box_color,0, wxEXPAND |wxALL, 5)
359    
360     # create the positionbox
361     umn_legend_status= self.umn_legend.get_status(art="string")
362     possible_choices = []
363     for key in legend_status_type:
364     possible_choices.append(legend_status_type[key])
365     self.choice_status = wxRadioBox(self, -1, choices=possible_choices,
366     label='Status', majorDimension=1,
367     name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
368     self.choice_status.SetStringSelection(umn_legend_status)
369     top.Add(self.choice_status,0, wxEXPAND |wxALL, 5)
370    
371     # create the positionbox
372     umn_legend_position= self.umn_legend.get_position(art="string")
373     possible_choices = []
374     for key in legend_position_type:
375     possible_choices.append(legend_position_type[key])
376     self.choice_position = wxRadioBox(self, -1, choices=possible_choices,
377     label='Position', majorDimension=1,
378     name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
379     self.choice_position.SetStringSelection(umn_legend_position)
380     top.Add(self.choice_position,0, wxEXPAND |wxALL, 5)
381    
382     #test button for label
383     button = wxButton(self, ID_LABEL_CHANGE, _("Change Label"))
384     button.SetFocus()
385     EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel)
386     top.Add(button, 1, wxEXPAND|wxALL, 5)
387    
388     #buttons
389     box_buttons = wxBoxSizer(wxHORIZONTAL)
390     button = wxButton(self, wxID_OK, _("OK"))
391     box_buttons.Add(button, 0, wxALL, 5)
392     button = wxButton(self, wxID_CANCEL, _("Cancel"))
393     box_buttons.Add(button, 0, wxALL, 5)
394     #set the button funcitons
395     EVT_BUTTON(self, wxID_OK, self.OnOK)
396     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
397     top.Add(box_buttons, 0, wxALIGN_RIGHT)
398    
399     # final layout settings
400     self.SetSizer(top)
401     top.Fit(self)
402    
403     def OnChangeLabel(self, event):
404     dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200),
405     style = wxDEFAULT_DIALOG_STYLE
406     )
407     dialog.CenterOnScreen()
408     if dialog.ShowModal() == wxID_OK:
409     return
410     dialog.Destroy()
411    
412     def OnChangeColor(self, event):
413     cur = self.umn_legend.get_imagecolor().get_thubancolor()
414     dialog = ColorDialog(self)
415     dialog.SetColor(cur)
416     self.retcolor = None
417     if dialog.ShowModal() == wxID_OK:
418     self.retcolor = dialog.GetColor()
419     dialog.Destroy()
420     if self.retcolor:
421     self.redcolor = int(round(self.retcolor.red*255))
422     self.greencolor = int(round(self.retcolor.green*255))
423     self.bluecolor = int(round(self.retcolor.blue*255))
424     self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
425     int(self.greencolor), int(self.bluecolor)))
426     self.umn_legend.get_imagecolor().set_rgbcolor(self.redcolor,
427     self.greencolor, self.bluecolor)
428    
429     def RunDialog(self):
430     self.ShowModal()
431     self.Destroy()
432    
433     def end_dialog(self, result):
434     self.result = result
435     if self.result is not None:
436     self.EndModal(wxID_OK)
437     else:
438     self.EndModal(wxID_CANCEL)
439     self.Show(False)
440    
441     def OnOK(self, event):
442     self.umn_legend.set_keysize(self.text_keysize_width.GetValue(),self.text_keysize_height.GetValue())
443     self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(),self.text_keyspacing_height.GetValue())
444     self.umn_legend.set_status(self.choice_status.GetStringSelection())
445     self.umn_legend.set_position(self.choice_position.GetStringSelection())
446     self.result ="OK"
447     self.end_dialog(self.result)
448    
449     def OnCancel(self, event):
450     self.end_dialog(None)
451    
452     class Label_Dialog(wxDialog):
453    
454     def __init__(self, parent, ID, title,
455     pos=wxDefaultPosition, size=wxDefaultSize,
456     style=wxDEFAULT_DIALOG_STYLE):
457    
458     # initialize the Dialog
459     wxDialog.__init__(self, parent, ID, title, pos, size, style)
460    
461     #add all boxes to this top box
462     top = wxBoxSizer(wxVERTICAL)
463    
464     # get the web object
465     #self.tb_map = parent.canvas.Map()
466     self.umn_label = parent.umn_legend.get_label()
467    
468     # size
469     labelsize= wxStaticBox(self, 1010, _("Size"), style = 0, name = "Size Box", )
470     box_labelsize = wxStaticBoxSizer(labelsize, wxVERTICAL)
471     umn_label_size= self.umn_label.get_size()
472     box_size = wxBoxSizer(wxHORIZONTAL)
473     box_size.Add(wxStaticText(self, -1, _("Size: ")), 0, wxALL, 2)
474     self.text_labelsize = wxSpinCtrl(self, -1,
475     value=str(umn_label_size), max=10, min=0,
476     name='size', style=wxSP_ARROW_KEYS)
477     box_size.Add(self.text_labelsize, 2, wxALL, 2)
478     box_labelsize.Add(box_size, 0, wxALIGN_RIGHT | wxALL, 2)
479     top.Add(box_labelsize,0, wxEXPAND |wxALL, 5)
480    
481    
482     # color chooser
483     box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color")
484     box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
485     # preview box
486     self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
487     color = self.umn_label.get_color()
488     self.previewcolor.SetBackgroundColour(wxColour(color.get_red(),
489     color.get_green(), color.get_blue()))
490     box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
491     # color change button, opens a new color dialog
492     button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
493     button.SetFocus()
494     EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
495     box_color.Add(button, 1, wxEXPAND|wxALL, 5)
496     top.Add(box_color,0, wxEXPAND |wxALL, 5)
497    
498     #get the set type
499     insidetype = self.umn_label.get_type()
500     #create the type selector for fonttype (Bitmap, TrueType)
501     # TODO: Truetype is not supported yet
502     box_typeStatic = wxStaticBox(self, 1011, _("Type"), style = 0, name = "type")
503     box_type = wxStaticBoxSizer(box_typeStatic, wxVERTICAL)
504     sam = []
505     for key in label_font_type:
506     # dont add truetype
507     #if key != 0:
508     sam.append(label_font_type[key])
509     self.choice_type = wxChoice(self, 40, (80, 50), choices = sam)
510     self.choice_type.SetStringSelection(insidetype)
511     box_type.Add(self.choice_type,0, wxEXPAND, wxALL, 5)
512     top.Add(box_type,0,wxEXPAND |wxALL, 5)
513    
514    
515     # Offset
516     offset= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", )
517     box_offset = wxStaticBoxSizer(offset, wxVERTICAL)
518     umn_label_offset = self.umn_label.get_offset()
519     box_offsetX = wxBoxSizer(wxHORIZONTAL)
520     box_offsetX.Add(wxStaticText(self, -1, _("X: ")), 0, wxALL, 2)
521     self.text_offsetx = wxSpinCtrl(self, -1,
522     value=str(umn_label_offset[0]), max=20, min=0,
523     name='offsetX', style=wxSP_ARROW_KEYS)
524     box_offsetX.Add(self.text_offsetx, 2, wxALL, 2)
525     box_offset.Add(box_offsetX, 0, wxALIGN_RIGHT | wxALL, 2)
526     box_offsetY = wxBoxSizer(wxHORIZONTAL)
527     box_offsetY.Add(wxStaticText(self, -1, _("Y: ")), 0, wxALL, 2),
528     self.text_offsety = wxSpinCtrl(self, -1,
529     value=str(umn_label_offset[1]), max=100, min=0,
530     name='offsetY', style=wxSP_ARROW_KEYS)
531     box_offsetY.Add(self.text_offsety, 2, wxALL, 2)
532     box_offset.Add(box_offsetY, 0, wxALIGN_RIGHT | wxALL, 2)
533     top.Add(box_offset,0, wxEXPAND |wxALL, 5)
534    
535    
536     #buttons
537     box_buttons = wxBoxSizer(wxHORIZONTAL)
538     button = wxButton(self, wxID_OK, _("OK"))
539     box_buttons.Add(button, 0, wxALL, 5)
540     button = wxButton(self, wxID_CANCEL, _("Cancel"))
541     box_buttons.Add(button, 0, wxALL, 5)
542     #set the button funcitons
543     EVT_BUTTON(self, wxID_OK, self.OnOK)
544     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
545     top.Add(box_buttons, 0, wxALIGN_RIGHT)
546    
547     # final layout settings
548     self.SetSizer(top)
549     top.Fit(self)
550    
551     def OnChangeColor(self, event):
552     cur = self.umn_label.get_color().get_thubancolor()
553     dialog = ColorDialog(self)
554     dialog.SetColor(cur)
555     self.retcolor = None
556     if dialog.ShowModal() == wxID_OK:
557     self.retcolor = dialog.GetColor()
558     dialog.Destroy()
559     if self.retcolor:
560     self.redcolor = int(round(self.retcolor.red*255))
561     self.greencolor = int(round(self.retcolor.green*255))
562     self.bluecolor = int(round(self.retcolor.blue*255))
563     self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
564     int(self.greencolor), int(self.bluecolor)))
565     self.umn_label.get_color().set_rgbcolor(self.redcolor,
566     self.greencolor, self.bluecolor)
567    
568     def RunDialog(self):
569     self.ShowModal()
570     self.Destroy()
571    
572     def end_dialog(self, result):
573     self.result = result
574     if self.result is not None:
575     self.EndModal(wxID_OK)
576     else:
577     self.EndModal(wxID_CANCEL)
578     self.Show(False)
579    
580     def OnOK(self, event):
581     self.umn_label.set_size(self.text_labelsize.GetValue())
582     self.umn_label.set_offset(self.text_offsetx.GetValue(), self.text_offsety.GetValue())
583     self.umn_label.set_type(self.choice_type.GetStringSelection())
584     self.result ="OK"
585     self.end_dialog(self.result)
586    
587     def OnCancel(self, event):
588     self.end_dialog(None)
589    
590    
591     def mapsettings(context):
592     win = Map_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200),
593     style = wxDEFAULT_DIALOG_STYLE
594     )
595     win.CenterOnScreen()
596     val = win.ShowModal()
597    
598     def websettings(context):
599     win = Web_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200),
600     style = wxDEFAULT_DIALOG_STYLE
601     )
602     win.CenterOnScreen()
603     val = win.ShowModal()
604    
605     def legendsettings(context):
606     win = Legend_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200),
607     style = wxDEFAULT_DIALOG_STYLE
608     )
609     win.CenterOnScreen()
610     val = win.ShowModal()
611    
612     #create a new mapfile
613     def create_new_mapfile(context):
614     theMap = MF_Map(mapObj(""))
615     context.mainwindow.canvas.Map().extension_umn_mapobj = theMap
616    
617     # ###################################
618     #
619     # Hook in MapServer Extension into Thuban
620     #
621     # ###################################
622    
623     # find the extensions menu (create it anew if not found)
624     experimental_menu = main_menu.FindOrInsertMenu("experimental", _("Experimenta&l"))
625     # find the extension menu and add a new submenu if found
626     mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", _("&MapServer"))
627    
628    
629     # register the new command
630     registry.Add(Command("create_new_mapfile", _("Create an empty MapObj"), \
631     create_new_mapfile, helptext = _("Create a new empty mapscript MapObj")))
632     # finally add the new entry to the extensions menu
633     mapserver_menu.InsertItem("create_new_mapfile")
634    
635    
636     # register the new command (Map Settings Dialog)
637     registry.Add(Command("Map Settings", _("Map Settings"), mapsettings,
638     helptext = _("Edit the Map Setting")))
639     # finally add the new entry to the extensions menu
640     mapserver_menu.InsertItem("Map Settings")
641    
642     # register the new command (Map Settings Dialog)
643     registry.Add(Command("Web Settings", _("Web Settings"), websettings,
644     helptext = _("Edit the Web Setting")))
645     # finally add the new entry to the extensions menu
646     mapserver_menu.InsertItem("Web Settings")
647    
648     # register the new command (Legend Settings Dialog)
649     registry.Add(Command("Legend Settings", _("Legend Settings"), legendsettings,
650     helptext = _("Edit the Legend Setting")))
651     # finally add the new entry to the extensions menu
652     mapserver_menu.InsertItem("Legend Settings")
653    
654    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26