Changeset View
Changeset View
Standalone View
Standalone View
libbreezecommon/breezerenderdecorationbuttonicon.h
- This file was added.
| Property | Old Value | New Value |
|---|---|---|
| File Mode | null | 100755 |
| 1 | #ifndef BREEZE_RENDERDECORATIONBUTTONICON_H | ||||
|---|---|---|---|---|---|
| 2 | #define BREEZE_RENDERDECORATIONBUTTONICON_H | ||||
| 3 | | ||||
| 4 | /* | ||||
| 5 | * Copyright 2020 Paul McAuley <kde@paulmcauley.com> | ||||
| 6 | * | ||||
| 7 | * This program is free software; you can redistribute it and/or | ||||
| 8 | * modify it under the terms of the GNU General Public License as | ||||
| 9 | * published by the Free Software Foundation; either version 2 of | ||||
| 10 | * the License or (at your option) version 3 or any later version | ||||
| 11 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
| 12 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
| 13 | * defined in Section 14 of version 3 of the license. | ||||
| 14 | * | ||||
| 15 | * This program is distributed in the hope that it will be useful, | ||||
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| 18 | * GNU General Public License for more details. | ||||
| 19 | * | ||||
| 20 | * You should have received a copy of the GNU General Public License | ||||
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
| 22 | */ | ||||
| 23 | | ||||
| 24 | #include "breezecommon_export.h" | ||||
| 25 | | ||||
| 26 | #include <QPainter> | ||||
| 27 | #include <memory> | ||||
| 28 | | ||||
| 29 | namespace Breeze | ||||
| 30 | { | ||||
| 31 | | ||||
| 32 | /** | ||||
| 33 | * @brief Base Class to render decoration button icons in style set by EnumButtonIconStyle. | ||||
| 34 | * Rendering is to be performed on a QPainter object with an 18x18 reference window. | ||||
| 35 | * Co-ordinates relative to top-left. | ||||
| 36 | * To be used as common code base across both kdecoration and kstyle. | ||||
| 37 | */ | ||||
| 38 | class BREEZECOMMON_EXPORT RenderDecorationButtonIcon18By18 | ||||
| 39 | { | ||||
| 40 | | ||||
| 41 | public: | ||||
| 42 | | ||||
| 43 | /** | ||||
| 44 | * @brief Button Icon styles as defined in the .kcfg files. | ||||
| 45 | */ | ||||
| 46 | enum EnumButtonIconStyle { StyleClassic, StyleOxygen, StyleRedmond }; | ||||
| 47 | | ||||
| 48 | | ||||
| 49 | /** | ||||
| 50 | * @brief Factory to return a pointer to a new inherited object to render in the specified style. | ||||
| 51 | * | ||||
| 52 | * @param painter A QPainter object already initialised with an 18x18 reference window. | ||||
| 53 | * @param pen QPen with width and color already initialized. | ||||
| 54 | * @param buttonIconStyle The desired icon style as equivalent to type EnumButtonIconStyle. | ||||
| 55 | * @param notInTitlebar Indicates that button is not to be drawn in the title bar, but somewhere else in the UI -- ususally means will be smaller | ||||
| 56 | * @return std::unique_ptr< Breeze::RenderDecorationButtonIcon18By18, std::default_delete< Breeze::RenderDecorationButtonIcon18By18 > > Pointer to a new sub-style object. | ||||
| 57 | */ | ||||
| 58 | static std::unique_ptr<RenderDecorationButtonIcon18By18> factory( QPainter* painter, const QPen& pen, int buttonIconStyle = int(StyleOxygen), const bool notInTitlebar = false); | ||||
| 59 | | ||||
| 60 | virtual ~RenderDecorationButtonIcon18By18(){}; | ||||
| 61 | | ||||
| 62 | virtual void renderCloseIcon(); | ||||
| 63 | virtual void renderMaximizeIcon(); | ||||
| 64 | virtual void renderRestoreIcon(); | ||||
| 65 | virtual void renderMinimizeIcon(); | ||||
| 66 | virtual void renderPinnedOnAllDesktopsIcon(); | ||||
| 67 | virtual void renderPinOnAllDesktopsIcon(); | ||||
| 68 | virtual void renderShadeIcon(); | ||||
| 69 | virtual void renderUnShadeIcon(); | ||||
| 70 | virtual void renderKeepBehindIcon(); | ||||
| 71 | virtual void renderKeepInFrontIcon(); | ||||
| 72 | virtual void renderApplicationMenuIcon(); | ||||
| 73 | virtual void renderContextHelpIcon(); | ||||
| 74 | | ||||
| 75 | protected: | ||||
| 76 | | ||||
| 77 | /** | ||||
| 78 | * @brief Constructor | ||||
| 79 | * | ||||
| 80 | * @param painter A QPainter object already initialised with an 18x18 reference window. | ||||
| 81 | * @param pen QPen with width and color already initialised. | ||||
| 82 | * @param notInTitlebar Indicates that button is not to be drawn in the title bar, but somewhere else in the UI -- ususally means will be smaller | ||||
| 83 | */ | ||||
| 84 | RenderDecorationButtonIcon18By18( QPainter* painter, const QPen& pen, const bool notInTitlebar); | ||||
| 85 | | ||||
| 86 | | ||||
| 87 | /** | ||||
| 88 | * @brief Initialises pen to standardise cap and join styles. | ||||
| 89 | * No brush is normal for Breeze's simple outline style. | ||||
| 90 | */ | ||||
| 91 | virtual void initPainter(); | ||||
| 92 | | ||||
| 93 | QPainter* painter; | ||||
| 94 | QPen pen; | ||||
| 95 | bool notInTitlebar; | ||||
| 96 | | ||||
| 97 | }; | ||||
| 98 | | ||||
| 99 | } | ||||
| 100 | | ||||
| 101 | #endif | ||||