KiCad PCB EDA Suite
eda_dockart.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 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 2
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 <eda_dockart.h>
25 #include <wx/aui/tabart.h>
26 #include <wx/aui/auibook.h>
27 //#include <class_draw_panel_gal.h>
28 //#include <class_drawpanel.h>
29 #include <draw_frame.h>
30 
31 void EDA_DOCKART::DrawBorder( wxDC& aDC, wxWindow* aWindow, const wxRect& aRect,
32  wxAuiPaneInfo& aPane )
33 {
34  const wxRect& r = aRect;
35  aDC.SetPen( m_borderPen );
36  aDC.SetBrush( *wxTRANSPARENT_BRUSH );
37 
38  // notebooks draw the border themselves, so they can use native rendering (e.g. tabartgtk)
39  wxAuiTabArt* art = nullptr;
40  wxAuiNotebook* nb = wxDynamicCast( aWindow, wxAuiNotebook );
41 
42  if( nb )
43  art = nb->GetArtProvider();
44 
45  if( art )
46  {
47  art->DrawBorder( aDC, aWindow, r );
48  }
49  else if( aPane.name == "DrawFrame" || aPane.name == "DrawFrameGal" )
50  {
51  // We don't want to re-write the layout manager, so we give the canvas a single-pixel
52  // border and then fill in the top and left with the canvas background colour.
53  //
54  // This achieves a right-bottom-bordered canvas, which works reasonably well with
55  // wxWidgets right-bottom bordered toolbars.
56 
57  //wxWindow* window = reinterpret_cast<wxWindow*>( m_frame->GetCanvas() );
58  //wxSize scrollbarSize = window->GetSize() - window->GetClientSize();
59  // Not sure why it takes a pen twice as wide as the border to fill it in, but it does.
60  #if 0
61  int borderWidth = GetMetric( wxAUI_DOCKART_PANE_BORDER_SIZE ) * 2;
62  int borderAdjust = borderWidth;
63 
64  aDC.SetPen( wxPen( m_frame->GetDrawBgColor().ToColour(), borderWidth ) );
65 
66  // Yes, this leaves me scratching my head too.
67  if( m_frame->IsType( FRAME_PCB )
71  || m_frame->IsType( FRAME_GERBER ) )
72  {
73  borderAdjust += 1;
74  }
75 
76  // left
77  aDC.DrawLine( r.x + 1, r.y, r.x + 1, r.y + r.height - borderAdjust - scrollbarSize.y );
78  // top
79  aDC.DrawLine( r.x + 1, r.y, r.x + r.width - borderAdjust - scrollbarSize.x, r.y );
80 
81  aDC.SetPen( m_borderPen );
82 
83  // finish off bottom of left side (at end of scrollbar)
84  aDC.DrawLine( r.x, r.y + r.height - 1 - scrollbarSize.y, r.x, r.y + r.height - 1 );
85  // right
86  aDC.DrawLine( r.x + r.width, r.y, r.x + r.width, r.y + r.height - 1 );
87  // bottom
88  aDC.DrawLine( r.x, r.y + r.height - 1, r.x + r.width - 1, r.y + r.height - 1 );
89  #endif
90  }
91  else
92  {
93  aDC.DrawRectangle( r );
94  }
95 }
96 
97 
EDA_DRAW_FRAME * m_frame
Definition: eda_dockart.h:38
void DrawBorder(wxDC &aDC, wxWindow *aWindow, const wxRect &r, wxAuiPaneInfo &aPane) override
Draw borders for Kicad AUI panes.
Definition: eda_dockart.cpp:31
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:375
bool IsType(FRAME_T aType) const