void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList() { m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 ); m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 ); // Select a not show cell, to avoid a wrong cell selection for user int row = 0; wxString layername; for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq ) { LAYER_ID layerid = *ui_seq; if( !IsCopperLayer( layerid ) ) break; COLOR4D color = GetLayerColor( layerid ); layername = GetLayerName( layerid ); if( row ) m_leftGridLayers->AppendRows( 1 ); m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color.ToColour() ); m_leftGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername ); m_layersId.push_back( layerid ); if( m_frontLayer == layerid ) { SetGridCursor( m_leftGridLayers, row, true ); m_leftRowSelected = row; } if( row ) m_rightGridLayers->AppendRows( 1 ); m_rightGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM, color.ToColour() ); m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername ); if( m_backLayer == layerid ) { SetGridCursor( m_rightGridLayers, row, true ); m_rightRowSelected = row; } row++; } m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM); m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM); }
void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event ) { wxBitmapButton* button = (wxBitmapButton*) event.GetEventObject(); wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) ); COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData(); wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) ); wxColourData colourData; colourData.SetColour( currentColors[ colorButton->m_Layer ].ToColour() ); wxColourDialog *dialog = new wxColourDialog( this, &colourData ); COLOR4D newColor = COLOR4D::UNSPECIFIED; if( dialog->ShowModal() == wxID_OK ) { newColor = COLOR4D( dialog->GetColourData().GetColour() ); } if( newColor == COLOR4D::UNSPECIFIED || currentColors[ colorButton->m_Layer ] == newColor ) return; currentColors[ colorButton->m_Layer ] = newColor; wxMemoryDC iconDC; wxBitmap bitmap = button->GetBitmapLabel(); iconDC.SelectObject( bitmap ); iconDC.SetPen( *wxBLACK_PEN ); wxBrush brush; brush.SetColour( newColor.ToColour() ); brush.SetStyle( wxBRUSHSTYLE_SOLID ); iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); button->SetBitmapLabel( bitmap ); button->Refresh(); Refresh( false ); }
void SELECT_COPPER_LAYERS_PAIR_DIALOG::SetGridCursor( wxGrid* aGrid, int aRow, bool aEnable ) { if( aEnable ) { LAYER_ID layerid = m_layersId[aRow]; COLOR4D color = GetLayerColor( layerid ); aGrid->SetCellValue( aRow, SELECT_COLNUM, wxT("X") ); aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color.ToColour() ); aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM ); } else { aGrid->SetCellValue( aRow, SELECT_COLNUM, wxEmptyString ); aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, aGrid->GetDefaultCellBackgroundColour() ); aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM ); } }
void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg ) { BASE_SCREEN* Screen = GetScreen(); if( Screen == NULL ) return; COLOR4D bgColor = GetParent()->GetDrawBgColor(); // TODO(JE): Is this correct? if( bgColor.GetBrightness() > 0.5 ) { g_XorMode = GR_NXOR; g_GhostColor = BLACK; } else { g_XorMode = GR_XOR; g_GhostColor = WHITE; } GRResetPenAndBrush( DC ); DC->SetBackground( wxBrush( bgColor.ToColour() ) ); DC->SetBackgroundMode( wxSOLID ); if( erasebg ) EraseScreen( DC ); GetParent()->RedrawActiveWindow( DC, erasebg ); // Verfies that the clipping is working correctly. If these two sets of numbers are // not the same or really close. The clipping algorithms are broken. wxLogTrace( kicadTraceCoords, wxT( "Clip box: (%d, %d, %d, %d), Draw extents (%d, %d, %d, %d)" ), m_ClipBox.GetX(), m_ClipBox.GetY(), m_ClipBox.GetRight(), m_ClipBox.GetBottom(), DC->MinX(), DC->MinY(), DC->MaxX(), DC->MaxY() ); }
void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls() { wxStaticText* label; int buttonId = 1800; m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( m_mainBoxSizer ); BUTTONINDEX* groups = buttonGroups; wxBoxSizer* columnBoxSizer = NULL; while( groups->m_Buttons != NULL ) { COLORBUTTON* buttons = groups->m_Buttons; columnBoxSizer = new wxBoxSizer( wxVERTICAL ); m_mainBoxSizer->Add( columnBoxSizer, 1, wxALIGN_TOP | wxLEFT, 5 ); wxBoxSizer* rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); // Add a text string to identify the column of color select buttons. label = new wxStaticText( this, wxID_ANY, groups->m_Name ); // Make the column label font bold. wxFont font( label->GetFont() ); font.SetWeight( wxFONTWEIGHT_BOLD ); label->SetFont( font ); rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); while( buttons->m_Layer >= 0 ) { rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxALL, 0 ); COLOR4D color = GetLayerColor( SCH_LAYER_ID( buttons->m_Layer ) ); currentColors[ buttons->m_Layer ] = color; wxMemoryDC iconDC; wxBitmap bitmap( m_butt_size_pix ); iconDC.SelectObject( bitmap ); iconDC.SetPen( *wxBLACK_PEN ); wxBrush brush; brush.SetColour( color.ToColour() ); brush.SetStyle( wxBRUSHSTYLE_SOLID ); iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, m_butt_size_pix.x, m_butt_size_pix.y ); wxBitmapButton* bitmapButton = new wxBitmapButton( this, buttonId, bitmap, wxDefaultPosition, m_butt_size_pix + m_butt_border_pix + wxSize( 1, 1 ) ); bitmapButton->SetClientData( (void*) buttons ); rowBoxSizer->Add( bitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); label = new wxStaticText( this, wxID_ANY, wxGetTranslation( buttons->m_Name ) ); rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); buttonId += 1; buttons++; } groups++; } Connect( 1800, buttonId, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) ); // Dialog now needs to be resized, but the associated command is found elsewhere. }
void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls() { wxStaticText* label; int buttonId = 1800; m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( m_mainBoxSizer ); BUTTONINDEX* groups = buttonGroups; wxBoxSizer* columnBoxSizer = NULL; while( groups->m_Buttons != NULL ) { COLORBUTTON* buttons = groups->m_Buttons; columnBoxSizer = new wxBoxSizer( wxVERTICAL ); m_mainBoxSizer->Add( columnBoxSizer, 1, wxALIGN_TOP | wxLEFT | wxTOP, 5 ); wxBoxSizer* rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); // Add a text string to identify the column of color select buttons. label = new wxStaticText( this, wxID_ANY, groups->m_Name ); // Make the column label font bold. wxFont font( label->GetFont() ); font.SetWeight( wxFONTWEIGHT_BOLD ); label->SetFont( font ); rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); while( buttons->m_Layer >= 0 ) { rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxALL, 0 ); COLOR4D color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) ); currentColors[ buttons->m_Layer ] = color; wxMemoryDC iconDC; wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); iconDC.SelectObject( bitmap ); iconDC.SetPen( *wxBLACK_PEN ); wxBrush brush; brush.SetColour( color.ToColour() ); brush.SetStyle( wxBRUSHSTYLE_SOLID ); iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); wxBitmapButton* bitmapButton = new wxBitmapButton( this, buttonId, bitmap, wxDefaultPosition, wxSize( BUTT_SIZE_X+8, BUTT_SIZE_Y+6 ) ); bitmapButton->SetClientData( (void*) buttons ); rowBoxSizer->Add( bitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); label = new wxStaticText( this, wxID_ANY, wxGetTranslation( buttons->m_Name ) ); rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); buttonId += 1; buttons++; } groups++; } COLOR4D bgColor = GetDrawFrame()->GetDrawBgColor(); wxMemoryDC iconDC; wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); iconDC.SelectObject( bitmap ); iconDC.SetPen( *wxBLACK_PEN ); wxBrush brush; brush.SetColour( bgColor.ToColour() ); brush.SetStyle( wxBRUSHSTYLE_SOLID ); iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); buttonId++; wxBitmapButton* selBgColorBtn = new wxBitmapButton( this, buttonId, bitmap, wxDefaultPosition, wxSize( BUTT_SIZE_X + 8, BUTT_SIZE_Y + 6 ) ); selBgColorBtn->SetClientData( (void*) &bgColorButton ); Connect( 1800, buttonId, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) ); wxStaticText* bgColorLabel = new wxStaticText( this, wxID_ANY, _( "Background Color" ) ); wxFont font( bgColorLabel->GetFont() ); font.SetWeight( wxFONTWEIGHT_BOLD ); bgColorLabel->SetFont( font ); if( columnBoxSizer ) { // Add a spacer to improve appearance. columnBoxSizer->AddSpacer( 5 ); columnBoxSizer->Add( bgColorLabel, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); columnBoxSizer->Add( selBgColorBtn, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); } currentColors[ LAYER_BACKGROUND ] = bgColor; // Dialog now needs to be resized, but the associated command is found elsewhere. }
void PCB_ONE_LAYER_SELECTOR::buildList() { // Hide layerid column which is used only to know the layer id // not to be shown in dialogs m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 ); m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 ); int left_row = 0; int right_row = 0; wxString layername; for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq ) { LAYER_ID layerid = *ui_seq; if( m_notAllowedLayersMask[layerid] ) continue; COLOR4D color = GetLayerColor( layerid ); layername = GetLayerName( layerid ); if( IsCopperLayer( layerid ) ) { if( left_row ) m_leftGridLayers->AppendRows( 1 ); m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM, color.ToColour() ); m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername ); if( m_layerSelected == layerid ) { m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, wxT("X") ); m_leftGridLayers->SetCellBackgroundColour ( left_row, SELECT_COLNUM, color.ToColour() ); m_leftGridLayers->SetGridCursor( left_row, LAYERNAME_COLNUM ); } m_layersIdLeftColumn.push_back( layerid ); left_row++; } else { if( right_row ) m_rightGridLayers->AppendRows( 1 ); m_rightGridLayers->SetCellBackgroundColour ( right_row, COLOR_COLNUM, color.ToColour() ); m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername ); if( m_layerSelected == layerid ) { m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, wxT("X") ); m_rightGridLayers->SetCellBackgroundColour ( right_row, SELECT_COLNUM, color.ToColour() ); m_rightGridLayers->SetGridCursor( right_row, LAYERNAME_COLNUM ); } m_layersIdRightColumn.push_back( layerid ); right_row++; } } // Show only populated lists: if( left_row <= 0 ) m_leftGridLayers->Show( false ); if( right_row <= 0 ) m_rightGridLayers->Show( false ); m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM); m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM); }