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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <widgets/wx_panel.h>
21#include <wx/dcclient.h>
22#include <wx/settings.h>
23
24WX_PANEL::WX_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
25 long style, const wxString& name ) :
26 wxPanel( parent, id, pos, size, style, name ),
27 m_leftBorder( false ),
28 m_rightBorder( false ),
29 m_topBorder( false ),
30 m_bottomBorder( false ),
32{
33 this->Connect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) );
34}
35
36
38{
39 this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) );
40}
41
42
43void WX_PANEL::OnPaint( wxPaintEvent& event )
44{
45 wxRect rect( wxPoint( 0, 0 ), GetClientSize() );
46 wxPaintDC dc( this );
47
49
50 if( border == KIGFX::COLOR4D::UNSPECIFIED )
51 {
52 KIGFX::COLOR4D bg = wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK );
53 KIGFX::COLOR4D fg = wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER );
54 border = fg.Mix( bg, 0.18 );
55 }
56
57 dc.SetPen( wxPen( border.ToColour(), 1 ) );
58
59 if( m_leftBorder )
60 dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom() );
61
62 if( m_rightBorder )
63 dc.DrawLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom() );
64
65 if( m_topBorder )
66 dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetTop() );
67
68 if( m_bottomBorder )
69 dc.DrawLine( rect.GetLeft(), rect.GetBottom(), rect.GetRight(), rect.GetBottom() );
70}
71
72
const char * name
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
wxColour ToColour() const
Definition color4d.cpp:221
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:292
bool m_topBorder
Definition wx_panel.h:54
bool m_rightBorder
Definition wx_panel.h:53
bool m_leftBorder
Definition wx_panel.h:52
bool m_bottomBorder
Definition wx_panel.h:55
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:24
void OnPaint(wxPaintEvent &event)
Definition wx_panel.cpp:43
KIGFX::COLOR4D m_borderColor
Definition wx_panel.h:57
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29