Beispiel #1
0
	bool OnInit(void)
	{
		wxArrayString lcids;
		lcids.Add(wxT("en_US"));
		lcids.Add(wxT("sk_SK"));
		wxString lcid(
			wxGetSingleChoice(
				wxT("Pick a locale"),
				wxT("Locale"),
				lcids
			)
		);
		const wxLanguageInfo* lci = wxLocale::FindLanguageInfo(lcid);
		if((lci != nullptr) && appLocale.Init(lci->Language, 0))
		{
			wxStandardPaths stdPaths;
			wxFileName localePath(stdPaths.GetExecutablePath());
			localePath.SetName(wxEmptyString);
			localePath.AppendDir(wxT("locale"));
			appLocale.AddCatalogLookupPathPrefix(
				localePath.GetFullPath()
			);
			appLocale.AddCatalog(wxT("test"));
		}
		SetTopWindow(new TestFrame);
		return true;
	}
jewel::Decimal
wx_to_decimal
(   wxString wxs,
    wxLocale const& loc,
    DecimalParsingFlags p_flags
)
{
    bool const allow_parens =
        p_flags.test(string_flags::allow_negative_parens);
    wxs = wxs.Trim().Trim(false);  // trim both right and left.
    typedef wxChar CharT;
    static CharT const open_paren = wxChar('(');
    static CharT const close_paren = wxChar(')');
    static CharT const minus_sign = wxChar('-');
    wxString const decimal_point_s = loc.GetInfo
    (   wxLOCALE_DECIMAL_POINT,
        wxLOCALE_CAT_MONEY
    );
    wxString const thousands_sep_s = loc.GetInfo
    (   wxLOCALE_THOUSANDS_SEP,
        wxLOCALE_CAT_MONEY
    );
    if (wxs.IsEmpty())
    {
        return Decimal(0, 0);
    }
    JEWEL_ASSERT (wxs.Len() >= 1);
    if ((wxs.Len() == 1) && (*(wxs.begin()) == minus_sign))
    {
        return Decimal(0, 0);
    }

    // We first convert wxs into a canonical form in which there are no
    // thousands separators, negativity is indicated only by a minus
    // sign, and the decimal point is '.'.
    if (allow_parens && (wxs[0] == open_paren) && (wxs.Last() == close_paren))
    {
        wxs[0] = minus_sign;  // Replace left parenthesis with minus sign
        wxs.RemoveLast();  // Drop right parenthesis
    }
    wxs.Replace(thousands_sep_s, wxEmptyString);

    // We need to get the std::locale (not wxLocale) related decimal point
    // character, so that we can ensure the Decimal constructor-from-string
    // sees that appropriate decimal point character.
    locale const gloc;  // global locale
    char const spot_char = use_facet<numpunct<char> >(gloc).decimal_point();
    char const spot_str[] = { spot_char, '\0' };
    wxs.Replace(decimal_point_s, wxString(spot_str));

    string const s = wx_to_std8(wxs);
    Decimal const ret(s);
    return ret;
}
Beispiel #3
0
bool MyApp::OnInit()
{
    m_locale.Init();
#ifdef APP_LOCALE_DIR
    m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR));
#endif
    m_locale.AddCatalog(wxT(APP_CATALOG));

    wxInitAllImageHandlers();
    MyFrame* frame_1 = new MyFrame(NULL, wxID_ANY, wxEmptyString);
    SetTopWindow(frame_1);
    frame_1->Show();
    return true;
}
Beispiel #4
0
bool AppEditor::OnInit()
{
    m_locale.Init();
#ifdef APP_LOCALE_DIR
    m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR));
#endif
    m_locale.AddCatalog(wxT(APP_CATALOG));

    wxInitAllImageHandlers();
    FrameEditor* frmEditor = new FrameEditor(NULL, wxID_ANY, wxEmptyString);
    SetTopWindow(frmEditor);
    frmEditor->Show();
    return true;
}
bool MyApp::OnInit()
{
    m_locale.Init();
#ifdef APP_LOCALE_DIR
    m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR));
