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.
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>
================================================================================
+ pcbnew

View File

@ -1,9 +1,9 @@
/************************/
/* SETCOLOR.CPP */
/************************/
/************************/
/* SETCOLOR.CPP */
/************************/
/* Affichage et selection de la palette des couleurs disponibles
dans une frame
*/
* dans une frame
*/
#include "fctsys.h"
#include "gr_basic.h"
@ -22,30 +22,33 @@ enum colors_id {
class WinEDA_SelColorFrame: public wxDialog
/*******************************************/
/* Frame d'affichage de la palette des couleurs disponibles
*/
*/
{
private:
public:
// Constructor and destructor
WinEDA_SelColorFrame(wxWindow *parent, const wxPoint& framepos);
WinEDA_SelColorFrame(wxWindow *parent,
const wxPoint& framepos, int OldColor);
~WinEDA_SelColorFrame(void) {};
private:
void OnCancel(wxCommandEvent& event);
void SelColor(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
/* Construction de la table des evenements pour FrameClassMain */
BEGIN_EVENT_TABLE(WinEDA_SelColorFrame, wxDialog)
EVT_COMMAND_RANGE(ID_COLOR_BLACK,ID_COLOR_BLACK+31,
wxEVT_COMMAND_BUTTON_CLICKED,
WinEDA_SelColorFrame::SelColor)
EVT_BUTTON(wxID_CANCEL, WinEDA_SelColorFrame::OnCancel)
EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + 31,
wxEVT_COMMAND_BUTTON_CLICKED, WinEDA_SelColorFrame::SelColor )
END_EVENT_TABLE()
/***************************************/
int DisplayColorFrame(wxWindow * parent)
int DisplayColorFrame(wxWindow * parent, int OldColor)
/***************************************/
{
wxPoint framepos;
@ -53,27 +56,33 @@ int color;
wxGetMousePosition(&framepos.x, &framepos.y);
WinEDA_SelColorFrame * frame = new WinEDA_SelColorFrame(parent,framepos);
color = frame->ShowModal(); frame->Destroy();
if (color > NBCOLOR) color = -1;
WinEDA_SelColorFrame * frame = new WinEDA_SelColorFrame(parent,
framepos, OldColor);
color = frame->ShowModal();
frame->Destroy();
if( color > NBCOLOR )
color = -1;
return color;
}
/*******************************************************************/
WinEDA_SelColorFrame::WinEDA_SelColorFrame(wxWindow *parent,
const wxPoint& framepos):
const wxPoint& framepos, int OldColor):
wxDialog(parent, -1, _("Colors"), framepos, wxSize(375, 240),
DIALOG_STYLE )
/*******************************************************************/
{
#define START_Y 10
wxBitmapButton * Button;
wxBitmapButton * BitmapButton;
wxButton * Button;
int ii, butt_ID, buttcolor;
wxPoint pos;
int w = 20, h = 20;
wxStaticText * text;
int right, bottom, line_height;
bool ColorFound = false;
SetFont(*g_DialogFont);
SetReturnCode(-1);
@ -99,33 +108,64 @@ int right, bottom, line_height;
iconDC.SetBrush(Brush);
iconDC.SetBackground(*wxGREY_BRUSH);
iconDC.Clear();
iconDC.DrawRoundedRectangle(0,0, w, h, (double)h/3);
iconDC.DrawRoundedRectangle(0, 0, w, h, (double)h / 3);
text = new wxStaticText(this,-1,
text = new wxStaticText( this, -1,
ColorRefs[ii].m_Name,
wxPoint(pos.x + 2 + w , pos.y ),
wxSize(-1,-1), 0 );
line_height = MAX( line_height, text->GetRect().GetHeight());
right = MAX(right, text->GetRect().GetRight());
bottom = MAX(bottom, text->GetRect().GetBottom());
Button = new wxBitmapButton(this, butt_ID,
ButtBitmap,
wxPoint(pos.x, pos.y - ((h -line_height)/2)),
wxSize(w,h) );
wxPoint( pos.x + 2 + w, pos.y ),
wxSize(-1, -1), 0 );
line_height = MAX( line_height, text->GetRect().GetHeight() );
right = MAX( right, text->GetRect().GetRight() );
bottom = MAX( bottom, text->GetRect().GetBottom() );
pos.y += line_height + 5;
if ( ii == 7 )
BitmapButton = new wxBitmapButton( this, butt_ID,
ButtBitmap,
wxPoint( pos.x, pos.y - (h - line_height) / 2 ),
wxSize(w, h) );
// Set focus to this button if its color matches the
// 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);
}

View File

@ -273,9 +273,11 @@ void DisplayColorSetupFrame(WinEDA_DrawFrame * parent,
{
WinEDA_SetColorsFrame * frame =
new WinEDA_SetColorsFrame(parent, framepos);
frame->ShowModal(); frame->Destroy();
frame->ShowModal();
frame->Destroy();
}
/**********************************************************************/
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent,
const wxPoint& framepos):
@ -299,9 +301,9 @@ wxPoint bg_color_pos;
right = pos.x; bottom = 0;
line_height = h;
for ( ii = 0; laytool_list[ii] != NULL; ii++ )
{
if( laytool_list[ii]->m_Color == NULL )
{
if( laytool_list[ii]->m_Color == NULL)
{
if( pos.y != START_Y )
{
pos.x = right + 10;
@ -309,14 +311,14 @@ wxPoint bg_color_pos;
bg_color_pos = pos;
}
wxString msg = wxGetTranslation(laytool_list[ii]->m_Name);
text = new wxStaticText(this,-1,
text = new wxStaticText( this, -1,
msg,
wxPoint(pos.x, pos.y ),
wxSize(-1,-1), 0 );
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;
@ -334,19 +336,19 @@ wxPoint bg_color_pos;
Brush.SetStyle(wxSOLID);
iconDC.SetBrush(Brush);
iconDC.DrawRectangle(0,0, w, h);
iconDC.DrawRectangle(0, 0, w, h);
Button = new wxBitmapButton(this, butt_ID,
Button = new wxBitmapButton( this, butt_ID,
ButtBitmap,
wxPoint(pos.x, pos.y - ((h -line_height)/2) ),
wxSize(w,h) );
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,
text = new wxStaticText( this, -1,
msg,
wxPoint(pos.x + 5 + w , pos.y ),
wxSize(-1,-1), 0 );
wxPoint(pos.x + 5 + w, pos.y ),
wxSize(-1, -1), 0 );
wxPoint lowpos;
lowpos.x = text->GetRect().GetRight();
lowpos.y = text->GetRect().GetBottom();
@ -356,7 +358,7 @@ wxPoint bg_color_pos;
yy = line_height + 5;
pos.y += yy;
}
}
bg_color_pos.x += 5; bg_color_pos.y += 25;
wxString bg_choice[2] = { _("White Background"), _("Black Background")};
@ -364,8 +366,8 @@ wxString bg_choice[2] = { _("White Background"), _("Black Background")};
_("Background Colour"), bg_color_pos,
wxDefaultSize, 2, bg_choice, 1, wxRA_SPECIFY_COLS);
m_SelBgColor->SetSelection( (g_DrawBgColor == BLACK) ? 1 : 0);
bottom = MAX(bottom, m_SelBgColor->GetRect().GetBottom());;
right = MAX(right, m_SelBgColor->GetRect().GetRight());;
bottom = MAX(bottom, m_SelBgColor->GetRect().GetBottom());
right = MAX(right, m_SelBgColor->GetRect().GetRight());
SetClientSize(wxSize(right+10, bottom+10));
}
@ -375,17 +377,23 @@ wxString bg_choice[2] = { _("White Background"), _("Black Background")};
void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event)
/***************************************************************/
{
int ii;
int id = event.GetId();
int color = DisplayColorFrame(this);
int color;
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;
wxMemoryDC iconDC;
@ -421,21 +429,20 @@ void WinEDA_SetColorsFrame::BgColorChoice(wxCommandEvent& event)
{
int color;
if ( m_SelBgColor->GetSelection() == 0 ) color = WHITE;
else color = BLACK;
if ( m_SelBgColor->GetSelection() == 0 )
color = WHITE;
else
color = BLACK;
if ( color != g_DrawBgColor )
{
{
g_DrawBgColor = color;
m_Parent->SetDrawBgColor(g_DrawBgColor);
m_Parent->ReDrawPanel();
}
}
}
/*************************/
void SeedLayers(void)
/*************************/
@ -445,18 +452,18 @@ int pt;
LayerPointer->CommonColor = WHITE;
LayerPointer->Flags = 0;
pt=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->LayerStatus[pt] = 0;
LayerPointer->LayerColor[pt] = DARKGRAY;
}
}
LayerPointer->NumberOfLayers = pt - 1;
/* Couleurs specifiques: Mise a jour par la lecture de la config*/
/* Couleurs specifiques: Mise a jour par la lecture de la config */
}
@ -464,10 +471,9 @@ int pt;
int ReturnLayerColor(int Layer)
/*******************************/
{
if(g_LayerDescr.Flags==0)
return(g_LayerDescr.LayerColor[Layer]);
if( g_LayerDescr.Flags==0 )
return( g_LayerDescr.LayerColor[Layer] );
else
return(g_LayerDescr.CommonColor);
return( g_LayerDescr.CommonColor );
}

