LibreOffice Module vcl (master) 1
gtkgdi.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#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
21#define INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
22
23#include <config_cairo_canvas.h>
24
25#include <gtk/gtk.h>
26#include "gtkbackend.hxx"
27#include <gdk/gdkkeysyms.h>
28
29#include <unx/gtk/gtkframe.hxx>
30#include <ControlCacheKey.hxx>
31
32#include <headless/svpgdi.hxx>
33#include <textrender.hxx>
34
36{
38 Button,
44 Entry,
51 Listbox,
81 MenuBar,
84 Menu,
94};
95
96class GtkSalGraphics final : public SvpSalGraphics
97{
99
100#if !GTK_CHECK_VERSION(4, 0, 0)
102 virtual bool drawNativeControl( ControlType nType, ControlPart nPart,
103 const tools::Rectangle& rControlRegion,
104 ControlState nState, const ImplControlValue& aValue,
105 const OUString& rCaption,
106 const Color& rBackgroundColor ) override;
108 const tools::Rectangle& rControlRegion,
109 ControlState nState,
110 const ImplControlValue& aValue,
111 const OUString& rCaption,
112 tools::Rectangle &rNativeBoundingRegion,
113 tools::Rectangle &rNativeContentRegion ) override;
114#endif
116 void handleDamage(const tools::Rectangle&) override;
117
118public:
120
121#if ENABLE_CAIRO_CANVAS
122 virtual bool SupportsCairo() const override;
123 virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
124 virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
125#endif
126
127 void WidgetQueueDraw() const;
128
129 virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
130
131 virtual OUString getRenderBackendName() const override { return "gtk3svp"; }
132
133 GtkStyleContext* createStyleContext(GtkControlPart ePart);
134#if !GTK_CHECK_VERSION(4, 0, 0)
135 GtkStyleContext* makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent);
136#endif
137private:
139 static GtkStyleContext *mpWindowStyle;
140 static GtkStyleContext *mpButtonStyle;
141 static GtkStyleContext *mpLinkButtonStyle;
142 static GtkStyleContext *mpEntryStyle;
143 static GtkStyleContext *mpTextViewStyle;
144 static GtkStyleContext *mpVScrollbarStyle;
145 static GtkStyleContext *mpVScrollbarContentsStyle;
146 static GtkStyleContext *mpVScrollbarTroughStyle;
147 static GtkStyleContext *mpVScrollbarSliderStyle;
148 static GtkStyleContext *mpVScrollbarButtonStyle;
149 static GtkStyleContext *mpHScrollbarStyle;
150 static GtkStyleContext *mpHScrollbarContentsStyle;
151 static GtkStyleContext *mpHScrollbarTroughStyle;
152 static GtkStyleContext *mpHScrollbarSliderStyle;
153 static GtkStyleContext *mpHScrollbarButtonStyle;
154 static GtkStyleContext *mpToolbarStyle;
155 static GtkStyleContext *mpToolButtonStyle;
156 static GtkStyleContext *mpToolbarSeparatorStyle;
157 static GtkStyleContext *mpCheckButtonStyle;
158 static GtkStyleContext *mpCheckButtonCheckStyle;
159 static GtkStyleContext *mpRadioButtonStyle;
160 static GtkStyleContext *mpRadioButtonRadioStyle;
161 static GtkStyleContext *mpSpinStyle;
162 static GtkStyleContext *mpSpinUpStyle;
163 static GtkStyleContext *mpSpinDownStyle;
164 static GtkStyleContext *mpComboboxStyle;
165 static GtkStyleContext *mpComboboxBoxStyle;
166 static GtkStyleContext *mpComboboxEntryStyle;
167 static GtkStyleContext *mpComboboxButtonStyle;
168 static GtkStyleContext *mpComboboxButtonBoxStyle;
169 static GtkStyleContext *mpComboboxButtonArrowStyle;
170 static GtkStyleContext *mpListboxStyle;
171 static GtkStyleContext *mpListboxBoxStyle;
172 static GtkStyleContext *mpListboxButtonStyle;
173 static GtkStyleContext *mpListboxButtonBoxStyle;
174 static GtkStyleContext *mpListboxButtonArrowStyle;
175 static GtkStyleContext *mpFrameInStyle;
176 static GtkStyleContext *mpFrameOutStyle;
177 static GtkStyleContext *mpFixedHoriLineStyle;
178 static GtkStyleContext *mpFixedVertLineStyle;
179 static GtkStyleContext *mpTreeHeaderButtonStyle;
180 static GtkStyleContext *mpProgressBarStyle;
181 static GtkStyleContext *mpProgressBarTroughStyle;
182 static GtkStyleContext *mpProgressBarProgressStyle;
183 static GtkStyleContext *mpNotebookStyle;
184 static GtkStyleContext *mpNotebookStackStyle;
185 static GtkStyleContext *mpNotebookHeaderStyle;
186 static GtkStyleContext *mpNotebookHeaderTabsStyle;
187 static GtkStyleContext *mpNotebookHeaderTabsTabStyle;
188 static GtkStyleContext *mpNotebookHeaderTabsTabLabelStyle;
191 static GtkStyleContext *mpMenuBarStyle;
192 static GtkStyleContext *mpMenuBarItemStyle;
193 static GtkStyleContext *mpMenuWindowStyle;
194 static GtkStyleContext *mpMenuStyle;
195 static GtkStyleContext *mpMenuItemStyle;
196 static GtkStyleContext *mpMenuItemLabelStyle;
197 static GtkStyleContext *mpMenuItemArrowStyle;
198 static GtkStyleContext *mpCheckMenuItemStyle;
199 static GtkStyleContext *mpCheckMenuItemCheckStyle;
200 static GtkStyleContext *mpRadioMenuItemStyle;
201 static GtkStyleContext *mpRadioMenuItemRadioStyle;
202 static GtkStyleContext *mpSeparatorMenuItemStyle;
203 static GtkStyleContext *mpSeparatorMenuItemSeparatorStyle;
205
206#if !GTK_CHECK_VERSION(4, 0, 0)
210
211 static void PaintScrollbar(GtkStyleContext *context,
212 cairo_t *cr,
213 const tools::Rectangle& rControlRectangle,
214 ControlPart nPart,
215 const ImplControlValue& aValue );
216 void PaintOneSpinButton( GtkStyleContext *context,
217 cairo_t *cr,
218 ControlPart nPart,
219 tools::Rectangle aAreaRect,
220 ControlState nState );
221 void PaintSpinButton(GtkStateFlags flags,
222 cairo_t *cr,
223 const tools::Rectangle& rControlRectangle,
224 ControlPart nPart,
225 const ImplControlValue& aValue);
226 static void PaintCombobox(GtkStateFlags flags,
227 cairo_t *cr,
228 const tools::Rectangle& rControlRectangle,
229 ControlType nType,
230 ControlPart nPart);
231 static void PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context,
232 const tools::Rectangle& rControlRectangle,
233 bool bIsCheck, bool bInMenu);
234
235 static void PaintCheck(cairo_t *cr, GtkStyleContext *context,
236 const tools::Rectangle& rControlRectangle, bool bInMenu);
237
238 static void PaintRadio(cairo_t *cr, GtkStyleContext *context,
239 const tools::Rectangle& rControlRectangle, bool bInMenu);
240#endif
241
242 static bool style_loaded;
243};
244
245#endif // INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
246
247/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _cairo cairo_t
Definition: CairoCommon.hxx:45
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
static void PaintCheck(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bInMenu)
void handleDamage(const tools::Rectangle &) override
Handle damage done by drawing with a widget draw override.
static void PaintRadio(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bInMenu)
static GtkStyleContext * mpProgressBarStyle
Definition: gtkgdi.hxx:180
static GtkStyleContext * mpFixedHoriLineStyle
Definition: gtkgdi.hxx:177
static tools::Rectangle NWGetSpinButtonRect(ControlPart nPart, tools::Rectangle aAreaRect)
static GtkStyleContext * mpProgressBarProgressStyle
Definition: gtkgdi.hxx:182
static GtkStyleContext * mpNotebookStyle
Definition: gtkgdi.hxx:183
static GtkStyleContext * mpEntryStyle
Definition: gtkgdi.hxx:142
static GtkStyleContext * mpSpinUpStyle
Definition: gtkgdi.hxx:162
static GtkStyleContext * mpVScrollbarContentsStyle
Definition: gtkgdi.hxx:145
static GtkStyleContext * mpFrameOutStyle
Definition: gtkgdi.hxx:176
static GtkStyleContext * mpNotebookHeaderTabsTabLabelStyle
Definition: gtkgdi.hxx:188
void PaintSpinButton(GtkStateFlags flags, cairo_t *cr, const tools::Rectangle &rControlRectangle, ControlPart nPart, const ImplControlValue &aValue)
static GtkStyleContext * mpMenuBarItemStyle
Definition: gtkgdi.hxx:192
static GtkStyleContext * mpToolbarSeparatorStyle
Definition: gtkgdi.hxx:156
static GtkStyleContext * mpHScrollbarStyle
Definition: gtkgdi.hxx:149
static GtkStyleContext * mpCheckButtonStyle
Definition: gtkgdi.hxx:157
static GtkStyleContext * mpWindowStyle
Definition: gtkgdi.hxx:139
static GtkStyleContext * mpSeparatorMenuItemStyle
Definition: gtkgdi.hxx:202
static GtkStyleContext * mpVScrollbarSliderStyle
Definition: gtkgdi.hxx:147
virtual bool getNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &rCaption, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) override
Get the native control regions for the control part.
static GtkStyleContext * mpNotebookHeaderTabsTabHoverLabelStyle
Definition: gtkgdi.hxx:190
GtkSalGraphics(GtkSalFrame *pFrame, GtkWidget *pWindow)
GtkSalFrame *const mpFrame
Definition: gtkgdi.hxx:98
GtkStyleContext * makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent)
void WidgetQueueDraw() const
static GtkStyleContext * mpProgressBarTroughStyle
Definition: gtkgdi.hxx:181
static GtkStyleContext * mpButtonStyle
Definition: gtkgdi.hxx:140
static GtkStyleContext * mpSpinDownStyle
Definition: gtkgdi.hxx:163
static GtkStyleContext * mpListboxButtonBoxStyle
Definition: gtkgdi.hxx:173
static void PaintScrollbar(GtkStyleContext *context, cairo_t *cr, const tools::Rectangle &rControlRectangle, ControlPart nPart, const ImplControlValue &aValue)
static GtkStyleContext * mpCheckMenuItemCheckStyle
Definition: gtkgdi.hxx:199
virtual bool drawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &rCaption, const Color &rBackgroundColor) override
Draw the requested control.
static GtkStyleContext * mpLinkButtonStyle
Definition: gtkgdi.hxx:141
static GtkStyleContext * mpFrameInStyle
Definition: gtkgdi.hxx:175
static GtkStyleContext * mpToolButtonStyle
Definition: gtkgdi.hxx:155
static GtkStyleContext * mpHScrollbarContentsStyle
Definition: gtkgdi.hxx:150
static GtkStyleContext * mpNotebookHeaderTabsTabStyle
Definition: gtkgdi.hxx:187
static GtkStyleContext * mpTreeHeaderButtonStyle
Definition: gtkgdi.hxx:179
static GtkStyleContext * mpRadioButtonStyle
Definition: gtkgdi.hxx:159
static GtkStyleContext * mpSpinStyle
Definition: gtkgdi.hxx:161
static GtkStyleContext * mpMenuBarStyle
Definition: gtkgdi.hxx:191
static GtkStyleContext * mpListboxButtonArrowStyle
Definition: gtkgdi.hxx:174
bool isNativeControlSupported(ControlType, ControlPart) override
Query the platform layer for native control support.
static GtkStyleContext * mpListboxButtonStyle
Definition: gtkgdi.hxx:172
GtkStyleContext * createStyleContext(GtkControlPart ePart)
static GtkStyleContext * mpRadioMenuItemStyle
Definition: gtkgdi.hxx:200
virtual OUString getRenderBackendName() const override
Definition: gtkgdi.hxx:131
static tools::Rectangle NWGetScrollButtonRect(ControlPart nPart, tools::Rectangle aAreaRect)
static void PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bIsCheck, bool bInMenu)
static GtkStyleContext * mpHScrollbarSliderStyle
Definition: gtkgdi.hxx:152
static GtkStyleContext * mpRadioMenuItemRadioStyle
Definition: gtkgdi.hxx:201
static GtkStyleContext * mpToolbarStyle
Definition: gtkgdi.hxx:154
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY) override
static GtkStyleContext * mpNotebookHeaderStyle
Definition: gtkgdi.hxx:185
static tools::Rectangle NWGetComboBoxButtonRect(ControlType nType, ControlPart nPart, tools::Rectangle aAreaRect)
static GtkStyleContext * mpComboboxButtonStyle
Definition: gtkgdi.hxx:167
static GtkStyleContext * mpMenuItemStyle
Definition: gtkgdi.hxx:195
static bool style_loaded
Definition: gtkgdi.hxx:242
GtkWidget * mpWindow
Definition: gtkgdi.hxx:138
static GtkStyleContext * mpFixedVertLineStyle
Definition: gtkgdi.hxx:178
static GtkStyleContext * mpComboboxButtonArrowStyle
Definition: gtkgdi.hxx:169
static GtkStyleContext * mpRadioButtonRadioStyle
Definition: gtkgdi.hxx:160
static GtkStyleContext * mpComboboxBoxStyle
Definition: gtkgdi.hxx:165
static GtkStyleContext * mpHScrollbarTroughStyle
Definition: gtkgdi.hxx:151
void PaintOneSpinButton(GtkStyleContext *context, cairo_t *cr, ControlPart nPart, tools::Rectangle aAreaRect, ControlState nState)
static GtkStyleContext * mpMenuItemArrowStyle
Definition: gtkgdi.hxx:197
bool updateSettings(AllSettings &) override
static gint mnVerticalSeparatorMinWidth
Definition: gtkgdi.hxx:204
static GtkStyleContext * mpVScrollbarTroughStyle
Definition: gtkgdi.hxx:146
static GtkStyleContext * mpComboboxStyle
Definition: gtkgdi.hxx:164
static GtkStyleContext * mpHScrollbarButtonStyle
Definition: gtkgdi.hxx:153
static GtkStyleContext * mpListboxBoxStyle
Definition: gtkgdi.hxx:171
static GtkStyleContext * mpCheckMenuItemStyle
Definition: gtkgdi.hxx:198
static GtkStyleContext * mpNotebookStackStyle
Definition: gtkgdi.hxx:184
static GtkStyleContext * mpComboboxButtonBoxStyle
Definition: gtkgdi.hxx:168
static GtkStyleContext * mpVScrollbarStyle
Definition: gtkgdi.hxx:144
static GtkStyleContext * mpMenuWindowStyle
Definition: gtkgdi.hxx:193
static GtkStyleContext * mpComboboxEntryStyle
Definition: gtkgdi.hxx:166
static GtkStyleContext * mpCheckButtonCheckStyle
Definition: gtkgdi.hxx:158
static GtkStyleContext * mpSeparatorMenuItemSeparatorStyle
Definition: gtkgdi.hxx:203
static GtkStyleContext * mpMenuStyle
Definition: gtkgdi.hxx:194
static GtkStyleContext * mpNotebookHeaderTabsStyle
Definition: gtkgdi.hxx:186
static void PaintCombobox(GtkStateFlags flags, cairo_t *cr, const tools::Rectangle &rControlRectangle, ControlType nType, ControlPart nPart)
static GtkStyleContext * mpTextViewStyle
Definition: gtkgdi.hxx:143
static GtkStyleContext * mpVScrollbarButtonStyle
Definition: gtkgdi.hxx:148
static GtkStyleContext * mpMenuItemLabelStyle
Definition: gtkgdi.hxx:196
static GtkStyleContext * mpListboxStyle
Definition: gtkgdi.hxx:170
static GtkStyleContext * mpNotebookHeaderTabsTabActiveLabelStyle
Definition: gtkgdi.hxx:189
Common ancestor for MenuFloatingWindow and MenuBarWindow.
Definition: menuwindow.hxx:49
Definition: menu.hxx:116
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
GtkControlPart
Definition: gtkgdi.hxx:36
@ NotebookHeaderTabsTabActiveLabel
@ ScrollbarHorizontalContents
@ NotebookHeaderTabsTabHoverLabel
@ SeparatorMenuItemSeparator
@ NotebookHeaderTabsTabLabel
struct _GtkWidget GtkWidget
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:72
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:70