/**
    File        : CSplashScreen.cpp
    Description : Splash Screen
    Author      : Raymond Marsh
    Created     : 08/01/2009
    Copyright 2009, 2010 Raymond Marsh

    This program is distributed under the terms of the GNU General Public License.
    To view a copy of the license see the file 'copying.txt'

    This file is part of the Ace Personal Finance Assistant Suite.

    Ace Personal Finance Assistant 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 3 of the License, or (at your option) any later version.

    Ace Personal Finance Assistant 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 Ace Personal Finance Assistant.
    If not, see <http://www.gnu.org/licenses/>.
**/

#include "SplashScreen.h"

BEGIN_EVENT_TABLE(CSplashScreen,wxDialog)
	EVT_PAINT (CSplashScreen::OnPaint)
END_EVENT_TABLE()

CSplashScreen::CSplashScreen(wxWindow* parent, const int Time, const int idTimer, wxString& Version, wxString& Revision)
: wxDialog(parent, wxID_ANY, "", wxDefaultPosition, wxSize(650, 300), wxSTAY_ON_TOP | wxNO_BORDER),
  m_Version(Version), m_Revision(Revision)
{
	wxString Filename = _("Media\\Images\\splash.png");

	m_Bitmap.LoadFile(Filename, wxBITMAP_TYPE_PNG);
    if (!m_Bitmap.IsOk() )
        aceMSGBOX(this, ace::MB_ERROR, _("Could not load Bitmap!"), NULL);

    // start timer
	m_pTimer = new wxTimer(parent, idTimer);
	if (!m_pTimer->Start(Time, true) )
        aceMSGBOX(this, ace::MB_ERROR, "Could not start timer", NULL);
}

CSplashScreen::~CSplashScreen()
{
    if (m_pTimer)
        delete m_pTimer;
}

void CSplashScreen::End()
{
    this->Show(false);
}

void CSplashScreen::OnPaint(wxPaintEvent& paint_event)
{
    wxPaintDC DC(this);
    if (!DC.IsOk() )
    {
        aceMSGBOX(this, ace::MB_ERROR, "Bad DC!", NULL);
        return;
    }

    // draw bitmap
    DC.DrawBitmap(m_Bitmap, 0, 0);

    // draw version info
    DC.SetTextForeground(wxColor(0, 0, 0) );
    DC.SetFont(wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL) );
    DC.DrawText(m_Version, 420, 180);
    DC.DrawText(m_Revision, 420, 200);

    // draw status line
    DC.SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD) );
    DC.DrawText(m_StatusMsg, 400, 230);
}
