diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-09-27 09:38:41 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:54 +0100 |
commit | be23f7fbb872eb9e1151a722348b039bc65ea4cb (patch) | |
tree | a6d16fcd82286ff429c20fdad7642d64b9db7326 /vcl | |
parent | 0c430547d8eaca42e0a4875c9a201c202f1d2aa6 (diff) |
sort child positions within parents according to grid position
so that tabbing between widgets jumps between then in a sensible
order
Change-Id: I852f4fb08781da2b703f8f87e84abdf4c366fa26
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/builder.hxx | 28 | ||||
-rw-r--r-- | vcl/inc/vcl/layout.hxx | 28 | ||||
-rw-r--r-- | vcl/source/uipreviewer/previewer.cxx | 27 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 65 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 27 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 4 |
6 files changed, 47 insertions, 132 deletions
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index bd5cd6e535d8..a84f6d10285c 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -1,30 +1,12 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * This file is part of the LibreOffice project. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Initial Developer of the Original Code is - * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) - * Portions created by the Initial Developer are Copyright (C) 2011 the - * Initial Developer. All Rights Reserved. - * - * Contributor(s): Caolán McNamara <caolanm@redhat.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + #ifndef _VCLBUILDER_HXX #define _VCLBUILDER_HXX diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index 47355283f68a..9e869a3ae258 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -1,30 +1,12 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * This file is part of the LibreOffice project. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Initial Developer of the Original Code is - * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) - * Portions created by the Initial Developer are Copyright (C) 2011 the - * Initial Developer. All Rights Reserved. - * - * Contributor(s): Caolán McNamara <caolanm@redhat.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + #ifndef _VCLLAYOUT_HXX #define _VCLLAYOUT_HXX diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx index 42c035333575..24329863f6df 100644 --- a/vcl/source/uipreviewer/previewer.cxx +++ b/vcl/source/uipreviewer/previewer.cxx @@ -1,29 +1,10 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * This file is part of the LibreOffice project. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Initial Developer of the Original Code is - * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) - * Portions created by the Initial Developer are Copyright (C) 2011 the - * Initial Developer. All Rights Reserved. - * - * Contributor(s): Caolán McNamara <caolanm@redhat.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <com/sun/star/lang/XComponent.hpp> diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 31e72ceb0a82..33e43b606279 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1,29 +1,10 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * This file is part of the LibreOffice project. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Initial Developer of the Original Code is - * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) - * Portions created by the Initial Developer are Copyright (C) 2012 the - * Initial Developer. All Rights Reserved. - * - * Contributor(s): Caolán McNamara <caolanm@redhat.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <osl/module.hxx> @@ -767,6 +748,22 @@ void VclBuilder::handleTabChild(Window *pParent, xmlreader::XmlReader &reader) pTabControl->RemovePage(pTabControl->GetCurPageId()); } +namespace +{ + bool sortByGridPositions(Window *pA, Window *pB) + { + sal_Int32 nTopA = pA->get_grid_top_attach(); + sal_Int32 nTopB = pB->get_grid_top_attach(); + if (nTopA < nTopB) + return true; + if (nTopA > nTopB) + return false; + sal_Int32 nLeftA = pA->get_grid_left_attach(); + sal_Int32 nLeftB = pB->get_grid_left_attach(); + return nLeftA < nLeftB; + } +} + void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader) { Window *pCurrentChild = NULL; @@ -818,8 +815,6 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader) { //To-Do make reorder a virtual in Window, move this foo //there and see above - - rtl::OString sPosition(RTL_CONSTASCII_STRINGPARAM("position")); std::vector<Window*> aChilds; for (Window* pChild = pCurrentChild->GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT)) @@ -827,26 +822,20 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader) aChilds.push_back(pChild); } + //sort child order within parent list by grid position + //so that tabbing between controls goes in a visually sensible sequence + std::stable_sort(aChilds.begin(), aChilds.end(), sortByGridPositions); for (size_t i = 0; i < aChilds.size(); ++i) - { - sal_Int32 nPosition = get_window_packing_position(aChilds[i]); - if (nPosition == -1) - continue; - reorderWithinParent(*aChilds[i], nPosition); - } + reorderWithinParent(*aChilds[i], i); -#if TODO -//sort by ltr ttb - rtl::OString sLeftAttach(RTL_CONSTASCII_STRINGPARAM("left-attach")); - rtl::OString sTopAttach(RTL_CONSTASCII_STRINGPARAM("top-attach")); + //honour box positions if there is any for (size_t i = 0; i < aChilds.size(); ++i) { - sal_uInt16 nPosition = aChilds[i]->getWidgetProperty<sal_uInt16>(sPosition, 0xFFFF); - if (nPosition == 0xFFFF) + sal_Int32 nPosition = get_window_packing_position(aChilds[i]); + if (nPosition == -1) continue; reorderWithinParent(*aChilds[i], nPosition); } -#endif } } } diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index d20cede3101c..b125c2dab2af 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1,29 +1,10 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * This file is part of the LibreOffice project. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Initial Developer of the Original Code is - * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) - * Portions created by the Initial Developer are Copyright (C) 2011 the - * Initial Developer. All Rights Reserved. - * - * Contributor(s): Caolán McNamara <caolanm@redhat.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <vcl/dialog.hxx> diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 07311a980058..d874d811527b 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -640,8 +640,8 @@ void Window::ImplInitWindowData( WindowType nType ) mpWindowImpl->mePackType = VCL_PACK_START; mpWindowImpl->mnPadding = 0; mpWindowImpl->mnGridHeight = 1; - mpWindowImpl->mnGridLeftAttach = 0; - mpWindowImpl->mnGridTopAttach = 0; + mpWindowImpl->mnGridLeftAttach = -1; + mpWindowImpl->mnGridTopAttach = -1; mpWindowImpl->mnGridWidth = 1; mpWindowImpl->mnBorderWidth = 0; mpWindowImpl->mnMarginLeft = 0; |