You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <fctsys.h>
  25. #include <html_messagebox.h>
  26. #include <macros.h>
  27. #include <common.h>
  28. HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* parent, const wxString& aTitle,
  29. wxPoint aPos, wxSize aSize) :
  30. DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, aTitle, aPos, aSize )
  31. {
  32. m_htmlWindow->SetLayoutDirection( wxLayout_LeftToRight );
  33. ListClear();
  34. Center();
  35. }
  36. void HTML_MESSAGE_BOX::OnCloseButtonClick( wxCommandEvent& event )
  37. {
  38. // the dialog can be shown modal or not modal.
  39. // therefore, use the right way to close it.
  40. if( IsModal() )
  41. EndModal( 0 );
  42. else
  43. Destroy();
  44. }
  45. void HTML_MESSAGE_BOX::ListClear()
  46. {
  47. m_htmlWindow->SetPage( wxEmptyString );
  48. }
  49. void HTML_MESSAGE_BOX::ListSet( const wxString& aList )
  50. {
  51. wxArrayString strings_list;
  52. wxStringSplit( aList, strings_list, wxChar( '\n' ) );
  53. wxString msg = wxT( "<ul>" );
  54. for ( unsigned ii = 0; ii < strings_list.GetCount(); ii++ )
  55. {
  56. msg += wxT( "<li>" );
  57. msg += strings_list.Item( ii ) + wxT( "</li>" );
  58. }
  59. msg += wxT( "</ul>" );
  60. m_htmlWindow->AppendToPage( msg );
  61. }
  62. void HTML_MESSAGE_BOX::ListSet( const wxArrayString& aList )
  63. {
  64. wxString msg = wxT( "<ul>" );
  65. for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
  66. {
  67. msg += wxT( "<li>" );
  68. msg += aList.Item( ii ) + wxT( "</li>" );
  69. }
  70. msg += wxT( "</ul>" );
  71. m_htmlWindow->AppendToPage( msg );
  72. }
  73. void HTML_MESSAGE_BOX::MessageSet( const wxString& message )
  74. {
  75. wxString message_value = wxString::Format(
  76. wxT( "<b>%s</b><br>" ), GetChars( message ) );
  77. m_htmlWindow->AppendToPage( message_value );
  78. }
  79. void HTML_MESSAGE_BOX::AddHTML_Text( const wxString& message )
  80. {
  81. m_htmlWindow->AppendToPage( message );
  82. }