Commit e295e8e0 authored by g_harland's avatar g_harland

Enhance "EESchema Preferences" dialog box;

sizers and OK, Cancel, and Apply buttons now provided
parent a287b16f
......@@ -5,6 +5,15 @@ Please add newer entries at the top, list the date and your name with
email address.
2007-Oct-23 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ eeschema
* Sizers have now been provided for the "EESchema Preferences" dialog box,
together with "OK", "Cancel", and "Apply" buttons. And an additional bitmap
button and checkbox have also been provided for the purpose of editing the
color and visibility of the grid.
2007-Oct-21 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ all
......
/* Set up color Layers */
/***************/
/* eelayer.cpp */
/***************/
/* Set up color Layers for EESchema
*/
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "eelayer.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
#include "fctsys.h"
#include "gr_basic.h"
......@@ -12,319 +32,166 @@
#include "protos.h"
#include "eelayer.h"
/* Variables locales */
/* Fonctions locales: */
/* Macro utile : */
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])
#define BUTT_SIZE_X 30
#define BUTT_SIZE_Y 20
enum col_sel_id {
ID_COLOR_SETUP = 1800
};
/**********************************/
/* Liste des menus de Menu_Layers */
/**********************************/
struct ColorButton
{
wxString m_Name;
int* m_Color;
int m_Id;
wxBitmapButton* m_Button;
int m_State;
};
static ColorButton Msg_General =
{
_( "General" ), /* Title */
NULL
};
static ColorButton Msg_Sheets =
{
_( "Sheets" ), /* Title */
NULL
};
static ColorButton Layer_Wire_Item =
{
_( "Wire" ), /* Title */
ADR( LAYER_WIRE ) /* adr du parametre optionnel */
};
static ColorButton Layer_Bus_Item =
{
_( "Bus" ), /* Title */
ADR( LAYER_BUS ) /* adr du parametre optionnel */
};
static ColorButton Layer_Jonction_Item =
{
_( "Junction" ), /* Title */
ADR( LAYER_JUNCTION ) /* adr du parametre optionnel */
};
static ColorButton Layer_LocalLabel_Item =
{
_( "Label" ), /* Title */
ADR( LAYER_LOCLABEL ) /* adr du parametre optionnel */
};
// Local variables:
static ColorButton Layer_GlobLabel_Item =
{
_( "GlobLabel" ), /* Title */
ADR( LAYER_GLOBLABEL ) /* adr du parametre optionnel */
};
int CurrentColor[NB_BUTT]; // Holds color for each layer while dialog box open
static ColorButton Layer_PinNum_Item =
{
_( "PinNum" ), /* Title */
ADR( LAYER_PINNUM ) /* adr du parametre optionnel */
};
static ColorButton Layer_PinNam_Item =
{
_( "PinNam" ), /* Title */
ADR( LAYER_PINNAM ) /* adr du parametre optionnel */
};
IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetColorsFrame, wxDialog )
static ColorButton Layer_Reference_Item =
{
_( "Reference" ), /* Title */
ADR( LAYER_REFERENCEPART ) /* adr du parametre optionnel */
};
// 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()
static ColorButton Layer_Value_Item =
{
_( "Value" ), /* Title */
ADR( LAYER_VALUEPART ) /* adr du parametre optionnel */
};
static ColorButton Layer_Fields_Item =
/**************************************************************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos )
/**************************************************************/
{
_( "Fields" ), /* Title */
ADR( LAYER_FIELDS ) /* adr du parametre optionnel */
};
WinEDA_SetColorsFrame* frame =
new WinEDA_SetColorsFrame( parent, framepos );
static ColorButton Layer_BodyDevice_Item =
{
_( "Body" ), /* Title */
ADR( LAYER_DEVICE ) /* adr du parametre optionnel */
};
frame->ShowModal();
frame->Destroy();
}
static ColorButton Layer_BodyBackgroundDevice_Item =
{
_( "Body Bg" ), /* Title */
ADR( LAYER_DEVICE_BACKGROUND ) /* adr du parametre optionnel */
};
static ColorButton MsgDevice_Item =
// Default Constructor (whose provision is mandated by the inclusion
// of DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame ) within eelayer.h)
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame()
{
_( "Device" ), /* Title */
NULL
};
Init();
}
static ColorButton Layer_Notes_Item =
{
_( "Notes" ), /* Title */
ADR( LAYER_NOTES ) /* adr du parametre optionnel */
};
static ColorButton Layer_NetNam_Item =
// Standard Constructor
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos )
{
_( "Netname" ), /* Title */
ADR( LAYER_NETNAM ) /* adr du parametre optionnel */
};
m_Parent = parent;
Init();
Create( parent,
SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
framepos,
wxDefaultSize,
SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
}
static ColorButton Layer_Pin_Item =
{
_( "Pin" ), /* Title */
ADR( LAYER_PIN ) /* adr du parametre optionnel */
};
static ColorButton Layer_Sheet_Item =
{
_( "Sheet" ), /* Title */
ADR( LAYER_SHEET ) /* adr du parametre optionnel */
};
// Destructor
WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame() { }
static ColorButton Layer_SheetName_Item =
{
_( "SheetName" ), /* Title */
ADR( LAYER_SHEETNAME ) /* adr du parametre optionnel */
};
static ColorButton Layer_SheetFileName_Item =
/**********************************************************/
bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style )
/**********************************************************/
{
_( "Sheetfile" ), /* Title */
ADR( LAYER_SHEETFILENAME ) /* adr du parametre optionnel */
};
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
static ColorButton Layer_SheetLabel_Item =
{
_( "SheetLabel" ), /* Title */
ADR( LAYER_SHEETLABEL ) /* adr du parametre optionnel */
};
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
return true;
}
static ColorButton Layer_NoConnect_Item =
{
_( "NoConn" ), /* Title */
ADR( LAYER_NOCONNECT ) /* adr du parametre optionnel */
};
/**********************************************************/
void WinEDA_SetColorsFrame::Init()
/**********************************************************/
{
OuterBoxSizer = NULL;
MainBoxSizer = NULL;
ColumnBoxSizer = NULL;
RowBoxSizer = NULL;
BitmapButton = NULL;
text = NULL;
m_ShowGrid = NULL;
m_SelBgColor = NULL;
Line = NULL;
BottomBoxSizer = NULL;
Button = NULL;
}
static ColorButton Msg_ErcMarck =
{
_( "Erc Mark" ), /* Title */
NULL
};
static ColorButton Layer_Erc_Warning_Item =
/**********************************************************/
void WinEDA_SetColorsFrame::CreateControls()
/**********************************************************/
{
_( "Erc Warning" ), /* Title */
ADR( LAYER_ERC_WARN ) /* adr du parametre optionnel */
};
int ii, jj, butt_ID, buttcolor;
static ColorButton Layer_Erc_Error_Item =
{
_( "Erc Error" ), /* Title */
ADR( LAYER_ERC_ERR ) /* adr du parametre optionnel */
};
#define NB_BUTT 26
static ColorButton* laytool_list[NB_BUTT + 1] = {
&Msg_General,
&Layer_Wire_Item,
&Layer_Bus_Item,
&Layer_Jonction_Item,
&Layer_LocalLabel_Item,
&Layer_GlobLabel_Item,
&Layer_NetNam_Item,
&Layer_Notes_Item,
&Layer_NoConnect_Item,
&MsgDevice_Item,
&Layer_BodyDevice_Item,
&Layer_BodyBackgroundDevice_Item,
&Layer_Pin_Item,
&Layer_PinNum_Item,
&Layer_PinNam_Item,
&Layer_Reference_Item,
&Layer_Value_Item,
&Layer_Fields_Item,
&Msg_Sheets,
&Layer_Sheet_Item,
&Layer_SheetFileName_Item,
&Layer_SheetName_Item,
&Layer_SheetLabel_Item,
&Msg_ErcMarck,
&Layer_Erc_Warning_Item,
&Layer_Erc_Error_Item,
NULL
};
/*************************************************************/
/* classe derivee pour la frame de Configuration des couleurs*/
/*************************************************************/
class WinEDA_SetColorsFrame : public wxDialog
{
private:
WinEDA_DrawFrame* m_Parent;
wxRadioBox* m_SelBgColor;
SetFont( *g_DialogFont );
public:
OuterBoxSizer = new wxBoxSizer(wxVERTICAL);
SetSizer(OuterBoxSizer);
// Constructor and destructor
WinEDA_SetColorsFrame( WinEDA_DrawFrame * parent, const wxPoint &framepos );
~WinEDA_SetColorsFrame() { };
MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT, 5);
private:
void SetColor( wxCommandEvent& event );
void BgColorChoice( wxCommandEvent& event );
// Add various items to the dialog box, as determined by the
// details of each element contained within laytool_list[]
for( ii = 0, jj = 0; ii < NB_BUTT; ii++ )
{
// Look for the initial button of each group of controls.
if( ii == laytool_index[jj]->m_Index )
{
// Add another column spacer, unless the current value of
// jj is BUTTON_GROUPS - 1. (The very last group of controls
// differs from the previous groups in that its associated
// controls are located in the same column as the controls
// associated with the preceeding group.)
if( jj < BUTTON_GROUPS - 1 )
{
ColumnBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_TOP|wxLEFT|wxTOP, 5);
}
else
{
// Add a spacer to better separate the text string (which is
// about to be added) from the items located above it.
ColumnBoxSizer->AddSpacer(5);
}
DECLARE_EVENT_TABLE()
};
/* Table des evenements pour WinEDA_SetColorsFrame */
BEGIN_EVENT_TABLE( WinEDA_SetColorsFrame, wxDialog )
EVT_RADIOBOX( ID_SEL_BG_COLOR, WinEDA_SetColorsFrame::BgColorChoice )
EVT_COMMAND_RANGE( ID_COLOR_SETUP, ID_COLOR_SETUP + 26,
wxEVT_COMMAND_BUTTON_CLICKED,
WinEDA_SetColorsFrame::SetColor )
END_EVENT_TABLE()
RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
// Add a text string to identify the following set of controls
text = new wxStaticText( this, -1, laytool_index[jj]->m_Name,
wxDefaultPosition, wxDefaultSize, 0 );
// Make this text string bold (so that it stands out better)
text->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(),
wxNORMAL, wxBOLD, false, wxNORMAL_FONT->GetFaceName() ) );
/**************************************************************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos )
/**************************************************************/
{
WinEDA_SetColorsFrame* frame =
new WinEDA_SetColorsFrame( parent, framepos );
RowBoxSizer->Add(text, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
frame->ShowModal();
frame->Destroy();
}
/**********************************************************************/
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos ) :
wxDialog( parent, -1, _( "EESchema Preferences" ), framepos,
wxSize( 500, 270 ), DIALOG_STYLE )
/**********************************************************************/
{
#define START_Y 15
wxBitmapButton* Button;
int ii, yy, butt_ID, buttcolor;
wxPoint pos;
int w = BUTT_SIZE_X, h = BUTT_SIZE_Y;
wxStaticText* text;
int right, bottom, line_height;
wxPoint bg_color_pos;
jj++;
}
m_Parent = parent;
SetFont( *g_DialogFont );
RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxALL, 0);
pos.x = 10; pos.y = START_Y;
right = pos.x; bottom = 0;
line_height = h;
for( ii = 0; laytool_list[ii] != NULL; ii++ )
{
if( laytool_list[ii]->m_Color == NULL )
{
if( pos.y != START_Y )
{
pos.x = right + 10;
pos.y = START_Y;
bg_color_pos = pos;
}
wxString msg = wxGetTranslation( laytool_list[ii]->m_Name );
text = new wxStaticText( this, -1,
msg,
wxPoint ( pos.x, pos.y ),
wxSize( -1, -1 ), 0 );
line_height = MAX( line_height, text->GetRect().GetHeight() );
pos.y += line_height;
continue;
}
butt_ID = ID_COLOR_SETUP + ii;
laytool_list[ii]->m_Id = butt_ID;
wxMemoryDC iconDC;
wxBitmap ButtBitmap( w, h );
wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
iconDC.SelectObject( ButtBitmap );
buttcolor = *laytool_list[ii]->m_Color;
CurrentColor[ii] = buttcolor;
wxBrush Brush;
iconDC.SelectObject( ButtBitmap );
iconDC.SetPen( *wxBLACK_PEN );
......@@ -336,119 +203,183 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
Brush.SetStyle( wxSOLID );
iconDC.SetBrush( Brush );
iconDC.DrawRectangle( 0, 0, w, h );
Button = new wxBitmapButton( this, butt_ID,
ButtBitmap,
wxPoint ( pos.x, pos.y - (h - line_height) / 2 ),
wxSize (w, h) );
laytool_list[ii]->m_Button = Button;
wxString msg = wxGetTranslation( laytool_list[ii]->m_Name );
text = new wxStaticText( this, -1,
msg,
wxPoint (pos.x + 5 + w, pos.y ),
wxSize( -1, -1 ), 0 );
wxPoint lowpos;
lowpos.x = text->GetRect().GetRight();
lowpos.y = text->GetRect().GetBottom();
right = MAX( right, lowpos.x );
bottom = MAX( bottom, lowpos.y );
bg_color_pos.y = lowpos.y;
yy = line_height + 5;
pos.y += yy;
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
BitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap, wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) );
RowBoxSizer->Add(BitmapButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5);
laytool_list[ii]->m_Button = BitmapButton;
// Add a text string, unless the current value of ii is NB_BUTT - 1
if( ii < NB_BUTT - 1 )
{
text = new wxStaticText( this, wxID_STATIC, wxGetTranslation( laytool_list[ii]->m_Name ),
wxDefaultPosition, wxDefaultSize, 0 );
RowBoxSizer->Add(text, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
}
else
{
// Special case; provide a checkbox instead (rather than a text string).
m_ShowGrid = new wxCheckBox( this, ID_CHECKBOX_SHOW_GRID, _("Grid"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowGrid->SetValue( m_Parent->m_Draw_Grid );
RowBoxSizer->Add(m_ShowGrid, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
}
}
bg_color_pos.x += 5; bg_color_pos.y += 25;
static const wxString bg_choice[2] = { _( "White Background" ), _( "Black Background" ) };
m_SelBgColor = new wxRadioBox( this, ID_SEL_BG_COLOR,
_( "Background Colour" ), bg_color_pos,
wxDefaultSize, 2, bg_choice, 1, wxRA_SPECIFY_COLS );
// Add a spacer to improve appearance.
ColumnBoxSizer->AddSpacer(5);
wxArrayString m_SelBgColorStrings;
m_SelBgColorStrings.Add(_("White Background"));
m_SelBgColorStrings.Add(_("Black Background"));
m_SelBgColor = new wxRadioBox( this, ID_RADIOBOX_BACKGROUND_COLOR, _("Background Color"),
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);
// 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);
BottomBoxSizer = new wxBoxSizer(wxHORIZONTAL);
OuterBoxSizer->Add(BottomBoxSizer, 0, wxALIGN_RIGHT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
Button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 );
Button->SetForegroundColour( *wxRED );
BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
Button->SetForegroundColour( *wxBLUE );
BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
Button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition, wxDefaultSize, 0 );
BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
// (Dialog now needs to be resized, but the associated command is found elsewhere.)
}
/**********************************************************/
bool WinEDA_SetColorsFrame::ShowToolTips()
/**********************************************************/
{
return true;
}
/**********************************************************/
wxBitmap WinEDA_SetColorsFrame::GetBitmapResource( const wxString& name )
/**********************************************************/
{
wxUnusedVar(name);
return wxNullBitmap;
}
m_SelBgColor->SetSelection( (g_DrawBgColor == BLACK) ? 1 : 0 );
bottom = MAX( bottom, m_SelBgColor->GetRect().GetBottom() );
right = MAX( right, m_SelBgColor->GetRect().GetRight() );
SetClientSize( wxSize( right + 10, bottom + 10 ) );
/**********************************************************/
wxIcon WinEDA_SetColorsFrame::GetIconResource( const wxString& name )
/**********************************************************/
{
wxUnusedVar(name);
return wxNullIcon;
}
/***************************************************************/
/**********************************************************/
void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
/***************************************************************/
/**********************************************************/
{
int ii;
int id = event.GetId();
int color;
int w = BUTT_SIZE_X, h = BUTT_SIZE_Y;
wxBitmapButton* Button;
color = DisplayColorFrame( this,
*laytool_list[id - ID_COLOR_SETUP]->m_Color );
CurrentColor[id - ID_COLOR_SETUP] );
if( color < 0 )
return;
for( ii = 0; laytool_list[ii] != NULL; ii++ )
{
if( laytool_list[ii]->m_Id != id )
continue;
if( *laytool_list[ii]->m_Color == color )
break;
if( CurrentColor[id - ID_COLOR_SETUP] == color )
return;
*laytool_list[ii]->m_Color = color;
wxMemoryDC iconDC;
CurrentColor[id - ID_COLOR_SETUP] = color;
wxMemoryDC iconDC;
wxBitmapButton* Button = laytool_list[ii]->m_Button;
Button = laytool_list[id - ID_COLOR_SETUP]->m_Button;
wxBitmap ButtBitmap = Button->GetBitmapLabel();
iconDC.SelectObject( ButtBitmap );
int buttcolor = *laytool_list[ii]->m_Color;
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 );
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, w, h );
Button->SetBitmapLabel( ButtBitmap );
if( m_Parent->GetScreen() )
m_Parent->GetScreen()->SetRefreshReq();
}
iconDC.SetBrush( Brush );
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
Button->SetBitmapLabel( ButtBitmap );
Button->Refresh();
Refresh( FALSE );
}
/***************************************************************/
void WinEDA_SetColorsFrame::BgColorChoice( wxCommandEvent& event )
/***************************************************************/
/******************************************************************/
void WinEDA_SetColorsFrame::UpdateLayerSettings()
/******************************************************************/
{
int color;
// Update colors for each layer
for( int ii = 0; ii < NB_BUTT; ii++ )
{
if( laytool_list[ii]->m_Color )
*laytool_list[ii]->m_Color = CurrentColor[ii];
}
// Update whether grid is actually displayed or otherwise
m_Parent->m_Draw_Grid = g_ShowGrid = m_ShowGrid->GetValue();
// Update color of background
if( m_SelBgColor->GetSelection() == 0 )
color = WHITE;
g_DrawBgColor = WHITE;
else
color = BLACK;
g_DrawBgColor = BLACK;
m_Parent->SetDrawBgColor( g_DrawBgColor );
}
if( color != g_DrawBgColor )
{
g_DrawBgColor = color;
m_Parent->SetDrawBgColor( g_DrawBgColor );
m_Parent->ReDrawPanel();
}
/**********************************************************************/
void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{
UpdateLayerSettings();
m_Parent->ReDrawPanel();
EndModal( 1 );
}
/*******************************************************************/
void WinEDA_SetColorsFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************/
{
EndModal( -1 );
}
/*******************************************************************/
void WinEDA_SetColorsFrame::OnApplyClick( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************/
{
UpdateLayerSettings();
m_Parent->ReDrawPanel();
}
/*************************/
void SeedLayers()
/*************************/
......@@ -477,7 +408,7 @@ void SeedLayers()
int ReturnLayerColor( int Layer )
/*******************************/
{
if( g_LayerDescr.Flags==0 )
if( g_LayerDescr.Flags == 0 )
return g_LayerDescr.LayerColor[Layer];
else
return g_LayerDescr.CommonColor;
......
/*************/
/* eelayer.h */
/*************/
#ifndef _EELAYER_H_
#define _EELAYER_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "annotate_dialog.cpp"
#endif
#include "wx/statline.h"
class wxBoxSizer;
class wxStaticLine;
// Specify how many elements are contained within laytool_list[]
const int NB_BUTT = 23; // Includes an element associated with the grid
// Specify how many elements are contained within laytool_index[]
const int BUTTON_GROUPS = 5;
// Specify the numbers associated with assorted controls
enum col_sel_id {
ID_DIALOG = 1800,
ID_CHECKBOX_SHOW_GRID,
ID_RADIOBOX_BACKGROUND_COLOR,
ID_COLOR_SETUP
};
// #define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
#define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_SETCOLORSFRAME_TITLE _("EESchema Preferences")
#define SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME ID_DIALOG
// #define SYMBOL_WINEDA_SETCOLORSFRAME_SIZE wxSize(400, 300)
// #define SYMBOL_WINEDA_SETCOLORSFRAME_POSITION wxDefaultPosition
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 30;
const int BUTT_SIZE_Y = 20;
// Macro utile :
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])
/**********************************/
/* Liste des menus de Menu_Layers */
/**********************************/
struct ColorButton
{
wxString m_Name;
int* m_Color;
int m_Id;
wxBitmapButton* m_Button;
// int m_State; // This is not used at present (so commented
}; // out until such a time that it actually is used)
struct ButtonIndex
{
wxString m_Name;
int m_Index;
};
static ColorButton Layer_Wire_Item =
{
_( "Wire" ), // Title
ADR( LAYER_WIRE ) // Adr of optional parameter
};
static ColorButton Layer_Bus_Item =
{
_( "Bus" ), // Title
ADR( LAYER_BUS ) // Adr of optional parameter
};
static ColorButton Layer_Junction_Item =
{
_( "Junction" ), // Title
ADR( LAYER_JUNCTION ) // Adr of optional parameter
};
static ColorButton Layer_LocalLabel_Item =
{
_( "Label" ), // Title
ADR( LAYER_LOCLABEL ) // Adr of optional parameter
};
static ColorButton Layer_GlobLabel_Item =
{
_( "GlobLabel" ), // Title
ADR( LAYER_GLOBLABEL ) // Adr of optional parameter
};
static ColorButton Layer_NetNam_Item =
{
_( "Netname" ), // Title
ADR( LAYER_NETNAM ) // Adr of optional parameter
};
static ColorButton Layer_Notes_Item =
{
_( "Notes" ), // Title
ADR( LAYER_NOTES ) // Adr of optional parameter
};
static ColorButton Layer_NoConnect_Item =
{
_( "NoConn" ), // Title
ADR( LAYER_NOCONNECT ) // Adr of optional parameter
};
static ColorButton Layer_BodyDevice_Item =
{
_( "Body" ), // Title
ADR( LAYER_DEVICE ) // Adr of optional parameter
};
static ColorButton Layer_BodyBackgroundDevice_Item =
{
_( "Body Bg" ), // Title
ADR( LAYER_DEVICE_BACKGROUND ) // Adr of optional parameter
};
static ColorButton Layer_Pin_Item =
{
_( "Pin" ), // Title
ADR( LAYER_PIN ) // Adr of optional parameter
};
static ColorButton Layer_PinNum_Item =
{
_( "PinNum" ), // Title
ADR( LAYER_PINNUM ) // Adr of optional parameter
};
static ColorButton Layer_PinNam_Item =
{
_( "PinNam" ), // Title
ADR( LAYER_PINNAM ) // Adr of optional parameter
};
static ColorButton Layer_Reference_Item =
{
_( "Reference" ), // Title
ADR( LAYER_REFERENCEPART ) // Adr of optional parameter
};
static ColorButton Layer_Value_Item =
{
_( "Value" ), // Title
ADR( LAYER_VALUEPART ) // Adr of optional parameter
};
static ColorButton Layer_Fields_Item =
{
_( "Fields" ), // Title
ADR( LAYER_FIELDS ) // Adr of optional parameter
};
static ColorButton Layer_Sheet_Item =
{
_( "Sheet" ), // Title
ADR( LAYER_SHEET ) // Adr of optional parameter
};
static ColorButton Layer_SheetFileName_Item =
{
_( "Sheetfile" ), // Title
ADR( LAYER_SHEETFILENAME ) // Adr of optional parameter
};
static ColorButton Layer_SheetName_Item =
{
_( "SheetName" ), // Title
ADR( LAYER_SHEETNAME ) // Adr of optional parameter
};
static ColorButton Layer_SheetLabel_Item =
{
_( "SheetLabel" ), // Title
ADR( LAYER_SHEETLABEL ) // Adr of optional parameter
};
static ColorButton Layer_Erc_Warning_Item =
{
_( "Erc Warning" ), // Title
ADR( LAYER_ERC_WARN ) // Adr of optional parameter
};
static ColorButton Layer_Erc_Error_Item =
{
_( "Erc Error" ), // Title
ADR( LAYER_ERC_ERR ) // Adr of optional parameter
};
static ColorButton Layer_Grid_Item =
{
_( "Grid" ), // Title
&g_GridColor // Adr of optional parameter
};
static ColorButton* laytool_list[NB_BUTT] = {
&Layer_Wire_Item,
&Layer_Bus_Item,
&Layer_Junction_Item,
&Layer_LocalLabel_Item,
&Layer_GlobLabel_Item,
&Layer_NetNam_Item,
&Layer_Notes_Item,
&Layer_NoConnect_Item,
&Layer_BodyDevice_Item,
&Layer_BodyBackgroundDevice_Item,
&Layer_Pin_Item,
&Layer_PinNum_Item,
&Layer_PinNam_Item,
&Layer_Reference_Item,
&Layer_Value_Item,
&Layer_Fields_Item,
&Layer_Sheet_Item,
&Layer_SheetFileName_Item,
&Layer_SheetName_Item,
&Layer_SheetLabel_Item,
&Layer_Erc_Warning_Item,
&Layer_Erc_Error_Item,
&Layer_Grid_Item
};
static ButtonIndex Msg_General =
{
_( "General" ), // Title
0 // Index to first bitmap button in group
};
static ButtonIndex MsgDevice_Item =
{
_( "Device" ), // Title
8 // Index to first bitmap button in group
};
static ButtonIndex Msg_Sheets =
{
_( "Sheets" ), // Title
16 // Index to first bitmap button in group
};
static ButtonIndex Msg_ErcMarck =
{
_( "Erc Mark" ), // Title
20 // Index to first bitmap button in group
};
static ButtonIndex Msg_Other =
{
_( "Other" ), // Title
22 // Index to first bitmap button in group
};
static ButtonIndex* laytool_index[BUTTON_GROUPS] = {
&Msg_General,
&MsgDevice_Item,
&Msg_Sheets,
&Msg_ErcMarck,
&Msg_Other
};
/**************************************************************/
/* classe derivee pour la frame de Configuration des couleurs */
/**************************************************************/
class WinEDA_SetColorsFrame: public wxDialog
{
private:
DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame )
DECLARE_EVENT_TABLE()
WinEDA_DrawFrame* m_Parent;
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxBoxSizer* ColumnBoxSizer;
wxBoxSizer* RowBoxSizer;
wxBitmapButton* BitmapButton;
wxStaticText* text;
wxCheckBox* m_ShowGrid;
wxRadioBox* m_SelBgColor;
wxStaticLine* Line;
wxBoxSizer* BottomBoxSizer;
wxButton* Button;
// Creation
bool Create( wxWindow* parent,
wxWindowID id = SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
// Initialises member variables
void Init();
// Creates the controls and sizers
void CreateControls();
wxBitmap GetBitmapResource( const wxString& name );
wxIcon GetIconResource( const wxString& name );
static bool ShowToolTips();
void UpdateLayerSettings();
void SetColor( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnApplyClick( wxCommandEvent& event );
public:
// Constructors and destructor
WinEDA_SetColorsFrame();
WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos );
~WinEDA_SetColorsFrame();
};
#endif
// _EELAYER_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment