/* *Copyright (C) 2001 LIS Laboratory Yann Davin * *This program is free software; you can redistribute it and/or *modify it under the terms of the GNU General Public License *as published by the Free Software Foundation; either version 2 *of the License, or (at your option) any later version. * *This program is distributed in the hope that it will be useful, *but WITHOUT ANY WARRANTY; without even the implied warranty of *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *GNU General Public License for more details. * *You should have received a copy of the GNU General Public License *along with this program; if not, write to the Free Software *Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "my_dialog_yuv.hh" using namespace std; my_dialog_yuv::my_dialog_yuv(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long WXUNUSED(style)) : wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxTE_PROCESS_ENTER|wxTE_PROCESS_TAB |wxDIALOG_MODAL) { height="288"; width="352"; this->SetAutoLayout(TRUE); wxButton* button_ok = new wxButton(this, wxID_OK, "OK", wxPoint(-1,-1), wxSize(-1, -1)); wxButton* button_cancel= new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(0,0), wxSize(-1, -1)); wxStaticBox* static_size=new wxStaticBox(this, -1, "&Size", wxPoint(-1,-1), wxSize(-1, -1)); TextCtrlWidth=new wxTextCtrl(this, VALIDATE_WIDTH, "", wxPoint(-1,-1), wxSize(-1, -1), 0, wxTextValidator(wxFILTER_NUMERIC, &width)); TextCtrlHeight=new wxTextCtrl(this, VALIDATE_HEIGHT, "", wxPoint(-1,-1), wxSize(-1, -1), 0, wxTextValidator(wxFILTER_NUMERIC, &height)); wxStaticText* static_name=new wxStaticText(this, -1, title, wxPoint(-1, -1), wxDefaultSize, wxALIGN_LEFT); wxStaticText* StaticTextWidthLabel=new wxStaticText(this, -1, "Width", wxPoint(-1, -1), wxDefaultSize, wxALIGN_LEFT); wxStaticText* StaticTextHeightLabel=new wxStaticText(this, -1, "Height", wxPoint(-1, -1), wxDefaultSize, wxALIGN_LEFT); /* wxStaticBox *static_format=new wxStaticBox( this, -1, "&Format", wxPoint(-1,-1), wxSize(-1, -1)); */ /* wxCheckBox* check_QCIF_PAL=new wxCheckBox(this,ID_QCIF_PAL, "QCIF_PAL (192x144)", wxPoint(-1,-1), wxDefaultSize,wxSUNKEN_BORDER, wxDefaultValidator, "checkbox"); wxCheckBox* check_QCIF_NTSC=new wxCheckBox(this,ID_QCIF_NTSC, "QCIF_NTSC (176x144)", wxPoint(-1,-1), wxDefaultSize,wxSUNKEN_BORDER, wxDefaultValidator, "checkbox"); wxCheckBox* check_CIF_PAL=new wxCheckBox(this,ID_CIF_PAL, "CIF_PAL (384x288)", wxPoint(-1,-1), wxDefaultSize,wxSUNKEN_BORDER, wxDefaultValidator, "checkbox"); wxCheckBox* check_CIF_NTSC=new wxCheckBox(this,ID_CIF_NTSC, "CIF_NTSC (352x288)", wxPoint(-1,-1), wxDefaultSize,wxSUNKEN_BORDER, wxDefaultValidator, "checkbox"); wxCheckBox* check_CUSTOM=new wxCheckBox(this,ID_CUSTOM, "CUSTOM", wxPoint(-1,-1), wxDefaultSize,wxSUNKEN_BORDER, wxDefaultValidator, "checkbox"); */ static const wxString choices[] = { "QCIF_PAL (192x144)", "QCIF_NTSC (176x144)", "CIF_PAL (384x288)", "CIF_NTSC (352x288)", "CUSTOM" }; wxRadioBox* child_radio_box = new wxRadioBox( this, ID_RADIOBOX, "F&ormats", wxPoint(10,10), wxSize(-1,-1), WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS ); child_radio_box->SetSelection(3); wxLayoutConstraints *layout_static_name=new wxLayoutConstraints; layout_static_name->left.PercentOf (this, wxWidth, 3); layout_static_name->top.PercentOf (this, wxHeight, 3); layout_static_name->width.PercentOf (this, wxWidth, 80); layout_static_name->height.PercentOf (this, wxHeight, 10); static_name->SetConstraints(layout_static_name); wxLayoutConstraints *layout_static_size=new wxLayoutConstraints; layout_static_size->left.PercentOf (this, wxWidth, 3); layout_static_size->top.Below (static_name, 3); layout_static_size->width.PercentOf (this, wxWidth, 30); layout_static_size->height.PercentOf (this, wxHeight, 60); static_size->SetConstraints(layout_static_size); wxLayoutConstraints *layout_static_size_width_label=new wxLayoutConstraints; layout_static_size_width_label->left.PercentOf (this, wxWidth, 4); layout_static_size_width_label->top.Below (static_name,16); layout_static_size_width_label->width.PercentOf (this, wxWidth, 25); layout_static_size_width_label->height.PercentOf (this, wxHeight, 8); StaticTextWidthLabel->SetConstraints(layout_static_size_width_label); wxLayoutConstraints *layout_static_size_width_entry=new wxLayoutConstraints; layout_static_size_width_entry->left.PercentOf (this, wxWidth, 4); layout_static_size_width_entry->top.Below (StaticTextWidthLabel, 8); layout_static_size_width_entry->width.PercentOf (this, wxWidth, 25); layout_static_size_width_entry->height.PercentOf (this, wxHeight, 8); TextCtrlWidth->SetConstraints(layout_static_size_width_entry); wxLayoutConstraints *layout_static_size_height_label=new wxLayoutConstraints; layout_static_size_height_label->left.PercentOf (this, wxWidth, 4); layout_static_size_height_label->top.Below (TextCtrlWidth,10); layout_static_size_height_label->width.PercentOf (this, wxWidth, 25); layout_static_size_height_label->height.PercentOf (this, wxHeight, 8); StaticTextHeightLabel->SetConstraints(layout_static_size_height_label); wxLayoutConstraints *layout_static_size_height_entry=new wxLayoutConstraints; layout_static_size_height_entry->left.PercentOf (this, wxWidth, 4); layout_static_size_height_entry->top.Below (StaticTextHeightLabel, 8); layout_static_size_height_entry->width.PercentOf (this, wxWidth, 25); layout_static_size_height_entry->height.PercentOf (this, wxHeight, 8); TextCtrlHeight->SetConstraints(layout_static_size_height_entry); wxLayoutConstraints *layout_static_format=new wxLayoutConstraints; layout_static_format->top.PercentOf (this, wxHeight, 3); layout_static_format->width.PercentOf (this, wxWidth, 60); layout_static_format->height.PercentOf (this, wxHeight, 70); layout_static_format->left.SameAs(static_size,wxRight,10); child_radio_box->SetConstraints(layout_static_format); wxLayoutConstraints *layout_ok=new wxLayoutConstraints; layout_ok->left.SameAs (this, wxLeft, 10); layout_ok->top.Below (static_size, 10); layout_ok->width.PercentOf (this, wxWidth, 20); layout_ok->height.PercentOf (this, wxHeight, 8); button_ok->SetConstraints(layout_ok); wxLayoutConstraints *layout_cancel=new wxLayoutConstraints; layout_cancel->top.Below (static_size, 10); layout_cancel->width.PercentOf (this, wxWidth, 20); layout_cancel->height.PercentOf (this, wxHeight, 8); layout_cancel->left.RightOf(button_ok,5); button_cancel->SetConstraints(layout_cancel); button_ok->SetFocus(); button_ok->SetDefault(); } void my_dialog_yuv::OnOk() { long w; long h; width=TextCtrlWidth->GetValue(); height=TextCtrlHeight->GetValue(); width.ToLong(&w); height.ToLong(&h); if(w%2==0 && h%2==0) { EndModal(wxID_OK); } else { (void)wxMessageBox("La taille des séquence YUV\ndoit être paire", "Attention", wxOK|wxICON_EXCLAMATION); } } void my_dialog_yuv::OnRadioBox() { wxString selection; selection=((wxRadioBox*)(this->FindWindow(ID_RADIOBOX)))->GetStringSelection(); // TODO: search loop if(selection=="QCIF_PAL (192x144)") { width="192"; height="144"; } else if(selection=="QCIF_NTSC (176x144)") { width="176"; height="144"; } else if(selection=="CIF_PAL (384x288)") { width="384"; height="288"; } else if(selection=="CIF_NTSC (352x288)") { width="352"; height="288"; } else if(selection=="CUSTOM") { } TextCtrlWidth->SetValue(width); TextCtrlHeight->SetValue(height); } BEGIN_EVENT_TABLE(my_dialog_yuv, wxDialog) EVT_BUTTON(wxID_OK,my_dialog_yuv::OnOk) EVT_RADIOBOX(ID_RADIOBOX, my_dialog_yuv::OnRadioBox) END_EVENT_TABLE()