WxSizer
Proportion
Add()등에 proportion이라는 인자가 존재한다.
아래는 Proportion에 관한 인자 설명이다.
| Although the meaning of this parameter is undefined in wxSizer, it is used in wxBoxSizer to indicate if a child of a sizer can change its size in the main orientation of the wxBoxSizer - where 0 stands for not changeable and a value of more than zero is interpreted relative to the value of other children of the same wxBoxSizer. For example, you might have a horizontal wxBoxSizer with three children, two of which are supposed to change their size with the sizer. Then the two stretchable windows would get a value of 1 each to make them grow and shrink equally with the sizer's horizontal dimension. |
요약하면 아래와 같다.
- wxSizer에서는 사용하지 않는 값이다.
- wxBoxSizer에서 사용되는 값이다.
- wxBoxSizer의 자식들이 차지하는 공간의 비율이다.
- 이 값이
0일 경우 변경하지 않는다(stands for not changeable). -
0보다 클 경우 자식들의 비율(Proportion)에 맞춰, 해석된다.
즉, Android LinearLayout의 weight과 비슷한 역할을 한다. 그리고 wxBoxSizer는 LinearLayout역할을 한다.
FLAG
플래그값에 대하여 wxSizerFlags에 정리한다.
ALIGN CENTER
중앙 정렬에 관련된 내용은 wxSizerFlags#ALIGN_CENTER를 참조하면 된다.
Media Controller Sizer Sample
아래는 미디어 컨트롤을 위한 위젯 배치 샘플이다:
MediaControlPanel::MediaControlPanel(wxWindow * parent
, wxWindowID id, wxPoint const & pos, wxSize const & size)
: wxPanel(parent, id, pos, size)
{
wxBoxSizer * sizer = new wxBoxSizer(wxHORIZONTAL);
{
int const kButtonProportion = 0;
int const kProgressProportion = 1;
int const kBorder = wxSizerFlags::GetDefaultBorder();
R r;
wxBitmap play(r.icon().get("media-playback-start-5.png"), wxBITMAP_TYPE_PNG);
wxBitmap stop(r.icon().get("media-playback-stop-5.png"), wxBITMAP_TYPE_PNG);
wxBitmap prev(r.icon().get("media-skip-backward-5.png"), wxBITMAP_TYPE_PNG);
wxBitmap next(r.icon().get("media-skip-forward-5.png"), wxBITMAP_TYPE_PNG);
_play_button = new wxBitmapButton(this, ID_MEDIA_CONTROL_PANEL__PLAY_BUTTON, play);
_stop_button = new wxBitmapButton(this, ID_MEDIA_CONTROL_PANEL__STOP_BUTTON, stop);
_prev_button = new wxBitmapButton(this, ID_MEDIA_CONTROL_PANEL__PREV_BUTTON, prev);
_next_button = new wxBitmapButton(this, ID_MEDIA_CONTROL_PANEL__NEXT_BUTTON, next);
int const kProgressMin = 0;
int const kProgressMax = 100;
_video_progress = new wxSlider(this, ID_MEDIA_CONTROL_PANEL__VIDEO_PROGRESS
, kProgressMin, kProgressMin, kProgressMax, wxDefaultPosition, wxDefaultSize
, wxSL_BOTH | wxSL_MIN_MAX_LABELS);
wxSizerFlags flags = wxSizerFlags().Proportion(kButtonProportion).Align(wxALIGN_LEFT)
.Border(wxUP | wxDOWN | wxRIGHT, kBorder);
sizer->Add(_play_button, kButtonProportion, wxALIGN_LEFT | wxALL, kBorder);
sizer->Add(_stop_button, flags);
sizer->Add(_prev_button, flags);
sizer->Add(_next_button, flags);
sizer->Add(_video_progress, flags.Proportion(kProgressProportion));
}
SetSizer(sizer);
Center();
}
ImageListView
아래는 이미지 리스트뷰를 위한 위젯 배치 샘플이다:
MainFrame::MainFrame(wxString const & title
, wxWindowID id, wxPoint const & pos, wxSize const & size, long style)
: wxFrame(nullptr, id, title, pos, size, style)
{
createMenu();
int const kBorder = 5;
wxBoxSizer * control_sizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * button_sizer = new wxBoxSizer(wxHORIZONTAL);
{
_list = new wxListCtrl(this, ID_MAINFRAME__IMAGE_LISTCTRL);
control_sizer->Add(_list, 1, wxEXPAND, kBorder);
wxButton * refresh = new wxButton(this, ID_MAINFRAME__REFRESH_BUTTON, wxT("Refresh"));
wxButton * exit = new wxButton(this, ID_MAINFRAME__EXIT_BUTTON, wxT("Exit"));
button_sizer->Add(refresh);
button_sizer->Add(exit);
}
control_sizer->Add(button_sizer, 0, wxALIGN_RIGHT | wxALL, kBorder);
SetSizer(control_sizer);
refresh();
Centre();
}