bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / qt5 / Qt5Graphics_Controls.hxx
blob515cae7be70b95bef651c055b3d417f20cd534f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <vclpluginapi.h>
23 #include <WidgetDrawInterface.hxx>
25 #include <memory>
27 #include <QtGui/QImage>
28 #include <QtGui/QPainter>
29 #include <QtGui/QRegion>
30 #include <QtWidgets/QPushButton>
31 #include <QtWidgets/QStyle>
32 #include <QtWidgets/QStyleOption>
34 class Qt5GraphicsBase;
36 class Qt5Graphics_Controls final : public vcl::WidgetDrawInterface
38 std::unique_ptr<QImage> m_image;
39 QRect m_lastPopupRect;
40 Qt5GraphicsBase const& m_rGraphics;
42 public:
43 Qt5Graphics_Controls(const Qt5GraphicsBase& rGraphics);
45 QImage* getImage() { return m_image.get(); }
47 bool isNativeControlSupported(ControlType nType, ControlPart nPart) override;
48 bool hitTestNativeControl(ControlType nType, ControlPart nPart,
49 const tools::Rectangle& rControlRegion, const Point& aPos,
50 bool& rIsInside) override;
51 bool drawNativeControl(ControlType nType, ControlPart nPart,
52 const tools::Rectangle& rControlRegion, ControlState nState,
53 const ImplControlValue& aValue, const OUString& aCaption,
54 const Color& rBackgroundColor) override;
55 bool getNativeControlRegion(ControlType nType, ControlPart nPart,
56 const tools::Rectangle& rControlRegion, ControlState nState,
57 const ImplControlValue& aValue, const OUString& aCaption,
58 tools::Rectangle& rNativeBoundingRegion,
59 tools::Rectangle& rNativeContentRegion) override;
61 private:
62 static int pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option = nullptr);
63 static QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption* option,
64 const QSize& contentsSize);
65 static QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex* option,
66 QStyle::SubControl subControl);
67 static QRect subElementRect(QStyle::SubElement element, const QStyleOption* option);
69 void draw(QStyle::ControlElement element, QStyleOption& rOption, QImage* image,
70 const Color& rBackgroundColor, QStyle::State const state = QStyle::State_None,
71 QRect rect = QRect());
72 void draw(QStyle::PrimitiveElement element, QStyleOption& rOption, QImage* image,
73 const Color& rBackgroundColor, QStyle::State const state = QStyle::State_None,
74 QRect rect = QRect());
75 void draw(QStyle::ComplexControl element, QStyleOptionComplex& rOption, QImage* image,
76 const Color& rBackgroundColor, QStyle::State const state = QStyle::State_None);
77 void drawFrame(QStyle::PrimitiveElement element, QImage* image, const Color& rBackGroundColor,
78 QStyle::State const& state, bool bClip = true,
79 QStyle::PixelMetric eLineMetric = QStyle::PM_DefaultFrameWidth);
81 static void fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot);
82 void fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option, bool bDownscale);
84 enum class Round
86 Floor,
87 Ceil,
90 int downscale(int value, Round eRound);
91 int upscale(int value, Round eRound);
92 QRect downscale(const QRect& rect);
93 QRect upscale(const QRect& rect);
94 QSize downscale(const QSize& size, Round eRound);
95 QSize upscale(const QSize& size, Round eRound);
96 QPoint upscale(const QPoint& point, Round eRound);
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */