List of usage examples for org.eclipse.jface.util Util WS_GTK
String WS_GTK
To view the source code for org.eclipse.jface.util Util WS_GTK.
Click Source Link
From source file:com.patrikdufresne.switchbutton.SwitchButton.java
License:Open Source License
/** * Paint the widget// www .j ava 2 s . c o m * * @param event * paint event */ private void paint(final PaintEvent event) { final Rectangle rect = this.getClientArea(); if (rect.width == 0 || rect.height == 0) { return; } // For ease of use declare width and height. final int x = rect.x; final int y = rect.y; final int width = rect.width; final int height = rect.height; GC gc = event.gc; gc.setAntialias(SWT.ON); /* * Draw background */ // Draw back color gc.setForeground(!this.selection ? this.unselectedBackgroundColor : this.selectedBackgroundColor); gc.setBackground(!this.selection ? this.unselectedBackgroundColor : this.selectedBackgroundColor); if (!getEnabled()) { gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); } gc.fillRoundRectangle(x, y, width - 1, height - 1, this.round, this.round); // Draw back border gc.setForeground(!this.selection ? getUnselectedBorderColor() : getSelectedBorderColor()); if (!getEnabled()) { gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } gc.drawRoundRectangle(x, y, width - 1, height - 1, this.round, this.round); // Draw Left text gc.setForeground(this.selectedForegroundColor); if (!getEnabled()) { gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } final Point onSize = gc.textExtent(this.textOn, SWT.DRAW_MNEMONIC); gc.drawText(this.textOn, x + width / 4 - onSize.x / 2, y + height / 2 - onSize.y / 2, SWT.DRAW_MNEMONIC); // Draw Right text gc.setForeground(this.unselectedForegroundColor); if (!getEnabled()) { gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } final Point offSize = gc.textExtent(this.textOff, SWT.DRAW_MNEMONIC); gc.drawText(this.textOff, x + 3 * width / 4 - offSize.x / 2, y + height / 2 - offSize.y / 2, SWT.DRAW_MNEMONIC); // Draw toggle button. Rectangle b; gc.setBackground(this.buttonBackgroundColor); if (!this.selection) { b = new Rectangle(x, y, width / 2, height); } else { b = new Rectangle(x + width - (width / 2), y, width / 2, height); } gc.fillRoundRectangle(b.x, b.y, b.width, b.height, this.round, this.round); gc.setForeground(!this.selection ? this.unselectedBorderColor : this.selectedBorderColor); if (!getEnabled()) { gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } gc.drawRoundRectangle(b.x, b.y, b.width - 1, b.height - 1, this.round, this.round); // Draw hover line inside the button. if (this.focusColor != null && this.mouseInside) { gc.setForeground(this.focusColor); gc.setLineWidth(1); gc.drawRoundRectangle(b.x + 1, b.y + 1, b.width - 3, b.height - 3, this.round, this.round); gc.setLineWidth(1); } // Draw focus line in button if (paintFocus && hasFocus) { gc.setForeground(getForeground()); if (Util.getWS().equals(Util.WS_GTK)) { gc.drawFocus(b.x + 3, b.y + 3, b.width - 7, b.height - 7); } else { gc.drawFocus(b.x + 3, b.y + 3, b.width - 6, b.height - 6); } } }
From source file:org.eclipse.e4.ui.keybinding.tests.BindingPersistenceTest.java
License:Open Source License
public final void testBindingTransform() throws Exception { ICommandService commandService = (ICommandService) fWorkbench.getAdapter(ICommandService.class); IBindingService bindingService = (IBindingService) fWorkbench.getAdapter(IBindingService.class); ParameterizedCommand addWS = new ParameterizedCommand( commandService.getCommand("org.eclipse.ui.navigate.addToWorkingSet"), null); KeySequence m18w = KeySequence.getInstance("M1+8 W"); KeySequence m28w = KeySequence.getInstance("M2+8 W"); boolean foundDeleteMarker = false; int numOfMarkers = 0; Binding[] bindings = bindingService.getBindings(); for (int i = 0; i < bindings.length; i++) { final Binding binding = bindings[i]; if (binding.getType() == Binding.SYSTEM) { String platform = binding.getPlatform(); int idx = (platform == null ? -1 : platform.indexOf(',')); assertEquals(binding.toString(), -1, idx); if (addWS.equals(binding.getParameterizedCommand())) { if (m18w.equals(binding.getTriggerSequence())) { numOfMarkers++;/*from w w w . j av a 2 s. c om*/ assertNull(m18w.format(), binding.getPlatform()); } else if (m28w.equals(binding.getTriggerSequence())) { numOfMarkers++; assertTrue(platform, Util.WS_CARBON.equals(platform) || Util.WS_COCOA.equals(platform) || Util.WS_GTK.equals(platform) || Util.WS_WIN32.equals(platform)); } } else if (binding.getParameterizedCommand() == null && m18w.equals(binding.getTriggerSequence())) { assertTrue(platform, Util.WS_CARBON.equals(platform) || Util.WS_COCOA.equals(platform) || Util.WS_GTK.equals(platform) || Util.WS_WIN32.equals(platform)); numOfMarkers++; foundDeleteMarker = true; } } } assertEquals(3, numOfMarkers); assertTrue("Unable to find delete marker", foundDeleteMarker); TriggerSequence[] activeBindingsFor = bindingService.getActiveBindingsFor(addWS); assertEquals(1, activeBindingsFor.length); }
From source file:org.eclipse.ui.tests.keys.BindingPersistenceTest.java
License:Open Source License
public final void testBindingTransform() throws Exception { ICommandService commandService = (ICommandService) fWorkbench.getAdapter(ICommandService.class); IBindingService bindingService = (IBindingService) fWorkbench.getAdapter(IBindingService.class); ParameterizedCommand addWS = new ParameterizedCommand( commandService.getCommand("org.eclipse.ui.navigate.addToWorkingSet"), null); KeySequence m18w = KeySequence.getInstance("M1+8 W"); KeySequence m28w = KeySequence.getInstance("M2+8 W"); boolean foundDeleteMarker = false; int numOfMarkers = 0; Binding[] bindings = bindingService.getBindings(); for (int i = 0; i < bindings.length; i++) { final Binding binding = bindings[i]; if (binding.getType() == Binding.SYSTEM) { String platform = binding.getPlatform(); int idx = (platform == null ? -1 : platform.indexOf(',')); assertEquals(binding.toString(), -1, idx); if (addWS.equals(binding.getParameterizedCommand())) { if (m18w.equals(binding.getTriggerSequence())) { numOfMarkers++;//from www. j a va 2 s.co m assertNull(m18w.format(), binding.getPlatform()); } else if (m28w.equals(binding.getTriggerSequence())) { numOfMarkers++; assertTrue(platform, Util.WS_CARBON.equals(platform) || Util.WS_COCOA.equals(platform) || Util.WS_GTK.equals(platform) || Util.WS_WIN32.equals(platform)); } } else if (binding.getParameterizedCommand() == null && m18w.equals(binding.getTriggerSequence())) { assertTrue(platform, Util.WS_CARBON.equals(platform) || Util.WS_COCOA.equals(platform) || Util.WS_GTK.equals(platform) || Util.WS_WIN32.equals(platform)); numOfMarkers++; foundDeleteMarker = true; } } } assertEquals(3, numOfMarkers); assertTrue("Unable to find delete marker", foundDeleteMarker); // make sure that the proper contexts are currently active IContextService contextService = (IContextService) fWorkbench.getService(IContextService.class); contextService.activateContext(IContextService.CONTEXT_ID_DIALOG_AND_WINDOW); contextService.activateContext(IContextService.CONTEXT_ID_WINDOW); TriggerSequence[] activeBindingsFor = bindingService.getActiveBindingsFor(addWS); assertEquals(1, activeBindingsFor.length); }