Commit 41a643c1 authored by g_harland's avatar g_harland

"Colors" dialog box has been enhanced

parent b78ccb72
......@@ -6,6 +6,11 @@ email address.
2007-Nov-11 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ eeschema & pcbnew & gerbview
* The "Colors" dialog box has been enhanced; the distance between adjacent
controls now increases (and in both horizontal and vertical directions)
when that dialog is resized. And the "Cancel" button is no longer centre-
justified; it is now right-justifed instead.
+ eeschema
* A wxStdDialogButtonSizer is now used within the "EESchema Colors" dialog box,
meaning that the sequence of the "OK", "Cancel", and "Apply" buttons within
......
/****************/
/* SETCOLOR.CPP */
/* SELCOLOR.CPP */
/****************/
/* Affichage et selection de la palette des couleurs disponibles
* dans une frame
......@@ -16,7 +16,7 @@
enum colors_id {
ID_COLOR_BLACK = 2000, // ID_COLOR_ = ID_COLOR_BLACK a ID_COLOR_BLACK + 31
ID_COLOR_BLACK = 2000 // ID_COLOR_ = ID_COLOR_BLACK a ID_COLOR_BLACK + 31
};
......@@ -73,45 +73,51 @@ int color;
WinEDA_SelColorFrame::WinEDA_SelColorFrame( wxWindow *parent,
const wxPoint& framepos, int OldColor ):
wxDialog( parent, -1, _("Colors"), framepos, wxDefaultSize,
DIALOG_STYLE )
wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER )
/*******************************************************************/
{
wxBoxSizer* OuterBoxSizer = NULL;
wxBoxSizer* MainBoxSizer = NULL;
wxBoxSizer* ColumnBoxSizer = NULL;
wxBoxSizer* RowBoxSizer = NULL;
wxBitmapButton* BitmapButton = NULL;
wxStaticText* text = NULL;
wxStaticLine* line = NULL;
wxButton* Button = NULL;
int ii, butt_ID, buttcolor;
int w = 20, h = 20;
bool ColorFound = false;
wxBoxSizer* OuterBoxSizer = NULL;
wxBoxSizer* MainBoxSizer = NULL;
wxFlexGridSizer* FlexColumnBoxSizer = NULL;
wxBitmapButton* BitmapButton = NULL;
wxStaticText* Label = NULL;
wxStaticLine* Line = NULL;
wxStdDialogButtonSizer* StdDialogButtonSizer = NULL;
wxButton* Button = NULL;
int ii, butt_ID, buttcolor;
int w = 20, h = 20;
bool ColorFound = false;
SetFont( *g_DialogFont );
SetReturnCode( -1 );
OuterBoxSizer = new wxBoxSizer(wxVERTICAL);
SetSizer(OuterBoxSizer);
MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
OuterBoxSizer->Add(MainBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
for( ii = 0; ColorRefs[ii].m_Name != NULL; ii++ )
{
// Provide a separate column for every eight buttons (and
// their associated text strings)
// Provide a separate column for every eight buttons (and their associated text
// strings), so provide a FlexGrid Sizer with eight rows and two columns.
if( ii % 8 == 0 )
{
ColumnBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(ColumnBoxSizer, 0, wxALIGN_TOP|wxTOP, 5);
FlexColumnBoxSizer = new wxFlexGridSizer(8, 2, 0, 0);
// Specify that all of the rows can be expanded.
for( int ii = 0; ii < 8; ii++ )
{
FlexColumnBoxSizer->AddGrowableRow(ii);
}
// Provide a sizer for each button and its associated text string
RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
ColumnBoxSizer->Add(RowBoxSizer, 0, wxALIGN_LEFT, 5);
// Specify that the second column can also be expanded.
FlexColumnBoxSizer->AddGrowableCol(1);
MainBoxSizer->Add(FlexColumnBoxSizer, 1, wxGROW|wxTOP, 5);
}
butt_ID = ID_COLOR_BLACK + ii;
wxMemoryDC iconDC;
......@@ -134,7 +140,7 @@ bool ColorFound = false;
BitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap,
wxDefaultPosition, wxSize( w, h ) );
RowBoxSizer->Add(BitmapButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5);
FlexColumnBoxSizer->Add(BitmapButton, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5);
// Set focus to this button if its color matches the
// color which had been selected previously (for
......@@ -145,9 +151,9 @@ bool ColorFound = false;
BitmapButton->SetFocus();
}
text = new wxStaticText( this, -1, ColorRefs[ii].m_Name,
Label = new wxStaticText( this, -1, ColorRefs[ii].m_Name,
wxDefaultPosition, wxDefaultSize, 0 );
RowBoxSizer->Add(text, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
FlexColumnBoxSizer->Add(Label, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
}
// Provide a Cancel button as well, so that this dialog
......@@ -155,37 +161,17 @@ bool ColorFound = false;
// (and also provide a horizontal static line to separate
// that button from all of the other buttons).
line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add(line, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
#if 0
BottomBoxSizer = new wxBoxSizer(wxHORIZONTAL);
OuterBoxSizer->Add(BottomBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add(Line, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
Button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 );
Button->SetForegroundColour( *wxRED );
BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
StdDialogButtonSizer = new wxStdDialogButtonSizer;
OuterBoxSizer->Add(StdDialogButtonSizer, 0, wxGROW|wxALL, 10);
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
Button = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
Button->SetForegroundColour( *wxBLUE );
BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
// Dialog boxes usually contain both an "OK" button and a "Cancel" button (and sometimes
// also contain an "Apply" button). The previous code implements an additional sizer
// (to contain such buttons), then installs that sizer into the outermost sizer, then
// implements "OK" and "Cancel" buttons, and then installs those buttons into that sizer.
//
// However, as this particular dialog does not contain an "OK" button (nor an "Apply"
// button), it is not necessary to provide an additional sizer to contain (just) a
// "Cancel" button; that button can be installed directly into the outermost sizer
// instead. (Note that a value of 10 has been specified for the margin surrounding that
// button; that provides the same outcome as specifying the customary value of 5 for both
// that button, and the BottomBoxSizer that it would otherwise be installed within.)
#endif
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
Button->SetForegroundColour( *wxBLUE );
OuterBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
StdDialogButtonSizer->AddButton(Button);
StdDialogButtonSizer->Realize();
// Set focus to the Cancel button if the currently selected color
// does not match any of the colors provided by this dialog box.
......@@ -194,7 +180,7 @@ bool ColorFound = false;
Button->SetFocus();
// Resize the dialog
if (GetSizer())
if( GetSizer() )
{
GetSizer()->SetSizeHints(this);
}
......@@ -210,7 +196,7 @@ void WinEDA_SelColorFrame::OnCancel(wxCommandEvent& WXUNUSED(event))
// 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);
EndModal( -1 );
}
......
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