Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 361799 | Differences between
and this patch

Collapse All | Expand All

(-)js/qx/ui/core/Widget.js (-1 / +16 lines)
Lines 866-876 Link Here
866
    },
866
    },
867
867
868
    /**
868
    /**
869
     * Mapping to native style property background-position.
870
     */
871
    backgroundPosition : {
872
      check : ["left top", "left center", "left bottom", "right top", "right center", "right bottom", "center top", "center center", "center bottom"],
873
      nullable : true,
874
      init : "left top",
875
      apply : "_applyBackgroundPosition",
876
      themeable : true
877
    },
878
879
    /**
869
     * Mapping to native style property background-repeat.
880
     * Mapping to native style property background-repeat.
870
     */
881
     */
871
    backgroundRepeat : {
882
    backgroundRepeat : {
872
      check : "String",
883
      check : ["repeat", "repeat-x", "repeat-y", "no-repeat"],
873
      nullable : true,
884
      nullable : true,
885
      init : "repeat",
874
      apply : "_applyBackgroundRepeat",
886
      apply : "_applyBackgroundRepeat",
875
      themeable : true
887
      themeable : true
876
    },
888
    },
Lines 3533-3538 Link Here
3533
    _applyBackgroundRepeat : function(value, old) {
3545
    _applyBackgroundRepeat : function(value, old) {
3534
      value ? this.setStyleProperty("backgroundRepeat", value) : this.removeStyleProperty("backgroundRepeat");
3546
      value ? this.setStyleProperty("backgroundRepeat", value) : this.removeStyleProperty("backgroundRepeat");
3535
    },
3547
    },
3548
    _applyBackgroundPosition : function(value, old) {
3549
      value ? this.setStyleProperty("backgroundPosition", value) : this.removeStyleProperty("backgroundPosition");
3550
    },
3536
3551
3537
    ///////////////////
3552
    ///////////////////
3538
    // CLIPPING SUPPORT
3553
    // CLIPPING SUPPORT
(-)src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java (+71 lines)
Lines 118-123 Link Here
118
      result = readFloat( unit );
118
      result = readFloat( unit );
119
    } else if( isAnimationProperty( name ) ) {
119
    } else if( isAnimationProperty( name ) ) {
120
      result = readAnimation( unit );
120
      result = readAnimation( unit );
121
    } else if( isBackgroundRepeatProperty( name ) ) {
122
      result = readBackgroundRepeat( unit );
123
    } else if( isBackgroundPositionProperty( name ) ) {
124
      result = readBackgroundPosition( unit );
121
    } else if( isShadowProperty( name ) ) {
125
    } else if( isShadowProperty( name ) ) {
122
      result = readShadow( unit );
126
      result = readShadow( unit );
123
    } else {
127
    } else {
Lines 869-874 Link Here
869
    return result;
873
    return result;
870
  }
874
  }
871
875
876
  static boolean isBackgroundRepeatProperty( final String property ) {
877
    return "background-repeat".equals( property );
878
  }
879
880
  static QxIdentifier readBackgroundRepeat( final LexicalUnit unit ) {
881
    QxIdentifier result = null;
882
    short type = unit.getLexicalUnitType();
883
    if( type == LexicalUnit.SAC_IDENT ) {
884
      String value = unit.getStringValue();
885
      if(    "repeat".equals( value )
886
          || "repeat-x".equals( value )
887
          || "repeat-y".equals( value )
888
          || "no-repeat".equals( value ) )
889
      {
890
        result = new QxIdentifier( value );
891
      } else {
892
        String msg = "Invalid value for background-repeat: " + value;
893
        throw new IllegalArgumentException( msg );
894
      }
895
    }
896
    if( result == null ) {
897
      throw new IllegalArgumentException( "Failed to parse background-repeat "
898
                                          + toString( unit ) );
899
    }
900
    return result;
901
  }
902
903
  static boolean isBackgroundPositionProperty(final String property ) {
904
    return "background-position".equals( property );
905
  }
