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 244004 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/internal/widgets/Props.java (-7 / +8 lines)
Lines 22-28 Link Here
22
  public static final String VISIBLE = "visible";
22
  public static final String VISIBLE = "visible";
23
  public static final String ENABLED = "enabled";
23
  public static final String ENABLED = "enabled";
24
  public static final String CONTROL_LISTENERS = "hasControlListeners";
24
  public static final String CONTROL_LISTENERS = "hasControlListeners";
25
  
25
  public static final String CURSOR = "cursor";
26
26
  // Scrollable
27
  // Scrollable
27
  public static final String CLIENT_AREA = "clientArea";
28
  public static final String CLIENT_AREA = "clientArea";
28
29
Lines 30-50 Link Here
30
  public static final String SELECTION_LISTENERS = "selectionListeners";
31
  public static final String SELECTION_LISTENERS = "selectionListeners";
31
  public static final String ACTIVATE_LISTENER = "activateListener";
32
  public static final String ACTIVATE_LISTENER = "activateListener";
32
  public static final String FOCUS_LISTENER = "focusListener";
33
  public static final String FOCUS_LISTENER = "focusListener";
33
  
34
34
  // Text properties
35
  // Text properties
35
  public static final String TEXT = "text";
36
  public static final String TEXT = "text";
36
  
37
37
  public static final String IMAGE = "image";
38
  public static final String IMAGE = "image";
38
  
39
39
  // Table, TableItem and TableColumn properties
40
  // Table, TableItem and TableColumn properties
40
  public static final String SELECTION_INDICES = "selection";
41
  public static final String SELECTION_INDICES = "selection";
41
  
42
42
  // CoolBar/CoolItem properties
43
  // CoolBar/CoolItem properties
43
  public static final String LOCKED = "locked";
44
  public static final String LOCKED = "locked";
44
  public static final String CONTROL = "control";
45
  public static final String CONTROL = "control";
45
  
46
46
  public static final String TOOLTIP = "toolTip";
47
  public static final String TOOLTIP = "toolTip";
47
  
48
48
  public static final String BACKGROUND = "background";
49
  public static final String BACKGROUND = "background";
49
  public static final String FOREGROUND = "foreground";
50
  public static final String FOREGROUND = "foreground";
50
  public static final String FONT = "font";
51
  public static final String FONT = "font";
(-)src/org/eclipse/rwt/graphics/Graphics.java (-22 / +34 lines)
Lines 23-29 Link Here
23
 * As RAP needs to handle with multiple clients simultaneously there are no
23
 * As RAP needs to handle with multiple clients simultaneously there are no
24
 * constructors for these objects to share them between different sessions
24
 * constructors for these objects to share them between different sessions
25
 * in order to have a much smaller memory footprint.
25
 * in order to have a much smaller memory footprint.
26
 * 
26
 *
27
 * @since 1.0
27
 * @since 1.0
28
 */
28
 */
29
public final class Graphics {
29
public final class Graphics {
Lines 31-40 Link Here
31
  /**
31
  /**
32
   * Returns an instance of {@link Color} given an
32
   * Returns an instance of {@link Color} given an
33
   * <code>RGB</code> describing the desired red, green and blue values.
33
   * <code>RGB</code> describing the desired red, green and blue values.
34
   * 
34
   *
35
   * @param rgb the RGB values of the desired color
35
   * @param rgb the RGB values of the desired color
36
   * @return the color
36
   * @return the color
37
   * 
37
   *
38
   * @see RGB
38
   * @see RGB
39
   * @see Device#getSystemColor
39
   * @see Device#getSystemColor
40
   */
40
   */
Lines 46-52 Link Here
46
   * Returns a {@link Color} given the
46
   * Returns a {@link Color} given the
47
   * desired red, green and blue values expressed as ints in the range
47
   * desired red, green and blue values expressed as ints in the range
48
   * 0 to 255 (where 0 is black and 255 is full brightness).
48
   * 0 to 255 (where 0 is black and 255 is full brightness).
49
   * 
49
   *
50
   * @param red the amount of red in the color
50
   * @param red the amount of red in the color
51
   * @param green the amount of green in the color
51
   * @param green the amount of green in the color
52
   * @param blue the amount of blue in the color
52
   * @param blue the amount of blue in the color
Lines 60-66 Link Here
60
  /**
60
  /**
61
   * Returns a new font given a font data
61
   * Returns a new font given a font data
62
   * which describes the desired font's appearance.
62
   * which describes the desired font's appearance.
63
   * 
63
   *
64
   * @param data the {@link FontData} to use
64
   * @param data the {@link FontData} to use
65
   * @return the font
65
   * @return the font
66
   */
66
   */
Lines 71-77 Link Here
71
  /**
71
  /**
72
   * Returns a {@link Font} object given a font name, the height of the desired
72
   * Returns a {@link Font} object given a font name, the height of the desired
73
   * font in points, and a font style.
73
   * font in points, and a font style.
74
   * 
74
   *
75
   * @param name the name of the font (must not be null)
75
   * @param name the name of the font (must not be null)
76
   * @param height the font height in points
76
   * @param height the font height in points
77
   * @param style a bit or combination of <code>NORMAL</code>,
77
   * @param style a bit or combination of <code>NORMAL</code>,
Lines 88-96 Link Here
88
  /**
88
  /**
89
   * Returns an instance of {@link Image} based on the specified
89
   * Returns an instance of {@link Image} based on the specified
90
   * image path. The image has to be on the applications class-path.
90
   * image path. The image has to be on the applications class-path.
91
   * 
91
   *
92
   * @param path the path to the image
92
   * @param path the path to the image
93
   * 
93
   *
94
   * @return the image
94
   * @return the image
95
   */
95
   */
96
  public static Image getImage( final String path ) {
96
  public static Image getImage( final String path ) {
Lines 101-110 Link Here
101
   * Returns an instance of {@link Image} based on the specified
101
   * Returns an instance of {@link Image} based on the specified
102
   * image path. The image has to be on the applications class-path.
102
   * image path. The image has to be on the applications class-path.
103
   * Uses the specified classloader to load the image.
103
   * Uses the specified classloader to load the image.
104
   * 
104
   *
105
   * @param path the path to the image
105
   * @param path the path to the image
106
   * @param imageLoader the classloader to use
106
   * @param imageLoader the classloader to use
107
   * 
107
   *
108
   * @return the image
108
   * @return the image
109
   */
109
   */
110
  public static Image getImage( final String path,
110
  public static Image getImage( final String path,
Lines 113-126 Link Here
113
    return ResourceFactory.findImage( path, imageLoader );
113
    return ResourceFactory.findImage( path, imageLoader );
114
  }
114
  }
115
115
116
  
116
117
  /**
117
  /**
118
   * Returns an instance of {@link Image} based on the specified
118
   * Returns an instance of {@link Image} based on the specified
119
   * image path. The image will be read from the provided InputStream.
119
   * image path. The image will be read from the provided InputStream.
120
   * 
120
   *
121
   * @param path the path to the image
121
   * @param path the path to the image
122
   * @param inputStream the input stream for the image
122
   * @param inputStream the input stream for the image
123
   * 
123
   *
124
   * @return the image
124
   * @return the image
125
   */
125
   */
126
  public static Image getImage( final String path,
126
  public static Image getImage( final String path,
Lines 128-137 Link Here
128
  {
128
  {
129
    return ResourceFactory.findImage( path, inputStream );
129
    return ResourceFactory.findImage( path, inputStream );
130
  }
130
  }
131
  
131
132
  /**
133
   * Returns an instance of {@link Cursor} based on the specified style.
134
   *
135
   * @param style the cursor style
136
   * @return
137
   *
138
   * @return the cursor
139
   */
140
  public static Cursor getCursor( final int style ) {
141
    return ResourceFactory.getCursor( style );
142
  }
143
132
  //////////////////////////
144
  //////////////////////////
133
  // Text-Size-Determination
145
  // Text-Size-Determination
134
  
146
135
  /**
147
  /**
136
   * Returns the extent of the given string. Tab expansion and carriage return
148
   * Returns the extent of the given string. Tab expansion and carriage return
137
   * processing are performed.
149
   * processing are performed.
Lines 139-145 Link Here
139
   * The <em>extent</em> of a string is the width and height of the
151
   * The <em>extent</em> of a string is the width and height of the
140
   * rectangular area it would cover if drawn in a particular font.
152
   * rectangular area it would cover if drawn in a particular font.
141
   * </p>
153
   * </p>
142
   * 
154
   *
143
   * @param font the font for which the result is valid
155
   * @param font the font for which the result is valid
144
   * @param string the string to measure
156
   * @param string the string to measure
145
   * @param wrapWidth the maximum width of the text. The text will be wrapped to
157
   * @param wrapWidth the maximum width of the text. The text will be wrapped to
Lines 159-165 Link Here
159
    }
171
    }
160
    return TextSizeDetermination.textExtent( font, string, wrapWidth );
172
    return TextSizeDetermination.textExtent( font, string, wrapWidth );
161
  }
173
  }
162
  
174
163
  /**
175
  /**
164
   * Returns the extent of the given string. No tab expansion or carriage return
176
   * Returns the extent of the given string. No tab expansion or carriage return
165
   * processing will be performed.
177
   * processing will be performed.
Lines 167-173 Link Here
167
   * The <em>extent</em> of a string is the width and height of the
179
   * The <em>extent</em> of a string is the width and height of the
168
   * rectangular area it would cover if drawn in a particular font.
180
   * rectangular area it would cover if drawn in a particular font.
169
   * </p>
181
   * </p>
170
   * 
182
   *
171
   * @param font the font for which the result is valid
183
   * @param font the font for which the result is valid
172
   * @param string the string to measure
184
   * @param string the string to measure
173
   * @return a point containing the extent of the string
185
   * @return a point containing the extent of the string
Lines 182-191 Link Here
182
    }
194
    }
183
    return TextSizeDetermination.stringExtent( font, string );
195
    return TextSizeDetermination.stringExtent( font, string );
184
  }
196
  }
185
  
197
186
  /**
198
  /**
187
   * Returns the height of the specified font, measured in pixels.
199
   * Returns the height of the specified font, measured in pixels.
188
   * 
200
   *
189
   * @param font the font for which the result is valid
201
   * @param font the font for which the result is valid
190
   * @return the height of the font
202
   * @return the height of the font
191
   */
203
   */
Lines 195-205 Link Here
195
    }
207
    }
196
    return TextSizeDetermination.getCharHeight( font );
208
    return TextSizeDetermination.getCharHeight( font );
197
  }
209
  }
198
  
210
199
  /**
211
  /**
200
   * Returns the average character width of the specified font, measured in
212
   * Returns the average character width of the specified font, measured in
201
   * pixels.
213
   * pixels.
202
   * 
214
   *
203
   * @param font the font for which the result is valid
215
   * @param font the font for which the result is valid
204
   * @return the average character width of the font
216
   * @return the average character width of the font
205
   */
217
   */
(-)src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java (-19 / +60 lines)
Lines 51-57 Link Here
51
    = new JSListenerInfo( "focusout",
51
    = new JSListenerInfo( "focusout",
52
                          "org.eclipse.swt.EventUtil.focusLost",
52
                          "org.eclipse.swt.EventUtil.focusLost",
53
                          JSListenerType.ACTION );
53
                          JSListenerType.ACTION );
54
  
54
55
  private static final JSListenerInfo MOUSE_DOWN_LISTENER_INFO
55
  private static final JSListenerInfo MOUSE_DOWN_LISTENER_INFO
56
    = new JSListenerInfo( "mousedown",
56
    = new JSListenerInfo( "mousedown",
57
                          "org.eclipse.swt.EventUtil.mouseDown",
57
                          "org.eclipse.swt.EventUtil.mouseDown",
Lines 124-129 Link Here
124
                                      controlAdapter.getBackgroundTransparency() );
124
                                      controlAdapter.getBackgroundTransparency() );
125
    preserveBackgroundImage( control );
125
    preserveBackgroundImage( control );
126
    WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() );
126
    WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() );
127
    adapter.preserve( Props.CURSOR, control.getCursor() );
127
    adapter.preserve( Props.CONTROL_LISTENERS,
128
    adapter.preserve( Props.CONTROL_LISTENERS,
128
                      Boolean.valueOf( ControlEvent.hasListener( control ) ) );
129
                      Boolean.valueOf( ControlEvent.hasListener( control ) ) );
129
    adapter.preserve( PROP_ACTIVATE_LISTENER,
130
    adapter.preserve( PROP_ACTIVATE_LISTENER,
Lines 310-315 Link Here
310
    writeBackground( control );
311
    writeBackground( control );
311
    writeBackgroundImage( control );
312
    writeBackgroundImage( control );
312
    writeFont( control );
313
    writeFont( control );
314
    writeCursor( control );
313
//    TODO [rst] missing: writeControlListener( control );
315
//    TODO [rst] missing: writeControlListener( control );
314
    writeActivateListener( control );
316
    writeActivateListener( control );
315
    writeFocusListener( control );
317
    writeFocusListener( control );
Lines 634-639 Link Here
634
    WidgetLCAUtil.resetFont();
636
    WidgetLCAUtil.resetFont();
635
  }
637
  }
636
638
639
  /**
640
   * Determines whether the property <code>cursor</code> of the given control
641
   * has changed during the processing of the current request and if so, writes
642
   * JavaScript code to the response that updates the client-side cursor property.
643
   *
644
   * @param control the control whose font property to write
645
   * @throws IOException
646
   */
647
  public static void writeCursor( final Control control ) throws IOException {
648
    Cursor newValue = control.getCursor();
649
    if( WidgetLCAUtil.hasChanged( control, Props.CURSOR, newValue, null ) ) {
650
      String qxCursor = null;
651
      if( newValue != null ) {
652
        int hashCode = newValue.hashCode();
653
        if( hashCode >= 0 && hashCode < JSConst.QX_CURSOR_VALUES.length ) {
654
          qxCursor = JSConst.QX_CURSOR_VALUES[ hashCode ];
655
          if( "null".equals( qxCursor ) ) {
656
            qxCursor = null;
657
          }
658
        }
659
      }
660
      JSWriter writer = JSWriter.getWriterFor( control );
661
      writer.set( JSConst.QX_FIELD_CURSOR, qxCursor );
662
    }
663
  }
664
665
  /**
666
   * Writes JavaScript code to the response that resets the property
667
   * <code>cursor</code> of a control. This method is intended to be used by
668
   * implementations of the method
669
   * {@link AbstractWidgetLCA#createResetHandlerCalls(String)}.
670
   *
671
   * @throws IOException
672
   */
673
  public static void resetCursor() throws IOException {
674
    JSWriter writer = JSWriter.getWriterForResetHandler();
675
    writer.reset( JSConst.QX_FIELD_CURSOR );
676
  }
