/*
 * File:        wxtemp.cpp
 * Purpose:     wxWindows template
 * Version:     0.1.1
 * Author:      Peter Ivanov
 * Created:     2003-09-30
 * Last modify: 2003-11-01
 */

// ============================================================================
// declarations
// ============================================================================

// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------

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

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers)
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

// "wxtemp.h"-t IRD AT!
#include "wxtemp.h"
#include "wx/intl.h"
#include "mylogwin.h"

// Create a new application object: this macro will allow wxWindows to create
// the application object during program execution (it's better than using a
// static object for many reasons) and also implements the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// not wxApp)
IMPLEMENT_APP(MyApp)

// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------

// the application icon (under Windows and OS/2 it is in resources)
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
    #include "mondrian.xpm"
#endif

// ============================================================================
// implementation
// ============================================================================

// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------

// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
    wxLog::SetTimestamp (_T("[%Y.%m.%d. %H:%M:%S]"));
    m_locale.Init (wxLANGUAGE_HUNGARIAN, wxLOCALE_LOAD_DEFAULT);
    
    // create the main application window
    MyFrame *frame = new MyFrame(_T("wxTemplate2"),
                                 wxPoint(50, 50), wxSize(450, 340));

    // and show it (the frames, unlike simple controls, are not shown when
    // created initially)
    frame->Show(TRUE);

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returned FALSE here, the
    // application would exit immediately.
    return TRUE;
}

// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------

// frame constructor
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
       : wxFrame(NULL, -1, title, pos, size, style)
{
    // set the frame icon
    SetIcon(wxICON(deltav_icon));

#if wxUSE_MENUS
    wxMenuBar *menuBar = new wxMenuBar();

    menuFile = new wxMenu;
    menuView = new wxMenu;
    menuHelp = new wxMenu;
    
    menuBar->Append (menuFile, _T("&Fjl"));
    menuBar->Append (menuView, _T("&Nzet"));
    menuBar->Append (menuHelp, _T("&Segtsg"));

    // File    
    menuFile->Append (App_Quit, _T("&Kilp\tAlt-X"), 
        _T("Kilps a programbl"));

    // View
    //menuView->Append (App_View1, _T("&Valami..."),
    //    _T("Valami menu"));
    #ifdef __WXDEBUG__
    menuView->AppendSeparator ();
    menuView->AppendCheckItem (App_ViewLogWindow, _T("&Napl"),
        _T("A hibafeldertst segt naplkpet jelenti meg"));
    menuView->Check (App_ViewLogWindow, false);
    #endif


    // Help
    menuHelp->Append(App_About, _T("&Nvjegy...\tF1"), 
        _T("Informcik a programrl s a szerzrl"));

    // ... and attach this menu bar to the frame
    SetMenuBar(menuBar);
#endif // wxUSE_MENUS

#if wxUSE_STATUSBAR
    // create a status bar just for fun (by default with 1 pane only)
    CreateStatusBar (1);
    SetStatusText(_T("dvzllek!"));
#endif // wxUSE_STATUSBAR

    wxPanel *panel = new wxPanel (this);
    wxBoxSizer *topsizer = new wxBoxSizer (wxVERTICAL);
    
    topsizer->Add (new wxStaticText (panel, -1, _T("Hello")), 0,
        wxALL, 5);
    
    panel->SetSizer (topsizer);      // use the sizer for layout
    topsizer->SetSizeHints (panel);   // set size hints to honour minimum size

    #ifdef __WXDEBUG__
    this->logwin = new MyLogWindow (this, "Nyomkvetsi napl", false);
    this->logwin->GetFrame ()->SetSize (50, 400, -1, 500, 
        wxSIZE_AUTO | wxSIZE_USE_EXISTING);
    this->logwin->SetMenu ((int)App_ViewLogWindow, this->menuView);

    wxLogDebug(_T("Binris kszlt: " __DATE__ " " __TIME__ ));
    wxLogDebug(_T("Opercis rendszer: %s"), wxGetOsDescription ().c_str ());
    wxLogDebug(_T("GCC verzi: " __VERSION__));
    wxLogDebug(_T("wxWindows verzi: %i.%i.%i"), 
        wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER);
    #endif
}

// event handlers

#ifdef __WXDEBUG__
void MyFrame::OnViewLogWindow (wxCommandEvent& WXUNUSED(event))
{
    this->logwin->Show (menuView->IsChecked (App_ViewLogWindow));
}
#endif

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    // TRUE is to force the frame to close
    Close(TRUE);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxString msg;
    msg.Printf(_T("wxTemplate\n")
               _T("Binris kszlt: " __DATE__ " " __TIME__ "\n")
               _T("Szerz: Ivanov Pter\n\n")
               _T("Opercis rendszer: %s\n")
               _T("GCC verzi: " __VERSION__ "\n")
               _T("wxWindows verzi: %i.%i.%i"), 
               wxGetOsDescription ().c_str (),
               wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER );

    wxMessageBox (msg, _T("Nvjegy"), wxOK | wxICON_INFORMATION, this);
}


