NIREP

GetPanelFromUser.cpp

Go to the documentation of this file.
00001 
00002 // Name:        GetPanelFromUser.cpp
00003 // Purpose:     
00004 // Author:      
00005 // Modified by: 
00006 // Created:     07/01/2010 12:14:52
00007 // RCS-ID:      
00008 // Copyright:   
00009 // Licence:     
00011 
00012 // For compilers that support precompilation, includes "wx/wx.h".
00013 #include "wx/wxprec.h"
00014 
00015 #ifdef __BORLANDC__
00016 #pragma hdrstop
00017 #endif
00018 
00019 #ifndef WX_PRECOMP
00020 #include "wx/wx.h"
00021 #endif
00022 
00025 
00026 #include "GetPanelFromUser.h"
00027 #include "NIREPDisplay.h"
00028 
00031 
00032 
00037 IMPLEMENT_CLASS( GetPanelFromUser, wxFrame )
00038 
00039 
00040 
00044 BEGIN_EVENT_TABLE( GetPanelFromUser, wxFrame )
00045 
00047     EVT_BUTTON( ID_OK_BUTTON, GetPanelFromUser::OnOkButtonClick )
00048 
00049     EVT_BUTTON( ID_CANCEL_BUTTON, GetPanelFromUser::OnCancelButtonClick )
00050 
00052 
00053 END_EVENT_TABLE()
00054 
00055 
00060 GetPanelFromUser::GetPanelFromUser()
00061 {
00062     Init();
00063 }
00064 
00065 GetPanelFromUser::GetPanelFromUser( wxWindow* parent,int NumberOfRows, int NumberOfCols, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00066 {
00067     displayParent = (NIREPDisplay*)parent;
00068     numberOfRows = NumberOfRows;
00069     numberOfCols = NumberOfCols;
00070     Init();
00071     Create( parent, id, caption, pos, size, style );
00072 }
00073 
00074 
00079 bool GetPanelFromUser::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00080 {
00082     wxFrame::Create( parent, id, caption, pos, size, style );
00083 
00084     CreateControls();
00085     Centre();
00087     return true;
00088 }
00089 
00090 
00095 GetPanelFromUser::~GetPanelFromUser()
00096 {
00099 }
00100 
00101 
00106 void GetPanelFromUser::Init()
00107 {
00110 }
00111 
00112 
00117 void GetPanelFromUser::CreateControls()
00118 {    
00120     GetPanelFromUser* itemFrame1 = this;
00121 
00122     wxPanel* itemPanel2 = new wxPanel( itemFrame1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
00123 
00124     wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
00125     itemPanel2->SetSizer(itemBoxSizer3);
00126 
00127     wxStaticText* itemStaticText4 = new wxStaticText( itemPanel2, wxID_STATIC, _("Please enter the row and column of the Panel you wish to edit."), wxDefaultPosition, wxDefaultSize, 0 );
00128     itemStaticText4->SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
00129     itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00130 
00131     wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
00132     itemBoxSizer3->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00133 
00134     wxStaticText* itemStaticText6 = new wxStaticText( itemPanel2, wxID_STATIC, _("Row"), wxDefaultPosition, wxDefaultSize, 0 );
00135     itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00136 
00137     rowText = new wxTextCtrl( itemPanel2, ID_ROW_TEXT, _T("1"), wxDefaultPosition, wxDefaultSize, 0 );
00138     itemBoxSizer5->Add(rowText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00139 
00140     wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
00141     itemBoxSizer3->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00142 
00143     wxStaticText* itemStaticText9 = new wxStaticText( itemPanel2, wxID_STATIC, _("Column"), wxDefaultPosition, wxDefaultSize, 0 );
00144     itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00145 
00146     colText = new wxTextCtrl( itemPanel2, ID_COLUMN_TEXT, _T("1"), wxDefaultPosition, wxDefaultSize, 0 );
00147     itemBoxSizer8->Add(colText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00148 
00149     wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
00150     itemBoxSizer3->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00151 
00152     wxButton* itemButton12 = new wxButton( itemPanel2, ID_OK_BUTTON, _("Ok"), wxDefaultPosition, wxDefaultSize, 0 );
00153     itemBoxSizer11->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00154 
00155     wxButton* itemButton13 = new wxButton( itemPanel2, ID_CANCEL_BUTTON, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
00156     itemBoxSizer11->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00157 
00159 }
00160 
00161 
00166 bool GetPanelFromUser::ShowToolTips()
00167 {
00168     return true;
00169 }
00170 
00175 wxBitmap GetPanelFromUser::GetBitmapResource( const wxString& name )
00176 {
00177     // Bitmap retrieval
00179     wxUnusedVar(name);
00180     return wxNullBitmap;
00182 }
00183 
00188 wxIcon GetPanelFromUser::GetIconResource( const wxString& name )
00189 {
00190     // Icon retrieval
00192     wxUnusedVar(name);
00193     return wxNullIcon;
00195 }
00196 
00197 
00201 //okay, need to do some error checking and then exit out
00202 //
00203 void GetPanelFromUser::OnOkButtonClick( wxCommandEvent& event )
00204 {
00205   long rowNumber = -1;
00206   long colNumber = -1;
00207   rowText->GetLabelText().ToLong(&rowNumber);
00208   colText->GetLabelText().ToLong(&colNumber);
00209   if(rowText->GetLabelText().IsNumber()&& !rowText->GetLabelText().IsEmpty() &&  rowNumber<= numberOfRows && rowNumber>= 0 && colNumber>= 0  && colText->GetLabelText().IsNumber() && !colText->GetLabelText().IsEmpty() && colNumber<= numberOfCols)
00210   {
00211     this->displayParent->EditPanel(rowNumber-1,colNumber-1);
00212     this->Close();
00213   }
00214   else
00215   {
00216     wxString temp = wxT("Please put in a row that is less then: ");// + numberOfRows+   " and a column that is less then: "+numberOfCols;
00217     temp.Append(wxString::Format (wxT("%d"), numberOfRows+1));
00218     temp.Append(wxT(" or greater then 0 and put in a column that is more then: "));
00219     temp.Append(wxString::Format (wxT("%d"), numberOfCols+1));
00220     temp.Append(wxT(" or greater then 0."));
00221     wxLogError(temp);
00222   }
00223 }
00224 
00225 
00230 void GetPanelFromUser::OnCancelButtonClick( wxCommandEvent& event )
00231 {
00232   this->Close();
00233 }
00234 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines