commit-gnue
[Top][All Lists]
Advanced

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

gnue/common/src/cursing Button.py ComboBox.py C...


From: Jason Cater
Subject: gnue/common/src/cursing Button.py ComboBox.py C...
Date: Thu, 10 Oct 2002 21:46:06 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/10/10 21:46:06

Modified files:
        common/src/cursing: Button.py ComboBox.py Control.py Dialog.py 
                            Frame.py GraphicObject.py Label.py 
                            ScreenContainer.py ScrollBar.py TextBox.py 
                            VButton.py VScrollBar.py __init__.py sio.py 
                            utility.py 
Added files:
        common/src/cursing: TextArea.py 

Log message:
        * Full-color support / colorized default widgets
        * Simplified drawing of widgets
        * Lots of code simplification
        * Started on keystroke/event hooks
        * Dialogs: Made border optional
        * Dialogs: Added optional dropshadows
        * Dialogs: Added support for a "Title" on dialogs
        * TextArea: Added a TextArea class (Multi-line text boxes)
        * Buttons: Spacebar triggers a press

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/TextArea.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Button.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/ComboBox.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Control.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Dialog.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Frame.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/GraphicObject.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Label.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/ScreenContainer.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/ScrollBar.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/TextBox.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/VButton.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/VScrollBar.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/__init__.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/sio.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/utility.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gnue/common/src/cursing/Button.py
diff -c gnue/common/src/cursing/Button.py:1.4 
gnue/common/src/cursing/Button.py:1.5
*** gnue/common/src/cursing/Button.py:1.4       Thu Oct 10 02:45:35 2002
--- gnue/common/src/cursing/Button.py   Thu Oct 10 21:46:05 2002
***************
*** 29,34 ****
--- 29,35 ----
  from gnue.common import GDebug
  from constants import *
  from Control import Control
+ import sio
  
  #
  #  An example control implementation doing a command button
***************
*** 53,58 ****
--- 54,63 ----
      self.SetMethod("GOTFOCUS", None)  # user event
      self.SetMethod("SYSRUN", self.Run)  # system event
      self.EXITFORM = 0
+     self.COLOR = sio.C_BUTTON
+     self.FOCUSCOLOR = sio.C_BUTTON_FOCUS
+ #    self.SetColor(sio.C_BUTTON)
+ 
  
    def Run(self, v1, v2, v3):    # handle user actions
      Container = self.PARENT.SCREEN
***************
*** 66,71 ****
--- 71,81 ----
        ch = Container.GetChar()
        if self.PARENT.BreakOrder(ch) :
          return
+ 
+       ch = self.PARENT.KeyboardHook(ch)
+       if ch == None:
+         return
+ 
        if self.active == 0:
          return 0
        if ch in (Container.TokNextField, Container.TokRightArrow):
***************
*** 74,85 ****
        elif ch == Container.TokLeftArrow:
          BACKWARDS=1
          return 0
!       elif ch == self.PARENT.SCREEN.TokActivate:
          self.ExecMethod("CLICK", self, None, None)
          if self.EXITFORM:
            return(1)
          self.ExecMethod("SYSGOTFOCUS", None, None, None)
!         
    def Paint(self, HaveFocus, v2, v3):           # event args not used
      """
        control's paint event
--- 84,95 ----
        elif ch == Container.TokLeftArrow:
          BACKWARDS=1
          return 0
!       elif ch in (self.PARENT.SCREEN.TokActivate, 32):
          self.ExecMethod("CLICK", self, None, None)
          if self.EXITFORM:
            return(1)
          self.ExecMethod("SYSGOTFOCUS", None, None, None)
! 
    def Paint(self, HaveFocus, v2, v3):           # event args not used
      """
        control's paint event
***************
*** 89,98 ****
      """
      Container = self.PARENT.SCREEN
      if Container == None:
!       raise "Container is Nothing in def Paint!"
      if HaveFocus:
        self.HiLight()
      else:
        self.LoLight()
      tROW, tCOL = self.Y, self.X
      tCaption = self.CAPTION
--- 99,110 ----
      """
      Container = self.PARENT.SCREEN
      if Container == None:
!       raise "No container!"
      if HaveFocus:
+       self.SetColor(sio.C_BUTTON_FOCUS)
        self.HiLight()
      else:
+       self.SetColor(sio.C_BUTTON)
        self.LoLight()
      tROW, tCOL = self.Y, self.X
      tCaption = self.CAPTION
***************
*** 110,118 ****
          leadingSpaces -= 1
        elif spaces + leadingSpaces + len(tCaption) < tAW:
          spaces += 1
!     
        tCaption = (" " * leadingSpaces) + tCaption + (" " * spaces)
!     Container.PrintAt(tROW, tCOL, "[" + tCaption + "]")
  
    def GotFocus(self, Arg1, Arg2, Arg3):
      self.FOCUS = 1
--- 122,130 ----
          leadingSpaces -= 1
        elif spaces + leadingSpaces + len(tCaption) < tAW:
          spaces += 1
! 
        tCaption = (" " * leadingSpaces) + tCaption + (" " * spaces)
!     Container.PrintAt(tROW, tCOL, "<" + tCaption + ">")
  
    def GotFocus(self, Arg1, Arg2, Arg3):
      self.FOCUS = 1
