From 3157b4d188d00f5fe1e6b5239bd628fdad0ebe0b Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Sun, 2 Sep 2012 13:01:12 +0200 Subject: [PATCH] Enforced EDA_COLOR_T type and minor const-ification --- common/block_commande.cpp | 2 +- common/class_colors_design_settings.cpp | 18 +-- common/common.cpp | 6 +- common/drawframe.cpp | 10 +- common/drawpanel.cpp | 8 +- common/eda_text.cpp | 4 +- common/edaappl.cpp | 6 +- common/gr_basic.cpp | 123 +++++++++--------- common/msgpanel.cpp | 10 +- common/projet_config.cpp | 12 +- common/selcolor.cpp | 8 +- common/worksheet.cpp | 2 +- cvpcb/class_DisplayFootprintsFrame.cpp | 4 +- cvpcb/class_DisplayFootprintsFrame.h | 4 +- eeschema/block_libedit.cpp | 6 +- eeschema/bus-wire-junction.cpp | 4 +- eeschema/class_libentry.cpp | 7 +- eeschema/class_libentry.h | 3 +- eeschema/dialogs/dialog_color_config.cpp | 4 +- eeschema/dialogs/dialog_lib_edit_pin.cpp | 2 +- .../dialogs/dialog_print_using_printer.cpp | 2 +- eeschema/eeredraw.cpp | 2 +- eeschema/eeschema.cpp | 4 +- eeschema/general.h | 8 +- eeschema/lib_arc.cpp | 7 +- eeschema/lib_arc.h | 4 +- eeschema/lib_bezier.cpp | 5 +- eeschema/lib_bezier.h | 2 +- eeschema/lib_circle.cpp | 5 +- eeschema/lib_circle.h | 2 +- eeschema/lib_draw_item.cpp | 6 +- eeschema/lib_draw_item.h | 8 +- eeschema/lib_field.cpp | 7 +- eeschema/lib_field.h | 4 +- eeschema/lib_pin.cpp | 13 +- eeschema/lib_pin.h | 6 +- eeschema/lib_polyline.cpp | 4 +- eeschema/lib_polyline.h | 2 +- eeschema/lib_rectangle.cpp | 4 +- eeschema/lib_rectangle.h | 2 +- eeschema/lib_text.cpp | 7 +- eeschema/lib_text.h | 2 +- eeschema/libeditframe.cpp | 12 +- eeschema/pinedit.cpp | 12 +- eeschema/protos.h | 2 +- eeschema/sch_bitmap.cpp | 2 +- eeschema/sch_bitmap.h | 2 +- eeschema/sch_bus_entry.cpp | 4 +- eeschema/sch_bus_entry.h | 2 +- eeschema/sch_component.cpp | 2 +- eeschema/sch_component.h | 4 +- eeschema/sch_field.cpp | 6 +- eeschema/sch_field.h | 2 +- eeschema/sch_junction.cpp | 4 +- eeschema/sch_junction.h | 2 +- eeschema/sch_line.cpp | 4 +- eeschema/sch_line.h | 2 +- eeschema/sch_marker.cpp | 4 +- eeschema/sch_marker.h | 2 +- eeschema/sch_no_connect.cpp | 5 +- eeschema/sch_no_connect.h | 2 +- eeschema/sch_polyline.cpp | 4 +- eeschema/sch_polyline.h | 2 +- eeschema/sch_screen.cpp | 2 +- eeschema/sch_sheet.cpp | 8 +- eeschema/sch_sheet.h | 4 +- eeschema/sch_sheet_pin.cpp | 2 +- eeschema/sch_text.cpp | 20 +-- eeschema/sch_text.h | 8 +- eeschema/symbdraw.cpp | 8 +- gerbview/block.cpp | 3 +- gerbview/class_aperture_macro.cpp | 4 +- gerbview/class_aperture_macro.h | 4 +- gerbview/class_gbr_layer_box_selector.cpp | 4 +- gerbview/class_gbr_layer_box_selector.h | 6 +- gerbview/class_gerber_draw_item.cpp | 11 +- gerbview/class_gerber_draw_item.h | 2 +- gerbview/class_gerbview_layer_widget.cpp | 4 +- gerbview/class_gerbview_layer_widget.h | 4 +- gerbview/dcode.cpp | 5 +- gerbview/dcode.h | 4 +- gerbview/draw_gerber_screen.cpp | 2 +- gerbview/gerbview.cpp | 2 +- gerbview/gerbview_config.cpp | 4 +- gerbview/gerbview_frame.cpp | 10 +- gerbview/gerbview_frame.h | 8 +- include/block_commande.h | 4 +- include/class_colors_design_settings.h | 14 +- include/class_drawpanel.h | 2 +- include/class_layer_box_selector.h | 6 +- include/class_sch_screen.h | 2 +- include/colors.h | 101 ++++++++------ include/common.h | 5 +- include/eda_text.h | 4 +- include/gr_basic.h | 90 +++++++------ include/param_config.h | 30 ++--- include/sch_item_struct.h | 2 +- include/wxPcbStruct.h | 8 +- include/wxstruct.h | 44 ++----- pcbnew/autorouter/autoplac.cpp | 5 +- pcbnew/autorouter/autorout.cpp | 7 +- pcbnew/autorouter/solve.cpp | 2 +- pcbnew/class_board.cpp | 10 +- pcbnew/class_board.h | 8 +- pcbnew/class_dimension.cpp | 3 +- pcbnew/class_drawsegment.cpp | 8 +- pcbnew/class_edge_mod.cpp | 9 +- pcbnew/class_mire.cpp | 4 +- pcbnew/class_module.cpp | 2 +- pcbnew/class_netinfo_item.cpp | 2 +- pcbnew/class_pad.h | 6 +- pcbnew/class_pad_draw_functions.cpp | 31 ++--- pcbnew/class_pcb_layer_box_selector.cpp | 6 +- pcbnew/class_pcb_layer_box_selector.h | 6 +- pcbnew/class_pcb_layer_widget.cpp | 14 +- pcbnew/class_pcb_layer_widget.h | 4 +- pcbnew/class_pcb_text.cpp | 8 +- pcbnew/class_text_mod.cpp | 3 +- pcbnew/class_track.cpp | 30 +---- pcbnew/class_zone.cpp | 35 ++--- pcbnew/dialogs/dialog_SVG_print.cpp | 2 +- pcbnew/dialogs/dialog_copper_zones.cpp | 8 +- .../dialog_keepout_area_properties.cpp | 7 +- pcbnew/dialogs/dialog_pad_properties.cpp | 4 +- pcbnew/editrack.cpp | 4 +- pcbnew/export_vrml.cpp | 6 +- pcbnew/gen_drill_report_files.cpp | 7 +- pcbnew/layer_widget.cpp | 35 +++-- pcbnew/layer_widget.h | 26 ++-- pcbnew/pcbframe.cpp | 8 +- pcbnew/pcbnew_config.cpp | 52 ++++---- pcbnew/plot_rtn.cpp | 4 +- pcbnew/print_board_functions.cpp | 4 +- pcbnew/printout_controler.cpp | 2 +- pcbnew/ratsnest.cpp | 2 +- pcbnew/tool_pcb.cpp | 2 +- 136 files changed, 598 insertions(+), 649 deletions(-) diff --git a/common/block_commande.cpp b/common/block_commande.cpp index 2ecb289d5f..59a6beca79 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -117,7 +117,7 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor ) + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { int w = GetWidth(); diff --git a/common/class_colors_design_settings.cpp b/common/class_colors_design_settings.cpp index e809d0d88e..8901544c58 100644 --- a/common/class_colors_design_settings.cpp +++ b/common/class_colors_design_settings.cpp @@ -15,7 +15,7 @@ /* Initial colors values: optimized for Pcbnew, but are also Ok for Eeschema * these values are superseded by config reading */ -static const int default_layer_color[LAYERSCOLORSBUFFERSIZE] = +static const EDA_COLOR_T default_layer_color[LAYERSCOLORSBUFFERSIZE] = { GREEN, BLUE, LIGHTGRAY, BROWN, RED, MAGENTA, LIGHTGRAY, MAGENTA, @@ -34,7 +34,7 @@ static const int default_layer_color[LAYERSCOLORSBUFFERSIZE] = DARKGRAY }; -static const int default_items_color[LAYERSCOLORSBUFFERSIZE] = +static const EDA_COLOR_T default_items_color[LAYERSCOLORSBUFFERSIZE] = { LIGHTGRAY, // unused CYAN, // VIA_MICROVIA_VISIBLE @@ -78,13 +78,13 @@ COLORS_DESIGN_SETTINGS:: COLORS_DESIGN_SETTINGS() * @return the color for aLayer which is one of the layer indices given * in pcbstruct.h or in schematic */ -int COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer ) +EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer ) const { if( (unsigned) aLayer < DIM(m_LayersColors) ) { return m_LayersColors[aLayer]; } - return -1; + return UNSPECIFIED_COLOR; } @@ -93,7 +93,7 @@ int COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer ) * sets the color for aLayer which is one of the layer indices given * in pcbstruct.h or in schematic */ -void COLORS_DESIGN_SETTINGS::SetLayerColor( int aLayer, int aColor ) +void COLORS_DESIGN_SETTINGS::SetLayerColor( int aLayer, EDA_COLOR_T aColor ) { if( (unsigned) aLayer < DIM(m_LayersColors) ) { @@ -107,13 +107,13 @@ void COLORS_DESIGN_SETTINGS::SetLayerColor( int aLayer, int aColor ) * @return the color for an item which is one of the item indices given * in pcbstruct.h, enum PCB_VISIBLE or in schematic */ -int COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) +EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) { if( (unsigned) aItemIdx < DIM(m_ItemsColors) ) { return m_ItemsColors[aItemIdx]; } - return -1; + return UNSPECIFIED_COLOR; } @@ -122,7 +122,7 @@ int COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) * sets the color for an item which is one of the item indices given * in pcbstruct.h, enum PCB_VISIBLE or in schematic */ -void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, int aColor ) +void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, EDA_COLOR_T aColor ) { if( (unsigned) aItemIdx < DIM(m_ItemsColors) ) { @@ -136,7 +136,7 @@ void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, int aColor ) * sets alls colors to aColor * Usefull to create a monochrome color selection for printing purpose */ -void COLORS_DESIGN_SETTINGS::SetAllColorsAs( int aColor) +void COLORS_DESIGN_SETTINGS::SetAllColorsAs( EDA_COLOR_T aColor ) { for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ ) m_LayersColors[ii] = aColor; diff --git a/common/common.cpp b/common/common.cpp index 7f0e4cc6e1..2b4183744c 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -57,13 +57,13 @@ wxString g_Prj_Config_LocalFilename; EDA_UNITS_T g_UserUnit; -int g_GhostColor; +EDA_COLOR_T g_GhostColor; #if defined(KICAD_GOST) -static bool s_gost = true; +static const bool s_gost = true; #else -static bool s_gost = false; +static const bool s_gost = false; #endif bool IsGOST() diff --git a/common/drawframe.cpp b/common/drawframe.cpp index a06d3e6bcd..b00ca4f3cb 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -475,7 +475,7 @@ void EDA_DRAW_FRAME::OnGrid( int grid_type ) } -wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) +wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const { wxPoint pos = aPosition; @@ -553,7 +553,7 @@ void EDA_DRAW_FRAME::LoadSettings() int itmp; if( cfg->Read( m_FrameName + GridColorEntryKeyword, &itmp ) ) - SetGridColor( itmp ); + SetGridColor( ColorFromInt( itmp ) ); cfg->Read( m_FrameName + LastGridSizeId, &m_LastGridSizeId, 0L ); } @@ -575,7 +575,7 @@ void EDA_DRAW_FRAME::SaveSettings() void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper, const wxString& textLower, - int color, int pad ) + EDA_COLOR_T color, int pad ) { if( m_messagePanel == NULL ) return; @@ -593,12 +593,12 @@ void EDA_DRAW_FRAME::ClearMsgPanel( void ) } -wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) +wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) const { return ::CoordinateToString( aValue, aConvertToMils ); } -wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMils ) +wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMils ) const { return ::LengthDoubleToString( aValue, aConvertToMils ); } diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 16c2f7b6f6..f65ae44873 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -153,7 +153,7 @@ BASE_SCREEN* EDA_DRAW_PANEL::GetScreen() } -void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, int aColor ) +void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor ) { if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair ) return; @@ -560,7 +560,7 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg ) void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC ) { - int axis_color = BLUE; + EDA_COLOR_T axis_color = BLUE; GRSetDrawMode( DC, GR_COPY ); @@ -721,7 +721,7 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) if( origin == wxPoint( 0, 0 ) ) return; - int color = DARKRED; + EDA_COLOR_T color = DARKRED; wxSize pageSize = GetParent()->GetPageSizeIU(); GRSetDrawMode( aDC, aDrawMode ); @@ -752,7 +752,7 @@ void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) || ( screen->m_GridOrigin.x == 0 && screen->m_GridOrigin.y == 0 ) ) return; - int color = GetParent()->GetGridColor(); + EDA_COLOR_T color = GetParent()->GetGridColor(); wxSize pageSize = GetParent()->GetPageSizeIU(); GRSetDrawMode( aDC, aDrawMode ); diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 3b301bc608..35bda7bed7 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -237,7 +237,7 @@ void EDA_TEXT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, aColor, aDrawMode, aFillMode, - i ? UNSPECIFIED : aAnchor_color, + i ? UNSPECIFIED_COLOR : aAnchor_color, txt, pos ); pos += offset; @@ -273,7 +273,7 @@ void EDA_TEXT::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GRSetDrawMode( aDC, aDrawMode ); /* Draw text anchor, if allowed */ - if( aAnchor_color != UNSPECIFIED ) + if( aAnchor_color != UNSPECIFIED_COLOR ) { int anchor_size = aDC->DeviceToLogicalXRel( 2 ); diff --git a/common/edaappl.cpp b/common/edaappl.cpp index d870a08ac7..2359b83c3e 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -655,9 +655,11 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory ) } } - m_settings->Read( wxT( "BgColor" ), &g_DrawBgColor ); + int draw_bg_color; + m_settings->Read( wxT( "BgColor" ), &draw_bg_color ); + g_DrawBgColor = ColorFromInt( draw_bg_color ); - /* Load per-user search paths from settings file */ + // Load per-user search paths from settings file wxString upath; int i = 1; diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 9c6f368b5f..bfe4b3952e 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -14,10 +14,7 @@ #include #include - -#ifndef FILLED -#define FILLED 1 -#endif +static const bool FILLED = true; /* Important Note: * These drawing functions clip draw item before send these items to wxDC draw @@ -50,7 +47,7 @@ GR_DRAWMODE g_XorMode = GR_NXOR; // Background color of the design frame -int g_DrawBgColor = WHITE; +EDA_COLOR_T g_DrawBgColor = WHITE; #define USE_CLIP_FILLED_POLYGONS @@ -64,7 +61,7 @@ static void ClipAndDrawFilledPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points * from user units to screen units(pixels coordinates) */ static void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, - int x2, int y2, int aWidth, int aColor, + int x2, int y2, int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID ); /**/ @@ -77,11 +74,11 @@ static int xcliplo = 0, xcliphi = 2000, ycliphi = 2000; -static int s_DC_lastcolor = -1; +static EDA_COLOR_T s_DC_lastcolor = UNSPECIFIED_COLOR; static int s_DC_lastwidth = -1; static int s_DC_lastpenstyle = -1; -static int s_DC_lastbrushcolor = -1; -static int s_DC_lastbrushfill = -1; +static EDA_COLOR_T s_DC_lastbrushcolor = UNSPECIFIED_COLOR; +static bool s_DC_lastbrushfill = false; static wxDC* s_DC_lastDC = NULL; @@ -318,7 +315,7 @@ static bool clipLine( EDA_RECT* aClipBox, int& x1, int& y1, int& x2, int& y2 ) static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int Color, int width = 1 ) + EDA_COLOR_T Color, int width = 1 ) { GRLastMoveToX = x2; GRLastMoveToY = y2; @@ -342,8 +339,8 @@ static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int void GRResetPenAndBrush( wxDC* DC ) { GRSetBrush( DC, BLACK ); // Force no fill - s_DC_lastbrushcolor = -1; - s_DC_lastcolor = -1; + s_DC_lastbrushcolor = UNSPECIFIED_COLOR; + s_DC_lastcolor = UNSPECIFIED_COLOR; s_DC_lastDC = NULL; } @@ -352,7 +349,7 @@ void GRResetPenAndBrush( wxDC* DC ) * Function GRSetColorPen * sets a pen style, width, color, and alpha into the given device context. */ -void GRSetColorPen( wxDC* DC, int Color, int width, wxPenStyle style ) +void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style ) { if( width < 0 ) width = 0; @@ -391,7 +388,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, wxPenStyle style ) } -void GRSetBrush( wxDC* DC, int Color, int fill ) +void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill ) { if( s_ForceBlackPen ) Color = BLACK; @@ -489,7 +486,7 @@ void GRSetDrawMode( wxDC* DC, GR_DRAWMODE draw_mode ) } -void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int Color ) +void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, EDA_COLOR_T Color ) { if( ClipBox && !ClipBox->Contains( x, y ) ) return; @@ -509,7 +506,7 @@ void GRLine( EDA_RECT* ClipBox, int x2, int y2, int width, - int Color ) + EDA_COLOR_T Color ) { WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width ); GRLastMoveToX = x2; @@ -517,18 +514,18 @@ void GRLine( EDA_RECT* ClipBox, } -void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor ) +void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor ) { GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor ); } -void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, int Color ) +void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, EDA_COLOR_T Color ) { - s_DC_lastcolor = -1; + s_DC_lastcolor = UNSPECIFIED_COLOR; GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH ); GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width, Color ); - s_DC_lastcolor = -1; + s_DC_lastcolor = UNSPECIFIED_COLOR; GRSetColorPen( DC, Color, width ); GRLastMoveToX = x2; GRLastMoveToY = y2; @@ -542,14 +539,14 @@ void GRDashedLine( EDA_RECT* ClipBox, int x2, int y2, int width, - int Color ) + EDA_COLOR_T Color ) { GRLastMoveToX = x2; GRLastMoveToY = y2; - s_DC_lastcolor = -1; + s_DC_lastcolor = UNSPECIFIED_COLOR; GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH ); GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color ); - s_DC_lastcolor = -1; + s_DC_lastcolor = UNSPECIFIED_COLOR; GRSetColorPen( DC, Color, width ); } @@ -567,7 +564,7 @@ void GRMoveTo( int x, int y ) /* * Draw line to a new position, in object space. */ -void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, int Color ) +void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, EDA_COLOR_T Color ) { int GRLineToX, GRLineToY; @@ -579,7 +576,7 @@ void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, int Color ) void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color ) + int width, EDA_COLOR_T Color ) { GRSetColorPen( DC, Color, width, wxPENSTYLE_DOT_DASH ); GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color ); @@ -599,7 +596,7 @@ void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, * @see EDA_COLOR_T and colors.h */ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector& aLines, - int aWidth, int aColor ) + int aWidth, EDA_COLOR_T aColor ) { GRSetColorPen( aDC, aColor, aWidth ); @@ -642,7 +639,7 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector& aLines, void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int aPenSize, int Color ) + int width, int aPenSize, EDA_COLOR_T Color ) { long radius; int dwx, dwy; @@ -787,14 +784,14 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color ) + int width, EDA_COLOR_T Color ) { GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color ); } void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, - int aWidth, int aColor ) + int aWidth, EDA_COLOR_T aColor ) { GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor ); } @@ -804,14 +801,14 @@ void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, * Draw segment (full) with rounded ends in object space (real coords.). */ void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color ) + int width, EDA_COLOR_T Color ) { WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width ); } void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, - int aWidth, int aColor ) + int aWidth, EDA_COLOR_T aColor ) { WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aColor, aWidth ); } @@ -865,8 +862,8 @@ static void GRSPoly( EDA_RECT* ClipBox, wxPoint Points[], bool Fill, int width, - int Color, - int BgColor ) + EDA_COLOR_T Color, + EDA_COLOR_T BgColor ) { if( !IsGRSPolyDrawable( ClipBox, n, Points ) ) return; @@ -911,8 +908,8 @@ static void GRSClosedPoly( EDA_RECT* ClipBox, wxPoint aPoints[], bool Fill, int width, - int Color, - int BgColor ) + EDA_COLOR_T Color, + EDA_COLOR_T BgColor ) { if( !IsGRSPolyDrawable( ClipBox, aPointCount, aPoints ) ) return; @@ -955,7 +952,7 @@ static void GRSClosedPoly( EDA_RECT* ClipBox, * Draw a new polyline and fill it if Fill, in drawing space. */ void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], - bool Fill, int width, int Color, int BgColor ) + bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ) { GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor ); } @@ -965,20 +962,20 @@ void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], * Draw a closed polyline and fill it if Fill, in object space. */ void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], - bool Fill, int Color, int BgColor ) + bool Fill, EDA_COLOR_T Color, EDA_COLOR_T BgColor ) { GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor ); } void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], - bool Fill, int width, int Color, int BgColor ) + bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ) { GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor ); } -void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, int Color ) +void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, EDA_COLOR_T Color ) { /* Clip circles off screen. */ if( ClipBox ) @@ -1008,20 +1005,20 @@ void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, in } -void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int Color ) +void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, EDA_COLOR_T Color ) { GRCircle( ClipBox, DC, x, y, r, 0, Color ); } -void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor ) +void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, EDA_COLOR_T aColor ) { GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor ); } void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, - int width, int Color, int BgColor ) + int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ) { /* Clip circles off screen. */ if( ClipBox ) @@ -1047,7 +1044,7 @@ void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, } -void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor ) +void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, EDA_COLOR_T aColor ) { GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor ); } @@ -1057,7 +1054,7 @@ void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, i * Draw an arc in user space. */ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int xc, int yc, int Color ) + int xc, int yc, EDA_COLOR_T Color ) { GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color ); } @@ -1067,7 +1064,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, * Draw an arc, width = width in user space. */ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int xc, int yc, int width, int Color ) + int xc, int yc, int width, EDA_COLOR_T Color ) { /* Clip arcs off screen. */ if( ClipBox ) @@ -1095,7 +1092,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, - wxPoint aCenter, int aWidth, int aColor ) + wxPoint aCenter, int aWidth, EDA_COLOR_T aColor ) { GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y, aWidth, aColor ); @@ -1113,8 +1110,8 @@ void GRFilledArc( EDA_RECT* ClipBox, int EndAngle, int r, int width, - int Color, - int BgColor ) + EDA_COLOR_T Color, + EDA_COLOR_T BgColor ) { int x1, y1, x2, y2; @@ -1155,7 +1152,7 @@ void GRFilledArc( EDA_RECT* ClipBox, void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, - int StAngle, int EndAngle, int r, int Color, int BgColor ) + int StAngle, int EndAngle, int r, EDA_COLOR_T Color, EDA_COLOR_T BgColor ) { GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor ); } @@ -1165,7 +1162,7 @@ void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, * Draw an arc in drawing space. */ void GRArc( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int StAngle, - int EndAngle, int r, int Color ) + int EndAngle, int r, EDA_COLOR_T Color ) { int x1, y1, x2, y2; @@ -1216,7 +1213,7 @@ void GRArc( EDA_RECT* ClipBox, int EndAngle, int r, int width, - int Color ) + EDA_COLOR_T Color ) { int x1, y1, x2, y2; @@ -1259,13 +1256,13 @@ void GRArc( EDA_RECT* ClipBox, /* * Draw a rectangle in drawing space. */ -void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, int aColor ) +void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, EDA_COLOR_T aColor ) { GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor ); } -void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aColor, wxPenStyle aStyle ) +void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, EDA_COLOR_T aColor, wxPenStyle aStyle ) { int x1 = aRect.GetX(); int y1 = aRect.GetY(); @@ -1279,13 +1276,13 @@ void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aColor, /* * Draw a rectangle (thick lines) in drawing space. */ -void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color ) +void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color ) { GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color ); } -void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, int aColor ) +void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, EDA_COLOR_T aColor ) { int x1 = aRect.GetX(); int y1 = aRect.GetY(); @@ -1300,7 +1297,7 @@ void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, i * Draw a rectangle (filled with AreaColor) in drawing space. */ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int Color, int BgColor ) + EDA_COLOR_T Color, EDA_COLOR_T BgColor ) { GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor ); } @@ -1310,7 +1307,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, * Draw a rectangle (filled with AreaColor) in drawing space. */ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color, int BgColor ) + int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ) { GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor ); } @@ -1321,7 +1318,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, */ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, - int aWidth, int aColor, wxPenStyle aStyle ) + int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle ) { wxPoint points[5]; @@ -1344,7 +1341,7 @@ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, - int aWidth, int aColor, int aBgColor ) + int aWidth, EDA_COLOR_T aColor, EDA_COLOR_T aBgColor ) { wxPoint points[5]; @@ -1430,10 +1427,10 @@ void GRBezier( EDA_RECT* ClipBox, int x3, int y3, int width, - int Color ) + EDA_COLOR_T Color ) { std::vector Points = Bezier2Poly( x1, y1, x2, y2, x3, y3 ); - GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, 0 ); + GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color ); } @@ -1448,8 +1445,8 @@ void GRBezier( EDA_RECT* ClipBox, int x4, int y4, int width, - int Color ) + EDA_COLOR_T Color ) { std::vector Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 ); - GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, 0 ); + GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color ); } diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp index c57d32f5e2..69d46cd3b1 100644 --- a/common/msgpanel.cpp +++ b/common/msgpanel.cpp @@ -76,7 +76,7 @@ int EDA_MSG_PANEL::GetRequiredHeight() } -wxSize EDA_MSG_PANEL::computeTextSize( const wxString& text ) +wxSize EDA_MSG_PANEL::computeTextSize( const wxString& text ) const { // Get size of the wxSYS_DEFAULT_GUI_FONT wxSize textSizeInPixels; @@ -109,7 +109,7 @@ void EDA_MSG_PANEL::OnPaint( wxPaintEvent& event ) void EDA_MSG_PANEL::AppendMessage( const wxString& textUpper, const wxString& textLower, - int color, int pad ) + EDA_COLOR_T color, int pad ) { wxString text; wxSize drawSize = GetClientSize(); @@ -143,7 +143,7 @@ void EDA_MSG_PANEL::AppendMessage( const wxString& textUpper, void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText, - const wxString& aLowerText, int aColor ) + const wxString& aLowerText, EDA_COLOR_T aColor ) { wxPoint pos; wxSize drawSize = GetClientSize(); @@ -196,11 +196,11 @@ void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText, void EDA_MSG_PANEL::showItem( wxDC& dc, const EDA_MSG_ITEM& aItem ) { - int color = aItem.m_Color; + EDA_COLOR_T color = aItem.m_Color; if( color >= 0 ) { - color &= MASKCOLOR; + color = ColorGetBase( color ); dc.SetTextForeground( wxColour( ColorRefs[color].m_Red, ColorRefs[color].m_Green, ColorRefs[color].m_Blue ) ); diff --git a/common/projet_config.cpp b/common/projet_config.cpp index 94ef5cded8..8707d58c7d 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -463,8 +463,8 @@ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) const } -PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, - int default_val, +PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptparam, + EDA_COLOR_T default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) { @@ -475,8 +475,8 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, - int* ptparam, - int default_val, + EDA_COLOR_T* ptparam, + EDA_COLOR_T default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) { @@ -488,9 +488,11 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const { + static const int MAX_COLOR = 0x8001F; + if( m_Pt_param == NULL || aConfig == NULL ) return; - int itmp = aConfig->Read( m_Ident, m_Default ); + EDA_COLOR_T itmp = ColorFromInt( aConfig->Read( m_Ident, m_Default ) ); if( (itmp < 0) || (itmp > MAX_COLOR) ) itmp = m_Default; diff --git a/common/selcolor.cpp b/common/selcolor.cpp index 0b3b3cb1e2..abb0d7e420 100644 --- a/common/selcolor.cpp +++ b/common/selcolor.cpp @@ -45,19 +45,19 @@ BEGIN_EVENT_TABLE( WinEDA_SelColorFrame, wxDialog ) END_EVENT_TABLE() -int DisplayColorFrame( wxWindow* parent, int OldColor ) +EDA_COLOR_T DisplayColorFrame( wxWindow* parent, int OldColor ) { wxPoint framepos; - int color; + EDA_COLOR_T color; wxGetMousePosition( &framepos.x, &framepos.y ); WinEDA_SelColorFrame* frame = new WinEDA_SelColorFrame( parent, framepos, OldColor ); - color = frame->ShowModal(); + color = static_cast( frame->ShowModal() ); frame->Destroy(); if( color > NBCOLOR ) - color = -1; + color = UNSPECIFIED_COLOR; return color; } diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 1917d091aa..9e79735fc5 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -1606,7 +1606,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi } -const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition ) +const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition ) const { const PAGE_INFO& pageInfo = GetPageSettings(); diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 69d55be7db..68b455f8f0 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -464,7 +464,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int ) * Function IsGridVisible() , virtual * @return true if the grid must be shown */ -bool DISPLAY_FOOTPRINTS_FRAME::IsGridVisible() +bool DISPLAY_FOOTPRINTS_FRAME::IsGridVisible() const { return m_DrawGrid; } @@ -486,7 +486,7 @@ void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible) * Function GetGridColor() , virtual * @return the color of the grid */ -int DISPLAY_FOOTPRINTS_FRAME::GetGridColor() +EDA_COLOR_T DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const { return DARKGRAY; } diff --git a/cvpcb/class_DisplayFootprintsFrame.h b/cvpcb/class_DisplayFootprintsFrame.h index 37dad4c960..bdf2874141 100644 --- a/cvpcb/class_DisplayFootprintsFrame.h +++ b/cvpcb/class_DisplayFootprintsFrame.h @@ -46,7 +46,7 @@ public: * Function IsGridVisible() , virtual * @return true if the grid must be shown */ - virtual bool IsGridVisible(); + virtual bool IsGridVisible() const; /** * Function SetGridVisibility() , virtual @@ -59,7 +59,7 @@ public: * Function GetGridColor() , virtual * @return the color of the grid */ - virtual int GetGridColor(); + virtual EDA_COLOR_T GetGridColor() const; void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index 5e149620f1..5f099321b1 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -338,15 +338,15 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() ); component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, - g_XorMode, -1, DefaultTransform, true, true, true ); + g_XorMode, UNSPECIFIED_COLOR, DefaultTransform, true, true, true ); } - /* Repaint new view */ + // Repaint new view block->SetMoveVector( screen->GetCrossHairPosition() - block->GetLastCursorPosition() ); GRSetDrawMode( aDC, g_XorMode ); block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() ); component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, - g_XorMode, -1, DefaultTransform, true, true, true ); + g_XorMode, UNSPECIFIED_COLOR, DefaultTransform, true, true, true ); } diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index dcca3a87dd..1939c3ff89 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -63,13 +63,13 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi bool aErase ) { SCH_LINE* segment; - int color; if( s_wires.GetCount() == 0 ) return; segment = (SCH_LINE*) s_wires.begin(); - color = ReturnLayerColor( segment->GetLayer() ) ^ HIGHLIGHT_FLAG; + EDA_COLOR_T color = ReturnLayerColor( segment->GetLayer() ); + ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) ); if( aErase ) { diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 8054496e52..01e00fe734 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -273,7 +273,7 @@ void LIB_COMPONENT::SetName( const wxString& aName ) void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, int aMulti, - int aConvert, GR_DRAWMODE aDrawMode, int aColor, const TRANSFORM& aTransform, + int aConvert, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor, const TRANSFORM& aTransform, bool aShowPinText, bool aDrawFields, bool aOnlySelected ) { BASE_SCREEN* screen = aPanel->GetScreen(); @@ -286,7 +286,8 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff * printing in black and white * If the color is not the default color (aColor != -1 ) */ - if( ! (screen->m_IsPrinting && GetGRForceBlackPenState()) && (aColor == -1) ) + if( ! (screen->m_IsPrinting && GetGRForceBlackPenState()) + && (aColor == UNSPECIFIED_COLOR) ) { BOOST_FOREACH( LIB_ITEM& drawItem, drawings ) { @@ -426,7 +427,7 @@ from component %s in library %s." ), if( *i == aItem ) { if( aDc != NULL ) - aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform ); + aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); drawings.erase( i ); SetModified(); diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 127c52acd6..ee567a258e 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -397,7 +397,8 @@ public: * Used for block move redraws. */ void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, - int aMulti, int aConvert, GR_DRAWMODE aDrawMode, int aColor = -1, + int aMulti, int aConvert, GR_DRAWMODE aDrawMode, + EDA_COLOR_T aColor = UNSPECIFIED_COLOR, const TRANSFORM& aTransform = DefaultTransform, bool aShowPinText = true, bool aDrawFields = true, bool aOnlySelected = false ); diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp index 38a239d03f..b87f9f17c5 100644 --- a/eeschema/dialogs/dialog_color_config.cpp +++ b/eeschema/dialogs/dialog_color_config.cpp @@ -66,7 +66,7 @@ static ButtonIndex buttonGroups[] = { }; -static int currentColors[ MAX_LAYER ]; +static EDA_COLOR_T currentColors[ MAX_LAYER ]; IMPLEMENT_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG, wxDialog ) @@ -253,7 +253,7 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event ) wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) ); - int color = DisplayColorFrame( this, colorButton->m_Layer ); + EDA_COLOR_T color = DisplayColorFrame( this, colorButton->m_Layer ); if( color < 0 || currentColors[ colorButton->m_Layer ] == color ) return; diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index 9c65992709..54e5b78c22 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -65,7 +65,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event ) NEGATE( offset.y ); GRResetPenAndBrush( &dc ); - m_dummyPin->Draw( NULL, &dc, offset, -1, GR_COPY, + m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR, GR_COPY, NULL, DefaultTransform ); m_dummyPin->SetParent(NULL); diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index aceacedff4..b25d6ea58c 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -415,7 +415,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) aScreen->m_IsPrinting = true; - int bg_color = g_DrawBgColor; + EDA_COLOR_T bg_color = g_DrawBgColor; aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE ); diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 63acb50cf0..04bdf2ed91 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -45,7 +45,7 @@ #include -void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, int Color ) +void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, EDA_COLOR_T Color ) { BASE_SCREEN* screen = panel->GetScreen(); diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index e899851990..caac4ce5b0 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -81,11 +81,11 @@ int g_DrawDefaultLineThickness = 6; /* Default line thickness in * line width */ // Color to draw selected items -int g_ItemSelectetColor = BROWN; +EDA_COLOR_T g_ItemSelectetColor = BROWN; // Color to draw items flagged invisible, in libedit (they are invisible // in Eeschema -int g_InvisibleItemColor = DARKGRAY; +EDA_COLOR_T g_InvisibleItemColor = DARKGRAY; TRANSFORM DefaultTransform = TRANSFORM( 1, 0, 0, -1 ); diff --git a/eeschema/general.h b/eeschema/general.h index 40a3ec4e4c..40d2434711 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -95,12 +95,12 @@ class LayerStruct { public: char LayerNames[MAX_LAYERS + 1][8]; - int LayerColor[MAX_LAYERS + 1]; + EDA_COLOR_T LayerColor[MAX_LAYERS + 1]; char LayerStatus[MAX_LAYERS + 1]; int NumberOfLayers; int CurrentLayer; int CurrentWidth; - int CommonColor; + EDA_COLOR_T CommonColor; int Flags; }; @@ -149,10 +149,10 @@ extern int g_DrawDefaultLineThickness; /// Color to draw selected items -extern int g_ItemSelectetColor; +extern EDA_COLOR_T g_ItemSelectetColor; /// Color to draw items flagged invisible, in libedit (they are invisible in Eeschema -extern int g_InvisibleItemColor; +extern EDA_COLOR_T g_InvisibleItemColor; /* Global Variables */ diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 75f0715dd4..cb028bafd3 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -341,7 +341,7 @@ int LIB_ARC::GetPenSize() const } -void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, int aColor ) +void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor ) { // The edit indicators only get drawn when a new arc is being drawn. if( !IsNew() ) @@ -362,7 +362,8 @@ void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, int aColor ) void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, + const TRANSFORM& aTransform ) { // Don't draw the arc until the end point is selected. Only the edit indicators // get drawn at this time. @@ -370,7 +371,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf return; wxPoint pos1, pos2, posc; - int color = ReturnLayerColor( LAYER_DEVICE ); + EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); if( aColor < 0 ) // Used normal color or selected color { diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index b3dc3b0ba7..4bf41aba49 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -61,13 +61,13 @@ class LIB_ARC : public LIB_ITEM * Draws the arc. */ void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); /** * Draw the graphics when the arc is being edited. */ - void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, int aColor ); + void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor ); /** * Calculates the center, radius, and angles at \a aPosition when the arc is being edited. diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 89466cb4d5..54d85b9017 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -287,12 +287,13 @@ int LIB_BEZIER::GetPenSize() const void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, + const TRANSFORM& aTransform ) { wxPoint pos1; std::vector PolyPointsTraslated; - int color = ReturnLayerColor( LAYER_DEVICE ); + EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); m_PolyPoints = Bezier2Poly( m_BezierPoints[0], m_BezierPoints[1], diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index 878a482a0a..b900a17bd5 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -43,7 +43,7 @@ class LIB_BEZIER : public LIB_ITEM std::vector m_PolyPoints; // list of points (>= 2) void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); public: diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 63dbeede20..caf9b07474 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -210,11 +210,12 @@ int LIB_CIRCLE::GetPenSize() const void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, + const TRANSFORM& aTransform ) { wxPoint pos1; - int color = ReturnLayerColor( LAYER_DEVICE ); + EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); if( aColor < 0 ) // Used normal color or selected color { diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index 49e01549b6..ce42932d7d 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -39,7 +39,7 @@ class LIB_CIRCLE : public LIB_ITEM int m_Width; // Line width. void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); void calcEdit( const wxPoint& aPosition ); diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp index 2ef77b0f2e..8475f179e1 100644 --- a/eeschema/lib_draw_item.cpp +++ b/eeschema/lib_draw_item.cpp @@ -114,14 +114,14 @@ bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const } -void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, +void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { if( InEditMode() ) { // Temporarily disable filling while the item is being edited. FILL_T fillMode = m_Fill; - int color = GetDefaultColor(); + EDA_COLOR_T color = GetDefaultColor(); m_Fill = NO_FILL; @@ -150,7 +150,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, } -int LIB_ITEM::GetDefaultColor() +EDA_COLOR_T LIB_ITEM::GetDefaultColor() { return ReturnLayerColor( LAYER_DEVICE ); } diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index d743cb4dcd..db95eb037c 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -88,7 +88,7 @@ class LIB_ITEM : public EDA_ITEM * @param aTransform A reference to a #TRANSFORM object containing drawing transform. */ virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, int aColor, + const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) = 0; @@ -99,7 +99,7 @@ class LIB_ITEM : public EDA_ITEM * @param aDC The device context to draw on. * @param aColor The index of the color to draw. */ - virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, int aColor ) {} + virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, int EDA_COLOR_T ) {} /** * Calculates the attributes of an item at \a aPosition when it is being edited. @@ -213,7 +213,7 @@ public: * @param aTransform Transform Matrix (rotation, mirror ..) */ virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint &aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); /** @@ -402,7 +402,7 @@ public: void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; } - virtual int GetDefaultColor(); + virtual EDA_COLOR_T GetDefaultColor(); void SetUnit( int aUnit ) { m_Unit = aUnit; } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 9a3c9ee08c..9627c8aedb 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -260,7 +260,8 @@ int LIB_FIELD::GetPenSize() const void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, + const TRANSFORM& aTransform ) { wxPoint text_pos; int color; @@ -514,9 +515,9 @@ EDA_RECT LIB_FIELD::GetBoundingBox() const } -int LIB_FIELD::GetDefaultColor() +EDA_COLOR_T LIB_FIELD::GetDefaultColor() { - int color; + EDA_COLOR_T color; switch( m_id ) { diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index e46610692c..fef1c85fb2 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -71,7 +71,7 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT *

*/ void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); /** @@ -205,7 +205,7 @@ public: */ wxString GetFullText( int unit = 1 ); - int GetDefaultColor(); + EDA_COLOR_T GetDefaultColor(); void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 9dc2161bda..ff5c39c0be 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -789,7 +789,7 @@ int LIB_PIN::GetPenSize() const void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) @@ -854,15 +854,14 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, const wxPoint& aPinPos, int aOrient, GR_DRAWMODE aDrawMode, - int aColor ) + EDA_COLOR_T aColor ) { int MapX1, MapY1, x1, y1; - int color; int width = GetPenSize(); int posX = aPinPos.x, posY = aPinPos.y, len = m_length; EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; - color = ReturnLayerColor( LAYER_PIN ); + EDA_COLOR_T color = ReturnLayerColor( LAYER_PIN ); if( aColor < 0 ) // Used normal color or selected color { @@ -1069,7 +1068,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, int TextInside, bool DrawPinNum, bool DrawPinName, - int Color, + EDA_COLOR_T Color, GR_DRAWMODE DrawMode ) { int x, y, x1, y1; @@ -1271,9 +1270,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ) { int MapX1, MapY1, x1, y1; - EDA_COLOR_T color = UNSPECIFIED; - - color = ReturnLayerColor( LAYER_PIN ); + EDA_COLOR_T color = ReturnLayerColor( LAYER_PIN ); aPlotter->SetColor( color ); diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 64c01e4036..37b9fae0eb 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -117,7 +117,7 @@ class LIB_PIN : public LIB_ITEM int m_nameTextSize; /* Pin num and Pin name sizes */ void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); public: @@ -363,7 +363,7 @@ public: */ void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, int aOrientation, GR_DRAWMODE aDrawMode, - int aColor = -1 ); + EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); /** * Function DrawPinTexts @@ -376,7 +376,7 @@ public: */ void DrawPinTexts( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition, int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName, - int aColor, GR_DRAWMODE aDrawMode ); + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode ); /** * Function PlotPinTexts diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 8d26694e1b..1ea2645c34 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -265,11 +265,11 @@ int LIB_POLYLINE::GetPenSize() const void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1; - int color = ReturnLayerColor( LAYER_DEVICE ); + EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); wxPoint* buffer = NULL; if( aColor < 0 ) // Used normal color or selected color diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 3332998cf9..cd8be707a0 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -40,7 +40,7 @@ class LIB_POLYLINE : public LIB_ITEM int m_ModifyIndex; // Index of the polyline point to modify void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); void calcEdit( const wxPoint& aPosition ); diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index e0675fb28a..1824c443a7 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -195,12 +195,12 @@ int LIB_RECTANGLE::GetPenSize() const void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, int aColor, GR_DRAWMODE aDrawMode, + const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1, pos2; - int color = ReturnLayerColor( LAYER_DEVICE ); + EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); if( aColor < 0 ) // Used normal color or selected color { diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 4743406c73..70e300297a 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -42,7 +42,7 @@ class LIB_RECTANGLE : public LIB_ITEM bool m_isStartPointSelected; // Flag: is the upper left edge selected? void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); void calcEdit( const wxPoint& aPosition ); diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 565fad24d7..2151f64e61 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -318,7 +318,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + offset; - plotter->Text( pos, UNSPECIFIED, m_Text, + plotter->Text( pos, UNSPECIFIED_COLOR, m_Text, t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), m_Italic, m_Bold ); @@ -344,9 +344,10 @@ int LIB_TEXT::GetPenSize() const void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, + const TRANSFORM& aTransform ) { - int color = GetDefaultColor(); + EDA_COLOR_T color = GetDefaultColor(); if( aColor < 0 ) // Used normal color or selected color { diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 4d9fb9e859..50c19a16fa 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -48,7 +48,7 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT bool m_updateText; ///< Flag to indicate text change occurred while editing. void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aColor, GR_DRAWMODE aDrawMode, void* aData, + EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ); void calcEdit( const wxPoint& aPosition ); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index fc403a8fdf..a8f4fe76ce 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -726,9 +726,9 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_canvas->MoveCursorToCrossHair(); int oldFlags = m_drawItem->GetFlags(); m_drawItem->ClearFlags(); - m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform ); + m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); ( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCrossHairPosition( true ) ); - m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform ); + m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); m_drawItem->SetFlags( oldFlags ); m_lastDrawItem = NULL; break; @@ -932,18 +932,18 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem ) if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) ) return; - /* Deleting old text. */ + // Deleting old text if( DC && !DrawItem->InEditMode() ) - DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform ); + DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem ); frame->ShowModal(); frame->Destroy(); OnModify(); - /* Display new text. */ + // Display new text if( DC && !DrawItem->InEditMode() ) - DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, NULL, + DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, NULL, DefaultTransform ); } diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 232660af34..5573323e84 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -267,7 +267,7 @@ another pin. Continue?" ) ); m_canvas->CrossHairOff( DC ); bool showPinText = true; - CurrentPin->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, + CurrentPin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, &showPinText, DefaultTransform ); m_canvas->CrossHairOn( DC ); @@ -342,13 +342,13 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi if( aErase ) { CurrentPin->SetPosition( PinPreviousPos ); - CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), -1, g_XorMode, + CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, &showPinText, DefaultTransform ); } // Redraw pin in new position CurrentPin->SetPosition( aPanel->GetScreen()->GetCrossHairPosition( true ) ); - CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), -1, g_XorMode, &showPinText, DefaultTransform ); + CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, &showPinText, DefaultTransform ); PinPreviousPos = CurrentPin->GetPosition(); @@ -412,7 +412,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC ) m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove ); if( DC ) - pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, GR_COPY, &showPinText, + pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_COPY, &showPinText, DefaultTransform ); } @@ -500,7 +500,7 @@ void LIB_EDIT_FRAME::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id ) if( selected && !Pin->IsSelected() ) continue; - Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, g_XorMode, &showPinText, DefaultTransform ); + Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, &showPinText, DefaultTransform ); switch( id ) { @@ -517,7 +517,7 @@ void LIB_EDIT_FRAME::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id ) break; } - Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, &showPinText, + Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, &showPinText, DefaultTransform ); } } diff --git a/eeschema/protos.h b/eeschema/protos.h index 38763ffcc3..df1b6ba9fd 100644 --- a/eeschema/protos.h +++ b/eeschema/protos.h @@ -49,7 +49,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false ); /****************/ /* EEREDRAW.CPP */ /****************/ -void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, int Color ); +void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, EDA_COLOR_T Color ); /***********************************/ diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 5534e788d0..452af7162d 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -195,7 +195,7 @@ EDA_RECT SCH_BITMAP::GetBoundingBox() const void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor ) + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { wxPoint pos = m_Pos + aOffset; diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 4267394a68..cf77d16ed8 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -95,7 +95,7 @@ public: void SwapData( SCH_ITEM* aItem ); void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor = -1 ); + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); /** * Function ReadImageFile diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 4e8605910d..1d8c603de0 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -178,9 +178,9 @@ int SCH_BUS_ENTRY::GetPenSize() const void SCH_BUS_ENTRY::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor ) + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { - int color; + EDA_COLOR_T color; if( aColor >= 0 ) color = aColor; diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index e4bb2fa641..9ad33c8d42 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -86,7 +86,7 @@ public: void SwapData( SCH_ITEM* aItem ); void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor = -1 ); + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); bool Save( FILE* aFile ) const; diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 675ed10673..d15d7e66bb 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -290,7 +290,7 @@ int SCH_COMPONENT::GetPartCount() const void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE DrawMode, int Color, bool DrawPinText ) + GR_DRAWMODE DrawMode, EDA_COLOR_T Color, bool DrawPinText ) { bool dummy = false; diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 88fbeec360..833d3f8fe0 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -250,7 +250,7 @@ public: wxDC* DC, const wxPoint& offset, GR_DRAWMODE draw_mode, - int Color = -1 ) + EDA_COLOR_T Color = UNSPECIFIED_COLOR ) { Draw( panel, DC, offset, draw_mode, Color, true ); } @@ -259,7 +259,7 @@ public: wxDC* DC, const wxPoint& offset, GR_DRAWMODE draw_mode, - int Color, + EDA_COLOR_T Color, bool DrawPinText ); void SwapData( SCH_ITEM* aItem ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index a354f4ad14..83b68699eb 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -130,7 +130,7 @@ int SCH_FIELD::GetPenSize() const void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - const wxPoint& offset, GR_DRAWMODE DrawMode, int Color ) + const wxPoint& offset, GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) { int orient; EDA_COLOR_T color; @@ -537,9 +537,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T, wxT( "Cannot plot field with invalid parent." ) ); - EDA_COLOR_T color = UNSPECIFIED; - - color = ReturnLayerColor( GetLayer() ); + EDA_COLOR_T color = ReturnLayerColor( GetLayer() ); if( m_Attributs & TEXT_NO_VISIBLE ) return; diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index c10760d33f..0a66ba2450 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -138,7 +138,7 @@ public: wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - int aColor = -1 ); + EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); bool Save( FILE* aFile ) const; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 542c59207b..a8d7efab93 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -114,9 +114,9 @@ EDA_RECT SCH_JUNCTION::GetBoundingBox() const void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor ) + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { - int color; + EDA_COLOR_T color; if( aColor >= 0 ) color = aColor; diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 0a0ad2b05c..6b295f5baa 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -55,7 +55,7 @@ public: EDA_RECT GetBoundingBox() const; void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor = -1 ); + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); bool Save( FILE* aFile ) const; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 0f127f41f8..bfacb238a4 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -222,9 +222,9 @@ int SCH_LINE::GetPenSize() const void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE DrawMode, int Color ) + GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) { - int color; + EDA_COLOR_T color; int width = GetPenSize(); if( Color >= 0 ) diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 10bc87e597..bb5c7876dc 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -85,7 +85,7 @@ public: double GetLength() const; void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor = -1 ); + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); bool Save( FILE* aFile ) const; diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index 96ea330e57..cfc7feb78c 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -103,7 +103,7 @@ bool SCH_MARKER::Save( FILE* aFile ) const void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, GR_DRAWMODE aDrawMode, int aColor ) + const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { EDA_COLOR_T color = (EDA_COLOR_T) m_Color; EDA_COLOR_T tmp = color; @@ -118,7 +118,7 @@ void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, if( aColor < 0 ) m_Color = color; else - m_Color = (EDA_COLOR_T) aColor; + m_Color = aColor; DrawMarker( aPanel, aDC, aDrawMode, aOffset ); m_Color = tmp; diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index 08b1dfef4a..748ac82591 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -67,7 +67,7 @@ public: } void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDraw_mode, int aColor = -1 ); + GR_DRAWMODE aDraw_mode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); bool Save( FILE* aFile ) const; diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index d08c1e23a5..4412bee4d3 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -123,15 +123,16 @@ int SCH_NO_CONNECT::GetPenSize() const void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor ) + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { - int pX, pY, color; + int pX, pY; int delta = m_size.x / 2; int width = g_DrawDefaultLineThickness; pX = m_pos.x + aOffset.x; pY = m_pos.y + aOffset.y; + EDA_COLOR_T color; if( aColor >= 0 ) color = aColor; else diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index 5da5ef132b..c2956e65d4 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -55,7 +55,7 @@ public: void SwapData( SCH_ITEM* aItem ); void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor = -1 ); + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); bool Save( FILE* aFile ) const; diff --git a/eeschema/sch_polyline.cpp b/eeschema/sch_polyline.cpp index fe5bc895f2..299bcbb256 100644 --- a/eeschema/sch_polyline.cpp +++ b/eeschema/sch_polyline.cpp @@ -156,9 +156,9 @@ int SCH_POLYLINE::GetPenSize() const void SCH_POLYLINE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor ) + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { - int color; + EDA_COLOR_T color; int width = GetPenSize(); if( aColor >= 0 ) diff --git a/eeschema/sch_polyline.h b/eeschema/sch_polyline.h index 4cdde356f0..84ac454d2f 100644 --- a/eeschema/sch_polyline.h +++ b/eeschema/sch_polyline.h @@ -52,7 +52,7 @@ public: } void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, int aColor = -1 ); + GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); bool Save( FILE* aFile ) const; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 71e871015d..47716a302b 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -549,7 +549,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const // note: SCH_SCREEN::Draw is useful only for schematic. // library editor and library viewer do not use a draw list, and therefore // SCH_SCREEN::Draw draws nothing -void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, int aColor ) +void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() ) { diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index f1c09ff675..758ff3da34 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -566,11 +566,11 @@ wxPoint SCH_SHEET::GetFileNamePosition() void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, GR_DRAWMODE aDrawMode, int aColor ) + const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { - int txtcolor; + EDA_COLOR_T txtcolor; wxString Text; - int color; + EDA_COLOR_T color; int name_orientation; wxPoint pos_sheetname,pos_filename; wxPoint pos = m_pos + aOffset; @@ -1102,7 +1102,7 @@ void SCH_SHEET::GetNetListItem( vector& aNetListItems, void SCH_SHEET::Plot( PLOTTER* aPlotter ) { - EDA_COLOR_T txtcolor = UNSPECIFIED; + EDA_COLOR_T txtcolor = UNSPECIFIED_COLOR; wxSize size; wxString Text; int name_orientation; diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 8cd29a75a4..7b371f2cdd 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -98,7 +98,7 @@ public: wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDraw_mode, - int aColor = -1 ); + EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); /** * Function CreateGraphicShape (virtual) @@ -395,7 +395,7 @@ public: wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - int aColor = -1 ); + EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); EDA_RECT GetBoundingBox() const; diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 373fa23f6d..fa9ef9a8ea 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -71,7 +71,7 @@ void SCH_SHEET_PIN::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDraw_mode, - int aColor ) + EDA_COLOR_T aColor ) { // The icon selection is handle by the virtual method CreateGraphicShape // called by ::Draw diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index b6e386d5a5..c431abf135 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -370,7 +370,7 @@ int SCH_TEXT::GetPenSize() const void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, - GR_DRAWMODE DrawMode, int Color ) + GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) { EDA_COLOR_T color; int linewidth = ( m_Thickness == 0 ) ? g_DrawDefaultLineThickness : m_Thickness; @@ -378,7 +378,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); if( Color >= 0 ) - color = (EDA_COLOR_T) Color; + color = Color; else color = ReturnLayerColor( m_Layer ); @@ -386,7 +386,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, wxPoint text_offset = aOffset + GetSchematicTextOffset(); EXCHG( linewidth, m_Thickness ); // Set the minimum width - EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED ); + EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Thickness ); // set initial value if( m_isDangling ) @@ -880,7 +880,7 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE DrawMode, int Color ) + GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) { SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color ); } @@ -1192,14 +1192,14 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, GR_DRAWMODE DrawMode, - int Color ) + EDA_COLOR_T Color ) { static std::vector Poly; EDA_COLOR_T color; wxPoint text_offset = aOffset + GetSchematicTextOffset(); if( Color >= 0 ) - color = (EDA_COLOR_T) Color; + color = Color; else color = ReturnLayerColor( m_Layer ); @@ -1208,7 +1208,7 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, int linewidth = (m_Thickness == 0) ? g_DrawDefaultLineThickness : m_Thickness; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); EXCHG( linewidth, m_Thickness ); // Set the minimum width - EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED ); + EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Thickness ); // set initial value CreateGraphicShape( Poly, m_Pos + aOffset ); @@ -1522,7 +1522,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, GR_DRAWMODE DrawMode, - int Color ) + EDA_COLOR_T Color ) { static std::vector Poly; EDA_COLOR_T color; @@ -1531,7 +1531,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); if( Color >= 0 ) - color = (EDA_COLOR_T) Color; + color = Color; else color = ReturnLayerColor( m_Layer ); @@ -1539,7 +1539,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, EXCHG( linewidth, m_Thickness ); // Set the minimum width wxPoint text_offset = offset + GetSchematicTextOffset(); - EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED ); + EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Thickness ); // set initial value CreateGraphicShape( Poly, m_Pos + offset ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index cbea95b59a..f06ae636cf 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -134,7 +134,7 @@ public: wxDC* DC, const wxPoint& offset, GR_DRAWMODE draw_mode, - int Color = -1 ); + EDA_COLOR_T Color = UNSPECIFIED_COLOR ); /** * Function CreateGraphicShape @@ -231,7 +231,7 @@ public: wxDC* DC, const wxPoint& offset, GR_DRAWMODE draw_mode, - int Color = -1 ); + EDA_COLOR_T Color = UNSPECIFIED_COLOR ); wxString GetClass() const { @@ -282,7 +282,7 @@ public: wxDC* DC, const wxPoint& offset, GR_DRAWMODE draw_mode, - int Color = -1 ); + EDA_COLOR_T Color = UNSPECIFIED_COLOR ); wxString GetClass() const { @@ -337,7 +337,7 @@ public: wxDC* DC, const wxPoint& offset, GR_DRAWMODE draw_mode, - int Color = -1 ); + EDA_COLOR_T Color = UNSPECIFIED_COLOR ); wxString GetClass() const { diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index f6f8d7db5d..b66099bf57 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -240,7 +240,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC ) if( m_drawItem->ContinueEdit( pos ) ) { - m_drawItem->Draw( m_canvas, DC, pos, -1, g_XorMode, NULL, DefaultTransform ); + m_drawItem->Draw( m_canvas, DC, pos, UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); return; } @@ -270,11 +270,11 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx { int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit(); wxString text = ((LIB_FIELD*)item)->GetFullText( unit ); - item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, &text, + item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, &text, DefaultTransform ); } else - item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, NULL, + item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); } @@ -317,7 +317,7 @@ static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& return; item->SetEraseLastDrawItem( aErase ); - item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, NULL, + item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); } diff --git a/gerbview/block.cpp b/gerbview/block.cpp index b36fae0431..774e5dde2a 100644 --- a/gerbview/block.cpp +++ b/gerbview/block.cpp @@ -151,10 +151,9 @@ bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC ) static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase ) { - int Color; BASE_SCREEN* screen = aPanel->GetScreen(); - Color = YELLOW; + EDA_COLOR_T Color = YELLOW; if( aErase ) { diff --git a/gerbview/class_aperture_macro.cpp b/gerbview/class_aperture_macro.cpp index 2e7d9ee4a3..b9714f6bbc 100644 --- a/gerbview/class_aperture_macro.cpp +++ b/gerbview/class_aperture_macro.cpp @@ -131,7 +131,7 @@ int AM_PRIMITIVE::GetExposure(GERBER_DRAW_ITEM* aParent) const void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC, - int aColor, int aAltColor, + EDA_COLOR_T aColor, EDA_COLOR_T aAltColor, wxPoint aShapePos, bool aFilledShape ) { @@ -727,7 +727,7 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) */ void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC, - int aColor, int aAltColor, + EDA_COLOR_T aColor, EDA_COLOR_T aAltColor, wxPoint aShapePos, bool aFilledShape ) { for( AM_PRIMITIVES::iterator prim_macro = primitives.begin(); diff --git a/gerbview/class_aperture_macro.h b/gerbview/class_aperture_macro.h index 7d2ace227d..959a2546aa 100644 --- a/gerbview/class_aperture_macro.h +++ b/gerbview/class_aperture_macro.h @@ -135,7 +135,7 @@ public: AM_PRIMITIVE( bool aGerbMetric, AM_PRIMITIVE_ID aId = AMP_UNKNOWN ) * @param aFilledShape = true to draw in filled mode, false to draw in skecth mode */ void DrawBasicShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC, - int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape ); + EDA_COLOR_T aColor, EDA_COLOR_T aAltColor, wxPoint aShapePos, bool aFilledShape ); /** GetShapeDim * Calculate a value that can be used to evaluate the size of text @@ -207,7 +207,7 @@ struct APERTURE_MACRO * @param aFilledShape = true to draw in filled mode, false to draw in skecth mode */ void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC, - int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape ); + EDA_COLOR_T aColor, EDA_COLOR_T aAltColor, wxPoint aShapePos, bool aFilledShape ); /** * Function GetShapeDim diff --git a/gerbview/class_gbr_layer_box_selector.cpp b/gerbview/class_gbr_layer_box_selector.cpp index 49f56df014..a931aca56d 100644 --- a/gerbview/class_gbr_layer_box_selector.cpp +++ b/gerbview/class_gbr_layer_box_selector.cpp @@ -64,7 +64,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync() } // Returns a color index from the layer id -int GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) +EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) const { GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent(); @@ -72,7 +72,7 @@ int GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) } // Returns the name of the layer id -const wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex ) +wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex ) const { wxString name; name.Printf( _( "Layer %d" ), aLayerIndex + 1 ); diff --git a/gerbview/class_gbr_layer_box_selector.h b/gerbview/class_gbr_layer_box_selector.h index d21fd06287..64812e5a57 100644 --- a/gerbview/class_gbr_layer_box_selector.h +++ b/gerbview/class_gbr_layer_box_selector.h @@ -37,15 +37,15 @@ public: // Returns a color index from the layer id // Virtual function - int GetLayerColor( int aLayerIndex ); + EDA_COLOR_T GetLayerColor( int aLayerIndex ) const; // Returns true if the layer id is enabled (i.e. is it should be displayed) // Virtual function - bool IsLayerEnabled( int aLayerIndex ) { return true; }; + bool IsLayerEnabled( int aLayerIndex ) const { return true; }; // Returns the name of the layer id // Virtual function - const wxString GetLayerName( int aLayerIndex ); + wxString GetLayerName( int aLayerIndex ) const; }; #endif //CLASS_GBR_LAYER_BOX_SELECTOR_H diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index 86199f6cbc..2d428d19e9 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -308,7 +308,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra { // used when a D_CODE is not found. default D_CODE to draw a flashed item static D_CODE dummyD_CODE( 0 ); - int color, alt_color; + EDA_COLOR_T color, alt_color; bool isFilled; int radius; int halfPenWidth; @@ -325,12 +325,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra color = gerbFrame->GetLayerColor( GetLayer() ); if( aDrawMode & GR_HIGHLIGHT ) - { - if( aDrawMode & GR_AND ) - color &= ~HIGHLIGHT_FLAG; - else - color |= HIGHLIGHT_FLAG; - } + ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) ); if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -528,7 +523,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( ) void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_RECT* aClipBox, wxDC* aDC, - int aColor, + EDA_COLOR_T aColor, const wxPoint& aOffset, bool aFilledShape ) { diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h index 8735ec8211..d0d4a33518 100644 --- a/gerbview/class_gerber_draw_item.h +++ b/gerbview/class_gerber_draw_item.h @@ -237,7 +237,7 @@ public: * a helper function used to draw the polygon stored in m_PolyCorners */ void DrawGbrPoly( EDA_RECT* aClipBox, - wxDC* aDC, int aColor, + wxDC* aDC, EDA_COLOR_T aColor, const wxPoint& aOffset, bool aFilledShape ); /* divers */ diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index 8325c2b1cc..9eb862cdc9 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -208,7 +208,7 @@ void GERBER_LAYER_WIDGET::ReFill() //------------------------------------------------ -void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, int aColor ) +void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) { myframe->SetLayerColor( aLayer, aColor ); myframe->m_SelLayerBox->ResyncBitmapOnly(); @@ -244,7 +244,7 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin myframe->GetCanvas()->Refresh(); } -void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, int aColor ) +void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor ) { myframe->SetVisibleElementColor( aId, aColor ); myframe->GetCanvas()->Refresh(); diff --git a/gerbview/class_gerbview_layer_widget.h b/gerbview/class_gerbview_layer_widget.h index 3c93e73571..60349aba6b 100644 --- a/gerbview/class_gerbview_layer_widget.h +++ b/gerbview/class_gerbview_layer_widget.h @@ -88,10 +88,10 @@ public: void ReFillRender(); //---------------- - void OnLayerColorChange( int aLayer, int aColor ); + void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ); bool OnLayerSelect( int aLayer ); void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ); - void OnRenderColorChange( int aId, int aColor ); + void OnRenderColorChange( int aId, EDA_COLOR_T aColor ); void OnRenderEnable( int aId, bool isEnabled ); /** * Function SetLayersManagerTabsText diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 0a6201d0f8..14f02bbf54 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -339,7 +339,8 @@ void GERBVIEW_FRAME::CopyDCodesSizeToItems() void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, - EDA_RECT* aClipBox, wxDC* aDC, int aColor, int aAltColor, + EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor, + EDA_COLOR_T aAltColor, wxPoint aShapePos, bool aFilledShape ) { int radius; @@ -456,7 +457,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC, - int aColor, bool aFilled, + EDA_COLOR_T aColor, bool aFilled, const wxPoint& aPosition ) { if( m_PolyCorners.size() == 0 ) diff --git a/gerbview/dcode.h b/gerbview/dcode.h index 87de8ac0a4..ebc36c1f54 100644 --- a/gerbview/dcode.h +++ b/gerbview/dcode.h @@ -171,7 +171,7 @@ public: * @param aFilledShape = true to draw in filled mode, false to draw in sketch mode */ void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, - wxDC* aDC, int aColor, int aAltColor, + wxDC* aDC, EDA_COLOR_T aColor, EDA_COLOR_T aAltColor, wxPoint aShapePos, bool aFilledShape ); /** @@ -188,7 +188,7 @@ public: * @param aPosition = the actual shape position */ void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, - EDA_RECT* aClipBox, wxDC* aDC, int aColor, + EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor, bool aFilled, const wxPoint& aPosition ); /** diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index bbb56fd631..098d979722 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -259,7 +259,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, if( gerber->m_ImageNegative ) { // Draw background negative (i.e. in graphic layer color) for negative images. - int color = gerbFrame->GetLayerColor( layer ); + EDA_COLOR_T color = gerbFrame->GetLayerColor( layer ); GRSetDrawMode( &layerDC, GR_COPY ); GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(), diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index d78b478b0d..36bbd91341 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -44,7 +44,7 @@ // Colors for layers and items COLORS_DESIGN_SETTINGS g_ColorsSettings; -extern int g_DrawBgColor; +extern EDA_COLOR_T g_DrawBgColor; int g_Default_GERBER_Format; diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index 5ae6b915af..a690359d9c 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -102,7 +102,7 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings() false ) ); // Default colors for layers 0 to 31 - static const int color_default[] = { + static const EDA_COLOR_T color_default[] = { GREEN, BLUE, LIGHTGRAY, MAGENTA, RED, DARKGREEN, BROWN, MAGENTA, LIGHTGRAY, BLUE, GREEN, CYAN, @@ -134,7 +134,7 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings() for( unsigned i = 0; i < DIM(keys); ++i ) { - int* prm = &g_ColorsSettings.m_LayersColors[i]; + EDA_COLOR_T* prm = &g_ColorsSettings.m_LayersColors[i]; PARAM_CFG_SETCOLOR* prm_entry = new PARAM_CFG_SETCOLOR( true, keys[i], prm, color_default[i] ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 869fd806c2..24e206b7f3 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -563,9 +563,9 @@ bool GERBVIEW_FRAME::IsLayerVisible( int aLayerIndex ) const * returns the color of a pcb visible element. * @see enum PCB_VISIBLE */ -int GERBVIEW_FRAME::GetVisibleElementColor( int aItemIdVisible ) +EDA_COLOR_T GERBVIEW_FRAME::GetVisibleElementColor( int aItemIdVisible ) { - int color = -1; + EDA_COLOR_T color = UNSPECIFIED_COLOR; switch( aItemIdVisible ) { @@ -594,7 +594,7 @@ void GERBVIEW_FRAME::SetGridVisibility( bool aVisible ) } -void GERBVIEW_FRAME::SetVisibleElementColor( int aItemIdVisible, int aColor ) +void GERBVIEW_FRAME::SetVisibleElementColor( int aItemIdVisible, EDA_COLOR_T aColor ) { switch( aItemIdVisible ) { @@ -617,7 +617,7 @@ void GERBVIEW_FRAME::SetVisibleElementColor( int aItemIdVisible, int aColor ) * Function GetLayerColor * gets a layer color for any valid layer, including non-copper ones. */ -int GERBVIEW_FRAME::GetLayerColor( int aLayer ) +EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( int aLayer ) const { return m_colorsSettings->GetLayerColor( aLayer ); } @@ -627,7 +627,7 @@ int GERBVIEW_FRAME::GetLayerColor( int aLayer ) * Function SetLayerColor * changes a layer color for any valid layer, including non-copper ones. */ -void GERBVIEW_FRAME::SetLayerColor( int aLayer, int aColor ) +void GERBVIEW_FRAME::SetLayerColor( int aLayer, EDA_COLOR_T aColor ) { m_colorsSettings->SetLayerColor( aLayer, aColor ); } diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 41fc77506f..98f5e348c8 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -320,21 +320,21 @@ public: * returns the color of a pcb visible element. * @see enum PCB_VISIBLE */ - int GetVisibleElementColor( int aItemIdVisible ); + EDA_COLOR_T GetVisibleElementColor( int aItemIdVisible ); - void SetVisibleElementColor( int aItemIdVisible, int aColor ); + void SetVisibleElementColor( int aItemIdVisible, EDA_COLOR_T aColor ); /** * Function GetLayerColor * gets a layer color for any valid layer, including non-copper ones. */ - int GetLayerColor( int aLayer ); + EDA_COLOR_T GetLayerColor( int aLayer ) const; /** * Function SetLayerColor * changes a layer color for any valid layer, including non-copper ones. */ - void SetLayerColor( int aLayer, int aColor ); + void SetLayerColor( int aLayer, EDA_COLOR_T aColor ); /** * Function ReFillLayerWidget diff --git a/include/block_commande.h b/include/block_commande.h index 26bc974635..c8579c1c14 100644 --- a/include/block_commande.h +++ b/include/block_commande.h @@ -124,7 +124,7 @@ public: wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - int aColor ); + EDA_COLOR_T aColor ); /** * Function PushItem @@ -147,7 +147,7 @@ public: */ void ClearItemsList(); - unsigned GetCount() + unsigned GetCount() const { return m_items.GetCount(); } diff --git a/include/class_colors_design_settings.h b/include/class_colors_design_settings.h index 8e8dcc0d10..fe606cb389 100644 --- a/include/class_colors_design_settings.h +++ b/include/class_colors_design_settings.h @@ -19,10 +19,10 @@ public: // Color options for screen display of the Printed Board and schematic: // Common to Eeschema, Pcbnew, GerbView - int m_LayersColors[LAYERSCOLORSBUFFERSIZE]; ///< Layer colors (tracks and graphic items) + EDA_COLOR_T m_LayersColors[LAYERSCOLORSBUFFERSIZE]; ///< Layer colors (tracks and graphic items) // Common to Eeschema, Pcbnew - int m_ItemsColors[ITEMSCOLORSBUFFERSIZE]; ///< All others items but layers + EDA_COLOR_T m_ItemsColors[ITEMSCOLORSBUFFERSIZE]; ///< All others items but layers public: COLORS_DESIGN_SETTINGS( ); @@ -32,35 +32,35 @@ public: * @return the color for aLayer which is one of the layer indices given * in pcbstruct.h or in schematic */ - int GetLayerColor( int aLayer ); + EDA_COLOR_T GetLayerColor( int aLayer ) const; /** * Function SetLayerColor * sets the color for aLayer which is one of the layer indices given * in pcbstruct.h or in schematic */ - void SetLayerColor( int aLayer, int aColor ); + void SetLayerColor( int aLayer, EDA_COLOR_T aColor ); /** * Function GetItemColor * @return the color for an item which is one of the item indices given * in pcbstruct.h, enum PCB_VISIBLE or in schematic */ - int GetItemColor( int aItemIdx ); + EDA_COLOR_T GetItemColor( int aItemIdx ); /** * Function SetItemColor * sets the color for an item which is one of the item indices given * in pcbstruct.h, enum PCB_VISIBLE or in schematic */ - void SetItemColor( int aItemIdx, int aColor ); + void SetItemColor( int aItemIdx, EDA_COLOR_T aColor ); /** * Function SetAllColorsAs * sets alls colors to aColor * Usefull to create a monochrome color selection for printing purpose */ - void SetAllColorsAs( int aColor); + void SetAllColorsAs( EDA_COLOR_T aColor); }; #endif // _COLORS_DESIGN_SETTING_H diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index 0b88a30ac3..059c4a7437 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -326,7 +326,7 @@ public: * @param aDC - the device context to draw the cursor * @param aColor - the color to draw the cursor */ - void DrawCrossHair( wxDC* aDC, int aColor = WHITE ); + void DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor = WHITE ); // Hide the cross hair. void CrossHairOff( wxDC* DC ); diff --git a/include/class_layer_box_selector.h b/include/class_layer_box_selector.h index c4039d8bae..4ee711981c 100644 --- a/include/class_layer_box_selector.h +++ b/include/class_layer_box_selector.h @@ -34,15 +34,15 @@ public: // Returns a color index from the layer id // Virtual function because GerbView uses its own functions in a derived class - virtual int GetLayerColor( int aLayerIndex ) = 0; + virtual EDA_COLOR_T GetLayerColor( int aLayerIndex ) const = 0; // Returns the name of the layer id // Virtual pure function because GerbView uses its own functions in a derived class - virtual const wxString GetLayerName( int aLayerIndex ) = 0; + virtual wxString GetLayerName( int aLayerIndex ) const = 0; // Returns true if the layer id is enabled (i.e. is it should be displayed) // Virtual function pure because GerbView uses its own functions in a derived class - virtual bool IsLayerEnabled( int aLayerIndex ) = 0; + virtual bool IsLayerEnabled( int aLayerIndex ) const = 0; // Get Current Item # int GetChoice(); diff --git a/include/class_sch_screen.h b/include/class_sch_screen.h index 40bfb5c317..26f9a7b0ec 100644 --- a/include/class_sch_screen.h +++ b/include/class_sch_screen.h @@ -190,7 +190,7 @@ public: * @param aColor The drawing color. */ void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, - int aColor = -1 ); + EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); /** * Function Plot diff --git a/include/colors.h b/include/colors.h index 7a26ea3baa..ee33edc137 100644 --- a/include/colors.h +++ b/include/colors.h @@ -7,43 +7,12 @@ #include -/* Number of colors ( 32 bit palette. ) */ -#define NBCOLOR 24 - -#define MASKCOLOR 31 ///< mask for color index into ColorRefs[] - -/// Flag bit display (seen / not seen) items: (defined in the color values -//IMB: Not used anymore #define ITEM_NOT_SHOW (1<<18) // 0x40000 - -#define HIGHLIGHT_FLAG ( 1<<19 ) // 0x80000 - - -/** - * Function SetAlpha - * ORs in the alpha blend parameter in to a color index. +/** The color enumeration. Also contains a flag and the alpha value in + * the upper bits */ -static inline void SetAlpha( int* aColor, int aBlend ) -{ - const int MASKALPHA = 0xFF; - - *aColor = (*aColor & ~(MASKALPHA << 24)) | ((aBlend & MASKALPHA) << 24); -} - - -/** - * Function GetAlpha - * returns the alpha blend parameter from a color index. - */ -static inline int GetAlpha( int aColor ) -{ - const int MASKALPHA = 0xFF; - return (aColor >> 24) & MASKALPHA; -} - - enum EDA_COLOR_T { - UNSPECIFIED = -1, + UNSPECIFIED_COLOR = -1, BLACK = 0, BLUE, GREEN, @@ -68,19 +37,72 @@ enum EDA_COLOR_T DARKMAGENTA, DARKBROWN, LIGHTYELLOW, - LASTCOLOR + LASTCOLOR, + HIGHLIGHT_FLAG = ( 1<<19 ), + NBCOLOR = 24, ///< Number of colors + MASKCOLOR = 31 ///< mask for color index into ColorRefs[] }; +/// Checked cast. Use only when necessary (ex. I/O) +inline EDA_COLOR_T ColorFromInt( int aColor ) +{ + wxASSERT( aColor >= UNSPECIFIED_COLOR && aColor < LASTCOLOR ); + return static_cast( aColor ); +} + +/// Return only the plain color part +inline EDA_COLOR_T ColorGetBase( EDA_COLOR_T aColor) +{ + return static_cast( aColor & MASKCOLOR ); +} + +/// Force the color part of a color to darkdarkgray +inline void ColorTurnToDarkDarkGray( EDA_COLOR_T *aColor ) +{ + *aColor = static_cast( (int(*aColor) & ~MASKCOLOR) | DARKDARKGRAY ); +} + +inline void ColorChangeHighlightFlag( EDA_COLOR_T *aColor, bool flag ) +{ + if( flag ) + *aColor = static_cast( (int(*aColor) | HIGHLIGHT_FLAG ) ); + else + *aColor = static_cast( (int(*aColor) & ~HIGHLIGHT_FLAG ) ); +} + +/** + * Function SetAlpha + * ORs in the alpha blend parameter in to a color index. + */ +inline void SetAlpha( EDA_COLOR_T* aColor, unsigned char aBlend ) +{ + const unsigned char MASKALPHA = 0xFF; + + *aColor = static_cast((*aColor & ~(MASKALPHA << 24)) + | ((aBlend & MASKALPHA) << 24)); +} + + +/** + * Function GetAlpha + * returns the alpha blend parameter from a color index. + */ +inline unsigned char GetAlpha( EDA_COLOR_T aColor ) +{ + const unsigned char MASKALPHA = 0xFF; + return (aColor >> 24) & MASKALPHA; +} + struct StructColors { unsigned char m_Blue; unsigned char m_Green; unsigned char m_Red; - unsigned char m_Numcolor; + EDA_COLOR_T m_Numcolor; const wxChar* m_Name; - int m_LightColor; + EDA_COLOR_T m_LightColor; }; // list of existing Colors: @@ -95,7 +117,7 @@ extern StructColors ColorRefs[NBCOLOR]; * not supporting alpha. * @return wxColour - given a KiCad color index with alpha value */ -static inline wxColour MakeColour( int aColor ) +inline wxColour MakeColour( EDA_COLOR_T aColor ) { #if wxCHECK_VERSION(2,8,5) int alpha = GetAlpha( aColor ); @@ -112,7 +134,4 @@ static inline wxColour MakeColour( int aColor ) ); } -int DisplayColorFrame( wxWindow* parent, int OldColor ); - - #endif /* ifndef _COLORS_H */ diff --git a/include/common.h b/include/common.h index 7bc8ba65cc..af30065d12 100644 --- a/include/common.h +++ b/include/common.h @@ -40,6 +40,7 @@ #include #include +#include #if !wxUSE_PRINTING_ARCHITECTURE && !SWIG # error "You must use '--enable-printarch' in your wx library configuration." @@ -465,7 +466,7 @@ extern wxString g_Prj_Config_LocalFilename; extern EDA_UNITS_T g_UserUnit; ///< display units /// Draw color for moving objects. -extern int g_GhostColor; +extern EDA_COLOR_T g_GhostColor; // COMMON.CPP @@ -574,7 +575,7 @@ void InitKiCadAbout( wxAboutDialogInfo& info ); */ time_t GetNewTimeStamp(); -int DisplayColorFrame( wxWindow* parent, int OldColor ); +EDA_COLOR_T DisplayColorFrame( wxWindow* parent, int OldColor ); int GetCommandOptions( const int argc, const char** argv, const char* stringtst, const char** optarg, int* optind ); diff --git a/include/eda_text.h b/include/eda_text.h index 8dd0540f34..c93050ff9b 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -166,7 +166,7 @@ public: void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode = LINE, - EDA_COLOR_T aAnchor_color = UNSPECIFIED ); + EDA_COLOR_T aAnchor_color = UNSPECIFIED_COLOR ); private: @@ -180,7 +180,7 @@ private: * @param aColor = text color * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. * @param aFillMode = LINE, FILLED or SKETCH - * @param aAnchor_color = anchor color ( UNSPECIFIED = do not draw anchor ). + * @param aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). * @param aText = the single line of text to draw. * @param aPos = the position of this line ). */ diff --git a/include/gr_basic.h b/include/gr_basic.h index 06cbdc977c..e8d290bb6e 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -73,8 +73,6 @@ inline GR_DRAWMODE operator &(const GR_DRAWMODE& a, const GR_DRAWMODE& b) return static_cast( int( a ) & int( b ) ); } - - #define GR_M_LEFT_DOWN 0x10000000 #define GR_M_RIGHT_DOWN 0x20000000 #define GR_M_MIDDLE_DOWN 0x40000000 @@ -90,7 +88,7 @@ typedef int wxPenStyle; extern GR_DRAWMODE g_XorMode; -extern int g_DrawBgColor; +extern EDA_COLOR_T g_DrawBgColor; typedef enum { @@ -106,8 +104,8 @@ class EDA_DRAW_PANEL; void GRSetDrawMode( wxDC* DC, GR_DRAWMODE mode ); GR_DRAWMODE GRGetDrawMode( wxDC* DC ); void GRResetPenAndBrush( wxDC* DC ); -void GRSetColorPen( wxDC* DC, int Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID ); -void GRSetBrush( wxDC* DC, int Color, int fill = 0 ); +void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID ); +void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill = false ); /** * Function GRForceBlackPen @@ -121,23 +119,23 @@ void GRForceBlackPen( bool flagforce ); */ bool GetGRForceBlackPenState( void ); -void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor ); -void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color ); +void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor ); +void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color ); void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color ); + int width, EDA_COLOR_T Color ); void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color ); -void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, int Color ); + int width, EDA_COLOR_T Color ); +void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, EDA_COLOR_T Color ); void GRMoveTo( int x, int y ); -void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, int Color ); +void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, EDA_COLOR_T Color ); void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill, - int width, int Color, int BgColor ); + int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ); void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int x3, int y3, int width, int Color ); + int x3, int y3, int width, EDA_COLOR_T Color ); void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int x3, int y3, int x4, int y4, int width, int Color ); + int x3, int y3, int x4, int y4, int width, EDA_COLOR_T Color ); /** * Function GRClosedPoly @@ -156,8 +154,8 @@ void GRClosedPoly( EDA_RECT* ClipBox, int aPointCount, wxPoint aPoints[], bool doFill, - int aPenColor, - int aFillColor ); + EDA_COLOR_T aPenColor, + EDA_COLOR_T aFillColor ); // @todo could make these 2 closed polygons calls a single function and default // the aPenWidth argument @@ -181,8 +179,8 @@ void GRClosedPoly( EDA_RECT* ClipBox, wxPoint aPoints[], bool doFill, int aPenWidth, - int aPenColor, - int aFillColor ); + EDA_COLOR_T aPenColor, + EDA_COLOR_T aFillColor ); /** @@ -198,56 +196,56 @@ void GRClosedPoly( EDA_RECT* ClipBox, * @param aColor is an index into our color table of RGB colors. * @see EDA_COLOR_T and colors.h */ -void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, int aColor ); -void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ); +void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, EDA_COLOR_T aColor ); +void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, EDA_COLOR_T Color ); void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, - int Color, int BgColor ); -void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor ); -void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor ); + EDA_COLOR_T Color, EDA_COLOR_T BgColor ); +void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, EDA_COLOR_T aColor ); +void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, EDA_COLOR_T aColor ); void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle, - int EndAngle, int r, int Color ); + int EndAngle, int r, EDA_COLOR_T Color ); void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle, - int EndAngle, int r, int width, int Color ); + int EndAngle, int r, int width, EDA_COLOR_T Color ); void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int xc, int yc, int Color ); + int xc, int yc, EDA_COLOR_T Color ); void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int xc, int yc, int width, int Color ); + int xc, int yc, int width, EDA_COLOR_T Color ); void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, - wxPoint aCenter, int aWidth, int aColor ); + wxPoint aCenter, int aWidth, EDA_COLOR_T aColor ); void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, - int StAngle, int EndAngle, int r, int Color, int BgColor ); + int StAngle, int EndAngle, int r, EDA_COLOR_T Color, EDA_COLOR_T BgColor ); void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle, - int EndAngle, int r, int width, int Color, int BgColor ); -void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color ); + int EndAngle, int r, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ); +void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color ); void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color ); + int width, EDA_COLOR_T Color ); void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, - int aWidth, int aColor ); + int aWidth, EDA_COLOR_T aColor ); void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int aPenSize, int Color ); + int width, int aPenSize, EDA_COLOR_T Color ); void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, - int aWidth, int aColor ); + int aWidth, EDA_COLOR_T aColor ); -void GRSetColor( int Color ); +void GRSetColor( EDA_COLOR_T Color ); void GRSetDefaultPalette(); -int GRGetColor(); -void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int color ); +EDA_COLOR_T GRGetColor(); +void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, EDA_COLOR_T color ); void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, - int x2, int y2, int Color, int BgColor ); + int x2, int y2, EDA_COLOR_T Color, EDA_COLOR_T BgColor ); void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, - int x2, int y2, int width, int Color, int BgColor ); -void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int Color ); -void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, int Color ); + int x2, int y2, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ); +void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, EDA_COLOR_T Color ); +void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, EDA_COLOR_T Color ); void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, - int x2, int y2, int width, int Color ); + int x2, int y2, int width, EDA_COLOR_T Color ); void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect, - int aWidth, int aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID ); + int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID ); void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, - int x2, int y2, int width, int Color, int BgColor ); + int x2, int y2, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ); /** * Function GRLineArray @@ -260,6 +258,6 @@ void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, * @see EDA_COLOR_T and colors.h */ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector& aLines, - int aWidth, int aColor ); + int aWidth, EDA_COLOR_T aColor ); #endif /* define GR_BASIC */ diff --git a/include/param_config.h b/include/param_config.h index a1d83c5309..a98ca1c607 100644 --- a/include/param_config.h +++ b/include/param_config.h @@ -9,7 +9,8 @@ #include #include #include - +#include +#include @@ -26,13 +27,6 @@ enum paramcfg_id { PARAM_FIELDNAME_LIST }; -#define MAX_COLOR 0x8001F -#define IS_VALID_COLOR( c ) ( ( c >= 0 ) && ( c <= 0x8001F ) ) - -#define INT_MINVAL 0x80000000 -#define INT_MAXVAL 0x7FFFFFFF - - /** * Class PARAM_CFG_BASE @@ -84,10 +78,14 @@ public: public: PARAM_CFG_INT( const wxChar* ident, int* ptparam, - int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, + int default_val = 0, + int min = std::numeric_limits::min(), + int max = std::numeric_limits::max(), const wxChar* group = NULL ); PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam, - int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, + int default_val = 0, + int min = std::numeric_limits::min(), + int max = std::numeric_limits::max(), const wxChar* group = NULL ); virtual void ReadParam( wxConfigBase* aConfig ) const; @@ -102,14 +100,14 @@ public: class PARAM_CFG_SETCOLOR : public PARAM_CFG_BASE { public: - int* m_Pt_param; ///< Pointer to the parameter value - int m_Default; ///< The default value of the parameter + EDA_COLOR_T* m_Pt_param; ///< Pointer to the parameter value + EDA_COLOR_T m_Default; ///< The default value of the parameter public: - PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, - int default_val, const wxChar* group = NULL ); - PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam, - int default_val, const wxChar* group = NULL ); + PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptparam, + EDA_COLOR_T default_val, const wxChar* group = NULL ); + PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, EDA_COLOR_T* ptparam, + EDA_COLOR_T default_val, const wxChar* group = NULL ); virtual void ReadParam( wxConfigBase* aConfig ) const; virtual void SaveParam( wxConfigBase* aConfig ) const; diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index 2d156484c3..42e6496715 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -168,7 +168,7 @@ public: wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - int aColor = -1 ) = 0; + EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0; /** * Function Move diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index fe8ebcb289..accb2eb734 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -281,7 +281,7 @@ public: * Function IsGridVisible() , virtual * @return true if the grid must be shown */ - virtual bool IsGridVisible(); + virtual bool IsGridVisible() const; /** * Function SetGridVisibility() , virtual @@ -295,13 +295,13 @@ public: * Function GetGridColor() , virtual * @return the color of the grid */ - virtual int GetGridColor(); + virtual EDA_COLOR_T GetGridColor() const; /** * Function SetGridColor() , virtual * @param aColor = the new color of the grid */ - virtual void SetGridColor(int aColor); + virtual void SetGridColor(EDA_COLOR_T aColor); // Configurations: void InstallConfigFrame(); @@ -513,7 +513,7 @@ public: * @return bool - true if the element is visible. * @see enum PCB_VISIBLE */ - bool IsElementVisible( int aElement ); + bool IsElementVisible( int aElement ) const; /** * Function SetElementVisibility diff --git a/include/wxstruct.h b/include/wxstruct.h index 8e25273b92..0af8992150 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -378,7 +378,7 @@ protected: EDA_HOTKEY_CONFIG* m_HotkeysZoomAndGridList; int m_LastGridSizeId; bool m_DrawGrid; // hide/Show grid - int m_GridColor; // Grid color + EDA_COLOR_T m_GridColor; // Grid color /// The area to draw on. EDA_DRAW_PANEL* m_canvas; @@ -533,7 +533,7 @@ public: * Function IsGridVisible() , virtual * @return true if the grid must be shown */ - virtual bool IsGridVisible() + virtual bool IsGridVisible() const { return m_DrawGrid; } @@ -552,7 +552,7 @@ public: * Function GetGridColor() , virtual * @return the color of the grid */ - virtual int GetGridColor() + virtual EDA_COLOR_T GetGridColor() const { return m_GridColor; } @@ -561,7 +561,7 @@ public: * Function SetGridColor() , virtual * @param aColor = the new color of the grid */ - virtual void SetGridColor( int aColor ) + virtual void SetGridColor( EDA_COLOR_T aColor ) { m_GridColor = aColor; } @@ -574,7 +574,7 @@ public: * @param aPosition The position to test. * @return The wxPoint of the appropriate cursor position. */ - wxPoint GetGridPosition( const wxPoint& aPosition ); + wxPoint GetGridPosition( const wxPoint& aPosition ) const; /** * Command event handler for selecting grid sizes. @@ -694,7 +694,7 @@ public: * @return a wxString containing the message locator like A3 or B6 * (or ?? if out of page limits) */ - const wxString GetXYSheetReferences( const wxPoint& aPosition ); + const wxString GetXYSheetReferences( const wxPoint& aPosition ) const; void DisplayToolMsg( const wxString& msg ); virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; @@ -816,7 +816,7 @@ public: * @param pad - Number of spaces to pad between messages (default = 4). */ void AppendMsgPanel( const wxString& textUpper, const wxString& textLower, - int color, int pad = 6 ); + EDA_COLOR_T color, int pad = 6 ); /** * Clear all messages from the message panel. @@ -843,7 +843,7 @@ public: * the current user unit is millimeters. * @return The converted string for display in user interface elements. */ - wxString CoordinateToString( int aValue, bool aConvertToMils = false ); + wxString CoordinateToString( int aValue, bool aConvertToMils = false ) const; /** * Function LengthDoubleToString @@ -854,7 +854,7 @@ public: * the current user unit is millimeters. * @return The converted string for display in user interface elements. */ - wxString LengthDoubleToString( double aValue, bool aConvertToMils = false ); + wxString LengthDoubleToString( double aValue, bool aConvertToMils = false ) const; DECLARE_EVENT_TABLE() }; @@ -871,25 +871,7 @@ struct EDA_MSG_ITEM int m_LowerY; wxString m_UpperText; wxString m_LowerText; - int m_Color; - - /** - * Function operator= - * overload the assignment operator so that the wxStrings get copied - * properly when copying a EDA_MSG_ITEM. - * No, actually I'm not sure this needed, C++ compiler may auto-generate it. - */ - EDA_MSG_ITEM& operator=( const EDA_MSG_ITEM& rv ) - { - m_X = rv.m_X; - m_UpperY = rv.m_UpperY; - m_LowerY = rv.m_LowerY; - m_UpperText = rv.m_UpperText; // overloaded operator=() - m_LowerText = rv.m_LowerText; // overloaded operator=() - m_Color = rv.m_Color; - - return * this; - } + EDA_COLOR_T m_Color; }; @@ -917,7 +899,7 @@ protected: /** * Calculate the width and height of a text string using the system UI font. */ - wxSize computeTextSize( const wxString& text ); + wxSize computeTextSize( const wxString& text ) const; public: EDA_MSG_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& pos, const wxSize& size ); @@ -944,7 +926,7 @@ public: * @param aColor Color of the text to display. */ void SetMessage( int aXPosition, const wxString& aUpperText, - const wxString& aLowerText, int aColor ); + const wxString& aLowerText, EDA_COLOR_T aColor ); /** * Append a message to the message panel. @@ -960,7 +942,7 @@ public: * @param pad - Number of spaces to pad between messages (default = 4). */ void AppendMessage( const wxString& textUpper, const wxString& textLower, - int color, int pad = 6 ); + EDA_COLOR_T color, int pad = 6 ); DECLARE_EVENT_TABLE() }; diff --git a/pcbnew/autorouter/autoplac.cpp b/pcbnew/autorouter/autoplac.cpp index 16f8b14958..3d8859bd27 100644 --- a/pcbnew/autorouter/autoplac.cpp +++ b/pcbnew/autorouter/autoplac.cpp @@ -373,7 +373,8 @@ end_of_tst: void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC ) { - int color, ii, jj; + int ii, jj; + EDA_COLOR_T color; int ox, oy; MATRIX_CELL top_state, bottom_state; @@ -896,7 +897,7 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) cout = 0; - int color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); + EDA_COLOR_T color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); if( AutoPlaceShowAll ) GRSetDrawMode( DC, GR_XOR ); diff --git a/pcbnew/autorouter/autorout.cpp b/pcbnew/autorouter/autorout.cpp index 7ea56d1768..76e33038c0 100644 --- a/pcbnew/autorouter/autorout.cpp +++ b/pcbnew/autorouter/autorout.cpp @@ -220,7 +220,8 @@ void PCB_EDIT_FRAME::Reset_Noroutable( wxDC* DC ) /* DEBUG Function: displays the routing matrix */ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC ) { - int dcell0, dcell1 = 0, color; + int dcell0, dcell1 = 0; + EDA_COLOR_T color; int maxi = 600 / RoutingMatrix.m_Ncols; maxi = ( maxi * 3 ) / 4; @@ -234,7 +235,7 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC ) { for( int row = 0; row < RoutingMatrix.m_Nrows; row++ ) { - color = 0; + color = BLACK; dcell0 = RoutingMatrix.GetCell( row, col, BOTTOM ); if( dcell0 & HOLE ) @@ -244,7 +245,7 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC ) // dcell1 = GetCell( row, col, TOP ); if( dcell1 & HOLE ) - color |= RED; + color = RED; // dcell0 |= dcell1; diff --git a/pcbnew/autorouter/solve.cpp b/pcbnew/autorouter/solve.cpp index 17f9ae35f6..a7f907c6e7 100644 --- a/pcbnew/autorouter/solve.cpp +++ b/pcbnew/autorouter/solve.cpp @@ -333,7 +333,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount ) /* Draw segment. */ GRLine( m_canvas->GetClipBox(), DC, segm_oX, segm_oY, segm_fX, segm_fY, - 0, WHITE | GR_XOR ); + 0, WHITE ); pt_cur_ch->m_PadStart->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT ); pt_cur_ch->m_PadEnd->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 962fc08386..0909d49762 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -723,9 +723,9 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled ) } -int BOARD::GetVisibleElementColor( int aPCB_VISIBLE ) +EDA_COLOR_T BOARD::GetVisibleElementColor( int aPCB_VISIBLE ) { - int color = -1; + EDA_COLOR_T color = UNSPECIFIED_COLOR; switch( aPCB_VISIBLE ) { @@ -751,7 +751,7 @@ int BOARD::GetVisibleElementColor( int aPCB_VISIBLE ) } -void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, int aColor ) +void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, EDA_COLOR_T aColor ) { switch( aPCB_VISIBLE ) { @@ -775,13 +775,13 @@ void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, int aColor ) } -void BOARD::SetLayerColor( int aLayer, int aColor ) +void BOARD::SetLayerColor( int aLayer, EDA_COLOR_T aColor ) { GetColorsSettings()->SetLayerColor( aLayer, aColor ); } -int BOARD::GetLayerColor( int aLayer ) +EDA_COLOR_T BOARD::GetLayerColor( int aLayer ) const { return GetColorsSettings()->GetLayerColor( aLayer ); } diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 08dee42524..37c33ff5a2 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -574,9 +574,9 @@ public: * returns the color of a pcb visible element. * @see enum PCB_VISIBLE */ - int GetVisibleElementColor( int aPCB_VISIBLE ); + EDA_COLOR_T GetVisibleElementColor( int aPCB_VISIBLE ); - void SetVisibleElementColor( int aPCB_VISIBLE, int aColor ); + void SetVisibleElementColor( int aPCB_VISIBLE, EDA_COLOR_T aColor ); /** * Function GetDesignSettings @@ -673,13 +673,13 @@ public: * Function SetLayerColor * changes a layer color for any valid layer, including non-copper ones. */ - void SetLayerColor( int aLayer, int aColor ); + void SetLayerColor( int aLayer, EDA_COLOR_T aColor ); /** * Function GetLayerColor * gets a layer color for any valid layer, including non-copper ones. */ - int GetLayerColor( int aLayer ); + EDA_COLOR_T GetLayerColor( int aLayer ) const; /** Functions to get some items count */ int GetNumSegmTrack() const; diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 26847def3e..31aa1080fa 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -354,7 +354,8 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, const wxPoint& offset ) { - int ox, oy, typeaff, width, gcolor; + int ox, oy, typeaff, width; + EDA_COLOR_T gcolor; ox = -offset.x; oy = -offset.y; diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index d0de057b87..6761f8e73e 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -172,9 +172,10 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, { int ux0, uy0, dx, dy; int l_trace; - int color, mode; + int mode; int radius; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; + EDA_COLOR_T color; BOARD * brd = GetBoard( ); @@ -186,10 +187,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) && !IsOnLayer( EDGE_N ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 8816cc435f..23ad4714e2 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -99,7 +99,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, const wxPoint& offset ) { int ux0, uy0, dx, dy, radius, StAngle, EndAngle; - int color, type_trace; + int type_trace; int typeaff; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; PCB_BASE_FRAME* frame; @@ -114,15 +114,12 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, if( brd->IsLayerVisible( m_Layer ) == false ) return; - color = brd->GetLayerColor( m_Layer ); + EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); if(( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index bd44948c34..ccb7210cf3 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -97,7 +97,7 @@ void PCB_TARGET::Copy( PCB_TARGET* source ) void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, const wxPoint& offset ) { - int radius, ox, oy, gcolor, width; + int radius, ox, oy, width; int dx1, dx2, dy1, dy2; int typeaff; @@ -109,7 +109,7 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, if( brd->IsLayerVisible( m_Layer ) == false ) return; - gcolor = brd->GetLayerColor( m_Layer ); + EDA_COLOR_T gcolor = brd->GetLayerColor( m_Layer ); GRSetDrawMode( DC, mode_color ); typeaff = DisplayOpt.DisplayDrawItems; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 2a73c0e820..2cb21e53b7 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -190,7 +190,7 @@ void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, if( GetBoard()->IsElementVisible( ANCHOR_VISIBLE ) ) { - int color = g_ColorsSettings.GetItemColor( ANCHOR_VISIBLE ); + EDA_COLOR_T color = g_ColorsSettings.GetItemColor( ANCHOR_VISIBLE ); GRLine( panel->GetClipBox(), DC, m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y, m_Pos.x - offset.x + anchor_size, m_Pos.y - offset.y, diff --git a/pcbnew/class_netinfo_item.cpp b/pcbnew/class_netinfo_item.cpp index 5099f0779e..c850ddf6e4 100644 --- a/pcbnew/class_netinfo_item.cpp +++ b/pcbnew/class_netinfo_item.cpp @@ -199,7 +199,7 @@ void RATSNEST_ITEM::Draw( EDA_DRAW_PANEL* panel, { GRSetDrawMode( DC, aDrawMode ); - int color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); + EDA_COLOR_T color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); GRLine( panel->GetClipBox(), DC, m_PadStart->GetPosition() - aOffset, diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 7c5043bc01..1ba650471e 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -70,10 +70,10 @@ class PAD_DRAWINFO public: EDA_DRAW_PANEL* m_DrawPanel; // the EDA_DRAW_PANEL used to draw a PAD ; can be null GR_DRAWMODE m_DrawMode; // the draw mode - int m_Color; // color used to draw the pad shape , from pad layers and + EDA_COLOR_T m_Color; // color used to draw the pad shape , from pad layers and // visible layers - int m_HoleColor; // color used to draw the pad hole - int m_NPHoleColor; // color used to draw a pad Not Plated hole + EDA_COLOR_T m_HoleColor; // color used to draw the pad hole + EDA_COLOR_T m_NPHoleColor; // color used to draw a pad Not Plated hole int m_PadClearance; // clearance value, used to draw the pad area outlines wxSize m_Mask_margin; // margin, used to draw solder paste when only one layer is shown bool m_Display_padnum; // true to show pad number diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index d2c7aa07cd..d139dddf62 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -78,7 +78,7 @@ PAD_DRAWINFO::PAD_DRAWINFO() void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, const wxPoint& aOffset ) { - int color = 0; + EDA_COLOR_T color = ColorFromInt(0); // XXX EVIL (it will be ORed later) wxSize mask_margin; // margin (clearance) used for some non copper layers #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR @@ -150,10 +150,11 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, if( m_layerMask & LAYER_BACK ) { - color |= brd->GetVisibleElementColor( PAD_BK_VISIBLE ); + // XXX EVIL merge + color = ColorFromInt( color | brd->GetVisibleElementColor( PAD_BK_VISIBLE ) ); } - if( color == 0 ) /* Not on copper layer */ + if( color == 0 ) // Not on copper layer XXX EVIL check { // If the pad in on only one tech layer, use the layer color else use DARKGRAY int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS; @@ -253,10 +254,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, || ( ( 1 << screen->m_Active_Layer ) & ( LAYER_BACK | LAYER_FRONT ) ) ) { if( !IsOnLayer( screen->m_Active_Layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } // else routing between an internal signal layer and some other // layer. Grey out all PAD_SMD pads not on current or the single @@ -265,8 +263,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, && !IsOnLayer( routeTop ) && !IsOnLayer( routeBot ) ) { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; + ColorTurnToDarkDarkGray( &color ); } } // when not edting tracks, show PAD_SMD components not on active layer @@ -274,10 +271,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, else { if( !IsOnLayer( screen->m_Active_Layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } } @@ -336,12 +330,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, if( aDraw_mode & GR_HIGHLIGHT ) - { - if( aDraw_mode & GR_AND ) - color &= ~HIGHLIGHT_FLAG; - else - color |= HIGHLIGHT_FLAG; - } + ColorChangeHighlightFlag( &color, !(aDraw_mode & GR_AND) ); if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -505,7 +494,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) else GRSetDrawMode( aDC, GR_XOR ); - int hole_color = aDrawInfo.m_HoleColor; + EDA_COLOR_T hole_color = aDrawInfo.m_HoleColor; if( aDrawInfo. m_ShowNotPlatedHole ) // Draw a specific hole color hole_color = aDrawInfo.m_NPHoleColor; @@ -556,7 +545,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( m_Netname.IsEmpty() && aDrawInfo.m_ShowNCMark ) { int dx0 = MIN( halfsize.x, halfsize.y ); - int nc_color = BLUE; + EDA_COLOR_T nc_color = BLUE; if( m_layerMask & LAYER_FRONT ) /* Draw \ */ GRLine( aClipBox, aDC, holepos.x - dx0, holepos.y - dx0, diff --git a/pcbnew/class_pcb_layer_box_selector.cpp b/pcbnew/class_pcb_layer_box_selector.cpp index 4dc9f1a331..a5f138b3fd 100644 --- a/pcbnew/class_pcb_layer_box_selector.cpp +++ b/pcbnew/class_pcb_layer_box_selector.cpp @@ -82,7 +82,7 @@ void PCB_LAYER_BOX_SELECTOR::Resync() } // Returns true if the layer id is enabled (i.e. is it should be displayed) -bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( int aLayerIndex ) +bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( int aLayerIndex ) const { PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent(); BOARD* board = pcbFrame->GetBoard(); @@ -92,7 +92,7 @@ bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( int aLayerIndex ) } // Returns a color index from the layer id -int PCB_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) +EDA_COLOR_T PCB_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) const { PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent(); BOARD* board = pcbFrame->GetBoard(); @@ -102,7 +102,7 @@ int PCB_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) } // Returns the name of the layer id -const wxString PCB_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex ) +wxString PCB_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex ) const { PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent(); BOARD* board = pcbFrame->GetBoard(); diff --git a/pcbnew/class_pcb_layer_box_selector.h b/pcbnew/class_pcb_layer_box_selector.h index 82865cd023..790988fd07 100644 --- a/pcbnew/class_pcb_layer_box_selector.h +++ b/pcbnew/class_pcb_layer_box_selector.h @@ -40,15 +40,15 @@ public: // Returns a color index from the layer id // Virtual function - int GetLayerColor( int aLayerIndex ); + EDA_COLOR_T GetLayerColor( int aLayerIndex ) const; // Returns true if the layer id is enabled (i.e. is it should be displayed) // Virtual function - bool IsLayerEnabled( int aLayerIndex ); + bool IsLayerEnabled( int aLayerIndex ) const; // Returns the name of the layer id // Virtual function - const wxString GetLayerName( int aLayerIndex ); + wxString GetLayerName( int aLayerIndex ) const; }; #define DECLARE_LAYERS_HOTKEY(list) int list[LAYER_COUNT] = \ diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 3cd7ec006b..819a589f20 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -66,11 +66,11 @@ const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = { RR( _( "Anchors" ), ANCHOR_VISIBLE, WHITE, _( "Show footprint and text origins as a cross" ) ), RR( _( "Grid" ), GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ), - RR( _( "No-Connects" ), NO_CONNECTS_VISIBLE, -1, _( "Show a marker on pads which have no net connected" ) ), - RR( _( "Modules Front" ), MOD_FR_VISIBLE, -1, _( "Show footprints that are on board's front") ), - RR( _( "Modules Back" ), MOD_BK_VISIBLE, -1, _( "Show footprints that are on board's back") ), - RR( _( "Values" ), MOD_VALUES_VISIBLE, -1, _( "Show footprint's values") ), - RR( _( "References" ), MOD_REFERENCES_VISIBLE, -1, _( "Show footprint's references") ), + RR( _( "No-Connects" ), NO_CONNECTS_VISIBLE, UNSPECIFIED_COLOR, _( "Show a marker on pads which have no net connected" ) ), + RR( _( "Modules Front" ), MOD_FR_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprints that are on board's front") ), + RR( _( "Modules Back" ), MOD_BK_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprints that are on board's back") ), + RR( _( "Values" ), MOD_VALUES_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprint's values") ), + RR( _( "References" ), MOD_REFERENCES_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprint's references") ), }; @@ -324,7 +324,7 @@ void PCB_LAYER_WIDGET::ReFill() //------------------------------------------------ -void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, int aColor ) +void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) { myframe->GetBoard()->SetLayerColor( aLayer, aColor ); myframe->ReCreateLayerBox( NULL ); @@ -362,7 +362,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal myframe->GetCanvas()->Refresh(); } -void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, int aColor ) +void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor ) { myframe->GetBoard()->SetVisibleElementColor( aId, aColor ); myframe->GetCanvas()->Refresh(); diff --git a/pcbnew/class_pcb_layer_widget.h b/pcbnew/class_pcb_layer_widget.h index 13f3a85007..8fa09595b5 100644 --- a/pcbnew/class_pcb_layer_widget.h +++ b/pcbnew/class_pcb_layer_widget.h @@ -82,10 +82,10 @@ public: void SetLayersManagerTabsText(); //---------------- - void OnLayerColorChange( int aLayer, int aColor ); + void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ); bool OnLayerSelect( int aLayer ); void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ); - void OnRenderColorChange( int aId, int aColor ); + void OnRenderColorChange( int aId, EDA_COLOR_T aColor ); void OnRenderEnable( int aId, bool isEnabled ); //--------------- diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 189f1dcc8b..d4164ddd72 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -89,20 +89,20 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, if( brd->IsLayerVisible( m_Layer ) == false ) return; - int color = brd->GetLayerColor( m_Layer ); + EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); EDA_DRAW_MODE_T fillmode = FILLED; if( DisplayOpt.DisplayDrawItems == SKETCH ) fillmode = SKETCH; - int anchor_color = UNSPECIFIED; + EDA_COLOR_T anchor_color = UNSPECIFIED_COLOR; if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) anchor_color = brd->GetVisibleElementColor( ANCHOR_VISIBLE ); - EDA_TEXT::Draw( panel, DC, offset, (EDA_COLOR_T) color, - DrawMode, fillmode, (EDA_COLOR_T) anchor_color ); + EDA_TEXT::Draw( panel, DC, offset, color, + DrawMode, fillmode, anchor_color ); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 599cc25a6c..325660ce70 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -238,7 +238,7 @@ EDA_RECT TEXTE_MODULE::GetBoundingBox() const void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, const wxPoint& offset ) { - int width, color, orient; + int width, orient; wxSize size; wxPoint pos; // Center of text PCB_BASE_FRAME* frame; @@ -268,6 +268,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, GRSetDrawMode( DC, draw_mode ); BOARD * brd = GetBoard( ); + EDA_COLOR_T color; if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) { color = brd->GetVisibleElementColor(ANCHOR_VISIBLE); diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 4b70775747..9d070df617 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -586,7 +586,6 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, const wxPoint& aOffset ) { int l_trace; - int color; int radius; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; @@ -594,7 +593,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, return; BOARD * brd = GetBoard( ); - color = brd->GetLayerColor(m_Layer); + EDA_COLOR_T color = brd->GetLayerColor(m_Layer); if( brd->IsLayerVisible( m_Layer ) == false && !( draw_mode & GR_HIGHLIGHT ) ) return; @@ -608,19 +607,11 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } if( draw_mode & GR_HIGHLIGHT ) - { - if( draw_mode & GR_AND ) - color &= ~HIGHLIGHT_FLAG; - else - color |= HIGHLIGHT_FLAG; - } + ColorChangeHighlightFlag( &color, !(draw_mode & GR_AND) ); if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -760,7 +751,6 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, const wxPoint& aOffset ) { - int color; int radius; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; @@ -774,7 +764,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, GRSetDrawMode( DC, draw_mode ); BOARD * brd = GetBoard( ); - color = brd->GetVisibleElementColor(VIAS_VISIBLE + m_Shape); + EDA_COLOR_T color = brd->GetVisibleElementColor(VIAS_VISIBLE + m_Shape); if( brd->IsElementVisible( PCB_VISIBLE(VIAS_VISIBLE + m_Shape) ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG ) @@ -783,19 +773,11 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, if( DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } if( draw_mode & GR_HIGHLIGHT ) - { - if( draw_mode & GR_AND ) - color &= ~HIGHLIGHT_FLAG; - else - color |= HIGHLIGHT_FLAG; - } + ColorChangeHighlightFlag( &color, !(draw_mode & GR_AND) ); if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index bd6fbb1f8f..7b57d5f303 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -172,7 +172,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); - int color = brd->GetLayerColor( m_Layer ); + EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG ) return; @@ -182,19 +182,11 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod if( DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } if( aDrawMode & GR_HIGHLIGHT ) - { - if( aDrawMode & GR_AND ) - color &= ~HIGHLIGHT_FLAG; - else - color |= HIGHLIGHT_FLAG; - } + ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) ); if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -263,7 +255,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, BOARD* brd = GetBoard(); int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - int color = brd->GetLayerColor( m_Layer ); + EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG ) return; @@ -273,19 +265,11 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, if( DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } if( aDrawMode & GR_HIGHLIGHT ) - { - if( aDrawMode & GR_AND ) - color &= ~HIGHLIGHT_FLAG; - else - color |= HIGHLIGHT_FLAG; - } + ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) ); if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -412,15 +396,12 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); - int color = brd->GetLayerColor( m_Layer ) & MASKCOLOR; + EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); if( DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } + ColorTurnToDarkDarkGray( &color ); } // draw the lines diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index ba4b10e850..164d632f36 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -288,7 +288,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, screen->m_IsPrinting = true; - int bg_color = g_DrawBgColor; + EDA_COLOR_T bg_color = g_DrawBgColor; g_DrawBgColor = WHITE; if( PrintPageRef() ) diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 1cb1b13588..c51872edd6 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -116,7 +116,7 @@ private: * creates the colored rectangle bitmaps used in the layer selection widget. * @param aColor is the color to fill the rectangle with. */ - wxBitmap makeLayerBitmap( int aColor ); + wxBitmap makeLayerBitmap( EDA_COLOR_T aColor ); }; @@ -251,7 +251,7 @@ void DIALOG_COPPER_ZONE::initDialog() m_LayerSelectionCtrl->InsertColumn( 0, col0 ); // Build copper layer list and append to layer widget int layerCount = board->GetCopperLayerCount(); - int layerNumber, itemIndex, layerColor; + int layerNumber, itemIndex; wxImageList* imageList = new wxImageList( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL ); for( int ii = 0; ii < layerCount; ii++ ) @@ -266,7 +266,7 @@ void DIALOG_COPPER_ZONE::initDialog() m_LayerId.insert( m_LayerId.begin(), layerNumber ); msg = board->GetLayerName( layerNumber ).Trim(); - layerColor = board->GetLayerColor( layerNumber ); + EDA_COLOR_T layerColor = board->GetLayerColor( layerNumber ); imageList->Add( makeLayerBitmap( layerColor ) ); itemIndex = m_LayerSelectionCtrl->InsertItem( 0, msg, ii ); @@ -683,7 +683,7 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets() } -wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( int aColor ) +wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( EDA_COLOR_T aColor ) { wxBitmap bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); wxBrush brush; diff --git a/pcbnew/dialogs/dialog_keepout_area_properties.cpp b/pcbnew/dialogs/dialog_keepout_area_properties.cpp index 7963f6d29b..ea400d9ca1 100644 --- a/pcbnew/dialogs/dialog_keepout_area_properties.cpp +++ b/pcbnew/dialogs/dialog_keepout_area_properties.cpp @@ -85,7 +85,7 @@ private: * creates the colored rectangle bitmaps used in the layer selection widget. * @param aColor is the color to fill the rectangle with. */ - wxBitmap makeLayerBitmap( int aColor ); + wxBitmap makeLayerBitmap( EDA_COLOR_T aColor ); }; @@ -149,7 +149,8 @@ void DIALOG_KEEPOUT_AREA_PROPERTIES::initDialog() m_LayerSelectionCtrl->InsertColumn( 0, col0 ); // Build copper layer list and append to layer widget int layerCount = board->GetCopperLayerCount(); - int layerNumber, itemIndex, layerColor; + int layerNumber, itemIndex; + EDA_COLOR_T layerColor; wxImageList* imageList = new wxImageList( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL ); for( int ii = 0; ii < layerCount; ii++ ) @@ -261,7 +262,7 @@ bool DIALOG_KEEPOUT_AREA_PROPERTIES::AcceptOptionsForKeepOut() return true; } -wxBitmap DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerBitmap( int aColor ) +wxBitmap DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerBitmap( EDA_COLOR_T aColor ) { wxBitmap bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); wxBrush brush; diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 0dc3dd5058..4b363399f5 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -171,7 +171,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) wxPaintDC dc( m_panelShowPad ); PAD_DRAWINFO drawInfo; - int color = 0; + EDA_COLOR_T color = ColorFromInt( 0 ); // XXX EVIL merge if( m_dummyPad->GetLayerMask() & LAYER_FRONT ) { @@ -180,7 +180,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) if( m_dummyPad->GetLayerMask() & LAYER_BACK ) { - color |= m_Board->GetVisibleElementColor( PAD_BK_VISIBLE ); + color = ColorFromInt( color | m_Board->GetVisibleElementColor( PAD_BK_VISIBLE ) ); // XXX EVIL merge } if( color == 0 ) diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 1c7c5feeda..01646443c4 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -684,7 +684,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) { - int color = g_ColorsSettings.GetLayerColor( g_CurrentTrackSegment->GetLayer() ); + EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( g_CurrentTrackSegment->GetLayer() ); GRCircle( aPanel->GetClipBox(), aDC, g_CurrentTrackSegment->m_End.x, g_CurrentTrackSegment->m_End.y, @@ -752,7 +752,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) { - int color = g_ColorsSettings.GetLayerColor(g_CurrentTrackSegment->GetLayer()); + EDA_COLOR_T color = g_ColorsSettings.GetLayerColor(g_CurrentTrackSegment->GetLayer()); GRCircle( aPanel->GetClipBox(), aDC, g_CurrentTrackSegment->m_End.x, g_CurrentTrackSegment->m_End.y, diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index c2c75e9d17..48c4d1fe1e 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -711,7 +711,7 @@ static void export_vrml_pcbtext( TEXTE_PCB* text ) for( unsigned i = 0; iCount(); i++ ) { wxString txt = list->Item( i ); - DrawGraphicText( NULL, NULL, pos, (EDA_COLOR_T) 0, + DrawGraphicText( NULL, NULL, pos, BLACK, txt, text->GetOrientation(), size, text->m_HJustify, text->m_VJustify, text->m_Thickness, text->m_Italic, @@ -724,7 +724,7 @@ static void export_vrml_pcbtext( TEXTE_PCB* text ) } else { - DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_COLOR_T) 0, + DrawGraphicText( NULL, NULL, text->m_Pos, BLACK, text->m_Text, text->GetOrientation(), size, text->m_HJustify, text->m_VJustify, text->m_Thickness, text->m_Italic, @@ -873,7 +873,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) //{{{ s_text_layer = module->GetLayer(); s_text_width = module->m_Thickness; - DrawGraphicText( NULL, NULL, module->m_Pos, (EDA_COLOR_T) 0, + DrawGraphicText( NULL, NULL, module->m_Pos, BLACK, module->m_Text, module->GetDrawRotation(), size, module->m_HJustify, module->m_VJustify, module->m_Thickness, module->m_Italic, diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp index ca59c0256b..e2c21cdabf 100644 --- a/pcbnew/gen_drill_report_files.cpp +++ b/pcbnew/gen_drill_report_files.cpp @@ -180,7 +180,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, // Plot title "Info" wxString Text = wxT( "Drill Map:" ); - plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED, Text, 0, + plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED_COLOR, Text, 0, wxSize( (int) ( charSize * charScale ), (int) ( charSize * charScale ) ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, @@ -232,9 +232,10 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, aToolListBuffer[ii].m_OvalCount ); msg += FROM_UTF8( line ); - plotter->Text( wxPoint( plotX, y ), UNSPECIFIED, + plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR, msg, - 0, wxSize( (int) ( charSize * charScale ), (int) ( charSize * charScale ) ), + 0, wxSize( (int) ( charSize * charScale ), + (int) ( charSize * charScale ) ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false ); diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index 3f3a7a7440..fba80155f0 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -147,7 +147,7 @@ static const char * rightarrow_alternate_xpm[] = { * returns a string containing the numeric value of the color. * in a form like 0x00000000. (Color is currently an index, not RGB). */ -static wxString makeColorTxt( int aColor ) +static wxString makeColorTxt( EDA_COLOR_T aColor ) { wxString txt; txt.Printf( wxT("0x%08x"), aColor ); @@ -181,7 +181,7 @@ int LAYER_WIDGET::getDecodedId( int aControlId ) } -wxBitmap LAYER_WIDGET::makeBitmap( int aColor ) +wxBitmap LAYER_WIDGET::makeBitmap( EDA_COLOR_T aColor ) { // the bitmap will be BUTT_VOID*2 pixels smaller than the button, leaving a // border of BUTT_VOID pixels on each side. @@ -201,7 +201,7 @@ wxBitmap LAYER_WIDGET::makeBitmap( int aColor ) } -wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, int aColor, int aID ) +wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, EDA_COLOR_T aColor, int aID ) { // dynamically make a wxBitMap and brush it with the appropriate color, // then create a wxBitmapButton from it. @@ -274,8 +274,8 @@ void LAYER_WIDGET::OnMiddleDownLayerColor( wxMouseEvent& event ) wxString colorTxt = eventSource->GetName(); - int oldColor = strtoul( TO_UTF8(colorTxt), NULL, 0 ); - int newColor = DisplayColorFrame( this, oldColor ); + EDA_COLOR_T oldColor = ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) ); + EDA_COLOR_T newColor = DisplayColorFrame( this, oldColor ); if( newColor >= 0 ) { @@ -309,8 +309,8 @@ void LAYER_WIDGET::OnMiddleDownRenderColor( wxMouseEvent& event ) wxString colorTxt = eventSource->GetName(); - int oldColor = strtoul( TO_UTF8(colorTxt), NULL, 0 ); - int newColor = DisplayColorFrame( this, oldColor ); + EDA_COLOR_T oldColor = ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) ); + EDA_COLOR_T newColor = DisplayColorFrame( this, oldColor ); if( newColor >= 0 ) { @@ -346,7 +346,7 @@ void LAYER_WIDGET::OnTabChange( wxNotebookEvent& event ) } -wxWindow* LAYER_WIDGET::getLayerComp( int aRow, int aColumn ) +wxWindow* LAYER_WIDGET::getLayerComp( int aRow, int aColumn ) const { int ndx = aRow * LYR_COLUMN_COUNT + aColumn; if( (unsigned) ndx < m_LayersFlexGridSizer->GetChildren().GetCount() ) @@ -355,7 +355,7 @@ wxWindow* LAYER_WIDGET::getLayerComp( int aRow, int aColumn ) } -int LAYER_WIDGET::findLayerRow( int aLayer ) +int LAYER_WIDGET::findLayerRow( int aLayer ) const { int count = GetLayerRowCount(); for( int row=0; rowGetChildren().GetCount() ) @@ -380,7 +380,7 @@ wxWindow* LAYER_WIDGET::getRenderComp( int aRow, int aColumn ) } -int LAYER_WIDGET::findRenderRow( int aId ) +int LAYER_WIDGET::findRenderRow( int aId ) const { int count = GetRenderRowCount(); for( int row=0; row= 0 ) @@ -798,7 +798,7 @@ void LAYER_WIDGET::SetLayerColor( int aLayer, int aColor ) } -int LAYER_WIDGET::GetLayerColor( int aLayer ) +EDA_COLOR_T LAYER_WIDGET::GetLayerColor( int aLayer ) const { int row = findLayerRow( aLayer ); if( row >= 0 ) @@ -808,11 +808,10 @@ int LAYER_WIDGET::GetLayerColor( int aLayer ) wxASSERT( bmb ); wxString colorTxt = bmb->GetName(); - int color = strtoul( TO_UTF8(colorTxt), NULL, 0 ); - return color; + return ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) ); } - return 0; // it's caller fault, gave me a bad layer + return UNSPECIFIED_COLOR; // it's caller fault, gave me a bad layer } @@ -876,7 +875,7 @@ class MYFRAME : public wxFrame { } - void OnLayerColorChange( int aLayer, int aColor ) + void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) { printf( "OnLayerColorChange( aLayer:%d, aColor:%d )\n", aLayer, aColor ); @@ -900,7 +899,7 @@ class MYFRAME : public wxFrame printf( "OnLayerVisible( aLayer:%d, isVisible:%d isFinal:%d)\n", aLayer, isVisible, isFinal ); } - void OnRenderColorChange( int aId, int aColor ) + void OnRenderColorChange( int aId, EDA_COLOR_T aColor ) { printf( "OnRenderColorChange( aId:%d, aColor:%d )\n", aId, aColor ); } diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h index a80f58e382..39d55d17ad 100644 --- a/pcbnew/layer_widget.h +++ b/pcbnew/layer_widget.h @@ -41,7 +41,7 @@ #include #include #include - +#include #define LYR_COLUMN_COUNT 4 ///< Layer tab column count #define RND_COLUMN_COUNT 2 ///< Rendering tab column count @@ -74,11 +74,11 @@ public: { wxString rowName; ///< the prompt or layername int id; ///< either a layer or "visible element" id - int color; ///< -1 if none. + EDA_COLOR_T color; ///< -1 if none. bool state; ///< initial wxCheckBox state wxString tooltip; ///< if not empty, use this tooltip on row - ROW( const wxString& aRowName, int aId, int aColor = -1, + ROW( const wxString& aRowName, int aId, EDA_COLOR_T aColor = UNSPECIFIED_COLOR, const wxString& aTooltip = wxEmptyString, bool aState = true ) { rowName = aRowName; @@ -109,7 +109,7 @@ protected: int m_CurrentRow; ///< selected row of layer list int m_PointSize; - static wxBitmap makeBitmap( int aColor ); + static wxBitmap makeBitmap( EDA_COLOR_T aColor ); /** * Virtual Function useAlternateBitmap @@ -140,7 +140,7 @@ protected: * Function makeColorButton * creates a wxBitmapButton and assigns it a solid color and a control ID */ - wxBitmapButton* makeColorButton( wxWindow* aParent, int aColor, int aID ); + wxBitmapButton* makeColorButton( wxWindow* aParent, EDA_COLOR_T aColor, int aID ); void OnLeftDownLayers( wxMouseEvent& event ); @@ -173,15 +173,15 @@ protected: * @param aColumn is the column * @return wxWindow - the component installed within the sizer at given grid coordinate. */ - wxWindow* getLayerComp( int aRow, int aColumn ); - wxWindow* getRenderComp( int aRow, int aColumn ); + wxWindow* getLayerComp( int aRow, int aColumn ) const; + wxWindow* getRenderComp( int aRow, int aColumn ) const; /** * Function findLayerRow * returns the row index that \a aLayer resides in, or -1 if not found. */ - int findLayerRow( int aLayer ); - int findRenderRow( int aId ); + int findLayerRow( int aLayer ) const; + int findRenderRow( int aId ) const; /** * Function insertLayerRow @@ -319,13 +319,13 @@ public: * Function SetLayerColor * changes the color of \a aLayer */ - void SetLayerColor( int aLayer, int aColor ); + void SetLayerColor( int aLayer, EDA_COLOR_T aColor ); /** * Function GetLayerColor * returns the color of the layer ROW associated with \a aLayer id. */ - int GetLayerColor( int aLayer ); + EDA_COLOR_T GetLayerColor( int aLayer ) const; /** * Function SetRenderState @@ -373,7 +373,7 @@ public: * @param aLayer is the board layer to change * @param aColor is the new color */ - virtual void OnLayerColorChange( int aLayer, int aColor ) = 0; + virtual void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) = 0; /** * Function OnLayerSelect @@ -404,7 +404,7 @@ public: * via the AddRenderRow() function. * @param aColor is the new color */ - virtual void OnRenderColorChange( int aId, int aColor ) = 0; + virtual void OnRenderColorChange( int aId, EDA_COLOR_T aColor ) = 0; /** * Function OnRenderEnable diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 119a80cc5a..ad52213cbd 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -616,7 +616,7 @@ void PCB_EDIT_FRAME::SaveSettings() } -bool PCB_EDIT_FRAME::IsGridVisible() +bool PCB_EDIT_FRAME::IsGridVisible() const { return IsElementVisible( GRID_VISIBLE ); } @@ -628,13 +628,13 @@ void PCB_EDIT_FRAME::SetGridVisibility(bool aVisible) } -int PCB_EDIT_FRAME::GetGridColor() +EDA_COLOR_T PCB_EDIT_FRAME::GetGridColor() const { return GetBoard()->GetVisibleElementColor( GRID_VISIBLE ); } -void PCB_EDIT_FRAME::SetGridColor(int aColor) +void PCB_EDIT_FRAME::SetGridColor(EDA_COLOR_T aColor) { GetBoard()->SetVisibleElementColor( GRID_VISIBLE, aColor ); } @@ -688,7 +688,7 @@ void PCB_EDIT_FRAME::unitsChangeRefresh() } -bool PCB_EDIT_FRAME::IsElementVisible( int aElement ) +bool PCB_EDIT_FRAME::IsElementVisible( int aElement ) const { return GetBoard()->IsElementVisible( aElement ); } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 3dc0c3420d..6c081f1f60 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -282,63 +282,63 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay2" ), LOC_COLOR( 2 ), LIGHTGRAY ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay3" ), LOC_COLOR( 3 ), - 5 ) ); + MAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay4" ), LOC_COLOR( 4 ), - 4 ) ); + RED ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay5" ), LOC_COLOR( 5 ), - 5 ) ); + MAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay6" ), LOC_COLOR( 6 ), - 6 ) ); + BROWN ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay7" ), LOC_COLOR( 7 ), - 5 ) ); + MAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay8" ), LOC_COLOR( 8 ), - 7 ) ); + LIGHTGRAY ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay9" ), LOC_COLOR( 9 ), - 1 ) ); + BLUE ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayA" ), LOC_COLOR( 10 ), - 2 ) ); + GREEN ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayB" ), LOC_COLOR( 11 ), - 3 ) ); + CYAN ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayC" ), LOC_COLOR( 12 ), - 12 ) ); + LIGHTRED ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayD" ), LOC_COLOR( 13 ), - 13 ) ); + LIGHTMAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayE" ), LOC_COLOR( 14 ), - 14 ) ); + YELLOW ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayF" ), LOC_COLOR( 15 ), RED ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayG" ), LOC_COLOR( 16 ), - 1 ) ); + BLUE ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayH" ), LOC_COLOR( 17 ), - 5 ) ); + MAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayI" ), LOC_COLOR( 18 ), - 11 ) ); + LIGHTCYAN ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayJ" ), LOC_COLOR( 19 ), - 4 ) ); + RED ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayK" ), LOC_COLOR( 20 ), - 5 ) ); + MAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayL" ), LOC_COLOR( 21 ), - 3 ) ); + CYAN ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayM" ), LOC_COLOR( 22 ), - 6 ) ); + BROWN ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayN" ), LOC_COLOR( 23 ), - 5 ) ); + MAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayO" ), LOC_COLOR( 24 ), LIGHTGRAY ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayP" ), LOC_COLOR( 25 ), - 1 ) ); + BLUE ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayQ" ), LOC_COLOR( 26 ), - 2 ) ); + GREEN ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayR" ), LOC_COLOR( 27 ), - 14 ) ); + YELLOW ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayS" ), LOC_COLOR( 28 ), YELLOW ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayT" ), LOC_COLOR( 29 ), - 13 ) ); + LIGHTMAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayU" ), LOC_COLOR( 30 ), - 14 ) ); + YELLOW ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayV" ), LOC_COLOR( 31 ), - 7 ) ); + LIGHTGRAY ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CTxtMoC" ), ITEM_COLOR( MOD_TEXT_FR_VISIBLE ), LIGHTGRAY ) ); diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 50fb516106..385b06c4db 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -512,7 +512,7 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC for( unsigned i = 0; i < list->Count(); i++ ) { wxString txt = list->Item( i ); - aPlotter->Text( pos, UNSPECIFIED, txt, orient, size, + aPlotter->Text( pos, UNSPECIFIED_COLOR, txt, orient, size, pt_texte->m_HJustify, pt_texte->m_VJustify, thickness, pt_texte->m_Italic, allow_bold ); pos += offset; @@ -522,7 +522,7 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC } else { - aPlotter->Text( pos, UNSPECIFIED, pt_texte->m_Text, orient, size, + aPlotter->Text( pos, UNSPECIFIED_COLOR, pt_texte->m_Text, orient, size, pt_texte->m_HJustify, pt_texte->m_VJustify, thickness, pt_texte->m_Italic, allow_bold ); } diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 116a1cddb8..fc57d876e3 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -232,7 +232,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, if( pt_trace->Type() == PCB_VIA_T ) // VIA encountered. { int radius = pt_trace->m_Width >> 1; - int color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + pt_trace->m_Shape ); + EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + pt_trace->m_Shape ); GRSetDrawMode( aDC, drawmode ); GRFilledCircle( m_canvas->GetClipBox(), aDC, pt_trace->m_Start.x, @@ -285,7 +285,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, if( drillShapeOpt != PRINT_PARAMETERS::NO_DRILL_SHAPE ) { pt_trace = Pcb->m_Track; - int color = g_DrawBgColor; + EDA_COLOR_T color = g_DrawBgColor; bool blackpenstate = GetGRForceBlackPenState(); GRForceBlackPen( false ); GRSetDrawMode( aDC, GR_COPY ); diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 7ae272445d..09024dbe17 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -281,7 +281,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) ); m_Parent->GetScreen()->m_IsPrinting = true; - int bg_color = g_DrawBgColor; + EDA_COLOR_T bg_color = g_DrawBgColor; if( m_PrintParams.m_Print_Sheet_Ref ) m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index 2d6bd56481..2b19175bce 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -710,7 +710,7 @@ void PCB_BASE_FRAME::TraceModuleRatsNest( wxDC* DC ) if( ( m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 ) return; - int tmpcolor = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); + EDA_COLOR_T tmpcolor = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); for( unsigned ii = 0; ii < m_Pcb->m_LocalRatsnest.size(); ii++ ) { diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 9f20d9372d..3e779fa138 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -94,7 +94,7 @@ static const char s_BitmapLayerIcon[24][24] = { void PCB_EDIT_FRAME::PrepareLayerIndicator() { int ii, jj; - int active_layer_color, Route_Layer_TOP_color, + EDA_COLOR_T active_layer_color, Route_Layer_TOP_color, Route_Layer_BOTTOM_color, via_color; bool change = false; bool first_call = LayerPairBitmap == NULL;