wxCrafter Frame design drastically differs from compiled result

Post here wxCrafter related issues / features / bugs
var_null
CodeLite Curious
Posts: 9
Joined: Fri Feb 28, 2020 5:54 am
Genuine User: Yes
IDE Question: C++
Contact:

wxCrafter Frame design drastically differs from compiled result

Post by var_null »

Hello, I've been recently using wxCrafter and it's great, love it, however (in my project) the design on wxCrafter looks this way:

Image

And the compiled binary looks a bit different, with lots of blank space:

Image

What can I do to remove that blank space between controls?

Thanks

P.D.: Here is the code:

wxcrafter.h:

Code: Select all

//////////////////////////////////////////////////////////////////////
// This file was auto-generated by codelite's wxCrafter Plugin
// wxCrafter project file: wxcrafter.wxcp
// Do not modify this file by hand!
//////////////////////////////////////////////////////////////////////

#ifndef _WORKSPACE_MEDCEN_PLUS_WXCRAFTER_BASE_CLASSES_H
#define _WORKSPACE_MEDCEN_PLUS_WXCRAFTER_BASE_CLASSES_H

#include <wx/artprov.h>
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/iconbndl.h>
#include <wx/menu.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/statline.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/toolbar.h>
#include <wx/xrc/xh_bmp.h>
#include <wx/xrc/xmlres.h>
#if wxVERSION_NUMBER >= 2900
#include <wx/persist.h>
#include <wx/persist/bookctrl.h>
#include <wx/persist/toplevel.h>
#include <wx/persist/treebook.h>
#endif

#ifdef WXC_FROM_DIP
#undef WXC_FROM_DIP
#endif
#if wxVERSION_NUMBER >= 3100
#define WXC_FROM_DIP(x) wxWindow::FromDIP(x, NULL)
#else
#define WXC_FROM_DIP(x) x
#endif

class MainFrameBaseClass : public wxFrame
{
protected:
    wxMenuBar* m_menuBar;
    wxMenu* m_name6;
    wxMenuItem* m_menuItem7;
    wxMenu* m_name8;
    wxMenuItem* m_menuItem9;
    wxToolBar* m_mainToolbar;
    wxStaticText* m_staticText17;
    wxTextCtrl* textCtrl_DocLastNam;
    wxStaticText* m_staticText175;
    wxTextCtrl* textCtrl_DocFirstNam;
    wxStaticText* m_staticText1742;
    wxTextCtrl* textCtrl_PatFirstNam;
    wxStaticText* m_staticText174;
    wxTextCtrl* textCtrl_PatLastNam;
    wxStaticLine* m_staticLine52;
    wxButton* btn_RecordData;
    wxButton* btn_List;

protected:
    virtual void OnExit(wxCommandEvent& event)
    {
	event.Skip();
    }
    virtual void OnAbout(wxCommandEvent& event)
    {
	event.Skip();
    }
    virtual void OnBtn_recorddataButtonClicked(wxCommandEvent& event)
    {
	event.Skip();
    }
    virtual void OnBtn_listButtonClicked(wxCommandEvent& event)
    {
	event.Skip();
    }

public:
    wxMenuBar* GetMenuBar()
    {
	return m_menuBar;
    }
    wxToolBar* GetMainToolbar()
    {
	return m_mainToolbar;
    }
    wxStaticText* GetStaticText17()
    {
	return m_staticText17;
    }
    wxTextCtrl* GetTextCtrl_DocLastNam()
    {
	return textCtrl_DocLastNam;
    }
    wxStaticText* GetStaticText175()
    {
	return m_staticText175;
    }
    wxTextCtrl* GetTextCtrl_DocFirstNam()
    {
	return textCtrl_DocFirstNam;
    }
    wxStaticText* GetStaticText1742()
    {
	return m_staticText1742;
    }
    wxTextCtrl* GetTextCtrl_PatFirstNam()
    {
	return textCtrl_PatFirstNam;
    }
    wxStaticText* GetStaticText174()
    {
	return m_staticText174;
    }
    wxTextCtrl* GetTextCtrl_PatLastNam()
    {
	return textCtrl_PatLastNam;
    }
    wxStaticLine* GetStaticLine52()
    {
	return m_staticLine52;
    }
    wxButton* GetBtn_RecordData()
    {
	return btn_RecordData;
    }
    wxButton* GetBtn_List()
    {
	return btn_List;
    }
    MainFrameBaseClass(wxWindow* parent,
        wxWindowID id = wxID_ANY,
        const wxString& title = _("MedCen++"),
        const wxPoint& pos = wxDefaultPosition,
        const wxSize& size = wxSize(500, 350),
        long style = wxCAPTION | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCLOSE_BOX);
    virtual ~MainFrameBaseClass();
};

#endif
wxcrafter.cpp:

Code: Select all

//////////////////////////////////////////////////////////////////////
// This file was auto-generated by codelite's wxCrafter Plugin
// wxCrafter project file: wxcrafter.wxcp
// Do not modify this file by hand!
//////////////////////////////////////////////////////////////////////

#include "wxcrafter.h"

// Declare the bitmap loading function
extern void wxC9ED9InitBitmapResources();

static bool bBitmapLoaded = false;

MainFrameBaseClass::MainFrameBaseClass(wxWindow* parent,
    wxWindowID id,
    const wxString& title,
    const wxPoint& pos,
    const wxSize& size,
    long style)
    : wxFrame(parent, id, title, pos, size, style)
{
    if(!bBitmapLoaded) {
	// We need to initialise the default bitmap handler
	wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler);
	wxC9ED9InitBitmapResources();
	bBitmapLoaded = true;
    }

    m_menuBar = new wxMenuBar(0);
    this->SetMenuBar(m_menuBar);

    m_name6 = new wxMenu();
    m_menuBar->Append(m_name6, _("File"));

    m_menuItem7 = new wxMenuItem(m_name6, wxID_EXIT, _("Exit\tAlt-X"), _("Quit"), wxITEM_NORMAL);
    m_name6->Append(m_menuItem7);

    m_name8 = new wxMenu();
    m_menuBar->Append(m_name8, _("Help"));

    m_menuItem9 = new wxMenuItem(m_name8, wxID_ABOUT, _("About..."), wxT(""), wxITEM_NORMAL);
    m_name8->Append(m_menuItem9);

    m_mainToolbar = this->CreateToolBar(wxTB_FLAT, wxID_ANY);
    m_mainToolbar->SetToolBitmapSize(wxSize(16, 16));

    wxBoxSizer* boxSizer1 = new wxBoxSizer(wxVERTICAL);
    this->SetSizer(boxSizer1);

    wxBoxSizer* boxSizer11 = new wxBoxSizer(wxHORIZONTAL);

    boxSizer1->Add(boxSizer11, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    wxStaticBoxSizer* staticBoxSizer64 =
        new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Patient's Data")), wxVERTICAL);

    boxSizer11->Add(staticBoxSizer64, 1, wxALL, WXC_FROM_DIP(5));

    wxBoxSizer* boxSizer15 = new wxBoxSizer(wxHORIZONTAL);

    staticBoxSizer64->Add(boxSizer15, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    m_staticText17 =
        new wxStaticText(this, wxID_ANY, _("Last Name:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    boxSizer15->Add(m_staticText17, 0, wxALL, WXC_FROM_DIP(5));

    textCtrl_DocLastNam =
        new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
#if wxVERSION_NUMBER >= 3000
    textCtrl_DocLastNam->SetHint(wxT(""));
#endif

    boxSizer15->Add(textCtrl_DocLastNam, 0, wxALL, WXC_FROM_DIP(5));

    wxBoxSizer* boxSizer154 = new wxBoxSizer(wxHORIZONTAL);

    staticBoxSizer64->Add(boxSizer154, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    m_staticText175 =
        new wxStaticText(this, wxID_ANY, _("First Name:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    boxSizer154->Add(m_staticText175, 0, wxALL, WXC_FROM_DIP(5));

    textCtrl_DocFirstNam =
        new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
#if wxVERSION_NUMBER >= 3000
    textCtrl_DocFirstNam->SetHint(wxT(""));
#endif

    boxSizer154->Add(textCtrl_DocFirstNam, 0, wxALL, WXC_FROM_DIP(5));

    wxStaticBoxSizer* staticBoxSizer66 =
        new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Doctor's Data")), wxVERTICAL);

    boxSizer11->Add(staticBoxSizer66, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    wxBoxSizer* boxSizer1531 = new wxBoxSizer(wxHORIZONTAL);

    staticBoxSizer66->Add(boxSizer1531, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    m_staticText1742 =
        new wxStaticText(this, wxID_ANY, _("First Name:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    boxSizer1531->Add(m_staticText1742, 0, wxALL, WXC_FROM_DIP(5));

    textCtrl_PatFirstNam =
        new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
#if wxVERSION_NUMBER >= 3000
    textCtrl_PatFirstNam->SetHint(wxT(""));
#endif

    boxSizer1531->Add(textCtrl_PatFirstNam, 0, wxALL, WXC_FROM_DIP(5));

    wxBoxSizer* boxSizer153 = new wxBoxSizer(wxHORIZONTAL);

    staticBoxSizer66->Add(boxSizer153, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    m_staticText174 =
        new wxStaticText(this, wxID_ANY, _("Last Name:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    boxSizer153->Add(m_staticText174, 0, wxALL, WXC_FROM_DIP(5));

    textCtrl_PatLastNam =
        new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
#if wxVERSION_NUMBER >= 3000
    textCtrl_PatLastNam->SetHint(wxT(""));
#endif

    boxSizer153->Add(textCtrl_PatLastNam, 0, wxALL, WXC_FROM_DIP(5));

    boxSizer1->Add(0, 0, 1, wxALL, WXC_FROM_DIP(5));

    m_staticLine52 =
        new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), wxLI_HORIZONTAL);

    boxSizer1->Add(m_staticLine52, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    wxBoxSizer* boxSizer48 = new wxBoxSizer(wxHORIZONTAL);

    boxSizer1->Add(boxSizer48, 1, wxALL | wxALIGN_CENTER, WXC_FROM_DIP(5));

    btn_RecordData =
        new wxButton(this, wxID_ANY, _("Record Data"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    boxSizer48->Add(btn_RecordData, 0, wxALL | wxALIGN_BOTTOM, WXC_FROM_DIP(5));

    btn_List = new wxButton(this, wxID_ANY, _("List"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    boxSizer48->Add(btn_List, 0, wxALL | wxALIGN_BOTTOM, WXC_FROM_DIP(5));

    SetName(wxT("MainFrameBaseClass"));
    SetSize(wxDLG_UNIT(this, wxSize(500, 350)));
    if(GetSizer()) {
	GetSizer()->Fit(this);
    }
    if(GetParent()) {
	CentreOnParent(wxBOTH);
    } else {
	CentreOnScreen(wxBOTH);
    }
#if wxVERSION_NUMBER >= 2900
    if(!wxPersistenceManager::Get().Find(this)) {
	wxPersistenceManager::Get().RegisterAndRestore(this);
    } else {
	wxPersistenceManager::Get().Restore(this);
    }
#endif
    // Connect events
    this->Connect(m_menuItem7->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnExit),
        NULL, this);
    this->Connect(m_menuItem9->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnAbout),
        NULL, this);
    btn_RecordData->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
        wxCommandEventHandler(MainFrameBaseClass::OnBtn_recorddataButtonClicked), NULL, this);
    btn_List->Connect(
        wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainFrameBaseClass::OnBtn_listButtonClicked), NULL, this);
}

MainFrameBaseClass::~MainFrameBaseClass()
{
    this->Disconnect(m_menuItem7->GetId(), wxEVT_COMMAND_MENU_SELECTED,
        wxCommandEventHandler(MainFrameBaseClass::OnExit), NULL, this);
    this->Disconnect(m_menuItem9->GetId(), wxEVT_COMMAND_MENU_SELECTED,
        wxCommandEventHandler(MainFrameBaseClass::OnAbout), NULL, this);
    btn_RecordData->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED,
        wxCommandEventHandler(MainFrameBaseClass::OnBtn_recorddataButtonClicked), NULL, this);
    btn_List->Disconnect(
        wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainFrameBaseClass::OnBtn_listButtonClicked), NULL, this);
}
Last edited by var_null on Sat Feb 29, 2020 3:02 am, edited 3 times in total.
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: wxCrafter Frame style drastically different from compiled result

Post by DavidGH »

Without looking at all the code, I see you're doing things like:
boxSizer1->Add(boxSizer11, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

You need to read about wxSizers. In brief, wxEXPAND stretches the sizer/contents in one orientation; and the second, proportion, parameter of '1' (or anything >0) stretches things in the other.

See also this tutorial.
var_null
CodeLite Curious
Posts: 9
Joined: Fri Feb 28, 2020 5:54 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxCrafter Frame design drastically differs from compiled result

Post by var_null »

Thanks for the links

Looks like the problem was that I deleted the main panel that is generated by default and put everything inside a wxBoxSizer (without a panel)

I rearranged everything so the wxBoxSizer with all the controls is inside of a main panel, which is inside of the main wxBoxSizer, and now the program looks fine after compiling

Regards
Post Reply