cpp/main.cpp
changeset 3 01dafa022fa1
parent 2 5331bd08a294
equal deleted inserted replaced
2:5331bd08a294 3:01dafa022fa1
     1 #include <wx/wx.h>
     1 #include <wx/wx.h>
     2 #include <wx/log.h>
     2 #include <wx/log.h>
     3 #include <wx/image.h>
     3 #include <wx/image.h>
     4 #include <wx/string.h>
     4 #include <wx/string.h>
     5 #include <wx/init.h>
     5 #include <wx/init.h>
       
     6 #include <fstream>
       
     7 #include <iostream>
     6 
     8 
       
     9 #include "main.hpp"
     7 #include "MainWindow.hpp"
    10 #include "MainWindow.hpp"
     8 
    11 
     9 class MyApp : public wxApp
    12 class MyApp : public wxApp
    10 {
    13 {
    11     public:
    14     public:
    12         virtual bool OnInit();
    15         virtual bool OnInit();
    13 };
    16 };
    14 
    17 
    15 IMPLEMENT_APP(MyApp)
    18 IMPLEMENT_APP(MyApp)
    16 
    19 
       
    20 std::vector<std::string> words;
       
    21 
       
    22 void
       
    23 loadwords()
       
    24 {
       
    25     std::ifstream f("words.txt");
       
    26     
       
    27     do
       
    28     {
       
    29         std::string s;
       
    30         std::getline(f,s);
       
    31         if (!f.fail())
       
    32         {
       
    33             words.push_back(s);
       
    34             std::cerr << "Loaded: " << s << std::endl;
       
    35         }
       
    36     }while(!f.fail());
       
    37 
       
    38 }
       
    39 
    17 bool MyApp::OnInit()
    40 bool MyApp::OnInit()
    18 {
    41 {
    19     if(!wxApp::OnInit())
    42     if(!wxApp::OnInit())
    20         return false;
    43         return false;
       
    44 
       
    45     loadwords();
    21 
    46 
    22     MainWindow *mw = new MainWindow();
    47     MainWindow *mw = new MainWindow();
    23     mw->Show();
    48     mw->Show();
    24     SetTopWindow(mw);
    49     SetTopWindow(mw);
    25 
    50