CTabFolder.setTopRight() with a ToolBar [message #452019] |
Sat, 12 March 2005 21:08 |
Eclipse User |
|
|
|
Originally posted by: groovynfunky.gmx.net
Hi,
I am trying to figure out, how to add a ToolBar to a CTabFolder. Got
following code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class T {
public static void main( String[] args ) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setLayout( new FillLayout() );
CTabFolder tabFolder = new CTabFolder( shell, SWT.BORDER );
tabFolder.setSingle( true );
tabFolder.setSimple( false );
tabFolder.setSelectionBackground( display.getSystemColor(
SWT.COLOR_WHITE ) );
CTabItem tabItem = new CTabItem( tabFolder, SWT.NONE );
tabItem.setText( "tabitem" );
ToolBar t = new ToolBar( tabFolder, SWT.FLAT );
ToolItem i = new ToolItem( t, SWT.PUSH );
i.setText( "toolitem" );
tabFolder.setTopRight( t, SWT.RIGHT );
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
}
}
Unfortunately this renders only a gray box without the toolItem. I am
using Eclipse 3.1M5. I tried practically everything possible - what am I
doing wrong?
Thanks for your help,
Michael
|
|
|
Re: CTabFolder.setTopRight() with a ToolBar [message #452080 is a reply to message #452019] |
Mon, 14 March 2005 12:31 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
In the height of the toolbar is not sufficient to show the whole toolbar,
non of the toolbar is shown. What you need to do is make sure that the tab
height is tall enough to show the toolbar. See below:
public static void main( String[] args ) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setLayout( new FillLayout() );
CTabFolder tabFolder = new CTabFolder( shell, SWT.BORDER );
tabFolder.setSingle( true );
tabFolder.setSimple( false );
tabFolder.setSelectionBackground(
display.getSystemColor(SWT.COLOR_WHITE ) );
CTabItem tabItem = new CTabItem( tabFolder, SWT.NONE );
tabItem.setText( "tabitem" );
ToolBar t = new ToolBar( tabFolder, SWT.FLAT );
ToolItem i = new ToolItem( t, SWT.PUSH );
i.setText( "toolitem" );
tabFolder.setTopRight( t, SWT.RIGHT );
// !!!!
// Need to set height of tab to show toolbar
tabFolder.setTabHeight(Math.max(t.computeSize(SWT.DEFAULT,
SWT.DEFAULT).y, tabFolder.getTabHeight()));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
}
"Michael Kerbel" <groovynfunky@gmx.net> wrote in message
news:d0vlot$57f$1@www.eclipse.org...
> Hi,
>
> I am trying to figure out, how to add a ToolBar to a CTabFolder. Got
> following code:
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
>
> public class T {
>
> public static void main( String[] args ) {
> final Display display = Display.getDefault();
> final Shell shell = new Shell();
> shell.setLayout( new FillLayout() );
>
> CTabFolder tabFolder = new CTabFolder( shell, SWT.BORDER );
> tabFolder.setSingle( true );
> tabFolder.setSimple( false );
> tabFolder.setSelectionBackground( display.getSystemColor(
> SWT.COLOR_WHITE ) );
>
> CTabItem tabItem = new CTabItem( tabFolder, SWT.NONE );
> tabItem.setText( "tabitem" );
>
> ToolBar t = new ToolBar( tabFolder, SWT.FLAT );
> ToolItem i = new ToolItem( t, SWT.PUSH );
> i.setText( "toolitem" );
> tabFolder.setTopRight( t, SWT.RIGHT );
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> }
> }
>
>
> Unfortunately this renders only a gray box without the toolItem. I am
> using Eclipse 3.1M5. I tried practically everything possible - what am I
> doing wrong?
>
> Thanks for your help,
> Michael
>
|
|
|
Re: CTabFolder.setTopRight() with a ToolBar [message #452164 is a reply to message #452080] |
Mon, 14 March 2005 20:58 |
Eclipse User |
|
|
|
Originally posted by: groovynfunky.gmx.net
That's it! Thank you very much. I was very desperate...
I don't understand, why the Toolbar behaves this way, though. Actually I
tried a vertically oversized label as well, which lets itself render - it
is cropped appropriately.
Veronika Irvine wrote:
> In the height of the toolbar is not sufficient to show the whole toolbar,
> non of the toolbar is shown. What you need to do is make sure that the tab
> height is tall enough to show the toolbar. See below:
> public static void main( String[] args ) {
> final Display display = Display.getDefault();
> final Shell shell = new Shell();
> shell.setLayout( new FillLayout() );
> CTabFolder tabFolder = new CTabFolder( shell, SWT.BORDER );
> tabFolder.setSingle( true );
> tabFolder.setSimple( false );
> tabFolder.setSelectionBackground(
> display.getSystemColor(SWT.COLOR_WHITE ) );
> CTabItem tabItem = new CTabItem( tabFolder, SWT.NONE );
> tabItem.setText( "tabitem" );
> ToolBar t = new ToolBar( tabFolder, SWT.FLAT );
> ToolItem i = new ToolItem( t, SWT.PUSH );
> i.setText( "toolitem" );
> tabFolder.setTopRight( t, SWT.RIGHT );
> // !!!!
> // Need to set height of tab to show toolbar
> tabFolder.setTabHeight(Math.max(t.computeSize(SWT.DEFAULT,
> SWT.DEFAULT).y, tabFolder.getTabHeight()));
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> }
> "Michael Kerbel" <groovynfunky@gmx.net> wrote in message
> news:d0vlot$57f$1@www.eclipse.org...
>> Hi,
>>
>> I am trying to figure out, how to add a ToolBar to a CTabFolder. Got
>> following code:
>>
>>
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.custom.*;
>> import org.eclipse.swt.layout.*;
>> import org.eclipse.swt.widgets.*;
>>
>> public class T {
>>
>> public static void main( String[] args ) {
>> final Display display = Display.getDefault();
>> final Shell shell = new Shell();
>> shell.setLayout( new FillLayout() );
>>
>> CTabFolder tabFolder = new CTabFolder( shell, SWT.BORDER );
>> tabFolder.setSingle( true );
>> tabFolder.setSimple( false );
>> tabFolder.setSelectionBackground( display.getSystemColor(
>> SWT.COLOR_WHITE ) );
>>
>> CTabItem tabItem = new CTabItem( tabFolder, SWT.NONE );
>> tabItem.setText( "tabitem" );
>>
>> ToolBar t = new ToolBar( tabFolder, SWT.FLAT );
>> ToolItem i = new ToolItem( t, SWT.PUSH );
>> i.setText( "toolitem" );
>> tabFolder.setTopRight( t, SWT.RIGHT );
>>
>> shell.open();
>> while (!shell.isDisposed()) {
>> if (!display.readAndDispatch()) display.sleep();
>> }
>> }
>> }
>>
>>
>> Unfortunately this renders only a gray box without the toolItem. I am
>> using Eclipse 3.1M5. I tried practically everything possible - what am I
>> doing wrong?
>>
>> Thanks for your help,
>> Michael
>>
|
|
|
Powered by
FUDForum. Page generated in 0.01733 seconds