commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/gnuef TODO samples/trigger/trigger.gfd src...


From: James Thompson
Subject: gnue/gnuef TODO samples/trigger/trigger.gfd src...
Date: Thu, 11 Jan 2001 22:08:48 -0800

CVSROOT:        /cvs
Module name:    gnue
Changes by:     James Thompson <address@hidden> 01/01/11 22:08:48

Modified files:
        gnuef          : TODO 
        gnuef/samples/trigger: trigger.gfd 
        gnuef/src      : GFController.py GFForm.py GFObjects.py 
                         GFOptions.py GFTrigger.py UIwxpython.py 

Log message:
        Rewrote internal objects to be less dependent upon events (speed up)
        Added enhannced About box
        Added support for label alignemnts
        Hack for rollback errors (see comments for more info)
        Misc bug fixing and code cleanup
        Clean up

CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/TODO.diff?r1=1.35&r2=1.36
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/samples/trigger/trigger.gfd.diff?r1=1.4&r2=1.5
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFController.py.diff?r1=1.8&r2=1.9
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFForm.py.diff?r1=1.57&r2=1.58
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFObjects.py.diff?r1=1.50&r2=1.51
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFOptions.py.diff?r1=1.13&r2=1.14
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFTrigger.py.diff?r1=1.8&r2=1.9
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/UIwxpython.py.diff?r1=1.51&r2=1.52

Patches:
Index: gnue/gnuef/TODO
diff -u gnue/gnuef/TODO:1.35 gnue/gnuef/TODO:1.36
--- gnue/gnuef/TODO:1.35        Wed Jan 10 06:53:52 2001
+++ gnue/gnuef/TODO     Thu Jan 11 22:08:47 2001
@@ -1,6 +1,8 @@
 Tasks that someone is working on have the persons email and/or 
 name in []
 
+I've broken msgboxs in triggers
+
 **MUST HAVES for 0.1.0
 **  windows support (ODBC?) [jade]
 
@@ -76,30 +78,20 @@
 
     Make other datasources accessible from forms easily
 
-
   Nitpicks & bugs
     Dropdowns don't allow you to go to next|prev record via up and down arrows
     
-    Rollback on master/detail forms is screwed up
-
     Inital detail not kept up to date with top record
       (needs to update upon field update not record switch) 
 
     might not work on display's other than :0 (need to test)
 
-    Need to make About box two part.  First part has GNUe version, 
-      Info and copyright for forms itself.  Second part has the 
-      form version, info, copryight, author. as part of this 
-      an <author> needs to be supported in forms options.
-
     Tooltips dont show on smaller forms.  Status bar perhaps needs 
       less containers.  Also, eventually tool tips should display 
       if you mouse over the field.
 
     samples/geas/ needs table creation scripts or needs to instruct to
       build the tables from geas samples to work properly.
-
-    Make labels so you can align text and add width property.
 
     Add checkbox, button and memo box widgets.
    
Index: gnue/gnuef/samples/trigger/trigger.gfd
diff -u gnue/gnuef/samples/trigger/trigger.gfd:1.4 
gnue/gnuef/samples/trigger/trigger.gfd:1.5
--- gnue/gnuef/samples/trigger/trigger.gfd:1.4  Fri Dec 22 15:14:43 2000
+++ gnue/gnuef/samples/trigger/trigger.gfd      Thu Jan 11 22:08:48 2001
@@ -10,11 +10,12 @@
   <version>0.0.3</version>
   <height>8</height>
   <width>50</width>
+  <author>GNUE Enterprise Developers</author>
 </options>
 
   <page>
     <block name="block1">
-      <label text="Field One" x="1" y="1" />
+      <label text="Field One" x="1" y="1" width="48" alignment="center"/>
       <entry name="one" x="1" y="2" width="48"/>
       <label text="Field Two" x="1" y="3" />
       <entry name="two" x="1" y="4" width="48"/>
Index: gnue/gnuef/src/GFController.py
diff -u gnue/gnuef/src/GFController.py:1.8 gnue/gnuef/src/GFController.py:1.9
--- gnue/gnuef/src/GFController.py:1.8  Fri Dec 15 19:32:11 2000
+++ gnue/gnuef/src/GFController.py      Thu Jan 11 22:08:48 2001
@@ -25,7 +25,6 @@
 
     ui.registerEventListener(form.processEvent)
     form.registerEventListener(ui.processEvent)
-#    form.registerEventListener(self.processEvent)
 
 
 
