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 872-882 Link Here
872
    },
872
    },
873
873
874
    /**
874
    /**
875
     * Mapping to native style property background-position.
876
     */
877
    backgroundPosition : {
878
      check : ["left top", "left center", "left bottom", "right top", "right center", "right bottom", "center top", "center center", "center bottom"],
879
      nullable : true,
880
      init : "left top",
881
      apply : "_applyBackgroundPosition",
882
      themeable : true
883
    },
884
885
    /**
875
     * Mapping to native style property background-repeat.
886
     * Mapping to native style property background-repeat.
876
     */
887
     */
877
    backgroundRepeat : {
888
    backgroundRepeat : {
878
      check : "String",
889
      check : ["repeat", "repeat-x", "repeat-y", "no-repeat"],
879
      nullable : true,
890
      nullable : true,
891
      init : "repeat",
880
      apply : "_applyBackgroundRepeat",
892
      apply : "_applyBackgroundRepeat",
881
      themeable : true
893
      themeable : true
882
    },
894
    },
Lines 3528-3533 Link Here
3528
    _applyBackgroundRepeat : function(value, old) {
3540
    _applyBackgroundRepeat : function(value, old) {
3529
      value ? this.setStyleProperty("backgroundRepeat", value) : this.removeStyleProperty("backgroundRepeat");
3541
      value ? this.setStyleProperty("backgroundRepeat", value) : this.removeStyleProperty("backgroundRepeat");
3530
    },
3542
    },
3543
    _applyBackgroundPosition : function(value, old) {
3544
      value ? this.setStyleProperty("backgroundPosition", value) : this.removeStyleProperty("backgroundPosition");
3545
    },
3531
3546
3532
    ///////////////////
3547
    ///////////////////
3533
    // CLIPPING SUPPORT
3548
    // CLIPPING SUPPORT
(-)src/org/eclipse/rwt/internal/theme/css/PropertyResolver.java (+71 lines)
Lines 117-122 Link Here
117
      result = readFloat( unit );
117
      result = readFloat( unit );
118
    } else if( isAnimationProperty( name ) ) {
118
    } else if( isAnimationProperty( name ) ) {
119
      result = readAnimation( unit );
119
      result = readAnimation( unit );
120
    } else if( isBackgroundRepeatProperty( name ) ) {
121
      result = readBackgroundRepeat( unit );
122
    } else if( isBackgroundPositionProperty( name ) ) {
123
      result = readBackgroundPosition( unit );
120
    } else if( isShadowProperty( name ) ) {
124
    } else if( isShadowProperty( name ) ) {
121
      result = readShadow( unit );
125
      result = readShadow( unit );
122
    } else {
126
    } else {
Lines 893-898 Link Here
893
    return result;
897
    return result;
894
  }
898
  }
895
899
900
  static boolean isBackgroundRepeatProperty( final String property ) {
901
    return "background-repeat".equals( property );
902
  }
903
904
  static QxIdentifier readBackgroundRepeat( final LexicalUnit unit ) {
905
    QxIdentifier result = null;
906
    short type = unit.getLexicalUnitType();
907
    if( type == LexicalUnit.SAC_IDENT ) {
908
      String value = unit.getStringValue();
909
      if(    "repeat".equals( value )
910
          || "repeat-x".equals( value )
911
          || "repeat-y".equals( value )
912
          || "no-repeat".equals( value ) )
913
      {
914
        result = new QxIdentifier( value );
915
      } else {
916
        String msg = "Invalid value for background-repeat: " + value;
917
        throw new IllegalArgumentException( msg );
918
      }
919
    }
920
    if( result == null ) {
921
      throw new IllegalArgumentException( "Failed to parse background-repeat "
922
                                          + toString( unit ) );
923
    }
924
    return result;
925
  }
926
927
  static boolean isBackgroundPositionProperty(final String property ) {
928
    return "background-position".equals( property );
929
  }
