KiCad PCB EDA Suite
WIDGET_EESCHEMA_COLOR_CONFIG Class Reference

#include <widget_eeschema_color_config.h>

Inheritance diagram for WIDGET_EESCHEMA_COLOR_CONFIG:

Public Member Functions

 WIDGET_EESCHEMA_COLOR_CONFIG (wxWindow *aParent, EDA_DRAW_FRAME *aDrawFrame)
 
bool TransferDataFromControl ()
 

Private Member Functions

void CreateControls ()
 
void SetColor (wxCommandEvent &aEvent)
 
virtual EDA_DRAW_FRAMEGetDrawFrame ()
 

Private Attributes

EDA_DRAW_FRAMEm_drawFrame
 
wxBoxSizer * m_mainBoxSizer
 
wxSize m_butt_size_pix
 
wxSize m_butt_border_pix
 

Detailed Description

Definition at line 42 of file widget_eeschema_color_config.h.

Constructor & Destructor Documentation

◆ WIDGET_EESCHEMA_COLOR_CONFIG()

WIDGET_EESCHEMA_COLOR_CONFIG::WIDGET_EESCHEMA_COLOR_CONFIG ( wxWindow *  aParent,
EDA_DRAW_FRAME aDrawFrame 
)

Definition at line 116 of file widget_eeschema_color_config.cpp.

116  :
117  wxPanel( aParent ), m_drawFrame( aDrawFrame )
118 {
119  m_butt_size_pix = ConvertDialogToPixels( BUTT_SIZE );
120  m_butt_border_pix = ConvertDialogToPixels( BUTT_BORDER );
121 
122  CreateControls();
123 }
const wxSize BUTT_BORDER(4, 4)
const wxSize BUTT_SIZE(10, 6)

References BUTT_BORDER(), BUTT_SIZE(), CreateControls(), m_butt_border_pix, and m_butt_size_pix.

Member Function Documentation

◆ CreateControls()

void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls ( )
private

Definition at line 126 of file widget_eeschema_color_config.cpp.

127 {
128  wxStaticText* label;
129  int buttonId = 1800;
130 
131  m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
132  SetSizer( m_mainBoxSizer );
133 
134  BUTTONINDEX* groups = buttonGroups;
135  wxBoxSizer* columnBoxSizer = NULL;
136 
137  while( groups->m_Buttons != NULL )
138  {
139  COLORBUTTON* buttons = groups->m_Buttons;
140 
141  columnBoxSizer = new wxBoxSizer( wxVERTICAL );
142  m_mainBoxSizer->Add( columnBoxSizer, 1, wxALIGN_TOP | wxLEFT, 5 );
143  wxBoxSizer* rowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
144  columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
145 
146  // Add a text string to identify the column of color select buttons.
147  label = new wxStaticText( this, wxID_ANY, groups->m_Name );
148 
149  // Make the column label font bold.
150  wxFont font( label->GetFont() );
151  font.SetWeight( wxFONTWEIGHT_BOLD );
152  label->SetFont( font );
153 
154  rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
155 
156  while( buttons->m_Layer >= 0 )
157  {
158  rowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
159  columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxALL, 0 );
160 
162  currentColors[ buttons->m_Layer ] = color;
163 
164  wxMemoryDC iconDC;
165  wxBitmap bitmap( m_butt_size_pix );
166 
167  iconDC.SelectObject( bitmap );
168  iconDC.SetPen( *wxBLACK_PEN );
169 
170  wxBrush brush;
171  brush.SetColour( color.ToColour() );
172  brush.SetStyle( wxBRUSHSTYLE_SOLID );
173  iconDC.SetBrush( brush );
174  iconDC.DrawRectangle( 0, 0, m_butt_size_pix.x, m_butt_size_pix.y );
175 
176  wxBitmapButton* bitmapButton = new wxBitmapButton(
177  this, buttonId, bitmap, wxDefaultPosition,
178  m_butt_size_pix + m_butt_border_pix + wxSize( 1, 1 ) );
179  bitmapButton->SetClientData( (void*) buttons );
180 
181  rowBoxSizer->Add( bitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
182 
183  label = new wxStaticText( this, wxID_ANY, wxGetTranslation( buttons->m_Name ) );
184  rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
185  buttonId += 1;
186  buttons++;
187  }
188 
189  groups++;
190  }
191 
192  Connect( 1800, buttonId, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) );
193 
194  // Dialog now needs to be resized, but the associated command is found elsewhere.
195 }
int color
Definition: DXF_plotter.cpp:62
static BUTTONINDEX buttonGroups[]
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:160
SCH_LAYER_ID
Eeschema drawing layers.
static COLOR4D currentColors[LAYER_ID_COUNT]
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References buttonGroups, color, currentColors, GetLayerColor(), m_butt_border_pix, m_butt_size_pix, BUTTONINDEX::m_Buttons, COLORBUTTON::m_Layer, m_mainBoxSizer, BUTTONINDEX::m_Name, and SetColor().

