2007-11-09 08:14:39 +00:00
|
|
|
/*****************/
|
|
|
|
/* set_color.cpp */
|
|
|
|
/*****************/
|
|
|
|
|
|
|
|
/*Set up the items and layer colors and show/no show options
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "set_color.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
#include "set_color.h" // Header file associated with this file
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Local variables:
|
|
|
|
const int COLOR_COUNT = 40; // 40 = 29 (layers) + 11 (others)
|
2007-10-10 21:35:41 +00:00
|
|
|
int CurrentColor[COLOR_COUNT]; // Holds color for each layer while dialog box open
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetColorsFrame, wxDialog )
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Table of events for WinEDA_SetColorsFrame
|
2007-08-24 03:40:04 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_SetColorsFrame, wxDialog )
|
|
|
|
EVT_BUTTON( ID_COLOR_RESET_SHOW_LAYER_OFF, WinEDA_SetColorsFrame::ResetDisplayLayersCu )
|
|
|
|
EVT_BUTTON( ID_COLOR_RESET_SHOW_LAYER_ON, WinEDA_SetColorsFrame::ResetDisplayLayersCu )
|
2007-11-09 08:14:39 +00:00
|
|
|
EVT_COMMAND_RANGE( ID_COLOR_SETUP, ID_COLOR_SETUP + NB_BUTT - 1,
|
|
|
|
wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
WinEDA_SetColorsFrame::SetColor )
|
2007-10-10 21:35:41 +00:00
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_SetColorsFrame::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_SetColorsFrame::OnCancelClick )
|
|
|
|
EVT_BUTTON( wxID_APPLY, WinEDA_SetColorsFrame::OnApplyClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************/
|
2008-03-04 04:22:27 +00:00
|
|
|
void DisplayColorSetupFrame( WinEDA_PcbFrame* parent,
|
2007-08-24 03:40:04 +00:00
|
|
|
const wxPoint& framepos )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************/
|
|
|
|
{
|
2007-08-24 03:40:04 +00:00
|
|
|
WinEDA_SetColorsFrame* frame =
|
2007-09-13 09:24:43 +00:00
|
|
|
new WinEDA_SetColorsFrame( parent, framepos );
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-09-13 09:24:43 +00:00
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Default Constructor (whose provision is mandated by the inclusion
|
|
|
|
// of DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame ) within set_color.h)
|
|
|
|
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Standard Constructor
|
2008-03-04 04:22:27 +00:00
|
|
|
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_PcbFrame* parent,
|
2007-11-09 08:14:39 +00:00
|
|
|
const wxPoint& framepos )
|
|
|
|
{
|
2007-08-24 03:40:04 +00:00
|
|
|
m_Parent = parent;
|
2007-11-09 08:14:39 +00:00
|
|
|
Init();
|
|
|
|
Create( parent,
|
|
|
|
SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
|
|
|
|
SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
|
|
|
|
framepos,
|
|
|
|
wxDefaultSize,
|
|
|
|
SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame() { }
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id,
|
|
|
|
const wxString& caption, const wxPoint& pos,
|
|
|
|
const wxSize& size, long style )
|
|
|
|
/**********************************************************/
|
|
|
|
{
|
|
|
|
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
|
|
|
if (GetSizer())
|
|
|
|
{
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
void WinEDA_SetColorsFrame::Init()
|
|
|
|
/**********************************************************/
|
|
|
|
{
|
|
|
|
OuterBoxSizer = NULL;
|
|
|
|
MainBoxSizer = NULL;
|
|
|
|
FlexColumnBoxSizer = NULL;
|
|
|
|
Label = NULL;
|
|
|
|
RowBoxSizer = NULL;
|
|
|
|
BitmapButton = NULL;
|
|
|
|
CheckBox = NULL;
|
|
|
|
Button = NULL;
|
|
|
|
Line = NULL;
|
|
|
|
StdDialogButtonSizer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
void WinEDA_SetColorsFrame::CreateControls()
|
|
|
|
/**********************************************************/
|
|
|
|
{
|
|
|
|
int lyr, cln, butt_ID, buttcolor;
|
|
|
|
wxString msg;
|
|
|
|
wxSize CorrectRowSize; // Used while specifying height of various spacers
|
|
|
|
int ButtonHeight; // Used while specifying height of other spacers
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
SetFont( *g_DialogFont );
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
OuterBoxSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
SetSizer(OuterBoxSizer);
|
|
|
|
|
|
|
|
MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT, 5);
|
2007-10-10 21:35:41 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Add various items to the dialog box, as determined by the
|
|
|
|
// details of each element contained within laytool_list[]
|
|
|
|
for( lyr = 0, cln = 0; lyr < NB_BUTT; lyr++ )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
// Look for the first set of controls within each column.
|
|
|
|
if( lyr == 0 || lyr == laytool_index[cln]->m_Index + 1 )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
if( lyr != 0 )
|
|
|
|
cln++;
|
2007-10-10 21:35:41 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Specify a FlexGrid sizer with nineteen rows and one column.
|
|
|
|
FlexColumnBoxSizer = new wxFlexGridSizer(19, 1, 0, 0);
|
|
|
|
|
|
|
|
// Specify that all of the rows can be expanded.
|
|
|
|
for( int ii = 0; ii < 19; ii++ )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
FlexColumnBoxSizer->AddGrowableRow(ii);
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Specify that the column can also be expanded.
|
|
|
|
FlexColumnBoxSizer->AddGrowableCol(0);
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
MainBoxSizer->Add(FlexColumnBoxSizer, 1, wxGROW|wxLEFT|wxBOTTOM, 5);
|
2007-09-13 09:24:43 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Add a text string to identify the controls within this column.
|
|
|
|
Label = new wxStaticText( this, wxID_STATIC, laytool_index[cln]->m_Name,
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Make this text string bold (so that it stands out better).
|
|
|
|
Label->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(),
|
|
|
|
wxNORMAL, wxBOLD, false, wxNORMAL_FONT->GetFaceName() ) );
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
FlexColumnBoxSizer->Add(Label, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Provide a sizer to accomodate the (bitmap button and) checkbox associated with the
|
|
|
|
// current layer (while providing a spacer instead a button, when appropriate).
|
|
|
|
RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
FlexColumnBoxSizer->Add(RowBoxSizer, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 5);
|
|
|
|
|
|
|
|
butt_ID = ID_COLOR_SETUP + lyr;
|
|
|
|
laytool_list[lyr]->m_Id = butt_ID;
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
if( laytool_list[lyr]->m_Color )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
// Provide a bitmap button, and "paint" this with the appropriate color.
|
2007-08-24 03:40:04 +00:00
|
|
|
wxMemoryDC iconDC;
|
2007-10-10 21:35:41 +00:00
|
|
|
wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
|
2007-08-24 03:40:04 +00:00
|
|
|
iconDC.SelectObject( ButtBitmap );
|
2007-11-09 08:14:39 +00:00
|
|
|
buttcolor = *laytool_list[lyr]->m_Color & MASKCOLOR;
|
|
|
|
CurrentColor[lyr] = buttcolor;
|
2007-08-24 03:40:04 +00:00
|
|
|
wxBrush Brush;
|
|
|
|
iconDC.SelectObject( ButtBitmap );
|
|
|
|
iconDC.SetPen( *wxBLACK_PEN );
|
|
|
|
Brush.SetColour(
|
|
|
|
ColorRefs[buttcolor].m_Red,
|
|
|
|
ColorRefs[buttcolor].m_Green,
|
|
|
|
ColorRefs[buttcolor].m_Blue
|
|
|
|
);
|
|
|
|
Brush.SetStyle( wxSOLID );
|
|
|
|
|
|
|
|
iconDC.SetBrush( Brush );
|
2007-10-10 21:35:41 +00:00
|
|
|
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
BitmapButton = new wxBitmapButton( this, butt_ID,
|
|
|
|
ButtBitmap,
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) );
|
|
|
|
laytool_list[lyr]->m_Button = BitmapButton;
|
|
|
|
|
|
|
|
RowBoxSizer->Add(BitmapButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Provide a spacer instead (rather than a bitmap button).
|
|
|
|
RowBoxSizer->Add(BUTT_SIZE_X, BUTT_SIZE_Y, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5);
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
if( laytool_list[lyr]->m_LayerNumber >= 0 )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
if( laytool_list[lyr]->m_Title == wxT( "*" ) )
|
|
|
|
msg = g_ViaType_Name[laytool_list[lyr]->m_LayerNumber];
|
2007-08-24 03:40:04 +00:00
|
|
|
else
|
2008-03-04 04:22:27 +00:00
|
|
|
msg = m_Parent->m_Pcb->GetLayerName( laytool_list[lyr]->m_LayerNumber );
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
|
|
|
else
|
2007-11-09 08:14:39 +00:00
|
|
|
msg = wxGetTranslation( laytool_list[lyr]->m_Title.GetData() );
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
CheckBox = new wxCheckBox( this, ID_COLOR_CHECKBOX_ONOFF, msg,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
laytool_list[lyr]->m_CheckBox = CheckBox;
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
if( laytool_list[lyr]->m_NoDisplayIsColor )
|
|
|
|
{
|
|
|
|
if( *laytool_list[lyr]->m_Color & ITEM_NOT_SHOW )
|
|
|
|
CheckBox->SetValue( FALSE );
|
|
|
|
else
|
|
|
|
CheckBox->SetValue( TRUE );
|
|
|
|
}
|
|
|
|
else if( laytool_list[lyr]->m_NoDisplay )
|
|
|
|
CheckBox->SetValue( *laytool_list[lyr]->m_NoDisplay );
|
|
|
|
|
|
|
|
RowBoxSizer->Add(CheckBox, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
|
|
|
|
|
|
|
|
// Check whether the last (bitmap button and) checkbox has been provided for this column.
|
|
|
|
if( lyr == laytool_index[cln]->m_Index )
|
|
|
|
{
|
|
|
|
// What happens now depends upon which column is currently being created. Another
|
|
|
|
// two (standard/non-bitmap) buttons are provided within the first column, while
|
|
|
|
// assorted spacers are added to each of the other two columns (so that if the
|
|
|
|
// dialog box is resized by the user, each of the controls within each of the
|
|
|
|
// columns will be repositioned in an aesthetically-acceptable manner).
|
|
|
|
if( cln == 0 )
|
|
|
|
{
|
|
|
|
// Provide another two buttons; for aesthetic reasons, these will both be
|
|
|
|
// made equally wide.
|
|
|
|
|
|
|
|
int GoodWidth, width0;
|
|
|
|
|
|
|
|
// Specify the relevent details for the first button, but in the first instance,
|
|
|
|
// specify the caption which will be used by the second of these buttons (with
|
|
|
|
// the objective being to determine how wide those buttons would need to be to
|
|
|
|
// be able to accomodate the caption provided for either of them).
|
|
|
|
Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_ON, _("Show None"),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
|
|
|
|
// Note the height of this button, so that the same height can also be specified for
|
|
|
|
// the spacers occupying the corresponding cells within each of the other two columns.
|
|
|
|
// Also note the width of the button required for the initially specified caption.
|
|
|
|
Button->GetSize( &width0, &ButtonHeight );
|
|
|
|
|
|
|
|
// Now change the caption of this button to what is really wanted for it.
|
|
|
|
Button->SetLabel( _("Show All") );
|
|
|
|
|
|
|
|
// Also note the width of the button required for the updated caption.
|
|
|
|
Button->GetSize( &GoodWidth, &ButtonHeight );
|
|
|
|
|
|
|
|
// Upate the value of GoodWidth if required (as that variable will subsequently
|
|
|
|
// be used to specify the (minimum) width for both of these buttons).
|
|
|
|
if( GoodWidth < width0 )
|
|
|
|
GoodWidth = width0;
|
|
|
|
|
|
|
|
// Complete the steps necessary for providing the first button.
|
|
|
|
if (WinEDA_SetColorsFrame::ShowToolTips())
|
|
|
|
Button->SetToolTip( _("Switch on all of the copper layers") );
|
|
|
|
Button->SetMinSize( wxSize( GoodWidth, ButtonHeight ) );
|
|
|
|
Button->SetForegroundColour( wxColor( 0, 100, 0 ) );
|
|
|
|
FlexColumnBoxSizer->Add(Button, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5);
|
|
|
|
|
|
|
|
// Now do everything required for providing the second button.
|
|
|
|
Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_OFF, _("Show None"),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
if (WinEDA_SetColorsFrame::ShowToolTips())
|
|
|
|
Button->SetToolTip( _("Switch off all of the copper layers") );
|
|
|
|
Button->SetMinSize( wxSize( GoodWidth, ButtonHeight ) );
|
|
|
|
Button->SetForegroundColour( wxColor( 100, 0, 0 ) );
|
|
|
|
FlexColumnBoxSizer->Add(Button, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Provide additional spacers within each other column to occupy any cells
|
|
|
|
// that would otherwise remain unoccupied.
|
|
|
|
//
|
|
|
|
// Provide a spacer, of appropriate height, for each row that
|
|
|
|
// would otherwise contain a (bitmap button and) checkbox.
|
|
|
|
//
|
|
|
|
// First determine what height is required for those spacers; i.e. the
|
|
|
|
// larger of each bitmap button's height and each checkbox'es height.
|
|
|
|
// (That only needs to be determined once, so do so after the last
|
|
|
|
// bitmap button and checkbox have been provided for the second column.)
|
|
|
|
if( cln == 1 )
|
|
|
|
{
|
|
|
|
CorrectRowSize = CheckBox->GetSize();
|
|
|
|
if( CorrectRowSize.y < BUTT_SIZE_Y )
|
|
|
|
CorrectRowSize.y = BUTT_SIZE_Y;
|
|
|
|
}
|
2007-09-13 09:24:43 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// The first column contains 16 checkboxes, while each of the other two columns
|
|
|
|
// contains a smaller number. Determine how many checkboxes have actually been
|
|
|
|
// provided within each of the other columns, then provide an appropriate number
|
|
|
|
// of sizers (to take the total count of checkboxes and substitute sizers to 16).
|
|
|
|
for( int ii = lyr; ii < 16 + laytool_index[cln - 1]->m_Index
|
|
|
|
+ lyr - laytool_index[cln]->m_Index; ii++ )
|
|
|
|
{
|
|
|
|
FlexColumnBoxSizer->Add(5, CorrectRowSize.y, 1, wxBOTTOM, 5);
|
|
|
|
}
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// As the first column also contains two (standard/non-bitmap) buttons, while each of
|
|
|
|
// the other two columns doesn't, also provide yet another two spacers, each of button
|
|
|
|
// height, within each of the other two columns.
|
|
|
|
FlexColumnBoxSizer->Add(5, ButtonHeight, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP, 5);
|
|
|
|
FlexColumnBoxSizer->Add(5, ButtonHeight, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP, 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-10 21:35:41 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// Provide a line to separate the controls which have been provided so far from
|
|
|
|
// the OK, Cancel, and Apply buttons (which will be provided after this line)
|
|
|
|
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
|
|
|
OuterBoxSizer->Add(Line, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// 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);
|
2007-10-10 21:35:41 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
Button = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
2007-10-10 21:35:41 +00:00
|
|
|
Button->SetForegroundColour( *wxRED );
|
2007-11-09 08:14:39 +00:00
|
|
|
StdDialogButtonSizer->AddButton(Button);
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
2007-08-24 03:40:04 +00:00
|
|
|
Button->SetForegroundColour( *wxBLUE );
|
2007-11-09 08:14:39 +00:00
|
|
|
StdDialogButtonSizer->AddButton(Button);
|
2007-09-13 09:24:43 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
Button = new wxButton( this, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
StdDialogButtonSizer->AddButton(Button);
|
2007-10-10 21:35:41 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
StdDialogButtonSizer->Realize();
|
2007-10-10 21:35:41 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
// (Dialog now needs to be resized, but the associated command is provided elsewhere.)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
bool WinEDA_SetColorsFrame::ShowToolTips()
|
|
|
|
/**********************************************************/
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
wxBitmap WinEDA_SetColorsFrame::GetBitmapResource( const wxString& name )
|
|
|
|
/**********************************************************/
|
|
|
|
{
|
|
|
|
wxUnusedVar(name);
|
|
|
|
return wxNullBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
wxIcon WinEDA_SetColorsFrame::GetIconResource( const wxString& name )
|
|
|
|
/**********************************************************/
|
|
|
|
{
|
|
|
|
wxUnusedVar(name);
|
|
|
|
return wxNullIcon;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-10-10 21:35:41 +00:00
|
|
|
void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
|
|
|
{
|
2007-10-10 21:35:41 +00:00
|
|
|
UpdateLayerSettings();
|
2008-12-20 13:12:57 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
2007-10-10 21:35:41 +00:00
|
|
|
EndModal( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************/
|
|
|
|
void WinEDA_SetColorsFrame::OnCancelClick(wxCommandEvent& WXUNUSED(event))
|
|
|
|
/*******************************************************************/
|
|
|
|
{
|
|
|
|
EndModal( -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************/
|
|
|
|
void WinEDA_SetColorsFrame::OnApplyClick(wxCommandEvent& WXUNUSED(event))
|
|
|
|
/*******************************************************************/
|
|
|
|
{
|
|
|
|
UpdateLayerSettings();
|
2008-12-20 13:12:57 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2007-08-24 03:40:04 +00:00
|
|
|
void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
|
|
|
{
|
2007-08-24 03:40:04 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
int color;
|
2007-09-13 09:24:43 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
wxBitmapButton* Button;
|
|
|
|
|
|
|
|
color = DisplayColorFrame( this,
|
|
|
|
CurrentColor[id - ID_COLOR_SETUP] );
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
if( color < 0 )
|
|
|
|
return;
|
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
if( CurrentColor[id - ID_COLOR_SETUP] == color )
|
|
|
|
return;
|
|
|
|
|
|
|
|
CurrentColor[id - ID_COLOR_SETUP] = color;
|
|
|
|
wxMemoryDC iconDC;
|
|
|
|
|
|
|
|
Button = laytool_list[id - ID_COLOR_SETUP]->m_Button;
|
|
|
|
|
|
|
|
wxBitmap ButtBitmap = Button->GetBitmapLabel();
|
|
|
|
iconDC.SelectObject( ButtBitmap );
|
|
|
|
wxBrush Brush;
|
|
|
|
iconDC.SetPen( *wxBLACK_PEN );
|
|
|
|
Brush.SetColour(
|
|
|
|
ColorRefs[color].m_Red,
|
|
|
|
ColorRefs[color].m_Green,
|
|
|
|
ColorRefs[color].m_Blue
|
|
|
|
);
|
|
|
|
Brush.SetStyle( wxSOLID );
|
|
|
|
|
|
|
|
iconDC.SetBrush( Brush );
|
|
|
|
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
|
|
|
|
Button->SetBitmapLabel( ButtBitmap );
|
|
|
|
Button->Refresh();
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
Refresh( FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
2007-10-10 21:35:41 +00:00
|
|
|
void WinEDA_SetColorsFrame::UpdateLayerSettings()
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************************/
|
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
for( int lyr = 0; lyr < NB_BUTT; lyr++ )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
if( laytool_list[lyr]->m_NoDisplayIsColor )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
if( laytool_list[lyr]->m_CheckBox->GetValue() )
|
|
|
|
*laytool_list[lyr]->m_Color = CurrentColor[lyr] & ~ITEM_NOT_SHOW;
|
2007-08-24 03:40:04 +00:00
|
|
|
else
|
2007-11-09 08:14:39 +00:00
|
|
|
*laytool_list[lyr]->m_Color = CurrentColor[lyr] | ITEM_NOT_SHOW;
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
if( laytool_list[lyr]->m_Color )
|
|
|
|
*laytool_list[lyr]->m_Color = CurrentColor[lyr];
|
2007-10-10 21:35:41 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
*laytool_list[lyr]->m_NoDisplay = laytool_list[lyr]->m_CheckBox->GetValue();
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-10 21:35:41 +00:00
|
|
|
// Additional command required for updating visibility of grid.
|
|
|
|
m_Parent->m_Draw_Grid = g_ShowGrid;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-08-24 03:40:04 +00:00
|
|
|
void WinEDA_SetColorsFrame::ResetDisplayLayersCu( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
bool NewState = ( event.GetId() == ID_COLOR_RESET_SHOW_LAYER_ON )
|
|
|
|
? TRUE
|
|
|
|
: FALSE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-09 08:14:39 +00:00
|
|
|
for( int lyr = 0; lyr < 16; lyr++ )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-11-09 08:14:39 +00:00
|
|
|
// if( laytool_list[lyr]->m_CheckBox )
|
|
|
|
// laytool_list[lyr]->m_CheckBox->SetValue( NewState );
|
|
|
|
|
|
|
|
// (As checkboxes are actually provided for *all* of these layers,
|
|
|
|
// the following (simpler) command can be used instead.)
|
|
|
|
laytool_list[lyr]->m_CheckBox->SetValue( NewState );
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|