Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnIconFactory.h
1 /*****************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnIconFactory.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 ** DESCRIPTION:
11 ** Factory for creating icons for nodes. Icons are associated with a node's
12 ** type (so all nodes of the same type have the same icon). Unknown types
13 ** get a generic icon. The colour of the top-left corner of the icon is
14 ** assumed to be transparent.
15 **
16 *****************************************************************************/
17 
18 #pragma once
19 
20 #include "wx/wx.h"
21 #include "wx/utils.h"
22 
23 // drwnIconFactory -----------------------------------------------------------
24 
26 {
27  protected:
28  wxBitmap *_defaultIcon;
29  map<string, wxBitmap *> _registry;
30 
31  public:
32  ~drwnIconFactory();
33  static drwnIconFactory& get();
34 
35  void registerIcon(const char *name, const wxBitmap *bmp);
36  void unregisterIcon(const char *name);
37 
38  const wxBitmap *getIcon(const char *name) const;
39 
40  protected:
41  drwnIconFactory(); // singleton class (requires gui initialization)
42 
43  // Creates the transparency mask for the icon by examining the colour
44  // of the top-left corner. Returns the same pointer passed in.
45  static wxBitmap *setIconMask(wxBitmap *bmp);
46 };
47 
48 #define gIconFactory drwnIconFactory::get()
Definition: drwnIconFactory.h:25