commit-gnue
[Top][All Lists]
Advanced

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

gnue common/doc/Menus.txt common/src/GMenu.py c...


From: James Thompson
Subject: gnue common/doc/Menus.txt common/src/GMenu.py c...
Date: Sun, 17 Feb 2002 01:08:47 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     James Thompson <address@hidden> 02/02/17 01:08:47

Modified files:
        common/doc     : Menus.txt 
        common/src     : GMenu.py __init__.py 
        forms/src      : GFInstance.py UIbase.py UIwxpython.py 

Log message:
        The long overdue death of uiEventTrap :)
        moved lineWrap function into common
        older work on menus

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/doc/Menus.txt.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GMenu.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/__init__.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFInstance.py.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/UIbase.py.diff?tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/UIwxpython.py.diff?tr1=1.139&tr2=1.140&r1=text&r2=text

Patches:
Index: gnue/common/doc/Menus.txt
diff -c gnue/common/doc/Menus.txt:1.3 gnue/common/doc/Menus.txt:1.4
*** gnue/common/doc/Menus.txt:1.3       Tue Feb 12 20:57:55 2002
--- gnue/common/doc/Menus.txt   Sun Feb 17 01:08:46 2002
***************
*** 23,30 ****
  The default menu system for a gnue app would be stored in a file
  in the gnue/etc area so that it could be customized by the site
  
- If a GMenu contains nothing it's a seperator
- 
  GMenu
    name           - The name of the menu object
    event          - The comma seperated list of events that this menu item 
should fire
--- 23,28 ----
Index: gnue/common/src/GMenu.py
diff -c gnue/common/src/GMenu.py:1.1 gnue/common/src/GMenu.py:1.2
*** gnue/common/src/GMenu.py:1.1        Mon Feb 11 22:03:50 2002
--- gnue/common/src/GMenu.py    Sun Feb 17 01:08:46 2002
***************
*** 51,57 ****
    #TODO: 2 chars.  So we have to add a placeholer G to the type :(
    def __init__(self, parent=None, type="GGMenu"):
      GObjects.GObj.__init__(self, parent, type)
-     self.type = type
  
      #
      # trigger support
--- 51,56 ----
***************
*** 95,107 ****
                 'Required': 1,
                 'Unique':   1,
                 'Typecast': GTypecast.name },
!             'text':        {
!                'Typecast': GTypecast.text},
              'trigger':      {
                 'Typecast': GTypecast.name },
!             },
           'ParentTags': None },
!   }
  
    for alteration in updates.keys():
      xmlElements[alteration].update(updates[alteration])
--- 94,117 ----
                 'Required': 1,
                 'Unique':   1,
                 'Typecast': GTypecast.name },
!             'label':        {
!                'Typecast': GTypecast.name},
              'trigger':      {
                 'Typecast': GTypecast.name },
!             'type':      {
!                'Typecast': GTypecast.name },
!             'leader':      {
!                'Typecast': GTypecast.text },
!             'event':      {
!                'Typecast': GTypecast.text },
!             'location':      {
!                'Typecast': GTypecast.text },
!             'enabled': {
!                'Typecast': GTypecast.boolean,
!                'Default': 0 },
           'ParentTags': None },
!          }
!       }
  
    for alteration in updates.keys():
      xmlElements[alteration].update(updates[alteration])
Index: gnue/common/src/__init__.py
diff -c gnue/common/src/__init__.py:1.8 gnue/common/src/__init__.py:1.9
*** gnue/common/src/__init__.py:1.8     Tue Jan 22 00:56:19 2002
--- gnue/common/src/__init__.py Sun Feb 17 01:08:46 2002
***************
*** 87,89 ****
--- 87,114 ----
      raise ImportError, mesg
  
  
+ # very simple lineWrap
+ def lineWrap(message,maxWidth):
+   text = ""
+ 
+   temptext = string.strip(message)
+ 
+   for strings in string.split(temptext,"\n"):
+     while len(strings) > maxWidth:
+       index = 0
+       for sep in [' ',',',':']:
+         ind = string.rfind(strings,sep,0,maxWidth-1)+1
+         if ind > index: index = ind
+ 
+       if index > maxWidth:
+         index = maxWidth-1
+ 
+       text += "%s\n" % strings[:index]
+       strings = strings[index:]
+ 
+     text +=  "%s\n" % strings
+ 
+   return text
+   
+ 
+ 
Index: gnue/forms/src/GFInstance.py
diff -c gnue/forms/src/GFInstance.py:1.28 gnue/forms/src/GFInstance.py:1.29
*** gnue/forms/src/GFInstance.py:1.28   Fri Feb 15 22:57:55 2002
--- gnue/forms/src/GFInstance.py        Sun Feb 17 01:08:46 2002
***************
*** 67,73 ****
                             'requestPREVBLOCK'    : self.previousBlock,
                             'requestPREVRECORD'   : self.prevRecord,
                             'requestNEXTRECORD'   : self.nextRecord,
!                            'requestRECORDNUMBER' : self.jumpRecords,
                             'requestPAGE'         : self.gotoPage,
  
                             # Proxied "Entry" events
--- 67,74 ----
                             'requestPREVBLOCK'    : self.previousBlock,
                             'requestPREVRECORD'   : self.prevRecord,
                             'requestNEXTRECORD'   : self.nextRecord,
!                            'requestRECORDNUMBER' : self.jumpToRecord,
!                            'requestJUMPRECORD'   : self.jumpRecords,
                             'requestPAGE'         : self.gotoPage,
  
                             # Proxied "Entry" events
***************
*** 224,235 ****
      self.updateRecordStatus()
  
    #
!   # jumpRecord
    #
!   # Called enever an event source has requested that the
!   # form move an arbitrary number of records
    #
!   def jumpRecords(self,event):
      try:
        count = abs(int(event.data))-1
      except ValueError:
--- 225,236 ----
      self.updateRecordStatus()
  
    #
!   # jumpToRecord
    #
!   # Called whenever an event source has requested that the
!   # form move a specific record
    #
!   def jumpToRecord(self,event):
      try:
        count = abs(int(event.data))-1
      except ValueError:
***************
*** 246,252 ****
      self.updateRecordCounter()
      self.updateRecordStatus()
  
!             
        
    def executeExit(self, event):
      if not self._form.isSaved():
--- 247,266 ----
      self.updateRecordCounter()
      self.updateRecordStatus()
  
! 
! 
!   def jumpRecords(self,event):
!     count = event.data
!     for jumps in range(abs(count)):
!       if count > 0:
!         self._form.nextRecord()
!       if count < 0:
!         self._form.prevRecord()
!         
!     
self.dispatchEvent(GFEvent('gotoENTRY',{'object':self._form._currentEntry}))
!     self.updateRecordCounter()
!     self.updateRecordStatus()
!                                      
        
    def executeExit(self, event):
      if not self._form.isSaved():
Index: gnue/forms/src/UIbase.py
diff -c gnue/forms/src/UIbase.py:1.54 gnue/forms/src/UIbase.py:1.55
*** gnue/forms/src/UIbase.py:1.54       Sat Feb 16 19:46:32 2002
--- gnue/forms/src/UIbase.py    Sun Feb 17 01:08:46 2002
***************
*** 32,37 ****
--- 32,47 ----
  from GFEvent import *
  from gnue.common.GObjects import *
  
+ # Used in updating the status bar
+ 
+ statusValues = {'saved':'OK',
+                 'modified':'MOD',
+                 'deleted':'DEL',
+                 'query':'QRY'}
+ 
+ 
+ 
+ 
  #
  # GFUserInterfaceBase
  #
***************
*** 80,87 ****
      self._formToUI = {}                   # the GFObj to UI widget cross ref
      self._formToUIWidget = {}             # dictionary of driver specific 
UIfoo
                                            # widgets with the GFObj used as 
the key
!     self._screenWidgetToGFObject= {}
!                                           
      self.containerWidgets= ['GFPage']     # GFForm objects that contain others
      
      self._pageList = []                   # A list of page widgets created by 
the form
--- 90,96 ----
      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.containerWidgets= ['GFPage']     # GFForm objects that contain others
      
      self._pageList = []                   # A list of page widgets created by 
the form
***************
*** 196,205 ****
    #
    # Calls the UIs function to update status
    def updateStatusBar(self,event):
-     statusValues = {'saved':'OK',
-                     'modified':'MOD',
-                     'deleted':'DEL',
-                     'query':'QRY'}
  
      tip, recordStatus, insertMode, currentRecord, maxRecord, currentPage, 
maxPage =event.data
  
--- 205,210 ----
Index: gnue/forms/src/UIwxpython.py
diff -c gnue/forms/src/UIwxpython.py:1.139 gnue/forms/src/UIwxpython.py:1.140
*** gnue/forms/src/UIwxpython.py:1.139  Sat Feb 16 19:46:32 2002
--- gnue/forms/src/UIwxpython.py        Sun Feb 17 01:08:46 2002
***************
*** 25,30 ****
--- 25,31 ----
  # A wxPython based user interface driver for GNUE forms.
  #
  # NOTES:
+ #  TODO: why does UIhelper not inherit from UIwidget?
  #
  
  from wxPython.wx import *
***************
*** 42,47 ****
--- 43,49 ----
  from gnue.forms import VERSION
  from gnue.common import GDebug, GLoginHandler
  from gnue.common import GConfig
+ from gnue.common import lineWrap
  
  _NOTEBOOK = None
  _LOOPTRAP = 0
***************
*** 59,64 ****
--- 61,72 ----
  
  __wxApp = None
  
+ # hack for wxPython 2.2 (2.3+ doesn't need this)
+ def _eventObjTowxWindow(event):
+   eo = event.GetEventObject()
+   return wxPyTypeCast(eo, 'wxWindow')
+           
+ 
  class GFwxApp(wxApp):
    def OnInit(self):
      GDebug.printMesg(7,"WxApp initializing")
***************
*** 79,84 ****
--- 87,93 ----
  def initFont(widget, affectsLayout=1):
    if int(GConfig.get('fixedWidthFont')):
      
widget.SetFont(wxFont(int(GConfig.get('pointSize')),wxMODERN,wxNORMAL,wxNORMAL))
+ 
  #
  # GFUserInterface
  #
***************
*** 179,192 ****
      global _charWidth
  
      _charWidth = int(self.charWidth)
!     print "_charWidth",_charWidth
!     self.borderPercentage = (int(GConfig.get('borderPercentage')) / 100.0)
!     self.textPercentage = (int(GConfig.get('textPercentage')) / 100.0)
! 
!     self.widgetWidth = (self.charWidth * self.borderPercentage)
!     self.widgetHeight = (self.charHeight * self.borderPercentage) + 3
!     self.textWidth = self.charWidth * self.textPercentage
!     self.textHeight = self.charHeight * self.textPercentage
  
      self.menu_sb_space=4 # the extra spaces needed by the menu, toolbar and 
statusbar
      
--- 188,198 ----
      global _charWidth
  
      _charWidth = int(self.charWidth)
! 
!     self.widgetWidth = self.charWidth
!     self.widgetHeight = self.charHeight + 3
!     self.textWidth = self.charWidth
!     self.textHeight = self.charHeight
  
      self.menu_sb_space=4 # the extra spaces needed by the menu, toolbar and 
statusbar
      
***************
*** 274,280 ****
      self.mainWindow.Show(true)
      return true
  
