📄 resource_manager.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: resource_manager.hpp,v $ * PRODUCTION Revision 1000.0 2004/06/01 19:56:47 gouriano * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.5 * PRODUCTION * =========================================================================== */#ifndef __GUI_WIDGETS_FL___RESOURCE_MANAGER__HPP#define __GUI_WIDGETS_FL___RESOURCE_MANAGER__HPP/* $Id: resource_manager.hpp,v 1000.0 2004/06/01 19:56:47 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Andrey Yazhuk * * File Description: * */#include <corelib/ncbiobj.hpp>#include <gui/gui.hpp>#include <FL/Fl_Image.H>#include <FL/Fl_PNG_Image.H>/** @addtogroup GUI_FltkWidgets * * @{ */BEGIN_NCBI_SCOPE///////////////////////////////////////////////////////////////////////////////////class CFLTKImageHandle{public: typedef Fl_Image TImage; typedef CObjectFor<TImage*> TObjForImage; typedef CRef<TObjForImage> TImageRef; CFLTKImageHandle() {}; CFLTKImageHandle(TImage* image) // takes ownership of the image { if(image) { m_Ref = new TObjForImage; *m_Ref = image; } else m_Ref = NULL; } inline TImage& operator*() { return *(*m_Ref).GetData(); } inline TImage* operator->() { return (*m_Ref).GetData(); } inline operator bool() { return (bool) m_Ref; } protected: TImageRef m_Ref;};/////////////////////////////////////////////////////////////////////////////////// CPNGImageExt - this class provides a way to draw transparent PNGs (what is not/// supported in FLTK 1.5). Image is blended with given background color using /// alpha-channel data present in the image and then result is drawn on screen /// as non-transperent.class CPNGImageExt : public Fl_PNG_Image{public: typedef uchar TByte; CPNGImageExt(const char* filename); virtual void DrawTransparent(Fl_Color back_color, int X, int Y, int W, int H, bool disabled = false, int cx = 0, int cy = 0);};/////////////////////////////////////////////////////////////////////////////////// CResourceManager////// Provides access to application-specific resources such images and icons./// Resources are stored as files in repository which is a directory in file/// system. Resources are identified by local paths inside repository or aliases./// Aliases are symbolic names of resources making programming GUI independent from/// the actual filenames.class NCBI_GUIWIDGETS_FL_EXPORT CResourceManager : public CObject{public: typedef CFLTKImageHandle::TImage TImage; /// Specifies ";" - separated list of directorries where resources are located. /// When CResourceManager is loading a resource it concatenates local path /// corresponding to a resource with directories from this list and tries to /// resolve the resultant path. If path exists - resource is loaded using this path CResourceManager(const string& dir_list); /// register symbolic name (alias) for a resource identified by "local_path" void RegisterAlias(const string& alias, const string& local_path); CFLTKImageHandle GetImage(const string& alias);protected: typedef list<string> TDirList; typedef map<string, string> TAliasToPathMap; typedef map<string, CFLTKImageHandle> TAliasToImageMap; TDirList m_DirList; // directories where resources are located TAliasToPathMap m_AliasToPath; TAliasToImageMap m_AliasToImage;};END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: resource_manager.hpp,v $ * Revision 1000.0 2004/06/01 19:56:47 gouriano * PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.5 * * Revision 1.5 2004/05/13 17:24:22 yazhuk * Added "disabled" argument to CPNGImageExt::DrawTransparent() * * Revision 1.4 2004/05/11 18:55:14 dicuccio * Added doxygen modules info * * Revision 1.3 2004/05/03 19:48:31 yazhuk * Added Fl_PNG_Image class, implemented support for "standard" directories * * Revision 1.2 2004/05/03 12:47:08 dicuccio * Added #include for gui/gui.hpp. gui/utils ->gui/objutils where needed. * * Revision 1.1 2004/04/22 16:53:18 yazhuk * Initial revision: menu_window.hpp * * =========================================================================== */#endif // __GUI_WIDGETS_FL___RESOURCE_MANAGER__HPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -