0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.s60tools.imaker;
|
|
19 |
|
|
20 |
|
|
21 |
import org.eclipse.core.runtime.Assert;
|
|
22 |
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
23 |
import org.eclipse.jface.resource.JFaceResources;
|
|
24 |
import org.eclipse.swt.SWT;
|
|
25 |
import org.eclipse.swt.layout.GridData;
|
|
26 |
import org.eclipse.swt.widgets.Button;
|
|
27 |
|
|
28 |
public class SWTFactory {
|
|
29 |
|
|
30 |
public static int getButtonWidthHint(Button button) {
|
|
31 |
button.setFont(JFaceResources.getDialogFont());
|
|
32 |
PixelConverter converter= new PixelConverter();
|
|
33 |
int widthHint= converter.convertHorizontalDLUsToPixels(button,IDialogConstants.BUTTON_WIDTH);
|
|
34 |
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
|
|
35 |
}
|
|
36 |
|
|
37 |
public static void setButtonWidthHint(Button button) {
|
|
38 |
Assert.isNotNull(button);
|
|
39 |
Object gd= button.getLayoutData();
|
|
40 |
if (gd instanceof GridData) {
|
|
41 |
((GridData)gd).widthHint= getButtonWidthHint(button);
|
|
42 |
((GridData)gd).horizontalAlignment = GridData.FILL;
|
|
43 |
}
|
|
44 |
}
|
|
45 |
}
|