commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8707 - trunk/gnue-forms/src/uidrivers/curses/widgets


From: reinhard
Subject: [gnue] r8707 - trunk/gnue-forms/src/uidrivers/curses/widgets
Date: Mon, 2 Oct 2006 08:25:37 -0500 (CDT)

Author: reinhard
Date: 2006-10-02 08:25:37 -0500 (Mon, 02 Oct 2006)
New Revision: 8707

Modified:
   trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/button.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
Log:
A little restructuring.


Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py      2006-10-02 
10:50:13 UTC (rev 8706)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py      2006-10-02 
13:25:37 UTC (rev 8707)
@@ -41,13 +41,9 @@
 
     # should go in base uidriver
     self._parent = event.parent
-    self._focusIndex = None
     self._x = self._gfObject ['Char:x']
     self._y = self._gfObject ['Char:y']
 
-    # curses specific
-    self.__cursor = (0, 0)
-
   # ---------------------------------------------------------------------------
   # Initialize widget
   # ---------------------------------------------------------------------------
@@ -63,20 +59,14 @@
 
   def indexed_focus (self, index):
 
-    # should go in base uidriver
-    self._focusIndex = index
     self._getFocus (index)
 
-    # curses specific
-    self.__updateCursorPosition ()
-
   # ---------------------------------------------------------------------------
   # Remove focus from widget
   # ---------------------------------------------------------------------------
 
   def lose_focus (self, index):
 
-    self._focusIndex = None
     self._lose_focus (index)
 
   # ---------------------------------------------------------------------------
@@ -93,22 +83,3 @@
       self._parent.write (self._x + s2, self._y + index, text[s2:], attr)
     else:
       self._parent.write (self._x, self._y + index, text, attr)
-
-  # ---------------------------------------------------------------------------
-  # Set cursor position for widget
-  # ---------------------------------------------------------------------------
-
-  def _setCursor (self, x, y):
-
-    self.__cursor = (x, y)
-    self.__updateCursorPosition ()
-
-  # ---------------------------------------------------------------------------
-  # Update cursor position
-  # ---------------------------------------------------------------------------
-
-  def __updateCursorPosition (self):
-
-    if self._focusIndex is not None:
-      (x, y) = self.__cursor
-      self._parent.move (self._x + x, self._y + self._focusIndex + y)

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/button.py     2006-10-02 
10:50:13 UTC (rev 8706)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/button.py     2006-10-02 
13:25:37 UTC (rev 8707)
@@ -53,7 +53,7 @@
 
   def _init (self, index):
 
-    self.__repaint (index)
+    self.__repaint (index, False)
 
   # ---------------------------------------------------------------------------
   # Focus has changed to this button
@@ -61,7 +61,7 @@
 
   def _getFocus (self, index):
 
-    self.__repaint (index)
+    self.__repaint (index, True)
 
   # ---------------------------------------------------------------------------
   # Focus has changed away from this button
@@ -69,15 +69,15 @@
 
   def _lose_focus (self, index):
 
-    self.__repaint (index)
+    self.__repaint (index, False)
 
   # ---------------------------------------------------------------------------
   # Update button representation on screen
   # ---------------------------------------------------------------------------
 
-  def __repaint (self, index):
+  def __repaint (self, index, focused):
 
-    if index == self._focusIndex:
+    if focused:
       attr = self._uiDriver.attr ['focusentry']
     else:
       attr = self._uiDriver.attr ['entry']

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py      2006-10-02 
10:50:13 UTC (rev 8706)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py      2006-10-02 
13:25:37 UTC (rev 8707)
@@ -55,6 +55,10 @@
     self.__isMultiline = (self.__style in ['default', 'password'] and \
                           self.__height > 1)
 
+    self.__focusIndex = None
+
+    self.__cursor = (0, 0)
+
     # additional indices for listboxes
     self.__index  = {}
     self.__pindex = {}
@@ -68,7 +72,7 @@
       self.__data.sort ()
 
     if self.__style == 'checkbox':
-      self._setCursor (1, 0)
+      self.__setCursor (1, 0)
 
   # ---------------------------------------------------------------------------
   # Initialization per row
@@ -90,6 +94,8 @@
 
   def _getFocus (self, index):
 
+    self.__focusIndex = index
+
     self.__offset [index]  = 0
     self.__voffset [index] = 0
     self.__index [index]   = 0
@@ -98,6 +104,8 @@
     if self.__style == 'listbox':
       self.__oldCursor = curses.curs_set (0)
 
+    self.__updateCursorPosition ()
+
     self.__repaint (index)
 
   # ---------------------------------------------------------------------------
@@ -109,6 +117,8 @@
     if self.__style == 'listbox':
       curses.curs_set (self.__oldCursor)
 
+    self.__focusIndex = None
+
     self.__repaint (index)
 
   # ---------------------------------------------------------------------------
@@ -146,7 +156,7 @@
         self.__offset [index]  = 0
         self.__voffset [index] = 0
         self.__repaint (index)
-        self._setCursor (0, 0)
+        self.__setCursor (0, 0)
         return
 
       # Grab the text portion, which is everything up to position. If the last
@@ -203,7 +213,7 @@
       assert gDebug (2, "H/V: %s/%s - Offsets %s/%s" % (cpHorizontal, 
cpVertical,
         self.__offset [index], self.__voffset [index]))
 
-      self._setCursor (cpHorizontal, cpVertical)
+      self.__setCursor (cpHorizontal, cpVertical)
 
 
     else:
@@ -221,7 +231,7 @@
 
         position = npos
 
-      self._setCursor (position, 0)
+      self.__setCursor (position, 0)
 
 
   # ---------------------------------------------------------------------------
@@ -311,7 +321,7 @@
       attr = self._uiDriver.attr ['background']
     elif not self.__enabled [index]:
       attr = self._uiDriver.attr ['disabled']
-    elif index == self._focusIndex:
+    elif index == self.__focusIndex:
       attr = self._uiDriver.attr ['focusentry']
     else:
       attr = self._uiDriver.attr ['entry']
@@ -349,7 +359,7 @@
 
   def __move (self, direction):
 
-    index = self._focusIndex
+    index = self.__focusIndex
     self.__pindex [index] += direction
     self.__index [index] += direction
 
@@ -368,8 +378,26 @@
 
     self.__value [index] = self.__data [self.__index [index]]
     self._request ('REPLACEVALUE', text = self.__data [self.__index [index]])
-    
 
+  # ---------------------------------------------------------------------------
+  # Set cursor position for widget
+  # ---------------------------------------------------------------------------
+
+  def __setCursor (self, x, y):
+
+    self.__cursor = (x, y)
+    self.__updateCursorPosition ()
+
+  # ---------------------------------------------------------------------------
+  # Update cursor position
+  # ---------------------------------------------------------------------------
+
+  def __updateCursorPosition (self):
+
+    if self.__focusIndex is not None:
+      (x, y) = self.__cursor
+      self._parent.move (self._x + x, self._y + self.__focusIndex + y)
+
 # =============================================================================
 # Configuration data
 # =============================================================================





reply via email to

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