差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
wxwidgets:helloworld [2025/05/23 09:29] – freemikan | wxwidgets:helloworld [2025/05/24 16:35] (現在) – [結果の確認] Mark out generated file freemikan | ||
---|---|---|---|
行 1: | 行 1: | ||
====== Hello World ====== | ====== Hello World ====== | ||
+ | {{: | ||
- | {{: | ||
- | 作業ディレクトリ | + | ===== 前提 ===== |
+ | [[install|インストールのページ]]に従い、wxWidget 3.2がインストール済みであることを前提とします。 | ||
- | $HOME/ | + | |
+ | ===== 作業ディレクトリの用意 ===== | ||
+ | 作業ディレクトリは | ||
+ | |||
+ | < | ||
+ | こういった名前やパスは、何かしら決めておかないと説明がしづらいので提示しているだけです。 | ||
+ | 同じ名前にする必要は全くありません。 | ||
+ | ご自身の好みの場所に好きな名前で作成してください。 | ||
+ | </ | ||
+ | |||
+ | まずディレクトリを作成して、そこに移動しておきます。 | ||
+ | |||
+ | < | ||
+ | $ mkdir -p ~/ | ||
+ | $ cd $_ | ||
+ | </ | ||
+ | |||
+ | ===== プログラムのソースコード ===== | ||
+ | 今回作成するプログラムのソースコードは、公式のドキュメントにあるHello Worldのサンプルをそのまま拝借します。 | ||
+ | |||
+ | * https:// | ||
+ | |||
+ | ソースコードは1つのファイルのみで、名前はmain.cppとします。 | ||
__main.cpp__ | __main.cpp__ | ||
<code cpp> | <code cpp> | ||
- | // | + | /**************************************************************/ |
- | // https:// | + | /* https:// |
- | // | + | /**************************************************************/ |
// Start of wxWidgets "Hello World" Program | // Start of wxWidgets "Hello World" Program | ||
#include < | #include < | ||
- | + | ||
- | class MyApp : public wxApp | + | class MyApp : public wxApp { |
- | { | + | |
public: | public: | ||
- | | + | |
}; | }; | ||
- | + | ||
wxIMPLEMENT_APP(MyApp); | wxIMPLEMENT_APP(MyApp); | ||
- | + | ||
- | class MyFrame : public wxFrame | + | class MyFrame : public wxFrame { |
- | { | + | |
public: | public: | ||
- | | + | |
- | + | ||
private: | private: | ||
- | | + | |
- | void OnExit(wxCommandEvent& | + | void OnExit(wxCommandEvent & |
- | void OnAbout(wxCommandEvent& | + | void OnAbout(wxCommandEvent & |
}; | }; | ||
- | + | ||
- | enum | + | enum { ID_Hello = 1 }; |
- | { | + | |
- | | + | bool MyApp:: |
- | }; | + | MyFrame *frame = new MyFrame(); |
- | + | frame-> | |
- | bool MyApp:: | + | return true; |
- | { | + | |
- | MyFrame *frame = new MyFrame(); | + | |
- | frame-> | + | |
- | return true; | + | |
} | } | ||
- | + | ||
- | MyFrame:: | + | MyFrame:: |
- | | + | wxMenu *menuFile = new wxMenu; |
- | { | + | menuFile-> |
- | wxMenu *menuFile = new wxMenu; | + | |
- | menuFile-> | + | menuFile-> |
- | | + | menuFile-> |
- | menuFile-> | + | |
- | menuFile-> | + | wxMenu *menuHelp = new wxMenu; |
- | + | menuHelp-> | |
- | wxMenu *menuHelp = new wxMenu; | + | |
- | menuHelp-> | + | wxMenuBar *menuBar = new wxMenuBar; |
- | + | menuBar-> | |
- | wxMenuBar *menuBar = new wxMenuBar; | + | menuBar-> |
- | menuBar-> | + | |
- | menuBar-> | + | SetMenuBar(menuBar); |
- | + | ||
- | SetMenuBar( menuBar ); | + | CreateStatusBar(); |
- | + | SetStatusText(" | |
- | CreateStatusBar(); | + | |
- | SetStatusText(" | + | Bind(wxEVT_MENU, |
- | + | Bind(wxEVT_MENU, | |
- | Bind(wxEVT_MENU, | + | Bind(wxEVT_MENU, |
- | Bind(wxEVT_MENU, | + | |
- | Bind(wxEVT_MENU, | + | |
} | } | ||
- | + | ||
- | void MyFrame:: | + | void MyFrame:: |
- | { | + | |
- | | + | void MyFrame:: |
+ | wxMessageBox(" | ||
+ | wxOK | wxICON_INFORMATION); | ||
} | } | ||
- | + | ||
- | void MyFrame:: | + | void MyFrame:: |
- | { | + | wxLogMessage(" |
- | wxMessageBox(" | + | |
- | " | + | |
- | } | + | |
- | + | ||
- | void MyFrame:: | + | |
- | { | + | |
- | wxLogMessage(" | + | |
} | } | ||
</ | </ | ||
- | コンパイル | + | |
+ | ===== コンパイル | ||
<cli> | <cli> | ||
行 97: | 行 108: | ||
</ | </ | ||
- | コンパイル結果の確認 | + | ==== 結果の確認 |
<cli> | <cli> | ||
行 103: | 行 114: | ||
合計 200 | 合計 200 | ||
-rw-rw-r-- 1 freemikan freemikan | -rw-rw-r-- 1 freemikan freemikan | ||
- | -rw-rw-r-- 1 freemikan freemikan 197544 | + | -rw-rw-r-- 1 freemikan freemikan 197544 |
</ | </ | ||
- | リンク | + | |
+ | ===== リンク | ||
<cli> | <cli> | ||
行 112: | 行 124: | ||
</ | </ | ||
- | リンク結果の確認 | + | |
+ | ==== 結果の確認 | ||
<cli> | <cli> | ||
$ ls -l | $ ls -l | ||
合計 348 | 合計 348 | ||
- | -rwxrwxr-x 1 freemikan freemikan 151144 | + | -rwxrwxr-x 1 freemikan freemikan 151144 |
-rw-rw-r-- 1 freemikan freemikan | -rw-rw-r-- 1 freemikan freemikan | ||
-rw-rw-r-- 1 freemikan freemikan 197544 | -rw-rw-r-- 1 freemikan freemikan 197544 | ||
</ | </ | ||
- | 実行 | + | |
+ | ===== 実行 | ||
<cli> | <cli> |