PB wrote:You already have an answer to the title of the thread, so why ask this?
Let me clarify the OP.
tuk1 wrote:This does work, however putting the panel directly on an wxFrame means the wxFrame won't auto 'fit to content' due to the lack of sizer. Yes, the wxFrame size can be manually set with fixed xy, but auto 'fit to content' is the ideal.
The first 3 words(in bold) in the OP acknowledge the faq answer, and a quote and link are also provided, the 4th word "however" indicates there might be a problem with the faq answer, the words that come after "however" answer your question, but be sure to let me know if the topic purpose is still unclear.
Obviously, you can set wxFrame's background to any color you wish with SetBackgroundColour() and you should be able to obtain the "panel" color with wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK).
Yes, you can do that, but it defeats the purpose of the solution given in the faq, which is what this topic is about.
Nor imo, does it meet the criteria of being an elegant solution.
I do not understand the remark about autofitting the content,
'Fit to content' is the term used by Julian Smart, hence the use of single quotes..
In code terms:
Code: Select all
Without a sizer or setting fixed dims of the wxFrame ......the wxFrame will not expand to the correct size in relation to it's contents, aka ''Fit to content'.
... also there is no border around the sizer unless you add it there...
Can you provide code that proves your statement?
Here is a picture of a bare bones project, containing a wxFrame, wxBoxSizerV and a wxPanel(dims 50,50), as you can see the dark grey border( underlap between the wxFrame and wxBoxSizerV) is there without being specifically added, unless I'm missing something?:
Code: Select all
testFrame::testFrame( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
Create( parent, id, caption, pos, size, style );
bool testFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
wxFrame::Create( parent, id, caption, pos, size, style );
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)