Using wxSizers on high dpi, positions the widgets differently then on low dpi
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
Hi,
Keep the DoGetBestSize() override, if its working.
Thank you.
Keep the DoGetBestSize() override, if its working.
Thank you.
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
Please read the entire post, i've edited it
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
Hhi,
You said that when you overrode DoGetBestSize() everything worked, right?
So, keep that code...
Thank you.
You said that when you overrode DoGetBestSize() everything worked, right?
So, keep that code...
Thank you.
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
I never said I overrode DoGetBestSize() ???
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
PLEASE READ MY ENTIRE POST
_____________________________________
Okay I managed to override DoGetBestClientSize() with my subclass of wxCheckListBox. It looks exactly the same as before . The Only problem is
The source code I modified for DoGetBestClientSize(), has windows specific code :
As you can see I have edited everything after that SendMessage() call.
this function SendMessage() is windows specific , what SendMessage() does it that it gets the height of a single checkbox.
This function MSWGetFullItemSize() is also windows specific , and allot of other stuff is also windows specific
Is there a cross-platform way to override DoGetBestClientSize ?
_____________________________________
Okay I managed to override DoGetBestClientSize() with my subclass of wxCheckListBox. It looks exactly the same as before . The Only problem is
The source code I modified for DoGetBestClientSize(), has windows specific code :
Code: Select all
// find the widest string
int wLine;
int wListbox = 0;
for (unsigned int i = 0; i < m_noItems; i++)
{
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);
if (wLine > wListbox)
wListbox = wLine;
}
// give it some reasonable default value if there are no strings in the
// list
if (wListbox == 0)
wListbox = 6 * GetCharWidth();
// the listbox should be slightly larger than the widest string
wListbox += 3 * GetCharWidth();
// add room for the scrollbar
wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_parent);
// I've made my changes from here:
// don't make the listbox too tall (limit height to 6 and a two quarters items) but don't
// make it too small neither
int hListbox = SendMessage(GetHWND(), LB_GETITEMHEIGHT, 0, 0) * wxMin(wxMax(6, 3), 6);
// Get Some Additional Empty Space
int additional_space = ((((hListbox / 6) / 3)) + ((hListbox / 6) / 9));
// Add it to the hieght
hListbox += additional_space;
wxSize best = wxSize(wListbox, hListbox);
// add room for the checkbox
return MSWGetFullItemSize(best.x, best.y);
this function SendMessage() is windows specific , what SendMessage() does it that it gets the height of a single checkbox.
This function MSWGetFullItemSize() is also windows specific , and allot of other stuff is also windows specific
Is there a cross-platform way to override DoGetBestClientSize ?
Last edited by ibrahim on Fri May 27, 2022 10:39 am, edited 1 time in total.
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
I think you're over-complicating things. Here's what i'd do:
- set a reasonable minimum height for the wxchecklistbox, you could even use different hard-coded values for each platform
- make the sizer row that contains the wxchecklistbox growable
- make the outer window resizable
- store the size of that window when it's closed
- restore the size of that window when it's opened
That way the user can resize the dialog to the size he wants and everyone is happy.
BTW: What's the minimum/maximum number of checkboxes in that control?
- set a reasonable minimum height for the wxchecklistbox, you could even use different hard-coded values for each platform
- make the sizer row that contains the wxchecklistbox growable
- make the outer window resizable
- store the size of that window when it's closed
- restore the size of that window when it's opened
That way the user can resize the dialog to the size he wants and everyone is happy.
BTW: What's the minimum/maximum number of checkboxes in that control?
Use the source, Luke!
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
I could do that , but I want to go with my plan. Please answer my questions....
Edit :
I could actually have a different harcoded size per platform with some preprocessor platform macros.....
But I would rather do this , ONEEYEMAN suggested this
Edit :
I could actually have a different harcoded size per platform with some preprocessor platform macros.....
But I would rather do this , ONEEYEMAN suggested this
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
It could be anything , I only find out at runtime.BTW: What's the minimum/maximum number of checkboxes in that control?
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
I think the cleanest way would be to create a hidden control and measure its size at runtime.
Code: Select all
wxCheckListBox *clb = new wxCheckListBox();
clb->Hide();
clb->Create(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxArrayString() );
for(int i = 0; i < 6; i++ ) { // change number of items you want here
clb->Append("dummy");
}
wxSize bestSize = clb->GetBestSize();
clb->Destroy();
Use the source, Luke!
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
This gives me the width and height of all the checkboxes in the list right ??
I want to add to the returned size a bit more extra height , based on the size of one checkbox.
I want to add to the returned size a bit more extra height , based on the size of one checkbox.
Last edited by ibrahim on Fri May 27, 2022 10:58 am, edited 1 time in total.
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
It gives you the size of the whole control including borders etc.
Use the source, Luke!
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
I edited my above post
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
The code i posted contains everything you need.
Use the source, Luke!
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
OMG it worked , I used your code and edited the "bestSize" to get extra space according to the height of one checkbox. Then I used "SetMinSize" on the "wxCheckListBox" like this :
now Its cross-platform
I made extra space like this :
Now I don't need the subclass.
I have made the wxCheckListBox without hardcoding now . I only have to do the textctrls now
Code: Select all
reports__->SetMinSize(this->FromDIP(wxSize(-1, bestSize.y)));
I made extra space like this :
Its pure mathbestSize.y += ((((bestSize.y / 6) / 3) * 2) + ((bestSize.y / 12) / 2));
Now I don't need the subclass.
I have made the wxCheckListBox without hardcoding now . I only have to do the textctrls now
Re: Using wxSizers on high dpi, positions the widgets differently then on low dpi
Code: Select all
reports__->SetMinSize(this->FromDIP(wxSize(-1, bestSize.y)));
Use the source, Luke!