Exemplo n.º 1
0
GEUIDialog::GEUIDialog(wxWindow *pparent, wxWindowID id, wxAuiManager *auimgr, int tbitem, gecomapi_pi *ppi)
      :wxPanel(pparent, id, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, _T("GoogleEarth"))
{
      pPlugIn = ppi;
      LogDebugMessage(_T("Constructing the GE plugin window"));
      m_pauimgr = auimgr;
      m_toolbar_item_id = tbitem;
      m_ballowStart = false;
      m_bshouldcatchup = true;
      m_bbusy = false;

      m_pfocusedwindow = FindFocus();
      GEParentHwnd = NULL;

      this->SetSizeHints( wxDefaultSize, wxDefaultSize );

      itemBoxSizer = new wxBoxSizer(wxVERTICAL);
      SetSizerAndFit(itemBoxSizer);

      m_panel1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	itemBoxSizer->Add( m_panel1, 1, wxEXPAND | wxALL, 5 );

      itemBoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
      itemBoxSizer->Add(itemBoxSizer1, 0, wxEXPAND);

      m_cbConnected = new wxCheckBox( this, wxID_ANY, _("Connected to chart viewport"), wxDefaultPosition, wxDefaultSize, 0 );
	itemBoxSizer1->Add( m_cbConnected, 0, wxALIGN_RIGHT|wxALL, 10 );

      m_buttonSave = new wxButton( this, wxID_ANY, _("Save view..."), wxDefaultPosition, wxDefaultSize, 0 );
      itemBoxSizer1->Add( m_buttonSave, 0, wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT|wxTOP, 5 );
	
	this->Layout();
	
	this->Centre( wxBOTH );

      Connect(this->GetId(), wxEVT_SIZE, wxSizeEventHandler(GEUIDialog::OnSize));
      Connect(this->GetId(), wxEVT_SHOW, wxShowEventHandler(GEUIDialog::OnShow));
      
      app = NULL;

      m_bgeisuseable = false;
      m_binitializing = false;
      m_bclosed = false;
      m_bisfollowingboat = false;

      //LogDebugMessage(_T("GE plugin window created, going to start GE"));
      //GEInitialize();
      m_buttonSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GEUIDialog::SaveView ), NULL, this );
      m_cbConnected->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( GEUIDialog::ConnectedClicked ), NULL, this );

      ConnectToGE();

      m_stopwatch.Start();
      m_stopwatch_boat.Start();
      m_pPositions = new PositionsList();
      m_sEnvelopeKmlFilename = wxStandardPaths().GetTempDir() + _T("\\gecomapi.kml");
      m_sLiveKmlFilename = wxStandardPaths().GetTempDir() + _T("\\gecomapilive.kml");

      m_pdialog = new GESaveViewDlgImpl(this,  wxID_ANY, _("Save view"), wxDefaultPosition, wxSize( -1,-1 ), wxDEFAULT_DIALOG_STYLE );
}
Exemplo n.º 2
0
/**
 * Initialize the application
 */
bool MiniLaunchBar::OnInit() {
  //_CrtSetBreakAlloc(18609);  

  // Remove GUI log errors
  delete wxLog::SetActiveTarget(new wxLogStderr());

  #ifdef __WINDOWS__
  osInfo_.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  BOOL gotInfo = GetVersionEx(&osInfo_);
  if (!gotInfo) {
    osInfo_.dwMajorVersion = 5; // Assume Windows 2000
    osInfo_.dwMinorVersion = 0;
  }  
  #endif // __WINDOWS__

  TiXmlBase::SetCondenseWhiteSpace(false);

  singleInstanceChecker_ = NULL;
  mainFrame_ = NULL;
  locale_ = NULL;
  pluginManager_ = NULL;
  ftLibrary_ = NULL;
  ftFace_ = NULL;
  stopWatch_.Start();
  user_ = new User();

  allowedIconSizes_.push_back(SMALL_ICON_SIZE);
  allowedIconSizes_.push_back(MEDIUM_ICON_SIZE);
  allowedIconSizes_.push_back(LARGE_ICON_SIZE);
  allowedIconSizes_.push_back(EXTRA_LARGE_ICON_SIZE);

  // ***********************************************************************************
  // Initialize the command line object
  // ***********************************************************************************

  wxCmdLineEntryDesc cmdLineDesc[] = {
    { wxCMD_LINE_SWITCH, _T("u"), _T("useuserdatadir"), _("Uses user data directory to save settings.") },
    { wxCMD_LINE_OPTION, _T("d"), _T("datapath"),  _("Sets user data path (-u will be ignored)") },
    { wxCMD_LINE_SWITCH, _T("l"), _T("logwindow"), _("Displays the log window (useful for debugging)") },
    { wxCMD_LINE_SWITCH, _T("?"), _T("help"), _("Displays this help message") },
    { wxCMD_LINE_NONE }
  };

  fileCommandLine_.SetDesc(cmdLineDesc);  

  wxFileName executablePath = wxFileName(wxStandardPaths().GetExecutablePath());
  wxString applicationDirectory = executablePath.GetPath();
  wxString argumentsFilePath = applicationDirectory + _T("/Arguments.txt");

  if (wxFileName::FileExists(argumentsFilePath)) {

    wxTextFile file;
    bool success = file.Open(argumentsFilePath);
    if (!success) {
      ELOG(_T("Couldn't open ") + argumentsFilePath);
    } else {
      wxString line;
      wxString fileArgv;

      for (line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine()) {
        line = line.Trim(true).Trim(false);
        if (line == wxEmptyString) continue;        
        fileArgv += _T(" ") + line;        
      }

      fileCommandLine_.SetCmdLine(fileArgv);
      fileCommandLine_.Parse();
    }

  }

  commandLine_.SetDesc(cmdLineDesc);
  commandLine_.SetCmdLine(argc, argv);
  commandLine_.Parse(); 

  if (commandLine_.Found(_T("?"))) commandLine_.Usage();

  // Required to enable PNG support
  wxInitAllImageHandlers();

  // Setting this option to "0" removed the flickering.
  wxSystemOptions::SetOption(_T("msw.window.no-clip-children"), _T("0"));

  // ***********************************************************************************
  // Initialize the file paths
  // ***********************************************************************************

  FilePaths::InitializePaths();

  // If the setting file doesn't exist, assume it's the first time the app is launched
  isFirstLaunch_ = !wxFileName::FileExists(FilePaths::GetSettingsFile());

  // ***********************************************************************************
  // Initialize user
  // ***********************************************************************************

  GetUser()->Load();
  UserSettings* userSettings = GetUser()->GetSettings();

  // ***********************************************************************************
  // Initialize locale
  // ***********************************************************************************

  bool localeSet = false;

  wxLanguageInfo info;
  LNG(wxLANGUAGE_USER_DEFINED + 1, "an", LANG_SPANISH, SUBLANG_SPANISH, wxLayout_LeftToRight, "Aragonese");


  if (IsFirstLaunch()) {
    // If it is the first launch, try to detect the language

    int systemLanguage = wxLocale::GetSystemLanguage();
    
    if (systemLanguage != wxLANGUAGE_UNKNOWN) {
      const wxLanguageInfo* info = wxLocale::GetLanguageInfo(systemLanguage);
      if (info) {
        localeSet = ChangeLocale(info->CanonicalName);
        if (localeSet) {
          userSettings->SetString(_T("Locale"), Localization::Instance()->GetLanguageCodeOnly(info->CanonicalName));
        }
      }
    }
  } else {
    localeSet = ChangeLocale(userSettings->GetString(_T("Locale")));
  }
    
  if (!localeSet) {
    localeSet = ChangeLocale(_T("en"));
    if (!localeSet) {
      MessageBoxes::ShowError(_("Could not initialize locale."));
      ::wxExit();
    }
  }  

  // ***********************************************************************************
  // At this point, user settings are loaded
  // ***********************************************************************************

  if (userSettings->GetBool(_T("UniqueApplicationInstance"))) {
    const wxString name = wxString::Format(_T("%s-%s"), APPLICATION_NAME, wxGetUserId());
    singleInstanceChecker_ = new wxSingleInstanceChecker(name);

    if (singleInstanceChecker_->IsAnotherRunning()) {
      ILOG(_T("Another instance of the application is already running."));
      wxDELETE(singleInstanceChecker_);
      return false;
    }
  }

  // ***********************************************************************************
  // Load the skin file
  // ***********************************************************************************
  Styles::LoadSkinFile(FilePaths::GetSkinDirectory() + _T("/") + SKIN_FILE_NAME);

  // ***********************************************************************************
  // Create and initialize the main frame
  // ***********************************************************************************
  mainFrame_ = new MainFrame();
  mainFrame_->Show();
  mainFrame_->SetRotated(userSettings->GetBool(_T("Rotated")));  
  mainFrame_->UpdateTransparency();

  SetTopWindow(mainFrame_);

  if (IsFirstLaunch()) {
    user_->AddAutoAddExclusion(_T("*setup.exe"));
    user_->AddAutoAddExclusion(_T("*unins*.exe"));
    user_->AddAutoAddExclusion(_T("*installer.exe"));
    user_->AddAutoAddExclusion(_T("*unstall.exe"));
    user_->AddAutoAddExclusion(_T("*updater.exe"));
    user_->AddAutoAddExclusion(_T("*unwise.exe"));
    user_->AddAutoAddExclusion(_T("*uninst.exe"));
    user_->AddAutoAddExclusion(_T("*setup*.exe"));
    user_->AddAutoAddExclusion(_T("msiexec.exe"));
  } 

  if (userSettings->GetBool(_T("OptionPanelOpen"))) {
    mainFrame_->InvalidateLayout();
    mainFrame_->InvalidateMask();
    mainFrame_->Update();
    mainFrame_->OpenOptionPanel();
  }

  // ***********************************************************************************
  // Localize the main frame (this is going to recursively call
  // all the Localize() handlers)
  // ***********************************************************************************
  mainFrame_->Localize();  

  // Note: the rest of the initialization code is in MainFrame::OnIdle (on the first IDLE event)

  return true;
}