Referenced by WIDGET_EESCHEMA_COLOR_CONFIG().

◆ GetDrawFrame()

virtual EDA_DRAW_FRAME* WIDGET_EESCHEMA_COLOR_CONFIG::GetDrawFrame ( )
inlineprivatevirtual

Definition at line 55 of file widget_eeschema_color_config.h.

55 { return m_drawFrame; }

References m_drawFrame.

◆ SetColor()

void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ( wxCommandEvent &  aEvent)
private

Definition at line 198 of file widget_eeschema_color_config.cpp.

199 {
200  wxBitmapButton* button = (wxBitmapButton*) event.GetEventObject();
201 
202  wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) );
203 
204  COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData();
205 
206  wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) );
207  COLOR4D oldColor = currentColors[ colorButton->m_Layer ];
208  COLOR4D newColor = COLOR4D::UNSPECIFIED;
209  DIALOG_COLOR_PICKER dialog( this, oldColor, false );
210 
211  if( dialog.ShowModal() == wxID_OK )
212  {
213  newColor = dialog.GetColor();
214  }
215 
216  if( newColor == COLOR4D::UNSPECIFIED || oldColor == newColor )
217  return;
218 
219  currentColors[ colorButton->m_Layer ] = newColor;
220 
221  wxMemoryDC iconDC;
222 
223  wxBitmap bitmap = button->GetBitmapLabel();
224  iconDC.SelectObject( bitmap );
225  iconDC.SetPen( *wxBLACK_PEN );
226 
227  wxBrush brush;
228  brush.SetColour( newColor.ToColour() );
229  brush.SetStyle( wxBRUSHSTYLE_SOLID );
230 
231  iconDC.SetBrush( brush );
232  iconDC.DrawRectangle( 0, 0, m_butt_size_pix.x, m_butt_size_pix.y );
233  button->SetBitmapLabel( bitmap );
234  button->Refresh();
235 
236  Refresh( false );
237 }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
static COLOR4D currentColors[LAYER_ID_COUNT]
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References currentColors, DIALOG_COLOR_PICKER::GetColor(), m_butt_size_pix, COLORBUTTON::m_Layer, and Refresh().

Referenced by CreateControls().

◆ TransferDataFromControl()

bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl ( )

Definition at line 240 of file widget_eeschema_color_config.cpp.

241 {
242  // Check for color conflicts with background color to give user a chance to bail
243  // out before making changes.
244 
246 
247  for( SCH_LAYER_ID clyr = SCH_LAYER_ID_START; clyr < SCH_LAYER_ID_END; ++clyr )
248  {
249  if( bgcolor == currentColors[ clyr ] && clyr != LAYER_SCHEMATIC_BACKGROUND )
250  {
251  wxString msg = _( "Some items have the same color as the background\n"
252  "and they will not be seen on the screen. Are you\n"
253  "sure you want to use these colors?" );
254 
255  if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
256  return false;
257 
258  break;
259  }
260  }
261 
262  for( SCH_LAYER_ID clyr = SCH_LAYER_ID_START; clyr < SCH_LAYER_ID_END; ++clyr )
263  SetLayerColor( currentColors[ clyr ], clyr );
264 
266 
267  return true;
268 }
void SetLayerColor(COLOR4D aColor, SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
SCH_LAYER_ID
Eeschema drawing layers.
#define _(s)
static COLOR4D currentColors[LAYER_ID_COUNT]
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References _, currentColors, LAYER_SCHEMATIC_BACKGROUND, LAYER_WORKSHEET, SCH_LAYER_ID_END, SCH_LAYER_ID_START, and SetLayerColor().

Referenced by PANEL_EESCHEMA_COLOR_CONFIG::TransferDataFromWindow().

Member Data Documentation

◆ m_butt_border_pix

wxSize WIDGET_EESCHEMA_COLOR_CONFIG::m_butt_border_pix
private

Definition at line 48 of file widget_eeschema_color_config.h.

Referenced by CreateControls(), and WIDGET_EESCHEMA_COLOR_CONFIG().

◆ m_butt_size_pix

wxSize WIDGET_EESCHEMA_COLOR_CONFIG::m_butt_size_pix
private

◆ m_drawFrame

EDA_DRAW_FRAME* WIDGET_EESCHEMA_COLOR_CONFIG::m_drawFrame
private

Definition at line 45 of file widget_eeschema_color_config.h.

Referenced by GetDrawFrame().

◆ m_mainBoxSizer

wxBoxSizer* WIDGET_EESCHEMA_COLOR_CONFIG::m_mainBoxSizer
private

Definition at line 46 of file widget_eeschema_color_config.h.

Referenced by CreateControls().


The documentation for this class was generated from the following files: