summaryrefslogtreecommitdiffstats
path: root/Project/main.cpp
blob: 106ca828fbe963a1ad54944f3f67b2dedc662e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <wx/app.h>
#include <wx/event.h>
#include <wx/image.h>
#include <wx/stdpaths.h>

#include "MainFrame.h"

// Define the MainApp
class MainApp : public wxApp
{
   public:
    MainApp() {}
    virtual ~MainApp() {}
    void LoadCatalogs(wxLocale* locale)
    {
		locale->Init(
			locale->GetSystemLanguage(),
			wxLOCALE_DONT_LOAD_DEFAULT);  // captura as propriedades locais do computador (idioma, numeração, etc...)

		wxString langPath = wxStandardPaths::Get().GetExecutablePath();
		// remove o nome do executável
		for(int i = langPath.size(); i >= 0; i--) {
			if(langPath[i] == '/' || langPath[i] == '\\') {
				langPath.Truncate(i + 1);
				break;
				}
			}
		langPath += wxT("data\\lang");

		locale->AddCatalogLookupPathPrefix(langPath);
		// Carregar catálogos de tradução
		locale->AddCatalog(wxT("pt_BR"), wxLANGUAGE_PORTUGUESE_BRAZILIAN);
    }

    virtual bool OnInit()
    {
		// Add the common image handlers
		wxImage::AddHandler(new wxPNGHandler);
		wxImage::AddHandler(new wxJPEGHandler);

		wxLocale* locale = new wxLocale();
		LoadCatalogs(locale);

		MainFrame* mainFrame = new MainFrame(NULL, locale);
		SetTopWindow(mainFrame);
		return GetTopWindow()->Show();
    }
};

DECLARE_APP(MainApp)
IMPLEMENT_APP(MainApp)