[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9381 - trunk/gnue-forms/src/uidrivers/curses/widgets
From: |
johannes |
Subject: |
[gnue] r9381 - trunk/gnue-forms/src/uidrivers/curses/widgets |
Date: |
Wed, 14 Feb 2007 02:36:18 -0600 (CST) |
Author: johannes
Date: 2007-02-14 02:36:18 -0600 (Wed, 14 Feb 2007)
New Revision: 9381
Modified:
trunk/gnue-forms/src/uidrivers/curses/widgets/menu.py
Log:
Better placement of submenus, separator are also navigable (fixed
scrolling)
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/menu.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/menu.py 2007-02-14
07:56:56 UTC (rev 9380)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/menu.py 2007-02-14
08:36:18 UTC (rev 9381)
@@ -98,20 +98,30 @@
offsy = ca_top
maxy, maxx = ca_bottom, ca_right
+ move_y = 0
+ # Can we add it to the right side
if offsx + self.__sep_len + 4 < maxx:
self.left = offsx
+ # Hm, so try to add it to the left side, but make sure to move the
+ # vertical position by a line (otherwise it would hide the linking menu
+ # entry)
elif offsx - self.__sep_len - 4 > 0:
self.left = offsx - self.__sep_len - 4
+ move_y = 1
+ # Ok, there seems to be no place for this menu, so just align it at the
+ # left margin.
else:
self.left = 0
+ move_y = 1
- if offsy + len(self.__data) + 2 < maxy:
- self.top = offsy
+ # Vertical position: is there enough space below the starting row
+ if offsy + move_y + len(self.__data) + 2 < maxy:
+ self.top = offsy + move_y
- elif offsy - len(self.__data) - 2 > 0:
- self.top = offsy - len(self.__data) - 2
+ elif offsy - move_y - len(self.__data) - 2 > 0:
+ self.top = offsy - move_y - len(self.__data) - 2
else:
self.top = 0
@@ -196,14 +206,18 @@
data.extend([''] * (count - len(data)))
for row, value in enumerate(data):
+ attr = self.__normal
+ if highlight and row == self.display:
+ attr = self.__reverse
+
if isinstance(value, basestring):
text = value.ljust(self.width - 2)[:self.width - 2]
- attr = self.__normal
- if highlight and row == self.display:
- attr = self.__reverse
self.__window.addstr(1 + row, 1, o(text), attr)
else:
- self.__window.hline(1 + row, 2, curses.ACS_HLINE, self.width-4)
+ self.__window.addch(1 + row, 1, ' ', attr)
+ self.__window.hline(1 + row, 2, curses.ACS_HLINE | attr,
+ self.width - 4)
+ self.__window.addch(1 + row, self.width - 2, ' ', attr)
self.__window.refresh()
@@ -245,8 +259,10 @@
break
elif key != curses.KEY_RIGHT:
- current._gfObject._event_fire()
- break
+ # Don't fire an event on separators
+ if current._gfObject.label is not None:
+ current._gfObject._event_fire()
+ break
elif key == curses.KEY_LEFT:
result = False
@@ -283,7 +299,7 @@
def __step_down(self, destination, run):
offsx = self.left + self.width - 1
- offsy = self.top + self.selected + 1
+ offsy = self.top + self.display + 1
return destination.show(self.__page, offsx, offsy, run)
@@ -293,13 +309,12 @@
def __move(self, direction):
- movement = self.__get_next(direction)
- self.display += movement
- self.selected += movement
+ self.display += direction
+ self.selected += direction
if self.display >= self.height - 2:
if self.selected < len(self.__data):
- self.offset += movement
+ self.offset += 1
elif self.display < 0:
self.offset = max(0, self.offset - 1)
@@ -312,26 +327,6 @@
# -------------------------------------------------------------------------
- # Get the next usable menu-item (skipping separators)
- # -------------------------------------------------------------------------
-
- def __get_next(self, direction):
-
- if direction > 0:
- next = self.__data[self.selected+1:]
- else:
- next = self.__data[:self.selected]
- next.reverse()
-
- for add, item in enumerate(next):
- if item != self.__separator:
- res = direction * (add + 1)
- return res
-
- return 0
-
-
- # -------------------------------------------------------------------------
# Repaint the menu
# -------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9381 - trunk/gnue-forms/src/uidrivers/curses/widgets,
johannes <=