Symbol chooser: base default size on font for DPI flexibility
This commit is contained in:
parent
aeefa45608
commit
57fe3739ca
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2012-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2012-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -100,6 +100,7 @@ DIALOG_SHIM::~DIALOG_SHIM()
|
||||||
delete m_qmodal_parent_disabler; // usually NULL by now
|
delete m_qmodal_parent_disabler; // usually NULL by now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_SHIM::FinishDialogSettings()
|
void DIALOG_SHIM::FinishDialogSettings()
|
||||||
{
|
{
|
||||||
// must be called from the constructor of derived classes,
|
// must be called from the constructor of derived classes,
|
||||||
|
@ -114,6 +115,13 @@ void DIALOG_SHIM::FinishDialogSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DIALOG_SHIM::SetSizeInChars( int x, int y )
|
||||||
|
{
|
||||||
|
auto text_sz = GetTextExtent( "X" );
|
||||||
|
SetSize( x * text_sz.x, y * text_sz.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// our hashtable is an implementation secret, don't need or want it in a header file
|
// our hashtable is an implementation secret, don't need or want it in a header file
|
||||||
#include <hashtables.h>
|
#include <hashtables.h>
|
||||||
#include <base_struct.h> // EDA_RECT
|
#include <base_struct.h> // EDA_RECT
|
||||||
|
|
|
@ -48,10 +48,12 @@
|
||||||
FOOTPRINT_ASYNC_LOADER DIALOG_CHOOSE_COMPONENT::m_fp_loader;
|
FOOTPRINT_ASYNC_LOADER DIALOG_CHOOSE_COMPONENT::m_fp_loader;
|
||||||
std::unique_ptr<FOOTPRINT_LIST> DIALOG_CHOOSE_COMPONENT::m_fp_list;
|
std::unique_ptr<FOOTPRINT_LIST> DIALOG_CHOOSE_COMPONENT::m_fp_list;
|
||||||
|
|
||||||
|
wxSize DIALOG_CHOOSE_COMPONENT::m_default_size( -1, -1 );
|
||||||
|
|
||||||
DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
||||||
CMP_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert, bool aAllowFieldEdits,
|
CMP_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert, bool aAllowFieldEdits,
|
||||||
bool aShowFootprints )
|
bool aShowFootprints )
|
||||||
: DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxSize( 800, 650 ),
|
: DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
|
||||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
|
||||||
m_fp_sel_ctrl( nullptr ),
|
m_fp_sel_ctrl( nullptr ),
|
||||||
m_fp_view_ctrl( nullptr ),
|
m_fp_view_ctrl( nullptr ),
|
||||||
|
@ -120,6 +122,19 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
|
||||||
EVT_FOOTPRINT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnFootprintSelected, this );
|
EVT_FOOTPRINT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnFootprintSelected, this );
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
|
if( m_default_size == wxSize( -1, -1 ) )
|
||||||
|
{
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
SetSizeInChars( 60, 32 );
|
||||||
|
#else
|
||||||
|
SetSizeInChars( 80, 32 );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetSize( m_default_size );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,6 +146,8 @@ DIALOG_CHOOSE_COMPONENT::~DIALOG_CHOOSE_COMPONENT()
|
||||||
Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this );
|
Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this );
|
||||||
|
|
||||||
delete m_dbl_click_timer;
|
delete m_dbl_click_timer;
|
||||||
|
|
||||||
|
m_default_size = GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,8 @@ protected:
|
||||||
static FOOTPRINT_ASYNC_LOADER m_fp_loader;
|
static FOOTPRINT_ASYNC_LOADER m_fp_loader;
|
||||||
static std::unique_ptr<FOOTPRINT_LIST> m_fp_list;
|
static std::unique_ptr<FOOTPRINT_LIST> m_fp_list;
|
||||||
std::vector<std::pair<int, wxString>> m_field_edits;
|
std::vector<std::pair<int, wxString>> m_field_edits;
|
||||||
|
|
||||||
|
static wxSize m_default_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DIALOG_CHOOSE_COMPONENT_H */
|
#endif /* DIALOG_CHOOSE_COMPONENT_H */
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2012-2016 KiCad Developers, see CHANGELOG.TXT for contributors.
|
* Copyright (C) 2012-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -127,6 +127,15 @@ protected:
|
||||||
*/
|
*/
|
||||||
void FinishDialogSettings();
|
void FinishDialogSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the dialog to given dimensions in character widths and heights.
|
||||||
|
* This is useful for dialogs with highly flexible sizes, like the symbol chooser,
|
||||||
|
* where standard methods of computing default dialog sizes are a bit useless.
|
||||||
|
*
|
||||||
|
* This should be called at the end of the constructor.
|
||||||
|
*/
|
||||||
|
void SetSizeInChars( int x, int y );
|
||||||
|
|
||||||
bool m_fixupsRun;
|
bool m_fixupsRun;
|
||||||
|
|
||||||
std::string m_hash_key; // alternate for class_map when classname re-used.
|
std::string m_hash_key; // alternate for class_map when classname re-used.
|
||||||
|
|
Loading…
Reference in New Issue