commit-gnue
[Top][All Lists]
Advanced

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

gnue common/src/cursing/Frame.py common/src/cur...


From: Jason Cater
Subject: gnue common/src/cursing/Frame.py common/src/cur...
Date: Mon, 11 Nov 2002 01:00:03 -0500

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/11/11 01:00:00

Modified files:
        common/src/cursing: Frame.py GraphicObject.py MenuBar.py 
                            Notebook.py ScreenContainer.py 
        forms/src/uidrivers/curses: UIdriver.py 

Log message:
        More work on the curses driver; mainly further implementation of 
Notebook.py

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/Frame.py.diff?cvsroot=OldCVS&tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/GraphicObject.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/MenuBar.py.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/Notebook.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/cursing/ScreenContainer.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/curses/UIdriver.py.diff?cvsroot=OldCVS&tr1=1.18&tr2=1.19&r1=text&r2=text

Patches:
Index: gnue/common/src/cursing/Frame.py
diff -c gnue/common/src/cursing/Frame.py:1.7 
gnue/common/src/cursing/Frame.py:1.8
*** gnue/common/src/cursing/Frame.py:1.7        Thu Nov  7 11:37:03 2002
--- gnue/common/src/cursing/Frame.py    Mon Nov 11 00:59:59 2002
***************
*** 112,129 ****
      self._PaintDropShadow()
      ScreenContainer.Paint(self,*args, **parms)
  
- ##  def RunDialog(self):
- ##    self._PaintBorder()
- ##    self._PaintDropShadow()
- ##    t = self.Run()
- ##    self.Screen().RestoreScreen(self._Y,self._X,
- ##             self.R2 + self.DROPSHADOW + self.BORDER*2,
- ##             self.C2 + self.DROPSHADOW + self.BORDER*2,
- ##             self.buffer)
- ##    self.SCREEN.Refresh()
- ##    self.PARENT.Paint()
- ##    return t
- 
    def Height(self):
      return self.R2- self._Y
  
--- 112,117 ----
Index: gnue/common/src/cursing/GraphicObject.py
diff -c gnue/common/src/cursing/GraphicObject.py:1.4 
gnue/common/src/cursing/GraphicObject.py:1.5
*** gnue/common/src/cursing/GraphicObject.py:1.4        Thu Oct 10 21:46:06 2002
--- gnue/common/src/cursing/GraphicObject.py    Mon Nov 11 00:59:59 2002
***************
*** 46,53 ****
  
  
    def __init__( self, sioScreen, **properties):
!     self._Properties = self.__dict__
!     self._Properties.update( properties)
      self.SCREEN = sioScreen
      self.breakUp = 0
      self.SetColor( colorLow,colorHi)
--- 46,52 ----
  
  
    def __init__( self, sioScreen, **properties):
!     self.__dict__.update(properties)
      self.SCREEN = sioScreen
      self.breakUp = 0
      self.SetColor( colorLow,colorHi)
***************
*** 56,76 ****
  
  
    def GetProperty(self, pptyName):
!     return self._Properties[pptyName]
! 
! 
!   def GetProperties(self):
!     " Return _Properties as a list of key value pairs "
!     return self._Properties.items()
  
  
    def SetProperty(self, pptyName, pptyVal):
!     self._Properties[pptyName] = pptyVal
  
  
    def HasProperty(self, pptyName):
      "Equally well named pptyExists(x)"
!     return self._Properties.has_key(pptyName)
  
  
    def IsPropertyInherited( self, pptyName):
--- 55,70 ----
  
  
    def GetProperty(self, pptyName):
!     return self.__dict__[pptyName]
  
  
    def SetProperty(self, pptyName, pptyVal):
!     self.__dict__[pptyName] = pptyVal
  
  
    def HasProperty(self, pptyName):
      "Equally well named pptyExists(x)"
!     return self.__dict__.has_key(pptyName)
  
  
    def IsPropertyInherited( self, pptyName):
Index: gnue/common/src/cursing/MenuBar.py
diff -c gnue/common/src/cursing/MenuBar.py:1.6 
gnue/common/src/cursing/MenuBar.py:1.7
*** gnue/common/src/cursing/MenuBar.py:1.6      Thu Nov  7 11:37:03 2002
--- gnue/common/src/cursing/MenuBar.py  Mon Nov 11 00:59:59 2002
***************
*** 56,66 ****
      self.STATUSBAR_INDEX = index
  
    def _AddMenu(self,menu):
-     self.Controls.append(menu)
      newX = 0
!     if len(self.Controls) > 1:
!       newX  = self.Controls[-2:-1][0].X
!       newX += len(self.Controls[-2:-1][0].CAPTION) + 2
  
      menu.X = newX
      menu.Y = self.Y