View File

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

View File

@ -551,7 +551,7 @@ void AfficheDoc(WinEDA_DrawFrame * frame, const wxString & Doc, const wxString &
int GetTimeStamp(void);
/* 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,
const char ** optarg, int * optind);
@ -627,4 +627,3 @@ void DrawAndSizingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase
#endif // COMMON_H

View File

@ -50,11 +50,6 @@ static ColorButton Msg_Layers_Cu =
_( "Copper Layers" ), -1 /* Title */
};
static ColorButton Msg_Layers_Tech =
{
_( "Tech Layers" ), -1 /* Title */
};
static ColorButton Layer_1_Butt =
{
wxEmptyString,
@ -183,6 +178,12 @@ static ColorButton Layer_16_Butt =
TRUE // toggle bit ITEM_NOT_SHOW of the color variable
};
static ColorButton Msg_Layers_Tech =
{
_( "Tech Layers" ), -1 /* Title */
};
static ColorButton Layer_17_Butt =
{
wxEmptyString,
@ -322,7 +323,8 @@ static ColorButton Ratsnest_Butt =
_( "Ratsnest" ), /* Title */
-1,
&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 =
@ -455,6 +457,7 @@ static ColorButton* laytool_list[] = {
// &Layer_30_Butt,
// &Layer_31_Butt,
// &Layer_32_Butt,
&Msg_Others_Items,
&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 + 42, 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()
/*****************************************************/
@ -561,9 +564,10 @@ void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
/*****************************************************/
{
WinEDA_SetColorsFrame* frame =
new WinEDA_SetColorsFrame( parent,framepos);
new WinEDA_SetColorsFrame( parent, framepos );
frame->ShowModal(); frame->Destroy();
frame->ShowModal();
frame->Destroy();
}
@ -586,7 +590,7 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(
SetFont( *g_DialogFont );
pos.x = 5;
pos.x = 5;
pos.y = START_Y;
for( ii = 0; laytool_list[ii] != NULL; ii++ )
@ -595,7 +599,7 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(
{
if( pos.y != START_Y )
{
pos.x += w + 120;
pos.x += w + 120;
pos.y = START_Y;
}
@ -619,7 +623,7 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(
if( laytool_list[ii]->m_Id == 0 )
laytool_list[ii]->m_Id = ID_COLOR_SETUP + ii;
butt_ID = laytool_list[ii]->m_Id;
laytool_list[ii]->m_CheckBox = new wxCheckBox( this,
@ -693,9 +697,9 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(
pos.y += yy;
}
pos.x = 150;
pos.x = 150;
pos.y = 300;
wxButton* Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_ON,
_( "Show All" ), pos );
@ -712,8 +716,8 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(
_( "Exit" ), pos );
Button->SetForegroundColour( *wxBLUE );
winsize.x = 500;
winsize.x = 500;
winsize.y = pos.y + Button->GetSize().y + 5;
SetClientSize( winsize );
}
@ -736,7 +740,9 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
int color;
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;