#endif
    m_locale.AddCatalog(wxT(APP_CATALOG));

    wxInitAllImageHandlers();
    WMain_wxg* wmain = new WMain_wxg(NULL, wxID_ANY, wxEmptyString);
    SetTopWindow(wmain);
    wmain->Show();
    return true;
}
Beispiel #6
0
// Handle command line options
//
bool TestApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
    if (parser.GetParamCount())
    {
        for (size_t i = 0; i < parser.GetParamCount(); i++)
            m_registries.push_back(parser.GetParam(i));
    }

    m_longlist = parser.Found("longlist");
    m_list = m_longlist || parser.Found("list");
    m_timing = parser.Found("timing");
    m_detail = !m_timing && parser.Found("detail");

    wxString loc;
    if ( parser.Found("locale", &loc) )
    {
        const wxLanguageInfo * const info = wxLocale::FindLanguageInfo(loc);
        if ( !info )
        {
            cerr << "Locale \"" << string(loc.mb_str()) << "\" is unknown.\n";
            return false;
        }

        m_locale = new wxLocale(info->Language);
        if ( !m_locale->IsOk() )
        {
            cerr << "Using locale \"" << string(loc.mb_str()) << "\" failed.\n";
            return false;
        }
    }

    return TestAppBase::OnCmdLineParsed(parser);
}
Beispiel #7
0
/**
 * 初期処理
 */
bool DicApp::OnInit()
{
	// カレントフォルダを実行ファイルの場所にする。
	::wxSetWorkingDirectory(::wxPathOnly(argv[0]));

	// メッセージカタログの設定をする。
	m_locale.Init(wxLANGUAGE_DEFAULT);
	m_locale.AddCatalogLookupPathPrefix(wxT("locale"));
	m_locale.AddCatalog(wxT("digdic"));
	
#if 0
	// 設定ファイルの設定をする。
	wxString iniDir = wxStandardPaths::Get().GetUserDataDir();
	wxFileName::Mkdir(iniDir, 0777, wxPATH_MKDIR_FULL);
	wxFileName fn = wxFileName(iniDir, GetAppName(), wxT("ini"));
	DicShare::iniFile = fn.GetFullPath();
	wxFileConfig* config = new wxFileConfig(
		wxEmptyString,
		wxEmptyString,
		DicShare::iniFile,
		wxEmptyString,
		wxCONFIG_USE_LOCAL_FILE,
		*wxConvCurrent);
#else
	// レジストリを使う。
	wxConfig* config = new wxConfig(
		wxT("digdic"),
		wxT("digdic"),
		wxEmptyString,
		wxEmptyString,
		wxCONFIG_USE_LOCAL_FILE);
#endif
	wxConfigBase::Set(config);

	// 共通の設定を読み込む。
	DicShare::LoadConfig();
	
    wxInitAllImageHandlers();
    DicMainFrame* main_frame = new DicMainFrame(0, -1, wxT(""));
    SetTopWindow(main_frame);
    main_frame->Show();
    return true;
}
Beispiel #8
0
// Handle command line options
//
bool TestApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
    if (parser.GetParamCount())
    {
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
        for (size_t i = 0; i < parser.GetParamCount(); i++)
            m_registries.push_back(parser.GetParam(i));
    }

    m_longlist = parser.Found("longlist");
    m_list = m_longlist || parser.Found("list");
    m_timing = parser.Found("timing");
    m_detail = !m_timing && parser.Found("detail");

    wxString loc;
    if ( parser.Found("locale", &loc) )
    {
        const wxLanguageInfo * const info = wxLocale::FindLanguageInfo(loc);
        if ( !info )
        {
            cerr << "Locale \"" << string(loc.mb_str()) << "\" is unknown.\n";
            return false;
        }

        m_locale = new wxLocale(info->Language);
        if ( !m_locale->IsOk() )
        {
            cerr << "Using locale \"" << string(loc.mb_str()) << "\" failed.\n";
            return false;
        }
    }

    return TestAppBase::OnCmdLineParsed(parser);
}
Beispiel #9
0
        bool OnInit()
        {
            //i18n/l10n:
            //20120603: Change suggested by Juan Pizarro to solve the i18n bug in some Windows and Linux machines:
            //if ( !locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING) )
#if defined (linux)
            wxLogNull logNo;
#endif
            if ( !locale.Init(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING) )
                wxLogWarning(_("Error #1: This language is not supported by the system."));

            wxString lanPath(wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) +
                             wxFileName::GetPathSeparator() + wxString("GUI") +
                             wxFileName::GetPathSeparator() + wxString("Texts") //##Unhardcode this in the future? I'm not sure...
                            );
            wxLocale::AddCatalogLookupPathPrefix(lanPath);
            wxString initialCatalogName("en.mo"); //This basic English catalog must exist.
            //wxString initialCatalogName("es.mo"); //##Debug...
            if (!locale.AddCatalog(initialCatalogName))
            {
                //##Future: See if future wxLocale implementations solve this problem:
                wxLogWarning(   _("Error #1: The installation path\n\n\"") + wxStandardPaths::Get().GetExecutablePath() +
                                _("\"\n\ncontains non-English chars.\n") +
                                _("Please try to install Minibloq on a location without this kind of chars. ") +
                                _("Otherwise, the program will run, but the translation system will not work properly.")
                            );
                //wxLogWarning(_("Error #2: Can't load ") + initialCatalogName);
            }

            MainFrame* frame = NULL;
            wxString caption = wxString("miniBloq v0.82.Beta");
            wxPoint framePosition = wxDefaultPosition;
            wxSize frameSize = wxDefaultSize;
            long style = wxDEFAULT_FRAME_STYLE;

            //Default values:
            initialFrameX = 0;
            initialFrameY = 0;
            initialFrameHeight = 600;
            initialFrameWidth = 800;
            maximized = true;
            centered = true;
            strBoard = wxString("");

            //Try to read the configuration file:
            readConfig();

            //Priorities:
            //  maximized has priority over all the other pos and size settings.
            //  centered has priority over x and y settings.
            if (maximized)
                style = style | wxMAXIMIZE;
            if ( (initialFrameWidth > 0) && (initialFrameHeight > 0) )
            {
                framePosition = wxPoint(initialFrameX, initialFrameY);
                frameSize = wxSize(initialFrameWidth, initialFrameHeight);
            }
            frame = new MainFrame(  NULL,
                                    wxID_ANY,
                                    locale,
                                    lanPath,
                                    initialCatalogName,
                                    caption,
                                    strBoard,
                                    framePosition,
                                    frameSize,
                                    style
                                  );
            /*## Future: Full screen:
            wxFrame* frame = new MainFrame(NULL,
                                         wxID_ANY,
                                         wxString("Minibloq v1.0"),
                                         wxDefaultPosition,
                                         wxSize(1280, 800),
                                         wxCLIP_CHILDREN);
            */
            if (frame)
            {
                if (centered)
                    frame->Centre();
                frame->setCentered(centered);

                SetTopWindow(frame);
                frame->Show();
                if (maximized)
                {
                    frame->Maximize();
                }
                if (argc > 0)
                {
                    wxString fileName = argv[1];
                    if (wxFile::Exists(fileName))
                    {
                        frame->loadFileComponent(fileName);
                    }
                }
            }

            return true;
        }
wxString finformat_wx
(   jewel::Decimal const& decimal,
    wxLocale const& loc,
    DecimalFormatFlags p_flags
)
{
#   ifdef DCM_DISALLOW_DASH_FOR_ZERO
        bool const dash_for_zero = false;
#   else
        bool const dash_for_zero = p_flags.test(string_flags::dash_for_zero);
#   endif

    bool const pad = !p_flags.test(string_flags::hard_align_right);

    // TODO LOW PRIORITY Make this cleaner and more efficient.
    Decimal::places_type const places = decimal.places();
    Decimal::int_type const intval = decimal.intval();
    typedef wxChar CharT;
    static CharT const zeroc = wxChar('0');
    wxString const decimal_point_s = loc.GetInfo
    (   wxLOCALE_DECIMAL_POINT,
        wxLOCALE_CAT_MONEY
    );
    wxString const thousands_sep_s = loc.GetInfo
    (   wxLOCALE_THOUSANDS_SEP,
        wxLOCALE_CAT_MONEY
    );
    // We will build it backwards.
    deque<CharT> ret;
    JEWEL_ASSERT (ret.empty());
    // Special case of zero
    if (dash_for_zero && (intval == 0))
    {
        ret.push_back(CharT('-'));
        if (places > 0)
        {
            for (deque<CharT>::size_type i = 0; i != places; ++i)
            {
                ret.push_back(CharT(' '));
            }
        }
    }
    else
    {
        // Our starting point is the string of digits representing the
        // absolute value of the underlying integer.
        ostringstream tempstream;
        tempstream.imbue(locale::classic());
        wxString wxtemp;
        if (intval == numeric_limits<Decimal::int_type>::min())
        {
            // Special case as we can't use std::abs here without
            // overflow.
            tempstream << intval;
            wxtemp = std8_to_wx(tempstream.str());
            wxString::const_iterator it = wxtemp.begin();
            JEWEL_ASSERT (*it == CharT('-'));
            ++it;
            wxtemp = wxString(it, wxtemp.end());
        }
        else
        {
            tempstream << std::abs(intval);
            wxtemp = std8_to_wx(tempstream.str());
        }

        // Write the fractional part
        wxString::reverse_iterator const rend = wxtemp.rend();
        wxString::reverse_iterator rit = wxtemp.rbegin();
        wxString::size_type digits_written = 0;
        for
        (   ;
            (digits_written != places) && (rit != rend);
            ++rit, ++digits_written
        )
        {
            ret.push_front(*rit);
        }
        // Deal with any "filler zerooes" required in the fractional
        // part
        while (digits_written != places)
        {
            ret.push_front(zeroc);
            ++digits_written;
        }
        // Write the decimal point at front if required.
        if (places != 0)
        {
            for (auto k = decimal_point_s.size(); k != 0; --k)
            {
                JEWEL_ASSERT (k >= 1);
                ret.push_front(decimal_point_s[k - 1]);
            }
        }

        // Write the whole part

        // Assume the grouping of digits is normal "threes".
        // TODO MEDIUM PRIORITY Is this a safe assumption? There doesn't seem to
        // be an equivalent of grouping() for wxLocale.
        static vector<wxString::size_type> const grouping(1, 3);
        vector<wxString::size_type>::const_iterator grouping_it =
            grouping.begin();
        vector<wxString::size_type>::const_iterator last_group_datum =
            grouping.end() - 1;
        wxString::size_type digits_written_this_group = 0;
        for
        (   ;
            rit != rend;
            ++rit, ++digits_written, ++digits_written_this_group
        )
        {
            if
            (   digits_written_this_group ==
                static_cast<wxString::size_type>(*grouping_it)
            )
            {
                // Write thousands separator at front.
                for (auto k = thousands_sep_s.size(); k != 0; --k)
                {
                    JEWEL_ASSERT (k >= 1);
                    ret.push_front(thousands_sep_s[k - 1]);
                }
                digits_written_this_group = 0;
                if (grouping_it != last_group_datum) ++grouping_it;
            }
            ret.push_front(*rit);
        }
        // Write a leading zero if required
        if (digits_written == places)
        {
            ret.push_front(zeroc);
        }
    }
    // Indicate negative if required
    if (intval < 0)
    {
        ret.push_front(CharT('('));
        ret.push_back(CharT(')'));
    }
    else if (pad)
    {
        ret.push_back(CharT(' '));
    }
    wxString wret;
    for (CharT const& elem: ret) wret.Append(elem);
    return wret;
}
Beispiel #11
0
bool MadEditApp::OnInit()
{
    xm::EncodingManager::PreInit();

    xm::RemoteAccessInit();

	wxm::AppPath::Instance().Init(GetAppName());

    // parse commandline to filelist
    wxm::FileList filelist;
    for(int i=1; i<argc; i++)
    {
        wxFileName filename(argv[i]);
        filename.MakeAbsolute();
        filelist.Append(filename.GetFullPath());
    }

    // init wxConfig
	wxFileConfig *cfg=new wxFileConfig(wxEmptyString, wxEmptyString, wxm::AppPath::Instance().ConfigPath(), 
	                                   wxEmptyString, wxCONFIG_USE_RELATIVE_PATH|wxCONFIG_USE_NO_ESCAPE_CHARACTERS);
    cfg->SetExpandEnvVars(false);
    cfg->SetRecordDefaults(true);
    wxFileConfig::Set(cfg);

    bool bSingleInstance=true;
    cfg->Read(wxT("/wxMEdit/SingleInstance"), &bSingleInstance, true);

    // check SingleInstance and send filelist to previous instance
    if(bSingleInstance && OpenFilesInPrevInst(filelist.String()))
        return false;

#ifdef __WXGTK__
    bool bDisableWarningMessage = true;
    cfg->Read(wxT("/wxMEdit/DisableWarningMessage"), &bDisableWarningMessage, true);
    if(bDisableWarningMessage)
    {
        // redirect "IPP request failed" message to /dev/null
        int fdnull = open ("/dev/null", O_WRONLY, 0);
        if(fdnull >= 0)
        {
            dup2(fdnull, STDERR_FILENO);
        }
    }
#endif


    // init locale
    wxString strlang;
    cfg->Read(wxT("/wxMEdit/Language"), &strlang);
    int lang=g_LanguageValue[0];
    if(!strlang.IsEmpty())
    {
        strlang.MakeLower();
        for(size_t idx=1; idx<g_LanguageCount; idx++)
        {
            if(strlang == wxString(g_LanguageString[idx]).Lower())
            {
                lang=g_LanguageValue[idx];
                break;
            }
        }
    }

    wxm::AppPath& path = wxm::AppPath::Instance();
    g_Locale.Init(lang);
    g_Locale.AddCatalogLookupPathPrefix(wxT("./locale/"));
    g_Locale.AddCatalogLookupPathPrefix(path.AppDir() + wxT("locale/"));
    if (path.AppDir() != path.HomeDir())
        g_Locale.AddCatalogLookupPathPrefix(path.HomeDir() + wxT("locale/"));
#ifndef __WXMSW__
# ifdef DATA_DIR
    g_Locale.AddCatalogLookupPathPrefix(wxT(DATA_DIR"/locale/"));
# endif
#endif

    g_Locale.AddCatalog(wxT("wxmedit"));

    // set colors
    wxm::SetL10nHtmlColors();

    wxm::UpdatePeriods::Instance().Initialize();

#if defined(__WXMSW__) || defined(__WXGTK__)
    bool maximize=false;
    cfg->Read(wxT("/wxMEdit/WindowMaximize"), &maximize, false);
#endif
    wxPoint pos=wxDefaultPosition;
    wxSize size;
    wxRect rect = wxGetClientDisplayRect(); // FIXME: multi-monitor
    size.x = std::min(rect.width, wxm::DEFAULT_WINDOW_WIDTH);
    size.y = std::min(rect.height, wxm::DEFAULT_WINDOW_HEIGHT);

    long x=0,y=0,w=0,h=0;
    cfg->Read(wxT("/wxMEdit/WindowLeft"), &x);
    cfg->Read(wxT("/wxMEdit/WindowTop"), &y);
    cfg->Read(wxT("/wxMEdit/WindowWidth"), &w);
    cfg->Read(wxT("/wxMEdit/WindowHeight"), &h);

    if(x+w>0 && y+h>0)
    //if(w>0 && h>0)
    {
        size.x=w;
        size.y=h;

        pos.x=x;
        pos.y=y;
    }

    // load FontWidth buffers
    cfg->Read(wxT("/wxMEdit/FontWidthBufferMaxCount"), &FontWidthManager::MaxCount, 10);
    if(FontWidthManager::MaxCount < 4) FontWidthManager::MaxCount=4;
    else if(FontWidthManager::MaxCount>40) FontWidthManager::MaxCount=40;
    FontWidthManager::Init(wxm::AppPath::Instance().HomeDir());


    // create the main frame
    MadEditFrame *myFrame = new MadEditFrame(nullptr, 1 , wxEmptyString, pos, size);
    SetTopWindow(myFrame);

#if defined(__WXMSW__) || defined(__WXGTK__)
    if (maximize)
        myFrame->Maximize(true);
#endif

    myFrame->Show(true);


#if defined(__WXGTK__) && wxMAJOR_VERSION == 2
    if(bSingleInstance)
    {
        GtkPizza *pizza = GTK_PIZZA(myFrame->m_mainWidget);
        Window win=GDK_WINDOW_XWINDOW(pizza->bin_window);
        XSetSelectionOwner(g_Display, g_MadEdit_atom, win, CurrentTime);
        gdk_window_add_filter(nullptr, my_gdk_filter, nullptr);
    }
#endif

    wxm::AutoCheckUpdates(cfg);

    // reload files previously opened
    wxString files;
    cfg->Read(wxT("/wxMEdit/ReloadFilesList"), &files);
    files += filelist.String();

    if(!files.IsEmpty())
    {
        // use OnReceiveMessage() to open the files
        OnReceiveMessage(files.c_str(), (files.size()+1)*sizeof(wxChar));
    }

    if(myFrame->OpenedFileCount()==0)
    {
        myFrame->OpenFile(wxEmptyString, false);
    }

    return true;
}
Beispiel #12
0
void szAppImpl::InitializeLocale(wxArrayString &catalogs, wxLocale &locale) {

	wxString lang = wxConfig::Get()->Read(_T("LANGUAGE"), AUTO_LANGUAGE);
	if (lang == AUTO_LANGUAGE)
		lang = DEFAULT_LANGUAGE;

	const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang);

	int l;

	if (info)
	{
		l = info->Language;
	} else
		l = wxLANGUAGE_ENGLISH;

	locale.Init(l);

	if (!locale.IsOk()) {
		if(locale.IsAvailable(locale.GetSystemLanguage())) {
			l = locale.GetSystemLanguage();
			locale.Init(l);
			if(!locale.IsOk()) {
				wxMessageBox(_("Default locale cannot be loaded. Exiting"), _("Information."), wxICON_ERROR);
				exit(1);
			}
			wxString Ls = L"Locale " + lang + L" not available.\nDefault system locale loaded.";
			wxMessageBox(_(s), _("Information."), wxICON_INFORMATION);
		}
		else {
			wxLogWarning(_("No locale for this system`s language."));
		}
	}

	locale.AddCatalogLookupPathPrefix(GetSzarpDir() + _T("resources/locales"));

	for(size_t i = 0; i < catalogs.Count(); i++)
		locale.AddCatalog(catalogs[i]);

#ifdef __WXGTK__
	if (!locale.IsOk()) {
		wxLogInfo(_("Setting locale to \"C\""));
		setenv("LC_ALL", "C", 1);
	} else if( locale.GetSystemEncodingName() == _("") ) { // this probably doesn't happen on unix machines 
		wxLogInfo(_("wx: Setting locale to \"") + locale.GetCanonicalName() + _("\""));
		setenv("LC_ALL", SC::S2A(locale.GetCanonicalName()).c_str(), 1);
	} else {
		wxString localename = locale.GetCanonicalName() + _(".") + locale.GetSystemEncodingName();
		wxLogInfo(_("wx: Setting locale to \"") + localename + _("\""));
		setenv("LC_ALL", SC::S2A(localename).c_str(), 1);
	}
#endif

}
Beispiel #13
0
bool AddLocaleCatalog( wxString catalog )
{
      return locale_def_lang.AddCatalog( catalog );
}
Beispiel #14
0
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    if ( m_lang == wxLANGUAGE_UNKNOWN )
    {
        int lng = wxGetSingleChoiceIndex
                  (
                    _("Please choose language:"),
                    _("Language"),
                    WXSIZEOF(langNames),
                    langNames
                  );
        m_lang = lng == -1 ? wxLANGUAGE_DEFAULT : langIds[lng];
    }

    // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
    // false just because it failed to load wxstd catalog
    if ( !m_locale.Init(m_lang, wxLOCALE_DONT_LOAD_DEFAULT) )
    {
        wxLogWarning(_("This language is not supported by the system."));

        // continue nevertheless
    }

    // normally this wouldn't be necessary as the catalog files would be found
    // in the default locations, but when the program is not installed the
    // catalogs are in the build directory where we wouldn't find them by
    // default
    wxLocale::AddCatalogLookupPathPrefix(".");

    // Initialize the catalogs we'll be using
    const wxLanguageInfo* pInfo = wxLocale::GetLanguageInfo(m_lang);
    if (!m_locale.AddCatalog("internat"))
    {
        wxLogError(_("Couldn't find/load the 'internat' catalog for locale '%s'."),
                   pInfo ? pInfo->GetLocaleName() : _("unknown"));
    }

    // Now try to add wxstd.mo so that loading "NOTEXIST.ING" file will produce
    // a localized error message:
    m_locale.AddCatalog("wxstd");
        // NOTE: it's not an error if we couldn't find it!

    // this catalog is installed in standard location on Linux systems and
    // shows that you may make use of the standard message catalogs as well
    //
    // if it's not installed on your system, it is just silently ignored
#ifdef __LINUX__
    {
        wxLogNull noLog;
        m_locale.AddCatalog("fileutils");
    }
#endif

    // Create the main frame window
    MyFrame *frame = new MyFrame(m_locale);

    // Show the frame
    frame->Show(true);

    return true;
}
Beispiel #15
0
        bool OnInit()
        {

#if DEBUG
            wxLogWarning("MODO DEBUG");
#else
            wxSetAssertHandler(NULL);
#endif

            //i18n/l10n:
            //20120603: Change suggested by Juan Pizarro to solve the i18n bug in some Windows and Linux machines:
            //if ( !locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING) )

#if !defined(linux)
            wxLogWarning("Esta version esta desarrollada exclusivamente para Linux");
            return true;
#endif


/*
#if defined (linux)
            wxLogNull logNo;
#endif
*/
            /*
            if ( !locale.Init(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING) )
                wxLogWarning(_("Error #1: This language is not supported by the system."));
            */

            /*
            wxString lanPath(wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) +
                             wxFileName::GetPathSeparator() + wxString("GUI") +
                             wxFileName::GetPathSeparator() + wxString("Texts") //##Unhardcode this in the future? I'm not sure...
                            );
            */


            //wxString lanPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) + "/../../GUI/Texts/";
            //wxLocale::AddCatalogLookupPathPrefix(lanPath);

	    wxString lanPath = "/usr/share";
	    locale.AddCatalogLookupPathPrefix(lanPath);


            //Por defecto debe levantar en Castellano
            //wxString initialCatalogName("es.mo");

	    wxString initialCatalogName = "Minibloq.mo";

            //wxString initialCatalogName("es.mo"); //##Debug...
            if (!locale.AddCatalog(initialCatalogName))
            {
                //##Future: See if future wxLocale implementations solve this problem:
                wxLogWarning(   _("Error #1: The installation path\n\n\"") + wxStandardPaths::Get().GetExecutablePath() +
                                _("\"\n\ncontains non-English chars.\n") +
                                _("Please try to install Minibloq on a location without this kind of chars. ") +
                                _("Otherwise, the program will run, but the translation system will not work properly.")
                            );
                //wxLogWarning(_("Error #2: Can't load ") + initialCatalogName);
                printf("NO ENCUENTRO EL CATALOGO\n");
            }

            MainFrame* frame = NULL;

            wxString caption = wxString(wxString("miniBloq ") + MINIBLOQ_VERSION);
            wxPoint framePosition = wxDefaultPosition;
            wxSize frameSize = wxDefaultSize;
            long style = wxDEFAULT_FRAME_STYLE;

            //Default values:
            initialFrameX = 0;
            initialFrameY = 0;
            initialFrameHeight = 600;
            initialFrameWidth = 800;
            maximized = true;
            centered = true;
            strBoard = wxString("");

            //Try to read the configuration file:
            readConfig();

            //Priorities:
            //  maximized has priority over all the other pos and size settings.
            //  centered has priority over x and y settings.
            if (maximized)
                style = style | wxMAXIMIZE;
            if ( (initialFrameWidth > 0) && (initialFrameHeight > 0) )
            {
                framePosition = wxPoint(initialFrameX, initialFrameY);
                frameSize = wxSize(initialFrameWidth, initialFrameHeight);
            }

            //TODO: Chequeo de errores
	    wxString execPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()); 
	    wxString splashImg = execPath + "/../../GUI/Images/minibloqSplash.png";

            wxBitmap splashPng;
            splashPng.LoadFile(splashImg);
            wxSplashScreen* splash = new wxSplashScreen(splashPng,
                                                        wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
                                                        3000,
                                                        NULL,
                                                        -1,
                                                        wxDefaultPosition,
                                                        wxDefaultSize,
                                                        wxBORDER_SIMPLE|wxSTAY_ON_TOP);

            wxYield();


            frame = new MainFrame(  NULL,
                                    wxID_ANY,
                                    locale,
                                    lanPath,
                                    initialCatalogName,
                                    caption,
                                    strBoard,
                                    framePosition,
                                    frameSize,
                                    style
                                  );
            /*## Future: Full screen:
            wxFrame* frame = new MainFrame(NULL,
                                         wxID_ANY,
                                         wxString("Minibloq v1.0"),
                                         wxDefaultPosition,
                                         wxSize(1280, 800),
                                         wxCLIP_CHILDREN);
            */
            if (frame)
            {
                if (centered)
                    frame->Centre();
                frame->setCentered(centered);

                SetTopWindow(frame);
                frame->Show();
                if (maximized)
                {
                    frame->Maximize();
                }
                if (argc > 0)
                {
                    wxString fileName = argv[1];
                    if (wxFile::Exists(fileName))
                    {
                        frame->loadFileComponent(fileName);
                    }
                }
            }

            return true;
        }