[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue common/src/cursing/Menu.py common/src/curs...
From: |
Jason Cater |
Subject: |
gnue common/src/cursing/Menu.py common/src/curs... |
Date: |
Sun, 13 Oct 2002 23:59:23 -0400 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/10/13 23:59:23
Modified files:
common/src/cursing: Menu.py MenuBar.py MenuItem.py
ScreenContainer.py TextArea.py TextBox.py
forms/src/uidrivers/nstti: UIdriver.py
Log message:
more work on curses driver
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/Menu.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/MenuBar.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/MenuItem.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/ScreenContainer.py.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/TextArea.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/TextBox.py.diff?cvsroot=OldCVS&tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/forms/src/uidrivers/nstti/UIdriver.py.diff?cvsroot=OldCVS&tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: gnue/common/src/cursing/Menu.py
diff -c gnue/common/src/cursing/Menu.py:1.3 gnue/common/src/cursing/Menu.py:1.4
*** gnue/common/src/cursing/Menu.py:1.3 Wed Oct 9 23:42:11 2002
--- gnue/common/src/cursing/Menu.py Sun Oct 13 23:59:23 2002
***************
*** 32,37 ****
--- 32,38 ----
from Dialog import Dialog
from MenuItem import MenuItem
from ScreenContainer import *
+ import sio
class Menu(FocusedLabel):
def __init__(self,Parent,MenuName,Y,X,DisplayName = "", **properties):
***************
*** 58,64 ****
return 0
ch = Container.GetChar()
if self.PARENT.BreakOrder(ch) :
! return
if ch in (Container.TokNextField, Container.TokRightArrow):
BACKWARDS=0
return
--- 59,65 ----
return 0
ch = Container.GetChar()
if self.PARENT.BreakOrder(ch) :
! return
if ch in (Container.TokNextField, Container.TokRightArrow):
BACKWARDS=0
return
***************
*** 81,88 ****
Y = self.Y + 1
Parent = self.PARENT
Screen = Parent.SCREEN
! self.myscreen = Screen.CaptureScreen( Y, X, Y + MenuHeight ,
! X + MenuWidth )
MenuWin = Dialog(Parent, Y, X, Y + MenuHeight, X + MenuWidth )
count = 1
self.EXITFORM = 0
--- 82,89 ----
Y = self.Y + 1
Parent = self.PARENT
Screen = Parent.SCREEN
! self.myscreen = Screen.CaptureScreen( Y, X, Y + MenuHeight ,
! X + MenuWidth )
MenuWin = Dialog(Parent, Y, X, Y + MenuHeight, X + MenuWidth )
count = 1
self.EXITFORM = 0
***************
*** 93,105 ****
else:
newTitle = self.items[i][1]
text = self.__FixDisplay(newTitle)
! item = MenuItem(MenuWin,str(self.items[i][0]),count,2,text)
item.ITEMID = self.items[i][0]
count += 1
item.SetMethod("CLICK",self.ItemSelected)
MenuWin.AddDialogControl(item)
! item.DeActivate(self.items[i][2])
! MenuWin.SetColor(colorLow)
MenuWin.INSET = 1
MenuWin.RunDialog()
Parent.Paint()
--- 94,108 ----
else:
newTitle = self.items[i][1]
text = self.__FixDisplay(newTitle)
! item = MenuItem(MenuWin,str(self.items[i][0]),count,2,text,
! self.items[i][2], (self.PARENT.STATUSBAR,
! self.PARENT.STATUSBAR_INDEX))
item.ITEMID = self.items[i][0]
count += 1
item.SetMethod("CLICK",self.ItemSelected)
MenuWin.AddDialogControl(item)
! item.DeActivate(self.items[i][3])
! MenuWin.SetColor(sio.C_MENUBAR)
MenuWin.INSET = 1
MenuWin.RunDialog()
Parent.Paint()
***************
*** 112,118 ****
oldLen = self.maxLength - 4
if newLen >= oldLen:
oldLen -= 3
! oldLen = oldLen / 2
erg = newTitle[:oldLen] + '...' + newTitle[-oldLen:]
else:
erg = newTitle + (oldLen-newLen)*' '
--- 115,121 ----
oldLen = self.maxLength - 4
if newLen >= oldLen:
oldLen -= 3
! oldLen = oldLen / 2
erg = newTitle[:oldLen] + '...' + newTitle[-oldLen:]
else:
erg = newTitle + (oldLen-newLen)*' '
***************
*** 129,146 ****
Parent = self.PARENT
Screen = Parent.SCREEN
Screen.RestoreScreen(Y,X, Y + MenuHeight , X + MenuWidth ,
! self.myscreen )
if(self.GetMethod("CHOSEN") <> None):
apply(self.GetMethod("CHOSEN"),(self,control.ITEMID,control.TITLE))
def DeActivateItem(self,itemId,state):
for i in range(0,len(self.items)):
if self.items[i][0] == itemId:
! self.items[i][2] = state
return
! def AddItem(self, itemId, itemCaption, initialState = 1):
! self.items.append( [ itemId, itemCaption, initialState ] )
if not self.maxLengthFixed and self.maxLength < len(itemCaption)+4:
self.maxLength = len(itemCaption)+4
--- 132,149 ----
Parent = self.PARENT
Screen = Parent.SCREEN
Screen.RestoreScreen(Y,X, Y + MenuHeight , X + MenuWidth ,
! self.myscreen )
if(self.GetMethod("CHOSEN") <> None):
apply(self.GetMethod("CHOSEN"),(self,control.ITEMID,control.TITLE))
def DeActivateItem(self,itemId,state):
for i in range(0,len(self.items)):
if self.items[i][0] == itemId:
! self.items[i][3] = state
return
! def AddItem(self, itemId, itemCaption, itemDescription = "", initialState =
1):
! self.items.append( [ itemId, itemCaption, itemDescription, initialState ]
)
if not self.maxLengthFixed and self.maxLength < len(itemCaption)+4:
self.maxLength = len(itemCaption)+4
Index: gnue/common/src/cursing/MenuBar.py
diff -c gnue/common/src/cursing/MenuBar.py:1.3
gnue/common/src/cursing/MenuBar.py:1.4
*** gnue/common/src/cursing/MenuBar.py:1.3 Wed Oct 9 23:42:11 2002
--- gnue/common/src/cursing/MenuBar.py Sun Oct 13 23:59:23 2002
***************
*** 43,49 ****
self.H = 2
self.W = 0
self.menus = []
!
def NewMenu(self,Name,Caption):
newEntry = Menu(self.rootwin, Name, 0,0, Caption)
self._AddMenu(newEntry)
--- 43,49 ----
self.H = 2
self.W = 0
self.menus = []
!
def NewMenu(self,Name,Caption):
newEntry = Menu(self.rootwin, Name, 0,0, Caption)
self._AddMenu(newEntry)
***************
*** 53,58 ****
--- 53,62 ----
self.screen.PrintAt(self.Y+1,
self.X,
(self.W+2)*chr(tiHLINE))
+
+ def SetStatusBar(self, statusbar, index=0):
+ self.STATUSBAR = statusbar
+ self.STATUSBAR_INDEX = index
def _AddMenu(self,menu):
self.menus.append(menu)
Index: gnue/common/src/cursing/MenuItem.py
diff -c gnue/common/src/cursing/MenuItem.py:1.2
gnue/common/src/cursing/MenuItem.py:1.3
*** gnue/common/src/cursing/MenuItem.py:1.2 Wed Oct 9 23:04:41 2002
--- gnue/common/src/cursing/MenuItem.py Sun Oct 13 23:59:23 2002
***************
*** 31,39 ****
from FocusedLabel import FocusedLabel
class MenuItem(FocusedLabel):
! def __init__(self,Parent,MenuName,Y,X,DisplayName = "", **properties):
apply(FocusedLabel.__init__, (self,Parent,MenuName,Y,X,DisplayName),
properties)
self.TITLE = DisplayName
def Run(self,v1,v2,v3):
Container = self.PARENT.Screen()
--- 31,42 ----
from FocusedLabel import FocusedLabel
class MenuItem(FocusedLabel):
! def __init__(self,Parent,MenuName,Y,X,DisplayName = "", itemDescription="",
! statusbar_info=(None, None), **properties):
apply(FocusedLabel.__init__, (self,Parent,MenuName,Y,X,DisplayName),
properties)
self.TITLE = DisplayName
+ self.DESCRIPTION = itemDescription
+ (self.STATUSBAR, self.STATUSBAR_INDEX) = statusbar_info
def Run(self,v1,v2,v3):
Container = self.PARENT.Screen()
***************
*** 43,49 ****
while 1:
ch = Container.GetChar()
if self.PARENT.BreakOrder(ch) :
! return
global BACKWARDS
if ch in (Container.TokRightArrow, Container.TokLeftArrow):
BACKWARDS=0
--- 46,52 ----
while 1:
ch = Container.GetChar()
if self.PARENT.BreakOrder(ch) :
! return
global BACKWARDS
if ch in (Container.TokRightArrow, Container.TokLeftArrow):
BACKWARDS=0
***************
*** 69,74 ****
--- 72,79 ----
if self.active:
if HasFocus :
self.SetColor(2)
+ if self.STATUSBAR:
+ self.STATUSBAR.SetText(self.STATUSBAR_INDEX, self.DESCRIPTION)
else:
self.SetColor(1)
else:
Index: gnue/common/src/cursing/ScreenContainer.py
diff -c gnue/common/src/cursing/ScreenContainer.py:1.5
gnue/common/src/cursing/ScreenContainer.py:1.6
*** gnue/common/src/cursing/ScreenContainer.py:1.5 Thu Oct 10 21:46:06 2002
--- gnue/common/src/cursing/ScreenContainer.py Sun Oct 13 23:59:23 2002
***************
*** 29,34 ****
--- 29,38 ----
from gnue.common import GDebug
import math
import curses
+ ##try:
+ ## from curses import panel
+ ##except ImportError:
+ ## raise "The use of curses requires at least Python 2.1"
from constants import *
import sio
***************
*** 57,62 ****
--- 61,67 ----
self.nextCtl = None
self.eventX = -1
self.eventY = -1
+ self._CurrentFocus = None
***************
*** 125,131 ****
return self.Screen().MAXCOL + 1
def Run(self):
- """Run"""
self.Paint()
# myControlStackIndex
--- 130,135 ----
***************
*** 179,184 ****
--- 183,189 ----
# Otherwise, we have an 'active' Control!
# "only go to the control if it can get focus"
elif myCtl.CANGETFOCUS:
+ self._CurrentFocus = myCtl
# call system level gotfocus
myCtl.ExecMethod("SYSGOTFOCUS", None, None, None)
# If a custom GOTFOCUS method has been assigned,
***************
*** 215,220 ****
--- 220,335 ----
myCsi = self.__GetNextActiveCtlIndex(myCsi)
activate = 0
+
+
+ ## def Run(self):
+ ## """Run"""
+ ## self.Paint()
+ ##
+ ## # myControlStackIndex
+ ## myCsi = self.STARTPOINT
+ ## # Sanity check the Csi
+ ## if myCsi == None:
+ ## myCsi = 0
+ ##
+ ## # event loop runs forever
+ ## while 1:
+ ## activate = 0
+ ##
+ ## # if breakUp is set to TermInfoTrue, return ControlStackIndex
+ ## # less one.
+ ## if self.breakUp :
+ ## self.breakUp = 0
+ ## return myCsi-1
+ ##
+ ## # Sanity check the Control Stack index (again!), reset index to
+ ## # zero on exception.
+ ## try:
+ ## myCtl = self.Controls[myCsi]
+ ## except:
+ ## myCsi = 0
+ ## try:
+ ## myCtl = self.Controls[myCsi]
+ ## except:
+ ## print "WARNING: No widgets!!"
+ ## return
+ ##
+ ## # if nextControl is not at the initial state: ie. in the "loaded"
+ ## # state:
+ ## if self.nextCtl != None:
+ ## # get and set the next desired ControlStackIndex based on
+ ## # the next queued up control
+ ## myCsi = self.Controls.index(self.nextCtl)
+ ## # reassign myCtl control to the next desired.
+ ## myCtl = self.nextCtl
+ ## # reset the next Control value to None
+ ## self.nextCtl = None
+ ## # My control is set and ready, mark it to be activated.
+ ## activate = 1
+ ##
+ ## # if this control has explicitly been set to 'non-active' with
+ ## # Control.DeActivate or Control.SetActiveState then don't
+ ## # initialize it.
+ ## if myCtl.active == 0:
+ ## # assign the next active control stack index to myCsi
+ ## myCsi = self.__GetNextActiveCtlIndex(myCsi)
+ ##
+ ## # Otherwise, we have an 'active' Control!
+ ## # "only go to the control if it can get focus"
+ ## elif myCtl.CANGETFOCUS:
+ ## # call system level gotfocus
+ ## c = self.SetFocus(myCtl, activate)
+ ## if c != None:
+ ## myCsi = c
+ ##
+ ## activate = 0
+
+
+ def SetFocus(self, myCtl, activate=1, run=1):
+
+ if self._CurrentFocus:
+ if not self._LoseFocus(self._CurrentFocus):
+ return None
+
+ self._CurrentFocus = myCtl
+
+ myCtl.ExecMethod("SYSGOTFOCUS", None, None, None)
+ # If a custom GOTFOCUS method has been assigned,
+ # has the user supply a Got Focus routine?
+ UserGotFocus = myCtl.GetMethod("GOTFOCUS")
+
+ if run:
+ # call user level gotfocus method
+ if UserGotFocus <> None:
+ # if it's alright to get focus, do so
+ if UserGotFocus(myCtl, None, None):
+ # do system level run
+ if myCtl.ExecMethod( "SYSRUN", activate,
+ self.eventY, self.eventX) :
+ return myCsi
+
+ else:
+ # otherwise, _just_ do system level run
+ if myCtl.ExecMethod("SYSRUN", activate,
+ self.eventY, self.eventX) :
+ return myCsi
+
+
+ def _LoseFocus(self, myCtl):
+
+ myCtl.ExecMethod("SYSLOSTFOCUS", None, None, None)
+ UserLostFocus = myCtl.GetMethod("LOSTFOCUS")
+
+ if UserLostFocus <> None:
+ if UserLostFocus(myCtl, None, None):
+ return 1
+ else:
+ return 0
+
+ # if the Control is 'active', BUT can't get focus:
+ else:
+ return 1
+
def BreakOrder(self, Char):
Index: gnue/common/src/cursing/TextArea.py
diff -c gnue/common/src/cursing/TextArea.py:1.2
gnue/common/src/cursing/TextArea.py:1.3
*** gnue/common/src/cursing/TextArea.py:1.2 Fri Oct 11 19:44:12 2002
--- gnue/common/src/cursing/TextArea.py Sun Oct 13 23:59:23 2002
***************
*** 188,193 ****
--- 188,197 ----
Container.PrintAt(self.Y + i + j, self.X, "_" * W)
+ def SetCursor(self, location):
+ self.DEPTH = location
+ curses.curs_set(1)
+ self.Paint(None, None, None)
def LostFocus(self, v1, v2, v3):
self.SetColor(sio.C_TEXTBOX)
Index: gnue/common/src/cursing/TextBox.py
diff -c gnue/common/src/cursing/TextBox.py:1.7
gnue/common/src/cursing/TextBox.py:1.8
*** gnue/common/src/cursing/TextBox.py:1.7 Fri Oct 11 19:44:12 2002
--- gnue/common/src/cursing/TextBox.py Sun Oct 13 23:59:23 2002
***************
*** 69,78 ****
def Run(self, v1, v2, v3):
Container = self.PARENT.Screen()
if self.EDITABLE:
! try:
! curses.curs_set(1)
! except:
! pass
if v1 :
Depth = self.DEPTH
offset = (v3 - self.X)
--- 69,79 ----
def Run(self, v1, v2, v3):
Container = self.PARENT.Screen()
if self.EDITABLE:
! ## try:
! ## curses.curs_set(1)
! ## except:
! ## pass
! pass
if v1 :
Depth = self.DEPTH
offset = (v3 - self.X)
***************
*** 90,106 ****
while 1:
ch = Container.GetChar()
if self.PARENT.BreakOrder(ch) :
! try:
! curses.curs_set(0)
! except:
! pass
return
ch = self.PARENT.KeystrokeHook(ch)
if ch == None:
! try:
! curses.curs_set(0)
! except:
continue
else:
--- 91,107 ----
while 1:
ch = Container.GetChar()
if self.PARENT.BreakOrder(ch) :
! ## try:
! ## curses.curs_set(0)
! ## except:
! ## pass
return
ch = self.PARENT.KeystrokeHook(ch)
if ch == None:
! ## try:
! ## curses.curs_set(0)
! ## except:
continue
else:
***************
*** 112,121 ****
if ch == Container.TokUpArrow:
BACKWARDS = 1
if self.ExecMethod( "VERIFY", self.TEXT, None, None) :
! try:
! curses.curs_set(0)
! except:
! pass
return
elif ch == Container.TokLeftArrow:
Depth = Depth - 1
--- 113,122 ----
if ch == Container.TokUpArrow:
BACKWARDS = 1
if self.ExecMethod( "VERIFY", self.TEXT, None, None) :
! ## try:
! ## curses.curs_set(0)
! ## except:
! ## pass
return
elif ch == Container.TokLeftArrow:
Depth = Depth - 1
***************
*** 184,190 ****
--- 185,199 ----
Container.PrintAt(self.Y, self.X, Visuals)
Container.GotoYX(self.Y, self.X+ W)
+ def SetCursor(self, location):
+ self.DEPTH = location
+ Container = self.PARENT.Screen()
+ curses.curs_set(1)
+ Container.GotoYX(self.Y, self.X+ self.DEPTH)
+ self.Paint(None, None, None)
+
def LostFocus(self, v1, v2, v3):
+ curses.curs_set(0)
self.SetColor(sio.C_TEXTBOX)
Container = self.PARENT.Screen()
self.Paint(None, None, None)
***************
*** 192,197 ****
--- 201,207 ----
def GotFocus(self, v1, v2, v3):
self.SetColor(sio.C_TEXTBOX_FOCUS)
Container = self.PARENT.Screen()
+ curses.curs_set(1)
Container.GotoYX(self.Y, self.X+ self.DEPTH)
self.Paint(None, None, None)
Index: gnue/forms/src/uidrivers/nstti/UIdriver.py
diff -c gnue/forms/src/uidrivers/nstti/UIdriver.py:1.10
gnue/forms/src/uidrivers/nstti/UIdriver.py:1.11
*** gnue/forms/src/uidrivers/nstti/UIdriver.py:1.10 Fri Oct 11 19:44:28 2002
--- gnue/forms/src/uidrivers/nstti/UIdriver.py Sun Oct 13 23:59:23 2002
***************
*** 445,451 ****
pass # self.Destroy()
def indexedFocus(self, index):
! pass # self.widgets[index].SetFocus()
def setValue(self, value, index=0):
self.widgets[index].SetValue(value)
--- 445,452 ----
pass # self.Destroy()
def indexedFocus(self, index):
! widget = self.widgets[index]
! widget.PARENT.SetFocus(widget,run=0)
def setValue(self, value, index=0):
self.widgets[index].SetValue(value)
***************
*** 454,464 ****
## self.widgets[index].SetEvtHandlerEnabled(1)
def setCursorPosition(self, position, index=0):
! pass
! ## try:
! ## self.widgets[index].SetInsertionPoint(position)
! ## except AttributeError:
! ## pass # For label-style entries
def setSelectedArea(self, selection1, selection2, index=0):
pass
--- 455,464 ----
## self.widgets[index].SetEvtHandlerEnabled(1)
def setCursorPosition(self, position, index=0):
! try:
! self.widgets[index].SetCursor(position)
! except AttributeError:
! pass
def setSelectedArea(self, selection1, selection2, index=0):
pass
***************
*** 584,590 ****
width = event.screenWidth
! newWidget = Dialog(event.container, y, x, y+height-1, x+width-1 )
###newWidget.DeActivate(0)
event.interface._pageList.append(newWidget)
--- 584,590 ----
width = event.screenWidth
! newWidget = Frame(event.container, y, x, y+height-1, x+width-1 )
###newWidget.DeActivate(0)
event.interface._pageList.append(newWidget)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue common/src/cursing/Menu.py common/src/curs...,
Jason Cater <=