26#include <wx/dcmemory.h>
27#include <wx/odcombo.h>
28#include <wx/menuitem.h>
29#include <wx/settings.h>
57 bmpDC.SelectObject( aLayerbmp );
59 brush.SetStyle( wxBRUSHSTYLE_SOLID );
61 if( aBackground != COLOR4D::UNSPECIFIED )
64 bmpDC.SetBrush( brush );
65 bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
68 brush.SetColour( aColor.
ToColour() );
69 bmpDC.SetBrush( brush );
70 bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
72 bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
73 bmpDC.SetPen( *wxBLACK_PEN );
74 bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
79 const wxSize& size,
int n,
const wxString choices[] ) :
80 wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
83 if( choices !=
nullptr )
87 GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
96 GetParent()->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
104 if( GetSelection() < 0 )
107 return (
int)(intptr_t) GetClientData( GetSelection() );
113 for(
int i = 0; i < (int) GetCount(); i++ )
115 if( GetClientData( (
unsigned) i ) == (
void*)(intptr_t) layer )
117 if( GetSelection() != i )
140 for(
int i = 0; i < (int) GetCount(); ++i )
142 wxBitmap layerbmp( size, size );
150void LAYER_BOX_SELECTOR::onKeyDown( wxKeyEvent& aEvent )
152 if( aEvent.GetKeyCode() == WXK_ESCAPE && IsPopupShown() )
162void LAYER_BOX_SELECTOR::OnDrawBackground( wxDC& dc,
const wxRect& rect,
int item,
int flags)
const
164 if( ( flags & wxODCB_PAINTING_CONTROL ) && !IsEnabled() )
166 wxColour fgCol = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
167 wxColour bgCol = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
170 bgCol = bgCol.ChangeLightness( 106 );
172 bgCol = bgCol.ChangeLightness( 160 );
174 dc.SetTextForeground( fgCol );
175 dc.SetBrush( bgCol );
177 dc.DrawRectangle( rect.Inflate( 1, 1 ) );
178 dc.SetClippingRegion( rect );
182 wxBitmapComboBox::OnDrawBackground( dc, rect, item, flags );
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
double GetScaleFactor() const override
Get the DPI scale from all known sources in order:
A color representation with 4 components: red, green, blue, alpha.
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
wxColour ToColour() const
~LAYER_BOX_SELECTOR() override
LAYER_BOX_SELECTOR(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=nullptr)
int GetLayerSelection() const
int SetLayerSelection(int layer)
Base class to build a layer list.
virtual COLOR4D getLayerColor(int aLayer) const =0
static void DrawColorSwatch(wxBitmap &aLayerbmp, const COLOR4D &aBackground, const COLOR4D &aColor)
bool SetLayersHotkeys(bool value)
@ LAYER_PCB_BACKGROUND
PCB background color.