diff options
-rw-r--r-- | src/main.rs | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 732805c..b2207a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::env::{current_dir, set_current_dir}; -use std::fs::{create_dir_all, metadata, read_to_string}; +use std::fs::{create_dir_all, metadata, read_to_string, write}; use std::path::Path; use std::process::Command; @@ -64,6 +64,80 @@ fn main() { assert!(cargo_new.success()); } + // we're putting the hello world example out here because yolo + create_dir_all("new/examples").unwrap(); + write( + "new/examples/hello_world.rs", + r#" +// wxWidgets "Hello World" Program + +struct MyApp; +impl wx::App for MyApp { + fn on_init() { + let frame = MyFrame::new(); + frame.show(true); + } +} + +struct MyFrame { + base: wx::FrameBase, +} +impl wx::Frame for MyFrame { + fn new() -> Self { + let base = wx::FrameBase::new(None, wx::Id::Any, "Hello World"); + + let file_menu = wx::Menu::new(); + +} + +wx::main!(MyApp); + +class MyFrame : public wxFrame +{ +public: + MyFrame(); +private: + void OnHello(wxCommandEvent& event); + void OnExit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); +}; +MyFrame::MyFrame() + : wxFrame(NULL, wxID_ANY, "Hello World") +{ + wxMenu *menuFile = new wxMenu; + menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", + "Help string shown in status bar for this menu item"); + menuFile->AppendSeparator(); + menuFile->Append(wxID_EXIT); + wxMenu *menuHelp = new wxMenu; + menuHelp->Append(wxID_ABOUT); + wxMenuBar *menuBar = new wxMenuBar; + menuBar->Append(menuFile, "&File"); + menuBar->Append(menuHelp, "&Help"); + SetMenuBar( menuBar ); + CreateStatusBar(); + SetStatusText("Welcome to wxWidgets!"); + Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello); + Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT); + Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT); +} +void MyFrame::OnExit(wxCommandEvent& event) +{ + Close(true); +} +void MyFrame::OnAbout(wxCommandEvent& event) +{ + wxMessageBox("This is a wxWidgets Hello World example", + "About Hello World", wxOK | wxICON_INFORMATION); +} +void MyFrame::OnHello(wxCommandEvent& event) +{ + wxLogMessage("Hello world from wxWidgets!"); +} +"#, + ) + .unwrap(); + let wx_h_text = read_to_string("orig/include/wx/wx.h").unwrap(); let lib_root_h = parse::parse(&wx_h_text); dbg!(lib_root_h); |