[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8750 - in trunk/gnue-forms/src/uidrivers: _base/widgets curses/w
From: |
johannes |
Subject: |
[gnue] r8750 - in trunk/gnue-forms/src/uidrivers: _base/widgets curses/widgets gtk2/widgets qt3 qt3/widgets win32/widgets wx/widgets wx26/widgets |
Date: |
Wed, 11 Oct 2006 07:07:26 -0500 (CDT) |
Author: johannes
Date: 2006-10-11 07:07:23 -0500 (Wed, 11 Oct 2006)
New Revision: 8750
Modified:
trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py
trunk/gnue-forms/src/uidrivers/qt3/__init__.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py
trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
Log:
Moved bounding-box stuff into base ui driver
Modified: trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py 2006-10-11
09:09:48 UTC (rev 8749)
+++ trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py 2006-10-11
12:07:23 UTC (rev 8750)
@@ -27,12 +27,30 @@
"""
from gnue.common import events
+from gnue.common.definitions import GParser
from gnue.common.definitions.GObjects import GObj
+from gnue.forms.GFObjects import GFTabStop, GFBox, GFScrollBar, GFLabel
from gnue.forms.input.GFKeyMapper import KeyMapper
-__all__ = ['UIWidget']
+__all__ = ['UIWidget', 'InvalidBoundingBoxError']
# =============================================================================
+# Exceptions
+# =============================================================================
+
+class InvalidBoundingBoxError(GParser.MarkupError):
+ """ Element A overlaps Element B """
+ def __init__(self, current, item):
+ cur_type = current._type[2:]
+ cmp_type = item._type[2:]
+ msg = u_("Widget %(cur_type)s '%(cur_name)s' overlaps %(cmp_type)s "
+ "'%(cmp_name)s'") \
+ % {'cur_type': cur_type, 'cur_name': current.name,
+ 'cmp_type': cmp_type, 'cmp_name': item.name}
+ GParser.MarkupError.__init__(self, msg, current._url,
+ current._lineNumber)
+
+# =============================================================================
# Base class for ui widgets
# =============================================================================
@@ -51,6 +69,17 @@
to render the form
@ivar _uiForm: the UIForm widget this widget is a child of
@ivar _form: the GFForm instance owning this widget
+
+ @ivar bouding_boxes: is a list of tuples with the bounding boxes of all the
+ widgets children. Such a tuple is made like (left, top, right, bottom,
+ gfObject of the corresponding child).
+ @ivar chr_x: zero-based x coordinate of the widget
+ @ivar chr_y: zero-based y coordinate of the widget
+ @ivar chr_w: width of the widgets in character-positions
+ @ivar chr_h: height of the widgets in character-positions
+ @ivar chr_pos: tuple of (chr_y, chr_x) defining the upper left corner
+ @ivar chr_span: tuple of (chr_h, chr_w) defining the number of rows and
+ columns the widget occupies
"""
# -------------------------------------------------------------------------
@@ -79,6 +108,14 @@
self.max_width = int(getattr(self._gfObject, 'Sizer__maxwidth', 0))
self.max_height = int(getattr(self._gfObject, 'Sizer__maxheight',
0))
+ else:
+ self.bounding_boxes = []
+ self.chr_w = None
+ self.chr_h = None
+ self.chr_x = None
+ self.chr_y = None
+ self.chr_pos = None
+ self.chr_span = None
self.in_grid = self.findParentOfType('UIGrid') is not None
@@ -131,6 +168,79 @@
# -------------------------------------------------------------------------
+ # Create an instance of the ui widget
+ # -------------------------------------------------------------------------
+
+ def create_widget(self, event, spacer):
+ """
+ """
+
+ if not self.managed:
+ if isinstance(self._gfObject, (GFBox, GFTabStop, GFLabel,
+ GFScrollBar)):
+ gap = self._gfObject._gap + 1
+
+ self.chr_y = self._gfObject.Char__y + spacer * gap
+ self.chr_x = self._gfObject.Char__x
+ self.chr_w = self._gfObject.Char__width
+ self.chr_h = getattr(self._gfObject, 'Char__height', 1)
+
+ self.chr_pos = (self.chr_y, self.chr_x)
+ self.chr_span = (self.chr_h, self.chr_w)
+
+ # Check the bounding box of the parent
+ (left, top, right, bottom) = self.get_bounding_box()
+
+ if getattr(self._uiDriver, '__rearrange_boxes__', False):
+ self.__check_bounding_box()
+
+
+ return self._create_widget_(event, spacer)
+
+
+ # -------------------------------------------------------------------------
+ # Verify if the widget has a proper bounding box
+ # -------------------------------------------------------------------------
+
+ def __check_bounding_box(self):
+
+ owner = self.getParent()
+ if isinstance(owner._gfObject, GFBox):
+ (oright, obottom) = owner.get_bounding_box()[2:]
+
+ if right >= oright or bottom >= obottom or left < 0 or top < 0:
+ raise InvalidBoundingBoxError(self._gfObject, owner._gfObject)
+
+ for (cleft, ctop, cright, cbot, citem) in owner.bounding_boxes:
+ if (right < cleft) or (left > cright) or \
+ (bottom < ctop) or (top > cbot):
+ continue
+ raise InvalidBoundingBoxError(self._gfObject, citem)
+
+ owner.bounding_boxes.append((left, top, right, bottom, self._gfObject))
+
+
+ # -------------------------------------------------------------------------
+ # Get the bounding box of an UIWidget
+ # -------------------------------------------------------------------------
+
+ def get_bounding_box(self):
+ """
+ Get the bounding box of the widget. For managed layouts this is always
+ None. For positioned layouts it is a tuple of character-positions
+ (left, top, right, bottom)
+
+ @returns: bounding-box as (left, top, right, bottom)
+ """
+
+ if self.managed:
+ return None
+ else:
+ return (self.chr_x, self.chr_y, self.chr_x + self.chr_w - 1,
+ self.chr_y + self.chr_h - 1)
+
+
+ # -------------------------------------------------------------------------
# Helper functions for descendants
# -------------------------------------------------------------------------
@@ -211,8 +321,8 @@
# -------------------------------------------------------------------------
# TODO: add docstrings to these methods and pep8-ify them
- def create_widget(self, event, spacer):
- assert gDebug(1,"UI doesn't support %s" % self.__class__)
+ def _create_widget_(event, spacer):
+ assert gDebug(1, "UI does not support %s" % self.__class__)
def _ui_set_focus_(self, index):
self.indexed_focus(index)
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-10-11
09:09:48 UTC (rev 8749)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-10-11
12:07:23 UTC (rev 8750)
@@ -48,7 +48,7 @@
# Initialize widget
# ---------------------------------------------------------------------------
- def create_widget (self, event, spacer):
+ def _create_widget_(self, event, spacer):
# should go in base uidriver
self._init (spacer)
Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py 2006-10-11
09:09:48 UTC (rev 8749)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py 2006-10-11
12:07:23 UTC (rev 8750)
@@ -44,7 +44,7 @@
# Create a new GTK widget
# ---------------------------------------------------------------------------
- def create_widget (self, event, spacer):
+ def _create_widget_ (self, event, spacer):
"""
This function creates a new GTK widget and adds it to the cross reference
table.
Modified: trunk/gnue-forms/src/uidrivers/qt3/__init__.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/__init__.py 2006-10-11 09:09:48 UTC
(rev 8749)
+++ trunk/gnue-forms/src/uidrivers/qt3/__init__.py 2006-10-11 12:07:23 UTC
(rev 8750)
@@ -1,2 +1,4 @@
from UIdriver import *
from UILoginHandler import *
+
+__rearrange_boxes__ = True
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2006-10-11 09:09:48 UTC
(rev 8749)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2006-10-11 12:07:23 UTC
(rev 8750)
@@ -201,7 +201,7 @@
# -------------------------------------------------------------------------
- def _ui_goto_page(self, page):
+ def _ui_goto_page_(self, page):
"""
Change to container to show the requested page
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py 2006-10-11 09:09:48 UTC
(rev 8749)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py 2006-10-11 12:07:23 UTC
(rev 8750)
@@ -19,7 +19,7 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# $Id: $
+# $Id$
import qt
@@ -64,7 +64,7 @@
if isinstance(parent, qt.QTabWidget):
title = "%s" % (self._gfObject.caption or self._gfObject.name)
- parent.addPage(self._container, title)
+ parent.addTab(self._container, title)
else:
parent.layout().addWidget(self._container)
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py 2006-10-11
09:09:48 UTC (rev 8749)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py 2006-10-11
12:07:23 UTC (rev 8750)
@@ -732,7 +732,7 @@
def _ui_set_selected_area_(self, index, selection1, selection2):
self.widgets[index].set_selected_area(selection1, selection2)
- def create_widget(self, event, spacer):
+ def _create_widget_(self, event, spacer):
gfObject = event.object
if hasattr (gfObject, 'Char__y'):
Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py 2006-10-11 09:09:48 UTC
(rev 8749)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py 2006-10-11 12:07:23 UTC
(rev 8750)
@@ -235,7 +235,7 @@
# --------------------------------------------------------------------------
# Create a new widget and add it to the cross reference table
# --------------------------------------------------------------------------
- def create_widget(self, event, spacer):
+ def _create_widget_(self, event, spacer):
"""
Creates a new WX widget and adds it to the cross reference table.
"""
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2006-10-11
09:09:48 UTC (rev 8749)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2006-10-11
12:07:23 UTC (rev 8750)
@@ -31,27 +31,9 @@
from gnue.forms.GFObjects import GFTabStop, GFBox, GFScrollBar, GFLabel
from gnue.forms.uidrivers._base.widgets._base import UIWidget
-__all__ = ['InvalidBoundingBoxError', 'UIHelper', 'ManagedBox',
- 'create_gridbag']
+__all__ = ['UIHelper', 'ManagedBox', 'create_gridbag']
# =============================================================================
-# Exceptions
-# =============================================================================
-
-class InvalidBoundingBoxError(GParser.MarkupError):
- """ Element A overlaps Element B """
- def __init__(self, current, item):
- cur_type = current._type[2:]
- cmp_type = item._type[2:]
- msg = u_("Widget %(cur_type)s '%(cur_name)s' overlaps %(cmp_type)s "
- "'%(cmp_name)s'") \
- % {'cur_type': cur_type, 'cur_name': current.name,
- 'cmp_type': cmp_type, 'cmp_name': item.name}
- GParser.MarkupError.__init__(self, msg, current._url,
- current._lineNumber)
-
-
-# =============================================================================
# This class implements the common behaviour of wx 2.6 widgets
# =============================================================================
@@ -68,17 +50,6 @@
available space this widget will consume as much as possible.
The following attributes are properly set for a positioned layout:
-
- @ivar bouding_boxes: is a list of tuples with the bounding boxes of all the
- widgets children. Such a tuple is made like (left, top, right, bottom,
- gfObject of the corresponding child).
- @ivar chr_x: zero-based x coordinate of the widget
- @ivar chr_y: zero-based y coordinate of the widget
- @ivar chr_w: width of the widgets in character-positions
- @ivar chr_h: height of the widgets in character-positions
- @ivar chr_pos: tuple of (chr_y, chr_x) defining the upper left corner
- @ivar chr_span: tuple of (chr_h, chr_w) defining the number of rows and
- columns the widget occupies
"""
growable = False
@@ -94,93 +65,10 @@
self.label = None
self.widget = None
- self.bounding_boxes = []
- self.chr_w = None
- self.chr_h = None
- self.chr_x = None
- self.chr_y = None
- self.chr_pos = None
- self.chr_span = None
self._block_focus_ = False
# -------------------------------------------------------------------------
- # Create a new wx widget
- # -------------------------------------------------------------------------
-
- def create_widget(self, event, spacer):
- """
- This function creates a new wx widget and adds it to the cross
- reference table.
- """
-
- self.__prepare_for_layout(spacer)
- return self._create_widget_(event, spacer)
-
-
- # -------------------------------------------------------------------------
- # Prepare a widget for the layout-manager
- # -------------------------------------------------------------------------
-
- def __prepare_for_layout(self, spacer):
-
- if not self.managed:
- if isinstance(self._gfObject, (GFBox, GFTabStop, GFLabel,
- GFScrollBar)):
- gap = self._gfObject._gap + 1
-
- self.chr_y = self._gfObject.Char__y + spacer * gap
- self.chr_x = self._gfObject.Char__x
- self.chr_w = self._gfObject.Char__width
- self.chr_h = getattr(self._gfObject, 'Char__height', 1)
-
- self.chr_pos = (self.chr_y, self.chr_x)
- self.chr_span = (self.chr_h, self.chr_w)
-
- # Check the bounding box of the parent
- (left, top, right, bottom) = self.get_bounding_box()
-
- owner = self.getParent()
- if isinstance(owner._gfObject, GFBox):
- (oright, obottom) = owner.get_bounding_box()[2:]
-
- if right >= oright or bottom >= obottom or left < 0 \
- or top < 0:
- raise InvalidBoundingBoxError(self._gfObject,
- owner._gfObject)
-
- for (cleft, ctop, cright, cbot, citem) in owner.bounding_boxes:
- if (right < cleft) or (left > cright) or \
- (bottom < ctop) or (top > cbot):
- continue
-
- raise InvalidBoundingBoxError(self._gfObject, citem)
-
- owner.bounding_boxes.append((left, top, right, bottom,
- self._gfObject))
-
-
- # -------------------------------------------------------------------------
- # Get the bounding box of an UIWidget
- # -------------------------------------------------------------------------
-
- def get_bounding_box(self):
- """
- Get the bounding box of the widget. For managed layouts this is always
- None. For positioned layouts it is a tuple of character-positions
- (left, top, right, bottom)
-
- @returns: bounding-box as (left, top, right, bottom)
- """
-
- if self.managed:
- return None
- else:
- return (self.chr_x, self.chr_y, self.chr_x + self.chr_w - 1,
- self.chr_y + self.chr_h - 1)
-
-
- # -------------------------------------------------------------------------
# Get the best size of a widget
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py 2006-10-11 09:09:48 UTC
(rev 8749)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py 2006-10-11 12:07:23 UTC
(rev 8750)
@@ -30,27 +30,10 @@
from gnue.common.definitions import GParser
from gnue.forms.uidrivers.wx26.widgets import _base
-__all__ = ['InvalidBoundingBoxError', 'UIBox']
+__all__ = ['UIBox']
# =============================================================================
-# Exceptions
-# =============================================================================
-
-class InvalidBoundingBoxError(GParser.MarkupError):
- """ Element A overlaps Element B """
- def __init__(self, current, item):
- cur_type = current._type[2:]
- cmp_type = item._type[2:]
- msg = u_("Widget %(cur_type)s '%(cur_name)s' overlaps %(cmp_type)s "
- "'%(cmp_name)s'") \
- % {'cur_type': cur_type, 'cur_name': current.name,
- 'cmp_type': cmp_type, 'cmp_name': item.name}
- GParser.MarkupError.__init__(self, msg, current._url,
- current._lineNumber)
-
-
-# =============================================================================
# Interface implementation for a box widget
# =============================================================================
@@ -81,11 +64,6 @@
height, width = self.chr_span
owner = self.getParent()
- if isinstance(owner, UIBox):
- if owner.chr_x + owner.chr_w <= left + width or \
- owner.chr_y + owner.chr_h <= top + height:
- raise InvalidBoundingBoxError(self, owner)
-
parent = event.container
# Box-Panel
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8750 - in trunk/gnue-forms/src/uidrivers: _base/widgets curses/widgets gtk2/widgets qt3 qt3/widgets win32/widgets wx/widgets wx26/widgets,
johannes <=