]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/htlbox/htlbox.cpp
1. renamed wxFontMapper::IsWxFontMapper() to IsDummy() (with reverse semantics)
[wxWidgets.git] / samples / htlbox / htlbox.cpp
index 95d99d5c0e467c4eea9569cea4478628113ae3a0..0522932c5ec88584932985be2d390e99c95b1ec1 100644 (file)
@@ -37,6 +37,7 @@
     #include "wx/textctrl.h"
 
     #include "wx/dc.h"
+    #include "wx/icon.h"
 #endif
 
 #include "wx/colordlg.h"
     #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("<h%d><font color=#%2x%2x%2x>")
-                            _T("Item</font> <b>%lu</b>")
-                            _T("</h%d>"),
-                            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("<h%d><font color=#%2x%2x%2x>")
+                                      _T("Item</font> <b>%lu</b>")
+                                      _T("</h%d>"),
+                                      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("<a href='1'>Click here...</a>");
+        else
+            label += _T("<font color='#9999ff'>Clicked here...</font>");
+    }
+
+    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);
+}