com.gwtext.client.widgets
Class ColorPalette

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.gwtext.client.widgets.Component
              extended by com.gwtext.client.widgets.ColorPalette
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, Observable

public class ColorPalette
extends Component

Simple color palette class for choosing colors.


Field Summary
 
Fields inherited from class com.gwtext.client.widgets.Component
config, id
 
Constructor Summary
ColorPalette()
          Create a new CollorPalette.
ColorPalette(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 
Method Summary
 void addListener(ColorPaletteListener listener)
          Add a ColorPalette listener.
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
           
 java.lang.String[] getColors()
          An array of 6-digit color hex code strings (without the # symbol).
protected  com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
           
 java.lang.String getItemCls()
           
 java.lang.String getValue()
          The highlighted color.
 java.lang.String getXType()
          Gets the xtype for this component as registered with ComponentMgr.
 boolean isAllowReselect()
          Return true if reselecting is allowed.
 void select(java.lang.String color)
          Selects the specified color in the palette (fires the select event).
 void setAllowReselect(boolean allowReselect)
          If set to true then reselecting a color that is already selected fires the selection event.
 void setColors(java.lang.String[] colors)
          Set the colors array.
 void setItemCls(java.lang.String itemCls)
          The CSS class to apply to the containing element (defaults to "x-color-palette").
 void setValue(java.lang.String value)
          The color to highlight (should be a valid 6-digit color hex code without the # symbol).
 
Methods inherited from class com.gwtext.client.widgets.Component
addClass, addClassCreated, addEvent, addEvents, addListener, addListener, addListener, addPlugin, addStyleDependentName, addStyleName, afterRender, beforeDestroy, check, checkExtVer, cloneComponent, cloneComponent, cloneConfig, destroy, disable, enable, equals, error, findParentBy, findParentByType, fireEvent, focus, focus, focus, getApplyTo, getAttribute, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAutoShow, getCls, getComponentJS, getConfig, getConfigAsString, getCtCls, getDisabledClass, getEl, getElement, getElement, getElement, getHideMode, getHideParent, getId, getItemId, getJsObj, getOffsetHeight, getOffsetWidth, getOrCreateJsObj, getOwnerContainer, getRenderTo, getStateEvents, getStateId, getTitle, getXTypes, hashCode, hide, initComponent, isCreated, isDisabled, isHidden, isRendered, isVisible, isXType, isXType, onDestroy, purgeListeners, removeClass, removeStyleDependentName, removeStyleName, render, render, render, render, render, render, resumeEvents, setApplyTo, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoEl, setAutoEl, setAutoShow, setCls, setCtCls, setDisabled, setDisabledClass, setEl, setEl, setElement, setHeight, setHideMode, setHideParent, setId, setRenderTo, setRenderToID, setStateEvents, setStateId, setStyle, setStyle, setStyleName, setStylePrimaryName, setTitle, setVisible, setWidth, show, suspendEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
getAbsoluteLeft, getAbsoluteTop, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, setPixelSize, setSize, setStyleName, setStyleName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColorPalette

public ColorPalette()
Create a new CollorPalette.


ColorPalette

public ColorPalette(com.google.gwt.core.client.JavaScriptObject jsObj)
Method Detail

getConfigPrototype

protected com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
Specified by:
getConfigPrototype in class Component

getXType

public java.lang.String getXType()
Description copied from class: Component
Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes, see the Component javadocs.

 
 

TextField field = new TextField(); field.getXType() returns "textfield"

Overrides:
getXType in class Component
Returns:
the xtype

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
Specified by:
create in class Component

select

public void select(java.lang.String color)
Selects the specified color in the palette (fires the select event).

Parameters:
color - A valid 6-digit color hex code (# will be stripped if included)

addListener

public void addListener(ColorPaletteListener listener)
Add a ColorPalette listener.

Parameters:
listener - the listener

isAllowReselect

public boolean isAllowReselect()
Return true if reselecting is allowed.

Returns:
true if reselecting is allowed

setAllowReselect

public void setAllowReselect(boolean allowReselect)
If set to true then reselecting a color that is already selected fires the selection event.

Parameters:
allowReselect - true to allow reselect

getItemCls

public java.lang.String getItemCls()
Returns:
the CSS of the containing element

setItemCls

public void setItemCls(java.lang.String itemCls)
The CSS class to apply to the containing element (defaults to "x-color-palette").

Parameters:
itemCls - the item CSS class

getValue

public java.lang.String getValue()
The highlighted color.

Returns:
the color value

setValue

public void setValue(java.lang.String value)
The color to highlight (should be a valid 6-digit color hex code without the # symbol). Note that the hex codes are case-sensitive.

Parameters:
value - the initial color

getColors

public java.lang.String[] getColors()
An array of 6-digit color hex code strings (without the # symbol). This array can contain any number of colors, and each hex code should be unique. The width of the palette is controlled via CSS by adjusting the width property of the 'x-color-palette' class (or assigning a custom class), so you can balance the number of colors with the width setting until the box is symmetrical.

Returns:
the colors array

setColors

public void setColors(java.lang.String[] colors)
               throws java.lang.IllegalStateException
Set the colors array.

Parameters:
colors - the colors array
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered