You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.6 KiB

  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, 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. #include <widgets/wx_panel.h>
  24. #include <wx/dcclient.h>
  25. #include <wx/settings.h>
  26. WX_PANEL::WX_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
  27. long style, const wxString& name ) :
  28. wxPanel( parent, id, pos, size, style, name ),
  29. m_leftBorder( false ),
  30. m_rightBorder( false ),
  31. m_topBorder( false ),
  32. m_bottomBorder( false ),
  33. m_borderColor( KIGFX::COLOR4D::UNSPECIFIED )
  34. {
  35. this->Connect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) );
  36. }
  37. WX_PANEL::~WX_PANEL()
  38. {
  39. this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) );
  40. }
  41. void WX_PANEL::OnPaint( wxPaintEvent& event )
  42. {
  43. wxRect rect( wxPoint( 0, 0 ), GetClientSize() );
  44. wxPaintDC dc( this );
  45. KIGFX::COLOR4D border = m_borderColor;
  46. if( border == KIGFX::COLOR4D::UNSPECIFIED )
  47. {
  48. KIGFX::COLOR4D bg = wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK );
  49. KIGFX::COLOR4D fg = wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER );
  50. border = fg.Mix( bg, 0.18 );
  51. }
  52. dc.SetPen( wxPen( border.ToColour(), 1 ) );
  53. if( m_leftBorder )
  54. dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom() );
  55. if( m_rightBorder )
  56. dc.DrawLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom() );
  57. if( m_topBorder )
  58. dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetTop() );
  59. if( m_bottomBorder )
  60. dc.DrawLine( rect.GetLeft(), rect.GetBottom(), rect.GetRight(), rect.GetBottom() );
  61. }