As an exercise, I am trying to create a simple program that generates a valid XML file from user input (the contents of the XML are unimportant).
I use XRC to keep the interface as separate from the code as possible.
Aside from the plenty questions below, I'm also in need of style guidance, as in: am I structuring my code incorrectly when using wxWidgets? Should the frame be a member data of the app? Should the event Bind()'s happen in the frame constructor instead of the app OnInit()? And so on. Basically let me know if you spot bad practices.
Now on to the questions themselves, numbered for convenience. Feel free to skip answering the ones you don't feel like, but please number your answers accordingly.
- Is the way I associate the Escape with the frame closing the proper way to do it? See xmlapp_frame::on_key_up(). If not, how else to associate Escape with closing the frame?
- Why is the frame background color not the usual color from Windows, but a dark grey?
- How to make the wxGridSizer split the two columns at 25-75 instead of 50-50? Or should another sizer be used?
- The wxFormBuilder utility doesn't set minimum size of frame in XRC, is this on purpose?
- How come the application closes when the Close button on the titlebar is clicked, despite that event not being handled by my code? (Asking because in some tutorial code I remember it was handled as EVT_CLOSE.)
- How to set the file path text in the file picker as read-only?
- I noticed I had to include <wx/valnum.h> for wxFloatingPointValidator but not <wx/valtext.h> for wxTextValidator. I'd therefore like to know which headers exactly wxprec.h and wx.h can be relied to include, by themselves, regardless of wxWidgets version. For example if I include <wx/valtext.h> or <wx/image.h> by hand to make sure future users won't get a compilation error, am I paranoid to do so?
- How to make the input fields (wxTextCtrl) stretch only horizontally when the window is resized, but not stretch vertically?
- Is it overzealous to include all wxWidgets .lib files? And if yes, how can I figure out which ones are unneeded, other than by trial and error as by removing and restoring them in the linker parameters?
- Despite using validators to associate data with the input fields, I still had to override wxFrame::TransferDataFromWindow(). Does this mean that validators only update the data when the dialog/frame is closed?
- Finally there is a coding bug somewhere in xmlapp_frame::on_generate(): when that function terminates, the program crashes with an exception pointing inside ~ConvertedBuffer() at:
Code: Select all
Attached are a screenshot and the source code. The screenshot shows the ugly background color of the frame and the undesirable vertical stretching of the text inputs.