Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 217426 Details for
Bug 361799
[Theming] Ability to specify background position and repeat
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Correction of last patch
7_Control_Widget_Background.patch (text/plain), 18.87 KB, created by
Stephan Leicht Vogt
on 2012-06-15 10:04:44 EDT
(
hide
)
Description:
Correction of last patch
Filename:
MIME Type:
Creator:
Stephan Leicht Vogt
Created:
2012-06-15 10:04:44 EDT
Size:
18.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >diff --git js/qx/ui/core/Widget.js js/qx/ui/core/Widget.js >index d9c343e..b3d31dc 100644 >--- js/qx/ui/core/Widget.js >+++ js/qx/ui/core/Widget.js >@@ -866,11 +866,23 @@ > }, > > /** >+ * Mapping to native style property background-position. >+ */ >+ backgroundPosition : { >+ check : ["left top", "left center", "left bottom", "right top", "right center", "right bottom", "center top", "center center", "center bottom"], >+ nullable : true, >+ init : "left top", >+ apply : "_applyBackgroundPosition", >+ themeable : true >+ }, >+ >+ /** > * Mapping to native style property background-repeat. > */ > backgroundRepeat : { >- check : "String", >+ check : ["repeat", "repeat-x", "repeat-y", "no-repeat"], > nullable : true, >+ init : "repeat", > apply : "_applyBackgroundRepeat", > themeable : true > }, >@@ -3533,6 +3545,9 @@ > _applyBackgroundRepeat : function(value, old) { > value ? this.setStyleProperty("backgroundRepeat", value) : this.removeStyleProperty("backgroundRepeat"); > }, >+ _applyBackgroundPosition : function(value, old) { >+ value ? this.setStyleProperty("backgroundPosition", value) : this.removeStyleProperty("backgroundPosition"); >+ }, > > /////////////////// > // CLIPPING SUPPORT >diff --git src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java >index 5b43900..21d145e 100644 >--- src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java >+++ src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java >@@ -118,6 +118,10 @@ > result = readFloat( unit ); > } else if( isAnimationProperty( name ) ) { > result = readAnimation( unit ); >+ } else if( isBackgroundRepeatProperty( name ) ) { >+ result = readBackgroundRepeat( unit ); >+ } else if( isBackgroundPositionProperty( name ) ) { >+ result = readBackgroundPosition( unit ); > } else if( isShadowProperty( name ) ) { > result = readShadow( unit ); > } else { >@@ -869,6 +873,73 @@ > return result; > } > >+ static boolean isBackgroundRepeatProperty( final String property ) { >+ return "background-repeat".equals( property ); >+ } >+ >+ static QxIdentifier readBackgroundRepeat( final LexicalUnit unit ) { >+ QxIdentifier result = null; >+ short type = unit.getLexicalUnitType(); >+ if( type == LexicalUnit.SAC_IDENT ) { >+ String value = unit.getStringValue(); >+ if( "repeat".equals( value ) >+ || "repeat-x".equals( value ) >+ || "repeat-y".equals( value ) >+ || "no-repeat".equals( value ) ) >+ { >+ result = new QxIdentifier( value ); >+ } else { >+ String msg = "Invalid value for background-repeat: " + value; >+ throw new IllegalArgumentException( msg ); >+ } >+ } >+ if( result == null ) { >+ throw new IllegalArgumentException( "Failed to parse background-repeat " >+ + toString( unit ) ); >+ } >+ return result; >+ } >+ >+ static boolean isBackgroundPositionProperty(final String property ) { >+ return "background-position".equals( property ); >+ } >+ >+ static QxIdentifier readBackgroundPosition( final LexicalUnit unit ) { >+ QxIdentifier result = null; >+ short type = unit.getLexicalUnitType(); >+ if( type == LexicalUnit.SAC_IDENT ) { >+ StringBuffer valueBuffer = new StringBuffer(); >+ valueBuffer = valueBuffer.append( unit.getStringValue() ); >+ >+ LexicalUnit nextUnit = unit.getNextLexicalUnit(); >+ if(nextUnit != null && nextUnit.getStringValue() != null) { >+ valueBuffer = valueBuffer.append( " " ).append( nextUnit.getStringValue() ); >+ } >+ String value = valueBuffer.toString(); >+ >+ if( "left top".equals( value ) >+ || "left center".equals( value ) >+ || "left bottom".equals( value ) >+ || "right top".equals( value ) >+ || "right center".equals( value ) >+ || "right bottom".equals( value ) >+ || "center top".equals( value ) >+ || "center center".equals( value ) >+ || "center bottom".equals( value ) ) >+ { >+ result = new QxIdentifier( value ); >+ } else { >+ String msg = "Invalid value for background-position: " + value; >+ throw new IllegalArgumentException( msg ); >+ } >+ } >+ if( result == null ) { >+ throw new IllegalArgumentException( "Failed to parse background-position " >+ + toString( unit ) ); >+ } >+ return result; >+ } >+ > private static Integer readSingleLengthUnit( LexicalUnit unit ) { > Integer result = null; > short type = unit.getLexicalUnitType(); >diff --git src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java >index 18dd4e1..f7f1824 100644 >--- src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java >+++ src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java >@@ -61,6 +61,8 @@ > private static final String PROP_TAB_INDEX = "tabIndex"; > private static final String PROP_CURSOR = "cursor"; > private static final String PROP_BACKGROUND_IMAGE = "backgroundImage"; >+ private static final String PROP_BACKGROUND_REPEAT = "backgroundRepeat"; >+ private static final String PROP_BACKGROUND_POSITION = "backgroundPosition"; > private static final String PROP_CHILDREN = "children"; > > private static final String USER_DATA_KEY_LISTENER = "keyListener"; >@@ -240,6 +242,8 @@ > controlAdapter.getUserBackground(), > controlAdapter.getBackgroundTransparency() ); > preserveBackgroundImage( control ); >+ preserveBackgroundRepeat( control ); >+ preserveBackgroundPosition( control ); > WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() ); > adapter.preserve( PROP_CURSOR, control.getCursor() ); > WidgetLCAUtil.preserveListener( control, >@@ -278,6 +282,20 @@ > Image image = controlAdapter.getUserBackgroundImage(); > IWidgetAdapter adapter = WidgetUtil.getAdapter( control ); > adapter.preserve( PROP_BACKGROUND_IMAGE, image ); >+ } >+ >+ public static void preserveBackgroundRepeat( Control control ) { >+ IControlAdapter controlAdapter = control.getAdapter( IControlAdapter.class ); >+ String repeat = controlAdapter.getUserBackgroundRepeat(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( control ); >+ adapter.preserve( PROP_BACKGROUND_REPEAT, repeat ); >+ } >+ >+ public static void preserveBackgroundPosition( Control control ) { >+ IControlAdapter controlAdapter = control.getAdapter( IControlAdapter.class ); >+ String position = controlAdapter.getUserBackgroundPosition(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( control ); >+ adapter.preserve( PROP_BACKGROUND_POSITION, position ); > } > > /////////////////////////////////////////// >@@ -1124,7 +1142,12 @@ > public static void writeBackgroundImage( Control control ) throws IOException { > IControlAdapter controlAdapter = ControlUtil.getControlAdapter( control ); > Image image = controlAdapter.getUserBackgroundImage(); >- if( WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_IMAGE, image, null ) ) { >+ String repeat = controlAdapter.getUserBackgroundRepeat(); >+ String position = controlAdapter.getUserBackgroundPosition(); >+ if( WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_IMAGE, image, null ) >+ || WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_REPEAT, repeat, null ) >+ || WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_POSITION, position, null )) >+ { > JSWriter writer = JSWriter.getWriterFor( control ); > if( image != null ) { > String imagePath = ImageFactory.getImagePath( image ); >@@ -1143,6 +1166,8 @@ > writer.call( "setUserData", args ); > writer.reset( "backgroundImage" ); > } >+ writer.set( "backgroundRepeat", repeat ); >+ writer.set( "backgroundPosition", position ); > } > } > >diff --git src/org/eclipse/swt/SWT.java src/org/eclipse/swt/SWT.java >index bbc7277..f8fd179 100644 >--- src/org/eclipse/swt/SWT.java >+++ src/org/eclipse/swt/SWT.java >@@ -3399,6 +3399,136 @@ > */ > public static final int ID_QUIT = -6; > >+ /** >+ * The background image will be repeated both vertically and horizontally. This is default >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_REPEAT_REPEAT = 1; >+ >+ /** >+ * The background image will be repeated only horizontally >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_REPEAT_REPEAT_X = 2; >+ >+ /** >+ * The background image will be repeated only vertically >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_REPEAT_REPEAT_Y = 3; >+ >+ /** >+ * The background-image will not be repeated >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_REPEAT_NO_REPEAT = 4; >+ >+ /** >+ * The background-position property sets the starting position of a background image. This is default >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_LEFT_TOP = -1; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_LEFT_CENTER = -2; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_LEFT_BOTTOM = -3; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_RIGHT_TOP = -4; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_RIGHT_CENTER = -5; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_RIGHT_BOTTOM = -6; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_CENTER_TOP = -7; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_CENTER_CENTER = -8; >+ >+ /** >+ * The background-position property sets the starting position of a background image. >+ * >+ * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int) >+ * @see org.eclipse.swt.widgets.Control#getBackgroundPosition() >+ * >+ * @since 1.4 >+ */ >+ public static final int BACKGROUND_POSITION_CENTER_BOTTOM = -9; >+ > private static final int RWT_VERSION = getVersion( 1, 500 ); > > static { >diff --git src/org/eclipse/swt/internal/widgets/IControlAdapter.java src/org/eclipse/swt/internal/widgets/IControlAdapter.java >index 9640b59..4c38b3b 100644 >--- src/org/eclipse/swt/internal/widgets/IControlAdapter.java >+++ src/org/eclipse/swt/internal/widgets/IControlAdapter.java >@@ -28,6 +28,8 @@ > Color getUserForeground(); > Color getUserBackground(); > Image getUserBackgroundImage(); >+ String getUserBackgroundRepeat(); >+ String getUserBackgroundPosition(); > > boolean getBackgroundTransparency(); > >diff --git src/org/eclipse/swt/widgets/Control.java src/org/eclipse/swt/widgets/Control.java >index b809530..949fb24 100644 >--- src/org/eclipse/swt/widgets/Control.java >+++ src/org/eclipse/swt/widgets/Control.java >@@ -88,6 +88,46 @@ > return Control.this.backgroundImage; > } > >+ public String getUserBackgroundRepeat() { >+ switch( Control.this.backgroundRepeat ) { >+ case SWT.BACKGROUND_REPEAT_REPEAT: >+ return "repeat"; >+ case SWT.BACKGROUND_REPEAT_REPEAT_X: >+ return "repeat-x"; >+ case SWT.BACKGROUND_REPEAT_REPEAT_Y: >+ return "repeat-y"; >+ case SWT.BACKGROUND_REPEAT_NO_REPEAT: >+ return "no-repeat"; >+ default: >+ return null; >+ } >+ } >+ >+ public String getUserBackgroundPosition() { >+ switch( Control.this.backgroundPosition ) { >+ case SWT.BACKGROUND_POSITION_LEFT_TOP: >+ return "left top"; >+ case SWT.BACKGROUND_POSITION_LEFT_CENTER: >+ return "left center"; >+ case SWT.BACKGROUND_POSITION_LEFT_BOTTOM: >+ return "left bottom"; >+ case SWT.BACKGROUND_POSITION_RIGHT_TOP: >+ return "right top"; >+ case SWT.BACKGROUND_POSITION_RIGHT_CENTER: >+ return "right center"; >+ case SWT.BACKGROUND_POSITION_RIGHT_BOTTOM: >+ return "right bottom"; >+ case SWT.BACKGROUND_POSITION_CENTER_TOP: >+ return "center top"; >+ case SWT.BACKGROUND_POSITION_CENTER_CENTER: >+ return "center center"; >+ case SWT.BACKGROUND_POSITION_CENTER_BOTTOM: >+ return "center bottom"; >+ default: >+ return null; >+ } >+ } >+ > public boolean getBackgroundTransparency() { > return Control.this.backgroundTransparency; > } >@@ -108,6 +148,8 @@ > private Color foreground; > private Color background; > private Image backgroundImage; >+ private int backgroundRepeat; >+ private int backgroundPosition; > private boolean backgroundTransparency; > private Font font; > private Cursor cursor; >@@ -511,6 +553,105 @@ > } > > /** >+ * >+ * Sets the repeat property of the background to the receiver, which must be one of the following values: >+ * <dl> >+ * <dt><code>BACKGROUND_REPEAT_REPEAT</code></dt> >+ * <dt><code>BACKGROUND_REPEAT_REPEAT_X</code></dt> >+ * <dt><code>BACKGROUND_REPEAT_REPEAT_Y</code></dt> >+ * <dt><code>BACKGROUND_REPEAT_NO_REPEAT</code></dt> >+ * </dl> >+ * >+ * @param repeat new repeat style >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * >+ * @since 1.4 >+ */ >+ public void setBackgroundRepeat( final int repeat) { >+ checkWidget(); >+ if( backgroundRepeat != repeat ) { >+ backgroundRepeat = repeat; >+ } >+ } >+ >+ /** >+ * Returns the receiver's background repeat property. >+ * >+ * @return the background repeat property >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * >+ * @since 1.4 >+ */ >+ public int getBackgroundRepeat() { >+ checkWidget(); >+ Control control = findBackgroundControl(); >+ if( control == null ) { >+ control = this; >+ } >+ return control.backgroundRepeat; >+ } >+ >+ /** >+ * >+ * Sets the position property of the background to the receiver, which must be one of the following values: >+ * <dl> >+ * <dt><code>BACKGROUND_POSITION_LEFT_TOP</code></dt> >+ * <dt><code>BACKGROUND_POSITION_LEFT_CENTER</code></dt> >+ * <dt><code>BACKGROUND_POSITION_LEFT_BOTTOM</code></dt> >+ * <dt><code>BACKGROUND_POSITION_RIGHT_TOP</code></dt> >+ * <dt><code>BACKGROUND_POSITION_RIGHT_CENTER</code></dt> >+ * <dt><code>BACKGROUND_POSITION_RIGHT_BOTTOM</code></dt> >+ * <dt><code>BACKGROUND_POSITION_CENTER_TOP</code></dt> >+ * <dt><code>BACKGROUND_POSITION_CENTER_CENTER</code></dt> >+ * <dt><code>BACKGROUND_POSITION_CENTER_BOTTOM</code></dt> >+ * </dl> >+ * >+ * @param repeat new position style >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * >+ * @since 1.4 >+ */ >+ public void setBackgroundPosition( final int position) { >+ checkWidget(); >+ if( backgroundPosition != position ) { >+ backgroundPosition = position; >+ } >+ } >+ >+ /** >+ * Returns the receiver's background position property. >+ * >+ * @return the background position property >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * >+ * @since 1.4 >+ */ >+ public int getBackgroundPosition() { >+ checkWidget(); >+ Control control = findBackgroundControl(); >+ if( control == null ) { >+ control = this; >+ } >+ return control.backgroundPosition; >+ } >+ >+ /** > * Sets the receiver's foreground color to the color specified > * by the argument, or to the default system color for the control > * if the argument is null. >diff --git widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml >index 2424989..4dd95c5 100644 >--- widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml >+++ widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml >@@ -27,6 +27,12 @@ > <property name="background-image" > description="Background image for buttons." /> > >+ <property name="background-position" >+ description="Background image position for buttons." /> >+ >+ <property name="background-repeat" >+ description="Background image repetition for buttons." /> >+ > <property name="border" > description="Border for buttons." /> >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 361799
:
205810
| 217426