NCBI C++ ToolKit
pt_icon_list.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: pt_icon_list.cpp 32870 2015-04-30 18:47:53Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
36 
38 
40 
41 using namespace PT;
42 
44 {
45  static CPTIcons instance;
46  return instance;
47 }
48 
50  : m_IconsImageList(16, 16, true, 0)
51  , m_DataSourceIcon(-1)
52  , m_FolderOpenIcon(-1)
53  , m_FolderClosedIcon(-1)
54  , m_WorkspaceClosedIcon(-1)
55  , m_WorkspaceOpenIcon(-1)
56  , m_ProjectItemIcon(-1)
57  , m_DocIconDisabled(-1)
58  , m_ProjectClosedIcon(-1)
59  , m_ProjectOpenIcon(-1)
60  , m_ViewerIcon(-1)
61  , m_ViewIcon(-1)
62  , m_HiddenItemsIcon(-1)
63 {
65 
66  provider->RegisterFileAlias(wxT("tree::data_source"), wxT("data_source.png"));
67 
68  provider->RegisterFileAlias(wxT("tree::workspace_open_item"), wxT("workspace_open_item.png"));
69  provider->RegisterFileAlias(wxT("tree::workspace_closed_item"), wxT("workspace_closed_item.png"));
70  provider->RegisterFileAlias(wxT("tree::project_closed_item"), wxT("project_closed_item.png"));
71  provider->RegisterFileAlias(wxT("tree::project_open_item"), wxT("project_open_item.png"));
72  provider->RegisterFileAlias(wxT("tree::folder_open"), wxT("folder_open.png"));
73  provider->RegisterFileAlias(wxT("tree::folder_closed"), wxT("folder_closed.png"));
74  provider->RegisterFileAlias(wxT("tree::doc_item"), wxT("doc_item.png"));
75 
76  provider->RegisterFileAlias(wxT("tree::view_item"), wxT("view_item.png"));
77  provider->RegisterFileAlias(wxT("tree::doc_item_disabled"), wxT("doc_item_disabled.png"));
78  provider->RegisterFileAlias(wxT("tree::viewer_item"), wxT("viewer_item.png"));
79 
80  provider->RegisterFileAlias(wxT("tree::bio_tree_item"), wxT("bio_tree_container.png"));
81  provider->RegisterFileAlias(wxT("tree::assembly_item"), wxT("gc_assembly.png"));
82 
83  provider->RegisterFileAlias(wxT("tree::hidden_items"), wxT("bw_folder_closed.png"));
84 
85  m_DataSourceIcon = x_AddIconToImageList("tree::data_source");
86  m_WorkspaceOpenIcon = x_AddIconToImageList("tree::workspace_open_item");
87  m_WorkspaceClosedIcon = x_AddIconToImageList("tree::workspace_closed_item");
88  m_ProjectClosedIcon = x_AddIconToImageList("tree::project_closed_item");
89  m_ProjectOpenIcon = x_AddIconToImageList("tree::project_open_item");
90  m_FolderOpenIcon = x_AddIconToImageList("tree::folder_open");
91  m_FolderClosedIcon = x_AddIconToImageList("tree::folder_closed");
92  m_ProjectItemIcon = x_AddIconToImageList("tree::doc_item");
93 
94  m_ViewerIcon = x_AddIconToImageList("tree::viewer_item");
95  m_DocIconDisabled = x_AddIconToImageList("tree::doc_item_disabled");
96  m_ViewIcon = x_AddIconToImageList("tree::view_item");
97 
98  m_HiddenItemsIcon = x_AddIconToImageList("tree::hidden_items");
99 }
100 
102 {
103  switch(icon) {
104  case eDataSourceIcon : return m_DataSourceIcon;
105  case eFolderOpenIcon : return m_FolderOpenIcon;
109  case eProjectItemIcon : return m_ProjectItemIcon;
110  case eDocIconDisabled : return m_DocIconDisabled;
112  case eProjectOpenIcon : return m_ProjectOpenIcon;
113  case eViewerIcon : return m_ViewerIcon;
114  case eViewIcon : return m_ViewIcon;
115  case eHiddenItemsIcon : return m_HiddenItemsIcon;
116  }
117  return -1;
118 }
119 
120 int CPTIcons::GetImageIndex(const string& alias)
121 {
123  if (it == m_AliasToIndex.end()) {
124  int index = x_AddIconToImageList(alias);
125  if (index != -1)
126  m_AliasToIndex[alias] = index;
127  return index;
128  } else {
129  return it->second;
130  }
131 }
132 
133 int CPTIcons::x_AddIconToImageList(const string& alias)
134 {
135  wxBitmap bmp = wxArtProvider::GetBitmap(ToWxString(alias));
136  if (bmp.IsOk())
137  return m_IconsImageList.Add(bmp);
138 
139  return -1;
140 }
141 
static CPTIcons & GetInstance()
int m_WorkspaceClosedIcon
int m_FolderClosedIcon
int m_WorkspaceOpenIcon
int x_AddIconToImageList(const string &alias)
wxImageList m_IconsImageList
map< string, int > m_AliasToIndex
int GetImageIndex(EIcon icon) const
int m_ProjectClosedIcon
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
thread_local unique_ptr< FtaMsgPost > bmp
Definition: ftaerr.cpp:120
#define true
Definition: bool.h:35
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define wxT(x)
Definition: muParser.cpp:41
wxFileArtProvider * GetDefaultFileArtProvider()
Definition: wx_utils.cpp:334
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Tue May 21 10:56:29 2024 by modify_doxy.py rev. 669887