⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdecorationdefault_qws.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include <qapplication.h>#include <qwidget.h>#include <qpainter.h>#include <qpaintengine.h>#include <qdrawutil.h>#include "qdecorationdefault_qws.h"#if !defined(QT_NO_QWS_DECORATION_DEFAULT) || defined(QT_PLUGIN)QPixmap *QDecorationDefault::staticHelpPixmap = 0;QPixmap *QDecorationDefault::staticMenuPixmap = 0;QPixmap *QDecorationDefault::staticClosePixmap = 0;QPixmap *QDecorationDefault::staticMinimizePixmap = 0;QPixmap *QDecorationDefault::staticMaximizePixmap = 0;QPixmap *QDecorationDefault::staticNormalizePixmap = 0;#ifndef QT_NO_IMAGEFORMAT_XPM/* XPM */static const char * const default_menu_xpm[] = {/* width height ncolors chars_per_pixel */"16 16 11 1",/* colors */"  c #000000",". c #336600","X c #666600","o c #99CC00","O c #999933","+ c #333300","@ c #669900","# c #999900","$ c #336633","% c #666633","& c #99CC33",/* pixels */"oooooooooooooooo","oooooooooooooooo","ooooo#.++X#ooooo","ooooX      Xoooo","oooX  XO#%  X&oo","oo#  Ooo&@O  Ooo","oo. Xoo#+ @X Xoo","oo+ OoO+ +O# +oo","oo+ #O+  +## +oo","oo. %@ ++ +. Xoo","oo#  O@OO+   #oo","oooX  X##$   Ooo","ooooX        Xoo","oooo&OX++X#OXooo","oooooooooooooooo","oooooooooooooooo"};static const char * const default_help_xpm[] = {"16 16 3 1","       s None  c None",".      c #ffffff","X      c #707070","                ","                ","    ......      ","   ..XXXXXX     ","   .XX   .XX    ","   .XX   .XX    ","        ..XX    ","       ..XX     ","      ..XX      ","      .XX       ","      .XX       ","      ..        ","      .XX       ","      .XX       ","                ","                "};static const char * const default_close_xpm[] = {"16 16 3 1","       s None  c None",".      c #ffffff","X      c #707070","                ","                ","  .X        .X  ","  .XX      .XX  ","   .XX    .XX   ","    .XX  .XX    ","     .XX.XX     ","      .XXX      ","      .XXX      ","     .XX.XX     ","    .XX  .XX    ","   .XX    .XX   ","  .XX      .XX  ","  .X        .X  ","                ","                "};static const char * const default_maximize_xpm[] = {"16 16 3 1","       s None  c None",".      c #ffffff","X      c #707070","                ","                ","  ...........   ","  .XXXXXXXXXX   ","  .X       .X   ","  .X       .X   ","  .X       .X   ","  .X       .X   ","  .X       .X   ","  .X       .X   ","  .X       .X   ","  .X........X   ","  .XXXXXXXXXX   ","                ","                ","                "};static const char * const default_minimize_xpm[] = {"16 16 3 1","       s None  c None",".      c #ffffff","X      c #707070","                ","                ","                ","                ","                ","                ","       ...      ","       . X      ","       .XX      ","                ","                ","                ","                ","                ","                ","                "};static const char * const default_normalize_xpm[] = {"16 16 3 1","       s None  c None",".      c #ffffff","X      c #707070","                ","                ","     ........   ","     .XXXXXXXX  ","     .X     .X  ","     .X     .X  ","  ....X...  .X  ","  .XXXXXXXX .X  ","  .X     .XXXX  ","  .X     .X     ","  .X     .X     ","  .X......X     ","  .XXXXXXXX     ","                ","                ","                "};#endif // QT_NO_IMAGEFORMAT_XPMQDecorationDefault::QDecorationDefault()    : QDecoration(){    menu_width = 20;    help_width = 20;    close_width = 20;    minimize_width = 20;    maximize_width = 20;    normalize_width = 20;}QDecorationDefault::~QDecorationDefault(){    delete staticMenuPixmap;    delete staticClosePixmap;    delete staticMinimizePixmap;    delete staticMaximizePixmap;    delete staticNormalizePixmap;    // This makes it safe to delete and then create a QDecorationDefault    staticMenuPixmap = 0;    staticClosePixmap = 0;    staticMinimizePixmap = 0;    staticMaximizePixmap = 0;    staticNormalizePixmap = 0;}const char **QDecorationDefault::xpmForRegion(int reg){#ifdef QT_NO_IMAGEFORMAT_XPM    Q_UNUSED(reg);#else    switch(reg)    {    case Help:        return (const char **)default_help_xpm;    case Menu:        return (const char **)default_menu_xpm;    case Close:        return (const char **)default_close_xpm;    case Minimize:        return (const char **)default_minimize_xpm;    case Maximize:        return (const char **)default_maximize_xpm;    case Normalize:        return (const char **)default_normalize_xpm;    }#endif    return 0;}QPixmap QDecorationDefault::pixmapFor(const QWidget *widget, int decorationRegion,                                      int &xoff, int &/*yoff*/){#ifdef QT_NO_IMAGEFORMAT_XPM    Q_UNUSED(widget);    Q_UNUSED(decorationRegion);    Q_UNUSED(xoff);    return QPixmap();#else    static const char **staticHelpPixmapXPM = 0;    static const char **staticMenuPixmapXPM = 0;    static const char **staticClosePixmapXPM = 0;    static const char **staticMinimizePixmapXPM = 0;    static const char **staticMaximizePixmapXPM = 0;    static const char **staticNormalizePixmapXPM = 0;    const char **xpm;    // Why don't we just use/extend the enum type...    if (staticHelpPixmapXPM != (xpm = xpmForRegion(Help)) || !staticHelpPixmap) {        staticHelpPixmapXPM = xpm;        staticHelpPixmap = new QPixmap(xpm);    }    if (staticMenuPixmapXPM != (xpm = xpmForRegion(Menu)) || !staticMenuPixmap) {        staticMenuPixmapXPM = xpm;        staticMenuPixmap = new QPixmap(xpm);    }    if (staticClosePixmapXPM != (xpm = xpmForRegion(Close)) || !staticClosePixmap) {        staticClosePixmapXPM = xpm;        staticClosePixmap = new QPixmap(xpm);    }    if (staticMinimizePixmapXPM != (xpm = xpmForRegion(Minimize)) || !staticMinimizePixmap) {        staticMinimizePixmapXPM = xpm;        staticMinimizePixmap = new QPixmap(xpm);    }    if (staticMaximizePixmapXPM != (xpm = xpmForRegion(Maximize)) || !staticMaximizePixmap) {        staticMaximizePixmapXPM = xpm;        staticMaximizePixmap = new QPixmap(xpm);    }    if (staticNormalizePixmapXPM != (xpm = xpmForRegion(Normalize)) || !staticNormalizePixmap) {        staticNormalizePixmapXPM = xpm;        staticNormalizePixmap = new QPixmap(xpm);    }    const QPixmap *pm = 0;    switch (decorationRegion) {        case Help:            pm = staticHelpPixmap;            break;        case Menu:            if (!widget->windowIcon().isNull())                return widget->windowIcon().pixmap(16,16); //##### QIcon::pixmap() needs a size !!!!!!"            if (!pm) {                xoff = 1;                pm = staticMenuPixmap;            }            break;        case Close:            pm = staticClosePixmap;            break;        case Maximize:            pm = staticMaximizePixmap;            break;        case Normalize:            pm = staticNormalizePixmap;            break;        case Minimize:            pm = staticMinimizePixmap;            break;        default:            break;    }    return *pm;#endif}int QDecorationDefault::titleBarHeight(const QWidget *){    return qMax(20, QApplication::fontMetrics().lineSpacing() + BORDER_WIDTH);}QRegion QDecorationDefault::region(const QWidget *widget, const QRect &rect, int decorationRegion){    Qt::WindowFlags flags = widget->windowFlags();    bool hasBorder = !widget->isMaximized();    bool hasTitle = flags & Qt::WindowTitleHint;    bool hasSysMenu = flags & Qt::WindowSystemMenuHint;    bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;    bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;    bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;    int state = widget->windowState();    bool isMinimized = state & Qt::WindowMinimized;    bool isMaximized = state & Qt::WindowMaximized;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -