/*******************************************************************************
  TPI - flexible but useless plug-in framework.
  Copyright (C) 2002-2009 Silky

  This library is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free
  Software Foundation; either version 2.1 of the License, or (at your option)
  any later version.

  This library 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 Lesser General Public License along
  with this library; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

  $Id: frontend-wx.cpp,v 1.2 2009/08/09 07:15:21 sirakaba Exp $
*******************************************************************************/

#include "frontend-wx.h"
#include "frm_main.h"

//******************************************************************************
// Frontend
//******************************************************************************

class Frontend: public wxApp
{
public:
    bool OnInit();
};

IMPLEMENT_APP(Frontend)

bool Frontend::OnInit()
{
	wxInitAllImageHandlers();
	::wxXmlResource::Get()->InitAllHandlers();

	MainFrame * frm_main = new MainFrame();

	// 作業パスを設定。
	frm_main->szCurrentPath = ::wxGetCwd() + wxT("/");
	{
		wxStandardPaths p;
		::wxSetWorkingDirectory(::wxPathOnly(p.GetExecutablePath()) + wxT("/"));
	}

	if (! ::wxXmlResource::Get()->Load(FE_DIR_S_XRC wxT("frm_main.xrc")))
	{
		::wxMessageBox(wxT("Error: Unable to find XRC!"));
		return false;
	}

	::wxXmlResource::Get()->LoadFrame(frm_main, NULL, wxT("frame_main"));
	::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("frm_main.xrc"));
	SetTopWindow(frm_main);
	frm_main->cmdLine.SetCmdLine(this->argc, this->argv);
	frm_main->InitDialog();
	frm_main->Show();

	return true;
}
