commit-gnue
[Top][All Lists]
Advanced

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

gnue/forms/src GFForm.py


From: Jason Cater
Subject: gnue/forms/src GFForm.py
Date: Thu, 03 Jan 2002 19:35:39 -0500

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/01/03 19:35:39

Modified files:
        forms/src      : GFForm.py 

Log message:
        changes to forms for input mask; misc code cleanup/documentation

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/forms/src/GFForm.py.diff?cvsroot=OldCVS&tr1=1.135&tr2=1.136&r1=text&r2=text

Patches:
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.135 gnue/forms/src/GFForm.py:1.136
*** gnue/forms/src/GFForm.py:1.135      Tue Jan  1 13:32:42 2002
--- gnue/forms/src/GFForm.py    Thu Jan  3 19:35:39 2002
***************
*** 381,387 ****
       formversion = self.getOption('version') or "Unknown"
       author = self.getOption('author') or "Unknown"
       description = self.getOption('description') or "Unknown"
!      
       
self.dispatchEvent(GFEvent('uiABOUT',[version,name,formversion,author,description]))
  
    def rollback(self, recover=0):
--- 381,387 ----
       formversion = self.getOption('version') or "Unknown"
       author = self.getOption('author') or "Unknown"
       description = self.getOption('description') or "Unknown"
! 
       
self.dispatchEvent(GFEvent('uiABOUT',[version,name,formversion,author,description]))
  
    def rollback(self, recover=0):
***************
*** 418,424 ****
      except TriggerError, t:
        message = self.TriggerErrorFunc(t)
      return message
!                         
    #
    # moveCursor
    #
--- 418,424 ----
      except TriggerError, t:
        message = self.TriggerErrorFunc(t)
      return message
! 
    #
    # moveCursor
    #
***************
*** 427,441 ****
    # moved to a new location
    #
    def moveCursor(self, position):
!     if position == 'end':
!       self._currentEntry._cursorPosition = 
len(self._currentEntry.getDisplay(hasFocus=1))
!     elif position == 'home':
!       self._currentEntry._cursorPosition = 0
!     elif position == 'left' and self._currentEntry._cursorPosition > 0:
!         self._currentEntry._cursorPosition = 
self._currentEntry._cursorPosition - 1
!     elif position == 'right':
!       if self._currentEntry._cursorPosition < 
len(self._currentEntry.getDisplay(hasFocus=1)):
!         self._currentEntry._cursorPosition= 
self._currentEntry._cursorPosition + 1
  
    def replaceValue(self,object, value):
      replacement = ""
--- 427,469 ----
    # moved to a new location
    #
    def moveCursor(self, position):
! 
!     # If an input mask handler is being used, we
!     # need to use its logic to move the cursor.
! 
!     if not self._currentEntry._maskHandler:
! 
!       # use default logic
! 
!       if position == 'end':
!         self._currentEntry._cursorPosition = \
!           len(self._currentEntry.getDisplay(hasFocus=1))
!       elif position == 'home':
!         self._currentEntry._cursorPosition = 0
!       elif position == 'left' and self._currentEntry._cursorPosition > 0:
!         self._currentEntry._cursorPosition -= 1
!       elif ( position == 'right' ) and \
!            ( self._currentEntry._cursorPosition < \
!              len(self._currentEntry.getDisplay(hasFocus=1)) ):
!         self._currentEntry._cursorPosition += 1
! 
!     else:
! 
!       # use mask handler's logic
! 
!       if position == 'end':
!         self._currentEntry._cursorPosition = \
!            self._currentEntry._maskHandler.moveCursorToEnd()
!       elif position == 'home':
!         self._currentEntry._cursorPosition = \
!            self._currentEntry._maskHandler.moveCursorToBegin()
!       elif position == 'left':
!         self._currentEntry._cursorPosition = \
!            self._currentEntry._maskHandler.moveCursorRelative(-1)
!       elif position == 'right':
!         self._currentEntry._cursorPosition = \
!            self._currentEntry._maskHandler.moveCursorRelative(1)
! 
  
    def replaceValue(self,object, value):
      replacement = ""
***************
*** 475,483 ****
            value= self._currentEntry.findClosestValue(value)
            if not value: return modified
  
!         self._currentEntry.processTrigger('pre-change')
            self._currentEntry.setValue(value)
!         self._currentEntry.processTrigger('post-change')
            modified = 1
            return modified
  
--- 503,511 ----
            value= self._currentEntry.findClosestValue(value)
            if not value: return modified
  
!           self._currentEntry.processTrigger('pre-change')
            self._currentEntry.setValue(value)
!           self._currentEntry.processTrigger('post-change')
            modified = 1
            return modified
  
***************
*** 489,522 ****
            if len(currentvalue) >= int(self._currentEntry.max_length):
              return modified
  
!         if self._currentEntry._numeric and self._currentBlock.mode == 
'normal':
            if not (value in string.digits or value in '.'):
              return modified
  
