def paintContent(self, target): """Paints the content of this component. @param target: the Paint Event. @raise PaintException: if the paint operation failed. """ super(AbstractSplitPanel, self).paintContent(target) position = str(self._pos) + self.UNIT_SYMBOLS[self._posUnit] target.addAttribute('position', position) if self.isLocked(): target.addAttribute('locked', True) target.addAttribute('reversed', self._posReversed) if self._firstComponent is not None: self._firstComponent.paint(target) else: temporaryComponent = VerticalLayout() temporaryComponent.setParent(self) temporaryComponent.paint(target) if self._secondComponent is not None: self._secondComponent.paint(target) else: temporaryComponent = VerticalLayout() temporaryComponent.setParent(self) temporaryComponent.paint(target)
def createDefaultContent(self): """Create a IComponentContainer which is added by default to the Panel if user does not specify any content. """ layout = VerticalLayout() # Force margins by default layout.setMargin(True) return layout
def __init__(self): """Instantiates a new color picker select. @param rows the rows @param columns the columns """ super(ColorPickerSelect, self).__init__() layout = VerticalLayout() self.setCompositionRoot(layout) self.setStyleName('colorselect') self.setWidth('220px') self._range = Select() self._range.setImmediate(True) self._range.setImmediate(True) self._range.setNullSelectionAllowed(False) self._range.setNewItemsAllowed(False) self._range.setWidth('220px') self._range.addListener(self, IValueChangeListener) for Id in ColorRangePropertyId.values(): self._range.addItem(Id) layout.addComponent(self._range) self._grid = ColorPickerGrid(self.createAllColors(14, 10)) self._grid.setWidth('220px') self._grid.setHeight('270px') layout.addComponent(self._grid) self._range.select(ColorRangePropertyId.ALL)
def init(self): # This is called whenever a colorpicker popup is closed main = Window() main.setWidth('1000px') self.setMainWindow(main) # Create an instance of the preview and add it to the window # self._display = Embedded('Color preview') self._display = Canvas() self._display.setWidth('270px') self._display.setHeight('270px') # Add the foreground and background colorpickers to a layout self._mainLayout = mainLayout = HorizontalLayout() mainLayout.setMargin(True) mainLayout.setSpacing(True) main.setContent(mainLayout) layout = VerticalLayout() layout.setWidth('450px') layout.setSpacing(True) optPanel = Panel('Customize the color picker popup window', GridLayout(3, 2)) optPanel.getContent().setSizeFull() optPanel.getContent().setMargin(True) optPanel.getContent().setSpacing(True) self._rgbBox.addListener(RgbClickListener(self), IClickListener) self._rgbBox.setValue(self._rgbVisible) self._rgbBox.setImmediate(True) optPanel.getContent().addComponent(self._rgbBox) self._hsvBox.addListener(HsvClickListener(self), IClickListener) self._hsvBox.setValue(self._hsvVisible) self._hsvBox.setImmediate(True) optPanel.getContent().addComponent(self._hsvBox) self._swaBox.addListener(SwaClickListener(self), IClickListener) self._swaBox.setValue(self._swaVisible) self._swaBox.setImmediate(True) optPanel.getContent().addComponent(self._swaBox) self._hisBox.addListener(HisClickListener(self), IClickListener) self._hisBox.setValue(self._historyVisible) self._hisBox.setImmediate(True) optPanel.getContent().addComponent(self._hisBox) self._txtBox.addListener(TxtClickListener(self), IClickListener) self._txtBox.setValue(self._txtfieldVisible) self._txtBox.setImmediate(True) optPanel.getContent().addComponent(self._txtBox) layout.addComponent(optPanel) panel1 = Panel( 'Button like colorpicker with current color and CSS code', HorizontalLayout()) panel1.getContent().setSizeFull() panel1.getContent().setMargin(True) self._colorpicker1 = ColorPicker('Foreground', self._foregroundColor) self._colorpicker1.setWidth('100px') self._colorpicker1.addListener(self) panel1.addComponent(self._colorpicker1) panel1.getContent().setComponentAlignment(self._colorpicker1, Alignment.MIDDLE_CENTER) self._colorpicker2 = ColorPicker('Background', self._backgroundColor) self._colorpicker2.addListener(self) self._colorpicker2.setWidth('100px') panel1.addComponent(self._colorpicker2) panel1.getContent().setComponentAlignment(self._colorpicker2, Alignment.MIDDLE_CENTER) layout.addComponent(panel1) panel2 = Panel( 'Button like colorpicker with current color and custom caption', HorizontalLayout()) panel2.getContent().setSizeFull() panel2.getContent().setMargin(True) self._colorpicker3 = ColorPicker('Foreground', self._foregroundColor) self._colorpicker3.addListener(self) self._colorpicker3.setWidth('120px') self._colorpicker3.setButtonCaption('Foreground') panel2.addComponent(self._colorpicker3) panel2.getContent().setComponentAlignment(self._colorpicker3, Alignment.MIDDLE_CENTER) self._colorpicker4 = ColorPicker('Background', self._backgroundColor) self._colorpicker4.addListener(self) self._colorpicker4.setWidth('120px') self._colorpicker4.setButtonCaption('Background') panel2.addComponent(self._colorpicker4) panel2.getContent().setComponentAlignment(self._colorpicker4, Alignment.MIDDLE_CENTER) layout.addComponent(panel2) panel3 = Panel('Color area color picker with caption', HorizontalLayout()) panel3.getContent().setSizeFull() panel3.getContent().setMargin(True) self._colorpicker5 = ColorPicker('Foreground', self._foregroundColor) self._colorpicker5.setCaption('Foreground') self._colorpicker5.addListener(self) self._colorpicker5.setButtonStyle(ButtonStyle.BUTTON_AREA) panel3.addComponent(self._colorpicker5) panel3.getContent().setComponentAlignment(self._colorpicker5, Alignment.MIDDLE_CENTER) self._colorpicker6 = ColorPicker('Background', self._backgroundColor) self._colorpicker6.setCaption('Background') self._colorpicker6.addListener(self) self._colorpicker6.setButtonStyle(ButtonStyle.BUTTON_AREA) panel3.addComponent(self._colorpicker6) panel3.getContent().setComponentAlignment(self._colorpicker6, Alignment.MIDDLE_CENTER) layout.addComponent(panel3) mainLayout.addComponent(layout) mainLayout.addComponent(self._display) self.updateDisplay(self._foregroundColor, self._backgroundColor)