@@ -37,6 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3737#include < wx/statline.h>
3838#include < wx/tokenzr.h>
3939#include < wx/dir.h>
40+ #include < wx/gdicmn.h>
4041
4142#include < wex/exttree.h>
4243#include < wex/exttext.h>
@@ -65,6 +66,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6566#include " macro.h"
6667
6768#include " ../resource/graph.cpng"
69+ #include " ../resource/notes.cpng"
70+
6871
6972class CollapsePaneCtrl : public wxPanel
7073{
@@ -147,16 +150,11 @@ BEGIN_EVENT_TABLE( CaseWindow, wxSplitterWindow )
147150 EVT_LISTBOX( ID_INPUTPAGELIST , CaseWindow::OnCommand )
148151 EVT_DATAVIEW_SELECTION_CHANGED(ID_TechTree, CaseWindow::OnTree)
149152 EVT_DATAVIEW_ITEM_COLLAPSING(ID_TechTree, CaseWindow::OnTreeCollapsing)
150-
151- // EVT_DATAVIEW_ITEM_START_EDITING(ID_TechTree, CaseWindow::OnTreeActivated)
152- // EVT_DATAVIEW_ITEM_ACTIVATED(ID_TechTree, CaseWindow::OnTreeActivated)
153- // EVT_LISTBOX( ID_TechTree, CaseWindow::OnCommand)
154153 EVT_BUTTON( ID_EXCL_BUTTON , CaseWindow::OnCommand )
155154 EVT_LISTBOX( ID_EXCL_RADIO , CaseWindow::OnCommand)
156155 EVT_CHECKBOX( ID_COLLAPSE , CaseWindow::OnCommand )
157156 EVT_MENU_RANGE( ID_EXCL_OPTION , ID_EXCL_OPTION_MAX , CaseWindow::OnCommand )
158157 EVT_LISTBOX( ID_EXCL_TABLIST , CaseWindow::OnCommand )
159-
160158 EVT_NOTEBOOK_PAGE_CHANGED( ID_PAGES , CaseWindow::OnSubNotebookPageChanged )
161159 EVT_NOTEBOOK_PAGE_CHANGED( ID_BASECASE_PAGES , CaseWindow::OnSubNotebookPageChanged )
162160END_EVENT_TABLE()
@@ -177,7 +175,7 @@ CaseWindow::CaseWindow( wxWindow *parent, Case *c )
177175 wxFont lafont (*wxNORMAL_FONT);
178176 lafont.SetWeight (wxFONTWEIGHT_BOLD);
179177
180- m_pageNote = 0 ;
178+ m_pageNote = new PageNote ( this ); // create page note before m_pageFlipper adds pages
181179 m_currentGroup = 0 ;
182180
183181 // navigation menu objects
@@ -297,8 +295,6 @@ CaseWindow::CaseWindow( wxWindow *parent, Case *c )
297295 SetMinimumPaneSize ( 50 );
298296 SplitVertically ( m_left_panel, m_pageFlipper, (int )(210 *xScale) );
299297
300- m_pageNote = new PageNote ( this );
301-
302298 // load page note window geometry
303299 int nw_xrel, nw_yrel, nw_w, nw_h;
304300 double sf = wxGetScreenHDScale ();
@@ -637,6 +633,8 @@ bool CaseWindow::GenerateReport( wxString pdffile, wxString templfile, VarValue
637633
638634void CaseWindow::OnTree (wxDataViewEvent &evt)
639635{
636+ UpdateNotesIcon (); // when leaving a page and notes erased
637+
640638 m_pageFlipper->SetSelection (0 );
641639 wxDataViewItem dvi = evt.GetItem ();
642640 if (!dvi.IsOk ())
@@ -660,10 +658,30 @@ void CaseWindow::OnTree(wxDataViewEvent &evt)
660658 else {
661659 m_currentSelection = evt.GetItem ();
662660 }
661+
662+ /*
663+ if (HasPageNote(GetCurrentContext())) {
664+ m_navigationMenu->SetItemIcon(m_currentSelection, wxBitmapBundle::FromBitmap(wxBITMAP_PNG_FROM_DATA(notes)));
665+ //m_navigationMenu->im // TODO set images and override onImagesChanged method to show notes icon
666+ m_navigationMenu->Refresh();
667+ }
668+ // update all navigation items note icon
669+ m_navigationMenu->get
670+ auto bmb = wxBitmapBundle::FromBitmap(wxBITMAP_PNG_FROM_DATA(notes));
671+ for (size_t i = 0; i < m_pageGroups.size(); i++)
672+ if (HasPageNote(m_pageGroups[i]->HelpContext)
673+ m_currentGroup = m_pageGroups[i];
674+
675+ */
676+
677+
663678 wxString title = m_navigationMenu->GetItemText (m_currentSelection);
664679 m_navigationMenu->SetFocus ();
665680 SwitchToInputPage (title);
666681
682+ m_left_panel->Layout (); // Issue 1552
683+ // wxVariant x = wxDataViewIconText("text", wxBitmapBundle::FromBitmap(wxBITMAP_PNG_FROM_DATA(notes)));
684+ // m_navigationMenu->SetItemData(m_currentSelection,(wxClientData*) & x);
667685}
668686
669687void CaseWindow::OnTreeCollapsing (wxDataViewEvent& evt)
@@ -1076,7 +1094,7 @@ bool CaseWindow::SwitchToInputPage( const wxString &name )
10761094 wxBusyCursor wait;
10771095// m_inputPagePanel->Freeze();
10781096
1079- // DetachCurrentInputPage();
1097+ // DetachCurrentInputPage();
10801098
10811099 m_currentGroup = 0 ;
10821100 for ( size_t i=0 ;i<m_pageGroups.size ();i++ )
@@ -1100,6 +1118,8 @@ bool CaseWindow::SwitchToInputPage( const wxString &name )
11001118// if ( m_inputPageList->GetStringSelection() != name )
11011119 int p = m_inputPageList->Find (name);
11021120 m_inputPageList->Select ( p );
1121+ m_inputPageList->Refresh ();
1122+ m_left_panel->Layout ();// try to force onPaint call for the input page list
11031123
11041124 return true ;
11051125}
@@ -1469,7 +1489,7 @@ void CaseWindow::UpdateConfiguration()
14691489 if (cfg->TechnologyFullName .Contains (" Generic" )) return ; // if generic get out of the loop
14701490
14711491 wxDataViewItem dvi = m_navigationMenu->GetNthChild (wxDataViewItem (0 ), 0 );
1472- if (m_navigationMenu->IsContainer (dvi)) {
1492+ if (dvi. IsOk () && m_navigationMenu->IsContainer (dvi)) {
14731493 dvi = m_navigationMenu->GetNthChild (dvi, 0 );
14741494 }
14751495
@@ -1479,7 +1499,7 @@ void CaseWindow::UpdateConfiguration()
14791499 }
14801500
14811501 // check for orphaned notes and if any found add to first page per Github issue 796
1482- CheckAndUpdateNotes (inputPageHelpContext);
1502+ // CheckAndUpdateNotes(inputPageHelpContext);
14831503
14841504 m_szsims->Clear (true );
14851505 if (m_case->GetTechnology ().Contains (" wave" ) || m_case->GetTechnology ().Contains (" tidal" )) {
@@ -1577,12 +1597,56 @@ void CaseWindow::UpdatePageNote()
15771597 // update ID
15781598 m_lastPageNoteId = GetCurrentContext ();
15791599
1580- // update text on page note
1600+ // update text on page note
15811601 wxString text = m_case->RetrieveNote ( m_lastPageNoteId );
15821602 m_pageNote->SetText (text);
1583- m_pageNote->Show ( SamApp::Window ()->GetCurrentCaseWindow () == this && !text.IsEmpty () );
1603+
1604+ bool bShowNote = SamApp::Window ()->GetCurrentCaseWindow () == this && !text.IsEmpty ();
1605+
1606+ m_pageNote->Show ( bShowNote );
1607+
1608+ UpdateNotesIcon ();
15841609}
15851610
1611+ void CaseWindow::UpdateNotesIcon ()
1612+ {
1613+ wxDataViewModel* model = m_navigationMenu->GetModel ();
1614+ if (!model)
1615+ return ;
1616+
1617+ // Get the invisible root item
1618+ wxDataViewItem root = model->GetParent (wxDataViewItem (nullptr ));
1619+
1620+ // Start iteration (depth-first traversal shown)
1621+ UpdateNotesIconChildren (model, root);
1622+ }
1623+
1624+ void CaseWindow::UpdateNotesIconChildren (wxDataViewModel* model, const wxDataViewItem& parent)
1625+ {
1626+ wxDataViewItemArray children;
1627+ model->GetChildren (parent, children);
1628+ for (const wxDataViewItem& child : children) {
1629+ // Check if the child item has a note
1630+ bool bShowNote = false ;
1631+ for (auto pg : m_pageGroups) {
1632+ if (pg->SideBarLabel == m_navigationMenu->GetItemText (child))
1633+ bShowNote = HasPageNote (pg->HelpContext );
1634+ }
1635+
1636+ if (bShowNote) {
1637+ m_navigationMenu->SetItemIcon (child, wxBitmapBundle::FromBitmap (wxBITMAP_PNG_FROM_DATA (notes)));
1638+ }
1639+ else {
1640+ m_navigationMenu->SetItemIcon (child, wxNullBitmap);
1641+ }
1642+ // Recursively check its children if it's a container
1643+ if (model->IsContainer (child)) {
1644+ UpdateNotesIconChildren (model, child);
1645+ }
1646+ }
1647+ }
1648+
1649+
15861650void CaseWindow::ShowPageNote ()
15871651{
15881652 m_pageNote->Show ();
@@ -1600,7 +1664,7 @@ bool CaseWindow::HasPageNote(const wxString &id)
16001664 return !id.IsEmpty () && !m_case->RetrieveNote (id).IsEmpty ();
16011665}
16021666
1603- void CaseWindow::OnSubNotebookPageChanged ( wxNotebookEvent & )
1667+ void CaseWindow::OnSubNotebookPageChanged ( wxNotebookEvent &evt )
16041668{
16051669 // common event handler for notebook page events to update the page note
16061670 UpdatePageNote ();
0 commit comments