- 
    # Called by SplashScreen when timer expires
    def onCloseSplash(self):
      # For some reason, a simple Close() doesn't cooperate with
--- 280,285 ----
***************
*** 355,369 ****
      recordWidth,unused = 
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(3))
      pageWidth,unused = 
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(4))
  
!     statusWidth *= 2
!     insertWidth *= 2
!     recordWidth *= 2
!     pageWidth   *= 2
! 
!     if statusWidth == 0:      statusWidth = 5
!     if insertWidth == 0:      insertWidth = 5
!     if recordWidth == 0:      recordWidth = 5
!     if pageWidth == 0:        pageWidth = 5
  
      
self.statusBar.SetStatusWidths([tipWidth,statusWidth,insertWidth,recordWidth,pageWidth])
      
--- 360,370 ----
      recordWidth,unused = 
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(3))
      pageWidth,unused = 
self.statusBar.GetTextExtent(self.statusBar.GetStatusText(4))
  
!     # Either double the width if it's set or default to 5
!     statusWidth = statusWidth and (statusWidth * 2) or 5 
!     insertWidth = insertWidth and (insertWidth * 2) or 5 
!     recordWidth = recordWidth and (recordWidth * 2) or 5 
!     pageWidth   = pageWidth   and (pageWidth   * 2) or 5 
  
      
self.statusBar.SetStatusWidths([tipWidth,statusWidth,insertWidth,recordWidth,pageWidth])
      
***************
*** 380,390 ****
    # makes the requested page visible on the screen
    #
    def gotoPage(self, event):
-     index = 0 # self._formToUI[event.data][1]
-     print "INDEX", index
      if not _NOTEBOOK:
        self.visiblePage.Show(FALSE)
        self.visiblePage = self._formToUI[event.data][0]
        
self.visiblePage.SetSize(wxSize(int(self._form.width)*int(self.widgetWidth),
                                        
int(int(self._form.height)+self.menu_sb_space)*int(self.widgetHeight)))
      else:
--- 381,390 ----
    # makes the requested page visible on the screen
    #
    def gotoPage(self, event):
      if not _NOTEBOOK:
        self.visiblePage.Show(FALSE)
        self.visiblePage = self._formToUI[event.data][0]
+       # TODO: move the calculatoin out of here
        
self.visiblePage.SetSize(wxSize(int(self._form.width)*int(self.widgetWidth),
                                        
int(int(self._form.height)+self.menu_sb_space)*int(self.widgetHeight)))
      else:
***************
*** 393,402 ****
          if self.visiblePage.GetId() == _NOTEBOOK.GetPage(count).GetId():
            _NOTEBOOK.SetSelection(count)
            break
- 
      self.visiblePage.Show(TRUE)
  
- 
    #
    # formAlert
    #
--- 393,400 ----
***************
*** 435,441 ****
        self.dispatchEvent(GFEvent('requestRECORDNUMBER', dlg.GetValue()))
        dlg.Destroy()
  
- 
    #
    # closeTrap
    #
--- 433,438 ----
***************
*** 444,558 ****
    # back an event closing the application
    #`
    def closeTrap(self,event):
!     # hack for swig shortcomming
!     eo = event.GetEventObject()
!     object = wxPyTypeCast(eo, 'wxFrame')
      if event.CanVeto():
        self.dispatchEvent(GFEvent('requestEXIT'))
      else:
        object.Destroy()
  
-   #
-   # uiEventTrap
-   #
-   # traps most data entry related wxPython events and converts them to 
GFForms UI requests
-   # really need to be recoded to something more friendly - maybe multiple 
event handlers
-   #
-   # TODO: Being phased out
-   # 
-   def uiEventTrap(self, event):
-     action = None
-     #
-     # ra3vat CheckBox Events
-     #    
-     if event.GetEventType() == wxEVT_COMMAND_CHECKBOX_CLICKED:
-       # hack for swig shortcomming
-       eo = event.GetEventObject()
-       object = wxPyTypeCast(eo, 'wxCheckBox')
- 
-       for key in self._formToUI.keys():
-         for count in range(len(self._formToUI[key])):
-           if self._formToUI[key][count].GetId() == object.GetId():
-             self.dispatchEvent(GFEvent('requestFOCUS',key))
-             eventdata = [key, object.GetValue()]
-             self.dispatchEvent(GFEvent('requestJUMPRECORD',count - 
key._visibleIndex))
-             self.dispatchEvent(GFEvent('requestTOGGLECHKBOX',eventdata))
-             break
-     #
-     # Combo box events
-     #
-     elif event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED:
- 
-       print "I taught I taw a puddy tat"
-       # hack for swig shortcomming
-       eo = event.GetEventObject()
-       object = wxPyTypeCast(eo, 'wxWindow')
- 
-       #
-       # Begin duplicate of the mouse handling code to see
-       # if it will allow me proper focus control w/
-       # comboxes
-       #
- 
-       # Move to proper object
-       for key in self._formToUI.keys():
-         for count in range(len(self._formToUI[key])):
-           if self._formToUI[key][count].GetId() == object.GetId():
-             self.dispatchEvent(GFEvent('requestFOCUS',key))
-             #self.dispatchEvent(GFEvent('requestJUMPRECORD',count - 
key._visibleIndex))
-             break
- 
-       for key in self._formToUI.keys():
-         for count in range(len(self._formToUI[key])):
-           if self._formToUI[key][count].GetId() == object.GetId():
-             self.dispatchEvent(GFEvent('requestJUMPRECORD',count - 
key._visibleIndex))
-             break
- 
-       #
-       # slightly altered event to call immediate
-       #
-             # Move to proper object
-             self.dispatchEvent(GFEvent('requestFOCUS',key))
-       #
-       # End duplicate of mouse handling code
-       #
- 
-       selection = event.GetSelection()
-       for key in self._formToUI.keys():
-         for uiItem in self._formToUI[key]:
-           if uiItem.GetId() == object.GetId():
-             eventdata = [key, event.GetString()]
-             action = GFEvent('requestREPLACEVALUE',eventdata)
- 
-     #
-     # Button Events
-     #
-     elif event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED:
-       print "I did! I did taw a puddy tat"
-       eo = event.GetEventObject()
-       object = wxPyTypeCast(eo, 'wxWindow')
- 
-       for key in self._formToUI.keys():
-         for count in range(len(self._formToUI[key])):
-           if self._formToUI[key][count].GetId() == object.GetId():
-             action = GFEvent('fireTRIGGER',key.trigger)
-     #
-     # Notebook tab events
-     #
-     elif event.GetEventType() == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING:
-       global _LOOPTRAP
-       if _LOOPTRAP == 0:
-         _LOOPTRAP = 1
-         action = GFEvent('requestPAGE',event.GetSelection())
-       else:
-         _LOOPTRAP = 0      
-     else:
-       # Need to probably log this somewhere in debug mode
-       pass
- 
-     if action:
-       self.dispatchEvent(action)
- 
    # Called whenever forms goes into a "wait" state in which user cannot
    # interact with interface (e.g., while waiting for a query or a commit)
    def beginWait (self, event):
