2 Copyright (C) 2014 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __canvas_stateful_image_h__
20 #define __canvas_stateful_image_h__
26 #include <cairomm/cairomm.h>
28 #include "canvas/item.h"
33 class FontDescription;
36 namespace ArdourCanvas {
38 class StatefulImage : public Item
41 typedef Cairo::RefPtr<Cairo::ImageSurface> ImageHandle;
48 typedef std::vector<State> States;
52 StatefulImage (Canvas*, const XMLNode&);
53 StatefulImage (Item*, const XMLNode&);
56 bool set_state (States::size_type);
57 void set_text (const std::string&);
59 void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
60 void compute_bounding_box () const;
62 static void set_image_search_path (const std::string&);
66 States::size_type _state;
68 Pango::FontDescription* _font;
73 int load_states (const XMLNode&);
75 typedef std::map<std::string,Cairo::RefPtr<Cairo::ImageSurface> > ImageCache;
76 static ImageCache _image_cache;
77 static PBD::Searchpath _image_search_path;
79 static ImageHandle find_image (const std::string&);
84 #endif /* __canvas_stateful_image_h__ */