30 #include <wx/textfile.h> 
   37     wxXmlResource::Get()->LoadDialog(
this, parent, 
"choice_aspect_dlg");
 
   38     m_aspectList = XRCCTRL(*
this, 
"aspect_listbox", wxListBox);
 
   70     if (selection != wxNOT_FOUND)
 
   77 bool CheckInputs(wxWindow* parent, wxTextCtrl* labelCtrl, wxTextCtrl* aspectRatioCtrl, 
double& value)
 
   80     const wxString label = labelCtrl->GetValue().Trim(
true).Trim(
false);
 
   81     if (label.IsEmpty() || label.Find(
separator) != wxNOT_FOUND)
 
   88     wxString valueString = aspectRatioCtrl->GetValue();
 
   89     int pos = valueString.Find(
":");
 
   90     if (pos != wxNOT_FOUND)
 
   95             double val1, val2 = 0;
 
   96             if (valueString.Mid(0, pos).ToDouble(&val1) && valueString.Mid(pos + 1).ToDouble(&val2))
 
  101                     if (value > 1e-4 && value < 10000)
 
  108                             _(
"Hugin"), wxOK | wxICON_ERROR, parent);
 
  118         if (valueString.ToDouble(&value))
 
  120             if (value > 1e-4 && value < 10000)
 
  126                 hugin_utils::HuginMessageBox(wxString::Format(_(
"The aspect ratio \"%s\" is not in the valid range."), aspectRatioCtrl->GetValue()), _(
"Hugin"), wxOK | wxICON_ERROR, parent);
 
  132     hugin_utils::HuginMessageBox(wxString::Format(_(
"The input \"%s\" is not a valid number."), aspectRatioCtrl->GetValue()), _(
"Hugin"), wxOK | wxICON_ERROR, parent);
 
  139     wxXmlResource::Get()->LoadDialog(&dlg, 
this, 
"add_aspect_dlg");
 
  140     wxTextCtrl* labelCtrl = XRCCTRL(dlg, 
"aspect_label_textctrl", wxTextCtrl);
 
  141     wxTextCtrl* aspectRatioCtrl = XRCCTRL(dlg, 
"aspect_ratio_textctrl", wxTextCtrl);
 
  142     aspectRatioCtrl->SetValue(
"2:1");
 
  144     dlg.Bind(wxEVT_COMMAND_BUTTON_CLICKED, [labelCtrl, aspectRatioCtrl, &dlg](wxCommandEvent &e)
 
  147             if (
CheckInputs(&dlg, labelCtrl, aspectRatioCtrl, val))
 
  149                 dlg.EndModal(wxID_OK);
 
  151         }, XRCID(
"wxID_OK"));
 
  152     if (dlg.ShowModal() == wxID_OK)
 
  155         if (
CheckInputs(&dlg, labelCtrl, aspectRatioCtrl, value))
 
  192     XRCCTRL(*
this, 
"wxID_OK", wxButton)->Enable(selection != wxNOT_FOUND);
 
  193     XRCCTRL(*
this, 
"remove_aspect_button", wxButton)->Enable(selection != wxNOT_FOUND && 
m_aspectRatioStrings.size() > 1);
 
  202         const auto addAspect = [
this](
const double v1, 
const double v2)
 
  227     if (textFile.Exists())
 
  232         for (wxString 
line = textFile.GetFirstLine(); !textFile.Eof(); 
line = textFile.GetNextLine())
 
  237             if (pos != wxNOT_FOUND && pos > 0 && pos + 
separator.length() < 
line.length())
 
  239                 const wxString aspectRatio = 
line.Mid(pos + 
separator.length());
 
  240                 if (aspectRatio.IsEmpty())
 
  246                 if (aspectRatio.ToCDouble(&ratio))
 
  259     if (textFile.Exists())
 
bool CheckInputs(wxWindow *parent, wxTextCtrl *labelCtrl, wxTextCtrl *aspectRatioCtrl, double &value)
check the input of the add aspect ratio dialog 
 
std::vector< double > m_aspectRatios
vector with values of all aspect ratios, ratio=width/height 
 
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
 
static const wxString separator
 
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
 
void OnListBoxSelect(wxCommandEvent &e)
event handler for activation/deactivation of buttons if necessary 
 
void OnOk(wxCommandEvent &e)
handler for Ok, check for valid inputs 
 
wxArrayString m_aspectRatioStrings
array with names of all aspect ratios 
 
void LoadAspectRatios()
load aspect ratios from file 
 
Definition of dialog for selecting and editing aspect ratios of crop. 
 
void SaveAspectRatios()
save the aspect ratios to the file 
 
double GetSelectedAspectRatio() const 
returns the selected aspect ratio 
 
void OnRemoveAspectRatio(wxCommandEvent &e)
handler for removing selected aspect ratio 
 
include file for the hugin project 
 
void OnAddAspectRatio(wxCommandEvent &e)
handler for adding new aspect ratio setting 
 
std::string GetUserAppDataDir()
returns the directory for user specific Hugin settings, e.g. 
 
wxListBox * m_aspectList
pointer to wxListBox of aspect ratios 
 
wxFileName GetAspectRatioFilename() const 
returns the file name for the list of aspect ratios 
 
~SelectAspectRatioDialog()
destructor, save position and list of aspect ratios 
 
SelectAspectRatioDialog(wxWindow *parent)
constructor, build dialog and load settings from file 
 
void FillListBox()
read the settings from the file and add them to the list box if the file does not exist...
 
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
 
void ListBoxSelectionChanged()
implementation of activation/deactivation of buttons if necessary