KiCad PCB EDA Suite
gbr_layer_box_selector.cpp
Go to the documentation of this file.
1 
7 /*
8  * This program source code file is part of KiCad, a free EDA CAD application.
9  *
10  * Copyright (C) 1992-2016 Jean-Pierre Charras <jp.charras at wanadoo.fr>
11  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
12  * Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, you may find one here:
26  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
27  * or you may search the http://www.gnu.org website for the version 2 license,
28  * or you may write to the Free Software Foundation, Inc.,
29  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
30  */
31 
32 #include <common.h>
33 #include <gerbview_frame.h>
34 #include <gerber_file_image_list.h>
35 
36 #include <gbr_layer_box_selector.h>
37 
39 {
40  #define BM_SIZE 14
41  Freeze();
42  Clear();
43 
45 
46  for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
47  {
48  if( !IsLayerEnabled( layerid ) )
49  continue;
50 
51  // Prepare Bitmap
52  wxBitmap bmp( BM_SIZE, BM_SIZE );
54 
55  Append( GetLayerName( layerid ), bmp, (void*)(intptr_t) layerid );
56  }
57 
58  // Ensure the width of the widget is enough to show the text and the icon
59  SetMinSize( wxSize( -1, -1 ) );
60  int minwidth = GetBestSize().x + BM_SIZE + 10;
61  SetMinSize( wxSize( minwidth, -1 ) );
62 
63  Thaw();
64 }
65 
66 
67 // Returns a color index from the layer id
69 {
70  GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
71 
72  return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
73 }
74 
75 
76 // Returns the name of the layer id
77 wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const
78 {
80  wxString name = images.GetDisplayName( aLayer );
81 
82  return name;
83 }
const wxString GetDisplayName(int aIdx, bool aNameOnly=false)
COLOR4D GetLayerColor(int aLayer) const override
wxString GetLayerName(int aLayer) const override
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
static GERBER_FILE_IMAGE_LIST & GetImagesList()
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
#define BM_SIZE
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
const char * name
Definition: DXF_plotter.cpp:61
The common library.
#define GERBER_DRAW_LAYER(x)
bool IsLayerEnabled(int aLayer) const override
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39