--- 56,65 ----
      self.STATUSBAR_INDEX = index
  
    def _AddMenu(self,menu):
      newX = 0
!     if len(self.Controls) > 0:
!       newX  = self.Controls[-1:][0].X
!       newX += len(self.Controls[-1:][0].CAPTION) + 2
  
      menu.X = newX
      menu.Y = self.Y
Index: gnue/common/src/cursing/Notebook.py
diff -c gnue/common/src/cursing/Notebook.py:1.1 
gnue/common/src/cursing/Notebook.py:1.2
*** gnue/common/src/cursing/Notebook.py:1.1     Thu Nov  7 11:37:03 2002
--- gnue/common/src/cursing/Notebook.py Mon Nov 11 00:59:59 2002
***************
*** 58,60 ****
--- 58,216 ----
        self._DialogWidth + 2, self.INSET, caption=self.CAPTION,
        captionColor=sio.C_DIALOG_TITLE)
  
+   def NewPage(self, title):
+     page = NotebookPage(self, r1=self.r1, c1=self.c1, r2=self.r2, c2=self.c2, 
title=title)
+     self.AddFrame(page)
+     self._AddButton(page)
+     if self._CurrentFrame == self:
+       self._CurrentFrame = page
+ 
+   def _AddButton(self,page):
+     ctrl =
+     newX = 0
+     if len(self.Controls) > 0:
+       newX  = self.Controls[-1:][0].X
+       newX += len(self.Controls[-1:][0].CAPTION) + 2
+ 
+     ctrl.X = newX
+     ctrl.Y = self.Y
+ 
+     self.AddControl(ctrl)
+ 
+     for page in self.Frames:
+       page.SetPageControls(self.Controls)
+ 
+ 
+ 
+ 
+ class NotebookButton(FocusedLabel):
+   def __init__(self,Parent,MenuName,Y,X,DisplayName = "",
+                **properties):
+     self.maxLengthFixed = 0
+     DisplayName = self.__FixDisplay(DisplayName)
+     apply(FocusedLabel.__init__, (self,Parent,MenuName,Y,X,DisplayName), 
properties)
+     self.PARENT = Parent
+     self.SetMethod("CLICK",self.ShowOff)
+     self.items = []
+     self.maxLength = 0
+ 
+   def Run(self,v1,v2,v3):
+     if v1 :
+       self.ExecMethod("CLICK", self, None, None)
+       if self.EXITFORM:
+         return 1
+     Container = self.SCREEN;
+     global BACKWARDS
+     while 1:
+       if self.active != 1:
+         self.breakUp = 1
+       if self.breakUp :
+         self.breakUp = 0
+         return 0
+       ch = Container.GetChar()
+       if self.PARENT.BreakOrder(ch) :
+         return
+       if ch in (Container.TokNextField, Container.TokRightArrow):
+         BACKWARDS=0
+         return
+       elif ch == Container.TokLeftArrow:
+         BACKWARDS=1
+         return
+       elif ch in (Container.TokDownArrow,  Container.TokActivate):
+         self.ExecMethod("CLICK", self, None, None)
+         if self.EXITFORM:
+           self.PARENT.Paint()
+           if self.PARENT.__class__ != ScreenContainer:
+             self.PARENT.Refresh(None,None,None)
+           return 1
+         self.ExecMethod("SYSGOTFOCUS", None, None, None)
+ 
+   def ShowOff(self,arg1, arg2,arg3):
+     MenuHeight = len(self.items) + 2
+     MenuWidth  = self.maxLength
+     X = self.X
+     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
+     for i in range(len(self.items)):
+       text = ''
+       if self.items[i][0] == -1:
+         text = (self.maxLength - 4) * chr(tiHLINE)
+       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.STATUSBARLINK)
+       item.ITEMID = self.items[i][0]
+       count += 1
+       item.SetMethod("CLICK",self.ItemSelected)
+       MenuWin.AddDialogControl(item)
+       item.DeActivate(self.items[i][2])
+     MenuWin.SetColor(sio.C_MENUBAR)
+     MenuWin.INSET = 1
+     MenuWin.RunDialog()
+     Parent.Paint()
+     Parent.Screen().Refresh()
+ 
+   def __FixDisplay(self, newTitle):
+     erg = newTitle
+     if self.maxLengthFixed :
+       newLen = len(newTitle)
+       oldLen = self.maxLength -  4
+       if newLen >= oldLen:
+         oldLen -= 3
+         oldLen = oldLen / 2
+         erg = newTitle[:oldLen] + '...' + newTitle[-oldLen:]
+       else:
+         erg = newTitle + (oldLen-newLen)*' '
+     return erg
+ 
+   def Finalize(self):
+     self.PARENT.AddControl(self)
+ 
+   def ItemSelected(self,control, arg2,arg3):
+     MenuHeight = len(self.items) + 2
+     MenuWidth  = self.maxLength
+     X = self.X
+     Y = self.Y+ 1
+     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, 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
+ 
+   def InsertSeperator(self):
+     self.items.append( [ -1, '', 0 ])
+ 
+   def ChangeTitle(self,newTitle):
+     newLen = len(newTitle)
+     oldLen = len(self.CAPTION)
+     if newLen >= oldLen:
+       newTitle = self.__FixDisplay(newTitle)
+       self.CAPTION = newTitle[:oldLen]
+     else:
+       newTitle = newTitle + (oldLen-newLen)*' '
+       self.CAPTION = newTitle
+ 
+   def Clear(self):
+     self.items = []
+ 
+   def GetWidth(self):
+     return self.maxLength
Index: gnue/common/src/cursing/ScreenContainer.py
diff -c gnue/common/src/cursing/ScreenContainer.py:1.7 
gnue/common/src/cursing/ScreenContainer.py:1.8
*** gnue/common/src/cursing/ScreenContainer.py:1.7      Thu Nov  7 11:37:03 2002
--- gnue/common/src/cursing/ScreenContainer.py  Mon Nov 11 00:59:59 2002
***************
*** 60,65 ****
--- 60,66 ----
      self.Controls = []  # Stack of control objects
      self.Frames = []    # Stack of child frames
      self.FrameStackOrder = []  # The display/stack order of frames
