[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue common/src/events/EventController.py desig...
From: |
James Thompson |
Subject: |
gnue common/src/events/EventController.py desig... |
Date: |
Sat, 21 Dec 2002 14:29:56 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/12/21 14:29:55
Modified files:
common/src/events: EventController.py
designer/src : Designer.py
forms/src : GFForm.py GFInstance.py
forms/src/GFObjects: GFButton.py
forms/src/uidrivers/_base: UIdriver.py
forms/src/uidrivers/curses: UIdriver.py
forms/src/uidrivers/wx: UIdriver.py __init__.py
Added files:
forms/src/uidrivers/wx: UILoginHandler.py UIWXSplashScreen.py
Log message:
Started breaking apart wx uidriver
form event model changes instances are not tracking a current form
instead events pass affected form
Other stuff I probably forgot
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/events/EventController.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Designer.py.diff?tr1=1.57&tr2=1.58&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFForm.py.diff?tr1=1.219&tr2=1.220&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFInstance.py.diff?tr1=1.78&tr2=1.79&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFObjects/GFButton.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/_base/UIdriver.py.diff?tr1=1.83&tr2=1.84&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/curses/UIdriver.py.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/wx/UILoginHandler.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/wx/UIWXSplashScreen.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/wx/UIdriver.py.diff?tr1=1.224&tr2=1.225&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/wx/__init__.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/common/src/events/EventController.py
diff -c gnue/common/src/events/EventController.py:1.3
gnue/common/src/events/EventController.py:1.4
*** gnue/common/src/events/EventController.py:1.3 Mon Nov 25 00:41:41 2002
--- gnue/common/src/events/EventController.py Sat Dec 21 14:29:55 2002
***************
*** 51,57 ****
def dispatchEvent(self, event, *args, **parms):
-
# Hackery so dispatchEvent can be passed
# either an Event() object, or a text string
# identifying the type of event. If the
--- 51,56 ----
Index: gnue/designer/src/Designer.py
diff -c gnue/designer/src/Designer.py:1.57 gnue/designer/src/Designer.py:1.58
*** gnue/designer/src/Designer.py:1.57 Fri Dec 20 19:19:29 2002
--- gnue/designer/src/Designer.py Sat Dec 21 14:29:55 2002
***************
*** 68,74 ****
from gnue.forms.GFConfig import ConfigOptions
from base.Config import ConfigOptions as DesignerConfigOptions
! from gnue.forms.uidrivers.wx import UIdriver as UIwxpython
class Designer(GClientApp, wxApp):
--- 68,74 ----
from gnue.forms.GFConfig import ConfigOptions
from base.Config import ConfigOptions as DesignerConfigOptions
! from gnue.forms.uidrivers.wx import UILoginHandler # import UIdriver as
UIwxpython
class Designer(GClientApp, wxApp):
***************
*** 94,100 ****
self.configurationManager.registerAlias('gConfigForms', 'forms')
self.configurationManager.registerAlias('gConfigReports', 'reports')
! self.getConnectionManager().setLoginHandler(UIwxpython.UILoginHandler())
self.loadToolInformation()
wxApp.__init__(self,0)
--- 94,100 ----
self.configurationManager.registerAlias('gConfigForms', 'forms')
self.configurationManager.registerAlias('gConfigReports', 'reports')
! self.getConnectionManager().setLoginHandler(UILoginHandler())
self.loadToolInformation()
wxApp.__init__(self,0)
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.219 gnue/forms/src/GFForm.py:1.220
*** gnue/forms/src/GFForm.py:1.219 Tue Dec 17 19:36:09 2002
--- gnue/forms/src/GFForm.py Sat Dec 21 14:29:55 2002
***************
*** 201,207 ****
#
def primaryInit(self):
# Initialize our events system
- ## print "Init ", self
events.EventAware.__init__(self, self._instance.eventController)
# Find the logic and layout controllers
--- 201,206 ----
***************
*** 323,329 ****
try:
if self._currentEntry:
! event = events.Event('endEDITMODE', None)
self._instance.dispatchEvent(event)
if event.__error__:
return 1
--- 322,329 ----
try:
if self._currentEntry:
! event = events.Event('endEDITMODE',_form=self)
!
self._instance.dispatchEvent(event)
if event.__error__:
return 1
***************
*** 367,379 ****
self._currentPage = self._currentEntry._page
if pageChange:
! self.dispatchEvent('gotoPAGE',self._currentPage);
if blockChange:
self.refreshDisplay(self._currentBlock)
! self.dispatchEvent('updateENTRY', oldEntry)
! self.dispatchEvent('updateENTRY', self._currentEntry)
if fireFocusTriggers:
if pageChange:
--- 367,379 ----
self._currentPage = self._currentEntry._page
if pageChange:
! self.dispatchEvent('gotoPAGE',self._currentPage, _form=self);
if blockChange:
self.refreshDisplay(self._currentBlock)
! self.dispatchEvent('updateENTRY', oldEntry, _form=self)
! self.dispatchEvent('updateENTRY', self._currentEntry, _form=self)
if fireFocusTriggers:
if pageChange:
***************
*** 404,410 ****
def updateUIEntry(self,field):
for entry in field._entryList:
! self._instance.dispatchEvent('updateENTRY',entry);
#
# Incoming Event handlers
--- 404,410 ----
def updateUIEntry(self,field):
for entry in field._entryList:
! self._instance.dispatchEvent('updateENTRY',entry, _form=self);
#
# Incoming Event handlers
***************
*** 442,448 ****
return message
def executeQuery(self):
! self._instance.dispatchEvent('beginWAIT',None);
message = None
try:
--- 442,448 ----
return message
def executeQuery(self):
! self._instance.dispatchEvent('beginWAIT',None, _form=self);
message = None
try:
***************
*** 452,461 ****
self.rollback(1)
message = _("Database query error:\n%s\n%s ") % (sys.exc_info()[0],
sys.exc_info()[1])
! self._instance.dispatchEvent('endWAIT',None)
def commit(self):
! self._instance.dispatchEvent('beginWAIT',None)
message = None
--- 452,461 ----
self.rollback(1)
message = _("Database query error:\n%s\n%s ") % (sys.exc_info()[0],
sys.exc_info()[1])
! self._instance.dispatchEvent('endWAIT',None, _form=self)
def commit(self):
! self._instance.dispatchEvent('beginWAIT',None, _form=self)
message = None
***************
*** 466,472 ****
self.processTrigger('Pre-Commit')
except TriggerError:
GDebug.printMesg(1, "Trigger form Pre-Commit threw a TriggerError!")
! self._instance.dispatchEvent('endWAIT',None)
return _("Form trigger returned error")
for block in self._logic._blockList:
--- 466,472 ----
self.processTrigger('Pre-Commit')
except TriggerError:
GDebug.printMesg(1, "Trigger form Pre-Commit threw a TriggerError!")
! self._instance.dispatchEvent('endWAIT',None, _form=self)
return _("Form trigger returned error")
for block in self._logic._blockList:
***************
*** 479,485 ****
block.processCommit()
except TriggerError:
GDebug.printMesg(1, "Trigger block Pre-Commit threw a
TriggerError!")
! self._instance.dispatchEvent('endWAIT',None)
return _("Block trigger returned error")
block.processTrigger('Post-Commit')
--- 479,485 ----
block.processCommit()
except TriggerError:
GDebug.printMesg(1, "Trigger block Pre-Commit threw a
TriggerError!")
! self._instance.dispatchEvent('endWAIT',None, _form=self)
return _("Block trigger returned error")
block.processTrigger('Post-Commit')
***************
*** 488,494 ****
else:
message = _('Form is readonly')
! self._instance.dispatchEvent('endWAIT',None)
return message
self.processTrigger('Post-Commit')
--- 488,494 ----
else:
message = _('Form is readonly')
! self._instance.dispatchEvent('endWAIT',None, _form=self)
return message
self.processTrigger('Post-Commit')
***************
*** 502,508 ****
traceback.print_exc(file=sys.stdout)
print '-'*60
! self._instance.dispatchEvent('endWAIT',None)
return message
--- 502,508 ----
traceback.print_exc(file=sys.stdout)
print '-'*60
! self._instance.dispatchEvent('endWAIT',None, _form=self)
return message
***************
*** 513,519 ****
author = self.getOption('author') or "Unknown"
description = self.getOption('description') or "Unknown"
!
self.dispatchEvent('uiABOUT',[version,name,formversion,author,description])
def rollback(self, recover=0):
self.endEditing()
--- 513,519 ----
author = self.getOption('author') or "Unknown"
description = self.getOption('description') or "Unknown"
!
self.dispatchEvent('uiABOUT',[version,name,formversion,author,description],
_form=self)
def rollback(self, recover=0):
self.endEditing()
***************
*** 634,640 ****
def __refreshDisplay(self, object):
if object._type == 'GFEntry':
! self.dispatchEvent('updateENTRY',object)
--- 634,640 ----
def __refreshDisplay(self, object):
if object._type == 'GFEntry':
! self.dispatchEvent('updateENTRY',object, _form=self)
***************
*** 683,689 ****
# mode and save it's value to the virtual form
#
def endEditing(self):
! event = events.Event('endEDITMODE',None)
self.dispatchEvent(event)
return not event.__error__
--- 683,689 ----
# mode and save it's value to the virtual form
#
def endEditing(self):
! event = events.Event('endEDITMODE',None, _form=self)
self.dispatchEvent(event)
return not event.__error__
***************
*** 723,729 ****
def triggerSetFocus(self,object):
self.changeFocus(object._object,1)
! self.dispatchEvent('gotoENTRY',{'object':self._currentEntry})
def triggerGetCurrentEntry(self):
return self._currentEntry
--- 723,729 ----
def triggerSetFocus(self,object):
self.changeFocus(object._object,1)
! self.dispatchEvent('gotoENTRY',object=self._currentEntry,_form=self)
def triggerGetCurrentEntry(self):
return self._currentEntry
***************
*** 735,741 ****
return self._currentPage
def triggerSetStatusText(self,tip=''):
! self.dispatchEvent('uiUPDATESTATUS',tip=tip)
def triggerRunForm(self,fileName):
from GFInstance import GFInstance
--- 735,741 ----
return self._currentPage
def triggerSetStatusText(self,tip=''):
! self.dispatchEvent('uiUPDATESTATUS',tip=tip, _form=self)
def triggerRunForm(self,fileName):
from GFInstance import GFInstance
***************
*** 750,756 ****
# Close this form.
def close(self):
! event = events.Event('requestEXIT')
self._instance.dispatchEvent(event)
if event.__error__:
return 1
--- 750,756 ----
# Close this form.
def close(self):
! event = events.Event('requestEXIT', _form=self)
self._instance.dispatchEvent(event)
if event.__error__:
return 1
Index: gnue/forms/src/GFInstance.py
diff -c gnue/forms/src/GFInstance.py:1.78 gnue/forms/src/GFInstance.py:1.79
*** gnue/forms/src/GFInstance.py:1.78 Tue Dec 17 19:36:09 2002
--- gnue/forms/src/GFInstance.py Sat Dec 21 14:29:55 2002
***************
*** 228,241 ****
#
def activateForm(self,formName='__main__'):
self._form = self._formsDictionary[formName]
-
## print "Current entry", self._form._currentEntry
if not self._form._currentEntry:
raise _('There are no navigable widgets in this form. Unable to
display.')
self._uiinstance.activateForm(formName)
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.dispatchEvent('updateENTRY',self._form._currentEntry)
self._form.refreshDisplay(self._form)
self.updateStatus()
--- 228,242 ----
#
def activateForm(self,formName='__main__'):
self._form = self._formsDictionary[formName]
## print "Current entry", self._form._currentEntry
+
if not self._form._currentEntry:
raise _('There are no navigable widgets in this form. Unable to
display.')
self._uiinstance.activateForm(formName)
! self.dispatchEvent('gotoENTRY',object=self._form._currentEntry,
! _form=self._form)
self.dispatchEvent('updateENTRY',self._form._currentEntry)
self._form.refreshDisplay(self._form)
self.updateStatus()
***************
*** 334,340 ****
# repeated code.
#
def _entryUpdated(self):
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateRecordCounter()
self.updateRecordStatus()
--- 335,341 ----
# repeated code.
#
def _entryUpdated(self):
! self.dispatchEvent('gotoENTRY',object=self._form._currentEntry,
_form=self._form)
self.updateRecordCounter()
self.updateRecordStatus()
***************
*** 347,357 ****
# any relevant events here and pass on to the entry.
#
def proxyEntryEvent(self, event):
! if self._form._currentEntry and \
! self._form._currentEntry._type != 'GFButton':
!
! handler = self._form._currentEntry._displayHandler
# If the display will need to be refreshed,
# then the proxied event should set this to 1
--- 348,357 ----
# any relevant events here and pass on to the entry.
#
def proxyEntryEvent(self, event):
+ if event._form._currentEntry and \
+ event._form._currentEntry._type != 'GFButton':
! handler = event._form._currentEntry._displayHandler
# If the display will need to be refreshed,
# then the proxied event should set this to 1
***************
*** 380,393 ****
# focus change to the next data entry object
#
def nextEntry(self, event):
! if not self._form.endEditing():
return
! message = self._form.nextEntry()
if message:
messageBox = GFMsgBox(self, message)
messageBox.show()
return
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateRecordStatus()
self.updateTip()
--- 380,393 ----
# focus change to the next data entry object
#
def nextEntry(self, event):
! if not event._form.endEditing():
return
! message = event._form.nextEntry()
if message:
messageBox = GFMsgBox(self, message)
messageBox.show()
return
! self.dispatchEvent('gotoENTRY',object=event._form._currentEntry,
_form=event._form)
self.updateRecordStatus()
self.updateTip()
***************
*** 398,407 ****
# focus change to the next data entry object
#
def previousEntry(self, event):
! if not self._form.endEditing():
return
! self._form.previousEntry()
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateRecordStatus()
self.updateTip()
--- 398,407 ----
# focus change to the next data entry object
#
def previousEntry(self, event):
! if not event._form.endEditing():
return
! event._form.previousEntry()
! self.dispatchEvent('gotoENTRY',object=event._form._currentEntry,
_form=event._form)
self.updateRecordStatus()
self.updateTip()
***************
*** 412,421 ****
# focus change to the next data entry block
#
def nextBlock(self,event):
! if not self._form.endEditing():
return
! self._form.nextBlock()
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateStatus()
#
--- 412,421 ----
# focus change to the next data entry block
#
def nextBlock(self,event):
! if not event._form.endEditing():
return
! event._form.nextBlock()
! self.dispatchEvent('gotoENTRY',object=event._form._currentEntry,
_form=event._form)
self.updateStatus()
#
***************
*** 425,434 ****
# focus change to the next data entry block
#
def previousBlock(self, event):
! if not self._form.endEditing():
return
! self._form.previousBlock()
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateStatus()
#
--- 425,434 ----
# focus change to the next data entry block
#
def previousBlock(self, event):
! if not event._form.endEditing():
return
! event._form.previousBlock()
! self.dispatchEvent('gotoENTRY',object=event._form._currentEntry,
_form=event._form)
self.updateStatus()
#
***************
*** 437,446 ****
# Called to make the form jump to a specific page
#
def gotoPage(self,event):
! if not self._form.endEditing():
return
! self._form.findAndChangeFocus(self._form._layout._pageList[event.data])
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateStatus()
#
--- 437,446 ----
# Called to make the form jump to a specific page
#
def gotoPage(self,event):
! if not event._form.endEditing():
return
! event._form.findAndChangeFocus(event._form._layout._pageList[event.data])
! self.dispatchEvent('gotoENTRY',object=event._form._currentEntry,
_form=event._form)
self.updateStatus()
#
***************
*** 450,458 ****
# form advance to the next record in memory
#
def prevRecord(self, event):
! if not self._form.endEditing():
return
! message = self._form.prevRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
--- 450,458 ----
# form advance to the next record in memory
#
def prevRecord(self, event):
! if not event._form.endEditing():
return
! message = event._form.prevRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
***************
*** 466,474 ****
# form advance to the next record in memory
#
def nextRecord(self, event):
! if not self._form.endEditing():
return
! message = self._form.nextRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
--- 466,474 ----
# form advance to the next record in memory
#
def nextRecord(self, event):
! if not event._form.endEditing():
return
! message = event._form.nextRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
***************
*** 482,490 ****
# form advance to the first record in memory
#
def firstRecord(self, event):
! if not self._form.endEditing():
return
! message = self._form.firstRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
--- 482,490 ----
# form advance to the first record in memory
#
def firstRecord(self, event):
! if not event._form.endEditing():
return
! message = event._form.firstRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
***************
*** 498,506 ****
# form advance to the last record in memory
#
def lastRecord(self, event):
! if not self._form.endEditing():
return
! message = self._form.lastRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
--- 498,506 ----
# form advance to the last record in memory
#
def lastRecord(self, event):
! if not event._form.endEditing():
return
! message = event._form.lastRecord()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
***************
*** 514,527 ****
# form move a specific record
#
def jumpToRecord(self,event):
! if not self._form.endEditing():
return
try:
count = abs(int(event.data))-1
except ValueError:
message = _("Invalid numeric value entered.")
else:
! message = self._form.jumpRecord(count)
if message:
messageBox = GFMsgBox(self,message)
--- 514,527 ----
# form move a specific record
#
def jumpToRecord(self,event):
! if not event._form.endEditing():
return
try:
count = abs(int(event.data))-1
except ValueError:
message = _("Invalid numeric value entered.")
else:
! message = event._form.jumpRecord(count)
if message:
messageBox = GFMsgBox(self,message)
***************
*** 537,551 ****
# forward or backward.
#
def jumpRecords(self,event):
! if not self._form.endEditing():
return
count = event.data
# Doing this to reduce comparisons in the loop
if count > 0:
! method = self._form.nextRecord
else:
! method = self._form.prevRecord
for jumps in range(abs(int(count))):
method()
--- 537,551 ----
# forward or backward.
#
def jumpRecords(self,event):
! if not event._form.endEditing():
return
count = event.data
# Doing this to reduce comparisons in the loop
if count > 0:
! method = event._form.nextRecord
else:
! method = event._form.prevRecord
for jumps in range(abs(int(count))):
method()
***************
*** 558,568 ****
# has been saved
#
def executeExit(self, event):
! if not self._form.isSaved():
message = GFMsgBox(self, _('Data not saved. Save changes or clear the
form to proceed.'))
message.show()
else:
! self._form.processTrigger('On-Exit')
self.dispatchEvent('exitApplication',_('Current data is saved'))
return
--- 558,568 ----
# has been saved
#
def executeExit(self, event):
! if not event._form.isSaved():
message = GFMsgBox(self, _('Data not saved. Save changes or clear the
form to proceed.'))
message.show()
else:
! event._form.processTrigger('On-Exit')
self.dispatchEvent('exitApplication',_('Current data is saved'))
return
***************
*** 573,584 ****
# Tells the form to mark a record for delete
#
def deleteRecord(self, event):
! if self._form.readonly:
self.dispatchEvent('formALERT',_('Form is readonly'))
! elif self._form._currentBlock.restrictDelete:
self.dispatchEvent('formALERT',_('Block does not allow delete'))
else:
! self._form.deleteRecord()
self.updateRecordStatus()
#
--- 573,584 ----
# Tells the form to mark a record for delete
#
def deleteRecord(self, event):
! if event._form.readonly:
self.dispatchEvent('formALERT',_('Form is readonly'))
! elif event._form._currentBlock.restrictDelete:
self.dispatchEvent('formALERT',_('Block does not allow delete'))
else:
! event._form.deleteRecord()
self.updateRecordStatus()
#
***************
*** 587,600 ****
# Tells the form to create a new record
#
def newRecord(self, event):
! if not self._form.endEditing():
return
! if self._form.readonly:
self.dispatchEvent('formALERT',_('Form is readonly'))
! elif self._form._currentBlock.restrictInsert:
self.dispatchEvent('formALERT',_('Block does not allow insert'))
else:
! self._form.newRecord()
self._entryUpdated()
#
--- 587,600 ----
# Tells the form to create a new record
#
def newRecord(self, event):
! if not event._form.endEditing():
return
! if event._form.readonly:
self.dispatchEvent('formALERT',_('Form is readonly'))
! elif event._form._currentBlock.restrictInsert:
self.dispatchEvent('formALERT',_('Block does not allow insert'))
else:
! event._form.newRecord()
self._entryUpdated()
#
***************
*** 603,612 ****
# Displays the about dialog
#
def executeAbout(self,event):
! name = self._form.title or "Unknown"
! formversion = self._form.getOption('version') or "Unknown"
! author = self._form.getOption('author') or "Unknown"
! description = self._form.getOption('description') or "Unknown"
self.dispatchEvent('uiABOUT',[VERSION,name,formversion,author,description])
#
--- 603,612 ----
# Displays the about dialog
#
def executeAbout(self,event):
! name = event._form.title or "Unknown"
! formversion = event._form.getOption('version') or "Unknown"
! author = event._form.getOption('author') or "Unknown"
! description = event._form.getOption('description') or "Unknown"
self.dispatchEvent('uiABOUT',[VERSION,name,formversion,author,description])
#
***************
*** 615,621 ****
# tells the form to toggle mode
#
def toggleInsertMode(self, event):
! self._form.toggleInsertMode()
self.updateInsertMode()
#
--- 615,621 ----
# tells the form to toggle mode
#
def toggleInsertMode(self, event):
! event._form.toggleInsertMode()
self.updateInsertMode()
#
***************
*** 624,631 ****
# If the form has a trigger named process-printout then fire it
#
def executePrintout(self,event):
! if self._form._triggerDictionary.has_key('process-printout'):
! self._form.fireTrigger('process-printout')
else:
# TODO: should probably do something else as a default if trigger not
available
# TODO: like a screen print
--- 624,631 ----
# If the form has a trigger named process-printout then fire it
#
def executePrintout(self,event):
! if event._form._triggerDictionary.has_key('process-printout'):
! event._form.fireTrigger('process-printout')
else:
# TODO: should probably do something else as a default if trigger not
available
# TODO: like a screen print
***************
*** 637,643 ****
# Tells the form to rollback everything it contains
#
def executeRollback(self,event):
! self._form.rollback()
self._entryUpdated()
#
--- 637,643 ----
# Tells the form to rollback everything it contains
#
def executeRollback(self,event):
! event._form.rollback()
self._entryUpdated()
#
***************
*** 647,669 ****
# an event source
#
def changeFocus(self, event):
! if not self._form.endEditing():
return
if event.data._type=='GFEntry':
if not event.data._navigable:
# is it possible ever to get into non-navigable field?
return
! if (event.data.readonly and self._form._currentBlock.mode!='query'):
GDebug.printMesg(2,"You can focus readonly field, but you won't be
able to change it.")
newEntry = event.data
! message = self._form.changeFocus(newEntry)
if message:
messageBox = GFMsgBox(self, message)
messageBox.show()
return
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateRecordStatus()
self.updateTip()
--- 647,669 ----
# an event source
#
def changeFocus(self, event):
! if not event._form.endEditing():
return
if event.data._type=='GFEntry':
if not event.data._navigable:
# is it possible ever to get into non-navigable field?
return
! if (event.data.readonly and event._form._currentBlock.mode!='query'):
GDebug.printMesg(2,"You can focus readonly field, but you won't be
able to change it.")
newEntry = event.data
! message = event._form.changeFocus(newEntry)
if message:
messageBox = GFMsgBox(self, message)
messageBox.show()
return
! self.dispatchEvent('gotoENTRY',object=event._form._currentEntry,
_form=event._form)
self.updateRecordStatus()
self.updateTip()
***************
*** 671,715 ****
# requestQuery
#
def requestQuery(self, event):
! if not self._form.endEditing():
return
! message = self._form.prepQuery()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
return
! self._form.refreshDisplay(self._form)
! self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
self.updateStatus()
#
# requestQuery
#
def executeCommit(self, event):
! if not self._form.endEditing():
return
! message = self._form.commit()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
return
! self._form.refreshDisplay(self._form._currentBlock)
self._entryUpdated()
#
# executeQuery
#
def executeQuery(self, event):
! if not self._form.endEditing():
return
! message = self._form.executeQuery()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
! self._form.refreshDisplay(self._form._currentBlock)
self._entryUpdated()
--- 671,715 ----
# requestQuery
#
def requestQuery(self, event):
! if not event._form.endEditing():
return
! message = event._form.prepQuery()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
return
! event._form.refreshDisplay(event._form)
! self.dispatchEvent('gotoENTRY',object=event._form._currentEntry,
_form=event._form)
self.updateStatus()
#
# requestQuery
#
def executeCommit(self, event):
! if not event._form.endEditing():
return
! message = event._form.commit()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
return
! event._form.refreshDisplay(event._form._currentBlock)
self._entryUpdated()
#
# executeQuery
#
def executeQuery(self, event):
! if not event._form.endEditing():
return
! message = event._form.executeQuery()
if message:
messageBox = GFMsgBox(self,message)
messageBox.show()
! event._form.refreshDisplay(event._form._currentBlock)
self._entryUpdated()
***************
*** 761,767 ****
# fireTrigger
#
def fireTrigger(self, event):
! self._form.fireTrigger(event.data)
#
# fireButton
--- 761,767 ----
# fireTrigger
#
def fireTrigger(self, event):
! event._form.fireTrigger(event.data)
#
# fireButton
Index: gnue/forms/src/GFObjects/GFButton.py
diff -c gnue/forms/src/GFObjects/GFButton.py:1.15
gnue/forms/src/GFObjects/GFButton.py:1.16
*** gnue/forms/src/GFObjects/GFButton.py:1.15 Thu Dec 12 13:03:29 2002
--- gnue/forms/src/GFObjects/GFButton.py Sat Dec 21 14:29:55 2002
***************
*** 46,51 ****
--- 46,52 ----
def initialize(self):
self._page = self.findParentOfType('GFPage')
+ self._form = self.findParentOfType('GFForm')
self._page._entryList.append(self)
Index: gnue/forms/src/uidrivers/_base/UIdriver.py
diff -c gnue/forms/src/uidrivers/_base/UIdriver.py:1.83
gnue/forms/src/uidrivers/_base/UIdriver.py:1.84
*** gnue/forms/src/uidrivers/_base/UIdriver.py:1.83 Wed Dec 11 23:08:09 2002
--- gnue/forms/src/uidrivers/_base/UIdriver.py Sat Dec 21 14:29:55 2002
***************
*** 57,63 ****
#
############################################################
events.EventAware.__init__(self, eventHandler)
!
# Configure event handling
self.registerEventListeners( {
'gotoENTRY' : self.switchFocus,
--- 57,63 ----
#
############################################################
events.EventAware.__init__(self, eventHandler)
!
# Configure event handling
self.registerEventListeners( {
'gotoENTRY' : self.switchFocus,
***************
*** 84,93 ****
# Mapping - internal record status : displayed on status bar
! self.statusValues = {'saved':'OK',
! 'modified':'MOD',
! 'deleted':'DEL',
! 'query':'QRY'}
# Our local "clipboard"
self.__clipboard = None
--- 84,94 ----
# Mapping - internal record status : displayed on status bar
! self.statusValues = {'saved' :'OK',
! 'modified' :'MOD',
! 'deleted' :'DEL',
! 'query' :'QRY',
! }
# Our local "clipboard"
self.__clipboard = None
***************
*** 144,155 ****
self._uiDictionary = {}
! # self.widgets = self._WIDGETS
! # 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._pageList = [] # A list of page widgets created
by the form
!
#
# buildUI
#
--- 145,155 ----
self._uiDictionary = {}
! 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._pageList = [] # A list of page widgets created by
the form
!
#
# buildUI
#
***************
*** 161,166 ****
--- 161,167 ----
def _buildUI(self):
try:
uiWidget = self.widgetConstructorFunction[self._currentObject[0]._type]
()
+ uiWidget._form = self._form
widget = uiWidget.widgets
GDebug.printMesg(2, "Widget is %s" % widget)
***************
*** 230,237 ****
def buildForm(self, form, formName):
currentForm = self._uiDictionary[formName] = UIForm()
! self._formToUI = {}
! self._formToUIWidget = {}
self._pageList = []
self._form = form
self._currentObject = [form]
--- 231,238 ----
def buildForm(self, form, formName):
currentForm = self._uiDictionary[formName] = UIForm()
! # self._formToUI = {}
! # self._formToUIWidget = {}
self._pageList = []
self._form = form
self._currentObject = [form]
***************
*** 250,257 ****
form = self._uiDictionary[formName]
! self._formToUI = form._formToUI
! self._formToUIWidget = form._formToUIWidget
self._pageList = form._pageList
self.currentWidget = form._currentWidget
self._form = form._form
--- 251,258 ----
form = self._uiDictionary[formName]
! # self._formToUI = form._formToUI
! # self._formToUIWidget = form._formToUIWidget
self._pageList = form._pageList
self.currentWidget = form._currentWidget
self._form = form._form
***************
*** 273,284 ****
# Moves the focus to a specific UI widget
#
def switchFocus(self, event):
! formObject = event.data['object']
! if formObject: # Some pages might not have any widgets that can be active
! index = formObject._visibleIndex
! self._formToUIWidget[formObject].indexedFocus(index)
! self.dispatchEvent(events.Event('beginEDITMODE', formObject))
#
# updateEntry
--- 274,285 ----
# Moves the focus to a specific UI widget
#
def switchFocus(self, event):
! object = event.object
! if object: # Some pages might not have any widgets that can be active
! index = object._visibleIndex
! self._formToUIWidget[object].indexedFocus(index)
! self.dispatchEvent('beginEDITMODE', object, _form=object._form)
#
# updateEntry
***************
*** 300,306 ****
for count in range(index):
value =
handler.getDisplayFiller(block._resultSet.getRecord(currentRecord- \
(index-count)).getField(field.field))
-
self._formToUIWidget[entry].setValue(value,count)
# Fill current spot
--- 301,306 ----
***************
*** 338,343 ****
--- 338,344 ----
def updateEntryEditor(self, event):
index = event.object._visibleIndex
widget = self._formToUIWidget[event.object]
+ #print "lookups in",self._formToUIWidget
widget.setValue(event.display, index)
widget.setCursorPosition(event.cursor, index)
Index: gnue/forms/src/uidrivers/curses/UIdriver.py
diff -c gnue/forms/src/uidrivers/curses/UIdriver.py:1.27
gnue/forms/src/uidrivers/curses/UIdriver.py:1.28
*** gnue/forms/src/uidrivers/curses/UIdriver.py:1.27 Wed Dec 11 23:08:10 2002
--- gnue/forms/src/uidrivers/curses/UIdriver.py Sat Dec 21 14:29:55 2002
***************
*** 787,792 ****
--- 787,797 ----
pass
if action:
+ # Add the object's _form to the outgoing event
+ # rather than every event in the function
+ action.__dict__.update({'_form':self._form})
+
+
self._eventProcessor(action)
return None
Index: gnue/forms/src/uidrivers/wx/UIdriver.py
diff -c gnue/forms/src/uidrivers/wx/UIdriver.py:1.224
gnue/forms/src/uidrivers/wx/UIdriver.py:1.225
*** gnue/forms/src/uidrivers/wx/UIdriver.py:1.224 Tue Dec 17 19:36:09 2002
--- gnue/forms/src/uidrivers/wx/UIdriver.py Sat Dec 21 14:29:55 2002
***************
*** 26,40 ****
#
# NOTES:
#
-
import sys
import string
from wxPython.wx import *
- from wxPython.lib.splashscreen import SplashScreen
from gnue.common import events
! from gnue.common import GDebug, GLoginHandler
from gnue.common import GConfig
from gnue.common.TextUtils import lineWrap
--- 26,38 ----
#
# NOTES:
#
import sys
import string
from wxPython.wx import *
from gnue.common import events
! from gnue.common import GDebug
from gnue.common import GConfig
from gnue.common.TextUtils import lineWrap
***************
*** 43,49 ****
from gnue.forms.uidrivers._base.UIdriver import *
from gnue.forms.uidrivers._base.UIWidget import *
! _LOOPTRAP = 0
_PROMPTFORRECORD = None
_charWidth = 0
_charHeight = 0
--- 41,52 ----
from gnue.forms.uidrivers._base.UIdriver import *
from gnue.forms.uidrivers._base.UIWidget import *
! from gnue.forms.uidrivers.wx.GFwxApp import *
! from gnue.forms.uidrivers.wx.UIWXSplashScreen import *
! #from UIWidgets import *
! from common import *
!
!
_PROMPTFORRECORD = None
_charWidth = 0
_charHeight = 0
***************
*** 53,65 ****
_disabledColour = wxLIGHT_GREY
-
# Shortcut
images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
-
# Finishing creation of dictionary for language font encodings
-
encodings = {
'iso8859-1': wxFONTENCODING_ISO8859_1,
'iso8859-2': wxFONTENCODING_ISO8859_2,
--- 56,65 ----
***************
*** 88,129 ****
eo = event.GetEventObject()
return wxPyTypeCast(eo, 'wxWindow')
- ##
- ## Only create one instance of wxApp
- ## Use getWxApp() to get or create the
- ## single instance
- ##
- ## TODO: It seems this could all be folded
- ## TODO: into an __init__ inside GFwxApp
- ##
- __wxApp = None
-
- def getWxApp():
- global __wxApp
-
- if not __wxApp:
- GDebug.printMesg(7,"WxApp initializing")
- __wxApp = GFwxApp(0)
- return __wxApp
-
-
- class GFwxApp(wxApp):
- _mainLoop= None
-
- def OnInit(self):
- GDebug.printMesg(7,"WxApp initializing")
- wxInitAllImageHandlers()
- return true
-
- def MainLoop (self):
- # just to launch one wx's mainloop
- # otherwise, the app does not finishes cleanly when several windows are
open
- # 'cause the first mainloop gets all the events
- # and the others just sit and wait for something to happen
- if self._mainLoop==None:
- self._mainLoop= 1
- wxApp.MainLoop (self)
-
#
# Little global helper routine to set font according to options
--- 88,93 ----
***************
*** 154,202 ****
# is written using wx and pulls these values from this driver
self._WIDGETS = WIDGETS
! self.wxSpecificInit(disableSplash)
!
! def wxSpecificInit(self, disableSplash):
! global _PROMPTFORRECORD
! _PROMPTFORRECORD = self.promptForRecordNumber
!
self._wxapp = getWxApp()
#
# SplashScreen
#
if not disableSplash:
! self.splash =
SplashScreen(None,bitmapfile=images_dir+gConfigForms('splashScreenPNG'),
! duration = 3000, callback=self.onCloseSplash,
! style=wxSIMPLE_BORDER|wxCENTRE_ON_SCREEN )
! swidth,sheight = self.splash.GetSizeTuple()
!
! # Make the splash text print white
! self.splash.SetForegroundColour(wxColour(0xFF, 0xFF, 0xFF))
! self.splash.SetFont(wxFont(20,wxSWISS,wxNORMAL,wxBOLD))
!
! text = _("GNU Enterprise Forms")
! twidth,theight = self.splash.GetTextExtent(text)
! wxStaticText(parent=self.splash, id=-1, label=str(text),
!
size=wxSize(swidth,theight),pos=wxPoint(1,1),style=wxALIGN_CENTRE)
!
! self.splash.SetFont(wxFont(10,wxSWISS,wxNORMAL,wxBOLD))
!
! text = _("Version %s") % VERSION
! twidth,theight = self.splash.GetTextExtent(text)
! wxStaticText(parent=self.splash, id=-1, label=str(text),
! size=wxSize(swidth,theight),
pos=wxPoint(1,25),style=wxALIGN_CENTRE)
!
! text = "(c)2000-2002 Free Software Foundation"
! twidth,theight = self.splash.GetTextExtent(text)
! wxStaticText(self.splash, -1, str(text),
! wxPoint(1,50),wxSize(swidth,theight),wxALIGN_CENTRE)
!
! text = _("Protected by GNU General Public Licence 2.0")
! wxStaticText(self.splash, -1, str(text),
!
wxPoint(1,sheight-(theight+10)),wxSize(swidth-5,theight),wxALIGN_RIGHT)
! self.splash.CenterOnScreen()
! self.splash.Show(true)
#
# Create the main window
--- 118,139 ----
# is written using wx and pulls these values from this driver
self._WIDGETS = WIDGETS
! ################################################################
! # WX Specifics
! ################################################################
self._wxapp = getWxApp()
+
#
# SplashScreen
#
if not disableSplash:
! self.splash = UIWXSplashScreen()
! self.wxSpecificInit(disableSplash)
!
! def wxSpecificInit(self, disableSplash):
! global _PROMPTFORRECORD
! _PROMPTFORRECORD = self.promptForRecordNumber
#
# Create the main window
***************
*** 217,234 ****
maxDescent = max(maxDescent,descent)
maxLeading = max(maxLeading,leading)
- self.charWidth = int(maxWidth+maxLeading)
- self.charHeight = int(maxHeight+maxDescent)
-
- self.widgetWidth = self.charWidth # The pixel width of a 1 char
widget (for things like buttons)
- self.widgetHeight = self.charHeight + 3 # The pixel height of a 1 char
widget (for things like buttons)
- self.textWidth = self.charWidth # The pixel width of text inside
a widget
- self.textHeight = self.charHeight # The pixel height of text inside
a widget
-
global _charWidth, _charHeight
! _charWidth = self.charWidth # Used by the mouse handler to
compute char offset into widget
! _charHeight = self.charHeight #
!
self.menu_sb_space=4 # the extra spaces needed by the menu, toolbar and
statusbar
--- 154,166 ----
maxDescent = max(maxDescent,descent)
maxLeading = max(maxLeading,leading)
global _charWidth, _charHeight
! _charWidth = int(maxWidth+maxLeading) # Used by the mouse handler
to compute char offset into widget
! _charHeight = int(maxHeight+maxDescent) #
! self.textWidth = _charWidth # The pixel width of text
inside a widget
! self.textHeight = _charHeight # The pixel height of text
inside a widget
! self.widgetWidth = _charWidth # The pixel width of a 1
char widget (for things like buttons)
! self.widgetHeight = _charHeight + 3 # The pixel height of a 1
char widget (for things like buttons)
self.menu_sb_space=4 # the extra spaces needed by the menu, toolbar and
statusbar
***************
*** 239,252 ****
self._scrollWindow = self.mainWindow.panel =
wxScrolledWindow(self.mainWindow,-1,
wxDefaultPosition,self.mainWindow.GetClientSize())
! global _disabledColour
! _disabledColour = self.mainWindow.GetBackgroundColour()
self.currentWidget = [self._scrollWindow]
EVT_CLOSE(self.mainWindow,self.closeTrap)
-
def _activateForm(self, form):
#
# Build Menu
--- 171,182 ----
self._scrollWindow = self.mainWindow.panel =
wxScrolledWindow(self.mainWindow,-1,
wxDefaultPosition,self.mainWindow.GetClientSize())
! setDisabledColour(self.mainWindow.GetBackgroundColour())
self.currentWidget = [self._scrollWindow]
EVT_CLOSE(self.mainWindow,self.closeTrap)
def _activateForm(self, form):
#
# Build Menu
***************
*** 260,303 ****
self.__eventMenuMapping = {}
fileMenu = wxMenu()
! self.__addMenuItem(fileMenu, _("&Save\tF6"),_('Save all changes to
database.'),'requestCOMMIT')
! self.__addMenuItem(fileMenu, _("&Clear Form\tF11"),_('Clear
Form'),'requestROLLBACK')
fileMenu.AppendSeparator()
! self.__addMenuItem(fileMenu, _("&Print"),_('Perform print routine for
this form.'),'requestPRINTOUT')
fileMenu.AppendSeparator()
! id = self.__addMenuItem(fileMenu, _("E&xit"),_('Leave the
application.'))
EVT_MENU(self._wxapp, id, self.menuExitEvent)
self.__eventMenuMapping['_exit_'] = id
editMenu = wxMenu()
! self.__addMenuItem(editMenu, _("C&ut"),_("Cut the selected
text"),'requestCUT')
! self.__addMenuItem(editMenu, _("&Copy"),_("Copy the selected text"),
'requestCOPY')
! self.__addMenuItem(editMenu, _("&Paste"),_("Paste text"),'requestPASTE')
dataMenu = wxMenu()
! self.__addMenuItem(dataMenu, _("&First Record\tCtrl+Up"),_('Navigate to
first record in memory.'),'requestFIRSTRECORD')
! self.__addMenuItem(dataMenu, _("&Previous Record\tUp"),_('Navigate to
previous record in memory.'),'requestPREVRECORD')
! self.__addMenuItem(dataMenu, _("&Next Record\tDown"),_('Navigate to
next record in memory.'),'requestNEXTRECORD')
! self.__addMenuItem(dataMenu, _("&Last Record\tCtrl+Down"),_('Navigate
to last record in memory.'),'requestLASTRECORD')
! id = self.__addMenuItem(dataMenu, _("&Jump to
Record...\tF2"),_('Prompts for a record number to which the system should
jump.'))
EVT_MENU(self._wxapp, id, _PROMPTFORRECORD)
self.__eventMenuMapping['_promptForRecord_'] = id
! self.__addMenuItem(dataMenu, _("N&ew Record\tF12"),_('Create a new
record for data input.'),'requestNEWRECORD')
! self.__addMenuItem(dataMenu, _("Mark Record for &Delete\tF5"),_('Mark
record for removal at next commit.'),'requestMARKFORDELETE')
dataMenu.AppendSeparator()
! self.__addMenuItem(dataMenu, _("Next &Block\tPgDn"),_('Navigate to next
data block.'),'requestNEXTBLOCK')
! self.__addMenuItem(dataMenu, _("P&revious Block\tPgUp"),_('Navigate to
previous data block.'),'requestPREVBLOCK')
dataMenu.AppendSeparator()
! self.__addMenuItem(dataMenu, _("&Enter Query\tF8"),_('Switch to input
query mask mode.'),'requestENTERQUERY')
! self.__addMenuItem(dataMenu, _("Execute &Query\tF9"), _('Execute query
using current mask.'),'requestEXECQUERY')
helpMenu = wxMenu()
! self.__addMenuItem(helpMenu, _("&About..."), _('Display info about GNUe
Forms.'),'requestABOUT')
menuBar = wxMenuBar()
menuBar.Append( fileMenu, _("&File") )
--- 190,233 ----
self.__eventMenuMapping = {}
fileMenu = wxMenu()
! self.__addMenuItem(fileMenu, _("&Save\tF6"),_('Save all changes to
database.'),'requestCOMMIT', form=form)
! self.__addMenuItem(fileMenu, _("&Clear Form\tF11"),_('Clear
Form'),'requestROLLBACK', form=form)
fileMenu.AppendSeparator()
! self.__addMenuItem(fileMenu, _("&Print"),_('Perform print routine for
this form.'),'requestPRINTOUT', form=form)
fileMenu.AppendSeparator()
! id = self.__addMenuItem(fileMenu, _("E&xit"),_('Leave the
application.'), form=form)
EVT_MENU(self._wxapp, id, self.menuExitEvent)
self.__eventMenuMapping['_exit_'] = id
editMenu = wxMenu()
! self.__addMenuItem(editMenu, _("C&ut"),_("Cut the selected
text"),'requestCUT', form=form)
! self.__addMenuItem(editMenu, _("&Copy"),_("Copy the selected text"),
'requestCOPY', form=form)
! self.__addMenuItem(editMenu, _("&Paste"),_("Paste
text"),'requestPASTE', form=form)
dataMenu = wxMenu()
! self.__addMenuItem(dataMenu, _("&First Record\tCtrl+Up"),_('Navigate to
first record in memory.'),'requestFIRSTRECORD', form=form)
! self.__addMenuItem(dataMenu, _("&Previous Record\tUp"),_('Navigate to
previous record in memory.'),'requestPREVRECORD', form=form)
! self.__addMenuItem(dataMenu, _("&Next Record\tDown"),_('Navigate to
next record in memory.'),'requestNEXTRECORD', form=form)
! self.__addMenuItem(dataMenu, _("&Last Record\tCtrl+Down"),_('Navigate
to last record in memory.'),'requestLASTRECORD', form=form)
! id = self.__addMenuItem(dataMenu, _("&Jump to
Record...\tF2"),_('Prompts for a record number to which the system should
jump.'), form=form)
EVT_MENU(self._wxapp, id, _PROMPTFORRECORD)
self.__eventMenuMapping['_promptForRecord_'] = id
! self.__addMenuItem(dataMenu, _("N&ew Record\tF12"),_('Create a new
record for data input.'),'requestNEWRECORD', form=form)
! self.__addMenuItem(dataMenu, _("Mark Record for &Delete\tF5"),_('Mark
record for removal at next commit.'),'requestMARKFORDELETE', form=form)
dataMenu.AppendSeparator()
! self.__addMenuItem(dataMenu, _("Next &Block\tPgDn"),_('Navigate to next
data block.'),'requestNEXTBLOCK', form=form)
! self.__addMenuItem(dataMenu, _("P&revious Block\tPgUp"),_('Navigate to
previous data block.'),'requestPREVBLOCK', form=form)
dataMenu.AppendSeparator()
! self.__addMenuItem(dataMenu, _("&Enter Query\tF8"),_('Switch to input
query mask mode.'),'requestENTERQUERY', form=form)
! self.__addMenuItem(dataMenu, _("Execute &Query\tF9"), _('Execute query
using current mask.'),'requestEXECQUERY', form=form)
helpMenu = wxMenu()
! self.__addMenuItem(helpMenu, _("&About..."), _('Display info about GNUe
Forms.'),'requestABOUT', form=form)
menuBar = wxMenuBar()
menuBar.Append( fileMenu, _("&File") )
***************
*** 391,398 ****
self.mainWindow.Show(true)
# Ensure splashscreen is on top
! if hasattr(self,'splash') and self.splash:
! self.splash.Raise()
#############################################################################
#
--- 321,328 ----
self.mainWindow.Show(true)
# Ensure splashscreen is on top
! #if hasattr(self,'splash') and self.splash:
! # self.splash.Raise()
#############################################################################
#
***************
*** 414,426 ****
#
# Internal helper function to add a menu item and an event
#
! def __addMenuItem(self, menu, text, help, event=None):
id = wxNewId()
menu.Append(id, text, help)
if event:
EVT_MENU(self._wxapp, id,
! lambda event, l=self, e=event: l.dispatchEvent(events.Event(e)))
self.__eventMenuMapping[event] = id
return id
--- 344,357 ----
#
# Internal helper function to add a menu item and an event
#
! def __addMenuItem(self, menu, text, help, event=None, form=None):
id = wxNewId()
menu.Append(id, text, help)
if event:
EVT_MENU(self._wxapp, id,
! lambda event, l=self, e=event, f=form:
l.dispatchEvent(events.Event(e,_form=f)))
self.__eventMenuMapping[event] = id
+
return id
***************
*** 590,600 ****
#
# Presents a dialog to user asking for the record number to jump to
#
! def promptForRecordNumber(self, event= None):
dlg = wxTextEntryDialog(self.mainWindow, _('Enter record number to jump
to'),
_('Which record?'))
if dlg.ShowModal() == wxID_OK:
! action = self.dispatchEvent('requestRECORDNUMBER', dlg.GetValue())
else:
action = None
--- 521,534 ----
#
# Presents a dialog to user asking for the record number to jump to
#
! def promptForRecordNumber(self, event=None):
dlg = wxTextEntryDialog(self.mainWindow, _('Enter record number to jump
to'),
_('Which record?'))
+
+ form =
_IdToGFObj[self.mainWindow.panel.GetId()].findParentOfType('GFForm')
+
if dlg.ShowModal() == wxID_OK:
! action = self.dispatchEvent('requestRECORDNUMBER', dlg.GetValue(),
_form=form)
else:
action = None
***************
*** 609,649 ****
# back an event closing the application
#`
def closeTrap(self,event):
! object = _eventObjTowxWindow(event)
if event.CanVeto():
! self.dispatchEvent('requestEXIT')
else:
object.Destroy()
!
! #
! # onCloseSplash
! #
! # Called by SplashScreen when timer expires
! #
! # If the splashscreen has timed out before the form is
! # ready then go ahead and display what we've got. This
! # is a desperate attempt to eliminate the vile
! #
! # Gdk-ERROR **: BadWindow (invalid Window parameter)
! # serial 1228 error_code 3 request_code 15 minor_code 0
! #
! # on heavily loaded machines. The key line seems to be
! # wxYield() but I'm leaving the others there because I
! # can :P The fix works for me all the way down to a
! # splash duration=1 millisecond
! #
! def onCloseSplash(self):
! self._wxapp.SetTopWindow(self.mainWindow)
! self.mainWindow.Show(true)
! wxYield() # Flush the pending queue to insure something is
! # there before the splashscreen dies
!
! # For some reason, a simple Close() doesn't cooperate with
! # the modal login box and all hell breaks loose
! self.splash.Show(0)
! self.splash.Destroy()
! self.splash = None
!
#############################################################################
#############################################################################
--- 543,556 ----
# back an event closing the application
#`
def closeTrap(self,event):
! form =
_IdToGFObj[self.mainWindow.panel.GetId()].findParentOfType('GFForm')
!
if event.CanVeto():
! self.dispatchEvent('requestEXIT',_form=form)
else:
+ object = _eventObjTowxWindow(event)
object.Destroy()
! # wxExit() TODO: Try and work this into navigator or here if it still
hangs
#############################################################################
#############################################################################
***************
*** 861,867 ****
_setDefaultEventHandlers(newWidget, event.eventHandler, event.initialize)
- ## print "page", newWidget,event.container, event.object
event.interface._pageList.append(newWidget)
return newWidget
--- 768,773 ----
***************
*** 905,912 ****
newWidget = wxCheckBox(event.container, -1, "",defaultPoint,
wxSize(2*event.textWidth,event.textHeight),
wxNO_BORDER)
! newWidget.SetValue(0)
! EVT_CHECKBOX(newWidget, newWidget.GetId(), self.checkboxHandler)
else: # Normal text box
if event.initialize:
--- 811,819 ----
newWidget = wxCheckBox(event.container, -1, "",defaultPoint,
wxSize(2*event.textWidth,event.textHeight),
wxNO_BORDER)
! if event.initialize:
! newWidget.SetValue(0)
! EVT_CHECKBOX(newWidget, newWidget.GetId(), self.checkboxHandler)
else: # Normal text box
if event.initialize:
***************
*** 934,940 ****
gfObject = _IdToGFObj[id]
eventdata = [gfObject, event.GetString()]
action = events.Event('requestREPLACEVALUE',object=gfObject,
! index=selection, text=event.GetString())
self._eventHandler(action)
def checkboxHandler(self,event):
--- 841,848 ----
gfObject = _IdToGFObj[id]
eventdata = [gfObject, event.GetString()]
action = events.Event('requestREPLACEVALUE',object=gfObject,
! index=selection, text=event.GetString(),
! _form=gfObject._form)
self._eventHandler(action)
def checkboxHandler(self,event):
***************
*** 944,950 ****
gfObject = _IdToGFObj[id]
eventdata = [gfObject, event.GetString()]
! action = events.Event('requestTOGGLECHKBOX')
self._eventHandler(action)
#
--- 852,858 ----
gfObject = _IdToGFObj[id]
eventdata = [gfObject, event.GetString()]
! action = events.Event('requestTOGGLECHKBOX', _form=gfObject._form)
self._eventHandler(action)
#
***************
*** 985,994 ****
def notebookTabHandler(self,event):
if event.GetEventType() == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING:
action = None
if self.__ui.__notebookLoopTrap == 0:
! action = events.Event('requestPAGE',event.GetSelection())
self.__ui.__notebookLoopTrap = 1
else:
self.__ui.__notebookLoopTrap = 0
--- 893,905 ----
def notebookTabHandler(self,event):
if event.GetEventType() == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING:
+ object = _IdToGFObj[_eventObjTowxWindow(event).GetId()]
+
+
action = None
if self.__ui.__notebookLoopTrap == 0:
! action = events.Event('requestPAGE',event.GetSelection(),
_form=object)
self.__ui.__notebookLoopTrap = 1
else:
self.__ui.__notebookLoopTrap = 0
***************
*** 1109,1116 ****
count = _IdToUIObj[id].widgets.index(screenWidget)
if event.GetTimestamp():
! self._eventProcessor('requestFOCUS',gfObject)
! self._eventProcessor('requestJUMPRECORD',count - gfObject._visibleIndex)
if isinstance(screenWidget,wxTextCtrl):
event.SetTimestamp(0)
--- 1020,1027 ----
count = _IdToUIObj[id].widgets.index(screenWidget)
if event.GetTimestamp():
! self._eventProcessor('requestFOCUS',gfObject,_form=_IdToUIObj[id]._form)
! self._eventProcessor('requestJUMPRECORD',count -
gfObject._visibleIndex,_form=_IdToUIObj[id]._form)
if isinstance(screenWidget,wxTextCtrl):
event.SetTimestamp(0)
***************
*** 1119,1125 ****
else:
textObject= wxPyTypeCast(object, 'wxTextCtrl')
cursorPosition = textObject.GetInsertionPoint()
! self._eventProcessor('requestCURSORMOVE',position=cursorPosition)
event.Skip()
--- 1030,1036 ----
else:
textObject= wxPyTypeCast(object, 'wxTextCtrl')
cursorPosition = textObject.GetInsertionPoint()
!
self._eventProcessor('requestCURSORMOVE',position=cursorPosition,_form=_IdToUIObj[id]._form)
event.Skip()
***************
*** 1205,1210 ****
--- 1116,1124 ----
pass
if action:
+ # Add the object's _form to the outgoing event
+ # rather than every event in the function
+ action.__dict__.update({'_form':object._form})
self._eventProcessor(action)
***************
*** 1216,1457 ****
'GFEntry' : UIEntry,
'GFButton' : UIButton,
'GFScrollBar' : UIScrollBar,
! }
!
!
! #####################################################################
! ##
! ## Login Support
! ##
! ## Everything below this point is in support of the wx drivers
! ## UILoginHandler
! ##
! #####################################################################
!
! #
! # UILoginHandler
! #
! class UILoginHandler(GLoginHandler.LoginHandler):
! def __init__(self):
! self._wxapp = getWxApp()
! self.dlg = None
!
! def getLogin(self, loginData, errortext=None):#"Invalid username/password"):
! if 1: # TODO: This is left here to prevent me from having to unindent
this code
! # TODO: Since the UI stuff is currently being gutted I'm not
wasting the time
! # TODO: to do the right thing
! if len(loginData[1]):
! loginMesg = _('Login required for\n"%s"') % (loginData[1])
! else:
! loginMesg = _('Login required for %s') % (loginData[0])
!
! self.dlg = wxDialog(NULL, -1, _("GNU Enterprise: Login to %s") %
loginData[0])
! self.dlg.SetAutoLayout(true)
!
! bmp = wxImage(images_dir+gConfigForms('smallPNG'),
wxBITMAP_TYPE_PNG).ConvertToBitmap()
!
! messageField = WrappedStaticText(self.dlg, -1, str(loginMesg), 300,
style=wxALIGN_CENTER)
!
! self.textctrlList = []
! labelList = []
!
! dlgWidth = max(bmp.GetWidth(), messageField.GetSize().GetWidth()+20)
!
! dlgHeight = bmp.GetHeight() + messageField.GetSize().GetHeight() + 80
!
! xSpacing = 0
! ySpacing = 0
! fieldLabelWidth = 0
!
! for prompt in loginData[2]:
! s = wxStaticText(self.dlg, -1, '%s:' % prompt[1])
! labelList.append(s)
! if prompt[2]:
! t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
! style=wxTE_PASSWORD|wxTE_PROCESS_ENTER)
! else:
! t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
! style=wxTE_PROCESS_ENTER)
!
! myID = len(self.textctrlList)
! 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() + 20)
!
! xSpacing = max(xSpacing, s.GetSize().GetWidth())
! ySpacing = max(ySpacing, s.GetSize().GetHeight())
! ySpacing = max(ySpacing, t.GetSize().GetHeight())
!
!
! loginId = wxNewId()
! cancelId = wxNewId()
!
! loginButton = wxButton(self.dlg,loginId,_('Login'))
! cancelButton = wxButton(self.dlg,cancelId,_('Cancel'))
!
! EVT_BUTTON(self.dlg, loginId, self.loginButtonEventTrap)
! EVT_BUTTON(self.dlg, cancelId, self.loginCancelEventTrap)
! dlgWidth = max(dlgWidth, loginButton.GetSize().GetWidth() +
! cancelButton.GetSize().GetWidth() + 6) + 20
!
! dlgHeight += max(loginButton.GetSize().GetHeight(),
! cancelButton.GetSize().GetHeight()) - 6
!
! if errortext:
! errorField = WrappedStaticText(self.dlg, -1, str(errortext), 300,
! style=wxALIGN_CENTER)
! errorField.SetForegroundColour(wxColour(223,0,0))
!
! dlgWidth = max(dlgWidth, errorField.GetSize().width+10)
! dlgHeight += errorField.GetSize().height + 6
!
!
! firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
! lastY = firstY
! xSpacing += 10 # Add whitespace between widgets
! ySpacing += 6 # Add whitespace between widgets
! xPos = dlgWidth/2 - fieldLabelWidth/2
!
!
! # Move the fields and labels into position
! for i in range(0, len(self.textctrlList)):
! dlgHeight = dlgHeight + ySpacing
! labelList[i].SetPosition(wxPoint(xPos, lastY))
! self.textctrlList[i].SetPosition(wxPoint(xPos + xSpacing, lastY))
! lastY = lastY + ySpacing
!
! if errortext:
! errorField.SetPosition(
! wxPoint(dlgWidth/2 - errorField.GetSize().width/2,
! lastY+3))
!
! # Set the focus to the first text entry field
! self.textctrlList[0].SetFocus()
!
! # Create and position the logo
! wxStaticBitmap(self.dlg,-1, bmp,
! wxPoint((dlgWidth-bmp.GetWidth())/2, 12),
! wxSize(bmp.GetWidth(), bmp.GetHeight()))
!
! # Move the various widgets into position
! messageField.SetPosition(
! wxPoint(dlgWidth/2 - messageField.GetSize().GetWidth()/2,
! 30 + bmp.GetHeight()))
!
! 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
!
! self.dlg.SetSize(wxSize(dlgWidth, dlgHeight))
!
! self.dlg.Refresh()
! self.dlg.Fit()
! self.dlg.Raise()
! self.dlg.CenterOnScreen()
!
! # If user cancels, this will be set to 0
! self._completed = 0
! self.dlg.ShowModal()
!
! if not self._completed:
! raise GLoginHandler.UserCanceledLogin
!
! rv = {}
! for i in range(0, len(loginData[2])):
! rv[loginData[2][i][0]] = self.textctrlList[i].GetValue()
!
! return rv
!
! #
! # Login is completed, for whatever reason
! #
! def loginCompleted(self, successful):
! self._completed = successful
! self.dlg.EndModal(1)
!
! #
! # Called when user clicks "login"
! #
! def loginButtonEventTrap(self, event):
! self.loginCompleted(1)
!
! #
! # Called when user clicks "cancel"
! #
! def loginCancelEventTrap(self, event):
! self.loginCompleted(0)
!
! #
! # TODO: This is a hack required because windows
! # TODO: seems to have issues with wxWindows dialogs
! #
! def destroyLoginDialog(self):
! self.dlg.Destroy()
!
! #
! # LoginFieldHandler
! #
! # 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()
!
!
!
! class WrappedStaticText(wxStaticText):
! def __init__(self, parent, id, label, width, *args, **params):
! wxStaticText.__init__(self, parent, id, "bah!", *args, **params)
!
!
! textSoFar = ""
! thisLine = ""
! for part in string.split(label,'\n'):
! for word in string.split(part):
! self.SetLabel(thisLine + word)
! if self.GetSize().width > width:
! textSoFar += thisLine + " \n"
! thisLine = word + " "
! else:
! thisLine += word + " "
!
! textSoFar += thisLine + " \n"
! thisLine = ""
!
! if len(textSoFar):
! self.SetLabel(string.replace(textSoFar,' \n','\n')[:-1])
! else:
! self.SetLabel("")
!
!
!
--- 1130,1133 ----
'GFEntry' : UIEntry,
'GFButton' : UIButton,
'GFScrollBar' : UIScrollBar,
! }
Index: gnue/forms/src/uidrivers/wx/__init__.py
diff -c gnue/forms/src/uidrivers/wx/__init__.py:1.1
gnue/forms/src/uidrivers/wx/__init__.py:1.2
*** gnue/forms/src/uidrivers/wx/__init__.py:1.1 Sun Feb 17 14:54:06 2002
--- gnue/forms/src/uidrivers/wx/__init__.py Sat Dec 21 14:29:55 2002
***************
*** 1 ****
--- 1,2 ----
from UIdriver import *
+ from UILoginHandler import *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue common/src/events/EventController.py desig...,
James Thompson <=