677
637
  public static void writeActivateListener( final Control control )
678
  public static void writeActivateListener( final Control control )
638
    throws IOException
679
    throws IOException
639
  {
680
  {
Lines 697-705 Link Here
697
    writer.removeListener( FOCUS_LOST_LISTENER_INFO.getEventType(),
738
    writer.removeListener( FOCUS_LOST_LISTENER_INFO.getEventType(),
698
                           FOCUS_LOST_LISTENER_INFO.getJSListener() );
739
                           FOCUS_LOST_LISTENER_INFO.getJSListener() );
699
  }
740
  }
700
  
741
701
  private static void writeMouseListener( final Control control ) 
742
  private static void writeMouseListener( final Control control )
702
    throws IOException 
743
    throws IOException
703
  {
744
  {
704
    boolean hasListener = MouseEvent.hasListener( control );
745
    boolean hasListener = MouseEvent.hasListener( control );
705
    JSWriter writer = JSWriter.getWriterFor( control );
746
    JSWriter writer = JSWriter.getWriterFor( control );
Lines 863-879 Link Here
863
                               true,
904
                               true,
864
                               SWT.NONE );
905
                               SWT.NONE );
865
  }
906
  }
866
  
907
867
  public static void processMouseEvents( final Control control ) {
908
  public static void processMouseEvents( final Control control ) {
868
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_DOWN ) ) {
909
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_DOWN ) ) {
869
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_DOWN );
910
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_DOWN );
870
      event.button
911
      event.button
871
        = readIntParam( control, JSConst.EVENT_MOUSE_DOWN_BUTTON );
912
        = readIntParam( control, JSConst.EVENT_MOUSE_DOWN_BUTTON );
872
      Point point = readXYParams( control,
913
      Point point = readXYParams( control,
873
                                  JSConst.EVENT_MOUSE_DOWN_X, 
914
                                  JSConst.EVENT_MOUSE_DOWN_X,
874
                                  JSConst.EVENT_MOUSE_DOWN_Y );
915
                                  JSConst.EVENT_MOUSE_DOWN_Y );
875
      event.x = point.x; 
916
      event.x = point.x;
876
      event.y = point.y; 
917
      event.y = point.y;
877
      event.processEvent();
918
      event.processEvent();
878
    }
919
    }
879
    String eventId = JSConst.EVENT_MOUSE_DOUBLE_CLICK;
920
    String eventId = JSConst.EVENT_MOUSE_DOUBLE_CLICK;
Lines 882-917 Link Here
882
        = new MouseEvent( control, MouseEvent.MOUSE_DOUBLE_CLICK );
923
        = new MouseEvent( control, MouseEvent.MOUSE_DOUBLE_CLICK );
883
      event.button
924
      event.button
884
        = readIntParam( control, JSConst.EVENT_MOUSE_DOUBLE_CLICK_BUTTON );
925
        = readIntParam( control, JSConst.EVENT_MOUSE_DOUBLE_CLICK_BUTTON );
885
      Point point = readXYParams( control, 
926
      Point point = readXYParams( control,
886
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_X, 
927
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_X,
887
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_Y );
928
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_Y );
888
      event.x = point.x; 
929
      event.x = point.x;
889
      event.y = point.y; 
930
      event.y = point.y;
890
      event.processEvent();
931
      event.processEvent();
891
    }
932
    }
892
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_UP ) ) {
933
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_UP ) ) {
893
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_UP );
934
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_UP );
894
      event.button = readIntParam( control, JSConst.EVENT_MOUSE_UP_BUTTON );
935
      event.button = readIntParam( control, JSConst.EVENT_MOUSE_UP_BUTTON );
895
      Point point = readXYParams( control,
936
      Point point = readXYParams( control,
896
                                  JSConst.EVENT_MOUSE_UP_X, 
937
                                  JSConst.EVENT_MOUSE_UP_X,
897
                                  JSConst.EVENT_MOUSE_UP_Y );
938
                                  JSConst.EVENT_MOUSE_UP_Y );
898
      event.x = point.x; 
939
      event.x = point.x;
899
      event.y = point.y; 
940
      event.y = point.y;
900
      event.processEvent();
941
      event.processEvent();
901
    }
942
    }
902
  }
943
  }
903
944
904
  private static int readIntParam( final Control control, 
945
  private static int readIntParam( final Control control,
905
                                   final String paramName ) 
946
                                   final String paramName )
906
  {
947
  {
907
    HttpServletRequest request = ContextProvider.getRequest();
948
    HttpServletRequest request = ContextProvider.getRequest();
908
    String value = request.getParameter( paramName );
949
    String value = request.getParameter( paramName );
909
    return Integer.parseInt( value );
950
    return Integer.parseInt( value );
910
  }
951
  }
911
952
912
  private static Point readXYParams( final Control control, 
953
  private static Point readXYParams( final Control control,
913
                                     final String paramNameX,
954
                                     final String paramNameX,
914
                                     final String paramNameY ) 
955
                                     final String paramNameY )
915
  {
956
  {
916
    int x = readIntParam( control, paramNameX );
957
    int x = readIntParam( control, paramNameX );
917
    int y = readIntParam( control, paramNameY );
958
    int y = readIntParam( control, paramNameY );
(-)src/org/eclipse/swt/internal/graphics/ResourceFactory.java (-1 / +39 lines)
Lines 30-35 Link Here
30
  private final static Map colors = new HashMap();
30
  private final static Map colors = new HashMap();
31
  private static final Map fonts = new HashMap();
31
  private static final Map fonts = new HashMap();
32
  private static final Map images = new HashMap();
32
  private static final Map images = new HashMap();
33
  private static final Map cursors = new HashMap();
33
  private static final ImageDataCache imageDataCache = new ImageDataCache();
34
  private static final ImageDataCache imageDataCache = new ImageDataCache();
34
35
35
  /////////
36
  /////////
Lines 218-223 Link Here
218
    return result;
219
    return result;
219
  }
220
  }
220
221
222
  ////////
223
  // Cursors
224
225
  public static Cursor getCursor( final int style ) {
226
    Cursor result;
227
    Integer key = new Integer( style );
228
    synchronized( Cursor.class ) {
229
      result = ( Cursor )cursors.get( key );
230
      if( result == null ) {
231
        result = createCursorInstance( style );
232
        cursors.put( key, result );
233
      }
234
    }
235
    return result;
236
  }
237
221
  ///////////////
238
  ///////////////
222
  // Test helpers
239
  // Test helpers
223
240
Lines 225-230 Link Here
225
    colors.clear();
242
    colors.clear();
226
    fonts.clear();
243
    fonts.clear();
227
    images.clear();
244
    images.clear();
245
    cursors.clear();
228
  }
246
  }
229
247
230
  static int colorsCount() {
248
  static int colorsCount() {
Lines 239-244 Link Here
239
    return images.size();
257
    return images.size();
240
  }
258
  }
241
259
260
  static int cursorsCount() {
261
    return cursors.size();
262
  }
263
242
264
243
  //////////////////
265
  //////////////////
244
  // Helping methods
266
  // Helping methods
Lines 447-453 Link Here
447
      Class[] paramList = new Class[] { int.class, int.class };
469
      Class[] paramList = new Class[] { int.class, int.class };
448
      Constructor constr = fontClass.getDeclaredConstructor( paramList );
470
      Constructor constr = fontClass.getDeclaredConstructor( paramList );
449
      constr.setAccessible( true );
471
      constr.setAccessible( true );
450
      result = ( Image )constr.newInstance( new Object[]{
472
      result = ( Image )constr.newInstance( new Object[] {
451
        new Integer( width ), new Integer( height )
473
        new Integer( width ), new Integer( height )
452
      } );
474
      } );
453
    } catch( final Exception e ) {
475
    } catch( final Exception e ) {
Lines 456-461 Link Here
456
    return result;
478
    return result;
457
  }
479
  }
458
480
481
  private static Cursor createCursorInstance( final int style ) {
482
    Cursor result = null;
483
    try {
484
      Class cursorClass = Cursor.class;
485
      Class[] paramList = new Class[] { int.class };
486
      Constructor constr = cursorClass.getDeclaredConstructor( paramList );
487
      constr.setAccessible( true );
488
      result = ( Cursor )constr.newInstance( new Object[] {
489
        new Integer( style )
490
      } );
491
    } catch( final Exception e ) {
492
      throw new RuntimeException( "Failed to instantiate Cursor", e );
493
    }
494
    return result;
495
  }
496
459
  private ResourceFactory() {
497
  private ResourceFactory() {
460
    // prevent instantiation
498
    // prevent instantiation
461
  }
499
  }
(-)src/org/eclipse/rwt/internal/lifecycle/JSConst.java (+28 lines)
Lines 145-150 Link Here
145
  public static final String QX_FIELD_APPEARANCE = "appearance";
145
  public static final String QX_FIELD_APPEARANCE = "appearance";
146
  public static final String QX_FIELD_Z_INDEX = "zIndex";
146
  public static final String QX_FIELD_Z_INDEX = "zIndex";
147
  public static final String QX_FIELD_TAB_INDEX = "tabIndex";
147
  public static final String QX_FIELD_TAB_INDEX = "tabIndex";
148
  public static final String QX_FIELD_CURSOR = "cursor";
149
150
  // cursor values
151
  // the order in the array correspond to the SWT#CURSOR_xxxx constants
152
  public static final String[] QX_CURSOR_VALUES = {
153
    "default",
154
    "wait",
155
    "crosshair",
156
    "null",     // SWT#CURSOR_APPSTARTING not exist in qx
157
    "help",
158
    "move",
159
    "ne-resize",
160
    "n-resize",
161
    "nw-resize",
162
    "w-resize",
163
    "n-resize",
164
    "s-resize",
165
    "e-resize",
166
    "w-resize",
167
    "ne-resize",
168
    "se-resize",
169
    "sw-resize",
170
    "nw-resize",
171
    "null",     // SWT#CURSOR_UPARROW not exist in qx
172
    "text",
173
    "null",     // SWT#CURSOR_NO not exist in qx
174
    "pointer"
175
  };
148
176
149
  // constants
177
  // constants
150
  public static final JSVar QX_CONST_VERTICAL_ORIENTATION
178
  public static final JSVar QX_CONST_VERTICAL_ORIENTATION
(-)src/org/eclipse/swt/widgets/Control.java (+51 lines)
Lines 96-101 Link Here
96
  private Image backgroundImage = null;
96
  private Image backgroundImage = null;
97
  private boolean backgroundTransparency;
97
  private boolean backgroundTransparency;
98
  private Font font;
98
  private Font font;
99
  private Cursor cursor;
99
100
100
  Control( final Composite parent ) {
101
  Control( final Composite parent ) {
101
    // prevent instantiation from outside this package; only called by Shell
102
    // prevent instantiation from outside this package; only called by Shell
Lines 586-591 Link Here
586
    return result;
587
    return result;
587
  }
588
  }
588
589
590
  /////////
591
  // Cursors
592
593
  /**
594
   * Sets the receiver's cursor to the cursor specified by the
595
   * argument, or to the default cursor for that kind of control
596
   * if the argument is null.
597
   * <p>
598
   * When the mouse pointer passes over a control its appearance
599
   * is changed to match the control's cursor.
600
   * </p>
601
   *
602
   * @param cursor the new cursor (or null)
603
   *
604
   * @exception IllegalArgumentException <ul>
605
   *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
606
   * </ul>
607
   * @exception SWTException <ul>
608
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
609
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
610
   * </ul>
611
   *
612
   * @since 1.1.1
613
   */
614
  public void setCursor (final Cursor cursor) {
615
    checkWidget ();
616
    this.cursor = cursor;
617
  }
618
619
  /**
620
   * Returns the receiver's cursor, or null if it has not been set.
621
   * <p>
622
   * When the mouse pointer passes over a control its appearance
623
   * is changed to match the control's cursor.
624
   * </p>
625
   *
626
   * @return the receiver's cursor or <code>null</code>
627
   *
628
   * @exception SWTException <ul>
629
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
630
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
631
   * </ul>
632
   *
633
   * @since 1.1.1
634
   */
635
  public Cursor getCursor () {
636
    checkWidget ();
637
    return cursor;
638
  }
639
589
  //////////////////
640
  //////////////////
590
  // Focus handling
641
  // Focus handling
591
642
(-)src/org/eclipse/swt/SWT.java (+135 lines)
Lines 971-976 Link Here
971
   */
971
   */
972
  public static final int ITALIC = 1 << 1;
972
  public static final int ITALIC = 1 << 1;
973
973
974
  // Cursor style constants
975
976
  /**
977
   * System arrow cursor  (value is 0).
978
   *
979
   * @see Graphics#getCursor(int)
980
   */
981
  public static final int CURSOR_ARROW = 0;
982
983
  /**
984
   * System wait cursor  (value is 1).
985
   *
986
   * @see Graphics#getCursor(int)
987
   */
988
  public static final int CURSOR_WAIT = 1;
989
990
  /**
991
   * System cross hair cursor  (value is 2).
992
   *
993
   * @see Graphics#getCursor(int)
994
   */
995
  public static final int CURSOR_CROSS = 2;
996
997
  /**
998
   * System help cursor  (value is 4).
999
   *
1000
   * @see Graphics#getCursor(int)
1001
   */
1002
  public static final int CURSOR_HELP = 4;
1003
1004
  /**
1005
   * System resize all directions cursor (value is 5).
1006
   *
1007
   * @see Graphics#getCursor(int)
1008
   */
1009
  public static final int CURSOR_SIZEALL = 5;
1010
1011
  /**
1012
   * System resize north-east-south-west cursor  (value is 6).
1013
   *
1014
   * @see Graphics#getCursor(int)
1015
   */
1016
  public static final int CURSOR_SIZENESW = 6;
1017
1018
  /**
1019
   * System resize north-south cursor  (value is 7).
1020
   *
1021
   * @see Graphics#getCursor(int)
1022
   */
1023
  public static final int CURSOR_SIZENS = 7;
1024
1025
  /**
1026
   * System resize north-west-south-east cursor  (value is 8).
1027
   *
1028
   * @see Graphics#getCursor(int)
1029
   */
1030
  public static final int CURSOR_SIZENWSE = 8;
1031
1032
  /**
1033
   * System resize west-east cursor  (value is 9).
1034
   *
1035
   * @see Graphics#getCursor(int)
1036
   */
1037
  public static final int CURSOR_SIZEWE = 9;
1038
1039
  /**
1040
   * System resize north cursor  (value is 10).
1041
   *
1042
   * @see Graphics#getCursor(int)
1043
   */
1044
  public static final int CURSOR_SIZEN = 10;
1045
1046
  /**
1047
   * System resize south cursor  (value is 11).
1048
   *
1049
   * @see Graphics#getCursor(int)
1050
   */
1051
  public static final int CURSOR_SIZES = 11;
1052
1053
  /**
1054
   * System resize east cursor  (value is 12).
1055
   *
1056
   * @see Graphics#getCursor(int)
1057
   */
1058
  public static final int CURSOR_SIZEE = 12;
1059
1060
  /**
1061
   * System resize west cursor  (value is 13).
1062
   *
1063
   * @see Graphics#getCursor(int)
1064
   */
1065
  public static final int CURSOR_SIZEW = 13;
1066
1067
  /**
1068
   * System resize north-east cursor (value is 14).
1069
   *
1070
   * @see Graphics#getCursor(int)
1071
   */
1072
  public static final int CURSOR_SIZENE = 14;
1073
1074
  /**
1075
   * System resize south-east cursor (value is 15).
1076
   *
1077
   * @see Graphics#getCursor(int)
1078
   */
1079
  public static final int CURSOR_SIZESE = 15;
1080
1081
  /**
1082
   * System resize south-west cursor (value is 16).
1083
   *
1084
   * @see Graphics#getCursor(int)
1085
   */
1086
  public static final int CURSOR_SIZESW = 16;
1087
1088
  /**
1089
   * System resize north-west cursor (value is 17).
1090
   *
1091
   * @see Graphics#getCursor(int)
1092
   */
1093
  public static final int CURSOR_SIZENW = 17;
1094
1095
  /**
1096
   * System i-beam cursor (value is 19).
1097
   *
1098
   * @see Graphics#getCursor(int)
1099
   */
1100
  public static final int CURSOR_IBEAM = 19;
1101
1102
  /**
1103
   * System hand cursor (value is 21).
1104
   *
1105
   * @see Graphics#getCursor(int)
1106
   */
1107
  public static final int CURSOR_HAND = 21;
1108
974
  // Predefined images
1109
  // Predefined images
975
1110
976
  /**
1111
  /**
(-)src/org/eclipse/swt/graphics/Cursor.java (+211 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.swt.graphics;
12
13
import org.eclipse.rwt.graphics.Graphics;
14
import org.eclipse.swt.SWT;
15
16
/**
17
 * Instances of this class manage operating system resources that
18
 * specify the appearance of the on-screen pointer.
19
 *
20
 * <p>Cursors may be constructed using one of the <code>getCursor</code> methods
21
 * in class <code>Graphics</code> by providing a style information.
22
 * </p>
23
 * <dl>
24
 * <dt><b>Styles:</b></dt>
25
 * <dd>
26
 *   CURSOR_ARROW, CURSOR_WAIT, CURSOR_CROSS, CURSOR_HELP,
27
 *   CURSOR_SIZEALL, CURSOR_SIZENESW, CURSOR_SIZENS, CURSOR_SIZENWSE, CURSOR_SIZEWE,
28
 *   CURSOR_SIZEN, CURSOR_SIZES, CURSOR_SIZEE, CURSOR_SIZEW, CURSOR_SIZENE, CURSOR_SIZESE,
29
 *   CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_IBEAM, CURSOR_HAND
30
 * </dd>
31
 * </dl>
32
 * <p>
33
 * Note: Only one of the above styles may be specified.
34
 * </p>
35
 *
36
 * @see Graphics
37
 *
38
 * @since 1.1.1
39
 */
