Page 1 of 1

Issue with nested wxStaticBox on Linux.

Posted: Mon Sep 24, 2018 7:21 am
by deepti
Hi,

Is there any known issue with nested wxStaticBox, containing wxCheckBox, wxTextCtrl etc?
I have a wxDialog which looks perfect on Windows and Mac, but is completely screwed up on Linux.

This is how it looks on Linux...
Linux.png
Linux.png (14.74 KiB) Viewed 999 times

And this is on Windows and Mac..
Win_Mac.jpg
Win_Mac.jpg (34.96 KiB) Viewed 999 times


The following is the code for dialog creation.
Please help!

Code: Select all

WxBandwidthSettingsDialog::WxBandwidthSettingsDialog(bool bDisableBWDialog) : wxDialog(NULL, wxID_ANY, "Bandwidth Settings", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{
	wxStaticBox *outermostBox = new wxStaticBox(this, wxID_ANY, "", wxDefaultPosition);
	wxSizer * const sizerTop = new wxStaticBoxSizer(outermostBox, wxVERTICAL);
	
	//group box 1
	wxStaticBox *innerBox1 = new wxStaticBox(outermostBox, wxID_ANY, "Global Rate Limits", wxDefaultPosition, wxDefaultSize);
	wxSizer * const sizerForAllControls = new wxStaticBoxSizer(innerBox1, wxHORIZONTAL);

	wxSizer*  bmpSizer = new wxBoxSizer(wxVERTICAL);
	sizerForAllControls->Add(bmpSizer);
	//BW icon
	wxStaticBitmap* bmp1 = new wxStaticBitmap(this, wxID_STATIC, wxBitmap("./cbglobal_rate_limit.png", wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(32, 32), 0);
	bmpSizer->Add(bmp1, 0, wxALL, 12);

	wxSizer*  sizerTop1 = new wxBoxSizer(wxVERTICAL);
	sizerForAllControls->Add(sizerTop1);
	
	wxFlexGridSizer* itemGridSizer1 = new wxFlexGridSizer(1, 6, 0, 0);
	sizerTop1->Add(itemGridSizer1);

	//upload controls (Global Rate Limits)
	wxCheckBox* checkboxUploadEnable1 = new wxCheckBox(this, ID_BWSETTINGS_CHKBOX_UPLOAD1, "", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer1->Add(checkboxUploadEnable1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);

	wxStaticText* uploadStaticText1 = new wxStaticText(this,
			wxID_STATIC, "Upload       ", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer1->Add(uploadStaticText1, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxSpinCtrl *spinCtrl_upload1 = new wxSpinCtrl(this, ID_BWSETTINGS_RATE_UPLOAD1, "-1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxALIGN_LEFT, -1, 1000000, -1);
	itemGridSizer1->Add(spinCtrl_upload1, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxStaticText* kbpsStaticText1 = new wxStaticText(this,
		wxID_STATIC, "KiB/s     ", wxDefaultPosition, wxDefaultSize);
	itemGridSizer1->Add(kbpsStaticText1, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
	
	//empty text to introduce some gap
	wxStaticText* emptyText1 = new wxStaticText(this,
		wxID_STATIC, "", wxDefaultPosition, wxDefaultSize, 0);
	sizerTop1->Add(emptyText1, 0, wxALL, 0);

	//download controls(Global Rate Limits)
	wxFlexGridSizer* itemGridSizer3 = new wxFlexGridSizer(1, 6, 0, 0);
	sizerTop1->Add(itemGridSizer3);

	wxCheckBox* checkboxDownloadEnable1 = new wxCheckBox(this, ID_BWSETTINGS_CHKBOX_DOWNLOAD1, "", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer3->Add(checkboxDownloadEnable1, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxStaticText* downloadStaticText1 = new wxStaticText(this,
		wxID_STATIC, "Download  ", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer3->Add(downloadStaticText1, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
	
	wxSpinCtrl *spinCtrl_download1 = new wxSpinCtrl(this, ID_BWSETTINGS_RATE_DOWNLOAD1, "-1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxALIGN_LEFT, -1, 1000000, -1);
	itemGridSizer3->Add(spinCtrl_download1, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxStaticText* kbpsStaticText2 = new wxStaticText(this,
		wxID_STATIC, "KiB/s     ", wxDefaultPosition, wxDefaultSize);
	itemGridSizer3->Add(kbpsStaticText2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
	
	//group box 2
	wxStaticBox *innerBox2 = new wxStaticBox(outermostBox, wxID_ANY, "Alternative Rate Limits", wxDefaultPosition, wxDefaultSize);
	wxSizer * const altGroupBox = new wxStaticBoxSizer(innerBox2, wxVERTICAL);

	wxSizer*  sizerForAllControls2 = new wxBoxSizer(wxHORIZONTAL);
	altGroupBox->Add(sizerForAllControls2);

	wxSizer*  bmpSizer1 = new wxBoxSizer(wxVERTICAL);
	sizerForAllControls2->Add(bmpSizer1);
	//BW icon
	wxStaticBitmap* bmp2 = new wxStaticBitmap(this, wxID_STATIC, wxBitmap("./cbalt_rate_limit.png", wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(32, 32), 0);
	bmpSizer1->Add(bmp2, 0, wxALL, 12);

	wxSizer* sizerTop2 = new wxBoxSizer(wxVERTICAL);
	sizerForAllControls2->Add(sizerTop2);

	wxFlexGridSizer* itemGridSizer4 = new wxFlexGridSizer(1, 6, 0, 0);
	sizerTop2->Add(itemGridSizer4);
	
	//upload controls (Alternative Rate Limits)
	wxCheckBox* checkboxUploadEnable2 = new wxCheckBox(this, ID_BWSETTINGS_CHKBOX_UPLOAD2, "", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer4->Add(checkboxUploadEnable2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);

	wxStaticText* uploadStaticText2 = new wxStaticText(this,
		wxID_STATIC, "Upload       ", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer4->Add(uploadStaticText2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxSpinCtrl *spinCtrl_upload2 = new wxSpinCtrl(this, ID_BWSETTINGS_RATE_UPLOAD2, "-1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxALIGN_LEFT, -1, 1000000, -1);
	itemGridSizer4->Add(spinCtrl_upload2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxStaticText* kbpsStaticText3 = new wxStaticText(this,
		wxID_STATIC, "KiB/s     ", wxDefaultPosition, wxDefaultSize);
	itemGridSizer4->Add(kbpsStaticText3, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
	
	wxStaticText* emptyText2 = new wxStaticText(this,
		wxID_STATIC, "", wxDefaultPosition, wxDefaultSize, 0);
	sizerTop2->Add(emptyText2, 0, wxALL, 0);

	//download controls (Alternative Rate Limits)
	wxFlexGridSizer* itemGridSizer6 = new wxFlexGridSizer(1, 6, 0, 0);
	sizerTop2->Add(itemGridSizer6);

	wxCheckBox* checkboxDownloadEnable2 = new wxCheckBox(this, ID_BWSETTINGS_CHKBOX_DOWNLOAD2, "", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer6->Add(checkboxDownloadEnable2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxStaticText* downloadStaticText2 = new wxStaticText(this,
		wxID_STATIC, "Download  ", wxDefaultPosition, wxDefaultSize, 0);
	itemGridSizer6->Add(downloadStaticText2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxSpinCtrl *spinCtrl_download2 = new wxSpinCtrl(this, ID_BWSETTINGS_RATE_DOWNLOAD2, "-1", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxALIGN_LEFT, -1, 1000000, -1);
	itemGridSizer6->Add(spinCtrl_download2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	wxStaticText* kbpsStaticText4 = new wxStaticText(this,
		wxID_STATIC, "KiB/s    ", wxDefaultPosition, wxDefaultSize);
	itemGridSizer6->Add(kbpsStaticText4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);

	//Schedule group box
	wxStaticBox *box3 = new wxStaticBox(this, wxID_ANY, "", wxDefaultPosition);
	wxSizer * const sizerTop3 = new wxStaticBoxSizer(box3 , wxVERTICAL);

	wxStaticText* Schedule_StaticText = new wxStaticText(this,
		ID_BWSETTINGS_STATIC_SCHEDULE, "Schedule the use of alternative rate limits", wxDefaultPosition, wxDefaultSize);
	sizerTop3->Add(Schedule_StaticText, 0, wxALIGN_LEFT , 0);

	wxFlexGridSizer* itemGridSizer7 = new wxFlexGridSizer(1, 5, 0, 0);
	sizerTop3->Add(itemGridSizer7, 0);

	wxStaticText* fromTimeStaticText = new wxStaticText(this,
		ID_BWSETTINGS_STATICFROM, "From:", wxDefaultPosition, wxDefaultSize);
	itemGridSizer7->Add(fromTimeStaticText, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
	fromTimeStaticText->Disable();

	wxDateTime time1(8, 0);
	wxTimePickerCtrl *timeCtrl_fromTime = new wxTimePickerCtrl(this, ID_BWSETTINGS_FROMTIME, time1);
	itemGridSizer7->Add(timeCtrl_fromTime, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5);
	timeCtrl_fromTime->Disable();

	wxStaticText* toTimeStaticText = new wxStaticText(this,
		ID_BWSETTINGS_STATICTO, "To:", wxDefaultPosition, wxDefaultSize);
	itemGridSizer7->Add(toTimeStaticText, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
	toTimeStaticText->Disable();

	wxDateTime time2(20, 0);
	wxTimePickerCtrl *timeCtrl_toTime = new wxTimePickerCtrl(this, ID_BWSETTINGS_TOTIME, time2);
	itemGridSizer7->Add(timeCtrl_toTime, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5);
	timeCtrl_toTime->Disable();

	wxStaticText* dummyText = new wxStaticText(this,
		wxID_ANY, "", wxDefaultPosition, wxDefaultSize);
	itemGridSizer7->Add(dummyText, 0, wxRIGHT, 35);

	wxFlexGridSizer* itemGridSizer8 = new wxFlexGridSizer(1, 2, 0, 0);
	sizerTop3->Add(itemGridSizer8, 0);

	wxStaticText* whenStaticText = new wxStaticText(this,
		ID_BWSETTINGS_STATICWHEN, "When:", wxDefaultPosition, wxDefaultSize);
	itemGridSizer8->Add(whenStaticText, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
	whenStaticText->Disable();

	wxString arr[] = {BXT("Every day"), BXT("Every Monday"), BXT("Every Tuesday"), BXT("Every Wednesday"), BXT("Every Thursday"), BXT("Every Friday"), BXT("Every Saturday"), BXT("Every Sunday") };
	wxArrayString choices(8, arr);
	wxComboBox* whenComboBox = new wxComboBox(this, ID_BWSETTINGS_SCHEDULE, BXT("Every day"), wxDefaultPosition, wxDefaultSize, choices);
	itemGridSizer8->Add(whenComboBox, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5);
	whenComboBox->SetSelection(0);
	whenComboBox->Disable();

	altGroupBox->Add(sizerTop3);
	wxButton* saveBtn = new wxButton(this, ID_BWSETTINGS_SAVECHANGES, BXT("Save Changes"), wxDefaultPosition, wxDefaultSize);
	

	//add sizer of both group boxes to the main sizer
	sizerTop->Add(sizerForAllControls);
	sizerTop->Add(altGroupBox);

	sizerTop->AddStretchSpacer(1);
	sizerTop->Add(saveBtn, 0, wxALIGN_CENTER_HORIZONTAL);
	sizerTop->AddStretchSpacer(1);
	

	UpdateControls(bDisableBWDialog);
	SetSizerAndFit(sizerTop);
	Centre();
}

Re: Issue with nested wxStaticBox on Linux.

Posted: Mon Sep 24, 2018 8:39 am
by PB
I would make sure the parents for individual controls are always correct. E.g., the controls in the wxStaticBox(Sizer) are its children and not children of the dialog.

Re: Issue with nested wxStaticBox on Linux.

Posted: Mon Sep 24, 2018 11:29 am
by deepti
Awesome! that worked..thanks a lot PB :)