[C++ - wxWidgets] buttonem zajmuje całą formatkę

0

Witam, mam następujący problem z Buttonem, piszę właśnie projekt z wykorzystaniem biblioteki graficznej wxWigdgets, dodaję do "formatki" Button, jednakże ten Button rozciąga się na całą formatkę ;/, w czym tkwi problem?,

Kod:

#include "wx/wx.h"
#include "wx/combobox.h"

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

class MyFrame: public wxFrame
{
public:

	MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
	
	
	void OnQuit(wxCommandEvent& event);
	void OnAbout(wxCommandEvent& event);
	void OnExample(wxCommandEvent& event);

	DECLARE_EVENT_TABLE()
};

enum
{
	ID_Quit = 1,
	ID_About,
	ID_Example,
	ID_COMBOBOX,
	ID_Button
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)

	EVT_MENU(ID_Quit,	MyFrame::OnQuit)
	EVT_MENU(ID_About,	MyFrame::OnAbout)
	EVT_MENU(ID_Example,	MyFrame::OnExample)
	EVT_BUTTON(ID_Button,	MyFrame::OnQuit)

END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
	MyFrame *frame = new MyFrame( _T("Projekt2"), wxPoint(700,300), wxSize(600, 450) );
	frame->Show(TRUE);
	
	SetTopWindow(frame);
	return TRUE;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
	wxMenu *menuFile = new wxMenu;

	menuFile->Append( ID_About, _T("&About...") );
	menuFile->AppendSeparator();
	menuFile->Append( ID_Example, _T("Ex&ample") );
	menuFile->AppendSeparator();
	menuFile->Append( ID_Quit, _T("E&xit") );

	wxMenu *menuEdit = new wxMenu;

	menuEdit->Append( ID_About, _T("&About"));

	wxMenuBar *menuBar = new wxMenuBar;
	menuBar->Append( menuFile, _T("&File") );
	menuBar->Append( menuEdit, _T("E&dit") );

	SetMenuBar( menuBar );

	CreateStatusBar();
	SetStatusText( _T("Projekt2") );

	wxButton* button = new wxButton(this, wxID_OK, wxT("&Button"), wxPoint(10, 10));
}

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
	Close(TRUE);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_T("This is a wxWindows Hello world sample"),
        _T("About Hello World"), wxOK | wxICON_INFORMATION, this);
}

void MyFrame::OnExample(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_T("This is an example"),
        _T("An easy example"), wxOK | wxICON_INFORMATION, this);
}

Dzięki z góry za pomoc, pozdrawiam Krzysiek</image>

0

http://docs.wxwidgets.org/2.6/wx_wxbutton.html#wxbuttonctor
bawiles sie pozostalymi parametrami? np. 'style' i wxBU_EXACTFIT ?

0

Z dokumentacji:

Constraint layout: more details

By default, windows do not have a wxLayoutConstraints object. In this case, much layout must be done explicitly, by performing calculations in OnSize members, except for the case of frames that have exactly one subwindow (not counting toolbar and statusbar which are also positioned by the frame automatically), where wxFrame::OnSize takes care of resizing the child to always fill the frame.

0

Dokladnie tak - po prostu musisz uzyc jakiegos sizera lub polozyc najpierw panel na wxFrame.

Jezeli uzywasz wxDialog zamiast wxFrame, to nie musisz i od razu mozesz dawac kontrolki. Tylko ze z kolei do dialogu jak sie zdaje nie da sie dodac main menu

1 użytkowników online, w tym zalogowanych: 0, gości: 1