Questions about wxHVScrolledWindow

27 views
Skip to first unread message

QuentinC

unread,
Apr 11, 2021, 9:01:13 AMApr 11
to wx-u...@googlegroups.com
Hello,

I have several questions about wxHVScrolledWindow:

1. Is it possible / allowed to have rows with different height ? Columns
will always stay constant width.

2. As far as I understand, it is only possible to scroll by the
widtt/height of an entire item.
So the first shown item will always be totally visible and at client
coordinates 0, 0.
Is this correct ?

3. How can I deal with text too long to fit for the entire width of the
control ?
Will there be automatically an horizontal scrollbar if OnColumnWidth()
returns something larger than the width of the control ?
Assuming for this case that there is only one column, if it helps.
Problem: if yes, then this would go against #2, i.e. when scrolling to
the right, items may not be entirely visible on the left.

4. Alternative for #3 if the answer is negative: how can I handle
displaying text on multiple lines ?
Using GetTextExtent, I can know the size needed to display a given
string, but I have the inverse problem: given the client width, how far
can I write / where do I need to cut ?
Do I need to find out where to cut by calling GetTextExtent multiple
times, progressively removing character after character or word after
word until it fits ? Isn't going to be slow ?
I'm using wxGraphicsContext to draw text.

Thank you for your answers.

Vadim Zeitlin

unread,
Apr 11, 2021, 9:46:54 AMApr 11
to wx-u...@googlegroups.com
On Sun, 11 Apr 2021 15:01:00 +0200 QuentinC wrote:

Q> I have several questions about wxHVScrolledWindow:

Note that wxHVScrolledWindow is implemented in wx itself, see the code in
src/generic/vscroll.cpp. This means that not only you can usually answer
any questions about it by looking there, but also that you can easily use
the modified version of the same code in your own program if you want to
change anything.

Q> 1. Is it possible / allowed to have rows with different height ?

Yes, this is the "Var" part.

Q> Columns will always stay constant width.

Using wxVarVScrollHelper, rather than the full wxVarHVScrollHelper, might
be a good idea in this case.

Q> 2. As far as I understand, it is only possible to scroll by the
Q> widtt/height of an entire item. So the first shown item will always be
Q> totally visible and at client coordinates 0, 0.
Q> Is this correct ?

I think so.

Q> 3. How can I deal with text too long to fit for the entire width of the
Q> control ?

You should be able to configure horizontal scrolling independently.

Q> 4. Alternative for #3 if the answer is negative: how can I handle
Q> displaying text on multiple lines ?
Q> Using GetTextExtent, I can know the size needed to display a given
Q> string, but I have the inverse problem: given the client width, how far
Q> can I write / where do I need to cut ?

You can use wxDC::DrawLabel() for this.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

QuentinC

unread,
Apr 12, 2021, 12:22:13 AMApr 12
to wx-u...@googlegroups.com
Hello,

Thank you for the answers, Vadim.

VZ> Note that wxHVScrolledWindow is implemented in wx itself, see the
code in
src/generic/vscroll.cpp. This means that not only you can usually answer
any questions about it by looking there, but also that you can easily
use the modified version of the same code in your own program if you want to

Thank you for the pointer. It isn't always easy to find out where is
what solly based on file name, and to instantly know if it can be found
in common, generic or MSW directory. Though I didn't even thought about
searching anything in source in this case.

Q> 3. How can I deal with text too long to fit for the entire width of
the control ?
VZ> You should be able to configure horizontal scrolling independently.

Do I necessarily need to implement my own variation of
wxHVScrolledWindow for this ?
IN this case the original source will be very useful.

Thank you, and have a nice week.

Vadim Zeitlin

unread,
Apr 12, 2021, 3:32:16 PMApr 12
to wx-u...@googlegroups.com
On Mon, 12 Apr 2021 06:22:01 +0200 QuentinC wrote:

Q> Q> 3. How can I deal with text too long to fit for the entire width of
Q> Q> the control ?
Q> VZ> You should be able to configure horizontal scrolling independently.
Q>
Q> Do I necessarily need to implement my own variation of
Q> wxHVScrolledWindow for this ?

Sorry, I'm really not sure. I think you should be able to just configure
the horizontal scrollbar in your code without interfering with what
wxVarVScrollHelper does for the vertical one, but I haven't tested this at
all.
Reply all
Reply to author
Forward
0 new messages