[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8876 - trunk/gnue-forms/src/uidrivers/qt3/widgets
From: |
johannes |
Subject: |
[gnue] r8876 - trunk/gnue-forms/src/uidrivers/qt3/widgets |
Date: |
Thu, 19 Oct 2006 10:22:15 -0500 (CDT) |
Author: johannes
Date: 2006-10-19 10:22:14 -0500 (Thu, 19 Oct 2006)
New Revision: 8876
Added:
trunk/gnue-forms/src/uidrivers/qt3/widgets/grid.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/gridline.py
Modified:
trunk/gnue-forms/src/uidrivers/qt3/widgets/button.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
Log:
Added grid-support (without hiding lables yet)
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/button.py 2006-10-19
14:52:30 UTC (rev 8875)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/button.py 2006-10-19
15:22:14 UTC (rev 8876)
@@ -45,11 +45,19 @@
Create the button widget
"""
- parent = event.container
+ owner = self.getParent()
+ if self.in_grid:
+ parent = owner._get_cell(self, spacer)
+ else:
+ parent = event.container
self.widget = Button(parent, self)
- self.getParent().add_widgets(self, spacer)
+ if self.in_grid:
+ self.widget._gnue_label_ = None
+
+ owner.add_widgets(self, spacer)
+
return self.widget
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-19 14:52:30 UTC
(rev 8875)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-19 15:22:14 UTC
(rev 8876)
@@ -41,16 +41,25 @@
def _create_widget_(self, event, spacer):
style = self._gfObject.style.lower()
+ self._block_change_ = False
+ owner = self.getParent()
- parent = event.container
+ if self.in_grid:
+ parent = owner._get_cell(self, spacer)
+ else:
+ parent = event.container
+
func = getattr(self, '_UIEntry__build_%s' % style, None)
if func:
(self.label, self.widget) = func(parent)
else:
(self.label, self.widget) = self.__build_default(parent)
- self.getParent().add_widgets(self, spacer)
+ if self.in_grid:
+ self.widget._gnue_label_ = self.label
+ owner.add_widgets(self, spacer)
+
return self.widget
# -------------------------------------------------------------------------
@@ -115,7 +124,7 @@
def __add_entry_label(self, parent):
if self.in_grid:
- result = None
+ result = qt.QLabel(parent)
elif self._gfObject.label:
result = qt.QLabel(self._gfObject.label, parent)
@@ -185,7 +194,19 @@
if method:
method(selection1, selection2)
+ # -------------------------------------------------------------------------
+ def _ui_set_focus_(self, index):
+
+ widget = self.widgets[index]
+ if self.in_grid and widget._gnue_label_:
+ label = widget._gnue_label_
+ widget.show()
+ label.hide()
+
+ UIHelper._ui_set_focus_(self, index)
+
+
# -------------------------------------------------------------------------
# Clipboard and selection
# -------------------------------------------------------------------------
Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/grid.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/grid.py 2006-10-19 14:52:30 UTC
(rev 8875)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/grid.py 2006-10-19 15:22:14 UTC
(rev 8876)
@@ -0,0 +1,157 @@
+# GNU Enterprise Forms - QT3 UI driver - Grid 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 import _base
+
+__all__ = ['UIGrid']
+
+# =============================================================================
+# Interface implementation for a grid widget
+# =============================================================================
+
+class UIGrid(_base.UIHelper):
+ """
+ The visual container for the grid control.
+ """
+
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self, event):
+
+ _base.UIHelper.__init__(self, event)
+ self.__max = 0
+ self.__visible = 0
+ self.growable = True
+
+
+ # -------------------------------------------------------------------------
+ # Create a wx box widget
+ # -------------------------------------------------------------------------
+
+ def _create_widget_ (self, event, spacer):
+ """
+ Create the QWidget for the grid control and add it to the owner.
+ The spacer is ignored for <grid> tags.
+
+ @param event: the creation-event instance carrying information like
+ container (parent-widget)
+ @param spacer: not used for grid tags
+
+ @returns: the QLayout instance used for adding the rows
+ """
+ parent = event.container
+
+ self.widget = qt.QFrame(parent)
+
+ hbox = qt.QHBoxLayout(self.widget, 2)
+
+ self._container = qt.QWidget(self.widget)
+ self.scroll = qt.QScrollBar(qt.Qt.Vertical, self.widget)
+
+ hbox.addWidget(self._container, 1)
+ hbox.addWidget(self.scroll, 0)
+
+ self.rowsizer = qt.QGridLayout(self._container)
+
+ self.__max = self._gfObject.rows
+ self.__visible = self.__max
+
+ self.__build_header()
+
+ self.getParent().add_widgets(self, spacer)
+
+ return None
+
+
+ # -------------------------------------------------------------------------
+ # Build the first row of the grid (the header)
+ # -------------------------------------------------------------------------
+
+ def __build_header(self):
+
+ cols = {}
+ linenum = 0
+ for line in self._gfObject.findChildrenOfType('GFGridLine', True,
True):
+ index = 0
+ for item in line._children:
+ span = int(getattr(item, 'Sizer__span', 1))
+ cols.setdefault(index, []).append(getattr(item, 'label', None))
+ index += span
+ linenum += 1
+
+ colnum = cols.keys()
+ colnum.sort()
+
+ for clx in colnum:
+ self.rowsizer.setColStretch(clx, 1)
+
+ pnl = qt.QFrame(self._container)
+ vbx = qt.QVBoxLayout(pnl)
+
+ for label in cols[clx]:
+ stc = qt.QLabel(label, pnl)
+ vbx.addWidget(stc)
+
+ self.rowsizer.addMultiCellWidget(pnl, 0, 0, clx, clx)
+
+
+ # -------------------------------------------------------------------------
+ # Get the row-number of a concrete gridline in the GridBagSizer
+ # -------------------------------------------------------------------------
+
+ def _get_row(self, line, record):
+ """
+ Get the row number of a concrete gridline in the QGridLayout
+ @param line: the UIGridLine instance we're interested in
+ @param record: the spacer (rel. record-number) of the line in question
+ @returns: the row within the QGridLayout
+ """
+
+ return len(self._children) * record + self._children.index(line) + 1
+
+
+ # -------------------------------------------------------------------------
+ # Adjust scrollbar if the current record has changed
+ # -------------------------------------------------------------------------
+
+ def _ui_adjust_scrollbar_(self, position, size, count):
+ """
+ Adjust the thumb-position and the number of rows of the scrollbar
+ """
+ # self.scroll.SetScrollbar(position, size, count, size - 1, True)
+ pass
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIGrid,
+ 'provides' : 'GFGrid',
+ 'container': 1
+}
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/grid.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/gridline.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/gridline.py 2006-10-19
14:52:30 UTC (rev 8875)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/gridline.py 2006-10-19
15:22:14 UTC (rev 8876)
@@ -0,0 +1,164 @@
+# GNU Enterprise Forms - QT3 UI Driver - GridLine widget
+#
+# 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$
+"""
+Implementation of a <gridline>. A gridline is a logical line within a <grid>
+and defines the controls building up the line.
+"""
+
+import qt
+
+from gnue.forms.uidrivers.qt3.widgets import _base
+
+__all__ = ['UIGridLine']
+
+# =============================================================================
+# Interface implementation for a grid line widget
+# =============================================================================
+
+class UIGridLine (_base.UIHelper):
+ """
+ Collection of controls building a given line in a grid.
+
+ @ivar _columns: a dictionary which holds a sequence of QFrame instances
+ per spacer. Each of these panels will get the parent widget for the
+ control located in that cell.
+ """
+
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self, event):
+
+ _base.UIHelper.__init__(self, event)
+ self._columns = {}
+
+
+ # -------------------------------------------------------------------------
+ # Create the line widget
+ # -------------------------------------------------------------------------
+
+ def _create_widget_ (self, event, spacer):
+ """
+ Prepare the columns (cells) for the girdline and add it to the owner.
+ """
+
+ parent = event.container
+ self.__prepare_columns(parent, spacer)
+ self._container = parent
+
+ return None
+
+
+ # -------------------------------------------------------------------------
+ # Prepare the cells for this gridline
+ # -------------------------------------------------------------------------
+
+ def __prepare_columns(self, parent, spacer):
+
+ owner = self.getParent()
+ sizer = parent.layout()
+ row = owner._get_row(self, spacer)
+
+ offset = 0
+ for child in self._children:
+ panel = qt.QWidget(parent)
+ hbx = qt.QHBoxLayout(panel)
+
+ if not spacer % 2:
+ name = 'grid_color_even'
+ else:
+ name = 'grid_color_odd'
+
+ color = self.__load_color_from_string(gConfigForms(name))
+ panel.setPaletteBackgroundColor(color)
+
+ self._columns.setdefault(spacer, []).append(panel)
+
+ sizer.addMultiCellWidget(panel, row, row, offset, offset +
+ child.span)
+ offset += child.span
+
+
+ # -------------------------------------------------------------------------
+ # Load the given colorname form the database or parse it as hex-rgb-string
+ # -------------------------------------------------------------------------
+
+ def __load_color_from_string(self, value):
+
+ result = qt.QColor(value)
+ if not result.isValid():
+ (red, green, blue) = value[:2], value[2:4], value[4:6]
+ result = qt.QColor(int(red, 16), int(green, 16), int(blue, 16))
+
+ return result
+
+
+ # -------------------------------------------------------------------------
+ # Add an UI widget to the Grid container
+ # -------------------------------------------------------------------------
+
+ def add_widgets(self, ui_widget, spacer):
+ """
+ Add a given UI widget to the gridline.
+
+ @param ui_widget: widget to add to the page
+ @param spacer: the row-index (relative record number) to add the
widget
+ """
+
+ panel = self._get_cell(ui_widget, spacer)
+ sizer = panel.layout()
+
+ if ui_widget.label:
+ sizer.addWidget(ui_widget.label)
+ sizer.addWidget(ui_widget.widget)
+
+ if ui_widget.label:
+ ui_widget.widget.hide()
+
+
+ # -------------------------------------------------------------------------
+ # Get the cell-parent for a given child-control
+ # -------------------------------------------------------------------------
+
+ def _get_cell(self, ui_widget, spacer):
+ """
+ Return the wx.Panel instance (acting as parent widget) for a given
+ UI-Widget.
+
+ @param ui_widget: the UIWidget to get the cell parent for
+ @param spacer: the spacer of the row to get the cell parent for
+ """
+ index = self._children.index(ui_widget)
+ return self._columns[spacer][index]
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIGridLine,
+ 'provides' : 'GFGridLine',
+ 'container': 1
+}
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/gridline.py
___________________________________________________________________
Name: svn:keywords
+ Id
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8876 - trunk/gnue-forms/src/uidrivers/qt3/widgets,
johannes <=