#include "WxFontDialog1Frame.h"
#include "WindowIDs.h"
#include <wx/menu.h>
#include <wx/dcclient.h>
WxFontDialog1Frame::WxFontDialog1Frame(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title)
{
    // The Open dialog is usually accessible from
    // the "File" menu so we create one.
    wxMenuBar* menuBar = new wxMenuBar;
    wxMenu* menuFile = new wxMenu;
    menuFile->Append(SelectFontMenuID, "Select Font...");
    menuBar->Append(menuFile, "&Options");
    SetMenuBar(menuBar);
    SetBackgroundColour(*wxWHITE);
}
// Event handler for the paint event
void WxFontDialog1Frame::OnPaint(wxPaintEvent& evt)
{
    wxPaintDC dc(this);
    // Set the font and text color based on the user
    // selection and draw some text
    dc.SetFont(m_fontData.GetChosenFont());
    dc.SetTextForeground(m_fontData.GetColour());
    dc.DrawText("Hello World!", 20, 20);
}
// Event handler for the Select Font menu item. It will
// display a wxFontDialog.
void WxFontDialog1Frame::OnSelectFont(wxCommandEvent& evt)
{
    // Create a new wxFontDialog dialog
    wxFontDialog* fontDialog = new wxFontDialog(this);
    // Display the dialog, save the select font
    // and color and refresh the window to
    // repaint it with the new font
    if (fontDialog->ShowModal() == wxID_OK)
    {
        m_fontData = fontDialog->GetFontData();
        Refresh();
    }
    fontDialog->Destroy();
}
// Add the event handler for the Select Font menu item
// to the event table and for the paint event
wxBEGIN_EVENT_TABLE(WxFontDialog1Frame, wxFrame)
    EVT_PAINT(WxFontDialog1Frame::OnPaint)
    EVT_MENU(SelectFontMenuID, WxFontDialog1Frame::OnSelectFont)
wxEND_EVENT_TABLE()