Exemplo n.º 1
0
void gecomapi_pi::UpdateAuiStatus(void)
{
      //    This method is called after the PlugIn is initialized
      //    and the frame has done its initial layout, possibly from a saved wxAuiManager "Perspective"
      //    It is a chance for the PlugIn to syncronize itself internally with the state of any Panes that
      //    were added to the frame in the PlugIn ctor.

      //    We use this callback here to keep the context menu selection in sync with the window state

      wxAuiPaneInfo &pane = m_pauimgr->GetPane(m_pgecomapi_window);
      if(!pane.IsOk())
            return;

      if (m_bstartHidden)
            pane.Show(false); 
      else if (pane.IsShown())
            m_pgecomapi_window->GEInitialize();
      if (pane.IsFloating())
            pane.frame->SetTransparent(m_iOpacity);
      m_pgecomapi_window->SetSize(m_iWindowWidth, m_iWindowHeight);
      pane.BestSize(m_iWindowWidth, m_iWindowHeight);
      m_pauimgr->Update();

      SetToolbarItemState(m_toolbar_item_id, pane.IsShown());
}
Exemplo n.º 2
0
void objsearch_pi::OnToolbarToolCallback ( int id )
{
    SetToolbarItemState( id, false );
    m_pObjSearchDialog->ClearFeatures();
    for(std::map<wxString, int>::iterator it = m_featuresInDb.begin(); it != m_featuresInDb.end(); ++it)
        m_pObjSearchDialog->AddFeature(it->first);
    
    m_pObjSearchDialog->Show();
}
Exemplo n.º 3
0
void GEUIDialog::OnShow(wxShowEvent& event)
{
      LogDebugMessage(_T("GE plugin - OnShow event"));
      if(m_ballowStart)
            GEInitialize();
      SetToolbarItemState(m_toolbar_item_id, IsShown());
      
      event.Skip();
}
Exemplo n.º 4
0
void gecomapi_pi::OnToolbarToolCallback(int id)
{
      if(NULL == m_pgecomapi_window)
            return;

      wxAuiPaneInfo &pane = m_pauimgr->GetPane(m_pgecomapi_window);
      if(!pane.IsOk())
            return;
      m_pgecomapi_window->m_ballowStart = true;

      pane.Show(!pane.IsShown());
      // Toggle is handled by the toolbar but we must keep plugin manager b_toggle updated
      // to actual status to ensure right status upon toolbar rebuild
      SetToolbarItemState(m_toolbar_item_id, pane.IsShown());
      
      if (NULL != m_pgecomapi_window->app)
      {
            if (!pane.IsShown())
            {
                  m_iWindowWidth = m_pgecomapi_window->GetSize().GetWidth();
                  m_iWindowHeight = m_pgecomapi_window->GetSize().GetHeight();
                  pane.window->SetSize(m_iWindowWidth, m_iWindowHeight);
                  pane.BestSize(m_iWindowWidth, m_iWindowHeight);
                  m_pgecomapi_window->GEAttachWindow(false);
            }
            else
            {
                    pane.window->SetSize(m_iWindowWidth, m_iWindowHeight);
                    pane.BestSize(m_iWindowWidth, m_iWindowHeight);
                    m_pgecomapi_window->GEAttachWindow(true);
            }
      }
      else
      {
            if (pane.IsShown())
            {
                  m_pgecomapi_window->m_pfocusedwindow = wxWindow::FindFocus();
                  m_pgecomapi_window->GEInitialize();
                  ApplyConfig();
            }
      }
      m_pauimgr->Update();
}
Exemplo n.º 5
0
void vdr_pi::OnToolbarToolCallback(int id)
{
      if ( id == m_tb_item_id_play )
      {
            if ( IsRunning() ) // Timer started?
            {
                  Stop(); // Stop timer
                  m_istream.Close();

                  if ( m_pvdrcontrol )
                  {
                        m_pauimgr->DetachPane( m_pvdrcontrol );
                        m_pvdrcontrol->Close();
                        m_pvdrcontrol->Destroy();
                        m_pvdrcontrol = NULL;
                  }
                  SetToolbarItemState( id, false );
            }
            else
            {
                  wxFileDialog fdlg( GetOCPNCanvasWindow(), _("Choose a file"), wxT(""), m_ifilename, wxT("*.*"), wxFD_OPEN|wxFD_FILE_MUST_EXIST );
                  if ( fdlg.ShowModal() != wxID_OK)
                  {
                        SetToolbarItemState( id, false );
                        return;
                  }
                  m_ifilename.Clear();
                  m_ifilename = fdlg.GetPath();

                  m_istream.Open( m_ifilename );
                  Start( m_interval, wxTIMER_CONTINUOUS ); // start timer
      
                  if (! m_pvdrcontrol )
                  {
                        m_pvdrcontrol = new VDRControl( GetOCPNCanvasWindow(), wxID_ANY, this, 1000/m_interval, m_istream.GetLineCount() );
                      wxAuiPaneInfo pane = wxAuiPaneInfo().Name(_T("VDR")).Caption(wxString::Format(_("VDR replay: %s"), fdlg.GetFilename())).CaptionVisible(true).Float().FloatingPosition(50,100).Dockable(false).Fixed().CloseButton(false).Show(true);
                        m_pauimgr->AddPane( m_pvdrcontrol, pane );
                        m_pauimgr->Update();
                  }

                  SetToolbarItemState( id, true );
            }
      }
      else if ( id == m_tb_item_id_record )
      {
            if ( m_recording )
            {
                  m_ostream.Close();
                  m_recording = false;

                  SetToolbarItemState( id, false );
            }
            else
            {
                  wxFileDialog fdlg( GetOCPNCanvasWindow(), _("Choose a file"), wxT(""), m_ofilename, wxT("*.*"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT );
                  if ( fdlg.ShowModal() != wxID_OK)
                  {
                        SetToolbarItemState( id, false );
                        return;
                  }
                  m_ofilename.Clear();
                  m_ofilename = fdlg.GetPath();

                  //m_ostream.Open( m_ofilename, wxFile::write_append );
                  m_ostream.Open( m_ofilename, wxFile::write );
                  m_recording = true;

                  SetToolbarItemState( id, true );
            }
      }
}
Exemplo n.º 6
0
void grib_pi::OnToolbarToolCallback(int id)
{
    if( !::wxIsBusy() ) ::wxBeginBusyCursor();

    bool starting = false;

    double scale_factor = GetOCPNGUIToolScaleFactor_PlugIn();
    if( scale_factor != m_GUIScaleFactor ) starting = true;

    m_GUIScaleFactor = scale_factor;
    
    if(!m_pGribCtrlBar)
    {
        starting = true;
        long style = m_DialogStyle == ATTACHED_HAS_CAPTION ? wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU : wxBORDER_NONE|wxSYSTEM_MENU;
        m_pGribCtrlBar = new GRIBUICtrlBar(m_parent_window, wxID_ANY, wxEmptyString, wxDefaultPosition,
                wxDefaultSize, style, this);
        m_pGribCtrlBar->SetScaledBitmap(m_GUIScaleFactor);
        
        wxMenu* dummy = new wxMenu(_T("Plugin"));
        wxMenuItem* table = new wxMenuItem( dummy, wxID_ANY, wxString( _("Weather table") ), wxEmptyString, wxITEM_NORMAL );
#ifdef __WXMSW__
        wxFont *qFont = OCPNGetFont(_("Menu"), 10);
        table->SetFont(*qFont);
#endif
        m_MenuItem = AddCanvasContextMenuItem(table, this);
        SetCanvasContextMenuItemViz(m_MenuItem, false);

        // Create the drawing factory
        m_pGRIBOverlayFactory = new GRIBOverlayFactory( *m_pGribCtrlBar );
        m_pGRIBOverlayFactory->SetTimeZone( m_bTimeZone );
        m_pGRIBOverlayFactory->SetParentSize( m_display_width, m_display_height);
        m_pGRIBOverlayFactory->SetSettings( m_bGRIBUseHiDef, m_bGRIBUseGradualColors );

        m_pGribCtrlBar->OpenFile( m_bLoadLastOpenFile == 0 );

    }

    if( m_pGribCtrlBar->GetFont() != *OCPNGetFont(_("Dialog"), 10) ) starting = true;

    //Toggle GRIB overlay display
    m_bShowGrib = !m_bShowGrib;

    //    Toggle dialog?
    if(m_bShowGrib) {
        if( starting ) {
            SetDialogFont( m_pGribCtrlBar );
	    m_pGribCtrlBar->SetScaledBitmap( m_GUIScaleFactor );
            m_pGribCtrlBar->SetDialogsStyleSizePosition( true );
            m_pGribCtrlBar->Refresh();
        } else {
            MoveDialog( m_pGribCtrlBar, GetCtrlBarXY(), wxPoint( 20, 60) );
            if( m_DialogStyle >> 1 == SEPARATED ) {
                MoveDialog( m_pGribCtrlBar->GetCDataDialog(), GetCursorDataXY(), wxPoint( 20, 170));
                m_pGribCtrlBar->GetCDataDialog()->Show( m_pGribCtrlBar->m_CDataIsShown );
                }
        }
        m_pGribCtrlBar->Show();
        if( m_pGribCtrlBar->m_bGRIBActiveFile ) {
            if( m_pGribCtrlBar->m_bGRIBActiveFile->IsOK() ) {
                ArrayOfGribRecordSets *rsa = m_pGribCtrlBar->m_bGRIBActiveFile->GetRecordSetArrayPtr();
                if(rsa->GetCount() > 1) SetCanvasContextMenuItemViz( m_MenuItem, true);
            }
        }
        // Toggle is handled by the CtrlBar but we must keep plugin manager b_toggle updated
        // to actual status to ensure correct status upon CtrlBar rebuild
        SetToolbarItemState( m_leftclick_tool_id, m_bShowGrib );
        RequestRefresh(m_parent_window); // refresh main window
    } else
Exemplo n.º 7
0
void osm_pi::OnToolbarToolCallback(int id)
{
    wxLogMessage (_T("OSM_PI: OnToolbarToolCallback\n"));
    
      // Qualify the GRIB dialog position
            bool b_reset_pos = false;


#ifdef __WXMSW__
        //  Support MultiMonitor setups which an allow negative window positions.
        //  If the requested window does not intersect any installed monitor,
        //  then default to simple primary monitor positioning.
            RECT frame_title_rect;
            frame_title_rect.left =   m_osm_dialog_x;
            frame_title_rect.top =    m_osm_dialog_y;
            frame_title_rect.right =  m_osm_dialog_x + m_osm_dialog_sx;
            frame_title_rect.bottom = m_osm_dialog_y + 30;


            if(NULL == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL))
                  b_reset_pos = true;
#else
       //    Make sure drag bar (title bar) of window on Client Area of screen, with a little slop...
            wxRect window_title_rect;                    // conservative estimate
            window_title_rect.x = m_osm_dialog_x;
            window_title_rect.y = m_osm_dialog_y;
            window_title_rect.width = m_osm_dialog_sx;
            window_title_rect.height = 30;

            wxRect ClientRect = wxGetClientDisplayRect();
            ClientRect.Deflate(60, 60);      // Prevent the new window from being too close to the edge
            if(!ClientRect.Intersects(window_title_rect))
                  b_reset_pos = true;

#endif

            if(b_reset_pos)
            {
                  m_osm_dialog_x = 20;
                  m_osm_dialog_y = 170;
                  m_osm_dialog_sx = 200;
                  m_osm_dialog_sy = 200;
            }


      // show the OSM dialog
      if(NULL == m_pOsmDialog)
      {
            m_pOsmDialog = new OsmDlg(m_parent_window, -1, _("OSM Display Control"),
                               wxPoint( m_osm_dialog_x, m_osm_dialog_y), 
                               wxSize( m_osm_dialog_sx, m_osm_dialog_sy));
            m_pOsmDialog->plugin = this;
            //m_pOsmDialog->Create ( m_parent_window, this, -1, _("OSM Display Control"), m_grib_dir,
            //                   wxPoint( m_osm_dialog_x, m_osm_dialog_y), wxSize( m_osm_dialog_sx, m_osm_dialog_sy));
      }

      //Toggle OSM overlay display
      m_bShowOsm = !m_bShowOsm;

      //    Toggle dialog?
      m_pOsmDialog->Show(m_bShowOsm);

      // Toggle is handled by the toolbar but we must keep plugin manager b_toggle updated
      // to actual status to ensure correct status upon toolbar rebuild
      SetToolbarItemState( m_leftclick_tool_id, m_bShowOsm );

    
    
    
/* OLD CODE    
    // OSM Dialog (here we can select what types of objects to show)
    if(NULL == m_pOsmDialog)
    {
        m_pOsmDialog = new OsmDlg(m_parent_window);
        m_pOsmDialog->plugin = this;
        m_pOsmDialog->Move(wxPoint(m_osm_dialog_x, m_osm_dialog_y));
    }
    m_pOsmDialog->Show(!m_pOsmDialog->IsShown());
*/
    //
    // TODO: this needs to show a dialog which allow the user
    // to update their local database by pressing a button? Maybe?
    //DownloadUrl(m_api_url);
/*
    double x1 = m_pastVp.lon_min;
    double y1 = m_pastVp.lat_min;
    double x2 = m_pastVp.lon_max;
    double y2 = m_pastVp.lat_max;
    
    bool success = m_pDownloader->Download(x1,y1,x2,y2);
    if (success)
    {
        wxLogMessage (_T("OSM_PI: We have a file to play with...."));
        m_pOsmDb->ConsumeOsm(OsmDownloader::m_osm_path);
    }
*/
}
Exemplo n.º 8
0
void weather_routing_pi::ShowMenuItems(bool show)
{
    SetToolbarItemState( m_leftclick_tool_id, show );
    SetCanvasContextMenuItemViz(m_position_menu_id, show);
}