Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
plone.app.controlpanel.widgets.MultiCheckBoxColumnsWidget Class Reference
Inheritance diagram for plone.app.controlpanel.widgets.MultiCheckBoxColumnsWidget:
Inheritance graph
[legend]
Collaboration diagram for plone.app.controlpanel.widgets.MultiCheckBoxColumnsWidget:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def renderItemsWithValues

Static Public Attributes

int how_many_columns = 2

Detailed Description

Definition at line 41 of file widgets.py.


Constructor & Destructor Documentation

Initialize the widget.

Definition at line 46 of file widgets.py.

00046 
00047     def __init__(self, field, request):
00048         """Initialize the widget."""
00049         super(MultiCheckBoxColumnsWidget, self).__init__(field,
00050             field.value_type.vocabulary, request)

Here is the caller graph for this function:


Member Function Documentation

Render the list of possible values, with those found in
`values` being marked as selected.

This code is mostly taken from from zope.app.form.browser.itemswidgets
import ItemsEditWidgetBase licensed under the ZPL 2.1.

Definition at line 51 of file widgets.py.

00051 
00052     def renderItemsWithValues(self, values):
00053         """Render the list of possible values, with those found in
00054         `values` being marked as selected.
00055 
00056         This code is mostly taken from from zope.app.form.browser.itemswidgets
00057         import ItemsEditWidgetBase licensed under the ZPL 2.1.
00058         """
00059 
00060         cssClass = self.cssClass
00061 
00062         # multiple items with the same value are not allowed from a
00063         # vocabulary, so that need not be considered here
00064         rendered_items = []
00065         count = 0
00066 
00067         # XXX remove the inline styles!
00068         rendered_items.append('<div style="float:left; margin-right: 2em;">')
00069 
00070         # Handle case of missing value
00071         missing = self._toFormValue(self.context.missing_value)
00072 
00073         if self._displayItemForMissingValue and not self.context.required:
00074             if missing in values:
00075                 render = self.renderSelectedItem
00076             else:
00077                 render = self.renderItem
00078 
00079             missing_item = render(count,
00080                 self.translate(self._messageNoValue),
00081                 missing,
00082                 self.name,
00083                 cssClass)
00084             rendered_items.append(missing_item)
00085             count += 1
00086 
00087         length = len(self.vocabulary)
00088         cc = self.how_many_columns
00089         breaks = [ length % cc == 0 and length / cc or length / cc + 1 ]
00090         for b in range(2, cc):
00091             breaks.append(breaks[0] * b)
00092 
00093         # Render normal values
00094         for term in self.vocabulary:
00095             item_text = self.textForValue(term)
00096 
00097             if term.value in values:
00098                 render = self.renderSelectedItem
00099             else:
00100                 render = self.renderItem
00101 
00102             rendered_item = render(count,
00103                 item_text,
00104                 term.token,
00105                 self.name,
00106                 cssClass)
00107 
00108             rendered_items.append(rendered_item)
00109             count += 1
00110 
00111             if count in breaks:
00112                 rendered_items.append('</div><div style="float:left; '
00113                                       'margin-right: 2em;">')
00114 
00115         rendered_items.append('</div><div style="clear:both">&nbsp;</div>')
00116 
00117         return rendered_items
00118 


Member Data Documentation

Reimplemented in plone.app.controlpanel.widgets.MultiCheckBoxThreeColumnWidget.

Definition at line 44 of file widgets.py.


The documentation for this class was generated from the following file: