KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wx_panel.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <widgets/wx_panel.h>
25#include <wx/dcclient.h>
26#include <wx/settings.h>
27
28WX_PANEL::WX_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
29 long style, const wxString& name ) :
30 wxPanel( parent, id, pos, size, style, name ),
31 m_leftBorder( false ),
32 m_rightBorder( false ),
33 m_topBorder( false ),
34 m_bottomBorder( false ),
35 m_borderColor( KIGFX::COLOR4D::UNSPECIFIED )
36{
37 this->Connect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) );
38}
39
40
42{
43 this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) );
44}
45
46
47void WX_PANEL::OnPaint( wxPaintEvent& event )
48{
49 wxRect rect( wxPoint( 0, 0 ), GetClientSize() );
50 wxPaintDC dc( this );
51
53
54 if( border == KIGFX::COLOR4D::UNSPECIFIED )
55 {
56 KIGFX::COLOR4D bg = wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK );
57 KIGFX::COLOR4D fg = wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER );
58 border = fg.Mix( bg, 0.18 );
59 }
60
61 dc.SetPen( wxPen( border.ToColour(), 1 ) );
62
63 if( m_leftBorder )
64 dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom() );
65
66 if( m_rightBorder )
67 dc.DrawLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom() );
68
69 if( m_topBorder )
70 dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetTop() );
71
72 if( m_bottomBorder )
73 dc.DrawLine( rect.GetLeft(), rect.GetBottom(), rect.GetRight(), rect.GetBottom() );
74}
75
76
const char * name
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
wxColour ToColour() const
Definition: color4d.cpp:220
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:398
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:295
bool m_topBorder
Definition: wx_panel.h:58
bool m_rightBorder
Definition: wx_panel.h:57
~WX_PANEL()
Definition: wx_panel.cpp:41
bool m_leftBorder
Definition: wx_panel.h:56
bool m_bottomBorder
Definition: wx_panel.h:59
WX_PANEL(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
Definition: wx_panel.cpp:28
void OnPaint(wxPaintEvent &event)
Definition: wx_panel.cpp:47
KIGFX::COLOR4D m_borderColor
Definition: wx_panel.h:61
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247