Index: gnue/gnuef/src/GFForm.py
diff -u gnue/gnuef/src/GFForm.py:1.57 gnue/gnuef/src/GFForm.py:1.58
--- gnue/gnuef/src/GFForm.py:1.57       Mon Jan  8 17:55:10 2001
+++ gnue/gnuef/src/GFForm.py    Thu Jan 11 22:08:48 2001
@@ -54,11 +54,8 @@
                            'requestCOMMIT'     : self.executeCommit,
                            'requestROLLBACK'   : self.executeRollback,
                            'requestEXIT'       : self.executeExit,
+                           'requestABOUT'      : self.executeAbout,
 
-                           'recordSWITCHED'    : self.recordSwitched,
-                           'notifyMASTERSWITCH': self.notifyDetailBlocks,
-                           'updateUIENTRY'     : self.updateUIEntry,
-                           'msgBOX'            : self.msgBox
                            }
 
     self.databaseDictionary = {}
@@ -221,8 +218,8 @@
     self.updateRecordStatus()
     self.updatePageCounter()
 
-  def updateUIEntry(self,event):
-    self.dispatchEvent(GFEvent('updateENTRY',event.data));
+  def updateUIEntry(self,entry):
+    self.dispatchEvent(GFEvent('updateENTRY',entry));
 
   #
   # This routine is only used once in GFObjects
@@ -255,7 +252,7 @@
             return
     
     self.dispatchEvent(GFEvent('uiNEXTRECORD',self.currentEntry))
-    self.dispatchEvent(GFEvent('nextRECORD',self.currentBlock))
+    self.currentBlock.nextRecord()
     self.dispatchEvent(GFEvent('gotoENTRY',self.currentEntry));
     self.updateRecordCounter()
     self.updateRecordStatus()
@@ -270,14 +267,14 @@
             message.show()
             return
     self.dispatchEvent(GFEvent('uiPREVRECORD',self.currentEntry))
-    self.dispatchEvent(GFEvent('prevRECORD',self.currentBlock))
+    self.currentBlock.prevRecord()
     self.dispatchEvent(GFEvent('gotoENTRY',self.currentEntry));
     self.updateRecordCounter()
     self.updateRecordStatus()
 
   def newRecord(self, event):
     if not hasattr(self,'readonly'):
-      self.dispatchEvent(GFEvent('newRECORD',self.currentBlock))
+      self.currentBlock.newRecord()
       self.updateRecordStatus()
       self.updateRecordCounter()
     else:
@@ -285,7 +282,7 @@
 
   def deleteRecord(self, event):
     if not hasattr(self,'readonly'):
-      self.dispatchEvent(GFEvent('deleteRECORD',self.currentBlock))
+      self.currentBlock.deleteRecord()
       self.updateRecordStatus()
     else:
       self.dispatchEvent(GFEvent('formALERT','Form is readonly'))
@@ -293,11 +290,12 @@
   def executeExit(self, event):
     for block in self.blockList:
       if not block.isSaved():
+        GFDebug.printMesg(0,"%s is not saved" % block.name)
         message = GFMsgBox(self, GFOptions._msgNOTSAVED)
        message.show()
         return
-    else:
-      self.dispatchEvent(GFEvent('exitApplication','Current data is saved'))
+      else:
+        self.dispatchEvent(GFEvent('exitApplication','Current data is saved'))
 
   def requestQuery(self, event):
     if hasattr(self.currentBlock,"master"):
@@ -310,31 +308,49 @@
        message.show()
         return
       
-    self.dispatchEvent(GFEvent('initQUERY',self.currentBlock))
+    self.currentBlock.initQuery()
+      
     self.updateStatus()
     
   def executeQuery(self, event):
-    self.dispatchEvent(GFEvent('processQUERY',self.currentBlock))
+    self.currentBlock.processQuery()
     self.updateStatus()
 
   def executeCommit(self, event):
     if not hasattr(self,'readonly'):
-      self.dispatchEvent(GFEvent('processCOMMIT',self.currentBlock))
+      for block in self.blockList:
+        self.currentBlock.processCommit()
       self.updateRecordStatus()
       self.updateRecordCounter()
     else:
       self.dispatchEvent(GFEvent('formALERT','Form is readonly'))
 
+  def executeAbout(self,event):
+     version = GFOptions.VERSION
+     name = hasattr(self,"title") and self.title or "Unknown"
+     formversion = hasattr(self,"version") and self.version or "Unknown"
+     author = hasattr(self,"author") and self.author or "Unknown"
+     description = hasattr(self,"description") and self.description or 
"Unknown"
+     
+     
self.dispatchEvent(GFEvent('uiABOUT',[version,name,formversion,author,description]))
+
   def executeRollback(self,event):
-    self.dispatchEvent(GFEvent('processROLLBACK',self.currentBlock))
+    for block in self.blockList:
+      block.processRollback();
     self.updateRecordStatus()
     self.updateRecordCounter()
     
