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 
97 {
99 
100 protected:
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  bool updateSettings(AllSettings&) override;
115  void handleDamage(const tools::Rectangle&) override;
116 
117 public:
118  GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
119 
120 #if ENABLE_CAIRO_CANVAS
121 
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 
126 #endif
127 
128  void WidgetQueueDraw() const;
129 
130  virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
131 
132  virtual OUString getRenderBackendName() const override { return "gtk3svp"; }
133 
134  GtkStyleContext* createStyleContext(GtkControlPart ePart);
135  GtkStyleContext* makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent);
136 private:
137  GtkWidget *mpWindow;
138  static GtkStyleContext *mpWindowStyle;
139  static GtkStyleContext *mpButtonStyle;
140  static GtkStyleContext *mpLinkButtonStyle;
141  static GtkStyleContext *mpEntryStyle;
142  static GtkStyleContext *mpTextViewStyle;
143  static GtkStyleContext *mpVScrollbarStyle;
144  static GtkStyleContext *mpVScrollbarContentsStyle;
145  static GtkStyleContext *mpVScrollbarTroughStyle;
146  static GtkStyleContext *mpVScrollbarSliderStyle;
147  static GtkStyleContext *mpVScrollbarButtonStyle;
148  static GtkStyleContext *mpHScrollbarStyle;
149  static GtkStyleContext *mpHScrollbarContentsStyle;
150  static GtkStyleContext *mpHScrollbarTroughStyle;
151  static GtkStyleContext *mpHScrollbarSliderStyle;
152  static GtkStyleContext *mpHScrollbarButtonStyle;
153  static GtkStyleContext *mpToolbarStyle;
154  static GtkStyleContext *mpToolButtonStyle;
155  static GtkStyleContext *mpToolbarSeparatorStyle;
156  static GtkStyleContext *mpCheckButtonStyle;
157  static GtkStyleContext *mpCheckButtonCheckStyle;
158  static GtkStyleContext *mpRadioButtonStyle;
159  static GtkStyleContext *mpRadioButtonRadioStyle;
160  static GtkStyleContext *mpSpinStyle;
161  static GtkStyleContext *mpSpinUpStyle;
162  static GtkStyleContext *mpSpinDownStyle;
163  static GtkStyleContext *mpComboboxStyle;
164  static GtkStyleContext *mpComboboxBoxStyle;
165  static GtkStyleContext *mpComboboxEntryStyle;
166  static GtkStyleContext *mpComboboxButtonStyle;
167  static GtkStyleContext *mpComboboxButtonBoxStyle;
168  static GtkStyleContext *mpComboboxButtonArrowStyle;
169  static GtkStyleContext *mpListboxStyle;
170  static GtkStyleContext *mpListboxBoxStyle;
171  static GtkStyleContext *mpListboxButtonStyle;
172  static GtkStyleContext *mpListboxButtonBoxStyle;
173  static GtkStyleContext *mpListboxButtonArrowStyle;
174  static GtkStyleContext *mpFrameInStyle;
175  static GtkStyleContext *mpFrameOutStyle;
176  static GtkStyleContext *mpFixedHoriLineStyle;
177  static GtkStyleContext *mpFixedVertLineStyle;
178  static GtkStyleContext *mpTreeHeaderButtonStyle;
179  static GtkStyleContext *mpProgressBarStyle;
180  static GtkStyleContext *mpProgressBarTroughStyle;
181  static GtkStyleContext *mpProgressBarProgressStyle;
182  static GtkStyleContext *mpNotebookStyle;
183  static GtkStyleContext *mpNotebookStackStyle;
184  static GtkStyleContext *mpNotebookHeaderStyle;
185  static GtkStyleContext *mpNotebookHeaderTabsStyle;
186  static GtkStyleContext *mpNotebookHeaderTabsTabStyle;
187  static GtkStyleContext *mpNotebookHeaderTabsTabLabelStyle;
189  static GtkStyleContext *mpNotebookHeaderTabsTabHoverLabelStyle;
190  static GtkStyleContext *mpMenuBarStyle;
191  static GtkStyleContext *mpMenuBarItemStyle;
192  static GtkStyleContext *mpMenuWindowStyle;
193  static GtkStyleContext *mpMenuStyle;
194  static GtkStyleContext *mpMenuItemStyle;
195  static GtkStyleContext *mpMenuItemLabelStyle;
196  static GtkStyleContext *mpMenuItemArrowStyle;
197  static GtkStyleContext *mpCheckMenuItemStyle;
198  static GtkStyleContext *mpCheckMenuItemCheckStyle;
199  static GtkStyleContext *mpRadioMenuItemStyle;
200  static GtkStyleContext *mpRadioMenuItemRadioStyle;
201  static GtkStyleContext *mpSeparatorMenuItemStyle;
202  static GtkStyleContext *mpSeparatorMenuItemSeparatorStyle;
203 
207 
208  static void PaintScrollbar(GtkStyleContext *context,
209  cairo_t *cr,
210  const tools::Rectangle& rControlRectangle,
211  ControlPart nPart,
212  const ImplControlValue& aValue );
213  void PaintOneSpinButton( GtkStyleContext *context,
214  cairo_t *cr,
215  ControlPart nPart,
216  tools::Rectangle aAreaRect,
217  ControlState nState );
218  void PaintSpinButton(GtkStateFlags flags,
219  cairo_t *cr,
220  const tools::Rectangle& rControlRectangle,
221  ControlPart nPart,
222  const ImplControlValue& aValue);
223  static void PaintCombobox(GtkStateFlags flags,
224  cairo_t *cr,
225  const tools::Rectangle& rControlRectangle,
226  ControlType nType,
227  ControlPart nPart);
228  static void PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context,
229  const tools::Rectangle& rControlRectangle,
230  bool bIsCheck, bool bInMenu);
231 
232  static void PaintCheck(cairo_t *cr, GtkStyleContext *context,
233  const tools::Rectangle& rControlRectangle, bool bInMenu);
234 
235  static void PaintRadio(cairo_t *cr, GtkStyleContext *context,
236  const tools::Rectangle& rControlRectangle, bool bInMenu);
237 
238 
239  static bool style_loaded;
240 };
241 
242 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
243 
244 /* 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:201
static GtkStyleContext * mpMenuItemArrowStyle
Definition: gtkgdi.hxx:196
static GtkStyleContext * mpListboxButtonStyle
Definition: gtkgdi.hxx:171
static GtkStyleContext * mpNotebookHeaderTabsTabStyle
Definition: gtkgdi.hxx:186
static GtkStyleContext * mpWindowStyle
Definition: gtkgdi.hxx:138
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY) override
GtkWidget * mpWindow
Definition: gtkgdi.hxx:137
static GtkStyleContext * mpToolButtonStyle
Definition: gtkgdi.hxx:154
static GtkStyleContext * mpMenuStyle
Definition: gtkgdi.hxx:193
static GtkStyleContext * mpVScrollbarTroughStyle
Definition: gtkgdi.hxx:145
static tools::Rectangle NWGetScrollButtonRect(ControlPart nPart, tools::Rectangle aAreaRect)
static GtkStyleContext * mpComboboxButtonBoxStyle
Definition: gtkgdi.hxx:167
static GtkStyleContext * mpComboboxButtonArrowStyle
Definition: gtkgdi.hxx:168
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:169
GtkStyleContext * createStyleContext(GtkControlPart ePart)
static GtkStyleContext * mpNotebookHeaderStyle
Definition: gtkgdi.hxx:184
static GtkStyleContext * mpListboxBoxStyle
Definition: gtkgdi.hxx:170
bool updateSettings(AllSettings &) override
static GtkStyleContext * mpVScrollbarSliderStyle
Definition: gtkgdi.hxx:146
GtkSalGraphics(GtkSalFrame *pFrame, GtkWidget *pWindow)
GtkSalFrame *const mpFrame
Definition: gtkgdi.hxx:98
static GtkStyleContext * mpTreeHeaderButtonStyle
Definition: gtkgdi.hxx:178
static GtkStyleContext * mpNotebookHeaderTabsStyle
Definition: gtkgdi.hxx:185
static GtkStyleContext * mpVScrollbarContentsStyle
Definition: gtkgdi.hxx:144
static GtkStyleContext * mpVScrollbarStyle
Definition: gtkgdi.hxx:143
static GtkStyleContext * mpProgressBarStyle
Definition: gtkgdi.hxx:179
void handleDamage(const tools::Rectangle &) override
Handle damage done by drawing with a widget draw override.
static GtkStyleContext * mpFixedVertLineStyle
Definition: gtkgdi.hxx:177
static GtkStyleContext * mpNotebookHeaderTabsTabHoverLabelStyle
Definition: gtkgdi.hxx:189
static GtkStyleContext * mpRadioButtonStyle
Definition: gtkgdi.hxx:158
static GtkStyleContext * mpProgressBarProgressStyle
Definition: gtkgdi.hxx:181
static GtkStyleContext * mpButtonStyle
Definition: gtkgdi.hxx:139
static GtkStyleContext * mpHScrollbarSliderStyle
Definition: gtkgdi.hxx:151
static void PaintCombobox(GtkStateFlags flags, cairo_t *cr, const tools::Rectangle &rControlRectangle, ControlType nType, ControlPart nPart)
static GtkStyleContext * mpSeparatorMenuItemSeparatorStyle
Definition: gtkgdi.hxx:202
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
static GtkStyleContext * mpVScrollbarButtonStyle
Definition: gtkgdi.hxx:147
static GtkStyleContext * mpHScrollbarButtonStyle
Definition: gtkgdi.hxx:152
static GtkStyleContext * mpLinkButtonStyle
Definition: gtkgdi.hxx:140
static GtkStyleContext * mpFrameOutStyle
Definition: gtkgdi.hxx:175
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:182
static GtkStyleContext * mpCheckButtonCheckStyle
Definition: gtkgdi.hxx:157
static GtkStyleContext * mpComboboxStyle
Definition: gtkgdi.hxx:163
static GtkStyleContext * mpCheckMenuItemCheckStyle
Definition: gtkgdi.hxx:198
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
static GtkStyleContext * mpSpinDownStyle
Definition: gtkgdi.hxx:162
static GtkStyleContext * mpHScrollbarStyle
Definition: gtkgdi.hxx:148
static tools::Rectangle NWGetComboBoxButtonRect(ControlType nType, ControlPart nPart, tools::Rectangle aAreaRect)
static GtkStyleContext * mpComboboxEntryStyle
Definition: gtkgdi.hxx:165
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:70
static GtkStyleContext * mpMenuWindowStyle
Definition: gtkgdi.hxx:192
static GtkStyleContext * mpMenuBarItemStyle
Definition: gtkgdi.hxx:191
static GtkStyleContext * mpToolbarStyle
Definition: gtkgdi.hxx:153
static GtkStyleContext * mpRadioMenuItemRadioStyle
Definition: gtkgdi.hxx:200
static GtkStyleContext * mpComboboxBoxStyle
Definition: gtkgdi.hxx:164
static GtkStyleContext * mpMenuBarStyle
Definition: gtkgdi.hxx:190
static GtkStyleContext * mpProgressBarTroughStyle
Definition: gtkgdi.hxx:180
static GtkStyleContext * mpListboxButtonArrowStyle
Definition: gtkgdi.hxx:173
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:183
bool isNativeControlSupported(ControlType, ControlPart) override
Query the platform layer for native control support.
static GtkStyleContext * mpHScrollbarContentsStyle
Definition: gtkgdi.hxx:149
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:142
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:197
static GtkStyleContext * mpRadioButtonRadioStyle
Definition: gtkgdi.hxx:159
static GtkStyleContext * mpHScrollbarTroughStyle
Definition: gtkgdi.hxx:150
static GtkStyleContext * mpEntryStyle
Definition: gtkgdi.hxx:141
virtual OUString getRenderBackendName() const override
Definition: gtkgdi.hxx:132
static GtkStyleContext * mpListboxButtonBoxStyle
Definition: gtkgdi.hxx:172
static GtkStyleContext * mpMenuItemLabelStyle
Definition: gtkgdi.hxx:195
static GtkStyleContext * mpMenuItemStyle
Definition: gtkgdi.hxx:194
static GtkStyleContext * mpRadioMenuItemStyle
Definition: gtkgdi.hxx:199
static void PaintRadio(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bInMenu)
static GtkStyleContext * mpSpinUpStyle
Definition: gtkgdi.hxx:161
GtkControlPart
Definition: gtkgdi.hxx:35
static GtkStyleContext * mpCheckButtonStyle
Definition: gtkgdi.hxx:156
static GtkStyleContext * mpNotebookHeaderTabsTabActiveLabelStyle
Definition: gtkgdi.hxx:188
static GtkStyleContext * mpToolbarSeparatorStyle
Definition: gtkgdi.hxx:155
static GtkStyleContext * mpFrameInStyle
Definition: gtkgdi.hxx:174
static GtkStyleContext * mpFixedHoriLineStyle
Definition: gtkgdi.hxx:176
static GtkStyleContext * mpNotebookHeaderTabsTabLabelStyle
Definition: gtkgdi.hxx:187
static GtkStyleContext * mpComboboxButtonStyle
Definition: gtkgdi.hxx:166
static bool style_loaded
Definition: gtkgdi.hxx:239
static GtkStyleContext * mpSpinStyle
Definition: gtkgdi.hxx:160
static void PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle &rControlRectangle, bool bIsCheck, bool bInMenu)