File indexing completed on 2024-05-19 09:43:14
0001 /***************************************************************************** 0002 * Copyright 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 #ifndef qtcurvesizegrip_h 0024 #define qtcurvesizegrip_h 0025 0026 ////////////////////////////////////////////////////////////////////////////// 0027 // qtcurvesizegrip.h 0028 // ------------------- 0029 // 0030 // Taken from Oxygen kwin decoration 0031 // ------------ 0032 // 0033 // Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0034 // 0035 // Permission is hereby granted, free of charge, to any person obtaining a copy 0036 // of this software and associated documentation files (the "Software"), to 0037 // deal in the Software without restriction, including without limitation the 0038 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 0039 // sell copies of the Software, and to permit persons to whom the Software is 0040 // furnished to do so, subject to the following conditions: 0041 // 0042 // The above copyright notice and this permission notice shall be included in 0043 // all copies or substantial portions of the Software. 0044 // 0045 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0046 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0047 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0048 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0049 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0050 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 0051 // IN THE SOFTWARE. 0052 ////////////////////////////////////////////////////////////////////////////// 0053 0054 #include <QWidget> 0055 #include <QPaintEvent> 0056 #include <QMouseEvent> 0057 0058 namespace QtCurve { 0059 namespace KWin { 0060 0061 class QtCurveClient; 0062 0063 //! implements size grip for all widgets 0064 class QtCurveSizeGrip: public QWidget { 0065 public: 0066 //! constructor 0067 QtCurveSizeGrip(QtCurveClient*); 0068 0069 //! constructor 0070 ~QtCurveSizeGrip() override; 0071 0072 //! event filter 0073 bool eventFilter(QObject*, QEvent*) override; 0074 0075 public Q_SLOTS: 0076 //! update background color 0077 void activeChange(); 0078 0079 protected Q_SLOTS: 0080 //! embed into parent widget 0081 void embed(); 0082 0083 protected: 0084 //!@name event handlers 0085 //@{ 0086 0087 //! paint 0088 void paintEvent(QPaintEvent*) override; 0089 0090 //! mouse press 0091 void mousePressEvent(QMouseEvent*) override; 0092 0093 //@} 0094 0095 //! client 0096 QtCurveClient& 0097 client() const 0098 { 0099 return *client_; 0100 } 0101 0102 //! update position 0103 void updatePosition(); 0104 0105 private: 0106 //! grip size 0107 enum { 0108 OFFSET = 0, 0109 GRIP_SIZE = 12 0110 }; 0111 // qtcurve client 0112 QtCurveClient* client_; 0113 }; 0114 0115 } 0116 } 0117 0118 #endif