From 122a6d7f46c4591b92e16187048c6ea9c6dabd3f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 27 Aug 2022 19:14:57 +0100 Subject: [PATCH] Move hypertext linking to user-page-numbers. Also moves most navigation code to SCH_NAVIGATION_TOOL. Also changes page number href to anchor syntax ('#foo'). Also adds hypertext processing to SCH_TEXTBOXes. Also adds combobox with schematic pages to text properties dialog. --- common/eda_text.cpp | 24 +- common/plotters/DXF_plotter.cpp | 2 +- common/plotters/GERBER_plotter.cpp | 2 +- common/plotters/HPGL_plotter.cpp | 2 +- common/plotters/PDF_plotter.cpp | 87 ++-- common/plotters/PS_plotter.cpp | 16 +- common/plotters/SVG_plotter.cpp | 2 +- common/plotters/plotter.cpp | 1 - eeschema/dialogs/dialog_plot_schematic.cpp | 12 +- eeschema/dialogs/dialog_text_properties.cpp | 66 ++- eeschema/dialogs/dialog_text_properties.h | 9 +- .../dialogs/dialog_text_properties_base.cpp | 74 ++- .../dialogs/dialog_text_properties_base.fbp | 466 ++++++++---------- .../dialogs/dialog_text_properties_base.h | 18 +- eeschema/sch_field.cpp | 2 +- eeschema/sch_field.h | 4 +- eeschema/sch_item.cpp | 3 + eeschema/sch_item.h | 2 +- eeschema/sch_painter.cpp | 42 +- eeschema/sch_sheet.cpp | 44 +- eeschema/sch_sheet.h | 4 +- eeschema/sch_text.cpp | 50 +- eeschema/sch_text.h | 7 +- eeschema/sch_textbox.cpp | 11 + eeschema/sch_textbox.h | 7 + .../symbol_editor/symbol_editor_plotter.cpp | 2 +- eeschema/tools/ee_selection_tool.cpp | 13 +- eeschema/tools/sch_navigate_tool.cpp | 26 +- eeschema/tools/sch_navigate_tool.h | 2 + include/eda_item.h | 5 + include/eda_text.h | 22 +- include/plotters/plotter.h | 2 +- include/plotters/plotter_dxf.h | 2 +- include/plotters/plotter_gerber.h | 2 +- include/plotters/plotter_hpgl.h | 2 +- include/plotters/plotters_pslike.h | 13 +- pcbnew/exporters/gen_drill_report_files.cpp | 2 +- pcbnew/exporters/gendrill_gerber_writer.cpp | 7 +- pcbnew/exporters/gerber_placefile_writer.cpp | 2 +- pcbnew/plot_board_layers.cpp | 2 +- 40 files changed, 505 insertions(+), 556 deletions(-) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index f08c56d07c..f1c99bbccd 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -983,33 +983,19 @@ bool EDA_TEXT::ValidateHyperlink( const wxString& aURL ) { wxURL url; - return aURL.IsEmpty() || url.SetURL( aURL ) == wxURL_NOERR || IsGotoPageHyperlink( aURL ); + return aURL.IsEmpty() || url.SetURL( aURL ) == wxURL_NOERR || IsGotoPageHref( aURL ); } -bool EDA_TEXT::IsGotoPageHyperlink( const wxString& aURL, int* aDestination ) +bool EDA_TEXT::IsGotoPageHref( const wxString& aHref, wxString* aDestination ) { - wxString dest; - - if( !aURL.StartsWith( "goto:", &dest ) ) - return false; - - long num; - bool retval = dest.ToLong( &num ); - - if( !retval || num < 0 ) - return false; - - if( aDestination ) - *aDestination = static_cast( num ); - - return true; + return aHref.StartsWith( wxT( "#" ), aDestination ); } -wxString EDA_TEXT::GotoPageHyperlinkString( const int& aDestination ) +wxString EDA_TEXT::GotoPageHref( const wxString& aDestination ) { - return wxString::Format( "goto:%d", aDestination ); + return wxT( "#" ) + aDestination; } diff --git a/common/plotters/DXF_plotter.cpp b/common/plotters/DXF_plotter.cpp index db3f84857c..877a3526fc 100644 --- a/common/plotters/DXF_plotter.cpp +++ b/common/plotters/DXF_plotter.cpp @@ -170,7 +170,7 @@ void DXF_PLOTTER::SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil, } -bool DXF_PLOTTER::StartPlot() +bool DXF_PLOTTER::StartPlot( const wxString& aPageNumber ) { wxASSERT( m_outputFile ); diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 72dc6aa154..5a5b5e43f0 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -234,7 +234,7 @@ void GERBER_PLOTTER::formatNetAttribute( GBR_NETLIST_METADATA* aData ) } -bool GERBER_PLOTTER::StartPlot() +bool GERBER_PLOTTER::StartPlot( const wxString& aPageNumber ) { m_hasApertureRoundRect = false; // true is at least one round rect aperture is in use m_hasApertureRotOval = false; // true is at least one oval rotated aperture is in use diff --git a/common/plotters/HPGL_plotter.cpp b/common/plotters/HPGL_plotter.cpp index 117f6fdaca..24e397a4fa 100644 --- a/common/plotters/HPGL_plotter.cpp +++ b/common/plotters/HPGL_plotter.cpp @@ -255,7 +255,7 @@ void HPGL_PLOTTER::SetTargetChordLength( double chord_len ) } -bool HPGL_PLOTTER::StartPlot() +bool HPGL_PLOTTER::StartPlot( const wxString& aPageNumber ) { wxASSERT( m_outputFile ); fprintf( m_outputFile, "IN;VS%d;PU;PA;SP%d;\n", m_penSpeed, m_penNumber ); diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 0a2456ea35..463d76bb8f 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -34,7 +34,7 @@ #include #include -#include // for IsGotoPageHyperlink +#include // for IsGotoPageHref #include #include #include @@ -670,11 +670,13 @@ void PDF_PLOTTER::closePdfStream() } -void PDF_PLOTTER::StartPage() +void PDF_PLOTTER::StartPage( const wxString& aPageNumber ) { wxASSERT( m_outputFile ); wxASSERT( !m_workFile ); + m_pageNumbers.push_back( aPageNumber ); + // Compute the paper size in IUs m_paperSize = m_pageInfo.GetSizeMils(); m_paperSize.x *= 10.0 / m_iuPerDeviceUnit; @@ -701,11 +703,9 @@ void PDF_PLOTTER::ClosePage() // Close the page stream (and compress it) closePdfStream(); - /* Page size is in 1/72 of inch (default user space units) - Works like the bbox in postscript but there is no need for - swapping the sizes, since PDF doesn't require a portrait page. - We use the MediaBox but PDF has lots of other less used boxes - to use */ + // Page size is in 1/72 of inch (default user space units). Works like the bbox in postscript + // but there is no need for swapping the sizes, since PDF doesn't require a portrait page. + // We use the MediaBox but PDF has lots of other less-used boxes that could be used. const double PTsPERMIL = 0.072; VECTOR2D psPaperSize = VECTOR2D( m_pageInfo.GetSizeMils() ) * PTsPERMIL; @@ -720,29 +720,8 @@ void PDF_PLOTTER::ClosePage() // Handle annotations (at the moment only "link" type objects) std::vector hyperlinkHandles; - // Write out all hyperlinks for the page as annotation links - /* - for( const std::pair& linkPair : m_urlHyperlinks ) - { - const BOX2I& box = linkPair.first; - const wxString& url = linkPair.second; - - VECTOR2D bottomLeft = iuToPdfUserSpace( box.GetPosition() ); - VECTOR2D topRight = iuToPdfUserSpace( box.GetEnd() ); - - hyperlinkHandles.push_back( startPdfObject() ); - fprintf( m_outputFile, - "<< /Type /Annot\n" - " /Subtype /Link\n" - " /Rect[%g %g %g %g] /Border[16 16 1]\n" - " /A << /Type /Action /S /URI /URI %s >>\n" - ">>\n", - bottomLeft.x, bottomLeft.y, topRight.x, topRight.y, - encodeStringForPlotter( url ).c_str() ); - closePdfObject(); - }*/ - - // Allocate all hyperlink objects for the page and calculate their position in user space coordinates + // Allocate all hyperlink objects for the page and calculate their position in user space + // coordinates for( const std::pair& linkPair : m_hyperlinksInPage ) { const BOX2I& box = linkPair.first; @@ -768,11 +747,16 @@ void PDF_PLOTTER::ClosePage() hyperLinkArrayHandle = startPdfObject(); bool isFirst = true; - fprintf( m_outputFile, "[%d 0 R", hyperlinkHandles[0] ); + fputs( "[", m_outputFile ); - for( auto it = hyperlinkHandles.begin() + 1; it != hyperlinkHandles.end(); ++it ) + for( int handle : hyperlinkHandles ) { - fprintf( m_outputFile, " %d 0 R", *it ); + if( isFirst ) + isFirst = false; + else + fprintf( m_outputFile, " " ); + + fprintf( m_outputFile, "%d 0 R", handle ); } fputs( "]\n", m_outputFile ); @@ -812,7 +796,7 @@ void PDF_PLOTTER::ClosePage() } -bool PDF_PLOTTER::StartPlot() +bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber ) { wxASSERT( m_outputFile ); @@ -837,7 +821,7 @@ bool PDF_PLOTTER::StartPlot() /* Now, the PDF is read from the end, (more or less)... so we start with the page stream for page 1. Other more important stuff is written at the end */ - StartPage(); + StartPage( aPageNumber ); return true; } @@ -873,7 +857,6 @@ bool PDF_PLOTTER::EndPlot() "<< /BaseFont %s\n" " /Type /Font\n" " /Subtype /Type1\n" - /* Adobe is so Mac-based that the nearest thing to Latin1 is the Windows ANSI encoding! */ " /Encoding /WinAnsiEncoding\n" @@ -895,9 +878,9 @@ bool PDF_PLOTTER::EndPlot() fputs( ">>\n", m_outputFile ); closePdfObject(); - for( const std::pair>& handlePair : m_hyperlinkHandles ) + for( const std::pair>& handlePair : m_hyperlinkHandles ) { - const int& linkhandle = handlePair.first; + const int& linkhandle = handlePair.first; const std::pair& linkpair = handlePair.second; const BOX2D& box = linkpair.first; const wxString& url = linkpair.second; @@ -907,22 +890,30 @@ bool PDF_PLOTTER::EndPlot() fprintf( m_outputFile, "<< /Type /Annot\n" " /Subtype /Link\n" - " /Rect[%g %g %g %g] /Border[16 16 1]\n", + " /Rect [%g %g %g %g]\n" + " /Border [16 16 0]\n", box.GetLeft(), box.GetBottom(), box.GetRight(), box.GetTop() ); - int pageIdx = -1; + wxString pageNumber; + bool pageFound = false; - if( EDA_TEXT::IsGotoPageHyperlink( url, &pageIdx ) ) + if( EDA_TEXT::IsGotoPageHref( url, &pageNumber ) ) { - if( pageIdx <= m_pageHandles.size() && pageIdx > 0 ) + for( size_t ii = 0; ii < m_pageNumbers.size(); ++ii ) { - fprintf( m_outputFile, - " /Dest [%d 0 R] >>\n" - ">>\n", - m_pageHandles[pageIdx - 1] ); - //todo: do we want to support specifying zoom factor/ position? e.g. /FitR + if( m_pageNumbers[ii] == pageNumber ) + { + fprintf( m_outputFile, + " /Dest [%d 0 R /FitB] >>\n" + ">>\n", + m_pageHandles[ii] ); + + pageFound = true; + break; + } } - else + + if( !pageFound ) { // destination page is not being plotted, assign the NOP action to the link fprintf( m_outputFile, diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index d8dbe10561..1078e0e530 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -762,7 +762,7 @@ void PS_PLOTTER::PenTo( const VECTOR2I& pos, char plume ) } -bool PS_PLOTTER::StartPlot() +bool PS_PLOTTER::StartPlot( const wxString& aPageNumber ) { wxASSERT( m_outputFile ); @@ -893,12 +893,14 @@ bool PS_PLOTTER::StartPlot() fputs( PSMacro[ii], m_outputFile ); } - // The following string has been specified here (rather than within - // PSMacro[]) to highlight that it has been provided to ensure that the - // contents of the postscript file comply with the details specified - // within the Document Structuring Convention. - fputs( "%%Page: 1 1\n" - "%%BeginPageSetup\n" + // The following strings are output here (rather than within PSMacro[]) + // to highlight that it has been provided to ensure that the contents of + // the postscript file comply with the Document Structuring Convention. + std::string page_num = encodeStringForPlotter( aPageNumber ); + + fprintf( m_outputFile, "%%Page: %s 1\n", page_num.c_str() ); + + fputs( "%%BeginPageSetup\n" "gsave\n" "0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates "linemode1\n", m_outputFile ); diff --git a/common/plotters/SVG_plotter.cpp b/common/plotters/SVG_plotter.cpp index 756c076bca..437304ff53 100644 --- a/common/plotters/SVG_plotter.cpp +++ b/common/plotters/SVG_plotter.cpp @@ -711,7 +711,7 @@ void SVG_PLOTTER::PenTo( const VECTOR2I& pos, char plume ) } -bool SVG_PLOTTER::StartPlot() +bool SVG_PLOTTER::StartPlot( const wxString& aPageNumber ) { wxASSERT( m_outputFile ); diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index d22db99f42..9fdbe48375 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -38,7 +38,6 @@ */ #include -#include #include #include #include diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index 9f7a39a51b..f1b5bc24f2 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -565,7 +565,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF( const wxString& aFileName, LOCALE_IO toggle; - plotter->StartPlot(); + plotter->StartPlot( m_parent->GetCurrentSheet().GetPageNumber() ); if( aPlotFrameRef ) { @@ -756,7 +756,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl( const wxString& aFileName, // Pen num and pen speed are not initialized here. // Default HPGL driver values are used plotter->SetPenDiameter( m_HPGLPenSize ); - plotter->StartPlot(); + plotter->StartPlot( m_parent->GetCurrentSheet().GetPageNumber() ); if( aPlotFrameRef ) { @@ -846,7 +846,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet // Open the plotter and do the first page setupPlotPagePDF( plotter, screen ); - plotter->StartPlot(); + plotter->StartPlot( sheetList[i].GetPageNumber() ); } catch( const IO_ERROR& e ) { @@ -865,7 +865,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet * reconfigure, and then start a new one */ plotter->ClosePage(); setupPlotPagePDF( plotter, screen ); - plotter->StartPage(); + plotter->StartPage( sheetList[i].GetPageNumber() ); } plotOneSheetPDF( plotter, screen, aPlotDrawingSheet ); @@ -1088,7 +1088,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, LOCALE_IO toggle; // Switch the locale to standard C - plotter->StartPlot(); + plotter->StartPlot( m_parent->GetCurrentSheet().GetPageNumber() ); if( m_plotBackgroundColor->GetValue() && plotter->GetColorMode() ) { @@ -1221,7 +1221,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( const wxString& aFileName, LOCALE_IO toggle; - plotter->StartPlot(); + plotter->StartPlot( m_parent->GetCurrentSheet().GetPageNumber() ); if( m_plotBackgroundColor->GetValue() && plotter->GetColorMode() ) { diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 2cbb23e2f4..35a9c56c15 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -126,6 +126,21 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITE m_separator3->SetIsSeparator(); + SCH_SHEET_LIST sheetList = m_frame->Schematic().GetSheets(); + sheetList.SortByPageNumbers( false ); + + for( const SCH_SHEET_PATH& sheet : sheetList ) + { + wxString sheetPageNum = sheet.GetPageNumber(); + wxString sheetName = sheet.size() == 1 ? _( "" ) : sheet.Last()->GetName(); + + m_hyperlinkCtrl->Append( wxString::Format( _( "Page %s (%s)" ), sheetPageNum, sheetName ) ); + m_pageNumbers.push_back( sheetPageNum ); + } + + m_hyperlinkCtrl->Append( wxT( "---------------------" ) ); + m_hyperlinkCtrl->Append( wxT( "http(s)://..." ) ); + SetupStandardButtons(); Layout(); @@ -159,7 +174,6 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() SCHEMATIC& schematic = m_frame->Schematic(); m_hyperlinkCb->SetValue( m_currentText->HasHyperlink() ); - m_hyperlinkDestinationLabel->Enable( m_currentText->HasHyperlink() ); m_hyperlinkCtrl->Enable( m_currentText->HasHyperlink() ); m_hyperlinkCtrl->SetValue( m_currentText->GetHyperlink() ); @@ -241,7 +255,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() } -void DIALOG_TEXT_PROPERTIES::onBorderChecked( wxCommandEvent& event ) +void DIALOG_TEXT_PROPERTIES::onBorderChecked( wxCommandEvent& aEvent ) { bool border = m_borderCheckbox->GetValue(); @@ -256,7 +270,7 @@ void DIALOG_TEXT_PROPERTIES::onBorderChecked( wxCommandEvent& event ) } -void DIALOG_TEXT_PROPERTIES::onFillChecked( wxCommandEvent& event ) +void DIALOG_TEXT_PROPERTIES::onFillChecked( wxCommandEvent& aEvent ) { bool fill = m_filledCtrl->GetValue(); @@ -267,16 +281,16 @@ void DIALOG_TEXT_PROPERTIES::onFillChecked( wxCommandEvent& event ) void DIALOG_TEXT_PROPERTIES::onHyperlinkChecked( wxCommandEvent& aEvent ) { - if( aEvent.IsChecked() ) + if( aEvent.IsChecked() && !m_hyperlinkCtrl->IsEnabled() ) { m_hyperlinkCtrl->Enable( true ); - m_hyperlinkDestinationLabel->Enable( true ); + m_hyperlinkCtrl->ChangeValue( m_lastLink ); m_hyperlinkCtrl->SetFocus(); } - else + else if( !aEvent.IsChecked() && m_hyperlinkCtrl->IsEnabled() ) { m_hyperlinkCtrl->Enable( false ); - m_hyperlinkDestinationLabel->Enable( false ); + m_lastLink = m_hyperlinkCtrl->GetValue(); m_hyperlinkCtrl->SetValue( wxEmptyString ); } @@ -284,6 +298,42 @@ void DIALOG_TEXT_PROPERTIES::onHyperlinkChecked( wxCommandEvent& aEvent ) } +void DIALOG_TEXT_PROPERTIES::onHyperlinkDropdown( wxCommandEvent& aEvent ) +{ + m_lastLink = m_hyperlinkCtrl->GetValue(); +} + + +void DIALOG_TEXT_PROPERTIES::onHyperlinkCombo( wxCommandEvent& aEvent ) +{ + size_t sel = aEvent.GetSelection(); + + if( sel < 0 ) + { + // user clicked outside dropdown; leave current value + } + else if( sel == m_hyperlinkCtrl->GetCount() - 2 ) + { + // separator (and wxWidgets already updated our value to it); + // replace value with that saved in the dropdown event + m_hyperlinkCtrl->ChangeValue( m_lastLink ); + m_hyperlinkCtrl->SetSelection( 0, m_hyperlinkCtrl->GetValue().Length() ); + } + else if( sel == m_hyperlinkCtrl->GetCount() - 1 ) + { + static wxString helper = wxT( "https://" ); + + m_hyperlinkCtrl->ChangeValue( helper ); + m_hyperlinkCtrl->SetInsertionPointEnd(); + } + else + { + m_hyperlinkCtrl->ChangeValue( wxT( "#" ) + m_pageNumbers[ sel ] ); + m_hyperlinkCtrl->SetSelection( 0, m_hyperlinkCtrl->GetValue().Length() ); + } +} + + void DIALOG_TEXT_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent ) { wxStyledTextCtrl* te = m_textCtrl; @@ -406,7 +456,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() if( !m_currentText->ValidateHyperlink( m_hyperlinkCtrl->GetValue() ) ) { DisplayError( this, _( "Invalid hyperlink destination. Please enter either a valid URL " - "(e.g. file:// or http(s)://) or \"goto:\" to create " + "(e.g. file:// or http(s)://) or \"#\" to create " "a hyperlink to a page in this schematic." ) ); return false; } diff --git a/eeschema/dialogs/dialog_text_properties.h b/eeschema/dialogs/dialog_text_properties.h index 81815ac34f..2c71054c8d 100644 --- a/eeschema/dialogs/dialog_text_properties.h +++ b/eeschema/dialogs/dialog_text_properties.h @@ -44,9 +44,11 @@ public: private: void onScintillaCharAdded( wxStyledTextEvent &aEvent ); void onSpinButton( wxCommandEvent &aEvent ); - void onBorderChecked( wxCommandEvent& event ) override; - void onFillChecked( wxCommandEvent& event ) override; + void onBorderChecked( wxCommandEvent& aEvent ) override; + void onFillChecked( wxCommandEvent& aEvent ) override; void onHyperlinkChecked( wxCommandEvent& aEvent ) override; + void onHyperlinkDropdown( wxCommandEvent& aEvent ) override; + void onHyperlinkCombo( wxCommandEvent& aEvent ) override; void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override; void onMultiLineTCLostFocus( wxFocusEvent& event ) override; @@ -60,8 +62,11 @@ private: UNIT_BINDER m_textSize; UNIT_BINDER m_borderWidth; SCINTILLA_TRICKS* m_scintillaTricks; + std::vector m_pageNumbers; HTML_MESSAGE_BOX* m_helpWindow; + + wxString m_lastLink; }; diff --git a/eeschema/dialogs/dialog_text_properties_base.cpp b/eeschema/dialogs/dialog_text_properties_base.cpp index 64086321d9..3c7ed7aa55 100644 --- a/eeschema/dialogs/dialog_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_text_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -81,41 +81,15 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi m_textEntrySizer->Add( bSizer41, wxGBPosition( 1, 5 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_RIGHT|wxLEFT, 80 ); - wxBoxSizer* bSizer11; - bSizer11 = new wxBoxSizer( wxHORIZONTAL ); - - m_hyperlinkCb = new wxCheckBox( this, wxID_ANY, _("Hyperlink"), wxDefaultPosition, wxDefaultSize, 0 ); - m_hyperlinkCb->SetToolTip( _("Make this text item a clickable hyperlink") ); - - bSizer11->Add( m_hyperlinkCb, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - bSizer11->Add( 10, 0, 0, wxEXPAND, 5 ); - - m_hyperlinkDestinationLabel = new wxStaticText( this, wxID_ANY, _("Destination:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_hyperlinkDestinationLabel->Wrap( -1 ); - m_hyperlinkDestinationLabel->Enable( false ); - - bSizer11->Add( m_hyperlinkDestinationLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_hyperlinkCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - m_hyperlinkCtrl->Enable( false ); - m_hyperlinkCtrl->SetToolTip( _("Please enter either a valid URL (e.g. file:// or http(s)://) or \"goto:\" to create a hyperlink to a page in this schematic.") ); - - bSizer11->Add( m_hyperlinkCtrl, 10, wxALL, 5 ); - - - m_textEntrySizer->Add( bSizer11, wxGBPosition( 2, 0 ), wxGBSpan( 1, 6 ), wxEXPAND, 5 ); - m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); m_fontLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); + m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") }; int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString ); m_fontCtrl = new FONT_CHOICE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 ); m_fontCtrl->SetSelection( 0 ); - m_textEntrySizer->Add( m_fontCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 ); + m_textEntrySizer->Add( m_fontCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 ); wxBoxSizer* bSizeCtrlSizer; bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -176,11 +150,11 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bSizeCtrlSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 3, 3 ), wxGBSpan( 1, 2 ), wxEXPAND|wxTOP, 5 ); + m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 2, 3 ), wxGBSpan( 1, 2 ), wxEXPAND|wxTOP, 5 ); m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); wxBoxSizer* bSizer71; bSizer71 = new wxBoxSizer( wxHORIZONTAL ); @@ -213,14 +187,14 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_textEntrySizer->Add( bSizer71, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); + m_textEntrySizer->Add( bSizer71, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); m_borderCheckbox = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_borderCheckbox, wxGBPosition( 6, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM, 2 ); + m_textEntrySizer->Add( m_borderCheckbox, wxGBPosition( 5, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM, 2 ); m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_borderWidthLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 7, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxHORIZONTAL ); @@ -253,19 +227,19 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bSizer7->Add( m_panelBorderColor, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_textEntrySizer->Add( bSizer7, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + m_textEntrySizer->Add( bSizer7, wxGBPosition( 6, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 ); m_borderStyleLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 8, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 7, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) ); - m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 8, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); m_filledCtrl = new wxCheckBox( this, wxID_ANY, _("Background fill"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 6, 4 ), wxGBSpan( 1, 2 ), wxRIGHT, 80 ); + m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 5, 4 ), wxGBSpan( 1, 2 ), wxRIGHT, 80 ); wxBoxSizer* bSizer8; bSizer8 = new wxBoxSizer( wxHORIZONTAL ); @@ -288,12 +262,21 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bSizer8->Add( m_panelFillColor, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_textEntrySizer->Add( bSizer8, wxGBPosition( 7, 4 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + m_textEntrySizer->Add( bSizer8, wxGBPosition( 6, 4 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + + m_hyperlinkCb = new wxCheckBox( this, wxID_ANY, _("Link:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_hyperlinkCb->SetValue(true); + m_hyperlinkCb->SetToolTip( _("Make this text item a clickable hyperlink") ); + + m_textEntrySizer->Add( m_hyperlinkCb, wxGBPosition( 9, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); + + m_hyperlinkCtrl = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + m_textEntrySizer->Add( m_hyperlinkCtrl, wxGBPosition( 9, 1 ), wxGBSpan( 1, 6 ), wxEXPAND|wxBOTTOM, 5 ); m_textEntrySizer->AddGrowableCol( 3 ); - bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxALL, 10 ); + bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bMainSizer->Add( m_staticline, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -311,18 +294,21 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bSizer4->Add( m_sdbSizer1, 1, wxALL|wxEXPAND, 5 ); - bMainSizer->Add( bSizer4, 0, wxEXPAND|wxALL, 5 ); + bMainSizer->Add( bSizer4, 0, wxEXPAND, 5 ); this->SetSizer( bMainSizer ); this->Layout(); + bMainSizer->Fit( this ); // Connect Events m_textCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); m_syntaxHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); - m_hyperlinkCb->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkChecked ), NULL, this ); m_borderCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onBorderChecked ), NULL, this ); m_filledCtrl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onFillChecked ), NULL, this ); + m_hyperlinkCb->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkChecked ), NULL, this ); + m_hyperlinkCtrl->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkCombo ), NULL, this ); + m_hyperlinkCtrl->Connect( wxEVT_COMBOBOX_DROPDOWN, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkDropdown ), NULL, this ); } DIALOG_TEXT_PROPERTIES_BASE::~DIALOG_TEXT_PROPERTIES_BASE() @@ -330,8 +316,10 @@ DIALOG_TEXT_PROPERTIES_BASE::~DIALOG_TEXT_PROPERTIES_BASE() // Disconnect Events m_textCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); m_syntaxHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); - m_hyperlinkCb->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkChecked ), NULL, this ); m_borderCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onBorderChecked ), NULL, this ); m_filledCtrl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onFillChecked ), NULL, this ); + m_hyperlinkCb->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkChecked ), NULL, this ); + m_hyperlinkCtrl->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkCombo ), NULL, this ); + m_hyperlinkCtrl->Disconnect( wxEVT_COMBOBOX_DROPDOWN, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onHyperlinkDropdown ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_text_properties_base.fbp b/eeschema/dialogs/dialog_text_properties_base.fbp index 497912cdbf..3b8229709e 100644 --- a/eeschema/dialogs/dialog_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_text_properties_base.fbp @@ -47,7 +47,7 @@ DIALOG_TEXT_PROPERTIES_BASE - 778,449 + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Text Properties @@ -123,7 +123,7 @@ 10 - wxEXPAND|wxALL + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 -1,-1 @@ -278,16 +278,16 @@ wxEXPAND|wxALIGN_RIGHT|wxLEFT 1 1 - + bSizer41 wxVERTICAL none - + 6 wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -349,226 +349,12 @@ - - 5 - 6 - 0 - wxEXPAND - 2 - 1 - - - bSizer11 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Hyperlink - - 0 - - - 0 - - 1 - m_hyperlinkCb - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - Make this text item a clickable hyperlink - - wxFILTER_NONE - wxDefaultValidator - - - - - onHyperlinkChecked - - - - 5 - wxEXPAND - 0 - - 0 - protected - 10 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - - 1 - - 0 - 0 - wxID_ANY - Destination: - 0 - - 0 - - - 0 - - 1 - m_hyperlinkDestinationLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALL - 10 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - -1,-1 - 0 - -1,-1 - 1 - m_hyperlinkCtrl - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - Please enter either a valid URL (e.g. file:// or http(s)://) or "goto:<page sequence>" to create a hyperlink to a page in this schematic. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 1 0 wxALIGN_CENTER_VERTICAL|wxTOP - 3 + 2 1 1 @@ -632,7 +418,7 @@ 2 1 wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP - 3 + 2 1 1 @@ -699,9 +485,9 @@ 2 3 wxEXPAND|wxTOP - 3 + 2 1 - + bSizeCtrlSizer wxHORIZONTAL @@ -1071,11 +857,11 @@ - + 5 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -1290,11 +1076,11 @@ - + 5 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -1516,7 +1302,7 @@ 1 0 wxALIGN_CENTER_VERTICAL - 4 + 3 1 1 @@ -1580,18 +1366,18 @@ 1 1 wxEXPAND - 4 + 3 1 - + bSizer71 wxHORIZONTAL none - + 5 wxEXPAND 0 - + 1 1 1 @@ -1651,11 +1437,11 @@ - + 3 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -1712,11 +1498,11 @@ -1 - + 15 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -1773,21 +1559,21 @@ -1 - + 5 0 - + 0 protected 5 - + 5 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -1838,16 +1624,16 @@ wxBORDER_SIMPLE|wxTAB_TRAVERSAL - + bSizer22 wxVERTICAL none - + 5 wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL 0 - + 1 1 1 @@ -1915,7 +1701,7 @@ 2 0 wxBOTTOM - 6 + 5 1 1 @@ -1983,7 +1769,7 @@ 1 0 wxALIGN_CENTER_VERTICAL - 7 + 6 1 1 @@ -2047,18 +1833,18 @@ 2 1 wxEXPAND - 7 + 6 1 - + bSizer7 wxHORIZONTAL none - + 5 wxEXPAND 0 - + 1 1 1 @@ -2118,11 +1904,11 @@ - + 3 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -2179,11 +1965,11 @@ -1 - + 15 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -2240,21 +2026,21 @@ -1 - + 5 0 - + 0 protected 5 - + 5 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2305,7 +2091,7 @@ wxBORDER_SIMPLE|wxTAB_TRAVERSAL - + bSizer2 wxVERTICAL @@ -2382,7 +2168,7 @@ 1 0 wxALIGN_CENTER_VERTICAL - 8 + 7 1 1 @@ -2446,7 +2232,7 @@ 2 1 wxEXPAND - 8 + 7 1 1 @@ -2514,7 +2300,7 @@ 2 4 wxRIGHT - 6 + 5 1 1 @@ -2582,18 +2368,18 @@ 2 4 wxEXPAND - 7 + 6 1 - + bSizer8 wxHORIZONTAL none - + 5 wxRIGHT|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2650,11 +2436,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2705,16 +2491,16 @@ wxBORDER_SIMPLE|wxTAB_TRAVERSAL - + bSizer21 wxVERTICAL none - + 5 wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL 0 - + 1 1 1 @@ -2777,6 +2563,144 @@ + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxBOTTOM + 9 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Link: + + 0 + + + 0 + + 1 + m_hyperlinkCb + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Make this text item a clickable hyperlink + + wxFILTER_NONE + wxDefaultValidator + + + + + onHyperlinkChecked + + + + 5 + 6 + 1 + wxEXPAND|wxBOTTOM + 9 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_hyperlinkCtrl + 1 + + + protected + 1 + + Resizable + -1 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + onHyperlinkCombo + onHyperlinkDropdown + + @@ -2839,7 +2763,7 @@ 5 - wxEXPAND|wxALL + wxEXPAND 0 diff --git a/eeschema/dialogs/dialog_text_properties_base.h b/eeschema/dialogs/dialog_text_properties_base.h index 72e71dbc70..3aa4e4fb2e 100644 --- a/eeschema/dialogs/dialog_text_properties_base.h +++ b/eeschema/dialogs/dialog_text_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -26,16 +26,17 @@ class WX_INFOBAR; #include #include #include -#include -#include #include #include #include #include #include #include +#include #include +#include #include +#include #include #include #include @@ -55,9 +56,6 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_textLabel; wxStyledTextCtrl* m_textCtrl; wxHyperlinkCtrl* m_syntaxHelp; - wxCheckBox* m_hyperlinkCb; - wxStaticText* m_hyperlinkDestinationLabel; - wxTextCtrl* m_hyperlinkCtrl; wxStaticText* m_fontLabel; FONT_CHOICE* m_fontCtrl; BITMAP_BUTTON* m_separator1; @@ -90,6 +88,8 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_fillColorLabel; wxPanel* m_panelFillColor; COLOR_SWATCH* m_fillColorSwatch; + wxCheckBox* m_hyperlinkCb; + wxComboBox* m_hyperlinkCtrl; wxStaticLine* m_staticline; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; @@ -98,14 +98,16 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM // Virtual event handlers, override them in your derived class virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } virtual void OnFormattingHelp( wxHyperlinkEvent& event ) { event.Skip(); } - virtual void onHyperlinkChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onFillChecked( wxCommandEvent& event ) { event.Skip(); } + virtual void onHyperlinkChecked( wxCommandEvent& event ) { event.Skip(); } + virtual void onHyperlinkCombo( wxCommandEvent& event ) { event.Skip(); } + virtual void onHyperlinkDropdown( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 778,449 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_TEXT_PROPERTIES_BASE(); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index c81edada32..39ba4879de 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -736,7 +736,7 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorType() == SCH_GLOBAL_LABEL_T; } - virtual void DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) const override; + void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override; /** * Return the field name (not translated).. diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index f2c6a25f0f..41fad0064f 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -293,6 +293,9 @@ const wxString& SCH_ITEM::GetDefaultFont() const bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const { + if( IsHypertext() ) + return false; + if( const EDA_TEXT* text = dynamic_cast( this ) ) return text->GetTextHeight() * aWorldScale < BITMAP_FONT_SIZE_THRESHOLD; diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 7e85422a65..3ebf74082b 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -236,7 +236,7 @@ public: */ virtual bool IsHypertext() const { return false; } - virtual void DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) const { } + virtual void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const { } /** * Return the layer this item is on. diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 9eedb7271a..99a48e7a66 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -1837,12 +1837,6 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) return; } - if( aText->IsHypertext() && ( aText->GetFlags() & IS_ROLLOVER ) && !drawingShadows - && !aText->IsMoving() ) - { - color = m_schSettings.GetLayerColor( LAYER_HOVERED ); - } - m_gal->SetStrokeColor( color ); m_gal->SetFillColor( color ); @@ -1865,6 +1859,13 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) attrs.m_Angle = aText->GetDrawRotation(); attrs.m_StrokeWidth = getTextThickness( aText ); + if( aText->IsHypertext() && aText->IsRollover() ) + { + m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) ); + m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) ); + attrs.m_Underlined = true; + } + // Adjust text drawn in an outline font to more closely mimic the positioning of // SCH_FIELD text. if( aText->GetDrawFont()->IsOutline() ) @@ -1889,7 +1890,8 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) { std::vector>* cache = nullptr; - cache = aText->GetRenderCache( shownText, text_offset ); + if( !aText->IsHypertext() ) + cache = aText->GetRenderCache( shownText, text_offset ); if( cache ) { @@ -1922,9 +1924,17 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) attrs.m_Angle = aTextBox->GetDrawRotation(); attrs.m_StrokeWidth = getTextThickness( aTextBox ); + if( aTextBox->IsHypertext() && aTextBox->IsRollover() ) + { + m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) ); + m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) ); + attrs.m_Underlined = true; + } + std::vector>* cache = nullptr; - cache = aTextBox->GetRenderCache( shownText ); + if( !aTextBox->IsHypertext() ) + cache = aTextBox->GetRenderCache( shownText ); if( cache ) { @@ -2167,12 +2177,6 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children ) return; - if( aField->IsHypertext() && ( aField->GetFlags() & IS_ROLLOVER ) > 0 - && !drawingShadows && !aField->IsMoving() ) - { - color = m_schSettings.GetLayerColor( LAYER_HOVERED ); - } - // Calculate the text orientation according to the parent orientation. EDA_ANGLE orient = aField->GetTextAngle(); @@ -2230,6 +2234,13 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) attributes.m_StrokeWidth = getTextThickness( aField ); attributes.m_Angle = orient; + if( aField->IsHypertext() && aField->IsRollover() ) + { + m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) ); + m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) ); + attributes.m_Underlined = true; + } + if( nonCached( aField ) && aField->RenderAsBitmap( m_gal->GetWorldScale() ) ) { bitmapText( shownText, textpos, attributes ); @@ -2239,7 +2250,8 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) { std::vector>* cache = nullptr; - cache = aField->GetRenderCache( shownText, textpos, attributes ); + if( !aField->IsHypertext() ) + cache = aField->GetRenderCache( shownText, textpos, attributes ); if( cache ) { diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 5bab628eee..6d3c30452c 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -908,45 +908,22 @@ void SCH_SHEET::renumberPins() } -int SCH_SHEET::guessPageFromParentScreen() const +SCH_SHEET_PATH SCH_SHEET::getSheetPath() const { SCH_SCREEN* parentScreen = static_cast( m_parent ); - int vPageNumParent = parentScreen->GetVirtualPageNumber(); + size_t vPageNumParent = parentScreen->GetVirtualPageNumber(); SCH_SHEET_LIST sheets = parentScreen->Schematic()->GetSheets(); - wxCHECK( sheets.size() >= vPageNumParent && vPageNumParent > 0, m_screen->GetVirtualPageNumber() ); - // We can use the virtual page number as an index to find the instance - SCH_SHEET_PATH parentSheetPath = sheets.at( vPageNumParent - 1 ); + size_t parentIdx = std::max( 0, std::min( sheets.size(), vPageNumParent ) - 1 ); + SCH_SHEET_PATH sheetPath = sheets.at( parentIdx ); // Make sure our asumption about the virtual page number being the index-1 is correct - wxCHECK( parentSheetPath.LastScreen()->GetFileName() == parentScreen->GetFileName(), - m_screen->GetVirtualPageNumber() ); + wxASSERT( sheetPath.LastScreen()->GetFileName() == parentScreen->GetFileName() ); - KIID_PATH parentSheetKIIDPath = parentSheetPath.PathWithoutRootUuid(); + sheetPath.push_back( const_cast( this ) ); - for( const SCH_SHEET_INSTANCE& instance : m_instances ) - { - KIID_PATH instancePath = instance.m_Path; - - if( instancePath.MakeRelativeTo( parentSheetKIIDPath ) && instancePath.size() == 1 ) - { - // find the virtual page number of this path - auto isThePath = [&]( const SCH_SHEET_PATH& aPath ) -> bool - { - return aPath.PathWithoutRootUuid() == instance.m_Path; - }; - - auto result = std::find_if( sheets.begin(), sheets.end(), isThePath ); - - wxCHECK( result != sheets.end(), m_screen->GetVirtualPageNumber() ); - - return result - sheets.begin() + 1; - } - } - - wxFAIL_MSG( "Couldn't find a valid path?" ); - return m_screen->GetVirtualPageNumber(); + return sheetPath; } @@ -1073,7 +1050,6 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground ) const if( aBackground && !aPlotter->GetColorMode() ) return; - VECTOR2I pos; auto* settings = dynamic_cast( aPlotter->RenderSettings() ); bool override = settings ? settings->m_OverrideItemColors : false; COLOR4D borderColor = GetBorderColor(); @@ -1102,9 +1078,9 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground ) const if( !aBackground ) { BOX2I rect( m_pos, m_size ); - int virtualPage = guessPageFromParentScreen(); - wxString hyperlinkDestination = EDA_TEXT::GotoPageHyperlinkString( virtualPage ); - aPlotter->HyperlinkBox( rect, hyperlinkDestination ); + wxString pageNum = GetPageNumber( getSheetPath() ); + + aPlotter->HyperlinkBox( rect, EDA_TEXT::GotoPageHref( pageNum ) ); } // Plot sheet pins diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 1f61ecea3b..ee2cd32df8 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -451,12 +451,12 @@ protected: void renumberPins(); /** - * Guess the virtual page number of this sheet based on the virtual page number currently set + * Guess the sheet path of this sheet based on the virtual page number currently set * on the parent screen. (Useful helper function for plotting) * * @return the instance corresponding to this sheet */ - int guessPageFromParentScreen() const; + SCH_SHEET_PATH getSheetPath() const; private: bool doIsConnected( const VECTOR2I& aPosition ) const override; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index b94d3be3be..e7685afab1 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +42,6 @@ #include #include #include -#include #include #include @@ -385,55 +383,13 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const } -void SCH_TEXT::DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) const +void SCH_TEXT::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const { wxCHECK_MSG( IsHypertext(), /* void */, "Calling a hypertext menu on a SCH_TEXT with no hyperlink?" ); - int destPage = -1; - wxMenu menu; - - if( IsGotoPageHyperlink( m_hyperlink, &destPage ) && destPage > 0 ) - { - std::map sheetNames; - std::map sheetPages; - - for( const SCH_SHEET_PATH& sheet : Schematic()->GetSheets() ) - { - sheetPages[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber(); - - if( sheet.size() == 1 ) - sheetNames[sheet.GetVirtualPageNumber()] = _( "" ); - else - sheetNames[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName(); - } - - if( sheetPages.count( destPage ) > 0 ) - { - menu.Append( 0, wxString::Format( _( "Go to Page %s (%s)" ), - sheetPages[destPage], - sheetNames[destPage] ) ); - - int sel = aFrame->GetPopupMenuSelectionFromUser( menu ); - void* param = &destPage; - - if( param ) - aFrame->GetToolManager()->RunAction( EE_ACTIONS::hypertextCommand, true, param ); - } - else - { - aFrame->ShowInfoBarError( wxString::Format( _( "Page sequence '%d' does not exist." ), - destPage ) ); - } - } - else - { - menu.Append( 1, wxString::Format( _( "Open %s" ), m_hyperlink ) ); - int sel = aFrame->GetPopupMenuSelectionFromUser( menu ); - - if( sel == 1 ) - GetAssociatedDocument( aFrame, m_hyperlink, &aFrame->Prj() ); - } + SCH_NAVIGATE_TOOL* navTool = aFrame->GetToolManager()->GetTool(); + navTool->HypertextCommand( m_hyperlink ); } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index a5696c11ab..3d523eb784 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -133,9 +133,12 @@ public: wxString GetShownText( int aDepth = 0 ) const override; - virtual bool IsHypertext() const override { return HasHyperlink(); } + bool IsHypertext() const override + { + return HasHyperlink(); + } - virtual void DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) const override; + void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override; /** * Set a spin or rotation angle, along with specific horizontal and vertical justification diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 999da78cb4..2f88350718 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -38,6 +38,7 @@ #include #include #include +#include using KIGFX::SCH_RENDER_SETTINGS; @@ -319,6 +320,16 @@ bool SCH_TEXTBOX::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy } +void SCH_TEXTBOX::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const +{ + wxCHECK_MSG( IsHypertext(), /* void */, + "Calling a hypertext menu on a SCH_TEXTBOX with no hyperlink?" ); + + SCH_NAVIGATE_TOOL* navTool = aFrame->GetToolManager()->GetTool(); + navTool->HypertextCommand( m_hyperlink ); +} + + wxString SCH_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const { return wxString::Format( _( "Graphic Text Box" ) ); diff --git a/eeschema/sch_textbox.h b/eeschema/sch_textbox.h index c1df42be52..44a510e20e 100644 --- a/eeschema/sch_textbox.h +++ b/eeschema/sch_textbox.h @@ -57,6 +57,13 @@ public: wxString GetShownText( int aDepth = 0 ) const override; + bool IsHypertext() const override + { + return HasHyperlink(); + } + + void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override; + void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override; void SwapData( SCH_ITEM* aItem ) override; diff --git a/eeschema/symbol_editor/symbol_editor_plotter.cpp b/eeschema/symbol_editor/symbol_editor_plotter.cpp index a63d6564fe..2555c6f4d6 100644 --- a/eeschema/symbol_editor/symbol_editor_plotter.cpp +++ b/eeschema/symbol_editor/symbol_editor_plotter.cpp @@ -57,7 +57,7 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName ) LOCALE_IO toggle; - plotter->StartPlot(); + plotter->StartPlot( wxT( "1" ) ); if( m_symbol ) { diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 06ee82e4b5..561ab4bc3c 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -382,7 +382,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) } else if( collector[0]->IsHypertext() ) { - collector[0]->DoHypertextMenu( m_frame ); + collector[ 0 ]->DoHypertextAction( m_frame ); selCancelled = true; } } @@ -620,9 +620,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( rolloverItem != lastRolloverItem ) { - EDA_ITEM* item = m_frame->GetItem( lastRolloverItem ); - - if( item ) + if( EDA_ITEM* item = m_frame->GetItem( lastRolloverItem ) ) { item->ClearFlags( IS_ROLLOVER ); lastRolloverItem = niluuid; @@ -632,10 +630,11 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else m_frame->GetCanvas()->GetView()->Update( item ); } + } - item = m_frame->GetItem( rolloverItem ); - - if( item ) + if( EDA_ITEM* item = m_frame->GetItem( rolloverItem ) ) + { + if( !( item->GetFlags() & IS_ROLLOVER ) ) { item->SetFlags( IS_ROLLOVER ); lastRolloverItem = rolloverItem; diff --git a/eeschema/tools/sch_navigate_tool.cpp b/eeschema/tools/sch_navigate_tool.cpp index 27f0cf6cb6..1a8a731d0d 100644 --- a/eeschema/tools/sch_navigate_tool.cpp +++ b/eeschema/tools/sch_navigate_tool.cpp @@ -26,7 +26,7 @@ #include #include #include - +#include "eda_doc.h" void SCH_NAVIGATE_TOOL::ResetHistory() { @@ -81,6 +81,30 @@ int SCH_NAVIGATE_TOOL::HypertextCommand( const TOOL_EVENT& aEvent ) } +void SCH_NAVIGATE_TOOL::HypertextCommand( const wxString& href ) +{ + wxString destPage; + + if( EDA_TEXT::IsGotoPageHref( href, &destPage ) && !destPage.IsEmpty() ) + { + for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() ) + { + if( sheet.GetPageNumber() == destPage ) + { + changeSheet( sheet ); + return; + } + } + + m_frame->ShowInfoBarError( wxString::Format( _( "Page '%d' not found." ), destPage ) ); + } + else + { + GetAssociatedDocument( m_frame, href, &m_frame->Prj() ); + } +} + + int SCH_NAVIGATE_TOOL::Up( const TOOL_EVENT& aEvent ) { // Checks for CanGoUp() diff --git a/eeschema/tools/sch_navigate_tool.h b/eeschema/tools/sch_navigate_tool.h index fad9b54961..9991c01704 100644 --- a/eeschema/tools/sch_navigate_tool.h +++ b/eeschema/tools/sch_navigate_tool.h @@ -66,6 +66,8 @@ public: int Next( const TOOL_EVENT& aEvent ); int HypertextCommand( const TOOL_EVENT& aEvent ); + void HypertextCommand( const wxString& href ); + bool CanGoBack(); bool CanGoForward(); bool CanGoUp(); diff --git a/include/eda_item.h b/include/eda_item.h index ed227f26a5..262a63554e 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -124,6 +124,11 @@ public: inline bool IsResized() const { return m_flags & IS_RESIZING; } inline bool IsBrightened() const { return m_flags & BRIGHTENED; } + inline bool IsRollover() const + { + return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER; + } + inline void SetWireImage() { SetFlags( IS_WIRE_IMAGE ); } inline void SetSelected() { SetFlags( SELECTED ); } inline void SetBrightened() { SetFlags( BRIGHTENED ); } diff --git a/include/eda_text.h b/include/eda_text.h index a859c83e04..9a3e779567 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -336,24 +336,26 @@ public: static bool ValidateHyperlink( const wxString& aURL ); /** - * Check if aURL is a valid "goto" hyperlink. + * Check if aHref is a valid internal hyperlink. * - * @param aURL String to validate - * @param aDestinationIdx optional. pointer to populate with the page index destination - * @return true if aURL is a valid hyperlink + * @param aHref String to validate + * @param aDestination [optional] pointer to populate with the destination page + * @return true if aHref is a valid internal hyperlink. Does *not* check if the destination + * page actually exists. */ - static bool IsGotoPageHyperlink( const wxString& aURL, int* aDestination = nullptr ); + static bool IsGotoPageHref( const wxString& aHref, wxString* aDestination = nullptr ); /** - * Generate a hyperlink string that goes to the page number specified - * @param aDestination Virtual page number to go to. Note that the root sheet is 1. - * @return A hyperlink String that goes to the page number specified + * Generate a href to a page in the current schematic. + * + * @param aDestination Destination sheet's page number. + * @return A hyperlink href string that goes to the specified page. */ - static wxString GotoPageHyperlinkString( const int& aDestination ); + static wxString GotoPageHref( const wxString& aDestination ); protected: /** - * A hyperlink to a URL or file in the system. If empty, this text object is not a hyperlink + * A hyperlink URL. If empty, this text object is not a hyperlink. */ wxString m_hyperlink; diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index b805bd3c94..0b708519bd 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -123,7 +123,7 @@ public: */ virtual PLOT_FORMAT GetPlotterType() const = 0; - virtual bool StartPlot() = 0; + virtual bool StartPlot( const wxString& aPageNumber ) = 0; virtual bool EndPlot() = 0; virtual void SetNegative( bool aNegative ) { m_negativeMode = aNegative; } diff --git a/include/plotters/plotter_dxf.h b/include/plotters/plotter_dxf.h index f90e285f86..49fcfaa46b 100644 --- a/include/plotters/plotter_dxf.h +++ b/include/plotters/plotter_dxf.h @@ -61,7 +61,7 @@ public: /** * Open the DXF plot with a skeleton header. */ - virtual bool StartPlot() override; + virtual bool StartPlot( const wxString& aPageNumber ) override; virtual bool EndPlot() override; // For now we don't use 'thick' primitives, so no line width diff --git a/include/plotters/plotter_gerber.h b/include/plotters/plotter_gerber.h index 7801a32fbd..232939f474 100644 --- a/include/plotters/plotter_gerber.h +++ b/include/plotters/plotter_gerber.h @@ -49,7 +49,7 @@ public: /** * Write GERBER header to file initialize global variable g_Plot_PlotOutputFile. */ - virtual bool StartPlot() override; + virtual bool StartPlot( const wxString& pageNumber ) override; virtual bool EndPlot() override; virtual void SetCurrentLineWidth( int aLineWidth, void* aData = nullptr ) override; diff --git a/include/plotters/plotter_hpgl.h b/include/plotters/plotter_hpgl.h index ad2ec8e068..603f6f07ce 100644 --- a/include/plotters/plotter_hpgl.h +++ b/include/plotters/plotter_hpgl.h @@ -61,7 +61,7 @@ public: /** * At the start of the HPGL plot pen speed and number are requested. */ - virtual bool StartPlot() override; + virtual bool StartPlot( const wxString& aPageNumber ) override; /** * HPGL end of plot: sort and emit graphics, pen return and release. diff --git a/include/plotters/plotters_pslike.h b/include/plotters/plotters_pslike.h index 74d3d64ae9..7cfbd475c5 100644 --- a/include/plotters/plotters_pslike.h +++ b/include/plotters/plotters_pslike.h @@ -185,7 +185,7 @@ public: * BBox is the boundary box (position and size of the "client rectangle" * for drawings (page - margins) in mils (0.001 inch) */ - virtual bool StartPlot() override; + virtual bool StartPlot( const wxString& aPageNumber ) override; virtual bool EndPlot() override; /** @@ -273,13 +273,13 @@ public: * The PDF engine supports multiple pages; the first one is opened 'for free' the following * are to be closed and reopened. Between each page parameters can be set. */ - virtual bool StartPlot() override; + virtual bool StartPlot( const wxString& aPageNumber ) override; virtual bool EndPlot() override; /** * Start a new page in the PDF document. */ - virtual void StartPage(); + virtual void StartPage( const wxString& aPageNumber ); /** * Close the current page in the PDF document (and emit its compressed stream). @@ -417,8 +417,11 @@ protected: FILE* m_workFile; ///< Temporary file to construct the stream before zipping std::vector m_xrefTable; ///< The PDF xref offset table + ///< List of user-space page numbers for resolving internal hyperlinks + std::vector m_pageNumbers; + ///< List of loaded hyperlinks in current page - std::vector> m_hyperlinksInPage; + std::vector> m_hyperlinksInPage; ///< Handles for all the hyperlink objects that will be deferred std::map> m_hyperlinkHandles; @@ -445,7 +448,7 @@ public: /** * Create SVG file header. */ - virtual bool StartPlot() override; + virtual bool StartPlot( const wxString& aPageNumber ) override; virtual bool EndPlot() override; /** diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 8d323aa6f2..357c639767 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -207,7 +207,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ gbrplotter->AddLineToHeader( text ); } - plotter->StartPlot(); + plotter->StartPlot( wxT( "1" ) ); // Draw items on edge layer. // Not all, only items useful for drill map, i.e. board outlines. diff --git a/pcbnew/exporters/gendrill_gerber_writer.cpp b/pcbnew/exporters/gendrill_gerber_writer.cpp index 48e9807eae..04e86f79d8 100644 --- a/pcbnew/exporters/gendrill_gerber_writer.cpp +++ b/pcbnew/exporters/gendrill_gerber_writer.cpp @@ -156,9 +156,8 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth, // Add the standard X2 FileFunction for drill files // %TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH][Blind][Buried],Drill[Route][Mixed]*% wxString text = BuildFileFunctionAttributeString( aLayerPair, - aIsNpth - ? TYPE_FILE::NPTH_FILE - : TYPE_FILE::PTH_FILE ); + aIsNpth ? TYPE_FILE::NPTH_FILE + : TYPE_FILE::PTH_FILE ); plotter.AddLineToHeader( text ); // Add file polarity (positive) @@ -168,7 +167,7 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth, if( !plotter.OpenFile( aFullFilename ) ) return -1; - plotter.StartPlot(); + plotter.StartPlot( wxT( "1" ) ); holes_count = 0; diff --git a/pcbnew/exporters/gerber_placefile_writer.cpp b/pcbnew/exporters/gerber_placefile_writer.cpp index 4444b0f18d..0fb10d056e 100644 --- a/pcbnew/exporters/gerber_placefile_writer.cpp +++ b/pcbnew/exporters/gerber_placefile_writer.cpp @@ -109,7 +109,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER // We need a BRDITEMS_PLOTTER to plot pads BRDITEMS_PLOTTER brd_plotter( &plotter, m_pcb, plotOpts ); - plotter.StartPlot(); + plotter.StartPlot( wxT( "1" ) ); // Some tools in P&P files have the type and size defined. // they are position flash (round), pad1 flash (diamond), other pads flash (round) diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 5d679d0c32..bd7a267399 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1174,7 +1174,7 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL AddGerberX2Attribute( plotter, aBoard, aLayer, not useX2mode ); } - plotter->StartPlot(); + plotter->StartPlot( wxT( "1" ) ); // Plot the frame reference if requested if( aPlotOpts->GetPlotFrameRef() )