とりあえず、wxWidgetsでウインドウを表示するだけのプログラムを作ってみた。
wxAppを継承したアプリケーションクラス(TestApp)とメインウインドウになるwxFrame(TestFrame)を継承したクラスを用意する。
TestAppクラスのOnInit()でTestFrameクラスのインスタンスを作って表示する。
と、とりあえずウィンドウが表示されるだけのプログラムができる(^^;)
TestApp.h
#ifndef __TESTAPP_H__
#define __TESTAPP_H__
class TestApp:public wxApp
{
public:
virtual bool OnInit();
};
#endif
TestApp.cpp
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "TestApp.h"
#include "TestFrame.h"
bool TestApp::OnInit()
{
TestFrame *frame = new TestFrame();
frame->Show(true);
return true;
}
wxIMPLEMENT_APP(TestApp);
TestFrame.h
#ifndef __TESTFRAME_H__
#define __TESTFRAME_H__
class TestFrame:public wxFrame
{
public:
TestFrame();
};
#endif
TestFrame.cpp
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "TestFrame.h"
TestFrame::TestFrame():wxFrame(NULL, wxID_ANY, "win")
{
}
Makefile
OBJS=TestApp.o TestFrame.o
TARGET=win
CXX=$(shell wx-config --cxx)
CXXFLAGS+=$(shell wx-config --cxxflags)
CPPFLAGS=$(CXXFLAGS)
LDCONFIG=$(shell wx-config --libs)
all:$(TARGET)
$(TARGET):$(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LDCONFIG)
clean:
rm -f $(OBJS) $(TARGET)
コメント