]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/button.cpp
Fix wrong in wxListCtrl::SetItemColumnImage() in r74716.
[wxWidgets.git] / samples / widgets / button.cpp
index e5bedb53b704d8542a46de0c4e68af99c6f50f70..ac100e2b5a50c4a9134a95f8871d747322bbef66 100644 (file)
@@ -4,7 +4,6 @@
 // Purpose:     Part of the widgets sample showing wxButton
 // Author:      Vadim Zeitlin
 // Created:     10.04.01
-// Id:          $Id$
 // Copyright:   (c) 2001 Vadim Zeitlin
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -131,7 +130,11 @@ protected:
 #if wxUSE_COMMANDLINKBUTTON
                *m_chkCommandLink,
 #endif // wxUSE_COMMANDLINKBUTTON
-               *m_chkDefault;
+#if wxUSE_MARKUP
+               *m_chkUseMarkup,
+#endif // wxUSE_MARKUP
+               *m_chkDefault,
+               *m_chkUseBitmapClass;
 
     // more checkboxes for wxBitmapButton only
     wxCheckBox *m_chkUsePressed,
@@ -209,7 +212,11 @@ ButtonWidgetsPage::ButtonWidgetsPage(WidgetsBookCtrl *book,
 #if wxUSE_COMMANDLINKBUTTON
     m_chkCommandLink =
 #endif // wxUSE_COMMANDLINKBUTTON
+#if wxUSE_MARKUP
+    m_chkUseMarkup =
+#endif // wxUSE_MARKUP
     m_chkDefault =
+    m_chkUseBitmapClass =
     m_chkUsePressed =
     m_chkUseFocused =
     m_chkUseCurrent =
@@ -241,8 +248,15 @@ void ButtonWidgetsPage::CreateContent()
 #if wxUSE_COMMANDLINKBUTTON
     m_chkCommandLink = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("Use command &link button"));
 #endif
+#if wxUSE_MARKUP
+    m_chkUseMarkup = CreateCheckBoxAndAddToSizer(sizerLeft, "Interpret &markup");
+#endif // wxUSE_MARKUP
     m_chkDefault = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Default"));
 
+    m_chkUseBitmapClass = CreateCheckBoxAndAddToSizer(sizerLeft,
+        "Use wxBitmapButton");
+    m_chkUseBitmapClass->SetValue(true);
+
     sizerLeft->AddSpacer(5);
 
     wxSizer *sizerUseLabels =
@@ -351,6 +365,10 @@ void ButtonWidgetsPage::Reset()
 #if wxUSE_COMMANDLINKBUTTON
     m_chkCommandLink->SetValue(false);
 #endif
+#if wxUSE_MARKUP
+    m_chkUseMarkup->SetValue(false);
+#endif // wxUSE_MARKUP
+    m_chkUseBitmapClass->SetValue(true);
 
     m_chkUsePressed->SetValue(true);
     m_chkUseFocused->SetValue(true);
@@ -437,8 +455,17 @@ void ButtonWidgetsPage::CreateButton()
     {
         showsBitmap = true;
 
-        wxBitmapButton *bbtn = new wxBitmapButton(this, ButtonPage_Button,
-                                                  CreateBitmap(wxT("normal")));
+        wxButton *bbtn;
+        if ( m_chkUseBitmapClass->GetValue() )
+        {
+          bbtn = new wxBitmapButton(this, ButtonPage_Button,
+                                    CreateBitmap(wxT("normal")));
+        }
+        else
+        {
+          bbtn = new wxButton(this, ButtonPage_Button);
+          bbtn->SetBitmapLabel(CreateBitmap(wxT("normal")));
+        }
         if ( m_chkUsePressed->GetValue() )
             bbtn->SetBitmapPressed(CreateBitmap(wxT("pushed")));
         if ( m_chkUseFocused->GetValue() )
@@ -485,19 +512,21 @@ void ButtonWidgetsPage::CreateButton()
             wxLEFT, wxRIGHT, wxTOP, wxBOTTOM
         };
 
-        m_button->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION),
+        m_button->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_BUTTON),
                             positions[m_radioImagePos->GetSelection()]);
 
         if ( m_chkUsePressed->GetValue() )
-            m_button->SetBitmapPressed(wxArtProvider::GetIcon(wxART_HELP));
+            m_button->SetBitmapPressed(wxArtProvider::GetIcon(wxART_HELP, wxART_BUTTON));
         if ( m_chkUseFocused->GetValue() )
-            m_button->SetBitmapFocus(wxArtProvider::GetIcon(wxART_ERROR));
+            m_button->SetBitmapFocus(wxArtProvider::GetIcon(wxART_ERROR, wxART_BUTTON));
         if ( m_chkUseCurrent->GetValue() )
-            m_button->SetBitmapCurrent(wxArtProvider::GetIcon(wxART_WARNING));
+            m_button->SetBitmapCurrent(wxArtProvider::GetIcon(wxART_WARNING, wxART_BUTTON));
         if ( m_chkUseDisabled->GetValue() )
-            m_button->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE));
+            m_button->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE, wxART_BUTTON));
     }
 
+    m_chkUseBitmapClass->Enable(showsBitmap);
+
     m_chkUsePressed->Enable(showsBitmap);
     m_chkUseFocused->Enable(showsBitmap);
     m_chkUseCurrent->Enable(showsBitmap);
@@ -547,12 +576,21 @@ void ButtonWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
 
 void ButtonWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event))
 {
+    const wxString labelText = m_textLabel->GetValue();
+
 #if wxUSE_COMMANDLINKBUTTON
     if ( m_cmdLnkButton )
-        m_cmdLnkButton->SetMainLabel(m_textLabel->GetValue());
+        m_cmdLnkButton->SetMainLabel(labelText);
     else
 #endif // wxUSE_COMMANDLINKBUTTON
-        m_button->SetLabel(m_textLabel->GetValue());
+    {
+#if wxUSE_MARKUP
+        if ( m_chkUseMarkup->GetValue() )
+            m_button->SetLabelMarkup(labelText);
+        else
+#endif // wxUSE_MARKUP
+            m_button->SetLabel(labelText);
+    }
 
     m_sizerButton->Layout();
 }
@@ -580,7 +618,7 @@ wxBitmap ButtonWidgetsPage::CreateBitmap(const wxString& label)
     wxBitmap bmp(180, 70); // shouldn't hardcode but it's simpler like this
     wxMemoryDC dc;
     dc.SelectObject(bmp);
-    dc.SetBackground(wxBrush(*wxCYAN));
+    dc.SetBackground(*wxCYAN_BRUSH);
     dc.Clear();
     dc.SetTextForeground(*wxBLACK);
     dc.DrawLabel(wxStripMenuCodes(m_textLabel->GetValue()) + wxT("\n")