Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Could we add text alignment in grid varying by row
Could we add text alignment in grid varying by row [message #33953] Thu, 03 May 2007 14:53 Go to next message
Eclipse UserFriend
Originally posted by: slorenc.infogix.com

I would like to propose adding ability to vary column alignment in grid
control. Currently you can set it once for the entire column but if you
want different alignment in each cell of a single column you can't do it.

Looking at GridItem implementation I think it could be done in a similar
manner to how the text, fonts and backgrounds are saved for each column.
Then the DefaultCellRenderer could retrieve alignment from item instead of
from itself.

Thanks,

Swavek
Re: Could we add text alignment in grid varying by row [message #34007 is a reply to message #33953] Thu, 03 May 2007 16:20 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
Hi Swavek,

The feature could be added as you suggest but I'm not sure its something
that many people would use. I will consider adding it in the future but
I'm wary of adding feature upon feature that simply make the Grid more
complex. You can always create your own cell renderer to have this
feature in your own app.

Regards,
-Chris

Swavek Lorenc wrote:
> I would like to propose adding ability to vary column alignment in grid
> control. Currently you can set it once for the entire column but if you
> want different alignment in each cell of a single column you can't do it.
>
> Looking at GridItem implementation I think it could be done in a similar
> manner to how the text, fonts and backgrounds are saved for each column.
> Then the DefaultCellRenderer could retrieve alignment from item instead of
> from itself.
>
> Thanks,
>
> Swavek
>
>
Re: Could we add text alignment in grid varying by row [message #34025 is a reply to message #34007] Thu, 03 May 2007 19:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: slorenc.infogix.com

Chris,

I tried adding it to the CellRenderer but realized that cell renderer would
have to hold this data for each row in a column. It will not scale if you
have large number of rows. GridItem is the object which holds style data
for the entire row so it is logical to place it there. Plus if virtual
management of rows is implemented fully in Grid and I would like to take
advantage of it I would have to add virtual managment of alignment
information inside CellRenderer as well.

I got the code working and could volunter if you are intested. It's a 3
line change in DefaultCellRender and a few set/get methods in GridItem.

There is another change to DefaultColumnHeaderRender that has to do with
alignment. I think this one is easy to add and makes the column header more
esthetically pleasing. I think it looks more esthetic to center text in the
header of the column rather than left justify it. A simple change to the
DefaultColumnHeaderRenderer would make it possible to change the default
alignment to center (or even right justified). What do you think abou this
change? After adding get/setTextAlignment all is needed is this code in
paint method
//
// draw header text
//
int textX = getBounds().x + x + pushedDrawingOffset;
int textY = y + pushedDrawingOffset;
// shorten header text to 'My header text...' to fit within
specified column width
String headerShortString = TextUtils.getShortString(gc,
column.getText(), width);
int textWidth = gc.stringExtent(headerShortString).x;
if ((textAlignment & SWT.CENTER) != 0)
{
textX += (width - textWidth) / 2;
}
else if ((textAlignment & SWT.RIGHT) != 0)
{
textX += width - textWidth;
}
gc.drawString(headerShortString, textX, textY, true);


replacing this code around line 126

gc.drawString(TextUtils.getShortString(gc, column.getText(), width),
getBounds().x + x + pushedDrawingOffset,
y + pushedDrawingOffset,true);

Swavek
"Chris Gross" <chris.gross@us.ibm.com> wrote in message
news:f1d23c$fqe$2@build.eclipse.org...
> Hi Swavek,
>
> The feature could be added as you suggest but I'm not sure its something
> that many people would use. I will consider adding it in the future but
> I'm wary of adding feature upon feature that simply make the Grid more
> complex. You can always create your own cell renderer to have this
> feature in your own app.
>
> Regards,
> -Chris
>
> Swavek Lorenc wrote:
>> I would like to propose adding ability to vary column alignment in grid
>> control. Currently you can set it once for the entire column but if you
>> want different alignment in each cell of a single column you can't do it.
>>
>> Looking at GridItem implementation I think it could be done in a similar
>> manner to how the text, fonts and backgrounds are saved for each column.
>> Then the DefaultCellRenderer could retrieve alignment from item instead
>> of from itself.
>>
>> Thanks,
>>
>> Swavek
>>
Re: Could we add text alignment in grid varying by row [message #34052 is a reply to message #34025] Thu, 03 May 2007 20:21 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
Hi Swavek,

If you wanted to add this feature in your own renderer you would still
want to keep the value of the property on each GridItem. You could
store it in the GridItem's data map (i.e. setData(key,value),
getData(key,value)).

I'd be interested in any patch that you can contribute but please post
it to a bugzilla entry and please use a patch file (i.e. CVS Team
provider unified patch). But I will have to think about whether to
commit each patch. There's a sweet spot somewhere between adding all
functionality anyone could ever want in the Grid and just making it
extensible so if you want the behavior you can add it yourself.

Regards,
-Chris

Swavek Lorenc wrote:
> Chris,
>
> I tried adding it to the CellRenderer but realized that cell renderer would
> have to hold this data for each row in a column. It will not scale if you
> have large number of rows. GridItem is the object which holds style data
> for the entire row so it is logical to place it there. Plus if virtual
> management of rows is implemented fully in Grid and I would like to take
> advantage of it I would have to add virtual managment of alignment
> information inside CellRenderer as well.
>
> I got the code working and could volunter if you are intested. It's a 3
> line change in DefaultCellRender and a few set/get methods in GridItem.
>
> There is another change to DefaultColumnHeaderRender that has to do with
> alignment. I think this one is easy to add and makes the column header more
> esthetically pleasing. I think it looks more esthetic to center text in the
> header of the column rather than left justify it. A simple change to the
> DefaultColumnHeaderRenderer would make it possible to change the default
> alignment to center (or even right justified). What do you think abou this
> change? After adding get/setTextAlignment all is needed is this code in
> paint method
> //
> // draw header text
> //
> int textX = getBounds().x + x + pushedDrawingOffset;
> int textY = y + pushedDrawingOffset;
> // shorten header text to 'My header text...' to fit within
> specified column width
> String headerShortString = TextUtils.getShortString(gc,
> column.getText(), width);
> int textWidth = gc.stringExtent(headerShortString).x;
> if ((textAlignment & SWT.CENTER) != 0)
> {
> textX += (width - textWidth) / 2;
> }
> else if ((textAlignment & SWT.RIGHT) != 0)
> {
> textX += width - textWidth;
> }
> gc.drawString(headerShortString, textX, textY, true);
>
>
> replacing this code around line 126
>
> gc.drawString(TextUtils.getShortString(gc, column.getText(), width),
> getBounds().x + x + pushedDrawingOffset,
> y + pushedDrawingOffset,true);
>
> Swavek
> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
> news:f1d23c$fqe$2@build.eclipse.org...
>> Hi Swavek,
>>
>> The feature could be added as you suggest but I'm not sure its something
>> that many people would use. I will consider adding it in the future but
>> I'm wary of adding feature upon feature that simply make the Grid more
>> complex. You can always create your own cell renderer to have this
>> feature in your own app.
>>
>> Regards,
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> I would like to propose adding ability to vary column alignment in grid
>>> control. Currently you can set it once for the entire column but if you
>>> want different alignment in each cell of a single column you can't do it.
>>>
>>> Looking at GridItem implementation I think it could be done in a similar
>>> manner to how the text, fonts and backgrounds are saved for each column.
>>> Then the DefaultCellRenderer could retrieve alignment from item instead
>>> of from itself.
>>>
>>> Thanks,
>>>
>>> Swavek
>>>
>
Re: Could we add text alignment in grid varying by row [message #34082 is a reply to message #34052] Thu, 03 May 2007 20:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: slorenc.infogix.com

I am now trying to use GridItem's data map because I decided to implement
the cell renderer myself. This way I can alter not just alignment but also
how the bounding rectangle is drawn.

My goal is to display Excel's spreadsheet in a grid as closely as possible
(fonts, alignment, background and text color) etc. That's why I wanted to
control alignment on per cell rather than per column basis.

Thanks for suggestion.

Swavek


"Chris Gross" <chris.gross@us.ibm.com> wrote in message
news:f1dg7c$t45$1@build.eclipse.org...
> Hi Swavek,
>
> If you wanted to add this feature in your own renderer you would still
> want to keep the value of the property on each GridItem. You could store
> it in the GridItem's data map (i.e. setData(key,value),
> getData(key,value)).
>
> I'd be interested in any patch that you can contribute but please post it
> to a bugzilla entry and please use a patch file (i.e. CVS Team provider
> unified patch). But I will have to think about whether to commit each
> patch. There's a sweet spot somewhere between adding all functionality
> anyone could ever want in the Grid and just making it extensible so if you
> want the behavior you can add it yourself.
>
> Regards,
> -Chris
>
> Swavek Lorenc wrote:
>> Chris,
>>
>> I tried adding it to the CellRenderer but realized that cell renderer
>> would have to hold this data for each row in a column. It will not scale
>> if you have large number of rows. GridItem is the object which holds
>> style data for the entire row so it is logical to place it there. Plus
>> if virtual management of rows is implemented fully in Grid and I would
>> like to take advantage of it I would have to add virtual managment of
>> alignment information inside CellRenderer as well.
>>
>> I got the code working and could volunter if you are intested. It's a 3
>> line change in DefaultCellRender and a few set/get methods in GridItem.
>>
>> There is another change to DefaultColumnHeaderRender that has to do with
>> alignment. I think this one is easy to add and makes the column header
>> more esthetically pleasing. I think it looks more esthetic to center
>> text in the header of the column rather than left justify it. A simple
>> change to the DefaultColumnHeaderRenderer would make it possible to
>> change the default alignment to center (or even right justified). What
>> do you think abou this change? After adding get/setTextAlignment all is
>> needed is this code in paint method
>> //
>> // draw header text
>> //
>> int textX = getBounds().x + x + pushedDrawingOffset;
>> int textY = y + pushedDrawingOffset;
>> // shorten header text to 'My header text...' to fit within
>> specified column width
>> String headerShortString = TextUtils.getShortString(gc,
>> column.getText(), width);
>> int textWidth = gc.stringExtent(headerShortString).x;
>> if ((textAlignment & SWT.CENTER) != 0)
>> {
>> textX += (width - textWidth) / 2;
>> }
>> else if ((textAlignment & SWT.RIGHT) != 0)
>> {
>> textX += width - textWidth;
>> }
>> gc.drawString(headerShortString, textX, textY, true);
>>
>>
>> replacing this code around line 126
>>
>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>> width),
>> getBounds().x + x + pushedDrawingOffset,
>> y + pushedDrawingOffset,true);
>>
>> Swavek
>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>> news:f1d23c$fqe$2@build.eclipse.org...
>>> Hi Swavek,
>>>
>>> The feature could be added as you suggest but I'm not sure its something
>>> that many people would use. I will consider adding it in the future but
>>> I'm wary of adding feature upon feature that simply make the Grid more
>>> complex. You can always create your own cell renderer to have this
>>> feature in your own app.
>>>
>>> Regards,
>>> -Chris
>>>
>>> Swavek Lorenc wrote:
>>>> I would like to propose adding ability to vary column alignment in grid
>>>> control. Currently you can set it once for the entire column but if
>>>> you want different alignment in each cell of a single column you can't
>>>> do it.
>>>>
>>>> Looking at GridItem implementation I think it could be done in a
>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>> each column. Then the DefaultCellRenderer could retrieve alignment from
>>>> item instead of from itself.
>>>>
>>>> Thanks,
>>>>
>>>> Swavek
>>>>
>>
Re: Could we add text alignment in grid varying by row [message #34116 is a reply to message #34082] Fri, 04 May 2007 15:16 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
Post some screenshots when you're done. I'd like to see it!

-Chris

Swavek Lorenc wrote:
> I am now trying to use GridItem's data map because I decided to implement
> the cell renderer myself. This way I can alter not just alignment but also
> how the bounding rectangle is drawn.
>
> My goal is to display Excel's spreadsheet in a grid as closely as possible
> (fonts, alignment, background and text color) etc. That's why I wanted to
> control alignment on per cell rather than per column basis.
>
> Thanks for suggestion.
>
> Swavek
>
>
> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
> news:f1dg7c$t45$1@build.eclipse.org...
>> Hi Swavek,
>>
>> If you wanted to add this feature in your own renderer you would still
>> want to keep the value of the property on each GridItem. You could store
>> it in the GridItem's data map (i.e. setData(key,value),
>> getData(key,value)).
>>
>> I'd be interested in any patch that you can contribute but please post it
>> to a bugzilla entry and please use a patch file (i.e. CVS Team provider
>> unified patch). But I will have to think about whether to commit each
>> patch. There's a sweet spot somewhere between adding all functionality
>> anyone could ever want in the Grid and just making it extensible so if you
>> want the behavior you can add it yourself.
>>
>> Regards,
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> Chris,
>>>
>>> I tried adding it to the CellRenderer but realized that cell renderer
>>> would have to hold this data for each row in a column. It will not scale
>>> if you have large number of rows. GridItem is the object which holds
>>> style data for the entire row so it is logical to place it there. Plus
>>> if virtual management of rows is implemented fully in Grid and I would
>>> like to take advantage of it I would have to add virtual managment of
>>> alignment information inside CellRenderer as well.
>>>
>>> I got the code working and could volunter if you are intested. It's a 3
>>> line change in DefaultCellRender and a few set/get methods in GridItem.
>>>
>>> There is another change to DefaultColumnHeaderRender that has to do with
>>> alignment. I think this one is easy to add and makes the column header
>>> more esthetically pleasing. I think it looks more esthetic to center
>>> text in the header of the column rather than left justify it. A simple
>>> change to the DefaultColumnHeaderRenderer would make it possible to
>>> change the default alignment to center (or even right justified). What
>>> do you think abou this change? After adding get/setTextAlignment all is
>>> needed is this code in paint method
>>> //
>>> // draw header text
>>> //
>>> int textX = getBounds().x + x + pushedDrawingOffset;
>>> int textY = y + pushedDrawingOffset;
>>> // shorten header text to 'My header text...' to fit within
>>> specified column width
>>> String headerShortString = TextUtils.getShortString(gc,
>>> column.getText(), width);
>>> int textWidth = gc.stringExtent(headerShortString).x;
>>> if ((textAlignment & SWT.CENTER) != 0)
>>> {
>>> textX += (width - textWidth) / 2;
>>> }
>>> else if ((textAlignment & SWT.RIGHT) != 0)
>>> {
>>> textX += width - textWidth;
>>> }
>>> gc.drawString(headerShortString, textX, textY, true);
>>>
>>>
>>> replacing this code around line 126
>>>
>>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>>> width),
>>> getBounds().x + x + pushedDrawingOffset,
>>> y + pushedDrawingOffset,true);
>>>
>>> Swavek
>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>> news:f1d23c$fqe$2@build.eclipse.org...
>>>> Hi Swavek,
>>>>
>>>> The feature could be added as you suggest but I'm not sure its something
>>>> that many people would use. I will consider adding it in the future but
>>>> I'm wary of adding feature upon feature that simply make the Grid more
>>>> complex. You can always create your own cell renderer to have this
>>>> feature in your own app.
>>>>
>>>> Regards,
>>>> -Chris
>>>>
>>>> Swavek Lorenc wrote:
>>>>> I would like to propose adding ability to vary column alignment in grid
>>>>> control. Currently you can set it once for the entire column but if
>>>>> you want different alignment in each cell of a single column you can't
>>>>> do it.
>>>>>
>>>>> Looking at GridItem implementation I think it could be done in a
>>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>>> each column. Then the DefaultCellRenderer could retrieve alignment from
>>>>> item instead of from itself.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Swavek
>>>>>
>
>
Re: Could we add text alignment in grid varying by row [message #34825 is a reply to message #34116] Tue, 15 May 2007 17:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: slorenc.infogix.com

Chris,

What are the chances of adding variable row heights to this upcoming release
of Grid? I had to modify Grid class extensively to get it to work but would
prefer if it was done by you so I don't have to deal with licensing issues.

Swavek


"Chris Gross" <chris.gross@us.ibm.com> wrote in message
news:f1finl$p1c$1@build.eclipse.org...
> Post some screenshots when you're done. I'd like to see it!
>
> -Chris
>
> Swavek Lorenc wrote:
>> I am now trying to use GridItem's data map because I decided to implement
>> the cell renderer myself. This way I can alter not just alignment but
>> also how the bounding rectangle is drawn.
>>
>> My goal is to display Excel's spreadsheet in a grid as closely as
>> possible (fonts, alignment, background and text color) etc. That's why I
>> wanted to control alignment on per cell rather than per column basis.
>>
>> Thanks for suggestion.
>>
>> Swavek
>>
>>
>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>> news:f1dg7c$t45$1@build.eclipse.org...
>>> Hi Swavek,
>>>
>>> If you wanted to add this feature in your own renderer you would still
>>> want to keep the value of the property on each GridItem. You could
>>> store it in the GridItem's data map (i.e. setData(key,value),
>>> getData(key,value)).
>>>
>>> I'd be interested in any patch that you can contribute but please post
>>> it to a bugzilla entry and please use a patch file (i.e. CVS Team
>>> provider unified patch). But I will have to think about whether to
>>> commit each patch. There's a sweet spot somewhere between adding all
>>> functionality anyone could ever want in the Grid and just making it
>>> extensible so if you want the behavior you can add it yourself.
>>>
>>> Regards,
>>> -Chris
>>>
>>> Swavek Lorenc wrote:
>>>> Chris,
>>>>
>>>> I tried adding it to the CellRenderer but realized that cell renderer
>>>> would have to hold this data for each row in a column. It will not
>>>> scale if you have large number of rows. GridItem is the object which
>>>> holds style data for the entire row so it is logical to place it there.
>>>> Plus if virtual management of rows is implemented fully in Grid and I
>>>> would like to take advantage of it I would have to add virtual
>>>> managment of alignment information inside CellRenderer as well.
>>>>
>>>> I got the code working and could volunter if you are intested. It's a
>>>> 3 line change in DefaultCellRender and a few set/get methods in
>>>> GridItem.
>>>>
>>>> There is another change to DefaultColumnHeaderRender that has to do
>>>> with alignment. I think this one is easy to add and makes the column
>>>> header more esthetically pleasing. I think it looks more esthetic to
>>>> center text in the header of the column rather than left justify it. A
>>>> simple change to the DefaultColumnHeaderRenderer would make it possible
>>>> to change the default alignment to center (or even right justified).
>>>> What do you think abou this change? After adding get/setTextAlignment
>>>> all is needed is this code in paint method
>>>> //
>>>> // draw header text
>>>> //
>>>> int textX = getBounds().x + x + pushedDrawingOffset;
>>>> int textY = y + pushedDrawingOffset;
>>>> // shorten header text to 'My header text...' to fit within
>>>> specified column width
>>>> String headerShortString = TextUtils.getShortString(gc,
>>>> column.getText(), width);
>>>> int textWidth = gc.stringExtent(headerShortString).x;
>>>> if ((textAlignment & SWT.CENTER) != 0)
>>>> {
>>>> textX += (width - textWidth) / 2;
>>>> }
>>>> else if ((textAlignment & SWT.RIGHT) != 0)
>>>> {
>>>> textX += width - textWidth;
>>>> }
>>>> gc.drawString(headerShortString, textX, textY, true);
>>>>
>>>>
>>>> replacing this code around line 126
>>>>
>>>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>>>> width),
>>>> getBounds().x + x + pushedDrawingOffset,
>>>> y + pushedDrawingOffset,true);
>>>>
>>>> Swavek
>>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>>> news:f1d23c$fqe$2@build.eclipse.org...
>>>>> Hi Swavek,
>>>>>
>>>>> The feature could be added as you suggest but I'm not sure its
>>>>> something that many people would use. I will consider adding it in
>>>>> the future but I'm wary of adding feature upon feature that simply
>>>>> make the Grid more complex. You can always create your own cell
>>>>> renderer to have this feature in your own app.
>>>>>
>>>>> Regards,
>>>>> -Chris
>>>>>
>>>>> Swavek Lorenc wrote:
>>>>>> I would like to propose adding ability to vary column alignment in
>>>>>> grid control. Currently you can set it once for the entire column
>>>>>> but if you want different alignment in each cell of a single column
>>>>>> you can't do it.
>>>>>>
>>>>>> Looking at GridItem implementation I think it could be done in a
>>>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>>>> each column. Then the DefaultCellRenderer could retrieve alignment
>>>>>> from item instead of from itself.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Swavek
>>>>>>
>>
Re: Could we add text alignment in grid varying by row [message #34899 is a reply to message #34825] Tue, 15 May 2007 20:26 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
I will not be able to add that feature soon. If your code is good
quality and takes into account all the features of Grid then I'd
consider applying it. If you're interested in this, first step is to
create a bugzilla entry and attach a patch.

Regards,
-Chris

Swavek Lorenc wrote:
> Chris,
>
> What are the chances of adding variable row heights to this upcoming release
> of Grid? I had to modify Grid class extensively to get it to work but would
> prefer if it was done by you so I don't have to deal with licensing issues.
>
> Swavek
>
>
> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
> news:f1finl$p1c$1@build.eclipse.org...
>> Post some screenshots when you're done. I'd like to see it!
>>
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> I am now trying to use GridItem's data map because I decided to implement
>>> the cell renderer myself. This way I can alter not just alignment but
>>> also how the bounding rectangle is drawn.
>>>
>>> My goal is to display Excel's spreadsheet in a grid as closely as
>>> possible (fonts, alignment, background and text color) etc. That's why I
>>> wanted to control alignment on per cell rather than per column basis.
>>>
>>> Thanks for suggestion.
>>>
>>> Swavek
>>>
>>>
>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>> news:f1dg7c$t45$1@build.eclipse.org...
>>>> Hi Swavek,
>>>>
>>>> If you wanted to add this feature in your own renderer you would still
>>>> want to keep the value of the property on each GridItem. You could
>>>> store it in the GridItem's data map (i.e. setData(key,value),
>>>> getData(key,value)).
>>>>
>>>> I'd be interested in any patch that you can contribute but please post
>>>> it to a bugzilla entry and please use a patch file (i.e. CVS Team
>>>> provider unified patch). But I will have to think about whether to
>>>> commit each patch. There's a sweet spot somewhere between adding all
>>>> functionality anyone could ever want in the Grid and just making it
>>>> extensible so if you want the behavior you can add it yourself.
>>>>
>>>> Regards,
>>>> -Chris
>>>>
>>>> Swavek Lorenc wrote:
>>>>> Chris,
>>>>>
>>>>> I tried adding it to the CellRenderer but realized that cell renderer
>>>>> would have to hold this data for each row in a column. It will not
>>>>> scale if you have large number of rows. GridItem is the object which
>>>>> holds style data for the entire row so it is logical to place it there.
>>>>> Plus if virtual management of rows is implemented fully in Grid and I
>>>>> would like to take advantage of it I would have to add virtual
>>>>> managment of alignment information inside CellRenderer as well.
>>>>>
>>>>> I got the code working and could volunter if you are intested. It's a
>>>>> 3 line change in DefaultCellRender and a few set/get methods in
>>>>> GridItem.
>>>>>
>>>>> There is another change to DefaultColumnHeaderRender that has to do
>>>>> with alignment. I think this one is easy to add and makes the column
>>>>> header more esthetically pleasing. I think it looks more esthetic to
>>>>> center text in the header of the column rather than left justify it. A
>>>>> simple change to the DefaultColumnHeaderRenderer would make it possible
>>>>> to change the default alignment to center (or even right justified).
>>>>> What do you think abou this change? After adding get/setTextAlignment
>>>>> all is needed is this code in paint method
>>>>> //
>>>>> // draw header text
>>>>> //
>>>>> int textX = getBounds().x + x + pushedDrawingOffset;
>>>>> int textY = y + pushedDrawingOffset;
>>>>> // shorten header text to 'My header text...' to fit within
>>>>> specified column width
>>>>> String headerShortString = TextUtils.getShortString(gc,
>>>>> column.getText(), width);
>>>>> int textWidth = gc.stringExtent(headerShortString).x;
>>>>> if ((textAlignment & SWT.CENTER) != 0)
>>>>> {
>>>>> textX += (width - textWidth) / 2;
>>>>> }
>>>>> else if ((textAlignment & SWT.RIGHT) != 0)
>>>>> {
>>>>> textX += width - textWidth;
>>>>> }
>>>>> gc.drawString(headerShortString, textX, textY, true);
>>>>>
>>>>>
>>>>> replacing this code around line 126
>>>>>
>>>>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>>>>> width),
>>>>> getBounds().x + x + pushedDrawingOffset,
>>>>> y + pushedDrawingOffset,true);
>>>>>
>>>>> Swavek
>>>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>>>> news:f1d23c$fqe$2@build.eclipse.org...
>>>>>> Hi Swavek,
>>>>>>
>>>>>> The feature could be added as you suggest but I'm not sure its
>>>>>> something that many people would use. I will consider adding it in
>>>>>> the future but I'm wary of adding feature upon feature that simply
>>>>>> make the Grid more complex. You can always create your own cell
>>>>>> renderer to have this feature in your own app.
>>>>>>
>>>>>> Regards,
>>>>>> -Chris
>>>>>>
>>>>>> Swavek Lorenc wrote:
>>>>>>> I would like to propose adding ability to vary column alignment in
>>>>>>> grid control. Currently you can set it once for the entire column
>>>>>>> but if you want different alignment in each cell of a single column
>>>>>>> you can't do it.
>>>>>>>
>>>>>>> Looking at GridItem implementation I think it could be done in a
>>>>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>>>>> each column. Then the DefaultCellRenderer could retrieve alignment
>>>>>>> from item instead of from itself.
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Swavek
>>>>>>>
>
Re: Could we add text alignment in grid varying by row [message #581763 is a reply to message #33953] Thu, 03 May 2007 16:20 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Hi Swavek,

The feature could be added as you suggest but I'm not sure its something
that many people would use. I will consider adding it in the future but
I'm wary of adding feature upon feature that simply make the Grid more
complex. You can always create your own cell renderer to have this
feature in your own app.

Regards,
-Chris

Swavek Lorenc wrote:
> I would like to propose adding ability to vary column alignment in grid
> control. Currently you can set it once for the entire column but if you
> want different alignment in each cell of a single column you can't do it.
>
> Looking at GridItem implementation I think it could be done in a similar
> manner to how the text, fonts and backgrounds are saved for each column.
> Then the DefaultCellRenderer could retrieve alignment from item instead of
> from itself.
>
> Thanks,
>
> Swavek
>
>
Re: Could we add text alignment in grid varying by row [message #581787 is a reply to message #34007] Thu, 03 May 2007 19:43 Go to previous message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
Chris,

I tried adding it to the CellRenderer but realized that cell renderer would
have to hold this data for each row in a column. It will not scale if you
have large number of rows. GridItem is the object which holds style data
for the entire row so it is logical to place it there. Plus if virtual
management of rows is implemented fully in Grid and I would like to take
advantage of it I would have to add virtual managment of alignment
information inside CellRenderer as well.

I got the code working and could volunter if you are intested. It's a 3
line change in DefaultCellRender and a few set/get methods in GridItem.

There is another change to DefaultColumnHeaderRender that has to do with
alignment. I think this one is easy to add and makes the column header more
esthetically pleasing. I think it looks more esthetic to center text in the
header of the column rather than left justify it. A simple change to the
DefaultColumnHeaderRenderer would make it possible to change the default
alignment to center (or even right justified). What do you think abou this
change? After adding get/setTextAlignment all is needed is this code in
paint method
//
// draw header text
//
int textX = getBounds().x + x + pushedDrawingOffset;
int textY = y + pushedDrawingOffset;
// shorten header text to 'My header text...' to fit within
specified column width
String headerShortString = TextUtils.getShortString(gc,
column.getText(), width);
int textWidth = gc.stringExtent(headerShortString).x;
if ((textAlignment & SWT.CENTER) != 0)
{
textX += (width - textWidth) / 2;
}
else if ((textAlignment & SWT.RIGHT) != 0)
{
textX += width - textWidth;
}
gc.drawString(headerShortString, textX, textY, true);


replacing this code around line 126

gc.drawString(TextUtils.getShortString(gc, column.getText(), width),
getBounds().x + x + pushedDrawingOffset,
y + pushedDrawingOffset,true);

Swavek
"Chris Gross" <chris.gross@us.ibm.com> wrote in message
news:f1d23c$fqe$2@build.eclipse.org...
> Hi Swavek,
>
> The feature could be added as you suggest but I'm not sure its something
> that many people would use. I will consider adding it in the future but
> I'm wary of adding feature upon feature that simply make the Grid more
> complex. You can always create your own cell renderer to have this
> feature in your own app.
>
> Regards,
> -Chris
>
> Swavek Lorenc wrote:
>> I would like to propose adding ability to vary column alignment in grid
>> control. Currently you can set it once for the entire column but if you
>> want different alignment in each cell of a single column you can't do it.
>>
>> Looking at GridItem implementation I think it could be done in a similar
>> manner to how the text, fonts and backgrounds are saved for each column.
>> Then the DefaultCellRenderer could retrieve alignment from item instead
>> of from itself.
>>
>> Thanks,
>>
>> Swavek
>>
Re: Could we add text alignment in grid varying by row [message #581830 is a reply to message #34025] Thu, 03 May 2007 20:21 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Hi Swavek,

If you wanted to add this feature in your own renderer you would still
want to keep the value of the property on each GridItem. You could
store it in the GridItem's data map (i.e. setData(key,value),
getData(key,value)).

I'd be interested in any patch that you can contribute but please post
it to a bugzilla entry and please use a patch file (i.e. CVS Team
provider unified patch). But I will have to think about whether to
commit each patch. There's a sweet spot somewhere between adding all
functionality anyone could ever want in the Grid and just making it
extensible so if you want the behavior you can add it yourself.

Regards,
-Chris

Swavek Lorenc wrote:
> Chris,
>
> I tried adding it to the CellRenderer but realized that cell renderer would
> have to hold this data for each row in a column. It will not scale if you
> have large number of rows. GridItem is the object which holds style data
> for the entire row so it is logical to place it there. Plus if virtual
> management of rows is implemented fully in Grid and I would like to take
> advantage of it I would have to add virtual managment of alignment
> information inside CellRenderer as well.
>
> I got the code working and could volunter if you are intested. It's a 3
> line change in DefaultCellRender and a few set/get methods in GridItem.
>
> There is another change to DefaultColumnHeaderRender that has to do with
> alignment. I think this one is easy to add and makes the column header more
> esthetically pleasing. I think it looks more esthetic to center text in the
> header of the column rather than left justify it. A simple change to the
> DefaultColumnHeaderRenderer would make it possible to change the default
> alignment to center (or even right justified). What do you think abou this
> change? After adding get/setTextAlignment all is needed is this code in
> paint method
> //
> // draw header text
> //
> int textX = getBounds().x + x + pushedDrawingOffset;
> int textY = y + pushedDrawingOffset;
> // shorten header text to 'My header text...' to fit within
> specified column width
> String headerShortString = TextUtils.getShortString(gc,
> column.getText(), width);
> int textWidth = gc.stringExtent(headerShortString).x;
> if ((textAlignment & SWT.CENTER) != 0)
> {
> textX += (width - textWidth) / 2;
> }
> else if ((textAlignment & SWT.RIGHT) != 0)
> {
> textX += width - textWidth;
> }
> gc.drawString(headerShortString, textX, textY, true);
>
>
> replacing this code around line 126
>
> gc.drawString(TextUtils.getShortString(gc, column.getText(), width),
> getBounds().x + x + pushedDrawingOffset,
> y + pushedDrawingOffset,true);
>
> Swavek
> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
> news:f1d23c$fqe$2@build.eclipse.org...
>> Hi Swavek,
>>
>> The feature could be added as you suggest but I'm not sure its something
>> that many people would use. I will consider adding it in the future but
>> I'm wary of adding feature upon feature that simply make the Grid more
>> complex. You can always create your own cell renderer to have this
>> feature in your own app.
>>
>> Regards,
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> I would like to propose adding ability to vary column alignment in grid
>>> control. Currently you can set it once for the entire column but if you
>>> want different alignment in each cell of a single column you can't do it.
>>>
>>> Looking at GridItem implementation I think it could be done in a similar
>>> manner to how the text, fonts and backgrounds are saved for each column.
>>> Then the DefaultCellRenderer could retrieve alignment from item instead
>>> of from itself.
>>>
>>> Thanks,
>>>
>>> Swavek
>>>
>
Re: Could we add text alignment in grid varying by row [message #581853 is a reply to message #34052] Thu, 03 May 2007 20:56 Go to previous message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
I am now trying to use GridItem's data map because I decided to implement
the cell renderer myself. This way I can alter not just alignment but also
how the bounding rectangle is drawn.

My goal is to display Excel's spreadsheet in a grid as closely as possible
(fonts, alignment, background and text color) etc. That's why I wanted to
control alignment on per cell rather than per column basis.

Thanks for suggestion.

Swavek


"Chris Gross" <chris.gross@us.ibm.com> wrote in message
news:f1dg7c$t45$1@build.eclipse.org...
> Hi Swavek,
>
> If you wanted to add this feature in your own renderer you would still
> want to keep the value of the property on each GridItem. You could store
> it in the GridItem's data map (i.e. setData(key,value),
> getData(key,value)).
>
> I'd be interested in any patch that you can contribute but please post it
> to a bugzilla entry and please use a patch file (i.e. CVS Team provider
> unified patch). But I will have to think about whether to commit each
> patch. There's a sweet spot somewhere between adding all functionality
> anyone could ever want in the Grid and just making it extensible so if you
> want the behavior you can add it yourself.
>
> Regards,
> -Chris
>
> Swavek Lorenc wrote:
>> Chris,
>>
>> I tried adding it to the CellRenderer but realized that cell renderer
>> would have to hold this data for each row in a column. It will not scale
>> if you have large number of rows. GridItem is the object which holds
>> style data for the entire row so it is logical to place it there. Plus
>> if virtual management of rows is implemented fully in Grid and I would
>> like to take advantage of it I would have to add virtual managment of
>> alignment information inside CellRenderer as well.
>>
>> I got the code working and could volunter if you are intested. It's a 3
>> line change in DefaultCellRender and a few set/get methods in GridItem.
>>
>> There is another change to DefaultColumnHeaderRender that has to do with
>> alignment. I think this one is easy to add and makes the column header
>> more esthetically pleasing. I think it looks more esthetic to center
>> text in the header of the column rather than left justify it. A simple
>> change to the DefaultColumnHeaderRenderer would make it possible to
>> change the default alignment to center (or even right justified). What
>> do you think abou this change? After adding get/setTextAlignment all is
>> needed is this code in paint method
>> //
>> // draw header text
>> //
>> int textX = getBounds().x + x + pushedDrawingOffset;
>> int textY = y + pushedDrawingOffset;
>> // shorten header text to 'My header text...' to fit within
>> specified column width
>> String headerShortString = TextUtils.getShortString(gc,
>> column.getText(), width);
>> int textWidth = gc.stringExtent(headerShortString).x;
>> if ((textAlignment & SWT.CENTER) != 0)
>> {
>> textX += (width - textWidth) / 2;
>> }
>> else if ((textAlignment & SWT.RIGHT) != 0)
>> {
>> textX += width - textWidth;
>> }
>> gc.drawString(headerShortString, textX, textY, true);
>>
>>
>> replacing this code around line 126
>>
>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>> width),
>> getBounds().x + x + pushedDrawingOffset,
>> y + pushedDrawingOffset,true);
>>
>> Swavek
>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>> news:f1d23c$fqe$2@build.eclipse.org...
>>> Hi Swavek,
>>>
>>> The feature could be added as you suggest but I'm not sure its something
>>> that many people would use. I will consider adding it in the future but
>>> I'm wary of adding feature upon feature that simply make the Grid more
>>> complex. You can always create your own cell renderer to have this
>>> feature in your own app.
>>>
>>> Regards,
>>> -Chris
>>>
>>> Swavek Lorenc wrote:
>>>> I would like to propose adding ability to vary column alignment in grid
>>>> control. Currently you can set it once for the entire column but if
>>>> you want different alignment in each cell of a single column you can't
>>>> do it.
>>>>
>>>> Looking at GridItem implementation I think it could be done in a
>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>> each column. Then the DefaultCellRenderer could retrieve alignment from
>>>> item instead of from itself.
>>>>
>>>> Thanks,
>>>>
>>>> Swavek
>>>>
>>
Re: Could we add text alignment in grid varying by row [message #581873 is a reply to message #34082] Fri, 04 May 2007 15:16 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Post some screenshots when you're done. I'd like to see it!

-Chris

Swavek Lorenc wrote:
> I am now trying to use GridItem's data map because I decided to implement
> the cell renderer myself. This way I can alter not just alignment but also
> how the bounding rectangle is drawn.
>
> My goal is to display Excel's spreadsheet in a grid as closely as possible
> (fonts, alignment, background and text color) etc. That's why I wanted to
> control alignment on per cell rather than per column basis.
>
> Thanks for suggestion.
>
> Swavek
>
>
> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
> news:f1dg7c$t45$1@build.eclipse.org...
>> Hi Swavek,
>>
>> If you wanted to add this feature in your own renderer you would still
>> want to keep the value of the property on each GridItem. You could store
>> it in the GridItem's data map (i.e. setData(key,value),
>> getData(key,value)).
>>
>> I'd be interested in any patch that you can contribute but please post it
>> to a bugzilla entry and please use a patch file (i.e. CVS Team provider
>> unified patch). But I will have to think about whether to commit each
>> patch. There's a sweet spot somewhere between adding all functionality
>> anyone could ever want in the Grid and just making it extensible so if you
>> want the behavior you can add it yourself.
>>
>> Regards,
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> Chris,
>>>
>>> I tried adding it to the CellRenderer but realized that cell renderer
>>> would have to hold this data for each row in a column. It will not scale
>>> if you have large number of rows. GridItem is the object which holds
>>> style data for the entire row so it is logical to place it there. Plus
>>> if virtual management of rows is implemented fully in Grid and I would
>>> like to take advantage of it I would have to add virtual managment of
>>> alignment information inside CellRenderer as well.
>>>
>>> I got the code working and could volunter if you are intested. It's a 3
>>> line change in DefaultCellRender and a few set/get methods in GridItem.
>>>
>>> There is another change to DefaultColumnHeaderRender that has to do with
>>> alignment. I think this one is easy to add and makes the column header
>>> more esthetically pleasing. I think it looks more esthetic to center
>>> text in the header of the column rather than left justify it. A simple
>>> change to the DefaultColumnHeaderRenderer would make it possible to
>>> change the default alignment to center (or even right justified). What
>>> do you think abou this change? After adding get/setTextAlignment all is
>>> needed is this code in paint method
>>> //
>>> // draw header text
>>> //
>>> int textX = getBounds().x + x + pushedDrawingOffset;
>>> int textY = y + pushedDrawingOffset;
>>> // shorten header text to 'My header text...' to fit within
>>> specified column width
>>> String headerShortString = TextUtils.getShortString(gc,
>>> column.getText(), width);
>>> int textWidth = gc.stringExtent(headerShortString).x;
>>> if ((textAlignment & SWT.CENTER) != 0)
>>> {
>>> textX += (width - textWidth) / 2;
>>> }
>>> else if ((textAlignment & SWT.RIGHT) != 0)
>>> {
>>> textX += width - textWidth;
>>> }
>>> gc.drawString(headerShortString, textX, textY, true);
>>>
>>>
>>> replacing this code around line 126
>>>
>>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>>> width),
>>> getBounds().x + x + pushedDrawingOffset,
>>> y + pushedDrawingOffset,true);
>>>
>>> Swavek
>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>> news:f1d23c$fqe$2@build.eclipse.org...
>>>> Hi Swavek,
>>>>
>>>> The feature could be added as you suggest but I'm not sure its something
>>>> that many people would use. I will consider adding it in the future but
>>>> I'm wary of adding feature upon feature that simply make the Grid more
>>>> complex. You can always create your own cell renderer to have this
>>>> feature in your own app.
>>>>
>>>> Regards,
>>>> -Chris
>>>>
>>>> Swavek Lorenc wrote:
>>>>> I would like to propose adding ability to vary column alignment in grid
>>>>> control. Currently you can set it once for the entire column but if
>>>>> you want different alignment in each cell of a single column you can't
>>>>> do it.
>>>>>
>>>>> Looking at GridItem implementation I think it could be done in a
>>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>>> each column. Then the DefaultCellRenderer could retrieve alignment from
>>>>> item instead of from itself.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Swavek
>>>>>
>
>
Re: Could we add text alignment in grid varying by row [message #582317 is a reply to message #34116] Tue, 15 May 2007 17:43 Go to previous message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
Chris,

What are the chances of adding variable row heights to this upcoming release
of Grid? I had to modify Grid class extensively to get it to work but would
prefer if it was done by you so I don't have to deal with licensing issues.

Swavek


"Chris Gross" <chris.gross@us.ibm.com> wrote in message
news:f1finl$p1c$1@build.eclipse.org...
> Post some screenshots when you're done. I'd like to see it!
>
> -Chris
>
> Swavek Lorenc wrote:
>> I am now trying to use GridItem's data map because I decided to implement
>> the cell renderer myself. This way I can alter not just alignment but
>> also how the bounding rectangle is drawn.
>>
>> My goal is to display Excel's spreadsheet in a grid as closely as
>> possible (fonts, alignment, background and text color) etc. That's why I
>> wanted to control alignment on per cell rather than per column basis.
>>
>> Thanks for suggestion.
>>
>> Swavek
>>
>>
>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>> news:f1dg7c$t45$1@build.eclipse.org...
>>> Hi Swavek,
>>>
>>> If you wanted to add this feature in your own renderer you would still
>>> want to keep the value of the property on each GridItem. You could
>>> store it in the GridItem's data map (i.e. setData(key,value),
>>> getData(key,value)).
>>>
>>> I'd be interested in any patch that you can contribute but please post
>>> it to a bugzilla entry and please use a patch file (i.e. CVS Team
>>> provider unified patch). But I will have to think about whether to
>>> commit each patch. There's a sweet spot somewhere between adding all
>>> functionality anyone could ever want in the Grid and just making it
>>> extensible so if you want the behavior you can add it yourself.
>>>
>>> Regards,
>>> -Chris
>>>
>>> Swavek Lorenc wrote:
>>>> Chris,
>>>>
>>>> I tried adding it to the CellRenderer but realized that cell renderer
>>>> would have to hold this data for each row in a column. It will not
>>>> scale if you have large number of rows. GridItem is the object which
>>>> holds style data for the entire row so it is logical to place it there.
>>>> Plus if virtual management of rows is implemented fully in Grid and I
>>>> would like to take advantage of it I would have to add virtual
>>>> managment of alignment information inside CellRenderer as well.
>>>>
>>>> I got the code working and could volunter if you are intested. It's a
>>>> 3 line change in DefaultCellRender and a few set/get methods in
>>>> GridItem.
>>>>
>>>> There is another change to DefaultColumnHeaderRender that has to do
>>>> with alignment. I think this one is easy to add and makes the column
>>>> header more esthetically pleasing. I think it looks more esthetic to
>>>> center text in the header of the column rather than left justify it. A
>>>> simple change to the DefaultColumnHeaderRenderer would make it possible
>>>> to change the default alignment to center (or even right justified).
>>>> What do you think abou this change? After adding get/setTextAlignment
>>>> all is needed is this code in paint method
>>>> //
>>>> // draw header text
>>>> //
>>>> int textX = getBounds().x + x + pushedDrawingOffset;
>>>> int textY = y + pushedDrawingOffset;
>>>> // shorten header text to 'My header text...' to fit within
>>>> specified column width
>>>> String headerShortString = TextUtils.getShortString(gc,
>>>> column.getText(), width);
>>>> int textWidth = gc.stringExtent(headerShortString).x;
>>>> if ((textAlignment & SWT.CENTER) != 0)
>>>> {
>>>> textX += (width - textWidth) / 2;
>>>> }
>>>> else if ((textAlignment & SWT.RIGHT) != 0)
>>>> {
>>>> textX += width - textWidth;
>>>> }
>>>> gc.drawString(headerShortString, textX, textY, true);
>>>>
>>>>
>>>> replacing this code around line 126
>>>>
>>>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>>>> width),
>>>> getBounds().x + x + pushedDrawingOffset,
>>>> y + pushedDrawingOffset,true);
>>>>
>>>> Swavek
>>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>>> news:f1d23c$fqe$2@build.eclipse.org...
>>>>> Hi Swavek,
>>>>>
>>>>> The feature could be added as you suggest but I'm not sure its
>>>>> something that many people would use. I will consider adding it in
>>>>> the future but I'm wary of adding feature upon feature that simply
>>>>> make the Grid more complex. You can always create your own cell
>>>>> renderer to have this feature in your own app.
>>>>>
>>>>> Regards,
>>>>> -Chris
>>>>>
>>>>> Swavek Lorenc wrote:
>>>>>> I would like to propose adding ability to vary column alignment in
>>>>>> grid control. Currently you can set it once for the entire column
>>>>>> but if you want different alignment in each cell of a single column
>>>>>> you can't do it.
>>>>>>
>>>>>> Looking at GridItem implementation I think it could be done in a
>>>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>>>> each column. Then the DefaultCellRenderer could retrieve alignment
>>>>>> from item instead of from itself.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Swavek
>>>>>>
>>
Re: Could we add text alignment in grid varying by row [message #582355 is a reply to message #34825] Tue, 15 May 2007 20:26 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
I will not be able to add that feature soon. If your code is good
quality and takes into account all the features of Grid then I'd
consider applying it. If you're interested in this, first step is to
create a bugzilla entry and attach a patch.

Regards,
-Chris

Swavek Lorenc wrote:
> Chris,
>
> What are the chances of adding variable row heights to this upcoming release
> of Grid? I had to modify Grid class extensively to get it to work but would
> prefer if it was done by you so I don't have to deal with licensing issues.
>
> Swavek
>
>
> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
> news:f1finl$p1c$1@build.eclipse.org...
>> Post some screenshots when you're done. I'd like to see it!
>>
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> I am now trying to use GridItem's data map because I decided to implement
>>> the cell renderer myself. This way I can alter not just alignment but
>>> also how the bounding rectangle is drawn.
>>>
>>> My goal is to display Excel's spreadsheet in a grid as closely as
>>> possible (fonts, alignment, background and text color) etc. That's why I
>>> wanted to control alignment on per cell rather than per column basis.
>>>
>>> Thanks for suggestion.
>>>
>>> Swavek
>>>
>>>
>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>> news:f1dg7c$t45$1@build.eclipse.org...
>>>> Hi Swavek,
>>>>
>>>> If you wanted to add this feature in your own renderer you would still
>>>> want to keep the value of the property on each GridItem. You could
>>>> store it in the GridItem's data map (i.e. setData(key,value),
>>>> getData(key,value)).
>>>>
>>>> I'd be interested in any patch that you can contribute but please post
>>>> it to a bugzilla entry and please use a patch file (i.e. CVS Team
>>>> provider unified patch). But I will have to think about whether to
>>>> commit each patch. There's a sweet spot somewhere between adding all
>>>> functionality anyone could ever want in the Grid and just making it
>>>> extensible so if you want the behavior you can add it yourself.
>>>>
>>>> Regards,
>>>> -Chris
>>>>
>>>> Swavek Lorenc wrote:
>>>>> Chris,
>>>>>
>>>>> I tried adding it to the CellRenderer but realized that cell renderer
>>>>> would have to hold this data for each row in a column. It will not
>>>>> scale if you have large number of rows. GridItem is the object which
>>>>> holds style data for the entire row so it is logical to place it there.
>>>>> Plus if virtual management of rows is implemented fully in Grid and I
>>>>> would like to take advantage of it I would have to add virtual
>>>>> managment of alignment information inside CellRenderer as well.
>>>>>
>>>>> I got the code working and could volunter if you are intested. It's a
>>>>> 3 line change in DefaultCellRender and a few set/get methods in
>>>>> GridItem.
>>>>>
>>>>> There is another change to DefaultColumnHeaderRender that has to do
>>>>> with alignment. I think this one is easy to add and makes the column
>>>>> header more esthetically pleasing. I think it looks more esthetic to
>>>>> center text in the header of the column rather than left justify it. A
>>>>> simple change to the DefaultColumnHeaderRenderer would make it possible
>>>>> to change the default alignment to center (or even right justified).
>>>>> What do you think abou this change? After adding get/setTextAlignment
>>>>> all is needed is this code in paint method
>>>>> //
>>>>> // draw header text
>>>>> //
>>>>> int textX = getBounds().x + x + pushedDrawingOffset;
>>>>> int textY = y + pushedDrawingOffset;
>>>>> // shorten header text to 'My header text...' to fit within
>>>>> specified column width
>>>>> String headerShortString = TextUtils.getShortString(gc,
>>>>> column.getText(), width);
>>>>> int textWidth = gc.stringExtent(headerShortString).x;
>>>>> if ((textAlignment & SWT.CENTER) != 0)
>>>>> {
>>>>> textX += (width - textWidth) / 2;
>>>>> }
>>>>> else if ((textAlignment & SWT.RIGHT) != 0)
>>>>> {
>>>>> textX += width - textWidth;
>>>>> }
>>>>> gc.drawString(headerShortString, textX, textY, true);
>>>>>
>>>>>
>>>>> replacing this code around line 126
>>>>>
>>>>> gc.drawString(TextUtils.getShortString(gc, column.getText(),
>>>>> width),
>>>>> getBounds().x + x + pushedDrawingOffset,
>>>>> y + pushedDrawingOffset,true);
>>>>>
>>>>> Swavek
>>>>> "Chris Gross" <chris.gross@us.ibm.com> wrote in message
>>>>> news:f1d23c$fqe$2@build.eclipse.org...
>>>>>> Hi Swavek,
>>>>>>
>>>>>> The feature could be added as you suggest but I'm not sure its
>>>>>> something that many people would use. I will consider adding it in
>>>>>> the future but I'm wary of adding feature upon feature that simply
>>>>>> make the Grid more complex. You can always create your own cell
>>>>>> renderer to have this feature in your own app.
>>>>>>
>>>>>> Regards,
>>>>>> -Chris
>>>>>>
>>>>>> Swavek Lorenc wrote:
>>>>>>> I would like to propose adding ability to vary column alignment in
>>>>>>> grid control. Currently you can set it once for the entire column
>>>>>>> but if you want different alignment in each cell of a single column
>>>>>>> you can't do it.
>>>>>>>
>>>>>>> Looking at GridItem implementation I think it could be done in a
>>>>>>> similar manner to how the text, fonts and backgrounds are saved for
>>>>>>> each column. Then the DefaultCellRenderer could retrieve alignment
>>>>>>> from item instead of from itself.
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Swavek
>>>>>>>
>
Previous Topic:DND for PShelf?
Next Topic:dynamic number of columns in CompositeTable
Goto Forum:
  


Current Time: Tue Apr 16 19:27:07 GMT 2024

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

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

Back to the top