]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/artprov/artbrows.cpp
fixed wxXmlResource::Load's detection of filenames to be done as early as possible
[wxWidgets.git] / samples / artprov / artbrows.cpp
index 6ecf00a2979edf252b739f63c3a0663172682bea..599c36c9c362183939835a5475d704af9b6a1e1c 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "artbrows.h"
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
@@ -83,7 +79,6 @@ static void FillBitmaps(wxImageList *images, wxListCtrl *list,
     ART_ICON(wxART_GO_DOWN)
     ART_ICON(wxART_GO_TO_PARENT)
     ART_ICON(wxART_GO_HOME)
     ART_ICON(wxART_GO_DOWN)
     ART_ICON(wxART_GO_TO_PARENT)
     ART_ICON(wxART_GO_HOME)
-    ART_ICON(wxART_FILE_OPEN)
     ART_ICON(wxART_PRINT)
     ART_ICON(wxART_HELP)
     ART_ICON(wxART_TIP)
     ART_ICON(wxART_PRINT)
     ART_ICON(wxART_HELP)
     ART_ICON(wxART_TIP)
@@ -91,12 +86,30 @@ static void FillBitmaps(wxImageList *images, wxListCtrl *list,
     ART_ICON(wxART_LIST_VIEW)
     ART_ICON(wxART_NEW_DIR)
     ART_ICON(wxART_FOLDER)
     ART_ICON(wxART_LIST_VIEW)
     ART_ICON(wxART_NEW_DIR)
     ART_ICON(wxART_FOLDER)
+    ART_ICON(wxART_FOLDER_OPEN);
     ART_ICON(wxART_GO_DIR_UP)
     ART_ICON(wxART_EXECUTABLE_FILE)
     ART_ICON(wxART_NORMAL_FILE)
     ART_ICON(wxART_TICK_MARK)
     ART_ICON(wxART_CROSS_MARK)
     ART_ICON(wxART_MISSING_IMAGE)
     ART_ICON(wxART_GO_DIR_UP)
     ART_ICON(wxART_EXECUTABLE_FILE)
     ART_ICON(wxART_NORMAL_FILE)
     ART_ICON(wxART_TICK_MARK)
     ART_ICON(wxART_CROSS_MARK)
     ART_ICON(wxART_MISSING_IMAGE)
+    ART_ICON(wxART_NEW);
+    ART_ICON(wxART_FILE_OPEN)
+    ART_ICON(wxART_FILE_SAVE)
+    ART_ICON(wxART_FILE_SAVE_AS)
+    ART_ICON(wxART_DELETE);
+    ART_ICON(wxART_COPY)
+    ART_ICON(wxART_CUT)
+    ART_ICON(wxART_PASTE)
+    ART_ICON(wxART_UNDO)
+    ART_ICON(wxART_REDO)
+    ART_ICON(wxART_QUIT)
+    ART_ICON(wxART_FIND)
+    ART_ICON(wxART_FIND_AND_REPLACE)
+    ART_ICON(wxART_HARDDISK)
+    ART_ICON(wxART_FLOPPY)
+    ART_ICON(wxART_CDROM)
+    ART_ICON(wxART_REMOVABLE)
 }
 
 
 }
 
 
@@ -135,6 +148,9 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent)
     subsizer->Add(m_list, 1, wxEXPAND | wxRIGHT, 10);
 
     wxSizer *subsub = new wxBoxSizer(wxVERTICAL);
     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);
     m_canvas = new wxStaticBitmap(this, wxID_ANY, wxBitmap(null_xpm));
     subsub->Add(m_canvas);
     subsub->Add(100, 100);
@@ -146,8 +162,7 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent)
     ok->SetDefault();
     sizer->Add(ok, 0, wxALIGN_RIGHT | wxALL, 10);
 
     ok->SetDefault();
     sizer->Add(ok, 0, wxALIGN_RIGHT | wxALL, 10);
 
-    SetSizer(sizer);
-    sizer->Fit(this);
+    SetSizerAndFit(sizer);
 
     choice->SetSelection(6/*wxART_MESSAGE_BOX*/);
     SetArtClient(wxART_MESSAGE_BOX);
 
     choice->SetSelection(6/*wxART_MESSAGE_BOX*/);
     SetArtClient(wxART_MESSAGE_BOX);
@@ -162,20 +177,24 @@ void wxArtBrowserDialog::SetArtClient(const wxArtClient& client)
     img->Add(wxIcon(null_xpm));
     int index = 0;
 
     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->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;
     m_client = client;
+    SetArtBitmap((const wxChar*)m_list->GetItemData(sel), m_client);
 }
 
 void wxArtBrowserDialog::OnSelectItem(wxListEvent &event)
 {
     const wxChar *data = (const wxChar*)event.GetData();
 }
 
 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)
 }
 
 void wxArtBrowserDialog::OnChooseClient(wxCommandEvent &event)
@@ -183,3 +202,12 @@ void wxArtBrowserDialog::OnChooseClient(wxCommandEvent &event)
     const wxChar *data = (const wxChar*)event.GetClientData();
     SetArtClient(data);
 }
     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();
+}