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
26 #include <gdk/gdkkeysyms.h>
29 #include <unx/gtk/gtkframe.hxx>
31 #if GTK_CHECK_VERSION(3,0,0)
33 #include <headless/svpgdi.hxx>
34 #include "textrender.hxx"
36 class GtkSalGraphics
: public SvpSalGraphics
40 GtkSalGraphics( GtkSalFrame
*pFrame
, GtkWidget
*pWindow
);
41 virtual bool drawNativeControl( ControlType nType
, ControlPart nPart
,
42 const Rectangle
& rControlRegion
,
43 ControlState nState
, const ImplControlValue
& aValue
,
44 const OUString
& rCaption
) SAL_OVERRIDE
;
45 virtual bool IsNativeControlSupported( ControlType nType
, ControlPart nPart
) SAL_OVERRIDE
;
46 virtual bool getNativeControlRegion( ControlType nType
, ControlPart nPart
,
47 const Rectangle
& rControlRegion
,
49 const ImplControlValue
& aValue
,
50 const OUString
& rCaption
,
51 Rectangle
&rNativeBoundingRegion
,
52 Rectangle
&rNativeContentRegion
) SAL_OVERRIDE
;
53 virtual bool SupportsCairo() const SAL_OVERRIDE
;
54 virtual cairo::SurfaceSharedPtr
CreateSurface(const cairo::CairoSurfaceSharedPtr
& rSurface
) const SAL_OVERRIDE
;
55 virtual cairo::SurfaceSharedPtr
CreateSurface(const OutputDevice
& rRefDevice
, int x
, int y
, int width
, int height
) const SAL_OVERRIDE
;
56 void WidgetQueueDraw() const;
58 void updateSettings( AllSettings
& rSettings
);
59 static void refreshFontconfig( GtkSettings
*pSettings
);
60 static void signalSettingsNotify( GObject
*, GParamSpec
*pSpec
, gpointer
);
62 cairo_t
* getCairoContext() const;
64 virtual void GetResolution(sal_Int32
& rDPIX
, sal_Int32
& rDPIY
) SAL_OVERRIDE
;
67 static GtkStyleContext
*mpButtonStyle
;
68 static GtkStyleContext
*mpEntryStyle
;
69 static GtkStyleContext
*mpTextViewStyle
;
70 static GtkStyleContext
*mpVScrollbarStyle
;
71 static GtkStyleContext
*mpHScrollbarStyle
;
72 static GtkStyleContext
*mpToolbarStyle
;
73 static GtkStyleContext
*mpToolButtonStyle
;
74 static GtkStyleContext
*mpToolbarSeperatorStyle
;
75 static GtkStyleContext
*mpCheckButtonStyle
;
76 static GtkStyleContext
*mpMenuBarStyle
;
77 static GtkStyleContext
*mpMenuBarItemStyle
;
78 static GtkStyleContext
*mpMenuStyle
;
79 static GtkStyleContext
*mpSpinStyle
;
80 static GtkStyleContext
*mpCheckMenuItemStyle
;
81 static GtkStyleContext
*mpComboboxStyle
;
82 static GtkStyleContext
*mpComboboxButtonStyle
;
83 static GtkStyleContext
*mpListboxStyle
;
84 static GtkStyleContext
*mpListboxButtonStyle
;
85 static GtkStyleContext
*mpNoteBookStyle
;
86 static GtkStyleContext
*mpFrameInStyle
;
87 static GtkStyleContext
*mpFrameOutStyle
;
88 static GtkStyleContext
*mpFixedHoriLineStyle
;
89 static GtkStyleContext
*mpFixedVertLineStyle
;
90 static GtkStyleContext
*mpTreeHeaderButtonStyle
;
91 static GtkStyleContext
*mpProgressBarStyle
;
93 static Rectangle
NWGetScrollButtonRect( ControlPart nPart
, Rectangle aAreaRect
);
94 static Rectangle
NWGetSpinButtonRect( ControlPart nPart
, Rectangle aAreaRect
);
95 static Rectangle
NWGetComboBoxButtonRect( ControlType nType
, ControlPart nPart
, Rectangle aAreaRect
);
97 static void PaintScrollbar(GtkStyleContext
*context
,
99 const Rectangle
& rControlRectangle
,
102 const ImplControlValue
& aValue
);
103 void PaintOneSpinButton( GtkStyleContext
*context
,
108 ControlState nState
);
109 void PaintSpinButton(GtkStyleContext
*context
,
111 const Rectangle
& rControlRectangle
,
114 const ImplControlValue
& aValue
);
115 static void PaintCombobox(GtkStateFlags flags
,
117 const Rectangle
& rControlRectangle
,
120 const ImplControlValue
& aValue
);
121 static void PaintCheckOrRadio(GtkStyleContext
*context
,
123 const Rectangle
& rControlRectangle
,
126 static bool style_loaded
;
130 #include <unx/salgdi.h>
133 class GtkSalGraphics
: public X11SalGraphics
135 GtkWidget
*m_pWindow
;
136 vcl::Region m_aClipRegion
;
139 GtkSalGraphics( GtkSalFrame
*, GtkWidget
*window
);
140 GtkSalGraphics( GtkSalFrame
*, GtkWidget
*window
, SalX11Screen nXScreen
);
141 virtual ~GtkSalGraphics();
143 inline GtkWidget
* GetGtkWidget() const { return m_pWindow
; }
144 inline GdkWindow
* GetGdkWindow() const { return m_pWindow
->window
; }
145 inline GtkSalFrame
* GetGtkFrame() const { return static_cast<GtkSalFrame
*>(m_pFrame
); }
146 void SetWindow( GtkWidget
* window
) { m_pWindow
= window
; }
148 // will be set when UI theme was changed
149 static bool bThemeChanged
;
150 static bool bNeedPixmapPaint
;
151 static bool bNeedTwoPasses
;
153 // native widget methods
154 virtual bool IsNativeControlSupported( ControlType nType
, ControlPart nPart
) SAL_OVERRIDE
;
155 virtual bool hitTestNativeControl( ControlType nType
, ControlPart nPart
, const Rectangle
& rControlRegion
,
156 const Point
& aPos
, bool& rIsInside
) SAL_OVERRIDE
;
157 virtual bool drawNativeControl( ControlType nType
, ControlPart nPart
, const Rectangle
& rControlRegion
,
158 ControlState nState
, const ImplControlValue
& aValue
,
159 const OUString
& rCaption
) SAL_OVERRIDE
;
160 virtual bool getNativeControlRegion( ControlType nType
, ControlPart nPart
, const Rectangle
& rControlRegion
, ControlState nState
,
161 const ImplControlValue
& aValue
, const OUString
& rCaption
,
162 Rectangle
&rNativeBoundingRegion
, Rectangle
&rNativeContentRegion
) SAL_OVERRIDE
;
164 //helper methods for frame's UpdateSettings
165 void updateSettings( AllSettings
& rSettings
);
166 static void refreshFontconfig( GtkSettings
*pSettings
);
167 static void signalSettingsNotify( GObject
*, GParamSpec
*pSpec
, gpointer
);
169 virtual bool setClipRegion( const vcl::Region
& ) SAL_OVERRIDE
;
170 virtual void ResetClipRegion() SAL_OVERRIDE
;
172 // some themes set the background pixmap of our window EVERY time
173 // a control is painted; but presentation effects need
174 // the background set to None; workaround: set the background
176 virtual void copyBits( const SalTwoRect
& rPosAry
,
177 SalGraphics
* pSrcGraphics
) SAL_OVERRIDE
;
180 typedef std::list
< Rectangle
> clipList
;
182 GdkX11Pixmap
* NWGetPixmapFromScreen( Rectangle srcRect
, int nBgColor
= 0 );
183 bool NWRenderPixmapToScreen( GdkX11Pixmap
* pPixmap
, GdkX11Pixmap
* pMask
, Rectangle dstRect
);
185 bool DoDrawNativeControl( GdkDrawable
* pDrawable
,
188 const Rectangle
& aCtrlRect
,
189 const clipList
& aClip
,
191 const ImplControlValue
& aValue
,
192 const OUString
& rCaption
);
194 bool NWPaintGTKArrow( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
195 const Rectangle
& rControlRectangle
,
196 const clipList
& rClipList
,
197 ControlState nState
, const ImplControlValue
& aValue
,
198 const OUString
& rCaption
);
199 bool NWPaintGTKListHeader( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
200 const Rectangle
& rControlRectangle
,
201 const clipList
& rClipList
,
202 ControlState nState
, const ImplControlValue
& aValue
,
203 const OUString
& rCaption
);
204 bool NWPaintGTKFixedLine( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
205 const Rectangle
& rControlRectangle
,
206 const clipList
& rClipList
,
207 ControlState nState
, const ImplControlValue
& aValue
,
208 const OUString
& rCaption
);
209 bool NWPaintGTKFrame( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
210 const Rectangle
& rControlRectangle
,
211 const clipList
& rClipList
,
212 ControlState nState
, const ImplControlValue
& aValue
,
213 const OUString
& rCaption
);
214 bool NWPaintGTKWindowBackground( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
215 const Rectangle
& rControlRectangle
,
216 const clipList
& rClipList
,
217 ControlState nState
, const ImplControlValue
& aValue
,
218 const OUString
& rCaption
);
219 bool NWPaintGTKButtonReal( GtkWidget
* button
, GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
220 const Rectangle
& rControlRectangle
,
221 const clipList
& rClipList
,
222 ControlState nState
, const ImplControlValue
& aValue
,
223 const OUString
& rCaption
);
224 bool NWPaintGTKButton( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
225 const Rectangle
& rControlRectangle
,
226 const clipList
& rClipList
,
227 ControlState nState
, const ImplControlValue
& aValue
,
228 const OUString
& rCaption
);
229 bool NWPaintGTKRadio( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
230 const Rectangle
& rControlRectangle
,
231 const clipList
& rClipList
,
232 ControlState nState
, const ImplControlValue
& aValue
,
233 const OUString
& rCaption
);
234 bool NWPaintGTKCheck( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
235 const Rectangle
& rControlRectangle
,
236 const clipList
& rClipList
,
237 ControlState nState
, const ImplControlValue
& aValue
,
238 const OUString
& rCaption
);
239 bool NWPaintGTKScrollbar( ControlType nType
, ControlPart nPart
,
240 const Rectangle
& rControlRectangle
,
241 const clipList
& rClipList
,
242 ControlState nState
, const ImplControlValue
& aValue
,
243 const OUString
& rCaption
);
244 bool NWPaintGTKEditBox( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
245 const Rectangle
& rControlRectangle
,
246 const clipList
& rClipList
,
247 ControlState nState
, const ImplControlValue
& aValue
,
248 const OUString
& rCaption
);
249 bool NWPaintGTKSpinBox( ControlType nType
, ControlPart nPart
,
250 const Rectangle
& rControlRectangle
,
251 const clipList
& rClipList
,
252 ControlState nState
, const ImplControlValue
& aValue
,
253 const OUString
& rCaption
);
254 bool NWPaintGTKComboBox( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
255 const Rectangle
& rControlRectangle
,
256 const clipList
& rClipList
,
257 ControlState nState
, const ImplControlValue
& aValue
,
258 const OUString
& rCaption
);
259 bool NWPaintGTKTabItem( ControlType nType
, ControlPart nPart
,
260 const Rectangle
& rControlRectangle
,
261 const clipList
& rClipList
,
262 ControlState nState
, const ImplControlValue
& aValue
,
263 const OUString
& rCaption
);
264 bool NWPaintGTKListBox( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
265 const Rectangle
& rControlRectangle
,
266 const clipList
& rClipList
,
267 ControlState nState
, const ImplControlValue
& aValue
,
268 const OUString
& rCaption
);
270 bool NWPaintGTKToolbar( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
271 const Rectangle
& rControlRectangle
,
272 const clipList
& rClipList
,
273 ControlState nState
, const ImplControlValue
& aValue
,
274 const OUString
& rCaption
);
275 bool NWPaintGTKMenubar( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
276 const Rectangle
& rControlRectangle
,
277 const clipList
& rClipList
,
278 ControlState nState
, const ImplControlValue
& aValue
,
279 const OUString
& rCaption
);
280 bool NWPaintGTKPopupMenu( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
281 const Rectangle
& rControlRectangle
,
282 const clipList
& rClipList
,
283 ControlState nState
, const ImplControlValue
& aValue
,
284 const OUString
& rCaption
);
285 bool NWPaintGTKTooltip( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
286 const Rectangle
& rControlRectangle
,
287 const clipList
& rClipList
,
288 ControlState nState
, const ImplControlValue
& aValue
,
289 const OUString
& rCaption
);
290 bool NWPaintGTKProgress( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
291 const Rectangle
& rControlRectangle
,
292 const clipList
& rClipList
,
293 ControlState nState
, const ImplControlValue
& aValue
,
294 const OUString
& rCaption
);
295 bool NWPaintGTKSlider( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
296 const Rectangle
& rControlRectangle
,
297 const clipList
& rClipList
,
298 ControlState nState
, const ImplControlValue
& aValue
,
299 const OUString
& rCaption
);
300 bool NWPaintGTKListNode( GdkDrawable
* gdkDrawable
, ControlType nType
, ControlPart nPart
,
301 const Rectangle
& rControlRectangle
,
302 const clipList
& rClipList
,
303 ControlState nState
, const ImplControlValue
& aValue
,
304 const OUString
& rCaption
);
309 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */