Xojo Conferences
XDCMay2019MiamiUSA

Re: How to prevent 'proportionlal spacing' in listboxes (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: possible to permanently cast to parent?
Next thread: scroll multiple editfields


Win32 API Declares   -   Berg, Heath
  Re: How to prevent 'proportionlal spacing' in listboxes   -   keatk comcast.net
    Re: How to prevent 'proportionlal spacing' in listboxes   -   Joseph J. Strout
    Re: How to prevent 'proportionlal spacing' in listboxes   -   keatk comcast.net
    Re: How to prevent 'proportionlal spacing' in listboxes   -   Joseph J. Strout
    How to prevent 'proportionlal spacing' in listboxes   -   Stefan Pantke
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Joseph J. Strout
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Charles Yeomans
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Stefan Pantke
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Stefan Pantke
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Charles Yeomans
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Joseph J. Strout
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Dennis Birch
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Paul Dobbs
     Re: How to prevent 'proportionlal spacing' in listboxes   -   Dennis Birch

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 16:52 (Mon, 01 Aug 2005 15:52:43 +0000)
From: keatk comcast.net
In cell TextPaint::
Dim Ypos as integer

g.DrawString theString 0, Round((g.Height - g.TextHeight)/2) + g.TextAscent

-------------- Original message --------------

>
> Am 01.08.2005 um 16:56 schrieb Charles Yeomans:
>
> > On Jul 31, 2005, at 12:30 PM, Dennis Birch wrote:
> >
> >> At 8:33 AM -0500 7/31/05, Paul Dobbs wrote:
> >>
> >>> You could draw the text yourself. Take a look at the
> >>> CellTextPaint event.
> >>>
> >>> On Jul 30, 2005, at 11:05 PM, Stefan Pantke wrote:
> >>>
> >>>> If a list box cell contains too much text, RB seems to compress
> >>>> the entire text, even if the compressed text doesn't fit in the
> >>>> cell.
> >>>>
> >>>> Unfortunately, the results of cells look ugly in this case. May
> >>>> I disable
> >>>> this feature, which seems to me more like a bug, than a feature?
> >>
> >> From a different angle: does anybody know if there is a way
> >> (declares?) to get the truncated text that is used in a listbox if
> >> a string is too long to fit within the confines of your column width?
> >
> > Try this code; I've posted it before.
> >
> > Function Truncate(Extends g as Graphics, input as String, width as
> > Integer) as String
> > dim leftEndpoint, rightEndpoint as Integer
> > dim midpoint as Integer
> >
> > Const Ellipsis = "..."
> >
> > If g.StringWidth(input) <= width then
> > Return input
> > End if
> >
> > leftEndpoint = 1
> > rightEndpoint = Len(input)
> > While (rightEndpoint - leftEndpoint > 0)
> > midpoint = (leftEndpoint + rightEndpoint)\2
> > If g.StringWidth(Left(input, midpoint) + Ellipsis) <= width then
> > leftEndpoint = midpoint + 1
> > Else
> > rightEndpoint = midpoint
> > End if
> > Wend
> >
> > If leftEndpoint = 0 then
> > Return Ellipsis
> > Else
> > Return Left(input, leftEndpoint - 1) + Ellipsis
> > End if
> > End Function
>
> Thanks, Charles, great snippet!
>
> If I implement the CellTextPaint() event like this
>
> >>>
> g.DrawString( g.Truncate( Me.Cell(row,column), g.width ), 0,
> g.Height() )
> return true
> <<<
>
> some pixels at the bottom of each like gets invisible.
>
> I suppose, I have to shift the text a bit, but g.Height()-g.TextAscent
> () moves the line
> far too much up.
>
> Any ideas?
>
> Kinds
> _______________________________________________
> Unsubscribe or switch delivery mode:
>
> Search the archives of this list here:
>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 17:22 (Mon, 1 Aug 2005 10:22:31 -0600)
From: Joseph J. Strout
At 3:52 PM +0000 8/1/05, <email address removed> wrote:

>In cell TextPaint::
>Dim Ypos as integer
>
>g.DrawString theString 0, Round((g.Height - g.TextHeight)/2) + g.TextAscent

No, you should instead do:

g.DrawString me.Cell(row, column), x, y

We have already computed the correct x and y position for drawing the
text; best results will be obtained by just using that rather than
trying to compute it yourself.

Best,
- Joe

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 17:59 (Mon, 01 Aug 2005 16:59:46 +0000)
From: keatk comcast.net
Hi Joe,

>> g.DrawString me.Cell(row, column), x, y
>
> We have already computed the correct x and y position for drawing the
> text; best results will be obtained by just using that rather than
> trying to compute it yourself.

Is there are reason not to assume you the above would work?

Why I ask is that I do things like that because I sometimes change things like font or textize or put multi-line text into listbox cells depending on the specific data for the cell etc ... and so I then can not count on the passed text position and that type of calculation is the most general solution

As I understand it the graphic object passed into the CellTextPaint event already accounts for just about everything (if hierachial, if checkbox present, if has rowpicture) except maybe gridlines. My code relies on this assumption an if that is a wrong assumption I would like to know it and what the right algorithim would be!

Thanks,
- Karen
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 18:20 (Mon, 1 Aug 2005 11:20:42 -0600)
From: Joseph J. Strout
At 4:59 PM +0000 8/1/05, <email address removed> wrote:

> > We have already computed the correct x and y position for drawing the
>> text; best results will be obtained by just using that rather than
>> trying to compute it yourself.
>
>Is there are reason not to assume you the above would work?

Well, yes. For example, you're drawing at X position 0; that's not
necessarily where the text should go (I imagine the standard position
is something like 2 or 3).

>As I understand it the graphic object passed into the CellTextPaint
>event already accounts for just about everything (if hierachial, if
>checkbox present, if has rowpicture) except maybe gridlines. My code
>relies on this assumption an if that is a wrong assumption I would
>like to know it and what the right algorithim would be!

Even if it's right -- and I don't know whether that's the case -- I
wouldn't consider it a safe assumption. The X and Y values are
passed in explicitly *because* we know where the text should be
drawn, and don't guarantee that calculations like yours will produce
the same answer.

Best,
- Joe

How to prevent 'proportionlal spacing' in listboxes
Date: 31.07.05 05:05 (Sun, 31 Jul 2005 06:05:34 +0200)
From: Stefan Pantke

If a list box cell contains too much text, RB seems to compress
the entire text, even if the compressed text doesn't fit in the cell.

Unfortunately, the results of cells look ugly in this case. May I
disable
this feature, which seems to me more like a bug, than a feature?

Kinds
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 15:27 (Mon, 1 Aug 2005 08:27:03 -0600)
From: Joseph J. Strout
At 6:05 AM +0200 7/31/05, Stefan Pantke wrote:

>If a list box cell contains too much text, RB seems to compress
>the entire text, even if the compressed text doesn't fit in the cell.

Right.

>Unfortunately, the results of cells look ugly in this case. May I disable
>this feature, which seems to me more like a bug, than a feature?

You can avoid that feature only by drawing the text yourself in the
CellTextPaint event.

Best,
- Joe

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 15:56 (Mon, 1 Aug 2005 10:56:28 -0400)
From: Charles Yeomans

On Jul 31, 2005, at 12:30 PM, Dennis Birch wrote:

> At 8:33 AM -0500 7/31/05, Paul Dobbs wrote:
>> You could draw the text yourself. Take a look at the CellTextPaint
>> event.
>>
>> On Jul 30, 2005, at 11:05 PM, Stefan Pantke wrote:
>>
>>>
>>> If a list box cell contains too much text, RB seems to compress
>>> the entire text, even if the compressed text doesn't fit in the cell.
>>>
>>> Unfortunately, the results of cells look ugly in this case. May I
>>> disable
>>> this feature, which seems to me more like a bug, than a feature?
>
> From a different angle: does anybody know if there is a way
> (declares?) to get the truncated text that is used in a listbox if a
> string is too long to fit within the confines of your column width?

Try this code; I've posted it before.

Function Truncate(Extends g as Graphics, input as String, width as
Integer) as String
dim leftEndpoint, rightEndpoint as Integer
dim midpoint as Integer

Const Ellipsis = "..."

If g.StringWidth(input) <= width then
Return input
End if

leftEndpoint = 1
rightEndpoint = Len(input)
While (rightEndpoint - leftEndpoint > 0)
midpoint = (leftEndpoint + rightEndpoint)\2
If g.StringWidth(Left(input, midpoint) + Ellipsis) <= width then
leftEndpoint = midpoint + 1
Else
rightEndpoint = midpoint
End if
Wend

If leftEndpoint = 0 then
Return Ellipsis
Else
Return Left(input, leftEndpoint - 1) + Ellipsis
End if
End Function


--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 16:45 (Mon, 1 Aug 2005 17:45:32 +0200)
From: Stefan Pantke

Am 01.08.2005 um 16:56 schrieb Charles Yeomans:

> On Jul 31, 2005, at 12:30 PM, Dennis Birch wrote:
>
>> At 8:33 AM -0500 7/31/05, Paul Dobbs wrote:
>>
>>> You could draw the text yourself. Take a look at the
>>> CellTextPaint event.
>>>
>>> On Jul 30, 2005, at 11:05 PM, Stefan Pantke wrote:
>>>
>>>> If a list box cell contains too much text, RB seems to compress
>>>> the entire text, even if the compressed text doesn't fit in the
>>>> cell.
>>>>
>>>> Unfortunately, the results of cells look ugly in this case. May
>>>> I disable
>>>> this feature, which seems to me more like a bug, than a feature?
>>
>> From a different angle: does anybody know if there is a way
>> (declares?) to get the truncated text that is used in a listbox if
>> a string is too long to fit within the confines of your column width?
>
> Try this code; I've posted it before.
>
> Function Truncate(Extends g as Graphics, input as String, width as
> Integer) as String
> dim leftEndpoint, rightEndpoint as Integer
> dim midpoint as Integer
>
> Const Ellipsis = "..."
>
> If g.StringWidth(input) <= width then
> Return input
> End if
>
> leftEndpoint = 1
> rightEndpoint = Len(input)
> While (rightEndpoint - leftEndpoint > 0)
> midpoint = (leftEndpoint + rightEndpoint)\2
> If g.StringWidth(Left(input, midpoint) + Ellipsis) <= width then
> leftEndpoint = midpoint + 1
> Else
> rightEndpoint = midpoint
> End if
> Wend
>
> If leftEndpoint = 0 then
> Return Ellipsis
> Else
> Return Left(input, leftEndpoint - 1) + Ellipsis
> End if
> End Function

Thanks, Charles, great snippet!

If I implement the CellTextPaint() event like this

>>>
g.DrawString( g.Truncate( Me.Cell(row,column), g.width ), 0,
g.Height() )
return true
<<<

some pixels at the bottom of each like gets invisible.

I suppose, I have to shift the text a bit, but g.Height()-g.TextAscent
() moves the line
far too much up.

Any ideas?

Kinds
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 16:46 (Mon, 1 Aug 2005 17:46:35 +0200)
From: Stefan Pantke

Am 01.08.2005 um 16:27 schrieb Joseph J. Strout:

> At 6:05 AM +0200 7/31/05, Stefan Pantke wrote:
>
>> Unfortunately, the results of cells look ugly in this case. May I
>> disable
>> this feature, which seems to me more like a bug, than a feature?
>>
> You can avoid that feature only by drawing the text yourself in the
> CellTextPaint event.

OK. Although I see no use of the default behaviour, I'll implement
your workaround.

Kinds
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 16:56 (Mon, 1 Aug 2005 11:56:34 -0400)
From: Charles Yeomans

On Aug 1, 2005, at 11:45 AM, Stefan Pantke wrote:

>
> Am 01.08.2005 um 16:56 schrieb Charles Yeomans:
>
>> On Jul 31, 2005, at 12:30 PM, Dennis Birch wrote:
>>
>>> At 8:33 AM -0500 7/31/05, Paul Dobbs wrote:
>>>
>>>> You could draw the text yourself. Take a look at the CellTextPaint
>>>> event.
>>>>
>>>> On Jul 30, 2005, at 11:05 PM, Stefan Pantke wrote:
>>>>
>>>>> If a list box cell contains too much text, RB seems to compress
>>>>> the entire text, even if the compressed text doesn't fit in the
>>>>> cell.
>>>>>
>>>>> Unfortunately, the results of cells look ugly in this case. May I
>>>>> disable
>>>>> this feature, which seems to me more like a bug, than a feature?
>>>
>>> From a different angle: does anybody know if there is a way
>>> (declares?) to get the truncated text that is used in a listbox if a
>>> string is too long to fit within the confines of your column width?
>>
>> Try this code; I've posted it before.
>>
>> Function Truncate(Extends g as Graphics, input as String, width as
>> Integer) as String
>> dim leftEndpoint, rightEndpoint as Integer
>> dim midpoint as Integer
>>
>> Const Ellipsis = "..."
>>
>> If g.StringWidth(input) <= width then
>> Return input
>> End if
>>
>> leftEndpoint = 1
>> rightEndpoint = Len(input)
>> While (rightEndpoint - leftEndpoint > 0)
>> midpoint = (leftEndpoint + rightEndpoint)\2
>> If g.StringWidth(Left(input, midpoint) + Ellipsis) <= width then
>> leftEndpoint = midpoint + 1
>> Else
>> rightEndpoint = midpoint
>> End if
>> Wend
>>
>> If leftEndpoint = 0 then
>> Return Ellipsis
>> Else
>> Return Left(input, leftEndpoint - 1) + Ellipsis
>> End if
>> End Function
>
> Thanks, Charles, great snippet!
>
> If I implement the CellTextPaint() event like this
>
> >>>
> g.DrawString( g.Truncate( Me.Cell(row,column), g.width ), 0,
> g.Height() )
> return true
> <<<
>
> some pixels at the bottom of each like gets invisible.
>
> I suppose, I have to shift the text a bit, but
> g.Height()-g.TextAscent() moves the line
> far too much up.
>
> Any ideas?

Use the default x, y values provided to CellTextPaint.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 17:21 (Mon, 1 Aug 2005 10:21:28 -0600)
From: Joseph J. Strout
At 5:46 PM +0200 8/1/05, Stefan Pantke wrote:

>>You can avoid that feature only by drawing the text yourself in the
>>CellTextPaint event.
>
>OK. Although I see no use of the default behaviour, I'll implement
>your workaround.

Most users like it, as it allows them to see more of the text. But
now you know how to rob your users of this feature. :)

Best,
- Joe

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 01.08.05 22:32 (Mon, 1 Aug 2005 14:32:28 -0700)
From: Dennis Birch
Thanks, Charles. That works very nicely.

At 10:56 AM -0400 8/1/05, Charles Yeomans wrote:
>On Jul 31, 2005, at 12:30 PM, Dennis Birch wrote:
>
>>At 8:33 AM -0500 7/31/05, Paul Dobbs wrote:
>>>You could draw the text yourself. Take a look at the CellTextPaint event.
>>>
>>>On Jul 30, 2005, at 11:05 PM, Stefan Pantke wrote:
>>>
>>>>
>>>>If a list box cell contains too much text, RB seems to compress
>>>>the entire text, even if the compressed text doesn't fit in the cell.
>>>>
>>>>Unfortunately, the results of cells look ugly in this case. May I disable
>>>>this feature, which seems to me more like a bug, than a feature?
>>
>>From a different angle: does anybody know if there is a way
>>(declares?) to get the truncated text that is used in a listbox if
>>a string is too long to fit within the confines of your column
>>width?
>
>Try this code; I've posted it before.
>
>Function Truncate(Extends g as Graphics, input as String, width as
>Integer) as String
> dim leftEndpoint, rightEndpoint as Integer
> dim midpoint as Integer
>
> Const Ellipsis = "..."
>
> If g.StringWidth(input) <= width then
> Return input
> End if
>
> leftEndpoint = 1
> rightEndpoint = Len(input)
> While (rightEndpoint - leftEndpoint > 0)
> midpoint = (leftEndpoint + rightEndpoint)\2
> If g.StringWidth(Left(input, midpoint) + Ellipsis) <= width then
> leftEndpoint = midpoint + 1
> Else
> rightEndpoint = midpoint
> End if
> Wend
>
> If leftEndpoint = 0 then
> Return Ellipsis
> Else
> Return Left(input, leftEndpoint - 1) + Ellipsis
> End if
>End Function
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 31.07.05 14:33 (Sun, 31 Jul 2005 08:33:12 -0500)
From: Paul Dobbs
You could draw the text yourself. Take a look at the CellTextPaint
event.

On Jul 30, 2005, at 11:05 PM, Stefan Pantke wrote:

>
> If a list box cell contains too much text, RB seems to compress
> the entire text, even if the compressed text doesn't fit in the cell.
>
> Unfortunately, the results of cells look ugly in this case. May I
> disable
> this feature, which seems to me more like a bug, than a feature?
>
> Kinds
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

------------------------------------------------------------
Paul Dobbs
<email address removed>
<email address removed>
http://webpages.charter.net/dobbsp
------------------------------------------------------------
There is no evil in the atom; only in men's souls. -- Adlai Stevenson

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: How to prevent 'proportionlal spacing' in listboxes
Date: 31.07.05 17:30 (Sun, 31 Jul 2005 09:30:07 -0700)
From: Dennis Birch
At 8:33 AM -0500 7/31/05, Paul Dobbs wrote:
>You could draw the text yourself. Take a look at the CellTextPaint event.
>
>On Jul 30, 2005, at 11:05 PM, Stefan Pantke wrote:
>
>>
>>If a list box cell contains too much text, RB seems to compress
>>the entire text, even if the compressed text doesn't fit in the cell.
>>
>>Unfortunately, the results of cells look ugly in this case. May I disable
>>this feature, which seems to me more like a bug, than a feature?

From a different angle: does anybody know if there is a way
(declares?) to get the truncated text that is used in a listbox if a
string is too long to fit within the confines of your column width?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>