FailedProjectsDialog.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00011 /*  This is free software; you can redistribute it and/or
00012  *  modify it under the terms of the GNU General Public
00013  *  License as published by the Free Software Foundation; either
00014  *  version 2 of the License, or (at your option) any later version.
00015  *
00016  *  This software is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *  Lesser General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public
00022  *  License along with this software; if not, write to the Free Software
00023  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 #include "FailedProjectsDialog.h"
00028 #include "base_wx/wxPlatform.h"
00029 #include "panoinc.h"
00030 #include "Batch.h"
00031 
00032 BEGIN_EVENT_TABLE(FailedProjectsDialog,wxDialog)
00033     EVT_LISTBOX(XRCID("failed_list"),FailedProjectsDialog::OnSelectProject)
00034 END_EVENT_TABLE()
00035 
00036 FailedProjectsDialog::FailedProjectsDialog(wxWindow* parent,Batch* batch,wxString xrcPrefix)
00037 {
00038     // load our children. some children might need special
00039     // initialization. this will be done later.
00040     wxXmlResource::Get()->LoadDialog(this,parent,wxT("failed_project_dialog"));
00041 
00042 #ifdef __WXMSW__
00043     wxIcon myIcon(xrcPrefix+ wxT("data/ptbatcher.ico"),wxBITMAP_TYPE_ICO);
00044 #else
00045     wxIcon myIcon(xrcPrefix + wxT("data/ptbatcher.png"),wxBITMAP_TYPE_PNG);
00046 #endif
00047     SetIcon(myIcon);
00048     m_batch=batch;
00049 
00050     m_list=XRCCTRL(*this,"failed_list",wxListBox);
00051     m_log=XRCCTRL(*this,"failed_log",wxTextCtrl);
00052 
00053     //fill list
00054     for(unsigned int i=0; i<batch->GetFailedProjectsCount(); i++)
00055     {
00056         m_list->AppendString(batch->GetFailedProjectName(i));
00057     };
00058     if(m_list->GetCount()>0)
00059     {
00060         m_list->SetSelection(0);
00061         wxCommandEvent dummy;
00062         OnSelectProject(dummy);
00063     };
00064 
00065     //set parameters
00066     wxConfigBase* config = wxConfigBase::Get();
00067     // restore position and size
00068     int dx,dy;
00069     wxDisplaySize(&dx,&dy);
00070     bool maximized = config->Read(wxT("/FailedProjectsDialog/maximized"), 0l) != 0;
00071     if (maximized)
00072     {
00073         this->Maximize();
00074     }
00075     else
00076     {
00077         //size
00078         int w = config->Read(wxT("/FailedProjectsDialog/width"),-1l);
00079         int h = config->Read(wxT("/FailedProjectsDialog/height"),-1l);
00080         if (w > 0 && w <= dx)
00081         {
00082             this->SetClientSize(w,h);
00083         }
00084         else
00085         {
00086             this->Fit();
00087         }
00088         //splitter position
00089         int splitter_pos=config->Read(wxT("/FailedProjectsDialog/splitterPos"),-1l);
00090         wxSplitterWindow* splitWindow=XRCCTRL(*this,"failed_splitter",wxSplitterWindow);
00091         if(splitter_pos>0 && splitter_pos<splitWindow->GetSize().GetWidth())
00092         {
00093             splitWindow->SetSashPosition(splitter_pos);
00094         };
00095         //position
00096         int x = config->Read(wxT("/FailedProjectsDialog/positionX"),-1l);
00097         int y = config->Read(wxT("/FailedProjectsDialog/positionY"),-1l);
00098         if ( y >= 0 && x >= 0 && x < dx && y < dy)
00099         {
00100             this->Move(x, y);
00101         }
00102         else
00103         {
00104             this->Move(0, 44);
00105         }
00106     }
00107 };
00108 
00109 FailedProjectsDialog::~FailedProjectsDialog()
00110 {
00111     wxConfigBase* config=wxConfigBase::Get();
00112     if(!this->IsMaximized())
00113     {
00114         wxSize sz = this->GetClientSize();
00115         config->Write(wxT("/FailedProjectsDialog/width"), sz.GetWidth());
00116         config->Write(wxT("/FailedProjectsDialog/height"), sz.GetHeight());
00117         wxPoint ps = this->GetPosition();
00118         config->Write(wxT("/FailedProjectsDialog/positionX"), ps.x);
00119         config->Write(wxT("/FailedProjectsDialog/positionY"), ps.y);
00120         config->Write(wxT("/FailedProjectsDialog/maximized"), 0);
00121     }
00122     else
00123     {
00124         config->Write(wxT("/FailedProjectsDialog/maximized"), 1l);
00125     };
00126     config->Write(wxT("/FailedProjectsDialog/splitterPos"), XRCCTRL(*this,"failed_splitter",wxSplitterWindow)->GetSashPosition());
00127 };
00128 
00129 void FailedProjectsDialog::OnSelectProject(wxCommandEvent& e)
00130 {
00131     int sel=m_list->GetSelection();
00132     m_log->Clear();
00133     if(sel!=wxNOT_FOUND)
00134     {
00135         wxString logfile=m_batch->GetFailedProjectLog(sel);
00136         if(!logfile.IsEmpty())
00137         {
00138             if(wxFileName::FileExists(logfile))
00139             {
00140                 m_log->LoadFile(logfile);
00141             }
00142         };
00143     };
00144 };

Generated on Sun Sep 21 01:25:41 2014 for Hugintrunk by  doxygen 1.3.9.1