906
907
  static QxIdentifier readBackgroundPosition( final LexicalUnit unit ) {
908
    QxIdentifier result = null;
909
    short type = unit.getLexicalUnitType();
910
    if( type == LexicalUnit.SAC_IDENT ) {
911
      StringBuffer valueBuffer = new StringBuffer();
912
      valueBuffer = valueBuffer.append( unit.getStringValue() );
913
914
      LexicalUnit nextUnit = unit.getNextLexicalUnit();
915
      if(nextUnit != null && nextUnit.getStringValue() != null) {
916
        valueBuffer = valueBuffer.append( " " ).append( nextUnit.getStringValue() );
917
      }
918
      String value = valueBuffer.toString();
919
      
920
      if(    "left top".equals( value )
921
          || "left center".equals( value )
922
          || "left bottom".equals( value )
923
          || "right top".equals( value )
924
          || "right center".equals( value )
925
          || "right bottom".equals( value )
926
          || "center top".equals( value )
927
          || "center center".equals( value )
928
          || "center bottom".equals( value ) )
929
      {
930
        result = new QxIdentifier( value );
931
      } else {
932
        String msg = "Invalid value for background-position: " + value;
933
        throw new IllegalArgumentException( msg );
934
      }
935
    }
936
    if( result == null ) {
937
      throw new IllegalArgumentException( "Failed to parse background-position "
938
                                          + toString( unit ) );
939
    }
940
    return result;
941
  }
942
872
  private static Integer readSingleLengthUnit( LexicalUnit unit ) {
943
  private static Integer readSingleLengthUnit( LexicalUnit unit ) {
873
    Integer result = null;
944
    Integer result = null;
874
    short type = unit.getLexicalUnitType();
945
    short type = unit.getLexicalUnitType();
(-)src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java (-1 / +26 lines)
Lines 61-66 Link Here
61
  private static final String PROP_TAB_INDEX = "tabIndex";
61
  private static final String PROP_TAB_INDEX = "tabIndex";
62
  private static final String PROP_CURSOR = "cursor";
62
  private static final String PROP_CURSOR = "cursor";
63
  private static final String PROP_BACKGROUND_IMAGE = "backgroundImage";
63
  private static final String PROP_BACKGROUND_IMAGE = "backgroundImage";
64
  private static final String PROP_BACKGROUND_REPEAT = "backgroundRepeat";
65
  private static final String PROP_BACKGROUND_POSITION = "backgroundPosition";
64
  private static final String PROP_CHILDREN = "children";
66
  private static final String PROP_CHILDREN = "children";
65
67
66
  private static final String USER_DATA_KEY_LISTENER = "keyListener";
68
  private static final String USER_DATA_KEY_LISTENER = "keyListener";
Lines 240-245 Link Here
240
                                      controlAdapter.getUserBackground(),
242
                                      controlAdapter.getUserBackground(),
241
                                      controlAdapter.getBackgroundTransparency() );
243
                                      controlAdapter.getBackgroundTransparency() );
242
    preserveBackgroundImage( control );
244
    preserveBackgroundImage( control );
245
    preserveBackgroundRepeat( control );
246
    preserveBackgroundPosition( control );
243
    WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() );
247
    WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() );
244
    adapter.preserve( PROP_CURSOR, control.getCursor() );
248
    adapter.preserve( PROP_CURSOR, control.getCursor() );
245
    WidgetLCAUtil.preserveListener( control,
249
    WidgetLCAUtil.preserveListener( control,
Lines 278-283 Link Here
278
    Image image = controlAdapter.getUserBackgroundImage();
282
    Image image = controlAdapter.getUserBackgroundImage();
279
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
283
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
280
    adapter.preserve( PROP_BACKGROUND_IMAGE, image );
284
    adapter.preserve( PROP_BACKGROUND_IMAGE, image );
285
  }
286
287
  public static void preserveBackgroundRepeat( Control control ) {
288
    IControlAdapter controlAdapter = control.getAdapter( IControlAdapter.class );
289
    String repeat = controlAdapter.getUserBackgroundRepeat();
290
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
291
    adapter.preserve( PROP_BACKGROUND_REPEAT, repeat );
292
  }
293
294
  public static void preserveBackgroundPosition( Control control ) {
295
    IControlAdapter controlAdapter = control.getAdapter( IControlAdapter.class );
296
    String position = controlAdapter.getUserBackgroundPosition();
297
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
298
    adapter.preserve( PROP_BACKGROUND_POSITION, position );
281
  }
299
  }
282
300
283
  ///////////////////////////////////////////
301
  ///////////////////////////////////////////
Lines 1124-1130 Link Here
1124
  public static void writeBackgroundImage( Control control ) throws IOException {
1142
  public static void writeBackgroundImage( Control control ) throws IOException {
1125
    IControlAdapter controlAdapter = ControlUtil.getControlAdapter( control );
1143
    IControlAdapter controlAdapter = ControlUtil.getControlAdapter( control );
1126
    Image image = controlAdapter.getUserBackgroundImage();
1144
    Image image = controlAdapter.getUserBackgroundImage();
1127
    if( WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_IMAGE, image, null ) ) {
1145
    String repeat = controlAdapter.getUserBackgroundRepeat();
1146
    String position = controlAdapter.getUserBackgroundPosition();
1147
    if( WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_IMAGE, image, null )
1148
        || WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_REPEAT, repeat, null )
1149
        || WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_POSITION, position, null ))
1150
    {
1128
      JSWriter writer = JSWriter.getWriterFor( control );
1151
      JSWriter writer = JSWriter.getWriterFor( control );
1129
      if( image != null ) {
1152
      if( image != null ) {
1130
        String imagePath = ImageFactory.getImagePath( image );
1153
        String imagePath = ImageFactory.getImagePath( image );
Lines 1143-1148 Link Here
1143
        writer.call( "setUserData", args );
1166
        writer.call( "setUserData", args );
1144
        writer.reset( "backgroundImage" );
1167
        writer.reset( "backgroundImage" );
1145
      }
1168
      }
1169
      writer.set( "backgroundRepeat", repeat );
1170
      writer.set( "backgroundPosition", position );
1146
    }
1171
    }
1147
  }
1172
  }
1148
1173
(-)src/org/eclipse/swt/SWT.java (+130 lines)
Lines 3399-3404 Link Here
3399
   */
3399
   */
3400
  public static final int ID_QUIT = -6;
3400
  public static final int ID_QUIT = -6;
3401
3401
3402
  /**
3403
   * The background image will be repeated both vertically and horizontally. This is default
3404
   *
3405
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3406
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3407
   *
3408
   * @since 1.4
3409
   */
3410
  public static final int BACKGROUND_REPEAT_REPEAT = 1;
3411
3412
  /**
3413
   * The background image will be repeated only horizontally
3414
   *
3415
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3416
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3417
   *
3418
   * @since 1.4
3419
   */
3420
  public static final int BACKGROUND_REPEAT_REPEAT_X = 2;
3421
3422
  /**
3423
   * The background image will be repeated only vertically
3424
   *
3425
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3426
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3427
   *
3428
   * @since 1.4
3429
   */
3430
  public static final int BACKGROUND_REPEAT_REPEAT_Y = 3;
3431
3432
  /**
3433
   * The background-image will not be repeated
3434
   *
3435
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3436
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3437
   *
3438
   * @since 1.4
3439
   */
3440
  public static final int BACKGROUND_REPEAT_NO_REPEAT = 4;
3441
3442
  /**
3443
   * The background-position property sets the starting position of a background image. This is default
3444
   *
3445
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3446
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3447
   *
3448
   * @since 1.4
3449
   */
3450
  public static final int BACKGROUND_POSITION_LEFT_TOP = -1;
3451
3452
  /**
3453
   * The background-position property sets the starting position of a background image.
3454
   *
3455
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3456
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3457
   *
3458
   * @since 1.4
3459
   */
3460
  public static final int BACKGROUND_POSITION_LEFT_CENTER = -2;
3461
3462
  /**
3463
   * The background-position property sets the starting position of a background image.
3464
   *
3465
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3466
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3467
   *
3468
   * @since 1.4
3469
   */
3470
  public static final int BACKGROUND_POSITION_LEFT_BOTTOM = -3;
3471
3472
  /**
3473
   * The background-position property sets the starting position of a background image.
3474
   *
3475
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3476
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3477
   *
3478
   * @since 1.4
3479
   */
3480
  public static final int BACKGROUND_POSITION_RIGHT_TOP = -4;
3481
3482
  /**
3483
   * The background-position property sets the starting position of a background image.
3484
   *
3485
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3486
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3487
   *
3488
   * @since 1.4
3489
   */
3490
  public static final int BACKGROUND_POSITION_RIGHT_CENTER = -5;
3491
3492
  /**
3493
   * The background-position property sets the starting position of a background image.
3494
   *
3495
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3496
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3497
   *
3498
   * @since 1.4
3499
   */
3500
  public static final int BACKGROUND_POSITION_RIGHT_BOTTOM = -6;
3501
3502
  /**
3503
   * The background-position property sets the starting position of a background image.
3504
   *
3505
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3506
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3507
   *
3508
   * @since 1.4
3509
   */
3510
  public static final int BACKGROUND_POSITION_CENTER_TOP = -7;
3511
3512
  /**
3513
   * The background-position property sets the starting position of a background image.
3514
   *
3515
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3516
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3517
   *
3518
   * @since 1.4
3519
   */
3520
  public static final int BACKGROUND_POSITION_CENTER_CENTER = -8;
3521
3522
  /**
3523
   * The background-position property sets the starting position of a background image.
3524
   *
3525
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3526
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3527
   *
3528
   * @since 1.4
3529
   */
3530
  public static final int BACKGROUND_POSITION_CENTER_BOTTOM = -9;
3531
3402
  private static final int RWT_VERSION = getVersion( 1, 500 );
3532
  private static final int RWT_VERSION = getVersion( 1, 500 );
3403
3533
3404
  static {
3534
  static {
(-)src/org/eclipse/swt/internal/widgets/IControlAdapter.java (+2 lines)
Lines 28-33 Link Here
28
  Color getUserForeground();
28
  Color getUserForeground();
29
  Color getUserBackground();
29
  Color getUserBackground();
30
  Image getUserBackgroundImage();
30
  Image getUserBackgroundImage();
31
  String getUserBackgroundRepeat();
32
  String getUserBackgroundPosition();
31
33
32
  boolean getBackgroundTransparency();
34
  boolean getBackgroundTransparency();
33
  
35
  
(-)src/org/eclipse/swt/widgets/Control.java (+141 lines)
Lines 88-93 Link Here
88
      return Control.this.backgroundImage;
88
      return Control.this.backgroundImage;
89
    }
89
    }
90
90
91
    public String getUserBackgroundRepeat() {
92
      switch( Control.this.backgroundRepeat ) {
93
        case SWT.BACKGROUND_REPEAT_REPEAT:
94
          return "repeat";
95
        case SWT.BACKGROUND_REPEAT_REPEAT_X:
96
          return "repeat-x";
97
        case SWT.BACKGROUND_REPEAT_REPEAT_Y:
98
          return "repeat-y";
99
        case SWT.BACKGROUND_REPEAT_NO_REPEAT:
100
          return "no-repeat";
101
        default:
102
          return null;
103
      }
104
    }
105
106
    public String getUserBackgroundPosition() {
107
      switch( Control.this.backgroundPosition ) {
108
        case SWT.BACKGROUND_POSITION_LEFT_TOP:
109
          return "left top";
110
        case SWT.BACKGROUND_POSITION_LEFT_CENTER:
111
          return "left center";
112
        case SWT.BACKGROUND_POSITION_LEFT_BOTTOM:
113
          return "left bottom";
114
        case SWT.BACKGROUND_POSITION_RIGHT_TOP:
115
          return "right top";
116
        case SWT.BACKGROUND_POSITION_RIGHT_CENTER:
117
          return "right center";
118
        case SWT.BACKGROUND_POSITION_RIGHT_BOTTOM:
119
          return "right bottom";
120
        case SWT.BACKGROUND_POSITION_CENTER_TOP:
121
          return "center top";
122
        case SWT.BACKGROUND_POSITION_CENTER_CENTER:
123
          return "center center";
124
        case SWT.BACKGROUND_POSITION_CENTER_BOTTOM:
125
          return "center bottom";
126
        default:
127
          return null;
128
      }
129
    }
130
91
    public boolean getBackgroundTransparency() {
131
    public boolean getBackgroundTransparency() {
92
      return Control.this.backgroundTransparency;
132
      return Control.this.backgroundTransparency;
93
    }
133
    }
Lines 108-113 Link Here
108
  private Color foreground;
148
  private Color foreground;
109
  private Color background;
149
  private Color background;
110
  private Image backgroundImage;
150
  private Image backgroundImage;
151
  private int backgroundRepeat;
152
  private int backgroundPosition;
111
  private boolean backgroundTransparency;
153
  private boolean backgroundTransparency;
112
  private Font font;
154
  private Font font;
113
  private Cursor cursor;
155
  private Cursor cursor;
