How to fit a Scale in a ToolBar properly [message #180938] |
Wed, 11 May 2005 12:23  |
Eclipse User |
|
|
|
Originally posted by: florin_florea.hotmail.com
I have aViewPart and want to use a "org.eclipse.swt.widgets.Scale" to zoom a
Figure inside the view.
For that matter I created the method below:
private void createToolBar() {
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
IContributionItem control = new ControlContribution("Scale") {
public Control createControl(Composite parent) {
Scale scale = new Scale (parent, SWT.HORIZONTAL);
scale.setMinimum(1);
scale.setMaximum(19);
scale.setSelection(10);
scale.setPageIncrement(3);
scale.setIncrement(1);
scale.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
int sel = ((Scale)e.getSource()).getSelection();
((ScalableFreeformLayeredPane)view).setScale((double)sel/10) ;
}
public void widgetDefaultSelected(SelectionEvent e) {}
});
return scale;
}
public int computeWidth(Control control) {
return control.computeSize(100, SWT.DEFAULT, true).x;
}
};
mgr.add(control);
mgr.add(new Separator());
}
The problem: the Scale height is larger than the ToolBar height. How can I
make the Scale fit inside the ToolBar's borders?
I tried different approaches (including setLayoutData(new GridData()) and so
forth) but didn't help.
Thanks,
F
|
|
|
Re: How to fit a Scale in a ToolBar properly [message #181037 is a reply to message #180938] |
Wed, 11 May 2005 19:35  |
Eclipse User |
|
|
|
org.eclipse.swt.widgets.Scale
There's no GEF or Draw2d in there.
Wrong newsgroup.
"Florin" <florin_florea@hotmail.com> wrote in message
news:d5tc27$o73$1@news.eclipse.org...
> I have aViewPart and want to use a "org.eclipse.swt.widgets.Scale" to zoom
a
> Figure inside the view.
> For that matter I created the method below:
>
> private void createToolBar() {
> IToolBarManager mgr =
getViewSite().getActionBars().getToolBarManager();
> IContributionItem control = new ControlContribution("Scale") {
> public Control createControl(Composite parent) {
> Scale scale = new Scale (parent, SWT.HORIZONTAL);
> scale.setMinimum(1);
> scale.setMaximum(19);
> scale.setSelection(10);
> scale.setPageIncrement(3);
> scale.setIncrement(1);
> scale.addSelectionListener(new SelectionListener() {
> public void widgetSelected(SelectionEvent e) {
> int sel = ((Scale)e.getSource()).getSelection();
>
> ((ScalableFreeformLayeredPane)view).setScale((double)sel/10) ;
> }
>
> public void widgetDefaultSelected(SelectionEvent e) {}
> });
> return scale;
> }
>
> public int computeWidth(Control control) {
> return control.computeSize(100, SWT.DEFAULT, true).x;
> }
> };
> mgr.add(control);
> mgr.add(new Separator());
> }
>
> The problem: the Scale height is larger than the ToolBar height. How can I
> make the Scale fit inside the ToolBar's borders?
>
> I tried different approaches (including setLayoutData(new GridData()) and
so
> forth) but didn't help.
>
> Thanks,
>
> F
>
>
|
|
|
Powered by
FUDForum. Page generated in 1.03741 seconds