commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8730 - trunk/gnue-forms/src/GFObjects


From: reinhard
Subject: [gnue] r8730 - trunk/gnue-forms/src/GFObjects
Date: Tue, 10 Oct 2006 11:52:51 -0500 (CDT)

Author: reinhard
Date: 2006-10-10 11:52:51 -0500 (Tue, 10 Oct 2006)
New Revision: 8730

Modified:
   trunk/gnue-forms/src/GFObjects/GFTabStop.py
Log:
recalculate_visible must be in GFTabStops because it is also used for buttons.


Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-10-10 16:23:59 UTC (rev 
8729)
+++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-10-10 16:52:51 UTC (rev 
8730)
@@ -70,7 +70,13 @@
 
         self._page     = None
 
+        self._rows = 1
+        self._gap = 0
 
+        self.__first_visible_record = 0
+        self.__last_enabled_row = 0
+
+
     # -------------------------------------------------------------------------
     # Implementation of virtual methods
     # -------------------------------------------------------------------------
@@ -107,8 +113,68 @@
                 return self.navigable and (not self.readonly)
 
 
+    # -------------------------------------------------------------------------
+    # Recalculate the visible index of an object
+    # -------------------------------------------------------------------------
+
+    def recalculate_visible(self, adjustment, cur_record, rec_count):
+        """
+        Recalculate the visible index of an object. This determines that real 
UI
+        widget of a 'row-based grid' which should be visible.
+
+        @param adjustment: value to change the visible index, e.g. 1 or -1
+        @param cur_record: the currently active record
+        @param rec_count: the number of records available at all
+
+        As a result of this recalculation the property self._visibleIndex will
+        be set to the new value.
+        """
+
+        if self.hidden:
+            return
+
+        index = min(max(self._visibleIndex + adjustment, 0),
+                    int(self._rows)-1)
+
+        # Don't let the index pass the number of records
+        lowestVisible = max(cur_record - index, 0)
+        if lowestVisible + index > rec_count:
+            index = index -1
+
+        # If the current record has rolled around from the top to the
+        # bottom then reset the counter.
+        if cur_record == 0:
+            index = 0
+
+        self._visibleIndex = index
+
+        if self.uiWidget is not None:
+            last_enabled_row = self._visibleIndex + \
+                    (rec_count - cur_record) - 1
+            last_enabled_row = min(last_enabled_row, self._rows - 1)
+
+            # Disable rows if necessary
+            for i in range(last_enabled_row + 1, self.__last_enabled_row + 1):
+                self.uiWidget._ui_disable_(i)
+
+            # Enable rows if necessary
+            for i in range(self.__last_enabled_row + 1, last_enabled_row + 1):
+                self.uiWidget._ui_enable_(i)
+
+            self.__last_enabled_row = last_enabled_row
+
+            # If we have scrolled, redisplay all records
+            first_visible_record = cur_record - self._visibleIndex
+            # FIXME
+            # if first_visible_record != self.__first_visible_record:
+            if True:
+                if isinstance(self, GFFieldBound):
+                    self.refresh_ui(0, self._rows - 1)
+                self.__first_visible_record = first_visible_record
+
+
 # =============================================================================
-# Mixin class for all widgets bound to a field
+# Base class for all widgets bound to a field
 # =============================================================================
 
 class GFFieldBound(GFTabStop):
@@ -124,13 +190,7 @@
         self._block = None
         self._field = None
 
-        self._rows = 1
-        self._gap = 0
 
-        self.__first_visible_record = 0
-        self.__last_enabled_row = 0
-
-
     # -------------------------------------------------------------------------
     # Phase 1 init
     # -------------------------------------------------------------------------
@@ -166,63 +226,6 @@
 
 
     # -------------------------------------------------------------------------
-    # Recalculate the visible index of an object
-    # -------------------------------------------------------------------------
-
-    def recalculate_visible(self, adjustment, cur_record, rec_count):
-        """
-        Recalculate the visible index of an object. This determines that real 
UI
-        widget of a 'row-based grid' which should be visible.
-
-        @param adjustment: value to change the visible index, e.g. 1 or -1
-        @param cur_record: the currently active record
-        @param rec_count: the number of records available at all
-
-        As a result of this recalculation the property self._visibleIndex will
-        be set to the new value.
-        """
-
-        if not self.hidden:
-            index = min(max(self._visibleIndex + adjustment, 0),
-                        int(self._rows)-1)
-
-            # Don't let the index pass the number of records
-            lowestVisible = max(cur_record - index, 0)
-            if lowestVisible + index > rec_count:
-                index = index -1
-
-            # If the current record has rolled around from the top to the
-            # bottom then reset the counter.
-            if cur_record == 0:
-                index = 0
-
-            self._visibleIndex = index
-
-            if self.uiWidget is not None:
-                last_enabled_row = self._visibleIndex + \
-                        (rec_count - cur_record) - 1
-                last_enabled_row = min(last_enabled_row, self._rows - 1)
-
-                # Disable rows if necessary
-                for i in range(last_enabled_row+1, self.__last_enabled_row+1):
-                    self.uiWidget._ui_disable_(i)
-
-                # Enable rows if necessary
-                for i in range(self.__last_enabled_row+1, last_enabled_row+1):
-                    self.uiWidget._ui_enable_(i)
-
-                self.__last_enabled_row = last_enabled_row
-
-                # If we have scrolled, redisplay all records
-                first_visible_record = cur_record - self._visibleIndex
-                # FIXME
-                # if first_visible_record != self.__first_visible_record:
-                if True:
-                    self.refresh_ui(0, self._rows - 1)
-                    self.__first_visible_record = first_visible_record
-
-
-    # -------------------------------------------------------------------------
     # Refresh the user interface with the current field data for current row
     # -------------------------------------------------------------------------
 
@@ -239,6 +242,10 @@
         if self.hidden:
             return
 
+        if not self.uiWidget:
+            print "refresh_ui called without uiWidget"
+            return
+
         for index in range (from_index, to_index + 1):
             # Do not execute if we were editing - would overwrite unsaved 
change
             if not self._displayHandler.editing:





reply via email to

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