!         if self._insertMode == 1:
!           if self._currentEntry._maskHandler:
!             currentvalue = 
self._currentEntry._maskHandler.processEdit(currentvalue, value,
!                   self._currentEntry._cursorPosition)
!           else:
!             currentvalue = currentvalue[:self._currentEntry._cursorPosition] 
+ value + \
!                    currentvalue[self._currentEntry._cursorPosition:]
          else:
-           if self._currentEntry._maskHandler:
-             currentvalue = 
self._currentEntry._maskHandler.processEdit(currentvalue, value,
-                   self._currentEntry._cursorPosition,1)
-           else:
-             currentvalue = currentvalue[:self._currentEntry._cursorPosition] 
+ value + \
-                    currentvalue[self._currentEntry._cursorPosition+1:]
  
!         self._currentEntry._cursorPosition += 1
!       self._currentEntry.processTrigger('pre-change')
!         self._currentEntry.setValue(currentvalue)
!       self._currentEntry.processTrigger('post-change')
  
          modified = 1
  
      return modified
  
    #
    # removeCharacter
    #
--- 517,568 ----
            if len(currentvalue) >= int(self._currentEntry.max_length):
              return modified
  
!         if ( self._currentEntry._numeric and \
!              self._currentBlock.mode == 'normal' ):
            if not (value in string.digits or value in '.'):
              return modified
  
! 
! 
!         # If an input mask handler is being
!         # used, we need to use its logic.
! 
!         if not self._currentEntry._maskHandler:
! 
!           # use default logic
! 
!           currentvalue = currentvalue[:self._currentEntry._cursorPosition] \
!                        + value \
!                        + currentvalue[self._currentEntry._cursorPosition \
!                                       + (not self._insertMode):]
! 
!           self._currentEntry._cursorPosition += 1
! 
          else:
  
!           # use mask handler's logic
  
+           currentvalue = self._currentEntry._maskHandler.processEdit(
+               currentvalue,
+               value,
+               self._currentEntry._cursorPosition,
+               not self._insertMode )
+           print "New value: %s" % currentvalue
+ 
+           self._currentEntry._cursorPosition = \
+             self._currentEntry._maskHandler.moveCursorRelative(1)
+ #              self._currentEntry._maskHandler.cursor
+ 
+ 
+         # Set the field's value, performing pre-/post-change triggers
+         self._currentEntry.processTrigger('pre-change')
+         self._currentEntry.setValue(currentvalue)
+         self._currentEntry.processTrigger('post-change')
          modified = 1
  
      return modified
  
+ 
    #
    # removeCharacter
    #
***************
*** 524,545 ****
    # charater be removed from the current entry object
    #
    def removeCharacter(self, action):
!       modified = 0
        if action == 'backspace':
          if self._currentEntry._cursorPosition > 0:
!           self._currentEntry._cursorPosition = 
self._currentEntry._cursorPosition - 1
!           modified = 1
          else:
!           return modified
!       
!       currentvalue = self._currentEntry.getValue()
!       currentvalue = currentvalue[:self._currentEntry._cursorPosition]  + \
!                currentvalue[self._currentEntry._cursorPosition+1:]
!       self._currentEntry.processTrigger('pre-change')
!       self._currentEntry.setValue(currentvalue)
!       self._currentEntry.processTrigger('post-change')
!       modified = 1
!       return modified
  
  
    #
--- 570,620 ----
    # charater be removed from the current entry object
    #
    def removeCharacter(self, action):
! 
! 
!     # For a backspace, we will fudge by simply
!     # moving the cursor left one position and
!     # performing a "delete".
!     #
!     # If an input mask handler is being used, we
!     # need to use its logic to move the cursor.
! 
!     if not self._currentEntry._maskHandler:
        if action == 'backspace':
          if self._currentEntry._cursorPosition > 0:
!           self._currentEntry._cursorPosition -= 1
          else:
!           # Cannot backspace if we are at pos 0
!           return 0
! 
!       newvalue = self._currentEntry.getValue()
!       newvalue = newvalue[:self._currentEntry._cursorPosition] \
!                + newvalue[self._currentEntry._cursorPosition+1:]
! 
!     else:
! 
!       if action == 'backspace':
!         newPos = self._currentEntry._maskHandler.moveCursorRelative(-1)
!         if self._currentEntry._cursorPosition != newPos:
!           self._currentEntry._cursorPosition = newPos
!         else:
!           # Cannot backspace if we are at pos 0
!           return 0
! 
!       newvalue = self._currentEntry._maskHandler.processEdit(
!             self._currentEntry.getValue(),
!             "",
!             self._currentEntry._maskHandler.cursorToIndex(
!                             self._currentEntry._cursorPosition),
!             1)
! 
! 
! 
!     self._currentEntry.processTrigger('pre-change')
!     self._currentEntry.setValue(newvalue)
!     self._currentEntry.processTrigger('post-change')
! 
!     return 1
  
  
    #



reply via email to

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