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 ThumbWin::OnPaint( wxPaintEvent& event ) { wxPaintDC dc( this ); if( pThumbChart ) { if( pThumbChart->GetThumbData() ) { if( pThumbChart->GetThumbData()->pDIBThumb ) dc.DrawBitmap( *( pThumbChart->GetThumbData()->pDIBThumb ), 0, 0, false ); wxPen ppPen( GetGlobalColor( _T("CHBLK") ), 1, wxPENSTYLE_SOLID ); dc.SetPen( ppPen ); wxBrush yBrush( GetGlobalColor( _T("CHYLW") ), wxBRUSHSTYLE_SOLID ); dc.SetBrush( yBrush ); dc.DrawCircle( pThumbChart->GetThumbData()->ShipX, pThumbChart->GetThumbData()->ShipY, 6 ); } } }
// build a texture to hold minimum sized rectangles and icons used to render the chart bar // this texture is only updated if the color scheme or chart bar height change void Piano::BuildGLTexture() { int h = GetHeight(); wxBrush tbackBrush; // transparent back brush ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); if(style->chartStatusWindowTransparent) tbackBrush = wxColour(1,1,1); else tbackBrush = m_backBrush; wxBrush brushes[] = { m_scBrush, m_cBrush, m_svBrush, m_vBrush, m_slBrush, m_tBrush, m_uvBrush }; m_tex_piano_height = h; m_texw = 64; m_texh = ((sizeof brushes) / (sizeof *brushes)) * h; m_texh += 4*16; // for icons; m_texh = NextPow2(m_texh); if(!m_tex) glGenTextures( 1, &m_tex ); glBindTexture(GL_TEXTURE_2D, m_tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); wxBitmap bmp(m_texw, m_texh); wxMemoryDC dc(bmp); dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetBrush(tbackBrush); dc.DrawRectangle(0, 0, m_texw, m_texh); // draw the needed rectangles with minimal width wxPen ppPen( GetGlobalColor( _T("CHBLK") ), 1, wxPENSTYLE_SOLID ); dc.SetPen( ppPen ); for(unsigned int b = 0; b < (sizeof brushes) / (sizeof *brushes); b++) { unsigned int x = 0, y = h * b; dc.SetBrush(brushes[b]); int u = 3, v = 2; dc.DrawRectangle(x+u, y+v, 3, h-2*v); x+=3+2*u; dc.DrawRoundedRectangle(x+u, y+v, 9, h-2*v, 4); x+=9+2*u; int w = 3; dc.DrawRoundedRectangle(x+u, y+v, 12, h-2*v, 4); dc.SetBrush( m_backBrush ); dc.DrawRoundedRectangle(x+u+w, y+v+w, 12-2*w, h-2*v-2*w, 3); x+=12+2*u; if(x >= m_texw) printf("texture too small\n"); } dc.SelectObject( wxNullBitmap ); wxImage image = bmp.ConvertToImage(); unsigned char *data = new unsigned char[4*m_texw*m_texh], *d = data, *e = image.GetData(), *a = image.GetAlpha(); for(unsigned int i=0; i<m_texw*m_texh; i++) { if(style->chartStatusWindowTransparent && e[0] == 1 && e[1] == 1 && e[2] == 1) d[3] = 0; else d[3] = 255; memcpy(d, e, 3), d+=4, e+=3; } glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_texw, m_texh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); delete [] data; // put the bitmaps in below wxBitmap *bitmaps[] = {m_pInVizIconBmp, m_pTmercIconBmp, m_pSkewIconBmp, m_pPolyIconBmp}; for(unsigned int i = 0; i < (sizeof bitmaps) / (sizeof *bitmaps); i++) { int iw = bitmaps[i]->GetWidth(), ih = bitmaps[i]->GetHeight(); wxASSERT(ih <= 16); wxImage im = bitmaps[i]->ConvertToImage(); unsigned char *data = new unsigned char[4*iw*ih], *d = data, *e = im.GetData(), *a = im.GetAlpha(); for(int j = 0; j<iw*ih; j++) { memcpy(d, e, 3), d+=3, e+=3; *d = *a, d++, a++; } int off = ((sizeof brushes) / (sizeof *brushes))*h + 16*i; glTexSubImage2D( GL_TEXTURE_2D, 0, 0, off, iw, ih, GL_RGBA, GL_UNSIGNED_BYTE, data ); delete [] data; } }
void Piano::Paint( int y, ocpnDC& dc, wxDC *shapeDC ) { if(shapeDC) { shapeDC->SetBackground( *wxBLACK_BRUSH); shapeDC->SetBrush( *wxWHITE_BRUSH); shapeDC->SetPen( *wxWHITE_PEN); shapeDC->Clear(); } ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); if(!style->chartStatusWindowTransparent) { dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetBrush( m_backBrush ); dc.DrawRectangle( 0, y, cc1->GetClientSize().x, GetHeight() ); } // Create the Piano Keys int nKeys = m_key_array.GetCount(); wxPen ppPen( GetGlobalColor( _T("CHBLK") ), 1, wxPENSTYLE_SOLID ); dc.SetPen( ppPen ); for( int i = 0; i < nKeys; i++ ) { int key_db_index = m_key_array.Item( i ); if( -1 == key_db_index ) continue; bool selected = InArray(m_active_index_array, key_db_index); if( ChartData->GetDBChartType( key_db_index ) == CHART_TYPE_CM93 || ChartData->GetDBChartType( key_db_index ) == CHART_TYPE_CM93COMP ) { if(selected) dc.SetBrush( m_scBrush ); else dc.SetBrush( m_cBrush ); } else if( ChartData->GetDBChartFamily( key_db_index ) == CHART_FAMILY_VECTOR ) { if(selected) dc.SetBrush( m_svBrush ); else dc.SetBrush( m_vBrush ); } else { // Raster Chart if(selected) dc.SetBrush( m_slBrush ); else dc.SetBrush( m_tBrush ); } #if 0 // Check to see if this box appears in the sub_light array // If so, add a crosshatch pattern to the brush if(InArray(m_eclipsed_index_array, key_db_index)) { wxBrush ebrush( dc.GetBrush().GetColour(), wxCROSSDIAG_HATCH ); dc.SetBrush(ebrush); } #endif if(m_bBusy) dc.SetBrush( m_uvBrush ); wxRect box = KeyRect.Item( i ); box.y += y; if( m_brounded ) { dc.DrawRoundedRectangle( box.x, box.y, box.width, box.height, 4 ); if(shapeDC) shapeDC->DrawRoundedRectangle( box.x, box.y, box.width, box.height, 4 ); } else { dc.DrawRectangle( box.x, box.y, box.width, box.height ); if(shapeDC) shapeDC->DrawRectangle( box ); } if(InArray(m_eclipsed_index_array, key_db_index)) { dc.SetBrush( m_backBrush ); int w = 3; dc.DrawRoundedRectangle( box.x + w, box.y + w, box.width - ( 2 * w ), box.height - ( 2 * w ), 3 ); } // Look in the current noshow array for this index if(InArray(m_noshow_index_array, key_db_index) && m_pInVizIconBmp && m_pInVizIconBmp->IsOk() ) dc.DrawBitmap(ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pInVizIconBmp ), box.x + 4, box.y + 3, false ); // Look in the current skew array for this index if(InArray(m_skew_index_array, key_db_index) && m_pSkewIconBmp && m_pSkewIconBmp->IsOk()) dc.DrawBitmap(ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pSkewIconBmp ), box.x + box.width - m_pSkewIconBmp->GetWidth() - 4, box.y + 2, false ); // Look in the current tmerc array for this index if(InArray(m_tmerc_index_array, key_db_index) && m_pTmercIconBmp && m_pTmercIconBmp->IsOk() ) dc.DrawBitmap(ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pTmercIconBmp ), box.x + box.width - m_pTmercIconBmp->GetWidth() - 4, box.y + 2, false ); // Look in the current poly array for this index if(InArray(m_poly_index_array, key_db_index) && m_pPolyIconBmp && m_pPolyIconBmp->IsOk() ) dc.DrawBitmap(ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pPolyIconBmp ), box.x + box.width - m_pPolyIconBmp->GetWidth() - 4, box.y + 2, false ); } }
void PianoWin::OnPaint(wxPaintEvent& event) { int width, height; GetClientSize(&width, &height ); wxPaintDC dc(this); dc.SetBackground(m_backBrush); dc.Clear(); // Create the Piano Keys int nKeys = m_key_array.GetCount(); // assert(nKeys <= KEY_REGIONS_MAX); if(nKeys) { wxPen ppPen(GetGlobalColor(_T("CHBLK")), 1, wxSOLID); dc.SetPen(ppPen); dc.SetBrush(m_tBrush); for(int i=0 ; i<nKeys ; i++) { int key_db_index = m_key_array.Item(i); if(-1 == key_db_index) continue; if(ChartData->GetDBChartType(m_key_array.Item(i)) == CHART_TYPE_S57) { dc.SetBrush(m_vBrush); for(unsigned int ino=0 ; ino < m_active_index_array.GetCount() ; ino++) { if(m_active_index_array.Item(ino) == key_db_index) // chart is in the active list dc.SetBrush(m_svBrush); } } else if(ChartData->GetDBChartType(m_key_array.Item(i)) == CHART_TYPE_CM93) { dc.SetBrush(m_cBrush); for(unsigned int ino=0 ; ino < m_active_index_array.GetCount() ; ino++) { if(m_active_index_array.Item(ino) == key_db_index) // chart is in the active list dc.SetBrush(m_scBrush); } } else if(ChartData->GetDBChartType(m_key_array.Item(i)) == CHART_TYPE_CM93COMP) { dc.SetBrush(m_cBrush); for(unsigned int ino=0 ; ino < m_active_index_array.GetCount() ; ino++) { if(m_active_index_array.Item(ino) == key_db_index) // chart is in the active list dc.SetBrush(m_scBrush); } } else { dc.SetBrush(m_tBrush); for(unsigned int ino=0 ; ino < m_active_index_array.GetCount() ; ino++) { if(m_active_index_array.Item(ino) == key_db_index) // chart is in the active list dc.SetBrush(m_slBrush); } } // Check to see if this box appears in the sub_light array // If so, add a crosshatch pattern to the brush for(unsigned int ino=0 ; ino < m_sublite_index_array.GetCount() ; ino++) { if(m_sublite_index_array.Item(ino) == key_db_index) // chart is in the sublite list { wxBrush ebrush(dc.GetBrush().GetColour(), wxCROSSDIAG_HATCH); // dc.SetBrush(ebrush); } } wxRect box = KeyRegion[i].GetBox(); if(m_brounded) dc.DrawRoundedRectangle(box.x, box.y, box.width, box.height, 4); else dc.DrawRectangle(box); for(unsigned int ino=0 ; ino < m_sublite_index_array.GetCount() ; ino++) { if(m_sublite_index_array.Item(ino) == key_db_index) // chart is in the sublite list { dc.SetBrush(dc.GetBackground()); int w = 3; dc.DrawRoundedRectangle(box.x + w, box.y + w, box.width - (2*w), box.height - (2 * w), 3); } } // Look in the current noshow array for this index for(unsigned int ino=0 ; ino < m_noshow_index_array.GetCount() ; ino++) { if(m_noshow_index_array.Item(ino) == key_db_index) // chart is in the noshow list { if(m_pInVizIconBmp && m_pInVizIconBmp->IsOk()) dc.DrawBitmap(*m_pInVizIconBmp, box.x + 4, box.y + 3, true); break; } } // Look in the current skew array for this index for(unsigned int ino=0 ; ino < m_skew_index_array.GetCount() ; ino++) { if(m_skew_index_array.Item(ino) == key_db_index) // chart is in the list { if(m_pSkewIconBmp && m_pSkewIconBmp->IsOk()) dc.DrawBitmap(*m_pSkewIconBmp, box.x + box.width - m_pSkewIconBmp->GetWidth(), box.y, true); break; } } // Look in the current tmerc array for this index for(unsigned int ino=0 ; ino < m_tmerc_index_array.GetCount() ; ino++) { if(m_tmerc_index_array.Item(ino) == key_db_index) // chart is in the list { if(m_pTmercIconBmp && m_pTmercIconBmp->IsOk()) dc.DrawBitmap(*m_pTmercIconBmp,box.x + box.width - m_pTmercIconBmp->GetWidth(), box.y, true); break; } } // Look in the current poly array for this index for(unsigned int ino=0 ; ino < m_poly_index_array.GetCount() ; ino++) { if(m_poly_index_array.Item(ino) == key_db_index) // chart is in the list { if(m_pPolyIconBmp && m_pPolyIconBmp->IsOk()) dc.DrawBitmap(*m_pPolyIconBmp,box.x + box.width - m_pPolyIconBmp->GetWidth(), box.y, true); break; } } } } }
void PianoWin::OnPaint( wxPaintEvent& event ) { ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); int width, height; GetClientSize( &width, &height ); wxPaintDC dc( this ); wxBitmap shape = wxBitmap( width, height ); wxMemoryDC shapeDc( shape ); shapeDc.SetBackground( *wxBLACK_BRUSH); shapeDc.SetBrush( *wxWHITE_BRUSH); shapeDc.SetPen( *wxWHITE_PEN); shapeDc.Clear(); dc.SetBackground( m_backBrush ); dc.Clear(); // Create the Piano Keys int nKeys = m_key_array.GetCount(); if( nKeys ) { wxPen ppPen( GetGlobalColor( _T("CHBLK") ), 1, wxSOLID ); dc.SetPen( ppPen ); dc.SetBrush( m_tBrush ); for( int i = 0; i < nKeys; i++ ) { int key_db_index = m_key_array.Item( i ); if( -1 == key_db_index ) continue; if( ChartData->GetDBChartType( m_key_array.Item( i ) ) == CHART_TYPE_S57 ) { dc.SetBrush( m_vBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_svBrush ); } } else if( ChartData->GetDBChartType( m_key_array.Item( i ) ) == CHART_TYPE_CM93 ) { dc.SetBrush( m_cBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_scBrush ); } } else if( ChartData->GetDBChartType( m_key_array.Item( i ) ) == CHART_TYPE_CM93COMP ) { dc.SetBrush( m_cBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_scBrush ); } } else { dc.SetBrush( m_tBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_slBrush ); } } // Check to see if this box appears in the sub_light array // If so, add a crosshatch pattern to the brush for( unsigned int ino = 0; ino < m_sublite_index_array.GetCount(); ino++ ) { if( m_sublite_index_array.Item( ino ) == key_db_index ) // chart is in the sublite list { wxBrush ebrush( dc.GetBrush().GetColour(), wxCROSSDIAG_HATCH ); // dc.SetBrush(ebrush); } } wxRect box = KeyRegion.Item( i ).GetBox(); if( m_brounded ) { dc.DrawRoundedRectangle( box.x, box.y, box.width, box.height, 4 ); shapeDc.DrawRoundedRectangle( box.x, box.y, box.width, box.height, 4 ); } else { dc.DrawRectangle( box ); shapeDc.DrawRectangle( box ); } for( unsigned int ino = 0; ino < m_sublite_index_array.GetCount(); ino++ ) { if( m_sublite_index_array.Item( ino ) == key_db_index ) { // chart is in the sublite list dc.SetBrush( dc.GetBackground() ); int w = 3; dc.DrawRoundedRectangle( box.x + w, box.y + w, box.width - ( 2 * w ), box.height - ( 2 * w ), 3 ); } } // Look in the current noshow array for this index for( unsigned int ino = 0; ino < m_noshow_index_array.GetCount(); ino++ ) { if( m_noshow_index_array.Item( ino ) == key_db_index ) { // chart is in the noshow list if( m_pInVizIconBmp && m_pInVizIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pInVizIconBmp ), box.x + 4, box.y + 3, false ); break; } } // Look in the current skew array for this index for( unsigned int ino = 0; ino < m_skew_index_array.GetCount(); ino++ ) { if( m_skew_index_array.Item( ino ) == key_db_index ) { // chart is in the list if( m_pSkewIconBmp && m_pSkewIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pSkewIconBmp ), box.x + box.width - m_pSkewIconBmp->GetWidth() - 4, box.y + 2, false ); break; } } // Look in the current tmerc array for this index for( unsigned int ino = 0; ino < m_tmerc_index_array.GetCount(); ino++ ) { if( m_tmerc_index_array.Item( ino ) == key_db_index ) { // chart is in the list if( m_pTmercIconBmp && m_pTmercIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pTmercIconBmp ), box.x + box.width - m_pTmercIconBmp->GetWidth() - 4, box.y + 2, false ); break; } } // Look in the current poly array for this index for( unsigned int ino = 0; ino < m_poly_index_array.GetCount(); ino++ ) { if( m_poly_index_array.Item( ino ) == key_db_index ) { // chart is in the list if( m_pPolyIconBmp && m_pPolyIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pPolyIconBmp ), box.x + box.width - m_pPolyIconBmp->GetWidth() - 4, box.y + 2, false ); break; } } } #ifndef __WXMAC__ if( style->chartStatusWindowTransparent ) ((wxDialog*) GetParent())->SetShape( wxRegion( shape, *wxBLACK, 0 ) ); } else { // SetShape() with a completely empty shape doesn't work, and leaving the shape // but hiding the window causes artifacts when dragging in GL mode on MSW. // The best solution found so far is to show just a single pixel, this is less // disturbing than flashing piano keys when dragging. (wxWidgets 2.8) if( style->chartStatusWindowTransparent ) ((wxDialog*) GetParent())->SetShape( wxRegion( wxRect(0,0,1,1) ) ); } #else }