--- nono/util/viewcgrom/viewcgrom.cpp 2026/04/29 17:04:28 1.1 +++ nono/util/viewcgrom/viewcgrom.cpp 2026/04/29 17:05:31 1.1.1.5 @@ -4,15 +4,15 @@ // Copyright (C) 2012-2019 isaki@NetBSD.org // -#include +#include "wxheader.h" #include #include #include #include #include -#define TITLE "X680x0 CGROMビューア" -#define COPYRIGHT "Copyright (C) 2012-2019 isaki@NetBSD.org" +#define TITLE wxT("X680x0 CGROMビューア") +#define COPYRIGHT wxT("Copyright (C) 2012-2019 isaki@NetBSD.org") /* CGROM.DAT の大きさ(バイト単位) */ #define CGROM_SIZE (768 * 1024) @@ -29,16 +29,12 @@ #define ROUND(x, y) (((x) + (y - 1)) / (y)) #define ROUND8(x) ROUND(x, 8) -/* 独自のイベントタイプ */ -DECLARE_EVENT_TYPE(WXEVT_CREATE, -1); -DEFINE_EVENT_TYPE(WXEVT_CREATE); - class MyFrame; struct ctxmenu_t { int id; int addr; - const char *label; + wxString label; int size; }; @@ -53,7 +49,7 @@ class ViewCtrl : public wxWindow unsigned char *imagebuf; private: void OnPaint(wxPaintEvent& event); - DECLARE_EVENT_TABLE(); + wxDECLARE_EVENT_TABLE(); }; class MyFrame : public wxFrame @@ -63,7 +59,7 @@ class MyFrame : public wxFrame MyFrame(); private: - void OnCreate(wxCommandEvent& event); + void OnWindowCreate(wxWindowCreateEvent& event); void OnOpen(wxCommandEvent& event); void DoOpenDialog(); void DoOpen(); @@ -105,7 +101,7 @@ class MyFrame : public wxFrame static ctxmenu_t ctxmenu[]; - DECLARE_EVENT_TABLE(); + wxDECLARE_EVENT_TABLE(); }; class MyApp : public wxApp @@ -175,7 +171,7 @@ bool MyApp::OnInit() } // イベントテーブル -BEGIN_EVENT_TABLE(MyFrame, inherited) +wxBEGIN_EVENT_TABLE(MyFrame, inherited) EVT_CONTEXT_MENU(MyFrame::OnContextMenu) EVT_MENU(ID_RELOAD, MyFrame::OnReload) EVT_UPDATE_UI(ID_RELOAD, MyFrame::OnReloadUI) @@ -193,18 +189,18 @@ BEGIN_EVENT_TABLE(MyFrame, inherited) EVT_MENU(wxID_OPEN, MyFrame::OnOpen) EVT_MENU(wxID_EXIT, MyFrame::OnExit) EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) - EVT_COMMAND(wxID_ANY, WXEVT_CREATE, MyFrame::OnCreate) -END_EVENT_TABLE() + EVT_WINDOW_CREATE(MyFrame::OnWindowCreate) +wxEND_EVENT_TABLE() // ショートカット用データ struct ctxmenu_t MyFrame::ctxmenu[] = { - { ID_FONT_16x16, 0x00000, "16x16フォント", SIZE_16x16, }, - { ID_FONT_8x8, 0x3a000, "8x8フォント", SIZE_8x8, }, - { ID_FONT_8x16, 0x3a800, "8x16フォント", SIZE_8x16, }, - { ID_FONT_12x12, 0x3b800, "12x12フォント", SIZE_12x12, }, - { ID_FONT_12x24, 0x3d000, "12x24フォント", SIZE_12x24, }, - { ID_FONT_24x24, 0x40000, "24x24フォント", SIZE_24x24, }, - { ID_FONT_6x12, 0xbf400, "6x12フォント", SIZE_6x12, }, + { ID_FONT_16x16, 0x00000, wxT("16x16フォント"), SIZE_16x16, }, + { ID_FONT_8x8, 0x3a000, wxT("8x8フォント"), SIZE_8x8, }, + { ID_FONT_8x16, 0x3a800, wxT("8x16フォント"), SIZE_8x16, }, + { ID_FONT_12x12, 0x3b800, wxT("12x12フォント"), SIZE_12x12, }, + { ID_FONT_12x24, 0x3d000, wxT("12x24フォント"), SIZE_12x24, }, + { ID_FONT_24x24, 0x40000, wxT("24x24フォント"), SIZE_24x24, }, + { ID_FONT_6x12, 0xbf400, wxT("6x12フォント"), SIZE_6x12, }, }; // コンストラクタ @@ -255,24 +251,24 @@ MyFrame::MyFrame() ctrlbox->Add(new wxStaticText(panel, wxID_ANY, wxT("開始アドレス"))); /* 開始アドレス(コントロール) */ - addrctrl = new wxTextCtrl(panel, ID_ADDRBOX, "", + addrctrl = new wxTextCtrl(panel, ID_ADDRBOX, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); ctrlbox->Add(addrctrl); ctrlbox->AddSpacer(5); /* フォントサイズ */ - ctrlbox->Add(new wxStaticText(panel, wxID_ANY, "フォントサイズ")); + ctrlbox->Add(new wxStaticText(panel, wxID_ANY, wxT("フォントサイズ"))); /* フォントサイズ(コントロール) */ wxString sizelist[] = { - "8x8", - "8x16", - "12x12", - "12x24", - "16x16", - "24x24", - "6x12", + wxT("8x8"), + wxT("8x16"), + wxT("12x12"), + wxT("12x24"), + wxT("16x16"), + wxT("24x24"), + wxT("6x12"), }; sizectrl = new wxChoice(panel, ID_SIZEBOX, wxDefaultPosition, wxDefaultSize, @@ -288,7 +284,7 @@ MyFrame::MyFrame() ctxmenu_t *c = &ctxmenu[i]; wxString label; - label.Printf("%05X: ", c->addr); + label.Printf(wxT("%05X: "), c->addr); label += c->label; wxButton *btn = new wxButton(panel, c->id, label, wxDefaultPosition, wxDefaultSize, wxBU_LEFT); @@ -297,14 +293,14 @@ MyFrame::MyFrame() ctrlbox->AddSpacer(5); ctrlbox->Add(new wxStaticText(panel, wxID_ANY, - "(6x12 フォントは\nX68030 のみ)")); + wxT("(6x12 フォントは\nX68030 のみ)"))); panel->SetSizer(hbox); hbox->SetSizeHints(this); /* コンテキストメニュー */ menu = new wxMenu(); - menu->Append(ID_RELOAD, "リロード"); + menu->Append(ID_RELOAD, wxT("リロード")); /* 固定地 */ num.x = 16; @@ -317,14 +313,13 @@ MyFrame::MyFrame() line = -1; DoUpdateAddr(); - /* すぐに OnCreate を呼ぶように仕掛けておく */ - wxCommandEvent event(WXEVT_CREATE); - AddPendingEvent(event); + Connect(wxEVT_CREATE, + wxWindowCreateEventHandler(MyFrame::OnWindowCreate), NULL, this); } -// ウィンドウ作成イベントのつもり +// ウィンドウ作成イベント void -MyFrame::OnCreate(wxCommandEvent& event) +MyFrame::OnWindowCreate(wxWindowCreateEvent& event) { if (!::wxGetApp().filename.IsEmpty()) { /* 引数でファイルが指定されていればそれを使う */ @@ -333,6 +328,10 @@ MyFrame::OnCreate(wxCommandEvent& event) /* ファイルオープン */ DoOpen(); } + + // 一度処理したら抜いておく (こうしないと複数回呼ばれる) + Disconnect(wxEVT_CREATE, + wxWindowCreateEventHandler(MyFrame::OnWindowCreate)); } // オープン @@ -347,9 +346,9 @@ MyFrame::OnOpen(wxCommandEvent& event) void MyFrame::DoOpenDialog() { - wxFileDialog dialog(this, "Select a file", + wxFileDialog dialog(this, wxT("Select a file"), ::wxGetCwd(), wxEmptyString, - "DAT files (*.DAT)|*.DAT;*.dat|すべてのファイル (*.*)|*.*"); + wxT("DAT files (*.DAT)|*.DAT;*.dat|すべてのファイル (*.*)|*.*")); if (dialog.ShowModal() != wxID_OK) { return; @@ -381,7 +380,7 @@ MyFrame::DoOpen() /* オープンできたのでタイトルを変更 */ wxString title; title = TITLE; - title += " - "; + title += wxT(" - "); title += filename; SetTitle(title); @@ -401,8 +400,8 @@ MyFrame::OnAbout(wxCommandEvent& event) { wxAboutDialogInfo ab; - ab.SetName("viewcgrom"); - ab.SetVersion("1.1"); + ab.SetName(wxT("viewcgrom")); + ab.SetVersion(wxT("1.1")); ab.SetDescription(TITLE); ab.SetCopyright(COPYRIGHT); @@ -606,7 +605,7 @@ MyFrame::DoUpdateAddr() /* アドレス欄に反映 */ wxString str; - str.Printf("%05X", addr); + str.Printf(wxT("%05X"), addr); addrctrl->SetValue(str); /* スクロールバーに反映 */ @@ -702,9 +701,9 @@ MyFrame::CreateImage() } // イベントテーブル -BEGIN_EVENT_TABLE(ViewCtrl, inherited) +wxBEGIN_EVENT_TABLE(ViewCtrl, inherited) EVT_PAINT(ViewCtrl::OnPaint) -END_EVENT_TABLE() +wxEND_EVENT_TABLE() // コンストラクタ ViewCtrl::ViewCtrl(wxWindow *parent)