/////////////////////////////////////////////////////////////////////////////
// Name:        wsAboutDialog.cpp
// Purpose:     wsAboutDialog
// Author:      Hans Van Leemputten
// Modified by:
// Created:     03/11/2001
// RCS-ID:      $Id: wsAboutDialog.cpp,v 1.2 2001/04/08 19:01:21 hansvl Exp $
// Copyright:   (c) Hans Van Leemputten
// Licence:     wxWindows license
/////////////////////////////////////////////////////////////////////////////

#ifdef __GNUG__
#pragma implementation "wsAboutDialog.h"
#endif

// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/statline.h"
#include "wx/pmf/wxHyperLink.h"
#include "wx/pmf/wsAboutDialog.h"
#include "build.h"

// Include the xpm into the source, so it's included into the binary file.
#include "wx/pmf/about.xpm"

// wsAboutDialog.cpp : implementation file
//

//IMPLEMENT_DYNAMIC_CLASS(wsAboutDialog, wxDialog)

BEGIN_EVENT_TABLE(wsAboutDialog, wxDialog)
    EVT_BUTTON(-1, wsAboutDialog::OnButton)
END_EVENT_TABLE()

/*
  Sizer Layout of the dialog...
  =============================
  sizerTotalVert    = *
  sizerLine1		= 1
  WS Image			= I
  sizerLine1Vert	= V
  sizerLine1_1		= H
  sizerLine1_1Vert  = #
  sizerLine1Vert2   = %
  Close Button		= B
  wxStaticLine		= -
  sizerLine2		= 2
  StaticText		= T

  **********************************************************
  *11111111111111111111111111111111111111111111111111111111*
  *1       VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV1*
  *1 IIIII VHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHV1*
  *1 IIIII VH#################################### BBBBB HV1*
  *1 IIIII VH#  TTTTTTTTT                       # BBBBB HV1*
  *1 IIIII VH#################################### BBBBB HV1*
  *1       VHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHV1*
  *1       V%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%V1*
  *1       V%   TTTTTTTTTTTTTTTTTTTTTTTTTTT             %V1*
  *1       V%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%V1*
  *1       VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV1*
  *11111111111111111111111111111111111111111111111111111111*
  *--------------------------------------------------------*
  *22222222222222222222222222222222222222222222222222222222*
  *2 TTTT TTTTTTTTTTTTTTTTT          TTTT TTTTTTTTTTTTTTT 2*
  *22222222222222222222222222222222222222222222222222222222*
  **********************************************************

*/


/////////////////////////////////////////////////////////////////////////////
// wsAboutDialog dialog

