• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

kdeuiwidgetsproxystyle.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries
00002 
00003     Copyright (C) 2007 Fredrik Höglund <fredrik@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License (LGPL) as published by the Free Software Foundation;
00008     either version 2 of the License, or (at your option) any later
00009     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 GNU
00014     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "kdeuiwidgetsproxystyle_p.h"
00023 
00024 #include <QtGui/QApplication>
00025 #include <QtGui/QWidget>
00026 #include <QtGui/QWindowsStyle>
00027 
00028 KdeUiProxyStyle::KdeUiProxyStyle(QWidget *parent)
00029     : QStyle(), parent(parent), lastResortStyle(0)
00030 {
00031 }
00032 
00033 KdeUiProxyStyle::~KdeUiProxyStyle()
00034 {
00035     delete lastResortStyle;
00036 }
00037 
00038 QStyle *KdeUiProxyStyle::style() const
00039 {
00040     QStyle* baseStyle;
00041     if (parent && parent->parentWidget()) {
00042         // Use parentWidget style, but only if it's not the stylesheet style,
00043         // to avoid infinite recursion in pixelMetrics()
00044         baseStyle = parent->parentWidget()->style();
00045         if (baseStyle->inherits("QStyleSheetStyle")) {
00046             baseStyle = QApplication::style();
00047         }
00048     } else {
00049         baseStyle = QApplication::style();
00050     }
00051 
00052     if (baseStyle->inherits("QStyleSheetStyle")) {
00053         // We may still get a QStyleSheetStyle based style if
00054         // QApplication::style() is a QStyleSheetStyle. In this case, fallback
00055         // to Windows style: since it's the base class of QStyleSheetStyle,
00056         // it's probably the closest one.
00057         if (!lastResortStyle) {
00058             lastResortStyle = new QWindowsStyle;
00059         }
00060         baseStyle = lastResortStyle;
00061     }
00062 
00063     return baseStyle;
00064 }
00065 
00066 void KdeUiProxyStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
00067                                         QPainter *painter, const QWidget *widget) const
00068 {
00069     style()->drawComplexControl(control, option, painter, widget);
00070 }
00071 
00072 void KdeUiProxyStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter,
00073                                  const QWidget *widget) const
00074 {
00075     style()->drawControl(element, option, painter, widget);
00076 }
00077 
00078 void KdeUiProxyStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment,
00079                                     const QPixmap &pixmap) const
00080 {
00081     style()->drawItemPixmap(painter, rectangle, alignment, pixmap);
00082 }
00083 
00084 void KdeUiProxyStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette,
00085                                   bool enabled, const QString &text, QPalette::ColorRole textRole) const
00086 {
00087     style()->drawItemText(painter, rectangle, alignment, palette, enabled, text, textRole);
00088 }
00089 
00090 void KdeUiProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter,
00091                                    const QWidget *widget) const
00092 {
00093     style()->drawPrimitive(element, option, painter, widget);
00094 }
00095 
00096 QPixmap KdeUiProxyStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
00097                                             const QStyleOption *option) const
00098 {
00099     return style()->generatedIconPixmap(iconMode, pixmap, option);
00100 }
00101 
00102 QStyle::SubControl KdeUiProxyStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
00103                                                          const QPoint &position, const QWidget *widget) const
00104 {
00105     return style()->hitTestComplexControl(control, option, position, widget);
00106 }
00107 
00108 QRect KdeUiProxyStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const
00109 {
00110     return style()->itemPixmapRect(rectangle, alignment, pixmap);
00111 }
00112 
00113 QRect KdeUiProxyStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment,
00114                                    bool enabled, const QString &text) const
00115 {
00116     return style()->itemTextRect(metrics, rectangle, alignment, enabled, text);
00117 }
00118 
00119 int KdeUiProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
00120 {
00121     return style()->pixelMetric(metric, option, widget);
00122 }
00123 
00124 void KdeUiProxyStyle::polish(QWidget *widget)
00125 {
00126     style()->polish(widget);
00127 }
00128 
00129 void KdeUiProxyStyle::polish(QApplication *application)
00130 {
00131     style()->polish(application);
00132 }
00133 
00134 void KdeUiProxyStyle::polish(QPalette &palette)
00135 {
00136     style()->polish(palette);
00137 }
00138 
00139 QSize KdeUiProxyStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
00140                                        const QSize &contentsSize, const QWidget *widget) const
00141 {
00142     return style()->sizeFromContents(type, option, contentsSize, widget);
00143 }
00144 
00145 QIcon KdeUiProxyStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
00146                                    const QWidget *widget) const
00147 {
00148     return style()->standardIcon(standardIcon, option, widget);
00149 }
00150 
00151 QPixmap KdeUiProxyStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option,
00152                                        const QWidget *widget) const
00153 {
00154     return style()->standardPixmap(standardPixmap, option, widget);
00155 }
00156 
00157 QPalette KdeUiProxyStyle::standardPalette() const
00158 {
00159     return style()->standardPalette();
00160 }
00161 
00162 int KdeUiProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
00163                               QStyleHintReturn *returnData) const
00164 {
00165     return style()->styleHint(hint, option, widget, returnData);
00166 }
00167 
00168 QRect KdeUiProxyStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
00169                                      SubControl subControl, const QWidget *widget) const
00170 {
00171     return style()->subControlRect(control, option, subControl, widget);
00172 }
00173 
00174 QRect KdeUiProxyStyle::subElementRect(SubElement element, const QStyleOption *option,
00175                                      const QWidget *widget) const
00176 {
00177     return style()->subElementRect(element, option, widget);
00178 }
00179 
00180 void KdeUiProxyStyle::unpolish(QWidget *widget)
00181 {
00182     style()->unpolish(widget);
00183 }
00184 
00185 void KdeUiProxyStyle::unpolish(QApplication *application)
00186 {
00187     style()->unpolish(application);
00188 }
00189 

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal