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/rwt/lifecycle/ControlLCAUtil_Test.java (+24 lines)
Lines 16-27 Link Here
16
import junit.framework.TestCase;
16
import junit.framework.TestCase;
17
17
18
import org.eclipse.rwt.Fixture;
18
import org.eclipse.rwt.Fixture;
19
import org.eclipse.rwt.graphics.Graphics;
19
import org.eclipse.rwt.internal.lifecycle.DisplayUtil;
20
import org.eclipse.rwt.internal.lifecycle.DisplayUtil;
20
import org.eclipse.rwt.internal.lifecycle.JSConst;
21
import org.eclipse.rwt.internal.lifecycle.JSConst;
21
import org.eclipse.rwt.internal.service.RequestParams;
22
import org.eclipse.rwt.internal.service.RequestParams;
22
import org.eclipse.swt.RWTFixture;
23
import org.eclipse.swt.RWTFixture;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.events.*;
25
import org.eclipse.swt.events.*;
26
import org.eclipse.swt.graphics.Cursor;
25
import org.eclipse.swt.graphics.Rectangle;
27
import org.eclipse.swt.graphics.Rectangle;
26
import org.eclipse.swt.internal.events.ActivateAdapter;
28
import org.eclipse.swt.internal.events.ActivateAdapter;
27
import org.eclipse.swt.internal.events.ActivateEvent;
29
import org.eclipse.swt.internal.events.ActivateEvent;
Lines 224-229 Link Here
224
    assertEquals( new Integer( 1 ), adapter.getPreserved( Props.Z_INDEX ) );
226
    assertEquals( new Integer( 1 ), adapter.getPreserved( Props.Z_INDEX ) );
225
  }
227
  }
226
228
229
  public void testWriteCursor() throws Exception {
230
    Display display = new Display();
231
    Shell shell = new Shell( display, SWT.NONE );
232
    final Control control = new Button( shell, SWT.PUSH );
233
    AbstractWidgetLCA controlLCA = WidgetUtil.getLCA( control );
234
    Cursor cursor = Graphics.getCursor( SWT.CURSOR_HAND );
235
    RWTFixture.markInitialized( control );
236
    RWTFixture.preserveWidgets();
237
    control.setCursor( cursor );
238
    ControlLCAUtil.writeCursor( control );
239
    assertTrue( Fixture.getAllMarkup().indexOf( "setCursor" ) != -1 );
240
241
    Fixture.fakeResponseWriter();
242
    controlLCA.preserveValues( control );
243
    ControlLCAUtil.writeCursor( control );
244
    assertEquals( "", Fixture.getAllMarkup() );
245
246
    control.setCursor( null );
247
    ControlLCAUtil.writeCursor( control );
248
    assertTrue( Fixture.getAllMarkup().indexOf( "resetCursor" ) != -1 );
249
  }
250
227
  protected void setUp() throws Exception {
251
  protected void setUp() throws Exception {
228
    RWTFixture.setUp();
252
    RWTFixture.setUp();
229
    Fixture.fakeResponseWriter();
253
    Fixture.fakeResponseWriter();
(-)js/org/eclipse/swt/theme/AppearancesBase.js (-1 / +2 lines)
Lines 142-147 Link Here
142
        result.backgroundColor = tv.getColor( "label.background" );
142
        result.backgroundColor = tv.getColor( "label.background" );
143
        result.textColor = tv.getColor( "label.foreground" );
143
        result.textColor = tv.getColor( "label.foreground" );
144
      }
144
      }
145
      result.cursor = "default";
145
      return result;
146
      return result;
146
    }
147
    }
147
  },
148
  },
Lines 764-769 Link Here
764
    style : function( states ) {
765
    style : function( states ) {
765
      var tv = new org.eclipse.swt.theme.ThemeValues( states );
766
      var tv = new org.eclipse.swt.theme.ThemeValues( states );
766
      return {
767
      return {
768
        cursor : "default",
767
        overflow : "hidden",
769
        overflow : "hidden",
768
        textColor : tv.getColor( "list.foreground" ),
770
        textColor : tv.getColor( "list.foreground" ),
769
        backgroundColor : tv.getColor( "list.background" ),
771
        backgroundColor : tv.getColor( "list.background" ),
Lines 777-783 Link Here
777
    style : function( states ) {
779
    style : function( states ) {
778
      var tv = new org.eclipse.swt.theme.ThemeValues( states );
780
      var tv = new org.eclipse.swt.theme.ThemeValues( states );
779
      var result = {
781
      var result = {
780
        cursor                  : "default",
781
        height                  : "auto",
782
        height                  : "auto",
782
        horizontalChildrenAlign : "left",
783
        horizontalChildrenAlign : "left",
783
        verticalChildrenAlign   : "middle",
784
        verticalChildrenAlign   : "middle",
(-)src/org/eclipse/rap/demo/controls/ExampleTab.java (+68 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.rap.demo.controls;
12
package org.eclipse.rap.demo.controls;
13
13
14
import java.lang.reflect.Field;
14
import java.util.*;
15
import java.util.*;
15
import java.util.List;
16
import java.util.List;
16
17
Lines 58-63 Link Here
58
  public static final Color FG_COLOR_BLUE = Graphics.getColor( 28, 96, 141 );
59
  public static final Color FG_COLOR_BLUE = Graphics.getColor( 28, 96, 141 );
59
  public static final Color FG_COLOR_ORANGE = Graphics.getColor( 249, 158, 0 );
60
  public static final Color FG_COLOR_ORANGE = Graphics.getColor( 249, 158, 0 );
60
61
62
  private static final String[] SWT_CURSORS = {
63
    "null",
64
    "CURSOR_ARROW",
65
    "CURSOR_WAIT",
66
    "CURSOR_CROSS",
67
    "CURSOR_HELP",
68
    "CURSOR_SIZEALL",
69
    "CURSOR_SIZENESW",
70
    "CURSOR_SIZENS",
71
    "CURSOR_SIZENWSE",
72
    "CURSOR_SIZEWE",
73
    "CURSOR_SIZEN",
74
    "CURSOR_SIZES",
75
    "CURSOR_SIZEE",
76
    "CURSOR_SIZEW",
77
    "CURSOR_SIZENE",
78
    "CURSOR_SIZESE",
79
    "CURSOR_SIZESW",
80
    "CURSOR_SIZENW",
81
    "CURSOR_IBEAM",
82
    "CURSOR_HAND"
83
  };
84
61
  public static Image BG_PATTERN_IMAGE
85
  public static Image BG_PATTERN_IMAGE
62
    = Graphics.getImage( "resources/pattern.png",
86
    = Graphics.getImage( "resources/pattern.png",
63
                         ExampleTab.class.getClassLoader() );
87
                         ExampleTab.class.getClassLoader() );
Lines 376-381 Link Here
376
  }
400
  }
377
401
378
  /**
402
  /**
403
   * Creates a combo that controls whether a cursor is set on the
404
   * registered controls.
405
   *
406
   * @return the created combo
407
   */
408
  protected Combo createCursorCombo() {
409
    Composite group = new Composite( styleComp, SWT.NONE );
410
    group.setLayout( new GridLayout( 2, false ) );
411
    new Label( group, SWT.NONE ).setText( "Cursor:" );
412
    final Combo combo = new Combo( group, SWT.READ_ONLY );
413
    combo.setItems( SWT_CURSORS );
414
    combo.select( 0 );
415
    combo.addSelectionListener( new SelectionAdapter() {
416
      public void widgetSelected( final SelectionEvent e ) {
417
        String selection = null;
418
        int index = combo.getSelectionIndex();
419
        if( index > 0 ) {
420
          selection = combo.getItem( index );
421
        }
422
        updateCursor( selection );
423
      }
424
    } );
425
    return combo;
426
  }
427
428
  /**
379
   * Adds a control to the list of registered controls. Registered controls can
429
   * Adds a control to the list of registered controls. Registered controls can
380
   * be hidden and disabled by the checkbuttons in the property area. This
430
   * be hidden and disabled by the checkbuttons in the property area. This
381
   * method is to be called within <code>createExampleControls</code>.
431
   * method is to be called within <code>createExampleControls</code>.
Lines 473-478 Link Here
473
    }
523
    }
474
  }
524
  }
475
525
526
  private void updateCursor( final String selection ) {
527
    Cursor cursor = null;
528
    Class swtClass = SWT.class;
529
    if( selection != null ) {
530
      try {
531
        Field field = swtClass.getField( selection );
532
        int cursorStyle = field.getInt( swtClass );
533
        cursor = Graphics.getCursor( cursorStyle );
534
      } catch( Exception e ) {
535
      }
536
    }
537
    Iterator iter = controls.iterator();
538
    while( iter.hasNext() ) {
539
      Control control = ( Control )iter.next();
540
      control.setCursor( cursor );
541
    }
542
  }
543
476
  protected Shell getShell() {
544
  protected Shell getShell() {
477
    return folder.getShell();
545
    return folder.getShell();
478
  }
546
  }
(-)src/org/eclipse/rap/demo/controls/ScaleTab.java (-11 / +12 lines)
Lines 19-46 Link Here
19
import org.eclipse.swt.layout.RowLayout;
19
import org.eclipse.swt.layout.RowLayout;
20
import org.eclipse.swt.widgets.*;
20
import org.eclipse.swt.widgets.*;
21
21
22
public class ScaleTab extends ExampleTab {  
22
public class ScaleTab extends ExampleTab {
23
23
24
  private static final String PROP_CONTEXT_MENU = "contextMenu";
24
  private static final String PROP_CONTEXT_MENU = "contextMenu";
25
  private static final String PROP_SELECTION_LISTENER = "selectionListener";
25
  private static final String PROP_SELECTION_LISTENER = "selectionListener";
26
  
26
27
  Scale scale;  
27
  Scale scale;
28
  Spinner minimumSpinner, maximumSpinner, selectionSpinner,
28
  Spinner minimumSpinner, maximumSpinner, selectionSpinner,
29
          incrementSpinner, pageIncrementSpinner;
29
          incrementSpinner, pageIncrementSpinner;
30
  
30
31
  public ScaleTab( final CTabFolder folder ) {
31
  public ScaleTab( final CTabFolder folder ) {
32
    super( folder, "Scale" );
32
    super( folder, "Scale" );
33
    setDefaultStyle( SWT.HORIZONTAL );
33
    setDefaultStyle( SWT.HORIZONTAL );
34
  }
34
  }
35
35
36
  protected void createStyleControls( final Composite parent ) {   
36
  protected void createStyleControls( final Composite parent ) {
37
    createStyleButton( parent, "HORIZONTAL", SWT.HORIZONTAL, SWT.RADIO, true );
37
    createStyleButton( parent, "HORIZONTAL", SWT.HORIZONTAL, SWT.RADIO, true );
38
    createStyleButton( parent, "VERTICAL", SWT.VERTICAL, SWT.RADIO, false ); 
38
    createStyleButton( parent, "VERTICAL", SWT.VERTICAL, SWT.RADIO, false );
39
    createStyleButton( "BORDER", SWT.BORDER );
39
    createStyleButton( "BORDER", SWT.BORDER );
40
    createVisibilityButton();
40
    createVisibilityButton();
41
    createEnablementButton();      
41
    createEnablementButton();
42
    createBgColorButton();
42
    createBgColorButton();
43
    createBgImageButton(); 
43
    createBgImageButton();
44
    createCursorCombo();
44
    minimumSpinner = createSpinnerControl( parent, "Minimum",
45
    minimumSpinner = createSpinnerControl( parent, "Minimum",
45
                                           0, 100000, 0 );
46
                                           0, 100000, 0 );
46
    minimumSpinner.addModifyListener( new ModifyListener() {
47
    minimumSpinner.addModifyListener( new ModifyListener() {
Lines 142-148 Link Here
142
    }
143
    }
143
    registerControl( scale );
144
    registerControl( scale );
144
  }
145
  }
145
  
146
146
  protected Button createStyleButton( final Composite parent,
147
  protected Button createStyleButton( final Composite parent,
147
                                      final String name,
148
                                      final String name,
148
                                      final int style,
149
                                      final int style,
Lines 161-167 Link Here
161
    button.setSelection( checked );
162
    button.setSelection( checked );
162
    return button;
163
    return button;
163
  }
164
  }
164
  
165
165
  private Spinner createSpinnerControl( final Composite parent,
166
  private Spinner createSpinnerControl( final Composite parent,
166
                                        final String labelText,
167
                                        final String labelText,
167
                                        final int minimum,
168
                                        final int minimum,
Lines 174-180 Link Here
174
    final Spinner spinner = new Spinner( composite, SWT.BORDER );
175
    final Spinner spinner = new Spinner( composite, SWT.BORDER );
175
    spinner.setSelection( selection );
176
    spinner.setSelection( selection );
176
    spinner.setMinimum( minimum );
177
    spinner.setMinimum( minimum );
177
    spinner.setMaximum( maximum );    
178
    spinner.setMaximum( maximum );
178
    return spinner;
179
    return spinner;
179
  }
180
  }
180
}
181
}
(-)src/org/eclipse/rap/demo/controls/ListTab.java (+1 lines)
Lines 76-81 Link Here
76
    createBgColorButton();
76
    createBgColorButton();
77
    createBgImageButton();
77
    createBgImageButton();
78
    createFontChooser();
78
    createFontChooser();
79
    createCursorCombo();
79
    createSelectionButton();
80
    createSelectionButton();
80
  }
81
  }
81
82
(-)src/org/eclipse/rap/demo/controls/SpinnerTab.java (+1 lines)
Lines 37-42 Link Here
37
    createFgColorButton();
37
    createFgColorButton();
38
    createBgColorButton();
38
    createBgColorButton();
39
    createFontChooser();
39
    createFontChooser();
40
    createCursorCombo();
40
  }
41
  }
41
42
42
  protected void createExampleControls( final Composite parent ) {
43
  protected void createExampleControls( final Composite parent ) {
(-)src/org/eclipse/rap/demo/controls/CompositeTab.java (+1 lines)
Lines 35-40 Link Here
35
    createBgColorButton();
35
    createBgColorButton();
36
    createBgImageButton();
36
    createBgImageButton();
37
    createBackgroundModeControls( parent );
37
    createBackgroundModeControls( parent );
38
    createCursorCombo();
38
    Button cbAddMouseListener = new Button( parent, SWT.CHECK );
39
    Button cbAddMouseListener = new Button( parent, SWT.CHECK );
39
    cbAddMouseListener.setText( "Attach MouseListener" );
40
    cbAddMouseListener.setText( "Attach MouseListener" );
40
    cbAddMouseListener.addSelectionListener( new SelectionAdapter() {
41
    cbAddMouseListener.addSelectionListener( new SelectionAdapter() {
(-)src/org/eclipse/rap/demo/controls/TextTab.java (-3 / +4 lines)
Lines 92-97 Link Here
92
    createFgColorButton();
92
    createFgColorButton();
93
    createBgColorButton();
93
    createBgColorButton();
94
    createFontChooser();
94
    createFontChooser();
95
    createCursorCombo();
95
    createLimitText( parent );
96
    createLimitText( parent );
96
    createSelectionChooser( parent );
97
    createSelectionChooser( parent );
97
  }
98
  }
Lines 160-166 Link Here
160
    final Button defaultButton = new Button( composite, SWT.PUSH );
161
    final Button defaultButton = new Button( composite, SWT.PUSH );
161
    defaultButton.setText( "Default" );
162
    defaultButton.setText( "Default" );
162
    defaultButton.addSelectionListener( new SelectionAdapter() {
163
    defaultButton.addSelectionListener( new SelectionAdapter() {
163
      
164
164
      public void widgetSelected( SelectionEvent e ) {
165
      public void widgetSelected( SelectionEvent e ) {
165
        String message = "Default button triggered";
166
        String message = "Default button triggered";
166
        MessageDialog.openInformation( parent.getShell(), "Info", message  );
167
        MessageDialog.openInformation( parent.getShell(), "Info", message  );
Lines 169-175 Link Here
169
    final Button setDefaultButton = new Button( composite, SWT.CHECK );
170
    final Button setDefaultButton = new Button( composite, SWT.CHECK );
170
    setDefaultButton.setText( "set as defaultButton" );
171
    setDefaultButton.setText( "set as defaultButton" );
171
    setDefaultButton.addSelectionListener( new SelectionAdapter() {
172
    setDefaultButton.addSelectionListener( new SelectionAdapter() {
172
      
173
173
      public void widgetSelected( SelectionEvent e ) {
174
      public void widgetSelected( SelectionEvent e ) {
174
        if( setDefaultButton.getSelection() ) {
175
        if( setDefaultButton.getSelection() ) {
175
          parent.getShell().setDefaultButton( defaultButton );
176
          parent.getShell().setDefaultButton( defaultButton );
Lines 265-271 Link Here
265
    Button selectAllButton = new Button( composite, SWT.PUSH );
266
    Button selectAllButton = new Button( composite, SWT.PUSH );
266
    selectAllButton.setText( "select all" );
267
    selectAllButton.setText( "select all" );
267
    selectAllButton.addSelectionListener( new SelectionAdapter() {
268
    selectAllButton.addSelectionListener( new SelectionAdapter() {
268
       
269
269
      public void widgetSelected( SelectionEvent e ) {
270
      public void widgetSelected( SelectionEvent e ) {
270
        text.selectAll();
271
        text.selectAll();
271
      }
272
      }
(-)src/org/eclipse/rap/demo/controls/ComboTab.java (+1 lines)
Lines 60-65 Link Here
60
    createFgColorButton();
60
    createFgColorButton();
61
    createBgColorButton();
61
    createBgColorButton();
62
    createFontChooser();
62
    createFontChooser();
63
    createCursorCombo();
63
    createPropertyCheckbox( "Create Empty Combo", PROP_EMPTY );
64
    createPropertyCheckbox( "Create Empty Combo", PROP_EMPTY );
64
    createPropertyCheckbox( "Preselect First Item", PROP_PRESELECT_ITEM );
65
    createPropertyCheckbox( "Preselect First Item", PROP_PRESELECT_ITEM );
65
    createPropertyCheckbox( "Add Selection Listener", PROP_SELECTION_LISTENER );
66
    createPropertyCheckbox( "Add Selection Listener", PROP_SELECTION_LISTENER );
(-)src/org/eclipse/rap/demo/controls/LabelTab.java (+1 lines)
Lines 60-65 Link Here
60
    createBgColorButton();
60
    createBgColorButton();
61
    createBgImageButton();
61
    createBgImageButton();
62
    createFontChooser();
62
    createFontChooser();
63
    createCursorCombo();
63
    createChangeTextControl( parent );
64
    createChangeTextControl( parent );
64
    createChangeToolTipControl( parent );
65
    createChangeToolTipControl( parent );
65
  }
66
  }
(-)src/org/eclipse/rap/demo/controls/ButtonTab.java (+1 lines)
Lines 54-59 Link Here
54
    createBgColorButton();
54
    createBgColorButton();
55
    createBgImageButton();
55
    createBgImageButton();
56
    createFontChooser();
56
    createFontChooser();
57
    createCursorCombo();
57
    Button button = createPropertyButton( "Toggle Button", SWT.PUSH );
58
    Button button = createPropertyButton( "Toggle Button", SWT.PUSH );
58
    button.setToolTipText( "Remote control the toggle button" );
59
    button.setToolTipText( "Remote control the toggle button" );
59
    button.addSelectionListener( new SelectionAdapter() {
60
    button.addSelectionListener( new SelectionAdapter() {
(-)src/org/eclipse/swt/widgets/Control_Test.java (+17 lines)
Lines 605-608 Link Here
605
    } catch( IllegalArgumentException e ) {
605
    } catch( IllegalArgumentException e ) {
606
    }
606
    }
607
  }
607
  }
608
609
  public void testCursor() {
610
    Display display = new Display();
611
    Shell shell = new Shell( display, SWT.NONE );
612
    final Control control = new Button( shell, SWT.PUSH );
613
    Cursor cursor = Graphics.getCursor( SWT.CURSOR_HAND );
614
    control.setCursor( cursor );
615
    assertEquals( cursor, control.getCursor() );
616
617
    cursor = null;
618
    control.setCursor( cursor );
619
    assertEquals( cursor, control.getCursor() );
620
621
    cursor = Graphics.getCursor( SWT.CURSOR_CROSS );
622
    control.setCursor( cursor );
623
    assertEquals( cursor, control.getCursor() );
624
  }
608
}
625
}
(-)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 / +64 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
      if( qxCursor == null ) {
662
        writer.reset( JSConst.QX_FIELD_CURSOR );
663
      } else {
664
        writer.set( JSConst.QX_FIELD_CURSOR, qxCursor );
665
      }
666
    }
667
  }
668
669
  /**
670
   * Writes JavaScript code to the response that resets the property
671
   * <code>cursor</code> of a control. This method is intended to be used by
672
   * implementations of the method
673
   * {@link AbstractWidgetLCA#createResetHandlerCalls(String)}.
674
   *
675
   * @throws IOException
676
   */
677
  public static void resetCursor() throws IOException {
678
    JSWriter writer = JSWriter.getWriterForResetHandler();
679
    writer.reset( JSConst.QX_FIELD_CURSOR );
680
  }
681
637
  public static void writeActivateListener( final Control control )
682
  public static void writeActivateListener( final Control control )
638
    throws IOException
683
    throws IOException
639
  {
684
  {
Lines 697-705 Link Here
697
    writer.removeListener( FOCUS_LOST_LISTENER_INFO.getEventType(),
742
    writer.removeListener( FOCUS_LOST_LISTENER_INFO.getEventType(),
698
                           FOCUS_LOST_LISTENER_INFO.getJSListener() );
743
                           FOCUS_LOST_LISTENER_INFO.getJSListener() );
699
  }
744
  }
700
  
745
701
  private static void writeMouseListener( final Control control ) 
746
  private static void writeMouseListener( final Control control )
702
    throws IOException 
747
    throws IOException
703
  {
748
  {
704
    boolean hasListener = MouseEvent.hasListener( control );
749
    boolean hasListener = MouseEvent.hasListener( control );
705
    JSWriter writer = JSWriter.getWriterFor( control );
750
    JSWriter writer = JSWriter.getWriterFor( control );
Lines 863-879 Link Here
863
                               true,
908
                               true,
864
                               SWT.NONE );
909
                               SWT.NONE );
865
  }
910
  }
866
  
911
867
  public static void processMouseEvents( final Control control ) {
912
  public static void processMouseEvents( final Control control ) {
868
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_DOWN ) ) {
913
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_DOWN ) ) {
869
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_DOWN );
914
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_DOWN );
870
      event.button
915
      event.button
871
        = readIntParam( control, JSConst.EVENT_MOUSE_DOWN_BUTTON );
916
        = readIntParam( control, JSConst.EVENT_MOUSE_DOWN_BUTTON );
872
      Point point = readXYParams( control,
917
      Point point = readXYParams( control,
873
                                  JSConst.EVENT_MOUSE_DOWN_X, 
918
                                  JSConst.EVENT_MOUSE_DOWN_X,
874
                                  JSConst.EVENT_MOUSE_DOWN_Y );
919
                                  JSConst.EVENT_MOUSE_DOWN_Y );
875
      event.x = point.x; 
920
      event.x = point.x;
876
      event.y = point.y; 
921
      event.y = point.y;
877
      event.processEvent();
922
      event.processEvent();
878
    }
923
    }
879
    String eventId = JSConst.EVENT_MOUSE_DOUBLE_CLICK;
924
    String eventId = JSConst.EVENT_MOUSE_DOUBLE_CLICK;
Lines 882-917 Link Here
882
        = new MouseEvent( control, MouseEvent.MOUSE_DOUBLE_CLICK );
927
        = new MouseEvent( control, MouseEvent.MOUSE_DOUBLE_CLICK );
883
      event.button
928
      event.button
884
        = readIntParam( control, JSConst.EVENT_MOUSE_DOUBLE_CLICK_BUTTON );
929
        = readIntParam( control, JSConst.EVENT_MOUSE_DOUBLE_CLICK_BUTTON );
885
      Point point = readXYParams( control, 
930
      Point point = readXYParams( control,
886
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_X, 
931
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_X,
887
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_Y );
932
                                  JSConst.EVENT_MOUSE_DOUBLE_CLICK_Y );
888
      event.x = point.x; 
933
      event.x = point.x;
889
      event.y = point.y; 
934
      event.y = point.y;
890
      event.processEvent();
935
      event.processEvent();
891
    }
