[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/forms/src GFForm.py UIbase.py UIcurses.py ...
From: |
James Thompson |
Subject: |
gnue/forms/src GFForm.py UIbase.py UIcurses.py ... |
Date: |
Sat, 16 Feb 2002 19:46:32 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/02/16 19:46:32
Modified files:
forms/src : GFForm.py UIbase.py UIcurses.py UIpyncurses.py
UIwxpython.py
Log message:
Start of changes to UI system (no where near complete)
this will break things
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFForm.py.diff?tr1=1.148&tr2=1.149&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/UIbase.py.diff?tr1=1.53&tr2=1.54&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/UIcurses.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/UIpyncurses.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/UIwxpython.py.diff?tr1=1.138&tr2=1.139&r1=text&r2=text
Patches:
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.148 gnue/forms/src/GFForm.py:1.149
*** gnue/forms/src/GFForm.py:1.148 Fri Feb 15 22:57:55 2002
--- gnue/forms/src/GFForm.py Sat Feb 16 19:46:32 2002
***************
*** 85,90 ****
--- 85,93 ----
self._triggerFunctions = {'setFocus':{'function':self.triggerSetFocus,
'global': 1,
},
+ # 'execute':{'function':self.executeCommand,
+ # 'global': 1,
+ # },
}
***************
*** 342,348 ****
def commit(self):
self._app.dispatchEvent(GFEvent('beginWAIT',None));
-
message = None
try:
--- 345,350 ----
Index: gnue/forms/src/UIbase.py
diff -c gnue/forms/src/UIbase.py:1.53 gnue/forms/src/UIbase.py:1.54
*** gnue/forms/src/UIbase.py:1.53 Fri Feb 15 22:57:55 2002
--- gnue/forms/src/UIbase.py Sat Feb 16 19:46:32 2002
***************
*** 26,32 ****
# not contain any specific UI widgetisms
#
# NOTES:
- # Not yet functional. Still has wxpython code thoughout.
#
from GFForm import *
--- 26,31 ----
***************
*** 42,48 ****
class GFUserInterfaceBase(GFEventAware):
def __init__(self, eventHandler):
GFEventAware.__init__(self, eventHandler)
-
#
# Events I monitor...
#
--- 41,46 ----
***************
*** 53,60 ****
'formALERT' : self.formAlert,
'beginWAIT' : self.beginWait,
'endWAIT' : self.endWait,
- 'uiNEXTRECORD' : self.adjustMultiView,
- 'uiPREVRECORD' : self.adjustMultiView,
'uiUPDATESTATUS' : self.updateStatusBar,
'uiABOUT' : self.aboutBox,
'exitApplication' : self.exitApplication,
--- 51,56 ----
***************
*** 78,98 ****
self.widgets = UI.WIDGETS
! self._loginHandler = None
!
self._formToUI = {} # the GFObj to UI widget cross ref
! self._formToUIWidget = {} # the GFObj to UI widget
cross ref
!
! self.containerWidgets= ['GFPage'] # GFForm objects that contain others
! self._pageList = [] # A list of pages
! self.keyEvents = {} # Keyboard events from the widget
set the
! # UI is expected to respond to
! # A dictionary of functions used by buildUI
! # to build the widgets. Can override in
! # UI specific module if necessary
self.widgetConstructorFunction = {
'GFBox' : self.stdHandler,
'GFButton' : self.stdHandler,
--- 74,96 ----
self.widgets = UI.WIDGETS
! self._loginHandler = None # A handle to the login dialog box
! # implemented by the UIdriver
self._formToUI = {} # the GFObj to UI widget cross ref
! self._formToUIWidget = {} # dictionary of driver specific
UIfoo
! # widgets with the GFObj used as
the key
! self._screenWidgetToGFObject= {}
!
! self.containerWidgets= ['GFPage'] # GFForm objects that contain others
! self._pageList = [] # A list of page widgets created by
the form
! self.keyEvents = {} # Keyboard events from the widget
set the
! # UI is expected to respond to
!
! # A dictionary of functions used by buildUI to build the widgets. Can
override in
! # UI specific module if necessary.
self.widgetConstructorFunction = {
'GFBox' : self.stdHandler,
'GFButton' : self.stdHandler,
***************
*** 102,112 ****
'GFScrollBar' : self.stdHandler,
'GFPage' : self.stdHandler,
}
!
def stdHandler(self):
object = self._currentObject[0]
container = self.currentWidget[0]
! newWidget = self.widgets[object.getObjectType()](object,container,
self.textWidth, self.textHeight, self.widgetWidth, self.widgetHeight, self)
return newWidget
--- 100,111 ----
'GFScrollBar' : self.stdHandler,
'GFPage' : self.stdHandler,
}
!
def stdHandler(self):
object = self._currentObject[0]
container = self.currentWidget[0]
! newWidget = self.widgets[object.getObjectType()](object,container,
self.textWidth, self.textHeight,
! self.widgetWidth,
self.widgetHeight, self)
return newWidget
***************
*** 119,134 ****
self._form = form
# Create the UI from the GFForm passed in
self.buildUI()
!
!
! #
! # getLoginHandler
! #
! # Returns the login handler for this session
! #
! def getLoginHandler(self):
! return self._loginHandler
!
#
# buildUI
#
--- 118,124 ----
self._form = form
# Create the UI from the GFForm passed in
self.buildUI()
!
#
# buildUI
#
***************
*** 140,155 ****
def buildUI(self):
try:
uiWidget =
self.widgetConstructorFunction[self._currentObject[0].getObjectType()] ()
! widget = uiWidget.widgets
GDebug.printMesg(2, "Widget is %s" % widget)
-
self._formToUIWidget[self._currentObject[0]]=uiWidget
# If the widget list is not empty then do the following
if not widget == []:
# Create a cross reference to the GFObject that created
# one or more UI widgets
! self._formToUI[self._currentObject[0]] = [widget,0]
# If the current object is a container then add the
# just created first created widget to it's widget list
if self._currentObject[0].getObjectType() in self.containerWidgets:
--- 130,147 ----
def buildUI(self):
try:
uiWidget =
self.widgetConstructorFunction[self._currentObject[0].getObjectType()] ()
! widget = uiWidget.widgets
GDebug.printMesg(2, "Widget is %s" % widget)
self._formToUIWidget[self._currentObject[0]]=uiWidget
+ #for id in widget:
+ # self._screenWidgetToGFObject[id] = self._currentObject[0]
+
# If the widget list is not empty then do the following
if not widget == []:
# Create a cross reference to the GFObject that created
# one or more UI widgets
! self._formToUI[self._currentObject[0]] = widget
# If the current object is a container then add the
# just created first created widget to it's widget list
if self._currentObject[0].getObjectType() in self.containerWidgets:
***************
*** 168,174 ****
if self._currentObject[0].getObjectType() in self.containerWidgets:
self.currentWidget.pop(0)
-
#############################################################################
#
# Generic Incoming Event Handlers
--- 160,165 ----
***************
*** 218,228 ****
insertValue = None
if insertMode != None:
! if int(insertMode) == 1:
! insertValue = 'INS'
! else:
! insertValue = 'OVR'
!
self._setStatusBar(tip, status, insertValue, currentRecord, maxRecord,
currentPage, maxPage)
#
--- 209,215 ----
insertValue = None
if insertMode != None:
! insertValue = insertMode and 'INS' or 'OVR'
self._setStatusBar(tip, status, insertValue, currentRecord, maxRecord,
currentPage, maxPage)
#
***************
*** 242,248 ****
#
def switchFocus(self, event):
formObject = event.data['object']
- #index = self._formToUI[formObject][1]
if formObject: # Some pages might not have any widgets that can be active
index = formObject._visibleIndex
self._formToUIWidget[formObject].indexedFocus(index)
--- 229,234 ----
***************
*** 254,269 ****
# Displays a modal about box on the screen.
#
def aboutBox(self, event):
- #print self.__class__.__file__
programVersion = event.data[0]
formName = event.data[1]
formVersion = event.data[2]
author = event.data[3]
description = event.data[4]
-
- #statement = "from %s import UIAbout" % self.getModule()
- #exec statement
about = UI.UIAbout(self.mainWindow, programVersion, formName,
formVersion, author, description)
about.showModal()
--- 240,251 ----
***************
*** 280,304 ****
dialog.Destroy()
#
- # adjustMultiView
- #
- # when a form object has more than one record visible on the screen
- # this will adjust the entries to ensure the proper one is visible
- #
- def adjustMultiView(self, event):
- print "Whoops - you should not be calling adjustMultiView"
-
- #
# updateEntry
#
def updateEntry(self,event):
if event.data.hidden:
return
-
index = event.data._visibleIndex
- form = event.data._block._form
block = event.data._block
currentRecord = block._resultSet.getRecordNumber()
if hasattr(event.data, 'style'):
--- 262,276 ----
dialog.Destroy()
#
# updateEntry
#
def updateEntry(self,event):
if event.data.hidden:
return
index = event.data._visibleIndex
block = event.data._block
+ form = block._form
currentRecord = block._resultSet.getRecordNumber()
if hasattr(event.data, 'style'):
***************
*** 319,329 ****
if style == 'dropdown':
value = event.data.allowedValues()[value]
elif style == 'checkbox':
! if value in (1,'1','T','t','TRUE','true'):
! value = 1
! else:
! value = 0
!
self._formToUIWidget[event.data].setValue(value,count)
# fill currently indexed spot
--- 291,297 ----
if style == 'dropdown':
value = event.data.allowedValues()[value]
elif style == 'checkbox':
! value = value in (1,'1','T','t','TRUE','true')
self._formToUIWidget[event.data].setValue(value,count)
# fill currently indexed spot
***************
*** 335,344 ****
if style == 'checkbox':
value = event.data.getValue()
! if value in (1,'1','T','t','TRUE','true'):
! value = 1
! else:
! value = 0
self._formToUIWidget[event.data].setValue(value, index)
else:
self._formToUIWidget[event.data].setValue(value, index)
--- 303,309 ----
if style == 'checkbox':
value = event.data.getValue()
! value = value in (1,'1','T','t','TRUE','true')
self._formToUIWidget[event.data].setValue(value, index)
else:
self._formToUIWidget[event.data].setValue(value, index)
***************
*** 370,381 ****
if style == 'dropdown':
value = event.data.allowedValues()[value]
elif style == 'checkbox':
! if value in (1,'1','T','t','TRUE','true'):
! value = 1
! else:
! value = 0
self._formToUIWidget[event.data].setValue(value, count)
! count = count +1
# Called whenever forms goes into a "wait" state in which user cannot
--- 335,343 ----
if style == 'dropdown':
value = event.data.allowedValues()[value]
elif style == 'checkbox':
! value = value in (1,'1','T','t','TRUE','true') # sets to 1 or 0
self._formToUIWidget[event.data].setValue(value, count)
! count += 1
# Called whenever forms goes into a "wait" state in which user cannot
***************
*** 407,424 ****
object._gap = 0
if hasattr(object,'width'):
! self.itemWidth = int(object.width)*int(textWidth)
! self.itemHeight = int(object.height)*int(textHeight)
else:
self.itemWidth = -1
self.itemHeight = -1
if not object.hidden:
for spacer in range(int(object._rows)):
! newWidget = self.createWidget(object, container, textWidth,
textHeight, widgetWidth, widgetHeight, interface, spacer, initialize)
self.widgets.append(newWidget)
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight, interface, spacer,initialize=1):
GDebug.printMesg(1,"UI doesn't support %s" % self.__class__)
--- 369,388 ----
object._gap = 0
if hasattr(object,'width'):
! self.itemWidth = object.width*int(textWidth)
! self.itemHeight = object.height*int(textHeight)
else:
self.itemWidth = -1
self.itemHeight = -1
if not object.hidden:
for spacer in range(int(object._rows)):
! newWidget = self.createWidget(object, container, textWidth,
textHeight,
! widgetWidth, widgetHeight, interface,
spacer, initialize)
self.widgets.append(newWidget)
! def createWidget(self, object, container, textWidth, textHeight,
! widgetWidth, widgetHeight, interface, spacer,initialize=1):
GDebug.printMesg(1,"UI doesn't support %s" % self.__class__)
Index: gnue/forms/src/UIcurses.py
diff -c gnue/forms/src/UIcurses.py:1.15 gnue/forms/src/UIcurses.py:1.16
*** gnue/forms/src/UIcurses.py:1.15 Fri Feb 15 22:57:55 2002
--- gnue/forms/src/UIcurses.py Sat Feb 16 19:46:32 2002
***************
*** 1,4 ****
--- 1,9 ----
#
+ # This file is extremely out of date and non-functional
+ # left for reference only.
+ #
+
+ #
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
Index: gnue/forms/src/UIpyncurses.py
diff -c gnue/forms/src/UIpyncurses.py:1.20 gnue/forms/src/UIpyncurses.py:1.21
*** gnue/forms/src/UIpyncurses.py:1.20 Tue Jul 31 19:22:30 2001
--- gnue/forms/src/UIpyncurses.py Sat Feb 16 19:46:32 2002
***************
*** 1,4 ****
--- 1,10 ----
#
+ # This file is extremely out of date and non-functional
+ # left for reference only.
+ #
+
+
+ #
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
Index: gnue/forms/src/UIwxpython.py
diff -c gnue/forms/src/UIwxpython.py:1.138 gnue/forms/src/UIwxpython.py:1.139
*** gnue/forms/src/UIwxpython.py:1.138 Fri Feb 15 22:57:55 2002
--- gnue/forms/src/UIwxpython.py Sat Feb 16 19:46:32 2002
***************
*** 22,28 ****
# UIwxpython.py
#
# DESCRIPTION:
! # A wxPython based user interface for GNUE forms.
#
# NOTES:
#
--- 22,28 ----
# UIwxpython.py
#
# DESCRIPTION:
! # A wxPython based user interface driver for GNUE forms.
#
# NOTES:
#
***************
*** 45,131 ****
_NOTEBOOK = None
_LOOPTRAP = 0
##
## Only create one instance of wxApp
## Use getWxApp() to get or create the
## single instance
class GFwxApp(wxApp):
def OnInit(self):
GDebug.printMesg(7,"WxApp initializing")
wxInitAllImageHandlers()
- GDebug.printMesg(7,"WxApp initializing2")
return true
- __wxApp = None
-
def getWxApp():
global __wxApp
if __wxApp == None:
__wxApp = GFwxApp(0)
- # __wxApp.MainLoop()
GDebug.printMesg(7,"WxApp initializing3")
-
return __wxApp
-
-
#
# Little global helper routine to set font according to options
#
def initFont(widget, affectsLayout=1):
-
- ## if not (affectsLayout or (not affectsLayout and \
- ## int(GConfig.get('fixedWidthEntries','1')))):
- ## return
- ##
- ## face = GConfig.get('fontface',None)
- ##
- ## if face != None:
- ## if string.lower(GConfig.get('fontweight','normal')) == 'bold':
- ## weight = wxBOLD
- ## else:
- ## weight = wxNORMAL
- ##
- ## widget.SetFont(wxFont(int(GConfig.get('PointSize')),wxMODERN,
- ## wxNORMAL,weight, faceName=face))
- ## elif...
if int(GConfig.get('fixedWidthFont')):
widget.SetFont(wxFont(int(GConfig.get('pointSize')),wxMODERN,wxNORMAL,wxNORMAL))
-
-
- # Helps out with layout
- def getLargest(val1, val2):
- if val1 > val2:
- return val1
- else:
- return val2
-
-
- # Used by the login handler
- # enables the user to press return and have it jump to the next box
- class LoginFieldHandler:
- def __init__(self, app, seq):
- self.app = app
- self.seq = seq
-
- def loginFieldEventTrap(self, event):
- if event.KeyCode() in (WXK_RETURN, WXK_TAB):
- if self.seq < len(self.app.textctrlList) - 1:
- self.app.textctrlList[self.seq+1].SetFocus()
- else:
- if event.KeyCode() == WXK_TAB:
- if event.ShiftDown():
- self.app.textctrlList[self.seq-1].SetFocus()
- else:
- self.app.loginButton.SetFocus()
- else:
- self.app.loginCompleted(1)
- else:
- event.Skip()
-
#
# GFUserInterface
#
--- 45,84 ----
_NOTEBOOK = None
_LOOPTRAP = 0
+ _EVENTPROCESSOR = None
+ _charWidth = 0
+ _IdToWxObj = {}
+ _IdToGFObj = {}
+ _IdToUIObj = {}
##
## Only create one instance of wxApp
## Use getWxApp() to get or create the
## single instance
+ ##
+
+ __wxApp = None
class GFwxApp(wxApp):
def OnInit(self):
GDebug.printMesg(7,"WxApp initializing")
wxInitAllImageHandlers()
return true
def getWxApp():
global __wxApp
if __wxApp == None:
__wxApp = GFwxApp(0)
GDebug.printMesg(7,"WxApp initializing3")
return __wxApp
#
# Little global helper routine to set font according to options
#
def initFont(widget, affectsLayout=1):
if int(GConfig.get('fixedWidthFont')):
widget.SetFont(wxFont(int(GConfig.get('pointSize')),wxMODERN,wxNORMAL,wxNORMAL))
#
# GFUserInterface
#
***************
*** 134,143 ****
#
class GFUserInterface(GFUserInterfaceBase):
def __init__(self, eventController, disableSplash = None):
self._wxapp = getWxApp()
self._disableSplash = disableSplash
GFUserInterfaceBase.__init__(self,eventController)
!
self.forms = {}
self.init()
--- 87,97 ----
#
class GFUserInterface(GFUserInterfaceBase):
def __init__(self, eventController, disableSplash = None):
+ global _EVENTPROCESSOR
self._wxapp = getWxApp()
self._disableSplash = disableSplash
GFUserInterfaceBase.__init__(self,eventController)
! _EVENTPROCESSOR = self.dispatchEvent
self.forms = {}
self.init()
***************
*** 163,175 ****
# It is used the build the basic UI
#
def init(self):
-
#
# SplashScreen
#
if not self._disableSplash:
self.splash =
SplashScreen(None,bitmapfile=os.environ['INSTALL_PREFIX']+'/'+GConfig.get('splashScreenPNG'),
- # duration=65535, callback=self.onMain,
duration = 4000, callback=self.onCloseSplash,
style=wxSIMPLE_BORDER|wxCENTRE_ON_SCREEN )
swidth,sheight = self.splash.GetSizeTuple()
--- 117,127 ----
***************
*** 209,228 ****
initFont(self.mainWindow,1)
maxWidth, maxHeight, maxDescent, maxLeading = [0,0,0,0]
!
! # need to add string.punctionation if we dump python 1.5.2
! checkchars = string.letters+string.digits+"-\|"
for letter in checkchars:
width,height,descent,leading = self.mainWindow.GetFullTextExtent(letter)
! maxWidth = maxWidth > width and maxWidth or width
! maxHeight = maxHeight > height and maxHeight or height
! maxDescent = maxDescent > descent and maxDescent or descent
! maxLeading = maxLeading > leading and maxLeading or leading
self.charWidth = maxWidth+maxLeading
self.charHeight = maxHeight+maxDescent
self.borderPercentage = (int(GConfig.get('borderPercentage')) / 100.0)
self.textPercentage = (int(GConfig.get('textPercentage')) / 100.0)
--- 161,185 ----
initFont(self.mainWindow,1)
+ #
+ # Find the max size of printable characters
+ # used to setup the grid
+ #
maxWidth, maxHeight, maxDescent, maxLeading = [0,0,0,0]
! checkchars = string.printable
for letter in checkchars:
width,height,descent,leading = self.mainWindow.GetFullTextExtent(letter)
! maxWidth = max(maxWidth,width)
! maxHeight = max(maxHeight,height)
! maxDescent = max(maxDescent,descent)
! maxLeading = max(maxLeading,leading)
self.charWidth = maxWidth+maxLeading
self.charHeight = maxHeight+maxDescent
+ global _charWidth
+ _charWidth = int(self.charWidth)
+ print "_charWidth",_charWidth
self.borderPercentage = (int(GConfig.get('borderPercentage')) / 100.0)
self.textPercentage = (int(GConfig.get('textPercentage')) / 100.0)
***************
*** 238,245 ****
self.statusBar.SetStatusWidths([-1,50,50,75,75])
initFont(self.statusBar,0)
- self.mainWindow.SetStatusText( "Let's get started" )
-
fileMenu = wxMenu()
fileMenu.Append( 100, "Commit (F6)",GConfig.get('msg_commit'))
EVT_MENU(self._wxapp, 100, lambda event, l=self:
l.dispatchEvent(GFEvent('requestCOMMIT')))
--- 195,200 ----
***************
*** 310,316 ****
mainToolBar.Realize()
self.mainWindow.panel = wxPanel(self.mainWindow,-1,
wxDefaultPosition,self.mainWindow.GetSize())
- EVT_CHAR(self.mainWindow.panel, self.uiEventTrap)
self.currentWidget = [self.mainWindow.panel]
self._wxapp.SetTopWindow(self.mainWindow)
--- 265,270 ----
***************
*** 333,352 ****
width = int(self._form.width)
height = int(self._form.height)
! self.mainWindow.SetSize(wxSize(width*int(self.widgetWidth),
!
int(height+self.menu_sb_space)*int(self.widgetHeight)))
self.mainWindow.SetTitle(str(self._form.title))
self.mainWindow.panel = self._pageList[0]
! self.mainWindow.panel.SetSize(wxSize(width*int(self.widgetWidth),
!
int(height+self.menu_sb_space)*int(self.widgetHeight)))
self._pageList[0].Show(TRUE)
# Only one page at a time can be visible
self.visiblePage = self._pageList[0]
if _NOTEBOOK: # Adjust sizes
! _NOTEBOOK.SetSize(wxSize(width*int(self.widgetWidth),
!
int(height+self.menu_sb_space)*int(self.widgetHeight)))
child = _NOTEBOOK.GetParent()
while child:
--- 287,306 ----
width = int(self._form.width)
height = int(self._form.height)
! formSize = wxSize(width*int(self.widgetWidth),
! int(height+self.menu_sb_space)*int(self.widgetHeight))
!
! self.mainWindow.SetSize(formSize)
self.mainWindow.SetTitle(str(self._form.title))
self.mainWindow.panel = self._pageList[0]
! self.mainWindow.panel.SetSize(formSize)
self._pageList[0].Show(TRUE)
# Only one page at a time can be visible
self.visiblePage = self._pageList[0]
if _NOTEBOOK: # Adjust sizes
! _NOTEBOOK.SetSize(formSize)
child = _NOTEBOOK.GetParent()
while child:
***************
*** 376,393 ****
# _setStatusBar
#
def _setStatusBar(self,tip, statusValue, insertValue, currentRecord,
maxRecord, currentPage, maxPage):
! if tip != None: self.statusBar.SetStatusText(str(tip),0)
! if statusValue != None:
self.statusBar.SetStatusText(statusValue,1)
! if insertValue != None:
self.statusBar.SetStatusText(insertValue,2)
! if currentRecord != None and maxRecord != None:
self.statusBar.SetStatusText(string.strip("%s/%s" %
(currentRecord,maxRecord)),3)
! if currentPage != None and maxPage != None:
self.statusBar.SetStatusText(string.strip("%s/%s" %
(currentPage,maxPage)),4)
#
--- 330,347 ----
# _setStatusBar
#
def _setStatusBar(self,tip, statusValue, insertValue, currentRecord,
maxRecord, currentPage, maxPage):
! if tip: self.statusBar.SetStatusText(str(tip),0)
! if statusValue:
self.statusBar.SetStatusText(statusValue,1)
! if insertValue:
self.statusBar.SetStatusText(insertValue,2)
! if currentRecord and maxRecord:
self.statusBar.SetStatusText(string.strip("%s/%s" %
(currentRecord,maxRecord)),3)
! if currentPage and maxPage:
self.statusBar.SetStatusText(string.strip("%s/%s" %
(currentPage,maxPage)),4)
#
***************
*** 401,410 ****
recordWidth,unused =
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(3))
pageWidth,unused =
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(4))
! statusWidth = statusWidth * 2
! insertWidth = insertWidth * 2
! recordWidth = recordWidth * 2
! pageWidth = pageWidth * 2
if statusWidth == 0: statusWidth = 5
if insertWidth == 0: insertWidth = 5
--- 355,364 ----
recordWidth,unused =
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(3))
pageWidth,unused =
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(4))
! statusWidth *= 2
! insertWidth *= 2
! recordWidth *= 2
! pageWidth *= 2
if statusWidth == 0: statusWidth = 5
if insertWidth == 0: insertWidth = 5
***************
*** 426,441 ****
# makes the requested page visible on the screen
#
def gotoPage(self, event):
! index = self._formToUI[event.data][1]
!
if not _NOTEBOOK:
self.visiblePage.Show(FALSE)
! self.visiblePage = self._formToUI[event.data][0][index]
self.visiblePage.SetSize(wxSize(int(self._form.width)*int(self.widgetWidth),
int(int(self._form.height)+self.menu_sb_space)*int(self.widgetHeight)))
- # self.Fit() # Trial run
else:
! self.visiblePage = self._formToUI[event.data][0][index]
for count in range(_NOTEBOOK.GetPageCount()):
if self.visiblePage.GetId() == _NOTEBOOK.GetPage(count).GetId():
_NOTEBOOK.SetSelection(count)
--- 380,394 ----
# makes the requested page visible on the screen
#
def gotoPage(self, event):
! index = 0 # self._formToUI[event.data][1]
! print "INDEX", index
if not _NOTEBOOK:
self.visiblePage.Show(FALSE)
! self.visiblePage = self._formToUI[event.data][0]
self.visiblePage.SetSize(wxSize(int(self._form.width)*int(self.widgetWidth),
int(int(self._form.height)+self.menu_sb_space)*int(self.widgetHeight)))
else:
! self.visiblePage = self._formToUI[event.data][0]
for count in range(_NOTEBOOK.GetPageCount()):
if self.visiblePage.GetId() == _NOTEBOOK.GetPage(count).GetId():
_NOTEBOOK.SetSelection(count)
***************
*** 505,599 ****
# traps most data entry related wxPython events and converts them to
GFForms UI requests
# really need to be recoded to something more friendly - maybe multiple
event handlers
#
def uiEventTrap(self, event):
-
action = None
-
- #
- # KeyBoard Events
- #
- if event.GetEventType() == wxEVT_CHAR or
event.GetEventType()==wxEVT_KEY_DOWN:
-
- command = GFKeyMapper.KeyMapper.getEvent(
- event.KeyCode(),
- event.ShiftDown(),
- event.ControlDown(),
- event.AltDown())
-
-
- if command == 'JUMPRECORD':
- self.promptForRecordNumber()
-
- elif command:
- action = GFEvent('request%s' % command)
-
- else:
- try:
- action = GFEvent('requestKEYPRESS', chr(event.KeyCode()),
- code=event.KeyCode())
- except ValueError:
- event.Skip()
- #
- # Mouse Events
- #
- elif event.GetEventType() == wxEVT_LEFT_DOWN:
- # hack for swig shortcomming
- eo = event.GetEventObject()
- object = wxPyTypeCast(eo, 'wxWindow')
-
- # Move to proper object
- for key in self._formToUI.keys():
- for count in range(len(self._formToUI[key][0])):
- if self._formToUI[key][0][count].GetId() == object.GetId():
- self.dispatchEvent(GFEvent('requestFOCUS',key))
- self.dispatchEvent(GFEvent('requestJUMPRECORD',count -
key._visibleIndex))
- break
-
#
# ra3vat CheckBox Events
! #
! elif event.GetEventType() == wxEVT_COMMAND_CHECKBOX_CLICKED:
# hack for swig shortcomming
eo = event.GetEventObject()
- # CheckBox does not work if uncomment this instead of next line (ra3vat)
- ## object = wxPyTypeCast(eo, 'wxWindow')
object = wxPyTypeCast(eo, 'wxCheckBox')
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key][0])):
! if self._formToUI[key][0][count].GetId() == object.GetId():
self.dispatchEvent(GFEvent('requestFOCUS',key))
eventdata = [key, object.GetValue()]
self.dispatchEvent(GFEvent('requestJUMPRECORD',count -
key._visibleIndex))
self.dispatchEvent(GFEvent('requestTOGGLECHKBOX',eventdata))
break
-
#
# Combo box events
#
elif event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED:
#
# Begin duplicate of the mouse handling code to see
# if it will allow me proper focus control w/
# comboxes
#
- # hack for swig shortcomming
- eo = event.GetEventObject()
- object = wxPyTypeCast(eo, 'wxWindow')
-
# Move to proper object
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key][0])):
! if self._formToUI[key][0][count].GetId() == object.GetId():
self.dispatchEvent(GFEvent('requestFOCUS',key))
! self.dispatchEvent(GFEvent('requestJUMPRECORD',count -
key._visibleIndex))
break
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key][0])):
! if self._formToUI[key][0][count].GetId() == object.GetId():
self.dispatchEvent(GFEvent('requestJUMPRECORD',count -
key._visibleIndex))
break
--- 458,510 ----
# traps most data entry related wxPython events and converts them to
GFForms UI requests
# really need to be recoded to something more friendly - maybe multiple
event handlers
#
+ # TODO: Being phased out
+ #
def uiEventTrap(self, event):
action = None
#
# ra3vat CheckBox Events
! #
! if event.GetEventType() == wxEVT_COMMAND_CHECKBOX_CLICKED:
# hack for swig shortcomming
eo = event.GetEventObject()
object = wxPyTypeCast(eo, 'wxCheckBox')
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key])):
! if self._formToUI[key][count].GetId() == object.GetId():
self.dispatchEvent(GFEvent('requestFOCUS',key))
eventdata = [key, object.GetValue()]
self.dispatchEvent(GFEvent('requestJUMPRECORD',count -
key._visibleIndex))
self.dispatchEvent(GFEvent('requestTOGGLECHKBOX',eventdata))
break
#
# Combo box events
#
elif event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED:
+ print "I taught I taw a puddy tat"
+ # hack for swig shortcomming
+ eo = event.GetEventObject()
+ object = wxPyTypeCast(eo, 'wxWindow')
+
#
# Begin duplicate of the mouse handling code to see
# if it will allow me proper focus control w/
# comboxes
#
# Move to proper object
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key])):
! if self._formToUI[key][count].GetId() == object.GetId():
self.dispatchEvent(GFEvent('requestFOCUS',key))
! #self.dispatchEvent(GFEvent('requestJUMPRECORD',count -
key._visibleIndex))
break
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key])):
! if self._formToUI[key][count].GetId() == object.GetId():
self.dispatchEvent(GFEvent('requestJUMPRECORD',count -
key._visibleIndex))
break
***************
*** 608,614 ****
selection = event.GetSelection()
for key in self._formToUI.keys():
! for uiItem in self._formToUI[key][0]:
if uiItem.GetId() == object.GetId():
eventdata = [key, event.GetString()]
action = GFEvent('requestREPLACEVALUE',eventdata)
--- 519,525 ----
selection = event.GetSelection()
for key in self._formToUI.keys():
! for uiItem in self._formToUI[key]:
if uiItem.GetId() == object.GetId():
eventdata = [key, event.GetString()]
action = GFEvent('requestREPLACEVALUE',eventdata)
***************
*** 617,628 ****
# Button Events
#
elif event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED:
eo = event.GetEventObject()
object = wxPyTypeCast(eo, 'wxWindow')
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key][0])):
! if self._formToUI[key][0][count].GetId() == object.GetId():
action = GFEvent('fireTRIGGER',key.trigger)
#
# Notebook tab events
--- 528,540 ----
# Button Events
#
elif event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED:
+ print "I did! I did taw a puddy tat"
eo = event.GetEventObject()
object = wxPyTypeCast(eo, 'wxWindow')
for key in self._formToUI.keys():
! for count in range(len(self._formToUI[key])):
! if self._formToUI[key][count].GetId() == object.GetId():
action = GFEvent('fireTRIGGER',key.trigger)
#
# Notebook tab events
***************
*** 633,654 ****
_LOOPTRAP = 1
action = GFEvent('requestPAGE',event.GetSelection())
else:
! _LOOPTRAP = 0
!
! #
! # Unhandled events
! #
! elif event.GetEventType() == wxEVT_KEY_DOWN:
! print "down"
!
else:
# Need to probably log this somewhere in debug mode
pass
! if action != None:
self.dispatchEvent(action)
-
# Called whenever forms goes into a "wait" state in which user cannot
# interact with interface (e.g., while waiting for a query or a commit)
def beginWait (self, event):
--- 545,558 ----
_LOOPTRAP = 1
action = GFEvent('requestPAGE',event.GetSelection())
else:
! _LOOPTRAP = 0
else:
# Need to probably log this somewhere in debug mode
pass
! if action:
self.dispatchEvent(action)
# Called whenever forms goes into a "wait" state in which user cannot
# interact with interface (e.g., while waiting for a query or a commit)
def beginWait (self, event):
***************
*** 697,716 ****
self.widgets[index].SetValue(value)
self.widgets[index].SetEvtHandlerEnabled(TRUE)
-
def setCursorPosition(self, position, index=0):
try:
self.widgets[index].SetInsertionPoint(position)
except AttributeError:
pass # For label-style entries
!
#
# UILabel
#
# Widget set specific function that creates a single instance of a label
#
class UILabel(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight,interface,spacer,initialize=1):
style = wxALIGN_LEFT|wxST_NO_AUTORESIZE
if hasattr(object,'alignment'):
--- 601,626 ----
self.widgets[index].SetValue(value)
self.widgets[index].SetEvtHandlerEnabled(TRUE)
def setCursorPosition(self, position, index=0):
try:
self.widgets[index].SetInsertionPoint(position)
except AttributeError:
pass # For label-style entries
!
! def _addToCrossRef(self, widget,gfobject, uiobject):
! id = widget.GetId()
! _IdToWxObj[id]=widget
! _IdToGFObj[id]=gfobject
! _IdToUIObj[id]=uiobject
!
#
# UILabel
#
# Widget set specific function that creates a single instance of a label
#
class UILabel(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth,
! widgetHeight,interface,spacer,initialize=1):
style = wxALIGN_LEFT|wxST_NO_AUTORESIZE
if hasattr(object,'alignment'):
***************
*** 720,729 ****
style = wxALIGN_RIGHT|wxST_NO_AUTORESIZE
newWidget = wxStaticText(container, -1, str(object.text),
! wxPoint(int(object.x)*int(widgetWidth),
!
(int(object.y)+spacer+(spacer*object._gap))*int(widgetHeight)),
wxSize(self.itemWidth,self.itemHeight), style)
initFont(newWidget)
return newWidget
#
--- 630,640 ----
style = wxALIGN_RIGHT|wxST_NO_AUTORESIZE
newWidget = wxStaticText(container, -1, str(object.text),
! wxPoint(object.x*int(widgetWidth),
!
(object.y+spacer+(spacer*object._gap))*int(widgetHeight)),
wxSize(self.itemWidth,self.itemHeight), style)
initFont(newWidget)
+ self._addToCrossRef(newWidget,object,self)
return newWidget
#
***************
*** 732,744 ****
# Widget set specific function that creates a single instance of a border box
#
class UIBox(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight,interface,spacer,initialize=1):
newWidget = wxStaticBox(container,-1,str(object.label),
!
wxPoint(int(object.x)*int(widgetWidth)+(int(widgetWidth)/2),
!
(int(object.y)+spacer+(spacer*object._gap))*int(widgetHeight)+(int(widgetHeight)/2)),
! wxSize((int(object.width)-1)*int(widgetWidth),
! (int(object.height)-1)*int(widgetHeight)))
initFont(newWidget)
return newWidget
#
--- 643,657 ----
# Widget set specific function that creates a single instance of a border box
#
class UIBox(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
! widgetWidth, widgetHeight,interface,spacer,initialize=1):
newWidget = wxStaticBox(container,-1,str(object.label),
!
wxPoint(object.x*int(widgetWidth)+(int(widgetWidth)/2),
!
(object.y+spacer+(spacer*object._gap))*int(widgetHeight)+(int(widgetHeight)/2)),
! wxSize((object.width-1)*int(widgetWidth),
! (object.height-1)*int(widgetHeight)))
initFont(newWidget)
+ self._addToCrossRef(newWidget,object,self)
return newWidget
#
***************
*** 748,775 ****
# to navigate multiple records
#
class UIScrollBar(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight,interface,spacer,initialize=1):
newWidget =wxScrollBar(container,-1,
!
wxPoint(int(object.x)*int(widgetWidth),(int(object.y)+spacer)*int(widgetHeight)),
!
wxSize(int(object.width)*int(widgetWidth),int(object.height)*int(widgetHeight)),
wxSB_VERTICAL)
initFont(newWidget,0)
return newWidget
#
# UIButton
#
# Widget set specific function that creates a single instance of a button
#
class UIButton(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight,interface,spacer,initialize=1):
newWidget = wxButton(container,-1,str(object.label),
!
wxPoint(int(object.x)*int(widgetWidth),(int(object.y)+spacer)*int(widgetHeight)),
!
wxSize(int(object.width)*int(widgetWidth),int(object.height)*int(widgetHeight))
)
initFont(newWidget,0)
if initialize:
! EVT_BUTTON(newWidget,newWidget.GetId(),interface.uiEventTrap)
return newWidget
#
--- 661,694 ----
# to navigate multiple records
#
class UIScrollBar(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
! widgetWidth, widgetHeight,interface,spacer,initialize=1):
newWidget =wxScrollBar(container,-1,
!
wxPoint(object.x*int(widgetWidth),(object.y+spacer)*int(widgetHeight)),
!
wxSize(object.width*int(widgetWidth),object.height*int(widgetHeight)),
wxSB_VERTICAL)
initFont(newWidget,0)
+ self._addToCrossRef(newWidget,object,self)
return newWidget
+
#
# UIButton
#
# Widget set specific function that creates a single instance of a button
#
class UIButton(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
! widgetWidth, widgetHeight,interface,spacer,initialize=1):
newWidget = wxButton(container,-1,str(object.label),
!
wxPoint(object.x*int(widgetWidth),(object.y+spacer)*int(widgetHeight)),
!
wxSize(object.width*int(widgetWidth),object.height*int(widgetHeight))
)
initFont(newWidget,0)
if initialize:
! _setDefaultEventHandlers(newWidget,initialize,
interface._screenWidgetToGFObject)
! # EVT_BUTTON(newWidget,newWidget.GetId(),interface.uiEventTrap)
! self._addToCrossRef(newWidget,object,self)
return newWidget
#
***************
*** 778,784 ****
# Widget set specific function that creates a single instance of a page
#
class UIPage(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight,interface,spacer,initialize=1):
if _NOTEBOOK:
newWidget = wxPanel(_NOTEBOOK, -1,wxDefaultPosition,_NOTEBOOK.GetSize())
_NOTEBOOK.AddPage(newWidget,object.name)
--- 697,704 ----
# Widget set specific function that creates a single instance of a page
#
class UIPage(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
! widgetWidth, widgetHeight,interface,spacer,initialize=1):
if _NOTEBOOK:
newWidget = wxPanel(_NOTEBOOK, -1,wxDefaultPosition,_NOTEBOOK.GetSize())
_NOTEBOOK.AddPage(newWidget,object.name)
***************
*** 787,796 ****
newWidget = wxPanel(container, -1,wxDefaultPosition,container.GetSize())
newWidget.Show(FALSE)
! if initialize:
! EVT_CHAR(newWidget, interface.uiEventTrap)
initFont(newWidget,0)
interface._pageList.append(newWidget)
return newWidget
#
--- 707,718 ----
newWidget = wxPanel(container, -1,wxDefaultPosition,container.GetSize())
newWidget.Show(FALSE)
! _setDefaultEventHandlers(newWidget,initialize,
interface._screenWidgetToGFObject)
!
initFont(newWidget,0)
interface._pageList.append(newWidget)
+ self._addToCrossRef(newWidget,object,self)
+
return newWidget
#
***************
*** 799,863 ****
# Widget set specific function that creates a single instance of a data entry
widget
#
class UIEntry(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight,interface,spacer,initialize=1):
! if hasattr(object,'style'):
! style = object.style
! else:
! style = 'text'
if style == 'dropdown':
- choices = []
if initialize:
! values = object.allowedValues()
! for key in values.keys():
! choices.append(values[key])
! choices.sort()
newWidget = wxComboBox(container, -1, "",
! wxPoint(int(object.x)*int(widgetWidth),
!
(int(object.y)+spacer+(object._gap*spacer))*int(widgetHeight)),
! wxSize(int(object.width)*int(textWidth),
! int(object.height)*int(textHeight)),
choices, wxCB_DROPDOWN|wxWANTS_CHARS,
)
- newWidget.SetValue("")
-
- #handler = comboEvtHandler()
- #newWidget.SetEventHandler(handler)
- #handler.SetEvtHandlerEnabled(TRUE)
-
- if initialize:
- EVT_CHAR(newWidget, interface.uiEventTrap)
- EVT_COMBOBOX(newWidget, newWidget.GetId(), interface.uiEventTrap)
elif style == 'label':
newWidget = wxStaticText(container, -1, "",
! wxPoint(int(object.x)*int(widgetWidth),
!
(int(object.y)+spacer+(object._gap*spacer))*int(widgetHeight)),
! wxSize(int(object.width)*int(textWidth),
! int(object.height)*int(textHeight)+1),
wxST_NO_AUTORESIZE)
-
# To make the label consistent with the other entry styles...
newWidget.SetValue = newWidget.SetLabel
newWidget.GetValue = newWidget.GetLabel
!
elif style == 'checkbox':
- style = object.style
-
newWidget = wxCheckBox(container, -1, "",
! wxPoint(int(object.x)*int(widgetWidth),
!
(int(object.y)+spacer+(object._gap*spacer))*int(widgetHeight)),
wxSize(int(2)*int(textWidth),
int(1)*int(textHeight)), wxNO_BORDER)
newWidget.SetValue(0)
! if initialize:
! EVT_CHECKBOX(newWidget, newWidget.GetId(), interface.uiEventTrap)
!
! else:
if initialize:
styles = wxTE_PROCESS_TAB
! if int(object.height) > 1:
styles = styles|wxTE_MULTILINE
value = object.getValue()
else:
--- 721,766 ----
# Widget set specific function that creates a single instance of a data entry
widget
#
class UIEntry(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
! widgetWidth, widgetHeight,interface,spacer,initialize=1):
+ style = object.style
if style == 'dropdown':
if initialize:
! choices = object.allowedValues().values()
! else:
! choices = [""]
newWidget = wxComboBox(container, -1, "",
! wxPoint(object.x*int(widgetWidth),
!
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
! wxSize(object.width*int(textWidth),
! object.height*int(textHeight)),
choices, wxCB_DROPDOWN|wxWANTS_CHARS,
)
elif style == 'label':
newWidget = wxStaticText(container, -1, "",
! wxPoint(object.x*int(widgetWidth),
!
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
! wxSize(object.width*int(textWidth),
! object.height*int(textHeight)+1),
wxST_NO_AUTORESIZE)
# To make the label consistent with the other entry styles...
newWidget.SetValue = newWidget.SetLabel
newWidget.GetValue = newWidget.GetLabel
!
elif style == 'checkbox':
newWidget = wxCheckBox(container, -1, "",
! wxPoint(object.x*int(widgetWidth),
!
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
wxSize(int(2)*int(textWidth),
int(1)*int(textHeight)), wxNO_BORDER)
newWidget.SetValue(0)
! else: # Normal text box
if initialize:
styles = wxTE_PROCESS_TAB
! if object.height > 1:
styles = styles|wxTE_MULTILINE
value = object.getValue()
else:
***************
*** 865,901 ****
value = ""
newWidget = wxTextCtrl(container, -1, value,
! wxPoint(int(object.x)*int(widgetWidth),
!
(int(object.y)+spacer+(object._gap*spacer))*int(widgetHeight)),
! wxSize(int(object.width)*int(textWidth),
! int(object.height)*int(textHeight)+1),
styles)
! if initialize:
! EVT_CHAR(newWidget, interface.uiEventTrap)
! EVT_MOUSE_EVENTS(newWidget, interface.uiEventTrap)
initFont(newWidget, 0)
return newWidget
! class comboEvtHandler(wxEvtHandler):
! def __init__(self, *args):
! eventList = [wxEVT_CHAR, wxEVT_KEY_DOWN, wxEVT_KEY_UP, wxEVT_LEFT_DOWN
! ]
! wxEvtHandler.__init__(self, *args)
for eventType in eventList:
! self.Connect(-1, -1, eventType, self._processEvent)
!
def _processEvent(self,event):
! print "foo"
! event.Skip()
#
# UIForm
#
# Widget set specific function that creates a single instance of a Form widget
#
class UIForm(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
widgetWidth, widgetHeight,interface,spacer,initialize=1):
global _NOTEBOOK
if object.tabbed:
--- 768,874 ----
value = ""
newWidget = wxTextCtrl(container, -1, value,
! wxPoint(object.x*int(widgetWidth),
!
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
! wxSize(object.width*int(textWidth),
! object.height*int(textHeight)+1),
styles)
!
! _setDefaultEventHandlers(newWidget,initialize,
interface._screenWidgetToGFObject)
initFont(newWidget, 0)
+ self._addToCrossRef(newWidget,object,self)
+
return newWidget
!
! def _setDefaultEventHandlers(newWidget, initialize, screenToGFObject):
! global _EVENTPROCESSOR
! if initialize:
!
#newWidget.SetEventHandler(mouseEvtHandler(_EVENTPROCESSOR,screenToGFObject))
!
newWidget.PushEventHandler(mouseEvtHandler(_EVENTPROCESSOR,screenToGFObject))
!
newWidget.PushEventHandler(keyboardEvtHandler(_EVENTPROCESSOR,screenToGFObject))
!
! class uiBaseEvtHandler(wxEvtHandler,GFEventAware):
! def __init__(self,eventList,eventProcessor,screenToGFObject):
! wxEvtHandler.__init__(self)
! self._eventProcessor = eventProcessor
! self._screenToGFObject = screenToGFObject
for eventType in eventList:
! self.Connect(-1, -1, eventType,self._processEvent)
!
def _processEvent(self,event):
! GDebug.printMesg(0,"uiBaseEvtHandler _processEvent was called?!?")
!
! class mouseEvtHandler(uiBaseEvtHandler):
! def __init__(self,eventProcessor,screenToGFObject):
! eventList = [wxEVT_LEFT_DOWN] #[wxEVT_LEFT_DOWN, wxEVT_LEFT_UP]
! uiBaseEvtHandler.__init__(self, eventList,
eventProcessor,screenToGFObject)
!
! def _processEvent(self,event):
! # hack for swig shortcomming
! eo = event.GetEventObject()
! object = wxPyTypeCast(eo, 'wxWindow')
!
! # compute the location of the character in the widget
! x = event.GetX()
! y = event.GetY()
! global _charWidth
! if _charWidth:
! charover = 1 + x/_charWidth
! print "I'm at the %d char" % charover
!
! # Move to proper object
! id = object.GetId()
! gfObject = _IdToGFObj[id]
! screenWidget = _IdToWxObj[id]
! count = _IdToUIObj[id].widgets.index(screenWidget)
! print "I should jump to record ", count - gfObject._visibleIndex
! self._eventProcessor(GFEvent('requestFOCUS',gfObject))
! self._eventProcessor(GFEvent('requestRECORDNUMBER',count -
gfObject._visibleIndex))
!
! class keyboardEvtHandler(uiBaseEvtHandler):
! def __init__(self, eventProcessor,screenToGFObject):
! eventList = [wxEVT_CHAR,wxEVT_KEY_DOWN]
! uiBaseEvtHandler.__init__(self, eventList,
eventProcessor,screenToGFObject)
+ def _processEvent(self,event):
+ action = None
+ # hack for swig shortcomming needed by wxPython 2.2.x (2.3 does not need
this)
+ eo = event.GetEventObject()
+
+ # compute the location of the character in the widget
+ if event.GetEventType() == wxEVT_CHAR or
event.GetEventType()==wxEVT_KEY_DOWN:
+ command = GFKeyMapper.KeyMapper.getEvent(
+ event.KeyCode(),
+ event.ShiftDown(),
+ event.ControlDown(),
+ event.AltDown())
+ object = wxPyTypeCast(eo, 'wxWindow')
+ # TODO : Broken for the moment
+ #if command == 'JUMPRECORD':
+ # self.promptForRecordNumber()
+
+ if command:
+ action = GFEvent('request%s' % command)
+
+ else:
+ try:
+ action = GFEvent('requestKEYPRESS', chr(event.KeyCode()),
+ code=event.KeyCode())
+ except ValueError:
+ event.Skip()
+ if action:
+ self._eventProcessor(action)
+
#
# UIForm
#
# Widget set specific function that creates a single instance of a Form widget
#
class UIForm(UIWidget, UIHelper):
! def createWidget(self, object, container, textWidth, textHeight,
! widgetWidth, widgetHeight,interface,spacer,initialize=1):
global _NOTEBOOK
if object.tabbed:
***************
*** 918,924 ****
if initialize:
EVT_CLOSE(interface.mainWindow,interface.closeTrap)
!
return newWidget
#
--- 891,899 ----
if initialize:
EVT_CLOSE(interface.mainWindow,interface.closeTrap)
!
! self._addToCrossRef(newWidget,object,self)
!
return newWidget
#
***************
*** 975,980 ****
--- 950,989 ----
return text
+ #
+ # Translate from wx keystrokes
+ # to our virtual keystrokes
+ #
+ from GFKeyMapper import vk
+
+ wxKeyTranslations = {
+ vk.F1 : WXK_F1, vk.F2 : WXK_F2,
+ vk.F3 : WXK_F3, vk.F4 : WXK_F4,
+ vk.F5 : WXK_F5, vk.F6 : WXK_F6,
+ vk.F7 : WXK_F7, vk.F8 : WXK_F8,
+ vk.F9 : WXK_F9, vk.F10 : WXK_F10,
+ vk.F11 : WXK_F11, vk.F12 : WXK_F12,
+ vk.INSERT : WXK_INSERT, vk.DELETE : WXK_DELETE,
+ vk.HOME : WXK_HOME, vk.END : WXK_END,
+ vk.PAGEUP : WXK_PRIOR, vk.PAGEDOWN : WXK_NEXT,
+ vk.UP : WXK_UP, vk.DOWN : WXK_DOWN,
+ vk.LEFT : WXK_LEFT, vk.RIGHT : WXK_RIGHT,
+ vk.TAB : WXK_TAB,
+ vk.ENTER : WXK_RETURN, vk.BACKSPACE : WXK_BACK }
+
+ GFKeyMapper.KeyMapper.setUIKeyMap(wxKeyTranslations)
+
+ #
+ # Create a mapping for use by UIBase
+ #
+ WIDGETS = {'GFLabel' : UILabel,
+ 'GFBox' : UIBox,
+ 'GFPage' : UIPage,
+ 'GFForm' : UIForm,
+ 'GFEntry' : UIEntry,
+ 'GFButton' : UIButton,
+ 'GFScrollBar' : UIScrollBar}
+
#####################################################################
#####################################################################
##
***************
*** 1008,1014 ****
messageField = wxStaticText(self.dlg, 1010, str(loginMesg))
labelList = []
! dlgWidth = getLargest(bmp.GetWidth(),
messageField.GetSize().GetWidth()+20)
dlgHeight = bmp.GetHeight() + messageField.GetSize().GetHeight() + 80
--- 1017,1023 ----
messageField = wxStaticText(self.dlg, 1010, str(loginMesg))
labelList = []
! dlgWidth = max(bmp.GetWidth(), messageField.GetSize().GetWidth()+20)
dlgHeight = bmp.GetHeight() + messageField.GetSize().GetHeight() + 80
***************
*** 1028,1042 ****
self.textctrlList.append(t)
EVT_CHAR(t, LoginFieldHandler(self, myID).loginFieldEventTrap)
! fieldLabelWidth = getLargest(fieldLabelWidth, \
s.GetSize().GetWidth() +
t.GetSize().GetWidth() + 10)
! dlgWidth = getLargest(dlgWidth, \
s.GetSize().GetWidth() + t.GetSize().GetWidth()
+ 10)
! xSpacing = getLargest(xSpacing, s.GetSize().GetWidth())
! ySpacing = getLargest(ySpacing, s.GetSize().GetHeight())
! ySpacing = getLargest(ySpacing, t.GetSize().GetHeight())
loginButton = wxButton(self.dlg,19998,'Login')
--- 1037,1051 ----
self.textctrlList.append(t)
EVT_CHAR(t, LoginFieldHandler(self, myID).loginFieldEventTrap)
! fieldLabelWidth = max(fieldLabelWidth, \
s.GetSize().GetWidth() +
t.GetSize().GetWidth() + 10)
! dlgWidth = max(dlgWidth, \
s.GetSize().GetWidth() + t.GetSize().GetWidth()
+ 10)
! xSpacing = max(xSpacing, s.GetSize().GetWidth())
! ySpacing = max(ySpacing, s.GetSize().GetHeight())
! ySpacing = max(ySpacing, t.GetSize().GetHeight())
loginButton = wxButton(self.dlg,19998,'Login')
***************
*** 1044,1054 ****
EVT_BUTTON(self.dlg, 19998, self.loginButtonEventTrap)
EVT_BUTTON(self.dlg, 19999, self.loginCancelEventTrap)
! dlgWidth = getLargest(dlgWidth, loginButton.GetSize().GetWidth() +
cancelButton.GetSize().GetWidth() + 6) + 20
dlgHeight = dlgHeight + \
! getLargest(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight()) - 6
firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
--- 1053,1063 ----
EVT_BUTTON(self.dlg, 19998, self.loginButtonEventTrap)
EVT_BUTTON(self.dlg, 19999, self.loginCancelEventTrap)
! dlgWidth = max(dlgWidth, loginButton.GetSize().GetWidth() +
cancelButton.GetSize().GetWidth() + 6) + 20
dlgHeight = dlgHeight + \
! max(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight()) - 6
firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
***************
*** 1080,1091 ****
cancelButton.SetPosition(
wxPoint(dlgWidth - 10 - cancelButton.GetSize().GetWidth(),
! dlgHeight - 10 - getLargest(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight())))
loginButton.SetPosition(
wxPoint(dlgWidth - 16 - cancelButton.GetSize().GetWidth() - \
loginButton.GetSize().GetWidth(),
! dlgHeight - 10 - getLargest(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight())))
self.loginButton = loginButton
--- 1089,1100 ----
cancelButton.SetPosition(
wxPoint(dlgWidth - 10 - cancelButton.GetSize().GetWidth(),
! dlgHeight - 10 - max(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight())))
loginButton.SetPosition(
wxPoint(dlgWidth - 16 - cancelButton.GetSize().GetWidth() - \
loginButton.GetSize().GetWidth(),
! dlgHeight - 10 - max(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight())))
self.loginButton = loginButton
***************
*** 1144,1207 ****
def destroyLoginDialog(self):
self.dlg.Destroy()
!
! class MyComboBoxValidator(wxPyValidator):
!
! def __init__(self):
! wxPyValidator.__init__(self)
! EVT_CHAR(self, self.OnChar)
! EVT_KEY_DOWN(self, self.OnKeyDown)
! EVT_KEY_UP(self, self.OnKeyUp)
!
! def Clone(self):
! return MyComboBoxValidator()
!
! def Validate(self, win):
! return 1
!
! def OnChar(self, event):
! print "OnChar called %s" % event.KeyCode()
!
! def OnKeyUp(self, event):
! print "OnKeyDown called %s" % event.KeyCode()
!
! def OnKeyDown(self, event):
! print "OnKeyDown called %s" % event.KeyCode()
!
!
! #
! # Translate from wx keystrokes
! # to our virtual keystrokes
! #
! from GFKeyMapper import vk
!
! wxKeyTranslations = {
! vk.F1 : WXK_F1, vk.F2 : WXK_F2,
! vk.F3 : WXK_F3, vk.F4 : WXK_F4,
! vk.F5 : WXK_F5, vk.F6 : WXK_F6,
! vk.F7 : WXK_F7, vk.F8 : WXK_F8,
! vk.F9 : WXK_F9, vk.F10 : WXK_F10,
! vk.F11 : WXK_F11, vk.F12 : WXK_F12,
! vk.INSERT : WXK_INSERT, vk.DELETE : WXK_DELETE,
! vk.HOME : WXK_HOME, vk.END : WXK_END,
! vk.PAGEUP : WXK_PRIOR, vk.PAGEDOWN : WXK_NEXT,
! vk.UP : WXK_UP, vk.DOWN : WXK_DOWN,
! vk.LEFT : WXK_LEFT, vk.RIGHT : WXK_RIGHT,
! vk.TAB : WXK_TAB,
! vk.ENTER : WXK_RETURN, vk.BACKSPACE : WXK_BACK }
!
! GFKeyMapper.KeyMapper.setUIKeyMap(wxKeyTranslations)
!
! #
! # Create a mapping for use by UIBase
! #
! WIDGETS = {'GFLabel' : UILabel,
! 'GFBox' : UIBox,
! 'GFPage' : UIPage,
! 'GFForm' : UIForm,
! 'GFEntry' : UIEntry,
! 'GFButton' : UIButton,
! 'GFScrollBar' : UIScrollBar}
--- 1153,1178 ----
def destroyLoginDialog(self):
self.dlg.Destroy()
+ # Used by the login handler
+ # enables the user to press return and have it jump to the next box
+ class LoginFieldHandler:
+ def __init__(self, app, seq):
+ self.app = app
+ self.seq = seq
! def loginFieldEventTrap(self, event):
! if event.KeyCode() in (WXK_RETURN, WXK_TAB):
! if self.seq < len(self.app.textctrlList) - 1:
! self.app.textctrlList[self.seq+1].SetFocus()
! else:
! if event.KeyCode() == WXK_TAB:
! if event.ShiftDown():
! self.app.textctrlList[self.seq-1].SetFocus()
! else:
! self.app.loginButton.SetFocus()
! else:
! self.app.loginCompleted(1)
! else:
! event.Skip()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/forms/src GFForm.py UIbase.py UIcurses.py ...,
James Thompson <=