Text and Fonts

Introduction

 File: StandardControls/WxStaticText1/src/WxStaticText1Frame.cpp
#ifndef _TUTORIALS_WXWIDGETS_DRAWINGTEXT1APP_H_
#define _TUTORIALS_WXWIDGETS_DRAWINGTEXT1APP_H_

#include <wx/app.h>

class DrawingText1App : public wxApp
{
public:
    virtual bool OnInit();
};

#endif
 File: StandardControls/WxStaticText1/src/WxStaticText1Frame.cpp
#include "DrawingText1App.h"
#include "DrawingText1Frame.h"

wxIMPLEMENT_APP(DrawingText1App);

bool DrawingText1App::OnInit()
{
    DrawingText1Frame* frame = new DrawingText1Frame("DrawingText1");
    frame->Show(true);
    return true;
}
 File: StandardControls/WxStaticText1/src/WxStaticText1Frame.cpp
#ifndef _TUTORIALS_WXWIDGETS_DRAWINGTEXT1FRAME_H_
#define _TUTORIALS_WXWIDGETS_DRAWINGTEXT1FRAME_H_

#include <wx/frame.h>

class DrawingText1Frame : public wxFrame
{
public:
    DrawingText1Frame(const wxString& title);

private:
    void OnPaint(wxPaintEvent& evt);

    wxDECLARE_EVENT_TABLE();
};

#endif
 File: StandardControls/WxStaticText1/src/WxStaticText1Frame.cpp
#include "DrawingText1Frame.h"
#include <wx/dcclient.h>

DrawingText1Frame::DrawingText1Frame(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title)
{
    SetBackgroundColour(*wxWHITE);
}

void< DrawingText1Frame::OnPaint(wxPaintEvent& evt)
{
    wxPaintDC dc(this);

    dc.SetTextForeground(*wxBLACK);
    dc.DrawText("Hello World!", 10, 10);
}

wxBEGIN_EVENT_TABLE(DrawingText1Frame, wxFrame)
    EVT_PAINT(DrawingText1Frame::OnPaint)
wxEND_EVENT_TABLE()