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.

97 lines
3.6 KiB

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