Commit 6aabb9bc authored by Dick Hollenbeck's avatar Dick Hollenbeck

EDA_LIST_DIALOG_BASE is used multiple times for different numbers of

columns.  DIALOG_SHIM would resize each separate usage to the same
size.  DIALOG_SHIM now supports and alternate m_hash_key in lieu
of the class name, optionally.
parent 94db11a8
......@@ -46,7 +46,17 @@ static RECT_MAP class_map;
bool DIALOG_SHIM::Show( bool show )
{
bool ret;
const char* classname = typeid(*this).name();
const char* hash_key;
if( m_hash_key.size() )
{
// a special case like EDA_LIST_DIALOG, which has multiple uses.
hash_key = m_hash_key.c_str();
}
else
{
hash_key = typeid(*this).name();
}
// Show or hide the window. If hiding, save current position and size.
// If showing, use previous position and size.
......@@ -55,7 +65,7 @@ bool DIALOG_SHIM::Show( bool show )
ret = wxDialog::Show( show );
// classname is key, returns a zeroed out default EDA_RECT if none existed before.
EDA_RECT r = class_map[ classname ];
EDA_RECT r = class_map[ hash_key ];
if( r.GetSize().x != 0 && r.GetSize().y != 0 )
SetSize( r.GetPosition().x, r.GetPosition().y, r.GetSize().x, r.GetSize().y, 0 );
......@@ -64,7 +74,7 @@ bool DIALOG_SHIM::Show( bool show )
{
// Save the dialog's position & size before hiding, using classname as key
EDA_RECT r( wxDialog::GetPosition(), wxDialog::GetSize() );
class_map[ classname ] = r;
class_map[ hash_key ] = r;
ret = wxDialog::Show( show );
}
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -24,6 +24,7 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
bSizerLeft->Add( m_staticTextName, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCmpNameCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCmpNameCtrl->SetMaxLength( 0 );
bSizerLeft->Add( m_textCmpNameCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextHistory = new wxStaticText( this, wxID_ANY, _("History list:"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -63,6 +64,7 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
......
......@@ -20,8 +20,10 @@
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</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="minimum_size"></property>
<property name="name">DIALOG_GET_COMPONENT_BASE</property>
<property name="pos"></property>
<property name="size">375,210</property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title"></property>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
......@@ -57,7 +59,7 @@ class DIALOG_GET_COMPONENT_BASE : public DIALOG_SHIM
public:
DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 375,210 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_GET_COMPONENT_BASE();
};
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -29,10 +29,8 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
m_staticText2->Wrap( -1 );
bSizerMain->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 );
m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxVSCROLL );
m_listBox->SetMinSize( wxSize( 300,200 ) );
bSizerMain->Add( m_listBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL|wxALWAYS_SHOW_SB|wxVSCROLL );
bSizerMain->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextMsg = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextMsg->Wrap( -1 );
......@@ -41,7 +39,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
m_messages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_messages->SetMinSize( wxSize( -1,80 ) );
bSizerMain->Add( m_messages, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
......@@ -55,6 +53,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
......
......@@ -20,8 +20,10 @@
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
......@@ -32,7 +34,7 @@
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="event_handler">decl_pure_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
......@@ -42,7 +44,7 @@
<property name="minimum_size"></property>
<property name="name">EDA_LIST_DIALOG_BASE</property>
<property name="pos"></property>
<property name="size">329,398</property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title"></property>
......@@ -351,7 +353,7 @@
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property>
<property name="proportion">1</property>
<property name="proportion">3</property>
<object class="wxListCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
......@@ -385,7 +387,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">300,200</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_listBox</property>
<property name="pane_border">1</property>
......@@ -397,7 +399,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLC_REPORT</property>
<property name="style">wxLC_REPORT|wxLC_SINGLE_SEL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
......@@ -407,7 +409,7 @@
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxVSCROLL</property>
<property name="window_style">wxALWAYS_SHOW_SB|wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
......@@ -539,7 +541,7 @@
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -48,17 +48,17 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void onClose( wxCloseEvent& event ) { event.Skip(); }
virtual void textChangeInFilterBox( wxCommandEvent& event ) { event.Skip(); }
virtual void onListItemActivated( wxListEvent& event ) { event.Skip(); }
virtual void onListItemSelected( wxListEvent& event ) { event.Skip(); }
virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onClose( wxCloseEvent& event ) = 0;
virtual void textChangeInFilterBox( wxCommandEvent& event ) = 0;
virtual void onListItemActivated( wxListEvent& event ) = 0;
virtual void onListItemSelected( wxListEvent& event ) = 0;
virtual void onCancelClick( wxCommandEvent& event ) = 0;
virtual void onOkClick( wxCommandEvent& event ) = 0;
public:
EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 329,398 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~EDA_LIST_DIALOG_BASE();
};
......
......@@ -27,6 +27,7 @@
*/
#include <fctsys.h>
#include <macros.h>
#include <wxstruct.h>
#include <kicad_string.h>
#include <dialog_helpers.h>
......@@ -48,7 +49,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
wxListItem column;
column.SetId( i );
column.SetText( aItemHeaders.Item( i ) );
column.SetWidth( 300 / aItemHeaders.Count() );
m_listBox->InsertColumn( i, column );
}
......@@ -66,6 +66,13 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
}
}
// DIALOG_SHIM needs a unique hash_key because classname is not sufficient
// because so many dialogs share this same class.
m_hash_key = TO_UTF8( aTitle );
for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
m_listBox->SetColumnWidth( i, wxLIST_AUTOSIZE );
if( m_callBackFct == NULL )
{
m_messages->Show( false );
......@@ -74,9 +81,7 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
m_filterBox->SetFocus();
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
Layout();
}
......
......@@ -52,15 +52,20 @@ public:
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr );
const wxString& name = wxDialogNameStr
);
bool Show( bool show ); // overload wxDialog::Show
protected:
std::string m_hash_key; // alternate for class_map when classname re-used.
#if DLGSHIM_USE_SETFOCUS
private:
void onInit( wxInitDialogEvent& aEvent );
#endif
};
#endif // DIALOG_SHIM_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment