X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1d41ed0a1c5cfa808398084b1e733728e2270320..d5bfbd9ab85dd7f07f5cb97353bca4963e63202a:/samples/htlbox/htlbox.cpp?ds=sidebyside diff --git a/samples/htlbox/htlbox.cpp b/samples/htlbox/htlbox.cpp index 95d99d5c0e..0522932c5e 100644 --- a/samples/htlbox/htlbox.cpp +++ b/samples/htlbox/htlbox.cpp @@ -37,6 +37,7 @@ #include "wx/textctrl.h" #include "wx/dc.h" + #include "wx/icon.h" #endif #include "wx/colordlg.h" @@ -51,14 +52,7 @@ #include "wx/textfile.h" #endif -// ---------------------------------------------------------------------------- -// resources -// ---------------------------------------------------------------------------- - -// the application icon (under Windows and OS/2 it is in resources) -#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__) - #include "mondrian.xpm" -#endif +#include "../sample.xpm" // ---------------------------------------------------------------------------- // private classes @@ -83,6 +77,8 @@ protected: virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const; virtual wxColour GetSelectedTextColour(const wxColour& colFg) const; + // override this method to handle mouse clicks + virtual void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link); // flag telling us whether we should use fg colour even for the selected // item @@ -91,6 +87,9 @@ protected: // flag which we toggle to update the first items text in OnGetItem() bool m_firstItemUpdated; + // flag which we toggle when the user clicks on the link in 2nd item + // to change 2nd item's text + bool m_linkClicked; #ifdef USE_HTML_FILE @@ -210,7 +209,7 @@ MyFrame::MyFrame() wxDefaultPosition, wxSize(400, 500)) { // set the frame icon - SetIcon(wxICON(mondrian)); + SetIcon(wxIcon(sample_xpm)); #if wxUSE_MENUS // create a menu bar @@ -429,6 +428,7 @@ MyHtmlListBox::MyHtmlListBox(wxWindow *parent, bool multi) { m_change = true; m_firstItemUpdated = false; + m_linkClicked = false; SetMargins(5, 5); @@ -475,14 +475,23 @@ wxString MyHtmlListBox::OnGetItem(size_t n) const return s; #else int level = n % 6 + 1; - return wxString::Format(_T("") - _T("Item %lu") - _T(""), - level, - abs((int)n - 192) % 256, - abs((int)n - 256) % 256, - abs((int)n - 128) % 256, - (unsigned long)n, level); + wxString label = wxString::Format(_T("") + _T("Item %lu") + _T(""), + level, + abs((int)n - 192) % 256, + abs((int)n - 256) % 256, + abs((int)n - 128) % 256, + (unsigned long)n, level); + if ( n == 1 ) + { + if ( !m_linkClicked ) + label += _T("Click here..."); + else + label += _T("Clicked here..."); + } + + return label; #endif } @@ -498,3 +507,10 @@ void MyHtmlListBox::UpdateFirstItem() RefreshLine(0); } +void MyHtmlListBox::OnLinkClicked(size_t WXUNUSED(n), + const wxHtmlLinkInfo& WXUNUSED(link)) +{ + m_linkClicked = true; + + RefreshLine(1); +}