Commit 2f3aeeaa authored by g_harland's avatar g_harland
Browse files

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

parent cb49ea89
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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
+79 −41
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
/*	 SETCOLOR.CPP		*/
/************************/
/* Affichage et selection de la palette des couleurs disponibles
dans une frame
 * dans une frame
 */

#include "fctsys.h"
@@ -28,24 +28,27 @@ 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_BUTTON(wxID_CANCEL, WinEDA_SelColorFrame::OnCancel)
	EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + 31,
		wxEVT_COMMAND_BUTTON_CLICKED,
		WinEDA_SelColorFrame::SelColor)
		wxEVT_COMMAND_BUTTON_CLICKED, WinEDA_SelColorFrame::SelColor )
END_EVENT_TABLE()


/***************************************/
int DisplayColorFrame(wxWindow * parent)
int DisplayColorFrame(wxWindow * parent, int OldColor)
/***************************************/
{
wxPoint framepos;
@@ -53,26 +56,32 @@ 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);

@@ -109,23 +118,54 @@ int right, bottom, line_height;
		right = MAX( right, text->GetRect().GetRight() );
		bottom = MAX( bottom, text->GetRect().GetBottom() );

		Button = new wxBitmapButton(this, butt_ID,
		BitmapButton = new wxBitmapButton( this, butt_ID,
							ButtBitmap,
						wxPoint(pos.x, pos.y  - ((h -line_height)/2)),
							wxPoint( pos.x, pos.y  - (h - line_height) / 2 ),
							wxSize(w, h) );

		pos.y +=  line_height + 5;
		if ( ii == 7 )
		// 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);
}

+44 −38
Original line number Diff line number Diff line
@@ -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):
@@ -338,7 +340,7 @@ wxPoint bg_color_pos;

		Button = new wxBitmapButton( this, butt_ID,
						ButtBitmap,
						wxPoint(pos.x, pos.y - ((h -line_height)/2) ),
						wxPoint( pos.x, pos.y - (h - line_height) / 2 ),
						wxSize(w, h) );
		laytool_list[ii]->m_Button = Button;

@@ -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,8 +429,10 @@ 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 )
	{
@@ -430,12 +440,9 @@ int color;
		m_Parent->SetDrawBgColor(g_DrawBgColor);
		m_Parent->ReDrawPanel();
	}


}



/*************************/
void SeedLayers(void)
/*************************/
@@ -470,4 +477,3 @@ int ReturnLayerColor(int Layer)
		return( g_LayerDescr.CommonColor );
}
+34 −26
Original line number Diff line number Diff line
@@ -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 == NULL )
			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;
@@ -306,28 +313,28 @@ 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_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)
/***********************************************************************/
@@ -336,7 +343,8 @@ 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);
	}

+1 −2
Original line number Diff line number Diff line
@@ -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
Loading