annotate orpg/gametree/nodehandlers/containers.py @ 196:0bc44a57ae6c alpha

Traipse Alpha 'OpenRPG' {100425-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 (Patch-2) New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues
author sirebral
date Sun, 25 Apr 2010 23:26:55 -0500
parents b633f4c64aae
children 50af54dbd6a6
rev   line source
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
2 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
3 # openrpg-dev@lists.sourceforge.net
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
4 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
5 # This program is free software; you can redistribute it and/or modify
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
6 # it under the terms of the GNU General Public License as published by
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
8 # (at your option) any later version.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
9 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
10 # This program is distributed in the hope that it will be useful,
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
13 # GNU General Public License for more details.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
14 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
15 # You should have received a copy of the GNU General Public License
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
16 # along with this program; if not, write to the Free Software
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
18 # --
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
19 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
20 # File: containers.py
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
21 # Author: Chris Davis
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
22 # Maintainer:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
23 # Version:
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
24 # $Id: containers.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
25 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
26 # Description: The file contains code for the container nodehandlers
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
27 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
28
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
29
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
30 from core import *
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
31 from wx.lib.splitter import MultiSplitterWindow
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
32 from orpg.tools.orpg_log import logger
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
33 from orpg.orpgCore import component
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
34
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
35 ##########################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
36 ## base container
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
37 ##########################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
38
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
39 class container_handler(node_handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
40 """ should not be used! only a base class!
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
41 <nodehandler name='?' module='core' class='container_handler' />
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
42 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
43 def __init__(self, xml, tree_node):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
44 node_handler.__init__(self, xml, tree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
45 self.load_children()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
46
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
47 def load_children(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
48 for child_xml in self.xml: self.tree.load_xml(child_xml,self.mytree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
49
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
50 def check_map_aware(self, treenode, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
51 node = self.tree.GetPyData(treenode)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
52 if hasattr(node,"map_aware") and node.map_aware(): node.on_send_to_map(evt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
53
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
54 def on_send_to_map(self, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
55 self.tree.traverse(self.mytree_node, self.check_map_aware, evt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
56
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
57 def checkChildToMap(self, treenode, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
58 node = self.tree.GetPyData(treenode)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
59 if hasattr(node,"map_aware") and node.map_aware(): self.mapcheck = True
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
60
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
61 def checkToMapMenu(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
62 self.mapcheck = False
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
63 self.tree.traverse(self.mytree_node, self.checkChildToMap)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
64 return self.mapcheck
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
65
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
66 def on_drop(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
67 drag_obj = self.tree.drag_obj
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
68 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): return
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
69 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
70 if opt == wx.YES:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
71 drop_xml = self.tree.drag_obj.delete()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
72 self.xml.insert(0, drop_xml)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
73 self.tree.load_xml(drop_xml, self.mytree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
74 self.tree.Expand(self.mytree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
75 elif opt == wx.NO: node_handler.on_drop(self,evt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
76
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
77 def gen_html(self, treenode, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
78 node = self.tree.GetPyData(treenode)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
79 self.html_str += "<p>" + node.tohtml()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
80
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
81 def tohtml(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
82 self.html_str = "<table border='1' ><tr><td>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
83 self.html_str += "<b>"+self.xml.get("name") + "</b>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
84 self.html_str += "</td></tr>\n"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
85 self.html_str += "<tr><td>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
86 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
87 self.html_str += "</td></tr></table>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
88 return self.html_str
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
89
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
90 def get_size_constraint(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
91 return 2
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
92
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
93
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
94 ##########################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
95 ## group node handler
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
96 ##########################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
97 class group_handler(container_handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
98 """ group nodehandler to be used as a placeholder for other nodehandlers.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
99 This handler will continue parsing child xml data.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
100 <nodehandler name='?' module='core' class='group_handler' />
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
101 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
102 def __init__(self, xml, tree_node):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
103 container_handler.__init__(self, xml, tree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
104
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
105 def load_children(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
106 self.atts = None
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
107 for child_xml in self.xml:
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
108 if child_xml.tag == "group_atts": #having the group attributes as a child is bad!
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
109 self.xml.remove(child_xml)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
110 elif child_xml: self.tree.load_xml(child_xml, self.mytree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
111 if not self.xml.get('cols'): self.xml.set('cols', '1')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
112 if not self.xml.get('border'): self.xml.set('border', '1')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
113
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
114 def get_design_panel(self,parent):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
115 return group_edit_panel(parent,self)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
116
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
117 def on_use(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
118 return
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
119
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
120 def gen_html(self, treenode, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
121 node = self.tree.GetPyData(treenode)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
122 if self.i not in self.tdatas: self.tdatas[self.i] = ''
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
123 self.tdatas[self.i] += "<P>" + node.tohtml()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
124 self.i += 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
125 if self.i >= self.cols: self.i = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
126
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
127 def tohtml(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
128 cols = self.xml.get("cols")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
129 border = self.xml.get("border")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
130 self.html_str = "<table border='"+border+"' ><tr><td colspan='"+cols+"'>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
131 self.html_str += "<font size=4>"+self.xml.get("name") + "</font>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
132 self.html_str += "</td></tr>\n<tr>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
133 self.cols = int(cols)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
134 self.i = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
135 self.tdatas = {}
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
136 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
137 for td in self.tdatas: self.html_str += "<td valign='top' >" + self.tdatas[td] + "</td>\n";
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
138 self.html_str += "</tr></table>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
139 return self.html_str
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
140
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
141 GROUP_COLS = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
142 GROUP_BOR = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
143
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
144 class group_edit_panel(wx.Panel):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
145 def __init__(self, parent, handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
146 wx.Panel.__init__(self, parent, -1)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
147 self.handler = handler
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
148 self.outline = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Group"), wx.VERTICAL)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
149
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
150 sizer = wx.BoxSizer(wx.VERTICAL)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
151 self.text = {P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) }
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
152 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
153 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
154 sizer.Add(wx.Size(10,10))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
156 radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"])
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
157 cols = handler.xml.get("cols")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
158 if cols != "": radio_c.SetSelection(int(cols)-1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
159
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
160 radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"])
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
161 border = handler.xml.get("border")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
162 if border != "": radio_b.SetSelection(int(border))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
163
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
164 sizer.Add(radio_c, 0, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
165 sizer.Add(wx.Size(10,10))
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
166 sizer.Add(radio_b, 0, wx.EXPAND)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
167
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
168 self.outline.Add(sizer, 0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
169 self.sizer = self.outline
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
170 self.SetSizer(self.sizer)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
171 self.SetAutoLayout(True)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
172 self.Fit()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
173 parent.SetSize(self.GetBestSize())
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
174 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
175 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_BOR)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
176 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_COLS)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
177
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
178 def on_radio_box(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
179 id = evt.GetId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
180 index = evt.GetInt()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
181 if id == GROUP_COLS: self.handler.xml.set("cols",str(index+1))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
182 elif id == GROUP_BOR: self.handler.xml.set("border",str(index))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
183
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
184 def on_text(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
185 id = evt.GetId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
186 if id == P_TITLE:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
187 txt = self.text[id].GetValue()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
188 if txt != "":
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
189 self.handler.xml.set('name',txt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
190 self.handler.rename(txt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
191
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
192
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
193
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
194 ##########################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
195 ## tabber node handler
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
196 ##########################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
197 class tabber_handler(container_handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
198 """ <nodehandler name='?' module='containers' class='tabber_handler' />"""
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
199
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
200 def __init__(self, xml, tree_node):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
201 container_handler.__init__(self, xml, tree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
202
181
fa18af3e04b9 Traipse Alpha 'OpenRPG' {100115-01}
sirebral
parents: 173
diff changeset
203 def get_design_panel(self, parent):
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
204 return tabbed_panel(parent, self, 1)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
205
181
fa18af3e04b9 Traipse Alpha 'OpenRPG' {100115-01}
sirebral
parents: 173
diff changeset
206 def get_use_panel(self, parent):
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
207 return tabbed_panel(parent, self, 0)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
208
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
209
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
210 class tabbed_panel(orpgTabberWnd):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
211 def __init__(self, parent, handler, mode):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
212 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
213 self.handler = handler
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
214 self.parent = parent
181
fa18af3e04b9 Traipse Alpha 'OpenRPG' {100115-01}
sirebral
parents: 173
diff changeset
215 if mode == 1: self.AddPage(tabbed_edit_panel(parent, handler), 'Tabber', False)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
216 handler.tree.traverse(handler.mytree_node, self.pick_panel, mode, False)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
217 parent.SetSize(self.GetBestSize())
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
218
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
219 def pick_panel(self, treenode, mode):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
220 node = self.handler.tree.GetPyData(treenode)
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
221
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
222 if mode == 1: panel = node.get_design_panel(self)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
223 else: panel = node.get_use_panel(self)
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
224 name = node.xml.get("name")
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
225 if name == None: ## Fixes broken 3e Inventory child
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
226 if node.xml.tag == 'inventory':
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
227 node.xml.set('name', 'Inventory')
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
228 name = "Inventory"
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
229 logger.info('A corrective action was take to a 3e PC Sheet', True)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
230 component.get('frame').TraipseSuiteWarn('item')
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
231 if panel: self.AddPage(panel, name, False)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
232
181
fa18af3e04b9 Traipse Alpha 'OpenRPG' {100115-01}
sirebral
parents: 173
diff changeset
233 class tabbed_edit_panel(wx.Panel):
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
234 def __init__(self, parent, handler):
181
fa18af3e04b9 Traipse Alpha 'OpenRPG' {100115-01}
sirebral
parents: 173
diff changeset
235 wx.Panel.__init__(self, parent, -1, style=FNB.FNB_NO_X_BUTTON)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
236 self.handler = handler
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
237 self.parent = parent
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
238 main_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Tabber"), wx.VERTICAL)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
239 self.title = wx.TextCtrl(self, 1, handler.xml.get('name'))
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
240 main_sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
241 main_sizer.Add(self.title, 0, wx.EXPAND)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
242 self.SetSizer(main_sizer)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
243 self.SetAutoLayout(True)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
244 self.Fit()
181
fa18af3e04b9 Traipse Alpha 'OpenRPG' {100115-01}
sirebral
parents: 173
diff changeset
245 parent.SetSize(self.GetBestSize())
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
246 self.Bind(wx.EVT_TEXT, self.on_text, id=1)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
247
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
248 def on_text(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
249 txt = self.title.GetValue()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
250 if txt != "":
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
251 self.handler.xml.set('name',txt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
252 self.handler.rename(txt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
253
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
254
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
255 #################################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
256 ## Splitter container
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
257 #################################
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
258
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
259 class splitter_handler(container_handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
260 """ <nodehandler name='?' module='containers' class='splitter_handler' />"""
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
261
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
262 def __init__(self,xml,tree_node):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
263 container_handler.__init__(self,xml,tree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
264
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
265 def load_children(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
266 self.atts = None
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
267 for child_xml in self.xml:
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
268 if child_xml.tag == "splitter_atts": print 'splitter_atts exist!'; self.xml.remove(child_xml) #Same here!
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
269 elif child_xml: self.tree.load_xml(child_xml,self.mytree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
270 if not self.xml.get('horizontal'): self.xml.set('horizontal', '0')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
271
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
272 def get_design_panel(self,parent):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
273 return self.build_splitter_wnd(parent, 1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
274
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
275 def get_use_panel(self,parent):
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
276 return self.build_splitter_wnd(parent, 0)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
277
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
278 def on_drop(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
279 drag_obj = self.tree.drag_obj
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
280 container_handler.on_drop(self,evt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
281
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
282 def build_splitter_wnd(self, parent, mode):
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
283 self.parent = parent
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
284 self.split = self.xml.get("horizontal")
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
285 self.pane = splitter_panel(parent, self, mode)
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
286 self.frame = self.pane.frame
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
287 self.splitter = MultiSplitterWindow(self.pane, -1,
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
288 style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH|wx.SP_NO_XP_THEME)
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
289 self.splitter.parent = self
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
290 if self.split == '1': self.splitter.SetOrientation(wx.VERTICAL)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
291 else: self.splitter.SetOrientation(wx.HORIZONTAL)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
292 self.tree.traverse(self.mytree_node, self.doSplit, mode, False)
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
293 self.pane.sizer.Add(self.splitter, -1, wx.EXPAND)
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
294 self.pane.SetAutoLayout(True)
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
295 self.pane.Fit()
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
296 parent.SetSize(self.pane.GetSize())
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
297 return self.pane
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
298
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
299 def doSplit(self, treenode, mode):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
300 node = self.tree.GetPyData(treenode)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
301 if mode == 1: tmp = node.get_design_panel(self.splitter)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
302 else: tmp = node.get_use_panel(self.splitter)
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
303 if self.split == '1': sash = self.frame.GetSize()[1]/len(self.xml.findall('nodehandler'))
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
304 else: sash = self.frame.GetSize()[0]/len(self.xml.findall('nodehandler'))
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
305 self.splitter.AppendWindow(tmp, sash)
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
306
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
307 def get_size_constraint(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
308 return 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
309
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
310 class splitter_panel(wx.Panel):
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
311 def __init__(self, parent, handler, mode):
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
312 wx.Panel.__init__(self, parent, -1)
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
313 self.parent = parent
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
314 self.handler = handler
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
315 self.sizer = wx.BoxSizer(wx.VERTICAL)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
316 if mode == 0: self.title = wx.StaticText(self, 1, handler.xml.get('name'))
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
317 elif mode == 1: self.title = wx.TextCtrl(self, 1, handler.xml.get('name'))
196
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
318 self.frame = self.GetParent()
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
319 while self.frame.GetName() != 'frame':
0bc44a57ae6c Traipse Alpha 'OpenRPG' {100425-00}
sirebral
parents: 195
diff changeset
320 self.frame = self.frame.GetParent()
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
321
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
322 if mode == 1:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
323 self.hozCheck = wx.CheckBox(self, -1, "Horizontal Split")
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
324 hoz = self.handler.xml.get("horizontal")
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
325 if hoz == '1': self.hozCheck.SetValue(True)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
326 else: self.hozCheck.SetValue(False)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
327
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
328 if mode == 1: self.sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
329 self.sizer.Add(self.title, 0)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
330 if mode == 1: self.sizer.Add(self.hozCheck, 0, wx.EXPAND)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
331 self.sizer.Add(wx.Size(10,0))
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
332
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
333 self.SetSizer(self.sizer)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
334 self.SetAutoLayout(True)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
335 self.Bind(wx.EVT_TEXT, self.on_text, id=1)
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 181
diff changeset
336 if mode == 1: self.Bind(wx.EVT_CHECKBOX, self.on_check_box, id=self.hozCheck.GetId())
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
337
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
338 def on_check_box(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
339 state = self.hozCheck.GetValue()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
340 if state: self.handler.xml.set("horizontal", "1")
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
341 else: self.handler.xml.set("horizontal", "0")
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
342
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
343 def on_text(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
344 txt = self.title.GetValue()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
345 if txt != "":
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
346 self.handler.xml.set('name',txt)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
347 self.handler.rename(txt)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
348