Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
GUIButton Class Reference
Inheritance diagram for GUIButton:
GUIStaticImage GUIElement GUICheckButton GUICompButton GUIRoomButton GUIRadioButton

Public Member Functions

def __init__
 
def onMouseUp
 
def onMouseDown
 
def onMouseEnter
 
def onMouseLeave
 
def onMouseMove
 
def onClick
 
def draw
 
def setNeutralState
 
def undraw
 
def hide
 
def show
 
def redraw
 
def setCaption
 
def setState
 
def getState
 
def hasState
 
def isEnabled
 
def enable
 
def disable
 
def setEnable
 
def getGroup
 
def setGroup
 
def onMessage
 
- Public Member Functions inherited from GUIStaticImage
def __init__
 
def spriteIsValid
 
def draw
 
def undraw
 
def redraw
 
def setSprite
 
- Public Member Functions inherited from GUIElement
def __init__
 
def __str__
 
def __repr__
 
def show
 
def hide
 
def notifyNeedRedraw
 
def draw
 
def undraw
 
def redraw
 
def onMessage
 
def onClick
 
def onShow
 
def onHide
 
def onDraw
 
def onUndraw
 
def onRedraw
 
def focus
 
def setModal
 
def isInteractive
 

Data Fields

 sprites
 
 hotspot
 
 linkdesc
 
 linkstate
 
 state
 
 group
 
 enabled
 
 clickHandler
 
 textOverlay
 
 textcolor
 
 textbgcolor
 
 textfontsize
 
 pythonstr
 
 visible
 
- Data Fields inherited from GUIStaticImage
 sprite
 
 index
 
 spritestate
 
 redrawPreservesZ
 
 visible
 
- Data Fields inherited from GUIElement
 room
 
 owner
 
 visible
 
 redrawPreservesZ
 
 id
 

Detailed Description

Definition at line 1100 of file GUI.py.

Constructor & Destructor Documentation

def __init__ (   self,
  room,
  linkdesc,
  index,
  spritefiles,
  hotspot,
  initialstate = 'enabled',
  clickHandler = None,
  textcolor = GUIColor.white(),
  textbgcolor = None,
  textfontsize = 1.0,
  kwarg 
)
Initializes the button (but does not draw it; use drawobjs())  
spritefiles: a dictionary, mapping states to sprites           
'enabled' : normal, default, enabled state                 
'disabled': disabled (grayed) state                        
'hot'     : hot state (mouse over)                         
'down'    : down state (mouse clicking)                    
'*'       : fallback state                                 
Each state in spriteifiles must be a tuple of the form:        
( path , location )                                        
or ( path, location, text [,textattrs] )                   
( ) - empty, for "no change"                               
with 'location' being a GUIRect                           
and  'text' being an optional overlaid text element       

Definition at line 1101 of file GUI.py.

1102  def __init__(self,room,linkdesc,index,spritefiles,hotspot,initialstate='enabled',clickHandler=None,textcolor=GUIColor.white(),textbgcolor=None,textfontsize=1.0,**kwarg):
1103  """ Initializes the button (but does not draw it; use drawobjs()) """
1104  """ spritefiles: a dictionary, mapping states to sprites """
1105  """ 'enabled' : normal, default, enabled state """
1106  """ 'disabled': disabled (grayed) state """
1107  """ 'hot' : hot state (mouse over) """
1108  """ 'down' : down state (mouse clicking) """
1109  """ '*' : fallback state """
1110  """ Each state in spriteifiles must be a tuple of the form: """
1111  """ ( path , location ) """
1112  """ or ( path, location, text [,textattrs] ) """
1113  """ ( ) - empty, for "no change" """
1114  """ with 'location' being a GUIRect """
1115  """ and 'text' being an optional overlaid text element """
1117  self.sprites=spritefiles
1118  self.hotspot=hotspot
1119  self.linkdesc=linkdesc
1120  self.linkstate=0
1121  self.state=initialstate
1122  self.group=index
1123  self.enabled=(initialstate!='disabled')
1124  self.clickHandler = clickHandler
1125  self.textOverlay = None
1126  self.textcolor = textcolor
1127  self.textbgcolor = textbgcolor
1128  self.textfontsize = textfontsize
1129 
1130  """ Init base class """
1131  GUIStaticImage.__init__(self,room,index,self._getStateSprite(self.state),**kwarg)
1132  self.textOverlay = GUIStaticText(self.room,self.index+"__text_overlay","",
1133  self.hotspot,self.textcolor,self.textfontsize,self.textbgcolor)
1134  self.textOverlay.hide()
1136  self.pythonstr = \
1137  "# <-- this disables precompiled python objects\n" \
1138  +"from GUI import GUIRootSingleton\n" \
1139  +"evData = Base.GetEventData()\n" \
1140  +"typeToMessage = {'click':'click','up':'up','down':'down','move':'move','enter':'enter','leave':'leave'}\n" \
1141  +"if ('type' in evData) and (evData['type'] in typeToMessage):\n" \
1142  +"\tGUIRootSingleton.dispatchMessage("+str(self.id)+",typeToMessage[evData['type']],evData)\n" \
1143  +"\tGUIRootSingleton.redrawIfNeeded()\n"

Member Function Documentation

def disable (   self)

Definition at line 1278 of file GUI.py.

References Breakpoint.enabled, GUIButton.enabled, and GUIButton.setNeutralState().

1279  def disable(self):
1280  self.enabled=False
1281  self.setNeutralState()
def draw (   self)
Creates the button 

Definition at line 1186 of file GUI.py.

1187  def draw(self):
1188  """ Creates the button """
1189  if (self.linkstate==0) and (self.visible==1) and self.enabled:
1190  # getHotRect returns the BOTTOM-left x,y needed by Base.Python
1191  (x,y,w,h) = self.hotspot.getHotRect()
1192  Base.Python(self.room.getIndex(),self.index,x,y,w,h,self.linkdesc,self.pythonstr,True)
1193  Base.SetLinkEventMask(self.room.getIndex(),self.index,'cduel')
1194  self.linkstate=1
1195  self.setState(self.state)
1196  GUIStaticImage.draw(self)
1197  if self.textOverlay.visible:
1198  self.textOverlay.draw()
def enable (   self)

Definition at line 1274 of file GUI.py.

References Breakpoint.enabled, GUIButton.enabled, and GUIButton.setNeutralState().

1275  def enable(self):
1276  self.enabled=True
1277  self.setNeutralState()
def getGroup (   self)

Definition at line 1288 of file GUI.py.

References _Dummy.group, and GUIButton.group.

1289  def getGroup(self):
1290  return self.group
def getState (   self)

Definition at line 1265 of file GUI.py.

References shlex.state, BinHex.state, HexBin.state, GUIButton.state, and Scanner.state.

1266  def getState(self):
1267  return self.state
def hasState (   self,
  state 
)

Definition at line 1268 of file GUI.py.

References GUIButton.sprites.

1269  def hasState(self,state):
1270  return self.sprites and (state in self.sprites)
def hide (   self)

Definition at line 1213 of file GUI.py.

1214  def hide(self):
1215  GUIStaticImage.hide(self)
1216  self.textOverlay.hide()
def isEnabled (   self)

Definition at line 1271 of file GUI.py.

References Breakpoint.enabled, and GUIButton.enabled.

1272  def isEnabled(self):
1273  return self.enabled
def onClick (   self,
  params 
)

Definition at line 1181 of file GUI.py.

1182  def onClick(self,params):
1183  if self.clickHandler:
1184  self.clickHandler(self,params)
1185  GUIStaticImage.onClick(self,params)
def onMessage (   self,
  message,
  params 
)

Definition at line 1294 of file GUI.py.

References Breakpoint.disable(), GUIButton.disable(), Breakpoint.enable(), GUIButton.enable(), GUIButton.getGroup(), DialogBox.Item.id, DialogBox.id, GUIElement.id, GUIElement.isInteractive(), GUIButton.onMouseDown(), GUIButton.onMouseEnter(), GUIButton.onMouseLeave(), GUIButton.onMouseMove(), and GUIButton.onMouseUp().

1295  def onMessage(self,message,params):
1296  # Button-specific actions
1297  if (message=='enable'):
1298  if (not ('group' in params) or (self.getGroup() == params['group'])) and (not ('exclude' in params) or (self.id != params['exclude'])):
1299  self.enable()
1300  elif (message=='disable'):
1301  if (not ('group' in params) or (self.getGroup() == params['group'])) and (not ('exclude' in params) or (self.id != params['exclude'])):
1302  self.disable()
1303  # Button-specific mouse events
1304  elif self.isInteractive():
1305  if (message=='move'):
1306  self.onMouseMove(params)
1307  elif (message=='up'):
1308  self.onMouseUp(params)
1309  elif (message=='down'):
1310  self.onMouseDown(params)
1311  elif (message=='enter'):
1312  self.onMouseEnter(params)
1313  elif (message=='leave'):
1314  self.onMouseLeave(params)
1315  # Fallback
1316  else:
1317  GUIStaticImage.onMessage(self,message,params)
1318 
1319 
1320 
1321 """----------------------------------------------------------------"""
1322 """ """
1323 """ GUICompButton - a button you can click on that takes you """
1324 """ to the original computer interface """
1325 """ """
1326 """----------------------------------------------------------------"""
def onMouseDown (   self,
  params 
)

Definition at line 1166 of file GUI.py.

References GUIButton.hasState(), GUIButton.isEnabled(), and GUIButton.setState().

1167  def onMouseDown(self,params):
1168  if self.isEnabled() and self.hasState('down'):
1169  self.setState('down')
def onMouseEnter (   self,
  params 
)

Definition at line 1170 of file GUI.py.

References GUIButton.hasState(), GUIButton.isEnabled(), and GUIButton.setState().

1171  def onMouseEnter(self,params):
1172  if self.isEnabled() and self.hasState('hot'):
1173  self.setState('hot')
def onMouseLeave (   self,
  params 
)

Definition at line 1174 of file GUI.py.

References GUIButton.getState(), and GUIButton.setNeutralState().

1175  def onMouseLeave(self,params):
1176  if self.getState()=='hot' or self.getState()=='down':
1177  self.setNeutralState()
def onMouseMove (   self,
  params 
)
Intentionally blank 

Definition at line 1178 of file GUI.py.

1179  def onMouseMove(self,params):
1180  """ Intentionally blank """
def onMouseUp (   self,
  params 
)

Definition at line 1162 of file GUI.py.

References GUIButton.getState(), and GUIButton.setNeutralState().

1163  def onMouseUp(self,params):
1164  if self.getState()=='down':
1165  self.setNeutralState()
def redraw (   self)
Creates the button 

Definition at line 1221 of file GUI.py.

References DialogBox.Item.draw(), DialogBox.List.draw(), DialogBox.Row.draw(), DialogBox.draw(), GUIElement.draw(), Breakpoint.enabled, GUIButton.enabled, Tokenizer.index, ListReader.index, GUIRoom.index, GUIStaticImage.index, GUIMouseOver.linkdesc, GUIButton.linkdesc, GUIMouseOver.linkstate, GUIButton.linkstate, GUIButton.pythonstr, GUIButton.setState(), shlex.state, BinHex.state, HexBin.state, GUIButton.state, Scanner.state, DialogBox.Item.undraw(), DialogBox.Row.undraw(), DialogBox.undraw(), GUIElement.undraw(), and GUIElement.visible.

1222  def redraw(self):
1223  """ Creates the button """
1224  if (self.linkstate==1) and (self.visible==1) and self.enabled:
1225  (x,y,w,h) = self.hotspot.getHotRect()
1226  Base.SetLinkArea(self.room.getIndex(),self.index,x,y,w,h)
1227  Base.SetLinkText(self.room.getIndex(),self.index,self.linkdesc)
1228  Base.SetLinkPython(self.room.getIndex(),self.index,self.pythonstr)
1229  self.linkstate=1
1230  self.setState(self.state)
1231  GUIStaticImage.redraw(self)
1232  if self.textOverlay.visible:
1233  self.textOverlay.redraw()
1234  else:
1235  self.undraw()
1236  self.draw()
def setCaption (   self,
  caption,
  attrs = None 
)

Definition at line 1237 of file GUI.py.

References locale.str().

1238  def setCaption(self,caption,attrs=None):
1239  if caption is not None:
1240  if not self.textOverlay.visible:
1241  self.textOverlay.show()
1242  if attrs is None:
1243  self.textOverlay.setText(str(caption))
1244  else:
1245  self.textOverlay.text = str(caption)
1246  self.textOverlay.color = attrs.get('color',self.textOverlay.color)
1247  self.textOverlay.bgcolor = attrs.get('bgcolor',self.textOverlay.bgcolor)
1248  self.textOverlay.fontsize = attrs.get('fontsize',self.textOverlay.fontsize)
1249  self.textOverlay.notifyNeedRedraw()
1250  else:
1251  self.textOverlay.hide()
1252 
def setEnable (   self,
  state 
)

Definition at line 1282 of file GUI.py.

References Breakpoint.disable(), GUIButton.disable(), Breakpoint.enable(), and GUIButton.enable().

1283  def setEnable(self,state):
1284  if state:
1285  self.enable()
1286  else:
1287  self.disable()
def setGroup (   self,
  group 
)

Definition at line 1291 of file GUI.py.

References _Dummy.group, and GUIButton.group.

1292  def setGroup(self,group):
1293  self.group = group
def setNeutralState (   self)

Definition at line 1199 of file GUI.py.

References GUIButton.isEnabled(), and GUIButton.setState().

1200  def setNeutralState(self):
1201  if self.isEnabled():
1202  self.setState('enabled')
1203  else:
1204  self.setState('disabled')
def setState (   self,
  newstate 
)

Definition at line 1253 of file GUI.py.

References GUIButton._getStateSprite(), GUIButton.setCaption(), GUIStaticImage.setSprite(), shlex.state, BinHex.state, HexBin.state, GUIButton.state, and Scanner.state.

1254  def setState(self,newstate):
1255  self.state = newstate
1256  spr = self._getStateSprite(self.state)
1257  self.setSprite(spr)
1258  if spr and len(spr)>2:
1259  if len(spr)>3:
1260  self.setCaption(spr[2],spr[3])
1261  else:
1262  self.setCaption(spr[2])
1263  elif spr:
1264  self.setCaption(None)
def show (   self)

Definition at line 1217 of file GUI.py.

1218  def show(self):
1219  GUIStaticImage.show(self)
1220  self.textOverlay.show()
def undraw (   self)
Hides the button

Definition at line 1205 of file GUI.py.

References Tokenizer.index, ListReader.index, GUIRoom.index, GUIStaticImage.index, GUIMouseOver.linkstate, and GUIButton.linkstate.

1206  def undraw(self):
1207  """Hides the button"""
1208  if self.linkstate==1:
1209  Base.EraseLink(self.room.getIndex(),self.index)
1210  self.linkstate=0
1211  GUIStaticImage.undraw(self)
1212  self.textOverlay.undraw()

Field Documentation

clickHandler

Definition at line 1123 of file GUI.py.

enabled

Definition at line 1122 of file GUI.py.

group

Definition at line 1121 of file GUI.py.

hotspot

Definition at line 1117 of file GUI.py.

linkdesc

Definition at line 1118 of file GUI.py.

linkstate

Definition at line 1119 of file GUI.py.

pythonstr

Definition at line 1135 of file GUI.py.

sprites

Definition at line 1116 of file GUI.py.

state

Definition at line 1120 of file GUI.py.

textbgcolor

Definition at line 1126 of file GUI.py.

textcolor

Definition at line 1125 of file GUI.py.

textfontsize

Definition at line 1127 of file GUI.py.

textOverlay

Definition at line 1124 of file GUI.py.

visible

Definition at line 1188 of file GUI.py.


The documentation for this class was generated from the following file: