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.

130 lines
3.9 KiB

15 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004-2012 Jean-Pierre Charras
  5. * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file commandframe.cpp
  26. * @brief Frame showing fast launch buttons and messages box
  27. */
  28. #include <bitmaps.h>
  29. #include "kicad.h"
  30. // Amount of clearance between tool buttons
  31. const int BUTTON_SEPARATION = 5;
  32. // Buttons are larger than images by this amount
  33. const int BUTTON_EXPANSION = 6;
  34. LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) :
  35. wxPanel( parent, wxID_ANY )
  36. {
  37. // Add bitmap buttons to launch KiCad utilities:
  38. CreateCommandToolbar();
  39. }
  40. int LAUNCHER_PANEL::GetPanelHeight() const
  41. {
  42. return m_height + 2 * BUTTON_SEPARATION;
  43. }
  44. int LAUNCHER_PANEL::GetPanelWidth() const
  45. {
  46. return m_width + BUTTON_SEPARATION;
  47. }
  48. /**
  49. * Add application launcher buttons
  50. * e.g. Eeschema, CvPcb, Pcbnew, GerbView
  51. */
  52. void LAUNCHER_PANEL::CreateCommandToolbar()
  53. {
  54. m_buttonSizer = new wxBoxSizer( wxHORIZONTAL );
  55. AddButton( ID_TO_SCH,
  56. KiBitmap( icon_eeschema_xpm ),
  57. _( "Schematic layout editor" ) );
  58. AddButton( ID_TO_SCH_LIB_EDITOR,
  59. KiBitmap( icon_libedit_xpm ),
  60. _( "Schematic library editor" ) );
  61. AddButton( ID_TO_PCB,
  62. KiBitmap( icon_pcbnew_xpm ),
  63. _( "PCB layout editor" ) );
  64. AddButton( ID_TO_PCB_FP_EDITOR,
  65. KiBitmap( icon_modedit_xpm ),
  66. _( "PCB library editor" ) );
  67. AddButton( ID_TO_GERBVIEW,
  68. KiBitmap( icon_gerbview_xpm ),
  69. _( "Gerber viewer" ) );
  70. AddButton( ID_TO_BITMAP_CONVERTER,
  71. KiBitmap( icon_bitmap2component_xpm ),
  72. _( "Import bitmap\n"
  73. "Convert bitmap images to schematic or PCB elements" ) );
  74. AddButton( ID_TO_PCB_CALCULATOR,
  75. KiBitmap( icon_pcbcalculator_xpm ),
  76. _( "Calculator tools" ) );
  77. AddButton( ID_TO_PL_EDITOR,
  78. KiBitmap( icon_pagelayout_editor_xpm ),
  79. _( "Worksheet layout editor" ) );
  80. // Add a stretchy spacer to make button bar fill the entire screen
  81. m_buttonSizer->AddStretchSpacer();
  82. SetSizer( m_buttonSizer );
  83. }
  84. /**
  85. * Add a single button to the toolbar
  86. * @param aId is the ID of the button
  87. * @param aBitmap is the image to be used
  88. * @param aToolTip is the button mouse-over tool tip
  89. */
  90. void LAUNCHER_PANEL::AddButton( wxWindowID aId, const wxBitmap& aBitmap, wxString aToolTip )
  91. {
  92. wxSize buttSize( aBitmap.GetWidth() + 2 * BUTTON_EXPANSION,
  93. aBitmap.GetHeight() + 2 * BUTTON_EXPANSION );
  94. if( m_height < buttSize.y )
  95. m_height = buttSize.y;
  96. m_width += buttSize.x + BUTTON_SEPARATION;
  97. auto btn = new wxBitmapButton( this, aId, aBitmap, wxDefaultPosition, buttSize );
  98. btn->SetToolTip( aToolTip );
  99. m_buttonSizer->Add( btn,
  100. 0,
  101. wxALL | wxEXPAND,
  102. BUTTON_SEPARATION );
  103. }