Line data Source code
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 _VCL_GTKGDI_HXX
21 : #define _VCL_GTKGDI_HXX
22 :
23 : #include <tools/prex.h>
24 : #include <gtk/gtk.h>
25 : #include <gdk/gdkx.h>
26 : #include <gdk/gdkkeysyms.h>
27 : #include <tools/postx.h>
28 :
29 : #include <unx/salgdi.h>
30 :
31 : #if GTK_CHECK_VERSION(3,0,0)
32 :
33 : #include <headless/svpgdi.hxx>
34 :
35 : class GtkSalFrame;
36 : class GtkSalGraphics : public SvpSalGraphics
37 : {
38 : GtkSalFrame *mpFrame;
39 : public:
40 : GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
41 : virtual void copyArea( long nDestX, long nDestY,
42 : long nSrcX, long nSrcY,
43 : long nSrcWidth, long nSrcHeight,
44 : sal_uInt16 /*nFlags*/ );
45 : virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart,
46 : const Rectangle& rControlRegion,
47 : ControlState nState, const ImplControlValue& aValue,
48 : const rtl::OUString& rCaption );
49 : virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart );
50 : virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart,
51 : const Rectangle& rControlRegion,
52 : ControlState nState,
53 : const ImplControlValue& aValue,
54 : const rtl::OUString& rCaption,
55 : Rectangle &rNativeBoundingRegion,
56 : Rectangle &rNativeContentRegion );
57 : void updateSettings( AllSettings& rSettings );
58 : private:
59 : GtkWidget *mpWindow;
60 : static GtkStyleContext *mpButtonStyle;
61 : static GtkStyleContext *mpEntryStyle;
62 : static GtkStyleContext *mpScrollbarStyle;
63 : static GtkStyleContext *mpToolbarStyle;
64 : static GtkStyleContext *mpToolButtonStyle;
65 : static GtkStyleContext *mpCheckButtonStyle;
66 : static GtkStyleContext *mpMenuBarStyle;
67 : static GtkStyleContext *mpMenuBarItemStyle;
68 : static GtkStyleContext *mpMenuStyle;
69 : static GtkStyleContext *mpMenuItemStyle;
70 : static GtkStyleContext *mpSpinStyle;
71 : static GtkStyleContext *mpComboboxStyle;
72 : static GtkStyleContext *mpListboxStyle;
73 :
74 : void renderAreaToPix( cairo_t* cr, cairo_rectangle_int_t *region );
75 : void getStyleContext( GtkStyleContext** style, GtkWidget* widget );
76 : Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
77 : Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
78 : Rectangle NWGetComboBoxButtonRect( ControlType nType, ControlPart nPart, Rectangle aAreaRect );
79 :
80 : void PaintScrollbar(GtkStyleContext *context,
81 : cairo_t *cr,
82 : const Rectangle& rControlRectangle,
83 : ControlType nType,
84 : ControlPart nPart,
85 : const ImplControlValue& aValue );
86 : void PaintOneSpinButton( GtkStyleContext *context,
87 : cairo_t *cr,
88 : ControlType nType,
89 : ControlPart nPart,
90 : Rectangle aAreaRect,
91 : ControlState nState );
92 : void PaintSpinButton(GtkStyleContext *context,
93 : cairo_t *cr,
94 : const Rectangle& rControlRectangle,
95 : ControlType nType,
96 : ControlPart nPart,
97 : const ImplControlValue& aValue );
98 : void PaintCombobox( GtkStyleContext *context,
99 : cairo_t *cr,
100 : const Rectangle& rControlRectangle,
101 : ControlType nType,
102 : ControlPart nPart,
103 : const ImplControlValue& aValue );
104 :
105 : static bool style_loaded;
106 : };
107 :
108 : #else
109 :
110 : class GtkSalGraphics : public X11SalGraphics
111 : {
112 : GtkWidget *m_pWindow;
113 : Region m_aClipRegion;
114 :
115 : public:
116 : GtkSalGraphics( GtkSalFrame *, GtkWidget *window );
117 : virtual ~GtkSalGraphics();
118 :
119 : inline GtkWidget* GetGtkWidget() const { return m_pWindow; }
120 0 : inline GdkWindow* GetGdkWindow() const { return m_pWindow->window; }
121 0 : inline GtkSalFrame* GetGtkFrame() const { return static_cast<GtkSalFrame*>(m_pFrame); }
122 0 : void SetWindow( GtkWidget* window ) { m_pWindow = window; }
123 :
124 :
125 : // will be set when UI theme was changed
126 : static sal_Bool bThemeChanged;
127 : static sal_Bool bNeedPixmapPaint;
128 :
129 : // native widget methods
130 : virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart );
131 : virtual sal_Bool hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
132 : const Point& aPos, sal_Bool& rIsInside );
133 : virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
134 : ControlState nState, const ImplControlValue& aValue,
135 : const rtl::OUString& rCaption );
136 : virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState,
137 : const ImplControlValue& aValue, const rtl::OUString& rCaption,
138 : Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion );
139 :
140 : //helper methods for frame's UpdateSettings
141 : void updateSettings( AllSettings& rSettings );
142 :
143 : virtual bool setClipRegion( const Region& );
144 : virtual void ResetClipRegion();
145 :
146 : // some themes set the background pixmap of our window EVERY time
147 : // a control is painted; but presentation effects need
148 : // the background set to None; workaround: set the background
149 : // before copyBits
150 : virtual void copyBits( const SalTwoRect* pPosAry,
151 : SalGraphics* pSrcGraphics );
152 :
153 : protected:
154 : typedef std::list< Rectangle > clipList;
155 :
156 : GdkPixmap* NWGetPixmapFromScreen( Rectangle srcRect );
157 : sal_Bool NWRenderPixmapToScreen( GdkPixmap* pPixmap, Rectangle dstRect );
158 :
159 : sal_Bool NWPaintGTKArrow( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
160 : const Rectangle& rControlRectangle,
161 : const clipList& rClipList,
162 : ControlState nState, const ImplControlValue& aValue,
163 : const OUString& rCaption );
164 : sal_Bool NWPaintGTKListHeader( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
165 : const Rectangle& rControlRectangle,
166 : const clipList& rClipList,
167 : ControlState nState, const ImplControlValue& aValue,
168 : const OUString& rCaption );
169 : sal_Bool NWPaintGTKFixedLine( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
170 : const Rectangle& rControlRectangle,
171 : const clipList& rClipList,
172 : ControlState nState, const ImplControlValue& aValue,
173 : const OUString& rCaption );
174 : sal_Bool NWPaintGTKFrame( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
175 : const Rectangle& rControlRectangle,
176 : const clipList& rClipList,
177 : ControlState nState, const ImplControlValue& aValue,
178 : const OUString& rCaption );
179 : sal_Bool NWPaintGTKWindowBackground( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
180 : const Rectangle& rControlRectangle,
181 : const clipList& rClipList,
182 : ControlState nState, const ImplControlValue& aValue,
183 : const OUString& rCaption );
184 : sal_Bool NWPaintGTKButtonReal( GtkWidget* button, GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
185 : const Rectangle& rControlRectangle,
186 : const clipList& rClipList,
187 : ControlState nState, const ImplControlValue& aValue,
188 : const OUString& rCaption );
189 : sal_Bool NWPaintGTKButton( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
190 : const Rectangle& rControlRectangle,
191 : const clipList& rClipList,
192 : ControlState nState, const ImplControlValue& aValue,
193 : const OUString& rCaption );
194 : sal_Bool NWPaintGTKRadio( 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 : sal_Bool NWPaintGTKCheck( 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 : sal_Bool NWPaintGTKScrollbar( ControlType nType, ControlPart nPart,
205 : const Rectangle& rControlRectangle,
206 : const clipList& rClipList,
207 : ControlState nState, const ImplControlValue& aValue,
208 : const OUString& rCaption );
209 : sal_Bool NWPaintGTKEditBox( 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 : sal_Bool NWPaintGTKSpinBox( ControlType nType, ControlPart nPart,
215 : const Rectangle& rControlRectangle,
216 : const clipList& rClipList,
217 : ControlState nState, const ImplControlValue& aValue,
218 : const OUString& rCaption );
219 : sal_Bool NWPaintGTKComboBox( 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 : sal_Bool NWPaintGTKTabItem( ControlType nType, ControlPart nPart,
225 : const Rectangle& rControlRectangle,
226 : const clipList& rClipList,
227 : ControlState nState, const ImplControlValue& aValue,
228 : const OUString& rCaption );
229 : sal_Bool NWPaintGTKListBox( 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 :
235 : sal_Bool NWPaintGTKToolbar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
236 : const Rectangle& rControlRectangle,
237 : const clipList& rClipList,
238 : ControlState nState, const ImplControlValue& aValue,
239 : const OUString& rCaption );
240 : sal_Bool NWPaintGTKMenubar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
241 : const Rectangle& rControlRectangle,
242 : const clipList& rClipList,
243 : ControlState nState, const ImplControlValue& aValue,
244 : const OUString& rCaption );
245 : sal_Bool NWPaintGTKPopupMenu( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
246 : const Rectangle& rControlRectangle,
247 : const clipList& rClipList,
248 : ControlState nState, const ImplControlValue& aValue,
249 : const OUString& rCaption );
250 : sal_Bool NWPaintGTKTooltip( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
251 : const Rectangle& rControlRectangle,
252 : const clipList& rClipList,
253 : ControlState nState, const ImplControlValue& aValue,
254 : const OUString& rCaption );
255 : sal_Bool NWPaintGTKProgress( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
256 : const Rectangle& rControlRectangle,
257 : const clipList& rClipList,
258 : ControlState nState, const ImplControlValue& aValue,
259 : const OUString& rCaption );
260 : sal_Bool NWPaintGTKSlider( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
261 : const Rectangle& rControlRectangle,
262 : const clipList& rClipList,
263 : ControlState nState, const ImplControlValue& aValue,
264 : const OUString& rCaption );
265 : sal_Bool NWPaintGTKListNode( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
266 : const Rectangle& rControlRectangle,
267 : const clipList& rClipList,
268 : ControlState nState, const ImplControlValue& aValue,
269 : const OUString& rCaption );
270 : };
271 :
272 : #endif // !gtk3
273 :
274 : #endif // _VCL_GTKGDI_HXX
275 :
276 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|