40
41
public final class Cursor extends Resource {
42
43
  /**
44
   * the handle to the cursor resource
45
   */
46
  int handle;
47
48
  //prevent instance creation
49
  private Cursor( final int style ) {
50
  	switch( style ) {
51
  		case SWT.CURSOR_HAND:
52
  		  handle = SWT.CURSOR_HAND;
53
  		  break;
54
  		case SWT.CURSOR_ARROW:
55
  		  handle = SWT.CURSOR_ARROW;
56
  		  break;
57
  		case SWT.CURSOR_WAIT:
58
  		  handle = SWT.CURSOR_WAIT;
59
  		  break;
60
  		case SWT.CURSOR_CROSS:
61
  		  handle = SWT.CURSOR_CROSS;
62
  		  break;
63
//  		case SWT.CURSOR_APPSTARTING:
64
//  		  handle = SWT.CURSOR_APPSTARTING;
65
//  		  break;
66
  		case SWT.CURSOR_HELP:
67
  		  handle = SWT.CURSOR_HELP;
68
  		  break;
69
  		case SWT.CURSOR_SIZEALL:
70
  		  handle = SWT.CURSOR_SIZEALL;
71
  		  break;
72
  		case SWT.CURSOR_SIZENESW:
73
  		  handle = SWT.CURSOR_SIZENESW;
74
  		  break;
75
  		case SWT.CURSOR_SIZENS:
76
  		  handle = SWT.CURSOR_SIZENS;
77
  		  break;
78
  		case SWT.CURSOR_SIZENWSE:
79
  		  handle = SWT.CURSOR_SIZENWSE;
80
  		  break;
81
  		case SWT.CURSOR_SIZEWE:
82
  		  handle = SWT.CURSOR_SIZEWE;
83
  		  break;
84
  		case SWT.CURSOR_SIZEN:
85
  		  handle = SWT.CURSOR_SIZEN;
86
  		  break;
87
  		case SWT.CURSOR_SIZES:
88
  		  handle = SWT.CURSOR_SIZES;
89
  		  break;
90
  		case SWT.CURSOR_SIZEE:
91
  		  handle = SWT.CURSOR_SIZEE;
92
  		  break;
93
  		case SWT.CURSOR_SIZEW:
94
  		  handle = SWT.CURSOR_SIZEW;
95
  		  break;
96
  		case SWT.CURSOR_SIZENE:
97
  		  handle = SWT.CURSOR_SIZENE;
98
  		  break;
99
  		case SWT.CURSOR_SIZESE:
100
  		  handle = SWT.CURSOR_SIZESE;
101
  		  break;
102
  		case SWT.CURSOR_SIZESW:
103
  		  handle = SWT.CURSOR_SIZESW;
104
  		  break;
105
  		case SWT.CURSOR_SIZENW:
106
  		  handle = SWT.CURSOR_SIZENW;
107
  		  break;
108
//  		case SWT.CURSOR_UPARROW:
109
//  		  handle = SWT.CURSOR_UPARROW;
110
//  		  break;
111
  		case SWT.CURSOR_IBEAM:
112
  		  handle = SWT.CURSOR_IBEAM;
113
  		  break;
114
//  		case SWT.CURSOR_NO:
115
//  		  handle = SWT.CURSOR_NO;
116
//  		  break;
117
  		default:
118
  			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
119
  	}
120
  }
121
122
  /**
123
   * Returns an integer hash code for the receiver.
124
   *
125
   * @return the receiver's hash
126
   */
127
  public int hashCode () {
128
    return handle;
129
  }
130
131
  /**
132
   * Returns a string containing a concise, human-readable
133
   * description of the receiver.
134
   *
135
   * @return a string representation of the receiver
136
   */
137
  public String toString () {
138
    String type;
139
    switch( handle ) {
140
      case SWT.CURSOR_HAND:
141
        type = "SWT.CURSOR_HAND";
142
        break;
143
      case SWT.CURSOR_ARROW:
144
        type = "SWT.CURSOR_ARROW";
145
        break;
146
      case SWT.CURSOR_WAIT:
147
        type = "SWT.CURSOR_WAIT";
148
        break;
149
      case SWT.CURSOR_CROSS:
150
        type = "SWT.CURSOR_CROSS";
151
        break;
152
//      case SWT.CURSOR_APPSTARTING:
153
//        type = "SWT.CURSOR_APPSTARTING";
154
//        break;
155
      case SWT.CURSOR_HELP:
156
        type = "SWT.CURSOR_HELP";
157
        break;
158
      case SWT.CURSOR_SIZEALL:
159
        type = "SWT.CURSOR_SIZEALL";
160
        break;
161
      case SWT.CURSOR_SIZENESW:
162
        type = "SWT.CURSOR_SIZENESW";
163
        break;
164
      case SWT.CURSOR_SIZENS:
165
        type = "SWT.CURSOR_SIZENS";
166
        break;
167
      case SWT.CURSOR_SIZENWSE:
168
        type = "SWT.CURSOR_SIZENWSE";
169
        break;
170
      case SWT.CURSOR_SIZEWE:
171
        type = "SWT.CURSOR_SIZEWE";
172
        break;
173
      case SWT.CURSOR_SIZEN:
174
        type = "SWT.CURSOR_SIZEN";
175
        break;
176
      case SWT.CURSOR_SIZES:
177
        type = "SWT.CURSOR_SIZES";
178
        break;
179
      case SWT.CURSOR_SIZEE:
180
        type = "SWT.CURSOR_SIZEE";
181
        break;
182
      case SWT.CURSOR_SIZEW:
183
        type = "SWT.CURSOR_SIZEW";
184
        break;
185
      case SWT.CURSOR_SIZENE:
186
        type = "SWT.CURSOR_SIZENE";
187
        break;
188
      case SWT.CURSOR_SIZESE:
189
        type = "SWT.CURSOR_SIZESE";
190
        break;
191
      case SWT.CURSOR_SIZESW:
192
        type = "SWT.CURSOR_SIZESW";
193
        break;
194
      case SWT.CURSOR_SIZENW:
195
        type = "SWT.CURSOR_SIZENW";
196
        break;
197
//      case SWT.CURSOR_UPARROW:
198
//        type = "SWT.CURSOR_UPARROW";
199
//        break;
200
      case SWT.CURSOR_IBEAM:
201
        type = "SWT.CURSOR_IBEAM";
202
        break;
203
//      case SWT.CURSOR_NO:
204
//        type = "SWT.CURSOR_NO";
205
//        break;
206
      default:
207
        type = "" + handle;
208
    }
209
    return "Cursor {" + type + "}";
210
  }
211
}

Return to bug 244004