diff --git a/src/Makefile.am b/src/Makefile.am index 3c60f12..2b76eb9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,8 @@ bin_PROGRAMS = spek spek_SOURCES = \ + spek-artwork.hh \ + spek-artwork.cc \ spek-audio-desc.cc \ spek-audio-desc.hh \ spek-events.cc \ diff --git a/src/spek-artwork.cc b/src/spek-artwork.cc new file mode 100644 index 0000000..4653dab --- /dev/null +++ b/src/spek-artwork.cc @@ -0,0 +1,59 @@ +/* spek-artwork.cc + * + * Copyright (C) 2012 Alexander Kojevnikov + * + * Spek is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Spek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Spek. If not, see . + */ + +#include +#include + +#include "spek-artwork.hh" + +class SpekArtProvider : public wxArtProvider +{ +protected: + virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size); +#if ART_HAS_ICON_BUNDLES + virtual wxIconBundle CreateIconBundle(const wxArtID& id, const wxArtClient& client); +#endif +}; + +wxBitmap SpekArtProvider::CreateBitmap( + const wxArtID& id, const wxArtClient& client, const wxSize& size) +{ + if (id == ART_SPEK) { +#ifdef OS_UNIX + return wxArtProvider::GetBitmap(wxT("spek"), client, size); +#endif + } + return wxNullBitmap; +} + +#if ART_HAS_ICON_BUNDLES +wxIconBundle SpekArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client) +{ + if (id == ART_SPEK) { +#ifdef OS_UNIX + return wxArtProvider::GetIconBundle(wxT("spek"), client); +#endif + } + return wxNullIconBundle; +} +#endif + +void spek_artwork_init() +{ + wxArtProvider::Push(new SpekArtProvider()); +} diff --git a/src/spek-artwork.hh b/src/spek-artwork.hh new file mode 100644 index 0000000..3bf83e8 --- /dev/null +++ b/src/spek-artwork.hh @@ -0,0 +1,34 @@ +/* spek-artwork.hh + * + * Copyright (C) 2012 Alexander Kojevnikov + * + * Spek is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Spek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Spek. If not, see . + */ + +#ifndef SPEK_ARTWORK_HH_ +#define SPEK_ARTWORK_HH_ + +#include + +#define ART_HAS_ICON_BUNDLES wxCHECK_VERSION(2, 9, 0) + +#define ART_SPEK wxT("art-spek") +#define ART_OPEN wxT("art-open") +#define ART_SAVE wxT("art-save") +#define ART_ABOUT wxT("art-about") +#define ART_CLOSE wxT("art-close") + +void spek_artwork_init(); + +#endif diff --git a/src/spek-window.cc b/src/spek-window.cc index 878b8bd..0b9eb87 100644 --- a/src/spek-window.cc +++ b/src/spek-window.cc @@ -30,6 +30,7 @@ extern "C" { #include } +#include "spek-artwork.hh" #include "spek-preferences-dialog.hh" #include "spek-preferences.hh" #include "spek-spectrogram.hh" @@ -74,8 +75,12 @@ SpekWindow::SpekWindow(const wxString& path) : { this->description = _("Spek - Acoustic Spectrum Analyser"); SetTitle(this->description); - // TODO: test on all platforms - //SetIcon(wxIcon(wxT("spek"))); + +#if ART_HAS_ICON_BUNDLES + SetIcons(wxArtProvider::GetIconBundle(ART_SPEK)); +#else + SetIcon(wxArtProvider::GetIcon(ART_SPEK, wxART_OTHER, wxSize(48, 48))); +#endif wxMenuBar *menu = new wxMenuBar(); diff --git a/src/spek.cc b/src/spek.cc index 436d936..7861068 100644 --- a/src/spek.cc +++ b/src/spek.cc @@ -24,6 +24,7 @@ extern "C" { #include } +#include "spek-artwork.hh" #include "spek-platform.hh" #include "spek-preferences.hh" @@ -51,6 +52,8 @@ bool Spek::OnInit() wxSocketBase::Initialize(); spek_audio_init(); + + spek_artwork_init(); spek_platform_init(); SpekPreferences::get().init();