1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
21 #define INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
23 #include <config_cairo_canvas.h>
27 #include <gdk/gdkkeysyms.h>
29 #include <unx/gtk/gtkframe.hxx>
30 #include <ControlCacheKey.hxx>
32 #if GTK_CHECK_VERSION(3,0,0)
34 #include <headless/svpgdi.hxx>
35 #include <textrender.hxx>
37 enum class GtkControlPart
52 ComboboxBoxButtonBoxArrow
,
57 ListboxBoxButtonBoxArrow
,
63 ScrollbarVerticalContents
,
64 ScrollbarVerticalTrough
,
65 ScrollbarVerticalSlider
,
66 ScrollbarVerticalButton
,
68 ScrollbarHorizontalContents
,
69 ScrollbarHorizontalTrough
,
70 ScrollbarHorizontalSlider
,
71 ScrollbarHorizontalButton
,
79 NotebookHeaderTabsTab
,
80 NotebookHeaderTabsTabLabel
,
81 NotebookHeaderTabsTabActiveLabel
,
82 NotebookHeaderTabsTabHoverLabel
,
96 SeparatorMenuItemSeparator
,
99 typedef void (*gtk_widget_path_iter_set_object_nameFunc
)(GtkWidgetPath
*, guint
, const char*);
101 class GtkSalGraphics
: public SvpSalGraphics
103 GtkSalFrame
*mpFrame
;
105 GtkSalGraphics( GtkSalFrame
*pFrame
, GtkWidget
*pWindow
);
106 virtual bool drawNativeControl( ControlType nType
, ControlPart nPart
,
107 const tools::Rectangle
& rControlRegion
,
108 ControlState nState
, const ImplControlValue
& aValue
,
109 const OUString
& rCaption
) override
;
110 virtual bool IsNativeControlSupported( ControlType nType
, ControlPart nPart
) override
;
111 virtual bool getNativeControlRegion( ControlType nType
, ControlPart nPart
,
112 const tools::Rectangle
& rControlRegion
,
114 const ImplControlValue
& aValue
,
115 const OUString
& rCaption
,
116 tools::Rectangle
&rNativeBoundingRegion
,
117 tools::Rectangle
&rNativeContentRegion
) override
;
118 #if ENABLE_CAIRO_CANVAS
120 virtual bool SupportsCairo() const override
;
121 virtual cairo::SurfaceSharedPtr
CreateSurface(const cairo::CairoSurfaceSharedPtr
& rSurface
) const override
;
122 virtual cairo::SurfaceSharedPtr
CreateSurface(const OutputDevice
& rRefDevice
, int x
, int y
, int width
, int height
) const override
;
126 void WidgetQueueDraw() const;
128 void updateSettings( AllSettings
& rSettings
);
129 static void refreshFontconfig( GtkSettings
*pSettings
);
130 static void signalSettingsNotify( GObject
*, GParamSpec
*pSpec
, gpointer
);
132 virtual void GetResolution(sal_Int32
& rDPIX
, sal_Int32
& rDPIY
) override
;
134 GtkStyleContext
* createStyleContext(gtk_widget_path_iter_set_object_nameFunc set_object_name
, GtkControlPart ePart
);
135 GtkStyleContext
* createNewContext(GtkControlPart ePart
, gtk_widget_path_iter_set_object_nameFunc set_object_name
);
136 GtkStyleContext
* createOldContext(GtkControlPart ePart
);
137 GtkStyleContext
* makeContext(GtkWidgetPath
*pPath
, GtkStyleContext
*pParent
);
140 static GtkStyleContext
*mpWindowStyle
;
141 static GtkStyleContext
*mpButtonStyle
;
142 static GtkStyleContext
*mpLinkButtonStyle
;
143 static GtkStyleContext
*mpEntryStyle
;
144 static GtkStyleContext
*mpTextViewStyle
;
145 static GtkStyleContext
*mpVScrollbarStyle
;
146 static GtkStyleContext
*mpVScrollbarContentsStyle
;
147 static GtkStyleContext
*mpVScrollbarTroughStyle
;
148 static GtkStyleContext
*mpVScrollbarSliderStyle
;
149 static GtkStyleContext
*mpVScrollbarButtonStyle
;
150 static GtkStyleContext
*mpHScrollbarStyle
;
151 static GtkStyleContext
*mpHScrollbarContentsStyle
;
152 static GtkStyleContext
*mpHScrollbarTroughStyle
;
153 static GtkStyleContext
*mpHScrollbarSliderStyle
;
154 static GtkStyleContext
*mpHScrollbarButtonStyle
;
155 static GtkStyleContext
*mpToolbarStyle
;
156 static GtkStyleContext
*mpToolButtonStyle
;
157 static GtkStyleContext
*mpToolbarSeperatorStyle
;
158 static GtkStyleContext
*mpCheckButtonStyle
;
159 static GtkStyleContext
*mpCheckButtonCheckStyle
;
160 static GtkStyleContext
*mpRadioButtonStyle
;
161 static GtkStyleContext
*mpRadioButtonRadioStyle
;
162 static GtkStyleContext
*mpSpinStyle
;
163 static GtkStyleContext
*mpSpinEntryStyle
;
164 static GtkStyleContext
*mpSpinUpStyle
;
165 static GtkStyleContext
*mpSpinDownStyle
;
166 static GtkStyleContext
*mpComboboxStyle
;
167 static GtkStyleContext
*mpComboboxBoxStyle
;
168 static GtkStyleContext
*mpComboboxEntryStyle
;
169 static GtkStyleContext
*mpComboboxButtonStyle
;
170 static GtkStyleContext
*mpComboboxButtonBoxStyle
;
171 static GtkStyleContext
*mpComboboxButtonArrowStyle
;
172 static GtkStyleContext
*mpListboxStyle
;
173 static GtkStyleContext
*mpListboxBoxStyle
;
174 static GtkStyleContext
*mpListboxButtonStyle
;
175 static GtkStyleContext
*mpListboxButtonBoxStyle
;
176 static GtkStyleContext
*mpListboxButtonArrowStyle
;
177 static GtkStyleContext
*mpFrameInStyle
;
178 static GtkStyleContext
*mpFrameOutStyle
;
179 static GtkStyleContext
*mpFixedHoriLineStyle
;
180 static GtkStyleContext
*mpFixedVertLineStyle
;
181 static GtkStyleContext
*mpTreeHeaderButtonStyle
;
182 static GtkStyleContext
*mpProgressBarStyle
;
183 static GtkStyleContext
*mpProgressBarTroughStyle
;
184 static GtkStyleContext
*mpProgressBarProgressStyle
;
185 static GtkStyleContext
*mpNotebookStyle
;
186 static GtkStyleContext
*mpNotebookStackStyle
;
187 static GtkStyleContext
*mpNotebookHeaderStyle
;
188 static GtkStyleContext
*mpNotebookHeaderTabsStyle
;
189 static GtkStyleContext
*mpNotebookHeaderTabsTabStyle
;
190 static GtkStyleContext
*mpNotebookHeaderTabsTabLabelStyle
;
191 static GtkStyleContext
*mpNotebookHeaderTabsTabActiveLabelStyle
;
192 static GtkStyleContext
*mpNotebookHeaderTabsTabHoverLabelStyle
;
193 static GtkStyleContext
*mpMenuBarStyle
;
194 static GtkStyleContext
*mpMenuBarItemStyle
;
195 static GtkStyleContext
*mpMenuWindowStyle
;
196 static GtkStyleContext
*mpMenuStyle
;
197 static GtkStyleContext
*mpMenuItemStyle
;
198 static GtkStyleContext
*mpMenuItemLabelStyle
;
199 static GtkStyleContext
*mpMenuItemArrowStyle
;
200 static GtkStyleContext
*mpCheckMenuItemStyle
;
201 static GtkStyleContext
*mpCheckMenuItemCheckStyle
;
202 static GtkStyleContext
*mpRadioMenuItemStyle
;
203 static GtkStyleContext
*mpRadioMenuItemRadioStyle
;
204 static GtkStyleContext
*mpSeparatorMenuItemStyle
;
205 static GtkStyleContext
*mpSeparatorMenuItemSeparatorStyle
;
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( ControlPart nPart
, tools::Rectangle aAreaRect
);
211 static void PaintScrollbar(GtkStyleContext
*context
,
213 const tools::Rectangle
& rControlRectangle
,
215 const ImplControlValue
& aValue
);
216 void PaintOneSpinButton( GtkStyleContext
*context
,
219 tools::Rectangle aAreaRect
,
220 ControlState nState
);
221 void PaintSpinButton(GtkStateFlags flags
,
223 const tools::Rectangle
& rControlRectangle
,
225 const ImplControlValue
& aValue
);
226 static void PaintCombobox(GtkStateFlags flags
,
228 const tools::Rectangle
& rControlRectangle
,
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
);
242 static bool style_loaded
;
246 #include <unx/salgdi.h>
249 class GtkSalGraphics
: public X11SalGraphics
251 GtkWidget
*m_pWindow
;
252 vcl::Region m_aClipRegion
;
255 GtkSalGraphics(GtkSalFrame
*, GtkWidget
*window
, SalX11Screen nXScreen
);
256 virtual ~GtkSalGraphics() override
;
258 GtkWidget
* GetGtkWidget() const { return m_pWindow
; }
259 GdkWindow
* GetGdkWindow() const { return m_pWindow
->window
; }
260 GtkSalFrame
* GetGtkFrame() const { return static_cast<GtkSalFrame
*>(m_pFrame
); }
261 void SetWindow( GtkWidget
* window
) { m_pWindow
= window
; }
263 // will be set when UI theme was changed
264 static bool bThemeChanged
;
265 static bool bNeedPixmapPaint
;
266 static bool bNeedTwoPasses
;
268 // native widget methods
269 virtual bool IsNativeControlSupported( ControlType nType
, ControlPart nPart
) override
;
270 virtual bool hitTestNativeControl( ControlType nType
, ControlPart nPart
, const tools::Rectangle
& rControlRegion
,
271 const Point
& aPos
, bool& rIsInside
) override
;
272 virtual bool drawNativeControl( ControlType nType
, ControlPart nPart
, const tools::Rectangle
& rControlRegion
,
273 ControlState nState
, const ImplControlValue
& aValue
,
274 const OUString
& rCaption
) override
;
275 virtual bool getNativeControlRegion( ControlType nType
, ControlPart nPart
, const tools::Rectangle
& rControlRegion
, ControlState nState
,
276 const ImplControlValue
& aValue
, const OUString
& rCaption
,
277 tools::Rectangle
&rNativeBoundingRegion
, tools::Rectangle
&rNativeContentRegion
) override
;
279 //helper methods for frame's UpdateSettings
280 void updateSettings( AllSettings
& rSettings
);
281 static void refreshFontconfig( GtkSettings
*pSettings
);
282 static void signalSettingsNotify( GObject
*, GParamSpec
*pSpec
, gpointer
);
284 virtual bool setClipRegion( const vcl::Region
& ) override
;
285 virtual void ResetClipRegion() override
;
287 // some themes set the background pixmap of our window EVERY time
288 // a control is painted; but presentation effects need
289 // the background set to None; workaround: set the background
291 virtual void copyBits( const SalTwoRect
& rPosAry
,
292 SalGraphics
* pSrcGraphics
) override
;
296 GdkX11Pixmap
* NWGetPixmapFromScreen( tools::Rectangle srcRect
, int nBgColor
= 0 );
297 bool NWRenderPixmapToScreen( GdkX11Pixmap
* pPixmap
, GdkX11Pixmap
* pMask
, tools::Rectangle dstRect
);
299 bool DoDrawNativeControl( GdkDrawable
* pDrawable
,
302 const tools::Rectangle
& aCtrlRect
,
303 const std::vector
< tools::Rectangle
>& aClip
,
305 const ImplControlValue
& aValue
,
306 ControlCacheKey
& rControlCacheKey
);
308 bool NWPaintGTKArrow( GdkDrawable
* gdkDrawable
,
309 const tools::Rectangle
& rControlRectangle
,
310 const std::vector
< tools::Rectangle
>& rClipList
,
311 ControlState nState
, const ImplControlValue
& aValue
);
312 bool NWPaintGTKListHeader( GdkDrawable
* gdkDrawable
,
313 const tools::Rectangle
& rControlRectangle
,
314 const std::vector
< tools::Rectangle
>& rClipList
,
315 ControlState nState
);
316 bool NWPaintGTKFixedLine( GdkDrawable
* gdkDrawable
, ControlPart nPart
,
317 const tools::Rectangle
& rControlRectangle
);
318 bool NWPaintGTKFrame( GdkDrawable
* gdkDrawable
,
319 const tools::Rectangle
& rControlRectangle
,
320 const std::vector
< tools::Rectangle
>& rClipList
,
321 const ImplControlValue
& aValue
);
322 bool NWPaintGTKWindowBackground( GdkDrawable
* gdkDrawable
,
323 const tools::Rectangle
& rControlRectangle
,
324 const std::vector
< tools::Rectangle
>& rClipList
);
325 bool NWPaintGTKButtonReal( GtkWidget
* button
, GdkDrawable
* gdkDrawable
,
326 const tools::Rectangle
& rControlRectangle
,
327 const std::vector
< tools::Rectangle
>& rClipList
,
328 ControlState nState
);
329 bool NWPaintGTKButton( GdkDrawable
* gdkDrawable
,
330 const tools::Rectangle
& rControlRectangle
,
331 const std::vector
< tools::Rectangle
>& rClipList
,
332 ControlState nState
);
333 bool NWPaintGTKRadio( GdkDrawable
* gdkDrawable
,
334 const tools::Rectangle
& rControlRectangle
,
335 const std::vector
< tools::Rectangle
>& rClipList
,
336 ControlState nState
, const ImplControlValue
& aValue
);
337 bool NWPaintGTKCheck( GdkDrawable
* gdkDrawable
,
338 const tools::Rectangle
& rControlRectangle
,
339 const std::vector
< tools::Rectangle
>& rClipList
,
340 ControlState nState
, const ImplControlValue
& aValue
);
341 bool NWPaintGTKScrollbar( ControlPart nPart
,
342 const tools::Rectangle
& rControlRectangle
,
343 ControlState nState
, const ImplControlValue
& aValue
);
344 bool NWPaintGTKEditBox( GdkDrawable
* gdkDrawable
, ControlType nType
,
345 const tools::Rectangle
& rControlRectangle
,
346 const std::vector
< tools::Rectangle
>& rClipList
,
347 ControlState nState
);
348 bool NWPaintGTKSpinBox(ControlType nType
, ControlPart nPart
,
349 const tools::Rectangle
& rControlRectangle
,
350 ControlState nState
, const ImplControlValue
& aValue
,
351 ControlCacheKey
& rControlCacheKey
);
352 bool NWPaintGTKComboBox( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
353 const tools::Rectangle
& rControlRectangle
,
354 const std::vector
< tools::Rectangle
>& rClipList
,
355 ControlState nState
);
356 bool NWPaintGTKTabItem( ControlType nType
,
357 const tools::Rectangle
& rControlRectangle
,
358 ControlState nState
, const ImplControlValue
& aValue
);
359 bool NWPaintGTKListBox( GdkDrawable
* gdkDrawable
, ControlPart nPart
,
360 const tools::Rectangle
& rControlRectangle
,
361 const std::vector
< tools::Rectangle
>& rClipList
,
362 ControlState nState
);
364 bool NWPaintGTKToolbar( GdkDrawable
* gdkDrawable
, ControlPart nPart
,
365 const tools::Rectangle
& rControlRectangle
,
366 const std::vector
< tools::Rectangle
>& rClipList
,
367 ControlState nState
, const ImplControlValue
& aValue
);
368 bool NWPaintGTKMenubar( GdkDrawable
* gdkDrawable
, ControlPart nPart
,
369 const tools::Rectangle
& rControlRectangle
,
370 const std::vector
< tools::Rectangle
>& rClipList
,
371 ControlState nState
);
372 bool NWPaintGTKPopupMenu( GdkDrawable
* gdkDrawable
, ControlPart nPart
,
373 const tools::Rectangle
& rControlRectangle
,
374 const std::vector
< tools::Rectangle
>& rClipList
,
375 ControlState nState
);
376 bool NWPaintGTKTooltip( GdkDrawable
* gdkDrawable
,
377 const tools::Rectangle
& rControlRectangle
,
378 const std::vector
< tools::Rectangle
>& rClipList
);
379 bool NWPaintGTKProgress(
380 const tools::Rectangle
& rControlRectangle
,
381 const ImplControlValue
& aValue
);
382 bool NWPaintGTKSlider( ControlPart nPart
,
383 const tools::Rectangle
& rControlRectangle
,
384 ControlState nState
, const ImplControlValue
& aValue
);
385 bool NWPaintGTKListNode(
386 const tools::Rectangle
& rControlRectangle
,
387 ControlState nState
, const ImplControlValue
& aValue
);
392 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
394 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */