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 205810 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]
Fix for enhancment request
7_Control_Widget_Background.patch (text/plain), 20.83 KB, created by
Stephan Leicht Vogt
on 2011-10-24 09:08:01 EDT
(
hide
)
Description:
Fix for enhancment request
Filename:
MIME Type:
Creator:
Stephan Leicht Vogt
Created:
2011-10-24 09:08:01 EDT
Size:
20.83 KB
patch
obsolete
>Index: js/qx/ui/core/Widget.js >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/js/qx/ui/core/Widget.js,v >retrieving revision 1.5 >diff -u -r1.5 Widget.js >--- js/qx/ui/core/Widget.js 14 Oct 2011 13:44:32 -0000 1.5 >+++ js/qx/ui/core/Widget.js 24 Oct 2011 13:06:57 -0000 >@@ -872,11 +872,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 > }, >@@ -3528,6 +3540,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 >Index: src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java,v >retrieving revision 1.31 >diff -u -r1.31 PropertyResolver.java >--- src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java 18 Oct 2011 11:46:50 -0000 1.31 >+++ src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java 24 Oct 2011 13:06:57 -0000 >@@ -117,6 +117,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 { >@@ -893,6 +897,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(); >Index: src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java,v >retrieving revision 1.43 >diff -u -r1.43 ControlLCAUtil.java >--- src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java 30 Aug 2011 12:58:36 -0000 1.43 >+++ src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java 24 Oct 2011 13:06:58 -0000 >@@ -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 USER_DATA_KEY_LISTENER = "keyListener"; > private static final String USER_DATA_TRAVERSE_LISTENER = "traverseListener"; >@@ -130,6 +132,8 @@ > controlAdapter.getUserBackground(), > controlAdapter.getBackgroundTransparency() ); > preserveBackgroundImage( control ); >+ preserveBackgroundRepeat( control ); >+ preserveBackgroundPosition( control ); > WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() ); > adapter.preserve( PROP_CURSOR, control.getCursor() ); > adapter.preserve( Props.CONTROL_LISTENERS, >@@ -159,6 +163,20 @@ > IWidgetAdapter adapter = WidgetUtil.getAdapter( control ); > adapter.preserve( PROP_BACKGROUND_IMAGE, image ); > } >+ >+ public static void preserveBackgroundRepeat( final 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( final Control control ) { >+ IControlAdapter controlAdapter = control.getAdapter( IControlAdapter.class ); >+ String position = controlAdapter.getUserBackgroundPosition(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( control ); >+ adapter.preserve( PROP_BACKGROUND_POSITION, position ); >+ } > > ////////////////// > // read properties >@@ -688,7 +706,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 ); >@@ -707,6 +730,8 @@ > writer.call( "setUserData", args ); > writer.reset( "backgroundImage" ); > } >+ writer.set( "backgroundRepeat", repeat ); >+ writer.set( "backgroundPosition", position ); > } > } > >Index: src/org/eclipse/swt/SWT.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/SWT.java,v >retrieving revision 1.84 >diff -u -r1.84 SWT.java >--- src/org/eclipse/swt/SWT.java 4 Oct 2011 12:40:50 -0000 1.84 >+++ src/org/eclipse/swt/SWT.java 24 Oct 2011 13:06:58 -0000 >@@ -3401,6 +3401,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 { >Index: src/org/eclipse/swt/internal/widgets/IControlAdapter.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IControlAdapter.java,v >retrieving revision 1.7 >diff -u -r1.7 IControlAdapter.java >--- src/org/eclipse/swt/internal/widgets/IControlAdapter.java 5 May 2011 07:43:11 -0000 1.7 >+++ src/org/eclipse/swt/internal/widgets/IControlAdapter.java 24 Oct 2011 13:06:58 -0000 >@@ -28,6 +28,8 @@ > Color getUserForeground(); > Color getUserBackground(); > Image getUserBackgroundImage(); >+ String getUserBackgroundRepeat(); >+ String getUserBackgroundPosition(); > > boolean getBackgroundTransparency(); > >Index: src/org/eclipse/swt/widgets/Control.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Control.java,v >retrieving revision 1.91 >diff -u -r1.91 Control.java >--- src/org/eclipse/swt/widgets/Control.java 14 Oct 2011 16:00:28 -0000 1.91 >+++ src/org/eclipse/swt/widgets/Control.java 24 Oct 2011 13:06:59 -0000 >@@ -87,6 +87,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; > } >@@ -107,6 +147,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; >@@ -502,6 +544,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. >Index: widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml,v >retrieving revision 1.1 >diff -u -r1.1 Button.theme.xml >--- widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml 11 Oct 2011 10:30:52 -0000 1.1 >+++ widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml 24 Oct 2011 13:06:59 -0000 >@@ -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