wxWidgets UNICODE 版の test
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
[[Hirofumi Fujii Start Page]]
* wxWidgets UNICODE 版の test [#ua142a4e]
&ref(http://www.wxwidgets.org/,wxWidgets);
は multi-platform な graphical user interface の
library である。wxWidgets は UNICODE 版を生成することがで...
(configure で --enable-unicode指定)。
UNICODE なので、基本的に
source 中に任意の UNICODE 文字を直接埋め込むことが可能で...
そこで、日本語を表示する
program を同一 source で Windows 2000 (wxMSW)と Linux(wxG...
とで生成できるかどうか試してみた。
結論から言えば、ほぼ動いた。「ほぼ」というのは、細かく見...
問題が無いわけではないということで、その点については後で...
** Test環境 [#v65a8dbe]
いずれも wxWidgets は 2.8.10 である。
- Windows 2000 は [[MinGW/MSYS での wxWidgets について]] ...
- Linux 1 は Red Hat 3.2.2-5 gcc/g++ 3.2.2 20030222
- Linux 2 は Red Hat 4.0.2-8 gcc/g++ 4.0.2 20051125
である。Linux 1 の方は、
../configure --enable-unicode --with-gtk=1 --enable-std_...
で configure; make; make install した。gtk は 2 が入って...
なぜか configure で package 云々の error が出るので、1 に...
また、最初 --disable-shared をつけなかったら、日本語 prog...
font library の so が無いとか何とか文句を言うので、--disa...
Linux 2 の方は
../configure --enable-unicode --enable-std_string --enab...
で install した。
** Test program [#r0673ae0]
Test program は以下に示すように
&ref(http://www.wxwidgets.org/,wxWidgets の home page); ...
&ref(http://www.wxwidgets.org/docs/tutorials/hello.htm,He...
若干書き換えたもので、wchar_t の配列を使って、UNICODE 文...
各文字 code の値を埋め込んでいる
([[MinGW/MSYS での wxWidgets について]]も参照)。
重要な点は、target system が
どんな文字 code を使っていようと(Shift-JIS だろうが、EUC...
この一つの source で同一の文字表示が行われる(はず)とい...
Build 方法は Linux でも Windows (MSYS/MinGW) でも全く同じ...
g++ jworld.cpp `wx-config --cxxflags` `wx-conig --libs` ...
である。
// jworld.cpp
#include <wx/wx.h>
#include <string>
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos,
const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
class MyText
{
public:
static const wchar_t m_frame_title[];
static const wchar_t m_menu_file[];
static const wchar_t m_menu_about[];
static const wchar_t m_menu_exit[];
static const wchar_t m_status[];
static const wchar_t m_about_title[];
static const wchar_t m_about[];
};
enum
{
ID_Quit = 1,
ID_About,
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Quit, MyFrame::OnQuit)
EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
const wchar_t MyText::m_frame_title[] =
{0x4e16,0x754c,0x3088,0x4eca,0x65e5,0x306f,0x0000};
const wchar_t MyText::m_menu_file[] =
{0x30d5,0x30a1,0x30a4,0x30eb,0x0000};
const wchar_t MyText::m_menu_about[] = {0x6982,0x8981,0x...
const wchar_t MyText::m_menu_exit[] = {0x7d42,0x4e86,0x0...
const wchar_t MyText::m_status[] =
{0x0077,0x0078,0x0057,0x0069,0x0064,0x0067,0x0065,0x007...
0x0020,
0x306b,0x3088,0x3046,0x3053,0x305d,0x0021,0x0000};
const wchar_t MyText::m_about_title[] =
{0x0077,0x0078,0x0057,0x0069,0x0064,0x0067,0x0065,0x007...
0x0020,
0x306b,0x3064,0x3044,0x3066,0x0000};
const wchar_t MyText::m_about[] =
{0x3053,0x308c,0x306f,0x0020,
0x0077,0x0078,0x0057,0x0069,0x0064,0x0067,0x0065,0x007...
0x0020,
0x306b,0x3088,0x308b,0x300c,
0x4e16,0x754c,0x3088,0x4eca,0x65e5,0x306f,
0x300d,0x306e,0x4f8b,0x3067,0x3059,0x3002,0x0000};
bool
MyApp::OnInit()
{
MyFrame* frame = new MyFrame(
MyText::m_frame_title, wxPoint(50,50),
wxSize(450,340));
frame->Show(TRUE);
SetTopWindow(frame);
return true;
}
MyFrame::MyFrame(const wxString& title,
const wxPoint& pos, const wxSize& size) :
wxFrame((wxFrame*)0, -1, title, pos, size)
{
wxMenu* menuFile = new wxMenu;
menuFile->Append(ID_About, MyText::m_menu_about);
menuFile->AppendSeparator();
menuFile->Append(ID_Quit, MyText::m_menu_exit);
wxMenuBar* menuBar = new wxMenuBar;
menuBar->Append(menuFile, MyText::m_menu_file);
SetMenuBar(menuBar);
CreateStatusBar();
SetStatusText(MyText::m_status);
}
void
MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
}
void
MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(MyText::m_about, MyText::m_about_title,
wxOK | wxICON_INFORMATION, this);
}
** 結果の画像 [#i72aea92]
結果の画像を示す。いずれも Windows XP(SP3) で表示したもの...
MSYS/MinGW 版は Windows 2000(SP4) で build して XP に cop...
実行したもの、Linux 1 (GTK1) と Linux 2 (GTK2) は、Xserve...
Xming を使って表示させたものである。
画像は、上から順に、起動直後、メニュー選択中、概要のダイ...
|CENTER:Windows MSYS/MinGW |CENTER:Linux GTK1 |CENTER:Lin...
|#ref("jworld01.png")|#ref("gtk1jworld01.png") |#ref("gtk...
|#ref("jworld02.png")|#ref("gtk1jworld02.png") |#ref("gtk...
|#ref("jworld03.png")|#ref("gtk1jworld03.png") |#ref("gtk...
同一 source 同一 build command で、ここまでできるのは、確...
が、、よく見ると、Linux 版では GTK1 でも GTK2 でも frame ...
title が出ていない。同様に dialog window (最下段)の tit...
日本語の部分が出ていない(多分日本語が表示できていないの...
また、MSYS/MinGW 版では、メニュー選択直後に
status window が消えて、復活しない。
終了行:
[[Hirofumi Fujii Start Page]]
* wxWidgets UNICODE 版の test [#ua142a4e]
&ref(http://www.wxwidgets.org/,wxWidgets);
は multi-platform な graphical user interface の
library である。wxWidgets は UNICODE 版を生成することがで...
(configure で --enable-unicode指定)。
UNICODE なので、基本的に
source 中に任意の UNICODE 文字を直接埋め込むことが可能で...
そこで、日本語を表示する
program を同一 source で Windows 2000 (wxMSW)と Linux(wxG...
とで生成できるかどうか試してみた。
結論から言えば、ほぼ動いた。「ほぼ」というのは、細かく見...
問題が無いわけではないということで、その点については後で...
** Test環境 [#v65a8dbe]
いずれも wxWidgets は 2.8.10 である。
- Windows 2000 は [[MinGW/MSYS での wxWidgets について]] ...
- Linux 1 は Red Hat 3.2.2-5 gcc/g++ 3.2.2 20030222
- Linux 2 は Red Hat 4.0.2-8 gcc/g++ 4.0.2 20051125
である。Linux 1 の方は、
../configure --enable-unicode --with-gtk=1 --enable-std_...
で configure; make; make install した。gtk は 2 が入って...
なぜか configure で package 云々の error が出るので、1 に...
また、最初 --disable-shared をつけなかったら、日本語 prog...
font library の so が無いとか何とか文句を言うので、--disa...
Linux 2 の方は
../configure --enable-unicode --enable-std_string --enab...
で install した。
** Test program [#r0673ae0]
Test program は以下に示すように
&ref(http://www.wxwidgets.org/,wxWidgets の home page); ...
&ref(http://www.wxwidgets.org/docs/tutorials/hello.htm,He...
若干書き換えたもので、wchar_t の配列を使って、UNICODE 文...
各文字 code の値を埋め込んでいる
([[MinGW/MSYS での wxWidgets について]]も参照)。
重要な点は、target system が
どんな文字 code を使っていようと(Shift-JIS だろうが、EUC...
この一つの source で同一の文字表示が行われる(はず)とい...
Build 方法は Linux でも Windows (MSYS/MinGW) でも全く同じ...
g++ jworld.cpp `wx-config --cxxflags` `wx-conig --libs` ...
である。
// jworld.cpp
#include <wx/wx.h>
#include <string>
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos,
const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
class MyText
{
public:
static const wchar_t m_frame_title[];
static const wchar_t m_menu_file[];
static const wchar_t m_menu_about[];
static const wchar_t m_menu_exit[];
static const wchar_t m_status[];
static const wchar_t m_about_title[];
static const wchar_t m_about[];
};
enum
{
ID_Quit = 1,
ID_About,
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Quit, MyFrame::OnQuit)
EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
const wchar_t MyText::m_frame_title[] =
{0x4e16,0x754c,0x3088,0x4eca,0x65e5,0x306f,0x0000};
const wchar_t MyText::m_menu_file[] =
{0x30d5,0x30a1,0x30a4,0x30eb,0x0000};
const wchar_t MyText::m_menu_about[] = {0x6982,0x8981,0x...
const wchar_t MyText::m_menu_exit[] = {0x7d42,0x4e86,0x0...
const wchar_t MyText::m_status[] =
{0x0077,0x0078,0x0057,0x0069,0x0064,0x0067,0x0065,0x007...
0x0020,
0x306b,0x3088,0x3046,0x3053,0x305d,0x0021,0x0000};
const wchar_t MyText::m_about_title[] =
{0x0077,0x0078,0x0057,0x0069,0x0064,0x0067,0x0065,0x007...
0x0020,
0x306b,0x3064,0x3044,0x3066,0x0000};
const wchar_t MyText::m_about[] =
{0x3053,0x308c,0x306f,0x0020,
0x0077,0x0078,0x0057,0x0069,0x0064,0x0067,0x0065,0x007...
0x0020,
0x306b,0x3088,0x308b,0x300c,
0x4e16,0x754c,0x3088,0x4eca,0x65e5,0x306f,
0x300d,0x306e,0x4f8b,0x3067,0x3059,0x3002,0x0000};
bool
MyApp::OnInit()
{
MyFrame* frame = new MyFrame(
MyText::m_frame_title, wxPoint(50,50),
wxSize(450,340));
frame->Show(TRUE);
SetTopWindow(frame);
return true;
}
MyFrame::MyFrame(const wxString& title,
const wxPoint& pos, const wxSize& size) :
wxFrame((wxFrame*)0, -1, title, pos, size)
{
wxMenu* menuFile = new wxMenu;
menuFile->Append(ID_About, MyText::m_menu_about);
menuFile->AppendSeparator();
menuFile->Append(ID_Quit, MyText::m_menu_exit);
wxMenuBar* menuBar = new wxMenuBar;
menuBar->Append(menuFile, MyText::m_menu_file);
SetMenuBar(menuBar);
CreateStatusBar();
SetStatusText(MyText::m_status);
}
void
MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
}
void
MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(MyText::m_about, MyText::m_about_title,
wxOK | wxICON_INFORMATION, this);
}
** 結果の画像 [#i72aea92]
結果の画像を示す。いずれも Windows XP(SP3) で表示したもの...
MSYS/MinGW 版は Windows 2000(SP4) で build して XP に cop...
実行したもの、Linux 1 (GTK1) と Linux 2 (GTK2) は、Xserve...
Xming を使って表示させたものである。
画像は、上から順に、起動直後、メニュー選択中、概要のダイ...
|CENTER:Windows MSYS/MinGW |CENTER:Linux GTK1 |CENTER:Lin...
|#ref("jworld01.png")|#ref("gtk1jworld01.png") |#ref("gtk...
|#ref("jworld02.png")|#ref("gtk1jworld02.png") |#ref("gtk...
|#ref("jworld03.png")|#ref("gtk1jworld03.png") |#ref("gtk...
同一 source 同一 build command で、ここまでできるのは、確...
が、、よく見ると、Linux 版では GTK1 でも GTK2 でも frame ...
title が出ていない。同様に dialog window (最下段)の tit...
日本語の部分が出ていない(多分日本語が表示できていないの...
また、MSYS/MinGW 版では、メニュー選択直後に
status window が消えて、復活しない。
ページ名: