Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Dynamic column widths in tables
Dynamic column widths in tables [message #448473] |
Mon, 10 January 2005 19:23 |
Bill Ewing Messages: 49 Registered: July 2009 |
Member |
|
|
As in a lot of apps, we want to programmatically resize table columns.
One common goal is to make the final column expand to fill extra space, if
there is any.
If you're doing the same and are a nooB (like us) this may help you get
started.
If you're an expert, please help out by explaining how you would program,
for example, a table that always has its last column sponge up any extra
space.
For starters, we've done things like:
1. Get table width with:
table.getSize().x.
2. Get the space consumed by borders with:
int borderWidth = t.getBorderWidth();
BTW, the doc'n does not explain, this is the overall border for the table,
not some borders for columns. We typically get a value of 2 for this.
3. Compute and set the desired size of columns with setWidth(). The
problem here is that the pesky vertical scrollbar may or may not be
present. So you get a reference to it with getVerticalBar, see if that's
non-null and then use the isVisible() method. The problem is, isVisible
always returns true, NO MATTER WHAT. This sure seems like a bug. Anybody
found a reliable way to test if the V scroll bar is visible?
OK, the worst thing here is that we soemtimes have extra space, the width
of a vertical scrollbar, showing along the right side of our app. If
that's OK with you, please don't respond.
And, BTW, computeTrim() looks appealing here, but is useless./
4. Learned from experts that the first column in windows will always be
LEFT JUSTIFIED. Give us trying to fix it! Our plan is to always make it
zero width or to do everything as "owner draw" - custom paint everything.
|
|
|
Re: Dynamic column widths in tables [message #448503 is a reply to message #448473] |
Tue, 11 January 2005 16:12 |
Steve Northover Messages: 1636 Registered: July 2009 |
Senior Member |
|
|
.... or you could just let the operating system table behave the way it is
supposed to instead of fighting it.
For ScrollBar.isVisible(), see:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=47763
"Bill Ewing" <ewing@irori.com> wrote in message
news:crukmq$si4$1@www.eclipse.org...
> As in a lot of apps, we want to programmatically resize table columns.
> One common goal is to make the final column expand to fill extra space, if
> there is any.
>
> If you're doing the same and are a nooB (like us) this may help you get
> started.
>
> If you're an expert, please help out by explaining how you would program,
> for example, a table that always has its last column sponge up any extra
> space.
>
> For starters, we've done things like:
>
> 1. Get table width with:
> table.getSize().x.
>
> 2. Get the space consumed by borders with:
> int borderWidth = t.getBorderWidth();
> BTW, the doc'n does not explain, this is the overall border for the table,
> not some borders for columns. We typically get a value of 2 for this.
>
> 3. Compute and set the desired size of columns with setWidth(). The
> problem here is that the pesky vertical scrollbar may or may not be
> present. So you get a reference to it with getVerticalBar, see if that's
> non-null and then use the isVisible() method. The problem is, isVisible
> always returns true, NO MATTER WHAT. This sure seems like a bug. Anybody
> found a reliable way to test if the V scroll bar is visible?
>
> OK, the worst thing here is that we soemtimes have extra space, the width
> of a vertical scrollbar, showing along the right side of our app. If
> that's OK with you, please don't respond.
>
> And, BTW, computeTrim() looks appealing here, but is useless./
>
> 4. Learned from experts that the first column in windows will always be
> LEFT JUSTIFIED. Give us trying to fix it! Our plan is to always make it
> zero width or to do everything as "owner draw" - custom paint everything.
>
>
|
|
|
Re: Dynamic column widths in tables [message #448544 is a reply to message #448503] |
Tue, 11 January 2005 20:47 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
The following snippet handles the scrollbar problem for resizing
TableColumns:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet77.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup
"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:cs0ttf$2al$1@www.eclipse.org...
> ... or you could just let the operating system table behave the way it is
> supposed to instead of fighting it.
>
> For ScrollBar.isVisible(), see:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=47763
>
> "Bill Ewing" <ewing@irori.com> wrote in message
> news:crukmq$si4$1@www.eclipse.org...
>> As in a lot of apps, we want to programmatically resize table columns.
>> One common goal is to make the final column expand to fill extra space,
>> if
>> there is any.
>>
>> If you're doing the same and are a nooB (like us) this may help you get
>> started.
>>
>> If you're an expert, please help out by explaining how you would program,
>> for example, a table that always has its last column sponge up any extra
>> space.
>>
>> For starters, we've done things like:
>>
>> 1. Get table width with:
>> table.getSize().x.
>>
>> 2. Get the space consumed by borders with:
>> int borderWidth = t.getBorderWidth();
>> BTW, the doc'n does not explain, this is the overall border for the
>> table,
>> not some borders for columns. We typically get a value of 2 for this.
>>
>> 3. Compute and set the desired size of columns with setWidth(). The
>> problem here is that the pesky vertical scrollbar may or may not be
>> present. So you get a reference to it with getVerticalBar, see if that's
>> non-null and then use the isVisible() method. The problem is, isVisible
>> always returns true, NO MATTER WHAT. This sure seems like a bug.
>> Anybody
>> found a reliable way to test if the V scroll bar is visible?
>>
>> OK, the worst thing here is that we soemtimes have extra space, the width
>> of a vertical scrollbar, showing along the right side of our app. If
>> that's OK with you, please don't respond.
>>
>> And, BTW, computeTrim() looks appealing here, but is useless./
>>
>> 4. Learned from experts that the first column in windows will always be
>> LEFT JUSTIFIED. Give us trying to fix it! Our plan is to always make it
>> zero width or to do everything as "owner draw" - custom paint everything.
>>
>>
>
>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 09:19:38 GMT 2024
Powered by FUDForum. Page generated in 0.03361 seconds
|