blob: db706f0e92925953414462f8f2d60a84097030dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*******************************************************************************
* Copyright (c) 2004, 2009 Tasktop Technologies and others.
* 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:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.editors;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
* @author Steffen Pingel
*/
public abstract class ToolBarButtonContribution extends ControlContribution {
public int marginLeft = 0;
public int marginRight = 0;
protected ToolBarButtonContribution(String id) {
super(id);
}
protected abstract Control createButton(Composite parent);
@Override
protected Control createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setBackground(null);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
if (Platform.WS_CARBON.equals(SWT.getPlatform())) {
layout.marginTop = -3;
}
layout.marginLeft = this.marginLeft;
layout.marginRight = this.marginRight;
composite.setLayout(layout);
Control button = createButton(composite);
int heigtHint = SWT.DEFAULT;
if (Platform.WS_WIN32.equals(SWT.getPlatform())) {
heigtHint = 22;
} else if (Platform.WS_CARBON.equals(SWT.getPlatform())) {
heigtHint = 32;
}
GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).hint(SWT.DEFAULT, heigtHint).applyTo(button);
return composite;
}
}
|