Enhance "Colors" dialog box (as listed in change_log.txt)

This commit is contained in:
g_harland 2007-09-13 09:24:43 +00:00
parent cb49ea8989
commit 2f3aeeaa29
6 changed files with 191 additions and 125 deletions

View File

@ -5,6 +5,15 @@ Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Sep-13 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ eeschema & pcbnew & gerbview
A Cancel button has now been provided for the "Colors" dialog box, which also
permits it to (otherwise) be cancelled by pressing the "Esc" key; the button
whose color matches that of the color currently selected (for the layer being
edited) also has the initial focus set to it.
2007-Sep-11 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Sep-11 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+ pcbnew + pcbnew

View File

@ -2,7 +2,7 @@
/* SETCOLOR.CPP */ /* SETCOLOR.CPP */
/************************/ /************************/
/* Affichage et selection de la palette des couleurs disponibles /* Affichage et selection de la palette des couleurs disponibles
dans une frame * dans une frame
*/ */
#include "fctsys.h" #include "fctsys.h"
@ -28,24 +28,27 @@ private:
public: public:
// Constructor and destructor // Constructor and destructor
WinEDA_SelColorFrame(wxWindow *parent, const wxPoint& framepos); WinEDA_SelColorFrame(wxWindow *parent,
const wxPoint& framepos, int OldColor);
~WinEDA_SelColorFrame(void) {}; ~WinEDA_SelColorFrame(void) {};
private: private:
void OnCancel(wxCommandEvent& event);
void SelColor(wxCommandEvent& event); void SelColor(wxCommandEvent& event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* Construction de la table des evenements pour FrameClassMain */ /* Construction de la table des evenements pour FrameClassMain */
BEGIN_EVENT_TABLE(WinEDA_SelColorFrame, wxDialog) BEGIN_EVENT_TABLE(WinEDA_SelColorFrame, wxDialog)
EVT_BUTTON(wxID_CANCEL, WinEDA_SelColorFrame::OnCancel)
EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + 31, EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + 31,
wxEVT_COMMAND_BUTTON_CLICKED, wxEVT_COMMAND_BUTTON_CLICKED, WinEDA_SelColorFrame::SelColor )
WinEDA_SelColorFrame::SelColor)
END_EVENT_TABLE() END_EVENT_TABLE()
/***************************************/ /***************************************/
int DisplayColorFrame(wxWindow * parent) int DisplayColorFrame(wxWindow * parent, int OldColor)
/***************************************/ /***************************************/
{ {
wxPoint framepos; wxPoint framepos;
@ -53,26 +56,32 @@ int color;
wxGetMousePosition(&framepos.x, &framepos.y); wxGetMousePosition(&framepos.x, &framepos.y);
WinEDA_SelColorFrame * frame = new WinEDA_SelColorFrame(parent,framepos); WinEDA_SelColorFrame * frame = new WinEDA_SelColorFrame(parent,
color = frame->ShowModal(); frame->Destroy(); framepos, OldColor);
if (color > NBCOLOR) color = -1; color = frame->ShowModal();
frame->Destroy();
if( color > NBCOLOR )
color = -1;
return color; return color;
} }
/*******************************************************************/ /*******************************************************************/
WinEDA_SelColorFrame::WinEDA_SelColorFrame(wxWindow *parent, WinEDA_SelColorFrame::WinEDA_SelColorFrame(wxWindow *parent,
const wxPoint& framepos): const wxPoint& framepos, int OldColor):
wxDialog(parent, -1, _("Colors"), framepos, wxSize(375, 240), wxDialog(parent, -1, _("Colors"), framepos, wxSize(375, 240),
DIALOG_STYLE ) DIALOG_STYLE )
/*******************************************************************/ /*******************************************************************/
{ {
#define START_Y 10 #define START_Y 10
wxBitmapButton * Button; wxBitmapButton * BitmapButton;
wxButton * Button;
int ii, butt_ID, buttcolor; int ii, butt_ID, buttcolor;
wxPoint pos; wxPoint pos;
int w = 20, h = 20; int w = 20, h = 20;
wxStaticText * text; wxStaticText * text;
int right, bottom, line_height; int right, bottom, line_height;
bool ColorFound = false;
SetFont(*g_DialogFont); SetFont(*g_DialogFont);
@ -109,23 +118,54 @@ int right, bottom, line_height;
right = MAX( right, text->GetRect().GetRight() ); right = MAX( right, text->GetRect().GetRight() );
bottom = MAX( bottom, text->GetRect().GetBottom() ); bottom = MAX( bottom, text->GetRect().GetBottom() );
Button = new wxBitmapButton(this, butt_ID, BitmapButton = new wxBitmapButton( this, butt_ID,
ButtBitmap, ButtBitmap,
wxPoint(pos.x, pos.y - ((h -line_height)/2)), wxPoint( pos.x, pos.y - (h - line_height) / 2 ),
wxSize(w, h) ); wxSize(w, h) );
pos.y += line_height + 5; // Set focus to this button if its color matches the
if ( ii == 7 ) // color which had been selected previously (for
// whichever layer's color is currently being edited).
if( OldColor == buttcolor )
{ {
pos.x = right + 10; pos.y = START_Y; ColorFound = true;
BitmapButton->SetFocus();
} }
else if ( (ii == 15) || (ii == 23) )
pos.y += line_height + 5;
if ( ii == 7 || ii == 15 )
{ {
pos.x = right+ 10; pos.y = START_Y; pos.x = right + 10;
pos.y = START_Y;
} }
} }
SetClientSize( wxSize(right + 10, bottom + 10) ); pos.x = 140;
// Provide a Cancel button as well, so that this dialog
// box can also be cancelled by pressing the Esc key.
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), pos );
Button->SetForegroundColour( *wxBLUE );
// Set focus to the Cancel button if the currently selected color
// does not match any of the colors provided by this dialog box.
// (That shouldn't ever happen in practice though.)
if( !ColorFound )
Button->SetFocus();
SetClientSize( wxSize( right + 10, bottom + 40 ) );
}
/***************************************************************/
void WinEDA_SelColorFrame::OnCancel(wxCommandEvent& WXUNUSED(event))
/***************************************************************/
/* Called by the Cancel button
*/
{
// Setting the return value to -1 indicates that the
// dialog box has been cancelled (and thus that the
// previously selected color is to be retained).
EndModal(-1);
} }
@ -138,5 +178,3 @@ int id = event.GetId();
EndModal(id - ID_COLOR_BLACK); EndModal(id - ID_COLOR_BLACK);
} }

View File

@ -273,9 +273,11 @@ void DisplayColorSetupFrame(WinEDA_DrawFrame * parent,
{ {
WinEDA_SetColorsFrame * frame = WinEDA_SetColorsFrame * frame =
new WinEDA_SetColorsFrame(parent, framepos); new WinEDA_SetColorsFrame(parent, framepos);
frame->ShowModal(); frame->Destroy(); frame->ShowModal();
frame->Destroy();
} }
/**********************************************************************/ /**********************************************************************/
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent,
const wxPoint& framepos): const wxPoint& framepos):
@ -338,7 +340,7 @@ wxPoint bg_color_pos;
Button = new wxBitmapButton( this, butt_ID, Button = new wxBitmapButton( this, butt_ID,
ButtBitmap, ButtBitmap,
wxPoint(pos.x, pos.y - ((h -line_height)/2) ), wxPoint( pos.x, pos.y - (h - line_height) / 2 ),
wxSize(w, h) ); wxSize(w, h) );
laytool_list[ii]->m_Button = Button; laytool_list[ii]->m_Button = Button;
@ -364,8 +366,8 @@ wxString bg_choice[2] = { _("White Background"), _("Black Background")};
_("Background Colour"), bg_color_pos, _("Background Colour"), bg_color_pos,
wxDefaultSize, 2, bg_choice, 1, wxRA_SPECIFY_COLS); wxDefaultSize, 2, bg_choice, 1, wxRA_SPECIFY_COLS);
m_SelBgColor->SetSelection( (g_DrawBgColor == BLACK) ? 1 : 0); m_SelBgColor->SetSelection( (g_DrawBgColor == BLACK) ? 1 : 0);
bottom = MAX(bottom, m_SelBgColor->GetRect().GetBottom());; bottom = MAX(bottom, m_SelBgColor->GetRect().GetBottom());
right = MAX(right, m_SelBgColor->GetRect().GetRight());; right = MAX(right, m_SelBgColor->GetRect().GetRight());
SetClientSize(wxSize(right+10, bottom+10)); SetClientSize(wxSize(right+10, bottom+10));
} }
@ -375,17 +377,23 @@ wxString bg_choice[2] = { _("White Background"), _("Black Background")};
void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event) void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event)
/***************************************************************/ /***************************************************************/
{ {
int ii;
int id = event.GetId(); int id = event.GetId();
int color = DisplayColorFrame(this); int color;
int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; int w = BUTT_SIZE_X, h = BUTT_SIZE_Y;
if ( color < 0) return; color = DisplayColorFrame( this,
*laytool_list[id - ID_COLOR_SETUP]->m_Color );
if ( color < 0 )
return;
for ( int ii = 0; laytool_list[ii] != NULL; ii++ ) for ( ii = 0; laytool_list[ii] != NULL; ii++ )
{ {
if( laytool_list[ii]->m_Id != id) continue; if( laytool_list[ii]->m_Id != id )
continue;
if( *laytool_list[ii]->m_Color == color) break; if( *laytool_list[ii]->m_Color == color )
break;
*laytool_list[ii]->m_Color = color; *laytool_list[ii]->m_Color = color;
wxMemoryDC iconDC; wxMemoryDC iconDC;
@ -421,8 +429,10 @@ void WinEDA_SetColorsFrame::BgColorChoice(wxCommandEvent& event)
{ {
int color; int color;
if ( m_SelBgColor->GetSelection() == 0 ) color = WHITE; if ( m_SelBgColor->GetSelection() == 0 )
else color = BLACK; color = WHITE;
else
color = BLACK;
if ( color != g_DrawBgColor ) if ( color != g_DrawBgColor )
{ {
@ -430,12 +440,9 @@ int color;
m_Parent->SetDrawBgColor(g_DrawBgColor); m_Parent->SetDrawBgColor(g_DrawBgColor);
m_Parent->ReDrawPanel(); m_Parent->ReDrawPanel();
} }
} }
/*************************/ /*************************/
void SeedLayers(void) void SeedLayers(void)
/*************************/ /*************************/
@ -470,4 +477,3 @@ int ReturnLayerColor(int Layer)
return( g_LayerDescr.CommonColor ); return( g_LayerDescr.CommonColor );
} }

View File

@ -28,6 +28,7 @@ enum col_sel_id {
ID_COLOR_SETUP ID_COLOR_SETUP
}; };
/**********************************/ /**********************************/
/* Liste des menus de Menu_Layers */ /* Liste des menus de Menu_Layers */
/**********************************/ /**********************************/
@ -133,11 +134,11 @@ void DisplayColorSetupFrame(WinEDA_DrawFrame * parent,
{ {
WinEDA_SetColorsFrame * frame = WinEDA_SetColorsFrame * frame =
new WinEDA_SetColorsFrame(parent, framepos); new WinEDA_SetColorsFrame(parent, framepos);
frame->ShowModal(); frame->Destroy(); frame->ShowModal();
frame->Destroy();
} }
/**********************************************************************/ /**********************************************************************/
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent,
const wxPoint& framepos): const wxPoint& framepos):
@ -185,7 +186,8 @@ wxBoxSizer * CurrBoxSizer = NULL;
{ {
if ( *laytool_list[ii]->m_Color & ITEM_NOT_SHOW ) if ( *laytool_list[ii]->m_Color & ITEM_NOT_SHOW )
laytool_list[ii]->m_CheckBox->SetValue(FALSE); laytool_list[ii]->m_CheckBox->SetValue(FALSE);
else laytool_list[ii]->m_CheckBox->SetValue(TRUE); else
laytool_list[ii]->m_CheckBox->SetValue(TRUE);
} }
else if ( laytool_list[ii]->m_NoDisplay ) else if ( laytool_list[ii]->m_NoDisplay )
@ -242,6 +244,7 @@ wxBoxSizer * CurrBoxSizer = NULL;
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints(this);
} }
/*******************************************************************/ /*******************************************************************/
void WinEDA_SetColorsFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void WinEDA_SetColorsFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
/*******************************************************************/ /*******************************************************************/
@ -251,7 +254,6 @@ void WinEDA_SetColorsFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
} }
/***********************************************************/ /***********************************************************/
void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event) void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event)
/***********************************************************/ /***********************************************************/
@ -261,16 +263,21 @@ int id = event.GetId();
int color; int color;
int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; int w = BUTT_SIZE_X, h = BUTT_SIZE_Y;
color = DisplayColorFrame( this,
color = DisplayColorFrame(this); *laytool_list[id - ID_COLOR_SETUP]->m_Color );
if ( color < 0) return; if ( color < 0 )
return;
for ( ii = 0; laytool_list[ii] != NULL; ii++ ) for ( ii = 0; laytool_list[ii] != NULL; ii++ )
{ {
if( laytool_list[ii]->m_Id != id) continue; if( laytool_list[ii]->m_Id != id )
if( laytool_list[ii]->m_Color == NULL) continue; continue;
if( *laytool_list[ii]->m_Color == color) break; if( laytool_list[ii]->m_Color == NULL )
continue;
if( *laytool_list[ii]->m_Color == color )
break;
*laytool_list[ii]->m_Color = color; *laytool_list[ii]->m_Color = color;
wxMemoryDC iconDC; wxMemoryDC iconDC;
@ -306,28 +313,28 @@ void WinEDA_SetColorsFrame::SetDisplayOnOff(wxCommandEvent& event)
{ {
for ( int ii = 0; laytool_list[ii] != NULL; ii++ ) for ( int ii = 0; laytool_list[ii] != NULL; ii++ )
{ {
if ( laytool_list[ii]->m_CheckBox == NULL ) continue; if ( laytool_list[ii]->m_CheckBox == NULL )
continue;
if ( ! laytool_list[ii]->m_NoDisplayIsColor && if ( ! laytool_list[ii]->m_NoDisplayIsColor &&
(laytool_list[ii]->m_NoDisplay == NULL) ) continue; (laytool_list[ii]->m_NoDisplay == NULL) )
continue;
if ( laytool_list[ii]->m_NoDisplayIsColor ) if ( laytool_list[ii]->m_NoDisplayIsColor )
{ {
if ( laytool_list[ii]->m_CheckBox->GetValue() ) if ( laytool_list[ii]->m_CheckBox->GetValue() )
*laytool_list[ii]->m_Color &= ~ITEM_NOT_SHOW; *laytool_list[ii]->m_Color &= ~ITEM_NOT_SHOW;
else *laytool_list[ii]->m_Color |= ITEM_NOT_SHOW; else
*laytool_list[ii]->m_Color |= ITEM_NOT_SHOW;
} }
else else
{ {
*laytool_list[ii]->m_NoDisplay = laytool_list[ii]->m_CheckBox->GetValue(); *laytool_list[ii]->m_NoDisplay = laytool_list[ii]->m_CheckBox->GetValue();
} }
} }
m_Parent->GetScreen()->SetRefreshReq(); m_Parent->GetScreen()->SetRefreshReq();
} }
/***********************************************************************/ /***********************************************************************/
void WinEDA_SetColorsFrame::ResetDisplayLayersCu(wxCommandEvent& event) void WinEDA_SetColorsFrame::ResetDisplayLayersCu(wxCommandEvent& event)
/***********************************************************************/ /***********************************************************************/
@ -336,7 +343,8 @@ bool NewState = (event.GetId() == ID_COLOR_RESET_SHOW_LAYER_ON) ? TRUE : FALSE;
for ( int ii = 1; ii < 34; ii++ ) for ( int ii = 1; ii < 34; ii++ )
{ {
if ( laytool_list[ii]->m_CheckBox == NULL ) continue; if ( laytool_list[ii]->m_CheckBox == NULL )
continue;
laytool_list[ii]->m_CheckBox->SetValue(NewState); laytool_list[ii]->m_CheckBox->SetValue(NewState);
} }

View File

@ -551,7 +551,7 @@ void AfficheDoc(WinEDA_DrawFrame * frame, const wxString & Doc, const wxString &
int GetTimeStamp(void); int GetTimeStamp(void);
/* Retoure une identification temporelle (Time stamp) differente a chaque appel */ /* Retoure une identification temporelle (Time stamp) differente a chaque appel */
int DisplayColorFrame(wxWindow * parent); int DisplayColorFrame(wxWindow * parent, int OldColor);
int GetCommandOptions(const int argc, const char **argv, const char * stringtst, int GetCommandOptions(const int argc, const char **argv, const char * stringtst,
const char ** optarg, int * optind); const char ** optarg, int * optind);
@ -627,4 +627,3 @@ void DrawAndSizingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase
#endif // COMMON_H #endif // COMMON_H

View File

@ -50,11 +50,6 @@ static ColorButton Msg_Layers_Cu =
_( "Copper Layers" ), -1 /* Title */ _( "Copper Layers" ), -1 /* Title */
}; };
static ColorButton Msg_Layers_Tech =
{
_( "Tech Layers" ), -1 /* Title */
};
static ColorButton Layer_1_Butt = static ColorButton Layer_1_Butt =
{ {
wxEmptyString, wxEmptyString,
@ -183,6 +178,12 @@ static ColorButton Layer_16_Butt =
TRUE // toggle bit ITEM_NOT_SHOW of the color variable TRUE // toggle bit ITEM_NOT_SHOW of the color variable
}; };
static ColorButton Msg_Layers_Tech =
{
_( "Tech Layers" ), -1 /* Title */
};
static ColorButton Layer_17_Butt = static ColorButton Layer_17_Butt =
{ {
wxEmptyString, wxEmptyString,
@ -322,7 +323,8 @@ static ColorButton Ratsnest_Butt =
_( "Ratsnest" ), /* Title */ _( "Ratsnest" ), /* Title */
-1, -1,
&g_DesignSettings.m_RatsnestColor, /* adr du parametre optionnel */ &g_DesignSettings.m_RatsnestColor, /* adr du parametre optionnel */
FALSE, &g_Show_Ratsnest // address of boolean display control parameter to toggle FALSE,
&g_Show_Ratsnest // address of boolean display control parameter to toggle
}; };
static ColorButton Pad_Cu_Butt = static ColorButton Pad_Cu_Butt =
@ -455,6 +457,7 @@ static ColorButton* laytool_list[] = {
// &Layer_30_Butt, // &Layer_30_Butt,
// &Layer_31_Butt, // &Layer_31_Butt,
// &Layer_32_Butt,
&Msg_Others_Items, &Msg_Others_Items,
&Via_Normale_Butt, &Via_Normale_Butt,
@ -552,7 +555,7 @@ BEGIN_EVENT_TABLE( WinEDA_SetColorsFrame, wxDialog )
EVT_BUTTON( ID_COLOR_SETUP + 41, WinEDA_SetColorsFrame::SetColor ) EVT_BUTTON( ID_COLOR_SETUP + 41, WinEDA_SetColorsFrame::SetColor )
EVT_BUTTON( ID_COLOR_SETUP + 42, WinEDA_SetColorsFrame::SetColor ) EVT_BUTTON( ID_COLOR_SETUP + 42, WinEDA_SetColorsFrame::SetColor )
EVT_BUTTON( ID_COLOR_SETUP + 43, WinEDA_SetColorsFrame::SetColor ) EVT_BUTTON( ID_COLOR_SETUP + 43, WinEDA_SetColorsFrame::SetColor )
EVT_BUTTON( ID_COLOR_SETUP + 44, WinEDA_SetColorsFrame::SetColor ) // EVT_BUTTON( ID_COLOR_SETUP + 44, WinEDA_SetColorsFrame::SetColor )
END_EVENT_TABLE() END_EVENT_TABLE()
/*****************************************************/ /*****************************************************/
@ -563,7 +566,8 @@ void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
WinEDA_SetColorsFrame* frame = WinEDA_SetColorsFrame* frame =
new WinEDA_SetColorsFrame( parent, framepos ); new WinEDA_SetColorsFrame( parent, framepos );
frame->ShowModal(); frame->Destroy(); frame->ShowModal();
frame->Destroy();
} }
@ -736,7 +740,9 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
int color; int color;
int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; int w = BUTT_SIZE_X, h = BUTT_SIZE_Y;
color = DisplayColorFrame( this ); color = DisplayColorFrame( this,
*laytool_list[id - ID_COLOR_SETUP]->m_Color );
if( color < 0 ) if( color < 0 )
return; return;