/*
 * A dialog which has been automatically generated by gendialog
 *
 *   Copyright (C) Michael Still                    2003
 *   Generated: Mon May 12 15:17:28 EST 2003

 *
 * This program 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 program 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 General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc., 675
 * Mass Ave, Cambridge, MA 02139, USA.
 */

#include "dlgPageSize.h"
#include "configuration.h"

BEGIN_EVENT_TABLE (dlgPageSize, wxDialog) 
EVT_BUTTON (wxID_OK, dlgPageSize::OnOK) 
EVT_BUTTON (wxID_CANCEL, dlgPageSize::OnQuit) 
EVT_CLOSE (dlgPageSize::OnQuit) 
END_EVENT_TABLE ()

dlgPageSize::dlgPageSize ():
  wxDialog ((wxDialog *) NULL, -1, "Page size", wxPoint (100, 100),
	    wxSize (330, 140))
{
  // We store the previous values in the config file so that the user gets
  // presented with that as a default
  configuration *config;
  config = (configuration *) & configuration::getInstance ();
  string confstr;

  m_panel = new wxPanel (this, -1, wxPoint (100, 100), wxSize (330, 140));

new wxStaticText (m_panel, -1, "What size should the PDF's pages be?", wxPoint (5, 10), wxSize (290, 30), wxALIGN_LEFT);
new wxStaticText (m_panel, -1, "Width", wxPoint (5, 50), wxSize (50, 30), wxALIGN_RIGHT);
config->getValue("user-pagesize-widthdefault", "100", confstr);
m_edit0 = new wxTextCtrl (m_panel, -1, confstr.c_str(),wxPoint (65, 45), wxSize (50, 30));
new wxStaticText (m_panel, -1, "pt", wxPoint (125, 50), wxSize (20, 30), wxALIGN_LEFT);
new wxStaticText (m_panel, -1, "Height", wxPoint (155, 50), wxSize (50, 30), wxALIGN_RIGHT);
config->getValue("user-pagesize-heightdefault", "100", confstr);
m_edit1 = new wxTextCtrl (m_panel, -1, confstr.c_str(),wxPoint (215, 45), wxSize (50, 30));
new wxStaticText (m_panel, -1, "pt", wxPoint (275, 50), wxSize (20, 30), wxALIGN_LEFT);
m_ok = new wxButton (m_panel, wxID_OK, "Ok", wxPoint (60, 95));
m_ok->SetDefault ();
m_cancel = new wxButton (m_panel, wxID_CANCEL, "Cancel", wxPoint (170, 95));


  Center ();
  ShowModal ();
}

// Cancel button hit
void
dlgPageSize::OnQuit (wxCommandEvent & WXUNUSED (event))
{
  EndModal (1);
  Destroy ();
}

// Ok button hit
void
dlgPageSize::OnOK (wxCommandEvent & WXUNUSED (event))
{
  // We store the previous values in the config file so that the user gets
  // presented with that as a default. This is also used as a simple message
  // passing scheme for the caller to find out what values were set
  configuration *config;
  config = (configuration *) & configuration::getInstance ();
  string confstr;

config->setValue("user-pagesize-widthdefault", (string) m_edit0->GetValue());
config->setValue("user-pagesize-heightdefault", (string) m_edit1->GetValue());


  EndModal (0);
  Destroy ();
}
