Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 119743 Details for
Bug 256740
Slider widget missing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
First version of slider widget
slider_patch.txt (text/plain), 80.78 KB, created by
Ivan Furnadjiev
on 2008-12-08 03:13:33 EST
(
hide
)
Description:
First version of slider widget
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2008-12-08 03:13:33 EST
Size:
80.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/RWTHostTestSuite.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java,v >retrieving revision 1.20 >diff -u -r1.20 RWTHostTestSuite.java >--- src/org/eclipse/RWTHostTestSuite.java 11 Nov 2008 14:09:33 -0000 1.20 >+++ src/org/eclipse/RWTHostTestSuite.java 5 Dec 2008 15:42:11 -0000 >@@ -149,6 +149,7 @@ > suite.addTestSuite( MessageBox_Test.class ); > suite.addTestSuite( ExpandBar_Test.class ); > suite.addTestSuite( ExpandItem_Test.class ); >+ suite.addTestSuite( Slider_Test.class ); > > suite.addTestSuite( Image_Test.class ); > suite.addTestSuite( ImageData_Test.class ); >Index: src/org/eclipse/swt/widgets/Slider_Test.java >=================================================================== >RCS file: src/org/eclipse/swt/widgets/Slider_Test.java >diff -N src/org/eclipse/swt/widgets/Slider_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/widgets/Slider_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,144 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.swt.widgets; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.rwt.lifecycle.PhaseId; >+import org.eclipse.swt.RWTFixture; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Point; >+ >+public class Slider_Test extends TestCase { >+ >+ protected void setUp() throws Exception { >+ RWTFixture.setUp(); >+ } >+ >+ protected void tearDown() throws Exception { >+ RWTFixture.tearDown(); >+ } >+ >+ public void testInitialValues() { >+ Display display = new Display(); >+ Shell shell = new Shell( display, SWT.NONE ); >+ Slider slider = new Slider( shell, SWT.NONE ); >+ assertEquals( 0, slider.getMinimum() ); >+ assertEquals( 100, slider.getMaximum() ); >+ assertEquals( 0, slider.getSelection() ); >+ assertEquals( 1, slider.getIncrement() ); >+ assertEquals( 10, slider.getPageIncrement() ); >+ assertEquals( 10, slider.getThumb() ); >+ } >+ >+ public void testValues() { >+ Display display = new Display(); >+ Shell shell = new Shell( display, SWT.NONE ); >+ Slider slider = new Slider( shell, SWT.NONE ); >+ >+ slider.setSelection( 34 ); >+ assertEquals( 34, slider.getSelection() ); >+ slider.setMinimum( 10 ); >+ assertEquals( 10, slider.getMinimum() ); >+ slider.setMaximum( 56 ); >+ assertEquals( 56, slider.getMaximum() ); >+ slider.setIncrement( 5 ); >+ assertEquals( 5, slider.getIncrement() ); >+ slider.setPageIncrement( 15 ); >+ assertEquals( 15, slider.getPageIncrement() ); >+ slider.setThumb( 13 ); >+ assertEquals( 13, slider.getThumb() ); >+ >+ slider.setMinimum( 40 ); >+ assertEquals( 40, slider.getMinimum() ); >+ assertEquals( 40, slider.getSelection() ); >+ >+ slider.setSelection( 55 ); >+ slider.setMaximum( 65 ); >+ assertEquals( 65, slider.getMaximum() ); >+ assertEquals( 43, slider.getSelection() ); >+ >+ slider.setMaximum( 30 ); >+ assertEquals( 65, slider.getMaximum() ); >+ >+ slider.setSelection( 10 ); >+ assertEquals( 40, slider.getSelection() ); >+ >+ slider.setSelection( -10 ); >+ assertEquals( 40, slider.getSelection() ); >+ >+ slider.setSelection( 73 ); >+ assertEquals( 52, slider.getSelection() ); >+ >+ slider.setPageIncrement( -15 ); >+ assertEquals( 15, slider.getPageIncrement() ); >+ >+ slider.setIncrement( -5 ); >+ assertEquals( 5, slider.getIncrement() ); >+ >+ slider.setThumb( -5 ); >+ assertEquals( 13, slider.getThumb() ); >+ >+ slider.setThumb( 0 ); >+ assertEquals( 13, slider.getThumb() ); >+ >+ slider.setThumb( 3 ); >+ assertEquals( 3, slider.getThumb() ); >+ >+ slider.setThumb( 30 ); >+ assertEquals( 25, slider.getThumb() ); >+ assertEquals( 40, slider.getSelection() ); >+ } >+ >+ public void testStyle() { >+ Display display = new Display(); >+ Shell shell = new Shell( display, SWT.NONE ); >+ // Test SWT.NONE >+ Slider slider = new Slider( shell, SWT.NONE ); >+ assertTrue( ( slider.getStyle() & SWT.HORIZONTAL ) != 0 ); >+ // Test SWT.BORDER >+ slider = new Slider( shell, SWT.BORDER ); >+ assertTrue( ( slider.getStyle() & SWT.HORIZONTAL ) != 0 ); >+ assertTrue( ( slider.getStyle() & SWT.BORDER ) != 0 ); >+ // Test SWT.VERTICAL >+ slider = new Slider( shell, SWT.VERTICAL ); >+ assertTrue( ( slider.getStyle() & SWT.VERTICAL ) != 0 ); >+ // Test combination of SWT.HORIZONTAL | SWT.VERTICAL >+ slider = new Slider( shell, SWT.HORIZONTAL | SWT.VERTICAL ); >+ assertTrue( ( slider.getStyle() & SWT.HORIZONTAL ) != 0 ); >+ assertTrue( ( slider.getStyle() & SWT.VERTICAL ) == 0 ); >+ } >+ >+ public void testDispose() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ Slider slider = new Slider( shell, SWT.NONE ); >+ slider.dispose(); >+ assertTrue( slider.isDisposed() ); >+ } >+ >+ public void testComputeSize() throws Exception { >+ RWTFixture.fakePhase( PhaseId.PROCESS_ACTION ); >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ Slider slider = new Slider( shell, SWT.HORIZONTAL ); >+ Point expected = new Point( 170, 16 ); >+ assertEquals( expected, slider.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); >+ >+ slider = new Slider( shell, SWT.VERTICAL ); >+ expected = new Point( 16, 170 ); >+ assertEquals( expected, slider.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); >+ >+ expected = new Point( 100, 100 ); >+ assertEquals( expected, slider.computeSize( 100, 100 ) ); >+ } >+} >#P org.eclipse.rap.demo >Index: theme1/theme.css >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.demo/theme1/theme.css,v >retrieving revision 1.17 >diff -u -r1.17 theme.css >--- theme1/theme.css 5 Dec 2008 08:40:08 -0000 1.17 >+++ theme1/theme.css 5 Dec 2008 15:42:14 -0000 >@@ -336,3 +336,44 @@ > Button[PUSH].special-red, Button[TOGGLE].special-red { > border: 2px solid red; > } >+ >+/* Slider */ >+ >+Slider { >+ background-color: #aaaaff; >+} >+ >+Slider-Thumb { >+ background-color: #ffaaaa; >+ border: 2px blue; >+} >+ >+Slider-Thumb:pressed { >+ background-color: #ff0000; >+} >+ >+Slider-MinButton { >+ background-color: #ffaaaa; >+ background-image: url( "/theme1/icons/slider-vbut-min-icon.gif" ); >+} >+ >+Slider-MinButton:hover { >+ background-color: #ffffff; >+} >+ >+Slider-MinButton:horizontal { >+ background-image: url( "/theme1/icons/slider-hbut-min-icon.gif" ); >+} >+ >+Slider-MaxButton { >+ background-color: #ffaaaa; >+ background-image: url( "/theme1/icons/slider-vbut-max-icon.gif" ); >+} >+ >+Slider-MaxButton:hover { >+ background-color: #ffffff; >+} >+ >+Slider-MaxButton:horizontal { >+ background-image: url( "/theme1/icons/slider-hbut-max-icon.gif" ); >+} >Index: src/org/eclipse/rap/demo/controls/ControlsDemo.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ControlsDemo.java,v >retrieving revision 1.49 >diff -u -r1.49 ControlsDemo.java >--- src/org/eclipse/rap/demo/controls/ControlsDemo.java 14 Nov 2008 14:00:28 -0000 1.49 >+++ src/org/eclipse/rap/demo/controls/ControlsDemo.java 5 Dec 2008 15:42:12 -0000 >@@ -52,6 +52,7 @@ > ensureMinTabHeight( topFolder ); > > final ExampleTab[] tabs = new ExampleTab[] { >+ new SliderTab( topFolder ), > new ButtonTab( topFolder ), > // new RequestTab( topFolder ), > new CBannerTab( topFolder ), >Index: src/org/eclipse/rap/demo/controls/SliderTab.java >=================================================================== >RCS file: src/org/eclipse/rap/demo/controls/SliderTab.java >diff -N src/org/eclipse/rap/demo/controls/SliderTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rap/demo/controls/SliderTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,191 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.rap.demo.controls; >+ >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CTabFolder; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.layout.RowLayout; >+import org.eclipse.swt.widgets.*; >+ >+public class SliderTab extends ExampleTab { >+ >+ private static final String PROP_CONTEXT_MENU = "contextMenu"; >+ private static final String PROP_SELECTION_LISTENER = "selectionListener"; >+ >+ Slider slider; >+ Spinner minimumSpinner, maximumSpinner, selectionSpinner, thumbSpinner, >+ incrementSpinner, pageIncrementSpinner; >+ >+ public SliderTab( final CTabFolder folder ) { >+ super( folder, "Slider" ); >+ setDefaultStyle( SWT.HORIZONTAL ); >+ } >+ >+ protected void createStyleControls( final Composite parent ) { >+ createStyleButton( parent, "HORIZONTAL", SWT.HORIZONTAL, SWT.RADIO, true ); >+ createStyleButton( parent, "VERTICAL", SWT.VERTICAL, SWT.RADIO, false ); >+ createVisibilityButton(); >+ createEnablementButton(); >+ createBgColorButton(); >+ createBgImageButton(); >+ minimumSpinner = createSpinnerControl( parent, "Minimum", >+ 0, 100000, 0 ); >+ minimumSpinner.addModifyListener( new ModifyListener() { >+ >+ public void modifyText( ModifyEvent event ) { >+ int minimum = minimumSpinner.getSelection(); >+ slider.setMinimum( minimum ); >+ } >+ } ); >+ maximumSpinner = createSpinnerControl( parent, "Maximum", >+ 0, 100000, 100 ); >+ maximumSpinner.addModifyListener( new ModifyListener() { >+ >+ public void modifyText( ModifyEvent event ) { >+ int maximum = maximumSpinner.getSelection(); >+ slider.setMaximum( maximum ); >+ } >+ } ); >+ selectionSpinner = createSpinnerControl( parent, "Selection", >+ 0, 100000, 0 ); >+ selectionSpinner.addModifyListener( new ModifyListener() { >+ >+ public void modifyText( ModifyEvent event ) { >+ int selection = selectionSpinner.getSelection(); >+ slider.setSelection( selection ); >+ } >+ } ); >+ thumbSpinner = createSpinnerControl( parent, "Thumb", >+ 1, 100000, 10 ); >+ thumbSpinner.addModifyListener( new ModifyListener() { >+ >+ public void modifyText( ModifyEvent event ) { >+ int thumb = thumbSpinner.getSelection(); >+ slider.setThumb( thumb ); >+ } >+ } ); >+ incrementSpinner = createSpinnerControl( parent, "Increment", >+ 0, 100000, 1 ); >+ incrementSpinner.addModifyListener( new ModifyListener() { >+ >+ public void modifyText( ModifyEvent event ) { >+ int increment = incrementSpinner.getSelection(); >+ slider.setIncrement( increment ); >+ } >+ } ); >+ pageIncrementSpinner = createSpinnerControl( parent, "Page Increment", >+ 0, 100000, 10 ); >+ pageIncrementSpinner.addModifyListener( new ModifyListener() { >+ >+ public void modifyText( ModifyEvent event ) { >+ int pageIncrement = pageIncrementSpinner.getSelection(); >+ slider.setPageIncrement( pageIncrement ); >+ } >+ } ); >+ createPropertyCheckbox( "Add Context Menu", PROP_CONTEXT_MENU ); >+ createPropertyCheckbox( "Add Selection Listener", PROP_SELECTION_LISTENER ); >+ } >+ >+ protected void createExampleControls( final Composite parent ) { >+ parent.setLayout( new RowLayout( SWT.VERTICAL ) ); >+ int style = getStyle(); >+ slider = new Slider( parent, style ); >+ if( hasCreateProperty( PROP_CONTEXT_MENU ) ) { >+ Menu sliderMenu = new Menu( slider ); >+ MenuItem sliderMenuItem = new MenuItem( sliderMenu, SWT.PUSH ); >+ sliderMenuItem.addSelectionListener( new SelectionAdapter() { >+ >+ public void widgetSelected( final SelectionEvent event ) { >+ String message = "You requested a context menu for the Slider"; >+ MessageDialog.openInformation( slider.getShell(), >+ "Information", >+ message ); >+ } >+ } ); >+ sliderMenuItem.setText( "Slider context menu item" ); >+ slider.setMenu( sliderMenu ); >+ } >+ if( hasCreateProperty( PROP_SELECTION_LISTENER ) ) { >+ slider.addSelectionListener( new SelectionListener() { >+ >+ public void widgetSelected( final SelectionEvent event ) { >+ String message = "Slider WidgetSelected! Current selection: " + slider.getSelection(); >+ log( message ); >+ selectionSpinner.setSelection( slider.getSelection() ); >+ } >+ >+ public void widgetDefaultSelected( final SelectionEvent event ) { >+ String message = "Slider WidgetDefaultSelected! Current selection: " + slider.getSelection(); >+ log( message ); >+ selectionSpinner.setSelection( slider.getSelection() ); >+ } >+ } ); >+ } >+ if( minimumSpinner != null ) { >+ slider.setMinimum( minimumSpinner.getSelection() ); >+ } >+ if( maximumSpinner != null ) { >+ slider.setMaximum( maximumSpinner.getSelection() ); >+ } >+ if( selectionSpinner != null ) { >+ slider.setSelection( selectionSpinner.getSelection() ); >+ } >+ if( thumbSpinner != null ) { >+ slider.setThumb( thumbSpinner.getSelection() ); >+ } >+ if( incrementSpinner != null ) { >+ slider.setIncrement( incrementSpinner.getSelection() ); >+ } >+ if( pageIncrementSpinner != null ) { >+ slider.setPageIncrement( pageIncrementSpinner.getSelection() ); >+ } >+ registerControl( slider ); >+ } >+ >+ protected Button createStyleButton( final Composite parent, >+ final String name, >+ final int style, >+ final int buttonStyle, >+ final boolean checked ) >+ { >+ Button button = new Button( parent, buttonStyle ); >+ button.setText( name ); >+ button.addSelectionListener( new SelectionAdapter() { >+ >+ public void widgetSelected( final SelectionEvent event ) { >+ createNew(); >+ } >+ } ); >+ button.setData( "style", new Integer( style ) ); >+ button.setSelection( checked ); >+ return button; >+ } >+ >+ private Spinner createSpinnerControl( final Composite parent, >+ final String labelText, >+ final int minimum, >+ final int maximum, >+ final int selection ) { >+ Composite composite = new Composite( parent, SWT.NONE ); >+ composite.setLayout( new GridLayout( 4, false ) ); >+ Label label = new Label( composite, SWT.NONE ); >+ label.setText( labelText ); >+ final Spinner spinner = new Spinner( composite, SWT.BORDER ); >+ spinner.setSelection( selection ); >+ spinner.setMinimum( minimum ); >+ spinner.setMaximum( maximum ); >+ return spinner; >+ } >+} >#P org.eclipse.rap.rwt.q07.test >Index: src/org/eclipse/RWTQ07TestSuite.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.q07.test/src/org/eclipse/RWTQ07TestSuite.java,v >retrieving revision 1.11 >diff -u -r1.11 RWTQ07TestSuite.java >--- src/org/eclipse/RWTQ07TestSuite.java 5 Dec 2008 10:57:30 -0000 1.11 >+++ src/org/eclipse/RWTQ07TestSuite.java 5 Dec 2008 15:42:21 -0000 >@@ -40,6 +40,7 @@ > import org.eclipse.swt.internal.widgets.sashkit.SashLCA_Test; > import org.eclipse.swt.internal.widgets.scalekit.ScaleLCA_Test; > import org.eclipse.swt.internal.widgets.shellkit.ShellLCA_Test; >+import org.eclipse.swt.internal.widgets.sliderkit.SliderLCA_Test; > import org.eclipse.swt.internal.widgets.spinnerkit.SpinnerLCA_Test; > import org.eclipse.swt.internal.widgets.tabfolderkit.TabFolderLCA_Test; > import org.eclipse.swt.internal.widgets.tablecolumnkit.TableColumnLCA_Test; >@@ -124,6 +125,7 @@ > suite.addTestSuite( DateTimeLCA_Test.class ); > suite.addTestSuite( ExpandBarLCA_Test.class ); > suite.addTestSuite( ExpandItemLCA_Test.class ); >+ suite.addTestSuite( SliderLCA_Test.class ); > > return suite; > } >Index: src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA_Test.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA_Test.java >diff -N src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,168 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.swt.internal.widgets.sliderkit; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.rwt.Fixture; >+import org.eclipse.rwt.graphics.Graphics; >+import org.eclipse.rwt.internal.lifecycle.JSConst; >+import org.eclipse.rwt.lifecycle.IWidgetAdapter; >+import org.eclipse.rwt.lifecycle.WidgetUtil; >+import org.eclipse.swt.RWTFixture; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.internal.widgets.Props; >+import org.eclipse.swt.widgets.*; >+ >+public class SliderLCA_Test extends TestCase { >+ >+ public void testSliderPreserveValues() { >+ Display display = new Display(); >+ Composite shell = new Shell( display, SWT.NONE ); >+ Slider slider = new Slider( shell, SWT.HORIZONTAL ); >+ RWTFixture.markInitialized( display ); >+ // Test preserved minimum, maximum, >+ // selection, increment, pageIncrement and thumb >+ RWTFixture.preserveWidgets(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( slider ); >+ Integer minimum >+ = ( Integer )adapter.getPreserved( SliderLCA.PROP_MINIMUM ); >+ assertEquals( 0, minimum.intValue() ); >+ Integer maximum >+ = ( Integer )adapter.getPreserved( SliderLCA.PROP_MAXIMUM ); >+ assertEquals( 100, maximum.intValue() ); >+ Integer selection >+ = ( Integer )adapter.getPreserved( SliderLCA.PROP_SELECTION ); >+ assertEquals( 0, selection.intValue() ); >+ Integer increment >+ = ( Integer )adapter.getPreserved( SliderLCA.PROP_INCREMENT ); >+ assertEquals( 1, increment.intValue() ); >+ Integer pageIncrement >+ = ( Integer )adapter.getPreserved( SliderLCA.PROP_PAGE_INCREMENT ); >+ assertEquals( 10, pageIncrement.intValue() ); >+ Integer thumb >+ = ( Integer )adapter.getPreserved( SliderLCA.PROP_THUMB ); >+ assertEquals( 10, thumb.intValue() ); >+ RWTFixture.clearPreserved(); >+ // Test preserved control properties >+ testPreserveControlProperties( slider ); >+ // Test preserved selection listeners >+ testPreserveSelectionListener( slider ); >+ display.dispose(); >+ } >+ >+ public void testSelectionEvent() { >+ Display display = new Display(); >+ Composite shell = new Shell( display, SWT.NONE ); >+ Slider slider = new Slider( shell, SWT.HORIZONTAL ); >+ testSelectionEvent( slider ); >+ } >+ >+ private void testPreserveControlProperties( final Slider slider ) { >+ // bound >+ Rectangle rectangle = new Rectangle( 10, 10, 10, 10 ); >+ slider.setBounds( rectangle ); >+ RWTFixture.preserveWidgets(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( rectangle, adapter.getPreserved( Props.BOUNDS ) ); >+ RWTFixture.clearPreserved(); >+ // enabled >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( Boolean.TRUE, adapter.getPreserved( Props.ENABLED ) ); >+ RWTFixture.clearPreserved(); >+ slider.setEnabled( false ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( Boolean.FALSE, adapter.getPreserved( Props.ENABLED ) ); >+ RWTFixture.clearPreserved(); >+ // visible >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( Boolean.TRUE, adapter.getPreserved( Props.VISIBLE ) ); >+ RWTFixture.clearPreserved(); >+ slider.setVisible( false ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( Boolean.FALSE, adapter.getPreserved( Props.VISIBLE ) ); >+ RWTFixture.clearPreserved(); >+ // menu >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( null, adapter.getPreserved( Props.MENU ) ); >+ RWTFixture.clearPreserved(); >+ Menu menu = new Menu( slider ); >+ MenuItem item = new MenuItem( menu, SWT.NONE ); >+ item.setText( "1 Item" ); >+ slider.setMenu( menu ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( menu, adapter.getPreserved( Props.MENU ) ); >+ RWTFixture.clearPreserved(); >+ //foreground background font >+ Color background = Graphics.getColor( 122, 33, 203 ); >+ slider.setBackground( background ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ assertEquals( background, adapter.getPreserved( Props.BACKGROUND ) ); >+ RWTFixture.clearPreserved(); >+ } >+ >+ private void testPreserveSelectionListener( final Slider slider ) { >+ RWTFixture.preserveWidgets(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( slider ); >+ Boolean hasListeners >+ = ( Boolean )adapter.getPreserved( Props.SELECTION_LISTENERS ); >+ assertEquals( Boolean.FALSE, hasListeners ); >+ RWTFixture.clearPreserved(); >+ SelectionListener selectionListener = new SelectionAdapter() { }; >+ slider.addSelectionListener( selectionListener ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( slider ); >+ hasListeners >+ = ( Boolean )adapter.getPreserved( Props.SELECTION_LISTENERS ); >+ assertEquals( Boolean.TRUE, hasListeners ); >+ RWTFixture.clearPreserved(); >+ } >+ >+ private void testSelectionEvent( final Slider slider ) { >+ final StringBuffer log = new StringBuffer(); >+ SelectionListener selectionListener = new SelectionAdapter() { >+ public void widgetSelected( SelectionEvent event ) { >+ assertEquals( slider, event.getSource() ); >+ assertEquals( null, event.item ); >+ assertEquals( SWT.NONE, event.detail ); >+ assertEquals( 0, event.x ); >+ assertEquals( 0, event.y ); >+ assertEquals( 0, event.width ); >+ assertEquals( 0, event.height ); >+ assertEquals( true, event.doit ); >+ log.append( "widgetSelected" ); >+ } >+ }; >+ slider.addSelectionListener( selectionListener ); >+ String dateTimeId = WidgetUtil.getId( slider ); >+ Fixture.fakeRequestParam( JSConst.EVENT_WIDGET_SELECTED, dateTimeId ); >+ RWTFixture.readDataAndProcessAction( slider ); >+ assertEquals( "widgetSelected", log.toString() ); >+ } >+ >+ protected void setUp() throws Exception { >+ RWTFixture.setUp(); >+ } >+ >+ protected void tearDown() throws Exception { >+ RWTFixture.tearDown(); >+ } >+} >#P org.eclipse.rap.rwt.q07 >Index: src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java,v >retrieving revision 1.9 >diff -u -r1.9 QooxdooResourcesUtil.java >--- src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java 30 Nov 2008 12:52:57 -0000 1.9 >+++ src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java 5 Dec 2008 15:42:23 -0000 >@@ -137,6 +137,8 @@ > = "org/eclipse/swt/widgets/ExpandBar.js"; > private static final String EXPAND_ITEM_JS > = "org/eclipse/swt/widgets/ExpandItem.js"; >+ private static final String SLIDER_JS >+ = "org/eclipse/swt/widgets/Slider.js"; > > private QooxdooResourcesUtil() { > // prevent intance creation >@@ -216,6 +218,7 @@ > register( CALENDAR_JS, compress ); > register( EXPAND_BAR_JS, compress ); > register( EXPAND_ITEM_JS, compress ); >+ register( SLIDER_JS, compress ); > > // register contributions > registerContributions(); >Index: js/org/eclipse/swt/theme/AppearancesBase.js >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.js,v >retrieving revision 1.59 >diff -u -r1.59 AppearancesBase.js >--- js/org/eclipse/swt/theme/AppearancesBase.js 5 Dec 2008 08:39:21 -0000 1.59 >+++ js/org/eclipse/swt/theme/AppearancesBase.js 5 Dec 2008 15:42:23 -0000 >@@ -1883,6 +1883,83 @@ > result.cursor = states.disabled ? "default" : "pointer"; > return result; > } >+ }, >+ >+ // ------------------------------------------------------------------------ >+ // Slider >+ >+ "slider" : { >+ style : function( states ) { >+ var tv = new org.eclipse.swt.theme.ThemeValues( states ); >+ return { >+ border : tv.getCssBorder( "*", "border" ), >+ font : tv.getCssFont( "*", "font" ), >+ textColor : tv.getCssColor( "*", "color" ), >+ backgroundColor : tv.getCssColor( "Slider", "background-color" ) >+ } >+ } >+ }, >+ >+ "slider-line" : { >+ include : "atom", >+ style : function( states ) { >+ var result = {}; >+ result.backgroundColor = "#eeeeee"; >+ result.opacity = 0; >+ // Assigning icon for proper visualization in IE >+ result.icon = "static/image/blank.gif"; >+ if( states.horizontal ){ >+ result.left = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ } else { >+ result.top = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ } >+ return result; >+ } >+ }, >+ >+ "slider-thumb" : { >+ include : "atom", >+ style : function( states ) { >+ var tv = new org.eclipse.swt.theme.ThemeValues( states ); >+ var result = {}; >+ result.backgroundColor = tv.getCssColor( "Slider-Thumb", "background-color" ); >+ result.border = tv.getCssBorder( "Slider-Thumb", "border" ); >+ // Assigning icon for proper visualization in IE >+ result.icon = "static/image/blank.gif"; >+ return result; >+ } >+ }, >+ >+ "slider-min-button" : { >+ include : "button", >+ style : function( states ) { >+ var tv = new org.eclipse.swt.theme.ThemeValues( states ); >+ var result = {}; >+ result.backgroundColor = tv.getCssColor( "Slider-MinButton", "background-color" ); >+ result.icon = tv.getCssImage( "Slider-MinButton", "background-image" ); >+ if( states.horizontal ){ >+ result.width = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ } else { >+ result.height = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ } >+ return result; >+ } >+ }, >+ >+ "slider-max-button" : { >+ include : "button", >+ style : function( states ) { >+ var tv = new org.eclipse.swt.theme.ThemeValues( states ); >+ var result = {}; >+ result.backgroundColor = tv.getCssColor( "Slider-MaxButton", "background-color" ); >+ result.icon = tv.getCssImage( "Slider-MaxButton", "background-image" ); >+ if( states.horizontal ){ >+ result.width = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ } else { >+ result.height = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ } >+ return result; >+ } > } > } > } ); >Index: js/org/eclipse/swt/widgets/Slider.js >=================================================================== >RCS file: js/org/eclipse/swt/widgets/Slider.js >diff -N js/org/eclipse/swt/widgets/Slider.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/org/eclipse/swt/widgets/Slider.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,537 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Innoopract Informationssysteme GmbH. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 which accompanies this distribution, >+ * and is available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+ >+/** >+ * This class provides the client-side counterpart for >+ * org.eclipse.swt.widgets.Slider. >+ */ >+qx.Class.define( "org.eclipse.swt.widgets.Slider", { >+ extend : qx.ui.layout.CanvasLayout, >+ >+ construct : function( style ) { >+ this.base( arguments ); >+ this.setAppearance( "slider" ); >+ // Get styles >+ this._horizontal = qx.lang.String.contains( style, "horizontal" ); >+ // >+ this._hasSelectionListener = false; >+ // Flag indicating that the next request can be sent >+ this._readyToSendChanges = true; >+ // Default values >+ this._selection = 0; >+ this._minimum = 0; >+ this._maximum = 100; >+ this._increment = 1; >+ this._pageIncrement = 10; >+ this._thumbWidth = 10; >+ this._pxStep = 1.38; >+ this._thumbPressed = false; >+ // _interactionId: Indicates what element is pressed - minButton, >+ // maxButton or area behind the thumb (line) >+ this._interactionId; >+ // _mousePos: Stores the mouse position, needed when calculating the >+ // thumb translation after click on the area behind the thumb (line) >+ this._mousePos; >+ // Timer: used for continuous scrolling >+ this._scrollTimer = new qx.client.Timer( 100 ); >+ this._scrollTimer.addEventListener( "interval", >+ this._onScrollTimerInterval, >+ this ); >+ // _scrollReadyToStart: Flag for starting the scrollTimer >+ this._scrollReadyToStart = false; >+ // Line - the area behind the thumb >+ this._line = new qx.ui.basic.Atom; >+ if( this._horizontal ) { >+ this._line.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); >+ } >+ this._line.setAppearance( "slider-line" ); >+ this._line.addEventListener( "mousedown", this._onLineMouseDown, this ); >+ this._line.addEventListener( "mouseup", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._line.addEventListener( "mousemove", this._onLineMouseMove, this ); >+ this._line.addEventListener( "mouseout", >+ this._onInteractionMouseUpOut, >+ this ); >+ this.add( this._line ); >+ // Thumb >+ this._thumb = new qx.ui.basic.Atom; >+ if( this._horizontal ) { >+ this._thumb.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); >+ } >+ this._thumb.setAppearance( "slider-thumb" ); >+ this._thumb.addEventListener( "mousedown", this._onThumbMouseDown, this ); >+ this._thumb.addEventListener( "mousemove", this._onThumbMouseMove, this ); >+ this._thumb.addEventListener( "mouseup", this._onThumbMouseUp, this ); >+ // Fix IE Styling issues >+ org.eclipse.swt.WidgetUtil.fixIEBoxHeight( this._thumb ); >+ this.add( this._thumb ); >+ // Thumb offset >+ this._thumbOffset = 0; >+ // Min button >+ this._minButton = new qx.ui.form.Button; >+ if( this._horizontal ) { >+ this._minButton.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); >+ } >+ this._minButton.addState( "rwt_PUSH" ); >+ this._minButton.setAppearance( "slider-min-button" ); >+ this._minButton.addEventListener( "mousedown", >+ this._onMinButtonMouseDown, >+ this ); >+ this._minButton.addEventListener( "mouseup", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._minButton.addEventListener( "mouseout", >+ this._onInteractionMouseUpOut, >+ this ); >+ // Fix IE Styling issues >+ org.eclipse.swt.WidgetUtil.fixIEBoxHeight( this._minButton ); >+ this.add( this._minButton ); >+ // Max button >+ this._maxButton = new qx.ui.form.Button; >+ if( this._horizontal ) { >+ this._maxButton.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); >+ } >+ this._maxButton.addState( "rwt_PUSH" ); >+ this._maxButton.setAppearance( "slider-max-button" ); >+ this._maxButton.addEventListener( "mousedown", >+ this._onMaxButtonMouseDown, >+ this ); >+ this._maxButton.addEventListener( "mouseup", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._maxButton.addEventListener( "mouseout", >+ this._onInteractionMouseUpOut, >+ this ); >+ // Fix IE Styling issues >+ org.eclipse.swt.WidgetUtil.fixIEBoxHeight( this._maxButton ); >+ this.add( this._maxButton ); >+ // Add events listeners >+ this.addEventListener( "changeWidth", this._onChangeSize, this ); >+ this.addEventListener( "changeHeight", this._onChangeSize, this ); >+ this.addEventListener( "contextmenu", this._onContextMenu, this ); >+ this.addEventListener( "changeEnabled", this._onChangeEnabled, this ); >+ }, >+ >+ destruct : function() { >+ this._line.removeEventListener( "mousedown", this._onLineMouseDown, this ); >+ this._line.removeEventListener( "mouseup", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._line.removeEventListener( "mousemove", this._onLineMouseMove, this ); >+ this._line.removeEventListener( "mouseout", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._minButton.removeEventListener( "mousedown", >+ this._onMinButtonMouseDown, >+ this ); >+ this._minButton.removeEventListener( "mouseup", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._minButton.removeEventListener( "mouseout", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._maxButton.removeEventListener( "mousedown", >+ this._onMaxButtonMouseDown, >+ this ); >+ this._maxButton.removeEventListener( "mouseup", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._maxButton.removeEventListener( "mouseout", >+ this._onInteractionMouseUpOut, >+ this ); >+ this._scrollTimer.removeEventListener( "interval", >+ this._onScrollTimerInterval, >+ this ); >+ this._thumb.removeEventListener( "mousedown", this._onThumbMouseDown, this ); >+ this._thumb.removeEventListener( "mousemove", this._onThumbMouseMove, this ); >+ this._thumb.removeEventListener( "mouseup", this._onThumbMouseUp, this ); >+ this.removeEventListener( "changeWidth", this._onChangeSize, this ); >+ this.removeEventListener( "changeHeight", this._onChangeSize, this ); >+ this.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this.removeEventListener( "changeEnabled", this._onChangeEnabled, this ); >+ if( this._scrollTimer != null ) { >+ this._scrollTimer.stop(); >+ this._scrollTimer.dispose(); >+ } >+ this._scrollTimer = null; >+ // this._disposeObjects( "_line", "_thumb", "_minButton", "_maxButton" ); >+ this._line.dispose(); >+ this._thumb.dispose(); >+ this._minButton.dispose(); >+ this._maxButton.dispose(); >+ }, >+ >+ statics : { >+ STATE_HORIZONTAL : "horizontal", >+ BUTTON_WIDTH : 16, >+ STATE_PRESSED : "pressed" >+ }, >+ >+ members : { >+ _onChangeSize : function( evt ) { >+ if( this._horizontal ) { >+ var left = this.getWidth() >+ - org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ this._maxButton.setLeft( left ); >+ } else { >+ var top = this.getHeight() >+ - org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ this._maxButton.setTop( top ); >+ } >+ this._updateLineSize(); >+ this._updateButtonsSize(); >+ this._updateThumbSize(); >+ }, >+ >+ _onContextMenu : function( evt ) { >+ var menu = this.getContextMenu(); >+ if( menu != null ) { >+ menu.setLocation( evt.getPageX(), evt.getPageY() ); >+ menu.setOpener( this ); >+ menu.show(); >+ evt.stopPropagation(); >+ } >+ }, >+ >+ _onChangeEnabled : function( evt ) { >+ this._thumb.setVisibility( evt.getValue() ); >+ }, >+ >+ _onLineMouseDown : function( evt ) { >+ this._interactionId = "line"; >+ var pxSel; >+ var sel; >+ var thumbMov; // Thumb movement after interaction >+ if( evt.isLeftButtonPressed() ) { >+ if( this._horizontal ) { >+ pxSel = this._thumb.getLeft() + ( this._thumb.getWidth() ) / 2; >+ this._mousePos = evt.getPageX() >+ - qx.html.Location.getClientBoxLeft( this.getElement() ); >+ thumbMov = this._pageIncrement * this._pxStep >+ + this._thumb.getWidth() / 2; >+ } else { >+ pxSel = this._thumb.getTop() + ( this._thumb.getHeight() ) / 2; >+ this._mousePos = evt.getPageY() >+ - qx.html.Location.getClientBoxTop( this.getElement() ); >+ thumbMov = this._pageIncrement * this._pxStep >+ + this._thumb.getHeight() / 2; >+ } >+ if( this._mousePos > pxSel ) { >+ sel = this._selection + this._pageIncrement; >+ } else { >+ sel = this._selection - this._pageIncrement; >+ } >+ // Check whether to start auto-repeat interaction >+ if( Math.abs( this._mousePos - pxSel ) > thumbMov ) { >+ this._scrollReadyToStart = true; >+ } >+ if( sel < this._minimum ) { >+ sel = this._minimum; >+ } >+ if( sel > ( this._maximum - this._thumbWidth ) ) { >+ sel = this._maximum - this._thumbWidth; >+ } >+ this.setSelection( sel ); >+ } >+ }, >+ >+ _onLineMouseMove : function( evt ) { >+ if( this._horizontal ) { >+ this._mousePos = evt.getPageX() >+ - qx.html.Location.getClientBoxLeft( this.getElement() ); >+ } else { >+ this._mousePos = evt.getPageY() >+ - qx.html.Location.getClientBoxTop( this.getElement() ); >+ } >+ }, >+ >+ _onMinButtonMouseDown : function( evt ) { >+ this._interactionId = "minButton"; >+ var sel; >+ if( evt.isLeftButtonPressed() ) { >+ this._scrollReadyToStart = true; >+ sel = this._selection - this._increment; >+ if( sel < this._minimum ) { >+ sel = this._minimum; >+ } >+ if( sel > ( this._maximum - this._thumbWidth ) ) { >+ sel = this._maximum - this._thumbWidth; >+ } >+ this.setSelection( sel ); >+ } >+ }, >+ >+ _onMaxButtonMouseDown : function( evt ) { >+ this._interactionId = "maxButton"; >+ var sel; >+ if( evt.isLeftButtonPressed() ) { >+ this._scrollReadyToStart = true; >+ sel = this._selection + this._increment; >+ if( sel < this._minimum ) { >+ sel = this._minimum; >+ } >+ if( sel > ( this._maximum - this._thumbWidth ) ) { >+ sel = this._maximum - this._thumbWidth; >+ } >+ this.setSelection( sel ); >+ } >+ }, >+ >+ _onInteractionMouseUpOut : function( evt ) { >+ this._scrollReadyToStart = false; >+ this._scrollTimer.stop(); >+ }, >+ >+ _scrollTimerStart : function() { >+ if( this._scrollReadyToStart ) { >+ this._scrollTimer.start(); >+ } >+ }, >+ >+ _onScrollTimerInterval : function( evt ) { >+ var sel; >+ switch( this._interactionId ) { >+ case "minButton": >+ sel = this._selection - this._increment; >+ break; >+ case "maxButton": >+ sel = this._selection + this._increment; >+ break; >+ case "line": >+ var pxSel; >+ var thumbMov; // Thumb movement after interaction >+ if( this._horizontal ) { >+ pxSel = this._thumb.getLeft() + this._thumb.getWidth() / 2; >+ thumbMov = this._pageIncrement * this._pxStep >+ + this._thumb.getWidth() / 2; >+ } else { >+ pxSel = this._thumb.getTop() + this._thumb.getHeight() / 2; >+ thumbMov = this._pageIncrement * this._pxStep >+ + this._thumb.getHeight() / 2; >+ } >+ if( this._mousePos > pxSel ) { >+ sel = this._selection + this._pageIncrement; >+ } else { >+ sel = this._selection - this._pageIncrement; >+ } >+ // Check whether to stop auto-repeat interaction >+ if( Math.abs( this._mousePos - pxSel ) <= thumbMov ) { >+ this._scrollReadyToStart = false; >+ this._scrollTimer.stop(); >+ } >+ break; >+ } >+ if( sel < this._minimum ) { >+ sel = this._minimum; >+ } >+ if( sel > ( this._maximum - this._thumbWidth ) ) { >+ sel = this._maximum - this._thumbWidth; >+ } >+ this.setSelection( sel ); >+ >+ if( this._readyToSendChanges ) { >+ this._readyToSendChanges = false; >+ // Send changes >+ qx.client.Timer.once( this._sendChanges, this, 500 ); >+ } >+ }, >+ >+ _onThumbMouseDown : function( evt ) { >+ var mousePos; >+ this._thumb.addState( org.eclipse.swt.widgets.Slider.STATE_PRESSED ); >+ this._thumbPressed = true; >+ if( evt.isLeftButtonPressed() ) { >+ if( this._horizontal ) { >+ mousePos = evt.getPageX() >+ - qx.html.Location.getClientBoxLeft( this.getElement() ); >+ this._thumbOffset = mousePos - this._thumb.getLeft(); >+ } else { >+ mousePos = evt.getPageY() >+ - qx.html.Location.getClientBoxTop( this.getElement() ); >+ this._thumbOffset = mousePos - this._thumb.getTop(); >+ } >+ this._thumb.setCapture( true ); >+ } >+ }, >+ >+ _onThumbMouseMove : function( evt ) { >+ var mousePos; >+ if( this._thumb.getCapture() ) { >+ if( this._horizontal ) { >+ mousePos = evt.getPageX() >+ - qx.html.Location.getClientBoxLeft( this.getElement() ); >+ } else { >+ mousePos = evt.getPageY() >+ - qx.html.Location.getClientBoxTop( this.getElement() ); >+ } >+ var sel = this._getSelectionFromThumbPosition( mousePos >+ - this._thumbOffset ); >+ if( this._selection != sel ) { >+ this.setSelection( sel ); >+ if( this._readyToSendChanges ) { >+ this._readyToSendChanges = false; >+ // Send changes >+ qx.client.Timer.once( this._sendChanges, this, 500 ); >+ } >+ } >+ } >+ }, >+ >+ _onThumbMouseUp : function( evt ) { >+ this._scrollTimer.stop(); >+ this._thumbPressed = false; >+ this._thumb.setCapture( false ); >+ this._thumb.removeState( org.eclipse.swt.widgets.Slider.STATE_PRESSED ); >+ }, >+ >+ _updateThumbSize : function() { >+ if( this._horizontal ) { >+ this._thumb.setWidth( this._thumbWidth * this._line.getWidth() >+ / ( this._maximum - this._minimum ) ); >+ this._thumb.setHeight( this.getHeight() ); >+ } else { >+ this._thumb.setWidth( this.getWidth() ); >+ this._thumb.setHeight( this._thumbWidth * this._line.getHeight() >+ / ( this._maximum - this._minimum ) ); >+ } >+ this._updateStep(); >+ }, >+ >+ _updateStep : function() { >+ var padding; >+ var numSteps = this._maximum - this._minimum - this._thumbWidth; >+ if( numSteps != 0 ) { >+ if( this._horizontal ) { >+ padding = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH >+ + ( this._thumb.getWidth() ) / 2; >+ this._pxStep = ( this.getWidth() - 2 * padding ) / numSteps; >+ } else { >+ padding = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH >+ + ( this._thumb.getHeight() ) / 2; >+ this._pxStep = ( this.getHeight() - 2 * padding ) / numSteps; >+ } >+ } else { >+ this._pxStep = 0; >+ } >+ this._updateThumbPosition(); >+ }, >+ >+ _updateThumbPosition : function() { >+ var pos; >+ if( this._selection >= ( this._maximum - this._thumbWidth ) ) { >+ pos = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH + this._pxStep >+ * ( this._maximum - this._minimum - this._thumbWidth ); >+ this._selection = this._maximum - this._thumbWidth; >+ } else if( this._selection <= this._minimum ) { >+ pos = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; >+ this._selection = this._minimum; >+ } else { >+ pos = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH + this._pxStep >+ * ( this._selection - this._minimum ); >+ } >+ if( this._horizontal ) { >+ this._thumb.setLeft( pos ); >+ } else { >+ this._thumb.setTop( pos ); >+ } >+ if( this._readyToSendChanges ) { >+ this._readyToSendChanges = false; >+ // Send changes >+ qx.client.Timer.once( this._sendChanges, this, 500 ); >+ // Starting the auto repeat functionality after a 250 ms delay >+ qx.client.Timer.once( this._scrollTimerStart, this, 250 ); >+ } >+ }, >+ >+ _updateLineSize : function() { >+ if( this._horizontal ) { >+ this._line.setWidth( this.getWidth() - 2 >+ * org.eclipse.swt.widgets.Slider.BUTTON_WIDTH ); >+ this._line.setHeight( this.getHeight() ); >+ } else { >+ this._line.setWidth( this.getWidth() ); >+ this._line.setHeight( this.getHeight() - 2 >+ * org.eclipse.swt.widgets.Slider.BUTTON_WIDTH ); >+ } >+ }, >+ >+ _updateButtonsSize : function() { >+ if( this._horizontal ) { >+ this._minButton.setHeight( this.getHeight() ); >+ this._maxButton.setHeight( this.getHeight() ); >+ } else { >+ this._minButton.setWidth( this.getWidth() ); >+ this._maxButton.setWidth( this.getWidth() ); >+ } >+ }, >+ >+ _getSelectionFromThumbPosition : function( position ) { >+ var sel = ( position - org.eclipse.swt.widgets.Slider.BUTTON_WIDTH ) >+ / this._pxStep + this._minimum; >+ sel = Math.round( sel ); >+ var sel_final; >+ if( sel < this._minimum ) { >+ sel_final = this._minimum; >+ } else if( sel > ( this._maximum - this._thumbWidth ) ) { >+ sel_final = this._maximum - this._thumbWidth; >+ } else { >+ sel_final = sel; >+ } >+ return sel_final; >+ }, >+ >+ _sendChanges : function() { >+ if( !org_eclipse_rap_rwt_EventUtil_suspend ) { >+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance(); >+ var req = org.eclipse.swt.Request.getInstance(); >+ var id = widgetManager.findIdByWidget( this ); >+ req.addParameter( id + ".selection", this._selection ); >+ if( this._hasSelectionListener ) { >+ req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >+ req.send(); >+ } >+ this._readyToSendChanges = true; >+ } >+ }, >+ >+ setHasSelectionListener : function( value ) { >+ this._hasSelectionListener = value; >+ }, >+ >+ setSelection : function( value ) { >+ this._selection = value; >+ this._updateThumbPosition(); >+ }, >+ >+ setMinimum : function( value ) { >+ this._minimum = value; >+ this._updateThumbSize(); >+ }, >+ >+ setMaximum : function( value ) { >+ this._maximum = value; >+ this._updateThumbSize(); >+ }, >+ >+ setIncrement : function( value ) { >+ this._increment = value; >+ }, >+ >+ setPageIncrement : function( value ) { >+ this._pageIncrement = value; >+ }, >+ >+ setThumb : function( value ) { >+ this._thumbWidth = value; >+ this._updateThumbSize(); >+ } >+ } >+} ); >Index: src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA.java >diff -N src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,190 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.swt.internal.widgets.sliderkit; >+ >+import java.io.IOException; >+ >+import org.eclipse.rwt.lifecycle.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.internal.widgets.Props; >+import org.eclipse.swt.widgets.Slider; >+import org.eclipse.swt.widgets.Widget; >+ >+ >+public class SliderLCA extends AbstractWidgetLCA { >+ >+ // Property names for preserveValues >+ static final String PROP_SELECTION = "selection"; >+ static final String PROP_MAXIMUM = "maximum"; >+ static final String PROP_MINIMUM = "minimum"; >+ static final String PROP_PAGE_INCREMENT = "pageIncrement"; >+ static final String PROP_INCREMENT = "increment"; >+ static final String PROP_THUMB = "thumb"; >+ >+ // Default values >+ static final Integer DEFAULT_SELECTION = new Integer( 0 ); >+ static final Integer DEFAULT_MAXIMUM = new Integer( 100 ); >+ static final Integer DEFAULT_MINIMUM = new Integer( 0 ); >+ static final Integer DEFAULT_PAGE_INCREMENT = new Integer( 10 ); >+ static final Integer DEFAULT_INCREMENT = new Integer( 1 ); >+ static final Integer DEFAULT_THUMB = new Integer( 10 ); >+ >+ public void preserveValues( final Widget widget ) { >+ Slider slider = ( Slider )widget; >+ ControlLCAUtil.preserveValues( slider ); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( slider ); >+ boolean hasListeners = SelectionEvent.hasListener( slider ); >+ adapter.preserve( Props.SELECTION_LISTENERS, >+ Boolean.valueOf( hasListeners ) ); >+ adapter.preserve( PROP_SELECTION, >+ new Integer( slider.getSelection() ) ); >+ adapter.preserve( PROP_MAXIMUM, >+ new Integer( slider.getMaximum() ) ); >+ adapter.preserve( PROP_MINIMUM, >+ new Integer( slider.getMinimum() ) ); >+ adapter.preserve( PROP_PAGE_INCREMENT, >+ new Integer( slider.getPageIncrement() ) ); >+ adapter.preserve( PROP_INCREMENT, >+ new Integer( slider.getIncrement() ) ); >+ adapter.preserve( PROP_THUMB, >+ new Integer( slider.getThumb() ) ); >+ } >+ >+ public void readData( final Widget widget ) { >+ Slider slider = ( Slider )widget; >+ String value = WidgetLCAUtil.readPropertyValue( slider, PROP_SELECTION ); >+ if( value != null ) { >+ slider.setSelection( Integer.parseInt( value ) ); >+ } >+ ControlLCAUtil.processSelection( slider, null, true ); >+ } >+ >+ public void renderInitialization( final Widget widget ) throws IOException { >+ Slider slider = ( Slider )widget; >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ String style = ""; >+ if( ( slider.getStyle() & SWT.HORIZONTAL ) != 0 ) { >+ style = "horizontal"; >+ } else { >+ style = "vertical"; >+ } >+ Object[] args = new Object[]{ >+ style >+ }; >+ writer.newWidget( "org.eclipse.swt.widgets.Slider", args ); >+ WidgetLCAUtil.writeCustomVariant( widget ); >+ ControlLCAUtil.writeStyleFlags( slider ); >+ } >+ >+ >+ public void renderChanges( final Widget widget ) throws IOException { >+ Slider slider = ( Slider )widget; >+ ControlLCAUtil.writeChanges( slider ); >+ writeMaximum( slider ); >+ writeMinimum( slider ); >+ writePageIncrement( slider ); >+ writeSelection( slider ); >+ writeIncrement( slider ); >+ writeThumb( slider ); >+ writeListener( slider ); >+ } >+ >+ public void renderDispose( final Widget widget ) throws IOException { >+ JSWriter writer = JSWriter.getWriterFor( widget ); >+ writer.dispose(); >+ } >+ >+ public void createResetHandlerCalls( final String typePoolId ) >+ throws IOException >+ { >+ } >+ >+ public String getTypePoolId( final Widget widget ) { >+ return null; >+ } >+ >+ ////////////////// >+ // Helping methods >+ private void writeMaximum( final Slider slider ) throws IOException { >+ Integer newValue = new Integer( slider.getMaximum() ); >+ if( WidgetLCAUtil.hasChanged( slider, >+ PROP_MAXIMUM, >+ newValue, >+ DEFAULT_MAXIMUM ) ) >+ { >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ writer.set( PROP_MAXIMUM, newValue ); >+ } >+ } >+ >+ private void writeMinimum( final Slider slider ) throws IOException { >+ Integer newValue = new Integer( slider.getMinimum() ); >+ String prop = PROP_MINIMUM; >+ Integer defValue = DEFAULT_MINIMUM; >+ if( WidgetLCAUtil.hasChanged( slider, prop, newValue, defValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ writer.set( PROP_MINIMUM, newValue ); >+ } >+ } >+ >+ private void writeSelection( final Slider slider ) throws IOException { >+ Integer newValue = new Integer( slider.getSelection() ); >+ String prop = PROP_SELECTION; >+ Integer defValue = DEFAULT_SELECTION; >+ if( WidgetLCAUtil.hasChanged( slider, prop, newValue, defValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ writer.set( PROP_SELECTION, newValue ); >+ } >+ } >+ >+ private void writeIncrement( final Slider slider ) throws IOException { >+ Integer newValue = new Integer( slider.getIncrement() ); >+ String prop = PROP_INCREMENT; >+ Integer defValue = DEFAULT_INCREMENT; >+ if( WidgetLCAUtil.hasChanged( slider, prop, newValue, defValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ writer.set( PROP_INCREMENT, newValue ); >+ } >+ } >+ >+ private void writePageIncrement( final Slider slider ) throws IOException { >+ Integer newValue = new Integer( slider.getPageIncrement() ); >+ String prop = PROP_PAGE_INCREMENT; >+ Integer defValue = DEFAULT_PAGE_INCREMENT; >+ if( WidgetLCAUtil.hasChanged( slider, prop, newValue, defValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ writer.set( PROP_PAGE_INCREMENT, newValue ); >+ } >+ } >+ >+ private void writeThumb( final Slider slider ) throws IOException { >+ Integer newValue = new Integer( slider.getThumb() ); >+ String prop = PROP_THUMB; >+ Integer defValue = DEFAULT_THUMB; >+ if( WidgetLCAUtil.hasChanged( slider, prop, newValue, defValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ writer.set( PROP_THUMB, newValue ); >+ } >+ } >+ >+ private void writeListener( final Slider slider ) throws IOException { >+ boolean hasListener = SelectionEvent.hasListener( slider ); >+ Boolean newValue = Boolean.valueOf( hasListener ); >+ String prop = Props.SELECTION_LISTENERS; >+ if( WidgetLCAUtil.hasChanged( slider, prop, newValue, Boolean.FALSE ) ) { >+ JSWriter writer = JSWriter.getWriterFor( slider ); >+ writer.set( "hasSelectionListener", newValue ); >+ } >+ } >+ >+} >#P org.eclipse.rap.rwt >Index: src/org/eclipse/rwt/internal/theme/ThemeManager.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/ThemeManager.java,v >retrieving revision 1.52 >diff -u -r1.52 ThemeManager.java >--- src/org/eclipse/rwt/internal/theme/ThemeManager.java 3 Dec 2008 22:11:49 -0000 1.52 >+++ src/org/eclipse/rwt/internal/theme/ThemeManager.java 5 Dec 2008 15:42:26 -0000 >@@ -162,7 +162,8 @@ > org.eclipse.swt.widgets.Tree.class, > org.eclipse.swt.widgets.Scale.class, > org.eclipse.swt.widgets.DateTime.class, >- org.eclipse.swt.widgets.ExpandBar.class >+ org.eclipse.swt.widgets.ExpandBar.class, >+ org.eclipse.swt.widgets.Slider.class > }; > > private static ThemeManager instance; >Index: src/org/eclipse/swt/internal/widgets/sliderkit/Slider.default.css >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/sliderkit/Slider.default.css >diff -N src/org/eclipse/swt/internal/widgets/sliderkit/Slider.default.css >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/sliderkit/Slider.default.css 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/* Slider default theme */ >+ >+Slider { >+ background-color: #eeeeee; >+} >+ >+Slider-Thumb { >+ background-color: #cccccc; >+ border: 1px outset; >+} >+ >+Slider-Thumb:pressed { >+ background-color: #aaaaaa; >+} >+ >+Slider-MinButton { >+ background-color: #cccccc; >+ background-image: url( resource/widget/rap/slider/vbut_min_icon.gif ); >+} >+ >+Slider-MinButton:hover { >+ background-color: #eeeeee; >+} >+ >+Slider-MinButton:horizontal { >+ background-image: url( resource/widget/rap/slider/hbut_min_icon.gif ); >+} >+ >+Slider-MaxButton { >+ background-color: #cccccc; >+ background-image: url( resource/widget/rap/slider/vbut_max_icon.gif ); >+} >+ >+Slider-MaxButton:hover { >+ background-color: #eeeeee; >+} >+ >+Slider-MaxButton:horizontal { >+ background-image: url( resource/widget/rap/slider/hbut_max_icon.gif ); >+} >Index: src/org/eclipse/swt/widgets/Slider.java >=================================================================== >RCS file: src/org/eclipse/swt/widgets/Slider.java >diff -N src/org/eclipse/swt/widgets/Slider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/widgets/Slider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,510 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.swt.widgets; >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.events.*; >+ >+/** >+ * Instances of this class are selectable user interface >+ * objects that represent a range of positive, numeric values. >+ * <p> >+ * At any given moment, a given slider will have a >+ * single 'selection' that is considered to be its >+ * value, which is constrained to be within the range of >+ * values the slider represents (that is, between its >+ * <em>minimum</em> and <em>maximum</em> values). >+ * </p><p> >+ * Typically, sliders will be made up of five areas: >+ * <ol> >+ * <li>an arrow button for decrementing the value</li> >+ * <li>a page decrement area for decrementing the value by a larger amount</li> >+ * <li>a <em>thumb</em> for modifying the value by mouse dragging</li> >+ * <li>a page increment area for incrementing the value by a larger amount</li> >+ * <li>an arrow button for incrementing the value</li> >+ * </ol> >+ * Based on their style, sliders are either <code>HORIZONTAL</code> >+ * (which have a left facing button for decrementing the value and a >+ * right facing button for incrementing it) or <code>VERTICAL</code> >+ * (which have an upward facing button for decrementing the value >+ * and a downward facing buttons for incrementing it). >+ * </p><p> >+ * On some platforms, the size of the slider's thumb can be >+ * varied relative to the magnitude of the range of values it >+ * represents (that is, relative to the difference between its >+ * maximum and minimum values). Typically, this is used to >+ * indicate some proportional value such as the ratio of the >+ * visible area of a document to the total amount of space that >+ * it would take to display it. SWT supports setting the thumb >+ * size even if the underlying platform does not, but in this >+ * case the appearance of the slider will not change. >+ * </p> >+ * <dl> >+ * <dt><b>Styles:</b></dt> >+ * <dd>HORIZONTAL, VERTICAL</dd> >+ * <dt><b>Events:</b></dt> >+ * <dd>Selection</dd> >+ * </dl> >+ * <p> >+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified. >+ * </p><p> >+ * IMPORTANT: This class is <em>not</em> intended to be subclassed. >+ * </p> >+ * >+ * @see ScrollBar >+ * @see <a href="http://www.eclipse.org/swt/snippets/#slider">Slider snippets</a> >+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a> >+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> >+ * @since 1.2 >+ */ >+public class Slider extends Control { >+ >+ private final Point PREFERRED_SIZE = new Point( 170, 16 ); >+ >+ private int increment; >+ private int maximum; >+ private int minimum; >+ private int pageIncrement; >+ private int selection; >+ private int thumb; >+ >+ /** >+ * Constructs a new instance of this class given its parent >+ * and a style value describing its behavior and appearance. >+ * <p> >+ * The style value is either one of the style constants defined in >+ * class <code>SWT</code> which is applicable to instances of this >+ * class, or must be built by <em>bitwise OR</em>'ing together >+ * (that is, using the <code>int</code> "|" operator) two or more >+ * of those <code>SWT</code> style constants. The class description >+ * lists the style constants that are applicable to the class. >+ * Style bits are also inherited from superclasses. >+ * </p> >+ * >+ * @param parent a composite control which will be the parent of the new instance (cannot be null) >+ * @param style the style of control to construct >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> >+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> >+ * </ul> >+ * >+ * @see SWT#HORIZONTAL >+ * @see SWT#VERTICAL >+ * @see Widget#checkSubclass >+ * @see Widget#getStyle >+ */ >+ public Slider( final Composite parent, final int style ) { >+ super( parent, checkStyle (style) ); >+ increment = 1; >+ maximum = 100; >+ minimum = 0; >+ pageIncrement = 10; >+ selection = 0; >+ thumb = 10; >+ } >+ >+ /** >+ * Adds the listener to the collection of listeners who will >+ * be notified when the user changes the receiver's value, by sending >+ * it one of the messages defined in the <code>SelectionListener</code> >+ * interface. >+ * <p> >+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values: >+ * <code>SWT.NONE</code> - for the end of a drag. >+ * <code>SWT.DRAG</code>. >+ * <code>SWT.HOME</code>. >+ * <code>SWT.END</code>. >+ * <code>SWT.ARROW_DOWN</code>. >+ * <code>SWT.ARROW_UP</code>. >+ * <code>SWT.PAGE_DOWN</code>. >+ * <code>SWT.PAGE_UP</code>. >+ * <code>widgetDefaultSelected</code> is not called. >+ * </p> >+ * >+ * @param listener the listener which should be notified when the user changes the receiver's value >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * >+ * @see SelectionListener >+ * @see #removeSelectionListener >+ * @see SelectionEvent >+ */ >+ public void addSelectionListener( final SelectionListener listener ) { >+ SelectionEvent.addListener( this, listener ); >+ } >+ >+ /** >+ * Removes the listener from the collection of listeners who will >+ * be notified when the user changes the receiver's value. >+ * >+ * @param listener the listener which should no longer be notified >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * >+ * @see SelectionListener >+ * @see #addSelectionListener >+ */ >+ public void removeSelectionListener( final SelectionListener listener ) { >+ SelectionEvent.removeListener( this, listener ); >+ } >+ >+ static int checkStyle( final int style ) { >+ return checkBits( style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0 ); >+ } >+ >+ public Point computeSize( final int wHint, >+ final int hHint, >+ final boolean changed ) >+ { >+ checkWidget(); >+ int width, height; >+ if( ( style & SWT.HORIZONTAL ) != 0 ) { >+ width = PREFERRED_SIZE.x; >+ height = PREFERRED_SIZE.y; >+ } else { >+ width = PREFERRED_SIZE.y; >+ height = PREFERRED_SIZE.x; >+ } >+ if( wHint != SWT.DEFAULT ) { >+ width = wHint; >+ } >+ if( hHint != SWT.DEFAULT ) { >+ height = hHint; >+ } >+ return new Point( width, height ); >+ } >+ >+ void createWidget() { >+ increment = 1; >+ pageIncrement = 10; >+ maximum = 100; >+ thumb = 10; >+ } >+ >+ public boolean getEnabled() { >+ checkWidget(); >+ return( state & DISABLED ) == 0; >+ } >+ >+ /** >+ * Returns the amount that the receiver's value will be >+ * modified by when the up/down (or right/left) arrows >+ * are pressed. >+ * >+ * @return the increment >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getIncrement() { >+ checkWidget(); >+ return increment; >+ } >+ >+ /** >+ * Returns the maximum value which the receiver will allow. >+ * >+ * @return the maximum >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getMaximum() { >+ checkWidget(); >+ return maximum; >+ } >+ >+ /** >+ * Returns the minimum value which the receiver will allow. >+ * >+ * @return the minimum >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getMinimum() { >+ checkWidget(); >+ return minimum; >+ } >+ >+ /** >+ * Returns the amount that the receiver's value will be >+ * modified by when the page increment/decrement areas >+ * are selected. >+ * >+ * @return the page increment >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getPageIncrement() { >+ checkWidget(); >+ return pageIncrement; >+ } >+ >+ /** >+ * Returns the 'selection', which is the receiver's value. >+ * >+ * @return the selection >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getSelection() { >+ checkWidget(); >+ return selection; >+ } >+ >+ /** >+ * Returns the size of the receiver's thumb relative to the >+ * difference between its maximum and minimum values. >+ * >+ * @return the thumb value >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getThumb() { >+ checkWidget(); >+ return thumb; >+ } >+ >+ /** >+ * Sets the amount that the receiver's value will be >+ * modified by when the up/down (or right/left) arrows >+ * are pressed to the argument, which must be at least >+ * one. >+ * >+ * @param value the new increment (must be greater than zero) >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setIncrement( final int value ) { >+ checkWidget(); >+ if( value >= 1 && value <= maximum - minimum ) { >+ increment = value; >+ } >+ } >+ >+ /** >+ * Sets the maximum. If this value is negative or less than or >+ * equal to the minimum, the value is ignored. If necessary, first >+ * the thumb and then the selection are adjusted to fit within the >+ * new range. >+ * >+ * @param value the new maximum, which must be greater than the current minimum >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setMaximum( final int value ) { >+ checkWidget(); >+ if( 0 <= minimum && minimum < value ) { >+ maximum = value; >+ if( selection > maximum - thumb ) { >+ selection = maximum - thumb; >+ } >+ } >+ if( thumb >= maximum - minimum ) { >+ thumb = maximum - minimum; >+ selection = minimum; >+ } >+ } >+ >+ /** >+ * Sets the minimum value. If this value is negative or greater >+ * than or equal to the maximum, the value is ignored. If necessary, >+ * first the thumb and then the selection are adjusted to fit within >+ * the new range. >+ * >+ * @param value the new minimum >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setMinimum( final int value ) { >+ checkWidget(); >+ if( 0 <= value && value < maximum ) { >+ minimum = value; >+ if( selection < minimum ) { >+ selection = minimum; >+ } >+ } >+ if( thumb >= maximum - minimum ) { >+ thumb = maximum - minimum; >+ selection = minimum; >+ } >+ } >+ >+ /** >+ * Sets the amount that the receiver's value will be >+ * modified by when the page increment/decrement areas >+ * are selected to the argument, which must be at least >+ * one. >+ * >+ * @param value the page increment (must be greater than zero) >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setPageIncrement( final int value ) { >+ checkWidget(); >+ if( value >= 1 && value <= maximum - minimum ) { >+ pageIncrement = value; >+ } >+ } >+ >+ /** >+ * Sets the 'selection', which is the receiver's >+ * value, to the argument which must be greater than or equal >+ * to zero. >+ * >+ * @param value the new selection (must be zero or greater) >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setSelection( final int value ) { >+ checkWidget(); >+ if( value < minimum ) { >+ selection = minimum; >+ } else if ( value > maximum - thumb ) { >+ selection = maximum - thumb; >+ } else { >+ selection = value; >+ } >+ } >+ >+ /** >+ * Sets the size of the receiver's thumb relative to the >+ * difference between its maximum and minimum values. This new >+ * value will be ignored if it is less than one, and will be >+ * clamped if it exceeds the receiver's current range. >+ * >+ * @param value the new thumb value, which must be at least one and not >+ * larger than the size of the current range >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setThumb( final int value ) { >+ checkWidget(); >+ if( value >= 1 ) { >+ thumb = value; >+ } >+ if( value >= maximum - minimum ) { >+ thumb = maximum - minimum; >+ selection = minimum; >+ } >+ } >+ >+ /** >+ * Sets the receiver's selection, minimum value, maximum >+ * value, thumb, increment and page increment all at once. >+ * <p> >+ * Note: This is similar to setting the values individually >+ * using the appropriate methods, but may be implemented in a >+ * more efficient fashion on some platforms. >+ * </p> >+ * >+ * @param selection the new selection value >+ * @param minimum the new minimum value >+ * @param maximum the new maximum value >+ * @param thumb the new thumb value >+ * @param increment the new increment value >+ * @param pageIncrement the new pageIncrement value >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setValues( final int selection, >+ final int minimum, >+ final int maximum, >+ final int thumb, >+ final int increment, >+ final int pageIncrement ) >+ { >+ checkWidget(); >+ if( selection >= minimum && selection <= maximum ) { >+ this.selection = selection; >+ } >+ if( 0 <= minimum && minimum < maximum ) { >+ this.minimum = minimum; >+ if( selection < minimum ) { >+ this.selection = minimum; >+ } >+ } >+ if( 0 <= minimum && minimum < maximum ) { >+ this.maximum = maximum; >+ if( selection > maximum - thumb ) { >+ this.selection = maximum - thumb; >+ } >+ } >+ if( thumb >= 1 ) { >+ this.thumb = thumb; >+ } >+ if( increment >= 1 && increment <= ( maximum - minimum ) ) { >+ this.increment = increment; >+ } >+ if( pageIncrement >= 1 && pageIncrement <= ( maximum - minimum ) ) { >+ this.pageIncrement = pageIncrement; >+ } >+ if( thumb >= maximum - minimum ) { >+ this.thumb = maximum - minimum; >+ this.selection = minimum; >+ } >+ } >+ >+} >Index: src/org/eclipse/swt/internal/widgets/sliderkit/Slider.theme.xml >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/sliderkit/Slider.theme.xml >diff -N src/org/eclipse/swt/internal/widgets/sliderkit/Slider.theme.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/sliderkit/Slider.theme.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+<?xml version="1.0" encoding="iso-8859-1" ?> >+<!-- >+ Copyright (c) 2008 Innoopract Informationssysteme GmbH. >+ All rights reserved. This program and the accompanying materials >+ are made available under the terms of the Eclipse Public License v1.0 >+ which accompanies this distribution, and is available at >+ http://www.eclipse.org/legal/epl-v10.html >+ >+ Contributors: >+ Innoopract Informationssysteme GmbH - initial API and implementation >+ --> >+ >+<theme> >+ >+ <element name="Slider" >+ description="Slider controls"> >+ >+ <property name="background-color" >+ type="color" >+ description="Background color for slider" /> >+ >+ <element name="Slider-Thumb" >+ description="The movable thumb"> >+ >+ <property name="background-color" >+ type="color" >+ description="Background color for slider thumb" /> >+ >+ <property name="border" >+ type="border" >+ description="Thumb border" /> >+ >+ <state name="pressed" >+ description="On thumb pressed" /> >+ >+ </element> >+ >+ <element name="Slider-MinButton" >+ description="The button for decreasing selection value"> >+ >+ <property name="background-color" >+ type="color" >+ description="Background color for min button" /> >+ >+ <property name="background-image" >+ type="image" >+ description="Icon of the min button - horizontal. >+ The max size of the image should be 16 x 16 pixels." /> >+ >+ <state name="hover" >+ description="On button roll over" /> >+ >+ <state name="horizontal" >+ description="Indicates that the slider is in horizontal state." /> >+ >+ </element> >+ >+ <element name="Slider-MaxButton" >+ description="The button for increasing selection value"> >+ >+ <property name="background-color" >+ type="color" >+ description="Background color for max button" /> >+ >+ <property name="background-image" >+ type="image" >+ description="Icon of the max button - horizontal. >+ The max size of the image should be 16 x 16 pixels." /> >+ >+ <state name="hover" >+ description="On button roll over" /> >+ >+ <state name="horizontal" >+ description="Indicates that the slider is in horizontal state." /> >+ >+ </element> >+ >+ </element> >+ >+</theme>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 256740
: 119743 |
119744