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 117 of file widget_eeschema_color_config.cpp.

117  :
118  wxPanel( aParent ), m_drawFrame( aDrawFrame )
119 {
120  m_butt_size_pix = ConvertDialogToPixels( BUTT_SIZE );
121  m_butt_border_pix = ConvertDialogToPixels( BUTT_BORDER );
122 
123  CreateControls();
124 }
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 127 of file widget_eeschema_color_config.cpp.

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

200 {
201  wxBitmapButton* button = (wxBitmapButton*) event.GetEventObject();
202 
203  wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) );
204 
205  COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData();
206 
207  wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) );
208  COLOR4D oldColor = currentColors[ colorButton->m_Layer ];
209  COLOR4D newColor = COLOR4D::UNSPECIFIED;
210  DIALOG_COLOR_PICKER dialog( this, oldColor, false );
211 
212  if( dialog.ShowModal() == wxID_OK )
213  {
214  newColor = dialog.GetColor();
215  }
216 
217  if( newColor == COLOR4D::UNSPECIFIED || oldColor == newColor )
218  return;
219 
220  currentColors[ colorButton->m_Layer ] = newColor;
221 
222  wxMemoryDC iconDC;
223 
224  wxBitmap bitmap = button->GetBitmapLabel();
225  iconDC.SelectObject( bitmap );
226  iconDC.SetPen( *wxBLACK_PEN );
227 
228  wxBrush brush;
229  brush.SetColour( newColor.ToColour() );
230  brush.SetStyle( wxBRUSHSTYLE_SOLID );
231 
232  iconDC.SetBrush( brush );
233  iconDC.DrawRectangle( 0, 0, m_butt_size_pix.x, m_butt_size_pix.y );
234  button->SetBitmapLabel( bitmap );
235  button->Refresh();
236 
237  Refresh( false );
238 }
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 241 of file widget_eeschema_color_config.cpp.

242 {
243  // Check for color conflicts with background color to give user a chance to bail
244  // out before making changes.
245 
247 
248  for( SCH_LAYER_ID clyr = SCH_LAYER_ID_START; clyr < SCH_LAYER_ID_END; ++clyr )
249  {
250  if( bgcolor == currentColors[ clyr ] && clyr != LAYER_SCHEMATIC_BACKGROUND )
251  {
252  wxString msg = _( "Some items have the same color as the background\n"
253  "and they will not be seen on the screen. Are you\n"
254  "sure you want to use these colors?" );
255 
256  if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
257  return false;
258 
259  break;
260  }
261  }
262 
263  for( SCH_LAYER_ID clyr = SCH_LAYER_ID_START; clyr < SCH_LAYER_ID_END; ++clyr )
264  SetLayerColor( currentColors[ clyr ], clyr );
265 
267 
268  return true;
269 }
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: