void grib_pi::MoveDialog(wxDialog *dialog, wxPoint position) { wxPoint p = GetOCPNCanvasWindow()->ScreenToClient(position); //Check and ensure there is always a "grabb" zone always visible wathever the dialoue size is. if (p.x + dialog->GetSize().GetX() > GetOCPNCanvasWindow()->GetClientSize().GetX()) p.x = GetOCPNCanvasWindow()->GetClientSize().GetX() - dialog->GetSize().GetX(); if (p.y + dialog->GetSize().GetY() > GetOCPNCanvasWindow()->GetClientSize().GetY()) p.y = GetOCPNCanvasWindow()->GetClientSize().GetY() - dialog->GetSize().GetY(); #ifdef __WXGTK__ dialog->Move(0, 0); #endif dialog->Move(GetOCPNCanvasWindow()->ClientToScreen(p)); }
int watchdog_pi::Init(void) { AddLocaleCatalog( PLUGIN_CATALOG_NAME ); Alarm::LoadConfigAll(); m_leftclick_tool_id = InsertPlugInTool (_T(""), _img_watchdog, _img_watchdog, wxITEM_NORMAL, _("Watchdog"), _T(""), NULL, WATCHDOG_TOOL_POSITION, 0, this); m_WatchdogDialog = NULL; m_ConfigurationDialog = NULL; m_PropertiesDialog = NULL; m_Timer.Connect(wxEVT_TIMER, wxTimerEventHandler ( watchdog_pi::OnTimer ), NULL, this); m_Timer.Start(3000); if(!m_WatchdogDialog) { m_WatchdogDialog = new WatchdogDialog(*this, GetOCPNCanvasWindow()); m_ConfigurationDialog = new ConfigurationDialog(*this, m_WatchdogDialog); wxIcon icon; icon.CopyFromBitmap(*_img_watchdog); m_WatchdogDialog->SetIcon(icon); m_ConfigurationDialog->SetIcon(icon); } m_bWatchdogDialogShown = false; return (WANTS_OVERLAY_CALLBACK | WANTS_OPENGL_OVERLAY_CALLBACK | WANTS_TOOLBAR_CALLBACK | WANTS_CURSOR_LATLON | WANTS_NMEA_SENTENCES | WANTS_NMEA_EVENTS | WANTS_AIS_SENTENCES | WANTS_PLUGIN_MESSAGING | WANTS_PREFERENCES | WANTS_CONFIG); }
int aisradar_pi::Init(void) { AddLocaleCatalog( _T("opencpn-aisradar_pi") ); m_radar_frame_x = m_radar_frame_y = 0; m_radar_frame_sx = m_radar_frame_sy = 200; m_pRadarFrame = 0; m_lat= m_lon=0.; m_cog= m_sog=0.; m_sats=0; ::wxDisplaySize(&m_display_width, &m_display_height); m_pconfig = GetOCPNConfigObject(); LoadConfig(); if (AisTargets) { // Init may be called more than once, check for cleanup WX_CLEAR_ARRAY(*AisTargets); delete AisTargets; } AisTargets = GetAISTargetArray(); m_parent_window = GetOCPNCanvasWindow(); if(m_radar_show_icon) { m_leftclick_tool_id = InsertPlugInTool(_T(""), _img_radar, _img_radar, wxITEM_NORMAL, wxString::Format(_T("AIS Radar View %d.%d"), PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR ), _T(""), 0, RADAR_TOOL_POSITION, 0, this ); } return (WANTS_TOOLBAR_CALLBACK | INSTALLS_TOOLBAR_TOOL | WANTS_CONFIG | WANTS_PREFERENCES | WANTS_AIS_SENTENCES | WANTS_NMEA_EVENTS | WANTS_PLUGIN_MESSAGING | USES_AUI_MANAGER ); }
int climatology_pi::Init() { AddLocaleCatalog( _T("opencpn-climatology_pi") ); // Set some default private member parameters m_climatology_dialog_x = 0; m_climatology_dialog_y = 0; m_climatology_dialog_sx = 200; m_climatology_dialog_sy = 400; ::wxDisplaySize(&m_display_width, &m_display_height); // Get a pointer to the opencpn configuration object m_pconfig = GetOCPNConfigObject(); // Get a pointer to the opencpn display canvas, to use as a parent for the dialog m_parent_window = GetOCPNCanvasWindow(); // This PlugIn needs a toolbar icon, so request its insertion if enabled locally #ifdef OCPN_USE_SVG m_leftclick_tool_id = InsertPlugInToolSVG( "Climatology" , _svg_climatology, _svg_climatology_rollover, _svg_climatology_toggled, wxITEM_CHECK, _("Climatology"), "" , NULL, CLIMATOLOGY_TOOL_POSITION, 0, this); #else m_leftclick_tool_id = InsertPlugInTool("", _img_climatology, _img_climatology, wxITEM_NORMAL, _("Climatology"), "", NULL, CLIMATOLOGY_TOOL_POSITION, 0, this); #endif SendClimatology(true); return (WANTS_OVERLAY_CALLBACK | WANTS_OPENGL_OVERLAY_CALLBACK | WANTS_CURSOR_LATLON | WANTS_TOOLBAR_CALLBACK | INSTALLS_TOOLBAR_TOOL | WANTS_CONFIG | WANTS_PLUGIN_MESSAGING ); }
void watchdog_pi::OnToolbarToolCallback(int id) { if(!m_WatchdogDialog) { m_WatchdogDialog = new WatchdogDialog(*this, GetOCPNCanvasWindow()); m_ConfigurationDialog = new ConfigurationDialog(*this, m_WatchdogDialog); wxIcon icon; icon.CopyFromBitmap(*_img_watchdog); m_WatchdogDialog->SetIcon(icon); m_ConfigurationDialog->SetIcon(icon); } m_WatchdogDialog->Show(!m_WatchdogDialog->IsShown()); if(m_WatchdogDialog->IsShown()) { m_bWatchdogDialogShown = true; m_WatchdogDialog->UpdateAlarms(); } wxPoint p = m_WatchdogDialog->GetPosition(); m_WatchdogDialog->Move(0, 0); // workaround for gtk autocentre dialog behavior m_WatchdogDialog->Move(p); }
iacfleet_pi::iacfleet_pi( void *ppimgr ) : opencpn_plugin_113( ppimgr ) { // Set some default private member parameters m_dialog_x = 0; m_dialog_y = 0; m_dialog_sx = 200; m_dialog_sy = 200; m_sort_type = SORT_NAME; m_dir = wxEmptyString; m_pDialog = NULL; m_pdc = NULL; m_bShowIcon = false; m_leftclick_tool_id = -1; // Get a pointer to the opencpn display canvas, to use as a parent for the GRIB dialog m_parent_window = GetOCPNCanvasWindow(); // Create the PlugIn icons initialize_images(); wxCurlBase::Init(); }
void PathProp::OnPathPropCancelClick( wxCommandEvent& event ) { // Look in the path list to be sure the path is still available // (May have been deleted by PathMangerDialog...) wxPathListNode *node = g_pPathList->GetFirst(); while( node ) { Path *pPath = node->GetData(); if( pPath == m_pPath ) { m_pPath->m_iBlink--; m_pPath->ClearHighlights(); break; } node = node->GetNext(); } m_bStartNow = false; Hide(); RequestRefresh( GetOCPNCanvasWindow() ); event.Skip(); }
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 ); } } }
int grib_pi::Init(void) { AddLocaleCatalog( _T("opencpn-grib_pi") ); // Set some default private member parameters m_CtrlBarxy = wxPoint( 0 ,0 ); m_CursorDataxy = wxPoint( 0, 0 ); m_pGribCtrlBar = NULL; m_pGRIBOverlayFactory = NULL; ::wxDisplaySize(&m_display_width, &m_display_height); m_DialogStyleChanged = false; // Get a pointer to the opencpn configuration object m_pconfig = GetOCPNConfigObject(); // And load the configuration items LoadConfig(); // Get a pointer to the opencpn display canvas, to use as a parent for the GRIB dialog m_parent_window = GetOCPNCanvasWindow(); // int m_height = GetChartbarHeight(); // This PlugIn needs a CtrlBar icon, so request its insertion if enabled locally if (m_bGRIBShowIcon) { wxString shareLocn = *GetpSharedDataLocation() + _T("plugins") + wxFileName::GetPathSeparator() + _T("grib_pi") + wxFileName::GetPathSeparator() + _T("data") + wxFileName::GetPathSeparator(); wxString normalIcon = shareLocn + _T("grib.svg"); wxString toggledIcon = shareLocn + _T("grib_toggled.svg"); wxString rolloverIcon = shareLocn + _T("grib_rollover.svg"); // For journeyman styles, we prefer the built-in raster icons which match the rest of the toolbar. if (GetActiveStyleName().Lower() != _T("traditional")){ normalIcon = _T(""); toggledIcon = _T(""); rolloverIcon = _T(""); } wxLogMessage(normalIcon); m_leftclick_tool_id = InsertPlugInToolSVG(_T(""), normalIcon, rolloverIcon, toggledIcon, wxITEM_CHECK, _("Grib"), _T(""), NULL, GRIB_TOOL_POSITION, 0, this); } if( !QualifyCtrlBarPosition( m_CtrlBarxy, m_CtrlBar_Sizexy ) ) { m_CtrlBarxy = wxPoint( 20, 60 ); //reset to the default position m_CursorDataxy = wxPoint( 20, 170 ); } return (WANTS_OVERLAY_CALLBACK | WANTS_OPENGL_OVERLAY_CALLBACK | WANTS_CURSOR_LATLON | WANTS_TOOLBAR_CALLBACK | INSTALLS_TOOLBAR_TOOL | WANTS_CONFIG | WANTS_PREFERENCES | WANTS_PLUGIN_MESSAGING | WANTS_MOUSE_EVENTS ); }
void CursorData::OnMouseEvent( wxMouseEvent &event ) { if( event.RightDown() ) { if( m_DialogStyle >> 1 == ATTACHED ) { wxMouseEvent evt(event); m_gparent.OnMouseEvent( evt ); } return; } static wxPoint s_gspt; int x, y; event.GetPosition( &x, &y ); wxPoint spt = wxPoint( x, y ); if( event.GetId() != 1000 ) spt = ClientToScreen( spt ); else spt = GetParent()->ClientToScreen( spt ); #ifdef __WXOSX__ if (!m_bLeftDown && event.LeftIsDown()) { m_bLeftDown = true; s_gspt = spt; if (!HasCapture()) CaptureMouse(); } else if (m_bLeftDown && !event.LeftIsDown()) { // GetParent()->Move( GetParent()->GetPosition() ); m_bLeftDown = false; if (HasCapture()) ReleaseMouse(); } #else if( event.LeftDown() ) { s_gspt = spt; CaptureMouse(); } if( event.LeftUp() ) { //GetParent()->Move( GetParent()->GetPosition() ); if( HasCapture() ) ReleaseMouse(); } #endif if( event.Dragging() ) { wxPoint par_pos_old = GetParent()->GetPosition(); wxPoint par_pos = par_pos_old; par_pos.x += spt.x - s_gspt.x; par_pos.y += spt.y - s_gspt.y; wxPoint pos_in_parent = GetOCPNCanvasWindow()->ScreenToClient( par_pos ); wxPoint pos_in_parent_old = GetOCPNCanvasWindow()->ScreenToClient( par_pos_old ); // X if( pos_in_parent.x < pos_in_parent_old.x ) { // moving left if( pos_in_parent.x < 10 ) { pos_in_parent.x = 0; } } else if( pos_in_parent.x > pos_in_parent_old.x ) { // moving right int max_right = GetOCPNCanvasWindow()->GetClientSize().x - GetParent()->GetSize().x; if( pos_in_parent.x > ( max_right - 10 ) ) { pos_in_parent.x = max_right; } } // Y if( pos_in_parent.y < pos_in_parent_old.y ) { // moving up if( pos_in_parent.y < 10 ) { pos_in_parent.y = 0; } } else if( pos_in_parent.y > pos_in_parent_old.y ) { // moving dow int max_down = GetOCPNCanvasWindow()->GetClientSize().y - GetParent()->GetSize().y; if( pos_in_parent.y > ( max_down - 10 ) ) { pos_in_parent.y = max_down; } } wxPoint final_pos = GetOCPNCanvasWindow()->ClientToScreen( pos_in_parent ); GetParent()->Move( final_pos ); s_gspt = spt; } }