KiCad PCB EDA Suite
class_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 <colors_selection.h>
34 #include <gerbview_frame.h>
36 
38 
40 {
41  #define BM_SIZE 14
42  Freeze();
43  Clear();
44 
46 
47  for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
48  {
49  wxBitmap layerbmp( BM_SIZE, BM_SIZE );
50  wxString layername;
51 
52  if( !IsLayerEnabled( layerid ) )
53  continue;
54 
55  // Prepare Bitmap
56  SetBitmapLayer( layerbmp, layerid );
57 
58  layername = GetLayerName( layerid );
59 
60  Append( layername, layerbmp, (void*)(intptr_t) layerid );
61  }
62 
63  // Ensure the width of the widget is enough to show the text and the icon
64  SetMinSize( wxSize( -1, -1 ) );
65  int minwidth = GetBestSize().x + BM_SIZE + 10;
66  SetMinSize( wxSize( minwidth, -1 ) );
67 
68  Thaw();
69 }
70 
71 
72 // Returns a color index from the layer id
74 {
75  GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
76 
77  return frame->GetLayerColor( aLayer );
78 }
79 
80 
81 // Returns the name of the layer id
82 wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const
83 {
85  wxString name = images.GetDisplayName( aLayer );
86 
87  return name;
88 }
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...
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
static GERBER_FILE_IMAGE_LIST & GetImagesList()
#define BM_SIZE
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
The common library.
bool IsLayerEnabled(int aLayer) const override
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39