BitmapFactory.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_BITMAPFACTORY_H
00025 #define GUI_BITMAPFACTORY_H
00026 
00027 #include <Base/Factory.h>
00028 #include <QPixmap>
00029 
00030 // forward declaration
00031 class SoSFImage;
00032 class QImage;
00033 
00034 namespace Gui {
00035 
00042 class BitmapFactoryInstP;
00043 class GuiExport BitmapFactoryInst : public Base::Factory
00044 {
00045 public:
00046     enum Position
00047     {
00048         TopLeft,  
00049         TopRight, 
00050         BottomLeft, 
00051         BottomRight 
00052     };
00053 
00054     static BitmapFactoryInst& instance(void);
00055     static void destruct (void);
00056 
00057     void addCustomPath(const QString&);
00058 
00060     void addPath(const QString& path);
00062     void removePath(const QString& path);
00064     QStringList findIconFiles() const;
00066     void addXPM(const char* name, const char** pXPM);
00068     void addPixmapToCache(const char* name, const QPixmap& icon);
00070     bool findPixmapInCache(const char* name, QPixmap& icon) const;
00072     QPixmap pixmap(const char* name) const;
00076     QPixmap pixmapFromSvg(const char* name, const QSize& size) const;
00081     QPixmap pixmapFromSvg(const QByteArray& contents, const QSize& size) const;
00085     QStringList pixmapNames() const;
00091     QPixmap resize(int w, int h, const QPixmap& p, Qt::BGMode bgmode) const;
00103     QPixmap fillRect(int x, int y, int w, int h, const QPixmap& p, Qt::BGMode) const;
00108     QPixmap merge(const QPixmap& p1, const QPixmap& p2, bool vertical) const;
00114     QPixmap merge(const QPixmap& p1, const QPixmap& p2, Position pos = BitmapFactoryInst::BottomLeft) const;
00118     QPixmap disabled(const QPixmap& p) const;
00121     void convert(const QImage& img, SoSFImage& out) const;
00124     void convert(const SoSFImage& img, QImage& out) const;
00125 
00126 private:
00127     void restoreCustomPaths();
00128 
00129     static BitmapFactoryInst* _pcSingleton;
00130     BitmapFactoryInst();
00131     ~BitmapFactoryInst();
00132 
00133     BitmapFactoryInstP* d;
00134 };
00135 
00137 inline BitmapFactoryInst& BitmapFactory(void)
00138 {
00139     return BitmapFactoryInst::instance();
00140 }
00141 
00142 } // namespace Gui
00143 
00144 #endif // GUI_BITMAPFACTORY_H

Generated on Wed Nov 23 18:59:58 2011 for FreeCAD by  doxygen 1.6.1