X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/50f65637a84135808d0fa246b7f53c6d66889a74..1dbcdf2d24c896eb1b4028877964146bf1703c49:/samples/artprov/artbrows.cpp diff --git a/samples/artprov/artbrows.cpp b/samples/artprov/artbrows.cpp index 2543ca97af..0fd8a8aae9 100644 --- a/samples/artprov/artbrows.cpp +++ b/samples/artprov/artbrows.cpp @@ -9,10 +9,6 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "artbrows.h" -#endif - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -146,6 +142,9 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) subsizer->Add(m_list, 1, wxEXPAND | wxRIGHT, 10); wxSizer *subsub = new wxBoxSizer(wxVERTICAL); + m_text = new wxStaticText(this, wxID_ANY, wxT("Size: 333x333")); + subsub->Add(m_text); + m_canvas = new wxStaticBitmap(this, wxID_ANY, wxBitmap(null_xpm)); subsub->Add(m_canvas); subsub->Add(100, 100); @@ -173,20 +172,24 @@ void wxArtBrowserDialog::SetArtClient(const wxArtClient& client) img->Add(wxIcon(null_xpm)); int index = 0; + long sel = m_list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED); + if (sel < 0) sel = 0; + m_list->DeleteAllItems(); FillBitmaps(img, m_list, index, client, wxSize(16, 16)); m_list->AssignImageList(img, wxIMAGE_LIST_SMALL); m_list->SetColumnWidth(0, wxLIST_AUTOSIZE); + m_list->SetItemState(sel, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); + m_client = client; + SetArtBitmap((const wxChar*)m_list->GetItemData(sel), m_client); } void wxArtBrowserDialog::OnSelectItem(wxListEvent &event) { const wxChar *data = (const wxChar*)event.GetData(); - wxBitmap bmp = wxArtProvider::GetBitmap(data, m_client); - m_canvas->SetBitmap(bmp); - m_canvas->SetSize(bmp.GetWidth(), bmp.GetHeight()); + SetArtBitmap(data, m_client, wxDefaultSize); } void wxArtBrowserDialog::OnChooseClient(wxCommandEvent &event) @@ -194,3 +197,12 @@ void wxArtBrowserDialog::OnChooseClient(wxCommandEvent &event) const wxChar *data = (const wxChar*)event.GetClientData(); SetArtClient(data); } + +void wxArtBrowserDialog::SetArtBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size) +{ + wxBitmap bmp = wxArtProvider::GetBitmap(id, client, size); + m_canvas->SetSize(bmp.GetWidth(), bmp.GetHeight()); + m_canvas->SetBitmap(bmp); + m_text->SetLabel(wxString::Format(wxT("Size: %d x %d"), bmp.GetWidth(), bmp.GetHeight())); + Refresh(); +}