Home » Eclipse Projects » Standard Widget Toolkit (SWT) » KTable FULL_SELECTION
KTable FULL_SELECTION [message #459078] |
Mon, 01 August 2005 12:31 |
Eclipse User |
|
|
|
Originally posted by: kongofrabongo.epost.no
How can I get a KTable to cover an intire form?
I have tried :
KTable table = new KTable (form.getBody(), SWT.FULL_SELECTION);
(this works fine with the JFace Table)
and the underlying Canvas is drawn correctly according to the style (i
can se the grey area covering the entire form), but the size of the
table remains fixed.
|
|
| |
Re: KTable FULL_SELECTION [message #459083 is a reply to message #459082] |
Mon, 01 August 2005 13:53 |
Eclipse User |
|
|
|
Originally posted by: kongofrabongo.epost.no
Lorenz Maierhofer wrote:
> Hi,
>
> KTable has a quite different concept than SWT Table.
> Look at the examples to check out how to create KTables.
>
> I'm not sure what you exactly want to achieve, but it seems that your
> KTable should grab all space in the form body.
> Try to use a FillLayout:
> form.getBody().setLayout(new FillLayout);
>
>
> Ola wrote:
>
>> How can I get a KTable to cover an intire form?
>> I have tried :
>>
>> KTable table = new KTable (form.getBody(), SWT.FULL_SELECTION);
>> (this works fine with the JFace Table)
>>
>> and the underlying Canvas is drawn correctly according to the style (i
>> can se the grey area covering the entire form), but the size of the
>> table remains fixed.
Hmm. Thanks, but using FillLayout does not change anything.
And, yes, I want the table to fill the entire form. Even though I only
have data to fill a few rows, I want the table to draw (empty)rows until
the end of the form (and the same for columns), like I can with the SWT
Table using the FULL_SELECTION style.
|
|
|
Re: KTable FULL_SELECTION [message #459084 is a reply to message #459083] |
Mon, 01 August 2005 15:46 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
The feature you need is not supported by KTable directly. What you need
to do is changing your KTableModel in such a way that it returns the
column width depending on the current table size.
You can obtain the current size of the table using KTable.getSize(). Use
this as a basis to calculate the column widths.
If you need any more help let me know.
Regards,
Friederich
Ola wrote:
> Lorenz Maierhofer wrote:
>
>> Hi,
>>
>> KTable has a quite different concept than SWT Table.
>> Look at the examples to check out how to create KTables.
>>
>> I'm not sure what you exactly want to achieve, but it seems that your
>> KTable should grab all space in the form body.
>> Try to use a FillLayout:
>> form.getBody().setLayout(new FillLayout);
>>
>>
>> Ola wrote:
>>
>>> How can I get a KTable to cover an intire form?
>>> I have tried :
>>>
>>> KTable table = new KTable (form.getBody(), SWT.FULL_SELECTION);
>>> (this works fine with the JFace Table)
>>>
>>> and the underlying Canvas is drawn correctly according to the style
>>> (i can se the grey area covering the entire form), but the size of
>>> the table remains fixed.
>
>
> Hmm. Thanks, but using FillLayout does not change anything.
> And, yes, I want the table to fill the entire form. Even though I only
> have data to fill a few rows, I want the table to draw (empty)rows until
> the end of the form (and the same for columns), like I can with the SWT
> Table using the FULL_SELECTION style.
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
|
Re: KTable FULL_SELECTION [message #459114 is a reply to message #459084] |
Tue, 02 August 2005 12:11 |
Eclipse User |
|
|
|
Originally posted by: kongofrabongo.epost.no
Friederich Kupzog wrote:
> The feature you need is not supported by KTable directly. What you need
> to do is changing your KTableModel in such a way that it returns the
> column width depending on the current table size.
>
> You can obtain the current size of the table using KTable.getSize(). Use
> this as a basis to calculate the column widths.
>
> If you need any more help let me know.
>
> Regards,
> Friederich
>
>
> Ola wrote:
>
>> Lorenz Maierhofer wrote:
>>
>>> Hi,
>>>
>>> KTable has a quite different concept than SWT Table.
>>> Look at the examples to check out how to create KTables.
>>>
>>> I'm not sure what you exactly want to achieve, but it seems that your
>>> KTable should grab all space in the form body.
>>> Try to use a FillLayout:
>>> form.getBody().setLayout(new FillLayout);
>>>
>>>
>>> Ola wrote:
>>>
>>>> How can I get a KTable to cover an intire form?
>>>> I have tried :
>>>>
>>>> KTable table = new KTable (form.getBody(), SWT.FULL_SELECTION);
>>>> (this works fine with the JFace Table)
>>>>
>>>> and the underlying Canvas is drawn correctly according to the style
>>>> (i can se the grey area covering the entire form), but the size of
>>>> the table remains fixed.
>>
>>
>>
>> Hmm. Thanks, but using FillLayout does not change anything.
>> And, yes, I want the table to fill the entire form. Even though I only
>> have data to fill a few rows, I want the table to draw (empty)rows
>> until the end of the form (and the same for columns), like I can with
>> the SWT Table using the FULL_SELECTION style.
>
>
>
Well. Say, if I want three columns. In order to make the table fill the
form (horizontally) I calculate the remaining space between the last
column right-edge and the table right-edge. Then I make the 4'th column
with this width. Now the table covers the form horizontally. Fine. Now,
as long as the three leftmost columns are in sight in the window (form)
I'd like no scrolling, so I do not append the SWT.H_SCROLL . But I'd
like scrolling to be automaticall turned on if the window (form) gets
narrower than the width of the three leftmost columns (like I get with
the SWT.FULL_SELECTION style in SWT Tables). How can I achieve that with
your solution ?
|
|
|
Re: KTable FULL_SELECTION [message #459139 is a reply to message #459114] |
Tue, 02 August 2005 13:24 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi Ola,
there is currently no way of automatically hiding KTable scrollbars. If
you need a scollbar sometimes, you have to enable it all the time. As
long it is not needed, it will display as a "grayed" scrollbar.
As you might have noticed I am the author of KTable. So, if you really
really really want the scrollbar to disappear, I could have a deep look
into the source and see how much work it is to implement that. But for
me the current solution works fine...
BTW, as a user I dislike "fake" table columns which fill the entire
table. I would prefer the existing columns to spread over the area. But
this seems to be a quesion of personal taste.
Regards,
Friederich
> Well. Say, if I want three columns. In order to make the table fill the
> form (horizontally) I calculate the remaining space between the last
> column right-edge and the table right-edge. Then I make the 4'th column
> with this width. Now the table covers the form horizontally. Fine. Now,
> as long as the three leftmost columns are in sight in the window (form)
> I'd like no scrolling, so I do not append the SWT.H_SCROLL . But I'd
> like scrolling to be automaticall turned on if the window (form) gets
> narrower than the width of the three leftmost columns (like I get with
> the SWT.FULL_SELECTION style in SWT Tables). How can I achieve that with
> your solution ?
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
|
Re: KTable FULL_SELECTION [message #459140 is a reply to message #459139] |
Tue, 02 August 2005 13:42 |
Eclipse User |
|
|
|
Originally posted by: kongofrabongo.epost.no
Friederich Kupzog wrote:
> Hi Ola,
>
> there is currently no way of automatically hiding KTable scrollbars. If
> you need a scollbar sometimes, you have to enable it all the time. As
> long it is not needed, it will display as a "grayed" scrollbar.
>
> As you might have noticed I am the author of KTable. So, if you really
> really really want the scrollbar to disappear, I could have a deep look
> into the source and see how much work it is to implement that. But for
> me the current solution works fine...
>
> BTW, as a user I dislike "fake" table columns which fill the entire
> table. I would prefer the existing columns to spread over the area. But
> this seems to be a quesion of personal taste.
>
> Regards,
> Friederich
>
>
>> Well. Say, if I want three columns. In order to make the table fill
>> the form (horizontally) I calculate the remaining space between the
>> last column right-edge and the table right-edge. Then I make the 4'th
>> column with this width. Now the table covers the form horizontally.
>> Fine. Now, as long as the three leftmost columns are in sight in the
>> window (form) I'd like no scrolling, so I do not append the
>> SWT.H_SCROLL . But I'd like scrolling to be automaticall turned on if
>> the window (form) gets narrower than the width of the three leftmost
>> columns (like I get with the SWT.FULL_SELECTION style in SWT Tables).
>> How can I achieve that with your solution ?
>
>
>
Ok. Thanks anyway. I think I'll stick with KTable as it is :)
|
|
| | |
Re: KTable FULL_SELECTION [message #460425 is a reply to message #460417] |
Thu, 25 August 2005 20:31 |
Vladimir Grishchenko Messages: 7 Registered: July 2009 |
Junior Member |
|
|
You may achieve better results if you use getClientArea() instead of
getSize() to find out the actual height as the value getSize() will also
include the scrollbars. Also, I think row count returned from the model
includes fixed rows, so you may be over-calculating your theoreticalHeight.
"Andreas Fuchs" <asf@boinkor.net> wrote in message
news:87wtma86a7.wl%asf@boinkor.net...
> On 2005-08-24, Vladimir Grishchenko <vladgri@hotmail.com> wrote:
> > It is possible to have scrollbars shown on demand with some custom
> > coding. In a nutshell you create KTable with scrollbars enabled and
> > then listen for control resize notifications. You then use the model
> > to find out the theoretical size and compare it to the actual
> > size. If the theoretical size is larger than the actual you make the
> > scrollbar(s) visible, if not you hide them. This seem to work for
> > me.
>
> After some initial confusion, I implemented your suggestion and so
> far, it seems to work fine for me. For anyone who could find it
> useful, here's the class I came up with (usable under Eclipse Public
> License):
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.Point;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.Listener;
>
> import de.kupzog.ktable.KTable;
> import de.kupzog.ktable.KTableModel;
>
> public class AutoScrollingKTable extends KTable {
>
> void setVerticalBarVisible() {
> KTableModel model = getModel();
> Point actualSize = getSize();
> int theoreticalHeight= model.getRowHeight()*model.getRowCount()
> + model.getFirstRowHeight();
> if (theoreticalHeight > actualSize.y) {
> getVerticalBar().setVisible(true);
> } else {
> getVerticalBar().setVisible(false);
> }
> }
>
> private class ResizeListener implements Listener{
>
> public void handleEvent(Event event) {
> setVerticalBarVisible();
> }
> }
>
> public void setModel(KTableModel model) {
> super.setModel(model);
> if (model != null)
> setVerticalBarVisible();
> else
> getVerticalBar().setVisible(false);
> }
>
> public AutoScrollingKTable(Composite parent, int style) {
> super(parent, style);
> addListener(SWT.Resize, new ResizeListener());
> }
> }
>
|
|
|
Re: KTable FULL_SELECTION [message #460430 is a reply to message #460425] |
Fri, 26 August 2005 09:21 |
Andreas Fuchs Messages: 6 Registered: July 2009 |
Junior Member |
|
|
On 2005-08-25, Vladimir Grishchenko <vgrishchenko@serena.com> wrote:
> You may achieve better results if you use getClientArea() instead of
> getSize() to find out the actual height as the value getSize() will
> also include the scrollbars. Also, I think row count returned from
> the model includes fixed rows, so you may be over-calculating your
> theoreticalHeight.
You're right in both cases. This works much better for me (and it also
does horizontal scroll bar goodness):
public class AutoScrollingKTable extends KTable {
private void setVerticalBarVisible() {
KTableModel model = getModel();
Rectangle actualSize = getClientArea();
getVerticalBar().setVisible(actualSize.height <
model.getRowHeight() * (model.getRowCount()-1)
+ model.getFirstRowHeight());
}
private void setHorizontalBarVisible() {
KTableModel model = getModel();
Rectangle actualSize = getClientArea();
int theoreticalWidth = 0;
for (int i = 0; i < model.getColumnCount(); i++)
theoreticalWidth += model.getColumnWidth(i);
getHorizontalBar().setVisible(actualSize.width < theoreticalWidth);
}
private class ResizeListener implements Listener{
public void handleEvent(Event event) {
setVerticalBarVisible();
setHorizontalBarVisible();
}
}
public void setModel(KTableModel model) {
super.setModel(model);
setVerticalBarVisible();
setHorizontalBarVisible();
}
public AutoScrollingKTable(Composite parent, int style) {
super(parent, style | SWT.V_SCROLL | SWT.H_SCROLL);
addListener(SWT.Resize, new ResizeListener());
}
}
Thanks!
--
Andreas Fuchs, <asf@boinkor.net>, asf@jabber.at, antifuchs
|
|
|
Re: KTable FULL_SELECTION [message #460526 is a reply to message #460430] |
Wed, 31 August 2005 11:19 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi Andreas,
would you actually mind me adding this to the next KTable release?
Regards,
Friederich
Andreas Fuchs wrote:
> On 2005-08-25, Vladimir Grishchenko <vgrishchenko@serena.com> wrote:
>
>>You may achieve better results if you use getClientArea() instead of
>>getSize() to find out the actual height as the value getSize() will
>>also include the scrollbars. Also, I think row count returned from
>>the model includes fixed rows, so you may be over-calculating your
>>theoreticalHeight.
>
>
> You're right in both cases. This works much better for me (and it also
> does horizontal scroll bar goodness):
>
> public class AutoScrollingKTable extends KTable {
> private void setVerticalBarVisible() {
> KTableModel model = getModel();
> Rectangle actualSize = getClientArea();
> getVerticalBar().setVisible(actualSize.height <
> model.getRowHeight() * (model.getRowCount()-1)
> + model.getFirstRowHeight());
>
> }
> private void setHorizontalBarVisible() {
> KTableModel model = getModel();
> Rectangle actualSize = getClientArea();
> int theoreticalWidth = 0;
> for (int i = 0; i < model.getColumnCount(); i++)
> theoreticalWidth += model.getColumnWidth(i);
> getHorizontalBar().setVisible(actualSize.width < theoreticalWidth);
> }
>
> private class ResizeListener implements Listener{
> public void handleEvent(Event event) {
> setVerticalBarVisible();
> setHorizontalBarVisible();
> }
> }
>
> public void setModel(KTableModel model) {
> super.setModel(model);
> setVerticalBarVisible();
> setHorizontalBarVisible();
>
> }
>
> public AutoScrollingKTable(Composite parent, int style) {
> super(parent, style | SWT.V_SCROLL | SWT.H_SCROLL);
> addListener(SWT.Resize, new ResizeListener());
> }
> }
>
> Thanks!
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
|
Re: KTable FULL_SELECTION [message #460584 is a reply to message #460526] |
Wed, 31 August 2005 20:41 |
Lorenz Maierhofer Messages: 88 Registered: July 2009 |
Member |
|
|
Hi Friedrich,
Hi Andreas,
I am currently spending some of my time with KTable and as there was
a comment about EPL of the posted code by Andreas, I just put that into
the current version under ktable.sourceforge.net
regards,
Lorenz Maierhofer
Friederich Kupzog wrote:
> Hi Andreas,
>
> would you actually mind me adding this to the next KTable release?
>
> Regards,
> Friederich
>
> Andreas Fuchs wrote:
>
>> On 2005-08-25, Vladimir Grishchenko <vgrishchenko@serena.com> wrote:
>>
>>> You may achieve better results if you use getClientArea() instead of
>>> getSize() to find out the actual height as the value getSize() will
>>> also include the scrollbars. Also, I think row count returned from
>>> the model includes fixed rows, so you may be over-calculating your
>>> theoreticalHeight.
>>
>>
>>
>> You're right in both cases. This works much better for me (and it also
>> does horizontal scroll bar goodness):
>>
>> public class AutoScrollingKTable extends KTable { private void
>> setVerticalBarVisible() {
>> KTableModel model = getModel();
>> Rectangle actualSize = getClientArea();
>> getVerticalBar().setVisible(actualSize.height <
>> model.getRowHeight() * (model.getRowCount()-1)
>> + model.getFirstRowHeight());
>>
>> }
>> private void setHorizontalBarVisible() {
>> KTableModel model = getModel();
>> Rectangle actualSize = getClientArea();
>> int theoreticalWidth = 0;
>> for (int i = 0; i < model.getColumnCount(); i++)
>> theoreticalWidth += model.getColumnWidth(i);
>> getHorizontalBar().setVisible(actualSize.width <
>> theoreticalWidth);
>> }
>> private class ResizeListener implements Listener{
>> public void handleEvent(Event event) {
>> setVerticalBarVisible();
>> setHorizontalBarVisible();
>> }
>> }
>> public void setModel(KTableModel model) {
>> super.setModel(model);
>> setVerticalBarVisible();
>> setHorizontalBarVisible();
>>
>> }
>> public AutoScrollingKTable(Composite parent, int style) {
>> super(parent, style | SWT.V_SCROLL | SWT.H_SCROLL);
>> addListener(SWT.Resize, new ResizeListener());
>> }
>> }
>>
>> Thanks!
>
>
>
|
|
| |
Goto Forum:
Current Time: Thu Sep 26 12:04:33 GMT 2024
Powered by FUDForum. Page generated in 0.05626 seconds
|