PathProp::PathProp( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { m_opList = NULL; m_nSelected = 0; m_pEnroutePoint = NULL; m_bStartNow = false; m_pPath = NULL; m_pEnroutePoint = NULL; m_bStartNow = false; #ifdef __WXOSX__ style |= wxSTAY_ON_TOP; #endif SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS ); wxDialog::Create( parent, id, caption, pos, size, style ); wxFont *qFont = OCPNGetFont(_("Dialog"), 0); SetFont( *qFont ); CreateControls(); // Make an estimate of the dialog size, without scrollbars showing wxSize esize; esize.x = GetCharWidth() * 110; esize.y = GetCharHeight() * 40; SetSize( esize ); Centre(); }
void CursorData::MenuAppend( wxMenu *menu, int id, wxString label, int setting) { wxMenuItem *item = new wxMenuItem(menu, id, label, _T(""), wxITEM_CHECK); #ifdef __WXMSW__ wxFont *qFont = OCPNGetFont( _("Menu"), 10 ); item->SetFont(*qFont); #endif menu->Append(item); bool check; if( id == B_ARROWS ) check = m_gparent.m_OverlaySettings.Settings[setting].m_bBarbedArrows; else if( id == ISO_LINE ) check = m_gparent.m_OverlaySettings.Settings[setting].m_bIsoBars; else if( id == D_ARROWS ) check = m_gparent.m_OverlaySettings.Settings[setting].m_bDirectionArrows; else if( id == OVERLAY ) check = m_gparent.m_OverlaySettings.Settings[setting].m_bOverlayMap; else if( id == NUMBERS ) check = m_gparent.m_OverlaySettings.Settings[setting].m_bNumbers; else if( id == PARTICLES ) check = m_gparent.m_OverlaySettings.Settings[setting].m_bParticles; else check = false; item->Check( check ); }
void GribRequestSetting::SetRequestDialogSize() { int y; /*first let's size the mail display space*/ GetTextExtent( _T("abc"), NULL, &y, 0, 0, OCPNGetFont(_("Dialog"), 10) ); m_MailImage->SetMinSize( wxSize( -1, ( (y * m_MailImage->GetNumberOfLines()) + 10 ) ) ); /*then as default sizing do not work with wxScolledWindow let's compute it*/ wxSize scroll = m_fgScrollSizer->Fit(m_sScrolledDialog); // the area size to be scrolled #ifdef __WXGTK__ SetMinSize( wxSize( 0, 0 ) ); #endif wxWindow *frame = wxTheApp->GetTopWindow(); int w = frame->GetClientSize().x; // the display size int h = frame->GetClientSize().y; int dMargin = 80; //set a margin h -= ( m_rButton->GetSize().GetY() + dMargin ); //height available for the scrolled window w -= dMargin; //width available for the scrolled window m_sScrolledDialog->SetMinSize( wxSize( wxMin( w, scroll.x ), wxMin( h, scroll.y ) ) ); //set scrolled area size with margin Layout(); Fit(); #ifdef __WXGTK__ wxSize sd = GetSize(); if( sd.y == GetClientSize().y ) sd.y += 30; SetSize( wxSize( sd.x, sd.y ) ); SetMinSize( wxSize( sd.x, sd.y ) ); #endif Refresh(); }
void GribRequestSetting::SetMailImageSize() { #ifndef __WXMSW__ //default resizing do not work properly on no Windows plateforms int h; GetTextExtent( _T("abc"), NULL, &h, 0, 0, OCPNGetFont(_("Dialog"), 10) ); m_MailImage->SetMinSize( wxSize( -1, (h * m_MailImage->GetNumberOfLines()) + 5 ) ); #endif this->Fit(); this->Refresh(); }
void GribRequestSetting::SetRequestDialogSize() { int y; /*first let's size the mail display space*/ GetTextExtent( _T("abc"), NULL, &y, 0, 0, OCPNGetFont(_("Dialog"), 10) ); m_MailImage->SetMinSize( wxSize( -1, ( (y * m_MailImage->GetNumberOfLines()) + 10 ) ) ); /*then as default sizing do not work with wxScolledWindow let's compute it*/ wxSize scroll = m_fgScrollSizer->Fit(m_sScrolledDialog); // the area size to be scrolled int w = GetOCPNCanvasWindow()->GetClientSize().x; // the display size int h = GetOCPNCanvasWindow()->GetClientSize().y; int dMargin = 80; //set a margin h -= ( m_rButton->GetSize().GetY() + dMargin ); //height available for the scrolled window w -= dMargin; //width available for the scrolled window m_sScrolledDialog->SetMinSize( wxSize( wxMin( w, scroll.GetWidth() ), h ) ); //set scrolled area size with margin Layout(); Fit(); Refresh(); }
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
void CursorData::PopulateTrackingControls( bool vertical ) { m_fgTrackingControls->Clear(); m_fgTrackingControls->SetCols( vertical ? 2 : 12); this->Fit(); //Get text controls sizing data wxFont *font = OCPNGetFont(_("Dialog"), 10); int wn, wd, ws,wl; GetTextExtent( _T("abcdefghih"), &wn, NULL, 0, 0, font); // normal width text control size GetTextExtent( _T("abcdef"), &ws, NULL, 0, 0, font); // short width text control size for direction only GetTextExtent( _T("abcdefghijklmopq"), &wd, NULL, 0, 0, font); // long width text control size for double unit wind display GetTextExtent( _T("abcdefghijklm"), &wl, NULL, 0, 0, font); // long width text control size for double unit wave display // bool bf = m_gparent.m_OverlaySettings.Settings[GribOverlaySettings::WIND].m_Units == GribOverlaySettings::BFS; wd = vertical ? wn: bf? wn: wd; wl = vertical? wn : wl; AddTrackingControl(m_cbWind, m_tcWindSpeed, m_tcWindSpeedBf, m_tcWindDirection, false, vertical, 0, 0 ); //hide all wind's parameters AddTrackingControl(m_cbWind, m_tcWindSpeed, vertical? (bf ? m_tcWindDirection: m_tcWindSpeedBf) : m_tcWindDirection, vertical? (bf ? 0: m_tcWindDirection): 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VX) != wxNOT_FOUND && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VY) != wxNOT_FOUND, vertical, wd, ws); AddTrackingControl(m_cbWindGust, m_tcWindGust, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_GUST) != wxNOT_FOUND && m_Altitude == 0, vertical, wn); AddTrackingControl(m_cbPressure, m_tcPressure, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRESSURE) != wxNOT_FOUND && m_Altitude == 0, vertical, wn); /* tracking for wave is funky */ AddTrackingControl(m_cbWave, m_tcWaveHeight, m_tcWavePeriode, m_tcWaveDirection, false, vertical, 0, 0); //hide all waves's parameters if(m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_HTSIGW) != wxNOT_FOUND) { if(m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WVDIR) != wxNOT_FOUND) AddTrackingControl(m_cbWave, m_tcWaveHeight, vertical? m_tcWavePeriode: m_tcWaveDirection, vertical? m_tcWaveDirection: 0 , m_Altitude == 0, vertical, wl, ws); else AddTrackingControl(m_cbWave, m_tcWaveHeight, 0, vertical? m_tcWavePeriode: 0, m_Altitude == 0, vertical, wn, ws); } else { if(m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WVDIR) != wxNOT_FOUND) AddTrackingControl(m_cbWave, m_tcWaveDirection, 0,0 , m_Altitude == 0, vertical, ws, ws); } AddTrackingControl(m_cbCurrent, m_tcCurrentVelocity, m_tcCurrentDirection, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEACURRENT_VX) != wxNOT_FOUND && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEACURRENT_VY) != wxNOT_FOUND && m_Altitude == 0, vertical, wn, ws); AddTrackingControl(m_cbPrecipitation, m_tcPrecipitation, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRECIP_TOT) != wxNOT_FOUND && m_Altitude == 0, vertical, wn); AddTrackingControl(m_cbCloud, m_tcCloud, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CLOUD_TOT) != wxNOT_FOUND && m_Altitude == 0, vertical, wn); AddTrackingControl(m_cbAirTemperature, m_tcAirTemperature, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_AIR_TEMP) != wxNOT_FOUND && m_Altitude == 0, vertical, wn); AddTrackingControl(m_cbSeaTemperature, m_tcSeaTemperature, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEA_TEMP) != wxNOT_FOUND && m_Altitude == 0, vertical, wn); AddTrackingControl(m_cbCAPE, m_tcCAPE, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CAPE) != wxNOT_FOUND && m_Altitude == 0, vertical, wn); // //init and show extra parameters for altitude tracking if necessary AddTrackingControl(m_cbAltitude, m_tcAltitude, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_GEOP_HGT + m_Altitude) != wxNOT_FOUND && m_Altitude != 0, vertical, wn); AddTrackingControl(m_cbTemp, m_tcTemp, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_AIR_TEMP + m_Altitude) != wxNOT_FOUND && m_Altitude != 0, vertical, wn); AddTrackingControl(m_cbRelHumid, m_tcRelHumid, 0, 0, m_gparent.m_pTimelineSet && m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_HUMID_RE + m_Altitude) != wxNOT_FOUND && m_Altitude != 0, vertical, wn); // m_stTrackingText->SetLabel( _("Data at cursor position") ); //add tooltips wxString t; double lev; lev = m_gparent.m_OverlaySettings.CalibrateValue(GribOverlaySettings::GEO_ALTITUDE, 10 ); //convert 10m in current altitude unit t.Printf( m_Altitude ? m_gparent.m_OverlaySettings.GetAltitudeFromIndex( m_Altitude, m_gparent.m_OverlaySettings.Settings[GribOverlaySettings::PRESSURE].m_Units) .Append( _T(" ") ).Append( m_gparent.m_OverlaySettings.GetUnitSymbol(GribOverlaySettings::PRESSURE) ) : wxString::Format( _T("%1.*f "), lev == (int) lev ? 0 : 1, lev ) .Append( m_gparent.m_OverlaySettings.GetUnitSymbol(GribOverlaySettings::GEO_ALTITUDE) ) ); m_tcWindSpeed->SetToolTip( _("Wind Speed at") + t.Prepend( _T(" ") ) ); m_tcWindSpeedBf->SetToolTip( _("Wind Speed in at") + t.Prepend( _T(" ") ) ); m_tcWindDirection->SetToolTip( _("Wind Direction at") + t ); t.Printf( _T(" %1.*f ") + m_gparent.m_OverlaySettings.GetUnitSymbol(GribOverlaySettings::GEO_ALTITUDE), lev == (int) lev ? 0 : 1, lev ); m_tcWindGust->SetToolTip( _("Wind Gust at") + t ); if( m_gparent.m_pTimelineSet ) { wxString s[] = { _T(" "), _("Air Temperature at"), _("Surface level"), _("Sea Surface Temperature") }; lev = m_gparent.m_OverlaySettings.CalibrateValue(GribOverlaySettings::GEO_ALTITUDE, 2 ); //convert 2m in current altitude unit t.Printf( m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index(1000 + NORWAY_METNO) != wxNOT_FOUND ? s[0] + s[2] : _T(" %1.*f ") + m_gparent.m_OverlaySettings.GetUnitSymbol(GribOverlaySettings::GEO_ALTITUDE), lev == (int) lev ? 0 : 1, lev ); m_tcAirTemperature->SetToolTip(s[1] + t ); m_tcSeaTemperature->SetToolTip( m_gparent.m_bGRIBActiveFile->m_GribIdxArray.Index( 1000 + NOAA_GFS) != wxNOT_FOUND ? s[1] + s[0] + s[2] : s[3] ); } }
void GribRequestSetting::InitRequestConfig() { wxFileConfig *pConf = GetOCPNConfigObject(); if(pConf) { pConf->SetPath ( _T( "/PlugIns/GRIB" ) ); wxString l; int m; pConf->Read ( _T( "MailRequestConfig" ), &m_RequestConfigBase, _T( "000220XX........0" ) ); pConf->Read ( _T( "MailSenderAddress" ), &l, _T("") ); m_pSenderAddress->ChangeValue( l ); pConf->Read ( _T( "MailRequestAddresses" ), &m_MailToAddresses, _T("[email protected];[email protected]") ); pConf->Read ( _T( "ZyGribLogin" ), &l, _T("") ); m_pLogin->ChangeValue( l ); pConf->Read ( _T( "ZyGribCode" ), &l, _T("") ); m_pCode->ChangeValue( l ); pConf->Read ( _T( "SendMailMethod" ), &m_SendMethod, 0 ); pConf->Read ( _T( "MovingGribSpeed" ), &m, 0 ); m_sMovingSpeed->SetValue( m ); pConf->Read ( _T( "MovingGribCourse" ), &m, 0 ); m_sMovingCourse->SetValue( m ); m_cManualZoneSel->SetValue( m_SavedZoneSelMode != AUTO_SELECTION ); //has been read in GriUbICtrlBar dialog implementation or updated previously m_cUseSavedZone->SetValue( m_SavedZoneSelMode == SAVED_SELECTION ); fgZoneCoordinatesSizer->ShowItems( m_SavedZoneSelMode != AUTO_SELECTION ); m_cUseSavedZone->Show( m_SavedZoneSelMode != AUTO_SELECTION ); if( m_cManualZoneSel->GetValue() ) { pConf->Read ( _T( "RequestZoneMaxLat" ), &m, 0 ); m_spMaxLat->SetValue( m ); pConf->Read ( _T( "RequestZoneMinLat" ), &m, 0 ); m_spMinLat->SetValue( m ); pConf->Read ( _T( "RequestZoneMaxLon" ), &m, 0 ); m_spMaxLon->SetValue( m ); pConf->Read ( _T( "RequestZoneMinLon" ), &m, 0 ); m_spMinLon->SetValue( m ); SetCoordinatesText(); } //if GriDataConfig has been corrupted , take the standard one to fix a crash if( m_RequestConfigBase.Len() != wxString (_T( "000220XX.............." ) ).Len() ) m_RequestConfigBase = _T( "000220XX.............." ); } //populate model, mail to, waves model choices wxString s1[] = {_T("GFS"),_T("COAMPS"),_T("RTOFS")}; for( unsigned int i= 0; i<(sizeof(s1) / sizeof(wxString));i++) m_pModel->Append( s1[i] ); wxString s2[] = {_T("Saildocs"),_T("zyGrib")}; for( unsigned int i= 0; i<(sizeof(s2) / sizeof(wxString));i++) m_pMailTo->Append( s2[i] ); wxString s3[] = {_T("WW3-GLOBAL"),_T("WW3-MEDIT")}; for( unsigned int i= 0; i<(sizeof(s3) / sizeof(wxString));i++) m_pWModel->Append( s3[i] ); m_rButtonYes->SetLabel(_("Send")); m_rButtonApply->SetLabel(_("Save")); m_tResUnit->SetLabel(wxString::Format( _T("\u00B0"))); m_sCourseUnit->SetLabel(wxString::Format( _T("\u00B0"))); //Set wxSpinCtrl sizing int w,h; GetTextExtent( _T("-360"), &w, &h, 0, 0, OCPNGetFont(_("Dialog"), 10)); // optimal text control size w += 30; h += 4; m_sMovingSpeed->SetMinSize( wxSize(w, h) ); m_sMovingCourse->SetMinSize( wxSize(w, h) ); m_spMaxLat->SetMinSize( wxSize(w, h) ); m_spMinLat->SetMinSize( wxSize(w, h) ); m_spMaxLon->SetMinSize( wxSize(w, h) ); m_spMinLon->SetMinSize( wxSize(w, h) ); //add tooltips m_pSenderAddress->SetToolTip(_("Address used to send request eMail. (Mandatory for LINUX)")); m_pLogin->SetToolTip(_("This is your zyGrib's forum access Login")); m_pCode->SetToolTip(_("Get this Code in zyGrib's forum ( This is not your password! )")); m_sMovingSpeed->SetToolTip(_("Enter your forescasted Speed (in Knots)")); m_sMovingCourse->SetToolTip(_("Enter your forecasted Course")); long i,j,k; ( (wxString) m_RequestConfigBase.GetChar(0) ).ToLong( &i ); //MailTo m_pMailTo->SetSelection(i); ( (wxString) m_RequestConfigBase.GetChar(1) ).ToLong( &i ); //Model m_pModel->SetSelection(i); m_cMovingGribEnabled->SetValue(m_RequestConfigBase.GetChar(16) == 'X' );//Moving Grib ( (wxString) m_RequestConfigBase.GetChar(2) ).ToLong( &i ); //Resolution ( (wxString) m_RequestConfigBase.GetChar(3) ).ToLong( &j ); //interval ( (wxString) m_RequestConfigBase.GetChar(4) ).ToLong( &k, 16 ); //Time Range k--; // range max = 2 to 16 stored in hexa from 1 to f #ifdef __WXMSW__ //show / hide sender elemants as necessary m_pSenderSizer->ShowItems(false); #else if(m_SendMethod == 0 ) m_pSenderSizer->ShowItems(false); else m_pSenderSizer->ShowItems(true); //possibility to use "sendmail" method with Linux #endif m_tMouseEventTimer.Connect(wxEVT_TIMER, wxTimerEventHandler( GribRequestSetting::OnMouseEventTimer ), NULL, this); m_RenderZoneOverlay = 0; ApplyRequestConfig( i, j ,k); ( (wxString) m_RequestConfigBase.GetChar(5) ).ToLong( &j ); //Waves model m_pWModel->SetSelection( j ); m_pWind->Enable( false ); //always selected if available m_pPress->Enable( false ); DimeWindow( this ); //aplly global colours scheme m_AllowSend = true; m_MailImage->SetValue( WriteMail() ); }
bool GribRequestSetting::DoRenderZoneOverlay() { wxPoint p; GetCanvasPixLL( m_Vp, &p, m_Lat, m_Lon); int x = (m_StartPoint.x < p.x) ? m_StartPoint.x : p.x; int y = (m_StartPoint.y < p.y) ? m_StartPoint.y : p.y; int zw = fabs( (double ) p.x - m_StartPoint.x ); int zh = fabs( (double ) p.y - m_StartPoint.y ); wxPoint center; center.x = x + (zw / 2); center.y = y + (zh / 2); wxFont *font = OCPNGetFont(_("Dialog"), 10); wxColour pen_color, back_color; GetGlobalColor( _T ( "DASHR" ), &pen_color ); GetGlobalColor( _T ( "YELO1" ), &back_color ); int label_offsetx = 5, label_offsety = 1; double size; EstimateFileSize( &size ); wxString label( _("Coord. ") ); label.Append( toMailFormat(1, m_spMaxLat->GetValue()) + _T(" ")); label.Append( toMailFormat(0, m_spMinLon->GetValue()) + _T(" ")); label.Append( toMailFormat(1, m_spMinLat->GetValue()) + _T(" ")); label.Append( toMailFormat(0, m_spMaxLon->GetValue()) + _T("\n")); label.Append( _T("Estim. Size ") ).Append((wxString::Format( _T("%1.2f " ) , size ) + _("MB") ) ); if( m_pdc ) { wxPen pen(pen_color); pen.SetWidth(3); m_pdc->SetPen( pen ); m_pdc->SetBrush( *wxTRANSPARENT_BRUSH); m_pdc->DrawRectangle(x, y, zw, zh); int w, h, sl; #ifdef __WXMAC__ wxScreenDC sdc; sdc.GetMultiLineTextExtent(label, &w, &h, &sl, font); #else m_pdc->GetMultiLineTextExtent(label, &w, &h, &sl, font); #endif w += 2*label_offsetx, h += 2*label_offsety; x = center.x - (w / 2); y = center.y - (h / 2); wxBitmap bm(w, h); wxMemoryDC mdc(bm); mdc.Clear(); mdc.SetFont( *font ); mdc.SetBrush(back_color); mdc.SetPen(*wxTRANSPARENT_PEN); mdc.SetTextForeground(wxColor( 0, 0, 0 )); mdc.DrawRectangle(0, 0, w, h); mdc.DrawLabel( label, wxRect( label_offsetx, label_offsety, w, h ) ); wxImage im = bm.ConvertToImage(); im.InitAlpha(); w = im.GetWidth(), h = im.GetHeight(); for( int j = 0; j < h; j++ ) for( int i = 0; i < w; i++ ) im.SetAlpha( i, j, 155 ); m_pdc->DrawBitmap(im, x, y, true); } else { #ifdef ocpnUSE_GL TexFont m_TexFontlabel; m_TexFontlabel.Build(*font); glColor3ub(pen_color.Red(), pen_color.Green(), pen_color.Blue() ); glPushAttrib(GL_COLOR_BUFFER_BIT | GL_LINE_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_HINT_BIT ); glEnable( GL_LINE_SMOOTH ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); glLineWidth( 3.f ); glBegin( GL_LINES ); glVertex2d( x, y ); glVertex2d( x+zw, y ); glVertex2d( x+zw, y ); glVertex2d( x+zw, y+zh ); glVertex2d( x+zw, y+zh ); glVertex2d( x, y+zh ); glVertex2d( x, y+zh ); glVertex2d( x, y ); glEnd(); int w, h; glColor4ub(back_color.Red(), back_color.Green(), back_color.Blue(), 155 ); m_TexFontlabel.GetTextExtent(label, &w, &h ); w += 2*label_offsetx, h += 2*label_offsety; x = center.x - (w / 2); y = center.y - (h / 2); /* draw text background */ glBegin(GL_QUADS); glVertex2i(x, y); glVertex2i(x+w, y); glVertex2i(x+w, y+h); glVertex2i(x, y+h); glEnd(); /* draw text */ glColor3ub( 0, 0, 0 ); glEnable(GL_TEXTURE_2D); m_TexFontlabel.RenderString(label, x + label_offsetx, y + label_offsety); glDisable(GL_TEXTURE_2D); glDisable( GL_BLEND ); #endif } return true; }