]> git.saurik.com Git - wxWidgets.git/commitdiff
wxHyperlink page for widgets presentation.
authorWłodzimierz Skiba <abx@abx.art.pl>
Tue, 30 May 2006 11:55:24 +0000 (11:55 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Tue, 30 May 2006 11:55:24 +0000 (11:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39473 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/widgets/hyperlnk.cpp [new file with mode: 0644]
samples/widgets/icons/hyperlnk.xpm [new file with mode: 0644]
samples/widgets/makefile.bcc
samples/widgets/makefile.gcc
samples/widgets/makefile.vc
samples/widgets/makefile.wat
samples/widgets/widgets.bkl
samples/widgets/widgets.dsp

diff --git a/samples/widgets/hyperlnk.cpp b/samples/widgets/hyperlnk.cpp
new file mode 100644 (file)
index 0000000..5c091ba
--- /dev/null
@@ -0,0 +1,233 @@
+/////////////////////////////////////////////////////////////////////////////
+// Program:     wxWidgets Widgets Sample
+// Name:        hyperlnk.cpp
+// Purpose:     Part of the widgets sample showing wxHyperlinkCtrl
+// Author:      Dimitri Schoolwerth, Vadim Zeitlin
+// Created:     27 Sep 2003
+// Id:          $Id$
+// Copyright:   (c) 2003 wxWindows team
+// License:     wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#if wxUSE_HYPERLINKCTRL
+
+// for all others, include the necessary headers
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/log.h"
+
+    #include "wx/bitmap.h"
+    #include "wx/button.h"
+    #include "wx/checkbox.h"
+    #include "wx/radiobox.h"
+    #include "wx/statbox.h"
+    #include "wx/stattext.h"
+    #include "wx/textctrl.h"
+
+    #include "wx/sizer.h"
+#endif
+
+#include "wx/Hyperlink.h"
+
+#include "widgets.h"
+
+#include "icons/hyperlnk.xpm"
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// control ids
+enum
+{
+    HyperlinkPage_Reset = wxID_HIGHEST,
+    HyperlinkPage_SetLabel,
+    HyperlinkPage_SetURL,
+    HyperlinkPage_Ctrl
+};
+
+// ----------------------------------------------------------------------------
+// CheckBoxWidgetsPage
+// ----------------------------------------------------------------------------
+
+class HyperlinkWidgetsPage : public WidgetsPage
+{
+public:
+    HyperlinkWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
+    virtual ~HyperlinkWidgetsPage(){};
+
+    virtual wxControl *GetWidget() const { return m_hyperlink; }
+    virtual void RecreateWidget() { CreateHyperlink(); }
+
+protected:
+    // event handlers
+    void OnButtonSetLabel(wxCommandEvent& event);
+    void OnButtonSetURL(wxCommandEvent& event);
+
+    void OnButtonReset(wxCommandEvent& event);
+
+    // reset the control parameters
+    void Reset();
+
+    // (re)create the hyperctrl
+    void CreateHyperlink();
+
+    // the controls
+    // ------------
+
+    // the checkbox itself and the sizer it is in
+    wxHyperlinkCtrl *m_hyperlink;
+    wxSizer *m_sizerHyperlink;
+
+    wxTextCtrl *m_label;
+    wxTextCtrl *m_url;
+
+    wxStaticText *m_visit;
+    wxStaticText *m_fun;
+
+    // the text entries for command parameters
+    wxTextCtrl *m_textLabel;
+
+private:
+    DECLARE_EVENT_TABLE()
+    DECLARE_WIDGETS_PAGE(HyperlinkWidgetsPage)
+};
+
+// ----------------------------------------------------------------------------
+// event tables
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(HyperlinkWidgetsPage, WidgetsPage)
+    EVT_BUTTON(HyperlinkPage_Reset, HyperlinkWidgetsPage::OnButtonReset)
+    EVT_BUTTON(HyperlinkPage_SetLabel, HyperlinkWidgetsPage::OnButtonSetLabel)
+    EVT_BUTTON(HyperlinkPage_SetURL, HyperlinkWidgetsPage::OnButtonSetURL)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+IMPLEMENT_WIDGETS_PAGE(HyperlinkWidgetsPage, wxT("Hyperlink"),
+                       GENERIC_CTRLS
+                       );
+
+HyperlinkWidgetsPage::HyperlinkWidgetsPage(WidgetsBookCtrl *book,
+                                           wxImageList *imaglist)
+                      :WidgetsPage(book, imaglist, hyperlnk_xpm)
+{
+    wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
+
+    // left pane
+    wxStaticBox *box = new wxStaticBox(this, wxID_ANY, wxT("Hyperlink details"));
+
+    wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
+
+    sizerLeft->Add( CreateSizerWithTextAndButton( HyperlinkPage_SetLabel , wxT("Set &Label"), wxID_ANY, &m_label ),
+                    0, wxALL | wxALIGN_RIGHT , 5 );
+
+    sizerLeft->Add( CreateSizerWithTextAndButton( HyperlinkPage_SetURL , wxT("Set &URL"), wxID_ANY, &m_url ),
+                    0, wxALL | wxALIGN_RIGHT , 5 );
+
+    // right pane
+    wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
+
+    m_visit = new wxStaticText(this, wxID_ANY, wxT("Visit "));
+
+    m_hyperlink = new wxHyperlinkCtrl(this,
+                                      HyperlinkPage_Ctrl,
+                                      wxT("wxWidgets website"),
+                                      wxT("www.wxwidgets.org"));
+
+    m_fun = new wxStaticText(this, wxID_ANY, wxT(" for fun!"));
+
+    sizerRight->Add(0, 0, 1, wxCENTRE);
+    sizerRight->Add(m_visit, 0, wxCENTRE);
+    sizerRight->Add(m_hyperlink, 0, wxCENTRE);
+    sizerRight->Add(m_fun, 0, wxCENTRE);
+    sizerRight->Add(0, 0, 1, wxCENTRE);
+    sizerRight->SetMinSize(150, 0);
+    m_sizerHyperlink = sizerRight; // save it to modify it later
+
+    // the 3 panes panes compose the window
+    sizerTop->Add(sizerLeft, 0, (wxALL & ~wxLEFT), 10);
+    sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
+
+    // final initializations
+    Reset();
+
+    SetSizer(sizerTop);
+
+    sizerTop->Fit(this);
+}
+
+void HyperlinkWidgetsPage::Reset()
+{
+    m_label->SetValue(m_hyperlink->GetLabel());
+    m_url->SetValue(m_hyperlink->GetURL());
+}
+
+void HyperlinkWidgetsPage::CreateHyperlink()
+{
+    const wxString label = m_hyperlink->GetLabel();
+    const wxString url = m_hyperlink->GetURL();
+
+    size_t count = m_sizerHyperlink->GetChildren().GetCount();
+    for ( size_t n = 0; n < count; n++ )
+    {
+        m_sizerHyperlink->Remove(0);
+    }
+
+    delete m_hyperlink;
+
+    m_hyperlink = new wxHyperlinkCtrl(this,
+                                      HyperlinkPage_Ctrl,
+                                      label,
+                                      url);
+
+    m_sizerHyperlink->Add(0, 0, 1, wxCENTRE);
+    m_sizerHyperlink->Add(m_visit, 0, wxCENTRE);
+    m_sizerHyperlink->Add(m_hyperlink, 0, wxCENTRE);
+    m_sizerHyperlink->Add(m_fun, 0, wxCENTRE);
+    m_sizerHyperlink->Add(0, 0, 1, wxCENTRE);
+    m_sizerHyperlink->Layout();
+}
+
+// ----------------------------------------------------------------------------
+// event handlers
+// ----------------------------------------------------------------------------
+
+void HyperlinkWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
+{
+    Reset();
+
+    CreateHyperlink();
+}
+
+void HyperlinkWidgetsPage::OnButtonSetLabel(wxCommandEvent& WXUNUSED(event))
+{
+    m_hyperlink->SetLabel(m_label->GetValue());
+    CreateHyperlink();
+}
+
+void HyperlinkWidgetsPage::OnButtonSetURL(wxCommandEvent& WXUNUSED(event))
+{
+    m_hyperlink->SetURL(m_url->GetValue());
+    CreateHyperlink();
+}
+
+#endif // wxUSE_HYPERLINKCTRL
diff --git a/samples/widgets/icons/hyperlnk.xpm b/samples/widgets/icons/hyperlnk.xpm
new file mode 100644 (file)
index 0000000..cf0475d
--- /dev/null
@@ -0,0 +1,54 @@
+/* XPM */\r
+static char *hyperlnk_xpm[] = {\r
+/* columns rows colors chars-per-pixel */\r
+"32 32 16 1",\r
+"  c Gray0",\r
+". c #808000",\r
+"X c #000080",\r
+"o c #808080",\r
+"O c #000000",\r
+"+ c #808000",\r
+"@ c #000080",\r
+"# c none",\r
+"$ c #808080",\r
+"% c Red",\r
+"& c Green",\r
+"* c Yellow",\r
+"= c Blue",\r
+"- c Magenta",\r
+"; c Cyan",\r
+": c Gray100",\r
+/* pixels */\r
+"################################",\r
+"################################",\r
+"################################",\r
+"#######################%######%#",\r
+"#######################%#####%%%",\r
+"#######################%######%#",\r
+"%###%#%###%#%###%####%%%##%%##%#",\r
+"%#%#%#%#%#%#%#%#%###%##%#%##%#%#",\r
+"%#%#%#%#%#%#%#%#%###%##%#%##%#%#",\r
+"#%#%###%#%  #%#%##%##%%%##%%##%#",\r
+"######### :: ###################",\r
+"%%%%%%%%% :: %%%%%%%%%%%%%%%%%%%",\r
+"######### :: ###################",\r
+"######### :: ###################",\r
+"######### :: ###################",\r
+"########  ::   #################",\r
+"####### : :: ::   ##############",\r
+"###### :: :: :: ::   ###########",\r
+"###### :: :: :: :: :: ##########",\r
+"###### :::::::: :: :: ##########",\r
+"###### ::::::::::: :: ##########",\r
+"###### :::::::::::::: ##########",\r
+"###### :::::::::::::: ##########",\r
+"###### :::::::::::::: ##########",\r
+"###### :::::::::::::: ##########",\r
+"###### ::::::::::::: ###########",\r
+"####### :::::::::::: ###########",\r
+"####### ::::::::::: ############",\r
+"#######             ############",\r
+"################################",\r
+"################################",\r
+"################################"\r
+};\r
index ccfc6c6643029f781dce83f4b517c6a4e3f4802e..1f1e7db1215e3dba5e1e31295b2f9993c179b471 100644 (file)
@@ -39,6 +39,7 @@ WIDGETS_OBJECTS =  \
        $(OBJS)\widgets_combobox.obj \
        $(OBJS)\widgets_datepick.obj \
        $(OBJS)\widgets_gauge.obj \
+       $(OBJS)\widgets_hyperlnk.obj \
        $(OBJS)\widgets_listbox.obj \
        $(OBJS)\widgets_notebook.obj \
        $(OBJS)\widgets_radiobox.obj \
@@ -253,6 +254,9 @@ $(OBJS)\widgets_datepick.obj: .\datepick.cpp
 $(OBJS)\widgets_gauge.obj: .\gauge.cpp
        $(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) $**
 
+$(OBJS)\widgets_hyperlnk.obj: .\hyperlnk.cpp
+       $(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) $**
+
 $(OBJS)\widgets_listbox.obj: .\listbox.cpp
        $(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) $**
 
index 40e91ab6b2048277dbef81117b38af0bc36dc739..fe219c4656c26808ce1982e0a92fb649b322b3a5 100644 (file)
@@ -32,6 +32,7 @@ WIDGETS_OBJECTS =  \
        $(OBJS)\widgets_combobox.o \
        $(OBJS)\widgets_datepick.o \
        $(OBJS)\widgets_gauge.o \
+       $(OBJS)\widgets_hyperlnk.o \
        $(OBJS)\widgets_listbox.o \
        $(OBJS)\widgets_notebook.o \
        $(OBJS)\widgets_radiobox.o \
@@ -246,6 +247,9 @@ $(OBJS)\widgets_datepick.o: ./datepick.cpp
 $(OBJS)\widgets_gauge.o: ./gauge.cpp
        $(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
 
+$(OBJS)\widgets_hyperlnk.o: ./hyperlnk.cpp
+       $(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
+
 $(OBJS)\widgets_listbox.o: ./listbox.cpp
        $(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
 
index 421d7223aec6b4a5e8e2ae70d5f34bdb5438aa29..49a91e9ec422d14c86ab4175c9aa78d821276100 100644 (file)
@@ -32,6 +32,7 @@ WIDGETS_OBJECTS =  \
        $(OBJS)\widgets_combobox.obj \
        $(OBJS)\widgets_datepick.obj \
        $(OBJS)\widgets_gauge.obj \
+       $(OBJS)\widgets_hyperlnk.obj \
        $(OBJS)\widgets_listbox.obj \
        $(OBJS)\widgets_notebook.obj \
        $(OBJS)\widgets_radiobox.obj \
@@ -328,6 +329,9 @@ $(OBJS)\widgets_datepick.obj: .\datepick.cpp
 $(OBJS)\widgets_gauge.obj: .\gauge.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) $**
 
+$(OBJS)\widgets_hyperlnk.obj: .\hyperlnk.cpp
+       $(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) $**
+
 $(OBJS)\widgets_listbox.obj: .\listbox.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) $**
 
index 20615ff4f1b55c31f7f52c38b85517bbee32490d..dd433e2716faf710f1b2af4e4198fd93cc9d2fd9 100644 (file)
@@ -229,6 +229,7 @@ WIDGETS_OBJECTS =  &
        $(OBJS)\widgets_combobox.obj &
        $(OBJS)\widgets_datepick.obj &
        $(OBJS)\widgets_gauge.obj &
+       $(OBJS)\widgets_hyperlnk.obj &
        $(OBJS)\widgets_listbox.obj &
        $(OBJS)\widgets_notebook.obj &
        $(OBJS)\widgets_radiobox.obj &
@@ -283,6 +284,9 @@ $(OBJS)\widgets_datepick.obj :  .AUTODEPEND .\datepick.cpp
 $(OBJS)\widgets_gauge.obj :  .AUTODEPEND .\gauge.cpp
        $(CXX) -bt=nt -zq -fo=$^@ $(WIDGETS_CXXFLAGS) $<
 
+$(OBJS)\widgets_hyperlnk.obj :  .AUTODEPEND .\hyperlnk.cpp
+       $(CXX) -bt=nt -zq -fo=$^@ $(WIDGETS_CXXFLAGS) $<
+
 $(OBJS)\widgets_listbox.obj :  .AUTODEPEND .\listbox.cpp
        $(CXX) -bt=nt -zq -fo=$^@ $(WIDGETS_CXXFLAGS) $<
 
index 1f57e7e8a3cb52b88d234ebae9143355ab5f53c5..ff0ff4ce77b90b91909e63b9b9209733183c660b 100644 (file)
@@ -10,6 +10,7 @@
             combobox.cpp
             datepick.cpp
             gauge.cpp
+            hyperlnk.cpp
             listbox.cpp
             notebook.cpp
             radiobox.cpp
index 9b7a89b87559a41668ede0373261225168cfad6e..a39c576c3bc96ad336506396694032f6bf272a92 100644 (file)
@@ -488,6 +488,10 @@ SOURCE=.\gauge.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\hyperlnk.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\listbox.cpp
 # End Source File
 # Begin Source File