+     self.Panels = []
      self.Metrics  = {}  # ditionary of dimensions, keyed by control obj
      self.VISIBLE = 1
  
***************
*** 87,92 ****
--- 88,96 ----
        for i in xrange(0, len(self.Controls)):
          self.Controls[i].SetProperty(PropertyName, PropertyValue)
  
+   def AddPanel(self, panel):
+     self.Panels.append(panel)
+ 
    def AddFrame(self, frame):
      self.Frames.append(frame)
      self.FrameStackOrder.insert(0,frame)
***************
*** 139,145 ****
      Paint EVERY Control registered in this ScreenContainer
      instance.  Effectively repainting the entire container iteratively.
      """
!     if not self.VISIBLE: 
        return 
        
      if captureRefresh:
--- 143,149 ----
      Paint EVERY Control registered in this ScreenContainer
      instance.  Effectively repainting the entire container iteratively.
      """
!     if not self.VISIBLE:
        return 
        
      if captureRefresh:
***************
*** 442,446 ****
      DialogWidth = self.Width()
      DialogHeight = self.Height()
      _paintBorder( self, 0,0, DialogHeight, DialogWidth, caption=caption)
- 
  
--- 446,449 ----
Index: gnue/forms/src/uidrivers/curses/UIdriver.py
diff -c gnue/forms/src/uidrivers/curses/UIdriver.py:1.18 
gnue/forms/src/uidrivers/curses/UIdriver.py:1.19
*** gnue/forms/src/uidrivers/curses/UIdriver.py:1.18    Thu Nov  7 11:37:03 2002
--- gnue/forms/src/uidrivers/curses/UIdriver.py Mon Nov 11 01:00:00 2002
***************
*** 29,35 ****
  
  from gnue.common.cursing import *
  import curses
! 
  from gnue.forms.GFForm import *
  from gnue.common import events
  from gnue.forms.uidrivers._base.UIdriver import *
--- 29,35 ----
  
  from gnue.common.cursing import *
  import curses
! import atexit
  from gnue.forms.GFForm import *
  from gnue.common import events
  from gnue.forms.uidrivers._base.UIdriver import *
***************
*** 63,71 ****
    if not _SIO:
      _SIO = sio()
      _SIO.BeginScreenAccess()
!     print "Setting cleanup function"
!     sys._clean_curses_exit = sys.exit
!     sys.exit = _restore
    return _SIO
  
  #
--- 63,69 ----
    if not _SIO:
      _SIO = sio()
      _SIO.BeginScreenAccess()
!     atexit.register(_restore)
    return _SIO
  
  #
***************
*** 283,289 ****
    #
    def _exit(self):
      self.mainWindow.EndScreenAccess()
-     _restore()
  
  
    def _setStatusBar(self,*args):
--- 281,286 ----
***************
*** 890,897 ****
      curses.endwin()          # Terminate curses
    except:
      pass
- 
-   sys._clean_curses_exit(*args, **parms)
  
  
  
--- 887,892 ----




reply via email to

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