-  def recordSwitched(self, event):
-    self.dispatchEvent(GFEvent('updateENTRY',event.data))
+  def recordSwitched(self, entry):
+    if entry.block.mode == 'normal':
+      # update the details
+      #
+      # This should be redone so that master blocks have detailBlocks register 
w/ them
+      # then the blocks updateDetail() could be simpler as only blocks that 
need the
+      # update get it
+      for block in self.blockList:
+        block.updateDetail(entry.block) 
 
-  def notifyDetailBlocks(self, event):
-    self.dispatchEvent(GFEvent('updateDETAILBLOCK',event.data))
+    self.dispatchEvent(GFEvent('updateENTRY',entry))
 
   #
   # nextEntry
@@ -439,9 +455,9 @@
       if keepNext == 1:
         nextBlock = object
         break
-
-    
self.currentBlock.dispatchEvent(GFEvent('switchRECORD',[self.currentBlock.currentRecord,self.currentBlock.currentRecord]))
 
+    
#self.currentBlock.dispatchEvent(GFEvent('switchRECORD',[self.currentBlock.currentRecord,self.currentBlock.currentRecord]))
+    
self.currentBlock.switchRecord(self.currentBlock.currentRecord,self.currentBlock.currentRecord)
     self.currentBlock.processTrigger('Pre-FocusOut')
     self.currentBlock.processTrigger('Post-FocusOut')
     nextBlock.processTrigger('Pre-FocusIn')
@@ -477,7 +493,8 @@
       
       nextBlock = object
 
-    
self.currentBlock.dispatchEvent(GFEvent('switchRECORD',[self.currentBlock.currentRecord,self.currentBlock.currentRecord]))
+    
#self.currentBlock.dispatchEvent(GFEvent('switchRECORD',[self.currentBlock.currentRecord,self.currentBlock.currentRecord]))
+    
self.currentBlock.switchRecord(self.currentBlock.currentRecord,self.currentBlock.currentRecord)
 
     self.currentBlock.processTrigger('Pre-FocusOut')
     self.currentBlock.processTrigger('Post-FocusOut')
@@ -595,8 +612,6 @@
       self.dispatchEvent(GFEvent('formALERT','Field is readonly'))
 
 
-  def msgBox(self, event):
-    self.dispatchEvent( GFEvent('msgBoxUI', event.data))
 
 
 
Index: gnue/gnuef/src/GFObjects.py
diff -u gnue/gnuef/src/GFObjects.py:1.50 gnue/gnuef/src/GFObjects.py:1.51
--- gnue/gnuef/src/GFObjects.py:1.50    Mon Jan  8 17:55:10 2001
+++ gnue/gnuef/src/GFObjects.py Thu Jan 11 22:08:48 2001
@@ -13,6 +13,7 @@
 #
 
 from GFEvent import *
+from GFTrigger import *
 from DBfactory import DBfactory
 import GFOptions
 import GFDebug
@@ -22,34 +23,34 @@
 TRUE = 1
 FALSE = 0
 
-#
-#!!Hack warning!!, have moved GFTriggerAware into this file
-#to prevent circular depenancies until a better solution
-#can be found
-#
-class GFTriggerAware:
-  def __init__(self):
-      self.trigger = {}
-
-      self.validTriggers = [ 'Pre-FocusOut',
-                             'Post-FocusOut',
-                             'Pre-FocusIn',
-                             'Post-FocusIn']
-
-  def addTrigger(self, key, function):
-    if not self.trigger.has_key(key):
-      self.trigger[key] = []
-    self.trigger[key].append(function)
-    
-  def processTrigger(self, key):
-    if self.validTriggers.count(key):
-      if self.trigger.has_key(key):
-        for function in self.trigger[key]:
-          function(self)
-      else:
-        GFDebug.printMesg(10, "No triggers to fire")
-    else:
-      print "Invalid trigger ",key
+###
+###!!Hack warning!!, have moved GFTriggerAware into this file
+###to prevent circular depenancies until a better solution
+###can be found
+###
+##class GFTriggerAware:
+##  def __init__(self):
+##      self.trigger = {}
+
+##      self.validTriggers = [ 'Pre-FocusOut',
+##                             'Post-FocusOut',
+##                             'Pre-FocusIn',
+##                             'Post-FocusIn']
+
+##  def addTrigger(self, key, function):
+##    if not self.trigger.has_key(key):
+##      self.trigger[key] = []
+##    self.trigger[key].append(function)
+    
+##  def processTrigger(self, key):
+##    if self.validTriggers.count(key):
+##      if self.trigger.has_key(key):
+##        for function in self.trigger[key]:
+##          function(self)
+##      else:
+##        GFDebug.printMesg(10, "No triggers to fire")
+##    else:
+##      print "Invalid trigger ",key
 
 #
 # Class GFObj
@@ -127,6 +128,8 @@
   def __init__(self, parent=None, value=None):
     GFValue.__init__(self, parent, value)
     self.type = "GFLabel"
+    self.alignment = "left"
+    self.height = GFOptions.widgetHeight
 
   def setValue(self, value):
     if not self.value:
@@ -135,10 +138,6 @@
 ############################################################
 # GFBlock
 #
-# This object handles events from GFEntry widgets but doesn't
-# need to register with them as the Events find the blocks
-# they are a part of and register for them.  This is probably
-# a bad idea.....ah, who cares we'll do it anyway :)
 #
 class GFBlock(GFObj, GFEventAware):
   def __init__(self, parent=None):
@@ -155,22 +154,11 @@
     self.recordCount = 0
 
     # Event processing
-    self.incommingEvent = {'newRECORD'     : self.newRecord,
-                           'deleteRECORD'  : self.deleteRecord,
-                           'nextRECORD'    : self.switchRecord,
-                           'prevRECORD'    : self.switchRecord,
-                           'recordSWITCHED': self.recordSwitched,
-                           'initQUERY'     : self.processQuery,
-                           'processQUERY'  : self.processQuery,
-                           'processCOMMIT' : self.processCommit,
-                           'processROLLBACK': self.processRollback,
-                           'updateDETAILBLOCK'  : self.updateDetail,
-                           'valueUPDATE'  : self.updateEntry,
-                           'msgBox'       : self.msgBox
+    self.incommingEvent = {                           
                            }
     
     # register to recieve events from it's parent GFForm
-    self.form.registerEventListener(self.processEvent)
+    # self.form.registerEventListener(self.processEvent)
 
     # register the form to recieve events from the block
     self.registerEventListener(self.form.processEvent)
@@ -191,74 +179,61 @@
   def isSaved(self):
     return self.dataSourceLink.isSaved()
   
-  def updateEntry(self, event):
-    self.dispatchEvent(GFEvent('updateUIENTRY',event.data))
-
-  def msgBox(self, event):
-    self.dispatchEvent(GFEvent('msgBOX', event.data))
-             
   #
   # deleteRecord
   #
-  def deleteRecord(self,event):
-    if event.data == self:
-      self.dataSourceLink.markForRemoval(self.currentRecord)
+  def deleteRecord(self):
+    self.dataSourceLink.markForRemoval(self.currentRecord)
 
   #
   # Adds a record to the current records in memory
   #
-  def newRecord(self, event):
-    if event.data == self:
-      self.dataSourceLink.new()
-      self.recordCount = self.dataSourceLink.getLastRecordNumber()
+  def newRecord(self):
+    self.dataSourceLink.new()
+    self.recordCount = self.dataSourceLink.getLastRecordNumber()
 
-      if hasattr(self,"master"):
-        masterBlock,masterField = string.split(self.master,'.')
-        fieldValue = str(self.form.findValue(masterBlock, masterField))
-        if len(fieldValue) > 0:
-          
self.dataSourceLink.setField(self.recordCount,self.detail,fieldValue,TRUE)
+    if hasattr(self,"master"):
+      masterBlock,masterField = string.split(self.master,'.')
+      fieldValue = str(self.form.findValue(masterBlock, masterField))
+      if len(fieldValue) > 0:
+        
self.dataSourceLink.setField(self.recordCount,self.detail,fieldValue,TRUE)
       
-      oldRecord = self.currentRecord
-      self.currentRecord = 0
-      
self.dispatchEvent(GFEvent('switchRECORD',[oldRecord,self.currentRecord]));
-      self.dispatchEvent(GFEvent('requestPREVRECORD',None))
+    oldRecord = self.currentRecord
+    self.currentRecord = 0
+    self.switchRecord(oldRecord,self.currentRecord)
+    
+    self.dispatchEvent(GFEvent('requestPREVRECORD',None))
 
   #
   # Moves the proper record into editing position
   #
-  def switchRecord(self, event):
-    if event.data == self:
-      if event.getEvent() == 'prevRECORD':
-        adjustment = -1
-      else:
-        adjustment = 1
 
-      oldRecord = self.currentRecord
-      self.currentRecord = self.currentRecord + adjustment
-        
-      if self.currentRecord < 0 : self.currentRecord = self.recordCount
-      if self.currentRecord > self.recordCount : self.currentRecord = 0
-        
-      
self.dispatchEvent(GFEvent('switchRECORD',[oldRecord,self.currentRecord]));
-      
-  #
-  # recordSwitched
-  #
-  def recordSwitched(self, event):
-    GFDebug.printMesg( 1, "%s just switched records"%event.data)
-    if self.mode == 'normal':
-      self.dispatchEvent(GFEvent('notifyMASTERSWITCH',self))
-    self.dispatchEvent(GFEvent('recordSWITCHED',event.data))
 
+  def switchRecord(self, oldRecord, newRecord):
+    for entry in self.entryList:
+      entry.switchRecord(oldRecord,self.currentRecord)
+
+  def nextRecord(self):
+    oldRecord = self.currentRecord
+    self.currentRecord = self.currentRecord + 1
+    if self.currentRecord > self.recordCount : self.currentRecord = 0
+    self.switchRecord(oldRecord,self.currentRecord)
+
+  def prevRecord(self):
+    oldRecord = self.currentRecord
+    self.currentRecord = self.currentRecord - 1
+    if self.currentRecord < 0 : self.currentRecord = self.recordCount    
+    self.switchRecord(oldRecord,self.currentRecord)
+      
   #
   # processCommit
   #
-  def processCommit(self, event):
+  def processCommit(self):
     GFDebug.printMesg(1, "processing commit")
     self.mode='commit'
 
-    
self.dispatchEvent(GFEvent('switchRECORD',[self.currentRecord,self.currentRecord]));
-
+    self.switchRecord(self.currentRecord,self.currentRecord)
+    
     # if this is a detail and the key isn't filled from master block then fill 
it
     if hasattr(self,"master"):
       masterBlock,masterField = string.split(self.master,'.')
@@ -274,7 +249,7 @@
     self.currentRecord = 0
 
     # Switch to first record
-    self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
+    self.switchRecord(-1,0)
     self.dispatchEvent(GFEvent('requestPREVRECORD',None))
     self.dispatchEvent(GFEvent('requestNEXTRECORD',None))
     self.mode='normal'
@@ -282,58 +257,64 @@
   #
   # processRollback
   #
-  def processRollback(self,event):
+  def processRollback(self):
     self.currentRecord = 0
     self.recordCount = 0
     self.dataSourceLink.clear()
-    self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
+#    print "Saved?", self.dataSourceLink.isSaved()
+    self.switchRecord(-1,0)
+
     self.dispatchEvent(GFEvent('requestPREVRECORD',None))
     self.dispatchEvent(GFEvent('requestNEXTRECORD',None))
 
+#    print "Still Saved?", self.dataSourceLink.isSaved()
+
   #
   # processQuery
   #
-  def processQuery(self, event):
-    if event.data == self:
-      eventType = event.getEvent()
-      if eventType == 'initQUERY':
-        if self.mode != 'query':
-          self.mode = 'query'
-        else:
-          self.mode = 'normal'
-        self.processRollback(None) 
-      elif eventType == 'processQUERY':
-        # Implement sloppyFocus system 
-        for entry in self.entryList:
-          if hasattr(entry,'sloppyQuery'):
-            newValue = '%'
-            value = entry.value
-            for letter in value:
-              if letter != "%":
-                newValue=newValue+letter+"%"
-            entry.setValue(newValue)
+  def initQuery(self):
+    if self.mode != 'query':
+      self.mode = 'query'
+    else:
+      self.mode = 'normal'
+      
+    self.processRollback() 
+    
+  def processQuery(self):
+    # Implement sloppyFocus system 
+    if self.mode == 'query':
+      for entry in self.entryList:
+        if hasattr(entry,'sloppyQuery'):
+          newValue = '%'
+          value = entry.value
+          for letter in value:
+            if letter != "%":
+              newValue=newValue+letter+"%"
+          entry.setValue(newValue)
           
-        if self.mode == 'query':
-          self.mode = 'normal'
-          self.dispatchEvent(GFEvent('switchRECORD',[0,0]));
-          self.dataSourceLink.query()
-          self.recordCount = self.dataSourceLink.getLastRecordNumber()
-          if self.recordCount < 0:
-            self.dataSourceLink.clear()
-            self.recordCount = self.dataSourceLink.getLastRecordNumber()
-            #self.recordCount = 
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
+      self.mode = 'normal'
+      self.switchRecord(0,0)
+
+      self.dataSourceLink.query()
+      
+      self.recordCount = self.dataSourceLink.getLastRecordNumber()
+      if self.recordCount < 0:
+        self.dataSourceLink.clear()
+        self.recordCount = self.dataSourceLink.getLastRecordNumber()
                             
-          self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
-          self.currentRecord = 0
+      self.switchRecord(-1,0)
+      self.currentRecord = 0
 
   #
   # updateDetail - makes block check to see if it needs to update itself
   # if so it forces the update automagically
+  #
+  # 
   # 
-  def updateDetail(self,event):
+  def updateDetail(self,originatingBlock):
     if hasattr(self,'master'):
       masterBlock,masterField = string.split(self.master,'.')
-      if masterBlock == event.data.name:
+      if masterBlock == originatingBlock.name:
         fieldValue = str(self.form.findValue(masterBlock, masterField))
         self.dataSourceLink.clear()
         if len(fieldValue) > 0:
@@ -346,42 +327,31 @@
 
         self.recordCount = self.dataSourceLink.getLastRecordNumber()
         GFDebug.printMesg( 3, "We now have %s records in memory" % 
self.recordCount )
-        self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
-        self.currentRecord = 0      
+        self.switchRecord(-1,0)
+        
+        self.currentRecord = 0
 
 ############################################################
 # GFEntry
 #
 # Matches the Entry form tag in the gfd
 #
-# It expects to recieve events from it's
-# parent GFBlock that tell it when to switch
-# which record it is currently editing and when
-# to create new Records
-#
 # It send events to its parent GFBlock
 #
-class GFEntry(GFValue, GFEventAware):
+#class GFEntry(GFValue, GFEventAware):
+class GFEntry(GFValue):
   def __init__(self, parent=None, value=None):
     GFValue.__init__(self, parent, value)
-    GFEventAware.__init__(self)    
+#    GFEventAware.__init__(self) 
     self.type = "GFEntry"
 
     self.value=""
     self.cursorPosition = len(self.value)
-
     self.height = GFOptions.widgetHeight
-
-    # Event processing
-    self.incommingEvent = {'switchRECORD': self.switchRecord
-                           }
-    
-    # register to recieve events from it's parent GFBlock
     self.block = self.findParentOfType('GFBlock')
-    self.block.registerEventListener(self.processEvent)
 
-    #register the block to recieve events from the entry
-    self.registerEventListener(self.block.processEvent)
+#    #register the block to recieve events from the entry
+#    self.registerEventListener(self.block.processEvent)
 
   def initialize(self):
     if not hasattr(self,'field'):
@@ -396,20 +366,19 @@
 
   def setValue(self, value):
     self.value = value
-    self.dispatchEvent(GFEvent('valueUPDATE',self))
+    self.block.form.updateUIEntry(self)
 
   #
   # switchRecord
   #
-  def switchRecord(self, event):
-    GFDebug.printMesg(2, "Switching to record %s from record %s" % 
(event.data[1] , event.data[0]))
+  def switchRecord(self, oldRecord, newRecord):
+    GFDebug.printMesg(2, "Switching to record %s from record %s" % (oldRecord, 
newRecord))
 
-    if event.data[0] >= 0:
-      self.block.dataSourceLink.setField(event.data[0],self.field,self.value)
-    
-    self.value = self.block.dataSourceLink.getField(event.data[1],self.field)
+    if oldRecord >= 0:
+      self.block.dataSourceLink.setField(oldRecord,self.field,self.value)
+    self.value = self.block.dataSourceLink.getField(newRecord,self.field)
     self.cursorPosition = len(self.value)
-    self.dispatchEvent(GFEvent('recordSWITCHED',self));
+    self.block.form.recordSwitched(self)
 
   #
   # verifyValue
@@ -426,6 +395,7 @@
           value = 1
           break        
     return value
+
   #
   # allowedValues
   #
@@ -496,6 +466,7 @@
     newentry = {}
     for key in self.emptyRecord.keys():
       newentry[key] = self.emptyRecord[key]
+      
     self.resultSet.append(newentry)
     self.resultSetStatus.append('saved')
     
@@ -524,6 +495,7 @@
         self.order_by = None
         
       self.resultSet = self.dataConnection.query(self.table, len(mask) and 
mask or None, self.order_by)
+      # Hack : need to verify below line doesn't need +1
       for count in range(len(self.resultSet)):
         self.resultSetStatus.append('saved')
       
@@ -628,8 +600,13 @@
     if len(self.resultSet) > recordNumber:
       if len(value) == 0:
         value = None
-        
-      if self.resultSet[recordNumber][fieldName] != value:
+
+
+      # Hack warning - the value != None is catching an error in the code
+      # where none is being stored for some reason in widgets.  Need to fix in 
proper
+      # place.  Without this hack the rollback doesn't work properly and the 
current
+      # block is never in a state of Saved after a rollback
+      if self.resultSet[recordNumber][fieldName] != value and value != None:
         self.resultSet[recordNumber][fieldName] = value
         if not internalCall: 
           self.resultSetStatus[recordNumber] = 'modified'
@@ -720,7 +697,7 @@
     self.parent = parent
 
   def show(self):
-    self.parent.dispatchEvent( GFEvent( 'msgBox', self) )
+    self.parent.dispatchEvent( GFEvent( 'msgBoxUI', self) )
 
 
 
Index: gnue/gnuef/src/GFOptions.py
diff -u gnue/gnuef/src/GFOptions.py:1.13 gnue/gnuef/src/GFOptions.py:1.14
--- gnue/gnuef/src/GFOptions.py:1.13    Mon Jan  8 17:55:10 2001
+++ gnue/gnuef/src/GFOptions.py Thu Jan 11 22:08:48 2001
@@ -12,6 +12,7 @@
 smallBMP=prefix+"/shared/gnue.bmp"
 
 
+
 # Might need altered but I doubt it
 widgetHeight=1  # The default height of widgets for widgets that don't specify 
height in .gfd file
 widgetWidth =10 # The default width of widgets for widgets that don't specify 
width in .gfd file
@@ -28,3 +29,6 @@
 # Fudge factor for altering widget size - should no longer be needed
 borderPercentage = 100
 textPercentage = 100
+
+# Version
+VERSION = "0.0.5"
Index: gnue/gnuef/src/GFTrigger.py
diff -u gnue/gnuef/src/GFTrigger.py:1.8 gnue/gnuef/src/GFTrigger.py:1.9
--- gnue/gnuef/src/GFTrigger.py:1.8     Fri Dec 15 19:32:11 2000
+++ gnue/gnuef/src/GFTrigger.py Thu Jan 11 22:08:48 2001
@@ -11,6 +11,7 @@
 # Copyright (c) 2000 Free Software Foundation
 #
 
+import sys
 import GFOptions
 from GFObjects import *
 from GFEvent import *
@@ -21,13 +22,47 @@
 #until to prevent circular dependencies until a better solution
 #can be found.
 #
+class GFTriggerAware:
+  def __init__(self):
+    self.trigger = {}
 
+    self.validTriggers = [ 'Pre-FocusOut',
+                           'Post-FocusOut',
+                           'Pre-FocusIn',
+                           'Post-FocusIn']
+
+
+
+  def addTrigger(self, key, function):
+    if not self.trigger.has_key(key):
+      self.trigger[key] = []
+    self.trigger[key].append(function)
+
+  def processTrigger(self, key):
+    if self.validTriggers.count(key):
+      if self.trigger.has_key(key):
+        for function in self.trigger[key]:
+          function(self)
+      else:
+        GFDebug.printMesg(10, "No triggers to fire")
+    else:
+      print "Invalid trigger ",key
+                                                        
 #
 # Class used to implement triggers
 #
-class GFTrigger(GFObj):
+##class GFTrigger(GFObj):
+class GFTrigger(GFEventAware):
   def __init__(self, parent=None, tr_type=None, id=None, src=None):
-    GFObj.__init__(self, parent)
+    GFEventAware.__init__(self)
+    
+##    GFObj.__init__(self, parent)
+    self.parent = parent
+    self.children = []
+    self.attributes = {}
+    if parent :
+      parent.addChild(self)
+    
     self.type = "GFTrigger"
     self.text=''
     self.language=''
@@ -78,6 +113,33 @@
       
   def dummyFunction(self, myself):
     print "Trigger not implemented"
+
+
+  #
+  # These may not all be needed but were copied from the GFObj object
+  # so that GFTrigger wouldn't have to inherit from it.  This removed the 
circular
+  # dependency that had made us move GFTriggerAware into GFObjects.
+
+  def getObjectType(self):
+    return self.type
+  
+  def addChild(self, child):
+    self.children.append(child)
+    
+  def walk(self, function):
+    function(self)
+    if self.children:
+      for child in self.children:
+        child.walk(function)
+
+  def findParentOfType(self,type):
+    parentObject = self
+    while (parentObject.getObjectType() != type):
+      parentObject = parentObject.parent
+      
+    return parentObject
+
+                                              
     
 #
 # Helper class for building the namespace for python triggers. All access
Index: gnue/gnuef/src/UIwxpython.py
diff -u gnue/gnuef/src/UIwxpython.py:1.51 gnue/gnuef/src/UIwxpython.py:1.52
--- gnue/gnuef/src/UIwxpython.py:1.51   Mon Jan  8 17:55:10 2001
+++ gnue/gnuef/src/UIwxpython.py        Thu Jan 11 22:08:48 2001
@@ -46,6 +46,7 @@
                            'uiNEXTRECORD' : self.adjustMultiView,
                            'uiPREVRECORD' : self.adjustMultiView,
                            'uiUPDATESTATUS': self.updateStatus,
+                           'uiABOUT': self.aboutBox,
                            'exitApplication': self.exitApplication
                           })
     
