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 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);
68
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);
80
81 static void fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot);
82 void fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option, bool bDownscale);
83
84 enum class Round
85 {
86 Floor,
87 Ceil,
88 };
89
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);
97};
98
99/* 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 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 int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option=nullptr)
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