annotate orpg/gametree/nodehandlers/containers.py @ 130:d54e1328dbb1 alpha

Traipse Alpha 'OpenRPG' {091003-02} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana **Pretty important update that can help remove thousands of dead children from your gametree. **Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! Dead Node Children, not that's a O O -v-v- Happy Halloween!
author sirebral
date Tue, 03 Nov 2009 21:06:03 -0600
parents 217fb049bd00
children 90d19eb43830
rev   line source
130
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
2 #
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
3 # openrpg-dev@lists.sourceforge.net
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
4 #
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
5 # This program is free software; you can redistribute it and/or modify
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
6 # it under the terms of the GNU General Public License as published by
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
8 # (at your option) any later version.
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
9 #
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
10 # This program is distributed in the hope that it will be useful,
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
13 # GNU General Public License for more details.
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
14 #
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
15 # You should have received a copy of the GNU General Public License
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
16 # along with this program; if not, write to the Free Software
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
18 # --
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
19 #
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
20 # File: containers.py
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
21 # Author: Chris Davis
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
22 # Maintainer:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
23 # Version:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
24 # $Id: containers.py,v 1.43 2007/08/08 19:17:17 digitalxero Exp $
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
25 #
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
26 # Description: The file contains code for the container nodehandlers
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
27 #
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
28
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
29
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
30 from core import *
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
31 import wx.lib.splitter
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
32
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
33
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
34 ##########################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
35 ## base contiainer
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
36 ##########################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
37
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
38 class container_handler(node_handler):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
39 """ should not be used! only a base class!
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
40 <nodehandler name='?' module='core' class='container_handler' />
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
41 """
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
42 def __init__(self,xml,tree_node):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
43 node_handler.__init__(self,xml,tree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
44 self.load_children()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
45
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
46 def load_children(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
47 for child_xml in self.xml:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
48 self.tree.load_xml(child_xml,self.mytree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
49
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
50 def check_map_aware(self, treenode, evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
51 node = self.tree.GetPyData(treenode)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
52 if hasattr(node,"map_aware") and node.map_aware():
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
53 node.on_send_to_map(evt)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
54
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
55 def on_send_to_map(self, evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
56 self.tree.traverse(self.mytree_node, self.check_map_aware, evt)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
57
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
58 def checkChildToMap(self, treenode, evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
59 node = self.tree.GetPyData(treenode)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
60 if hasattr(node,"map_aware") and node.map_aware():
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
61 self.mapcheck = True
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
62
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
63 def checkToMapMenu(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
64 self.mapcheck = False
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
65 self.tree.traverse(self.mytree_node, self.checkChildToMap)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
66 return self.mapcheck
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
67
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
68 def on_drop(self,evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
69 drag_obj = self.tree.drag_obj
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
70 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
71 return
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
72 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
73 if opt == wx.YES:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
74 drop_xml = self.tree.drag_obj.delete()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
75 self.xml.insert(0, drop_xml)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
76 self.tree.load_xml(drop_xml, self.mytree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
77 self.tree.Expand(self.mytree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
78 elif opt == wx.NO:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
79 node_handler.on_drop(self,evt)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
80
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
81 def gen_html(self, treenode, evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
82 node = self.tree.GetPyData(treenode)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
83 self.html_str += "<p>" + node.tohtml()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
84
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
85 def tohtml(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
86 self.html_str = "<table border=\"1\" ><tr><td>"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
87 self.html_str += "<b>"+self.xml.get("name") + "</b>"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
88 self.html_str += "</td></tr>\n"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
89 self.html_str += "<tr><td>"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
90
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
91 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
92
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
93 self.html_str += "</td></tr></table>"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
94 return self.html_str
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
95
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
96 def get_size_constraint(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
97 return 2
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
98
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
99
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
100
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
101
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
102 ##########################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
103 ## group node handler
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
104 ##########################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
105 class group_handler(container_handler):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
106 """ group nodehandler to be used as a placeholder for other nodehandlers.
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
107 This handler will continue parsing child xml data.
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
108 <nodehandler name='?' module='core' class='group_handler' />
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
109 """
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
110 def __init__(self,xml,tree_node):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
111 container_handler.__init__(self,xml,tree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
112
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
113 def load_children(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
114 self.atts = None
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
115 for child_xml in self.xml:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
116 if child_xml.tag == "group_atts":
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
117 self.atts = child_xml
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
118 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
119 self.tree.load_xml(child_xml,self.mytree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
120 if not self.atts:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
121 self.atts = ET.Element('group_atts')
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
122 self.atts.set("cols","1")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
123 self.atts.set("border","1")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
124 self.xml.append(self.atts)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
125
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
126 def get_design_panel(self,parent):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
127 return group_edit_panel(parent,self)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
128
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
129 def on_use(self,evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
130 return
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
131
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
132 def gen_html(self, treenode, evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
133 node = self.tree.GetPyData(treenode)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
134 if self.i not in self.tdatas:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
135 self.tdatas[self.i] = ''
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
136 self.tdatas[self.i] += "<P>" + node.tohtml()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
137 self.i += 1
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
138 if self.i >= self.cols:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
139 self.i = 0
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
140
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
141 def tohtml(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
142 cols = self.atts.get("cols")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
143 border = self.atts.get("border")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
144 self.html_str = "<table border=\""+border+"\" ><tr><td colspan=\""+cols+"\">"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
145 self.html_str += "<font size=4>"+self.xml.get("name") + "</font>"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
146 self.html_str += "</td></tr>\n<tr>"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
147
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
148 self.cols = int(cols)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
149 self.i = 0
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
150 self.tdatas = {}
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
151
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
152 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
153
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
154 for td in self.tdatas:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
155 self.html_str += "<td valign=\"top\" >" + self.tdatas[td] + "</td>\n";
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
156 self.html_str += "</tr></table>"
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
157 return self.html_str
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
158
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
159 GROUP_COLS = wx.NewId()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
160 GROUP_BOR = wx.NewId()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
161
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
162 class group_edit_panel(wx.Panel):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
163 def __init__(self, parent, handler):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
164 wx.Panel.__init__(self, parent, -1)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
165 self.handler = handler
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
166 sizer = wx.BoxSizer(wx.VERTICAL)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
167 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
168 }
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
169 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
170 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
171 sizer.Add(wx.Size(10,10))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
172
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
173 radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"])
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
174 cols = handler.atts.get("cols")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
175 if cols != "":
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
176 radio_c.SetSelection(int(cols)-1)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
177
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
178 radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"])
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
179 border = handler.atts.get("border")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
180 if border != "":
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
181 radio_b.SetSelection(int(border))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
182
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
183 sizer.Add(radio_c, 0, wx.EXPAND)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
184 sizer.Add(wx.Size(10,10))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
185 sizer.Add(radio_b, 0, wx.EXPAND)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
186
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
187 self.sizer = sizer
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
188 self.outline = wx.StaticBox(self,-1,"Group")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
189 self.SetSizer(self.sizer)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
190 self.SetAutoLayout(True)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
191 self.Fit()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
192 parent.SetSize(self.GetBestSize())
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
193 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
194 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_BOR)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
195 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_COLS)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
196
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
197 def on_radio_box(self,evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
198 id = evt.GetId()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
199 index = evt.GetInt()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
200 if id == GROUP_COLS:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
201 self.handler.atts.set("cols",str(index+1))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
202 elif id == GROUP_BOR:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
203 self.handler.atts.set("border",str(index))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
204
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
205 def on_text(self,evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
206 id = evt.GetId()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
207 if id == P_TITLE:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
208 txt = self.text[id].GetValue()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
209 if txt != "":
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
210 self.handler.xml.set('name',txt)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
211 self.handler.rename(txt)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
212
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
213
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
214
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
215 ##########################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
216 ## tabber node handler
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
217 ##########################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
218 class tabber_handler(container_handler):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
219 """ <nodehandler name='?' module='containers' class='tabber_handler' />"""
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
220
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
221 def __init__(self,xml,tree_node):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
222 container_handler.__init__(self,xml,tree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
223
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
224 def get_design_panel(self,parent):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
225 return tabbed_panel(parent,self,1)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
226
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
227 def get_use_panel(self,parent):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
228 return tabbed_panel(parent,self,2)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
229
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
230
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
231 class tabbed_panel(orpgTabberWnd):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
232 def __init__(self, parent, handler, mode):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
233 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
234 self.handler = handler
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
235 self.parent = parent
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
236 handler.tree.traverse(handler.mytree_node, self.pick_panel, mode, False)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
237
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
238 parent.SetSize(self.GetBestSize())
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
239
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
240 def pick_panel(self, treenode, mode):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
241 node = self.handler.tree.GetPyData(treenode)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
242 if mode == 1:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
243 panel = node.get_design_panel(self)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
244 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
245 panel = node.get_use_panel(self)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
246
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
247 name = node.xml.get("name")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
248
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
249 if panel:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
250 self.AddPage(panel, name, False)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
251
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
252 #################################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
253 ## Splitter container
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
254 #################################
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
255
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
256 class splitter_handler(container_handler):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
257 """ <nodehandler name='?' module='containers' class='splitter_handler' />"""
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
258
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
259 def __init__(self,xml,tree_node):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
260 container_handler.__init__(self,xml,tree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
261
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
262 def load_children(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
263 self.atts = None
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
264 for child_xml in self.xml:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
265 if child_xml.tag == "splitter_atts":
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
266 self.atts = child_xml
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
267 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
268 self.tree.load_xml(child_xml,self.mytree_node)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
269 if not self.atts:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
270 self.atts = ET.Element('splitter_atts')
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
271 self.atts.set("horizontal","0")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
272 self.xml.append(self.atts)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
273
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
274 def get_design_panel(self,parent):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
275 return self.build_splitter_wnd(parent, 1)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
276
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
277 def get_use_panel(self,parent):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
278 return self.build_splitter_wnd(parent, 2)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
279
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
280 def on_drop(self,evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
281 drag_obj = self.tree.drag_obj
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
282 container_handler.on_drop(self,evt)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
283
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
284 def build_splitter_wnd(self, parent, mode):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
285 self.split = self.atts.get("horizontal")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
286
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
287 self.pane = splitter_panel(parent, self)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
288
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
289 self.splitter = wx.lib.splitter.MultiSplitterWindow(self.pane, -1, style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH|wx.SP_NO_XP_THEME)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
290
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
291 if self.split == '1':
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
292 self.splitter.SetOrientation(wx.VERTICAL)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
293 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
294 self.splitter.SetOrientation(wx.HORIZONTAL)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
295
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
296 self.bestSizex = -1
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
297 self.bestSizey = -1
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
298
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
299 self.tree.traverse(self.mytree_node, self.doSplit, mode, False)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
300
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
301 self.pane.sizer.Add(self.splitter, 1, wx.EXPAND)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
302
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
303
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
304 if mode != 1:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
305 self.pane.hozCheck.Hide()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
306
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
307 self.pane.SetSize((self.bestSizex, self.bestSizey))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
308 self.pane.Layout()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
309 parent.SetSize(self.pane.GetSize())
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
310 return self.pane
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
311
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
312 def doSplit(self, treenode, mode):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
313 node = self.tree.GetPyData(treenode)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
314 if mode == 1:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
315 tmp = node.get_design_panel(self.splitter)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
316 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
317 tmp = node.get_use_panel(self.splitter)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
318
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
319 if self.split == '1':
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
320 sash = tmp.GetBestSize()[1]+1
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
321 self.bestSizey += sash+11
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
322 if self.bestSizex < tmp.GetBestSize()[0]:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
323 self.bestSizex = tmp.GetBestSize()[0]+10
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
324 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
325 sash = tmp.GetBestSize()[0]+1
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
326 self.bestSizex += sash
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
327 if self.bestSizey < tmp.GetBestSize()[1]:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
328 self.bestSizey = tmp.GetBestSize()[1]+31
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
329
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
330 self.splitter.AppendWindow(tmp, sash)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
331
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
332 def get_size_constraint(self):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
333 return 1
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
334
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
335 class splitter_panel(wx.Panel):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
336 def __init__(self, parent, handler):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
337 wx.Panel.__init__(self, parent, -1)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
338 self.handler = handler
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
339 sizer = wx.BoxSizer(wx.VERTICAL)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
340
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
341 self.hozCheck = wx.CheckBox(self, -1, "Horizontal Split")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
342 hoz = self.handler.atts.get("horizontal")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
343
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
344 if hoz == '1':
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
345 self.hozCheck.SetValue(True)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
346 #self.splitsize = wx.BoxSizer(wx.HORIZONTAL)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
347 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
348 self.hozCheck.SetValue(False)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
349 #self.splitsize = wx.BoxSizer(wx.VERTICAL)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
350
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
351 sizer.Add(self.hozCheck, 0, wx.EXPAND)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
352 sizer.Add(wx.Size(10,0))
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
353 #sizer.Add(self.splitsize, 1, wx.EXPAND)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
354
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
355 self.sizer = sizer
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
356 self.SetSizer(self.sizer)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
357 self.SetAutoLayout(True)
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
358
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
359 self.Bind(wx.EVT_CHECKBOX, self.on_check_box, id=self.hozCheck.GetId())
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
360
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
361 def on_check_box(self,evt):
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
362 state = self.hozCheck.GetValue()
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
363 if state:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
364 self.handler.atts.set("horizontal", "1")
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
365 else:
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 118
diff changeset
366 self.handler.atts.set("horizontal", "0")