File indexing completed on 2024-04-28 17:04:37
0001 /***************************************************************************** 0002 * Copyright 2007 - 2010 Craig Drummond <craig.p.drummond@gmail.com> * 0003 * Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU Lesser General Public License as * 0007 * published by the Free Software Foundation; either version 2.1 of the * 0008 * License, or (at your option) version 3, or any later version accepted * 0009 * by the membership of KDE e.V. (or its successor approved by the * 0010 * membership of KDE e.V.), which shall act as a proxy defined in * 0011 * Section 6 of version 3 of the license. * 0012 * * 0013 * This program is distributed in the hope that it will be useful, * 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0016 * Lesser General Public License for more details. * 0017 * * 0018 * You should have received a copy of the GNU Lesser General Public * 0019 * License along with this library. If not, * 0020 * see <http://www.gnu.org/licenses/>. * 0021 *****************************************************************************/ 0022 0023 /* 0024 based on the window decoration "Plastik": 0025 Copyright (C) 2003-2005 Sandro Giessl <sandro@giessl.com> 0026 0027 based on the window decoration "Web": 0028 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 0029 */ 0030 0031 #ifndef QTCURVECLIENT_H 0032 #define QTCURVECLIENT_H 0033 0034 #include "config.h" 0035 0036 #include <kdeversion.h> 0037 #include <kcommondecoration.h> 0038 #include <QPixmap> 0039 #include <QColor> 0040 #include "qtcurvehandler.h" 0041 0042 namespace QtCurve { 0043 namespace KWin { 0044 0045 class QtCurveSizeGrip; 0046 class QtCurveButton; 0047 class QtCurveToggleButton; 0048 0049 class QtCurveClient : public KCommonDecorationUnstable { 0050 Q_OBJECT 0051 public: 0052 QtCurveClient(KDecorationBridge *bridge, QtCurveHandler *factory); 0053 ~QtCurveClient() override; 0054 0055 QString visibleName() const; 0056 bool decorationBehaviour(DecorationBehaviour behaviour) const; 0057 int layoutMetric(LayoutMetric lm, bool respectWindowState=true, 0058 const KCommonDecorationButton *btn=0) const; 0059 KCommonDecorationButton *createButton(ButtonType type); 0060 void init(); 0061 void maximizeChange(); 0062 void shadeChange(); 0063 void activeChange(); 0064 void captionChange(); 0065 void reset(unsigned long changed); 0066 void paintEvent(QPaintEvent *e); 0067 void paintTitle(QPainter *painter, const QRect &capRect, 0068 const QRect &alignFullRect, const QString &cap, 0069 const QPixmap &pix, int shadowSize=0, bool isTab=false, 0070 bool activeTab=false); 0071 void updateWindowShape(); 0072 QRegion getMask(int round, const QRect &r) const; 0073 void updateCaption(); 0074 bool eventFilter(QObject *o, QEvent *e); 0075 bool isMaximized() const 0076 { 0077 return (maximizeMode() == MaximizeFull && 0078 !options()->moveResizeMaximizedWindows()); 0079 } 0080 void menuBarSize(int size); 0081 void statusBarState(bool state); 0082 QtCurveToggleButton *createToggleButton(bool menubar); 0083 void informAppOfBorderSizeChanges(); 0084 void sendToggleToApp(bool menubar); 0085 public Q_SLOTS: 0086 void toggleMenuBar(); 0087 void toggleStatusBar(); 0088 0089 private: 0090 bool onlyMenuIcon(bool left) const; 0091 QRect captionRect() const; 0092 void createSizeGrip(); 0093 void deleteSizeGrip(); 0094 void informAppOfActiveChange(); 0095 const QString &windowClass(); 0096 0097 struct ButtonBgnd { 0098 QPixmap pix; 0099 int app; 0100 QColor col; 0101 }; 0102 0103 static const int constNumButtonStates = 2; 0104 0105 QtCurveSizeGrip *m_resizeGrip; 0106 ButtonBgnd m_buttonBackground[constNumButtonStates]; 0107 QRect m_captionRect; 0108 QString m_caption; 0109 QString m_windowClass; 0110 QFont m_titleFont; 0111 int m_menuBarSize; 0112 QtCurveToggleButton *m_toggleMenuBarButton; 0113 QtCurveToggleButton *m_toggleStatusBarButton; 0114 // bool m_hover; 0115 }; 0116 0117 } 0118 } 0119 0120 #endif