annotate orpg/gametree/nodehandlers/forms.py @ 131:90d19eb43830 alpha

Traipse Alpha 'OpenRPG' {091003-03} 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!! (Apparently I pasted from the OpenRPG folder. Wrong! Pro's or not, they need to eventually see the read text in their own debugger console.) Dead Node Children, now that's a O O -v-v- Happy Halloween!
author sirebral
date Tue, 03 Nov 2009 21:30:36 -0600
parents d54e1328dbb1
children fe4dc5817d5e
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: forms.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: forms.py,v 1.53 2007/04/21 23:00:51 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 form based nodehanlers
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 __version__ = "$Id: forms.py,v 1.53 2007/04/21 23:00:51 digitalxero Exp $"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
30
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
31 from containers import *
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
32 import orpg.minidom as minidom
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
33 from orpg.orpg_xml import xml
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
34 from wx.lib.scrolledpanel import ScrolledPanel
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
35
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
36 def bool2int(b):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
37 #in wxPython 2.5+, evt.Checked() returns True or False instead of 1.0 or 0.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
38 #by running the results of that through this function, we convert it.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
39 #if it was an int already, nothing changes. The difference between 1.0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
40 #and 1, i.e. between ints and floats, is potentially dangerous when we
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
41 #use str() on it, but it seems to work fine right now.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
42 if b: return 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
43 else: return 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
44
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
45 #################################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
46 ## form container
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
47 #################################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
48
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
49 class form_handler(container_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
50 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
51 <nodehandler name='?' module='forms' class='form_handler' >
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
52 <form width='100' height='100' />
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
53 </nodehandler>
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 __init__(self,xml,tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
56 container_handler.__init__(self, xml, tree_node)
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 load_children(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
59 self.atts = None
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
60 for child_xml in self.xml:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
61 if child_xml.tag == "form": self.xml.remove(child_xml)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
62 elif child_xml: self.tree.load_xml(child_xml, self.mytree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
63 if not self.xml.get('width'): self.xml.set('width', '400')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
64 if not self.xml.get('height'): self.xml.set('height', '600')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
65
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
66 def get_design_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
67 return form_edit_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
68
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
69 def get_use_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
70 return form_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
71
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
72 def on_drop(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
73 # make sure its a contorl node
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
74 container_handler.on_drop(self,evt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
75
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
76 class form_panel(ScrolledPanel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
77 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
78 ScrolledPanel.__init__(self, parent, wx.ID_ANY, style=wx.NO_BORDER|wx.VSCROLL|wx.HSCROLL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
79 self.height = int(handler.xml.get("height"))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
80 self.width = int(handler.xml.get("width"))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
81 self.SetSize((0,0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
82 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
83 self.parent = parent
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
84 self.main_sizer = wx.BoxSizer(wx.VERTICAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
85 handler.tree.traverse(handler.mytree_node, self.create_child_wnd, None, False)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
86 self.SetSizer(self.main_sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
87 self.SetAutoLayout(True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
88 self.SetupScrolling()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
89 parent.SetSize(self.GetSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
90 self.Fit()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
91
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
92 def SetSize(self, xy):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
93 (x, y) = self.GetSize()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
94 (nx, ny) = xy
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
95 if x < nx:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
96 x = nx+10
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
97 y += ny+11
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
98 ScrolledPanel.SetSize(self, (x, y))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
99
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
100 def create_child_wnd(self, treenode, evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
101 node = self.handler.tree.GetPyData(treenode)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
102 panel = node.get_use_panel(self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
103 size = node.get_size_constraint()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
104 if panel:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
105 self.main_sizer.Add(panel, size, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
106 self.main_sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
107
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
108 F_HEIGHT = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
109 F_WIDTH = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
110 class form_edit_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
111 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
112 wx.Panel.__init__(self, parent, -1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
113 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
114 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Form Properties"), wx.VERTICAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
115 wh_sizer = wx.BoxSizer(wx.HORIZONTAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
116 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')),
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
117 F_HEIGHT : wx.TextCtrl(self, F_HEIGHT, handler.xml.get('height')),
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
118 F_WIDTH : wx.TextCtrl(self, F_WIDTH, handler.xml.get('width'))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
119 }
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
120
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
121 wh_sizer.Add(wx.StaticText(self, -1, "Width:"), 0, wx.ALIGN_CENTER)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
122 wh_sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
123 wh_sizer.Add(self.text[F_WIDTH], 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
124 wh_sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
125 wh_sizer.Add(wx.StaticText(self, -1, "Height:"), 0, wx.ALIGN_CENTER)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
126 wh_sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
127 wh_sizer.Add(self.text[F_HEIGHT], 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
128
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
129 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
130 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
131 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
132 sizer.Add(wh_sizer,0,wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
133
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
134 self.SetSizer(sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
135 self.SetAutoLayout(True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
136 self.Fit()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
137 parent.SetSize(self.GetBestSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
138
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
139 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
140 self.Bind(wx.EVT_TEXT, self.on_text, id=F_HEIGHT)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
141 self.Bind(wx.EVT_TEXT, self.on_text, id=F_WIDTH)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
142
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
143 def on_text(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
144 id = evt.GetId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
145 txt = self.text[id].GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
146 if not len(txt): return
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
147 if id == P_TITLE:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
148 self.handler.xml.set('name',txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
149 self.handler.rename(txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
150 elif id == F_HEIGHT or id == F_WIDTH:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
151 try: int(txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
152 except: return 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
153 if id == F_HEIGHT: self.handler.xml.set("height",txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
154 elif id == F_WIDTH: self.handler.xml.set("width",txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
155
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
156 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
157 ## control handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
158 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
159 class control_handler(node_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
160 """ A nodehandler for form controls.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
161 <nodehandler name='?' module='forms' class='control_handler' />
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
162 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
163 def __init__(self, xml, tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
164 node_handler.__init__(self, xml, tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
165
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
166 def get_size_constraint(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
167 return 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
168
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
169 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
170 ## textctrl handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
171 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
172 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
173 # Updated by Snowdog (April 2003)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
174 # Now includes Raw Send Mode (like the chat macro uses)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
175 # and an option to remove the title from text when sent
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
176 # to the chat in the normal non-chat macro mode.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
177 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
178 class textctrl_handler(node_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
179 """ <nodehandler class="textctrl_handler" module="form" name="">
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
180 <text multiline='0' send_button='0' raw_mode='0' hide_title='0'>Text In Node</text>
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
181 </nodehandler>
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
182 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
183 def __init__(self,xml,tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
184 node_handler.__init__(self,xml,tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
185 self.text_elem = self.xml.find('text')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
186 if self.text_elem.get("send_button") == "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
187 self.text_elem.set("send_button","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
188 if self.text_elem.get("raw_mode") == "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
189 self.text_elem.set("raw_mode","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
190 if self.text_elem.get("hide_title") == "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
191 self.text_elem.set("hide_title","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
192
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
193 def get_design_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
194 return textctrl_edit_panel(parent,self)
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 get_use_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
197 return text_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
198
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
199 def get_size_constraint(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
200 return int(self.text_elem.get("multiline",0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
201
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
202 def is_multi_line(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
203 return int(self.text_elem.get("multiline",0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
204
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
205 def is_raw_send(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
206 return int(self.text_elem.get("raw_mode",0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
207
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
208 def is_hide_title(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
209 return int(self.text_elem.get("hide_title",0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
210
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
211 def has_send_button(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
212 return int(self.text_elem.get("send_button",0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
213
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
214 def tohtml(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
215 txt = self.get_value()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
216 txt = string.replace(txt,'\n',"<br />")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
217 if not self.is_hide_title():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
218 txt = "<b>"+self.xml.get("name")+":</b> "+txt
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
219 return txt
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
220
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
221 def get_value(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
222 return self.text_elem.text
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
223
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
224 def set_value(self, new_value):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
225 self.text_elem.text = str(new_value)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
226
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
227 FORM_TEXT_CTRL = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
228 FORM_SEND_BUTTON = wx.NewId()
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 text_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
231 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
232 wx.Panel.__init__(self, parent, -1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
233 self.chat = handler.chat
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
234 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
235 if handler.is_multi_line():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
236 text_style = wx.TE_MULTILINE
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
237 sizer_style = wx.EXPAND
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
238 sizer = wx.BoxSizer(wx.VERTICAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
239 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
240 sizer_style = wx.ALIGN_CENTER
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
241 text_style = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
242 sizer = wx.BoxSizer(wx.HORIZONTAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
243
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
244 txt = handler.get_value()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
245 if txt == None: txt = ''
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
246 self.text = wx.TextCtrl(self, FORM_TEXT_CTRL, txt, style=text_style)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
247 sizer.Add(wx.StaticText(self, -1, handler.xml.get('name')+": "), 0, sizer_style)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
248 sizer.Add(wx.Size(5,0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
249 sizer.Add(self.text, 1, sizer_style)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
250
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
251 if handler.has_send_button():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
252 sizer.Add(wx.Button(self, FORM_SEND_BUTTON, "Send"), 0, sizer_style)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
253
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
254 self.sizer = sizer
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
255 self.SetSizer(sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
256 self.SetAutoLayout(True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
257
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
258 parent.SetSize(self.GetBestSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
259 self.Bind(wx.EVT_TEXT, self.on_text, id=FORM_TEXT_CTRL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
260 self.Bind(wx.EVT_BUTTON, self.on_send, id=FORM_SEND_BUTTON)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
261
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
262 def on_text(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
263 txt = self.text.GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
264 #txt = strip_text(txt) ##Does not seem to exist.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
265 self.handler.text_elem.text = txt
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
266
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
267 def on_send(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
268 txt = self.text.GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
269 if not self.handler.is_raw_send():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
270 #self.chat.ParsePost(self.tohtml(),True,True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
271 self.chat.ParsePost(self.handler.tohtml(),True,True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
272 return 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
273 actionlist = txt.split("\n")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
274 for line in actionlist:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
275 if(line != ""):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
276 if line[0] != "/": ## it's not a slash command
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
277 self.chat.ParsePost(line,True,True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
278 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
279 action = line
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
280 self.chat.chat_cmds.docmd(action)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
281 return 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
282
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
283 F_MULTI = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
284 F_SEND_BUTTON = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
285 F_RAW_SEND = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
286 F_HIDE_TITLE = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
287 F_TEXT = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
288
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
289 class textctrl_edit_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
290 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
291 wx.Panel.__init__(self, parent, -1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
292 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
293 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Text Properties"), wx.VERTICAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
294
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
295 self.title = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
296 self.multi = wx.CheckBox(self, F_MULTI, " Multi-Line")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
297 self.multi.SetValue(handler.is_multi_line())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
298 self.raw_send = wx.CheckBox(self, F_RAW_SEND, " Send as Macro")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
299 self.raw_send.SetValue(handler.is_raw_send())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
300 self.hide_title = wx.CheckBox(self, F_HIDE_TITLE, " Hide Title")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
301 self.hide_title.SetValue(handler.is_hide_title())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
302 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
303 self.send_button.SetValue(handler.has_send_button())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
304
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
305 sizer.Add(wx.StaticText(self, P_TITLE, "Title:"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
306 sizer.Add(self.title, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
307 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
308 sizer.Add(self.multi, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
309 sizer.Add(self.raw_send, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
310 sizer.Add(self.hide_title, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
311 sizer.Add(self.send_button, 0 , wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
312 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
313 if handler.is_multi_line():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
314 sizer_style = wx.EXPAND
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
315 text_style = wx.TE_MULTILINE
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
316 multi = 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
317 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
318 sizer_style=wx.EXPAND
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
319 text_style = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
320 multi = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
321 self.text = wx.TextCtrl(self, F_TEXT, handler.get_value(),style=text_style)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
322 sizer.Add(wx.Size(5,0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
323 sizer.Add(self.text, multi, sizer_style)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
324 self.SetSizer(sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
325 self.SetAutoLayout(True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
326
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
327 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
328 self.Bind(wx.EVT_TEXT, self.on_text, id=F_TEXT)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
329 self.Bind(wx.EVT_CHECKBOX, self.on_button, id=F_MULTI)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
330 self.Bind(wx.EVT_CHECKBOX, self.on_raw_button, id=F_RAW_SEND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
331 self.Bind(wx.EVT_CHECKBOX, self.on_hide_button, id=F_HIDE_TITLE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
332 self.Bind(wx.EVT_CHECKBOX, self.on_send_button, id=F_SEND_BUTTON)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
333
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
334 def on_text(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
335 id = evt.GetId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
336 if id == P_TITLE:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
337 txt = self.title.GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
338 if not len(txt): return
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
339 self.handler.xml.set('name',txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
340 self.handler.rename(txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
341 if id == F_TEXT:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
342 txt = self.text.GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
343 #txt = strip_text(txt) ##Does not seem to exist.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
344 self.handler.text_elem.text = txt
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
345
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
346 def on_button(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
347 self.handler.text_elem.set("multiline",str(bool2int(evt.Checked())))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
348
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
349 def on_raw_button(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
350 self.handler.text_elem.set("raw_mode",str(bool2int(evt.Checked())))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
351
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
352 def on_hide_button(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
353 self.handler.text_elem.set("hide_title",str(bool2int(evt.Checked())))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
354
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
355 def on_send_button(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
356 self.handler.text_elem.set("send_button",str(bool2int(evt.Checked())))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
357
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
358
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
359 #######################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
360 ## listbox handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
361 #######################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
362 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
363 # Updated by Snowdog (April 2003)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
364 # Now includesan option to remove the title from
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
365 # text when sent to the chat.
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
366 #
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
367 L_DROP = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
368 L_LIST = 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
369 L_RADIO = 2
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
370 L_CHECK = 3
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
371 L_ROLLER = 4
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
372
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
373 class listbox_handler(node_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
374 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
375 <nodehandler class="listbox_handler" module="forms" name="">
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
376 <list type="1" send_button='0' hide_title='0'>
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
377 <option value="" selected="" >Option Text I</option>
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
378 <option value="" selected="" >Option Text II</option>
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
379 </list>
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
380 </nodehandler>
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
381 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
382 def __init__(self,xml,tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
383 node_handler.__init__(self,xml,tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
384 self.list = self.xml.find('list')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
385 self.options = self.list.findall('option')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
386 if self.list.get("send_button") == "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
387 self.list.set("send_button","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
388 if self.list.get("hide_title") == "":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
389 self.list.set("hide_title","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
390
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
391 def get_design_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
392 return listbox_edit_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
393
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
394 def get_use_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
395 return listbox_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
396
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
397 def get_type(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
398 return int(self.list.get("type"))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
399
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
400 def set_type(self,type):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
401 self.list.set("type",str(type))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
402
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
403 def is_hide_title(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
404 return int(self.list.get("hide_title", 0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
405
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
406 # single selection methods
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
407 def get_selected_node(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
408 for opt in self.options:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
409 if opt.get("selected") == "1": return opt
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
410 return None
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
411
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
412 def get_selected_index(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
413 i = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
414 for opt in self.options:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
415 if opt.get("selected") == "1":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
416 return i
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
417 i += 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
418 return 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
419
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
420 def get_selected_text(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
421 node = self.get_selected_node()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
422 if node:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
423 return node.text
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
424 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
425 return ""
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
426
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
427
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
428 # mult selection methods
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
429
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
430 def get_selections(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
431 opts = []
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
432 for opt in self.options:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
433 if opt.get("selected") == "1":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
434 opts.append(opt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
435 return opts
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
436
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
437 def get_selections_text(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
438 opts = []
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
439 for opt in self.options:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
440 if opt.get("selected") == "1":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
441 opts.append(opt.text)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
442 return opts
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
443
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
444 def get_selections_index(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
445 opts = []
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
446 i = 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
447 for opt in self.options:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
448 if opt.get("selected") == "1":
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
449 opts.append(i)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
450 i += 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
451 return opts
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
452
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
453 # setting selection method
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
454
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
455 def set_selected_node(self,index,selected=1):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
456 if self.get_type() != L_CHECK:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
457 self.clear_selections()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
458 self.options[index].set("selected", str(bool2int(selected)))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
459
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
460 def clear_selections(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
461 for opt in self.options:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
462 opt.set("selected","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
463
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
464 # misc methods
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
465
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
466 def get_options(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
467 opts = []
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
468 for opt in self.options:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
469 opts.append(opt.text)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
470 return opts
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
471
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
472 def get_option(self,index):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
473 return self.options[index].text
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
474
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
475 def add_option(self,opt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
476 elem = Element('option')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
477 elem.set("value","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
478 elem.set("selected","0")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
479 elem.text = opt
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
480 self.list.append(elem)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
481 self.options = self.list.findall('option')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
482
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
483 def remove_option(self,index):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
484 self.list.remove(self.options[index])
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
485 self.options = self.list.findall('option')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
486
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
487 def edit_option(self,index,value):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
488 self.options[index].text = value
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
489
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
490 def has_send_button(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
491 if self.list.get("send_button") == '0':
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
492 return False
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
493 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
494 return True
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
495
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
496 def get_size_constraint(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
497 if self.get_type() == L_DROP:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
498 return 0
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
499 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
500 return 1
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
501
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
502 def tohtml(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
503 opts = self.get_selections_text()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
504 text = ""
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
505 if not self.is_hide_title():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
506 text = "<b>"+self.xml.get("name")+":</b> "
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
507 comma = ", "
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
508 text += comma.join(opts)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
509 return text
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
510
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
511 def get_value(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
512 return "\n".join(self.get_selections_text())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
513
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
514
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
515 F_LIST = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
516 F_SEND = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
517
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
518
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
519 class listbox_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
520 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
521 wx.Panel.__init__(self, parent, -1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
522 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
523 self.chat = handler.chat
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
524 opts = handler.get_options()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
525 cur_opt = handler.get_selected_text()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
526 type = handler.get_type()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
527 label = handler.xml.get('name')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
528
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
529 if type == L_DROP:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
530 self.list = wx.ComboBox(self, F_LIST, cur_opt, choices=opts, style=wx.CB_READONLY)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
531 if self.list.GetSize()[0] > 200:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
532 self.list.Destroy()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
533 self.list = wx.ComboBox(self, F_LIST, cur_opt, size=(200, -1), choices=opts, style=wx.CB_READONLY)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
534 elif type == L_LIST:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
535 self.list = wx.ListBox(self,F_LIST,choices=opts)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
536 elif type == L_RADIO:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
537 self.list = wx.RadioBox(self,F_LIST,label,choices=opts,majorDimension=3)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
538 elif type == L_CHECK:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
539 self.list = wx.CheckListBox(self,F_LIST,choices=opts)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
540 self.set_checks()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
541
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
542 for i in handler.get_selections_text():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
543 if type == L_DROP:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
544 self.list.SetValue( i )
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
545 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
546 self.list.SetStringSelection( i )
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
547
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
548 if type == L_DROP:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
549 sizer = wx.BoxSizer(wx.HORIZONTAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
550
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
551 else:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
552 sizer = wx.BoxSizer(wx.VERTICAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
553
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
554 if type != L_RADIO:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
555 sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
556 sizer.Add(wx.Size(5,0))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
557
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
558 sizer.Add(self.list, 1, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
559
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
560 if handler.has_send_button():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
561 sizer.Add(wx.Button(self, F_SEND, "Send"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
562 self.Bind(wx.EVT_BUTTON, self.handler.on_send_to_chat, id=F_SEND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
563
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
564 self.sizer = sizer
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
565 self.SetSizer(sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
566 self.SetAutoLayout(True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
567 self.Fit()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
568
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
569 parent.SetSize(self.GetBestSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
570
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
571 if type == L_DROP:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
572 self.Bind(wx.EVT_COMBOBOX, self.on_change, id=F_LIST)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
573 elif type == L_LIST:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
574 self.Bind(wx.EVT_LISTBOX, self.on_change, id=F_LIST)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
575 elif type == L_RADIO:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
576 self.Bind(wx.EVT_RADIOBOX, self.on_change, id=F_LIST)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
577 elif type == L_CHECK:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
578 self.Bind(wx.EVT_CHECKLISTBOX, self.on_check, id=F_LIST)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
579
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
580
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
581 self.type = type
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
582
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
583
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
584 def on_change(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
585 self.handler.set_selected_node(self.list.GetSelection())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
586
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
587 def on_check(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
588 for i in xrange(self.list.GetCount()):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
589 self.handler.set_selected_node(i, bool2int(self.list.IsChecked(i)))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
590
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
591 def set_checks(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
592 for i in self.handler.get_selections_index():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
593 self.list.Check(i)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
594
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
595
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
596
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
597 BUT_ADD = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
598 BUT_REM = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
599 BUT_EDIT = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
600 F_TYPE = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
601 F_NO_TITLE = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
602
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
603 class listbox_edit_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
604 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
605 wx.Panel.__init__(self, parent, -1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
606 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
607 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "List Box Properties"), wx.VERTICAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
608
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
609 self.text = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
610
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
611 opts = handler.get_options()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
612 self.listbox = wx.ListBox(self, F_LIST, choices=opts, style=wx.LB_HSCROLL|wx.LB_SINGLE|wx.LB_NEEDED_SB)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
613 opts = ['Drop Down', 'List Box', 'Radio Box', 'Check List']
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
614 self.type_radios = wx.RadioBox(self,F_TYPE,"List Type",choices=opts)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
615 self.type_radios.SetSelection(handler.get_type())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
616
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
617 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
618 self.send_button.SetValue(handler.has_send_button())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
619
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
620 self.hide_title = wx.CheckBox(self, F_NO_TITLE, " Hide Title")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
621 self.hide_title.SetValue(handler.is_hide_title())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
622
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
623 but_sizer = wx.BoxSizer(wx.HORIZONTAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
624 but_sizer.Add(wx.Button(self, BUT_ADD, "Add"), 1, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
625 but_sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
626 but_sizer.Add(wx.Button(self, BUT_EDIT, "Edit"), 1, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
627 but_sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
628 but_sizer.Add(wx.Button(self, BUT_REM, "Remove"), 1, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
629
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
630 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
631 sizer.Add(self.text, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
632 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
633 sizer.Add(self.type_radios, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
634 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
635 sizer.Add(self.send_button, 0 , wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
636 sizer.Add(self.hide_title, 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
637 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
638 sizer.Add(wx.StaticText(self, -1, "Options:"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
639 sizer.Add(self.listbox,1,wx.EXPAND);
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
640 sizer.Add(but_sizer,0,wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
641
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
642 self.SetSizer(sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
643 self.SetAutoLayout(True)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
644 self.Fit()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
645 parent.SetSize(self.GetBestSize())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
646
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
647 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
648 self.Bind(wx.EVT_BUTTON, self.on_edit, id=BUT_EDIT)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
649 self.Bind(wx.EVT_BUTTON, self.on_remove, id=BUT_REM)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
650 self.Bind(wx.EVT_BUTTON, self.on_add, id=BUT_ADD)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
651 self.Bind(wx.EVT_RADIOBOX, self.on_type, id=F_TYPE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
652 self.Bind(wx.EVT_CHECKBOX, self.on_hide_button, id=F_NO_TITLE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
653 self.Bind(wx.EVT_CHECKBOX, self.on_send_button, id=F_SEND_BUTTON)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
654
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
655 def on_type(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
656 self.handler.set_type(evt.GetInt())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
657
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
658 def on_add(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
659 dlg = wx.TextEntryDialog(self, 'Enter option?','Add Option', '')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
660 if dlg.ShowModal() == wx.ID_OK:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
661 self.handler.add_option(dlg.GetValue())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
662 dlg.Destroy()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
663 self.reload_options()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
664
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
665 def on_remove(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
666 index = self.listbox.GetSelection()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
667 if index >= 0:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
668 self.handler.remove_option(index)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
669 self.reload_options()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
670
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
671 def on_edit(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
672 index = self.listbox.GetSelection()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
673 if index >= 0:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
674 txt = self.handler.get_option(index)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
675 dlg = wx.TextEntryDialog(self, 'Enter option?','Edit Option', txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
676 if dlg.ShowModal() == wx.ID_OK:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
677 self.handler.edit_option(index,dlg.GetValue())
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
678 dlg.Destroy()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
679 self.reload_options()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
680
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
681 def reload_options(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
682 self.listbox.Clear()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
683 for opt in self.handler.get_options():
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
684 self.listbox.Append(opt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
685
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
686 def on_text(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
687 id = evt.GetId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
688 txt = self.text.GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
689 if not len(txt): return
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
690 if id == P_TITLE:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
691 self.handler.xml.set('name',txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
692 self.handler.rename(txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
693
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
694 def on_send_button(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
695 self.handler.list.set("send_button", str( bool2int(evt.Checked()) ))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
696
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
697 def on_hide_button(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
698 self.handler.list.set("hide_title", str( bool2int(evt.Checked()) ))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
699
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
700
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
701 ###############################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
702 ## link image handlers
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
703 ###############################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
704
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
705 class link_handler(node_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
706 """ A nodehandler for URLs. Will open URL in a wxHTMLFrame
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
707 <nodehandler name='?' module='forms' class='link_handler' >
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
708 <link href='http//??.??' />
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
709 </nodehandler >
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
710 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
711 def __init__(self,xml,tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
712 node_handler.__init__(self,xml,tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
713 self.link = self.xml[0]
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
714
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
715 def on_use(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
716 href = self.link.get("href")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
717 wb = webbrowser.get()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
718 wb.open(href)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
719
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
720 def get_design_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
721 return link_edit_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
722
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
723 def get_use_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
724 return link_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
725
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
726 def tohtml(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
727 href = self.link.get("href")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
728 title = self.xml.get("name")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
729 return "<a href=\""+href+"\" >"+title+"</a>"
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
730
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
731 class link_panel(wx.StaticText):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
732 def __init__(self,parent,handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
733 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
734 label = handler.xml.get('name')
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
735 wx.StaticText.__init__(self,parent,-1,label)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
736 self.SetForegroundColour(wx.BLUE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
737 self.Bind(wx.EVT_LEFT_DOWN, self.handler.on_use)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
738
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
739
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
740 P_URL = wx.NewId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
741
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
742 class link_edit_panel(wx.Panel):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
743 def __init__(self, parent, handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
744 wx.Panel.__init__(self, parent, -1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
745 self.handler = handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
746 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Link Properties"), wx.VERTICAL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
747
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
748 self.text = {}
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
749 self.text[P_TITLE] = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
750 self.text[P_URL] = wx.TextCtrl(self, P_URL, handler.link.get('href'))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
751
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
752 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
753 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
754 sizer.Add(wx.Size(10,10))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
755 sizer.Add(wx.StaticText(self, -1, "URL:"), 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
756 sizer.Add(self.text[P_URL], 0, wx.EXPAND)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
757 self.SetSizer(sizer)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
758 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
759 self.Bind(wx.EVT_TEXT, self.on_text, id=P_URL)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
760
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
761 def on_text(self,evt):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
762 id = evt.GetId()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
763 txt = self.text[id].GetValue()
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
764 if not len(txt): return
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
765 if id == P_TITLE:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
766 self.handler.xml.set('name',txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
767 self.handler.rename(txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
768 elif id == P_URL:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
769 self.handler.link.set('href',txt)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
770
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
771 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
772 ## webimg node handler
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
773 ##########################
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
774 class webimg_handler(node_handler):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
775 """ A nodehandler for URLs. Will open URL in a wxHTMLFrame
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
776 <nodehandler name='?' module='forms' class='webimg_handler' >
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
777 <link href='http//??.??' />
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
778 </nodehandler >
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
779 """
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
780 def __init__(self,xml,tree_node):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
781 node_handler.__init__(self,xml,tree_node)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
782 self.link = self.xml[0]
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
783
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
784 def get_design_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
785 return link_edit_panel(parent,self)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
786
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
787 def get_use_panel(self,parent):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
788 img = img_helper().load_url(self.link.get("href"))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
789 if not img is None:
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
790 return wx.StaticBitmap(parent,-1,img,size= wx.Size(img.GetWidth(),img.GetHeight()))
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
791 return wx.EmptyBitmap(1, 1)
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
792
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
793 def tohtml(self):
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
794 href = self.link.get("href")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
795 title = self.xml.get("name")
90d19eb43830 Traipse Alpha 'OpenRPG' {091003-03}
sirebral
parents: 130
diff changeset
796 return "<img src=\""+href+"\" alt="+title+" >"