wxWindow 클래스 5 – wxBoxSizer 샘플


MyFrame.h
#pragma  once

#include  <wx/wx.h>

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

DECLARE_APP(MyApp);

class MyFrame:public wxFrame
{
public:
    MyFrame(const wxString& title);
    ~MyFrame(void);

private:
   void test_boxsizer();
   void test_staticboxsizer();
   void test_wrapsizer();

   void aftersizer(wxSizer* top);
};

MyFrame.cpp
#include  "MyFrame.h"
#include  "MyDialog.h"
#include  <wx/wrapsizer.h>

IMPLEMENT_APP(MyApp);

bool
MyApp::OnInit(){
   wxFrame* m = new  MyFrame("Box1");
    m->Show(true);

   MyDialog* dlg = new  MyDialog("Dialog Test");
    dlg->Show(true);


   return  true;
}


MyFrame::~MyFrame(void)
{
   
}


MyFrame::MyFrame(const  wxString& title)
    :wxFrame(NULL, wxID_ANY, title)
{
    test_boxsizer();
}

void 
MyFrame::test_boxsizer(){
   //wxBoxSizer* mysizer = new wxBoxSizer(wxHORIZONTAL);

   wxBoxSizer* mysizer = new  wxBoxSizer(wxVERTICAL);

   wxButton* btn1 = new  wxButton(this,-1,"btn1", wxPoint(0,0), wxSize(100,50));
    mysizer->Add(btn1, 0,wxALL, 5);

   wxButton* btn2 = new  wxButton(this,-1,"btn2" );
    mysizer->Add(btn2, 0,wxALL|wxCENTER, 5);

   wxButton* btn3 = new  wxButton(this,-1,"btn3" );
    mysizer->Add(btn3, 1,wxALL|wxEXPAND, 5);

   wxSizerFlags flags;
    flags.Proportion(1);
    flags.Border(wxALL,10);
    flags.Center();
    flags.Expand();

   wxButton* btn4 = new  wxButton(this,-1,"wxSizerFlags" );
    mysizer->Add( btn4, flags);



    aftersizer(mysizer);

}

void 
MyFrame::test_wrapsizer(){
   wxWrapSizer* m = new  wxWrapSizer(wxHORIZONTAL,wxREMOVE_LEADING_SPACES);
   for(int i=0;i<10;++i){
      wxButton* btn = new  wxButton(this,wxID_ANY, wxString::Format("btn %d", i) );
       m->Add(btn,1,wxALL|wxEXPAND,5);
   }

    aftersizer(m);
}

void 
MyFrame::test_staticboxsizer(){
   wxStaticBoxSizer* mysizer = new  wxStaticBoxSizer(wxHORIZONTAL,this,"Label ...");

   wxWindow* parent = mysizer->GetStaticBox();

   wxButton* btn1 = new  wxButton(parent,-1,"btn1", wxPoint(0,0), wxSize(100,50));
    mysizer->Add(btn1, 0,wxALL, 5);

   wxButton* btn2 = new  wxButton(parent,-1,"btn2" );
    mysizer->Add(btn2, 0,wxALL|wxCENTER, 5);

   wxButton* btn3 = new  wxButton(parent,-1,"btn3" );
    mysizer->Add(btn3, 1,wxALL|wxEXPAND, 5);


    aftersizer(mysizer);
}



void 
MyFrame::aftersizer(wxSizer* top){
   this->SetSizer(top);
   this->Layout();
   this->Fit();
   this->SetAutoLayout(true);
}

MyDialog.h
#pragma  once
#include  <wx/wx.h>

class  MyDialog:public  wxDialog
{
public:
    MyDialog(const  wxString& title);
    ~MyDialog(void);

private:
   void aftersizer(wxSizer* top);
   void test_stddialogbuttonsizer();
};

MyDialog.cpp
#include  "MyDialog.h"


MyDialog::MyDialog(const wxString& title)
    :wxDialog(NULL, wxID_ANY, title)
{
    test_stddialogbuttonsizer();
}


MyDialog::~MyDialog(void)
{
}


void
MyDialog::test_stddialogbuttonsizer(){
    wxStdDialogButtonSizer* mysizer = new wxStdDialogButtonSizer();

    wxButton* btn1 = new wxButton(this, wxID_YES);
    wxButton* btn2 = new wxButton(this, wxID_NO);

    mysizer->AddButton(btn2);
    mysizer->AddButton(btn1);

    mysizer->Realize();
    aftersizer(mysizer);
}

void 
MyDialog::aftersizer(wxSizer* top){
   this->SetSizer(top);
   this->Layout();
   this->Fit();
   this->SetAutoLayout(true);
}

- 목록:

2 thoughts on “wxPaintDC 이해하기

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>