|
|
|
@ -16,53 +16,73 @@ |
|
|
|
|
|
|
|
#define ID_COLOR_SETUP 1800
|
|
|
|
|
|
|
|
// Specify the width and height of every (color-displaying / bitmap) button
|
|
|
|
const int BUTT_SIZE_X = 16; |
|
|
|
const int BUTT_SIZE_Y = 16; |
|
|
|
|
|
|
|
static ColorButton GeneralColorButtons[] = { |
|
|
|
{ _( "Wire" ), LAYER_WIRE }, |
|
|
|
{ _( "Bus" ), LAYER_BUS }, |
|
|
|
{ _( "Junction" ), LAYER_JUNCTION }, |
|
|
|
{ _( "Label" ), LAYER_LOCLABEL }, |
|
|
|
{ _( "Global label" ), LAYER_GLOBLABEL }, |
|
|
|
{ _( "Net name" ), LAYER_NETNAM }, |
|
|
|
{ _( "Notes" ), LAYER_NOTES }, |
|
|
|
|
|
|
|
/********************/ |
|
|
|
/* Layer menu list. */ |
|
|
|
/********************/ |
|
|
|
|
|
|
|
struct COLORBUTTON |
|
|
|
{ |
|
|
|
wxString m_Name; |
|
|
|
int m_Layer; |
|
|
|
}; |
|
|
|
|
|
|
|
struct BUTTONINDEX |
|
|
|
{ |
|
|
|
wxString m_Name; |
|
|
|
COLORBUTTON* m_Buttons; |
|
|
|
}; |
|
|
|
|
|
|
|
static COLORBUTTON generalColorButtons[] = { |
|
|
|
{ _( "Wire" ), LAYER_WIRE }, |
|
|
|
{ _( "Bus" ), LAYER_BUS }, |
|
|
|
{ _( "Junction" ), LAYER_JUNCTION }, |
|
|
|
{ _( "Label" ), LAYER_LOCLABEL }, |
|
|
|
{ _( "Global label" ), LAYER_GLOBLABEL }, |
|
|
|
{ _( "Net name" ), LAYER_NETNAM }, |
|
|
|
{ _( "Notes" ), LAYER_NOTES }, |
|
|
|
{ _( "No Connect Symbol" ), LAYER_NOCONNECT }, |
|
|
|
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
|
|
|
}; |
|
|
|
|
|
|
|
static ColorButton ComponentColorButtons[] = { |
|
|
|
{ _( "Body" ), LAYER_DEVICE }, |
|
|
|
{ _( "Body background" ), LAYER_DEVICE_BACKGROUND }, |
|
|
|
{ _( "Pin" ), LAYER_PIN }, |
|
|
|
{ _( "Pin number" ), LAYER_PINNUM }, |
|
|
|
{ _( "Pin name" ), LAYER_PINNAM }, |
|
|
|
{ _( "Reference" ), LAYER_REFERENCEPART }, |
|
|
|
{ _( "Value" ), LAYER_VALUEPART }, |
|
|
|
{ _( "Fields" ), LAYER_FIELDS }, |
|
|
|
static COLORBUTTON componentColorButtons[] = { |
|
|
|
{ _( "Body" ), LAYER_DEVICE }, |
|
|
|
{ _( "Body background" ), LAYER_DEVICE_BACKGROUND }, |
|
|
|
{ _( "Pin" ), LAYER_PIN }, |
|
|
|
{ _( "Pin number" ), LAYER_PINNUM }, |
|
|
|
{ _( "Pin name" ), LAYER_PINNAM }, |
|
|
|
{ _( "Reference" ), LAYER_REFERENCEPART }, |
|
|
|
{ _( "Value" ), LAYER_VALUEPART }, |
|
|
|
{ _( "Fields" ), LAYER_FIELDS }, |
|
|
|
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
|
|
|
}; |
|
|
|
|
|
|
|
static ColorButton SheetColorButtons[] = { |
|
|
|
{ _( "Sheet" ), LAYER_SHEET }, |
|
|
|
{ _( "Sheet file name" ), LAYER_SHEETFILENAME }, |
|
|
|
{ _( "Sheet name" ), LAYER_SHEETNAME }, |
|
|
|
{ _( "Sheet label" ), LAYER_SHEETLABEL }, |
|
|
|
{ _( "Hierarchical label" ), LAYER_HIERLABEL }, |
|
|
|
static COLORBUTTON sheetColorButtons[] = { |
|
|
|
{ _( "Sheet" ), LAYER_SHEET }, |
|
|
|
{ _( "Sheet file name" ), LAYER_SHEETFILENAME }, |
|
|
|
{ _( "Sheet name" ), LAYER_SHEETNAME }, |
|
|
|
{ _( "Sheet label" ), LAYER_SHEETLABEL }, |
|
|
|
{ _( "Hierarchical label" ),LAYER_HIERLABEL }, |
|
|
|
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
|
|
|
}; |
|
|
|
|
|
|
|
static ColorButton MiscColorButtons[] = { |
|
|
|
{ _( "Erc warning" ), LAYER_ERC_WARN }, |
|
|
|
{ _( "Erc error" ), LAYER_ERC_ERR }, |
|
|
|
{ _( "Grid" ), LAYER_GRID }, |
|
|
|
static COLORBUTTON miscColorButtons[] = { |
|
|
|
{ _( "Erc warning" ), LAYER_ERC_WARN }, |
|
|
|
{ _( "Erc error" ), LAYER_ERC_ERR }, |
|
|
|
{ _( "Grid" ), LAYER_GRID }, |
|
|
|
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static ButtonIndex buttonGroups[] = { |
|
|
|
{ _( "General" ), GeneralColorButtons }, |
|
|
|
{ _( "Component" ), ComponentColorButtons }, |
|
|
|
{ _( "Sheet" ), SheetColorButtons }, |
|
|
|
{ _( "Miscellaneous" ), MiscColorButtons }, |
|
|
|
static BUTTONINDEX buttonGroups[] = { |
|
|
|
{ _( "General" ), generalColorButtons }, |
|
|
|
{ _( "Component" ), componentColorButtons }, |
|
|
|
{ _( "Sheet" ), sheetColorButtons }, |
|
|
|
{ _( "Miscellaneous" ), miscColorButtons }, |
|
|
|
{ wxT( "" ), NULL } |
|
|
|
}; |
|
|
|
|
|
|
|
@ -81,7 +101,7 @@ DIALOG_COLOR_CONFIG::DIALOG_COLOR_CONFIG() |
|
|
|
|
|
|
|
DIALOG_COLOR_CONFIG::DIALOG_COLOR_CONFIG( EDA_DRAW_FRAME* aParent ) |
|
|
|
{ |
|
|
|
m_Parent = aParent; |
|
|
|
m_parent = aParent; |
|
|
|
Init(); |
|
|
|
Create( aParent ); |
|
|
|
} |
|
|
|
@ -115,38 +135,39 @@ bool DIALOG_COLOR_CONFIG::Create( wxWindow* aParent, |
|
|
|
|
|
|
|
void DIALOG_COLOR_CONFIG::Init() |
|
|
|
{ |
|
|
|
OuterBoxSizer = NULL; |
|
|
|
MainBoxSizer = NULL; |
|
|
|
ColumnBoxSizer = NULL; |
|
|
|
RowBoxSizer = NULL; |
|
|
|
BitmapButton = NULL; |
|
|
|
m_outerBoxSizer = NULL; |
|
|
|
m_mainBoxSizer = NULL; |
|
|
|
m_columnBoxSizer = NULL; |
|
|
|
m_rowBoxSizer = NULL; |
|
|
|
m_bitmapButton = NULL; |
|
|
|
m_SelBgColor = NULL; |
|
|
|
Line = NULL; |
|
|
|
StdDialogButtonSizer = NULL; |
|
|
|
Button = NULL; |
|
|
|
m_line = NULL; |
|
|
|
m_stdDialogButtonSizer = NULL; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COLOR_CONFIG::CreateControls() |
|
|
|
{ |
|
|
|
wxStaticText* label; |
|
|
|
int buttonId = 1800; |
|
|
|
ButtonIndex* groups = buttonGroups; |
|
|
|
wxButton* button; |
|
|
|
wxStaticText* label; |
|
|
|
int buttonId = 1800; |
|
|
|
|
|
|
|
OuterBoxSizer = new wxBoxSizer( wxVERTICAL ); |
|
|
|
SetSizer( OuterBoxSizer ); |
|
|
|
BUTTONINDEX* groups = buttonGroups; |
|
|
|
|
|
|
|
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); |
|
|
|
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT, 5 ); |
|
|
|
m_outerBoxSizer = new wxBoxSizer( wxVERTICAL ); |
|
|
|
SetSizer( m_outerBoxSizer ); |
|
|
|
|
|
|
|
m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); |
|
|
|
m_outerBoxSizer->Add( m_mainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT, 5 ); |
|
|
|
|
|
|
|
while( groups->m_Buttons != NULL ) |
|
|
|
{ |
|
|
|
ColorButton* buttons = groups->m_Buttons; |
|
|
|
COLORBUTTON* buttons = groups->m_Buttons; |
|
|
|
|
|
|
|
ColumnBoxSizer = new wxBoxSizer( wxVERTICAL ); |
|
|
|
MainBoxSizer->Add( ColumnBoxSizer, 1, wxALIGN_TOP | wxLEFT | wxTOP, 5 ); |
|
|
|
RowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); |
|
|
|
ColumnBoxSizer->Add( RowBoxSizer, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); |
|
|
|
m_columnBoxSizer = new wxBoxSizer( wxVERTICAL ); |
|
|
|
m_mainBoxSizer->Add( m_columnBoxSizer, 1, wxALIGN_TOP | wxLEFT | wxTOP, 5 ); |
|
|
|
m_rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); |
|
|
|
m_columnBoxSizer->Add( m_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 ); |
|
|
|
@ -156,34 +177,43 @@ void DIALOG_COLOR_CONFIG::CreateControls() |
|
|
|
font.SetWeight( wxFONTWEIGHT_BOLD ); |
|
|
|
label->SetFont( font ); |
|
|
|
|
|
|
|
RowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); |
|
|
|
m_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 ); |
|
|
|
m_rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); |
|
|
|
m_columnBoxSizer->Add( m_rowBoxSizer, 0, wxGROW | wxALL, 0 ); |
|
|
|
|
|
|
|
wxMemoryDC iconDC; |
|
|
|
wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); |
|
|
|
|
|
|
|
iconDC.SelectObject( bitmap ); |
|
|
|
|
|
|
|
EDA_COLOR_T color = GetLayerColor( LayerNumber( buttons->m_Layer ) ); |
|
|
|
currentColors[ buttons->m_Layer ] = color; |
|
|
|
|
|
|
|
iconDC.SetPen( *wxBLACK_PEN ); |
|
|
|
|
|
|
|
wxBrush brush; |
|
|
|
ColorSetBrush( &brush, color ); |
|
|
|
|
|
|
|
#if wxCHECK_VERSION( 3, 0, 0 )
|
|
|
|
brush.SetStyle( wxBRUSHSTYLE_SOLID ); |
|
|
|
#else
|
|
|
|
brush.SetStyle( wxSOLID ); |
|
|
|
#endif
|
|
|
|
|
|
|
|
iconDC.SetBrush( brush ); |
|
|
|
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); |
|
|
|
|
|
|
|
BitmapButton = new wxBitmapButton( this, buttonId, bitmap, wxDefaultPosition, |
|
|
|
m_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 ); |
|
|
|
m_bitmapButton->SetClientData( (void*) buttons ); |
|
|
|
|
|
|
|
m_rowBoxSizer->Add( m_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 ); |
|
|
|
m_rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); |
|
|
|
buttonId += 1; |
|
|
|
buttons++; |
|
|
|
} |
|
|
|
@ -195,7 +225,7 @@ void DIALOG_COLOR_CONFIG::CreateControls() |
|
|
|
wxCommandEventHandler( DIALOG_COLOR_CONFIG::SetColor ) ); |
|
|
|
|
|
|
|
// Add a spacer to improve appearance.
|
|
|
|
ColumnBoxSizer->AddSpacer( 5 ); |
|
|
|
m_columnBoxSizer->AddSpacer( 5 ); |
|
|
|
|
|
|
|
wxArrayString m_SelBgColorStrings; |
|
|
|
m_SelBgColorStrings.Add( _( "White" ) ); |
|
|
|
@ -204,30 +234,31 @@ void DIALOG_COLOR_CONFIG::CreateControls() |
|
|
|
wxDefaultPosition, wxDefaultSize, |
|
|
|
m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS ); |
|
|
|
m_SelBgColor->SetSelection( ( g_DrawBgColor == BLACK ) ? 1 : 0 ); |
|
|
|
ColumnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 ); |
|
|
|
m_columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 ); |
|
|
|
|
|
|
|
// Provide a line to separate all of the controls added so far from the
|
|
|
|
// "OK", "Cancel", and "Apply" buttons (which will be added after that
|
|
|
|
// line).
|
|
|
|
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); |
|
|
|
OuterBoxSizer->Add( Line, 0, wxGROW | wxALL, 5 ); |
|
|
|
m_line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); |
|
|
|
m_outerBoxSizer->Add( m_line, 0, wxGROW | wxALL, 5 ); |
|
|
|
|
|
|
|
// Provide a StdDialogButtonSizer to accommodate the OK, Cancel, and Apply
|
|
|
|
// buttons; using that type of sizer results in those buttons being
|
|
|
|
// automatically located in positions appropriate for each (OS) version of
|
|
|
|
// KiCad.
|
|
|
|
StdDialogButtonSizer = new wxStdDialogButtonSizer; |
|
|
|
OuterBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 ); |
|
|
|
m_stdDialogButtonSizer = new wxStdDialogButtonSizer; |
|
|
|
m_outerBoxSizer->Add( m_stdDialogButtonSizer, 0, wxGROW | wxALL, 10 ); |
|
|
|
|
|
|
|
button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 ); |
|
|
|
m_stdDialogButtonSizer->AddButton( button ); |
|
|
|
|
|
|
|
Button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 ); |
|
|
|
StdDialogButtonSizer->AddButton( Button ); |
|
|
|
button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); |
|
|
|
m_stdDialogButtonSizer->AddButton( button ); |
|
|
|
|
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); |
|
|
|
StdDialogButtonSizer->AddButton( Button ); |
|
|
|
Button->SetFocus(); |
|
|
|
button->SetFocus(); |
|
|
|
|
|
|
|
Button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition, wxDefaultSize, 0 ); |
|
|
|
StdDialogButtonSizer->AddButton( Button ); |
|
|
|
button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition, wxDefaultSize, 0 ); |
|
|
|
m_stdDialogButtonSizer->AddButton( button ); |
|
|
|
|
|
|
|
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, |
|
|
|
wxCommandEventHandler( DIALOG_COLOR_CONFIG::OnOkClick ) ); |
|
|
|
@ -236,7 +267,7 @@ void DIALOG_COLOR_CONFIG::CreateControls() |
|
|
|
Connect( wxID_APPLY, wxEVT_COMMAND_BUTTON_CLICKED, |
|
|
|
wxCommandEventHandler( DIALOG_COLOR_CONFIG::OnApplyClick ) ); |
|
|
|
|
|
|
|
StdDialogButtonSizer->Realize(); |
|
|
|
m_stdDialogButtonSizer->Realize(); |
|
|
|
|
|
|
|
// Dialog now needs to be resized, but the associated command is found elsewhere.
|
|
|
|
} |
|
|
|
@ -248,7 +279,7 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event ) |
|
|
|
|
|
|
|
wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) ); |
|
|
|
|
|
|
|
ColorButton* colorButton = (ColorButton*) button->GetClientData(); |
|
|
|
COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData(); |
|
|
|
|
|
|
|
wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) ); |
|
|
|
|
|
|
|
@ -263,10 +294,17 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event ) |
|
|
|
|
|
|
|
wxBitmap bitmap = button->GetBitmapLabel(); |
|
|
|
iconDC.SelectObject( bitmap ); |
|
|
|
wxBrush brush; |
|
|
|
iconDC.SetPen( *wxBLACK_PEN ); |
|
|
|
|
|
|
|
wxBrush brush; |
|
|
|
|
|
|
|
ColorSetBrush( &brush, color); |
|
|
|
|
|
|
|
#if wxCHECK_VERSION( 3, 0, 0 )
|
|
|
|
brush.SetStyle( wxBRUSHSTYLE_SOLID ); |
|
|
|
#else
|
|
|
|
brush.SetStyle( wxSOLID ); |
|
|
|
#endif
|
|
|
|
|
|
|
|
iconDC.SetBrush( brush ); |
|
|
|
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); |
|
|
|
@ -295,7 +333,7 @@ bool DIALOG_COLOR_CONFIG::UpdateColorsSettings() |
|
|
|
warning = true; |
|
|
|
} |
|
|
|
|
|
|
|
m_Parent->SetGridColor( GetLayerColor( LAYER_GRID ) ); |
|
|
|
m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) ); |
|
|
|
|
|
|
|
if( g_DrawBgColor == GetLayerColor( LAYER_GRID ) ) |
|
|
|
warning = true; |
|
|
|
@ -313,7 +351,7 @@ void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& event ) |
|
|
|
if( warning ) |
|
|
|
wxMessageBox( _("Warning:\nSome items have the same color as the background\nand they will not be seen on screen") ); |
|
|
|
|
|
|
|
m_Parent->GetCanvas()->Refresh(); |
|
|
|
m_parent->GetCanvas()->Refresh(); |
|
|
|
|
|
|
|
EndModal( 1 ); |
|
|
|
} |
|
|
|
@ -328,5 +366,5 @@ void DIALOG_COLOR_CONFIG::OnCancelClick( wxCommandEvent& event ) |
|
|
|
void DIALOG_COLOR_CONFIG::OnApplyClick( wxCommandEvent& event ) |
|
|
|
{ |
|
|
|
UpdateColorsSettings(); |
|
|
|
m_Parent->GetCanvas()->Refresh(); |
|
|
|
m_parent->GetCanvas()->Refresh(); |
|
|
|
} |