1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <vclpluginapi.h>
23 #include <WidgetDrawInterface.hxx>
27 #include <QtGui/QImage>
28 #include <QtGui/QPainter>
29 #include <QtGui/QRegion>
30 #include <QtWidgets/QPushButton>
31 #include <QtWidgets/QStyle>
32 #include <QtWidgets/QStyleOption>
36 class QtGraphics_Controls final
: public vcl::WidgetDrawInterface
38 std::unique_ptr
<QImage
> m_image
;
39 QRect m_lastPopupRect
;
40 QtGraphicsBase
const& m_rGraphics
;
43 QtGraphics_Controls(const QtGraphicsBase
& 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
;
62 static int pixelMetric(QStyle::PixelMetric metric
, const QStyleOption
* option
= nullptr,
63 const QWidget
* pWidget
= nullptr);
64 static QSize
sizeFromContents(QStyle::ContentsType type
, const QStyleOption
* option
,
65 const QSize
& contentsSize
);
66 static QRect
subControlRect(QStyle::ComplexControl control
, const QStyleOptionComplex
* option
,
67 QStyle::SubControl subControl
);
68 static QRect
subElementRect(QStyle::SubElement element
, const QStyleOption
* option
);
70 void draw(QStyle::ControlElement element
, QStyleOption
& rOption
, QImage
* image
,
71 const Color
& rBackgroundColor
, QStyle::State
const state
= QStyle::State_None
,
72 QRect rect
= QRect());
73 void draw(QStyle::PrimitiveElement element
, QStyleOption
& rOption
, QImage
* image
,
74 const Color
& rBackgroundColor
, QStyle::State
const state
= QStyle::State_None
,
75 QRect rect
= QRect());
76 void draw(QStyle::ComplexControl element
, QStyleOptionComplex
& rOption
, QImage
* image
,
77 const Color
& rBackgroundColor
, QStyle::State
const state
= QStyle::State_None
);
78 void drawFrame(QStyle::PrimitiveElement element
, QImage
* image
, const Color
& rBackGroundColor
,
79 QStyle::State
const& state
, bool bClip
= true,
80 QStyle::PixelMetric eLineMetric
= QStyle::PM_DefaultFrameWidth
);
82 static void fillQStyleOptionTab(const ImplControlValue
& value
, QStyleOptionTab
& sot
);
83 void fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame
& option
, bool bDownscale
);
91 int downscale(int value
, Round eRound
);
92 int upscale(int value
, Round eRound
);
93 QRect
downscale(const QRect
& rect
);
94 QRect
upscale(const QRect
& rect
);
95 QSize
downscale(const QSize
& size
, Round eRound
);
96 QSize
upscale(const QSize
& size
, Round eRound
);
97 QPoint
upscale(const QPoint
& point
, Round eRound
);
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */