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.

178 lines
7.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
  5. * Copyright (C) 2013 CERN
  6. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * @file toolbars_pl_editor.cpp
  23. * @brief Build tool bars
  24. */
  25. #include <fctsys.h>
  26. #include <common.h>
  27. #include <macros.h>
  28. #include <bitmaps.h>
  29. #include <pl_editor_id.h>
  30. #include <pl_editor_frame.h>
  31. #include <hotkeys.h>
  32. void PL_EDITOR_FRAME::ReCreateHToolbar( void )
  33. {
  34. if( m_mainToolBar )
  35. m_mainToolBar->Clear();
  36. else
  37. m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  38. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  39. wxString msg;
  40. // Standard file commands
  41. m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  42. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  43. m_mainToolBar->AddTool( wxID_NEW, wxEmptyString, KiScaledBitmap( new_page_layout_xpm, this ),
  44. _( "New page layout design" ) );
  45. m_mainToolBar->AddTool( wxID_OPEN, wxEmptyString, KiScaledBitmap( open_page_layout_xpm, this ),
  46. _( "Open an existing page layout design file" ) );
  47. m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiScaledBitmap( save_xpm, this ),
  48. _( "Save page layout design" ) );
  49. KiScaledSeparator( m_mainToolBar, this );
  50. m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiScaledBitmap( sheetset_xpm, this ),
  51. _( "Page settings" ) );
  52. m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiScaledBitmap( print_button_xpm, this ),
  53. _( "Print page layout" ) );
  54. KiScaledSeparator( m_mainToolBar, this );
  55. m_mainToolBar->AddTool( wxID_CUT, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
  56. _( "Delete selected item" ) );
  57. KiScaledSeparator( m_mainToolBar, this );
  58. m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString,
  59. KiScaledBitmap( undo_xpm, this ), _( "Undo" ) );
  60. m_mainToolBar->AddTool( wxID_REDO, wxEmptyString,
  61. KiScaledBitmap( redo_xpm, this ), _( "Redo" ) );
  62. // Standard Zoom controls:
  63. m_mainToolBar->AddSeparator();
  64. msg = AddHotkeyName( _( "Redraw view" ), PlEditorHokeysDescr, HK_ZOOM_REDRAW, IS_COMMENT );
  65. m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
  66. KiScaledBitmap( zoom_redraw_xpm, this ), msg );
  67. msg = AddHotkeyName( _( "Zoom in" ), PlEditorHokeysDescr, HK_ZOOM_IN, IS_COMMENT );
  68. m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
  69. msg = AddHotkeyName( _( "Zoom out" ), PlEditorHokeysDescr, HK_ZOOM_OUT, IS_COMMENT );
  70. m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
  71. msg = AddHotkeyName( _( "Zoom to fit page" ), PlEditorHokeysDescr, HK_ZOOM_AUTO, IS_COMMENT );
  72. m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
  73. KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
  74. // Zoom-to-selection
  75. m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
  76. _( "Zoom to selection" ), wxITEM_CHECK );
  77. // Display mode switch
  78. KiScaledSeparator( m_mainToolBar, this );
  79. m_mainToolBar->AddTool( ID_SHOW_REAL_MODE, wxEmptyString,
  80. KiScaledBitmap( pagelayout_normal_view_mode_xpm, this ),
  81. _( "Show title block like it will be displayed in applications\n"
  82. "texts with format are replaced by the full text"),
  83. wxITEM_CHECK );
  84. m_mainToolBar->AddTool( ID_SHOW_PL_EDITOR_MODE,
  85. wxEmptyString, KiScaledBitmap( pagelayout_special_view_mode_xpm, this ),
  86. _( "Show title block in edit mode: texts are shown as is:\n"
  87. "texts with format are displayed with no change"),
  88. wxITEM_CHECK );
  89. KiScaledSeparator( m_mainToolBar, this );
  90. wxString choiceList[5] =
  91. {
  92. _("Left Top paper corner"),
  93. _("Right Bottom page corner"),
  94. _("Left Bottom page corner"),
  95. _("Right Top page corner"),
  96. _("Left Top page corner")
  97. };
  98. m_originSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_COORDINATE_ORIGIN,
  99. wxDefaultPosition, wxDefaultSize,
  100. 5, choiceList );
  101. m_mainToolBar->AddControl( m_originSelectBox );
  102. m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
  103. int minwidth = 0;
  104. for( int ii = 0; ii < 5; ii++ )
  105. {
  106. int width = GetTextSize( choiceList[ii], m_originSelectBox ).x;
  107. minwidth = std::max( minwidth, width );
  108. }
  109. m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
  110. m_originSelectBox->SetSelection( m_originSelectChoice );
  111. wxString pageList[5] =
  112. {
  113. _("Page 1"),
  114. _("Other pages")
  115. };
  116. m_pageSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_PAGE_NUMBER,
  117. wxDefaultPosition, wxDefaultSize,
  118. 2, pageList );
  119. m_mainToolBar->AddControl( m_pageSelectBox );
  120. m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
  121. "which are not on all page are displayed") );
  122. m_pageSelectBox->SetSelection( 0 );
  123. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  124. m_mainToolBar->Realize();
  125. }
  126. void PL_EDITOR_FRAME::ReCreateVToolbar( void )
  127. {
  128. if( m_drawToolBar )
  129. m_drawToolBar->Clear();
  130. else
  131. m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  132. KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
  133. // Set up toolbar
  134. m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString,
  135. KiScaledBitmap( cursor_xpm, this ) );
  136. KiScaledSeparator( m_drawToolBar, this );
  137. m_drawToolBar->Realize();
  138. }
  139. void PL_EDITOR_FRAME::ReCreateOptToolbar( void )
  140. {
  141. }