wsAboutDialog::wsAboutDialog(wxWindow *parent)
             : wxDialog(parent, -1, wxString(wxT("About ")).Append(PROGRAM_NAME))
{
    // Create all sizers used in this dialog.
	wxBoxSizer *sizerLine1		= new wxBoxSizer(wxHORIZONTAL);
	wxBoxSizer *sizerLine1Vert	= new wxBoxSizer(wxVERTICAL);
	wxBoxSizer *sizerLine1_1	= new wxBoxSizer(wxHORIZONTAL);
	wxBoxSizer *sizerLine1_1Vert= new wxBoxSizer(wxVERTICAL);
	wxBoxSizer *sizerLine1Vert2	= new wxBoxSizer(wxVERTICAL);
	wxBoxSizer *sizerLine2		= new wxBoxSizer(wxHORIZONTAL);
	wxBoxSizer *sizerTotalVert	= new wxBoxSizer(wxVERTICAL);

	// Create some fonts used.
	wxFont fontBoldTitle = GetFont();
	wxFont fontSmallText(7, wxSWISS, wxNORMAL, wxLIGHT);  
	fontBoldTitle.SetPointSize(fontBoldTitle.GetPointSize() + 4);
	fontBoldTitle.SetWeight(wxBOLD);
	
	// Create some components that need a special font...
	wxStaticText *strProgTitle = new wxStaticText(this, -1, PROGRAM_NAME);
	wxStaticText *strProgVersion = new wxStaticText(this, -1, PROGRAM_VERSION);
	wxStaticText *strBuildDate = new wxStaticText(this, -1, wxString(wxT("Build Date: ")).Append(PROGRAM_BUILD_DATE));
	wxStaticText *strRAD_IDE = new wxStaticText(this, -1, PROGRAM_INFO);
	wxStaticText *strBasedOn = new wxStaticText(this, -1, wxString(wxT("Based on ")).Append(wxVERSION_STRING));
	wxStaticText *strCopyRight = new wxStaticText(this, -1, PROGRAM_COPYRIGHT);
	
	// Now assign a font to all different components.
	strProgTitle->SetFont(fontBoldTitle);
	strCopyRight->SetFont(fontSmallText);

	// Set all text information into the 2 Vertical sub-sizer, 
	// This will be put into the vertical sub sizer of line 1 
	sizerLine1_1Vert->Add( strProgTitle, 0, wxALIGN_LEFT | wxALL, 0);
	sizerLine1_1Vert->Add( strProgVersion, 0, wxALIGN_LEFT | wxALL, 0);
	sizerLine1_1Vert->Add( strBuildDate, 0, wxALIGN_LEFT | wxALL, 0);

	sizerLine1Vert2->Add( strRAD_IDE, 0, wxALIGN_LEFT | wxTOP, 10);
	sizerLine1Vert2->Add( strBasedOn, 0, wxALIGN_LEFT | wxALL, 0);
	sizerLine1Vert2->Add( strCopyRight, 0, wxALIGN_LEFT | wxTOP, 15);

	// Create the Close button and aling it.
	m_btnClose = new wxButton(this, -1, wxT("&Close"));
	sizerLine1_1->Add(sizerLine1_1Vert, 0, wxALIGN_LEFT | wxALL, 0);
	sizerLine1_1->Add(0, 0, 1, wxEXPAND);
	sizerLine1_1->Add(m_btnClose, 0, wxALIGN_RIGHT | wxTOP | wxBOTTOM | wxLEFT, 5);	

	// Get the vertical sizer ready to include into line 1
	sizerLine1Vert->Add(sizerLine1_1, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 0);
	sizerLine1Vert->Add(sizerLine1Vert2, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 0);

	// Now format it all on line 1
	//sizerLine1->Add(64+5, 64+5); // This is a dummy image...
	sizerLine1->Add(new wxStaticBitmap(this, -1, wxBitmap(about_xpm)), 0, wxALIGN_LEFT | wxTOP | wxBOTTOM | wxRIGHT, 5); 
	sizerLine1->Add(sizerLine1Vert, 1, wxEXPAND | wxALIGN_CENTER | wxTOP | wxBOTTOM | wxLEFT, 5);

	// Create text + hyper link and set it on a line.
	wxString strMail(wxT("mailto:"));
	strMail.Append(PROGRAM_MAIL_ADDRESS);
	m_WebLink = new wxHyperLink(this, -1, PROGRAM_WEBSITE);
	m_MailLink = new wxHyperLink(this, -1, strMail, PROGRAM_MAIL_ADDRESS);
	sizerLine2->Add(new wxStaticText(this, -1, wxT("Web:")), 0, wxALIGN_LEFT | wxTOP | wxBOTTOM | wxRIGHT, 5);
	sizerLine2->Add(m_WebLink, 0, wxALIGN_LEFT | wxTOP | wxBOTTOM, 5);
	sizerLine2->Add(5, 0, wxEXPAND);
	sizerLine2->Add(new wxStaticText(this, -1, wxT("E-Mail:")), 0, wxALIGN_RIGHT | wxTOP | wxBOTTOM | wxRIGHT, 5);
	sizerLine2->Add(m_MailLink, 0, wxALIGN_RIGHT | wxTOP | wxBOTTOM, 5);	

	// Now align it vertical in the dialog.
	sizerTotalVert->Add(sizerLine1, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
	sizerTotalVert->Add(new wxStaticLine(this, -1), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
	sizerTotalVert->Add(sizerLine2, 0, wxEXPAND | wxLEFT | wxRIGHT , 10);
	
	SetAutoLayout( TRUE );					// tell dialog to use sizer
	SetSizer( sizerTotalVert );				// actually set the sizer
	
	sizerTotalVert->Fit( this );			// set size to minimum size as calculated by the sizer
	sizerTotalVert->SetSizeHints( this );	// set size hints to honour mininum size

	m_btnClose->SetFocus();
    m_btnClose->SetDefault();
}


/////////////////////////////////////////////////////////////////////////////
// wsAboutDialog message handlers

void wsAboutDialog::OnButton(wxCommandEvent &event)
{
    if ( event.GetEventObject() == m_btnClose )
    {
		Close();
    }
    else
    {
        event.Skip();
    }
}
