kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24746
Re: Toolbar Overflows
-
To:
kicad-developers@xxxxxxxxxxxxxxxxxxx
-
From:
jp charras <jp.charras@xxxxxxxxxx>
-
Date:
Sat, 21 May 2016 09:41:52 +0200
-
In-reply-to:
<CAJQyTMCYdwD6-=crWfe5EpKMUsVrCtLfP_wPe3zSWiF_PA655Q@mail.gmail.com>
-
User-agent:
Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Thunderbird/45.1.0
Le 20/05/2016 à 23:51, Simon Wells a écrit :
> Attached is a patch that enables the overflow item in pcbnew options
> toolbar (the one on the left). Enabling it on the other toolbars is
> easily done if this one works correctly
>
> This has only been tested on osx so it would be helpful if a win and
> linux user could test it and let me know of any issues you find.
>
Tested in W7 32 bits, works fine after a small change in toolbar_art.cpp
Attached the modified file.
Thanks.
--
Jean-Pierre CHARRAS
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 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 <wx/menu.h>
#include <toolbar_art.h>
int TOOLBAR_ART::ShowDropDown( wxWindow* aWindow, const wxAuiToolBarItemArray& aItems )
{
wxMenu menuPopup;
size_t items_added = 0;
size_t i, count = aItems.GetCount();
for( i = 0; i < count; ++i )
{
wxAuiToolBarItem& item = aItems.Item( i );
wxString text;
wxMenuItem* m;
switch( item.GetKind() )
{
case wxITEM_NORMAL:
text = item.GetShortHelp();
if ( text.empty() )
text = item.GetLabel();
if ( text.empty() )
text = "";
m = new wxMenuItem( &menuPopup, item.GetId(), text, item.GetShortHelp() );
m->SetBitmap( item.GetBitmap() );
menuPopup.Append( m );
items_added++;
break;
case wxITEM_CHECK:
text = item.GetShortHelp();
if ( text.empty() )
text = item.GetLabel();
if ( text.empty() )
text = "";
m = new wxMenuItem( &menuPopup, item.GetId(), text, item.GetShortHelp(), wxITEM_CHECK );
#if defined( __WINDOWS__ )
m->SetBitmaps( item.GetBitmap(), item.GetDisabledBitmap() );
// A workaround to a strange bug on Windows, wxWidgets 3.0 (and 3.1):
// size of bitmaps is not taken in account for wxITEM_CHECK menu
// unless we call SetFont
m->SetFont(*wxNORMAL_FONT);
#else
m->SetBitmap( item.GetBitmap() );
#endif
menuPopup.Append( m );
m->Check( item.GetState() );
items_added++;
break;
case wxITEM_SEPARATOR:
if( items_added > 0 )
menuPopup.AppendSeparator();
break;
default:
break;
}
}
// find out where to put the popup menu of window items
wxPoint pt = ::wxGetMousePosition();
pt = aWindow->ScreenToClient( pt );
// find out the screen coordinate at the bottom of the tab ctrl
wxRect cli_rect = aWindow->GetClientRect();
pt.y = cli_rect.y + cli_rect.height;
aWindow->PopupMenu( &menuPopup, pt );
// Return -1 because otherwise the wxCommandEvent handler will break wxITEM_CHECK
return -1;
}
Follow ups
References