public SpinnerFieldEditor( String name, String labelText, Composite parent, int min, int max, int increment, int pageIncrement) { init(name, labelText); GridLayout layout = new GridLayout(); layout.numColumns = getNumberOfControls(); layout.marginWidth = 0; layout.marginHeight = 0; layout.horizontalSpacing = HORIZONTAL_GAP; parent.setLayout(layout); // create label control getLabelControl(parent); spinner = new BigDecimalSpinner(parent, SWT.NONE, 0, min, max, increment, pageIncrement); spinner.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { valueChanged(); } }); doFillIntoGrid(parent, layout.numColumns); }
/** @see OpenGLTab#createControls(Composite) */ void createControls(Composite composite) { Group movementGroup = new Group(composite, SWT.NONE); movementGroup.setText("Translation"); movementGroup.setLayout(new GridLayout(2, false)); new Label(movementGroup, SWT.NONE).setText("X:"); final Slider xMove = new Slider(movementGroup, SWT.NONE); xMove.setIncrement(1); xMove.setMaximum(12); xMove.setMinimum(0); xMove.setThumb(2); xMove.setPageIncrement(2); xMove.setSelection(5); xMove.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { xPos = xMove.getSelection() - 5; } }); new Label(movementGroup, SWT.NONE).setText("Y:"); final Slider yMove = new Slider(movementGroup, SWT.NONE); yMove.setIncrement(1); yMove.setMaximum(12); yMove.setMinimum(0); yMove.setThumb(2); yMove.setPageIncrement(2); yMove.setSelection(5); yMove.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { yPos = yMove.getSelection() - 5; } }); new Label(movementGroup, SWT.NONE).setText("Z:"); final Slider zMove = new Slider(movementGroup, SWT.NONE); zMove.setIncrement(1); zMove.setMaximum(24); zMove.setMinimum(0); zMove.setThumb(4); zMove.setPageIncrement(2); zMove.setSelection(10); zMove.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { zPos = zMove.getSelection() - 25; } }); Composite fogTypesGroup = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; fogTypesGroup.setLayout(layout); fogTypesGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); new Label(fogTypesGroup, SWT.NONE).setText("Fog Types:"); final Combo fogTypeCombo = new Combo(fogTypesGroup, SWT.READ_ONLY); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.grabExcessHorizontalSpace = true; fogTypeCombo.setLayoutData(data); fogTypeCombo.setItems(FOG_NAMES); fogTypeCombo.select(0); new Label(composite, SWT.NONE).setText("Fog Density:"); final Slider fogDensitySlider = new Slider(composite, SWT.NONE); fogDensitySlider.setIncrement(1); fogDensitySlider.setMaximum(32); fogDensitySlider.setMinimum(0); fogDensitySlider.setThumb(2); fogDensitySlider.setPageIncrement(5); fogDensitySlider.setSelection(0); fogDensitySlider.setEnabled(false); fogDensitySlider.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { float fogDensity = ((float) fogDensitySlider.getSelection()) / 100; GL.glFogf(GL.GL_FOG_DENSITY, fogDensity); } }); fogTypeCombo.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { int currentSelection = fogTypeCombo.getSelectionIndex(); // fog type GL.GL_LINEAR does not utilize fogDensity, but the other fog types do fogDensitySlider.setEnabled(currentSelection != 0); GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[currentSelection]); } }); }
/** Initializes the GUI. */ private void initGUI() { try { getShell() .addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent evt) { shellWidgetDisposed(evt); } }); getShell() .addControlListener( new ControlAdapter() { public void controlResized(ControlEvent evt) { shellControlResized(evt); } }); getShell() .addControlListener( new ControlAdapter() { public void controlMoved(ControlEvent evt) { shellControlMoved(evt); } }); GridLayout thisLayout = new GridLayout(); this.setLayout(thisLayout); { GridData toolBarLData = new GridData(); toolBarLData.grabExcessHorizontalSpace = true; toolBarLData.horizontalAlignment = GridData.FILL; toolBar = new ToolBar(this, SWT.FLAT); toolBar.setLayoutData(toolBarLData); toolBar.setBackgroundImage(SWTResourceManager.getImage("images/ToolbarBackground.gif")); { newToolItem = new ToolItem(toolBar, SWT.NONE); newToolItem.setImage(SWTResourceManager.getImage("images/new.gif")); newToolItem.setToolTipText("New"); } { openToolItem = new ToolItem(toolBar, SWT.NONE); openToolItem.setToolTipText("Open"); openToolItem.setImage(SWTResourceManager.getImage("images/open.gif")); openToolItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { openToolItemWidgetSelected(evt); } }); } { saveToolItem = new ToolItem(toolBar, SWT.NONE); saveToolItem.setToolTipText("Save"); saveToolItem.setImage(SWTResourceManager.getImage("images/save.gif")); } } { clientArea = new Composite(this, SWT.NONE); GridData clientAreaLData = new GridData(); clientAreaLData.grabExcessHorizontalSpace = true; clientAreaLData.grabExcessVerticalSpace = true; clientAreaLData.horizontalAlignment = GridData.FILL; clientAreaLData.verticalAlignment = GridData.FILL; clientArea.setLayoutData(clientAreaLData); clientArea.setLayout(null); } { statusArea = new Composite(this, SWT.NONE); GridLayout statusAreaLayout = new GridLayout(); statusAreaLayout.makeColumnsEqualWidth = true; statusAreaLayout.horizontalSpacing = 0; statusAreaLayout.marginHeight = 0; statusAreaLayout.marginWidth = 0; statusAreaLayout.verticalSpacing = 0; statusAreaLayout.marginLeft = 3; statusAreaLayout.marginRight = 3; statusAreaLayout.marginTop = 3; statusAreaLayout.marginBottom = 3; statusArea.setLayout(statusAreaLayout); GridData statusAreaLData = new GridData(); statusAreaLData.horizontalAlignment = GridData.FILL; statusAreaLData.grabExcessHorizontalSpace = true; statusArea.setLayoutData(statusAreaLData); statusArea.setBackground(SWTResourceManager.getColor(239, 237, 224)); { statusText = new Label(statusArea, SWT.BORDER); statusText.setText(" Ready"); GridData txtStatusLData = new GridData(); txtStatusLData.horizontalAlignment = GridData.FILL; txtStatusLData.grabExcessHorizontalSpace = true; txtStatusLData.verticalIndent = 3; statusText.setLayoutData(txtStatusLData); } } thisLayout.verticalSpacing = 0; thisLayout.marginWidth = 0; thisLayout.marginHeight = 0; thisLayout.horizontalSpacing = 0; thisLayout.marginTop = 3; this.setSize(474, 312); { menu1 = new Menu(getShell(), SWT.BAR); getShell().setMenuBar(menu1); { fileMenuItem = new MenuItem(menu1, SWT.CASCADE); fileMenuItem.setText("&File"); { fileMenu = new Menu(fileMenuItem); { newFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); newFileMenuItem.setText("&New"); newFileMenuItem.setImage(SWTResourceManager.getImage("images/new.gif")); } { openFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); openFileMenuItem.setText("&Open"); openFileMenuItem.setImage(SWTResourceManager.getImage("images/open.gif")); openFileMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { openFileMenuItemWidgetSelected(evt); } }); } { closeFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); closeFileMenuItem.setText("Close"); } { fileMenuSep1 = new MenuItem(fileMenu, SWT.SEPARATOR); } { saveFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); saveFileMenuItem.setText("&Save"); saveFileMenuItem.setImage(SWTResourceManager.getImage("images/save.gif")); saveFileMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { saveFileMenuItemWidgetSelected(evt); } }); } { fileMenuSep2 = new MenuItem(fileMenu, SWT.SEPARATOR); } { exitMenuItem = new MenuItem(fileMenu, SWT.CASCADE); exitMenuItem.setText("E&xit"); exitMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { exitMenuItemWidgetSelected(evt); } }); } fileMenuItem.setMenu(fileMenu); } } { helpMenuItem = new MenuItem(menu1, SWT.CASCADE); helpMenuItem.setText("&Help"); { helpMenu = new Menu(helpMenuItem); { aboutMenuItem = new MenuItem(helpMenu, SWT.CASCADE); aboutMenuItem.setText("&About"); aboutMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { aboutMenuItemWidgetSelected(evt); } }); } helpMenuItem.setMenu(helpMenu); } } } } catch (Exception e) { e.printStackTrace(); } }