--- 441,452 ----
    # back an event closing the application
    #`
    def closeTrap(self,event):
!     object = _eventObjTowxWindow(event)
      if event.CanVeto():
        self.dispatchEvent(GFEvent('requestEXIT'))
      else:
        object.Destroy()
  
    # Called whenever forms goes into a "wait" state in which user cannot
    # interact with interface (e.g., while waiting for a query or a commit)
    def beginWait (self, event):
***************
*** 561,569 ****
    # Called whenever forms leaves a "wait" state
    def endWait (self, event): 
      wxEndBusyCursor()
! 
! 
! 
  #############################################################################
  #
  # UI Objects
--- 455,461 ----
    # Called whenever forms leaves a "wait" state
    def endWait (self, event): 
      wxEndBusyCursor()
!     
  #############################################################################
  #
  # UI Objects
***************
*** 584,589 ****
--- 476,484 ----
  
    def show(self, flag=TRUE, index=None):
      if index:
+       # TODO: I don't thing this is ever called
+       # TODO: with an index
+       print "UIwxpython show using an index"
        self.widgets[index].Show(flag)
      else:
        self.Show(flag)
***************
*** 596,603 ****
  
    def setValue(self, value, index=0):
      self.widgets[index].SetEvtHandlerEnabled(FALSE)
-     # str is used to prevent unicode data types for bothering wxpython
-     # moved to UIbase -     self.widgets[index].SetValue(str(value))
      self.widgets[index].SetValue(value)
      self.widgets[index].SetEvtHandlerEnabled(TRUE)
  
--- 491,496 ----
***************
*** 612,640 ****
      _IdToWxObj[id]=widget
      _IdToGFObj[id]=gfobject
      _IdToUIObj[id]=uiobject
      
  #
  # UILabel
  #
  # Widget set specific function that creates a single instance of a label
  #
! class UILabel(UIWidget, UIHelper):
!   def createWidget(self, object, container, textWidth, textHeight, 
widgetWidth,
!                    widgetHeight,interface,spacer,initialize=1):
!     style = wxALIGN_LEFT|wxST_NO_AUTORESIZE
! 
!     if hasattr(object,'alignment'):
!       if object.alignment == 'center':
!         style = wxALIGN_CENTRE|wxST_NO_AUTORESIZE
!       elif object.alignment == 'right':
!         style = wxALIGN_RIGHT|wxST_NO_AUTORESIZE
  
      newWidget = wxStaticText(container, -1, str(object.text),
                               wxPoint(object.x*int(widgetWidth),
                                       
(object.y+spacer+(spacer*object._gap))*int(widgetHeight)),
                               wxSize(self.itemWidth,self.itemHeight), style)
-     initFont(newWidget)
-     self._addToCrossRef(newWidget,object,self)
      return newWidget
  
  #
--- 505,537 ----
      _IdToWxObj[id]=widget
      _IdToGFObj[id]=gfobject
      _IdToUIObj[id]=uiobject
+ 
+   def createWidget(self, object, container, textWidth, textHeight,
+                    widgetWidth, widgetHeight, interface, spacer,initialize=1):
      
+     newWidget = self._createWidget(object, container, textWidth, textHeight,
+                                    widgetWidth, widgetHeight, interface, 
spacer,initialize)
+     initFont(newWidget)
+     self._addToCrossRef(newWidget,object,self)
+     return newWidget
  #
  # UILabel
  #
  # Widget set specific function that creates a single instance of a label
  #
! class UILabel(UIHelper, UIWidget):
!   alignmentStyle = { 'left'  : wxALIGN_LEFT|wxST_NO_AUTORESIZE,
!                      'center': wxALIGN_CENTRE|wxST_NO_AUTORESIZE,
!                      'right' : wxALIGN_RIGHT|wxST_NO_AUTORESIZE,
!                      }
  
+   def _createWidget(self, object, container, textWidth, textHeight, 
widgetWidth,
+                    widgetHeight,interface,spacer,initialize=1):
+     style = self.alignmentStyle[object.alignment]
      newWidget = wxStaticText(container, -1, str(object.text),
                               wxPoint(object.x*int(widgetWidth),
                                       
(object.y+spacer+(spacer*object._gap))*int(widgetHeight)),
                               wxSize(self.itemWidth,self.itemHeight), style)
      return newWidget
  
  #
***************
*** 642,657 ****
  #
  # Widget set specific function that creates a single instance of a border box
  #
! class UIBox(UIWidget, UIHelper):
!   def createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      newWidget = wxStaticBox(container,-1,str(object.label),
                              
wxPoint(object.x*int(widgetWidth)+(int(widgetWidth)/2),
                                      
(object.y+spacer+(spacer*object._gap))*int(widgetHeight)+(int(widgetHeight)/2)),
                              wxSize((object.width-1)*int(widgetWidth),
                                     (object.height-1)*int(widgetHeight)))
-     initFont(newWidget)
-     self._addToCrossRef(newWidget,object,self)
      return newWidget
  
  #
--- 539,552 ----
  #
  # Widget set specific function that creates a single instance of a border box
  #
! class UIBox(UIHelper, UIWidget):
!   def _createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      newWidget = wxStaticBox(container,-1,str(object.label),
                              
wxPoint(object.x*int(widgetWidth)+(int(widgetWidth)/2),
                                      
(object.y+spacer+(spacer*object._gap))*int(widgetHeight)+(int(widgetHeight)/2)),
                              wxSize((object.width-1)*int(widgetWidth),
                                     (object.height-1)*int(widgetHeight)))
      return newWidget
  
  #
***************
*** 660,674 ****
  # Widget set specific function that creates a single instance of a scroll bar 
used
  # to navigate multiple records
  #
! class UIScrollBar(UIWidget, UIHelper):
!   def createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      newWidget =wxScrollBar(container,-1,
                             
wxPoint(object.x*int(widgetWidth),(object.y+spacer)*int(widgetHeight)),
                             
wxSize(object.width*int(widgetWidth),object.height*int(widgetHeight)),
                             wxSB_VERTICAL)
-     initFont(newWidget,0)
-     self._addToCrossRef(newWidget,object,self)
      return newWidget
    
  #
--- 555,567 ----
  # Widget set specific function that creates a single instance of a scroll bar 
used
  # to navigate multiple records
  #
! class UIScrollBar(UIHelper, UIWidget):
!   def _createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      newWidget =wxScrollBar(container,-1,
                             
wxPoint(object.x*int(widgetWidth),(object.y+spacer)*int(widgetHeight)),
                             
wxSize(object.width*int(widgetWidth),object.height*int(widgetHeight)),
                             wxSB_VERTICAL)
      return newWidget
    
  #
***************
*** 676,703 ****
  #
  # Widget set specific function that creates a single instance of a button
  #
! class UIButton(UIWidget, UIHelper):
!   def createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      newWidget = wxButton(container,-1,str(object.label),
                           
wxPoint(object.x*int(widgetWidth),(object.y+spacer)*int(widgetHeight)),
                           
wxSize(object.width*int(widgetWidth),object.height*int(widgetHeight))
                           )
- 
-     initFont(newWidget,0)
      if initialize:
!       _setDefaultEventHandlers(newWidget,initialize, 
interface._screenWidgetToGFObject)
! #      EVT_BUTTON(newWidget,newWidget.GetId(),interface.uiEventTrap)
!     self._addToCrossRef(newWidget,object,self)
      return newWidget
  
  #
  # UIPage
  #
  # Widget set specific function that creates a single instance of a page
  #
! class UIPage(UIWidget, UIHelper):
!   def createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      if _NOTEBOOK:
        newWidget = wxPanel(_NOTEBOOK, -1,wxDefaultPosition,_NOTEBOOK.GetSize())
--- 569,608 ----
  #
  # Widget set specific function that creates a single instance of a button
  #
! class UIButton(UIHelper, UIWidget):
!   def _createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      newWidget = wxButton(container,-1,str(object.label),
                           
wxPoint(object.x*int(widgetWidth),(object.y+spacer)*int(widgetHeight)),
                           
wxSize(object.width*int(widgetWidth),object.height*int(widgetHeight))
                           )
      if initialize:
!       EVT_BUTTON(newWidget,newWidget.GetId(),self.buttonHandler)
!       #_setDefaultEventHandlers(newWidget,initialize)
!       
      return newWidget
  
+   def buttonHandler(self,event):
+     if event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED:
+       action = None
+       object = _eventObjTowxWindow(event)
+ 
+       id = object.GetId()
+       gfObject     = _IdToGFObj[id]
+       action = GFEvent('fireTRIGGER',gfObject.trigger)
+       
+       if action:
+         _EVENTPROCESSOR(action) 
+ 
  #
  # UIPage
  #
  # Widget set specific function that creates a single instance of a page
  #
! # Note: The event trap for changing notebook pages is attached to the UIForm
! #
! class UIPage(UIHelper, UIWidget):
!   def _createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      if _NOTEBOOK:
        newWidget = wxPanel(_NOTEBOOK, -1,wxDefaultPosition,_NOTEBOOK.GetSize())
***************
*** 707,718 ****
        newWidget = wxPanel(container, -1,wxDefaultPosition,container.GetSize())
        newWidget.Show(FALSE)
                              
!     _setDefaultEventHandlers(newWidget,initialize, 
interface._screenWidgetToGFObject)
!         
!     initFont(newWidget,0)
      interface._pageList.append(newWidget)
-     self._addToCrossRef(newWidget,object,self)
-             
      return newWidget
  
  #
--- 612,620 ----
        newWidget = wxPanel(container, -1,wxDefaultPosition,container.GetSize())
        newWidget.Show(FALSE)
                              
!     _setDefaultEventHandlers(newWidget,initialize)
!     
      interface._pageList.append(newWidget)
      return newWidget
  
  #
***************
*** 720,765 ****
  #
  # Widget set specific function that creates a single instance of a data entry 
widget
  #
! class UIEntry(UIWidget, UIHelper):
!   def createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
  
      style = object.style
      if style == 'dropdown':
        if initialize:
          choices = object.allowedValues().values()
        else:
          choices = [""]
  
!       newWidget = wxComboBox(container, -1, "",
!                              wxPoint(object.x*int(widgetWidth),
!                                      
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
!                              wxSize(object.width*int(textWidth),
!                                     object.height*int(textHeight)),
!                              choices, wxCB_DROPDOWN|wxWANTS_CHARS,
!                             )
      elif style == 'label':
!       newWidget = wxStaticText(container, -1, "",
!                              wxPoint(object.x*int(widgetWidth),
!                                      
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
!                              wxSize(object.width*int(textWidth),
!                                     object.height*int(textHeight)+1),
!                              wxST_NO_AUTORESIZE)
        # To make the label consistent with the other entry styles...
        newWidget.SetValue = newWidget.SetLabel
        newWidget.GetValue = newWidget.GetLabel
        
      elif style == 'checkbox':
!       newWidget = wxCheckBox(container, -1, "",
!                              wxPoint(object.x*int(widgetWidth),
!                                      
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
!                              wxSize(int(2)*int(textWidth),
!                                     int(1)*int(textHeight)), wxNO_BORDER)
        newWidget.SetValue(0)
  
      else: # Normal text box
        if initialize:
!         styles = wxTE_PROCESS_TAB
          if object.height > 1:
            styles = styles|wxTE_MULTILINE
          value = object.getValue()
--- 622,665 ----
  #
  # Widget set specific function that creates a single instance of a data entry 
widget
  #
! class UIEntry(UIHelper, UIWidget):
!   def _createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
  
      style = object.style
+ 
+     defaultPoint =  wxPoint(object.x*int(widgetWidth),
+                             
(object.y+spacer+(object._gap*spacer))*int(widgetHeight))
+     defaultSize  = 
wxSize(object.width*int(textWidth),object.height*int(textHeight)+1)
+ 
      if style == 'dropdown':
        if initialize:
          choices = object.allowedValues().values()
        else:
          choices = [""]
  
!       newWidget = wxComboBox(container, -1, "",defaultPoint,
!                               
wxSize(object.width*int(textWidth),object.height*int(textHeight)),
!                              choices, wxCB_DROPDOWN|wxWANTS_CHARS,)
! 
!       EVT_COMBOBOX(newWidget, newWidget.GetId(), self.comboHandler)
!       
      elif style == 'label':
!       newWidget = wxStaticText(container, -1, "",defaultPoint,defaultSize,
!                                wxST_NO_AUTORESIZE)
        # To make the label consistent with the other entry styles...
        newWidget.SetValue = newWidget.SetLabel
        newWidget.GetValue = newWidget.GetLabel
        
      elif style == 'checkbox':
!       newWidget = wxCheckBox(container, -1, "",defaultPoint,
!                              
wxSize(int(2)*int(textWidth),int(1)*int(textHeight)),
!                              wxNO_BORDER)
        newWidget.SetValue(0)
  
      else: # Normal text box
        if initialize:
!         styles = wxTE_PROCESS_TAB 
          if object.height > 1:
            styles = styles|wxTE_MULTILINE
          value = object.getValue()
***************
*** 767,901 ****
          styles = 0
          value = ""
  
!       newWidget = wxTextCtrl(container, -1, value,
!                              wxPoint(object.x*int(widgetWidth),
!                                      
(object.y+spacer+(object._gap*spacer))*int(widgetHeight)),
!                              wxSize(object.width*int(textWidth),
!                                     object.height*int(textHeight)+1),
!                              styles)
! 
!     _setDefaultEventHandlers(newWidget,initialize, 
interface._screenWidgetToGFObject)
  
!     initFont(newWidget, 0)
!     self._addToCrossRef(newWidget,object,self)
!             
      return newWidget
  
! 
! def _setDefaultEventHandlers(newWidget, initialize, screenToGFObject):
!   global _EVENTPROCESSOR
!   if initialize:
!     
#newWidget.SetEventHandler(mouseEvtHandler(_EVENTPROCESSOR,screenToGFObject))
!     
newWidget.PushEventHandler(mouseEvtHandler(_EVENTPROCESSOR,screenToGFObject))
!     
newWidget.PushEventHandler(keyboardEvtHandler(_EVENTPROCESSOR,screenToGFObject))
! 
! class uiBaseEvtHandler(wxEvtHandler,GFEventAware):
!   def __init__(self,eventList,eventProcessor,screenToGFObject):
!     wxEvtHandler.__init__(self)
!     self._eventProcessor = eventProcessor
!     self._screenToGFObject = screenToGFObject
!     for eventType in eventList:
!       self.Connect(-1, -1, eventType,self._processEvent)
!                         
!   def _processEvent(self,event):
!     GDebug.printMesg(0,"uiBaseEvtHandler _processEvent was called?!?")
!   
! class mouseEvtHandler(uiBaseEvtHandler):
!   def __init__(self,eventProcessor,screenToGFObject):
!     eventList = [wxEVT_LEFT_DOWN] #[wxEVT_LEFT_DOWN, wxEVT_LEFT_UP]
!     uiBaseEvtHandler.__init__(self, eventList, 
eventProcessor,screenToGFObject)
!     
!   def _processEvent(self,event):
!     # hack for swig shortcomming
!     eo = event.GetEventObject()
!     object = wxPyTypeCast(eo, 'wxWindow')
!     
!     # compute the location of the character in the widget
!     x = event.GetX()
!     y = event.GetY()
!     global _charWidth
!     if _charWidth:
!       charover = 1 + x/_charWidth
!       print "I'm at the %d char" % charover
! 
!     # Move to proper object
!     id = object.GetId()
!     gfObject     = _IdToGFObj[id]
!     screenWidget = _IdToWxObj[id]
!     count        = _IdToUIObj[id].widgets.index(screenWidget)
!     print "I should jump to record ", count - gfObject._visibleIndex
!     self._eventProcessor(GFEvent('requestFOCUS',gfObject))
!     self._eventProcessor(GFEvent('requestRECORDNUMBER',count - 
gfObject._visibleIndex))
!         
! class keyboardEvtHandler(uiBaseEvtHandler):
!   def __init__(self, eventProcessor,screenToGFObject):
!     eventList = [wxEVT_CHAR,wxEVT_KEY_DOWN]
!     uiBaseEvtHandler.__init__(self, eventList, 
eventProcessor,screenToGFObject)
!     
!   def _processEvent(self,event):
      action = None
!     # hack for swig shortcomming needed by wxPython 2.2.x (2.3 does not need 
this)
!     eo = event.GetEventObject()
  
!     # compute the location of the character in the widget
!     if event.GetEventType() == wxEVT_CHAR or 
event.GetEventType()==wxEVT_KEY_DOWN:
!       command = GFKeyMapper.KeyMapper.getEvent(
!         event.KeyCode(),
!         event.ShiftDown(),
!         event.ControlDown(),
!         event.AltDown())
!       object = wxPyTypeCast(eo, 'wxWindow')
!       # TODO : Broken for the moment
!       #if command == 'JUMPRECORD':
!       #  self.promptForRecordNumber()
  
!       if command:
!         action = GFEvent('request%s' % command)
  
!       else:
!         try:
!           action = GFEvent('requestKEYPRESS', chr(event.KeyCode()),
!                            code=event.KeyCode())
!         except ValueError:
!           event.Skip()
!     if action:
!       self._eventProcessor(action)
!                 
  #
  # UIForm
  #
  # Widget set specific function that creates a single instance of a Form widget
  #
! class UIForm(UIWidget, UIHelper):
!   def createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      global _NOTEBOOK
  
      if object.tabbed:
!       if object.tabbed == 'left':
!         tabstyle = wxNB_LEFT
!       elif object.tabbed == 'right':
!         tabstyle = wxNB_RIGHT
!       elif object.tabbed == 'bottom':
!         tabstyle = wxNB_BOTTOM
!       else:
!         tabstyle = 0
  
!       _NOTEBOOK = 
wxNotebook(container,-1,wxPoint(10,10),size=container.GetSize(),style=tabstyle)
!       newWidget = _NOTEBOOK
!       _NOTEBOOK.Show(TRUE)
!       EVT_NOTEBOOK_PAGE_CHANGING(newWidget, newWidget.GetId(), 
interface.uiEventTrap)
!         
      else:                      
        newWidget = wxPanel(interface.mainWindow.panel,-1, wxDefaultPosition)
        
      if initialize: 
        EVT_CLOSE(interface.mainWindow,interface.closeTrap)
        
-     self._addToCrossRef(newWidget,object,self)
-         
      return newWidget
  
  #
  # UIAbout
  #
--- 667,756 ----
          styles = 0
          value = ""
  
!       newWidget = wxTextCtrl(container, -1, value, defaultPoint, defaultSize, 
styles)
  
!     _setDefaultEventHandlers(newWidget,initialize)
      return newWidget
  
!   def comboHandler(self, event):
      action = None
!     if event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED:
!       object = _eventObjTowxWindow(event)
!       id = object.GetId()
!        
!       selection = event.GetSelection()
!        
!       gfObject     = _IdToGFObj[id]
!       eventdata = [gfObject, event.GetString()]
!       action = GFEvent('requestREPLACEVALUE',eventdata)
!     _EVENTPROCESSOR(action)       
  
!   def checkboxHandler(self,event):
!     if event.GetEventType() == wxEVT_COMMAND_CHECKBOX_CLICKED:
!       # hack for swig shortcomming
!       eo = event.GetEventObject()
!       object = wxPyTypeCast(eo, 'wxCheckBox')
!       # TODO: this doesn't work yet :)
!       #for key in self._formToUI.keys():
!       #  for count in range(len(self._formToUI[key])):
!       #    if self._formToUI[key][count].GetId() == object.GetId():
!       #      self.dispatchEvent(GFEvent('requestFOCUS',key))
!       #      eventdata = [key, object.GetValue()]
!       #      self.dispatchEvent(GFEvent('requestJUMPRECORD',count - 
key._visibleIndex))
!       #      self.dispatchEvent(GFEvent('requestTOGGLECHKBOX',eventdata))
!       #      break
  
