diff --git a/clanglib-msw_32.cbp b/clanglib-msw_32.cbp
index 70ae7e7..3c7d2b7 100644
--- a/clanglib-msw_32.cbp
+++ b/clanglib-msw_32.cbp
@@ -19,6 +19,7 @@
+
@@ -38,6 +39,7 @@
+
diff --git a/clanglib-msw_32_wx30.cbp b/clanglib-msw_32_wx30.cbp
index 1889233..a9cb125 100644
--- a/clanglib-msw_32_wx30.cbp
+++ b/clanglib-msw_32_wx30.cbp
@@ -23,6 +23,7 @@
+
@@ -46,6 +47,7 @@
+
diff --git a/clanglib-unix.cbp b/clanglib-unix.cbp
index b97b6db..b62153a 100644
--- a/clanglib-unix.cbp
+++ b/clanglib-unix.cbp
@@ -21,6 +21,7 @@
+
@@ -41,6 +42,7 @@
+
diff --git a/clanglib-unix_wx30.cbp b/clanglib-unix_wx30.cbp
index 14615de..b899cbd 100644
--- a/clanglib-unix_wx30.cbp
+++ b/clanglib-unix_wx30.cbp
@@ -21,6 +21,7 @@
+
@@ -41,6 +42,7 @@
+
diff --git a/images/clanglib/class.png b/images/class.png
similarity index 100%
rename from images/clanglib/class.png
rename to images/class.png
diff --git a/images/clanglib/class_folder.png b/images/class_folder.png
similarity index 100%
rename from images/clanglib/class_folder.png
rename to images/class_folder.png
diff --git a/images/clanglib/class_private.png b/images/class_private.png
similarity index 100%
rename from images/clanglib/class_private.png
rename to images/class_private.png
diff --git a/images/clanglib/class_protected.png b/images/class_protected.png
similarity index 100%
rename from images/clanglib/class_protected.png
rename to images/class_protected.png
diff --git a/images/clanglib/class_public.png b/images/class_public.png
similarity index 100%
rename from images/clanglib/class_public.png
rename to images/class_public.png
diff --git a/images/clanglib/cpp_lang.png b/images/cpp_lang.png
similarity index 100%
rename from images/clanglib/cpp_lang.png
rename to images/cpp_lang.png
diff --git a/images/clanglib/ctor_private.png b/images/ctor_private.png
similarity index 100%
rename from images/clanglib/ctor_private.png
rename to images/ctor_private.png
diff --git a/images/clanglib/ctor_protected.png b/images/ctor_protected.png
similarity index 100%
rename from images/clanglib/ctor_protected.png
rename to images/ctor_protected.png
diff --git a/images/clanglib/ctor_public.png b/images/ctor_public.png
similarity index 100%
rename from images/clanglib/ctor_public.png
rename to images/ctor_public.png
diff --git a/images/clanglib/dtor_private.png b/images/dtor_private.png
similarity index 100%
rename from images/clanglib/dtor_private.png
rename to images/dtor_private.png
diff --git a/images/clanglib/dtor_protected.png b/images/dtor_protected.png
similarity index 100%
rename from images/clanglib/dtor_protected.png
rename to images/dtor_protected.png
diff --git a/images/clanglib/dtor_public.png b/images/dtor_public.png
similarity index 100%
rename from images/clanglib/dtor_public.png
rename to images/dtor_public.png
diff --git a/images/clanglib/enum.png b/images/enum.png
similarity index 100%
rename from images/clanglib/enum.png
rename to images/enum.png
diff --git a/images/clanglib/enum_private.png b/images/enum_private.png
similarity index 100%
rename from images/clanglib/enum_private.png
rename to images/enum_private.png
diff --git a/images/clanglib/enum_protected.png b/images/enum_protected.png
similarity index 100%
rename from images/clanglib/enum_protected.png
rename to images/enum_protected.png
diff --git a/images/clanglib/enum_public.png b/images/enum_public.png
similarity index 100%
rename from images/clanglib/enum_public.png
rename to images/enum_public.png
diff --git a/images/clanglib/enumerator.png b/images/enumerator.png
similarity index 100%
rename from images/clanglib/enumerator.png
rename to images/enumerator.png
diff --git a/images/clanglib/enums_folder.png b/images/enums_folder.png
similarity index 100%
rename from images/clanglib/enums_folder.png
rename to images/enums_folder.png
diff --git a/images/clanglib/folder.png b/images/folder.png
similarity index 100%
rename from images/clanglib/folder.png
rename to images/folder.png
diff --git a/images/clanglib/folder_blue.png b/images/folder_blue.png
similarity index 100%
rename from images/clanglib/folder_blue.png
rename to images/folder_blue.png
diff --git a/images/clanglib/folder_blue_open.png b/images/folder_blue_open.png
similarity index 100%
rename from images/clanglib/folder_blue_open.png
rename to images/folder_blue_open.png
diff --git a/images/clanglib/folder_green.png b/images/folder_green.png
similarity index 100%
rename from images/clanglib/folder_green.png
rename to images/folder_green.png
diff --git a/images/clanglib/folder_green_open.png b/images/folder_green_open.png
similarity index 100%
rename from images/clanglib/folder_green_open.png
rename to images/folder_green_open.png
diff --git a/images/clanglib/folder_open.png b/images/folder_open.png
similarity index 100%
rename from images/clanglib/folder_open.png
rename to images/folder_open.png
diff --git a/images/clanglib/funcs_folder.png b/images/funcs_folder.png
similarity index 100%
rename from images/clanglib/funcs_folder.png
rename to images/funcs_folder.png
diff --git a/images/clanglib/hierarchy_child.png b/images/hierarchy_child.png
similarity index 100%
rename from images/clanglib/hierarchy_child.png
rename to images/hierarchy_child.png
diff --git a/images/clanglib/hierarchy_parent.png b/images/hierarchy_parent.png
similarity index 100%
rename from images/clanglib/hierarchy_parent.png
rename to images/hierarchy_parent.png
diff --git a/images/clanglib/macro_def.png b/images/macro_def.png
similarity index 100%
rename from images/clanglib/macro_def.png
rename to images/macro_def.png
diff --git a/images/clanglib/macro_def_folder.png b/images/macro_def_folder.png
similarity index 100%
rename from images/clanglib/macro_def_folder.png
rename to images/macro_def_folder.png
diff --git a/images/clanglib/macro_use.png b/images/macro_use.png
similarity index 100%
rename from images/clanglib/macro_use.png
rename to images/macro_use.png
diff --git a/images/clanglib/macro_use_folder.png b/images/macro_use_folder.png
similarity index 100%
rename from images/clanglib/macro_use_folder.png
rename to images/macro_use_folder.png
diff --git a/images/clanglib/macro_use_private.png b/images/macro_use_private.png
similarity index 100%
rename from images/clanglib/macro_use_private.png
rename to images/macro_use_private.png
diff --git a/images/clanglib/macro_use_protected.png b/images/macro_use_protected.png
similarity index 100%
rename from images/clanglib/macro_use_protected.png
rename to images/macro_use_protected.png
diff --git a/images/clanglib/macro_use_public.png b/images/macro_use_public.png
similarity index 100%
rename from images/clanglib/macro_use_public.png
rename to images/macro_use_public.png
diff --git a/images/clanglib/method_private.png b/images/method_private.png
similarity index 100%
rename from images/clanglib/method_private.png
rename to images/method_private.png
diff --git a/images/clanglib/method_protected.png b/images/method_protected.png
similarity index 100%
rename from images/clanglib/method_protected.png
rename to images/method_protected.png
diff --git a/images/clanglib/method_public.png b/images/method_public.png
similarity index 100%
rename from images/clanglib/method_public.png
rename to images/method_public.png
diff --git a/images/clanglib/namespace.png b/images/namespace.png
similarity index 100%
rename from images/clanglib/namespace.png
rename to images/namespace.png
diff --git a/images/clanglib/others_folder.png b/images/others_folder.png
similarity index 100%
rename from images/clanglib/others_folder.png
rename to images/others_folder.png
diff --git a/images/clanglib/symbols_folder.png b/images/symbols_folder.png
similarity index 100%
rename from images/clanglib/symbols_folder.png
rename to images/symbols_folder.png
diff --git a/images/clanglib/typedef.png b/images/typedef.png
similarity index 100%
rename from images/clanglib/typedef.png
rename to images/typedef.png
diff --git a/images/clanglib/typedef_private.png b/images/typedef_private.png
similarity index 100%
rename from images/clanglib/typedef_private.png
rename to images/typedef_private.png
diff --git a/images/clanglib/typedef_protected.png b/images/typedef_protected.png
similarity index 100%
rename from images/clanglib/typedef_protected.png
rename to images/typedef_protected.png
diff --git a/images/clanglib/typedef_public.png b/images/typedef_public.png
similarity index 100%
rename from images/clanglib/typedef_public.png
rename to images/typedef_public.png
diff --git a/images/clanglib/typedefs_folder.png b/images/typedefs_folder.png
similarity index 100%
rename from images/clanglib/typedefs_folder.png
rename to images/typedefs_folder.png
diff --git a/images/clanglib/var_private.png b/images/var_private.png
similarity index 100%
rename from images/clanglib/var_private.png
rename to images/var_private.png
diff --git a/images/clanglib/var_protected.png b/images/var_protected.png
similarity index 100%
rename from images/clanglib/var_protected.png
rename to images/var_protected.png
diff --git a/images/clanglib/var_public.png b/images/var_public.png
similarity index 100%
rename from images/clanglib/var_public.png
rename to images/var_public.png
diff --git a/images/clanglib/vars_folder.png b/images/vars_folder.png
similarity index 100%
rename from images/clanglib/vars_folder.png
rename to images/vars_folder.png
diff --git a/src/clangplugin.cpp b/src/clangplugin.cpp
index 478cca5..b41ab21 100644
--- a/src/clangplugin.cpp
+++ b/src/clangplugin.cpp
@@ -38,15 +38,78 @@
#include
#endif // CB_PRECOMP
#include
+#include
+#include
#define CLANGPLUGIN_TRACE_FUNCTIONS
// this auto-registers the plugin
+
+const wxString ResourceFileName(wxT("clanglib.zip"));
+
+
namespace
{
+
PluginRegistrant reg(wxT("ClangLib"));
+/** \brief Short exception class for file loading
+ */
+struct bad_file_execp : public std::exception
+{
+ bad_file_execp(wxString msg) : m_msg(msg) {};
+ const char* what() { return m_msg.ToUTF8().data(); };
+ const wxString whatStr() { return m_msg; };
+ wxString m_msg;
+};
+
+
+/** \brief Load PNG file with the name \p name from the resource zip file
+ *
+ * \param name wxString Name of the PNG file.
+ * \return wxBitmap On success the loaded Bitmap. On error it throws a \ref bad_file_execp exception
+ *
+ */
+wxBitmap LoadPNGFromResourceFile(wxString name)
+{
+ wxFileSystem filesystem;
+ wxString filename = wxT("file:") + ConfigManager::GetDataFolder() + wxT("/") + ResourceFileName + wxT("#zip:/") + name;
+ wxFSFile *file = filesystem.OpenFile( filename, wxFS_READ | wxFS_SEEKABLE );
+ if(file == nullptr)
+ throw bad_file_execp(_("File not found: ") + filename);
+ wxImage img;
+ img.LoadFile(*file->GetStream(), wxBITMAP_TYPE_PNG);
+ wxBitmap ret(img);
+ if(!ret.IsOk())
+ throw bad_file_execp(_("File not loaded correctly: ") + filename);
+
+ return ret;
+}
+/** \brief Load GIF file with the name \p name from the resource zip file
+ *
+ * \param name wxString Name of the PNG file.
+ * \return wxAnimation On success the loaded GIF animation. On error it throws a \ref bad_file_execp exception
+ *
+ */
+wxAnimation LoadGifFromResourceFile(wxString name)
+{
+ wxFileSystem filesystem;
+ wxString filename = wxT("file:") + ConfigManager::GetDataFolder() + wxT("/") + ResourceFileName + wxT("#zip:/") + name;
+ wxFSFile *file = filesystem.OpenFile( filename, wxFS_READ | wxFS_SEEKABLE);
+ if(file == nullptr)
+ throw bad_file_execp(_("File not found: ") + filename);
+
+ wxAnimation ret;
+ if( ret.Load(*file->GetStream(), wxANIMATION_TYPE_GIF) == false)
+ throw bad_file_execp(_("File not loaded correctly: ") + filename);
+ if(!ret.IsOk())
+ throw bad_file_execp(_("File not loaded correctly: ") + filename);
+
+ return ret;
+}
+
+
void AddImages(wxBitmap& directionImage, unsigned cnt, wxImageList& destList)
{
for (unsigned i=0; iInit(this, g_idCCLogger, g_idCCDebugLogger, g_idCCErrorLogger);
- if (!Manager::LoadResource(wxT("clanglib.zip")))
- NotifyMissingFile(wxT("clanglib.zip"));
+ if (!Manager::LoadResource(ResourceFileName))
+ NotifyMissingFile(ResourceFileName);
}
ClangPlugin::~ClangPlugin()
@@ -148,7 +211,7 @@ void ClangPlugin::OnAttach()
{
wxBitmap bmp;
ConfigManager* cfg = Manager::Get()->GetConfigManager(CLANG_CONFIGMANAGER);
- wxString prefix = ConfigManager::GetDataFolder() + wxT("/images/clanglib/");
+ wxString prefix = wxT("images/");
// bitmaps must be added by order of PARSER_IMG_* consts (which are also TokenCategory enums)
const char* imgs[] =
{
@@ -195,18 +258,30 @@ void ClangPlugin::OnAttach()
"cpp_lang.png", // tcLangKeyword
nullptr
};
+
+ try
+ {
+
for (const char** itr = imgs; *itr; ++itr)
{
- m_ImageList.Add(cbLoadBitmap(prefix + wxString::FromUTF8(*itr), wxBITMAP_TYPE_PNG));
+ m_ImageList.Add(LoadPNGFromResourceFile(prefix + wxString::FromUTF8(*itr)));
}
- wxBitmap parentBitmap = cbLoadBitmap( prefix + wxT("hierarchy_parent.png"), wxBITMAP_TYPE_PNG );
+ wxBitmap parentBitmap = LoadPNGFromResourceFile( prefix + wxT("hierarchy_parent.png"));
m_ImageListRefParentIndex = m_ImageList.GetImageCount();
AddImages(parentBitmap,m_ImageListRefParentIndex,m_ImageList);
- wxBitmap childBitmap = cbLoadBitmap( prefix + wxT("hierarchy_child.png"), wxBITMAP_TYPE_PNG );
+ wxBitmap childBitmap = LoadPNGFromResourceFile( prefix + wxT("hierarchy_child.png"));
m_ImageListRefChildIndex = m_ImageList.GetImageCount();
AddImages(childBitmap, m_ImageListRefParentIndex,m_ImageList);
+ }
+ catch(bad_file_execp& e)
+ {
+ Manager::Get()->GetLogManager()->LogError( e.whatStr() );
+ }
+
+
+
EditorColourSet* theme = Manager::Get()->GetEditorManager()->GetColourSet();
wxStringTokenizer tokenizer(theme->GetKeywords(theme->GetHighlightLanguage(wxT("C/C++")), 0));
while (tokenizer.HasMoreTokens())