[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5960 - in trunk/gnue-forms/src/uidrivers: _base _commonGuiToolkit curse
From: |
reinhard |
Subject: |
r5960 - in trunk/gnue-forms/src/uidrivers: _base _commonGuiToolkit curses curses/widgets |
Date: |
Sat, 10 Jul 2004 08:10:27 -0500 (CDT) |
Author: reinhard
Date: 2004-07-10 08:10:25 -0500 (Sat, 10 Jul 2004)
New Revision: 5960
Added:
trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
Removed:
trunk/gnue-forms/src/uidrivers/curses/GFsio.py
trunk/gnue-forms/src/uidrivers/curses/common.py
trunk/gnue-forms/src/uidrivers/curses/widgets/form/
Modified:
trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/UILoginHandler.py
trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/__init__.py
trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
trunk/gnue-forms/src/uidrivers/curses/widgets/box.py
trunk/gnue-forms/src/uidrivers/curses/widgets/button.py
trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
trunk/gnue-forms/src/uidrivers/curses/widgets/label.py
trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
trunk/gnue-forms/src/uidrivers/curses/widgets/scrollbar.py
Log:
Started work on curses uidriver rewrite.
Modified: trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2004-07-09 22:21:14 UTC
(rev 5959)
+++ trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2004-07-10 13:10:25 UTC
(rev 5960)
@@ -258,7 +258,8 @@
def activateForm(self,formName, modal=0):
self._form = self._formNameToGFForm[formName]
- self._activateForm(self._form, modal)
+ self._UIform = self._formNameToUIForm[formName]
+ self._activateForm(self._UIform, modal)
#############################################################################
@@ -423,7 +424,7 @@
#
# UIDrivers must implement the following features
- def _activateForm(self,modal=0):
+ def _activateForm (self, form, modal):
GDebug.printMesg(0, "Fatal UI driver error. Required function not
implemented")
sys.exit(1)
Modified: trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/UIdriver.py
2004-07-09 22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/UIdriver.py
2004-07-10 13:10:25 UTC (rev 5960)
@@ -62,15 +62,11 @@
self._disabledColour = 0
- def _activateForm(self, form, modal=0):
- for key in self._formNameToUIForm.keys():
- if self._formNameToUIForm[key]._form == form:
- break
-
+ def _activateForm (self, form, modal):
if modal:
- self._formNameToUIForm[key].showModal()
+ form.showModal()
else:
- self._formNameToUIForm[key].show()
+ form.show()
#############################################################################
Deleted: trunk/gnue-forms/src/uidrivers/curses/GFsio.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/GFsio.py 2004-07-09 22:21:14 UTC
(rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/GFsio.py 2004-07-10 13:10:25 UTC
(rev 5960)
@@ -1,58 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
-
-import atexit
-#import curses
-from gnue.common.cursing import *
-
-
-_SIO = None
-
-def GetSIO():
- global _SIO
- if not _SIO:
- _SIO = sio()
- _SIO.BeginScreenAccess()
- atexit.register(_restore)
- return _SIO
-
-def _restore(*args, **parms):
- # Set everything back to normal
- try:
-# _SIO.keypad(0)
- curses.echo()
- curses.nocbreak()
- curses.endwin() # Terminate curses
- except:
- pass
-
-
-
-
-
Modified: trunk/gnue-forms/src/uidrivers/curses/UILoginHandler.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UILoginHandler.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/UILoginHandler.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Login Handler
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,128 +19,11 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id$
-import os
-import sys
-import string
-
-import atexit
-import curses
-from gnue.common.cursing import *
-
-from gnue.common import events
-
-from gnue.forms.GFForm import *
-
-from gnue.forms.uidrivers._commonGuiToolkit import UIdriver as commonToolkit
-from gnue.forms.uidrivers.curses.GFsio import *
-
-from gnue.common.apps import GDebug
from gnue.common.datasources import GLoginHandler
-from gnue.common.utils.TextUtils import lineWrap
-_NOTEBOOK = None
-_EVENTPROCESSOR = None
+# For now, we reuse the basic login handler
-
-#
-# UILoginHandler
-#
-class UILoginHandler(GLoginHandler.LoginHandler):
-## def __init__(self):
-## self._wxapp = getWxApp()
-## self.dlg = None
-
- def getLogin(self, loginData, errorText=None):
- 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
-
- # Get the screen
- root = GetSIO()
- screen = ScreenContainer(root)
-
- if len(loginData[1]):
- loginMesg = 'Login required for "%s"' % (loginData[1])
- else:
- loginMesg = 'Login required for %s' % (loginData[0])
-
- gnueMesg = _("GNU Enteprise Forms")
-
- dlgWidth = max(len(loginMesg), len(gnueMesg)) + 4
- dlgHeight = 5
-
- labelList = []
- textctrlList = []
- labelMsgList = []
-
- fieldLabelWidth = 0
-
- for prompt in loginData[2]:
- labelMsgList.append('%s:' % prompt[1])
- fieldLabelWidth = max(fieldLabelWidth, len ('%s:' % prompt[1]))
- dlgWidth = max(dlgWidth, fieldLabelWidth + 23)
- dlgHeight += 1
-
- lbMesg = _('Login')
- cbMesg = _('Cancel')
- dlgWidth = max(dlgWidth, len(lbMesg) + len(cbMesg) + 11) + 2
- dlgHeight += 1
-
- #
- # Create widgets
- #
-
- w = dlgWidth + 2
- h = dlgHeight + 2
- x = int(root.MAXCOL/2 - w/2 + .5)
- y = int(root.MAXROW/2 - h/2 + .5)
-
- dlg = Dialog(screen, y, x, y+h-1, x+w-1)
-
- gnueLabel = dlg.AddDialogControl(Label(dlg, "lbl1", 1,
- int((dlgWidth - len(gnueMesg))/2),
- gnueMesg))
- loginLabel = dlg.AddDialogControl(Label(dlg, "lbl1", 2,
- int((dlgWidth - len(loginMesg))/2),
- loginMesg))
-
- firstY = 4
- lastY = firstY
- xPos = int(dlgWidth/2 - fieldLabelWidth/2) - 11
-
- for prompt in loginData[2]:
- s = dlg.AddDialogControl(Label(dlg,"lbl2",lastY, xPos,'%s:' %
prompt[1]))
- labelList.append(s)
- t = dlg.AddDialogControl(TextBox(dlg, "inp", lastY, xPos +
fieldLabelWidth + 2, 20, Password=prompt[2]))
- textctrlList.append(t)
- lastY += 1
-
- loginButton = dlg.AddDialogControl(Button(dlg,"LoginButton",dlgHeight -
1,dlgWidth - len(cbMesg) - len(lbMesg) - 10,len(lbMesg)+4,lbMesg))
- loginButton.EXITFORM = 1
- cancelButton = dlg.AddDialogControl(Button(dlg,"CancelButton",dlgHeight
- 1,dlgWidth - len(cbMesg) - 5,len(cbMesg)+4,cbMesg))
- cancelButton.EXITFORM = 1
-
- t = dlg.RunDialog()
-
- if dlg.Controls[t] == cancelButton:
- raise GLoginHandler.UserCanceledLogin
-
- rv = {}
- for i in range(0, len(loginData[2])):
- rv[loginData[2][i][0]] = textctrlList[i].TEXT
-
- return rv
-
-
-
+class UILoginHandler (GLoginHandler.BasicLoginHandler):
+ pass
Property changes on: trunk/gnue-forms/src/uidrivers/curses/UILoginHandler.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2004-07-09 22:21:14 UTC
(rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2004-07-10 13:10:25 UTC
(rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - User Interface
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,226 +19,78 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id$
-import os
-import sys
-import string
+import curses
-import atexit
+from gnue.forms.uidrivers._base.UIdriver import GFUserInterfaceBase
-from gnue.forms.uidrivers._base import Exceptions
+# =============================================================================
+# User interface object
+# =============================================================================
-try:
- import curses
-except ImportError:
- raise Exceptions.DriverNotSupported, _("The GNUe-Forms Curses driver
requires Python 2.1+ and the ncurses library.")
+class GFUserInterface (GFUserInterfaceBase):
-from gnue.common.cursing import *
+ # ---------------------------------------------------------------------------
+ # Initialize user interface
+ # ---------------------------------------------------------------------------
-from gnue.common import events
+ def initialize (self):
+ self.widgetWidth = 1
+ self.widgetHeight = 1
+ self.textWidth = 1
+ self.textHeight = 1
+ self.__screen = curses.initscr ()
+ self.__screen.keypad (True)
-from gnue.forms.GFForm import *
+ # ---------------------------------------------------------------------------
+ # Activate the given form
+ # ---------------------------------------------------------------------------
-from gnue.forms.uidrivers._commonGuiToolkit import UIdriver as commonToolkit
-from gnue.forms.uidrivers.curses.GFsio import *
-from gnue.forms.uidrivers.curses.common import _EVENTPROCESSOR
+ def _activateForm (self, form, modal):
+ self.__currentForm = form
-from gnue.common.apps import GDebug
-from gnue.common.datasources import GLoginHandler
-from gnue.common.utils.TextUtils import lineWrap
+ # ---------------------------------------------------------------------------
+ # Clean up everything
+ # ---------------------------------------------------------------------------
-_NOTEBOOK = None
-_EVENTPROCESSOR = None
-global _EVENTPROCESSOR
+ def _exit (self):
+ curses.endwin ()
-#
-# GFUserInterface
-#
-# The public interface to the User Interface
-# All UIs must provide this class
-#
-class GFUserInterface(commonToolkit.GFUserInterface):
+ # ---------------------------------------------------------------------------
+ # Main loop
+ # ---------------------------------------------------------------------------
- _objectMapping = {}
+ def mainLoop (self):
+ self.__currentForm.wait ()
+ self._exit ()
+ # ---------------------------------------------------------------------------
+ # Display warning message
+ # ---------------------------------------------------------------------------
- #
- # initialize
- #
- def initialize(self):
+ def formAlert (self, event):
+ curses.beep ()
+ curses.flash ()
- global _EVENTPROCESSOR
- _EVENTPROCESSOR = self.dispatchEvent
+ # ---------------------------------------------------------------------------
+ # Indicate start of nonresponsive phase
+ # ---------------------------------------------------------------------------
- #
- # Create the main window
- #
-
- self._SIO = self._screen = GetSIO() # Must happen before the
curses.termname() call
- # in the next line.
- GDebug.printMesg(1,'Initializing curses interface (TERM=%s)' %
curses.termname())
- self._SIO.Cls()
-
- #
- # SplashScreen
- #
- if self._disableSplash:
- text = 'GNU Enterprise Forms\n' \
- + 'Version %s\n' % VERSION \
- + '(c)2000-2004 Free Software Foundation\n' \
- + 'Protected by GNU General Public Licence 2.0\n'
-
- #MsgBoxOK(self.mainWindow, text).Show()
-
- self.widgetWidth = 1 # The width of a 1 char widget (for things like
buttons)
- self.widgetHeight = 1 # The pixel height of a 1 char widget (for things
like buttons)
- self.textWidth = 1 # The pixel width of text inside a widget
- self.textHeight = 1 # The pixel height of text inside a widget
-
- #self.mainWindow.panel = MyDialog(self.mainWindow, 0, 0,
self._screen.MAXROW, self._screen.MAXCOL )
-
- #############################################################################
- #
- # Private UIBase support functions
- #
- # Called in UIbase functions to perform UI interaction with this specific
- # widget set.
- #
-
- #
- # _exit
- #
- # Tells the application to close it's main window
- #
- def _exit(self):
- self.mainWindow.EndScreenAccess()
-
-
- def _setStatusBar(self,*args):
- pass
-
-
- # Can be used by UI drivers to add more attributes to the creation event.
- def _updateCreateEvent(self, event):
- event.eventHandler = self.dispatchEvent
- event.ui = self
- event.formWidth = int(self._form._layout.Char__width)
- event.formHeight = int(self._form._layout.Char__height)
- event.screenHeight = self._screen.MAXROW - 3
- event.screenWidth = self._screen.MAXCOL
- return event
-
-
- #############################################################################
- #
- # Incoming Event Processors
- #
- # Processes the incoming events from other objects
- #
-
- #
- # mainLoop
- #
- # The primary loop of the user interface. Called once the UI is
- # fully activated
- #
- def mainLoop(self):
- self._children[0].mainWindow.Run()
- pass
-
-
- #
- # gotoPage
- #
- # makes the requested page visible on the screen
- #
- def gotoPage(self, event):
- self.visiblePage.Hide()
- self.visiblePage = self._objectMapping[event.data]
- self.visiblePage.Show()
-
-## 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:
-## self.visiblePage = self._formToUI[event.data][0]
-## for count in range(_NOTEBOOK.GetPageCount()):
-## if self.visiblePage.GetId() == _NOTEBOOK.GetPage(count).GetId():
-## _NOTEBOOK.SetSelection(count)
-## break
-## self.visiblePage.Show(1)
-
- #
- # formAlert
- #
- # Rings a bell and alters the statusbar to display
- # a line of text
- #
- def formAlert(self, event):
- curses.beep()
- curses.flash()
-
-
- # 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):
pass
+ # ---------------------------------------------------------------------------
+ # Indicate end of nonresponsive phase
+ # ---------------------------------------------------------------------------
- # Called whenever forms leaves a "wait" state
def endWait (self, event):
pass
+ # ---------------------------------------------------------------------------
+ # Helper method to create a new pad
+ # ---------------------------------------------------------------------------
- #############################################################################
- #
- # Internal Event Processors
- #
- # Processes the events from the widget set
- #
-
- #
- # menuExitEvent
- #
- # Catches the Exit event from the menu and make sure it closes in such a way
to
- # trigger the closeTrap method
- #
- def menuExitEvent(self, event):
- self.mainWindow.Close()
-
- #
- # promptForRecordNumber
- #
- # Presents a dialog to user asking for the record number to jump to
- #
- def promptForRecordNumber(self, event= None):
- pass
-
-
- #
- # closeTrap
- #
- # intercepts the applications closure and generates an event to the form
requesting
- # closure. Allows the form to control closure. If the form approves it'll
send
- # back an event closing the application
- #`
- def closeTrap(self,event):
- pass
-## object = _eventObjTowxWindow(event)
-## if event.CanVeto():
-## self.dispatchEvent(events.Event('requestEXIT'))
-## else:
-## object.Destroy()
+ def createPad (self):
+ (y, x) = self.__screen.getmaxyx ()
+ return curses.newpad (y, x)
Property changes on: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/curses/__init__.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/__init__.py 2004-07-09 22:21:14 UTC
(rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/__init__.py 2004-07-10 13:10:25 UTC
(rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,20 +19,7 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# __init__.py
-#
-# DESCRIPTION:
-"""
- A curses based user interface driver for GNUe forms.
-"""
-#
-# NOTES:
-#
+# $Id$
-
from UIdriver import GFUserInterface
-from UILoginHandler import *
-
+from UILoginHandler import UILoginHandler
Property changes on: trunk/gnue-forms/src/uidrivers/curses/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: trunk/gnue-forms/src/uidrivers/curses/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/common.py 2004-07-09 22:21:14 UTC
(rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/common.py 2004-07-10 13:10:25 UTC
(rev 5960)
@@ -1,208 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
-
-import os
-import sys
-import string
-
-import curses
-from gnue.common.cursing import *
-
-from gnue.common import events
-
-from gnue.forms.GFForm import *
-
-from gnue.forms.uidrivers._commonGuiToolkit import UIdriver as commonToolkit
-#from gnue.forms.uidrivers.curses.common import _EVENTPROCESSOR
-
-from gnue.common.apps import GDebug
-from gnue.common.datasources import GLoginHandler
-from gnue.common.utils.TextUtils import lineWrap
-
-_NOTEBOOK = None
-_LOOPTRAP = 0
-_EVENTPROCESSOR = None
-_charWidth = 0
-_IdToTkObj = {}
-_IdToGFObj = {}
-_IdToUIObj = {}
-
-#
-
-_SIO = None
-
-def GetSIO():
- global _SIO
- if not _SIO:
- _SIO = sio()
- _SIO.BeginScreenAccess()
- atexit.register(_restore)
- return _SIO
-
-def _restore(*args, **parms):
- # Set everything back to normal
- try:
-# _SIO.keypad(0)
- curses.echo()
- curses.nocbreak()
- curses.endwin() # Terminate curses
- except:
- pass
-
-
-#####################################################################
-##
-## Basic Event Processing
-##
-#####################################################################
-
-def _setDefaultEventHandlers(newWidget, initialize):
- global _EVENTPROCESSOR
- if initialize:
- newWidget.SetMethod("CLICK", mouseEvtHandler(_EVENTPROCESSOR))
-
-
-class uiBaseEvtHandler:
- def __init__(self,eventList,eventProcessor):
- pass
-## wxEvtHandler.__init__(self)
-## self._eventProcessor = eventProcessor
-## for eventType in eventList:
-## self.Connect(-1, -1, eventType,self._processEvent)
-
-## def _processEvent(self,a1, a2, a3):
-## GDebug.printMesg(0,"uiBaseEvtHandler _processEvent was called?!?")
-
-class mouseEvtHandler(uiBaseEvtHandler):
- def __init__(self,eventProcessor):
- pass
-## 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 = _IdToTkObj[id]
-## count = _IdToUIObj[id].widgets.index(screenWidget)
-## self._eventProcessor(events.Event('requestFOCUS',gfObject))
-## self._eventProcessor(events.Event('requestJUMPRECORD',count -
gfObject._visibleIndex))
-##
self._eventProcessor(events.Event('requestCURSORMOVE',position=cursorPosition))
-
-## event.Skip()
-
-class keyboardEvtHandler(uiBaseEvtHandler):
- def __init__(self, eventProcessor):
- self._eventProcessor = eventProcessor
- uiBaseEvtHandler.__init__(self, [], eventProcessor)
-
- def _processEvent(self, keystroke):
- ####return keystroke
- action = None
-
- ##object = _eventObjTowxWindow(event)
-
-
- gDebug(0,"key====== %s" % keystroke)
- command = GFKeyMapper.KeyMapper.getEvent(
- keystroke,
- 0, #event.ShiftDown(),
- 0, #event.ControlDown(),
- 0) #event.AltDown())
-
- gDebug(0,"========= %s" % command)
-
- # TODO : Broken for the moment, this should probably be form driven
- #if command == 'JUMPRECORD':
- # self.promptForRecordNumber()
-
- if command:
- action = events.Event('request%s' % command)
-
- else:
- try:
- GDebug.printMesg(1,'Keystroke=(%s,%s)' % (keystroke, chr(keystroke)))
- if 32 <= keystroke <= 255 and chr(keystroke) in string.printable:
- GDebug.printMesg(1,'Keystroke is printable')
- action = events.Event('requestKEYPRESS', chr(keystroke),
- text=chr(keystroke),
- code=keystroke)
- except ValueError:
- 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
-
-#####################################################################
-##
-## Keymapper Support
-##
-#####################################################################
-from gnue.forms import GFKeyMapper
-from gnue.forms.GFKeyMapper import vk
-
-# Translate from curses keystrokes to our virtual keystrokes
-cursesKeyTranslations = {
- vk.F1 : curses.KEY_F1, vk.F2 : curses.KEY_F2,
- vk.F3 : curses.KEY_F3, vk.F4 : curses.KEY_F4,
- vk.F5 : curses.KEY_F5, vk.F6 : curses.KEY_F6,
- vk.F7 : curses.KEY_F7, vk.F8 : curses.KEY_F8,
- vk.F9 : curses.KEY_F9, vk.F10 : curses.KEY_F10,
- vk.F11 : curses.KEY_F11, vk.F12 : curses.KEY_F12,
- vk.INSERT : curses.KEY_IC, vk.DELETE : curses.KEY_DC,
- vk.HOME : curses.KEY_HOME, vk.END : curses.KEY_END,
- vk.PAGEUP : curses.KEY_PPAGE, vk.PAGEDOWN : curses.KEY_NPAGE,
- vk.UP : curses.KEY_UP, vk.DOWN : curses.KEY_DOWN,
- vk.LEFT : curses.KEY_LEFT, vk.RIGHT : curses.KEY_RIGHT,
- vk.TAB : 9, vk.ENTER : 10,
- vk.BACKSPACE : curses.KEY_BACKSPACE }
-
-
-GFKeyMapper.KeyMapper.setUIKeyMap(cursesKeyTranslations)
-
-
-
-
-
-
-
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Widget Base
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,58 +19,39 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# _base.py
-#
-# DESCRIPTION:
-# Provides UIHelper, a UI widget set of std functions to reduce the
-# number of functions require in each individual UIclass
-#
-# NOTES:
-#
+# $Id$
-from gnue.common.cursing import *
+from gnue.forms.uidrivers._base.widgets._base import UIWidget
-from gnue.forms.GFForm import *
-from gnue.forms.uidrivers._base.widgets._base import *
-from gnue.common import events
+# =============================================================================
+# Widget helper class
+# =============================================================================
+class UIHelper (UIWidget):
-class UIHelper(UIWidget):
- def showModal(self):
- pass # self.ShowModal()
+ # ---------------------------------------------------------------------------
+ # Initialize widget
+ # ---------------------------------------------------------------------------
- def show(self, flag=1):
- pass # self.Show(flag)
+ def createWidget (self, event, spacer):
+ self._interface = event.interface
+ self._GFobject = event.object
+ self._parent = event.parent
+ self._spacer = spacer
+ self._init ()
- def destroy(self):
- pass # self.Destroy()
+ # ---------------------------------------------------------------------------
+ # Set text for widget
+ # ---------------------------------------------------------------------------
- def indexedFocus(self, index):
- GDebug.printMesg(0, "Widget list %s" % self.widgets)
- GDebug.printMesg(0, "Index %s" % index)
- widget = self.widgets[index]
- widget.PARENT.SetFocus(widget,run=False)
+ def setValue (self, value, index = 0, enabled = True):
+ x = self._GFobject ['Char:x']
+ y = self._GFobject ['Char:y'] + self._spacer
+ self._parent.write (x, y, value)
- def setValue(self, value, index=0, enabled=True):
- self.widgets[index].SetValue(value)
+ # ---------------------------------------------------------------------------
+ # Set focus to widget
+ # ---------------------------------------------------------------------------
- def setCursorPosition(self, position, index=0):
- try:
- self.widgets[index].SetCursor(position)
- except AttributeError:
- pass
-
- def setSelectedArea(self, selection1, selection2, index=0):
+ def indexedFocus (self, index):
pass
-
- def _addToCrossRef(self, widget,gfobject, uiobject):
- pass
-
-
- def createWidget(self, event, spacer):
- newWidget = self._createWidget(event, spacer)
- self._addToCrossRef(newWidget,event.object,self)
- return newWidget
Property changes on: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/box.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/box.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Box Widget
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,38 +19,22 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id$
-from gnue.common.cursing import *
+from _base import UIHelper
-from gnue.forms.uidrivers.curses.widgets._base import UIHelper
+# =============================================================================
+# Box class
+# =============================================================================
-#
-# UIBox
-#
-# Widget set specific function that creates a single instance of a border box
-#
-class UIBox(UIHelper):
- def _createWidget(self, event, spacer):
- object = event.object
- newWidget =
GroupBox(event.container,'name',object["Char:y"],object["Char:x"],
- object["Char:width"],
object["Char:height"],str(object.label))
- gDebug(0,'****PARENT: %s' % object)
- event.container.AddControl(newWidget)
- return newWidget
+class UIBox (UIHelper):
+ def _init (self):
+ pass
-#
+# =============================================================================
# Configuration data
-#
+# =============================================================================
+
configuration = {
'baseClass' : UIBox,
'provides' : 'GFBox',
Property changes on: trunk/gnue-forms/src/uidrivers/curses/widgets/box.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/button.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/button.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Button Widget
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,43 +19,22 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id$
-from gnue.common.cursing import *
+from _base import UIHelper
-from gnue.forms.uidrivers.curses.widgets._base import UIHelper
-from gnue.forms.uidrivers.curses.common import _EVENTPROCESSOR
-global _EVENTPROCESSOR
+# =============================================================================
+# Button class
+# =============================================================================
-#
-# UIButton
-#
-# Widget set specific function that creates a single instance of a button
-#
-class UIButton(UIHelper):
- def _createWidget(self, event, spacer):
- object = event.object
- newWidget =
Button(event.container,'name',object["Char:y"]+spacer,object["Char:x"],object["Char:width"],str(object.label))
- event.container.AddControl(newWidget)
- self.__gf = object
- newWidget.SetMethod("CLICK", self.buttonHandler)
- return newWidget
+class UIButton (UIHelper):
+ def _init (self):
+ pass
- def buttonHandler(self, a1, a2, a3):
- global _EVENTPROCESSOR
- GDebug.printMesg(1,"Click!")
+# =============================================================================
+# Configuration data
+# =============================================================================
- _EVENTPROCESSOR(events.Event('buttonActivated',self.__gf))
-
configuration = {
'baseClass' : UIButton,
'provides' : 'GFButton',
Property changes on: trunk/gnue-forms/src/uidrivers/curses/widgets/button.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Entry Widget
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,51 +19,27 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id$
-from gnue.common.cursing import *
+from _base import UIHelper
-from gnue.forms.uidrivers.curses.widgets._base import UIHelper
+# =============================================================================
+# Entry class
+# =============================================================================
-#
-# UIEntry
-#
-# Widget set specific function that creates a single instance of a data entry
widget
-#
-class UIEntry(UIHelper):
- def _createWidget(self, event, spacer):
- object = event.object
+class UIEntry (UIHelper):
+ def _init (self):
+ pass
- style = object.style
- if style == 'dropdown':
- if event.initialize:
- choices = object._field.allowedValues()[1]
- else:
- choices = [""]
- newWidget = ComboBox(event.container,
'name',object["Char:y"]+spacer,object["Char:x"], object["Char:width"])
- for index in range(len(choices)):
- newWidget.AddItem(index,choices[index])
- elif style == 'label':
- newWidget = TextBox(event.container, 'name', object["Char:y"]+spacer,
object["Char:x"], object["Char:width"])
- elif style == 'checkbox':
- newWidget = CheckBox(event.container,
'name',object["Char:y"]+spacer,object["Char:x"],'',0)
- elif hasattr(object,'["Char:height"]') and object["Char:height"] > 1: #
Normal text box/Multiline
- newWidget = TextArea(event.container, 'name', object["Char:y"]+spacer,
object["Char:x"], object["Char:width"], object["Char:height"])
- else: # Normal text box
- newWidget = TextBox(event.container, 'name', object["Char:y"]+spacer,
object["Char:x"], object["Char:width"])
+ def setCursorPosition (self, position, index = 0):
+ pass
- event.container.AddControl(newWidget)
+ def setSelectedArea (self, selection1, selection2, index = 0):
+ pass
- return newWidget
+# =============================================================================
+# Configuration data
+# =============================================================================
configuration = {
'baseClass' : UIEntry,
Property changes on: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -0,0 +1,72 @@
+# GNU Enterprise Forms - Curses UI Driver - Form Widget
+#
+# Copyright 2000-2004 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: $
+
+from gnue.forms.uidrivers._base.widgets._base import UIWidget
+
+# =============================================================================
+# Form class
+# =============================================================================
+
+class UIForm (UIWidget):
+
+ # ---------------------------------------------------------------------------
+ # Initialize form
+ # ---------------------------------------------------------------------------
+
+ def createWidget (self, event, spacer):
+ self.__pages = []
+ self.__currentPage = None
+
+ # ---------------------------------------------------------------------------
+ # Set status bar
+ # ---------------------------------------------------------------------------
+
+ def _setStatusBar (self, tip, statusValue, insertValue, currentRecord,
+ maxRecord, currentPage, maxPage):
+ pass
+
+ # ---------------------------------------------------------------------------
+ # Add a page to the form
+ # ---------------------------------------------------------------------------
+
+ def addPage (self, page):
+ self.__pages.append (page)
+ if not self.__currentPage:
+ self.__currentPage = page
+
+ # ---------------------------------------------------------------------------
+ # Update screen and wait for user input
+ # ---------------------------------------------------------------------------
+
+ def wait (self):
+ return self.__currentPage.wait ()
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass' : UIForm,
+ 'provides' : 'GFForm',
+ 'container' : 1,
+ }
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/label.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/label.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/label.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Label Widget
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,42 +19,22 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id: $
-from gnue.common.cursing import *
+from _base import UIHelper
-from gnue.forms.uidrivers.curses.widgets._base import UIHelper
-
-#
-# UILabel
-#
-# Widget set specific function that creates a single instance of a label
-#
-class UILabel(UIHelper):
- alignmentStyle = { 'left' : 0,
- 'center': 0,
- 'right' : 0,
- }
+# =============================================================================
+# Label class
+# =============================================================================
- def _createWidget(self, event, spacer):
- object = event.object
- style = self.alignmentStyle[object.alignment]
- gDebug(0,"*****Label Alert!!! (x,y)=(%s,%s) %s" % (object["Char:x"],
- object["Char:y"],event.container))
- newWidget = Label(event.container,str(self),object["Char:y"]+spacer,
- object["Char:x"],str(object.text))
- event.container.AddControl(newWidget)
- return newWidget
+class UILabel (UIHelper):
+ def _init (self):
+ self.setValue (self._GFobject.text)
+# =============================================================================
+# Configuration data
+# =============================================================================
+
configuration = {
'baseClass' : UILabel,
'provides' : 'GFLabel',
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Page Widget
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,67 +19,46 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id: $
-from gnue.common.apps import GDebug
-from gnue.common.cursing import *
-from gnue.forms.uidrivers.curses.widgets._base import UIHelper
-from gnue.forms.uidrivers.curses.common import keyboardEvtHandler
-from gnue.forms.uidrivers.curses.common import _EVENTPROCESSOR
-global _EVENTPROCESSOR
-#
-# 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):
- def _createWidget(self, event, spacer):
- object = event.object
+import curses
- GDebug.printMesg(0, "PAGE OBJECT %s" % object)
-
- width = event.formWidth + 2
- height = event.formHeight + 2
- x = int(event.screenWidth/2 - width/2)
- y = int(event.screenHeight/2 - height/2)
+from _base import UIHelper
- # For the menu bar
- if y < 2:
- y = 2
- # For sanity
- if x < 0:
- x = 0
- if y + height > event.screenHeight - 3:
- height = event.screenHeight - 3
- if x + width > event.screenWidth- 2:
- width = event.screenWidth
+# =============================================================================
+# Page class
+# =============================================================================
+class UIPage (UIHelper):
- newWidget = self._uiForm._wrapper.createPage(object)
+ # ---------------------------------------------------------------------------
+ # Initialize page
+ # ---------------------------------------------------------------------------
- ###newWidget.DeActivate(0)
- ###event.interface._pageList.append(newWidget)
- event.interface._objectMapping[object] = newWidget
- event.interface._objectMapping[newWidget] = object
+ def _init (self):
+ self.__window = self._interface.createPad ()
+ self._parent.addPage (self)
- ####
- global _EVENTPROCESSOR
- newWidget.KeystrokeHook = keyboardEvtHandler(_EVENTPROCESSOR)._processEvent
- self._containerToolkitWidget = newWidget
+ # ---------------------------------------------------------------------------
+ # Write a text to a given position
+ # ---------------------------------------------------------------------------
- return newWidget
+ def write (self, x, y, text):
+ self.__window.addstr (y, x, text)
+ # ---------------------------------------------------------------------------
+ # Update screen and wait for user input
+ # ---------------------------------------------------------------------------
+
+ def wait (self):
+ (y, x) = self.__window.getmaxyx ()
+ self.__window.refresh (0, 0, 0, 0, y, x)
+ return self.__window.getch ()
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
configuration = {
'baseClass' : UIPage,
'provides' : 'GFPage',
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/scrollbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/scrollbar.py 2004-07-09
22:21:14 UTC (rev 5959)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/scrollbar.py 2004-07-10
13:10:25 UTC (rev 5960)
@@ -1,4 +1,7 @@
+# GNU Enterprise Forms - Curses UI Driver - Scrollbar Widget
#
+# Copyright 2000-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,44 +19,24 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2004 Free Software Foundation
-#
-# FILE:
-# UIdriver.py
-#
-# DESCRIPTION:
-# A curses based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id: $
-from gnue.common.cursing import *
+from _base import UIHelper
-from gnue.forms.uidrivers.curses.widgets._base import UIHelper
+# =============================================================================
+# Scrollbar class
+# =============================================================================
-#
-# UIScrollBar
-#
-# Widget set specific function that creates a single instance of a scroll bar
used
-# to navigate multiple records
-#
-class UIScrollBar(UIHelper):
- def _createWidget(self, event, spacer):
- object = event.object
+class UIScrollBar (UIHelper):
+ def _init (self):
+ pass
- if object["Char:width"] > 1:
- newWidget = ScrollBar(event.container,'name',object['Char:y'],
- object['Char:x'],object['Char:width'])
- else:
- newWidget = VScrollBar(event.container,'name',object['Char:y'],
- object['Char:x'],object['Char:width'])
- event.container.AddControl(newWidget)
- newWidget.Init(10) ## TODO: This should be the number of rows
- return newWidget
+# =============================================================================
+# Configuration data
+# =============================================================================
configuration = {
'baseClass' : UIScrollBar,
'provides' : 'GFScrollBar',
'container' : 0,
}
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5960 - in trunk/gnue-forms/src/uidrivers: _base _commonGuiToolkit curses curses/widgets,
reinhard <=