void TacticsInstrument_Position::Draw(wxGCDC* dc) { wxColour cl; #ifdef __WXMSW__ wxBitmap tbm( dc->GetSize().x, m_DataHeight * 2, -1 ); wxMemoryDC tdc( tbm ); wxColour c2; GetGlobalColor( _T("DASHB"), &c2 ); tdc.SetBackground( c2 ); tdc.Clear(); tdc.SetFont(*g_pFontData ); GetGlobalColor( _T("DASHF"), &cl ); tdc.SetTextForeground( cl ); tdc.DrawText(m_data1, 10, 0); tdc.DrawText(m_data2, 10, m_DataHeight); tdc.SelectObject( wxNullBitmap ); dc->DrawBitmap(tbm, 0, m_TitleHeight, false); #else dc->SetFont(*g_pFontData ); GetGlobalColor( _T("DASHF"), &cl ); dc->SetTextForeground( cl ); dc->DrawText(m_data1, 10, m_TitleHeight); dc->DrawText(m_data2, 10, m_TitleHeight + m_DataHeight); #endif }
void DashboardInstrument_GPS::DrawForeground(wxBufferedDC* dc) { wxColour cl; GetGlobalColor(_T("BLUE1"), &cl); wxBrush brush; brush.SetStyle(wxSOLID); brush.SetColour(cl); dc->SetBrush(brush); dc->SetPen(*wxTRANSPARENT_PEN); dc->SetTextBackground(cl); GetGlobalColor(_T("BLUE2"), &cl); dc->SetTextForeground(cl); dc->SetBackgroundMode(wxSOLID); wxString label; wxFont font = dc->GetFont(); for (int idx = 0; idx < 12; idx++) { if (m_SatInfo[idx].SignalToNoiseRatio) { dc->DrawRectangle(idx*16+5, 140, 14, m_SatInfo[idx].SignalToNoiseRatio * -0.4); label.Printf(_T("%02d"), m_SatInfo[idx].SatNumber); int width, height; dc->GetTextExtent(label, &width, &height, 0, 0, &font); int posx = m_cx + m_radius * cos(deg2rad(m_SatInfo[idx].AzimuthDegreesTrue-ANGLE_OFFSET)) * sin(deg2rad(ANGLE_OFFSET-m_SatInfo[idx].ElevationDegrees)) - width/2; int posy = m_cy + m_radius * sin(deg2rad(m_SatInfo[idx].AzimuthDegreesTrue-ANGLE_OFFSET)) * sin(deg2rad(ANGLE_OFFSET-m_SatInfo[idx].ElevationDegrees)) - height/2; dc->DrawText(label, posx, posy); } } }
void ODPropertiesDialogImpl::SetTableCellBackgroundColours() { wxColour wxRed; GetGlobalColor( wxS( "URED" ), &wxRed ); wxColour wxGreen; GetGlobalColor( wxS( "UGREN" ), &wxGreen ); wxColour wxGray; GetGlobalColor( wxS( "GREY1" ), &wxGray ); m_gridODWDInteractions->SetCellBackgroundColour(0, 0, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(0, 1, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(0, 2, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(0, 3, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(0, 4, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(1, 0, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(2, 0, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(3, 0, wxGray); m_gridODWDInteractions->SetCellBackgroundColour(1, 1, wxGreen); m_gridODWDInteractions->SetCellBackgroundColour(2, 1, wxGreen); m_gridODWDInteractions->SetCellBackgroundColour(3, 1, wxGreen); m_gridODWDInteractions->SetCellBackgroundColour(1, 2, wxGreen); m_gridODWDInteractions->SetCellBackgroundColour(2, 2, wxRed); m_gridODWDInteractions->SetCellBackgroundColour(3, 2, wxRed); m_gridODWDInteractions->SetCellBackgroundColour(1, 3, wxRed); m_gridODWDInteractions->SetCellBackgroundColour(2, 3, wxGreen); m_gridODWDInteractions->SetCellBackgroundColour(3, 3, wxRed); m_gridODWDInteractions->SetCellBackgroundColour(1, 4, wxRed); m_gridODWDInteractions->SetCellBackgroundColour(2, 4, wxRed); m_gridODWDInteractions->SetCellBackgroundColour(3, 4, wxGreen); return; }
void PathMan::SetColorScheme( PI_ColorScheme cs ) { // Re-Create the pens and colors m_pActiveODPointPen = wxThePenList->FindOrCreatePen( wxColour( 0, 0, 255 ), g_path_line_width, wxPENSTYLE_SOLID ); m_pODPointPen = wxThePenList->FindOrCreatePen( wxColour( 0, 0, 255 ), g_path_line_width, wxPENSTYLE_SOLID ); // Or in something like S-52 compliance wxColour tColour; GetGlobalColor( wxS("UINFB"), &tColour ); m_pPathPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); m_pPathBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("UINFO"), &tColour ); m_pSelectedPathPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); m_pSelectedPathBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("UARTE"), &tColour ); m_pActivePathPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("PLRTE"), &tColour ); m_pActivePathBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID ); m_pActiveODPointBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID); m_pActiveODPointPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("CHBLK"), &tColour ); m_pODPointPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); m_pODPointBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID); }
StatWin::StatWin( wxWindow *win ) { long wstyle = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR; #ifndef __WXMAC__ wstyle |= wxFRAME_SHAPED; #endif #ifdef __WXMAC__ wstyle |= wxSTAY_ON_TOP; #endif wxDialog::Create( win, wxID_ANY, _T(""), wxPoint( 20, 20 ), wxSize( 5, 5 ), wstyle ); int x, y; GetClientSize( &x, &y ); m_backBrush = wxBrush( GetGlobalColor( _T("UIBDR") ), wxSOLID ); SetBackgroundColour( GetGlobalColor( _T("UIBDR") ) ); SetBackgroundStyle( wxBG_STYLE_CUSTOM ); // on WXMSW, this prevents flashing on color scheme change m_rows = 1; // Create the Children pPiano = new PianoWin( (wxFrame *) this ); }
// ctor StatWin::StatWin(wxFrame *frame): wxWindow(frame, wxID_ANY, wxPoint(20,20), wxSize(5,5), wxSIMPLE_BORDER) { int x,y; GetClientSize(&x, &y); m_backBrush = wxBrush(GetGlobalColor(_T("UIBDR")), wxSOLID); SetBackgroundColour(GetGlobalColor(_T("UIBDR"))); SetBackgroundStyle(wxBG_STYLE_CUSTOM); // on WXMSW, this prevents flashing on color scheme change m_rows = 1; // Create the Children pPiano = new PianoWin((wxFrame *)this); pPiano->SetSize(0, 0, x *6/10, y*1/m_rows); #ifdef USE_WIFI_CLIENT pWiFi = new WiFiStatWin((wxFrame *)this); pWiFi->SetSize(x * 6/10, 0, x *4/10, y * 1/m_rows); #endif }
//------------------------------------------------------------------------------ // 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); }
void WiFiStatWin::OnPaint(wxPaintEvent& event) { int width, height; GetClientSize(&width, &height ); wxPaintDC dc(this); dc.SetBackground(backBrush); dc.Clear(); int bar_total = width / NSIGBARS; // Create the Signal Strength Indicators dc.SetBrush(backBrush); wxPen ppPen(GetGlobalColor(_T("UBLCK")), 1, wxSOLID); dc.SetPen(ppPen); if(m_bserverstat) { for(int ista = 0 ; ista < NSIGBARS ; ista++) { if(0 != m_quality[ista]) { int x = width - bar_total * (ista + 1); dc.SetBrush(backBrush); dc.DrawRectangle(x+2, 2, bar_total-4 , height-4); // Old stations get soft color bars if(m_age[ista]) { dc.SetBrush(qual_hiBrush); if(m_secure[ista]) dc.SetBrush(secureBrush); } else { dc.SetBrush(qual_hiNewBrush); if(m_secure[ista]) dc.SetBrush(secureNewBrush); } DrawBars(dc, x+2, 2, bar_total-4 , height-4, m_quality[ista], 100); } } } else { wxPen yellowPen(GetGlobalColor(_T("CHYLW")), 1, wxSOLID); dc.SetPen(yellowPen); dc.DrawLine(1, 1, width-1, 1); dc.DrawLine(width-1, 1, width-1, height-1); dc.DrawLine(width-1, height-1, 1, height-1); dc.DrawLine(1, height-1, 1, 1); } }
void ChInfoWin::OnPaint( wxPaintEvent& event ) { int width, height; GetClientSize( &width, &height ); wxPaintDC dc( this ); dc.SetBrush( wxBrush( GetGlobalColor( _T ( "UIBCK" ) ) ) ); dc.SetPen( wxPen( GetGlobalColor( _T ( "UITX1" ) ) ) ); dc.DrawRectangle( 0, 0, width, height ); }
bool IACIsobarSystem::Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont) { bool hasDrawn = false; // draw isobar text at a random position of the isoline to prevent // text clutter. Getting the random positiuon must be before // "if" because otherwise the positions depend on the viewport int randomPositionIndex = rand() % m_positions.Count(); if (dc) { wxColour colour; GetGlobalColor(_T ( "CHBLK" ), &colour); wxPen pen(colour, ISOBAR_WIDTH); dc->SetPen(pen); dc->SetBrush(*wxTRANSPARENT_BRUSH); hasDrawn = DrawPositions(dc, vp); if (hasDrawn) { GeoPoint &Pos = m_positions[randomPositionIndex]; if (PointInLLBox(vp, Pos.x, Pos.y)) { wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); dc->SetTextForeground(colour); wxFont *font = wxTheFontList->FindOrCreateFont(NUMBERS_FONT_SIZE, wxFONTFAMILY_SWISS, wxNORMAL, wxFONTWEIGHT_NORMAL, FALSE, wxString(_T ( "Arial" ))); dc->SetFont(*font); wxString msg; msg.Printf(wxT("%u"), m_val); wxSize s1 = dc->GetTextExtent(msg); dc->DrawText(msg, p.x - (s1.GetWidth() / 2), p.y - (s1.GetHeight())); } } } else { GetGlobalColor(_T ( "CHBLK" ), &m_isoLineColor); m_isoLineWidth = wxMax(ISOBAR_WIDTH, GL_MIN_LINE_WIDTH); hasDrawn = DrawPositions(dc, vp); if (hasDrawn) { wxColour colour; GetGlobalColor(_T ( "CHBLK" ), &colour); GeoPoint &Pos = m_positions[randomPositionIndex]; wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); wxString msg; msg.Printf(wxT("%u"), m_val); int w, h; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); glColor3ub(colour.Red(), colour.Green(), colour.Blue()); numfont.GetTextExtent(msg, &w, &h); numfont.RenderString(msg, p.x - (w / 2), p.y - (h / 2)); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); } } return hasDrawn; }
void WiFiStatWin::SetColorScheme(ColorScheme cs) { backBrush = wxBrush(GetGlobalColor(_T("UIBDR")), wxSOLID); qual_hiBrush = wxBrush(GetGlobalColor(_T("CHYLW")), wxSOLID); //Yellow secureBrush = wxBrush(GetGlobalColor(_T("UINFO")), wxSOLID); //Orange qual_hiNewBrush = wxBrush(GetGlobalColor(_T("UGREN")), wxSOLID); //Bright Green secureNewBrush = wxBrush(GetGlobalColor(_T("URED")), wxSOLID); //Bright Red }
void ChInfoWin::SetBitmap() { SetBackgroundColour( GetGlobalColor( _T ( "UIBCK" ) ) ); m_pInfoTextCtl->SetBackgroundColour( GetGlobalColor( _T ( "UIBCK" ) ) ); m_pInfoTextCtl->SetForegroundColour( GetGlobalColor( _T ( "UITX1" ) ) ); m_pInfoTextCtl->SetSize( 1, 1, m_size.x - 2, m_size.y - 2 ); m_pInfoTextCtl->SetLabel( m_string ); SetSize( m_position.x, m_position.y, m_size.x, m_size.y ); }
void DashboardInstrument_Dial::DrawForeground(wxGCDC* dc) { // The default foreground is the arrow used in most dials wxColour cl; GetGlobalColor(_T("DASH2"), &cl); wxPen pen1; pen1.SetStyle(wxSOLID); pen1.SetColour(cl); pen1.SetWidth(2); dc->SetPen(pen1); GetGlobalColor(_T("DASH1"), &cl); wxBrush brush1; brush1.SetStyle(wxSOLID); brush1.SetColour(cl); dc->SetBrush(brush1); dc->DrawCircle(m_cx, m_cy, m_radius / 8); dc->SetPen(*wxTRANSPARENT_PEN); GetGlobalColor(_T("DASHN"), &cl); wxBrush brush; brush.SetStyle(wxSOLID); brush.SetColour(cl); dc->SetBrush(brush); /* this is fix for a +/-180° round instrument, when m_MainValue is supplied as <0..180><L | R> * for example TWA & AWA */ double data; if(m_MainValueUnit == _T("DegL")) data=360-m_MainValue; else data=m_MainValue; // The arrow should stay inside fixed limits double val; if (data < m_MainValueMin) val = m_MainValueMin; else if (data > m_MainValueMax) val = m_MainValueMax; else val = data; double value = deg2rad((val - m_MainValueMin) * m_AngleRange / (m_MainValueMax - m_MainValueMin)) + deg2rad(m_AngleStart - ANGLE_OFFSET); wxPoint points[4]; points[0].x = m_cx + (m_radius * 0.95 * cos(value - .010)); points[0].y = m_cy + (m_radius * 0.95 * sin(value - .010)); points[1].x = m_cx + (m_radius * 0.95 * cos(value + .015)); points[1].y = m_cy + (m_radius * 0.95 * sin(value + .015)); points[2].x = m_cx + (m_radius * 0.22 * cos(value + 2.8)); points[2].y = m_cy + (m_radius * 0.22 * sin(value + 2.8)); points[3].x = m_cx + (m_radius * 0.22 * cos(value - 2.8)); points[3].y = m_cy + (m_radius * 0.22 * sin(value - 2.8)); dc->DrawPolygon(4, points, 0, 0); }
void DashboardInstrument_Depth::DrawBackground(wxGCDC* dc) { wxSize size = GetClientSize(); wxColour cl; GetGlobalColor(_T("DASHL"), &cl); dc->SetTextForeground(cl); wxPen pen; pen.SetStyle(wxPENSTYLE_SOLID); GetGlobalColor(_T("DASHF"), &cl); pen.SetColour(cl); pen.SetWidth(1); dc->SetPen(pen); dc->DrawLine(3, 50, size.x-3, 50); dc->DrawLine(3, 140, size.x-3, 140); #ifdef __WXMSW__ pen.SetStyle(wxPENSTYLE_SHORT_DASH); #else pen.SetStyle(wxPENSTYLE_DOT); pen.SetWidth(1); #endif dc->SetPen(pen); dc->DrawLine(3, 65, size.x-3, 65); dc->DrawLine(3, 90, size.x-3, 90); dc->DrawLine(3, 115, size.x-3, 115); dc->SetFont(*g_pFontSmall); m_MaxDepth = 0; for (int idx = 0; idx < DEPTH_RECORD_COUNT; idx++) { if (m_ArrayDepth[idx] > m_MaxDepth) m_MaxDepth = m_ArrayDepth[idx]; } // Increase MaxDepth slightly for nicer display m_MaxDepth *= 1.2; wxString label; label.Printf(_T("%.0f ")+m_DepthUnit, 0.0); int width, height; dc->GetTextExtent(label, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label, size.x-width-1, 40-height); label.Printf(_T("%.0f ")+m_DepthUnit, m_MaxDepth); dc->GetTextExtent(label, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label, size.x-width-1, size.y-height); }
void ChInfoWin::SetBitmap() { SetBackgroundColour( GetGlobalColor( _T ( "UIBCK" ) ) ); m_pInfoTextCtl->SetBackgroundColour( GetGlobalColor( _T ( "UIBCK" ) ) ); m_pInfoTextCtl->SetForegroundColour( GetGlobalColor( _T ( "UITX1" ) ) ); m_pInfoTextCtl->SetSize( 1, 1, m_size.x - 2, m_size.y - 2 ); m_pInfoTextCtl->SetLabel( m_string ); wxPoint top_position = m_position; //GetParent()->ClientToScreen( m_position); SetSize( top_position.x, top_position.y, m_size.x, m_size.y ); SetClientSize( m_size.x, m_size.y ); }
void DashboardInstrument_Compass::DrawBackground(wxBufferedDC* dc) { wxPen pen; // wxBrush brushHatch(*wxLIGHT_GREY, wxTRANSPARENT); // Now draw the boat wxColour cl; GetGlobalColor(_T("GREY1"), &cl); pen.SetStyle(wxSOLID); pen.SetColour(cl); dc->SetPen(pen); GetGlobalColor(_T("GREY2"), &cl); dc->SetBrush(cl); wxPoint points[7]; /* * 0 * /\ * / \ * / \ * 6 / \ 1 * | X | * | | * 5 | | 2 * \ / * \__ _/ * 4 3 */ points[0].x = m_cx; points[0].y = m_cy - m_radius * .50; // a little bit longer than compass rose points[1].x = m_cx + m_radius * .15; points[1].y = m_cy; points[2].x = m_cx + m_radius * .15; points[2].y = m_cy + m_radius * .20; points[3].x = m_cx + m_radius * .10; points[3].y = m_cy + m_radius * .40; points[4].x = m_cx - m_radius * .10; points[4].y = m_cy + m_radius * .40; points[5].x = m_cx - m_radius * .15; points[5].y = m_cy + m_radius * .20; points[6].x = m_cx - m_radius * .15; points[6].y = m_cy; dc->DrawPolygon(7, points, 0, 0); DrawCompassRose(dc); }
void DashboardInstrument_Dial::DrawMarkers(wxGCDC* dc) { if( m_MarkerOption == DIAL_MARKER_NONE ) return; wxColour cl; GetGlobalColor( _T("DASHF"), &cl ); int penwidth = GetClientSize().x / 100; wxPen pen( cl, penwidth, wxSOLID ); dc->SetPen( pen ); int diff_angle = m_AngleStart + m_AngleRange - ANGLE_OFFSET; // angle between markers double abm = m_AngleRange * m_MarkerStep / ( m_MainValueMax - m_MainValueMin ); // don't draw last value, it's already done as first if( m_AngleRange == 360 ) diff_angle -= abm; int offset = 0; for( double angle = m_AngleStart - ANGLE_OFFSET; angle <= diff_angle; angle += abm ) { if( m_MarkerOption == DIAL_MARKER_REDGREEN ) { int a = int( angle + ANGLE_OFFSET ) % 360; if( a > 180 ) GetGlobalColor( _T("DASHR"), &cl ); else if( ( a > 0 ) && ( a < 180 ) ) GetGlobalColor( _T("DASHG"), &cl ); else GetGlobalColor( _T("DASHF"), &cl ); pen.SetColour( cl ); dc->SetPen( pen ); } double size = 0.92; if( offset % m_MarkerOffset ) { size = 0.96; } offset++; dc->DrawLine( m_cx + ( (m_radius-1) * size * cos( deg2rad( angle ) ) ), m_cy + ( (m_radius-1) * size * sin( deg2rad( angle ) ) ), m_cx + ( (m_radius-1) * cos( deg2rad( angle ) ) ), m_cy + ( (m_radius-1) * sin( deg2rad( angle ) ) ) ); } // We must reset pen color so following drawings are fine if( m_MarkerOption == DIAL_MARKER_REDGREEN ) { GetGlobalColor( _T("DASHF"), &cl ); pen.SetStyle( wxSOLID ); pen.SetColour( cl ); dc->SetPen( pen ); } }
bool GetGlobalColor(wxString colorName, wxColour *pcolour) { wxColour c = GetGlobalColor(colorName); *pcolour = c; return true; }
TStatWin::TStatWin( wxFrame *frame ) : wxWindow( frame, wxID_ANY, wxPoint( 20, 20 ), wxSize( 5, 5 ), wxSIMPLE_BORDER ) { SetBackgroundColour( GetGlobalColor( _T("UIBDR") ) ); pText = new wxString(); bTextSet = false; }
void TacticsInstrument_AppTrueWindAngle::Draw(wxGCDC* bdc) { wxColour c1; GetGlobalColor(_T("DASHB"), &c1); wxBrush b1(c1); bdc->SetBackground(b1); bdc->Clear(); wxSize size = GetClientSize(); m_cx = size.x / 2; int availableHeight = size.y - m_TitleHeight - 6; int width, height; bdc->GetTextExtent(_T("000"), &width, &height, 0, 0, g_pFontLabel); m_cy = m_TitleHeight + 2; m_cy += availableHeight / 2; m_radius = availableHeight / 2.0 * 0.95; DrawLabels(bdc); DrawFrame(bdc); DrawMarkers(bdc); DrawBackground(bdc); DrawData(bdc, m_MainValueApp, m_MainValueAppUnit, m_MainValueFormat, m_MainValueOption1); DrawData(bdc, m_MainValueTrue, m_MainValueTrueUnit, m_MainValueFormat, m_MainValueOption2); DrawData(bdc, m_ExtraValueApp, m_ExtraValueAppUnit, m_ExtraValueFormat, m_ExtraValueOption1); DrawData(bdc, m_ExtraValueTrue, m_ExtraValueTrueUnit, m_ExtraValueFormat, m_ExtraValueOption2); DrawData(bdc, m_TWD, m_MainValueTrueUnit, _T("TWD:%.0f"), DIAL_POSITION_INSIDE); DrawForeground(bdc); }
void AnnunText::SetColorScheme( ColorScheme cs ) { ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); m_pbackBrush = wxTheBrushList->FindOrCreateBrush( GetGlobalColor( _T("UBLCK") ), wxSOLID ); m_text_color = style->consoleFontColor; }
// draw the fleet code data // returns true if anything was drawn bool IACFile::Draw(wxDC *dc, PlugIn_ViewPort *vp) { bool retval = false; // draw only if file was successfully read and decoded if (IsOk()) { wxColor colour; GetGlobalColor(_T ( "SNDG1" ), &colour); wxPoint p1, p2, p3, p4; double minlon, maxlon; if (m_minlone < 999) minlon = m_minlone; else minlon = m_minlonw; if (m_maxlonw > -999) maxlon = m_maxlonw; else maxlon = m_maxlone; if (-179.0 < m_minlonw && m_minlonw < 0 && 179.0 > m_maxlone && m_maxlone > 0) { minlon = m_minlonw; maxlon = m_maxlone; } GetCanvasPixLL(vp, &p1, m_minlat, minlon); GetCanvasPixLL(vp, &p2, m_maxlat, minlon); GetCanvasPixLL(vp, &p3, m_maxlat, maxlon); GetCanvasPixLL(vp, &p4, m_minlat, maxlon); if (dc) { if (p3.x > 0 && p1.x < vp->pix_width) { dc->SetPen(wxPen(colour, ISOBAR_WIDTH)); wxPoint points[] = {p1, p2, p3, p4, p1}; dc->DrawLines(5, points); } } else { wxFont font_numbers(NUMBERS_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); m_TexFontNumbers.Build(font_numbers); wxFont font_systems(SYSTEMS_FONT_SIZE, wxFONTFAMILY_ROMAN, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD); m_TexFontSystems.Build(font_systems); if (p3.x > 0 && p1.x < vp->pix_width) { glColor3ub(colour.Red(), colour.Green(), colour.Blue()); glBegin(GL_LINE_LOOP); glVertex2i(p1.x, p1.y); glVertex2i(p2.x, p2.y); glVertex2i(p3.x, p3.y); glVertex2i(p4.x, p4.y); glEnd(); } } // This magic initialisation to the random numer generator // ensures that the (random) positions where some text // is written does not change between several calls to "Draw" // I love this kind of crazy code - it is like in the good // old days of programming where everything was allowed. srand(77); retval |= DrawSystems(dc, vp, (IACSystems &)m_pressure); retval |= DrawSystems(dc, vp, (IACSystems &)m_frontal); retval |= DrawSystems(dc, vp, (IACSystems &)m_isobars); retval |= DrawSystems(dc, vp, (IACSystems &)m_tropical); } return retval; }
//********************************************************************************* //draw background //********************************************************************************* void DashboardInstrument_BaroHistory::DrawBackground(wxGCDC* dc) { wxString label,label1,label2,label3,label4,label5; wxColour cl; wxPen pen; //--------------------------------------------------------------------------------- // draw legends for spressure //--------------------------------------------------------------------------------- DrawWindSpeedScale(dc); //--------------------------------------------------------------------------------- // horizontal lines //--------------------------------------------------------------------------------- GetGlobalColor(_T("UBLCK"), &cl); pen.SetColour(cl); dc->SetPen(pen); dc->DrawLine(m_LeftLegend+3, m_TopLineHeight, m_WindowRect.width-3-m_RightLegend, m_TopLineHeight); // the upper line dc->DrawLine(m_LeftLegend+3, (int)(m_TopLineHeight+m_DrawAreaRect.height), m_WindowRect.width-3-m_RightLegend, (int)(m_TopLineHeight+m_DrawAreaRect.height)); pen.SetStyle(wxPENSTYLE_DOT); dc->SetPen(pen); dc->DrawLine(m_LeftLegend+3, (int)(m_TopLineHeight+m_DrawAreaRect.height*0.25), m_WindowRect.width-3-m_RightLegend, (int)(m_TopLineHeight+m_DrawAreaRect.height*0.25)); dc->DrawLine(m_LeftLegend+3, (int)(m_TopLineHeight+m_DrawAreaRect.height*0.75), m_WindowRect.width-3-m_RightLegend, (int)(m_TopLineHeight+m_DrawAreaRect.height*0.75)); #ifdef __WXMSW__ pen.SetStyle(wxPENSTYLE_SHORT_DASH); dc->SetPen(pen); #endif dc->DrawLine(m_LeftLegend+3, (int)(m_TopLineHeight+m_DrawAreaRect.height*0.5), m_WindowRect.width-3-m_RightLegend, (int)(m_TopLineHeight+m_DrawAreaRect.height*0.5)); }
void DashboardInstrument_RudderAngle::DrawFrame(wxGCDC* dc) { // We don't need the upper part // Move center up wxSize size = GetClientSize(); wxColour cl; m_cx = size.x / 2; m_cy = m_TitleHeight + (size.y - m_TitleHeight) * 0.38; m_radius = (size.y - m_TitleHeight)*.6; dc->SetBrush(*wxTRANSPARENT_BRUSH); wxPen pen; pen.SetStyle(wxPENSTYLE_SOLID); pen.SetWidth(2); GetGlobalColor(_T("DASHF"), &cl); pen.SetColour(cl); dc->SetPen(pen); double angle1 = deg2rad(215); // 305-ANGLE_OFFSET double angle2 = deg2rad(-35); // 55-ANGLE_OFFSET wxCoord x1 = m_cx + (m_radius * cos(angle1)); wxCoord y1 = m_cy + (m_radius * sin(angle1)); wxCoord x2 = m_cx + (m_radius * cos(angle2)); wxCoord y2 = m_cy + (m_radius * sin(angle2)); dc->DrawArc(x1, y1, x2, y2, m_cx, m_cy); dc->DrawLine(x1, y1, x2, y2); }
void DashboardInstrument_RudderAngle::DrawFrame(wxBufferedDC* dc) { // We don't need the upper part // Move center up wxRect rect = GetClientRect(); wxColour cl; m_cx = rect.width / 2; m_cy = m_TitleHeight + (rect.height - m_TitleHeight) * 0.38; m_radius = (rect.height - m_TitleHeight)*.6; dc->SetBrush(*wxTRANSPARENT_BRUSH); wxPen pen; pen.SetStyle(wxSOLID); GetGlobalColor(_T("BLUE2"), &cl); pen.SetColour(cl); dc->SetPen(pen); double angle1 = deg2rad(215); // 305-ANGLE_OFFSET double angle2 = deg2rad(-35); // 55-ANGLE_OFFSET wxCoord x1 = m_cx + (m_radius * cos(angle1)); wxCoord y1 = m_cy + (m_radius * sin(angle1)); wxCoord x2 = m_cx + (m_radius * cos(angle2)); wxCoord y2 = m_cy + (m_radius * sin(angle2)); dc->DrawArc(x1, y1, x2, y2, m_cx, m_cy); dc->DrawLine(x1, y1, x2, y2); }
void TacticsInstrument_BearingCompass::DrawBearing(wxGCDC* dc) { wxColour cl; // no border for the circle dc->SetPen(*wxTRANSPARENT_PEN); GetGlobalColor(_T("URED"), &cl); wxBrush brush; brush.SetStyle(wxSOLID); brush.SetColour(cl); dc->SetBrush(brush); double value = deg2rad(m_Bearing) + deg2rad(m_AngleStart - ANGLE_OFFSET); dc->DrawCircle(m_cx + (m_radius * 0.8 * cos(value)), m_cy + (m_radius * 0.8 * sin(value)), m_radius / 16); wxPoint brg[2]; brg[0].x = m_cx + (m_radius * 0.8 * cos(value)); brg[0].y = m_cy + (m_radius * 0.8 * sin(value)); brg[1].x = m_cx + (m_radius * 0.98 * cos(value)); brg[1].y = m_cy + (m_radius * 0.98 * sin(value)); wxPen pen2; pen2.SetStyle(wxSOLID); pen2.SetColour(cl); pen2.SetWidth(2); dc->SetPen(pen2); dc->DrawLine(brg[0],brg[1]); dc->SetPen(*wxTRANSPARENT_PEN); }
void DashboardInstrument_Dial::Draw(wxGCDC* bdc) { wxColour c1; GetGlobalColor(_T("DASHB"), &c1); wxBrush b1(c1); bdc->SetBackground(b1); bdc->Clear(); wxSize size = GetClientSize(); m_cx = size.x / 2; int availableHeight = size.y - m_TitleHeight - 6; int width, height; bdc->GetTextExtent( _T("000"), &width, &height, 0, 0, g_pFontLabel ); m_cy = m_TitleHeight + 2; m_cy += availableHeight / 2; m_radius = availableHeight / 2; DrawLabels(bdc); DrawFrame(bdc); DrawMarkers(bdc); DrawBackground(bdc); DrawData(bdc, m_MainValue, m_MainValueUnit, m_MainValueFormat, m_MainValueOption); DrawData(bdc, m_ExtraValue, m_ExtraValueUnit, m_ExtraValueFormat, m_ExtraValueOption); DrawForeground(bdc); }
VDRControl::VDRControl( wxWindow *pparent, wxWindowID id, vdr_pi *vdr, int speed, int range ) :wxWindow( pparent, id, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, _T("Dashboard") ), m_pvdr(vdr) { wxColour cl; GetGlobalColor(_T("DILG1"), &cl); SetBackgroundColour(cl); wxFlexGridSizer *topsizer = new wxFlexGridSizer(2); topsizer->AddGrowableCol(1); wxStaticText *itemStaticText01 = new wxStaticText( this, wxID_ANY, _("Speed:") ); topsizer->Add( itemStaticText01, 0, wxEXPAND|wxALL, 2 ); m_pslider = new wxSlider( this, wxID_ANY, speed, 1, 100, wxDefaultPosition, wxSize( 200, 20) ); topsizer->Add( m_pslider, 1, wxALL|wxEXPAND, 2 ); m_pslider->Connect( wxEVT_COMMAND_SLIDER_UPDATED, wxCommandEventHandler(VDRControl::OnSliderUpdated), NULL, this); wxStaticText *itemStaticText02 = new wxStaticText( this, wxID_ANY, _("Progress:") ); topsizer->Add( itemStaticText02, 0, wxEXPAND|wxALL, 2 ); m_pgauge = new wxGauge( this, wxID_ANY, range, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL ); topsizer->Add( m_pgauge, 1, wxALL|wxEXPAND, 2 ); SetSizer( topsizer ); topsizer->Fit( this ); Layout(); }
void RolloverWin::SetBitmap( int rollover ) { wxDC* cdc = new wxScreenDC(); wxPoint canvasPos = GetParent()->GetScreenPosition(); wxMemoryDC mdc; delete m_pbm; m_pbm = new wxBitmap( m_size.x, m_size.y, -1 ); mdc.SelectObject( *m_pbm ); mdc.Blit( 0, 0, m_size.x, m_size.y, cdc, m_position.x + canvasPos.x, m_position.y + canvasPos.y ); delete cdc; ocpnDC dc( mdc ); switch( rollover ) { case AIS_ROLLOVER: AlphaBlending( dc, 0, 0, m_size.x, m_size.y, 6.0, GetGlobalColor( _T ( "YELO1" ) ), 172 ); mdc.SetTextForeground( FontMgr::Get().GetFontColor( _("AISRollover") ) ); break; case TC_ROLLOVER: AlphaBlending( dc, 0, 0, m_size.x, m_size.y, 0.0, GetGlobalColor( _T ( "YELO1" ) ), 255 ); mdc.SetTextForeground( FontMgr::Get().GetFontColor( _("TideCurrentGraphRollover") ) ); break; default: case LEG_ROLLOVER: AlphaBlending( dc, 0, 0, m_size.x, m_size.y, 6.0, GetGlobalColor( _T ( "YELO1" ) ), 172 ); mdc.SetTextForeground( FontMgr::Get().GetFontColor( _("RouteLegInfoRollover") ) ); break; } if(m_plabelFont && m_plabelFont->IsOk()) { // Draw the text mdc.SetFont( *m_plabelFont ); mdc.DrawLabel( m_string, wxRect( 0, 0, m_size.x, m_size.y ), wxALIGN_CENTRE_HORIZONTAL | wxALIGN_CENTRE_VERTICAL); } SetSize( m_position.x, m_position.y, m_size.x, m_size.y ); // Assumes a nominal 32 x 32 cursor // Retrigger the auto timeout if( m_timeout_sec > 0 ) m_timer_timeout.Start( m_timeout_sec * 1000, wxTIMER_ONE_SHOT ); }
void VDRControl::SetColorScheme( PI_ColorScheme cs ) { wxColour cl; GetGlobalColor( _T("DILG1"), &cl ); SetBackgroundColour( cl ); Refresh(false); }