Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[419cd4]: src / hugin1 / ptbatcher / FailedProjectsDialog.cpp Maximize Restore History

Download this file

FailedProjectsDialog.cpp    137 lines (125 with data), 4.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// -*- c-basic-offset: 4 -*-
/** @file FailedProjectsDialog.cpp
*
* @brief implementation of failed projects dialog
*
* @author Thomas Modes
*
*/
/* This 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 software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "FailedProjectsDialog.h"
#include "common/wxPlatform.h"
#include "panoinc.h"
#include "Batch.h"
BEGIN_EVENT_TABLE(FailedProjectsDialog,wxDialog)
EVT_LISTBOX(XRCID("failed_list"),FailedProjectsDialog::OnSelectProject)
END_EVENT_TABLE()
FailedProjectsDialog::FailedProjectsDialog(wxWindow *parent,Batch *batch,wxString xrcPrefix)
{
// load our children. some children might need special
// initialization. this will be done later.
wxXmlResource::Get()->LoadDialog(this,parent,wxT("failed_project_dialog"));
#ifdef __WXMSW__
wxIcon myIcon(xrcPrefix+ wxT("data/icon.ico"),wxBITMAP_TYPE_ICO);
#else
wxIcon myIcon(xrcPrefix + wxT("data/icon.png"),wxBITMAP_TYPE_PNG);
#endif
SetIcon(myIcon);
m_batch=batch;
m_list=XRCCTRL(*this,"failed_list",wxListBox);
m_log=XRCCTRL(*this,"failed_log",wxTextCtrl);
//fill list
for(unsigned int i=0;i<batch->GetFailedProjectsCount();i++)
{
m_list->AppendString(batch->GetFailedProjectName(i));
};
if(m_list->GetCount()>0)
{
m_list->SetSelection(0);
wxCommandEvent dummy;
OnSelectProject(dummy);
};
//set parameters
wxConfigBase * config = wxConfigBase::Get();
// restore position and size
int dx,dy;
wxDisplaySize(&dx,&dy);
bool maximized = config->Read(wxT("/FailedProjectsDialog/maximized"), 0l) != 0;
if (maximized)
{
this->Maximize();
}
else
{
//size
int w = config->Read(wxT("/FailedProjectsDialog/width"),-1l);
int h = config->Read(wxT("/FailedProjectsDialog/height"),-1l);
if (w > 0 && w <= dx)
{
this->SetClientSize(w,h);
}
else
{
this->Fit();
}
//position
int x = config->Read(wxT("/FailedProjectsDialog/positionX"),-1l);
int y = config->Read(wxT("/FailedProjectsDialog/positionY"),-1l);
if ( y >= 0 && x >= 0 && x < dx && y < dy)
{
this->Move(x, y);
}
else
{
this->Move(0, 44);
}
}
};
FailedProjectsDialog::~FailedProjectsDialog()
{
wxConfigBase* config=wxConfigBase::Get();
if(!this->IsMaximized())
{
wxSize sz = this->GetClientSize();
config->Write(wxT("/FailedProjectsDialog/width"), sz.GetWidth());
config->Write(wxT("/FailedProjectsDialog/height"), sz.GetHeight());
wxPoint ps = this->GetPosition();
config->Write(wxT("/FailedProjectsDialog/positionX"), ps.x);
config->Write(wxT("/FailedProjectsDialog/positionY"), ps.y);
config->Write(wxT("/FailedProjectsDialog/maximized"), 0);
}
else
{
config->Write(wxT("/FailedProjectsDialog/maximized"), 1l);
};
};
void FailedProjectsDialog::OnSelectProject(wxCommandEvent &e)
{
int sel=m_list->GetSelection();
m_log->Clear();
if(sel!=wxNOT_FOUND)
{
wxString logfile=m_batch->GetFailedProjectLog(sel);
if(!logfile.IsEmpty())
{
if(wxFileName::FileExists(logfile))
{
m_log->LoadFile(logfile);
}
};
};
};