Lines 511-516 Link Here
511
  }
553
  }
512
554
513
  /**
555
  /**
556
   *
557
   * Sets the repeat property of the background to the receiver, which must be one of the following values:
558
   * <dl>
559
   * <dt><code>BACKGROUND_REPEAT_REPEAT</code></dt>
560
   * <dt><code>BACKGROUND_REPEAT_REPEAT_X</code></dt>
561
   * <dt><code>BACKGROUND_REPEAT_REPEAT_Y</code></dt>
562
   * <dt><code>BACKGROUND_REPEAT_NO_REPEAT</code></dt>
563
   * </dl>
564
   *
565
   * @param repeat new repeat style
566
   *
567
   * @exception SWTException <ul>
568
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
569
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
570
   * </ul>
571
   *
572
   * @since 1.4
573
   */
574
  public void setBackgroundRepeat( final int repeat) {
575
    checkWidget();
576
    if( backgroundRepeat != repeat ) {
577
      backgroundRepeat = repeat;
578
    }
579
  }
580
581
  /**
582
   * Returns the receiver's background repeat property.
583
   *
584
   * @return the background repeat property
585
   *
586
   * @exception SWTException <ul>
587
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
588
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
589
   * </ul>
590
   *
591
   * @since 1.4
592
   */
593
  public int getBackgroundRepeat() {
594
    checkWidget();
595
    Control control = findBackgroundControl();
596
    if( control == null ) {
597
      control = this;
598
    }
599
    return control.backgroundRepeat;
600
  }
601
602
  /**
603
   *
604
   * Sets the position property of the background to the receiver, which must be one of the following values:
605
   * <dl>
606
   * <dt><code>BACKGROUND_POSITION_LEFT_TOP</code></dt>
607
   * <dt><code>BACKGROUND_POSITION_LEFT_CENTER</code></dt>
608
   * <dt><code>BACKGROUND_POSITION_LEFT_BOTTOM</code></dt>
609
   * <dt><code>BACKGROUND_POSITION_RIGHT_TOP</code></dt>
610
   * <dt><code>BACKGROUND_POSITION_RIGHT_CENTER</code></dt>
611
   * <dt><code>BACKGROUND_POSITION_RIGHT_BOTTOM</code></dt>
612
   * <dt><code>BACKGROUND_POSITION_CENTER_TOP</code></dt>
613
   * <dt><code>BACKGROUND_POSITION_CENTER_CENTER</code></dt>
614
   * <dt><code>BACKGROUND_POSITION_CENTER_BOTTOM</code></dt>
615
   * </dl>
616
   *
617
   * @param repeat new position style
618
   *
619
   * @exception SWTException <ul>
620
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
621
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
622
   * </ul>
623
   *
624
   * @since 1.4
625
   */
626
  public void setBackgroundPosition( final int position) {
627
    checkWidget();
628
    if( backgroundPosition != position ) {
629
      backgroundPosition = position;
630
    }
631
  }
632
633
  /**
634
   * Returns the receiver's background position property.
635
   *
636
   * @return the background position property
637
   *
638
   * @exception SWTException <ul>
639
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
640
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
641
   * </ul>
642
   *
643
   * @since 1.4
644
   */
645
  public int getBackgroundPosition() {
646
    checkWidget();
647
    Control control = findBackgroundControl();
648
    if( control == null ) {
649
      control = this;
650
    }
651
    return control.backgroundPosition;
652
  }
653
654
  /**
514
   * Sets the receiver's foreground color to the color specified
655
   * Sets the receiver's foreground color to the color specified
515
   * by the argument, or to the default system color for the control
656
   * by the argument, or to the default system color for the control
516
   * if the argument is null.
657
   * if the argument is null.
(-)widgetkits/org/eclipse/swt/internal/widgets/buttonkit/Button.theme.xml (+6 lines)
Lines 27-32 Link Here
27
    <property name="background-image"
27
    <property name="background-image"
28
        description="Background image for buttons." />
28
        description="Background image for buttons." />
29
29
30
    <property name="background-position"
31
        description="Background image position for buttons." />
32
33
    <property name="background-repeat"
34
        description="Background image repetition for buttons." />
35
30
    <property name="border"
36
    <property name="border"
31
        description="Border for buttons." />
37
        description="Border for buttons." />
32
38

Return to bug 361799