From 47dfabc6c8a800f265a17d76271e57e0d0dd693b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 11 Jan 2018 09:08:55 +0100 Subject: [PATCH] Add size control to HTML_MESSAGE_BOX. Fix incorrect default size of a few dialogs. Clean code: remove useless code and not used parameters. --- common/confirm.cpp | 10 ---------- common/dialog_about/dialog_about.cpp | 4 ++-- common/dialogs/dialog_env_var_config.cpp | 12 ++++++++++-- common/dialogs/dialog_hotkeys_editor.cpp | 2 +- common/hotkeys_basic.cpp | 5 +++-- common/html_messagebox.cpp | 10 ++++++---- eeschema/dialogs/dialog_bom.cpp | 4 ++-- .../dialogs/dialog_edit_components_libid.cpp | 2 +- include/confirm.h | 10 +--------- include/html_messagebox.h | 17 ++++++++++++++--- 10 files changed, 40 insertions(+), 36 deletions(-) diff --git a/common/confirm.cpp b/common/confirm.cpp index 5921f33645..773c3ae4b6 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -119,16 +119,6 @@ void DisplayInfoMessage( wxWindow* aParent, const wxString& aMessage, const wxSt } -void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title, - const wxString& text, const wxSize& size ) -{ - HTML_MESSAGE_BOX dlg( parent, title, wxDefaultPosition, size ); - - dlg.AddHTML_Text( text ); - dlg.ShowModal(); -} - - bool IsOK( wxWindow* aParent, const wxString& aMessage ) { wxMessageDialog dlg( aParent, aMessage, _( "Confirmation" ), diff --git a/common/dialog_about/dialog_about.cpp b/common/dialog_about/dialog_about.cpp index 0936240d0b..3ab6e88751 100644 --- a/common/dialog_about/dialog_about.cpp +++ b/common/dialog_about/dialog_about.cpp @@ -571,8 +571,8 @@ void DIALOG_ABOUT::onShowVersionInfo( wxCommandEvent& event ) wxString msg_version; buildVersionInfoData( msg_version, true ); - HTML_MESSAGE_BOX dlg( this, _( "Version Info" ), wxDefaultPosition, - wxSize( 550, 500 ) ); + HTML_MESSAGE_BOX dlg( this, _( "Version Info" )); + dlg.SetDialogSizeInDU( 400, 350 ); dlg.AddHTML_Text( msg_version ); dlg.ShowModal(); diff --git a/common/dialogs/dialog_env_var_config.cpp b/common/dialogs/dialog_env_var_config.cpp index 32659d1e41..c808520fdd 100644 --- a/common/dialogs/dialog_env_var_config.cpp +++ b/common/dialogs/dialog_env_var_config.cpp @@ -311,7 +311,11 @@ void DIALOG_ENV_VAR_CONFIG::OnHelpButton( wxCommandEvent& event ) msg << _( "KICAD_PTEMPLATES is optional and can be defined if you want to " "create your own project templates folder." ); - DisplayHtmlInfoMessage( GetParent(), _( "Environment Variable Help" ), msg ); + HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); + dlg.SetDialogSizeInDU( 400, 350 ); + + dlg.AddHTML_Text( msg ); + dlg.ShowModal(); } @@ -473,5 +477,9 @@ void DIALOG_ENV_VAR_SINGLE::onHelpClick( wxCommandEvent& event ) "cannot start with a digit (0-9)." ); - DisplayHtmlInfoMessage( GetParent(), _( "Environment Variable Help" ), msg ); + HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); + dlg.SetDialogSizeInDU( 400, 350 ); + + dlg.AddHTML_Text( msg ); + dlg.ShowModal(); } diff --git a/common/dialogs/dialog_hotkeys_editor.cpp b/common/dialogs/dialog_hotkeys_editor.cpp index 19c435a3f7..658d985691 100644 --- a/common/dialogs/dialog_hotkeys_editor.cpp +++ b/common/dialogs/dialog_hotkeys_editor.cpp @@ -49,7 +49,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent, m_sdbSizerOK->SetDefault(); Layout(); - SetSizeInDU( 240, 120 ); + SetSizeInDU( 350, 300 ); Center(); } diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 03594b4688..7ce719eaf2 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -482,8 +482,9 @@ void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescL // Create a non modal dialog, which shows the list of hotkeys until dismissed // but does not block the parent window - HTML_MESSAGE_BOX *dlg = new HTML_MESSAGE_BOX( aFrame, _( "Hotkeys List" ), - wxDefaultPosition, wxSize( 340, 750 ) ); + HTML_MESSAGE_BOX *dlg = new HTML_MESSAGE_BOX( aFrame, _( "Hotkeys List" ) ); + dlg->SetDialogSizeInDU( 300, 250 ); + dlg->AddHTML_Text( msg ); dlg->Show( true ); } diff --git a/common/html_messagebox.cpp b/common/html_messagebox.cpp index 18e584071c..8646701afe 100644 --- a/common/html_messagebox.cpp +++ b/common/html_messagebox.cpp @@ -28,13 +28,15 @@ #include -HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* parent, const wxString& aTitle, - wxPoint aPos, wxSize aSize) : - DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, aTitle, aPos, aSize ) +HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* parent, const wxString& aTitle) : + DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, aTitle ) { m_htmlWindow->SetLayoutDirection( wxLayout_LeftToRight ); ListClear(); - SetSizeInDU( 240, 120 ); + + // Gives a default logical size (the actual size depends on the display definition) + SetSizeInDU( 240, 150 ); + Center(); } diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 7bf956e058..bf894ec02c 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -642,8 +642,8 @@ void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event ) void DIALOG_BOM::OnHelp( wxCommandEvent& event ) { - HTML_MESSAGE_BOX help_Dlg( this, _("Bom Generation Help"), - wxDefaultPosition, wxSize( 750,550 ) ); + HTML_MESSAGE_BOX help_Dlg( this, _("Bom Generation Help") ); + help_Dlg.SetDialogSizeInDU( 500, 350 ); wxString msg = FROM_UTF8(s_bomHelpInfo); help_Dlg.m_htmlWindow->AppendToPage( msg ); diff --git a/eeschema/dialogs/dialog_edit_components_libid.cpp b/eeschema/dialogs/dialog_edit_components_libid.cpp index adc01a8258..0fab7d1d7d 100644 --- a/eeschema/dialogs/dialog_edit_components_libid.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid.cpp @@ -177,7 +177,7 @@ DIALOG_EDIT_COMPONENTS_LIBID::DIALOG_EDIT_COMPONENTS_LIBID( SCH_EDIT_FRAME* aPar m_panelGrid->SetMinSize( wxSize( minwidth, -1) ); Layout(); - SetSizeInDU( 360, 300 ); + SetSizeInDU( 500, 400 ); Center(); } diff --git a/include/confirm.h b/include/confirm.h index 0cedcc6930..d7e9fd6eba 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -113,14 +113,6 @@ int YesNoCancelDialog( wxWindow* aParent, const wxString& aCancelButtonText = wxEmptyString ); -/** - * Function DisplayHtmlInforMessage - * displays \a aMessage in HTML format. - */ -void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title, - const wxString& aMessage, - const wxSize& size = wxDefaultSize ); - /** * Displays a dialog with radioboxes asking the user to select an option. @@ -140,7 +132,7 @@ int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxStrin * @param aMessage is a text label displayed in the first row of the dialog. * @param aOptions is a vector of possible options. * @param aDefaultState is the default state for the checkboxes. - * @return Vector containing indices of the selected option. + * @return Vector containing indices of the selected option. */ std::pair> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage, const wxArrayString& aOptions, bool aDefaultState = false ); diff --git a/include/html_messagebox.h b/include/html_messagebox.h index 3e5a0edb30..6837c3adc4 100644 --- a/include/html_messagebox.h +++ b/include/html_messagebox.h @@ -47,9 +47,20 @@ public: /** * Constructor */ - HTML_MESSAGE_BOX( wxWindow* parent, const wxString& aTitle, - wxPoint aPos = wxDefaultPosition, - wxSize aSize = wxSize( 450, 250 ) ); + HTML_MESSAGE_BOX( wxWindow* parent, const wxString& aTitle ); + + /** + * set the dialog size, using a "logical value. + * the physical size in pixel will depend on the display definition + * so a value used here shoul be OK with any display (HDPI for instance) + * @param aWidth is a "logical" value of the dialog width. + * @param aHeight is a "logical" value of the dialog height. + */ + void SetDialogSizeInDU( int aWidth, int aHeight ) + { + SetSizeInDU( aWidth, aHeight ); + Center(); + } /** * Function ListSet