//------------------------------------------------------------------------------ // custom grid implementation //------------------------------------------------------------------------------ CustomGrid::CustomGrid( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) : wxGrid( parent, id, pos, size, style, name ) { //create grid SetTable( new wxGridStringTable(0, 0), true, wxGridSelectRows ); //some general settings EnableEditing( false ); EnableGridLines( true ); EnableDragGridSize( false ); SetMargins( 0, 0 ); EnableDragColMove( false ); EnableDragColSize( false ); EnableDragRowSize( false ); //init rows pref wxFileConfig *pConf = GetOCPNConfigObject(); if (pConf) { pConf->SetPath(_T("/Settings/GRIB")); m_IsDigit = pConf->Read(_T("GribDataTableRowPref"), _T("XXX")); } if( m_IsDigit.Len() != wxString(_T("XXX")).Len() ) m_IsDigit = _T("XXX"); //create structure for all numerical rows for( unsigned int i = 0; i < m_IsDigit.Len(); i++ ){ m_NumRow.push_back(wxNOT_FOUND); m_NumRowVal.push_back(std::vector <double>()); } //init labels attr wxFont labelfont = GetOCPNGUIScaledFont_PlugIn( _T("Dialog") ).MakeBold(); SetLabelFont(labelfont); wxColour colour; GetGlobalColor(_T("DILG0"), &colour); SetLabelBackgroundColour(colour); //set row label size int w; GetTextExtent( _T("Ab"), &w, NULL, 0, 0, &labelfont); double x = (double)w * 6.5; SetRowLabelSize((int)x); //colour settings GetGlobalColor(_T("GREEN1"), &m_greenColour); GetGlobalColor(_T("DILG1"), &m_greyColour); #ifdef __WXOSX__ m_bLeftDown = false; #endif //connect events at dialog level Connect(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollEventHandler( CustomGrid::OnScroll ), NULL, this ); Connect(wxEVT_SIZE, wxSizeEventHandler( CustomGrid::OnResize ), NULL, this ); Connect(wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( CustomGrid::OnLabeClick ), NULL, this ); //connect events at grid level GetGridWindow()->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); GetGridWindow()->Connect(wxEVT_LEFT_UP, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); GetGridWindow()->Connect(wxEVT_MOTION, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); //timer event m_tRefreshTimer.Connect(wxEVT_TIMER, wxTimerEventHandler( CustomGrid::OnRefreshTimer ), NULL, this); }
ODIconCombo::ODIconCombo (wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) :wxOwnerDrawnComboBox(parent, id, value, pos, size, n, choices, style, validator, name) { wxScreenDC dc; wxFont l_Font = GetOCPNGUIScaledFont_PlugIn(wxT("H")); wxSize sz = dc.GetTextExtent(_T("H")); double pt_per_pixel = 12.0 / (double)sz.y; itemHeight = l_Font.GetPointSize()/ pt_per_pixel; }
void MenuAppend( wxMenu *menu, int id, wxString label) { wxMenuItem *item = new wxMenuItem(menu, id, label); #ifdef __WXMSW__ // wxFont *qFont = OCPNGetFont(wxS("Menu"), 0); wxFont *qFont = GetOCPNScaledFont_PlugIn(_T("Menu")); item->SetFont(*qFont); #endif #ifdef __WXQT__ wxFont sFont = GetOCPNGUIScaledFont_PlugIn(_T("Menu")); item->SetFont(sFont); #endif menu->Append(item); }
void RadarCanvas::Render(wxPaintEvent &evt) { int w, h; if (!IsShown() || !m_pi->m_initialized) { return; } GetClientSize(&w, &h); wxPaintDC(this); // only to be used in paint events. use wxClientDC to paint // outside the paint event if (!m_pi->m_opengl_mode) { LOG_DIALOG(wxT("BR24radar_pi: %s cannot render non-OpenGL mode"), m_ri->m_name.c_str()); return; } if (!m_pi->m_opencpn_gl_context && !m_pi->m_opencpn_gl_context_broken) { LOG_DIALOG(wxT("BR24radar_pi: %s skip render as no context known yet"), m_ri->m_name.c_str()); return; } LOG_DIALOG(wxT("BR24radar_pi: %s render OpenGL canvas %d by %d "), m_ri->m_name.c_str(), w, h); SetCurrent(*m_context); glPushMatrix(); glPushAttrib(GL_ALL_ATTRIB_BITS); wxFont font = GetOCPNGUIScaledFont_PlugIn(_T("StatusBar")); m_FontNormal.Build(font); wxFont bigFont = GetOCPNGUIScaledFont_PlugIn(_T("Dialog")); bigFont.SetPointSize(bigFont.GetPointSize() + 2); bigFont.SetWeight(wxFONTWEIGHT_BOLD); m_FontBig.Build(bigFont); bigFont.SetPointSize(bigFont.GetPointSize() + 2); bigFont.SetWeight(wxFONTWEIGHT_NORMAL); m_FontMenu.Build(bigFont); bigFont.SetPointSize(bigFont.GetPointSize() + 10); bigFont.SetWeight(wxFONTWEIGHT_BOLD); m_FontMenuBold.Build(bigFont); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black Background glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear the canvas glEnable(GL_TEXTURE_2D); // Enable textures glEnable(GL_COLOR_MATERIAL); glEnable(GL_BLEND); // glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); // Next two operations on the project matrix stack glLoadIdentity(); // Reset projection matrix stack glOrtho(0, w, h, 0, -1, 1); glMatrixMode(GL_MODELVIEW); // Reset matrick stack target back to GL_MODELVIEW RenderRangeRingsAndHeading(w, h); Render_EBL_VRM(w, h); glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); // Next two operations on the project matrix stack glLoadIdentity(); // Reset projection matrix stack if (w >= h) { glScaled(1.0, (float)-w / h, 1.0); } else { glScaled((float)h / w, -1.0, 1.0); } glMatrixMode(GL_MODELVIEW); // Reset matrick stack target back to GL_MODELVIEW m_ri->RenderRadarImage(wxPoint(0, 0), 1.0, 0.0, false); glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); // Next two operations on the project matrix stack glLoadIdentity(); // Reset projection matrix stack glOrtho(0, w, h, 0, -1, 1); glMatrixMode(GL_MODELVIEW); // Reset matrick stack target back to GL_MODELVIEW glEnable(GL_TEXTURE_2D); RenderTexts(w, h); RenderCursor(w, h); #ifdef NEVER glDisable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); // Next two operations on the project matrix stack glLoadIdentity(); // Reset projection matrix stack glMatrixMode(GL_MODELVIEW); // Reset matrick stack target back to GL_MODELVIEW #endif glPopAttrib(); glPopMatrix(); glFlush(); glFinish(); SwapBuffers(); if (m_pi->m_opencpn_gl_context) { SetCurrent(*m_pi->m_opencpn_gl_context); } else { SetCurrent(*m_zero_context); // Make sure OpenCPN -at least- doesn't overwrite our context info } }