Index: gnue/common/src/cursing/ComboBox.py
diff -c gnue/common/src/cursing/ComboBox.py:1.3 
gnue/common/src/cursing/ComboBox.py:1.4
*** gnue/common/src/cursing/ComboBox.py:1.3     Wed Oct  9 23:42:11 2002
--- gnue/common/src/cursing/ComboBox.py Thu Oct 10 21:46:06 2002
***************
*** 80,88 ****
  
    def Clear(self):
      self._menu.Clear()
!   
! #
! # FileSelector-stuff
! #
  
  
--- 80,91 ----
  
    def Clear(self):
      self._menu.Clear()
! 
!   def SetValue(self, value):
!     GDebug.printMesg(0,'WARNING: SetValue called on a combo box... not yet 
implemented')
! 
!   def GetValue(self):
!     GDebug.printMesg(0,'WARNING: GetValue called on a combo box... not yet 
implemented')
! 
  
  
Index: gnue/common/src/cursing/Control.py
diff -c gnue/common/src/cursing/Control.py:1.3 
gnue/common/src/cursing/Control.py:1.4
*** gnue/common/src/cursing/Control.py:1.3      Wed Oct  9 23:42:11 2002
--- gnue/common/src/cursing/Control.py  Thu Oct 10 21:46:06 2002
***************
*** 35,40 ****
--- 35,42 ----
      apply (GraphicObject.__init__, (self, Parent.SCREEN),
         properties)
      self.NAME = CName
+     self.FOCUSCOLOR = 2
+     self.COLOR = 1
      self.X = -1
      self.Y = -1
      self.VISIBLE = 1
***************
*** 51,61 ****
    def DetermineAndSetColor(self, HasFocus):
      if self.active:
        if HasFocus :
!         self.SetColor(2)
        else:
!         self.SetColor(1)
      else:
!       self.SetColor(4)
  
    def CreateProperty(self, Property, Value):
      self.__dict__[Property] = Value
--- 53,64 ----
    def DetermineAndSetColor(self, HasFocus):
      if self.active:
        if HasFocus :
!         self.SetColor(self.FOCUSCOLOR)
        else:
!         self.SetColor(self.COLOR)
      else:
!       pass
!       ##self.SetColor(4)
  
    def CreateProperty(self, Property, Value):
      self.__dict__[Property] = Value
***************
*** 102,106 ****
  
    def GetWidth(self):
      return self.W
!   
  
--- 105,109 ----
  
    def GetWidth(self):
      return self.W
! 
  
Index: gnue/common/src/cursing/Dialog.py
diff -c gnue/common/src/cursing/Dialog.py:1.4 
gnue/common/src/cursing/Dialog.py:1.5
*** gnue/common/src/cursing/Dialog.py:1.4       Thu Oct 10 02:45:35 2002
--- gnue/common/src/cursing/Dialog.py   Thu Oct 10 21:46:06 2002
***************
*** 28,33 ****
--- 28,34 ----
  
  from gnue.common import GDebug
  from constants import *
+ import sio
  from utility import _paintBorder
  from ScreenContainer import ScreenContainer
  
***************
*** 37,43 ****
      the user defines a screen region which makes up the dialog...
      they may only put controls within this region.
    """
!   def __init__(self, ParentContainer, r1=0, c1=0, r2=0, c2=0, **properties):
      SIOInstance = ParentContainer.Screen()
      apply (ScreenContainer.__init__, (self, SIOInstance), properties)
      self.PARENT = ParentContainer
--- 38,45 ----
      the user defines a screen region which makes up the dialog...
      they may only put controls within this region.
    """
!   def __init__(self, ParentContainer, r1=0, c1=0, r2=0, c2=0, caption="",
!                 border=1, dropshadow=1, **properties):
      SIOInstance = ParentContainer.Screen()
      apply (ScreenContainer.__init__, (self, SIOInstance), properties)
      self.PARENT = ParentContainer
***************
*** 46,55 ****
--- 48,60 ----
      self.SCREEN = SIOInstance
      self.STARTPOINT = 0
      self.DIALOGWINDOW = None
+     self.CAPTION = caption
      self.R1 = r1
      self.R2 = r2
      self.C1 = c1
      self.C2 = c2
+     self.DROPSHADOW = dropshadow
+     self.BORDER = border
  
      # need to add some sanity checks for bad params here:
      #if r1 > 0 and r1 <= SIOInstance.MAXROW:
***************
*** 65,72 ****
      self._DialogHeight = r2 - r1
      self.INSET = 0
      self.buffer = self.Screen().CaptureScreen(self.R1,
!         self.C1,
!         self.R2, self.C2)
  
    def __del__(self):
       pass
--- 70,77 ----
      self._DialogHeight = r2 - r1
      self.INSET = 0
      self.buffer = self.Screen().CaptureScreen(self.R1,
!         self.C1, self.R2 + dropshadow + border*2, self.C2 + dropshadow + 
border*2)
!     self.SetColor(sio.C_DIALOG)
  
    def __del__(self):
       pass
***************
*** 77,85 ****
        dialog box
      """
      cRow = TheControl.Y
!     cRow = cRow + self.R1
      cCol = TheControl.X
!     cCol = cCol + self.C1
      TheControl.Y = cRow
      TheControl.X = cCol
      ScreenContainer.AddControl(self,TheControl)
--- 82,90 ----
        dialog box
      """
      cRow = TheControl.Y
!     cRow = cRow + self.R1 + self.BORDER
      cCol = TheControl.X
!     cCol = cCol + self.C1 + self.BORDER
      TheControl.Y = cRow
      TheControl.X = cCol
      ScreenContainer.AddControl(self,TheControl)
***************
*** 89,103 ****
      return self.AddDialogControl(control)
  
    def _PaintBorder(self):
      self.LoLight()
!     _paintBorder( self, self._Y,self._X, self._DialogHeight,
!       self._DialogWidth, self.INSET)
  
    def RunDialog(self):
      self._PaintBorder()
      t = self.Run()
      self.Screen().RestoreScreen(self._Y,self._X,
!              self.R2, self.C2,
               self.buffer)
      self.SCREEN.Refresh()
      self.PARENT.Paint()
--- 94,128 ----
      return self.AddDialogControl(control)
  
    def _PaintBorder(self):
+     if not self.BORDER:
+       return
+ 
      self.LoLight()
!     _paintBorder( self, self._Y,self._X, self._DialogHeight + 2,
!       self._DialogWidth + 2, self.INSET, caption=self.CAPTION,
!       captionColor=sio.C_DIALOG_TITLE)
! 
!   def _PaintDropShadow(self):
!     if not self.DROPSHADOW:
!       return
! 
!     color = self.SCREEN.GetColor()
!     self.SCREEN.SetColor(0)
! 
!     self.SCREEN.PrintAt( self.R2 + self.BORDER*2, self.C1 + 1 + self.BORDER*2,
!            (self._DialogWidth + self.BORDER*2) * " ")
!     for i in range(1,self._DialogHeight + self.BORDER*2):
!       self.SCREEN.PrintAt( self.R1 + i, self.C2 + self.BORDER*2, " ")
! 
!     self.SCREEN.SetColor(color)
  
    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()
Index: gnue/common/src/cursing/Frame.py
diff -c gnue/common/src/cursing/Frame.py:1.3 
gnue/common/src/cursing/Frame.py:1.4
*** gnue/common/src/cursing/Frame.py:1.3        Wed Oct  9 23:42:11 2002
--- gnue/common/src/cursing/Frame.py    Thu Oct 10 21:46:06 2002
***************
*** 28,48 ****
  
  from gnue.common import GDebug
  from constants import *
  from utility import _paintBorder
  from Control import Control
  
  class Frame(Control):
-   """
-   """
    def __init__( self, Root, Name, Y,X,W,H, Title='', **properties):
      apply(Control.__init__,(self, Root, Name), properties)
      self.active = 0
      self.Y = Y
      self.X = X
!     self.W = W 
!     self.H = H 
      self.TITLETEXT = Title
      self.CANGETFOCUS = 0
      self.SetMethod("SYSPAINT", self.Paint)
  
    def Paint(self,v1,v2,v3):
--- 28,49 ----
  
  from gnue.common import GDebug
  from constants import *
+ import sio
  from utility import _paintBorder
  from Control import Control
  
  class Frame(Control):
    def __init__( self, Root, Name, Y,X,W,H, Title='', **properties):
      apply(Control.__init__,(self, Root, Name), properties)
      self.active = 0
      self.Y = Y
      self.X = X
!     self.W = W
!     self.H = H
      self.TITLETEXT = Title
      self.CANGETFOCUS = 0
+     self.COLOR = sio.C_DIALOG
+     self.SetColor(self.COLOR)
      self.SetMethod("SYSPAINT", self.Paint)
  
    def Paint(self,v1,v2,v3):
Index: gnue/common/src/cursing/GraphicObject.py
diff -c gnue/common/src/cursing/GraphicObject.py:1.3 
gnue/common/src/cursing/GraphicObject.py:1.4
*** gnue/common/src/cursing/GraphicObject.py:1.3        Wed Oct  9 23:42:11 2002
--- gnue/common/src/cursing/GraphicObject.py    Thu Oct 10 21:46:06 2002
***************
*** 35,42 ****
    """
    GraphicObject is the base class for ScreenContainer: the full screen
    container, as well as for Control: the base class for all of the on-
!   screen controls. 
!   
    GraphicObject maintains a private dictionary of properties and is used
    heavily throughout to modify appearance and behaviour.  GraphicObject
    methods are mostly concerned with managing data in the _Properties dict.
--- 35,42 ----
    """
    GraphicObject is the base class for ScreenContainer: the full screen
    container, as well as for Control: the base class for all of the on-
!   screen controls.
! 
    GraphicObject maintains a private dictionary of properties and is used
    heavily throughout to modify appearance and behaviour.  GraphicObject
    methods are mostly concerned with managing data in the _Properties dict.
***************
*** 119,125 ****
    def _SetLight(self, PropertyName, Setter, DefaultSetter):
      try:
        if curses.has_colors():
!         Setter(self.GetProperty(PropertyName))
          return
      except (KeyError, AttributeError):
        pass
--- 119,125 ----
    def _SetLight(self, PropertyName, Setter, DefaultSetter):
      try:
        if curses.has_colors():
!         Setter(self.__dict__[PropertyName])
          return
      except (KeyError, AttributeError):
        pass
Index: gnue/common/src/cursing/Label.py
diff -c gnue/common/src/cursing/Label.py:1.4 
gnue/common/src/cursing/Label.py:1.5
*** gnue/common/src/cursing/Label.py:1.4        Thu Oct 10 02:45:35 2002
--- gnue/common/src/cursing/Label.py    Thu Oct 10 21:46:06 2002
***************
*** 31,36 ****
--- 31,37 ----
  from re import search
  from string import split
  from Control import Control
+ import sio
  
  class Label(Control):
    """
***************
*** 55,60 ****
--- 56,62 ----
      self.SetMethod("SYSGOTFOCUS", None)
      self.SetMethod("SYSLOSTFOCUS", None)
  
+     self.SetColor(sio.C_LABEL)
      self.SetText(Caption)
  
    def SetText (self, Caption):
***************
*** 90,96 ****
    def Paint(self, v1, v2, v3):
      Container = self.PARENT.Screen()
      if Container == None:
!       raise "Containeris Nothing in def Paint!"
      self.LoLight()
      Y = self.Y
      X = self.X
--- 92,98 ----
    def Paint(self, v1, v2, v3):
      Container = self.PARENT.Screen()
      if Container == None:
!       raise "No container--can't paint!"
      self.LoLight()
      Y = self.Y
      X = self.X
Index: gnue/common/src/cursing/ScreenContainer.py
diff -c gnue/common/src/cursing/ScreenContainer.py:1.4 
gnue/common/src/cursing/ScreenContainer.py:1.5
*** gnue/common/src/cursing/ScreenContainer.py:1.4      Thu Oct 10 02:45:35 2002
--- gnue/common/src/cursing/ScreenContainer.py  Thu Oct 10 21:46:06 2002
***************
*** 31,36 ****
--- 31,37 ----
  import curses
  
  from constants import *
+ import sio
  from utility import _paintBorder
  from GraphicObject import GraphicObject
  
***************
*** 52,63 ****
  
      self.STARTPOINT = 0
      self.breakUp = 0
!     self.SetColor(1)
      self.nextCtl = None
      self.eventX = -1
      self.eventY = -1
  
  
    def SetProperty(self, PropertyName, PropertyValue):
      """
      """
--- 53,65 ----
  
      self.STARTPOINT = 0
      self.breakUp = 0
!     self.SetColor(sio.C_SCREEN)
      self.nextCtl = None
      self.eventX = -1
      self.eventY = -1
  
  
+ 
    def SetProperty(self, PropertyName, PropertyValue):
      """
      """
***************
*** 136,142 ****
      while 1:
        activate = 0
  
!       # if breakUp is set to TermInfoTrue, return ControlStackIndex 
        # less one.
        if self.breakUp :
          self.breakUp = 0
--- 138,144 ----
      while 1:
        activate = 0
  
!       # if breakUp is set to TermInfoTrue, return ControlStackIndex
        # less one.
        if self.breakUp :
          self.breakUp = 0
***************
*** 176,201 ****
  
        # Otherwise, we have an 'active' Control!
        # "only go to the control if it can get focus"
!       elif myCtl.CANGETFOCUS:  
          # call system level gotfocus
!         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")         
  
          # 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
  
          # When in the world do we get program control here?!
--- 178,203 ----
  
        # Otherwise, we have an 'active' Control!
        # "only go to the control if it can get focus"
!       elif myCtl.CANGETFOCUS:
          # call system level gotfocus
!         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")
  
          # 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
  
          # When in the world do we get program control here?!
***************
*** 207,213 ****
              myCsi = self.__GetNextActiveCtlIndex(myCsi)
          else:
            myCsi = self.__GetNextActiveCtlIndex(myCsi)
!       
        # if the Control is 'active', BUT can't get focus:
        else:
          myCsi = self.__GetNextActiveCtlIndex(myCsi)
--- 209,215 ----
              myCsi = self.__GetNextActiveCtlIndex(myCsi)
          else:
            myCsi = self.__GetNextActiveCtlIndex(myCsi)
! 
        # if the Control is 'active', BUT can't get focus:
        else:
          myCsi = self.__GetNextActiveCtlIndex(myCsi)
***************
*** 234,239 ****
--- 236,245 ----
      return 0
  
  
+   def KeystrokeHook(self, Char):
+     return Char
+ 
+ 
  #
  # private functions
  #
***************
*** 268,277 ****
      return None
  
  
!   def __PaintBorder(self):
      self.LoLight()
      DialogWidth = self.Width()
      DialogHeight = self.Height()
!     _paintBorder( self, 0,0, DialogHeight, DialogWidth)
  
  
--- 274,283 ----
      return None
  
  
!   def __PaintBorder(self, caption=None):
      self.LoLight()
      DialogWidth = self.Width()
      DialogHeight = self.Height()
!     _paintBorder( self, 0,0, DialogHeight, DialogWidth, caption=caption)
  
  
Index: gnue/common/src/cursing/ScrollBar.py
diff -c gnue/common/src/cursing/ScrollBar.py:1.3 
gnue/common/src/cursing/ScrollBar.py:1.4
*** gnue/common/src/cursing/ScrollBar.py:1.3    Wed Oct  9 23:42:11 2002
--- gnue/common/src/cursing/ScrollBar.py        Thu Oct 10 21:46:06 2002
***************
*** 54,59 ****
--- 54,60 ----
      self.SetMethod("CLICK", self._ChangePos)
      self._max = 1
      self._val = 0
+     self.stepsize = 1
      self.__initButtons()
  
    def __initButtons(self):
Index: gnue/common/src/cursing/TextBox.py
diff -c gnue/common/src/cursing/TextBox.py:1.5 
gnue/common/src/cursing/TextBox.py:1.6
*** gnue/common/src/cursing/TextBox.py:1.5      Thu Oct 10 02:45:35 2002
--- gnue/common/src/cursing/TextBox.py  Thu Oct 10 21:46:06 2002
***************
*** 27,33 ****
  #
  
  from gnue.common import GDebug
! import curses
  
  from constants import *
  from Control import Control
--- 27,33 ----
  #
  
  from gnue.common import GDebug
! import curses, sio
  
  from constants import *
  from Control import Control
***************
*** 64,69 ****
--- 64,71 ----
      self.laststart = 0
      self.EDITABLE = 1
  
+     self.SetColor(sio.C_TEXTBOX)
+ 
    def Run(self, v1, v2, v3):
      Container = self.PARENT.Screen()
      if self.EDITABLE:
***************
*** 93,98 ****
--- 95,108 ----
          except:
            pass
          return
+ 
+       ch = self.PARENT.KeyboardHook(ch)
+       if ch == None:
+         try:
+           curses.curs_set(0)
+         except:
+           continue
+ 
        Depth = self.DEPTH
        Text = self.TEXT
        global BACKWARDS
***************
*** 158,192 ****
      Depth = self.DEPTH
      Visuals = ''
      self.LoLight()
      if TextLen <= W or Depth < W:
!       Visuals = Text + ((W - TextLen) * chr(tiHLINE))
        if len(Visuals) > W:
          Visuals = Visuals[:W-1] + ">"
        Container.PrintAt(self.Y, self.X, Visuals)
        Container.GotoYX(self.Y, self.X+ Depth)
      else:
        if Depth >= W:
!         Visuals = "<" + Text[Depth - (W - 1):] + (((W - 1) - TextLen) * 
chr(tiHLINE))
          if len(Visuals) > W:
            Visuals = Visuals[:W]
          Container.PrintAt(self.Y, self.X, Visuals)
          Container.GotoYX(self.Y, self.X+  W)
  
    def LostFocus(self, v1, v2, v3):
!     self.SetColor(1)
      self.Paint(None, None, None)
  
    def GotFocus(self, v1, v2, v3):
!     self.SetColor(3)
      Container = self.PARENT.Screen()
      Container.GotoYX(self.Y, self.X+ self.DEPTH)
      self.Paint(None, None, None)
  
!   def SetText(self, newText):
      self.TEXT = newText
      self.Paint(0,0,0)
  
!   def GetText(self):
      return self.TEXT
!     
!  
--- 168,204 ----
      Depth = self.DEPTH
      Visuals = ''
      self.LoLight()
+ 
      if TextLen <= W or Depth < W:
!       Visuals = Text + ((W - TextLen) * "_")
        if len(Visuals) > W:
          Visuals = Visuals[:W-1] + ">"
        Container.PrintAt(self.Y, self.X, Visuals)
        Container.GotoYX(self.Y, self.X+ Depth)
      else:
        if Depth >= W:
!         Visuals = "<" + Text[Depth - (W - 1):] + (((W - 1) - TextLen) * "_")
          if len(Visuals) > W:
            Visuals = Visuals[:W]
          Container.PrintAt(self.Y, self.X, Visuals)
          Container.GotoYX(self.Y, self.X+  W)
  
    def LostFocus(self, v1, v2, v3):
!     self.SetColor(sio.C_TEXTBOX)
!     Container = self.PARENT.Screen()
      self.Paint(None, None, None)
  
    def GotFocus(self, v1, v2, v3):
!     self.SetColor(sio.C_TEXTBOX_FOCUS)
      Container = self.PARENT.Screen()
      Container.GotoYX(self.Y, self.X+ self.DEPTH)
      self.Paint(None, None, None)
  
!   def SetValue(self, newText):
      self.TEXT = newText
      self.Paint(0,0,0)
  
!   def GetValue(self):
      return self.TEXT
! 
! 
Index: gnue/common/src/cursing/VButton.py
diff -c gnue/common/src/cursing/VButton.py:1.3 
gnue/common/src/cursing/VButton.py:1.4
*** gnue/common/src/cursing/VButton.py:1.3      Wed Oct  9 23:42:11 2002
--- gnue/common/src/cursing/VButton.py  Thu Oct 10 21:46:06 2002
***************
*** 29,34 ****
--- 29,35 ----
  from gnue.common import GDebug
  from constants import *
  from Button import Button
+ import sio
  
  class VButton(Button):
    """ A button that is laid out vertical (i.e. used for the
***************
*** 38,50 ****
--- 39,57 ----
      apply(Button.__init__, (self, Parent, ButtonName, Y, X, H, 
Caption),properties)
      self.W = 1
      self.H = H
+     self.COLOR = sio.C_SCROLL_BUTTON
+     self.FOCUSCOLOR = sio.C_SCROLL_BUTTON_FOCUS
+ 
+ 
    def Paint(self, HaveFocus, v2,v3):
      Container = self.PARENT.SCREEN
      if Container == None:
        raise "Container is Nothing in def Paint!"
      if HaveFocus:
+       self.SetColor(sio.C_SCROLL_BUTTON_FOCUS)
        self.HiLight()
      else:
+       self.SetColor(sio.C_SCROLL_BUTTON)
        self.LoLight()
      tROW, tCOL = self.Y, self.X
      tCaption = self.CAPTION
***************
*** 62,70 ****
          leadingSpaces -= 1
        elif spaces + leadingSpaces + len(tCaption) < tAW:
          spaces += 1
!  
        tCaption = (" " * leadingSpaces) + tCaption + (" " * spaces)
!     tCaption = '-' + tCaption + '-'
      for i in range(0,len(tCaption)):
        Container.PutAt(tROW + i, tCOL, tCaption[i])
  
--- 69,77 ----
          leadingSpaces -= 1
        elif spaces + leadingSpaces + len(tCaption) < tAW:
          spaces += 1
! 
        tCaption = (" " * leadingSpaces) + tCaption + (" " * spaces)
!     tCaption = tCaption
      for i in range(0,len(tCaption)):
        Container.PutAt(tROW + i, tCOL, tCaption[i])
  
Index: gnue/common/src/cursing/VScrollBar.py
diff -c gnue/common/src/cursing/VScrollBar.py:1.3 
gnue/common/src/cursing/VScrollBar.py:1.4
*** gnue/common/src/cursing/VScrollBar.py:1.3   Wed Oct  9 23:42:11 2002
--- gnue/common/src/cursing/VScrollBar.py       Thu Oct 10 21:46:06 2002
***************
*** 29,34 ****
--- 29,35 ----
  from gnue.common import GDebug
  import math
  import curses
+ import sio
  
  from constants import *
  from VButton import VButton
***************
*** 50,64 ****
      X = self.X
      H = self.H
      Parent = self.PARENT
!     self.rightarrow = VButton(Parent,'rightarrow',Y+H-6,X,3,'^')
!     self.rightarrow.SetMethod("CLICK",self._Dec)
!     Parent.AddControl(self.rightarrow)
!     self.left2arrow = VButton(Parent,'left2arrow',Y+H-3,X,3,'v')
      self.left2arrow.SetMethod("CLICK",self._Inc)
      Parent.AddControl(self.left2arrow)
      self.leftarrow = VButton(Parent,'leftarrow',Y,X,3,'^')
      self.leftarrow.SetMethod("CLICK",self._Dec)
      Parent.AddControl(self.leftarrow)
  
    def Init(self, Max):
      self._max = Max
--- 51,66 ----
      X = self.X
      H = self.H
      Parent = self.PARENT
! ##    self.rightarrow = VButton(Parent,'rightarrow',Y+H-2,X,3,'^')
! ##    self.rightarrow.SetMethod("CLICK",self._Dec)
! ##    Parent.AddControl(self.rightarrow)
!     self.left2arrow = VButton(Parent,'left2arrow',Y+H-1,X,3,'v')
      self.left2arrow.SetMethod("CLICK",self._Inc)
      Parent.AddControl(self.left2arrow)
      self.leftarrow = VButton(Parent,'leftarrow',Y,X,3,'^')
      self.leftarrow.SetMethod("CLICK",self._Dec)
      Parent.AddControl(self.leftarrow)
+     self.COLOR = sio.C_SCROLL_BACKGROUND
  
    def Init(self, Max):
      self._max = Max
***************
*** 70,85 ****
      if self.UsedSpace < 1:
        self.UsedSpace = 1
      self.Paint(None,None,None)
!  
    def Paint(self,v1,v2,v3):
      Pos = int(math.ceil(float(self._val) * (self.stepsize))) + self.start
      Screen = self.PARENT.Screen()
      Screen.AutoRefresh = 0
      # clear the bar region in reverse standard-color
!     self.SetColor(1)
!     self.LoLight()
      for i in range(0, int(self.WorkingArea)):
!       Screen.PutAt( self.start + i,self.X, ' ', curses.A_REVERSE)
      # correct position
      if Pos >= (self.WorkingArea + self.start):
        Pos = (self.start + self.WorkingArea)
--- 72,87 ----
      if self.UsedSpace < 1:
        self.UsedSpace = 1
      self.Paint(None,None,None)
! 
    def Paint(self,v1,v2,v3):
      Pos = int(math.ceil(float(self._val) * (self.stepsize))) + self.start
      Screen = self.PARENT.Screen()
      Screen.AutoRefresh = 0
      # clear the bar region in reverse standard-color
!     self.SetColor(sio.C_SCROLL_BACKGROUND)
! #    self.LoLight()
      for i in range(0, int(self.WorkingArea)):
!       Screen.PutAt( self.start + i,self.X, '?') #, curses.A_REVERSE)
      # correct position
      if Pos >= (self.WorkingArea + self.start):
        Pos = (self.start + self.WorkingArea)
***************
*** 87,104 ****
        Pos = self.start + self.UsedSpace
      # draw the handle in "menu"-hilight
      if self.FOCUS:
!       self.SetColor(3)
      else:
!       self.SetColor(2)
!     self.LoLight()
      for i in range(0, self.UsedSpace):
!       Screen.PutAt((Pos - self.UsedSpace) + i,self.X, ' ', curses.A_REVERSE)
      Screen.AutoRefresh = 1
      Screen.Refresh()
  
    def _ChangePos(self,arg1,newY,arg3):
      Screen = self.PARENT.Screen()
!     Y = newY - self.start 
      Screen.PrintAt(0,0,'Y = ' + str(Y) + '  ' + str(self.WorkingArea))
      if Y >= (self.WorkingArea-1):
        val = self._max
--- 89,106 ----
        Pos = self.start + self.UsedSpace
      # draw the handle in "menu"-hilight
      if self.FOCUS:
!       self.SetColor(sio.C_SCROLL_SLIDER_FOCUS)
      else:
!       self.SetColor(sio.C_SCROLL_SLIDER)
!     #self.LoLight()
      for i in range(0, self.UsedSpace):
!       Screen.PutAt((Pos - self.UsedSpace) + i,self.X, 'x')#, curses.A_REVERSE)
      Screen.AutoRefresh = 1
      Screen.Refresh()
  
    def _ChangePos(self,arg1,newY,arg3):
      Screen = self.PARENT.Screen()
!     Y = newY - self.start
      Screen.PrintAt(0,0,'Y = ' + str(Y) + '  ' + str(self.WorkingArea))
      if Y >= (self.WorkingArea-1):
        val = self._max
Index: gnue/common/src/cursing/__init__.py
diff -c gnue/common/src/cursing/__init__.py:1.1 
gnue/common/src/cursing/__init__.py:1.2
*** gnue/common/src/cursing/__init__.py:1.1     Wed Oct  9 22:44:22 2002
--- gnue/common/src/cursing/__init__.py Thu Oct 10 21:46:06 2002
***************
*** 56,61 ****
--- 56,62 ----
    "ScreenContainer ",
    "ScrollBar ",
    "TextBox ",
+   "TextArea ",
    "VButton ",
    "VScrollBar "
  ]
Index: gnue/common/src/cursing/sio.py
diff -c gnue/common/src/cursing/sio.py:1.4 gnue/common/src/cursing/sio.py:1.5
*** gnue/common/src/cursing/sio.py:1.4  Thu Oct 10 02:45:35 2002
--- gnue/common/src/cursing/sio.py      Thu Oct 10 21:46:06 2002
***************
*** 28,34 ****
  
  from gnue.common import GDebug
  
! # 
  # sio.py
  #
  # An interface to curses
--- 28,34 ----
  
  from gnue.common import GDebug
  
! #
  # sio.py
  #
  # An interface to curses
***************
*** 37,42 ****
--- 37,60 ----
  from constants import *
  import curses
  
+ C_SCREEN = 1
+ C_STATUSBAR = 2
+ C_TITLEBAR = 3
+ C_MENUBAR = 4
+ C_MENUBAR_FOCUS = 5
+ C_LABEL = 6
+ C_DIALOG = 7
+ C_DIALOG_TITLE = 8
+ C_TEXTBOX_FOCUS = 9
+ C_TEXTBOX = 10
+ C_BUTTON = 11
+ C_BUTTON_FOCUS = 12
+ C_SCROLL_BUTTON = 13
+ C_SCROLL_BUTTON_FOCUS = 14
+ C_SCROLL_BACKGROUND = 15
+ C_SCROLL_SLIDER = 16
+ C_SCROLL_SLIDER_FOCUS = 17
+ 
  class sio:
    """
    This class basically acts as an interface to curses.  To convert this
***************
*** 109,133 ****
        #self.SetColor(1)
  
        if curses.has_colors ():
!         # set red to white
!         curses.init_pair( 1, curses.COLOR_WHITE,
!           curses.COLOR_BLACK)
!         # set green to yellow with black back
!         curses.init_pair( 2, curses.COLOR_YELLOW,
!           curses.COLOR_BLACK)
!         # set yellow to cyan with black back
!         curses.init_pair( 3, curses.COLOR_CYAN,
!           curses.COLOR_BLACK)
!         # set blue to magenta with black back
!         curses.init_pair( 4, curses.COLOR_MAGENTA,
!           curses.COLOR_BLACK)
      except:
        pass
  
      events = curses.mousemask(curses.BUTTON1_CLICKED)
  
      if events == 0:
!       self.PrintAt(self.MAXROW, self.MAXCOL-8, 'SCHEISSE: no mouse.')
  
      self.AutoRefresh = 1
      self.Started = 1
--- 127,158 ----
        #self.SetColor(1)
  
        if curses.has_colors ():
!         curses.init_pair(C_SCREEN, curses.COLOR_WHITE,curses.COLOR_BLUE)
!         curses.init_pair(C_STATUSBAR, curses.COLOR_WHITE,curses.COLOR_BLUE)
!         curses.init_pair(C_TITLEBAR, curses.COLOR_WHITE,curses.COLOR_BLUE)
!         curses.init_pair(C_MENUBAR, curses.COLOR_YELLOW,curses.COLOR_BLUE)
!         curses.init_pair(C_MENUBAR_FOCUS, 
curses.COLOR_BLUE,curses.COLOR_WHITE)
!         curses.init_pair(C_LABEL, curses.COLOR_BLACK,curses.COLOR_WHITE)
!         curses.init_pair(C_DIALOG, curses.COLOR_BLACK,curses.COLOR_WHITE)
!         curses.init_pair(C_DIALOG_TITLE, 
curses.COLOR_YELLOW,curses.COLOR_WHITE)
!         curses.init_pair(C_TEXTBOX_FOCUS, curses.COLOR_BLACK,6)
! #        curses.init_pair(C_TEXTBOX, curses.COLOR_WHITE,curses.COLOR_BLUE)
!         curses.init_pair(C_TEXTBOX, curses.COLOR_BLUE,curses.COLOR_WHITE)
!         curses.init_pair(C_BUTTON, curses.COLOR_BLUE,curses.COLOR_WHITE)
!         curses.init_pair(C_BUTTON_FOCUS, curses.COLOR_WHITE,curses.COLOR_BLUE)
!         curses.init_pair(C_SCROLL_BUTTON, 
curses.COLOR_BLACK,curses.COLOR_WHITE)
!         curses.init_pair(C_SCROLL_BUTTON_FOCUS, 6,curses.COLOR_WHITE)
!         curses.init_pair(C_SCROLL_BACKGROUND, 
curses.COLOR_BLUE,curses.COLOR_GRAY)
!         curses.init_pair(C_SCROLL_SLIDER, 
curses.COLOR_WHITE,curses.COLOR_BLUE)
!         curses.init_pair(C_SCROLL_SLIDER_FOCUS, 0, 6)
! 
      except:
        pass
  
      events = curses.mousemask(curses.BUTTON1_CLICKED)
  
      if events == 0:
!       self.PrintAt(self.MAXROW, self.MAXCOL-8, 'no mouse.')
  
      self.AutoRefresh = 1
      self.Started = 1
***************
*** 234,240 ****
      """
      #self.s.addstr(Row, Column, "")
      # not really sure why s.addstr is being used when perhaps a 'move'
!     # will suffice?  
      #print "Row: %s, Col: %s" % (Row, Col)
      self.s.move( Row, Col)
      if self.AutoRefresh :
--- 259,265 ----
      """
      #self.s.addstr(Row, Column, "")
      # not really sure why s.addstr is being used when perhaps a 'move'
!     # will suffice?
      #print "Row: %s, Col: %s" % (Row, Col)
      self.s.move( Row, Col)
      if self.AutoRefresh :
***************
*** 281,288 ****
      """
      if curses.has_colors():
        # TODO: should this be curses.color_pair(colorHi)?
!       self.PrintMods = curses.color_pair(colorHi)
!       ##self.PrintMods = curses.color_pair(colorLo)
      else:
        self.PrintMods = curses.A_NORMAL
  
--- 306,313 ----
      """
      if curses.has_colors():
        # TODO: should this be curses.color_pair(colorHi)?
! ##      self.PrintMods = curses.color_pair(colorHi)
!       self.PrintMods = curses.A_BOLD
      else:
        self.PrintMods = curses.A_NORMAL
  
***************
*** 299,309 ****
--- 324,338 ----
    def SetColor(self, n):
      """
      """
+     self.COLOR = n
      try:
        if curses.has_colors():
          self.PrintMods = curses.color_pair(n)
      except AttributeError:
        pass
+       
+   def GetColor(self): 
+     return self.COLOR
  
  
    def PrintAt(self, Row, Col, String, Mods = None):
Index: gnue/common/src/cursing/utility.py
diff -c gnue/common/src/cursing/utility.py:1.2 
gnue/common/src/cursing/utility.py:1.3
*** gnue/common/src/cursing/utility.py:1.2      Wed Oct  9 23:04:41 2002
--- gnue/common/src/cursing/utility.py  Thu Oct 10 21:46:06 2002
***************
*** 27,32 ****
--- 27,33 ----
  #
  
  from gnue.common import GDebug
+ import curses
  
  #
  # utility.py
***************
*** 34,40 ****
  
  from constants import *
  
! def _paintBorder(dialog, Y, X, H, W, integrateUpper = 0):
    """ draw a border with curses_graphics
    """
    Screen = dialog.SCREEN
--- 35,42 ----
  
  from constants import *
  
! def _paintBorder(dialog, Y, X, H, W, integrateUpper = 0, 
!                  caption=None, captionColor=0):
    """ draw a border with curses_graphics
    """
    Screen = dialog.SCREEN
***************
*** 51,56 ****
--- 53,69 ----
  
    # first line
    Screen.PrintAt( Y,X, chr(upperLC) + (W-2) * chr(tiHLINE) + chr(upperRC))
+ 
+   if caption:
+     Screen.PrintAt (Y,X + 2, " ") #chr(tiRTEE) + " ")
+     Screen.PrintAt (Y,X + 2 + len(caption) + 1, " ") # + chr(tiLTEE) )
+     color = Screen.GetColor()
+     Screen.SetColor(captionColor or color)
+     Screen.PrintAt (Y,X + 3, caption, curses.A_BOLD)
+     Screen.SetColor(color)
+ 
+ 
+ 
  
    # "body"
    for i in range(Y+1,Y+H-1):




reply via email to

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