Scale list columns with dialog width.
Fixes https://gitlab.com/kicad/code/kicad/issues/13278
This commit is contained in:
parent
a18c2043c4
commit
542ff699cf
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 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
|
||||
|
@ -33,7 +33,7 @@
|
|||
// not, in repeatedly creating/destroying a wxDC to do the measurement in).
|
||||
// Use default column widths instead.
|
||||
static int DEFAULT_SINGLE_COL_WIDTH = 260;
|
||||
static int DEFAULT_COL_WIDTHS[] = { 200, 600 };
|
||||
static int DEFAULT_COL_WIDTHS[] = { 200, 300 };
|
||||
|
||||
|
||||
EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
|
||||
|
@ -55,9 +55,8 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
|
|||
|
||||
SetupStandardButtons();
|
||||
|
||||
// this line fixes an issue on Linux Ubuntu using Unity (dialog not shown),
|
||||
// and works fine on all systems
|
||||
GetSizer()->Fit( this );
|
||||
Layout();
|
||||
GetSizer()->Fit( this );
|
||||
|
||||
Centre();
|
||||
}
|
||||
|
@ -69,14 +68,20 @@ void EDA_LIST_DIALOG::initDialog( const wxArrayString& aItemHeaders, const wxStr
|
|||
{
|
||||
m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
|
||||
DEFAULT_SINGLE_COL_WIDTH );
|
||||
|
||||
m_listBox->SetMinClientSize( wxSize( DEFAULT_SINGLE_COL_WIDTH, 200 ) );
|
||||
SetMinClientSize( wxSize( DEFAULT_COL_WIDTHS[0], 220 ) );
|
||||
}
|
||||
else
|
||||
else if( aItemHeaders.Count() == 2 )
|
||||
{
|
||||
for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
|
||||
{
|
||||
m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
|
||||
DEFAULT_COL_WIDTHS[ i ] );
|
||||
}
|
||||
|
||||
m_listBox->SetMinClientSize( wxSize( DEFAULT_COL_WIDTHS[0] * 3, 200 ) );
|
||||
SetMinClientSize( wxSize( DEFAULT_COL_WIDTHS[0] * 2, 220 ) );
|
||||
}
|
||||
|
||||
InsertItems( m_itemsList, 0 );
|
||||
|
@ -222,6 +227,23 @@ void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void EDA_LIST_DIALOG::onSize( wxSizeEvent& event )
|
||||
{
|
||||
if( m_listBox->GetColumnCount() == 1 )
|
||||
{
|
||||
m_listBox->SetColumnWidth( 0, m_listBox->GetClientSize().x );
|
||||
}
|
||||
else if( m_listBox->GetColumnCount() == 2 )
|
||||
{
|
||||
int first = KiROUND( m_listBox->GetClientSize().x * 0.42 );
|
||||
m_listBox->SetColumnWidth( 0, first );
|
||||
m_listBox->SetColumnWidth( 1, m_listBox->GetClientSize().x - first );
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sort alphabetically, case insensitive.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bSizerMain;
|
||||
bSizerMain = new wxBoxSizer( wxVERTICAL );
|
||||
|
@ -56,6 +56,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
|
|||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_LIST_DIALOG_BASE::onSize ) );
|
||||
m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this );
|
||||
m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this );
|
||||
}
|
||||
|
@ -63,6 +64,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
|
|||
EDA_LIST_DIALOG_BASE::~EDA_LIST_DIALOG_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( EDA_LIST_DIALOG_BASE::onSize ) );
|
||||
m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this );
|
||||
m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this );
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="15" />
|
||||
<FileVersion major="1" minor="16" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
|
@ -14,6 +14,7 @@
|
|||
<property name="file">eda_list_dialog_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">eda_list_dialog_base</property>
|
||||
|
@ -25,6 +26,7 @@
|
|||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">0</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Dialog" expanded="1">
|
||||
|
@ -42,7 +44,7 @@
|
|||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="minimum_size">-1,-1</property>
|
||||
<property name="name">EDA_LIST_DIALOG_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size"></property>
|
||||
|
@ -50,9 +52,11 @@
|
|||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title"></property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnSize">onSize</event>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizerMain</property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -42,6 +42,7 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void onSize( wxSizeEvent& event ) = 0;
|
||||
virtual void onListItemActivated( wxListEvent& event ) = 0;
|
||||
virtual void textChangeInFilterBox( wxCommandEvent& event ) = 0;
|
||||
|
||||
|
@ -50,6 +51,7 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM
|
|||
wxBoxSizer* m_ButtonsSizer;
|
||||
|
||||
EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
|
||||
~EDA_LIST_DIALOG_BASE();
|
||||
|
||||
};
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
long GetSelection();
|
||||
|
||||
private:
|
||||
virtual void onSize( wxSizeEvent& event ) override;
|
||||
void onListItemActivated( wxListEvent& event ) override;
|
||||
void textChangeInFilterBox(wxCommandEvent& event) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue