#include "kwaFr_app.h"

#include "gui/mainFrame.h"

#include <chrono>
#include <sdi_toolBox/desktop/msw/win32Console.h>
#include <wx/image.h>
#include <wx/setup.h>

#if !wxUSE_WEBVIEW
#  error "wxWebView is not enabled in your wxWidgets build!"
#endif

// #if !wxUSE_WEBVIEW_EDGE
// #  error "Edge backend is not enabled in your wxWidgets build!"
// #endif

wxIMPLEMENT_APP(KwaFr_app);
using namespace std;

//--------------------------------------------------------------
bool KwaFr_app::OnInit()
{
  // Init application console and attach debug console under MSW
  sdi_toolBox::desktop::msw::Win32Console::initConsole();

  // setGlobalAppContext(&m_ctx);

  // Try to prevent the tzdb allocations from being reported as memory leaks
  //(void)chrono::current_zone();

  // wxWidgets configuration
  wxInitAllImageHandlers();

  // Init chart director licence
  // Chart::setLicenseCode("DEVP-2MGC-EMGP-RDYE-A2BD-361B");

  // Creating the main frame
  const auto frame = new gui::MainFrame(m_ctx);
  frame->Show();

  return true;
}
//--------------------------------------------------------------
int KwaFr_app::OnExit()
{
  // Try to prevent the tzdb allocations from being reported as memory leaks
  // std::chrono::get_tzdb_list().~tzdb_list();

  // m_ctx.releaseAll();

  return wxApp::OnExit();
}
//--------------------------------------------------------------