936
    }
892
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_UP ) ) {
937
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_UP ) ) {
893
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_UP );
938
      MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_UP );
894
      event.button = readIntParam( control, JSConst.EVENT_MOUSE_UP_BUTTON );
939
      event.button = readIntParam( control, JSConst.EVENT_MOUSE_UP_BUTTON );
895
      Point point = readXYParams( control,
940
      Point point = readXYParams( control,
896
                                  JSConst.EVENT_MOUSE_UP_X, 
941
                                  JSConst.EVENT_MOUSE_UP_X,
897
                                  JSConst.EVENT_MOUSE_UP_Y );
942
                                  JSConst.EVENT_MOUSE_UP_Y );
898
      event.x = point.x; 
943
      event.x = point.x;
899
      event.y = point.y; 
944
      event.y = point.y;
900
      event.processEvent();
945
      event.processEvent();
901
    }
946
    }
902
  }
947
  }
903
948
904
  private static int readIntParam( final Control control, 
949
  private static int readIntParam( final Control control,
905
                                   final String paramName ) 
950
                                   final String paramName )
906
  {
951
  {
907
    HttpServletRequest request = ContextProvider.getRequest();
952
    HttpServletRequest request = ContextProvider.getRequest();
908
    String value = request.getParameter( paramName );
953
    String value = request.getParameter( paramName );
909
    return Integer.parseInt( value );
954
    return Integer.parseInt( value );
910
  }
955
  }
911
956
912
  private static Point readXYParams( final Control control, 
957
  private static Point readXYParams( final Control control,
913
                                     final String paramNameX,
958
                                     final String paramNameX,
914
                                     final String paramNameY ) 
959
                                     final String paramNameY )
915
  {
960
  {
916
    int x = readIntParam( control, paramNameX );
961
    int x = readIntParam( control, paramNameX );
917
    int y = readIntParam( control, paramNameY );
962
    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 584-589 Link Here
584
    return result;
585
    return result;
585
  }
586
  }
586
587
588
  /////////
589
  // Cursors
590
591
  /**
592
   * Sets the receiver's cursor to the cursor specified by the
593
   * argument, or to the default cursor for that kind of control
594
   * if the argument is null.
595
   * <p>
596
   * When the mouse pointer passes over a control its appearance
597
   * is changed to match the control's cursor.
598
   * </p>
599
   *
600
   * @param cursor the new cursor (or null)
601
   *
602
   * @exception IllegalArgumentException <ul>
603
   *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
604
   * </ul>
605
   * @exception SWTException <ul>
606
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
607
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
608
   * </ul>
609
   *
610
   * @since 1.1.1
611
   */
612
  public void setCursor (final Cursor cursor) {
613
    checkWidget ();
614
    this.cursor = cursor;
615
  }
616
617
  /**
618
   * Returns the receiver's cursor, or null if it has not been set.
619
   * <p>
620
   * When the mouse pointer passes over a control its appearance
621
   * is changed to match the control's cursor.
622
   * </p>
623
   *
624
   * @return the receiver's cursor or <code>null</code>
625
   *
626
   * @exception SWTException <ul>
627
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
628
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
629
   * </ul>
630
   *
631
   * @since 1.1.1
632
   */
633
  public Cursor getCursor () {
634
    checkWidget ();
635
    return cursor;
636
  }
637
587
  //////////////////
638
  //////////////////
588
  // Focus handling
639
  // Focus handling
589
640
(-)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