bool CDStarRepeaterConfigApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	if (!wxApp::OnInit())
		return false;

	wxString frameName = APPLICATION_NAME + wxT(" - ");
	if (!m_name.IsEmpty()) {
		frameName.Append(m_name);
		frameName.Append(wxT(" - "));
	}
	frameName.Append(VERSION);

#if defined(__WINDOWS__)
	m_frame = new CDStarRepeaterConfigFrame(frameName, m_name);
#else
	m_frame = new CDStarRepeaterConfigFrame(frameName, m_confDir, m_name);
#endif
	m_frame->Show();

	SetTopWindow(m_frame);

	return true;
}
 /** OnInit
  *
  * Initializes the program
  */
bool BBBApp::OnInit()
{
    srand(time(NULL));
    logger.reset(new LoggerWx());

    if (!wxApp::OnInit())
        return false;
#ifndef __WIN32
    wxHandleFatalExceptions();
#endif
    wxInitAllImageHandlers();

    SetVendorName("Bottomless Block Builder");
    SetAppName("Bottomless Block Builder");

    wxBitmap bitmap(panels_gfx_xpm);
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(112, 16, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(0, 0, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(16, 0, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(32, 0, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(48, 0, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(64, 0, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(80, 0, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(96, 0, 16, 16)));
    panelImages.push_back(bitmap.GetSubBitmap(wxRect(112, 0, 16, 16)));

    BBBFrame* frame = new BBBFrame();
    frame->Show();

    return true;
}
Пример #3
0
bool App::OnInit()
{
    bool ok = wxApp::OnInit();

    if (ok)
    {
        wxLocaleHelper::Init(&m_locale, STE_APPNAME, m_cmdLine.m_lang);
        ::wxInitAllImageHandlers();

        // Fill in the application information fields before creating wxConfig.
        SetVendorName(wxT("wxWidgets"));
        SetAppName(APP_NAME_SHORT);
    #if (wxVERSION_NUMBER >= 2900)
        SetAppDisplayName(APP_NAME_DISPLAY);
    #endif

        // Create a document manager
        wxDocManager* docManager = CreateDocManager();

        // create the main frame window
        MainFrame* frame = new MainFrame();
        
        ok = frame->Create(docManager, GetAppDisplayName());
        if (ok)
        {
            frame->Show();
            OpenDocuments(docManager);
        }
        else
        {
            delete frame;
        }
    }
    return ok;
}
Пример #4
0
bool CRemoteControlApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	if (!wxApp::OnInit())
		return false;

	m_config = new CRemoteControlConfig(new wxConfig(APPLICATION_NAME), m_name);

	wxString frameName = APPLICATION_NAME + wxT(" - ");
	if (!m_name.IsEmpty()) {
		frameName.Append(m_name);
		frameName.Append(wxT(" - "));
	}
	frameName.Append(VERSION);

	wxPoint position = wxDefaultPosition;

	int x, y;
	getPosition(x, y);
	if (x >= 0 && y >= 0)
		position = wxPoint(x, y);

	m_frame = new CRemoteControlFrame(frameName, position);
	m_frame->Show();

	SetTopWindow(m_frame);

	return wxApp::OnInit();
}
Пример #5
0
bool MyApp::OnInit()
{
    SetVendorName(_T("Free world"));
    SetAppName(_T("wxEdit"));

    MyFrame *frame = new MyFrame( NULL, wxID_ANY, _T("wxEdit"), wxPoint(20,20), wxSize(500,340) );
    frame->Show( true );

    return true;
}
// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
	wxInitAllImageHandlers();
	wxBitmap splashbitmap;
  	if (splashbitmap.LoadFile("/opt/extras.ubuntu.com/azpazeta/media/splash.png", wxBITMAP_TYPE_PNG))
  	{
      	wxSplashScreen* splash = new wxSplashScreen(splashbitmap,
          wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
          6000, NULL, -1, wxDefaultPosition, wxSize(400,400),
          wxSIMPLE_BORDER|wxSTAY_ON_TOP);
  	}
  	wxYield();
	//ChrTaskBarIcon* icon = new ChrTaskBarIcon(); 
    // call the base class initialization method, currently it only parses a
    // few common command-line options but it could be do more in the future
    if ( !wxApp::OnInit() )
        return false;
	SetAppName(wxT("Azpazeta"));
	SetVendorName(wxT("Adrian Arroyo Calle para Divel"));
        if(wxApp::argc>=2){
	fachada=1;
        wxString archivo=wxApp::argv[1].mb_str();
        //int* newsavedlg=new SaveDialog::Cargar(wxString archivo);
        SaveDialog* newsavedlg=new SaveDialog();
        newsavedlg->Cargar(archivo);
	newsavedlg->Destroy();
	MyFrame *frame = new MyFrame("Azpazeta");
	frame->Show(true);
	frame->Load();
	frame->Paint();
	//if(city==4){MyFrame::Stage4();}
	
        
        }else{	MyFrame *frame = new MyFrame("Azpazeta");
	frame->Show(true);
	frame->OnJugar();
	frame->Paint();}
        
        
    // create the main application window

    // and show it (the frames, unlike simple controls, are not shown when
    // created initially)
    
	
	

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returned false here, the
    // application would exit immediately.
    return true;
}
Пример #7
0
OyunApp::OyunApp()
{
	// Some assorted wxWidgets initialization calls
	wxInitAllImageHandlers();
	wxFileSystem::AddHandler(new wxArchiveFSHandler);

	// We need a true-color visual for drawing the plots
	// later on
	SetUseBestVisual(true, true);

	// Tell the wxApp who we are
	SetAppName(wxT("Oyun"));
	SetClassName(wxT("Oyun"));
	SetVendorName(wxT("OyunTeam"));
}
Пример #8
0
    /// This function is called during application start-up.
    virtual bool OnInit()
    {
        wxLog::SetActiveTarget(new wxLogStderr);

        SetAppName(_T("CryptoTE"));
        SetVendorName(_T("panthema.net"));

        // Setup locale to system default

        locale = new MyLocale(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING);

        // Load and initialize the catalog
        if (!locale->AddCatalogFromMemory(_T("cryptote"), cryptote_catalogs) ||
            !locale->AddCatalogFromMemory(_T("wxstd"), wxstd_catalogs))
        {
            // Could not load message catalog for system language, falling back
            // to English.

            delete locale;
            locale = new MyLocale(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING);

            if (!locale->AddCatalogFromMemory(_T("cryptote"), cryptote_catalogs) ||
                !locale->AddCatalogFromMemory(_T("wxstd"), wxstd_catalogs))
            {
                wxLogError(_T("Could not load message catalog for system or English language."));
                return false;
            }
        }

        if (!wxApp::OnInit()) return false;

        wxImage::AddHandler(new wxPNGHandler());

        wxLog::SetActiveTarget(NULL);

        // Create main window frame
        wmain = new WPassGen(NULL, true);
        SetTopWindow(wmain);

        // Load config presets and settings from registry/user-configfile
        wxConfigBase* cfg = wxConfigBase::Get();
        wmain->LoadSettings(cfg);

        // Show Dialog
        wmain->Show();

        return true;
    }
Пример #9
0
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    // we're using wxConfig's "create-on-demand" feature: it will create the
    // config object when it's used for the first time. It has a number of
    // advantages compared with explicitly creating our wxConfig:
    //  1) we don't pay for it if we don't use it
    //  2) there is no danger to create it twice

    // application and vendor name are used by wxConfig to construct the name
    // of the config file/registry key and must be set before the first call
    // to Get() if you want to override the default values (the application
    // name is the name of the executable and the vendor name is the same)
    SetVendorName(wxT("wxWidgets"));
    SetAppName(wxT("conftest")); // not needed, it's the default value

    wxConfigBase *pConfig = wxConfigBase::Get();

    // uncomment this to force writing back of the defaults for all values
    // if they're not present in the config - this can give the user an idea
    // of all possible settings for this program
    pConfig->SetRecordDefaults();

    // or you could also write something like this:
    //  wxFileConfig *pConfig = new wxFileConfig("conftest");
    //  wxConfigBase::Set(pConfig);
    // where you can also specify the file names explicitly if you wish.
    // Of course, calling Set() is optional and you only must do it if
    // you want to later retrieve this pointer with Get().

    // create the main program window
    MyFrame *frame = new MyFrame;
    frame->Show(true);

    // use our config object...
    if ( pConfig->Read(wxT("/Controls/Check"), 1l) != 0 ) {
        wxMessageBox(wxT("You can disable this message box by unchecking\n")
                    wxT("the checkbox in the main window (of course, a real\n")
                    wxT("program would have a checkbox right here but we\n")
                    wxT("keep it simple)"), wxT("Welcome to wxConfig demo"),
                    wxICON_INFORMATION | wxOK);
    }

    return true;
}
Пример #10
0
 /** OnInit
  *
  * Initializes the program
  */
bool ComplxApp::OnInit()
{
    if (!wxApp::OnInit()) return false;

    SetVendorName("Complx");
    SetAppName("Complx");

    wxFileConfig *config = new wxFileConfig("Complx");
    wxConfigBase::Set(config);

    srand(time(NULL));
    complxframe = new ComplxFrame(decimal, disassemble, stack_size, true_traps, interrupts, highlight, address_str, state_file, files);
    wxIcon icon(icon32_xpm);
    complxframe->SetIcon(icon);
    complxframe->Show();

    size_t currentTip = 0;
    bool show = true;
    std::string last_ver = config->Read("/firstrun", "").ToStdString();
    // use our config object...
    if (last_ver.empty()) {
        wxCommandEvent event;
        complxframe->OnFirstTime(event);
        config->Write("/firstrun", AutoVersion::FULLVERSION_STRING);
        config->Flush();
    }
    else
    {
        currentTip = config->Read("/currenttip", 0l);
        config->Read("/showtips", &show);
    }

    if (show)
    {
        wxTipProvider* tip = wxCreateFileTipProvider("/usr/local/share/complx-tools/complx-tips.txt", currentTip);
        show = wxShowTip(complxframe, tip, show);

        config->Write("/showtips", show);
        config->Write("/currenttip", tip->GetCurrentTip());
        config->Flush();
        delete tip;
    }

    return true;
}
bool CDVToolReaderApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	wxFileName loggerName(wxFileName::GetHomeDir(), LOG_FILE_NAME, wxT("log"));
	wxLog* log = new CLogger(loggerName.GetFullPath());
	wxLog::SetActiveTarget(log);

	m_frame = new CDVToolReaderFrame(APPLICATION_NAME + wxT(" - ") + VERSION);
	m_frame->Show();

	SetTopWindow(m_frame);

	wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION);

	createThread();

	return wxApp::OnInit();
}
Пример #12
0
//==========================================================================
// Class:			ConverterApp
// Function:		OnInit
//
// Description:		Initializes the application window.
//
// Input Arguments:
//		None
//
// Output Arguments:
//		None
//
// Return Value:
//		bool = true for successful window initialization, false for error
//
//==========================================================================
bool ConverterApp::OnInit()
{
	// Set the application's name and the vendor's name
	SetAppName(name);
	SetVendorName(creator);

	// Create the MainFrame object - this is the parent for all other objects
	mainFrame = new MainFrame();

	// Make sure the MainFrame was successfully created
	if (mainFrame == NULL)
		return false;

	// Make the window visible
	mainFrame->Show(true);

	// Bring the window to the top
	//SetTopWindow(mainFrame);

	return true;
}
Пример #13
0
void PWUpdaterApp::Init()
{
    /* application information */
    SetVendorName(wxT("delta"));
    SetVendorDisplayName(wxT("Delta Electronics, Inc."));
    SetAppName(wxT("PWUpdater"));
    SetAppDisplayName(wxT("PixelWorks Ruby Platform Updater"));

    /* database */
    m_pOpt = new AppOptions;

    /* network adapter list */
    m_adapterList.clear();

    /* usb key state */
    m_keyFound = false;

    /* threads management */
    m_serverCS.Enter();
    m_pTftpdServerThread = NULL;
    m_serverCS.Leave();

    m_transmissionCS.Enter();
    m_tftpdTransmissionThreads.clear();
    m_transmissionCS.Leave();

    m_rockeyCS.Enter();
    m_pRockeyThread = NULL;
    m_rockeyCS.Leave();

    m_uartCS.Enter();
    m_pUartThread = NULL;
    m_uartCS.Leave();

    /* thread queue */
    m_pUartQueue = new ThreadSafeQueue<UartMessage>;

    /* create supported language map */
    AddSupportedLanguages();
}
Пример #14
0
bool CEditorApp::OnInit()
{
	Zion::InitDDLStub();
	Zion::InitContentObjects();
	Zion::InitLiveObjects();
	Zion::ContentObject::LoadContent(NULL, true);

	wxImage::AddHandler(ZION_NEW wxPNGHandler);

	SetVendorName(wxT("Zion"));
	SetAppName(wxT("Editor"));

	wxConfigBase *pConfig = wxConfigBase::Get();
	pConfig->SetRecordDefaults();

	CEditorFrame* pMainFrame;
	pMainFrame = ZION_NEW CEditorFrame;
	pMainFrame->Show(true);
	SetTopWindow(pMainFrame);

	return true;
}
Пример #15
0
bool CDVRPTRClientApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	wxFileName loggerName(wxFileName::GetHomeDir(), LOG_FILE_NAME, wxT("log"));
	wxLog* log = new CLogger(loggerName.GetFullPath());
	wxLog::SetActiveTarget(log);

	m_frame = new CDVRPTRClientFrame(APPLICATION_NAME + wxT(" - ") + VERSION);
	m_frame->Show();

	SetTopWindow(m_frame);

	wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION);

	// Log the SVN revsion and the version of wxWidgets and the Operating System
	wxLogInfo(SVNREV);
	wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str());

	createThread();

	return wxApp::OnInit();
}
Пример #16
0
// Main program equivalent, creating windows and returning main app frame
bool Regard3DApp::OnInit()
{
	wxString appName(wxT(REGARD3D_NAME));
	wxString vendorName(wxT(REGARD3D_VENDOR_NAME));

#if wxCHECK_VERSION(2, 9, 0)
	SetAppDisplayName(appName);
	SetVendorDisplayName(vendorName);
#endif
	appName.Replace(wxT(" "), wxEmptyString, true);
	SetAppName(appName);
	SetVendorName(vendorName);

#if wxUSE_IMAGE
	wxInitAllImageHandlers();
#endif

	Eigen::initParallel();

#if defined(R3D_HAVE_OPENMP)
	//omp_set_num_threads(1);	// omp_get_num_procs() + 1);	// +1 to fill delays in file I/O
#endif

	CameraDBLookup::getInstance().initialize();
	UserCameraDB::getInstance().initialize();
	R3DExternalPrograms::getInstance().initialize();
	R3DFontHandler::getInstance().initialize();

	pMainFrame_ = new Regard3DMainFrame(NULL);

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

	SetTopWindow(pMainFrame_);

	return true;
}
Пример #17
0
bool Kuvastin::OnInit()
{
    SetVendorName("Tapsa");
    SetAppName("Kuvastin");
    wxImage::AddHandler(new wxJPEGHandler);

    Peili* window;
    wxString settings;
    wxArrayString paths, names;
    for(size_t a = 1; a < wxApp::argc; ++a)
    {
        if('-' == wxApp::argv[a][0]) settings = wxApp::argv[a];
        else if(':' == wxApp::argv[a][1]) paths.Add(wxApp::argv[a]);
        else names.Add(wxApp::argv[a]);
    }

    window = new Peili("Kuvastin " + Peili::APP_VER, paths, settings, names);
    SetTopWindow(window);
    window->SetSize(900, 720);
    window->Show(true);
    window->load_pixs();

    return true;
}
Пример #18
0
// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------
// `Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    wxInitAllImageHandlers();
#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB
    wxFileSystem::AddHandler(new wxZipFSHandler);
#endif
    SetVendorName(wxT("wxWidgets"));
    SetAppName(wxT("wxHTMLHelp"));

    // Create the main application window
    MyFrame *frame = new MyFrame(_("HTML Help Sample"),
        wxDefaultPosition, wxDefaultSize);

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

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returned false here, the
    // application would exit immediately.
    return true;
}
Пример #19
0
bool CDummyRepeaterApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	if (!wxApp::OnInit())
		return false;

	if (!m_noLog) {
		wxLog* log = new CLogger(wxFileName::GetHomeDir(), LOG_BASE_NAME);
		wxLog::SetActiveTarget(log);
	} else {
		new wxLogNull;
	}

	wxPoint position = wxDefaultPosition;

	int x, y;
	getPosition(x, y);
	if (x >= 0 && y >= 0)
		position = wxPoint(x, y);

	m_frame = new CDummyRepeaterFrame(APPLICATION_NAME + wxT(" - ") + VERSION, position);
	m_frame->Show();

	SetTopWindow(m_frame);

	wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION);

	// Log the SVN revsion and the version of wxWidgets and the Operating System
	wxLogInfo(SVNREV);
	wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str());

	createThread();

	return wxApp::OnInit();
}
Пример #20
0
bool muhkuh_app::OnInit()
{
	wxSocketBase::Initialize();

	wxInitAllImageHandlers();
	// add virtual filesystem for zip archives
	wxFileSystem::AddHandler(new wxZipFSHandler);
	// add virtual filesystem for http and ftp
	wxFileSystem::AddHandler(new wxInternetFSHandler);

	// ... from wxLua demo application
#ifdef __WXGTK__
	// this call is very important since otherwise scripts using the decimal
	// point '.' could not work with those locales which use a different symbol
	// (e.g. the comma) for the decimal point...
	// It doesn't work to put os.setlocale('c', 'numeric') in the Lua file that
	// you want to use decimal points in. That's because the file has been lexed
	// and compiler before the locale has changed, so the lexer - the part that
	// recognises numbers - will use the old locale.
	setlocale(LC_NUMERIC, "C");
#endif

	// set application and vendor name, this is needed
	// for the config file (unix) or registry keys (win)
	SetVendorName(wxT(MUHKUH_APPLICATION_NAME) wxT(" team"));
	SetAppName(wxT(MUHKUH_APPLICATION_NAME));

	// create the muhkuh main frame
	ptMainframe = new muhkuh_mainFrame();

	// show the frame
	ptMainframe->Show(true);
	SetTopWindow(ptMainframe);

	return true;
}
Пример #21
0
bool CTimeServerApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	if (!wxApp::OnInit())
		return false;

	if (!m_nolog) {
		wxString logBaseName = LOG_BASE_NAME;
		if (!m_name.IsEmpty()) {
			logBaseName.Append(wxT("_"));
			logBaseName.Append(m_name);
		}

#if defined(__WINDOWS__)
		if (m_logDir.IsEmpty())
			m_logDir = wxFileName::GetHomeDir();
#else
		if (m_logDir.IsEmpty())
			m_logDir = LOG_DIR;
#endif

		wxLog* log = new CLogger(m_logDir, logBaseName);
		wxLog::SetActiveTarget(log);
	} else {
		new wxLogNull;
	}

	m_logChain = new wxLogChain(new CTimeServerLogRedirect);

