cpp/main.cpp
author viric <viriketo@gmail.com>
Sun, 13 Feb 2011 08:11:31 +0100
changeset 3 01dafa022fa1
parent 2 5331bd08a294
permissions -rw-r--r--
Fre que llegeixi un fitxer de paraules
#include <wx/wx.h>
#include <wx/log.h>
#include <wx/image.h>
#include <wx/string.h>
#include <wx/init.h>
#include <fstream>
#include <iostream>

#include "main.hpp"
#include "MainWindow.hpp"

class MyApp : public wxApp
{
    public:
        virtual bool OnInit();
};

IMPLEMENT_APP(MyApp)

std::vector<std::string> words;

void
loadwords()
{
    std::ifstream f("words.txt");
    
    do
    {
        std::string s;
        std::getline(f,s);
        if (!f.fail())
        {
            words.push_back(s);
            std::cerr << "Loaded: " << s << std::endl;
        }
    }while(!f.fail());

}

bool MyApp::OnInit()
{
    if(!wxApp::OnInit())
        return false;

    loadwords();

    MainWindow *mw = new MainWindow();
    mw->Show();
    SetTopWindow(mw);

    return true;
}