!       #if action:
!       #  self.dispatchEvent(action)
  
! 
!                             
  #
  # UIForm
  #
  # Widget set specific function that creates a single instance of a Form widget
  #
! class UIForm(UIHelper, UIWidget):
!   tabStyles = {'left':wxNB_LEFT,
!                'right':wxNB_RIGHT,
!                'bottom':wxNB_BOTTOM,
!                'top':0,
!                }
! 
!   def _createWidget(self, object, container, textWidth, textHeight,
                     widgetWidth, widgetHeight,interface,spacer,initialize=1):
      global _NOTEBOOK
  
      if object.tabbed:
!       tabstyle =self.tabStyles[object.tabbed]
!       newWidget = 
wxNotebook(container,-1,wxPoint(10,10),size=container.GetSize(),style=tabstyle)
!       newWidget.Show(TRUE)
!       EVT_NOTEBOOK_PAGE_CHANGING(newWidget, newWidget.GetId(), 
self.notebookTabHandler)
  
!       _NOTEBOOK  = newWidget
      else:                      
        newWidget = wxPanel(interface.mainWindow.panel,-1, wxDefaultPosition)
        
      if initialize: 
        EVT_CLOSE(interface.mainWindow,interface.closeTrap)
        
      return newWidget
  
+   def notebookTabHandler(self,event):
+     if event.GetEventType() == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING:
+       print "HOO"
+       action = None
+       global _LOOPTRAP
+       
+       if _LOOPTRAP == 0:
+         action = GFEvent('requestPAGE',event.GetSelection())
+ 
+       _LOOPTRAP = not _LOOPTRAP # flip the value
+       
+     if action:
+       _EVENTPROCESSOR(action)
+ 
+ 
  #
  # UIAbout
  #
***************
*** 921,955 ****
  #
  class UIMessageBox(wxMessageDialog, UIHelper):
    def __init__(self, interface, message, caption):
! 
!     message = self.lineWrap(message,60)
      wxMessageDialog.__init__(self, interface, message, caption, 
style=wxOK|wxICON_EXCLAMATION)
! 
! 
!   # TODO: very simple line wrap
!   # TODO: should be moved to common and made more intelligent
!   def lineWrap(self,message,maxWidth):
!     text = ""
! 
!     temptext = string.strip(message)
! 
!     for strings in string.split(temptext,"\n"):
!       while len(strings) > maxWidth:
!         index = 0
!         for sep in [' ',',',':']:
!           ind = string.rfind(strings,sep,0,maxWidth-1)+1
!           if ind > index: index = ind
! 
!         if index > maxWidth:
!           index = maxWidth-1
! 
!         text += "%s\n" % strings[:index]
!         strings = strings[index:]
!         
!       text +=  "%s\n" % strings
!       
!     return text
! 
  #
  # Translate from wx keystrokes
  # to our virtual keystrokes
--- 776,784 ----
  #
  class UIMessageBox(wxMessageDialog, UIHelper):
    def __init__(self, interface, message, caption):
!     message = lineWrap(message,60)
      wxMessageDialog.__init__(self, interface, message, caption, 
style=wxOK|wxICON_EXCLAMATION)
!     
  #
  # Translate from wx keystrokes
  # to our virtual keystrokes
***************
*** 985,995 ****
             'GFScrollBar' : UIScrollBar}
  
  #####################################################################
  #####################################################################
  ##
  ## Login Support
  ##
- #####################################################################
  #####################################################################
  
  #
--- 814,903 ----
             'GFScrollBar' : UIScrollBar}
  
  #####################################################################
+ ##
+ ## Event Processing
+ ##
+ #####################################################################
+ 
+ def _setDefaultEventHandlers(newWidget, initialize):
+   global _EVENTPROCESSOR
+   if initialize:
+     # TODO: this should use one instance
+     newWidget.PushEventHandler(mouseEvtHandler(_EVENTPROCESSOR))
+     newWidget.PushEventHandler(keyboardEvtHandler(_EVENTPROCESSOR))
+ 
+ class uiBaseEvtHandler(wxEvtHandler):
+   def __init__(self,eventList,eventProcessor):
+     wxEvtHandler.__init__(self)
+     self._eventProcessor = eventProcessor
+     for eventType in eventList:
+       self.Connect(-1, -1, eventType,self._processEvent)
+                         
+   def _processEvent(self,event):
+     GDebug.printMesg(0,"uiBaseEvtHandler _processEvent was called?!?")
+   
+ class mouseEvtHandler(uiBaseEvtHandler):
+   def __init__(self,eventProcessor):
+     eventList = [wxEVT_LEFT_DOWN]
+     uiBaseEvtHandler.__init__(self, eventList, eventProcessor)
+     
+   def _processEvent(self,event):
+     global _charWidth
+     object = _eventObjTowxWindow(event)
+     
+     # compute the location of the character in the widget
+     x,y = event.GetPosition()
+     cursorPosition = 1 + x/_charWidth
+ 
+     # Move to proper object
+     id = object.GetId()
+     gfObject     = _IdToGFObj[id]
+     screenWidget = _IdToWxObj[id]
+     count        = _IdToUIObj[id].widgets.index(screenWidget)
+     self._eventProcessor(GFEvent('requestFOCUS',gfObject))
+     self._eventProcessor(GFEvent('requestJUMPRECORD',count - 
gfObject._visibleIndex))
+     self._eventProcessor(GFEvent('requestCURSORMOVE',position=cursorPosition))
+ 
+     event.Skip()
+         
+ class keyboardEvtHandler(uiBaseEvtHandler):
+   def __init__(self, eventProcessor):
+     eventList = [wxEVT_CHAR,wxEVT_KEY_DOWN]
+     uiBaseEvtHandler.__init__(self, eventList, eventProcessor)
+     
+   def _processEvent(self,event):
+     action = None
+     # hack for swig shortcomming needed by wxPython 2.2.x (2.3 does not need 
this)
+     # compute the location of the character in the widget
+     if event.GetEventType() == wxEVT_CHAR or 
event.GetEventType()==wxEVT_KEY_DOWN:
+       object = _eventObjTowxWindow(event)
+       command = GFKeyMapper.KeyMapper.getEvent(
+         event.KeyCode(),
+         event.ShiftDown(),
+         event.ControlDown(),
+         event.AltDown())
+ 
+       # TODO : Broken for the moment, this should probably be form driven 
+       #if command == 'JUMPRECORD':
+       #  self.promptForRecordNumber()
+ 
+       if command:
+         action = GFEvent('request%s' % command)
+ 
+       else:
+         try:
+           action = GFEvent('requestKEYPRESS', chr(event.KeyCode()),
+                            code=event.KeyCode())
+         except ValueError:
+           pass #event.Skip()
+         
+     if action:
+       self._eventProcessor(action)
+ 
  #####################################################################
  ##
  ## Login Support
  ##
  #####################################################################
  
  #



reply via email to

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