diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 915acb7e7c..d6b835ac2d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -225,6 +225,7 @@ set( COMMON_WIDGET_SRCS widgets/paged_dialog.cpp widgets/progress_reporter.cpp widgets/stepped_slider.cpp + widgets/tab_traversal.cpp widgets/text_ctrl_eval.cpp widgets/two_column_tree_list.cpp widgets/ui_common.cpp diff --git a/common/widgets/tab_traversal.cpp b/common/widgets/tab_traversal.cpp new file mode 100644 index 0000000000..deef3080b4 --- /dev/null +++ b/common/widgets/tab_traversal.cpp @@ -0,0 +1,33 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + + +void KIUI::SetControlsTabOrder( const std::vector& aControlsInTabOrder ) +{ + for( unsigned i = 1; i < aControlsInTabOrder.size(); ++i ) + { + aControlsInTabOrder[i]->MoveAfterInTabOrder( aControlsInTabOrder[i - 1] ); + } +} diff --git a/eeschema/dialogs/dialog_sch_sheet_props.cpp b/eeschema/dialogs/dialog_sch_sheet_props.cpp index 3d622c59be..af85a7c9a5 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 2014-2018 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2019 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,12 +22,18 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include #include + +#include + +#include #include #include -#include + +#include + +#include + DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* parent, SCH_SHEET* aSheet ) : DIALOG_SCH_SHEET_PROPS_BASE( parent ), @@ -39,6 +45,17 @@ DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* parent, SCH_SHEE m_textFileName->SetFocus(); m_sdbSizer1OK->SetDefault(); + // Normally, the file and sheet name are the "main" edited fields + // so put them first + KIUI::SetControlsTabOrder( { + m_textFileName, + m_textSheetName, + m_filenameSizeCtrl, + m_sheetnameSizeCtrl, + } ); + + SetInitialFocus( m_textFileName ); + // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); diff --git a/include/widgets/tab_traversal.h b/include/widgets/tab_traversal.h new file mode 100644 index 0000000000..7ba3b7dbe5 --- /dev/null +++ b/include/widgets/tab_traversal.h @@ -0,0 +1,55 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef WIDGETS_TAB_TRAVERSAL__H +#define WIDGETS_TAB_TRAVERSAL__H + +/** + * @file + * Functions for manipulating tab traversal in forms and dialogs. + */ + +#include + +#include + +namespace KIUI +{ + +/** + * Set a list of controls to have a defined sequential tab order. + * + * Each control in the list will come after the previous one. The first control will + * keep its current position. The end result will be that the given control + * will be sequential when tabbed though. + * + * This can be slightly clearer than manually calling MoveAfterInTabOrder + * on each control in turn. + * + * @param aControlsInTabOrder list of controls (wxWindows) in desired tab order + */ +void SetControlsTabOrder( const std::vector& aControlsInTabOrder ); + +} // namespace KIUI + +#endif // WIDGETS_TAB_TRAVERSAL__H \ No newline at end of file diff --git a/pcbnew/dialogs/dialog_move_exact.cpp b/pcbnew/dialogs/dialog_move_exact.cpp index e302217c83..28d30c1045 100644 --- a/pcbnew/dialogs/dialog_move_exact.cpp +++ b/pcbnew/dialogs/dialog_move_exact.cpp @@ -22,9 +22,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include -#include "dialog_move_exact.h" +#include + +#include // initialise statics DIALOG_MOVE_EXACT::MOVE_EXACT_OPTIONS DIALOG_MOVE_EXACT::m_options; @@ -41,8 +43,12 @@ DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, wxPoint& aTransla m_rotate( aParent, m_rotLabel, m_rotEntry, m_rotUnit ) { // tabbing goes through the entries in sequence - m_yEntry->MoveAfterInTabOrder( m_xEntry ); - m_rotEntry->MoveAfterInTabOrder( m_yEntry ); + KIUI::SetControlsTabOrder( { + m_xEntry, + m_yEntry, + m_rotEntry, + m_anchorOptions, + } ); updateDialogControls( m_options.polarCoords ); diff --git a/pcbnew/dialogs/dialog_move_exact.h b/pcbnew/dialogs/dialog_move_exact.h index cc1d522437..2b70373368 100644 --- a/pcbnew/dialogs/dialog_move_exact.h +++ b/pcbnew/dialogs/dialog_move_exact.h @@ -28,7 +28,10 @@ #include #include -#include +#include + + +class PCB_BASE_FRAME; enum ROTATION_ANCHOR diff --git a/pcbnew/dialogs/dialog_position_relative.cpp b/pcbnew/dialogs/dialog_position_relative.cpp index a19e8c0acb..b616690a13 100644 --- a/pcbnew/dialogs/dialog_position_relative.cpp +++ b/pcbnew/dialogs/dialog_position_relative.cpp @@ -21,10 +21,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include "tools/pcb_actions.h" +#include -#include "dialog_position_relative.h" +#include + +#include + +#include // initialise statics DIALOG_POSITION_RELATIVE::POSITION_RELATIVE_OPTIONS DIALOG_POSITION_RELATIVE::m_options; @@ -40,7 +43,12 @@ DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent, wxP m_yOffset( aParent, m_yLabel, m_yEntry, m_yUnit ) { // tabbing goes through the entries in sequence - m_yEntry->MoveAfterInTabOrder( m_xEntry ); + KIUI::SetControlsTabOrder( { + m_xEntry, + m_yEntry, + } ); + + SetInitialFocus( m_xEntry ); // and set up the entries according to the saved options m_polarCoords->SetValue( m_options.polarCoords );