libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/QY2Styler.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:         QY2Styler.h
00020 
00021   Author:       Stefan Kulow <coolo@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #ifndef QY2Styler_h
00027 #define QY2Styler_h
00028 
00029 #include <QObject>
00030 #include <QHash>
00031 #include <QString>
00032 #include <QImage>
00033 #include <QMap>
00034 
00035 
00036 class QY2Styler : public QObject
00037 {
00038     Q_OBJECT
00039 
00040 protected:
00041 
00042     /**
00043      * Constructor. Use the static styler() function instead to return the
00044      * singleton for this class.
00045      **/
00046     QY2Styler( QObject * parent );
00047 
00048 public:
00049 
00050     static QY2Styler * styler();
00051 
00052     void loadStyleSheet( const QString &file );         // reads style sheet form a file
00053     void setStyleSheet( const QString & text );
00054     QString themeDir() const;
00055     void registerWidget( QWidget *widget );
00056     void unregisterWidget( QWidget *widget );
00057     void registerChildWidget( QWidget *parent, QWidget *widget );
00058     QString textStyle() const { return _textStyle; }
00059 
00060     bool updateRendering( QWidget *wid );
00061 
00062 protected:
00063     void renderParent( QWidget *wid );
00064     QImage getScaled( const QString name, const QSize & size );
00065 
00066     /**
00067      * Search and replace some self-defined macros in the style sheet.
00068      * Among other things, expands the file name inside url( filename.png ) in
00069      * the style sheet with the full path.
00070      **/
00071     void processUrls( QString & text );
00072 
00073     /*
00074      * Reimplemented from QObject.
00075      **/
00076     bool eventFilter( QObject * obj, QEvent * ev );
00077 
00078 
00079 private:
00080 
00081     struct BackgrInfo
00082     {
00083         QString filename;
00084         QImage pix;
00085         QImage scaled;
00086         QSize lastscale;
00087         bool full;
00088     };
00089 
00090     QHash<QString,BackgrInfo> _backgrounds;
00091     QMap<QWidget*, QList< QWidget* > > _children;
00092     QString _style;
00093     QString _textStyle;
00094 };
00095 
00096 
00097 #endif // QY2Styler_h
 All Classes Functions Variables