[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9162 - trunk/gnue-forms/src/uidrivers/curses/widgets
From: |
johannes |
Subject: |
[gnue] r9162 - trunk/gnue-forms/src/uidrivers/curses/widgets |
Date: |
Wed, 13 Dec 2006 03:33:39 -0600 (CST) |
Author: johannes
Date: 2006-12-13 03:33:38 -0600 (Wed, 13 Dec 2006)
New Revision: 9162
Modified:
trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
Log:
Listboxes do have a selection
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-12-13
09:03:46 UTC (rev 9161)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-12-13
09:33:38 UTC (rev 9162)
@@ -25,7 +25,7 @@
from gnue.forms.uidrivers._base.widgets._base import UIWidget
-__all__ = ['UIHelper', 'box', 'ManagedBoxMixin']
+__all__ = ['UIHelper', 'box', 'ManagedBox']
# =============================================================================
# Widget helper class
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-12-13
09:03:46 UTC (rev 9161)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-12-13
09:33:38 UTC (rev 9162)
@@ -25,11 +25,16 @@
from _base import UIHelper
+__all__ = ['UIEntry']
+
# =============================================================================
# Entry class
# =============================================================================
class UIEntry(UIHelper):
+ """
+ Interface implementation for <entry> widgets.
+ """
# -------------------------------------------------------------------------
# Initialization
@@ -39,7 +44,7 @@
UIHelper.__init__(self, event)
- self.__style = self._gfObject.style
+ self.__style = self._gfObject.style.lower()
self.__value = {}
self.__offset = {}
self.__selection = {}
@@ -67,7 +72,6 @@
def _create_widget_(self, event, spacer):
UIHelper._create_widget_(self, event, spacer)
- gDebug(2, "Creating widget: %s[%s]" % (self._gfObject.name, spacer))
self.__value[spacer] = None
self.__selection[spacer] = None
@@ -76,7 +80,6 @@
self.__voffset[spacer] = 0
self.__index[spacer] = 0
self.__pindex[spacer] = 1
- gLeave(2)
# -------------------------------------------------------------------------
@@ -109,7 +112,7 @@
if self.__style == 'listbox':
self.__oldCursor = curses.curs_set(0)
- self.__updateCursorPosition()
+ self.__update_cursor_position()
self.__repaint(index)
@@ -312,16 +315,14 @@
for (line, value) in enumerate(lines):
text = value.ljust(self.width)[:self.width]
- attr = self.__getAttr(index)
-
+ attr = self.__get_attr(index, (line == self.__pindex[index]-1))
# Note: this is not safe if there's a gap !
- self._set_text(index+line, text, attr, self.__selection[index])
+ self._set_text(index+line, text, attr)
self._parent.move(self.left, self.top + self.__pindex[index] - 1)
elif self.__is_multiline:
# Create all visible, empty lines
- gDebug(2, "LEN: %s, H: %s" % (self.width, self.height))
data = [''.ljust(self.width)] * self.height
hOffset = self.__offset[index]
vOffset = self.__voffset[index]
@@ -333,7 +334,7 @@
text = text[hOffset:hOffset + self.width]
data[ix] = text.ljust(self.width)[:self.width]
- attr = self.__getAttr(index)
+ attr = self.__get_attr(index)
# And write everything to screen
for (ix, text) in enumerate(data):
@@ -368,7 +369,7 @@
else:
gDebug(2, "STYLE==%s" % self.__style)
- attr = self.__getAttr(index)
+ attr = self.__get_attr(index)
self._set_text(index, text, attr, self.__selection[index])
@@ -376,18 +377,22 @@
# Get the current screen attributes to be used
# -------------------------------------------------------------------------
- def __getAttr(self, index):
+ def __get_attr(self, index, selected=False):
+ add = 0
if self.__style == 'label':
- attr = self._uiDriver.attr['background']
+ attr = 'background'
elif not self.__enabled[index]:
- attr = self._uiDriver.attr['disabled']
+ attr = 'disabled'
+
elif index == self.__focusIndex:
- attr = self._uiDriver.attr['focusentry']
+ attr = 'focusentry'
+ if self.__style == 'listbox' and selected:
+ add = curses.A_STANDOUT
else:
- attr = self._uiDriver.attr['entry']
+ attr = 'entry'
- return attr
+ return self._uiDriver.attr[attr] + add
# -------------------------------------------------------------------------
@@ -444,8 +449,7 @@
self.__pindex[index] = min(self.__pindex[index], self.height)
self.__value[index] = self.__choices[self.__index[index]]
- self._request('REPLACEVALUE', text =
- self.__choices[self.__index[index]])
+ self._request('REPLACEVALUE', text = self.__value[index])
# -------------------------------------------------------------------------
# Set cursor position for widget
@@ -454,13 +458,13 @@
def __setCursor(self, x, y):
self.__cursor = (x, y)
- self.__updateCursorPosition()
+ self.__update_cursor_position()
# -------------------------------------------------------------------------
# Update cursor position
# -------------------------------------------------------------------------
- def __updateCursorPosition(self):
+ def __update_cursor_position(self):
if self.__focusIndex is not None:
(x, y) = self.__cursor
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9162 - trunk/gnue-forms/src/uidrivers/curses/widgets,
johannes <=