#if defined(__WINDOWS__)
	m_config = new CTimeServerConfig(new wxConfig(APPLICATION_NAME), m_name);
#else
	if (m_confDir.IsEmpty())
		m_confDir = CONF_DIR;

	m_config = new CTimeServerConfig(m_confDir, m_name);
#endif

	wxString frameName = APPLICATION_NAME + wxT(" - ");
	if (!m_name.IsEmpty()) {
		frameName.Append(m_name);
		frameName.Append(wxT(" - "));
	}
	frameName.Append(VERSION);

	wxPoint position = wxDefaultPosition;

	int x, y;
	getPosition(x, y);
	if (x >= 0 && y >= 0)
		position = wxPoint(x, y);

	m_frame = new CTimeServerFrame(frameName, position, m_gui);
	m_frame->Show();

	SetTopWindow(m_frame);

	wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION);

	// Log the SVN revsion and the version of wxWidgets and the Operating System
	wxLogInfo(SVNREV);
	wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str());

	createThread();

	return true;
}
Пример #22
0
void WinEDA_App::InitEDA_Appl(const wxString & name)
/***************************************************/
{
wxString ident;
wxString EnvLang;

	ident = name + wxT("-") + wxGetUserId();
	m_Checker = new wxSingleInstanceChecker(ident);

	/* Init environnement
	(KICAD definit le chemin de kicad ex: set KICAD=d:\kicad) */
	m_Env_Defined = wxGetEnv( wxT("KICAD"), &m_KicadEnv);
	if ( m_Env_Defined )	// m_KicadEnv doit finir par "/" ou "\"
	{
		m_KicadEnv.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP);
		if ( m_KicadEnv.Last() != '/' ) m_KicadEnv += UNIX_STRING_DIR_SEP;
	}

	/* Prepare On Line Help */
	m_HelpFileName = name + wxT(".html");

	// Init parametres pour configuration
	SetVendorName(wxT("kicad"));
	SetAppName(name);
	m_EDA_Config = new wxConfig(name);
	m_EDA_CommonConfig = new wxConfig(wxT("kicad_common"));

	/* Creation des outils de trace */
	DrawPen = new wxPen( wxT("GREEN"), 1, wxSOLID);
	DrawBrush = new wxBrush(wxT("BLACK"), wxTRANSPARENT);

	/* Creation des fontes utiles */
	g_StdFontPointSize = FONT_DEFAULT_SIZE;
	g_MsgFontPointSize = FONT_DEFAULT_SIZE;
	g_DialogFontPointSize = FONT_DEFAULT_SIZE;
	g_FixedFontPointSize = FONT_DEFAULT_SIZE;
	g_StdFont = new wxFont(g_StdFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL);
	g_MsgFont = new wxFont(g_StdFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL);
	g_DialogFont = new wxFont(g_DialogFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL);
	g_ItalicFont = new wxFont(g_DialogFontPointSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_ITALIC,  wxNORMAL);
	g_FixedFont = new wxFont(g_FixedFontPointSize, wxFONTFAMILY_MODERN, wxNORMAL, wxNORMAL);

	/* installation des gestionnaires de visu d'images (pour help) */
	wxImage::AddHandler(new wxPNGHandler);
	wxImage::AddHandler(new wxGIFHandler);
	wxImage::AddHandler(new wxJPEGHandler);
    wxFileSystem::AddHandler(new wxZipFSHandler);

	// Analyse command line & init binary path
	SetBinDir();

	// Internationalisation: chargement du Dictionnaire de kicad
	m_EDA_CommonConfig->Read(wxT("Language"), &m_LanguageId, wxLANGUAGE_DEFAULT);

bool succes = SetLanguage(TRUE);
	if ( ! succes )
		{
		}

	if ( atof("0,1") ) g_FloatSeparator = ','; // Nombres flottants = 0,1
	else  g_FloatSeparator = '.';

}
Пример #23
0
bool CBOINCGUIApp::OnInit() {
    // Initialize globals
#ifdef SANDBOX
    g_use_sandbox = true;
#else
    g_use_sandbox = false;
#endif

    s_bSkipExitConfirmation = false;
    m_bFilterEvents = false;
    m_bAboutDialogIsOpen = false;

    // Initialize class variables
    m_pLocale = NULL;
    m_pSkinManager = NULL;
    m_pFrame = NULL;
    m_pDocument = NULL;
    m_pTaskBarIcon = NULL;
    m_pEventLog = NULL;
#ifdef __WXMAC__
    m_pMacDockIcon = NULL;
#endif
    m_strBOINCMGRExecutableName = wxEmptyString;
    m_strBOINCMGRRootDirectory = wxEmptyString;
    m_strBOINCMGRDataDirectory = wxEmptyString;
    m_strHostNameArg = wxEmptyString;
    m_strPasswordArg = wxEmptyString;
    m_iRPCPortArg = GUI_RPC_PORT;
    m_strBOINCArguments = wxEmptyString;
    m_bGUIVisible = true;
    m_bDebugSkins = false;
    m_bMultipleInstancesOK = false;
    m_bBOINCMGRAutoStarted = false;
    m_iBOINCMGRDisableAutoStart = 0;
    m_iShutdownCoreClient = 0;
    m_iDisplayExitDialog = 1;
    m_iGUISelected = BOINC_SIMPLEGUI;
    m_bSafeMessageBoxDisplayed = 0;
#ifdef __WXMSW__
    m_hClientLibraryDll = NULL;
#endif

    // Initialize local variables
    int      iErrorCode = 0;
    int      iSelectedLanguage = 0;
    bool     bOpenEventLog = false;
    wxString strDesiredSkinName = wxEmptyString;
    wxString strDialogMessage = wxEmptyString;
    bool     success = false;

    // Configure wxWidgets platform specific code
#ifdef __WXMSW__
    wxSystemOptions::SetOption(wxT("msw.staticbox.optimized-paint"), 0);
#endif
#ifdef __WXMAC__
    // In wxMac-2.8.7, default wxListCtrl::RefreshItem() does not work
    // so use traditional generic implementation.
    // This has been fixed in wxMac-2.8.8, but the Mac native implementation:
    //  - takes 3 times the CPU time as the Mac generic version.
    //  - seems to always redraw entire control even if asked to refresh only one row.
    //  - causes major flicker of progress bars, (probably due to full redraws.)
    wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), 1);

    AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr)QuitAppleEventHandler), 0, false );

    // Cache the current process serial number
    GetCurrentProcess(&m_psnCurrentProcess);
#endif


    // Commandline parsing is done in wxApp::OnInit()
    if (!wxApp::OnInit()) {
        return false;
    }

    if (g_use_sandbox) {
        wxCHANGE_UMASK(2);  // Set file creation mask to be writable by both user and group
                            // Our umask will be inherited by all our child processes
    }

    // Setup application and company information
    SetAppName(wxT("BOINC Manager"));
    SetVendorName(wxT("Space Sciences Laboratory, U.C. Berkeley"));


    // Initialize the configuration storage module
    m_pConfig = new wxConfig(GetAppName());
    wxConfigBase::Set(m_pConfig);
    wxASSERT(m_pConfig);


    // Restore Application State
    m_pConfig->SetPath(wxT("/"));
    m_pConfig->Read(wxT("AutomaticallyShutdownClient"), &m_iShutdownCoreClient, 0L);
    m_pConfig->Read(wxT("DisplayShutdownClientDialog"), &m_iDisplayExitDialog, 1L);
    m_pConfig->Read(wxT("DisableAutoStart"), &m_iBOINCMGRDisableAutoStart, 0L);
    m_pConfig->Read(wxT("Language"), &iSelectedLanguage, 0L);
    m_pConfig->Read(wxT("GUISelection"), &m_iGUISelected, BOINC_SIMPLEGUI);
    m_pConfig->Read(wxT("EventLogOpen"), &bOpenEventLog);


    // Should we abort the BOINC Manager startup process?
    if (m_bBOINCMGRAutoStarted && m_iBOINCMGRDisableAutoStart) {
        return false;
    }

    // Detect where BOINC Manager executable name.
    DetectExecutableName();

    // Detect where BOINC Manager was installed too.
    DetectRootDirectory();

    // Detect where the BOINC Data files are.
    DetectDataDirectory();


    // Switch the current directory to the BOINC Data directory
    if (!GetDataDirectory().IsEmpty()) {
    	success = wxSetWorkingDirectory(GetDataDirectory());
        if (!success) {
            if (!g_use_sandbox) {
                if (!wxDirExists(GetDataDirectory())) {
                    success = wxMkdir(GetDataDirectory(), 0777);    // Does nothing if dir exists
                }
            }
        }
    }

    if (!success) iErrorCode = -1016;

    // Initialize the BOINC Diagnostics Framework
    int dwDiagnosticsFlags =
        BOINC_DIAG_DUMPCALLSTACKENABLED | 
        BOINC_DIAG_HEAPCHECKENABLED |
        BOINC_DIAG_MEMORYLEAKCHECKENABLED |
#if defined(__WXMSW__) || defined(__WXMAC__)
        BOINC_DIAG_REDIRECTSTDERR |
        BOINC_DIAG_REDIRECTSTDOUT |
#endif
        BOINC_DIAG_TRACETOSTDOUT;

    diagnostics_init(
        dwDiagnosticsFlags,
        "stdoutgui",
        "stderrgui"
    );


    // Enable Logging and Trace Masks
    m_pLog = new wxLogBOINC();
    wxLog::SetActiveTarget(m_pLog);

    m_pLog->AddTraceMask(wxT("Function Start/End"));
    m_pLog->AddTraceMask(wxT("Function Status"));


    // Initialize the internationalization module
#ifdef __WXMSW__
    // On Windows, set all locales for this thread on a per-thread basis
    _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
#endif
    m_pLocale = new wxLocale();
    wxASSERT(m_pLocale);

    // Look for the localization files by absolute and relative locations.
    //   preference given to the absolute location.
    m_pLocale->Init(iSelectedLanguage);
    if (!m_strBOINCMGRRootDirectory.IsEmpty()) {
        m_pLocale->AddCatalogLookupPathPrefix(
            wxString(m_strBOINCMGRRootDirectory + wxT("locale"))
        );
    }
    m_pLocale->AddCatalogLookupPathPrefix(wxT("locale"));
    m_pLocale->AddCatalog(wxT("BOINC-Manager"));
    m_pLocale->AddCatalog(wxT("BOINC-Client"));
    m_pLocale->AddCatalog(wxT("BOINC-Web"));

    InitSupportedLanguages();

	language = m_pLocale->GetCanonicalName();

    // Note: JAWS for Windows will only speak the context-sensitive
    // help if you use this help provider:
    wxHelpProvider::Set(new wxHelpControllerHelpProvider());

    // Enable known image types
    wxInitAllImageHandlers();

    // Initialize the skin manager
    m_pSkinManager = new CSkinManager(m_bDebugSkins);
    wxASSERT(m_pSkinManager);


    // Load desired manager skin
    m_pConfig->Read(wxT("Skin"), &strDesiredSkinName, m_pSkinManager->GetDefaultSkinName());
    m_pSkinManager->ReloadSkin(strDesiredSkinName);


#ifdef SANDBOX
    // Make sure owners, groups and permissions are correct for the current setting of g_use_sandbox
    char path_to_error[MAXPATHLEN];
    path_to_error[0] = '\0';
    
    if (!iErrorCode) {
#if (defined(__WXMAC__) && defined(_DEBUG))     // TODO: implement this for other platforms
        // GDB can't attach to applications which are running as a different user   
        //  or group, so fix up data with current user and group during debugging
        if (check_security(g_use_sandbox, true, NULL, 0)) {
            CreateBOINCUsersAndGroups();
            SetBOINCDataOwnersGroupsAndPermissions();
            SetBOINCAppOwnersGroupsAndPermissions(NULL);
        }
#endif
        iErrorCode = check_security(
            g_use_sandbox, true, path_to_error, sizeof(path_to_error)
        );
    }

    if (iErrorCode) {

        ShowApplication(true);

        if (iErrorCode == -1099) {
            strDialogMessage.Printf(
                _("You currently are not authorized to manage the client.\n\nTo run %s as this user, please:\n  - reinstall %s answering \"Yes\" to the question about\n     non-administrative users\n or\n  - contact your administrator to add you to the 'boinc_master'\n     user group."),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str()
            );
        } else {
            strDialogMessage.Printf(
                _("%s ownership or permissions are not set properly; please reinstall %s.\n(Error code %d"),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
                iErrorCode
            );
            if (path_to_error[0]) {
                strDialogMessage += _(" at ");
                strDialogMessage += wxString::FromUTF8(path_to_error);
            }
            strDialogMessage += _(")");
            
            fprintf(stderr, "%s\n", (const char*)strDialogMessage.utf8_str());
        }

        wxMessageDialog* pDlg = new wxMessageDialog(
                                    NULL, 
                                    strDialogMessage, 
                                    m_pSkinManager->GetAdvanced()->GetApplicationName(), 
                                    wxOK
                                    );

        pDlg->ShowModal();
        if (pDlg)
            pDlg->Destroy();

        return false;
    }
#endif      // SANDBOX


#ifdef __WXMSW__
    // Perform any last minute checks that should keep the manager
    // from starting up.
    wxString strRebootPendingFile = 
        GetRootDirectory() + wxFileName::GetPathSeparator() + wxT("RebootPending.txt");
    
    if (wxFile::Exists(strRebootPendingFile)) {
        wxMessageDialog dialog(
            NULL,
            _("A reboot is required in order for BOINC to run properly.\nPlease reboot your computer and try again."),
            _("BOINC Manager"),
            wxOK|wxICON_ERROR
        );

        dialog.ShowModal();
        return false;
    }
#endif

    // Detect if BOINC Manager is already running, if so, bring it into the
    // foreground and then exit.
    if (!m_bMultipleInstancesOK) {
        if (DetectDuplicateInstance()) {
            return false;
        }
    }

    // Initialize the main document
    m_pDocument = new CMainDocument();
    wxASSERT(m_pDocument);

    m_pDocument->OnInit();


    // Is there a condition in which the Simple GUI should not be used?
    if (BOINC_SIMPLEGUI == m_iGUISelected) {
        // Screen too small?
        if (wxGetDisplaySize().GetHeight() < 600) {
            m_iGUISelected = BOINC_ADVANCEDGUI;
        }
    }


    // Initialize the task bar icon
	m_pTaskBarIcon = new CTaskBarIcon(
        m_pSkinManager->GetAdvanced()->GetApplicationName(), 
        m_pSkinManager->GetAdvanced()->GetApplicationIcon(),
        m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(),
        m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon()
#ifdef __WXMAC__
        , wxTBI_CUSTOM_STATUSITEM
#endif
    );
#ifdef __WXMAC__
    m_pMacDockIcon = new CTaskBarIcon(
        m_pSkinManager->GetAdvanced()->GetApplicationName(), 
        m_pSkinManager->GetAdvanced()->GetApplicationIcon(),
        m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(),
        m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon()
        , wxTBI_DOCK
    );
    wxASSERT(m_pMacDockIcon);
#endif
    wxASSERT(m_pTaskBarIcon);

    // Startup the System Idle Detection code
    IdleTrackerAttach();
    
#ifdef __WXMAC__
    ProcessSerialNumber psn;
    ProcessInfoRec pInfo;
    OSStatus err;
    
    memset(&pInfo, 0, sizeof(pInfo));
    pInfo.processInfoLength = sizeof( ProcessInfoRec );
    err = GetProcessInformation(&m_psnCurrentProcess, &pInfo);
    if (!err) {
        psn = pInfo.processLauncher;
        memset(&pInfo, 0, sizeof(pInfo));
        pInfo.processInfoLength = sizeof( ProcessInfoRec );
        err = GetProcessInformation(&psn, &pInfo);
    }
    // Don't open main window if we were started automatically at login
    if (pInfo.processSignature == 'lgnw') {  // Login Window app
        m_bGUIVisible = false;

        // If the system was just started, we usually get a "Connection 
        // failed" error if we try to connect too soon, so delay a bit.
        sleep(10);
    }
#endif

    // Show the UI
    SetActiveGUI(m_iGUISelected, m_bGUIVisible);

    if (!m_bGUIVisible) {
#ifdef __WXMAC__
        // We don't call Hide() or Show(false) for the main frame
        // under wxCocoa 2.9.5 because it bounces the Dock icon
        // (as in notification.)  We work around this by moving
        // the main window/frame off screen here.
        // The position will be restored in one of these methods:
        // CBOINCGUIApp::OnActivateApp(), CSimpleFrame::SaveState()
        // or CAdvancedFrame::SaveWindowDimensions().
        if (m_pFrame) {
            m_pFrame->MoveFrameOffScreen();
            m_pFrame->Show();
        }
#endif
        ShowApplication(false);
	}

    if (bOpenEventLog) {
        DisplayEventLog(m_bGUIVisible);
        if (m_bGUIVisible && m_pFrame) {
            m_pFrame->Raise();
        }
    }
    
    return true;
}
Пример #24
0
void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
{
    wxString EnvLang;

    m_Id = aId;
    m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) + wxGetUserId() );

    // Init KiCad environment
    // the environment variable KICAD (if exists) gives the kicad path:
    // something like set KICAD=d:\kicad
    bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv );

    if( isDefined )    // ensure m_KicadEnv ends by "/"
    {
        m_KicadEnv.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        if( !m_KicadEnv.IsEmpty() && m_KicadEnv.Last() != '/' )
            m_KicadEnv += UNIX_STRING_DIR_SEP;
    }

    // Prepare On Line Help. Use only lower case for help file names, in order to
    // avoid problems with upper/lower case file names under windows and unix.
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
    m_HelpFileName = aName.Lower() + wxT( ".html" );
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
    m_HelpFileName = aName.Lower() + wxT( ".pdf" );
#else
    #error Help files format not defined
#endif

    // Init parameters for configuration
    SetVendorName( wxT( "KiCad" ) );
    SetAppName( aName.Lower() );
    SetTitle( aName );
    m_settings = new wxConfig();
    wxASSERT( m_settings != NULL );
    m_commonSettings = new wxConfig( CommonConfigPath );
    wxASSERT( m_commonSettings != NULL );

    // Install some image handlers, mainly for help
    wxImage::AddHandler( new wxPNGHandler );
    wxImage::AddHandler( new wxGIFHandler );
    wxImage::AddHandler( new wxJPEGHandler );
    wxFileSystem::AddHandler( new wxZipFSHandler );

    // Analyze the command line & init binary path
    SetBinDir();
    SetDefaultSearchPaths();
    SetLanguagePath();
    ReadPdfBrowserInfos();

    // Internationalization: loading the kicad suitable Dictionary
    wxString languageSel;
    m_commonSettings->Read( languageCfgKey, &languageSel);
    m_LanguageId = wxLANGUAGE_DEFAULT;

    // Search for the current selection
    for( unsigned int ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    {
        if( s_Language_List[ii].m_Lang_Label == languageSel )
        {
            m_LanguageId = s_Language_List[ii].m_WX_Lang_Identifier;
            break;
        }
    }

    bool succes = SetLanguage( true );

    if( !succes )
    {
    }

    // Set locale option for separator used in float numbers
    SetLocaleTo_Default();
}
Пример #25
0
bool PoeditApp::OnInit()
{
    if (!wxApp::OnInit())
        return false;

#if defined(__WXMAC__)
    wxSystemOptions::SetOption(wxMAC_TEXTCONTROL_USE_SPELL_CHECKER, 1);
#endif

#ifdef __WXMAC__
    SetExitOnFrameDelete(false);
#endif

#if defined(__UNIX__) && !defined(__WXMAC__)
    wxStandardPaths::Get().SetInstallPrefix(POEDIT_PREFIX);

    wxString home = wxGetHomeDir() + "/";

    // create Poedit cfg dir, move ~/.poedit to ~/.poedit/config
    // (upgrade from older versions of Poedit which used ~/.poedit file)
    if (!wxDirExists(home + ".poedit"))
    {
        if (wxFileExists(home + ".poedit"))
            wxRenameFile(home + ".poedit", home + ".poedit2");
        wxMkdir(home + ".poedit");
        if (wxFileExists(home + ".poedit2"))
            wxRenameFile(home + ".poedit2", home + ".poedit/config");
    }
#endif

    SetVendorName("Vaclav Slavik");
    SetAppName("Poedit");

#if defined(__WXMAC__)
    #define CFG_FILE (wxStandardPaths::Get().GetUserConfigDir() + "/net.poedit.Poedit.cfg")
#elif defined(__UNIX__)
    #define CFG_FILE (home + ".poedit/config")
#else
    #define CFG_FILE wxEmptyString
#endif

#ifdef __WXMAC__
    // upgrade from the old location of config file:
    wxString oldcfgfile = wxStandardPaths::Get().GetUserConfigDir() + "/poedit.cfg";
    if (wxFileExists(oldcfgfile) && !wxFileExists(CFG_FILE))
    {
        wxRenameFile(oldcfgfile, CFG_FILE);
    }
#endif

    wxConfigBase::Set(
        new wxConfig(wxEmptyString, wxEmptyString, CFG_FILE, wxEmptyString, 
                     wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_LOCAL_FILE));
    wxConfigBase::Get()->SetExpandEnvVars(false);

    wxImage::AddHandler(new wxPNGHandler);
    wxXmlResource::Get()->InitAllHandlers();

#if defined(__WXMAC__)
    wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "/*.xrc");
#elif defined(__WXMSW__)
	wxStandardPaths::Get().DontIgnoreAppSubDir();
    wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "\\Resources\\*.xrc");
#else
    InitXmlResource();
#endif

    SetDefaultCfg(wxConfig::Get());

#if defined(__WXMAC__) || defined(__WXMSW__)
    u_setDataDirectory(wxStandardPaths::Get().GetResourcesDir().mb_str());
#endif

#ifndef __WXMAC__
    wxArtProvider::PushBack(new PoeditArtProvider);
#endif

    SetupLanguage();

#ifdef __WXMAC__
    wxMenuBar *bar = wxXmlResource::Get()->LoadMenuBar("mainmenu_mac_global");
    TweakOSXMenuBar(bar);
    wxMenuBar::MacSetCommonMenuBar(bar);
    // so that help menu is correctly merged with system-provided menu
    // (see http://sourceforge.net/tracker/index.php?func=detail&aid=1600747&group_id=9863&atid=309863)
    s_macHelpMenuTitleName = _("&Help");
#endif

    FileHistory().Load(*wxConfig::Get());

    // NB: It's important to do this before TM is used for the first time.
    if ( !MigrateLegacyTranslationMemory() )
        return false;

    // NB: opening files or creating empty window is handled differently on
    //     Macs, using MacOpenFiles() and MacNewFile(), so don't create empty
    //     window if no files are given on command line; but still support
    //     passing files on command line
    if (!gs_filesToOpen.empty())
    {
        OpenFiles(gs_filesToOpen);
        gs_filesToOpen.clear();
    }
#ifndef __WXMAC__
    else
    {
        OpenNewFile();
    }
#endif // !__WXMAC__

#ifdef USE_SPARKLE
    Sparkle_Initialize(CheckForBetaUpdates());
#endif // USE_SPARKLE

#ifdef __WXMSW__
    const char *appcast = "http://releases.poedit.net/appcast-win";

    if ( CheckForBetaUpdates() )
    {
        // Beta versions use unstable feed.
        appcast = "http://releases.poedit.net/appcast-win/beta";
    }

    win_sparkle_set_appcast_url(appcast);
    win_sparkle_init();
#endif

    return true;
}
Пример #26
0
bool CDStarRepeaterApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	if (!wxApp::OnInit())
		return false;

	if (!m_nolog) {
		wxString logBaseName = LOG_BASE_NAME;
		if (!m_name.IsEmpty()) {
			logBaseName.Append(wxT("_"));
			logBaseName.Append(m_name);
		}

#if defined(__WINDOWS__)
		if (m_logDir.IsEmpty())
			m_logDir = ::wxGetHomeDir();
#else
		if (m_logDir.IsEmpty())
			m_logDir = wxT(LOG_DIR);
#endif

		wxLog* log = new CLogger(m_logDir, logBaseName);
		wxLog::SetActiveTarget(log);
	} else {
		new wxLogNull;
	}

	m_logChain = new wxLogChain(new CDStarRepeaterLogger);

	wxString appName;
	if (!m_name.IsEmpty())
		appName = APPLICATION_NAME + wxT(" ") + m_name;
	else
		appName = APPLICATION_NAME;

#if !defined(__WINDOWS__)
	appName.Replace(wxT(" "), wxT("_"));
	m_checker = new wxSingleInstanceChecker(appName, wxT("/tmp"));
#else
	m_checker = new wxSingleInstanceChecker(appName);
#endif

	bool ret = m_checker->IsAnotherRunning();
	if (ret) {
		wxLogError(wxT("Another copy of the D-Star Repeater is running, exiting"));
		return false;
	}

#if defined(__WINDOWS__)
	if (m_confDir.IsEmpty())
		m_confDir = ::wxGetHomeDir();

	m_config = new CDStarRepeaterConfig(new wxConfig(APPLICATION_NAME), m_confDir, CONFIG_FILE_NAME, m_name);
#else
	if (m_confDir.IsEmpty())
		m_confDir = wxT(CONF_DIR);

	m_config = new CDStarRepeaterConfig(m_confDir, CONFIG_FILE_NAME, m_name);
#endif

	wxString type;
	m_config->getModem(type);

	wxString frameName = APPLICATION_NAME + wxT(" (") + type + wxT(") - ");
	if (!m_name.IsEmpty()) {
		frameName.Append(m_name);
		frameName.Append(wxT(" - "));
	}
	frameName.Append(VERSION);

	wxPoint position = wxDefaultPosition;

	int x, y;
	m_config->getPosition(x, y);
	if (x >= 0 && y >= 0)
		position = wxPoint(x, y);

	m_frame = new CDStarRepeaterFrame(frameName, type, position, m_gui);
	m_frame->Show();

	SetTopWindow(m_frame);

	wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION);

	// Log the version of wxWidgets and the Operating System
	wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str());

	createThread();

	return true;
}
Пример #27
0
bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    ::wxInitAllImageHandlers();

    // Fill in the application information fields before creating wxConfig.
    SetVendorName("wxWidgets");
    SetAppName("wx_docview_sample");
    SetAppDisplayName("wxWidgets DocView Sample");

    //// Create a document manager
    wxDocManager *docManager = new wxDocManager;

    //// Create a template relating drawing documents to their views
    new wxDocTemplate(docManager, "Drawing", "*.drw", "", "drw",
                      "Drawing Doc", "Drawing View",
                      CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
#if defined( __WXMAC__ )  && wxOSX_USE_CARBON
    wxFileName::MacRegisterDefaultTypeAndCreator("drw" , 'WXMB' , 'WXMA');
#endif

    if ( m_mode == Mode_Single )
    {
        // If we've only got one window, we only get to edit one document at a
        // time. Therefore no text editing, just doodling.
        docManager->SetMaxDocsOpen(1);
    }
    else // multiple documents mode: allow documents of different types
    {
        // Create a template relating text documents to their views
        new wxDocTemplate(docManager, "Text", "*.txt;*.text", "", "txt;text",
                          "Text Doc", "Text View",
                          CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
#if defined( __WXMAC__ ) && wxOSX_USE_CARBON
        wxFileName::MacRegisterDefaultTypeAndCreator("txt" , 'TEXT' , 'WXMA');
#endif
        // Create a template relating image documents to their views
        new wxDocTemplate(docManager, "Image", "*.png;*.jpg", "", "png;jpg",
                          "Image Doc", "Image View",
                          CLASSINFO(ImageDocument), CLASSINFO(ImageView));
    }

    // create the main frame window
    wxFrame *frame;
#if wxUSE_MDI_ARCHITECTURE
    if ( m_mode == Mode_MDI )
    {
        frame = new wxDocMDIParentFrame(docManager, NULL, wxID_ANY,
                                        GetAppDisplayName(),
                                        wxDefaultPosition,
                                        wxSize(500, 400));
    }
    else
#endif // wxUSE_MDI_ARCHITECTURE
    {
        frame = new wxDocParentFrame(docManager, NULL, wxID_ANY,
                                     GetAppDisplayName(),
                                     wxDefaultPosition,
                                     wxSize(500, 400));
    }

    // and its menu bar
    wxMenu *menuFile = new wxMenu;

    menuFile->Append(wxID_NEW);
    menuFile->Append(wxID_OPEN);

    if ( m_mode == Mode_Single )
        AppendDocumentFileCommands(menuFile, true);

    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);

    // A nice touch: a history of files visited. Use this menu.
    docManager->FileHistoryUseMenu(menuFile);
#if wxUSE_CONFIG
    docManager->FileHistoryLoad(*wxConfig::Get());
#endif // wxUSE_CONFIG


    if ( m_mode == Mode_Single )
    {
        m_canvas = new MyCanvas(NULL, frame);
        m_menuEdit = CreateDrawingEditMenu();
    }

    CreateMenuBarForFrame(frame, menuFile, m_menuEdit);

    frame->SetIcon(wxICON(doc));
    frame->Centre();
    frame->Show();

    if ( m_filesFromCmdLine.empty() )
    {
        docManager->CreateNewDocument();
    }
    else // we have files to open on command line
    {
        for ( size_t i = 0; i != m_filesFromCmdLine.size(); ++i )
            docManager->CreateDocument(m_filesFromCmdLine[i], wxDOC_SILENT);
    }

    return true;
}
Пример #28
0
bool PhdApp::OnInit()
{
    if (!wxApp::OnInit())
    {
        return false;
    }

    m_instanceChecker = new wxSingleInstanceChecker(wxString::Format("%s.%ld", GetAppName(), m_instanceNumber));
    if (m_instanceChecker->IsAnotherRunning())
    {
        wxLogError(wxString::Format(_("PHD2 instance %ld is already running. Use the "
            "-i INSTANCE_NUM command-line option to start a different instance."), m_instanceNumber));
        delete m_instanceChecker; // OnExit() won't be called if we return false
        m_instanceChecker = 0;
        return false;
    }

#ifndef DEBUG
    #if (wxMAJOR_VERSION > 2 || wxMINOR_VERSION > 8)
    wxDisableAsserts();
    #endif
#endif

    SetVendorName(_T("StarkLabs"));
    // use SetAppName() to ensure the local data directory is found even if the name of the executable is changed
#ifdef __APPLE__
    SetAppName(_T("PHD2"));
#else
    SetAppName(_T("phd2"));
#endif
    pConfig = new PhdConfig(_T("PHDGuidingV2"), m_instanceNumber);

    Debug.Init("debug", true);

    Debug.AddLine(wxString::Format("PHD2 version %s begins execution with:", FULLVER));
    Debug.AddLine(wxString::Format("   %s", wxVERSION_STRING));
    float dummy;
    Debug.AddLine(wxString::Format("   cfitsio %.2lf", ffvers(&dummy)));
#if defined(CV_VERSION)
    Debug.AddLine(wxString::Format("   opencv %s", CV_VERSION));
#endif

#if defined(__WINDOWS__)
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    Debug.AddLine("CoInitializeEx returns %x", hr);
#endif

    DisableOSXAppNap();

    if (m_resetConfig)
    {
        pConfig->DeleteAll();
    }

    wxString ldir = wxStandardPaths::Get().GetResourcesDir() + PATHSEPSTR "locale";
    if (!wxDirExists(ldir))
    {
        // for development environments
        ldir = _T("locale");
    }
    bool ex = wxDirExists(ldir);
    Debug.AddLine(wxString::Format("Using Locale Dir %s exists=%d", ldir, ex));
    wxLocale::AddCatalogLookupPathPrefix(ldir);
    m_localeDir = ldir;

    m_locale.Init(pConfig->Global.GetInt("/wxLanguage", wxLANGUAGE_DEFAULT));
    if (!m_locale.AddCatalog(PHD_MESSAGES_CATALOG))
    {
        Debug.AddLine("locale.AddCatalog failed");
    }
    wxSetlocale(LC_NUMERIC, "C");

    Debug.RemoveOldFiles();
    GuideLog.RemoveOldFiles();

    pConfig->InitializeProfile();

    PhdController::OnAppInit();

    wxImage::AddHandler(new wxJPEGHandler);
    wxImage::AddHandler(new wxPNGHandler);

    pFrame = new MyFrame(m_instanceNumber, &m_locale);

    pFrame->Show(true);

    if (pConfig->IsNewInstance() || (pConfig->NumProfiles() == 1 && pFrame->pGearDialog->IsEmptyProfile()))
    {
        pFrame->pGearDialog->ShowProfileWizard();               // First-light version of profile wizard
    }

    return true;
}
Пример #29
0
bool hvApp::OnInit()
{
#ifdef __WXMOTIF__
    delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
#endif

    // Don't exit on frame deletion, since the help window is programmed
    // to cause the app to exit even if it is still open. We need to have the app
    // close by other means.
    SetExitOnFrameDelete(false);

    wxArtProvider::Push(new AlternateArtProvider);

#ifdef __WXMAC__
    wxApp::s_macAboutMenuItemId = wxID_ABOUT;
    wxFileName::MacRegisterDefaultTypeAndCreator( wxT("htb") , 'HTBD' , 'HTBA' ) ;
#endif

    int istyle = wxHF_DEFAULT_STYLE|wxHF_OPEN_FILES;

    wxString service, windowName, titleFormat, argStr;
    wxString book[10];
    int bookCount = 0;
    int i;
    bool hasService = false;
    bool hasWindowName = false;
    bool createServer = false;

#if wxUSE_IPC
    m_server = NULL;
#endif

    // Help books are recognized by extension ".hhp" ".htb" or ".zip".
    // Service and window_name can occur anywhere in arguments,
    // but service must be first
    // Other arguments (topic?) could be added

    //  modes of operation:
    //  1) no arguments - stand alone, prompt user for book
    //  2) books only - stand alone, open books
    //  3) "--server" as (any) arg - start connection with default service;
    //     also open any books passed as other arguments
    //  4) at least one argument which is not book, and not "--server" - take first
    //     such argument as service, second (if present) as window name,
    //     start service, open any books

    for( i=1; i<argc; i++ )
    {
        argStr = argv[i];

        if ( argStr.Find( wxT(".hhp") ) >= 0
                || argStr.Find( wxT(".htb") ) >= 0
                || argStr.Find( wxT(".zip") ) >= 0 )
        {
            book[bookCount] = argStr;
            bookCount++;
        }
        else if ( argStr == wxT("--server") )
        {
            createServer = true;
#if defined(__WXMSW__)
            service = wxT("generic_helpservice");
#elif defined(__UNIX__)
            service = wxT("/tmp/") + wxString(wxT("generic_helpservice"));
#else
            service = wxT("4242");
#endif
        }
        else if ( !hasService )
        {
            service = argStr;
            hasService = true;
            createServer = true;
        }
        else if ( !hasWindowName )
        {
            windowName = argStr;
            hasWindowName = true;
        }
        else if ( argStr.Find( wxT("--Style") )  >= 0 )
        {
            long i;
            wxString numb = argStr.AfterLast(wxT('e'));
            if ( !(numb.ToLong(&i) ) )
            {
                wxLogError( wxT("Integer conversion failed for --Style") );
            }
            else
            {
                istyle = i;
            }
        }
        else
        {
            //unknown - could be topic?
        }
    }

    // No book - query user; but not on Mac, since there
    // may be an AppleEvent to open a document on the way
#ifndef __WXMAC__
    if ( bookCount < 1 )
    {
        wxString s = wxFileSelector( wxT("Open help file"),
                                     wxGetCwd(),
                                     wxEmptyString,
                                     wxEmptyString,
                                     wxT("Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|HTML Help Project (*.hhp)|*.hhp"),
                                     wxFD_OPEN | wxFD_FILE_MUST_EXIST,
                                     NULL);

        if (!s.empty())
        {
            book[0] = s;
            bookCount = 1;
        }
    }
#endif

#if wxUSE_IPC

    if ( createServer )
    {
        // Create a new server
        m_server = new hvServer;

        if ( !m_server->Create(service) )
        {
            wxString wxm = wxT("Server Create failed - service: ");
            wxString xxm = wxm << service;
            wxLogError( xxm );
            //if MSW quits here, probably another copy already exists
            return false;
        }
        createServer = false;
        wxUnusedVar(createServer);
    }

#endif  // wxUSE_IPC

    //now add help
    wxInitAllImageHandlers();
    wxFileSystem::AddHandler(new wxZipFSHandler);

    SetVendorName(wxT("wxWidgets") );
    SetAppName(wxT("wxHTMLHelpServer") );
    wxConfig::Get(); // create an instance

    m_helpController = new wxHtmlHelpController( istyle );

    if ( !hasWindowName )
    {
        titleFormat = wxT("Help: %s") ;
    }
    else
    {
        //remove underscores
        windowName.Replace( wxT("_"), wxT(" ") );
        titleFormat = windowName;
    }

    m_helpController->SetTitleFormat( titleFormat );

    for( i=0; i<bookCount; i++ )
    {
        wxFileName fileName(book[i]);
        m_helpController->AddBook(fileName);
    }

#ifdef __WXMOTIF__
    delete wxLog::SetActiveTarget(new wxLogGui);
#endif

    m_helpController->DisplayContents();
    SetTopWindow(m_helpController->GetFrame());
    m_exitIfNoMainWindow = true;

    return true;
}
bool CTimerControlApp::OnInit()
{
	SetVendorName(VENDOR_NAME);

	if (!wxApp::OnInit())
		return false;

	if (!m_nolog) {
		wxString logBaseName = LOG_BASE_NAME;
		if (!m_name.IsEmpty()) {
			logBaseName.Append(wxT("_"));
			logBaseName.Append(m_name);
		}

		if (m_logDir.IsEmpty())
			m_logDir = wxFileName::GetHomeDir();

		wxLog* log = new CLogger(m_logDir, logBaseName);
		wxLog::SetActiveTarget(log);
	} else {
		new wxLogNull;
	}

#if defined(__WINDOWS__)
	m_config = new CTimerControlConfig(new wxConfig(APPLICATION_NAME), m_name);
#else
	if (m_confDir.IsEmpty())
		m_confDir = CONF_DIR;

	m_config = new CTimerControlConfig(m_confDir, m_name);
#endif

	wxString frameName = APPLICATION_NAME + wxT(" - ");
	if (!m_name.IsEmpty()) {
		frameName.Append(m_name);
		frameName.Append(wxT(" - "));
	}
	frameName.Append(VERSION);

	if (!m_name.IsEmpty()) {
		wxString fileBase = SCHEDULE_BASE_NAME;
		fileBase.Append(wxT("_"));
		fileBase.Append(m_name);
		fileBase.Replace(wxT(" "), wxT("_"));

		wxString dir = m_confDir;
		if (dir.IsEmpty())
			dir = wxFileName::GetHomeDir();

		wxFileName fileName(dir, fileBase, wxT("dat"));
		m_fileName = fileName.GetFullPath();
	} else {
		wxString dir = m_confDir;
		if (dir.IsEmpty())
			dir = wxFileName::GetHomeDir();

		wxFileName fileName(dir, SCHEDULE_BASE_NAME, wxT("dat"));
		m_fileName = fileName.GetFullPath();
	}

	wxPoint position = wxDefaultPosition;

	int x, y;
	getPosition(x, y);
	if (x >= 0 && y >= 0)
		position = wxPoint(x, y);

	bool delay;
	getDelay(delay);

	m_frame = new CTimerControlFrame(frameName, position, delay);
	m_frame->Show();

	SetTopWindow(m_frame);

	wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION);

	// Log the SVN revsion and the version of wxWidgets and the Operating System
	wxLogInfo(SVNREV);
	wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str());

	createThread();

	return wxApp::OnInit();
}