LibreOffice Module vcl (master) 1
qt5/QtGraphics_Controls.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <vclpluginapi.h>
24
25#include <memory>
26
27#include <QtGui/QImage>
28#include <QtGui/QPainter>
29#include <QtGui/QRegion>
30#include <QtWidgets/QPushButton>
31#include <QtWidgets/QStyle>
32#include <QtWidgets/QStyleOption>
33
34class QtGraphicsBase;
35
37{
38 std::unique_ptr<QImage> m_image;
41
42public:
44
45 QImage* getImage() { return m_image.get(); }
46
49 const tools::Rectangle& rControlRegion, const Point& aPos,
50 bool& rIsInside) override;
52 const tools::Rectangle& rControlRegion, ControlState nState,
53 const ImplControlValue& aValue, const OUString& aCaption,
54 const Color& rBackgroundColor) override;
56 const tools::Rectangle& rControlRegion, ControlState nState,
57 const ImplControlValue& aValue, const OUString& aCaption,
58 tools::Rectangle& rNativeBoundingRegion,
59 tools::Rectangle& rNativeContentRegion) override;
60
61private:
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);
69
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);
81
82 static void fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot);
83 void fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option, bool bDownscale);
84
85 enum class Round
86 {
87 Floor,
88 Ceil,
89 };
90
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);
98};
99
100/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
QSize upscale(const QSize &size, Round eRound)
static int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *pWidget=nullptr)
static QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize)
void drawFrame(QStyle::PrimitiveElement element, QImage *image, const Color &rBackGroundColor, QStyle::State const &state, bool bClip=true, QStyle::PixelMetric eLineMetric=QStyle::PM_DefaultFrameWidth)
QtGraphicsBase const & m_rGraphics
std::unique_ptr< QImage > m_image
void fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame &option, bool bDownscale)
static QRect subElementRect(QStyle::SubElement element, const QStyleOption *option)
bool isNativeControlSupported(ControlType nType, ControlPart nPart) override
Query the platform layer for native control support.
bool getNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) override
Get the native control regions for the control part.
QtGraphics_Controls(const QtGraphicsBase &rGraphics)
void draw(QStyle::ControlElement element, QStyleOption &rOption, QImage *image, const Color &rBackgroundColor, QStyle::State const state=QStyle::State_None, QRect rect=QRect())
static QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl)
void draw(QStyle::PrimitiveElement element, QStyleOption &rOption, QImage *image, const Color &rBackgroundColor, QStyle::State const state=QStyle::State_None, QRect rect=QRect())
QPoint upscale(const QPoint &point, Round eRound)
QSize downscale(const QSize &size, Round eRound)
bool drawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor) override
Draw the requested control.
QRect upscale(const QRect &rect)
void draw(QStyle::ComplexControl element, QStyleOptionComplex &rOption, QImage *image, const Color &rBackgroundColor, QStyle::State const state=QStyle::State_None)
QRect downscale(const QRect &rect)
bool hitTestNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, const Point &aPos, bool &rIsInside) override
Query if a position is inside the native widget part.
static void fillQStyleOptionTab(const ImplControlValue &value, QStyleOptionTab &sot)
int downscale(int value, Round eRound)
int upscale(int value, Round eRound)
JCOPY_OPTION option
Definition: transupp.h:208