930
931
  static QxIdentifier readBackgroundPosition( final LexicalUnit unit ) {
932
    QxIdentifier result = null;
933
    short type = unit.getLexicalUnitType();
934
    if( type == LexicalUnit.SAC_IDENT ) {
935
      StringBuffer valueBuffer = new StringBuffer();
936
      valueBuffer = valueBuffer.append( unit.getStringValue() );
937
938
      LexicalUnit nextUnit = unit.getNextLexicalUnit();
939
      if(nextUnit != null && nextUnit.getStringValue() != null) {
940
        valueBuffer = valueBuffer.append( " " ).append( nextUnit.getStringValue() );
941
      }
942
      String value = valueBuffer.toString();
943
      
944
      if(    "left top".equals( value )
945
          || "left center".equals( value )
946
          || "left bottom".equals( value )
947
          || "right top".equals( value )
948
          || "right center".equals( value )
949
          || "right bottom".equals( value )
950
          || "center top".equals( value )
951
          || "center center".equals( value )
952
          || "center bottom".equals( value ) )
953
      {
954
        result = new QxIdentifier( value );
955
      } else {
956
        String msg = "Invalid value for background-position: " + value;
957
        throw new IllegalArgumentException( msg );
958
      }
959
    }
960
    if( result == null ) {
961
      throw new IllegalArgumentException( "Failed to parse background-position "
962
                                          + toString( unit ) );
963
    }
964
    return result;
965
  }
966
896
  private static Integer readSingleLengthUnit( LexicalUnit unit ) {
967
  private static Integer readSingleLengthUnit( LexicalUnit unit ) {
897
    Integer result = null;
968
    Integer result = null;
898
    short type = unit.getLexicalUnitType();
969
    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
66
65
  private static final String USER_DATA_KEY_LISTENER = "keyListener";
67
  private static final String USER_DATA_KEY_LISTENER = "keyListener";
66
  private static final String USER_DATA_TRAVERSE_LISTENER = "traverseListener";
68
  private static final String USER_DATA_TRAVERSE_LISTENER = "traverseListener";
Lines 130-135 Link Here
130
                                      controlAdapter.getUserBackground(),
132
                                      controlAdapter.getUserBackground(),
131
                                      controlAdapter.getBackgroundTransparency() );
133
                                      controlAdapter.getBackgroundTransparency() );
132
    preserveBackgroundImage( control );
134
    preserveBackgroundImage( control );
135
    preserveBackgroundRepeat( control );
136
    preserveBackgroundPosition( control );
133
    WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() );
137
    WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() );
134
    adapter.preserve( PROP_CURSOR, control.getCursor() );
138
    adapter.preserve( PROP_CURSOR, control.getCursor() );
135
    adapter.preserve( Props.CONTROL_LISTENERS,
139
    adapter.preserve( Props.CONTROL_LISTENERS,
Lines 159-164 Link Here
159
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
163
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
160
    adapter.preserve( PROP_BACKGROUND_IMAGE, image );
164
    adapter.preserve( PROP_BACKGROUND_IMAGE, image );
161
  }
165
  }
166
167
  public static void preserveBackgroundRepeat( final Control control ) {
168
    IControlAdapter controlAdapter = control.getAdapter( IControlAdapter.class );
169
    String repeat = controlAdapter.getUserBackgroundRepeat();
170
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
171
    adapter.preserve( PROP_BACKGROUND_REPEAT, repeat );
172
  }
173
174
  public static void preserveBackgroundPosition( final Control control ) {
175
    IControlAdapter controlAdapter = control.getAdapter( IControlAdapter.class );
176
    String position = controlAdapter.getUserBackgroundPosition();
177
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
178
    adapter.preserve( PROP_BACKGROUND_POSITION, position );
179
  }
162
  
180
  
163
  //////////////////
181
  //////////////////
164
  // read properties
182
  // read properties
Lines 688-694 Link Here
688
  public static void writeBackgroundImage( Control control ) throws IOException {
706
  public static void writeBackgroundImage( Control control ) throws IOException {
689
    IControlAdapter controlAdapter = ControlUtil.getControlAdapter( control );
707
    IControlAdapter controlAdapter = ControlUtil.getControlAdapter( control );
690
    Image image = controlAdapter.getUserBackgroundImage();
708
    Image image = controlAdapter.getUserBackgroundImage();
691
    if( WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_IMAGE, image, null ) ) {
709
    String repeat = controlAdapter.getUserBackgroundRepeat();
710
    String position = controlAdapter.getUserBackgroundPosition();
711
    if( WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_IMAGE, image, null )
712
        || WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_REPEAT, repeat, null )
713
        || WidgetLCAUtil.hasChanged( control, PROP_BACKGROUND_POSITION, position, null ))
714
    {
692
      JSWriter writer = JSWriter.getWriterFor( control );
715
      JSWriter writer = JSWriter.getWriterFor( control );
693
      if( image != null ) {
716
      if( image != null ) {
694
        String imagePath = ImageFactory.getImagePath( image );
717
        String imagePath = ImageFactory.getImagePath( image );
Lines 707-712 Link Here
707
        writer.call( "setUserData", args );
730
        writer.call( "setUserData", args );
708
        writer.reset( "backgroundImage" );
731
        writer.reset( "backgroundImage" );
709
      }
732
      }
733
      writer.set( "backgroundRepeat", repeat );
734
      writer.set( "backgroundPosition", position );
710
    }
735
    }
711
  }
736
  }
712
737
(-)src/org/eclipse/swt/SWT.java (+130 lines)
Lines 3401-3406 Link Here
3401
   */
3401
   */
3402
  public static final int ID_QUIT = -6;
3402
  public static final int ID_QUIT = -6;
3403
3403
3404
  /**
3405
   * The background image will be repeated both vertically and horizontally. This is default
3406
   *
3407
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3408
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3409
   *
3410
   * @since 1.4
3411
   */
3412
  public static final int BACKGROUND_REPEAT_REPEAT = 1;
3413
3414
  /**
3415
   * The background image will be repeated only horizontally
3416
   *
3417
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3418
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3419
   *
3420
   * @since 1.4
3421
   */
3422
  public static final int BACKGROUND_REPEAT_REPEAT_X = 2;
3423
3424
  /**
3425
   * The background image will be repeated only vertically
3426
   *
3427
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3428
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3429
   *
3430
   * @since 1.4
3431
   */
3432
  public static final int BACKGROUND_REPEAT_REPEAT_Y = 3;
3433
3434
  /**
3435
   * The background-image will not be repeated
3436
   *
3437
   * @see org.eclipse.swt.widgets.Control#setBackgroundRepeat(int)
3438
   * @see org.eclipse.swt.widgets.Control#getBackgroundRepeat()
3439
   *
3440
   * @since 1.4
3441
   */
3442
  public static final int BACKGROUND_REPEAT_NO_REPEAT = 4;
3443
3444
  /**
3445
   * The background-position property sets the starting position of a background image. This is default
3446
   *
3447
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3448
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3449
   *
3450
   * @since 1.4
3451
   */
3452
  public static final int BACKGROUND_POSITION_LEFT_TOP = -1;
3453
3454
  /**
3455
   * The background-position property sets the starting position of a background image.
3456
   *
3457
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3458
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3459
   *
3460
   * @since 1.4
3461
   */
3462
  public static final int BACKGROUND_POSITION_LEFT_CENTER = -2;
3463
3464
  /**
3465
   * The background-position property sets the starting position of a background image.
3466
   *
3467
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3468
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3469
   *
3470
   * @since 1.4
3471
   */
3472
  public static final int BACKGROUND_POSITION_LEFT_BOTTOM = -3;
3473
3474
  /**
3475
   * The background-position property sets the starting position of a background image.
3476
   *
3477
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3478
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3479
   *
3480
   * @since 1.4
3481
   */
3482
  public static final int BACKGROUND_POSITION_RIGHT_TOP = -4;
