edelib  2.1.0
IconLoader.h
1 /*
2  * $Id: IconLoader.h 3441 2012-11-01 20:40:30Z karijes $
3  *
4  * Icon loader via IconTheme
5  * Copyright (c) 2009 edelib authors
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __EDELIB_ICONLOADER_H__
22 #define __EDELIB_ICONLOADER_H__
23 
24 #include "IconTheme.h"
25 
26 class Fl_Shared_Image;
27 class Fl_Widget;
28 
29 EDELIB_NS_BEGIN
30 
31 struct IconLoaderItem;
32 
41  ICON_LOADER_OPTION_NO_WIDGET_REDRAW = (1 << 2),
43 };
44 
84 class EDELIB_API IconLoader {
85 private:
86  static IconLoader* pinstance;
87 
89  IconTheme* curr_theme;
90 
91  IconLoader();
92  ~IconLoader();
93  IconLoader(const IconLoader&);
94  IconLoader& operator=(const IconLoader&);
95 
96  void clear_items(void);
97 public:
98 #ifndef SKIP_DOCS
99  const char* get_icon_path(const char* name, IconSizes sz, IconContext ctx);
100  Fl_Shared_Image* get_icon(const char* name, IconSizes sz, IconContext ctx, unsigned long options);
101  bool set_icon(const char* name, Fl_Widget* widget, IconSizes sz, IconContext ctx, unsigned long options);
102  void load_theme(const char* name);
103  void reload_icons(void);
104  void repoll_icons(void);
105  const IconTheme* current_theme(void) const { return curr_theme; }
106 
107  static IconLoader* instance();
108 #endif
109 
114  static void init(const char* theme);
115 
119  static void init(void) { IconLoader::init(IconTheme::default_theme_name()); }
120 
124  static void shutdown(void);
125 
129  static bool inited(void);
130 
140  static void reload(const char* theme);
141 
151  static void repoll(void);
152 
166  static Fl_Shared_Image* get(const char* name, IconSizes sz, IconContext ctx = ICON_CONTEXT_ANY,
167  unsigned long options = 0);
168 
172  static String get_path(const char* name, IconSizes sz, IconContext ctx = ICON_CONTEXT_ANY);
173 
186  static bool set(Fl_Widget* widget, const char* name, IconSizes sz, IconContext ctx = ICON_CONTEXT_ANY,
187  unsigned long options = 0);
188 
192  static const IconTheme* theme(void);
193 
200  static void set_fallback_icon(const char* name);
201 
205  static const char* get_fallback_icon(void);
206 
211  static const char** get_builtin_xpm_icon(IconSizes sz);
212 };
213 
214 EDELIB_NS_END
215 #endif
Loads icons with IconTheme.
Definition: IconLoader.h:84
static void init(void)
Definition: IconLoader.h:119
IconSizes
Icon sizes to look for.
Definition: IconTheme.h:33
do not scale icon
Definition: IconLoader.h:42
Can be any icon context.
Definition: IconTheme.h:47
IconLoaderOptions
Settable options for IconLoader functions.
Definition: IconLoader.h:39
A (relatively simple) string implementation.
Definition: String.h:82
IconContext
Icon types to look for.
Definition: IconTheme.h:46
Finds named icon according to the given theme.
Definition: IconTheme.h:80
do not see given the path as absolute icon path
Definition: IconLoader.h:40