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 
35 enum class GtkControlPart
36 {
38  Button,
39  LinkButton,
44  Entry,
45  Combobox,
51  Listbox,
52  ListboxBox,
56  SpinButton,
72  Notebook,
81  MenuBar,
83  MenuWindow,
84  Menu,
85  MenuItem,
94 };
95 
96 class 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;
107  virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart,
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
115  bool updateSettings(AllSettings&) override;
116  void handleDamage(const tools::Rectangle&) override;
117 
118 public:
119  GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
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
137 private:
138  GtkWidget *mpWindow;
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;
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 
205 #if !GTK_CHECK_VERSION(4, 0, 0)
209 
210  static void PaintScrollbar(GtkStyleContext *context,
211  cairo_t *cr,
212  const tools::Rectangle& rControlRectangle,
213  ControlPart nPart,
214  const ImplControlValue& aValue );
215  void PaintOneSpinButton( GtkStyleContext *context,
216  cairo_t *cr,
217  ControlPart nPart,
218  tools::Rectangle aAreaRect,
219  ControlState nState );
220  void PaintSpinButton(GtkStateFlags flags,
221  cairo_t *cr,
222  const tools::Rectangle& rControlRectangle,
223  ControlPart nPart,
224  const ImplControlValue& aValue);
225  static void PaintCombobox(GtkStateFlags flags,
226  cairo_t *cr,
227  const tools::Rectangle& rControlRectangle,
228  ControlType nType,
229  ControlPart nPart);
230  static void PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context,
231  const tools::Rectangle& rControlRectangle,
232  bool bIsCheck, bool bInMenu);
233 
234  static void PaintCheck(cairo_t *cr, GtkStyleContext *context,
235  const tools::Rectangle& rControlRectangle, bool bInMenu);
236 
237  static void PaintRadio(cairo_t *cr, GtkStyleContext *context,
238  const tools::Rectangle& rControlRectangle, bool bInMenu);
239 #endif
240 
241  static bool style_loaded;
242 };
243 
244 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
245 
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void PaintOneSpinButton(GtkStyleContext *context, cairo_t *cr, ControlPart nPart, tools::Rectangle aAreaRect, ControlState nState)
static GtkStyleContext * mpSeparatorMenuItemStyle
Definition: gtkgdi.hxx:202
static GtkStyleContext * mpMenuItemArrowStyle
Definition: gtkgdi.hxx:197
static GtkStyleContext * mpListboxButtonStyle
Definition: gtkgdi.hxx:172
static GtkStyleContext * mpNotebookHeaderTabsTabStyle
Definition: gtkgdi.hxx:187
static GtkStyleContext * mpWindowStyle
Definition: gtkgdi.hxx:139
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY) override
GtkWidget * mpWindow
Definition: gtkgdi.hxx:138
static GtkStyleContext * mpToolButtonStyle
Definition: gtkgdi.hxx:155
static GtkStyleContext * mpMenuStyle
Definition: gtkgdi.hxx:194
static GtkStyleContext * mpVScrollbarTroughStyle
Definition: gtkgdi.hxx:146
static tools::Rectangle NWGetScrollButtonRect(ControlPart nPart, tools::Rectangle aAreaRect)
static GtkStyleContext * mpComboboxButtonBoxStyle
Definition: gtkgdi.hxx:168
static GtkStyleContext * mpComboboxButtonArrowStyle
Definition: gtkgdi.hxx:169
GtkStyleContext * makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent)
void PaintSpinButton(GtkStateFlags flags, cairo_t *cr, const tools::Rectangle &rControlRectangle, ControlPart nPart, const ImplControlValue &aValue)
static GtkStyleContext * mpListboxStyle
Definition: gtkgdi.hxx:170
GtkStyleContext * createStyleContext(GtkControlPart ePart)
static GtkStyleContext * mpNotebookHeaderStyle
Definition: gtkgdi.hxx:185
static GtkStyleContext * mpListboxBoxStyle
Definition: gtkgdi.hxx:171
bool updateSettings(AllSettings &) override
static GtkStyleContext * mpVScrollbarSliderStyle
Definition: gtkgdi.hxx:147
GtkSalGraphics(GtkSalFrame *pFrame, GtkWidget *pWindow)
GtkSalFrame *const mpFrame
Definition: gtkgdi.hxx:98
static GtkStyleContext * mpTreeHeaderButtonStyle
Definition: gtkgdi.hxx:179
static GtkStyleContext * mpNotebookHeaderTabsStyle
Definition: gtkgdi.hxx:186
static GtkStyleContext * mpVScrollbarContentsStyle
Definition: gtkgdi.hxx:145
static GtkStyleContext * mpVScrollbarStyle
Definition: gtkgdi.hxx:144
static GtkStyleContext * mpProgressBarStyle
Definition: gtkgdi.hxx:180
void handleDamage(const tools::Rectangle &) override
Handle damage done by drawing with a widget draw override.
static GtkStyleContext * mpFixedVertLineStyle
Definition: gtkgdi.hxx:178
static GtkStyleContext * mpNotebookHeaderTabsTabHoverLabelStyle
Definition: gtkgdi.hxx:190
static GtkStyleContext * mpRadioButtonStyle
Definition: gtkgdi.hxx:159
static GtkStyleContext * mpProgressBarProgressStyle
Definition: gtkgdi.hxx:182
static GtkStyleContext * mpButtonStyle
Definition: gtkgdi.hxx:140
static GtkStyleContext * mpHScrollbarSliderStyle
Definition: gtkgdi.hxx:152
static void PaintCombobox(GtkStateFlags flags, cairo_t *cr, const tools::Rectangle &rControlRectangle, ControlType nType, ControlPart nPart)
static GtkStyleContext * mpSeparatorMenuItemSeparatorStyle
Definition: gtkgdi.hxx:203
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
static GtkStyleContext * mpVScrollbarButtonStyle
Definition: gtkgdi.hxx:148
static GtkStyleContext * mpHScrollbarButtonStyle
Definition: gtkgdi.hxx:153
static GtkStyleContext * mpLinkButtonStyle
Definition: gtkgdi.hxx:141
static GtkStyleContext * mpFrameOutStyle
Definition: gtkgdi.hxx:176
void WidgetQueueDraw() const
static void PaintScrollbar(GtkStyleContext *context, cairo_t *cr, const tools::Rectangle &rControlRectangle, ControlPart nPart, const ImplControlValue &aValue)
static GtkStyleContext * mpNotebookStyle
Definition: gtkgdi.hxx:183
static GtkStyleContext * mpCheckButtonCheckStyle
Definition: gtkgdi.hxx:158
static GtkStyleContext * mpComboboxStyle
Definition: gtkgdi.hxx:164
static GtkStyleContext * mpCheckMenuItemCheckStyle
Definition: gtkgdi.hxx:199
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
static GtkStyleContext * mpSpinDownStyle
Definition: gtkgdi.hxx:163
static GtkStyleContext * mpHScrollbarStyle
Definition: gtkgdi.hxx:149
static tools::Rectangle NWGetComboBoxButtonRect(ControlType nType, ControlPart nPart, tools::Rectangle aAreaRect)
static GtkStyleContext * mpComboboxEntryStyle
Definition: gtkgdi.hxx:166
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
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.
struct _cairo cairo_t
Definition: svpgdi.hxx:71
static GtkStyleContext * mpMenuWindowStyle
Definition: gtkgdi.hxx:193
static GtkStyleContext * mpMenuBarItemStyle
Definition: gtkgdi.hxx:192
static GtkStyleContext * mpToolbarStyle
Definition: gtkgdi.hxx:154
static GtkStyleContext * mpRadioMenuItemRadioStyle
Definition: gtkgdi.hxx:201
static GtkStyleContext * mpComboboxBoxStyle
Definition: gtkgdi.hxx:165
static GtkStyleContext * mpMenuBarStyle
Definition: gtkgdi.hxx:191
static GtkStyleContext * mpProgressBarTroughStyle
Definition: gtkgdi.hxx:181
static GtkStyleContext * mpListboxButtonArrowStyle
Definition: gtkgdi.hxx:174
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
static GtkStyleContext * mpNotebookStackStyle
Definition: gtkgdi.hxx:184
bool isNativeControlSupported(ControlType, ControlPart) override
Query the platform layer for native control support.
static GtkStyleContext * mpHScrollbarContentsStyle
Definition: gtkgdi.hxx:150
static void PaintCheck(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bInMenu)
static tools::Rectangle NWGetSpinButtonRect(ControlPart nPart, tools::Rectangle aAreaRect)
static GtkStyleContext * mpTextViewStyle
Definition: gtkgdi.hxx:143
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 * mpCheckMenuItemStyle
Definition: gtkgdi.hxx:198
static GtkStyleContext * mpRadioButtonRadioStyle
Definition: gtkgdi.hxx:160
static GtkStyleContext * mpHScrollbarTroughStyle
Definition: gtkgdi.hxx:151
static GtkStyleContext * mpEntryStyle
Definition: gtkgdi.hxx:142
virtual OUString getRenderBackendName() const override
Definition: gtkgdi.hxx:131
static GtkStyleContext * mpListboxButtonBoxStyle
Definition: gtkgdi.hxx:173
static GtkStyleContext * mpMenuItemLabelStyle
Definition: gtkgdi.hxx:196
static GtkStyleContext * mpMenuItemStyle
Definition: gtkgdi.hxx:195
static GtkStyleContext * mpRadioMenuItemStyle
Definition: gtkgdi.hxx:200
static void PaintRadio(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bInMenu)
static GtkStyleContext * mpSpinUpStyle
Definition: gtkgdi.hxx:162
GtkControlPart
Definition: gtkgdi.hxx:35
static GtkStyleContext * mpCheckButtonStyle
Definition: gtkgdi.hxx:157
static GtkStyleContext * mpNotebookHeaderTabsTabActiveLabelStyle
Definition: gtkgdi.hxx:189
static GtkStyleContext * mpToolbarSeparatorStyle
Definition: gtkgdi.hxx:156
static GtkStyleContext * mpFrameInStyle
Definition: gtkgdi.hxx:175
static GtkStyleContext * mpFixedHoriLineStyle
Definition: gtkgdi.hxx:177
static GtkStyleContext * mpNotebookHeaderTabsTabLabelStyle
Definition: gtkgdi.hxx:188
static GtkStyleContext * mpComboboxButtonStyle
Definition: gtkgdi.hxx:167
static bool style_loaded
Definition: gtkgdi.hxx:241
static GtkStyleContext * mpSpinStyle
Definition: gtkgdi.hxx:161
static void PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bIsCheck, bool bInMenu)