| 1 | /* |
|---|
| 2 | * This file is part of Licq, an instant messaging client for UNIX. |
|---|
| 3 | * Copyright (C) 1999-2006 Licq developers |
|---|
| 4 | * |
|---|
| 5 | * Licq is free software; you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | * (at your option) any later version. |
|---|
| 9 | * |
|---|
| 10 | * Licq is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with Licq; if not, write to the Free Software |
|---|
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | // Skin Spec 0.1 |
|---|
| 21 | |
|---|
| 22 | #ifndef SKIN_H |
|---|
| 23 | #define SKIN_H |
|---|
| 24 | |
|---|
| 25 | #include "config.h" |
|---|
| 26 | |
|---|
| 27 | #include <QColor> |
|---|
| 28 | #include <QObject> |
|---|
| 29 | #include <QPalette> |
|---|
| 30 | #include <QPixmap> |
|---|
| 31 | #include <QRect> |
|---|
| 32 | |
|---|
| 33 | class CIniFile; |
|---|
| 34 | |
|---|
| 35 | namespace LicqQtGui |
|---|
| 36 | { |
|---|
| 37 | namespace Config |
|---|
| 38 | { |
|---|
| 39 | class Border |
|---|
| 40 | { |
|---|
| 41 | public: |
|---|
| 42 | unsigned short top, bottom; |
|---|
| 43 | unsigned short left, right; |
|---|
| 44 | |
|---|
| 45 | void AdjustForMenuBar(unsigned short h1, unsigned short h2); |
|---|
| 46 | }; |
|---|
| 47 | |
|---|
| 48 | class FrameSkin |
|---|
| 49 | { |
|---|
| 50 | public: |
|---|
| 51 | struct Border border; |
|---|
| 52 | unsigned short frameStyle; |
|---|
| 53 | bool maintainBorder; |
|---|
| 54 | bool hasMenuBar; |
|---|
| 55 | bool transparent; |
|---|
| 56 | QPixmap pixmap; |
|---|
| 57 | QPixmap mask; |
|---|
| 58 | |
|---|
| 59 | virtual ~FrameSkin() {} |
|---|
| 60 | virtual void loadSkin(CIniFile& skinFile, QString name, QString baseSkinDir); |
|---|
| 61 | }; |
|---|
| 62 | |
|---|
| 63 | class ShapeSkin |
|---|
| 64 | { |
|---|
| 65 | public: |
|---|
| 66 | QRect rect; |
|---|
| 67 | QColor foreground; |
|---|
| 68 | QColor background; |
|---|
| 69 | |
|---|
| 70 | virtual ~ShapeSkin() { } |
|---|
| 71 | virtual void loadSkin(CIniFile& skinFile, QString name); |
|---|
| 72 | QRect borderToRect(const QWidget* w) const; |
|---|
| 73 | void AdjustForMenuBar(unsigned short h1, unsigned short h2); |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | class ButtonSkin : public ShapeSkin |
|---|
| 77 | { |
|---|
| 78 | public: |
|---|
| 79 | QPixmap pixmapUpFocus; |
|---|
| 80 | QPixmap pixmapUpNoFocus; |
|---|
| 81 | QPixmap pixmapDown; |
|---|
| 82 | QString caption; |
|---|
| 83 | |
|---|
| 84 | virtual ~ButtonSkin() { } |
|---|
| 85 | virtual void loadSkin(CIniFile& skinFile, QString name, QString baseSkinDir); |
|---|
| 86 | |
|---|
| 87 | private: |
|---|
| 88 | using ShapeSkin::loadSkin; |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | class LabelSkin : public ShapeSkin |
|---|
| 92 | { |
|---|
| 93 | public: |
|---|
| 94 | QPixmap pixmap; |
|---|
| 95 | unsigned short frameStyle; |
|---|
| 96 | bool transparent; |
|---|
| 97 | unsigned short margin; |
|---|
| 98 | |
|---|
| 99 | virtual ~LabelSkin() { } |
|---|
| 100 | virtual void loadSkin(CIniFile& skinFile, QString name, QString baseSkinDir); |
|---|
| 101 | |
|---|
| 102 | private: |
|---|
| 103 | using ShapeSkin::loadSkin; |
|---|
| 104 | }; |
|---|
| 105 | |
|---|
| 106 | class ComboSkin : public ShapeSkin { }; |
|---|
| 107 | |
|---|
| 108 | class ListSkin : public ShapeSkin { }; |
|---|
| 109 | |
|---|
| 110 | /** |
|---|
| 111 | * Data for a gui skin |
|---|
| 112 | * A singleton instance is used for the skin currently used for the gui. |
|---|
| 113 | * Other instances may also be created to hold data for other skins, used by |
|---|
| 114 | * SkinBrowser dialog. |
|---|
| 115 | */ |
|---|
| 116 | class Skin : public QObject |
|---|
| 117 | { |
|---|
| 118 | Q_OBJECT |
|---|
| 119 | |
|---|
| 120 | public: |
|---|
| 121 | /** |
|---|
| 122 | * Create the active skin instance |
|---|
| 123 | * |
|---|
| 124 | * @param skinName Initial skin name to load |
|---|
| 125 | * @param parent Parent object |
|---|
| 126 | */ |
|---|
| 127 | static void createInstance(QString skinName = QString(), QObject* parent = NULL); |
|---|
| 128 | |
|---|
| 129 | /** |
|---|
| 130 | * Get the active skin |
|---|
| 131 | * |
|---|
| 132 | * @return The skin data singleton |
|---|
| 133 | */ |
|---|
| 134 | static Skin* active() |
|---|
| 135 | { return myInstance; } |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | Skin(QString skinName = QString(), QObject* parent = NULL); |
|---|
| 139 | virtual ~Skin() {} |
|---|
| 140 | void loadSkin(QString skinName); |
|---|
| 141 | |
|---|
| 142 | QString skinName() const { return mySkinName; } |
|---|
| 143 | QPixmap mainwinPixmap(int width, int height) const; |
|---|
| 144 | QPixmap mainwinMask(int width, int height) const; |
|---|
| 145 | |
|---|
| 146 | void setFrameTransparent(bool transparent); |
|---|
| 147 | void setFrameStyle(unsigned short frameStyle); |
|---|
| 148 | |
|---|
| 149 | FrameSkin frame; |
|---|
| 150 | ButtonSkin btnSys; |
|---|
| 151 | LabelSkin lblStatus, lblMsg; |
|---|
| 152 | ComboSkin cmbGroups; |
|---|
| 153 | ListSkin lstUsers; |
|---|
| 154 | |
|---|
| 155 | QColor backgroundColor; |
|---|
| 156 | QColor gridlineColor; |
|---|
| 157 | QColor scrollbarColor; |
|---|
| 158 | QColor buttonTextColor; |
|---|
| 159 | |
|---|
| 160 | QColor onlineColor; |
|---|
| 161 | QColor offlineColor; |
|---|
| 162 | QColor awayColor; |
|---|
| 163 | QColor newUserColor; |
|---|
| 164 | QColor awaitingAuthColor; |
|---|
| 165 | |
|---|
| 166 | QColor highBackColor; |
|---|
| 167 | QColor highTextColor; |
|---|
| 168 | |
|---|
| 169 | QColor groupBackColor; |
|---|
| 170 | QColor groupTextColor; |
|---|
| 171 | QColor groupHighBackColor; |
|---|
| 172 | QColor groupHighTextColor; |
|---|
| 173 | |
|---|
| 174 | QImage groupBackImage; |
|---|
| 175 | |
|---|
| 176 | bool tileGroupBackImage; |
|---|
| 177 | |
|---|
| 178 | // Functions |
|---|
| 179 | void AdjustForMenuBar(unsigned short n); |
|---|
| 180 | int frameWidth(void); |
|---|
| 181 | int frameHeight(void); |
|---|
| 182 | QPalette palette(QWidget* parent); |
|---|
| 183 | |
|---|
| 184 | signals: |
|---|
| 185 | void changed(); |
|---|
| 186 | void frameChanged(); |
|---|
| 187 | |
|---|
| 188 | private: |
|---|
| 189 | // Singleton instance |
|---|
| 190 | static Skin* myInstance; |
|---|
| 191 | |
|---|
| 192 | void SetDefaultValues(); |
|---|
| 193 | QPixmap scaleWithBorder(const QPixmap& pm, int width, int height) const; |
|---|
| 194 | |
|---|
| 195 | QString mySkinName; |
|---|
| 196 | unsigned short myMenuBarHeight; |
|---|
| 197 | }; |
|---|
| 198 | |
|---|
| 199 | } // namespace Config |
|---|
| 200 | } // namespace LicqQtGui |
|---|
| 201 | |
|---|
| 202 | #endif |
|---|