cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / vcl / inc / unx / gtk / gtkgdi.hxx
blobd07bb91ec214de2fc908eada7e59ae77ca7db699
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 <config_cairo_canvas.h>
24 #include <gtk/gtk.h>
25 #include "gtkbackend.hxx"
26 #include <gdk/gdkkeysyms.h>
28 #include <unx/gtk/gtkframe.hxx>
29 #include <ControlCacheKey.hxx>
31 #include <headless/svpgdi.hxx>
32 #include <textrender.hxx>
34 enum class GtkControlPart
36 ToplevelWindow,
37 Button,
38 LinkButton,
39 CheckButton,
40 CheckButtonCheck,
41 RadioButton,
42 RadioButtonRadio,
43 Entry,
44 Combobox,
45 ComboboxBox,
46 ComboboxBoxEntry,
47 ComboboxBoxButton,
48 ComboboxBoxButtonBox,
49 ComboboxBoxButtonBoxArrow,
50 Listbox,
51 ListboxBox,
52 ListboxBoxButton,
53 ListboxBoxButtonBox,
54 ListboxBoxButtonBoxArrow,
55 SpinButton,
56 SpinButtonUpButton,
57 SpinButtonDownButton,
58 ScrollbarVertical,
59 ScrollbarVerticalContents,
60 ScrollbarVerticalTrough,
61 ScrollbarVerticalSlider,
62 ScrollbarVerticalButton,
63 ScrollbarHorizontal,
64 ScrollbarHorizontalContents,
65 ScrollbarHorizontalTrough,
66 ScrollbarHorizontalSlider,
67 ScrollbarHorizontalButton,
68 ProgressBar,
69 ProgressBarTrough,
70 ProgressBarProgress,
71 Notebook,
72 NotebookHeader,
73 NotebookStack,
74 NotebookHeaderTabs,
75 NotebookHeaderTabsTab,
76 NotebookHeaderTabsTabLabel,
77 NotebookHeaderTabsTabActiveLabel,
78 NotebookHeaderTabsTabHoverLabel,
79 FrameBorder,
80 MenuBar,
81 MenuBarItem,
82 MenuWindow,
83 Menu,
84 MenuItem,
85 MenuItemLabel,
86 MenuItemArrow,
87 CheckMenuItem,
88 CheckMenuItemCheck,
89 RadioMenuItem,
90 RadioMenuItemRadio,
91 SeparatorMenuItem,
92 SeparatorMenuItemSeparator,
95 class GtkSalGraphics final : public SvpSalGraphics
97 GtkSalFrame * const mpFrame;
99 #if !GTK_CHECK_VERSION(4, 0, 0)
100 bool isNativeControlSupported(ControlType, ControlPart) override;
101 virtual bool drawNativeControl( ControlType nType, ControlPart nPart,
102 const tools::Rectangle& rControlRegion,
103 ControlState nState, const ImplControlValue& aValue,
104 const OUString& rCaption,
105 const Color& rBackgroundColor ) override;
106 virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart,
107 const tools::Rectangle& rControlRegion,
108 ControlState nState,
109 const ImplControlValue& aValue,
110 const OUString& rCaption,
111 tools::Rectangle &rNativeBoundingRegion,
112 tools::Rectangle &rNativeContentRegion ) override;
113 #endif
114 bool updateSettings(AllSettings&) override;
115 void handleDamage(const tools::Rectangle&) override;
117 public:
118 GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
120 #if ENABLE_CAIRO_CANVAS
121 virtual bool SupportsCairo() const override;
122 virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
123 virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
124 #endif
126 void WidgetQueueDraw() const;
128 virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
130 virtual OUString getRenderBackendName() const override { return u"gtk3svp"_ustr; }
132 GtkStyleContext* createStyleContext(GtkControlPart ePart);
133 #if !GTK_CHECK_VERSION(4, 0, 0)
134 GtkStyleContext* makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent);
135 #endif
136 private:
137 GtkWidget *mpWindow;
138 static GtkCssProvider *mpCustomThemeProvider;
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;
189 static GtkStyleContext *mpNotebookHeaderTabsTabActiveLabelStyle;
190 static GtkStyleContext *mpNotebookHeaderTabsTabHoverLabelStyle;
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;
204 static gint mnVerticalSeparatorMinWidth;
206 #if !GTK_CHECK_VERSION(4, 0, 0)
207 static tools::Rectangle NWGetScrollButtonRect( ControlPart nPart, tools::Rectangle aAreaRect );
208 static tools::Rectangle NWGetSpinButtonRect( ControlPart nPart, tools::Rectangle aAreaRect);
209 static tools::Rectangle NWGetComboBoxButtonRect(ControlType nType, ControlPart nPart, tools::Rectangle aAreaRect);
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);
235 static void PaintCheck(cairo_t *cr, GtkStyleContext *context,
236 const tools::Rectangle& rControlRectangle, bool bInMenu);
238 static void PaintRadio(cairo_t *cr, GtkStyleContext *context,
239 const tools::Rectangle& rControlRectangle, bool bInMenu);
240 #endif
242 static bool style_loaded;
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */