I derive a class named MyVListBox from wxVListBox. I override OnMeasureItem and return the same value for each item. To implement MyVListBox can insert, I call the function EstimateTotalHeight to get corrent height and set window size. I found that there is an empty area in the end of the MyVListBox. Is it a mistake? I read the source and can't find why. The "htmlbox" sample does same thing.
wxWidgets- 3.1.0 visual studio 2015
Height problem in wxVListBox
-
- Earned a small fee
- Posts: 24
- Joined: Thu Jan 04, 2018 8:05 am
Re: Height problem in wxVListBox
OnMeasureItem doesn't include the margins between two items. You get can those with GetMargins().
From the wxVListBox source:
From the wxVListBox source:
Code: Select all
wxCoord wxVListBox::OnGetRowHeight(size_t line) const
{
return OnMeasureItem(line) + 2*m_ptMargins.y;
}
Use the source, Luke!
-
- Earned a small fee
- Posts: 24
- Joined: Thu Jan 04, 2018 8:05 am
Re: Height problem in wxVListBox
doublemax wrote:OnMeasureItem doesn't include the margins between two items. You get can those with GetMargins().
From the wxVListBox source:Code: Select all
wxCoord wxVListBox::OnGetRowHeight(size_t line) const { return OnMeasureItem(line) + 2*m_ptMargins.y; }
Code: Select all
// we implement OnGetRowHeight() in terms of OnMeasureItem() because this
// allows us to add borders to the items easily
//
// this function is not supposed to be overridden by the derived classes
virtual wxCoord OnGetRowHeight(size_t line) const;
Re: Height problem in wxVListBox
How big is the empty area?
Can you show your code?
Can you show your code?
Use the source, Luke!
-
- Earned a small fee
- Posts: 24
- Joined: Thu Jan 04, 2018 8:05 am
Re: Height problem in wxVListBox
I guess that it's just look like the height of one item.doublemax wrote:How big is the empty area?
Can you show your code?
- Attachments
-
- HybirdButton.rar
- (10.83 KiB) Downloaded 40 times
Re: Height problem in wxVListBox
I only had time for a quick look (on my way to work):
Are you talking about the vlistbox in the popup? If yes, I think the size of the vlistbox is more or less ok ( maybe a few pixels off), the empty area is the OperRecordButton at the bottom of the popup. Set its background color to green or something and you'll see it.
Are you talking about the vlistbox in the popup? If yes, I think the size of the vlistbox is more or less ok ( maybe a few pixels off), the empty area is the OperRecordButton at the bottom of the popup. Set its background color to green or something and you'll see it.
Use the source, Luke!
-
- Earned a small fee
- Posts: 24
- Joined: Thu Jan 04, 2018 8:05 am
Re: Height problem in wxVListBox
I had found the solution. When I calculate the height of the control, I miss the height of border. Then, the control increased the height of an item automatically.doublemax wrote:I only had time for a quick look (on my way to work):
Are you talking about the vlistbox in the popup? If yes, I think the size of the vlistbox is more or less ok ( maybe a few pixels off), the empty area is the OperRecordButton at the bottom of the popup. Set its background color to green or something and you'll see it.