wxWindow 클래스 3 – Constraint 레이아웃


window layout 함수는 child 윈도우 배치를 위한 함수입니다. 사각형 모양의 객체를 공간에 배치할 때, 수직 방향으로 2개 조건, 수평 방향으로 2개 조건이 주어지면 됩니다.

window layout는 Constraint 방식과 Sizer 방식으로 구분됩니다. Constraint 방식은 4개의 조건을 윈도우 객체간 상관 관계로 표현합니다.

Sizer 방식은 프로그래머가 width, height 즉 2개 조건을 디자인하도록 하고, 나머지 2 조건을 Sizer 클래스가 정의하도록 합니다.

MyFrame.h
#pragma  once

#include  <wx/wx.h>

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

DECLARE_APP(MyApp);

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

MyFrame.cpp
#include  "MyFrame.h"

IMPLEMENT_APP(MyApp);

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


MyFrame::MyFrame(const  wxString& title)
    :wxFrame(NULL, wxID_ANY, title)
{
   wxLayoutConstraints* c1= new  wxLayoutConstraints();
    c1->left.SameAs(this,wxLeft,10);
    c1->width.AsIs();

    c1->top.PercentOf(this,wxHeight,10);
    c1->centreY.Absolute(400);

   wxButton* btn1 = new  wxButton(this, wxID_ANY, "btn1");
    btn1->SetConstraints(c1);

   wxLayoutConstraints* c2 = new  wxLayoutConstraints();
    c2->left.SameAs(btn1, wxRight,0);
    c2->width.AsIs();

    c2->centreY.SameAs(btn1, wxTop);
    c2->height.AsIs();

   wxButton* btn2 = new  wxButton(this, wxID_ANY, "btn2");
    btn2->SetConstraints(c2);

   wxLayoutConstraints* c3 = new  wxLayoutConstraints();
    c3->left.LeftOf(btn2);
    c3->width.Absolute(200);

    c3->top.Below(btn2);
    c3->height.Absolute(50);
   wxButton* btn3 = new  wxButton(this, wxID_ANY, "btn3");
    btn3->SetConstraints(c3);


   this->SetAutoLayout(true);

}


MyFrame::~MyFrame(void)
{
}

- 목록:

3 thoughts on “wxPaintDC 이해하기

  1. 공유해주신 동영상에서 많은 것을 배우고 있습니다. 감사합니다.
    윈도우에서 GUI 프로그래밍을 가끔 하지만, RAD 툴에서 만들어주는 코드를 약간 변형하는 정도입니다.
    동영상을 보다보니, 툴이 생성해주는 코드들에 대해 좀 더 이해할 수 있을 것 같습니다.
    wxSmith 를 이용하여 wxWidget 를 사용하려 알아보는 중인데, 설명을 들으니 wxSmith 나 wxFormWBuilder 가 해주는 일을 약간은 이해할 수 있게 된 것 같습니다. 해당 툴을 사용하는데 많은 도움이 될 것 같습니다.
    좋은 강좌에 감사드립니다.

Leave a Reply to admin Cancel 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>