wxBORDER_NONE / wxBORDER_SIMPLE sizers issue Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by Ambush »

hello everyone

I am having an issue with my layout using sizers, the problem occurs when i add the options
wxBORDER_NONE or wxBORDER_SIMPLE to my wxFrame, i have been trying all week to fix this with no luck.

i have tried to fix by using different sizer layouts, horizontal, vertical and options such as wxALIGN_RIGHT etc
in many different combinations, all to no effect.

as soon as the BORDER options are added to my frame, my sizers and controls lose all position and get pushed to the left.

I am not sure if this is my inexperience or an unintended feature lol

i will post the code below, i got this code from zetcode, but the same problem exists in my own code as well
hopefully one of you will see what i am doing wrong, or the problem

thanks

Sizers.h

Code: Select all

#include <wx/wx.h>

class Sizers : public wxFrame
{
public:
	Sizers(const wxString& title);

};
Sizer.cpp

Code: Select all

#include "Sizer.h"

Sizers::Sizers(const wxString& title)
	: wxFrame(NULL, wxID_ANY, title, wxPoint(wxDefaultPosition), wxSize(wxDefaultSize))<wxBORDER_NONE/SIMPLE>
{

	wxPanel *panel = new wxPanel(this, wxID_ANY);

	wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
	wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
	wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL);

	wxButton *ok = new wxButton(panel, wxID_ANY, wxT("Ok"));
	wxButton *cancel = new wxButton(panel, wxID_ANY, wxT("Cancel"));

	hbox1->Add(new wxPanel(panel, wxID_ANY));
	vbox->Add(hbox1, 1, wxEXPAND);


	hbox2->Add(ok);
	hbox2->Add(cancel);

	vbox->Add(hbox2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 0);
	panel->SetSizer(vbox);

	Centre();
}
main.h

Code: Select all

#include <wx/wx.h>

class MyApp : public wxApp
{
public:
	virtual bool OnInit();
};
main.cpp

Code: Select all

#include "main.h"
#include "Sizer.h"

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{

	Sizers *sizers = new Sizers(wxT("Align"));
	sizers->Show(true);

	return true;
}
User avatar
doublemax
Moderator
Moderator
Posts: 19162
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by doublemax »

Which platform and wxWidgets version? I just tested this under Windows everything looks fine both with wxBORDER_NONE or wxBORDER_SIMPLE.

Is it indended not to have a title bar? If not you should use wxDEFAULT_FRAME_STYLE and remove/add flags from/to that. E.g. if you just pass wxBORDER_SIMPLE, you won't get all the other flags like (wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
Use the source, Luke!
User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Re: wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by Ambush »

Thanks Doublemax

My Platform : Server 2012R2 with update
Wxwidgets Version : 3.03
Visual Studio 2013 update 5

You are correct my intent was not to have a titlebar or frame style, just a completly blank frame for my app.
The controls for maximize etc i am adding in manually using wxBitmapButton,
i will post a pic of before and after wxBORDER_NONE, this also happens with SUNKEN_BORDER
and also if i remove the border from a wxBitmapButton
User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Re: wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by Ambush »

No extra frame options
No options.png
No options.png (3.24 KiB) Viewed 1826 times
wxBORDER_NONE
wxBORDER_NONE.png
wxBORDER_NONE.png (1.75 KiB) Viewed 1826 times
but i will have a go with the wxDEFAULT_STYLE right now and see how it goes
User avatar
doublemax
Moderator
Moderator
Posts: 19162
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by doublemax »

Code: Select all

wxFrame(NULL, wxID_ANY, title, wxPoint(wxDefaultPosition), wxSize(wxDefaultSize))<wxBORDER_NONE/SIMPLE>
This can't be real code, so just to be sure, it should look like this:

Code: Select all

wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
or 
wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE );
( The wxPoint(wxDefaultPosition) etc. is ok, just unnecessary)
Use the source, Luke!
User avatar
doublemax
Moderator
Moderator
Posts: 19162
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by doublemax »

That "bad" screenshot looks familiar. Usually you get that when the sizer layout doesn't get triggered. Maybe that's because of the missing wxRESIZE_BORDER flag (although i don't see the problem here). Try manually calling Layout() after setting the sizer.
Use the source, Luke!
User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Re: wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by Ambush »

You are right, I only put <wxBORDER_NONE> there in case anyone was wandering which line i was adding the option to,
my own code looks exactly as you have posted, i should have explained it better in my explanation though.
User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Re: wxBORDER_NONE / wxBORDER_SIMPLE sizers issue

Post by Ambush »

brilliant, I do believe thats fixed it, the layout is back to the origional.

again, tnx for your help !
Post Reply