@@ -56,7 +57,8 @@
 ##                                       
(int(object.y)+spacer)*int(self.charHeight*self.borderPercentage)),
 ##                                wxDefaultSize)"""
 ##                             }
-    
+
+    self.widgetConstructorFunction['GFLabel'] = self.labelHandler
     self.widgetConstructor = {
                               'GFLabel':
                               """wxStaticText(container, -1, str(object.text),
@@ -405,6 +407,52 @@
 
     return widget
 
+  def labelHandler(self):
+    object    = self.currentObject[0]
+    container = self.currentWidget[0]
+    widget = []
+
+    if not hasattr(object,'hidden'):
+      if not hasattr(object,'visibleCount'):
+        object.visibleCount = 1
+      
+      count = int(object.visibleCount)
+
+      style = wxALIGN_LEFT|wxST_NO_AUTORESIZE
+
+      if hasattr(object,'alignment'):
+        if object.alignment == 'center':
+          print "I'm a center"
+          style = wxALIGN_CENTRE|wxST_NO_AUTORESIZE
+        elif object.alignment == 'right':
+          style = wxALIGN_RIGHT|wxST_NO_AUTORESIZE
+
+      if hasattr(object,'width'):
+        size = wxSize(int(object.width)*int(self.textWidth),
+                      int(object.height)*int(self.textHeight))
+      else:
+        size = wxDefaultSize
+
+      print style
+
+      for spacer in range(count):
+        spacer = int(spacer)        
+        newWidget = wxStaticText(container, -1, str(object.text),
+                                 wxPoint(int(object.x)*int(self.widgetWidth),
+                                         
(int(object.y)+spacer)*int(self.widgetHeight)),
+                                 size, style)
+        
+        #eval(self.widgetConstructor[object.getObjectType()])
+       
newWidget.SetFont(wxFont(GFOptions.pointSize,wxMODERN,wxNORMAL,wxNORMAL))
+
+        widget.append(newWidget)
+        EVT_CHAR(newWidget, self.uiEventTrap)
+        EVT_MOUSE_EVENTS(newWidget, self.uiEventTrap)
+
+    return widget
+    
+                                                                               
                                                                
+
   def pageHandler(self):
     object    = self.currentObject[0]
     container = self.currentWidget[0]
@@ -487,8 +535,8 @@
     
     helpMenu = wxMenu()
     helpMenu.Append( 300, "&About...", "Display info about gnuef" )
-    EVT_MENU(self, 300, self.OnAbout)
-#    EVT_MENU(self, 300, self.getLogin)
+    EVT_MENU(self, 300, lambda event, l=self: 
l.dispatchEvent(GFEvent('requestABOUT')))
+#    EVT_MENU(self, 300, self.OnAbout)
 
 
     menuBar = wxMenuBar()
@@ -500,7 +548,6 @@
     
     self.frame.panel = wxPanel(self.frame,-1, 
wxDefaultPosition,self.frame.GetSize())
     self.frame.SetTitle(str(self.form.title))
-#    self.frame.Show(true)
     EVT_CHAR(self.frame.panel, self.uiEventTrap)
 
     self.currentWidget = [self.frame.panel]
@@ -519,17 +566,29 @@
     else:
       object.Destroy()
       
-  def OnAbout(self, event):
-    dlg = wxMessageDialog(self.frame, "GNUE Forms : UIwxpython Driver\n"
-                          "Version 0.0.1"
-                          "\n"
-                          "Quick Ref:\n"
-                          "  F5: Mark record for delete at next commit\n"
-                          "  F6: Commit Changes\n"
-                          "  F8: Enter query mode|Abort query mode\n"
-                          "  F9: Execute query with current mask\n"
-                          " F12: Add new record\n",
-                          "About Me", wxOK | wxICON_INFORMATION)
+  def aboutBox(self, event):
+    programVersion = event.data[0]
+    formName = event.data[1]
+    formVersion = event.data[2]
+    author = event.data[3]
+    description = event.data[4]
+
+    dlg = wxMessageDialog(self.frame,
+                          "GNUE Forms\n"
+                          "  Version : %s\n"
+                          "  Driver  : UIwxpython\n"
+                          "-= Form Info =-\n"
+                          "  Name   : %s\n"
+                          "  Version: %s\n"
+                          "  Author : %s\n"
+                          "  Description: %s\n" 
+                          "-= Quick Reference =-\n"
+                          "  F5 : Mark record for delete at next commit\n"
+                          "  F6 : Commit Changes\n"
+                          "  F8 : Enter query mode|Abort query mode\n"
+                          "  F9 : Execute query with current mask\n"
+                          "  F12: Add new record\n" % (programVersion, 
formName ,formVersion,author,description),
+                          "About", wxOK | wxICON_INFORMATION)
     dlg.ShowModal()
     dlg.Destroy()
 
@@ -551,7 +610,8 @@
 
   def exitApplication(self,event):
     self.frame.Close(true)
-              
+
+
   def entryHandler(self):
     object    = self.currentObject[0]
     container = self.currentWidget[0]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]