3483
3484
  /**
3485
   * The background-position property sets the starting position of a background image.
3486
   *
3487
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3488
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3489
   *
3490
   * @since 1.4
3491
   */
3492
  public static final int BACKGROUND_POSITION_RIGHT_CENTER = -5;
3493
3494
  /**
3495
   * The background-position property sets the starting position of a background image.
3496
   *
3497
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3498
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3499
   *
3500
   * @since 1.4
3501
   */
3502
  public static final int BACKGROUND_POSITION_RIGHT_BOTTOM = -6;
3503
3504
  /**
3505
   * The background-position property sets the starting position of a background image.
3506
   *
3507
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3508
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3509
   *
3510
   * @since 1.4
3511
   */
3512
  public static final int BACKGROUND_POSITION_CENTER_TOP = -7;
3513
3514
  /**
3515
   * The background-position property sets the starting position of a background image.
3516
   *
3517
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3518
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3519
   *
3520
   * @since 1.4
3521
   */
3522
  public static final int BACKGROUND_POSITION_CENTER_CENTER = -8;
3523
3524
  /**
3525
   * The background-position property sets the starting position of a background image.
3526
   *
3527
   * @see org.eclipse.swt.widgets.Control#setBackgroundPosition(int)
3528
   * @see org.eclipse.swt.widgets.Control#getBackgroundPosition()
3529
   *
3530
   * @since 1.4
3531
   */
3532
  public static final int BACKGROUND_POSITION_CENTER_BOTTOM = -9;
3533
3404
  private static final int RWT_VERSION = getVersion( 1, 500 );
3534
  private static final int RWT_VERSION = getVersion( 1, 500 );
3405
3535
3406
  static {
3536
  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 87-92 Link Here
87
      return Control.this.backgroundImage;
87
      return Control.this.backgroundImage;
88
    }
88
    }
89
89
90
    public String getUserBackgroundRepeat() {
91
      switch( Control.this.backgroundRepeat ) {
92
        case SWT.BACKGROUND_REPEAT_REPEAT:
93
          return "repeat";
94
        case SWT.BACKGROUND_REPEAT_REPEAT_X:
95
          return "repeat-x";
96
        case SWT.BACKGROUND_REPEAT_REPEAT_Y:
97
          return "repeat-y";
98
        case SWT.BACKGROUND_REPEAT_NO_REPEAT:
99
          return "no-repeat";
100
        default:
101
          return null;
102
      }
103
    }
104
105
    public String getUserBackgroundPosition() {
106
      switch( Control.this.backgroundPosition ) {
107
        case SWT.BACKGROUND_POSITION_LEFT_TOP:
108
          return "left top";
109
        case SWT.BACKGROUND_POSITION_LEFT_CENTER:
110
          return "left center";
111
        case SWT.BACKGROUND_POSITION_LEFT_BOTTOM:
112
          return "left bottom";
113
        case SWT.BACKGROUND_POSITION_RIGHT_TOP:
114
          return "right top";
115
        case SWT.BACKGROUND_POSITION_RIGHT_CENTER:
116
          return "right center";
117
        case SWT.BACKGROUND_POSITION_RIGHT_BOTTOM:
118
          return "right bottom";
119
        case SWT.BACKGROUND_POSITION_CENTER_TOP:
120
          return "center top";
121
        case SWT.BACKGROUND_POSITION_CENTER_CENTER:
122
          return "center center";
123
        case SWT.BACKGROUND_POSITION_CENTER_BOTTOM:
124
          return "center bottom";
125
        default:
126
          return null;
127
      }
128
    }
129
90
    public boolean getBackgroundTransparency() {
130
    public boolean getBackgroundTransparency() {
91
      return Control.this.backgroundTransparency;
131
      return Control.this.backgroundTransparency;
92
    }
132
    }
Lines 107-112 Link Here
107
  private Color foreground;
147
  private Color foreground;
108
  private Color background;
148
  private Color background;
109
  private Image backgroundImage;
149
  private Image backgroundImage;
