Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _VCL_GTKGDI_HXX
30 : : #define _VCL_GTKGDI_HXX
31 : :
32 : : #include <tools/prex.h>
33 : : #include <gtk/gtk.h>
34 : : #include <gdk/gdkx.h>
35 : : #include <gdk/gdkkeysyms.h>
36 : : #include <tools/postx.h>
37 : :
38 : : #include <unx/salgdi.h>
39 : :
40 : : #if GTK_CHECK_VERSION(3,0,0)
41 : :
42 : : #include <headless/svpgdi.hxx>
43 : :
44 : : class GtkSalFrame;
45 : : class GtkSalGraphics : public SvpSalGraphics
46 : : {
47 : : GtkSalFrame *mpFrame;
48 : : public:
49 : : GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
50 : : virtual void copyArea( long nDestX, long nDestY,
51 : : long nSrcX, long nSrcY,
52 : : long nSrcWidth, long nSrcHeight,
53 : : sal_uInt16 /*nFlags*/ );
54 : : virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart,
55 : : const Rectangle& rControlRegion,
56 : : ControlState nState, const ImplControlValue& aValue,
57 : : const rtl::OUString& rCaption );
58 : : virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart );
59 : : virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart,
60 : : const Rectangle& rControlRegion,
61 : : ControlState nState,
62 : : const ImplControlValue& aValue,
63 : : const rtl::OUString& rCaption,
64 : : Rectangle &rNativeBoundingRegion,
65 : : Rectangle &rNativeContentRegion );
66 : : void updateSettings( AllSettings& rSettings );
67 : : private:
68 : : GtkWidget *mpWindow;
69 : : static GtkStyleContext *mpButtonStyle;
70 : : static GtkStyleContext *mpEntryStyle;
71 : : static GtkStyleContext *mpScrollbarStyle;
72 : : static GtkStyleContext *mpToolbarStyle;
73 : : static GtkStyleContext *mpToolButtonStyle;
74 : : static GtkStyleContext *mpCheckButtonStyle;
75 : : static GtkStyleContext *mpMenuBarStyle;
76 : : static GtkStyleContext *mpMenuBarItemStyle;
77 : : static GtkStyleContext *mpMenuStyle;
78 : : static GtkStyleContext *mpMenuItemStyle;
79 : : static GtkStyleContext *mpSpinStyle;
80 : : static GtkStyleContext *mpComboboxStyle;
81 : : static GtkStyleContext *mpListboxStyle;
82 : :
83 : : void renderAreaToPix( cairo_t* cr, cairo_rectangle_int_t *region );
84 : : void getStyleContext( GtkStyleContext** style, GtkWidget* widget );
85 : : Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
86 : : Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
87 : : Rectangle NWGetComboBoxButtonRect( ControlType nType, ControlPart nPart, Rectangle aAreaRect );
88 : :
89 : : void PaintScrollbar(GtkStyleContext *context,
90 : : cairo_t *cr,
91 : : const Rectangle& rControlRectangle,
92 : : ControlType nType,
93 : : ControlPart nPart,
94 : : const ImplControlValue& aValue );
95 : : void PaintOneSpinButton( GtkStyleContext *context,
96 : : cairo_t *cr,
97 : : ControlType nType,
98 : : ControlPart nPart,
99 : : Rectangle aAreaRect,
100 : : ControlState nState );
101 : : void PaintSpinButton(GtkStyleContext *context,
102 : : cairo_t *cr,
103 : : const Rectangle& rControlRectangle,
104 : : ControlType nType,
105 : : ControlPart nPart,
106 : : const ImplControlValue& aValue );
107 : : void PaintCombobox( GtkStyleContext *context,
108 : : cairo_t *cr,
109 : : const Rectangle& rControlRectangle,
110 : : ControlType nType,
111 : : ControlPart nPart,
112 : : const ImplControlValue& aValue );
113 : :
114 : : static bool style_loaded;
115 : : };
116 : :
117 : : #else
118 : :
119 : : class GtkSalGraphics : public X11SalGraphics
120 : : {
121 : : GtkWidget *m_pWindow;
122 : : Region m_aClipRegion;
123 : :
124 : : public:
125 : : GtkSalGraphics( GtkSalFrame *, GtkWidget *window );
126 : : virtual ~GtkSalGraphics();
127 : :
128 : : inline GtkWidget* GetGtkWidget() const { return m_pWindow; }
129 : 0 : inline GdkWindow* GetGdkWindow() const { return m_pWindow->window; }
130 : 0 : inline GtkSalFrame* GetGtkFrame() const { return static_cast<GtkSalFrame*>(m_pFrame); }
131 : 0 : void SetWindow( GtkWidget* window ) { m_pWindow = window; }
132 : :
133 : :
134 : : // will be set when UI theme was changed
135 : : static sal_Bool bThemeChanged;
136 : : static sal_Bool bNeedPixmapPaint;
137 : :
138 : : // native widget methods
139 : : virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart );
140 : : virtual sal_Bool hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
141 : : const Point& aPos, sal_Bool& rIsInside );
142 : : virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
143 : : ControlState nState, const ImplControlValue& aValue,
144 : : const rtl::OUString& rCaption );
145 : : virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState,
146 : : const ImplControlValue& aValue, const rtl::OUString& rCaption,
147 : : Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion );
148 : :
149 : : //helper methods for frame's UpdateSettings
150 : : void updateSettings( AllSettings& rSettings );
151 : :
152 : : virtual bool setClipRegion( const Region& );
153 : : virtual void ResetClipRegion();
154 : :
155 : : // some themes set the background pixmap of our window EVERY time
156 : : // a control is painted; but presentation effects need
157 : : // the background set to None; workaround: set the background
158 : : // before copyBits
159 : : virtual void copyBits( const SalTwoRect* pPosAry,
160 : : SalGraphics* pSrcGraphics );
161 : :
162 : : protected:
163 : : typedef std::list< Rectangle > clipList;
164 : :
165 : : GdkPixmap* NWGetPixmapFromScreen( Rectangle srcRect );
166 : : sal_Bool NWRenderPixmapToScreen( GdkPixmap* pPixmap, Rectangle dstRect );
167 : :
168 : : sal_Bool NWPaintGTKArrow( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
169 : : const Rectangle& rControlRectangle,
170 : : const clipList& rClipList,
171 : : ControlState nState, const ImplControlValue& aValue,
172 : : const OUString& rCaption );
173 : : sal_Bool NWPaintGTKListHeader( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
174 : : const Rectangle& rControlRectangle,
175 : : const clipList& rClipList,
176 : : ControlState nState, const ImplControlValue& aValue,
177 : : const OUString& rCaption );
178 : : sal_Bool NWPaintGTKFixedLine( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
179 : : const Rectangle& rControlRectangle,
180 : : const clipList& rClipList,
181 : : ControlState nState, const ImplControlValue& aValue,
182 : : const OUString& rCaption );
183 : : sal_Bool NWPaintGTKFrame( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
184 : : const Rectangle& rControlRectangle,
185 : : const clipList& rClipList,
186 : : ControlState nState, const ImplControlValue& aValue,
187 : : const OUString& rCaption );
188 : : sal_Bool NWPaintGTKWindowBackground( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
189 : : const Rectangle& rControlRectangle,
190 : : const clipList& rClipList,
191 : : ControlState nState, const ImplControlValue& aValue,
192 : : const OUString& rCaption );
193 : : sal_Bool NWPaintGTKButtonReal( GtkWidget* button, GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
194 : : const Rectangle& rControlRectangle,
195 : : const clipList& rClipList,
196 : : ControlState nState, const ImplControlValue& aValue,
197 : : const OUString& rCaption );
198 : : sal_Bool NWPaintGTKButton( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
199 : : const Rectangle& rControlRectangle,
200 : : const clipList& rClipList,
201 : : ControlState nState, const ImplControlValue& aValue,
202 : : const OUString& rCaption );
203 : : sal_Bool NWPaintGTKRadio( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
204 : : const Rectangle& rControlRectangle,
205 : : const clipList& rClipList,
206 : : ControlState nState, const ImplControlValue& aValue,
207 : : const OUString& rCaption );
208 : : sal_Bool NWPaintGTKCheck( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
209 : : const Rectangle& rControlRectangle,
210 : : const clipList& rClipList,
211 : : ControlState nState, const ImplControlValue& aValue,
212 : : const OUString& rCaption );
213 : : sal_Bool NWPaintGTKScrollbar( ControlType nType, ControlPart nPart,
214 : : const Rectangle& rControlRectangle,
215 : : const clipList& rClipList,
216 : : ControlState nState, const ImplControlValue& aValue,
217 : : const OUString& rCaption );
218 : : sal_Bool NWPaintGTKEditBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
219 : : const Rectangle& rControlRectangle,
220 : : const clipList& rClipList,
221 : : ControlState nState, const ImplControlValue& aValue,
222 : : const OUString& rCaption );
223 : : sal_Bool NWPaintGTKSpinBox( ControlType nType, ControlPart nPart,
224 : : const Rectangle& rControlRectangle,
225 : : const clipList& rClipList,
226 : : ControlState nState, const ImplControlValue& aValue,
227 : : const OUString& rCaption );
228 : : sal_Bool NWPaintGTKComboBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
229 : : const Rectangle& rControlRectangle,
230 : : const clipList& rClipList,
231 : : ControlState nState, const ImplControlValue& aValue,
232 : : const OUString& rCaption );
233 : : sal_Bool NWPaintGTKTabItem( ControlType nType, ControlPart nPart,
234 : : const Rectangle& rControlRectangle,
235 : : const clipList& rClipList,
236 : : ControlState nState, const ImplControlValue& aValue,
237 : : const OUString& rCaption );
238 : : sal_Bool NWPaintGTKListBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
239 : : const Rectangle& rControlRectangle,
240 : : const clipList& rClipList,
241 : : ControlState nState, const ImplControlValue& aValue,
242 : : const OUString& rCaption );
243 : :
244 : : sal_Bool NWPaintGTKToolbar( 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 : : sal_Bool NWPaintGTKMenubar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
250 : : const Rectangle& rControlRectangle,
251 : : const clipList& rClipList,
252 : : ControlState nState, const ImplControlValue& aValue,
253 : : const OUString& rCaption );
254 : : sal_Bool NWPaintGTKPopupMenu( 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 : : sal_Bool NWPaintGTKTooltip( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
260 : : const Rectangle& rControlRectangle,
261 : : const clipList& rClipList,
262 : : ControlState nState, const ImplControlValue& aValue,
263 : : const OUString& rCaption );
264 : : sal_Bool NWPaintGTKProgress( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
265 : : const Rectangle& rControlRectangle,
266 : : const clipList& rClipList,
267 : : ControlState nState, const ImplControlValue& aValue,
268 : : const OUString& rCaption );
269 : : sal_Bool NWPaintGTKSlider( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
270 : : const Rectangle& rControlRectangle,
271 : : const clipList& rClipList,
272 : : ControlState nState, const ImplControlValue& aValue,
273 : : const OUString& rCaption );
274 : : sal_Bool NWPaintGTKListNode( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
275 : : const Rectangle& rControlRectangle,
276 : : const clipList& rClipList,
277 : : ControlState nState, const ImplControlValue& aValue,
278 : : const OUString& rCaption );
279 : : };
280 : :
281 : : #endif // !gtk3
282 : :
283 : : #endif // _VCL_GTKGDI_HXX
284 : :
285 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|