commit-gnue
[Top][All Lists]
Advanced

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

gnue/common/src/cursing Button.py Dialog.py Fra...


From: Jason Cater
Subject: gnue/common/src/cursing Button.py Dialog.py Fra...
Date: Fri, 11 Oct 2002 19:44:12 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/10/11 19:44:12

Modified files:
        common/src/cursing: Button.py Dialog.py Frame.py TextArea.py 
                            TextBox.py __init__.py sio.py 
Added files:
        common/src/cursing: StatusBar.py 

Log message:
        Added Frame and StatusBar support; more code cleanup

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/StatusBar.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Button.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Dialog.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/Frame.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/TextArea.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/TextBox.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/__init__.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/cursing/sio.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gnue/common/src/cursing/Button.py
diff -c gnue/common/src/cursing/Button.py:1.5 
gnue/common/src/cursing/Button.py:1.6
*** gnue/common/src/cursing/Button.py:1.5       Thu Oct 10 21:46:05 2002
--- gnue/common/src/cursing/Button.py   Fri Oct 11 19:44:12 2002
***************
*** 72,78 ****
        if self.PARENT.BreakOrder(ch) :
          return
  
!       ch = self.PARENT.KeyboardHook(ch)
        if ch == None:
          return
  
--- 72,78 ----
        if self.PARENT.BreakOrder(ch) :
          return
  
!       ch = self.PARENT.KeystrokeHook(ch)
        if ch == None:
          return
  
Index: gnue/common/src/cursing/Dialog.py
diff -c gnue/common/src/cursing/Dialog.py:1.5 
gnue/common/src/cursing/Dialog.py:1.6
*** gnue/common/src/cursing/Dialog.py:1.5       Thu Oct 10 21:46:06 2002
--- gnue/common/src/cursing/Dialog.py   Fri Oct 11 19:44:12 2002
***************
*** 32,37 ****
--- 32,38 ----
  from utility import _paintBorder
  from ScreenContainer import ScreenContainer
  
