// -*- C++ -*- generated by wxGlade 0.6.3 on Mon Jun 08 11:33:11 2009

#include <iostream>

#include "Output.h"
#include "TestOutput.h"

// begin wxGlade: ::extracode
// end wxGlade

//OUTPUT::COutputAgentObject g_stOutputAgent;


MyFrame::MyFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
    wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE)
{
    // begin wxGlade: MyFrame::MyFrame
    sizer_4_staticbox = new wxStaticBox(this, -1, wxT("Level"));
    m_cbDEBUG = new wxCheckBox(this, ID_CB_DEBUG, wxT("DEBUG"));
    m_cbINFO = new wxCheckBox(this, ID_CB_INFO, wxT("INFO"));
    m_cbWARN = new wxCheckBox(this, ID_CB_WARN, wxT("WARN"));
    m_cbERROR = new wxCheckBox(this, ID_CB_ERROR, wxT("ERROR"));
    m_textInfo = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
    button_1 = new wxButton(this, wxID_ANY, wxT("Output"));
    m_textOutput = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);

    set_properties();
    do_layout();

	_output = new COutput(m_textOutput);

	g_stOutputAgent.SetOutput(_output);
	g_stOutputAgent.SetLevel(0);
	
    // end wxGlade
}


BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    // begin wxGlade: MyFrame::event_table
    EVT_CHECKBOX(ID_CB_DEBUG, MyFrame::OnCheckBoxLevel)
    EVT_CHECKBOX(ID_CB_INFO, MyFrame::OnCheckBoxLevel)
    EVT_CHECKBOX(ID_CB_WARN, MyFrame::OnCheckBoxLevel)
    EVT_CHECKBOX(ID_CB_ERROR, MyFrame::OnCheckBoxLevel)
    EVT_BUTTON(wxID_ANY, MyFrame::OnButtonOutput)
    // end wxGlade
END_EVENT_TABLE();


void MyFrame::OnCheckBoxLevel(wxCommandEvent &event)
{
	int level = event.GetId() - 100;
	if(event.IsChecked())
		g_stOutputAgent.SetLevel(g_stOutputAgent.GetLevel() | level);
	else
		g_stOutputAgent.SetLevel(g_stOutputAgent.GetLevel() & ~level);



	OUTPUT(OUTPUT::LEVEL_INFO, L"Level:" << g_stOutputAgent.GetLevel() << std::endl);
//   event.Skip();
//    wxLogDebug(wxT("Event handler (MyFrame::OnCheckBoxLevel) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
}


void MyFrame::OnButtonOutput(wxCommandEvent &event)
{
	std::wstring str = (m_textInfo->GetValue().wchar_str());//, m_textInfo->GetValue().size());	
	OUTPUT(OUTPUT::LEVEL_DEBUG, str << std::endl);
//    event.Skip();
//    wxLogDebug(wxT("Event handler (MyFrame::OnButtonOutput) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
}


// wxGlade: add MyFrame event handlers


void MyFrame::set_properties()
{
    // begin wxGlade: MyFrame::set_properties
    SetTitle(wxT("frame_1"));
    SetSize(wxSize(388, 358));
    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
    // end wxGlade
}


void MyFrame::do_layout()
{
    // begin wxGlade: MyFrame::do_layout
    wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer* sizer_2 = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer* sizer_3 = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer* sizer_5 = new wxBoxSizer(wxHORIZONTAL);
    wxBoxSizer* sizer_6 = new wxBoxSizer(wxHORIZONTAL);
    wxStaticBoxSizer* sizer_4 = new wxStaticBoxSizer(sizer_4_staticbox, wxHORIZONTAL);
    sizer_4->Add(m_cbDEBUG, 1, wxEXPAND, 0);
    sizer_4->Add(m_cbINFO, 1, wxEXPAND, 0);
    sizer_4->Add(m_cbWARN, 1, wxEXPAND, 0);
    sizer_4->Add(m_cbERROR, 1, wxEXPAND, 0);
    sizer_3->Add(sizer_4, 0, wxEXPAND, 0);
    sizer_6->Add(m_textInfo, 1, wxEXPAND, 0);
    sizer_6->Add(button_1, 0, 0, 0);
    sizer_5->Add(sizer_6, 1, wxEXPAND, 0);
    sizer_3->Add(sizer_5, 0, wxEXPAND, 0);
    sizer_2->Add(sizer_3, 0, wxEXPAND, 0);
    sizer_2->Add(m_textOutput, 1, wxEXPAND, 0);
    sizer_1->Add(sizer_2, 1, wxEXPAND, 0);
    SetSizer(sizer_1);
    Layout();
    // end wxGlade
}



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

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
//    wxInitAllImageHandlers();
    MyFrame* frame_1 = new MyFrame(NULL, wxID_ANY, wxEmptyString);
    SetTopWindow(frame_1);
    frame_1->Show();
    return true;
}


