Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to modify the height of a Scale widget inside a ToolBar?
How to modify the height of a Scale widget inside a ToolBar? [message #455304] Thu, 12 May 2005 15:45 Go to next message
Eclipse UserFriend
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 modify the height of a Scale widget inside a ToolBar? [message #455360 is a reply to message #455304] Fri, 13 May 2005 03:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: florin_florea.hotmail.com

Is someone able to help?

Thanks,

F


"Florin" <florin_florea@hotmail.com> wrote in message
news:d5vu69$g4b$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
>
>
Re: How to modify the height of a Scale widget inside a ToolBar? [message #455417 is a reply to message #455360] Fri, 13 May 2005 19:07 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Windows doesn't let you set the height of a tool item. The only way do to
this right now is to insert an image with the right height to force the tool
bar to be taller.

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
ToolBar toolBar = new ToolBar(shell, SWT.RIGHT);
Scale scale = new Scale(toolBar, SWT.NONE);
scale.pack();
int height = scale.getSize().y;
ToolItem scaleItem = new ToolItem(toolBar, SWT.SEPARATOR);
scaleItem.setControl(scale);
scaleItem.setWidth(128);
new ToolItem(toolBar, SWT.SEPARATOR);
ImageData imageData = new ImageData (1, height, 1, new PaletteData(new
RGB[] {new RGB(0, 0, 0)}));
imageData.transparentPixel = 0;
Image image = new Image (display, imageData);
for (int i = 0; i < 2; i++) {
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
item.setText("Push " + i);
item.setImage(image);
}
toolBar.pack();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
image.dispose ();
display.dispose();
}

"Florin" <florin_florea@hotmail.com> wrote in message
news:d616v3$sm5$1@news.eclipse.org...
> Is someone able to help?
>
> Thanks,
>
> F
>
>
> "Florin" <florin_florea@hotmail.com> wrote in message
> news:d5vu69$g4b$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
> >
> >
>
>
Re: How to modify the height of a Scale widget inside a ToolBar? [message #455419 is a reply to message #455417] Fri, 13 May 2005 20:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: florin_florea.hotmail.com

Thanks for the example below!

That's sad. It means that my Scale will always have to look bulky and ugly.
I thought there is a way to set its preferred size to a specific value. I
couldn't find a way myself and you're saying that actually is not even
possible.

What about the SWT Cotrols Example//"Slider/Scale". There is a radio button
group for Size. I cannot see the result for 10x10 but I was thinking that
the actual height of the Scale is reduced as well. Is it, or it's just the
bounds in which the Scale is contained?

Thanks,

Florin



"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:d62udn$rfc$1@news.eclipse.org...
> Windows doesn't let you set the height of a tool item. The only way do to
> this right now is to insert an image with the right height to force the
tool
> bar to be taller.
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> ToolBar toolBar = new ToolBar(shell, SWT.RIGHT);
> Scale scale = new Scale(toolBar, SWT.NONE);
> scale.pack();
> int height = scale.getSize().y;
> ToolItem scaleItem = new ToolItem(toolBar, SWT.SEPARATOR);
> scaleItem.setControl(scale);
> scaleItem.setWidth(128);
> new ToolItem(toolBar, SWT.SEPARATOR);
> ImageData imageData = new ImageData (1, height, 1, new PaletteData(new
> RGB[] {new RGB(0, 0, 0)}));
> imageData.transparentPixel = 0;
> Image image = new Image (display, imageData);
> for (int i = 0; i < 2; i++) {
> ToolItem item = new ToolItem(toolBar, SWT.PUSH);
> item.setText("Push " + i);
> item.setImage(image);
> }
> toolBar.pack();
> shell.pack();
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> image.dispose ();
> display.dispose();
> }
>
> "Florin" <florin_florea@hotmail.com> wrote in message
> news:d616v3$sm5$1@news.eclipse.org...
> > Is someone able to help?
> >
> > Thanks,
> >
> > F
> >
> >
> > "Florin" <florin_florea@hotmail.com> wrote in message
> > news:d5vu69$g4b$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
> > >
> > >
> >
> >
>
>
Re: How to modify the height of a Scale widget inside a ToolBar? [message #455476 is a reply to message #455419] Mon, 16 May 2005 19:13 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Not sure what you are asking. The example code makes the tool bar tall
enough to show the scale without clipping.

"Florin" <florin_florea@hotmail.com> wrote in message
news:d63309$oo$1@news.eclipse.org...
> Thanks for the example below!
>
> That's sad. It means that my Scale will always have to look bulky and
ugly.
> I thought there is a way to set its preferred size to a specific value. I
> couldn't find a way myself and you're saying that actually is not even
> possible.
>
> What about the SWT Cotrols Example//"Slider/Scale". There is a radio
button
> group for Size. I cannot see the result for 10x10 but I was thinking that
> the actual height of the Scale is reduced as well. Is it, or it's just the
> bounds in which the Scale is contained?
>
> Thanks,
>
> Florin
>
>
>
> "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> news:d62udn$rfc$1@news.eclipse.org...
> > Windows doesn't let you set the height of a tool item. The only way do
to
> > this right now is to insert an image with the right height to force the
> tool
> > bar to be taller.
> >
> > public static void main(String[] args) {
> > Display display = new Display();
> > Shell shell = new Shell(display);
> > ToolBar toolBar = new ToolBar(shell, SWT.RIGHT);
> > Scale scale = new Scale(toolBar, SWT.NONE);
> > scale.pack();
> > int height = scale.getSize().y;
> > ToolItem scaleItem = new ToolItem(toolBar, SWT.SEPARATOR);
> > scaleItem.setControl(scale);
> > scaleItem.setWidth(128);
> > new ToolItem(toolBar, SWT.SEPARATOR);
> > ImageData imageData = new ImageData (1, height, 1, new PaletteData(new
> > RGB[] {new RGB(0, 0, 0)}));
> > imageData.transparentPixel = 0;
> > Image image = new Image (display, imageData);
> > for (int i = 0; i < 2; i++) {
> > ToolItem item = new ToolItem(toolBar, SWT.PUSH);
> > item.setText("Push " + i);
> > item.setImage(image);
> > }
> > toolBar.pack();
> > shell.pack();
> > shell.open();
> > while (!shell.isDisposed()) {
> > if (!display.readAndDispatch())
> > display.sleep();
> > }
> > image.dispose ();
> > display.dispose();
> > }
> >
> > "Florin" <florin_florea@hotmail.com> wrote in message
> > news:d616v3$sm5$1@news.eclipse.org...
> > > Is someone able to help?
> > >
> > > Thanks,
> > >
> > > F
> > >
> > >
> > > "Florin" <florin_florea@hotmail.com> wrote in message
> > > news:d5vu69$g4b$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
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: How to modify the height of a Scale widget inside a ToolBar? [message #455483 is a reply to message #455476] Mon, 16 May 2005 21:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: florin_florea.hotmail.com

I was asking how can I modify the height of the Scale. I want to set its
height to whatever size I want (in my case I want it smaller than its
"preferred" height). I still couldn't do that. It looks like it's sticked to
some preferred height without any chance to modify it. I can change the
width no problem, but not the height.

No, I didn't ask how to make the ToolBar tall enough to show the Scale
properly.

Do you have an answer to my question now?

Thank you,

Florin


"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:d6arv9$m61$1@news.eclipse.org...
> Not sure what you are asking. The example code makes the tool bar tall
> enough to show the scale without clipping.
>
> "Florin" <florin_florea@hotmail.com> wrote in message
> news:d63309$oo$1@news.eclipse.org...
> > Thanks for the example below!
> >
> > That's sad. It means that my Scale will always have to look bulky and
> ugly.
> > I thought there is a way to set its preferred size to a specific value.
I
> > couldn't find a way myself and you're saying that actually is not even
> > possible.
> >
> > What about the SWT Cotrols Example//"Slider/Scale". There is a radio
> button
> > group for Size. I cannot see the result for 10x10 but I was thinking
that
> > the actual height of the Scale is reduced as well. Is it, or it's just
the
> > bounds in which the Scale is contained?
> >
> > Thanks,
> >
> > Florin
> >
> >
> >
> > "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> > news:d62udn$rfc$1@news.eclipse.org...
> > > Windows doesn't let you set the height of a tool item. The only way
do
> to
> > > this right now is to insert an image with the right height to force
the
> > tool
> > > bar to be taller.
> > >
> > > public static void main(String[] args) {
> > > Display display = new Display();
> > > Shell shell = new Shell(display);
> > > ToolBar toolBar = new ToolBar(shell, SWT.RIGHT);
> > > Scale scale = new Scale(toolBar, SWT.NONE);
> > > scale.pack();
> > > int height = scale.getSize().y;
> > > ToolItem scaleItem = new ToolItem(toolBar, SWT.SEPARATOR);
> > > scaleItem.setControl(scale);
> > > scaleItem.setWidth(128);
> > > new ToolItem(toolBar, SWT.SEPARATOR);
> > > ImageData imageData = new ImageData (1, height, 1, new
PaletteData(new
> > > RGB[] {new RGB(0, 0, 0)}));
> > > imageData.transparentPixel = 0;
> > > Image image = new Image (display, imageData);
> > > for (int i = 0; i < 2; i++) {
> > > ToolItem item = new ToolItem(toolBar, SWT.PUSH);
> > > item.setText("Push " + i);
> > > item.setImage(image);
> > > }
> > > toolBar.pack();
> > > shell.pack();
> > > shell.open();
> > > while (!shell.isDisposed()) {
> > > if (!display.readAndDispatch())
> > > display.sleep();
> > > }
> > > image.dispose ();
> > > display.dispose();
> > > }
> > >
> > > "Florin" <florin_florea@hotmail.com> wrote in message
> > > news:d616v3$sm5$1@news.eclipse.org...
> > > > Is someone able to help?
> > > >
> > > > Thanks,
> > > >
> > > > F
> > > >
> > > >
> > > > "Florin" <florin_florea@hotmail.com> wrote in message
> > > > news:d5vu69$g4b$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
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: How to modify the height of a Scale widget inside a ToolBar? [message #455566 is a reply to message #455483] Tue, 17 May 2005 18:05 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Use setSize() to set the width and height of the scale, not pack(). If the
size is too small, the scale will draw clipped, which is probably not what
you want. There is no way to tell the scale to draw smaller and not be
clipped.

"Florin" <florin_florea@hotmail.com> wrote in message
news:d6b27n$ufo$1@news.eclipse.org...
> I was asking how can I modify the height of the Scale. I want to set its
> height to whatever size I want (in my case I want it smaller than its
> "preferred" height). I still couldn't do that. It looks like it's sticked
to
> some preferred height without any chance to modify it. I can change the
> width no problem, but not the height.
>
> No, I didn't ask how to make the ToolBar tall enough to show the Scale
> properly.
>
> Do you have an answer to my question now?
>
> Thank you,
>
> Florin
>
>
> "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> news:d6arv9$m61$1@news.eclipse.org...
> > Not sure what you are asking. The example code makes the tool bar tall
> > enough to show the scale without clipping.
> >
> > "Florin" <florin_florea@hotmail.com> wrote in message
> > news:d63309$oo$1@news.eclipse.org...
> > > Thanks for the example below!
> > >
> > > That's sad. It means that my Scale will always have to look bulky and
> > ugly.
> > > I thought there is a way to set its preferred size to a specific
value.
> I
> > > couldn't find a way myself and you're saying that actually is not even
> > > possible.
> > >
> > > What about the SWT Cotrols Example//"Slider/Scale". There is a radio
> > button
> > > group for Size. I cannot see the result for 10x10 but I was thinking
> that
> > > the actual height of the Scale is reduced as well. Is it, or it's just
> the
> > > bounds in which the Scale is contained?
> > >
> > > Thanks,
> > >
> > > Florin
> > >
> > >
> > >
> > > "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> > > news:d62udn$rfc$1@news.eclipse.org...
> > > > Windows doesn't let you set the height of a tool item. The only way
> do
> > to
> > > > this right now is to insert an image with the right height to force
> the
> > > tool
> > > > bar to be taller.
> > > >
> > > > public static void main(String[] args) {
> > > > Display display = new Display();
> > > > Shell shell = new Shell(display);
> > > > ToolBar toolBar = new ToolBar(shell, SWT.RIGHT);
> > > > Scale scale = new Scale(toolBar, SWT.NONE);
> > > > scale.pack();
> > > > int height = scale.getSize().y;
> > > > ToolItem scaleItem = new ToolItem(toolBar, SWT.SEPARATOR);
> > > > scaleItem.setControl(scale);
> > > > scaleItem.setWidth(128);
> > > > new ToolItem(toolBar, SWT.SEPARATOR);
> > > > ImageData imageData = new ImageData (1, height, 1, new
> PaletteData(new
> > > > RGB[] {new RGB(0, 0, 0)}));
> > > > imageData.transparentPixel = 0;
> > > > Image image = new Image (display, imageData);
> > > > for (int i = 0; i < 2; i++) {
> > > > ToolItem item = new ToolItem(toolBar, SWT.PUSH);
> > > > item.setText("Push " + i);
> > > > item.setImage(image);
> > > > }
> > > > toolBar.pack();
> > > > shell.pack();
> > > > shell.open();
> > > > while (!shell.isDisposed()) {
> > > > if (!display.readAndDispatch())
> > > > display.sleep();
> > > > }
> > > > image.dispose ();
> > > > display.dispose();
> > > > }
> > > >
> > > > "Florin" <florin_florea@hotmail.com> wrote in message
> > > > news:d616v3$sm5$1@news.eclipse.org...
> > > > > Is someone able to help?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > F
> > > > >
> > > > >
> > > > > "Florin" <florin_florea@hotmail.com> wrote in message
> > > > > news:d5vu69$g4b$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
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: How to modify the height of a Scale widget inside a ToolBar? [message #456992 is a reply to message #455483] Mon, 13 June 2005 21:44 Go to previous message
Eclipse UserFriend
Originally posted by: jan-hendrik.gmx.de

I had the same problem:
Using a scale seemed the perfect tool for one of my wizards, but it just looks
ugly in it's prefered size (much larger than everything else).

Since the scale clips when reaching a certain height, I had to find a compromise
where the size did not make the page ugly, but the user can still operate the
slider. Actually I set the size so that only the slider and the upper scale
markings are visible.
Since I was using a GridLayout, I managed this by giving the scale a GridData
object with gridData.heightHint field set to about 22.

It would be really nice to have a scale that doesn't look unproportionally big
in a view or dialog page. If anyone knows a solution to this problem, please, I
would be happy to learn about it!!

Greetings ... Jan

Florin wrote:
> I was asking how can I modify the height of the Scale. I want to set its
> height to whatever size I want (in my case I want it smaller than its
> "preferred" height). I still couldn't do that. It looks like it's sticked to
> some preferred height without any chance to modify it. I can change the
> width no problem, but not the height.
>
> No, I didn't ask how to make the ToolBar tall enough to show the Scale
> properly.
>
> Do you have an answer to my question now?
>
> Thank you,
>
> Florin
>
Previous Topic:SuSE 9
Next Topic:Tools to Convert Swing source code to SWT
Goto Forum:
  


Current Time: Sat Apr 27 02:51:39 GMT 2024

Powered by FUDForum. Page generated in 0.03079 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top