150
  private int backgroundRepeat;
151
  private int backgroundPosition;
110
  private boolean backgroundTransparency;
152
  private boolean backgroundTransparency;
111
  private Font font;
153
  private Font font;
112
  private Cursor cursor;
154
  private Cursor cursor;
Lines 502-507 Link Here
502
  }
544
  }
503
545
504
  /**
546
  /**
547
   *
548
   * Sets the repeat property of the background to the receiver, which must be one of the following values:
549
   * <dl>
550
   * <dt><code>BACKGROUND_REPEAT_REPEAT</code></dt>
551
   * <dt><code>BACKGROUND_REPEAT_REPEAT_X</code></dt>
552
   * <dt><code>BACKGROUND_REPEAT_REPEAT_Y</code></dt>
553
   * <dt><code>BACKGROUND_REPEAT_NO_REPEAT</code></dt>
554
   * </dl>
555
   *
556
   * @param repeat new repeat style
557
   *
558
   * @exception SWTException <ul>
559
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
560
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
561
   * </ul>
562
   *
563
   * @since 1.4
564
   */
565
  public void setBackgroundRepeat( final int repeat) {
566
    checkWidget();
567
    if( backgroundRepeat != repeat ) {
568
      backgroundRepeat = repeat;
569
    }
570
  }
571
572
  /**
573
   * Returns the receiver's background repeat property.
574
   *
575
   * @return the background repeat property
576
   *
577
   * @exception SWTException <ul>
578
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
579
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
580
   * </ul>
581
   *
582
   * @since 1.4
583
   */
584
  public int getBackgroundRepeat() {
585
    checkWidget();
586
    Control control = findBackgroundControl();
587
    if( control == null ) {
588
      control = this;
589
    }
590
    return control.backgroundRepeat;
591
  }
592
593
  /**
594
   *
595
   * Sets the position property of the background to the receiver, which must be one of the following values:
596
   * <dl>
597
   * <dt><code>BACKGROUND_POSITION_LEFT_TOP</code></dt>
598
   * <dt><code>BACKGROUND_POSITION_LEFT_CENTER</code></dt>
599
   * <dt><code>BACKGROUND_POSITION_LEFT_BOTTOM</code></dt>
600
   * <dt><code>BACKGROUND_POSITION_RIGHT_TOP</code></dt>
601
   * <dt><code>BACKGROUND_POSITION_RIGHT_CENTER</code></dt>
602
   * <dt><code>BACKGROUND_POSITION_RIGHT_BOTTOM</code></dt>
603
   * <dt><code>BACKGROUND_POSITION_CENTER_TOP</code></dt>
604
   * <dt><code>BACKGROUND_POSITION_CENTER_CENTER</code></dt>
605
   * <dt><code>BACKGROUND_POSITION_CENTER_BOTTOM</code></dt>
606
   * </dl>
607
   *
608
   * @param repeat new position style
609
   *
610
   * @exception SWTException <ul>
611
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
612
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
613
   * </ul>
614
   *
615
   * @since 1.4
616
   */
617
  public void setBackgroundPosition( final int position) {
618
    checkWidget();
619
    if( backgroundPosition != position ) {
620
      backgroundPosition = position;
621
    }
622
  }
623
624
  /**
625
   * Returns the receiver's background position property.
626
   *
627
   * @return the background position property
628
   *
629
   * @exception SWTException <ul>
630
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
631
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
632
   * </ul>
633
   *
634
   * @since 1.4
635
   */
636
  public int getBackgroundPosition() {
637
    checkWidget();
638
    Control control = findBackgroundControl();
639
    if( control == null ) {
640
      control = this;
641
    }
642
    return control.backgroundPosition;
643
  }
644
645
  /**
505
   * Sets the receiver's foreground color to the color specified
646
   * Sets the receiver's foreground color to the color specified
506
   * by the argument, or to the default system color for the control
647
   * by the argument, or to the default system color for the control
507
   * if the argument is null.
648
   * 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