/*********************************************************** * mySizerMain.h **********************************************************/
#ifndef MYSIZERMAIN_H #define MYSIZERMAIN_H
//(*Headers(mySizerFrame) #include <wx/sizer.h> #include <wx/menu.h> #include <wx/textctrl.h> #include <wx/button.h> #include <wx/frame.h> //*) class mySizerFrame: public wxFrame { public: mySizerFrame(wxWindow* parent,wxWindowID id = -1); virtual ~mySizerFrame(); private: //(*Identifiers(mySizerFrame) static const long ID_TEXTCTRL1; static const long ID_TEXTCTRL2; static const long ID_BUTTON1; //*) //(*Declarations(mySizerFrame) wxButton* Button1; wxStatusBar* StatusBar1; wxTextCtrl* TextCtrl2; wxTextCtrl* TextCtrl1; //*) DECLARE_EVENT_TABLE() };
#endif // MYSIZERMAIN_H
/*********************************************************** * mySizerMain.cpp **********************************************************/ #include "mySizerMain.h" #include <wx/msgdlg.h> //(*InternalHeaders(mySizerFrame) #include <wx/intl.h> #include <wx/string.h> //*) //(*IdInit(mySizerFrame) const long mySizerFrame::ID_TEXTCTRL1 = wxNewId(); const long mySizerFrame::ID_TEXTCTRL2 = wxNewId(); const long mySizerFrame::ID_BUTTON1 = wxNewId(); //*) BEGIN_EVENT_TABLE(mySizerFrame,wxFrame) //(*EventTable(mySizerFrame) //*) END_EVENT_TABLE()
mySizerFrame::mySizerFrame(wxWindow* parent,wxWindowID id) { wxBoxSizer* BoxSizer1; wxFlexGridSizer* FlexGridSizer1;
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE); FlexGridSizer1 = new wxFlexGridSizer(3, 1, 0, 0); FlexGridSizer1->AddGrowableCol(0); // 让第一列大小可变 FlexGridSizer1->AddGrowableRow(0); // 让第一行大小可变
TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); FlexGridSizer1->Add(TextCtrl1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl2 = new wxTextCtrl(this, ID_TEXTCTRL2, _("Text"), wxDefaultPosition, wxSize(62,62), wxTE_MULTILINE); FlexGridSizer1->Add(TextCtrl2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1 = new wxBoxSizer(wxHORIZONTAL); BoxSizer1->Add(0,0,1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); // 添加一个空白BoxSizer Button1 = new wxButton(this, ID_BUTTON1, _("OK"), wxDefaultPosition, wxSize(60,30)); Button1->SetMaxSize(wxDLG_UNIT(this,wxSize(65,30))); // 设置按钮最大大小 BoxSizer1->Add(Button1, 1, wxALL|wxSHAPED|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); // wxSHAPED 让按钮不随BoxSize1变化 FlexGridSizer1->Add(BoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(FlexGridSizer1); FlexGridSizer1->Fit(10-23 19:12
|