2007-10-23 00:36:43 +00:00
|
|
|
/***************/
|
|
|
|
/* eelayer.cpp */
|
|
|
|
/***************/
|
|
|
|
|
|
|
|
/* Set up color Layers for EESchema
|
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2007-11-11 06:57:44 +00:00
|
|
|
#include "eelayer.h" // Header file associated with this file
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Local variables:
|
2010-02-01 21:23:27 +00:00
|
|
|
static int CurrentColor[NB_BUTT]; // Holds color for each layer while dialog box open
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetColorsFrame, wxDialog )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Table of events for WinEDA_SetColorsFrame
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_SetColorsFrame, wxDialog )
|
|
|
|
EVT_COMMAND_RANGE( ID_COLOR_SETUP, ID_COLOR_SETUP + NB_BUTT - 1,
|
|
|
|
wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
WinEDA_SetColorsFrame::SetColor )
|
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_SetColorsFrame::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_SetColorsFrame::OnCancelClick )
|
|
|
|
EVT_BUTTON( wxID_APPLY, WinEDA_SetColorsFrame::OnApplyClick )
|
|
|
|
END_EVENT_TABLE()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
/**************************************************************/
|
2010-03-20 19:57:59 +00:00
|
|
|
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
|
2007-10-23 00:36:43 +00:00
|
|
|
const wxPoint& framepos )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/**************************************************************/
|
2007-10-23 00:36:43 +00:00
|
|
|
WinEDA_SetColorsFrame* frame =
|
|
|
|
new WinEDA_SetColorsFrame( parent, framepos );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Default Constructor (whose provision is mandated by the inclusion
|
|
|
|
// of DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame ) within eelayer.h)
|
|
|
|
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-23 00:36:43 +00:00
|
|
|
Init();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Standard Constructor
|
2010-03-20 19:57:59 +00:00
|
|
|
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
|
2009-11-03 13:26:31 +00:00
|
|
|
const wxPoint& framepos )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-23 00:36:43 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
Init();
|
|
|
|
Create( parent,
|
|
|
|
SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
|
|
|
|
SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
|
|
|
|
framepos,
|
|
|
|
wxDefaultSize,
|
|
|
|
SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Destructor
|
2009-11-03 13:26:31 +00:00
|
|
|
WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame()
|
|
|
|
{
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
/**********************************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
bool WinEDA_SetColorsFrame::Create( wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/**********************************************************/
|
|
|
|
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
|
2007-10-23 00:36:43 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
CreateControls();
|
2009-11-03 13:26:31 +00:00
|
|
|
if( GetSizer() )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
/**********************************************************/
|
|
|
|
void WinEDA_SetColorsFrame::Init()
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/**********************************************************/
|
|
|
|
OuterBoxSizer = NULL;
|
|
|
|
MainBoxSizer = NULL;
|
|
|
|
ColumnBoxSizer = NULL;
|
|
|
|
RowBoxSizer = NULL;
|
|
|
|
Label = NULL;
|
|
|
|
BitmapButton = NULL;
|
|
|
|
m_ShowGrid = NULL;
|
|
|
|
m_SelBgColor = NULL;
|
|
|
|
Line = NULL;
|
2007-11-11 06:57:44 +00:00
|
|
|
StdDialogButtonSizer = NULL;
|
2009-11-03 13:26:31 +00:00
|
|
|
Button = NULL;
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
/**********************************************************/
|
|
|
|
void WinEDA_SetColorsFrame::CreateControls()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/**********************************************************/
|
2007-11-11 06:57:44 +00:00
|
|
|
int lyr, grp, butt_ID, buttcolor;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
SetSizer( OuterBoxSizer );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Add various items to the dialog box, as determined by the
|
|
|
|
// details of each element contained within laytool_list[]
|
2007-11-11 06:57:44 +00:00
|
|
|
for( lyr = 0, grp = 0; lyr < NB_BUTT; lyr++ )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
|
|
|
// Look for the initial button of each group of controls.
|
2007-11-11 06:57:44 +00:00
|
|
|
if( lyr == 0 || lyr == laytool_index[grp]->m_Index + 1 )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2007-11-11 06:57:44 +00:00
|
|
|
if( lyr != 0 )
|
|
|
|
grp++;
|
|
|
|
|
|
|
|
// Add another column sizer, unless the current value of
|
|
|
|
// grp is BUTTON_GROUPS - 1. (The very last group of controls
|
2007-10-23 00:36:43 +00:00
|
|
|
// differs from the previous groups in that its associated
|
|
|
|
// controls are located in the same column as the controls
|
|
|
|
// associated with the preceeding group.)
|
2007-11-11 06:57:44 +00:00
|
|
|
if( grp < BUTTON_GROUPS - 1 )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
ColumnBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
MainBoxSizer->Add( ColumnBoxSizer,
|
|
|
|
1,
|
|
|
|
wxALIGN_TOP | wxLEFT | wxTOP,
|
|
|
|
5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Add a spacer to better separate the text string (which is
|
|
|
|
// about to be added) from the items located above it.
|
2009-11-03 13:26:31 +00:00
|
|
|
ColumnBoxSizer->AddSpacer( 5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
RowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
ColumnBoxSizer->Add( RowBoxSizer,
|
|
|
|
0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Add a text string to identify the following set of controls
|
2007-11-11 06:57:44 +00:00
|
|
|
Label = new wxStaticText( this, -1, laytool_index[grp]->m_Name,
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Make this text string bold (so that it stands out better)
|
2009-11-03 13:26:31 +00:00
|
|
|
Label->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(),
|
|
|
|
wxNORMAL_FONT->GetFamily(),
|
|
|
|
wxNORMAL, wxBOLD, false,
|
|
|
|
wxNORMAL_FONT->GetFaceName() ) );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
RowBoxSizer->Add( Label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
RowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
ColumnBoxSizer->Add( RowBoxSizer, 0, wxGROW | wxALL, 0 );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2007-11-11 06:57:44 +00:00
|
|
|
butt_ID = ID_COLOR_SETUP + lyr;
|
|
|
|
laytool_list[lyr]->m_Id = butt_ID;
|
2007-09-13 11:55:46 +00:00
|
|
|
wxMemoryDC iconDC;
|
2009-11-03 13:26:31 +00:00
|
|
|
wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
iconDC.SelectObject( ButtBitmap );
|
2007-11-11 06:57:44 +00:00
|
|
|
buttcolor = *laytool_list[lyr]->m_Color;
|
|
|
|
CurrentColor[lyr] = buttcolor;
|
2007-09-13 11:55:46 +00:00
|
|
|
wxBrush Brush;
|
|
|
|
iconDC.SelectObject( ButtBitmap );
|
|
|
|
iconDC.SetPen( *wxBLACK_PEN );
|
2009-11-03 13:26:31 +00:00
|
|
|
Brush.SetColour( ColorRefs[buttcolor].m_Red,
|
|
|
|
ColorRefs[buttcolor].m_Green,
|
|
|
|
ColorRefs[buttcolor].m_Blue );
|
2007-09-13 11:55:46 +00:00
|
|
|
Brush.SetStyle( wxSOLID );
|
|
|
|
|
|
|
|
iconDC.SetBrush( Brush );
|
2007-10-23 00:36:43 +00:00
|
|
|
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
BitmapButton =
|
|
|
|
new wxBitmapButton( this, butt_ID, ButtBitmap, wxDefaultPosition,
|
2010-07-27 12:47:08 +00:00
|
|
|
wxSize( BUTT_SIZE_X+8, BUTT_SIZE_Y+6 ) );
|
2009-11-03 13:26:31 +00:00
|
|
|
RowBoxSizer->Add( BitmapButton,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
|
2007-11-11 06:57:44 +00:00
|
|
|
laytool_list[lyr]->m_Button = BitmapButton;
|
2007-10-23 00:36:43 +00:00
|
|
|
|
2007-11-11 06:57:44 +00:00
|
|
|
// Add a text string, unless the current value of lyr is NB_BUTT - 1
|
|
|
|
if( lyr < NB_BUTT - 1 )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
Label =
|
|
|
|
new wxStaticText( this, wxID_STATIC,
|
|
|
|
wxGetTranslation( laytool_list[lyr]->m_Name ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
RowBoxSizer->Add( Label, 1, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
// Special case; provide a checkbox instead (rather than a text
|
|
|
|
// string).
|
|
|
|
m_ShowGrid =
|
|
|
|
new wxCheckBox( this, ID_CHECKBOX_SHOW_GRID, _( "Grid" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2010-02-01 21:23:27 +00:00
|
|
|
m_ShowGrid->SetValue( m_Parent->IsGridVisible() );
|
2009-11-03 13:26:31 +00:00
|
|
|
RowBoxSizer->Add( m_ShowGrid,
|
|
|
|
1,
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxBOTTOM,
|
|
|
|
5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Add a spacer to improve appearance.
|
2009-11-03 13:26:31 +00:00
|
|
|
ColumnBoxSizer->AddSpacer( 5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
|
|
|
|
wxArrayString m_SelBgColorStrings;
|
2009-11-03 13:26:31 +00:00
|
|
|
m_SelBgColorStrings.Add( _( "White" ) );
|
|
|
|
m_SelBgColorStrings.Add( _( "Black" ) );
|
|
|
|
m_SelBgColor =
|
|
|
|
new wxRadioBox( this, ID_RADIOBOX_BACKGROUND_COLOR,
|
|
|
|
_( "Background Color:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS );
|
2007-10-23 00:36:43 +00:00
|
|
|
m_SelBgColor->SetSelection( ( g_DrawBgColor == BLACK ) ? 1 : 0 );
|
2009-11-03 13:26:31 +00:00
|
|
|
ColumnBoxSizer->Add( m_SelBgColor,
|
|
|
|
1,
|
|
|
|
wxGROW | wxRIGHT | wxTOP | wxBOTTOM,
|
|
|
|
5 );
|
2007-10-23 00:36:43 +00:00
|
|
|
|
|
|
|
// Provide a line to separate all of the controls added so far from the
|
2009-11-03 13:26:31 +00:00
|
|
|
// "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 );
|
2007-10-23 00:36:43 +00:00
|
|
|
|
2007-11-11 06:57:44 +00:00
|
|
|
// Provide a StdDialogButtonSizer to accommodate the OK, Cancel, and Apply
|
|
|
|
// buttons; using that type of sizer results in those buttons being
|
2009-11-03 13:26:31 +00:00
|
|
|
// automatically located in positions appropriate for each (OS) version of
|
|
|
|
// KiCad.
|
2007-11-11 06:57:44 +00:00
|
|
|
StdDialogButtonSizer = new wxStdDialogButtonSizer;
|
2009-11-03 13:26:31 +00:00
|
|
|
OuterBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
|
2007-10-23 00:36:43 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
Button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
|
|
|
StdDialogButtonSizer->AddButton( Button );
|
2007-10-23 00:36:43 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
StdDialogButtonSizer->AddButton( Button );
|
2008-04-30 11:52:34 +00:00
|
|
|
Button->SetFocus();
|
2007-10-23 00:36:43 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
Button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
|
|
|
StdDialogButtonSizer->AddButton( Button );
|
2007-11-11 06:57:44 +00:00
|
|
|
|
|
|
|
StdDialogButtonSizer->Realize();
|
2007-10-23 00:36:43 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
// (Dialog now needs to be resized, but the associated command is found
|
|
|
|
// elsewhere.)
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/**********************************************************/
|
|
|
|
int id = event.GetId();
|
|
|
|
int color;
|
2007-10-23 00:36:43 +00:00
|
|
|
|
|
|
|
wxBitmapButton* Button;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
color = DisplayColorFrame( this,
|
2009-11-03 13:26:31 +00:00
|
|
|
CurrentColor[id - ID_COLOR_SETUP] );
|
2007-11-11 06:57:44 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
if( color < 0 )
|
|
|
|
return;
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
if( CurrentColor[id - ID_COLOR_SETUP] == color )
|
|
|
|
return;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
CurrentColor[id - ID_COLOR_SETUP] = color;
|
2009-11-03 13:26:31 +00:00
|
|
|
wxMemoryDC iconDC;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
Button = laytool_list[id - ID_COLOR_SETUP]->m_Button;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
wxBitmap ButtBitmap = Button->GetBitmapLabel();
|
2007-10-23 00:36:43 +00:00
|
|
|
iconDC.SelectObject( ButtBitmap );
|
2009-11-03 13:26:31 +00:00
|
|
|
wxBrush Brush;
|
2007-10-23 00:36:43 +00:00
|
|
|
iconDC.SetPen( *wxBLACK_PEN );
|
2009-11-03 13:26:31 +00:00
|
|
|
Brush.SetColour( ColorRefs[color].m_Red,
|
|
|
|
ColorRefs[color].m_Green,
|
|
|
|
ColorRefs[color].m_Blue );
|
2007-10-23 00:36:43 +00:00
|
|
|
Brush.SetStyle( wxSOLID );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
iconDC.SetBrush( Brush );
|
|
|
|
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
|
|
|
|
Button->SetBitmapLabel( ButtBitmap );
|
|
|
|
Button->Refresh();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
Refresh( FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
/******************************************************************/
|
|
|
|
void WinEDA_SetColorsFrame::UpdateLayerSettings()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/******************************************************************/
|
2007-10-23 00:36:43 +00:00
|
|
|
// Update colors for each layer
|
2007-11-11 06:57:44 +00:00
|
|
|
for( int lyr = 0; lyr < NB_BUTT; lyr++ )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2007-11-11 06:57:44 +00:00
|
|
|
// (As a bitmap button has been provided for *every* layer,
|
|
|
|
// it is not necessary to check whether it actually has been
|
|
|
|
// provided for each of those layers.)
|
|
|
|
*laytool_list[lyr]->m_Color = CurrentColor[lyr];
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update whether grid is actually displayed or otherwise
|
2007-10-23 23:59:33 +00:00
|
|
|
// The previous command compiles OK, but to prevent a warning
|
|
|
|
// from being generated when the Linux version is being compiled,
|
|
|
|
// the next two commands are provided instead.
|
2010-02-01 21:23:27 +00:00
|
|
|
m_Parent->SetGridVisibility( m_ShowGrid->GetValue() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
// Update color of background
|
2007-09-13 11:55:46 +00:00
|
|
|
if( m_SelBgColor->GetSelection() == 0 )
|
2007-10-23 00:36:43 +00:00
|
|
|
g_DrawBgColor = WHITE;
|
2007-09-13 11:55:46 +00:00
|
|
|
else
|
2007-10-23 00:36:43 +00:00
|
|
|
g_DrawBgColor = BLACK;
|
2010-01-22 18:13:43 +00:00
|
|
|
|
|
|
|
m_Parent->Refresh();
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
|
|
|
|
/**********************************************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED( event ) )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/**********************************************************************/
|
2007-10-23 00:36:43 +00:00
|
|
|
UpdateLayerSettings();
|
2008-12-20 13:12:57 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
2007-10-23 00:36:43 +00:00
|
|
|
EndModal( 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-23 00:36:43 +00:00
|
|
|
/*******************************************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
void WinEDA_SetColorsFrame::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/*******************************************************************/
|
2007-10-23 00:36:43 +00:00
|
|
|
EndModal( -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
void WinEDA_SetColorsFrame::OnApplyClick( wxCommandEvent& WXUNUSED( event ) )
|
2007-10-23 00:36:43 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/*******************************************************************/
|
2007-10-23 00:36:43 +00:00
|
|
|
UpdateLayerSettings();
|
2008-12-20 13:12:57 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
2007-10-23 00:36:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void SeedLayers()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/*************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
LayerStruct* LayerPointer = &g_LayerDescr;
|
|
|
|
int pt;
|
|
|
|
|
|
|
|
LayerPointer->CommonColor = WHITE;
|
|
|
|
LayerPointer->Flags = 0;
|
|
|
|
pt = 0;
|
|
|
|
LayerPointer->CurrentWidth = 1;
|
|
|
|
|
|
|
|
/* seed Up the Layer colours, set all user layers off */
|
|
|
|
for( pt = 0; pt < MAX_LAYERS; pt++ )
|
|
|
|
{
|
|
|
|
LayerPointer->LayerStatus[pt] = 0;
|
|
|
|
LayerPointer->LayerColor[pt] = DARKGRAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerPointer->NumberOfLayers = pt - 1;
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Specific colors: update by reading the config. */
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
/***************************************/
|
|
|
|
EDA_Colors ReturnLayerColor( int Layer )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/****************************************/
|
2007-10-23 00:36:43 +00:00
|
|
|
if( g_LayerDescr.Flags == 0 )
|
2008-12-14 19:45:05 +00:00
|
|
|
return (EDA_Colors) g_LayerDescr.LayerColor[Layer];
|
2007-09-13 11:55:46 +00:00
|
|
|
else
|
2008-12-14 19:45:05 +00:00
|
|
|
return (EDA_Colors) g_LayerDescr.CommonColor;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|