Mercurial > traipse_dev
comparison orpg/mapper/min_dialogs.py @ 0:4385a7d0efd1 grumpy-goblin
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author | sirebral |
---|---|
date | Tue, 14 Jul 2009 16:41:58 -0500 |
parents | |
children | 78407d627cba |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4385a7d0efd1 |
---|---|
1 # Copyright (C) 2000-2001 The OpenRPG Project | |
2 # | |
3 # openrpg-dev@lists.sourceforge.net | |
4 # | |
5 # This program is free software; you can redistribute it and/or modify | |
6 # it under the terms of the GNU General Public License as published by | |
7 # the Free Software Foundation; either version 2 of the License, or | |
8 # (at your option) any later version. | |
9 # | |
10 # This program is distributed in the hope that it will be useful, | |
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 # GNU General Public License for more details. | |
14 # | |
15 # You should have received a copy of the GNU General Public License | |
16 # along with this program; if not, write to the Free Software | |
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
18 # -- | |
19 # | |
20 # File: mapper/min_dialogs.py | |
21 # Author: Chris Davis | |
22 # Maintainer: | |
23 # Version: | |
24 # $Id: min_dialogs.py,v 1.27 2006/11/13 02:23:16 digitalxero Exp $ | |
25 # | |
26 # Description: This file contains some of the basic definitions for the chat | |
27 # utilities in the orpg project. | |
28 | |
29 ##----------------------------- | |
30 ## Miniature List Panel | |
31 ##----------------------------- | |
32 | |
33 from miniatures import * | |
34 | |
35 class min_list_panel(wx.Dialog): | |
36 | |
37 def __init__(self, parent,layers, log, pos =(-1,-1)): | |
38 wx.Dialog.__init__(self, parent,-1, log,pos = (-1,-1), size = (785,175), style=wx.RESIZE_BORDER) | |
39 listID = wx.NewId() | |
40 self.parent = parent | |
41 self.min = layers['miniatures'].miniatures | |
42 self.grid = layers['grid'] | |
43 self.layers = layers | |
44 self.listID = listID | |
45 list_sizer = wx.BoxSizer(wx.VERTICAL) | |
46 self.list_sizer = list_sizer | |
47 listctrl = wx.ListCtrl(self, listID, style=wx.LC_REPORT | wx.SUNKEN_BORDER) | |
48 self.listctrl = listctrl | |
49 self.Centre(wx.BOTH) | |
50 self.log = log | |
51 self.list_sizer.Add(self.listctrl,1,wx.EXPAND) | |
52 self.listctrl.InsertColumn(0,"POS ") | |
53 self.listctrl.InsertColumn(0,"LOCKED") | |
54 self.listctrl.InsertColumn(0,"HEADING") | |
55 self.listctrl.InsertColumn(0,"FACING") | |
56 self.listctrl.InsertColumn(0,"LABEL") | |
57 self.listctrl.InsertColumn(0,"PATH") | |
58 self.listctrl.SetColumnWidth(1, wx.LIST_AUTOSIZE_USEHEADER) | |
59 self.listctrl.SetColumnWidth(2, wx.LIST_AUTOSIZE_USEHEADER) | |
60 self.listctrl.SetColumnWidth(3, wx.LIST_AUTOSIZE_USEHEADER) | |
61 self.listctrl.SetColumnWidth(4, wx.LIST_AUTOSIZE_USEHEADER) | |
62 self.listctrl.SetColumnWidth(5, wx.LIST_AUTOSIZE_USEHEADER) | |
63 self.list_sizer.Add(wx.Button(self, wx.ID_OK, "DONE"),0,wx.ALIGN_CENTER) | |
64 self.refresh() | |
65 self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK) | |
66 self.listctrl.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick, id=listID) | |
67 self.listctrl.Bind(wx.EVT_RIGHT_UP, self.OnRightClick) | |
68 self.listctrl.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) | |
69 self.SetSizer(self.list_sizer) | |
70 self.SetAutoLayout(True) | |
71 self.Fit() | |
72 | |
73 def OnRightClick(self,event): | |
74 if self.listctrl.GetSelectedItemCount() > 0: | |
75 menu = wx.Menu() | |
76 lPopupID1 = wx.NewId() | |
77 lPopupID2 = wx.NewId() | |
78 lPopupID3 = wx.NewId() | |
79 menu.Append(lPopupID1, "&Edit") | |
80 menu.Append(lPopupID2, "&Delete") | |
81 menu.Append(lPopupID3, "To &Gametree") | |
82 self.Bind(wx.EVT_MENU, self.onEdit, id=lPopupID1) | |
83 self.Bind(wx.EVT_MENU, self.onDelete, id=lPopupID2) | |
84 self.Bind(wx.EVT_MENU, self.onToGametree, id=lPopupID3) | |
85 self.PopupMenu(menu, cmpPoint(self.x, self.y)) | |
86 menu.Destroy() | |
87 event.Skip() | |
88 | |
89 def refresh(self): | |
90 self.SetMinSize((600,175)); | |
91 for m in self.min: | |
92 self.listctrl.InsertStringItem(self.min.index(m),self.min[self.min.index(m)].path) | |
93 self.listctrl.SetStringItem(self.min.index(m),1,self.min[self.min.index(m)].label) | |
94 self.listctrl.SetStringItem(self.min.index(m),2,`self.min[self.min.index(m)].heading`) | |
95 self.listctrl.SetStringItem(self.min.index(m),3,`self.min[self.min.index(m)].face`) | |
96 self.listctrl.SetStringItem(self.min.index(m),4,`self.min[self.min.index(m)].locked`) | |
97 self.listctrl.SetStringItem(self.min.index(m),5,`self.min[self.min.index(m)].pos`) | |
98 oldcolumnwidth = self.listctrl.GetColumnWidth(0) | |
99 self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE) | |
100 if oldcolumnwidth < self.listctrl.GetColumnWidth(0): | |
101 self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE) | |
102 else: | |
103 self.listctrl.SetColumnWidth(0, oldcolumnwidth) | |
104 self.list_sizer=self.list_sizer | |
105 | |
106 def onEdit(self,event): | |
107 min_list = [] | |
108 min_index = [] | |
109 loop_count = 0 | |
110 item =-1 | |
111 while True: | |
112 loop_count += 1 | |
113 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) | |
114 if item == -1: | |
115 break | |
116 min_list.append(self.min[item]) | |
117 min_index.append(item-loop_count+1) | |
118 if len(min_list) > 0: | |
119 dlg = min_list_edit_dialog(self.parent,min_index, min_list,self.layers) | |
120 if dlg.ShowModal() == wx.ID_OK: | |
121 pass | |
122 self.listctrl.DeleteAllItems() | |
123 self.refresh() | |
124 event.Skip() | |
125 | |
126 def onDelete(self,event): | |
127 loop_count = 0 | |
128 item = -1 | |
129 while True: | |
130 loop_count += 1 | |
131 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) | |
132 if item == -1: | |
133 break | |
134 #self.min.remove(self.min[item-loop_count+1]) | |
135 self.layers["miniatures"].del_miniature(self.min[item-loop_count+1]) | |
136 self.listctrl.DeleteAllItems() | |
137 self.refresh() | |
138 event.Skip() | |
139 | |
140 def onToGametree(self,event): | |
141 min_list = [] | |
142 min_index = [] | |
143 loop_count = 0 | |
144 item =-1 | |
145 while True: | |
146 loop_count += 1 | |
147 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) | |
148 if item == -1: | |
149 break | |
150 min_list.append(self.min[item]) | |
151 min_index.append(item-loop_count+1) | |
152 if len(min_list) > 0: | |
153 for sel_rmin in min_list: | |
154 ############# | |
155 min_xml = sel_rmin.toxml(action="new") | |
156 node_begin = "<nodehandler module='map_miniature_nodehandler' class='map_miniature_handler' name='" | |
157 | |
158 if sel_rmin.label: | |
159 node_begin += sel_rmin.label + "'" | |
160 else: | |
161 node_begin += "Unnamed Miniature'" | |
162 | |
163 node_begin += ">" | |
164 gametree = open_rpg.get_component('tree') | |
165 node_xml = node_begin + min_xml + '</nodehandler>' | |
166 print "Sending this XML to insert_xml:" + node_xml | |
167 gametree.insert_xml(node_xml) | |
168 ########## | |
169 self.listctrl.DeleteAllItems() | |
170 self.refresh() | |
171 event.Skip() | |
172 | |
173 def OnRightDown(self,event): | |
174 self.x = event.GetX() | |
175 self.y = event.GetY() | |
176 event.Skip() | |
177 | |
178 def on_ok(self,evt): | |
179 self.EndModal(wx.ID_OK) | |
180 | |
181 class min_list_edit_dialog(wx.Dialog): | |
182 def __init__(self,parent,min_index, min_list, layers): | |
183 wx.Dialog.__init__(self,parent,-1,"Miniature List",wx.DefaultPosition,wx.Size(600,530)) | |
184 self.layers = layers | |
185 grid = layers['grid'] | |
186 min = layers['miniatures'] | |
187 self.min_list = min_list | |
188 self.min_index = min_index | |
189 self.min = min | |
190 sizer1 = wx.BoxSizer(wx.VERTICAL) | |
191 sizer = wx.BoxSizer(wx.HORIZONTAL) | |
192 self.grid = grid | |
193 editor = min_list_edit_panel(self, min_index, min_list,layers) | |
194 sizer1.Add(editor, 1, wx.EXPAND) | |
195 sizer.Add(wx.Button(self, wx.ID_OK, "OK"), 1, wx.EXPAND) | |
196 sizer.Add(wx.Size(10,10)) | |
197 sizer.Add(wx.Size(10,10)) | |
198 sizer.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.EXPAND) | |
199 sizer1.Add(sizer, 0, wx.EXPAND) | |
200 self.editor = editor | |
201 self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK) | |
202 self.SetSizer(sizer1) | |
203 self.SetAutoLayout(True) | |
204 self.Fit() | |
205 | |
206 def on_revert(self,evt): | |
207 pass | |
208 | |
209 def on_ok(self,evt): | |
210 self.editor.on_ok(self.layers) | |
211 self.EndModal(wx.ID_OK) | |
212 | |
213 class min_list_edit_panel(wx.Panel): | |
214 def __init__(self, parent, min_index, min_list,layers): | |
215 LABEL_COMBO = wx.NewId() | |
216 PATH_COMBO = wx.NewId() | |
217 POS_COMB = wx.NewId() | |
218 MIN_POS = wx.NewId() | |
219 POS_SPIN = wx.NewId() | |
220 self.grid = layers['grid'] | |
221 self.min = layers['miniatures'].miniatures | |
222 self.min_list = min_list | |
223 self.min_index = min_index | |
224 self.layers = layers | |
225 wx.Panel.__init__(self, parent, -1) | |
226 self.min=min | |
227 listsizer = wx.StaticBoxSizer(wx.StaticBox(self,-1,"Miniature list properties"), wx.VERTICAL) | |
228 labelsizer = wx.BoxSizer(wx.HORIZONTAL) | |
229 self.labelcheck = wx.CheckBox(self,-1,"Serialize") | |
230 labelsizer.Add(wx.StaticText(self, -1, "Label: "), 0, wx.EXPAND) | |
231 labelsizer.Add(self.labelcheck,wx.ALIGN_RIGHT,wx.EXPAND) | |
232 listsizer.Add(labelsizer,0, wx.EXPAND) | |
233 self.labelcombo = wx.ComboBox(self, LABEL_COMBO,"no change",style=wx.CB_DROPDOWN) | |
234 listsizer.Add(self.labelcombo,0, wx.EXPAND) | |
235 self.pathcombo = wx.ComboBox(self, PATH_COMBO, "no change",style=wx.CB_DROPDOWN) | |
236 self.positioncombo = wx.ComboBox(self, POS_COMB, "no change", choices=["no change"], style=wx.CB_READONLY) | |
237 #self.positioncombo.SetValue(`min_list[0].pos`) | |
238 self.labelcombo.Append("no change") | |
239 self.pathcombo.Append("no change") | |
240 for m in min_list: | |
241 self.labelcombo.Append(min_list[min_list.index(m)].label) | |
242 self.pathcombo.Append(min_list[min_list.index(m)].path) | |
243 self.positioncombo.Append(`min_list[min_list.index(m)].pos`) | |
244 listsizer.Add(wx.StaticText(self, -1, "Path:"), 0, wx.EXPAND) | |
245 listsizer.Add(self.pathcombo, 0, wx.EXPAND) | |
246 listsizer.Add(wx.Size(10,10)) | |
247 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading", choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS) | |
248 self.heading.SetSelection( 9 ) | |
249 listsizer.Add( self.heading, 0, wx.EXPAND ) | |
250 listsizer.Add(wx.Size(10,10)) | |
251 self.face = wx.RadioBox(self, MIN_FACE, "Facing", choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS) | |
252 self.face.SetSelection(9) | |
253 listsizer.Add(self.face, 0, wx.EXPAND) | |
254 ### | |
255 ### Group together locked, Hide, and snap radioboxes in group2 box | |
256 ### | |
257 group2 = wx.BoxSizer(wx.HORIZONTAL) | |
258 self.locked = wx.RadioBox(self, MIN_LOCK, "Lock", choices=["Don't lock","Lock","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) | |
259 self.locked.SetSelection(2) | |
260 self.hide = wx.RadioBox(self, MIN_HIDE, "Hide", choices=["Don't hide", "Hide", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) | |
261 self.hide.SetSelection(2) | |
262 self.snap = wx.RadioBox(self,MIN_ALIGN,"Snap",choices=["Center","Top left","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) | |
263 self.snap.SetSelection(2) | |
264 group2.Add(self.locked, 0, wx.EXPAND) | |
265 group2.Add(wx.Size(10,0)) | |
266 group2.Add(self.hide, 0, wx.EXPAND) | |
267 group2.Add(wx.Size(10,0)) | |
268 group2.Add(self.snap, 0, wx.EXPAND) | |
269 group2.Add(wx.Size(10,0)) | |
270 listsizer.Add(group2,0,0) | |
271 ### | |
272 ### group together the postion radiobox and the and its selection elements | |
273 ### | |
274 xpos = int(min_list[0].pos[0]) | |
275 #xpos = int(`min_list[0].pos`[1:`min_list[0].pos`.index(',')]) | |
276 ypos = int(min_list[0].pos[1]) | |
277 #ypos = int(`min_list[0].pos`[`min_list[0].pos`.rfind(',')+1:len(`min_list[0].pos`)-1]) | |
278 self.scx = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25)) | |
279 self.scx.SetRange(0,self.grid.return_grid()[0]) | |
280 self.scx.SetValue(xpos) | |
281 self.scy = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25)) | |
282 self.scy.SetRange(0,self.grid.return_grid()[1]) | |
283 self.scy.SetValue(1) | |
284 self.scy.SetValue(ypos) | |
285 positionbox = wx.BoxSizer(wx.HORIZONTAL) | |
286 self.poschoice = wx.RadioBox(self,MIN_POS,"Position",choices=["Manual", "Existing", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) | |
287 self.poschoice.SetSelection(2) | |
288 positionbox.Add(self.poschoice,0,0) | |
289 ### | |
290 ### group together choices under position choice boxsizer | |
291 ### | |
292 poschoicebox = wx.BoxSizer(wx.VERTICAL) | |
293 ### | |
294 ### spinbox contains the x and y spinctrls | |
295 ### | |
296 spinbox = wx.BoxSizer(wx.HORIZONTAL) | |
297 group2.Add(positionbox,0, wx.EXPAND) | |
298 xpos = wx.StaticText(self, -1,"XPOS: ") | |
299 spinbox.Add(xpos,0, 0) | |
300 spinbox.Add(self.scx, 0, 0) | |
301 ypos = wx.StaticText(self, -1,"YPOS: ") | |
302 spinbox.Add(ypos,0, 0) | |
303 spinbox.Add(self.scy, 0, 0) | |
304 poschoicebox.Add(wx.Size(0,15)) | |
305 poschoicebox.Add(spinbox,0,0) | |
306 ### | |
307 ### kludge is just a way to horizontaly position text. .Add doesn't seem to work. | |
308 ### | |
309 kluge = wx.BoxSizer(wx.HORIZONTAL) | |
310 klugetext = wx.StaticText(self, -1, " ") | |
311 kluge.Add(klugetext,0,0) | |
312 kluge.Add(self.positioncombo,0,0) | |
313 poschoicebox.Add(wx.Size(0,1)) | |
314 poschoicebox.Add(kluge,0,0) | |
315 positionbox.Add(poschoicebox,0,0) | |
316 listsizer.Add(positionbox,0, 0) | |
317 self.listsizer = listsizer | |
318 #self.outline = wx.StaticBox(self,-1,"Miniature list properties") | |
319 #listsizer.Add(self.outline,0, wx.EXPAND) | |
320 self.SetSizer(listsizer) | |
321 self.SetAutoLayout(True) | |
322 self.Fit() | |
323 self.Bind(wx.EVT_SPINCTRL, self.on_spin, id=POS_SPIN) | |
324 self.Bind(wx.EVT_TEXT, self.on_combo_box, id=POS_COMB) | |
325 #self.Bind(wx.EVT_SIZE, self.on_size) | |
326 self.Bind(wx.EVT_TEXT, self.on_text, id=MIN_LABEL) | |
327 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_HEADING) | |
328 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE) | |
329 | |
330 def on_ok(self,min): | |
331 self.min = min | |
332 for m in self.min_list: | |
333 if self.hide.GetSelection() !=2: | |
334 m.hide = self.hide.GetSelection() | |
335 if self.heading.GetSelection() !=9: | |
336 m.heading = self.heading.GetSelection() | |
337 if self.face.GetSelection() !=9: | |
338 m.face = self.face.GetSelection() | |
339 if self.locked.GetSelection() !=2: | |
340 m.locked = self.locked.GetSelection() | |
341 if self.snap.GetSelection() !=2: | |
342 m.snap_to_align = self.snap.GetSelection() | |
343 if self.labelcombo.GetValue() != "no change": | |
344 m.label = self.labelcombo.GetValue() | |
345 if self.labelcheck.GetValue(): | |
346 m.label += " " + `self.layers['miniatures'].next_serial()` | |
347 # self.layers['miniatures'].serial_number +=1 | |
348 # m.label += " " + `self.layers['miniatures'].serial_number` | |
349 if self.pathcombo.GetValue() != "no change": | |
350 path = self.pathcombo.GetValue() | |
351 image = self.evaluate(path) | |
352 if str(image[1]) != '-1': | |
353 m.path = image[0] | |
354 m.bmp = image[1] | |
355 else: | |
356 image[-1] = -1 | |
357 while image[1] == -1: | |
358 image = 0 | |
359 self.dlg = wx.TextEntryDialog(self, 'You entered an invalid URL for the image path. Please Enter a valid URL or cancel to leave the old url unchanged') | |
360 if self.dlg.ShowModal() == wx.ID_OK: | |
361 path = self.dlg.GetValue() | |
362 image = self.evaluate(path) | |
363 if image[1] != -1: | |
364 m.path = image[0] | |
365 m.bmp = image[1] | |
366 self.dlg.Destroy() | |
367 else: | |
368 break | |
369 if self.poschoice.GetSelection() !=2: | |
370 if self.poschoice.GetSelection() == 0: | |
371 m.pos = cmpPoint(self.scx.GetValue(),self.scy.GetValue()) | |
372 else: | |
373 pos = self.positioncombo.GetValue() | |
374 m.pos = cmpPoint(int(`pos`[2:`pos`.index(",")]),int(`pos`[`pos`.rfind(',')+1:len(`pos`)-2])) | |
375 self.layers["miniatures"].canvas.send_map_data() | |
376 | |
377 def evaluate(self, ckpath): | |
378 path = [] | |
379 if ckpath[:7] != "http://": | |
380 ckpath = "http://" + ckpath | |
381 path = self.check_path(ckpath) | |
382 return [ckpath, path] | |
383 | |
384 def check_path(self, path): | |
385 if ImageHandler.Cache.has_key(path): | |
386 return ImageHandler.Cache[path] | |
387 img = ImageHandler.directLoad(path) | |
388 if img is None: | |
389 return -1 | |
390 return img | |
391 | |
392 def on_text(self,evt): | |
393 id=evt.GetId() | |
394 | |
395 def on_spin(self,evt): | |
396 self.poschoice.SetSelection(0) | |
397 | |
398 def on_combo_box(self,evt): | |
399 self.poschoice.SetSelection(1) | |
400 | |
401 def on_radio_box(self,evt): | |
402 id=evt.GetId() | |
403 index = evt.GetInt() | |
404 | |
405 def on_size(self,evt): | |
406 s = self.GetClientSizeTuple() | |
407 self.listsizer.SetDimension(20,20,s[0]-40,s[1]-40) | |
408 self.outline.SetDimensions(5,5,s[0]-10,s[1]-10) | |
409 | |
410 ##----------------------------- | |
411 ## Miniature Prop Panel | |
412 ##----------------------------- | |
413 | |
414 MIN_LABEL = wx.NewId() | |
415 MIN_HEADING = wx.NewId() | |
416 MIN_FACE = wx.NewId() | |
417 MIN_HIDE = wx.NewId() | |
418 MIN_LOCK = wx.NewId() | |
419 MIN_ALIGN = wx.NewId() | |
420 wxID_MIN_WIDTH = wx.NewId() | |
421 wxID_MIN_HEIGHT = wx.NewId() | |
422 wxID_MIN_SCALING = wx.NewId() | |
423 | |
424 class min_edit_panel(wx.Panel): | |
425 def __init__(self, parent, min): | |
426 wx.Panel.__init__(self, parent, -1) | |
427 self.min = min | |
428 sizer = wx.StaticBoxSizer(wx.StaticBox(self,-1,"Miniature"), wx.VERTICAL) | |
429 sizerSize = wx.BoxSizer(wx.HORIZONTAL) | |
430 hSizer = wx.BoxSizer(wx.HORIZONTAL) | |
431 self.label = wx.TextCtrl(self, MIN_LABEL, min.label) | |
432 sizer.Add(wx.StaticText(self, -1, "Label:"), 0, wx.EXPAND) | |
433 sizer.Add(self.label, 0, wx.EXPAND) | |
434 sizer.Add(wx.Size(10,10)) | |
435 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading", choices=["None","N","NE","E","SE","S","SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS) | |
436 self.heading.SetSelection(min.heading) | |
437 self.face = wx.RadioBox(self, MIN_FACE, "Facing", choices=["None","N","NE","E","SE","S","SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS) | |
438 self.face.SetSelection(min.face) | |
439 self.locked = wx.CheckBox(self, MIN_LOCK, " Lock") | |
440 self.locked.SetValue(min.locked) | |
441 self.hide = wx.CheckBox(self, MIN_HIDE, " Hide") | |
442 self.hide.SetValue(min.hide) | |
443 sizer.Add(self.heading, 0, wx.EXPAND) | |
444 sizer.Add(wx.Size(10,10)) | |
445 sizer.Add(self.face, 0, wx.EXPAND) | |
446 sizer.Add(wx.Size(10,10)) | |
447 # | |
448 #image resizing | |
449 # | |
450 self.min_width_old_value = str(self.min.bmp.GetWidth()) | |
451 self.min_width = wx.TextCtrl(self, wxID_MIN_WIDTH, self.min_width_old_value) | |
452 sizerSize.Add(wx.StaticText(self, -1, "Width: "), 0, wx.ALIGN_CENTER) | |
453 sizerSize.Add(self.min_width, 1, wx.EXPAND) | |
454 sizerSize.Add(wx.Size(20, 25)) | |
455 | |
456 #TODO:keep in mind that self.min is a local copy??? | |
457 self.min_height_old_value = str(self.min.bmp.GetHeight()) | |
458 self.min_height = wx.TextCtrl(self, wxID_MIN_HEIGHT, self.min_height_old_value) | |
459 sizerSize.Add(wx.StaticText(self, -1, "Height: "),0,wx.ALIGN_CENTER) | |
460 sizerSize.Add(self.min_height, 1, wx.EXPAND) | |
461 self.min_scaling = wx.CheckBox(self, wxID_MIN_SCALING, "Lock scaling") | |
462 self.min_scaling.SetValue(True) | |
463 sizerSize.Add(self.min_scaling, 1, wx.EXPAND) | |
464 sizer.Add(sizerSize, 0, wx.EXPAND) | |
465 sizer.Add(wx.Size(10, 10)) | |
466 | |
467 # Now, add the last items on in their own sizer | |
468 hSizer.Add(self.locked, 0, wx.EXPAND) | |
469 hSizer.Add(wx.Size(10,10)) | |
470 hSizer.Add(self.hide, 0, wx.EXPAND) | |
471 | |
472 # Add the hSizer to the main sizer | |
473 sizer.Add( hSizer ) | |
474 self.sizer = sizer | |
475 self.SetSizer(self.sizer) | |
476 self.SetAutoLayout(True) | |
477 self.Fit() | |
478 | |
479 #self.Bind(wx.EVT_SIZE, self.on_size) | |
480 self.Bind(wx.EVT_TEXT, self.on_text, id=MIN_LABEL) | |
481 self.Bind(wx.EVT_TEXT, self.on_scaling, id=wxID_MIN_WIDTH) | |
482 self.Bind(wx.EVT_TEXT, self.on_scaling, id=wxID_MIN_HEIGHT) | |
483 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_HEADING) | |
484 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE) | |
485 | |
486 def on_scaling(self, evt): | |
487 if self.min_scaling.GetValue() == False: | |
488 return | |
489 elif self.min_width.GetValue() and wxID_MIN_WIDTH == evt.GetId() and self.min_width.GetInsertionPoint(): | |
490 self.min_height.SetValue ( str(int((float(self.min_width.GetValue()) / float(self.min_width_old_value)) * float(self.min_height_old_value))) ) | |
491 elif self.min_height.GetValue() and wxID_MIN_HEIGHT == evt.GetId() and self.min_height.GetInsertionPoint(): | |
492 self.min_width.SetValue ( str(int((float(self.min_height.GetValue()) / float(self.min_height_old_value)) * float(self.min_width_old_value))) ) | |
493 | |
494 def update_min(self): | |
495 self.min.set_min_props(self.heading.GetSelection(), | |
496 self.face.GetSelection(), | |
497 self.label.GetValue(), | |
498 self.locked.GetValue(), | |
499 self.hide.GetValue(), | |
500 self.min_width.GetValue(), | |
501 self.min_height.GetValue()) | |
502 | |
503 def on_radio_box(self,evt): | |
504 id = evt.GetId() | |
505 index = evt.GetInt() | |
506 | |
507 def on_text(self,evt): | |
508 id = evt.GetId() | |
509 | |
510 def on_size(self,evt): | |
511 s = self.GetClientSizeTuple() | |
512 self.sizer.SetDimension(20,20,s[0]-40,s[1]-40) | |
513 self.outline.SetDimensions(5,5,s[0]-10,s[1]-10) | |
514 | |
515 class min_edit_dialog(wx.Dialog): | |
516 def __init__(self,parent,min): | |
517 #520,265 | |
518 wx.Dialog.__init__(self,parent,-1,"Miniature",wx.DefaultPosition,wx.Size(520,350)) | |
519 (w,h) = self.GetClientSizeTuple() | |
520 mastersizer = wx.BoxSizer(wx.VERTICAL) | |
521 editor = min_edit_panel(self,min) | |
522 #editor.SetDimensions(0,0,w,h-25) | |
523 self.editor = editor | |
524 mastersizer.Add(editor, 1, wx.EXPAND) | |
525 mastersizer.Add(wx.Size(10,10)) | |
526 sizer = wx.BoxSizer(wx.HORIZONTAL) | |
527 sizer.Add(wx.Button(self, wx.ID_OK, "OK"), 1, wx.EXPAND) | |
528 sizer.Add(wx.Size(10,10)) | |
529 sizer.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.EXPAND) | |
530 #sizer.SetDimension(0,h-25,w,25) | |
531 mastersizer.Add(sizer, 0, wx.EXPAND) | |
532 self.SetSizer(mastersizer) | |
533 self.SetAutoLayout(True) | |
534 self.Fit() | |
535 self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK) | |
536 | |
537 def on_ok(self,evt): | |
538 self.editor.update_min() | |
539 self.EndModal(wx.ID_OK) |