Author: johannes
Date: 2006-10-17 09:22:27 -0500 (Tue, 17 Oct 2006)
New Revision: 8816
Added:
trunk/gnue-forms/src/uidrivers/qt3/widgets/hbox.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/vbox.py
Modified:
trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
Log:
Added managed layout
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py 2006-10-17 14:00:58 UTC
(rev 8815)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py 2006-10-17 14:22:27 UTC
(rev 8816)
@@ -36,7 +36,21 @@
Implements the common behaviour of qt3 UI widgets
"""
+ growable = False
+
# -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self, event):
+
+ UIWidget.__init__(self, event)
+
+ self.widget = None
+ self.label = None
+
+
+ # -------------------------------------------------------------------------
# Set the focus to the given widget
# -------------------------------------------------------------------------
@@ -50,8 +64,6 @@
widget = self.widgets[index]
if widget:
widget.setFocus()
- else:
- print "** MISSING widget?", self._gfObject.name, index
# -------------------------------------------------------------------------
@@ -67,3 +79,64 @@
@param index: the index of the qt widget to kill the focus for
"""
pass
+
+# =============================================================================
+# Base class for H/V-Boxes in a managed layout
+# =============================================================================
+
+class ManagedBox(UIHelper):
+ """
+ """
+
+ growable = True
+ _vertical_ = True
+ _entry_pos = 0
+ last_item = 0
+
+ # -------------------------------------------------------------------------
+ # Create the widget
+ # -------------------------------------------------------------------------
+
+ def _create_widget_(self, event, spacer):
+ """
+ """
+
+ self._container = self.widget = qt.QGroupBox(event.container)
+ if self._gfObject.label is not None:
+ self._container.setTitle(self._gfObject.label)
+
+ self._container.setInsideMargin(6)
+
+ if self._vertical_:
+ self.sizer = qt.QGridLayout(1, 2, 2)
+ else:
+ self.sizer = qt.QGridLayout(2, 1, 2)
+
+ self._entry_pos = self.__need_both() and 2 or 1
+
+ if self._vertical_:
+ self.sizer.setColStretch(self._entry_pos - 1, 1)
+ else:
+ self.sizer.setRowStretch(self._entry_pos - 1, 1)
+
+ self._container.layout().addLayout(self.sizer)
+ self.getParent().add_widgets(self, 0)
+
+ self.last_item = 0
+
+
+ # -------------------------------------------------------------------------
+ # Does this box need both columns or rows ?
+ # -------------------------------------------------------------------------
+
+ def __need_both(self):
+
+ result = False
+
+ for item in self._children:
+ if (item._gfObject._type in ['GFEntry', 'GFImage']) and \
+ item._gfObject.label:
+ result = True
+ break
+
+ return result
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-17 14:00:58 UTC
(rev 8815)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-17 14:22:27 UTC
(rev 8816)
@@ -59,10 +59,12 @@
def __build_default(self, parent, password=False, multiline=False):
+ label = self.__add_entry_label(parent)
if multiline:
- return (None, MultiLineEdit(parent, self))
+ self.growable = True
+ return [label, MultiLineEdit(parent, self)]
else:
- return (None, LineEdit(parent, self, password))
+ return [label, LineEdit(parent, self, password)]
# -------------------------------------------------------------------------
@@ -81,31 +83,50 @@
def __build_label(self, parent):
ctrl = qt.QLabel(parent)
- return (None, ctrl)
+ return [self.__add_entry_label(parent), ctrl]
# -------------------------------------------------------------------------
def __build_checkbox(self, parent):
result = CheckBox(parent, self)
- return (None, result)
+ return [None, result]
# -------------------------------------------------------------------------
def __build_dropdown(self, parent):
result = ComboBox(parent, self)
- return (None, result)
+ return [self.__add_entry_label(parent), result]
# -------------------------------------------------------------------------
def __build_listbox(self, parent):
+ self.growable = True
result = ListBox(parent, self)
- return (None, result)
+ return [self.__add_entry_label(parent), result]
# -------------------------------------------------------------------------
+ # Create a label for a given entry
+ # -------------------------------------------------------------------------
+
+ def __add_entry_label(self, parent):
+
+ if self.in_grid:
+ result = None
+
+ elif self._gfObject.label:
+ result = qt.QLabel(self._gfObject.label, parent)
+ else:
+ result = None
+
+ return result
+
+
+
+ # -------------------------------------------------------------------------
# Enable/disable this entry
# -------------------------------------------------------------------------
@@ -349,7 +370,7 @@
def _ui_set_selected_area_(self, selection1, selection2):
- self.setSelectedArea(0, selection1, 0, selection2)
+ self.setSelection(0, selection1, 0, selection2)
@@ -369,7 +390,7 @@
def __init__(self, parent, ui_widget):
- qt.QCheckBox.__init__(self, parent)
+ qt.QCheckBox.__init__(self, ui_widget._gfObject.label, parent)
BaseEntry.__init__(self, ui_widget, qt.QCheckBox)
self.setTristate(True)
Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/hbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/hbox.py 2006-10-17 14:00:58 UTC
(rev 8815)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/hbox.py 2006-10-17 14:22:27 UTC
(rev 8816)
@@ -0,0 +1,77 @@
+# GNU Enterprise Forms - QT3 UI driver - VBox widgets
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+import qt
+
+from gnue.forms.uidrivers.qt3.widgets._base import ManagedBox
+
+# =============================================================================
+# Interface implementation for a box widget
+# =============================================================================
+
+class UIHBox(ManagedBox):
+
+ _vertical_ = False
+
+ # -------------------------------------------------------------------------
+ # Add an item to the box
+ # -------------------------------------------------------------------------
+
+ def add_widgets(self, ui_widget, spacer):
+ """
+ """
+
+ both = isinstance(ui_widget, (ManagedBox, qt.QCheckBox))
+ add = False
+
+ if ui_widget.label:
+ add = True
+ self.sizer.addMultiCellWidget(ui_widget.label, 0, 0,
+ self.last_item, self.last_item)
+
+ if ui_widget.widget:
+ add = True
+
+ span = 0
+ if both and not ui_widget.label:
+ span = 1
+
+ row = self._entry_pos - 1
+ self.sizer.addMultiCellWidget(ui_widget.widget, row, row+span,
+ self.last_item, self.last_item)
+
+ if add and ui_widget.growable:
+ self.sizer.setColStretch(self.last_item, ui_widget.stretch)
+
+ self.last_item += int(add)
+
+
+# =============================================================================
+# Configuration
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIHBox,
+ 'provides' : 'GFHBox',
+ 'container': 0
+}
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/hbox.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/vbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/vbox.py 2006-10-17 14:00:58 UTC
(rev 8815)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/vbox.py 2006-10-17 14:22:27 UTC
(rev 8816)
@@ -0,0 +1,75 @@
+# GNU Enterprise Forms - QT3 UI driver - VBox widgets
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+import qt
+
+from gnue.forms.uidrivers.qt3.widgets._base import ManagedBox
+
+# =============================================================================
+# Interface implementation for a box widget
+# =============================================================================
+
+class UIVBox(ManagedBox):
+
+ # -------------------------------------------------------------------------
+ # Add an item to the box
+ # -------------------------------------------------------------------------
+
+ def add_widgets(self, ui_widget, spacer):
+ """
+ """
+
+ both = isinstance(ui_widget, (ManagedBox, qt.QCheckBox))
+ add = False
+
+ if ui_widget.label:
+ add = True
+ self.sizer.addMultiCellWidget(ui_widget.label, self.last_item,
+ self.last_item, 0, 0)
+
+ if ui_widget.widget:
+ add = True
+
+ span = 0
+ if both and not ui_widget.label:
+ span = 1
+
+ self.sizer.addMultiCellWidget(ui_widget.widget, self.last_item,
+ self.last_item, self._entry_pos - 1, self._entry_pos - 1 +
+ span)
+
+ if add and ui_widget.growable:
+ self.sizer.setRowStretch(self.last_item, ui_widget.stretch)
+
+ self.last_item += int(add)
+
+
+# =============================================================================
+# Configuration
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIVBox,
+ 'provides' : 'GFVBox',
+ 'container': 0
+}
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/vbox.py
___________________________________________________________________
Name: svn:keywords
+ Id
_______________________________________________
commit-gnue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/commit-gnue