+ # TODO: This should be based off of Frame
  class Dialog(ScreenContainer):
    """
      like a full screen container, but only a smaller portion of it.
***************
*** 109,115 ****
      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, " ")
--- 110,116 ----
      color = self.SCREEN.GetColor()
      self.SCREEN.SetColor(0)
  
!     self.SCREEN.PrintAt( self.R2 + self.BORDER*2, self.C1 + 1,
             (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, " ")
Index: gnue/common/src/cursing/Frame.py
diff -c gnue/common/src/cursing/Frame.py:1.4 
gnue/common/src/cursing/Frame.py:1.5
*** gnue/common/src/cursing/Frame.py:1.4        Thu Oct 10 21:46:06 2002
--- gnue/common/src/cursing/Frame.py    Fri Oct 11 19:44:12 2002
***************
*** 19,25 ****
  # Copyright 2002 Free Software Foundation
  #
  # FILE:
! # Frame.py
  #
  # DESCRIPTION:
  #
--- 19,25 ----
  # Copyright 2002 Free Software Foundation
  #
  # FILE:
! # Dialog.py
  #
  # DESCRIPTION:
  #
***************
*** 30,57 ****
  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):
!     Y = self.Y
!     X = self.X
!     H = self.H
!     W = self.W
!     _paintBorder(self, Y, X, H, W)
  
  
  
--- 30,137 ----
  from constants import *
  import sio
  from utility import _paintBorder
! from ScreenContainer import ScreenContainer
  
! class Frame(ScreenContainer):
!   """
!     like a full screen container, but only a smaller portion of it.
!     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
!     self.scrnbuff = {}
!     self.Controls = []
!     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:
+     self._Y = r1
+     #else:
+     #  self._Y = 0
+     #if c1 > 0 and c1 <= SIOInstance.MAXCOL:
+     self._X = c1
+     #else:
+     #  self._X = 0
+ 
+     self._DialogWidth = c2 - c1
+     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
+ 
+   def AddFrameControl(self, TheControl):
+     """
+       Make sure the control is visible in the limited area of the
+       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)
+     return TheControl
+ 
+   def AddControl(self,control):
+     return self.AddFrameControl(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._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()
+     return t
+ 
+   def Height(self):
+     return self.R2- self._Y
+ 
+   def Width(self):
+     return self.C2- self._X
  
  
Index: gnue/common/src/cursing/TextArea.py
diff -c gnue/common/src/cursing/TextArea.py:1.1 
gnue/common/src/cursing/TextArea.py:1.2
*** gnue/common/src/cursing/TextArea.py:1.1     Thu Oct 10 21:46:06 2002
--- gnue/common/src/cursing/TextArea.py Fri Oct 11 19:44:12 2002
***************
*** 97,158 ****
            pass
          return
  
!       ch = self.PARENT.KeyboardHook(ch)
!       if ch == None:
!         try:
!           curses.curs_set(0)
!         except:
!           pass
!         return
  
!       Depth = self.DEPTH
!       Text = self.TEXT
!       global BACKWARDS
!       if ch in (Container.TokDownArrow, Container.TokNextField, 
Container.TokActivate, Container.TokUpArrow):
!         BACKWARDS = 0
!         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
!         self.last_act = 0
!         if Depth < 0:
            Depth = 0
!       elif ch == Container.TokHomeKey:
!         Depth = 0
!       elif ch == Container.TokEndKey:
!         Depth = len(Text)
!       elif ch == Container.TokRightArrow:
!         Depth = Depth + 1
!         self.last_act = 1
!         if Depth > len(Text):
            Depth = len(Text)
!       elif ch == Container.TokBackspace:
!         Depth = Depth - 1
!         if Depth < 0:
!           Depth = 0
!         Text = Text[0:Depth] + Text[Depth+1:len(Text)]
!       else:
!         if ch <= 256 and self.EDITABLE:
!           if Depth == len(Text):    # at end
!             Text = Text + chr(ch)
!           elif Depth == 0:    # at the beginning
!             if len(Text) == 0:
!               Text = chr(ch)
!             else:
!               Text = chr(ch) + Text
!           else:         # insert text
!             Text = Text[:Depth] + chr(ch) + Text[Depth:]
            Depth = Depth + 1
            self.last_act = 1
!       self.DEPTH = Depth
!       self.TEXT = Text
!       self.Paint(None, None, None)
  
    def BogusVerify(self, TheControl, TheText, v3):
      return 1
--- 97,153 ----
            pass
          return
  
!       ch = self.PARENT.KeystrokeHook(ch)
!       if ch != None:
  
!         Depth = self.DEPTH
!         Text = self.TEXT
!         global BACKWARDS
!         if ch in (Container.TokDownArrow, Container.TokNextField, 
Container.TokActivate, Container.TokUpArrow):
!           BACKWARDS = 0
!           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
!           self.last_act = 0
!           if Depth < 0:
!             Depth = 0
!         elif ch == Container.TokHomeKey:
            Depth = 0
!         elif ch == Container.TokEndKey:
            Depth = len(Text)
!         elif ch == Container.TokRightArrow:
            Depth = Depth + 1
            self.last_act = 1
!           if Depth > len(Text):
!             Depth = len(Text)
!         elif ch == Container.TokBackspace:
!           Depth = Depth - 1
!           if Depth < 0:
!             Depth = 0
!           Text = Text[0:Depth] + Text[Depth+1:len(Text)]
!         else:
!           if ch <= 256 and self.EDITABLE:
!             if Depth == len(Text):    # at end
!               Text = Text + chr(ch)
!             elif Depth == 0:    # at the beginning
!               if len(Text) == 0:
!                 Text = chr(ch)
!               else:
!                 Text = chr(ch) + Text
!             else:         # insert text
!               Text = Text[:Depth] + chr(ch) + Text[Depth:]
!             Depth = Depth + 1
!             self.last_act = 1
!         self.DEPTH = Depth
!         self.TEXT = Text
!         self.Paint(None, None, None)
  
    def BogusVerify(self, TheControl, TheText, v3):
      return 1
Index: gnue/common/src/cursing/TextBox.py
diff -c gnue/common/src/cursing/TextBox.py:1.6 
gnue/common/src/cursing/TextBox.py:1.7
*** gnue/common/src/cursing/TextBox.py:1.6      Thu Oct 10 21:46:06 2002
--- gnue/common/src/cursing/TextBox.py  Fri Oct 11 19:44:12 2002
***************
*** 96,156 ****
            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
!       if ch in (Container.TokDownArrow, Container.TokNextField, 
Container.TokActivate, Container.TokUpArrow):
!         BACKWARDS = 0
!         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
!         self.last_act = 0
!         if Depth < 0:
            Depth = 0
!       elif ch == Container.TokHomeKey:
!         Depth = 0
!       elif ch == Container.TokEndKey:
!         Depth = len(Text)
!       elif ch == Container.TokRightArrow:
!         Depth = Depth + 1
!         self.last_act = 1
!         if Depth > len(Text):
            Depth = len(Text)
!       elif ch == Container.TokBackspace:
!         Depth = Depth - 1
!         if Depth < 0:
!           Depth = 0
!         Text = Text[0:Depth] + Text[Depth+1:len(Text)]
!       else:
!         if ch <= 256 and self.EDITABLE:
!           if Depth == len(Text):    # at end
!             Text = Text + chr(ch)
!           elif Depth == 0:    # at the beginning
!             if len(Text) == 0:
!               Text = chr(ch)
!             else:
!               Text = chr(ch) + Text
!           else:         # insert text
!             Text = Text[:Depth] + chr(ch) + Text[Depth:]
            Depth = Depth + 1
            self.last_act = 1
!       self.DEPTH = Depth
!       self.TEXT = Text
!       self.Paint(None, None, None)
  
    def BogusVerify(self, TheControl, TheText, v3):
      return 1
--- 96,157 ----
            pass
          return
  
!       ch = self.PARENT.KeystrokeHook(ch)
        if ch == None:
          try:
            curses.curs_set(0)
          except:
            continue
+       else:
  
!         Depth = self.DEPTH
!         Text = self.TEXT
!         global BACKWARDS
!         if ch in (Container.TokDownArrow, Container.TokNextField, 
Container.TokActivate, Container.TokUpArrow):
!           BACKWARDS = 0
!           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
!           self.last_act = 0
!           if Depth < 0:
!             Depth = 0
!         elif ch == Container.TokHomeKey:
            Depth = 0
!         elif ch == Container.TokEndKey:
            Depth = len(Text)
!         elif ch == Container.TokRightArrow:
            Depth = Depth + 1
            self.last_act = 1
!           if Depth > len(Text):
!             Depth = len(Text)
!         elif ch == Container.TokBackspace:
!           Depth = Depth - 1
!           if Depth < 0:
!             Depth = 0
!           Text = Text[0:Depth] + Text[Depth+1:len(Text)]
!         else:
!           if ch <= 256 and self.EDITABLE:
!             if Depth == len(Text):    # at end
!               Text = Text + chr(ch)
!             elif Depth == 0:    # at the beginning
!               if len(Text) == 0:
!                 Text = chr(ch)
!               else:
!                 Text = chr(ch) + Text
!             else:         # insert text
!               Text = Text[:Depth] + chr(ch) + Text[Depth:]
!             Depth = Depth + 1
!             self.last_act = 1
!         self.DEPTH = Depth
!         self.TEXT = Text
!         self.Paint(None, None, None)
  
    def BogusVerify(self, TheControl, TheText, v3):
      return 1
Index: gnue/common/src/cursing/__init__.py
diff -c gnue/common/src/cursing/__init__.py:1.3 
gnue/common/src/cursing/__init__.py:1.4
*** gnue/common/src/cursing/__init__.py:1.3     Fri Oct 11 01:10:37 2002
--- gnue/common/src/cursing/__init__.py Fri Oct 11 19:44:12 2002
***************
*** 43,49 ****
    "FocusedLabel ",
    "Frame ",
    "GraphicObject ",
!   "GroupBox ",  
    "InputBox ",
    "Label ",
    "Menu ",
--- 43,49 ----
    "FocusedLabel ",
    "Frame ",
    "GraphicObject ",
!   "GroupBox ",
    "InputBox ",
    "Label ",
    "Menu ",
***************
*** 56,61 ****
--- 56,62 ----
    "RadioGroup ",
    "ScreenContainer ",
    "ScrollBar ",
+   "StatusBar ",
    "TextBox ",
    "TextArea ",
    "VButton ",
Index: gnue/common/src/cursing/sio.py
diff -c gnue/common/src/cursing/sio.py:1.5 gnue/common/src/cursing/sio.py:1.6
*** gnue/common/src/cursing/sio.py:1.5  Thu Oct 10 21:46:06 2002
--- gnue/common/src/cursing/sio.py      Fri Oct 11 19:44:12 2002
***************
*** 54,59 ****
--- 54,61 ----
  C_SCROLL_BACKGROUND = 15
  C_SCROLL_SLIDER = 16
  C_SCROLL_SLIDER_FOCUS = 17
+ C_STATUSBAR = 18
+ C_STATUSBAR_FIELD = 19
  
  class sio:
    """
***************
*** 145,150 ****
--- 147,154 ----
          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)
+         curses.init_pair(C_STATUSBAR, curses.COLOR_BLACK, curses.COLOR_WHITE)
+         curses.init_pair(C_STATUSBAR_FIELD, curses.COLOR_BLUE, 
curses.COLOR_WHITE)
  
      except:
        pass
***************
*** 330,337 ****
          self.PrintMods = curses.color_pair(n)
      except AttributeError:
        pass
!       
!   def GetColor(self): 
      return self.COLOR
  
  
--- 334,341 ----
          self.PrintMods = curses.color_pair(n)
      except AttributeError:
        pass
! 
!   def GetColor(self):
      return self.COLOR
  
  
***************
*** 345,350 ****
--- 349,355 ----
    def Cls(self):
      """
      """
+     self.SetColor(1)
      self.AutoRefresh = 0
      for row in range(0, self.MAXROW+1):
        self.PrintAt(row, 0, " " * self.MAXCOL)




reply via email to

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