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