Browse Source

Insert a cover for wxBitmapCombobox.

(This will allow us to hack-fix wxWidgets' bug
for determining the height when fonts are scaled.
This commit includes such a fix, but I have no
idea if this particular one will work or not.)
pull/18/head
Jeff Young 6 months ago
parent
commit
8dadbc1c5c
  1. 1
      common/CMakeLists.txt
  2. 52
      common/widgets/wx_bitmap_combobox.cpp
  3. 4
      eeschema/dialogs/dialog_pin_properties_base.cpp
  4. 2
      eeschema/dialogs/dialog_pin_properties_base.fbp
  5. 4
      eeschema/dialogs/dialog_pin_properties_base.h
  6. 7
      eeschema/widgets/pinshape_combobox.cpp
  7. 4
      eeschema/widgets/pinshape_combobox.h
  8. 7
      eeschema/widgets/pintype_combobox.cpp
  9. 6
      eeschema/widgets/pintype_combobox.h
  10. 42
      include/widgets/wx_bitmap_combobox.h

1
common/CMakeLists.txt

@ -436,6 +436,7 @@ endif()
set( COMMON_WIDGET_SRCS
widgets/app_progress_dialog.cpp
widgets/wx_bitmap_combobox.cpp
widgets/bitmap_toggle.cpp
widgets/button_row_panel.cpp
widgets/color_swatch.cpp

52
common/widgets/wx_bitmap_combobox.cpp

@ -0,0 +1,52 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright The KiCad Developers, see AUTHORS.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 3
* 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 <widgets/wx_bitmap_combobox.h>
#include <wx/textctrl.h>
WX_BITMAP_COMBOBOX::WX_BITMAP_COMBOBOX( wxWindow* parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, int n,
const wxString choices[], long style,
const wxValidator& validator, const wxString& name ) :
wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
{
}
wxSize WX_BITMAP_COMBOBOX::DoGetBestSize() const
{
wxSize size = wxBitmapComboBox::DoGetBestSize();
#ifdef __WXGTK__
// wxWidgets has a bug on GTK where the wxBitmapComboBox doesn't scale correctly with scaled
// fonts. This is a bit of a hack to get around it.
wxTextCtrl dummyCtrl( m_parent, wxID_ANY );
int dummyWidth = 100;
size.y = std::max( size.y, dummyCtrl.GetBestHeight( dummyWidth ) );
#endif
return size;
}

4
eeschema/dialogs/dialog_pin_properties_base.cpp

@ -8,9 +8,9 @@
#include "pinshape_combobox.h"
#include "pintype_combobox.h"
#include "widgets/std_bitmap_button.h"
#include "widgets/wx_bitmap_combobox.h"
#include "widgets/wx_grid.h"
#include "widgets/wx_infobar.h"
#include "wx/bmpcbox.h"
#include "dialog_pin_properties_base.h"
@ -114,7 +114,7 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind
m_staticTextOrient->Wrap( -1 );
gbSizer1->Add( m_staticTextOrient, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_choiceOrientation = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_READONLY );
m_choiceOrientation = new WX_BITMAP_COMBOBOX( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_READONLY );
gbSizer1->Add( m_choiceOrientation, wxGBPosition( 6, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_posXUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 );

2
eeschema/dialogs/dialog_pin_properties_base.fbp

@ -1487,7 +1487,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxCB_DROPDOWN|wxCB_READONLY</property>
<property name="subclass">wxBitmapComboBox; wx/bmpcbox.h</property>
<property name="subclass">WX_BITMAP_COMBOBOX; widgets/wx_bitmap_combobox.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>

4
eeschema/dialogs/dialog_pin_properties_base.h

@ -13,9 +13,9 @@
class PINSHAPE_COMBOBOX;
class PINTYPE_COMBOBOX;
class STD_BITMAP_BUTTON;
class WX_BITMAP_COMBOBOX;
class WX_GRID;
class WX_INFOBAR;
class wxBitmapComboBox;
#include "dialog_shim.h"
#include <wx/infobar.h>
@ -70,7 +70,7 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextGstyle;
PINSHAPE_COMBOBOX* m_choiceStyle;
wxStaticText* m_staticTextOrient;
wxBitmapComboBox* m_choiceOrientation;
WX_BITMAP_COMBOBOX* m_choiceOrientation;
wxStaticText* m_posXUnits;
wxStaticText* m_posYUnits;
wxStaticText* m_pinLengthUnits;

7
eeschema/widgets/pinshape_combobox.cpp

@ -23,15 +23,14 @@
*/
#include "pinshape_combobox.h"
#include <bitmaps.h>
#include <sch_pin.h>
PINSHAPE_COMBOBOX::PINSHAPE_COMBOBOX( wxWindow* parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, int n,
const wxString choices[], long style,
const wxValidator& validator, const wxString& name ) :
wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
WX_BITMAP_COMBOBOX( parent, id, value, pos, size, n, choices, style, validator, name )
{
for( unsigned ii = 0; ii < GRAPHIC_PINSHAPES_TOTAL; ++ii )
{
@ -56,5 +55,5 @@ GRAPHIC_PINSHAPE PINSHAPE_COMBOBOX::GetPinShapeSelection()
void PINSHAPE_COMBOBOX::SetSelection( GRAPHIC_PINSHAPE aShape )
{
wxBitmapComboBox::SetSelection( static_cast<int>( aShape ) );
WX_BITMAP_COMBOBOX::SetSelection( static_cast<int>( aShape ) );
}

4
eeschema/widgets/pinshape_combobox.h

@ -22,10 +22,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/bmpcbox.h>
#include <widgets/wx_bitmap_combobox.h>
#include <pin_type.h>
class PINSHAPE_COMBOBOX : public wxBitmapComboBox
class PINSHAPE_COMBOBOX : public WX_BITMAP_COMBOBOX
{
public:
PINSHAPE_COMBOBOX( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString,

7
eeschema/widgets/pintype_combobox.cpp

@ -23,15 +23,14 @@
*/
#include "pintype_combobox.h"
#include <bitmaps.h>
#include <sch_pin.h>
PINTYPE_COMBOBOX::PINTYPE_COMBOBOX( wxWindow* parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, int n,
const wxString choices[], long style,
const wxValidator& validator, const wxString& name ) :
wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
WX_BITMAP_COMBOBOX( parent, id, value, pos, size, n, choices, style, validator, name )
{
for( unsigned ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ++ii )
{
@ -56,5 +55,5 @@ ELECTRICAL_PINTYPE PINTYPE_COMBOBOX::GetPinTypeSelection()
void PINTYPE_COMBOBOX::SetSelection( ELECTRICAL_PINTYPE aType )
{
wxBitmapComboBox::SetSelection( static_cast<int>( aType ) );
WX_BITMAP_COMBOBOX::SetSelection( static_cast<int>( aType ) );
}

6
eeschema/widgets/pintype_combobox.h

@ -22,11 +22,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/bmpcbox.h>
#include <widgets/wx_bitmap_combobox.h>
#include <pin_type.h>
class PINTYPE_COMBOBOX : public wxBitmapComboBox
class PINTYPE_COMBOBOX : public WX_BITMAP_COMBOBOX
{
public:
PINTYPE_COMBOBOX( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString,
@ -36,7 +35,6 @@ public:
const wxString& name = wxBitmapComboBoxNameStr );
ELECTRICAL_PINTYPE GetPinTypeSelection();
void SetSelection( ELECTRICAL_PINTYPE aType );
private:

42
include/widgets/wx_bitmap_combobox.h

@ -0,0 +1,42 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright The KiCad Developers, see AUTHORS.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 3
* 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 WX_BITMAP_COMBOBOX_H
#define WX_BITMAP_COMBOBOX_H
#include <wx/bmpcbox.h>
class WX_BITMAP_COMBOBOX : public wxBitmapComboBox
{
public:
WX_BITMAP_COMBOBOX( wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR( wxBitmapComboBoxNameStr ) );
wxSize DoGetBestSize() const override;
};
#endif //WX_BITMAP_COMBOBOX_H
Loading…
Cancel
Save