Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
wxMessageDialogCheckbox.cpp
1 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
2 
3  Copyright (C) 2003-2009 (see file CONTACT for details)
4  Multimediale Systeme der Informationsverarbeitung
5  Institut fuer Informatik
6  Christian-Albrechts-Universitaet Kiel
7 
8  BIAS is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation; either version 2.1 of the License, or
11  (at your option) any later version.
12 
13  BIAS is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with BIAS; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21 
22 #include "wxMessageDialogCheckbox.hh"
23 #include <iostream>
24 
25 using namespace BIAS;
26 
27 
30  const wxString& title,
31  const wxString& text,
32  const wxPoint& pos,
33  const wxSize& size,
34  long style ):
35  wxDialog( parent, 0, title, pos, size, style | wxRESIZE_BORDER |wxDEFAULT_DIALOG_STYLE )
36 {
37  m_button1 = m_button2 =NULL;
38  m_parent = parent;
39  int w = size.GetWidth();
40  int h = size.GetHeight();
41  int length = text.Length();
42  h = (double)((length*180)/(double)(w-10))+70;
43  wxSize newSize(w,h);
44  wxSize buttonSize(80,30);
45  wxSize checkboxSize(w,30);
46 
47  this->SetSizeHints( newSize, wxDefaultSize );
48  this->SetSize(newSize);
49 
50  wxBoxSizer* bSizer2;
51  bSizer2 = new wxBoxSizer( wxVERTICAL );
52 
53 
54  displayText_ = new wxStaticText(this,wxID_ANY,wxT("test"));
55  displayText_->SetLabel(text);
56  displayText_->Wrap(w-5);
57  bSizer2->Add( displayText_, 0, wxALL, 5 );
58 
59  checkBox_ = new wxCheckBox(this, wxID_CHECKBOX,
60  wxT("Do not bother me again!"),
61  wxDefaultPosition, checkboxSize, 0 );
62  bSizer2->Add( checkBox_, 0, wxALL, 5 );
63  //ok button
64  if (style & wxOK){
65  m_button1 = new wxButton( this, wxID_OK);
66  if(style & wxCANCEL)
67  m_button2 = new wxButton( this, wxID_CANCEL);
68  }
69  else if (style & wxYES_NO){
70  m_button1 = new wxButton( this, wxID_YES);
71  m_button2 = new wxButton( this, wxID_NO);
72  }
73 
74  m_sdbSizer2 = new wxStdDialogButtonSizer();
75 
76  if(m_button1 != NULL)
77  m_sdbSizer2->Add(m_button1, 0, wxALL, 5 );
78  if(m_button2 != NULL)
79  m_sdbSizer2->Add(m_button2, 0, wxALL, 5 );
80 
81  m_sdbSizer2->Realize();
82  bSizer2->Add( m_sdbSizer2, 0, wxALL, 5 );
83  this->SetSizer( bSizer2 );
84  this->Layout();
85  this->Fit();
86 }
87 
90 {
91 }
92 
93 bool
96  return checkBox_->IsChecked();
97 }
98 
wxStdDialogButtonSizer * m_sdbSizer2
wxMessageDialogCheckbox(wxWindow *parent, const wxString &title=wxT("Ok dialog with check box"), const wxString &text=wxT("Your question?"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(200, 120), long style=wxOK|wxDEFAULT_DIALOG_STYLE)