annotate orpg/gametree/nodehandlers/containers.py @ 138:1ed2feab0db9 alpha

Traipse Alpha 'OpenRPG' {091021-00} 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!! New Gametree Recursion method, mapping, and context sensitivity. !!Alpha Still- Watch out for infinite loops!! New Syntax added for custom PC sheets Tip of the Day added, from Core and community Fixed Whiteboard ID to prevent random line or text deleting. Appended tr_ to ID's to prevent non updated clients from ruining the fix.
author sirebral
date Sat, 21 Nov 2009 03:19:34 -0600
parents 90d19eb43830
children 06f10429eedc
rev   line source
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
2 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
3 # openrpg-dev@lists.sourceforge.net
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
4 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
5 # This program is free software; you can redistribute it and/or modify
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
6 # it under the terms of the GNU General Public License as published by
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
8 # (at your option) any later version.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
9 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
10 # This program is distributed in the hope that it will be useful,
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
13 # GNU General Public License for more details.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
14 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
15 # You should have received a copy of the GNU General Public License
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
16 # along with this program; if not, write to the Free Software
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
18 # --
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
19 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
20 # File: containers.py
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
21 # Author: Chris Davis
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
22 # Maintainer:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
23 # Version:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
24 # $Id: containers.py,v 1.43 2007/08/08 19:17:17 digitalxero Exp $
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
25 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
26 # Description: The file contains code for the container nodehandlers
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
27 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
28
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
29
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
30 from core import *
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
31 from wx.lib.splitter import MultiSplitterWindow
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
32
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
33
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
34 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
35 ## base contiainer
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
36 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
37
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
38 class container_handler(node_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
39 """ should not be used! only a base class!
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
40 <nodehandler name='?' module='core' class='container_handler' />
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
41 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
42 def __init__(self, xml, tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
43 node_handler.__init__(self, xml, tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
44 self.load_children()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
45
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
46 def load_children(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
47 for child_xml in self.xml:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
48 self.tree.load_xml(child_xml,self.mytree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
49
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
50 def check_map_aware(self, treenode, evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
51 node = self.tree.GetPyData(treenode)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
52 if hasattr(node,"map_aware") and node.map_aware():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
53 node.on_send_to_map(evt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
54
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
55 def on_send_to_map(self, evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
56 self.tree.traverse(self.mytree_node, self.check_map_aware, evt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
57
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
58 def checkChildToMap(self, treenode, evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
59 node = self.tree.GetPyData(treenode)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
60 if hasattr(node,"map_aware") and node.map_aware():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
61 self.mapcheck = True
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
62
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
63 def checkToMapMenu(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
64 self.mapcheck = False
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
65 self.tree.traverse(self.mytree_node, self.checkChildToMap)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
66 return self.mapcheck
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
67
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
68 def on_drop(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
69 drag_obj = self.tree.drag_obj
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
70 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
71 return
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
72 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
73 if opt == wx.YES:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
74 drop_xml = self.tree.drag_obj.delete()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
75 self.xml.insert(0, drop_xml)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
76 self.tree.load_xml(drop_xml, self.mytree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
77 self.tree.Expand(self.mytree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
78 elif opt == wx.NO:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
79 node_handler.on_drop(self,evt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
80
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
81 def gen_html(self, treenode, evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
82 node = self.tree.GetPyData(treenode)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
83 self.html_str += "<p>" + node.tohtml()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
84
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
85 def tohtml(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
86 self.html_str = "<table border=\"1\" ><tr><td>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
87 self.html_str += "<b>"+self.xml.get("name") + "</b>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
88 self.html_str += "</td></tr>\n"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
89 self.html_str += "<tr><td>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
90
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
91 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
92
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
93 self.html_str += "</td></tr></table>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
94 return self.html_str
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
95
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
96 def get_size_constraint(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
97 return 2
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
98
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
99
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
100 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
101 ## group node handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
102 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
103 class group_handler(container_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
104 """ group nodehandler to be used as a placeholder for other nodehandlers.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
105 This handler will continue parsing child xml data.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
106 <nodehandler name='?' module='core' class='group_handler' />
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
107 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
108 def __init__(self, xml, tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
109 container_handler.__init__(self, xml, tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
110
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
111 def load_children(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
112 self.atts = None
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
113 for child_xml in self.xml:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
114 if child_xml.get == "group_atts": #having the group attributes as a child is bad!
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
115 self.xml.remove(child_xml)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
116 elif child_xml:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
117 self.tree.load_xml(child_xml, self.mytree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
118 if not self.xml.get('cols'): self.xml.set('cols', '1')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
119 if not self.xml.get('border'): self.xml.set('border', '1')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
120 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
121 if not self.atts:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
122 self.atts = Element('group_atts')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
123 self.atts.set("cols","1")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
124 self.atts.set("border","1")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
125 self.xml.append(self.atts)"""
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
126
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
127 def get_design_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
128 return group_edit_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
129
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
130 def on_use(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
131 return
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
132
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
133 def gen_html(self, treenode, evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
134 node = self.tree.GetPyData(treenode)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
135 if self.i not in self.tdatas:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
136 self.tdatas[self.i] = ''
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
137 self.tdatas[self.i] += "<P>" + node.tohtml()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
138 self.i += 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
139 if self.i >= self.cols:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
140 self.i = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
141
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
142 def tohtml(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
143 cols = self.xml.get("cols")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
144 border = self.xml.get("border")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
145 self.html_str = "<table border=\""+border+"\" ><tr><td colspan=\""+cols+"\">"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
146 self.html_str += "<font size=4>"+self.xml.get("name") + "</font>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
147 self.html_str += "</td></tr>\n<tr>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
148 self.cols = int(cols)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
149 self.i = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
150 self.tdatas = {}
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
151 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
152 for td in self.tdatas:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
153 self.html_str += "<td valign=\"top\" >" + self.tdatas[td] + "</td>\n";
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
154 self.html_str += "</tr></table>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
155 return self.html_str
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
156
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
157 GROUP_COLS = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
158 GROUP_BOR = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
159
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
160 class group_edit_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
161 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
162 wx.Panel.__init__(self, parent, -1)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
163 self.handler = handler
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
164 self.outline = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Group"), wx.VERTICAL)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
165
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
166 sizer = wx.BoxSizer(wx.VERTICAL)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
167 self.text = {P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) }
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
168 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
169 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
170 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
171
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
172 radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"])
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
173 cols = handler.xml.get("cols")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
174 if cols != "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
175 radio_c.SetSelection(int(cols)-1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
176
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
177 radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"])
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
178 border = handler.xml.get("border")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
179 if border != "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
180 radio_b.SetSelection(int(border))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
181
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
182 sizer.Add(radio_c, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
183 sizer.Add(wx.Size(10,10))
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
184 sizer.Add(radio_b, 0, wx.EXPAND)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
185
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
186 self.outline.Add(sizer, 0)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
187 self.sizer = self.outline
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
188 self.SetSizer(self.sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
189 self.SetAutoLayout(True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
190 self.Fit()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
191 parent.SetSize(self.GetBestSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
192 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
193 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_BOR)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
194 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_COLS)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
195
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
196 def on_radio_box(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
197 id = evt.GetId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
198 index = evt.GetInt()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
199 if id == GROUP_COLS:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
200 self.handler.xml.set("cols",str(index+1))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
201 elif id == GROUP_BOR:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
202 self.handler.xml.set("border",str(index))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
203
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
204 def on_text(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
205 id = evt.GetId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
206 if id == P_TITLE:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
207 txt = self.text[id].GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
208 if txt != "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
209 self.handler.xml.set('name',txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
210 self.handler.rename(txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
211
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
212
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
213
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
214 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
215 ## tabber node handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
216 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
217 class tabber_handler(container_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
218 """ <nodehandler name='?' module='containers' class='tabber_handler' />"""
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
219
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
220 def __init__(self, xml, tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
221 container_handler.__init__(self, xml, tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
222
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
223 def get_design_panel(self,parent):
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
224 return tabbed_edit_panel(parent, self)
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
225
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
226 def get_use_panel(self,parent):
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
227 return tabbed_panel(parent, self, 1)
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
228
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
229
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
230 class tabbed_panel(orpgTabberWnd):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
231 def __init__(self, parent, handler, mode):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
232 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
233 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
234 self.parent = parent
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
235 handler.tree.traverse(handler.mytree_node, self.pick_panel, mode, False)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
236 parent.SetSize(self.GetBestSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
237
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
238 def pick_panel(self, treenode, mode):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
239 node = self.handler.tree.GetPyData(treenode)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
240 if mode == 1: panel = node.get_design_panel(self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
241 else: panel = node.get_use_panel(self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
242 name = node.xml.get("name")
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
243 if panel: self.AddPage(panel, name, False)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
244
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
245 class tabbed_edit_panel(orpgTabberWnd):
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
246 def __init__(self, parent, handler):
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
247 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
248 self.handler = handler
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
249 self.parent = parent
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
250 main_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Tabber"), wx.VERTICAL)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
251 self.title = wx.TextCtrl(self, 1, handler.xml.get('name'))
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
252 main_sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
253 main_sizer.Add(self.title, 0, wx.EXPAND)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
254 self.SetSizer(main_sizer)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
255 self.SetAutoLayout(True)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
256 self.Fit()
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
257 self.Bind(wx.EVT_TEXT, self.on_text, id=1)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
258
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
259 def on_text(self,evt):
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
260 txt = self.title.GetValue()
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
261 if txt != "":
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
262 self.handler.xml.set('name',txt)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
263 self.handler.rename(txt)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
264
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
265
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
266 #################################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
267 ## Splitter container
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
268 #################################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
269
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
270 class splitter_handler(container_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
271 """ <nodehandler name='?' module='containers' class='splitter_handler' />"""
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
272
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
273 def __init__(self,xml,tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
274 container_handler.__init__(self,xml,tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
275
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
276 def load_children(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
277 self.atts = None
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
278 for child_xml in self.xml:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
279 if child_xml.tag == "splitter_atts": self.xml.remove(child_xml) #Same here!
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
280 elif child_xml: self.tree.load_xml(child_xml,self.mytree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
281 if not self.xml.get('horizontal'): self.xml.set('horizontal', '0')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
282
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
283 def get_design_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
284 return self.build_splitter_wnd(parent, 1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
285
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
286 def get_use_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
287 return self.build_splitter_wnd(parent, 2)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
288
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
289 def on_drop(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
290 drag_obj = self.tree.drag_obj
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
291 container_handler.on_drop(self,evt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
292
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
293 def build_splitter_wnd(self, parent, mode):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
294 self.split = self.xml.get("horizontal")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
295 self.pane = splitter_panel(parent, self)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
296 self.splitter = MultiSplitterWindow(self.pane, -1,
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
297 style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH|wx.SP_NO_XP_THEME)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
298 if self.split == '1': self.splitter.SetOrientation(wx.VERTICAL)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
299 else: self.splitter.SetOrientation(wx.HORIZONTAL)
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
300 self.bestSizex = -1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
301 self.bestSizey = -1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
302 self.tree.traverse(self.mytree_node, self.doSplit, mode, False)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
303 self.pane.sizer.Add(self.splitter, 1, wx.EXPAND)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
304 if mode != 1: self.pane.hozCheck.Hide()
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
305 self.pane.SetSize((self.bestSizex, self.bestSizey))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
306 self.pane.Layout()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
307 parent.SetSize(self.pane.GetSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
308 return self.pane
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
309
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
310 def doSplit(self, treenode, mode):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
311 node = self.tree.GetPyData(treenode)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
312 if mode == 1: tmp = node.get_design_panel(self.splitter)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
313 else: tmp = node.get_use_panel(self.splitter)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
314 if self.split == '1':
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
315 sash = tmp.GetBestSize()[1]+1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
316 self.bestSizey += sash+11
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
317 if self.bestSizex < tmp.GetBestSize()[0]:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
318 self.bestSizex = tmp.GetBestSize()[0]+10
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
319 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
320 sash = tmp.GetBestSize()[0]+1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
321 self.bestSizex += sash
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
322 if self.bestSizey < tmp.GetBestSize()[1]:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
323 self.bestSizey = tmp.GetBestSize()[1]+31
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
324 self.splitter.AppendWindow(tmp, sash)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
325 def get_size_constraint(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
326 return 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
327
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
328 class splitter_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
329 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
330 wx.Panel.__init__(self, parent, -1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
331 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
332 sizer = wx.BoxSizer(wx.VERTICAL)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
333 self.title = wx.TextCtrl(self, 1, handler.xml.get('name'))
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
334
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
335 self.hozCheck = wx.CheckBox(self, -1, "Horizontal Split")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
336 hoz = self.handler.xml.get("horizontal")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
337
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
338 if hoz == '1': self.hozCheck.SetValue(True)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
339 else: self.hozCheck.SetValue(False)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
340
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
341 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
342 sizer.Add(self.title, 0)
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
343 sizer.Add(self.hozCheck, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
344 sizer.Add(wx.Size(10,0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
345 #sizer.Add(self.splitsize, 1, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
346
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
347 self.sizer = sizer
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
348 self.SetSizer(self.sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
349 self.SetAutoLayout(True)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
350 self.Bind(wx.EVT_TEXT, self.on_text, id=1)
131
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
351 self.Bind(wx.EVT_CHECKBOX, self.on_check_box, id=self.hozCheck.GetId())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
352
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
353 def on_check_box(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
354 state = self.hozCheck.GetValue()
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
355 if state: self.handler.xml.set("horizontal", "1")
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
356 else: self.handler.xml.set("horizontal", "0")
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
357
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
358 def on_text(self,evt):
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
359 txt = self.title.GetValue()
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
360 if txt != "":
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
361 self.handler.xml.set('name',txt)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
362 self.handler.rename(txt)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
363