1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9f62ea84SAndrew Rist  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19*9f62ea84SAndrew Rist  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "vcl/svapp.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "unx/gtk/gtkframe.hxx"
30cdf0e10cSrcweir #include "unx/gtk/gtkdata.hxx"
31cdf0e10cSrcweir #include "unx/gtk/gtkinst.hxx"
32cdf0e10cSrcweir #include "unx/gtk/gtkgdi.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "unx/pspgraphics.h"
35cdf0e10cSrcweir #include "unx/saldata.hxx"
36cdf0e10cSrcweir #include "unx/saldisp.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <cstdio>
39cdf0e10cSrcweir #include <cmath>
40cdf0e10cSrcweir #include <vector>
41cdf0e10cSrcweir #include <algorithm>
42cdf0e10cSrcweir #include <hash_map>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir typedef struct _cairo_font_options cairo_font_options_t;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // initialize statics
47cdf0e10cSrcweir sal_Bool GtkSalGraphics::bThemeChanged = sal_True;
48cdf0e10cSrcweir sal_Bool GtkSalGraphics::bNeedPixmapPaint = sal_False;
49cdf0e10cSrcweir sal_Bool GtkSalGraphics::bGlobalNeedPixmapPaint = sal_False;
50cdf0e10cSrcweir sal_Bool GtkSalGraphics::bToolbarGripWorkaround = sal_False;
51cdf0e10cSrcweir sal_Bool GtkSalGraphics::bNeedButtonStyleAsEditBackgroundWorkaround = sal_False;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir GtkSalGraphics::~GtkSalGraphics()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using namespace rtl;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /*************************************
61cdf0e10cSrcweir  * Cached native widget objects
62cdf0e10cSrcweir  *************************************/
63cdf0e10cSrcweir class NWPixmapCacheList;
64cdf0e10cSrcweir class NWPixmapCache;
65cdf0e10cSrcweir struct NWFWidgetData
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     GtkWidget *	gCacheWindow;
68cdf0e10cSrcweir     GtkWidget *	gDumbContainer;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     GtkWidget *	gBtnWidget;
71cdf0e10cSrcweir     GtkWidget *	gRadioWidget;
72cdf0e10cSrcweir     GtkWidget *	gRadioWidgetSibling;
73cdf0e10cSrcweir     GtkWidget *	gCheckWidget;
74cdf0e10cSrcweir     GtkWidget *	gScrollHorizWidget;
75cdf0e10cSrcweir     GtkWidget *	gScrollVertWidget;
76cdf0e10cSrcweir     GtkWidget *	gArrowWidget;
77cdf0e10cSrcweir     GtkWidget *	gDropdownWidget;
78cdf0e10cSrcweir     GtkWidget *	gEditBoxWidget;
79cdf0e10cSrcweir     GtkWidget *	gSpinButtonWidget;
80cdf0e10cSrcweir     GtkWidget *	gNotebookWidget;
81cdf0e10cSrcweir     GtkWidget *	gOptionMenuWidget;
82cdf0e10cSrcweir     GtkWidget *	gComboWidget;
83cdf0e10cSrcweir     GtkWidget *	gScrolledWindowWidget;
84cdf0e10cSrcweir     GtkWidget *  gToolbarWidget;
85cdf0e10cSrcweir     GtkWidget *  gToolbarButtonWidget;
86cdf0e10cSrcweir     GtkWidget *  gToolbarToggleWidget;
87cdf0e10cSrcweir     GtkWidget *  gHandleBoxWidget;
88cdf0e10cSrcweir     GtkWidget *  gMenubarWidget;
89cdf0e10cSrcweir     GtkWidget *  gMenuItemMenubarWidget;
90cdf0e10cSrcweir     GtkWidget *  gMenuWidget;
91cdf0e10cSrcweir     GtkWidget *  gMenuItemMenuWidget;
92cdf0e10cSrcweir     GtkWidget *  gMenuItemCheckMenuWidget;
93cdf0e10cSrcweir     GtkWidget *  gMenuItemRadioMenuWidget;
94cdf0e10cSrcweir     GtkWidget *  gImageMenuItem;
95cdf0e10cSrcweir     GtkWidget *  gTooltipPopup;
96cdf0e10cSrcweir     GtkWidget *  gProgressBar;
97cdf0e10cSrcweir     GtkWidget *  gTreeView;
98cdf0e10cSrcweir     GtkWidget *  gHScale;
99cdf0e10cSrcweir     GtkWidget *  gVScale;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     NWPixmapCacheList* gNWPixmapCacheList;
102cdf0e10cSrcweir     NWPixmapCache* gCacheTabItems;
103cdf0e10cSrcweir     NWPixmapCache* gCacheTabPages;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     NWFWidgetData() :
106cdf0e10cSrcweir         gCacheWindow( NULL ),
107cdf0e10cSrcweir         gDumbContainer( NULL ),
108cdf0e10cSrcweir         gBtnWidget( NULL ),
109cdf0e10cSrcweir         gRadioWidget( NULL ),
110cdf0e10cSrcweir         gRadioWidgetSibling( NULL ),
111cdf0e10cSrcweir         gCheckWidget( NULL ),
112cdf0e10cSrcweir         gScrollHorizWidget( NULL ),
113cdf0e10cSrcweir         gScrollVertWidget( NULL ),
114cdf0e10cSrcweir         gArrowWidget( NULL ),
115cdf0e10cSrcweir         gDropdownWidget( NULL ),
116cdf0e10cSrcweir         gEditBoxWidget( NULL ),
117cdf0e10cSrcweir         gSpinButtonWidget( NULL ),
118cdf0e10cSrcweir         gNotebookWidget( NULL ),
119cdf0e10cSrcweir         gOptionMenuWidget( NULL ),
120cdf0e10cSrcweir         gComboWidget( NULL ),
121cdf0e10cSrcweir         gScrolledWindowWidget( NULL ),
122cdf0e10cSrcweir         gToolbarWidget( NULL ),
123cdf0e10cSrcweir         gToolbarButtonWidget( NULL ),
124cdf0e10cSrcweir         gToolbarToggleWidget( NULL ),
125cdf0e10cSrcweir         gHandleBoxWidget( NULL ),
126cdf0e10cSrcweir         gMenubarWidget( NULL ),
127cdf0e10cSrcweir         gMenuItemMenubarWidget( NULL ),
128cdf0e10cSrcweir         gMenuWidget( NULL ),
129cdf0e10cSrcweir         gMenuItemMenuWidget( NULL ),
130cdf0e10cSrcweir         gMenuItemCheckMenuWidget( NULL ),
131cdf0e10cSrcweir         gMenuItemRadioMenuWidget( NULL ),
132cdf0e10cSrcweir         gImageMenuItem( NULL ),
133cdf0e10cSrcweir         gTooltipPopup( NULL ),
134cdf0e10cSrcweir         gProgressBar( NULL ),
135cdf0e10cSrcweir         gTreeView( NULL ),
136cdf0e10cSrcweir         gHScale( NULL ),
137cdf0e10cSrcweir         gVScale( NULL ),
138cdf0e10cSrcweir         gNWPixmapCacheList( NULL ),
139cdf0e10cSrcweir         gCacheTabItems( NULL ),
140cdf0e10cSrcweir         gCacheTabPages( NULL )
141cdf0e10cSrcweir     {}
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir // Keep a hash table of Widgets->default flags so that we can
145cdf0e10cSrcweir // easily and quickly reset each to a default state before using
146cdf0e10cSrcweir // them
147cdf0e10cSrcweir static std::hash_map<long, guint>	gWidgetDefaultFlags;
148cdf0e10cSrcweir static std::vector<NWFWidgetData>   gWidgetData;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir static const GtkBorder aDefDefBorder		= { 1, 1, 1, 1 };
151cdf0e10cSrcweir 
152cdf0e10cSrcweir // Some GTK defaults
153cdf0e10cSrcweir #define MIN_ARROW_SIZE					11
154cdf0e10cSrcweir #define BTN_CHILD_SPACING				1
155cdf0e10cSrcweir #define MIN_SPIN_ARROW_WIDTH				6
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir static void NWEnsureGTKRadio			( int nScreen );
159cdf0e10cSrcweir static void NWEnsureGTKButton			( int nScreen );
160cdf0e10cSrcweir static void NWEnsureGTKCheck			( int nScreen );
161cdf0e10cSrcweir static void NWEnsureGTKScrollbars		( int nScreen );
162cdf0e10cSrcweir static void NWEnsureGTKArrow			( int nScreen );
163cdf0e10cSrcweir static void NWEnsureGTKEditBox			( int nScreen );
164cdf0e10cSrcweir static void NWEnsureGTKSpinButton		( int nScreen );
165cdf0e10cSrcweir static void NWEnsureGTKNotebook			( int nScreen );
166cdf0e10cSrcweir static void NWEnsureGTKOptionMenu		( int nScreen );
167cdf0e10cSrcweir static void NWEnsureGTKCombo			( int nScreen );
168cdf0e10cSrcweir static void NWEnsureGTKScrolledWindow	( int nScreen );
169cdf0e10cSrcweir static void NWEnsureGTKToolbar			( int nScreen );
170cdf0e10cSrcweir static void NWEnsureGTKMenubar          ( int nScreen );
171cdf0e10cSrcweir static void NWEnsureGTKMenu             ( int nScreen );
172cdf0e10cSrcweir static void NWEnsureGTKTooltip          ( int nScreen );
173cdf0e10cSrcweir static void NWEnsureGTKProgressBar      ( int nScreen );
174cdf0e10cSrcweir static void NWEnsureGTKTreeView         ( int nScreen );
175cdf0e10cSrcweir static void NWEnsureGTKSlider           ( int nScreen );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir static void NWConvertVCLStateToGTKState( ControlState nVCLState, GtkStateType* nGTKState, GtkShadowType* nGTKShadow );
178cdf0e10cSrcweir static void NWAddWidgetToCacheWindow( GtkWidget* widget, int nScreen );
179cdf0e10cSrcweir static void NWSetWidgetState( GtkWidget* widget, ControlState nState, GtkStateType nGtkState );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir /*
184cdf0e10cSrcweir  * Individual helper functions
185cdf0e10cSrcweir  *
186cdf0e10cSrcweir  */
187cdf0e10cSrcweir 
188cdf0e10cSrcweir //---
189cdf0e10cSrcweir static Rectangle NWGetButtonArea( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState,
190cdf0e10cSrcweir 								const ImplControlValue& aValue, const OUString& rCaption );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir //---
193cdf0e10cSrcweir static Rectangle NWGetEditBoxPixmapRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState,
194cdf0e10cSrcweir 							const ImplControlValue& aValue, const OUString& rCaption );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir static void NWPaintOneEditBox( int nScreen, GdkDrawable * gdkDrawable, GdkRectangle *gdkRect,
197cdf0e10cSrcweir                                ControlType nType, ControlPart nPart, Rectangle aEditBoxRect,
198cdf0e10cSrcweir                                ControlState nState, const ImplControlValue& aValue,
199cdf0e10cSrcweir                                const OUString& rCaption );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir //---
202cdf0e10cSrcweir static Rectangle NWGetSpinButtonRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState,
203cdf0e10cSrcweir 							const ImplControlValue& aValue, const OUString& rCaption );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir static void NWPaintOneSpinButton( int nScreen, GdkPixmap * pixmap, ControlType nType, ControlPart nPart, Rectangle aAreaRect,
206cdf0e10cSrcweir 							ControlState nState, const ImplControlValue& aValue,
207cdf0e10cSrcweir 							const OUString& rCaption );
208cdf0e10cSrcweir //---
209cdf0e10cSrcweir static Rectangle NWGetComboBoxButtonRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState,
210cdf0e10cSrcweir 							const ImplControlValue& aValue, const OUString& rCaption );
211cdf0e10cSrcweir 
212cdf0e10cSrcweir //---
213cdf0e10cSrcweir static Rectangle NWGetListBoxButtonRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState,
214cdf0e10cSrcweir 							const ImplControlValue& aValue, const OUString& rCaption );
215cdf0e10cSrcweir 
216cdf0e10cSrcweir static Rectangle NWGetListBoxIndicatorRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState,
217cdf0e10cSrcweir 							const ImplControlValue& aValue, const OUString& rCaption );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir static Rectangle NWGetToolbarRect( int nScreen,
220cdf0e10cSrcweir                                    ControlType nType,
221cdf0e10cSrcweir                                    ControlPart nPart,
222cdf0e10cSrcweir                                    Rectangle aAreaRect,
223cdf0e10cSrcweir                                    ControlState nState,
224cdf0e10cSrcweir                                    const ImplControlValue& aValue,
225cdf0e10cSrcweir                                    const OUString& rCaption );
226cdf0e10cSrcweir //---
227cdf0e10cSrcweir 
228cdf0e10cSrcweir static Rectangle NWGetScrollButtonRect(	int nScreen, ControlPart nPart, Rectangle aAreaRect );
229cdf0e10cSrcweir //---
230cdf0e10cSrcweir 
231cdf0e10cSrcweir /*********************************************************
232cdf0e10cSrcweir  * PixmapCache
233cdf0e10cSrcweir  *********************************************************/
234cdf0e10cSrcweir 
235cdf0e10cSrcweir // as some native widget drawing operations are pretty slow
236cdf0e10cSrcweir // with certain themes (eg tabpages)
237cdf0e10cSrcweir // this cache can be used to cache the corresponding pixmap
238cdf0e10cSrcweir // see NWPaintGTKTabItem
239cdf0e10cSrcweir 
240cdf0e10cSrcweir class NWPixmapCacheData
241cdf0e10cSrcweir {
242cdf0e10cSrcweir public:
243cdf0e10cSrcweir     ControlType m_nType;
244cdf0e10cSrcweir     ControlState m_nState;
245cdf0e10cSrcweir     Rectangle   m_pixmapRect;
246cdf0e10cSrcweir     GdkPixmap*  m_pixmap;
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     NWPixmapCacheData() : m_nType(0), m_nState(0), m_pixmap(0) {}
249cdf0e10cSrcweir     ~NWPixmapCacheData()
250cdf0e10cSrcweir         { SetPixmap( NULL ); };
251cdf0e10cSrcweir     void SetPixmap( GdkPixmap* pPixmap );
252cdf0e10cSrcweir };
253cdf0e10cSrcweir 
254cdf0e10cSrcweir class NWPixmapCache
255cdf0e10cSrcweir {
256cdf0e10cSrcweir     int m_size;
257cdf0e10cSrcweir     int m_idx;
258cdf0e10cSrcweir     int m_screen;
259cdf0e10cSrcweir     NWPixmapCacheData* pData;
260cdf0e10cSrcweir public:
261cdf0e10cSrcweir     NWPixmapCache( int nScreen );
262cdf0e10cSrcweir     ~NWPixmapCache();
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     void SetSize( int n)
265cdf0e10cSrcweir         { delete [] pData; m_idx = 0; m_size = n; pData = new NWPixmapCacheData[m_size]; }
266cdf0e10cSrcweir     int GetSize() { return m_size; }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     sal_Bool Find( ControlType aType, ControlState aState, const Rectangle& r_pixmapRect, GdkPixmap** pPixmap );
269cdf0e10cSrcweir     void Fill( ControlType aType, ControlState aState, const Rectangle& r_pixmapRect, GdkPixmap* pPixmap );
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     void ThemeChanged();
272cdf0e10cSrcweir };
273cdf0e10cSrcweir 
274cdf0e10cSrcweir class NWPixmapCacheList
275cdf0e10cSrcweir {
276cdf0e10cSrcweir public:
277cdf0e10cSrcweir     ::std::vector< NWPixmapCache* > mCaches;
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     void AddCache( NWPixmapCache *pCache );
280cdf0e10cSrcweir     void RemoveCache( NWPixmapCache *pCache );
281cdf0e10cSrcweir     void ThemeChanged();
282cdf0e10cSrcweir };
283cdf0e10cSrcweir 
284cdf0e10cSrcweir // --- implementation ---
285cdf0e10cSrcweir 
286cdf0e10cSrcweir void NWPixmapCacheData::SetPixmap( GdkPixmap* pPixmap )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir     if( m_pixmap )
289cdf0e10cSrcweir         g_object_unref( m_pixmap );
290cdf0e10cSrcweir 
291cdf0e10cSrcweir     m_pixmap = pPixmap;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     if( m_pixmap )
294cdf0e10cSrcweir         g_object_ref( m_pixmap );
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 
298cdf0e10cSrcweir NWPixmapCache::NWPixmapCache( int nScreen )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir     m_idx = 0;
301cdf0e10cSrcweir     m_size = 0;
302cdf0e10cSrcweir     m_screen = nScreen;
303cdf0e10cSrcweir     pData = NULL;
304cdf0e10cSrcweir     if( gWidgetData[m_screen].gNWPixmapCacheList )
305cdf0e10cSrcweir         gWidgetData[m_screen].gNWPixmapCacheList->AddCache(this);
306cdf0e10cSrcweir }
307cdf0e10cSrcweir NWPixmapCache::~NWPixmapCache()
308cdf0e10cSrcweir {
309cdf0e10cSrcweir     if( gWidgetData[m_screen].gNWPixmapCacheList )
310cdf0e10cSrcweir         gWidgetData[m_screen].gNWPixmapCacheList->RemoveCache(this);
311cdf0e10cSrcweir     delete[] pData;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir void NWPixmapCache::ThemeChanged()
314cdf0e10cSrcweir {
315cdf0e10cSrcweir     // throw away cached pixmaps
316cdf0e10cSrcweir     int i;
317cdf0e10cSrcweir     for(i=0; i<m_size; i++)
318cdf0e10cSrcweir         pData[i].SetPixmap( NULL );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir sal_Bool  NWPixmapCache::Find( ControlType aType, ControlState aState, const Rectangle& r_pixmapRect, GdkPixmap** pPixmap )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir     aState &= ~CTRL_CACHING_ALLOWED; // mask clipping flag
324cdf0e10cSrcweir     int i;
325cdf0e10cSrcweir     for(i=0; i<m_size; i++)
326cdf0e10cSrcweir     {
327cdf0e10cSrcweir         if( pData[i].m_nType == aType &&
328cdf0e10cSrcweir             pData[i].m_nState == aState &&
329cdf0e10cSrcweir             pData[i].m_pixmapRect.GetWidth() == r_pixmapRect.GetWidth() &&
330cdf0e10cSrcweir             pData[i].m_pixmapRect.GetHeight() == r_pixmapRect.GetHeight() &&
331cdf0e10cSrcweir             pData[i].m_pixmap != NULL )
332cdf0e10cSrcweir         {
333cdf0e10cSrcweir             *pPixmap = pData[i].m_pixmap;
334cdf0e10cSrcweir             return sal_True;
335cdf0e10cSrcweir         }
336cdf0e10cSrcweir     }
337cdf0e10cSrcweir     return sal_False;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir void NWPixmapCache::Fill( ControlType aType, ControlState aState, const Rectangle& r_pixmapRect, GdkPixmap* pPixmap )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir     if( !(aState & CTRL_CACHING_ALLOWED) )
343cdf0e10cSrcweir         return;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir     aState &= ~CTRL_CACHING_ALLOWED; // mask clipping flag
346cdf0e10cSrcweir     m_idx = (m_idx+1) % m_size; // just wrap
347cdf0e10cSrcweir     pData[m_idx].m_nType = aType;
348cdf0e10cSrcweir     pData[m_idx].m_nState = aState;
349cdf0e10cSrcweir     pData[m_idx].m_pixmapRect = r_pixmapRect;
350cdf0e10cSrcweir     pData[m_idx].SetPixmap( pPixmap );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 
354cdf0e10cSrcweir void NWPixmapCacheList::AddCache( NWPixmapCache* pCache )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     mCaches.push_back( pCache );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir void NWPixmapCacheList::RemoveCache( NWPixmapCache* pCache )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir     ::std::vector< NWPixmapCache* >::iterator p;
361cdf0e10cSrcweir     p = ::std::find( mCaches.begin(), mCaches.end(), pCache );
362cdf0e10cSrcweir     if( p != mCaches.end() )
363cdf0e10cSrcweir         mCaches.erase( p );
364cdf0e10cSrcweir }
365cdf0e10cSrcweir void NWPixmapCacheList::ThemeChanged( )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir     ::std::vector< NWPixmapCache* >::iterator p = mCaches.begin();
368cdf0e10cSrcweir     while( p != mCaches.end() )
369cdf0e10cSrcweir     {
370cdf0e10cSrcweir         (*p)->ThemeChanged();
371cdf0e10cSrcweir         p++;
372cdf0e10cSrcweir     }
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 
376cdf0e10cSrcweir /*********************************************************
377cdf0e10cSrcweir  * Make border manipulation easier
378cdf0e10cSrcweir  *********************************************************/
379cdf0e10cSrcweir inline void NW_gtk_border_set_from_border( GtkBorder& aDst, const GtkBorder * pSrc )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir 	aDst.left		= pSrc->left;
382cdf0e10cSrcweir 	aDst.top		= pSrc->top;
383cdf0e10cSrcweir 	aDst.right	= pSrc->right;
384cdf0e10cSrcweir 	aDst.bottom	= pSrc->bottom;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 
388cdf0e10cSrcweir /*********************************************************
389cdf0e10cSrcweir  * Initialize GTK and local stuff
390cdf0e10cSrcweir  *********************************************************/
391cdf0e10cSrcweir void GtkData::initNWF( void )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     // draw no border for popup menus (NWF draws its own)
396cdf0e10cSrcweir     pSVData->maNWFData.mbFlatMenu = true;
397cdf0e10cSrcweir 
398cdf0e10cSrcweir     // draw separate buttons for toolbox dropdown items
399cdf0e10cSrcweir     pSVData->maNWFData.mbToolboxDropDownSeparate = true;
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     // small extra border around menu items
402cdf0e10cSrcweir     pSVData->maNWFData.mnMenuFormatExtraBorder = 1;
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     // draw toolbars in separate lines
405cdf0e10cSrcweir     pSVData->maNWFData.mbDockingAreaSeparateTB = true;
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     // open first menu on F10
408cdf0e10cSrcweir     pSVData->maNWFData.mbOpenMenuOnF10 = true;
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     // omit GetNativeControl while painting (see brdwin.cxx)
411cdf0e10cSrcweir     pSVData->maNWFData.mbCanDrawWidgetAnySize = true;
412cdf0e10cSrcweir 
413cdf0e10cSrcweir     int nScreens = GetX11SalData()->GetDisplay()->GetScreenCount();
414cdf0e10cSrcweir     gWidgetData = std::vector<NWFWidgetData>( nScreens );
415cdf0e10cSrcweir     for( int i = 0; i < nScreens; i++ )
416cdf0e10cSrcweir         gWidgetData[i].gNWPixmapCacheList = new NWPixmapCacheList;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     if( SalGetDesktopEnvironment().equalsAscii( "KDE" ) )
420cdf0e10cSrcweir     {
421cdf0e10cSrcweir         // #i97196# ensure a widget exists and the style engine was loaded
422cdf0e10cSrcweir         NWEnsureGTKButton( 0 );
423cdf0e10cSrcweir         if( g_type_from_name( "QtEngineStyle" ) )
424cdf0e10cSrcweir         {
425cdf0e10cSrcweir             // KDE 3.3 invented a bug in the qt<->gtk theme engine
426cdf0e10cSrcweir             // that makes direct rendering impossible: they totally
427cdf0e10cSrcweir             // ignore the clip rectangle passed to the paint methods
428cdf0e10cSrcweir             GtkSalGraphics::bNeedPixmapPaint = GtkSalGraphics::bGlobalNeedPixmapPaint = true;
429cdf0e10cSrcweir         }
430cdf0e10cSrcweir     }
431cdf0e10cSrcweir     static const char* pEnv = getenv( "SAL_GTK_USE_PIXMAPPAINT" );
432cdf0e10cSrcweir     if( pEnv && *pEnv )
433cdf0e10cSrcweir         GtkSalGraphics::bNeedPixmapPaint = GtkSalGraphics::bGlobalNeedPixmapPaint = true;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir     #if OSL_DEBUG_LEVEL > 1
436cdf0e10cSrcweir     std::fprintf( stderr, "GtkPlugin: using %s NWF\n",
437cdf0e10cSrcweir              GtkSalGraphics::bNeedPixmapPaint ? "offscreen" : "direct" );
438cdf0e10cSrcweir     #endif
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 
442cdf0e10cSrcweir /*********************************************************
443cdf0e10cSrcweir  * Release GTK and local stuff
444cdf0e10cSrcweir  *********************************************************/
445cdf0e10cSrcweir void GtkData::deInitNWF( void )
446cdf0e10cSrcweir {
447cdf0e10cSrcweir 
448cdf0e10cSrcweir     for( unsigned int i = 0; i < gWidgetData.size(); i++ )
449cdf0e10cSrcweir     {
450cdf0e10cSrcweir         // free up global widgets
451cdf0e10cSrcweir         // gtk_widget_destroy will in turn destroy the child hierarchy
452cdf0e10cSrcweir         // so only destroy disjunct hierachies
453cdf0e10cSrcweir         if( gWidgetData[i].gCacheWindow )
454cdf0e10cSrcweir             gtk_widget_destroy( gWidgetData[i].gCacheWindow );
455cdf0e10cSrcweir         if( gWidgetData[i].gMenuWidget )
456cdf0e10cSrcweir             gtk_widget_destroy( gWidgetData[i].gMenuWidget );
457cdf0e10cSrcweir         if( gWidgetData[i].gTooltipPopup )
458cdf0e10cSrcweir             gtk_widget_destroy( gWidgetData[i].gTooltipPopup );
459cdf0e10cSrcweir         delete gWidgetData[i].gCacheTabPages;
460cdf0e10cSrcweir         gWidgetData[i].gCacheTabPages = NULL;
461cdf0e10cSrcweir         delete gWidgetData[i].gCacheTabItems;
462cdf0e10cSrcweir         gWidgetData[i].gCacheTabItems = NULL;
463cdf0e10cSrcweir         delete gWidgetData[i].gNWPixmapCacheList;
464cdf0e10cSrcweir         gWidgetData[i].gNWPixmapCacheList = NULL;
465cdf0e10cSrcweir     }
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 
469cdf0e10cSrcweir /**********************************************************
470cdf0e10cSrcweir  * track clip region
471cdf0e10cSrcweir  **********************************************************/
472cdf0e10cSrcweir void GtkSalGraphics::ResetClipRegion()
473cdf0e10cSrcweir {
474cdf0e10cSrcweir     m_aClipRegion.SetNull();
475cdf0e10cSrcweir     X11SalGraphics::ResetClipRegion();
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir bool GtkSalGraphics::setClipRegion( const Region& i_rClip )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir     m_aClipRegion = i_rClip;
481cdf0e10cSrcweir     bool bRet = X11SalGraphics::setClipRegion( m_aClipRegion );
482cdf0e10cSrcweir     if( m_aClipRegion.IsEmpty() )
483cdf0e10cSrcweir         m_aClipRegion.SetNull();
484cdf0e10cSrcweir     return bRet;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir void GtkSalGraphics::copyBits( const SalTwoRect* pPosAry,
488cdf0e10cSrcweir                                SalGraphics* pSrcGraphics )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir     GtkSalFrame* pFrame = GetGtkFrame();
491cdf0e10cSrcweir     XLIB_Window aWin = None;
492cdf0e10cSrcweir     if( pFrame && m_pWindow )
493cdf0e10cSrcweir     {
494cdf0e10cSrcweir         /* #i64117# some themes set the background pixmap VERY frequently */
495cdf0e10cSrcweir         GdkWindow* pWin = GTK_WIDGET(m_pWindow)->window;
496cdf0e10cSrcweir         if( pWin )
497cdf0e10cSrcweir         {
498cdf0e10cSrcweir             aWin = GDK_WINDOW_XWINDOW(pWin);
499cdf0e10cSrcweir             if( aWin != None )
500cdf0e10cSrcweir                 XSetWindowBackgroundPixmap( pFrame->getDisplay()->GetDisplay(),
501cdf0e10cSrcweir                                             aWin,
502cdf0e10cSrcweir                                             None );
503cdf0e10cSrcweir         }
504cdf0e10cSrcweir     }
505cdf0e10cSrcweir     X11SalGraphics::copyBits( pPosAry, pSrcGraphics );
506cdf0e10cSrcweir     if( pFrame && pFrame->getBackgroundPixmap() != None )
507cdf0e10cSrcweir         XSetWindowBackgroundPixmap( pFrame->getDisplay()->GetDisplay(),
508cdf0e10cSrcweir                                     aWin,
509cdf0e10cSrcweir                                     pFrame->getBackgroundPixmap() );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir /*
513cdf0e10cSrcweir  * IsNativeControlSupported()
514cdf0e10cSrcweir  *
515cdf0e10cSrcweir  *  Returns sal_True if the platform supports native
516cdf0e10cSrcweir  *  drawing of the control defined by nPart
517cdf0e10cSrcweir  */
518cdf0e10cSrcweir sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir 	if (
521cdf0e10cSrcweir 		((nType==CTRL_PUSHBUTTON)  && (nPart==PART_ENTIRE_CONTROL)) 	||
522cdf0e10cSrcweir  		((nType==CTRL_RADIOBUTTON) && (nPart==PART_ENTIRE_CONTROL))		||
523cdf0e10cSrcweir 		((nType==CTRL_CHECKBOX)    && (nPart==PART_ENTIRE_CONTROL))		||
524cdf0e10cSrcweir 		((nType==CTRL_SCROLLBAR) &&
525cdf0e10cSrcweir 				(  (nPart==PART_DRAW_BACKGROUND_HORZ)
526cdf0e10cSrcweir 				|| (nPart==PART_DRAW_BACKGROUND_VERT)
527cdf0e10cSrcweir 				|| (nPart==PART_ENTIRE_CONTROL)
528cdf0e10cSrcweir                 || (nPart==HAS_THREE_BUTTONS) )  				)	||
529cdf0e10cSrcweir 		((nType==CTRL_EDITBOX) &&
530cdf0e10cSrcweir 				(  (nPart==PART_ENTIRE_CONTROL)
531cdf0e10cSrcweir 				|| (nPart==HAS_BACKGROUND_TEXTURE) ) 			)	||
532cdf0e10cSrcweir 		((nType==CTRL_MULTILINE_EDITBOX) &&
533cdf0e10cSrcweir 				(  (nPart==PART_ENTIRE_CONTROL)
534cdf0e10cSrcweir 				|| (nPart==HAS_BACKGROUND_TEXTURE) ) 			)	||
535cdf0e10cSrcweir 		((nType==CTRL_SPINBOX) &&
536cdf0e10cSrcweir 				(  (nPart==PART_ENTIRE_CONTROL)
537cdf0e10cSrcweir 				|| (nPart==PART_ALL_BUTTONS)
538cdf0e10cSrcweir 				|| (nPart==HAS_BACKGROUND_TEXTURE) )			)	||
539cdf0e10cSrcweir 		((nType==CTRL_SPINBUTTONS) &&
540cdf0e10cSrcweir 				(  (nPart==PART_ENTIRE_CONTROL)
541cdf0e10cSrcweir 				|| (nPart==PART_ALL_BUTTONS)	)				)	||
542cdf0e10cSrcweir 		((nType==CTRL_COMBOBOX) &&
543cdf0e10cSrcweir 				(  (nPart==PART_ENTIRE_CONTROL)
544cdf0e10cSrcweir 				|| (nPart==HAS_BACKGROUND_TEXTURE)	)			)	||
545cdf0e10cSrcweir 		(((nType==CTRL_TAB_ITEM) || (nType==CTRL_TAB_PANE) ||
546cdf0e10cSrcweir 		  (nType==CTRL_TAB_BODY) || (nType==CTRL_FIXEDBORDER)) &&
547cdf0e10cSrcweir 				(  (nPart==PART_ENTIRE_CONTROL)
548cdf0e10cSrcweir 				|| (nPart==PART_TABS_DRAW_RTL) )				)	||
549cdf0e10cSrcweir 		((nType==CTRL_LISTBOX) &&
550cdf0e10cSrcweir 				(  (nPart==PART_ENTIRE_CONTROL)
551cdf0e10cSrcweir 				|| (nPart==PART_WINDOW)
552cdf0e10cSrcweir 				|| (nPart==HAS_BACKGROUND_TEXTURE) )			)   ||
553cdf0e10cSrcweir         ((nType == CTRL_TOOLBAR) &&
554cdf0e10cSrcweir          		(	(nPart==PART_ENTIRE_CONTROL)
555cdf0e10cSrcweir                 ||  (nPart==PART_DRAW_BACKGROUND_HORZ)
556cdf0e10cSrcweir                 ||  (nPart==PART_DRAW_BACKGROUND_VERT)
557cdf0e10cSrcweir                 ||  (nPart==PART_THUMB_HORZ)
558cdf0e10cSrcweir                 ||  (nPart==PART_THUMB_VERT)
559cdf0e10cSrcweir                 ||  (nPart==PART_BUTTON)
560cdf0e10cSrcweir                 )
561cdf0e10cSrcweir                                                                 )   ||
562cdf0e10cSrcweir         ((nType == CTRL_MENUBAR) &&
563cdf0e10cSrcweir                 (   (nPart==PART_ENTIRE_CONTROL) )              )   ||
564cdf0e10cSrcweir         ((nType == CTRL_TOOLTIP) &&
565cdf0e10cSrcweir                 (   (nPart==PART_ENTIRE_CONTROL) )              )   ||
566cdf0e10cSrcweir         ((nType == CTRL_MENU_POPUP) &&
567cdf0e10cSrcweir                 (   (nPart==PART_ENTIRE_CONTROL)
568cdf0e10cSrcweir                 ||  (nPart==PART_MENU_ITEM)
569cdf0e10cSrcweir                 ||  (nPart==PART_MENU_ITEM_CHECK_MARK)
570cdf0e10cSrcweir                 ||  (nPart==PART_MENU_ITEM_RADIO_MARK)
571cdf0e10cSrcweir                 )
572cdf0e10cSrcweir                                                                 )   ||
573cdf0e10cSrcweir         ((nType == CTRL_PROGRESS) &&
574cdf0e10cSrcweir                 (   (nPart == PART_ENTIRE_CONTROL) )
575cdf0e10cSrcweir                 )                                                   ||
576cdf0e10cSrcweir         ((nType == CTRL_LISTNODE || nType == CTRL_LISTNET) &&
577cdf0e10cSrcweir                 (   (nPart == PART_ENTIRE_CONTROL) )
578cdf0e10cSrcweir                 )                                                   ||
579cdf0e10cSrcweir         ((nType == CTRL_SLIDER) &&
580cdf0e10cSrcweir                 (   (nPart == PART_TRACK_HORZ_AREA)
581cdf0e10cSrcweir                 ||  (nPart == PART_TRACK_VERT_AREA)
582cdf0e10cSrcweir                 )
583cdf0e10cSrcweir         )
584cdf0e10cSrcweir         )
585cdf0e10cSrcweir 		return( sal_True );
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 	return( sal_False );
588cdf0e10cSrcweir }
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 
591cdf0e10cSrcweir /*
592cdf0e10cSrcweir  * HitTestNativeControl()
593cdf0e10cSrcweir  *
594cdf0e10cSrcweir  *  bIsInside is set to sal_True if aPos is contained within the
595cdf0e10cSrcweir  *  given part of the control, whose bounding region is
596cdf0e10cSrcweir  *  given by rControlRegion (in VCL frame coordinates).
597cdf0e10cSrcweir  *
598cdf0e10cSrcweir  *  returns whether bIsInside was really set.
599cdf0e10cSrcweir  */
600cdf0e10cSrcweir sal_Bool GtkSalGraphics::hitTestNativeControl( ControlType		nType,
601cdf0e10cSrcweir 								ControlPart		nPart,
602cdf0e10cSrcweir 								const Rectangle&		rControlRegion,
603cdf0e10cSrcweir 								const Point&		aPos,
604cdf0e10cSrcweir 								sal_Bool&			rIsInside )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir     if ( ( nType == CTRL_SCROLLBAR ) &&
607cdf0e10cSrcweir          ( ( nPart == PART_BUTTON_UP ) ||
608cdf0e10cSrcweir            ( nPart == PART_BUTTON_DOWN ) ||
609cdf0e10cSrcweir            ( nPart == PART_BUTTON_LEFT ) ||
610cdf0e10cSrcweir            ( nPart == PART_BUTTON_RIGHT ) ) )
611cdf0e10cSrcweir     {
612cdf0e10cSrcweir         NWEnsureGTKScrollbars( m_nScreen );
613cdf0e10cSrcweir 
614cdf0e10cSrcweir         // Grab some button style attributes
615cdf0e10cSrcweir         gboolean has_forward;
616cdf0e10cSrcweir         gboolean has_forward2;
617cdf0e10cSrcweir         gboolean has_backward;
618cdf0e10cSrcweir         gboolean has_backward2;
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 	    gtk_widget_style_get( gWidgetData[m_nScreen].gScrollHorizWidget, "has-forward-stepper", &has_forward,
621cdf0e10cSrcweir 									    "has-secondary-forward-stepper", &has_forward2,
622cdf0e10cSrcweir 									    "has-backward-stepper", &has_backward,
623cdf0e10cSrcweir 	   								    "has-secondary-backward-stepper", &has_backward2, (char *)NULL );
624cdf0e10cSrcweir         Rectangle aForward;
625cdf0e10cSrcweir         Rectangle aBackward;
626cdf0e10cSrcweir 
627cdf0e10cSrcweir         rIsInside = sal_False;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir         ControlPart nCounterPart = 0;
630cdf0e10cSrcweir         if ( nPart == PART_BUTTON_UP )
631cdf0e10cSrcweir             nCounterPart = PART_BUTTON_DOWN;
632cdf0e10cSrcweir         else if ( nPart == PART_BUTTON_DOWN )
633cdf0e10cSrcweir             nCounterPart = PART_BUTTON_UP;
634cdf0e10cSrcweir         else if ( nPart == PART_BUTTON_LEFT )
635cdf0e10cSrcweir             nCounterPart = PART_BUTTON_RIGHT;
636cdf0e10cSrcweir         else if ( nPart == PART_BUTTON_RIGHT )
637cdf0e10cSrcweir             nCounterPart = PART_BUTTON_LEFT;
638cdf0e10cSrcweir 
639cdf0e10cSrcweir         aBackward = NWGetScrollButtonRect( m_nScreen, nPart, rControlRegion );
640cdf0e10cSrcweir         aForward = NWGetScrollButtonRect( m_nScreen, nCounterPart, rControlRegion );
641cdf0e10cSrcweir 
642cdf0e10cSrcweir         if ( has_backward && has_forward2 )
643cdf0e10cSrcweir         {
644cdf0e10cSrcweir             Size aSize( aBackward.GetSize() );
645cdf0e10cSrcweir             if ( ( nPart == PART_BUTTON_UP ) || ( nPart == PART_BUTTON_DOWN ) )
646cdf0e10cSrcweir                 aSize.setHeight( aBackward.GetHeight() / 2 );
647cdf0e10cSrcweir             else
648cdf0e10cSrcweir                 aSize.setWidth( aBackward.GetWidth() / 2 );
649cdf0e10cSrcweir             aBackward.SetSize( aSize );
650cdf0e10cSrcweir 
651cdf0e10cSrcweir             if ( nPart == PART_BUTTON_DOWN )
652cdf0e10cSrcweir                 aBackward.Move( 0, aBackward.GetHeight() / 2 );
653cdf0e10cSrcweir             else if ( nPart == PART_BUTTON_RIGHT )
654cdf0e10cSrcweir                 aBackward.Move( aBackward.GetWidth() / 2, 0 );
655cdf0e10cSrcweir         }
656cdf0e10cSrcweir 
657cdf0e10cSrcweir         if ( has_backward2 && has_forward )
658cdf0e10cSrcweir         {
659cdf0e10cSrcweir             Size aSize( aForward.GetSize() );
660cdf0e10cSrcweir             if ( ( nPart == PART_BUTTON_UP ) || ( nPart == PART_BUTTON_DOWN ) )
661cdf0e10cSrcweir                 aSize.setHeight( aForward.GetHeight() / 2 );
662cdf0e10cSrcweir             else
663cdf0e10cSrcweir                 aSize.setWidth( aForward.GetWidth() / 2 );
664cdf0e10cSrcweir             aForward.SetSize( aSize );
665cdf0e10cSrcweir 
666cdf0e10cSrcweir             if ( nPart == PART_BUTTON_DOWN )
667cdf0e10cSrcweir                 aForward.Move( 0, aForward.GetHeight() / 2 );
668cdf0e10cSrcweir             else if ( nPart == PART_BUTTON_RIGHT )
669cdf0e10cSrcweir                 aForward.Move( aForward.GetWidth() / 2, 0 );
670cdf0e10cSrcweir         }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir         if ( ( nPart == PART_BUTTON_UP ) || ( nPart == PART_BUTTON_LEFT ) )
673cdf0e10cSrcweir         {
674cdf0e10cSrcweir             if ( has_backward )
675cdf0e10cSrcweir                 rIsInside |= aBackward.IsInside( aPos );
676cdf0e10cSrcweir             if ( has_backward2 )
677cdf0e10cSrcweir                 rIsInside |= aForward.IsInside( aPos );
678cdf0e10cSrcweir         }
679cdf0e10cSrcweir         else
680cdf0e10cSrcweir         {
681cdf0e10cSrcweir             if ( has_forward )
682cdf0e10cSrcweir                 rIsInside |= aBackward.IsInside( aPos );
683cdf0e10cSrcweir             if ( has_forward2 )
684cdf0e10cSrcweir                 rIsInside |= aForward.IsInside( aPos );
685cdf0e10cSrcweir         }
686cdf0e10cSrcweir         return ( sal_True );
687cdf0e10cSrcweir     }
688cdf0e10cSrcweir 
689cdf0e10cSrcweir     if( IsNativeControlSupported(nType, nPart) )
690cdf0e10cSrcweir 	{
691cdf0e10cSrcweir 		rIsInside = rControlRegion.IsInside( aPos );
692cdf0e10cSrcweir 		return( sal_True );
693cdf0e10cSrcweir 	}
694cdf0e10cSrcweir 	else
695cdf0e10cSrcweir 	{
696cdf0e10cSrcweir 		return( sal_False );
697cdf0e10cSrcweir 	}
698cdf0e10cSrcweir }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 
701cdf0e10cSrcweir /*
702cdf0e10cSrcweir  * DrawNativeControl()
703cdf0e10cSrcweir  *
704cdf0e10cSrcweir  *  Draws the requested control described by nPart/nState.
705cdf0e10cSrcweir  *
706cdf0e10cSrcweir  *  rControlRegion:	The bounding region of the complete control in VCL frame coordinates.
707cdf0e10cSrcweir  *  aValue:  		An optional value (tristate/numerical/string)
708cdf0e10cSrcweir  *  rCaption:  	A caption or title string (like button text etc)
709cdf0e10cSrcweir  */
710cdf0e10cSrcweir sal_Bool GtkSalGraphics::drawNativeControl(	ControlType nType,
711cdf0e10cSrcweir 							ControlPart nPart,
712cdf0e10cSrcweir 							const Rectangle& rControlRegion,
713cdf0e10cSrcweir 							ControlState nState,
714cdf0e10cSrcweir 							const ImplControlValue& aValue,
715cdf0e10cSrcweir 							const OUString& rCaption )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir 	sal_Bool			returnVal = sal_False;
718cdf0e10cSrcweir 	// get a GC with current clipping region set
719cdf0e10cSrcweir     GetFontGC();
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 
722cdf0e10cSrcweir     // theme changed ?
723cdf0e10cSrcweir     if( GtkSalGraphics::bThemeChanged )
724cdf0e10cSrcweir     {
725cdf0e10cSrcweir         // invalidate caches
726cdf0e10cSrcweir         for( unsigned int i = 0; i < gWidgetData.size(); i++ )
727cdf0e10cSrcweir             if( gWidgetData[i].gNWPixmapCacheList )
728cdf0e10cSrcweir                 gWidgetData[i].gNWPixmapCacheList->ThemeChanged();
729cdf0e10cSrcweir         GtkSalGraphics::bThemeChanged = sal_False;
730cdf0e10cSrcweir     }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     Rectangle aCtrlRect( rControlRegion );
733cdf0e10cSrcweir     Region aClipRegion( m_aClipRegion );
734cdf0e10cSrcweir     if( aClipRegion.IsNull() )
735cdf0e10cSrcweir         aClipRegion = aCtrlRect;
736cdf0e10cSrcweir 
737cdf0e10cSrcweir     clipList aClip;
738cdf0e10cSrcweir     GdkDrawable* gdkDrawable = GDK_DRAWABLE( GetGdkWindow() );
739cdf0e10cSrcweir     GdkPixmap* pixmap = NULL;
740cdf0e10cSrcweir     Rectangle aPixmapRect;
741cdf0e10cSrcweir     if( ( bNeedPixmapPaint )
742cdf0e10cSrcweir         && nType != CTRL_SCROLLBAR
743cdf0e10cSrcweir         && nType != CTRL_SPINBOX
744cdf0e10cSrcweir         && nType != CTRL_TAB_ITEM
745cdf0e10cSrcweir         && nType != CTRL_TAB_PANE
746cdf0e10cSrcweir         && nType != CTRL_PROGRESS
747cdf0e10cSrcweir         && ! (bToolbarGripWorkaround && nType == CTRL_TOOLBAR && (nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT) )
748cdf0e10cSrcweir         )
749cdf0e10cSrcweir     {
750cdf0e10cSrcweir         // make pixmap a little larger since some themes draw decoration
751cdf0e10cSrcweir         // outside the rectangle, see e.g. checkbox
752cdf0e10cSrcweir         aPixmapRect = Rectangle( Point( aCtrlRect.Left()-1, aCtrlRect.Top()-1 ),
753cdf0e10cSrcweir                                  Size( aCtrlRect.GetWidth()+2, aCtrlRect.GetHeight()+2) );
754cdf0e10cSrcweir         pixmap = NWGetPixmapFromScreen( aPixmapRect );
755cdf0e10cSrcweir         if( ! pixmap )
756cdf0e10cSrcweir             return sal_False;
757cdf0e10cSrcweir         gdkDrawable = GDK_DRAWABLE( pixmap );
758cdf0e10cSrcweir         aCtrlRect = Rectangle( Point(1,1), aCtrlRect.GetSize() );
759cdf0e10cSrcweir         aClip.push_back( aCtrlRect );
760cdf0e10cSrcweir     }
761cdf0e10cSrcweir     else
762cdf0e10cSrcweir     {
763cdf0e10cSrcweir         RegionHandle aHdl = aClipRegion.BeginEnumRects();
764cdf0e10cSrcweir         Rectangle aPaintRect;
765cdf0e10cSrcweir         while( aClipRegion.GetNextEnumRect( aHdl, aPaintRect ) )
766cdf0e10cSrcweir         {
767cdf0e10cSrcweir             aPaintRect = aCtrlRect.GetIntersection( aPaintRect );
768cdf0e10cSrcweir             if( aPaintRect.IsEmpty() )
769cdf0e10cSrcweir                 continue;
770cdf0e10cSrcweir             aClip.push_back( aPaintRect );
771cdf0e10cSrcweir         }
772cdf0e10cSrcweir         aClipRegion.EndEnumRects( aHdl );
773cdf0e10cSrcweir     }
774cdf0e10cSrcweir 
775cdf0e10cSrcweir     if ( (nType==CTRL_PUSHBUTTON) && (nPart==PART_ENTIRE_CONTROL) )
776cdf0e10cSrcweir     {
777cdf0e10cSrcweir         returnVal = NWPaintGTKButton( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
778cdf0e10cSrcweir     }
779cdf0e10cSrcweir     else if ( (nType==CTRL_RADIOBUTTON) && (nPart==PART_ENTIRE_CONTROL) )
780cdf0e10cSrcweir     {
781cdf0e10cSrcweir         returnVal = NWPaintGTKRadio( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
782cdf0e10cSrcweir     }
783cdf0e10cSrcweir     else if ( (nType==CTRL_CHECKBOX) && (nPart==PART_ENTIRE_CONTROL) )
784cdf0e10cSrcweir     {
785cdf0e10cSrcweir         returnVal = NWPaintGTKCheck( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
786cdf0e10cSrcweir     }
787cdf0e10cSrcweir     else if ( (nType==CTRL_SCROLLBAR) && ((nPart==PART_DRAW_BACKGROUND_HORZ) || (nPart==PART_DRAW_BACKGROUND_VERT)) )
788cdf0e10cSrcweir     {
789cdf0e10cSrcweir         returnVal = NWPaintGTKScrollbar( nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
790cdf0e10cSrcweir     }
791cdf0e10cSrcweir     else if ( ((nType==CTRL_EDITBOX) && ((nPart==PART_ENTIRE_CONTROL) || (nPart==HAS_BACKGROUND_TEXTURE)) )
792cdf0e10cSrcweir         || ((nType==CTRL_SPINBOX) && (nPart==HAS_BACKGROUND_TEXTURE))
793cdf0e10cSrcweir     || ((nType==CTRL_COMBOBOX) && (nPart==HAS_BACKGROUND_TEXTURE))
794cdf0e10cSrcweir     || ((nType==CTRL_LISTBOX) && (nPart==HAS_BACKGROUND_TEXTURE)) )
795cdf0e10cSrcweir     {
796cdf0e10cSrcweir         returnVal = NWPaintGTKEditBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
797cdf0e10cSrcweir     }
798cdf0e10cSrcweir     else if ( ((nType==CTRL_MULTILINE_EDITBOX) && ((nPart==PART_ENTIRE_CONTROL) || (nPart==HAS_BACKGROUND_TEXTURE)) ) )
799cdf0e10cSrcweir     {
800cdf0e10cSrcweir         returnVal = NWPaintGTKEditBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
801cdf0e10cSrcweir     }
802cdf0e10cSrcweir     else if ( ((nType==CTRL_SPINBOX) || (nType==CTRL_SPINBUTTONS))
803cdf0e10cSrcweir         && ((nPart==PART_ENTIRE_CONTROL) || (nPart==PART_ALL_BUTTONS)) )
804cdf0e10cSrcweir     {
805cdf0e10cSrcweir         returnVal = NWPaintGTKSpinBox( nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
806cdf0e10cSrcweir     }
807cdf0e10cSrcweir     else if ( (nType == CTRL_COMBOBOX) &&
808cdf0e10cSrcweir         ( (nPart==PART_ENTIRE_CONTROL)
809cdf0e10cSrcweir         ||(nPart==PART_BUTTON_DOWN)
810cdf0e10cSrcweir         ) )
811cdf0e10cSrcweir     {
812cdf0e10cSrcweir         returnVal = NWPaintGTKComboBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
813cdf0e10cSrcweir     }
814cdf0e10cSrcweir     else if ( (nType==CTRL_TAB_ITEM) || (nType==CTRL_TAB_PANE) || (nType==CTRL_TAB_BODY) || (nType==CTRL_FIXEDBORDER) )
815cdf0e10cSrcweir     {
816cdf0e10cSrcweir         if ( nType == CTRL_TAB_BODY )
817cdf0e10cSrcweir             returnVal = sal_True;
818cdf0e10cSrcweir         else
819cdf0e10cSrcweir             returnVal = NWPaintGTKTabItem( nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption);
820cdf0e10cSrcweir     }
821cdf0e10cSrcweir     else if ( (nType==CTRL_LISTBOX) && ((nPart==PART_ENTIRE_CONTROL) || (nPart==PART_WINDOW)) )
822cdf0e10cSrcweir     {
823cdf0e10cSrcweir         returnVal = NWPaintGTKListBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
824cdf0e10cSrcweir     }
825cdf0e10cSrcweir     else if ( (nType== CTRL_TOOLBAR) )
826cdf0e10cSrcweir     {
827cdf0e10cSrcweir         returnVal = NWPaintGTKToolbar( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
828cdf0e10cSrcweir     }
829cdf0e10cSrcweir     else if ( (nType== CTRL_MENUBAR) )
830cdf0e10cSrcweir     {
831cdf0e10cSrcweir         returnVal = NWPaintGTKMenubar( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
832cdf0e10cSrcweir     }
833cdf0e10cSrcweir     else if(    (nType == CTRL_MENU_POPUP)
834cdf0e10cSrcweir         && (  (nPart == PART_ENTIRE_CONTROL)
835cdf0e10cSrcweir     || (nPart == PART_MENU_ITEM)
836cdf0e10cSrcweir     || (nPart == PART_MENU_ITEM_CHECK_MARK)
837cdf0e10cSrcweir     || (nPart == PART_MENU_ITEM_RADIO_MARK)
838cdf0e10cSrcweir     )
839cdf0e10cSrcweir     )
840cdf0e10cSrcweir     {
841cdf0e10cSrcweir         returnVal = NWPaintGTKPopupMenu( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
842cdf0e10cSrcweir     }
843cdf0e10cSrcweir     else if( (nType == CTRL_TOOLTIP) && (nPart == PART_ENTIRE_CONTROL) )
844cdf0e10cSrcweir     {
845cdf0e10cSrcweir         returnVal = NWPaintGTKTooltip( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
846cdf0e10cSrcweir     }
847cdf0e10cSrcweir     else if( (nType == CTRL_PROGRESS) && (nPart == PART_ENTIRE_CONTROL) )
848cdf0e10cSrcweir     {
849cdf0e10cSrcweir         returnVal = NWPaintGTKProgress( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
850cdf0e10cSrcweir     }
851cdf0e10cSrcweir     else if( (nType == CTRL_LISTNODE) && (nPart == PART_ENTIRE_CONTROL) )
852cdf0e10cSrcweir     {
853cdf0e10cSrcweir         returnVal = NWPaintGTKListNode( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
854cdf0e10cSrcweir     }
855cdf0e10cSrcweir     else if( (nType == CTRL_LISTNET) && (nPart == PART_ENTIRE_CONTROL) )
856cdf0e10cSrcweir     {
857cdf0e10cSrcweir         // don't actually draw anything; gtk treeviews do not draw lines
858cdf0e10cSrcweir         returnVal = true;
859cdf0e10cSrcweir     }
860cdf0e10cSrcweir     else if( (nType == CTRL_SLIDER) )
861cdf0e10cSrcweir     {
862cdf0e10cSrcweir         returnVal = NWPaintGTKSlider( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
863cdf0e10cSrcweir     }
864cdf0e10cSrcweir 
865cdf0e10cSrcweir     if( pixmap )
866cdf0e10cSrcweir     {
867cdf0e10cSrcweir         returnVal = NWRenderPixmapToScreen( pixmap, aPixmapRect ) && returnVal;
868cdf0e10cSrcweir         g_object_unref( pixmap );
869cdf0e10cSrcweir     }
870cdf0e10cSrcweir 
871cdf0e10cSrcweir 	return( returnVal );
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir /*
875cdf0e10cSrcweir  * DrawNativeControlText()
876cdf0e10cSrcweir  *
877cdf0e10cSrcweir  *  OPTIONAL.  Draws the requested text for the control described by nPart/nState.
878cdf0e10cSrcweir  *     Used if text not drawn by DrawNativeControl().
879cdf0e10cSrcweir  *
880cdf0e10cSrcweir  *  rControlRegion:	The bounding region of the complete control in VCL frame coordinates.
881cdf0e10cSrcweir  *  aValue:  		An optional value (tristate/numerical/string)
882cdf0e10cSrcweir  *  rCaption:  	A caption or title string (like button text etc)
883cdf0e10cSrcweir  */
884cdf0e10cSrcweir sal_Bool GtkSalGraphics::drawNativeControlText(	ControlType,
885cdf0e10cSrcweir 								ControlPart,
886cdf0e10cSrcweir 								const Rectangle&,
887cdf0e10cSrcweir 								ControlState,
888cdf0e10cSrcweir 								const ImplControlValue&,
889cdf0e10cSrcweir 								const OUString& )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir 	return( sal_False );
892cdf0e10cSrcweir }
893cdf0e10cSrcweir 
894cdf0e10cSrcweir 
895cdf0e10cSrcweir /*
896cdf0e10cSrcweir  * GetNativeControlRegion()
897cdf0e10cSrcweir  *
898cdf0e10cSrcweir  *  If the return value is sal_True, rNativeBoundingRegion
899cdf0e10cSrcweir  *  contains the true bounding region covered by the control
900cdf0e10cSrcweir  *  including any adornment, while rNativeContentRegion contains the area
901cdf0e10cSrcweir  *  within the control that can be safely drawn into without drawing over
902cdf0e10cSrcweir  *  the borders of the control.
903cdf0e10cSrcweir  *
904cdf0e10cSrcweir  *  rControlRegion:	The bounding region of the control in VCL frame coordinates.
905cdf0e10cSrcweir  *  aValue:		An optional value (tristate/numerical/string)
906cdf0e10cSrcweir  *  rCaption:		A caption or title string (like button text etc)
907cdf0e10cSrcweir  */
908cdf0e10cSrcweir sal_Bool GtkSalGraphics::getNativeControlRegion(  ControlType nType,
909cdf0e10cSrcweir 								ControlPart nPart,
910cdf0e10cSrcweir 								const Rectangle& rControlRegion,
911cdf0e10cSrcweir 								ControlState nState,
912cdf0e10cSrcweir 								const ImplControlValue& aValue,
913cdf0e10cSrcweir 								const OUString& rCaption,
914cdf0e10cSrcweir 								Rectangle &rNativeBoundingRegion,
915cdf0e10cSrcweir 								Rectangle &rNativeContentRegion )
916cdf0e10cSrcweir {
917cdf0e10cSrcweir 	sal_Bool returnVal = sal_False;
918cdf0e10cSrcweir 
919cdf0e10cSrcweir     if ( (nType==CTRL_PUSHBUTTON) && (nPart==PART_ENTIRE_CONTROL)
920cdf0e10cSrcweir         && (rControlRegion.GetWidth() > 16)
921cdf0e10cSrcweir     && (rControlRegion.GetHeight() > 16) )
922cdf0e10cSrcweir     {
923cdf0e10cSrcweir         rNativeBoundingRegion = NWGetButtonArea( m_nScreen, nType, nPart, rControlRegion,
924cdf0e10cSrcweir         nState, aValue, rCaption );
925cdf0e10cSrcweir         rNativeContentRegion = rControlRegion;
926cdf0e10cSrcweir 
927cdf0e10cSrcweir         returnVal = sal_True;
928cdf0e10cSrcweir     }
929cdf0e10cSrcweir     if ( (nType==CTRL_COMBOBOX) && ((nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) )
930cdf0e10cSrcweir     {
931cdf0e10cSrcweir         rNativeBoundingRegion = NWGetComboBoxButtonRect( m_nScreen, nType, nPart, rControlRegion, nState,
932cdf0e10cSrcweir         aValue, rCaption );
933cdf0e10cSrcweir         rNativeContentRegion = rNativeBoundingRegion;
934cdf0e10cSrcweir 
935cdf0e10cSrcweir         returnVal = sal_True;
936cdf0e10cSrcweir     }
937cdf0e10cSrcweir     if ( (nType==CTRL_SPINBOX) && ((nPart==PART_BUTTON_UP) || (nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) )
938cdf0e10cSrcweir     {
939cdf0e10cSrcweir 
940cdf0e10cSrcweir         rNativeBoundingRegion = NWGetSpinButtonRect( m_nScreen, nType, nPart, rControlRegion, nState,
941cdf0e10cSrcweir         aValue, rCaption );
942cdf0e10cSrcweir         rNativeContentRegion = rNativeBoundingRegion;
943cdf0e10cSrcweir 
944cdf0e10cSrcweir         returnVal = sal_True;
945cdf0e10cSrcweir     }
946cdf0e10cSrcweir     if ( (nType==CTRL_LISTBOX) && ((nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) )
947cdf0e10cSrcweir     {
948cdf0e10cSrcweir         rNativeBoundingRegion = NWGetListBoxButtonRect( m_nScreen, nType, nPart, rControlRegion, nState,
949cdf0e10cSrcweir         aValue, rCaption );
950cdf0e10cSrcweir         rNativeContentRegion = rNativeBoundingRegion;
951cdf0e10cSrcweir 
952cdf0e10cSrcweir         returnVal = sal_True;
953cdf0e10cSrcweir     }
954cdf0e10cSrcweir     if ( (nType==CTRL_TOOLBAR) &&
955cdf0e10cSrcweir         ((nPart==PART_DRAW_BACKGROUND_HORZ)	||
956cdf0e10cSrcweir         (nPart==PART_DRAW_BACKGROUND_VERT)	||
957cdf0e10cSrcweir         (nPart==PART_THUMB_HORZ)			||
958cdf0e10cSrcweir         (nPart==PART_THUMB_VERT)            ||
959cdf0e10cSrcweir         (nPart==PART_BUTTON)
960cdf0e10cSrcweir         ))
961cdf0e10cSrcweir     {
962cdf0e10cSrcweir         rNativeBoundingRegion = NWGetToolbarRect( m_nScreen, nType, nPart, rControlRegion, nState, aValue, rCaption );
963cdf0e10cSrcweir         rNativeContentRegion = rNativeBoundingRegion;
964cdf0e10cSrcweir         returnVal = sal_True;
965cdf0e10cSrcweir     }
966cdf0e10cSrcweir     if ( (nType==CTRL_SCROLLBAR) && ((nPart==PART_BUTTON_LEFT) || (nPart==PART_BUTTON_RIGHT) ||
967cdf0e10cSrcweir         (nPart==PART_BUTTON_UP) || (nPart==PART_BUTTON_DOWN)  ) )
968cdf0e10cSrcweir     {
969cdf0e10cSrcweir         rNativeBoundingRegion = NWGetScrollButtonRect( m_nScreen, nPart, rControlRegion );
970cdf0e10cSrcweir         rNativeContentRegion = rNativeBoundingRegion;
971cdf0e10cSrcweir 
972cdf0e10cSrcweir         returnVal = sal_True;
973cdf0e10cSrcweir     }
974cdf0e10cSrcweir     if( (nType == CTRL_MENUBAR) && (nPart == PART_ENTIRE_CONTROL) )
975cdf0e10cSrcweir     {
976cdf0e10cSrcweir         NWEnsureGTKMenubar( m_nScreen );
977cdf0e10cSrcweir         GtkRequisition aReq;
978cdf0e10cSrcweir         gtk_widget_size_request( gWidgetData[m_nScreen].gMenubarWidget, &aReq );
979cdf0e10cSrcweir         Rectangle aMenuBarRect = rControlRegion;
980cdf0e10cSrcweir         aMenuBarRect = Rectangle( aMenuBarRect.TopLeft(),
981cdf0e10cSrcweir                                   Size( aMenuBarRect.GetWidth(), aReq.height+1 ) );
982cdf0e10cSrcweir         rNativeBoundingRegion = aMenuBarRect;
983cdf0e10cSrcweir         rNativeContentRegion = rNativeBoundingRegion;
984cdf0e10cSrcweir         returnVal = sal_True;
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir     if( (nType == CTRL_MENU_POPUP) )
987cdf0e10cSrcweir     {
988cdf0e10cSrcweir         if( (nPart == PART_MENU_ITEM_CHECK_MARK) ||
989cdf0e10cSrcweir             (nPart == PART_MENU_ITEM_RADIO_MARK) )
990cdf0e10cSrcweir         {
991cdf0e10cSrcweir             NWEnsureGTKMenu( m_nScreen );
992cdf0e10cSrcweir 
993cdf0e10cSrcweir             gint indicator_size = 0;
994cdf0e10cSrcweir             GtkWidget* pWidget = (nPart == PART_MENU_ITEM_CHECK_MARK) ?
995cdf0e10cSrcweir                                  gWidgetData[m_nScreen].gMenuItemCheckMenuWidget : gWidgetData[m_nScreen].gMenuItemRadioMenuWidget;
996cdf0e10cSrcweir             gtk_widget_style_get( pWidget,
997cdf0e10cSrcweir                                   "indicator_size", &indicator_size,
998cdf0e10cSrcweir                                   (char *)NULL );
999cdf0e10cSrcweir             rNativeBoundingRegion = rControlRegion;
1000cdf0e10cSrcweir             Rectangle aIndicatorRect( Point( 0,
1001cdf0e10cSrcweir                                              (rControlRegion.GetHeight()-indicator_size)/2),
1002cdf0e10cSrcweir                                       Size( indicator_size, indicator_size ) );
1003cdf0e10cSrcweir             rNativeContentRegion = aIndicatorRect;
1004cdf0e10cSrcweir             returnVal = sal_True;
1005cdf0e10cSrcweir         }
1006cdf0e10cSrcweir     }
1007cdf0e10cSrcweir     if( (nType == CTRL_RADIOBUTTON || nType == CTRL_CHECKBOX) )
1008cdf0e10cSrcweir     {
1009cdf0e10cSrcweir         NWEnsureGTKRadio( m_nScreen );
1010cdf0e10cSrcweir         NWEnsureGTKCheck( m_nScreen );
1011cdf0e10cSrcweir         GtkWidget* widget = (nType == CTRL_RADIOBUTTON) ? gWidgetData[m_nScreen].gRadioWidget : gWidgetData[m_nScreen].gCheckWidget;
1012cdf0e10cSrcweir         gint indicator_size, indicator_spacing;
1013cdf0e10cSrcweir         gtk_widget_style_get( widget,
1014cdf0e10cSrcweir                               "indicator_size", &indicator_size,
1015cdf0e10cSrcweir                               "indicator_spacing", &indicator_spacing,
1016cdf0e10cSrcweir                               (char *)NULL);
1017cdf0e10cSrcweir         indicator_size += 2*indicator_spacing; // guess overpaint of theme
1018cdf0e10cSrcweir         rNativeBoundingRegion = rControlRegion;
1019cdf0e10cSrcweir         Rectangle aIndicatorRect( Point( 0,
1020cdf0e10cSrcweir                                          (rControlRegion.GetHeight()-indicator_size)/2),
1021cdf0e10cSrcweir                                   Size( indicator_size, indicator_size ) );
1022cdf0e10cSrcweir         rNativeContentRegion = aIndicatorRect;
1023cdf0e10cSrcweir         returnVal = sal_True;
1024cdf0e10cSrcweir     }
1025cdf0e10cSrcweir     if( (nType == CTRL_EDITBOX || nType == CTRL_SPINBOX) && nPart == PART_ENTIRE_CONTROL )
1026cdf0e10cSrcweir     {
1027cdf0e10cSrcweir         NWEnsureGTKEditBox( m_nScreen );
1028cdf0e10cSrcweir         GtkWidget* widget = gWidgetData[m_nScreen].gEditBoxWidget;
1029cdf0e10cSrcweir         GtkRequisition aReq;
1030cdf0e10cSrcweir         gtk_widget_size_request( widget, &aReq );
1031cdf0e10cSrcweir         Rectangle aEditRect = rControlRegion;
1032cdf0e10cSrcweir         long nHeight = (aEditRect.GetHeight() > aReq.height+1) ? aEditRect.GetHeight() : aReq.height+1;
1033cdf0e10cSrcweir         aEditRect = Rectangle( aEditRect.TopLeft(),
1034cdf0e10cSrcweir                                Size( aEditRect.GetWidth(), nHeight ) );
1035cdf0e10cSrcweir         rNativeBoundingRegion = aEditRect;
1036cdf0e10cSrcweir         rNativeContentRegion = rNativeBoundingRegion;
1037cdf0e10cSrcweir         returnVal = sal_True;
1038cdf0e10cSrcweir     }
1039cdf0e10cSrcweir     if( (nType == CTRL_SLIDER) && (nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT) )
1040cdf0e10cSrcweir     {
1041cdf0e10cSrcweir         NWEnsureGTKSlider( m_nScreen );
1042cdf0e10cSrcweir         GtkWidget* widget = (nPart == PART_THUMB_HORZ) ? gWidgetData[m_nScreen].gHScale : gWidgetData[m_nScreen].gVScale;
1043cdf0e10cSrcweir         gint slider_length = 10;
1044cdf0e10cSrcweir         gint slider_width = 10;
1045cdf0e10cSrcweir         gtk_widget_style_get( widget,
1046cdf0e10cSrcweir                               "slider-width", &slider_width,
1047cdf0e10cSrcweir                               "slider-length", &slider_length,
1048cdf0e10cSrcweir                               (char *)NULL);
1049cdf0e10cSrcweir         Rectangle aRect( rControlRegion );
1050cdf0e10cSrcweir         if( nPart == PART_THUMB_HORZ )
1051cdf0e10cSrcweir         {
1052cdf0e10cSrcweir             aRect.Right() = aRect.Left() + slider_length - 1;
1053cdf0e10cSrcweir             aRect.Bottom() = aRect.Top() + slider_width - 1;
1054cdf0e10cSrcweir         }
1055cdf0e10cSrcweir         else
1056cdf0e10cSrcweir         {
1057cdf0e10cSrcweir             aRect.Bottom() = aRect.Top() + slider_length - 1;
1058cdf0e10cSrcweir             aRect.Right() = aRect.Left() + slider_width - 1;
1059cdf0e10cSrcweir         }
1060cdf0e10cSrcweir         rNativeBoundingRegion = rNativeContentRegion = aRect;
1061cdf0e10cSrcweir         returnVal = sal_True;
1062cdf0e10cSrcweir     }
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir 	return( returnVal );
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir /************************************************************************
1069cdf0e10cSrcweir  * Individual control drawing functions
1070cdf0e10cSrcweir  ************************************************************************/
1071cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKButton(
1072cdf0e10cSrcweir             GdkDrawable* gdkDrawable,
1073cdf0e10cSrcweir             ControlType, ControlPart,
1074cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
1075cdf0e10cSrcweir             const clipList& rClipList,
1076cdf0e10cSrcweir             ControlState nState, const ImplControlValue&,
1077cdf0e10cSrcweir 			const OUString& )
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir 	GtkStateType	stateType;
1080cdf0e10cSrcweir 	GtkShadowType	shadowType;
1081cdf0e10cSrcweir 	gboolean		interiorFocus;
1082cdf0e10cSrcweir 	gint			focusWidth;
1083cdf0e10cSrcweir 	gint			focusPad;
1084cdf0e10cSrcweir 	sal_Bool			bDrawFocus = sal_True;
1085cdf0e10cSrcweir 	gint			x, y, w, h;
1086cdf0e10cSrcweir 	GtkBorder		aDefBorder;
1087cdf0e10cSrcweir 	GtkBorder*		pBorder;
1088cdf0e10cSrcweir     GdkRectangle	clipRect;
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
1091cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 	x = rControlRectangle.Left();
1094cdf0e10cSrcweir     y = rControlRectangle.Top();
1095cdf0e10cSrcweir 	w = rControlRectangle.GetWidth();
1096cdf0e10cSrcweir 	h = rControlRectangle.GetHeight();
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	// Grab some button style attributes
1099cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[m_nScreen].gBtnWidget,	"focus-line-width",	&focusWidth,
1100cdf0e10cSrcweir 								"focus-padding", 	&focusPad,
1101cdf0e10cSrcweir 					 			"interior_focus",	&interiorFocus,
1102cdf0e10cSrcweir 								"default_border",	&pBorder,
1103cdf0e10cSrcweir 								(char *)NULL );
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir 	// Make sure the border values exist, otherwise use some defaults
1106cdf0e10cSrcweir 	if ( pBorder )
1107cdf0e10cSrcweir 	{
1108cdf0e10cSrcweir 		NW_gtk_border_set_from_border( aDefBorder, pBorder );
1109cdf0e10cSrcweir 		gtk_border_free( pBorder );
1110cdf0e10cSrcweir 	}
1111cdf0e10cSrcweir 	else NW_gtk_border_set_from_border( aDefBorder, &aDefDefBorder );
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 	// If the button is too small, don't ever draw focus or grab more space
1114cdf0e10cSrcweir 	if ( (w < 16) || (h < 16) )
1115cdf0e10cSrcweir 		bDrawFocus = sal_False;
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gBtnWidget, nState, stateType );
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir     gint xi = x, yi = y, wi = w, hi = h;
1120cdf0e10cSrcweir 	if ( (nState & CTRL_STATE_DEFAULT) && bDrawFocus )
1121cdf0e10cSrcweir 	{
1122cdf0e10cSrcweir 		xi += aDefBorder.left;
1123cdf0e10cSrcweir 		yi += aDefBorder.top;
1124cdf0e10cSrcweir 		wi -= aDefBorder.left + aDefBorder.right;
1125cdf0e10cSrcweir 		hi -= aDefBorder.top + aDefBorder.bottom;
1126cdf0e10cSrcweir 	}
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir 	if ( !interiorFocus && bDrawFocus )
1129cdf0e10cSrcweir 	{
1130cdf0e10cSrcweir 		xi += focusWidth + focusPad;
1131cdf0e10cSrcweir 		yi += focusWidth + focusPad;
1132cdf0e10cSrcweir 		wi -= 2 * (focusWidth + focusPad);
1133cdf0e10cSrcweir 		hi -= 2 * (focusWidth + focusPad);
1134cdf0e10cSrcweir 	}
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it)
1137cdf0e10cSrcweir     {
1138cdf0e10cSrcweir         clipRect.x = it->Left();
1139cdf0e10cSrcweir         clipRect.y = it->Top();
1140cdf0e10cSrcweir         clipRect.width = it->GetWidth();
1141cdf0e10cSrcweir         clipRect.height = it->GetHeight();
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir         // Buttons must paint opaque since some themes have alpha-channel enabled buttons
1144cdf0e10cSrcweir         gtk_paint_flat_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
1145cdf0e10cSrcweir                             &clipRect, m_pWindow, "base", x, y, w, h );
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir         if ( (nState & CTRL_STATE_DEFAULT) && (GTK_BUTTON(gWidgetData[m_nScreen].gBtnWidget)->relief == GTK_RELIEF_NORMAL) )
1148cdf0e10cSrcweir         {
1149cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
1150cdf0e10cSrcweir                            &clipRect, gWidgetData[m_nScreen].gBtnWidget, "buttondefault", x, y, w, h );
1151cdf0e10cSrcweir         }
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir         if ( (GTK_BUTTON(gWidgetData[m_nScreen].gBtnWidget)->relief != GTK_RELIEF_NONE)
1154cdf0e10cSrcweir             || (nState & CTRL_STATE_PRESSED)
1155cdf0e10cSrcweir 		    || (nState & CTRL_STATE_ROLLOVER) )
1156cdf0e10cSrcweir         {
1157cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, stateType, shadowType,
1158cdf0e10cSrcweir                            &clipRect, gWidgetData[m_nScreen].gBtnWidget, "button", xi, yi, wi, hi );
1159cdf0e10cSrcweir         }
1160cdf0e10cSrcweir     }
1161cdf0e10cSrcweir #if 0 // VCL draws focus rects
1162cdf0e10cSrcweir 	// Draw focus rect
1163cdf0e10cSrcweir 	if ( (nState & CTRL_STATE_FOCUSED) && (nState & CTRL_STATE_ENABLED) && bDrawFocus )
1164cdf0e10cSrcweir 	{
1165cdf0e10cSrcweir 		if (interiorFocus)
1166cdf0e10cSrcweir 		{
1167cdf0e10cSrcweir 			x += gWidgetData[m_nScreen].gBtnWidget->style->xthickness + focusPad;
1168cdf0e10cSrcweir 			y += gWidgetData[m_nScreen].gBtnWidget->style->ythickness + focusPad;
1169cdf0e10cSrcweir 			w -= 2 * (gWidgetData[m_nScreen].gBtnWidget->style->xthickness + focusPad);
1170cdf0e10cSrcweir 			h -=  2 * (gWidgetData[m_nScreen].gBtnWidget->style->xthickness + focusPad);
1171cdf0e10cSrcweir 		}
1172cdf0e10cSrcweir 		else
1173cdf0e10cSrcweir 		{
1174cdf0e10cSrcweir 			x -= focusWidth + focusPad;
1175cdf0e10cSrcweir 			y -= focusWidth + focusPad;
1176cdf0e10cSrcweir 			w += 2 * (focusWidth + focusPad);
1177cdf0e10cSrcweir 			h += 2 * (focusWidth + focusPad);
1178cdf0e10cSrcweir 		}
1179cdf0e10cSrcweir 		if ( !interiorFocus )
1180cdf0e10cSrcweir 			gtk_paint_focus( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, stateType, &clipRect,
1181cdf0e10cSrcweir                              gWidgetData[m_nScreen].gBtnWidget, "button", x, y, w, h );
1182cdf0e10cSrcweir 	}
1183cdf0e10cSrcweir #endif
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir 	return( sal_True );
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir static Rectangle NWGetButtonArea( int nScreen,
1189cdf0e10cSrcweir                                   ControlType, ControlPart, Rectangle aAreaRect, ControlState nState,
1190cdf0e10cSrcweir 							      const ImplControlValue&, const OUString& )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir 	gboolean		interiorFocus;
1193cdf0e10cSrcweir 	gint			focusWidth;
1194cdf0e10cSrcweir 	gint			focusPad;
1195cdf0e10cSrcweir 	GtkBorder		aDefBorder;
1196cdf0e10cSrcweir 	GtkBorder *	pBorder;
1197cdf0e10cSrcweir 	sal_Bool			bDrawFocus = sal_True;
1198cdf0e10cSrcweir 	Rectangle		aRect;
1199cdf0e10cSrcweir 	gint			x, y, w, h;
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir 	NWEnsureGTKButton( nScreen );
1202cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[nScreen].gBtnWidget,
1203cdf0e10cSrcweir                             	"focus-line-width",	&focusWidth,
1204cdf0e10cSrcweir 								"focus-padding", 	&focusPad,
1205cdf0e10cSrcweir 					 			"interior_focus",	&interiorFocus,
1206cdf0e10cSrcweir 								"default_border",	&pBorder,
1207cdf0e10cSrcweir 								(char *)NULL );
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir 	// Make sure the border values exist, otherwise use some defaults
1210cdf0e10cSrcweir 	if ( pBorder )
1211cdf0e10cSrcweir 	{
1212cdf0e10cSrcweir 		NW_gtk_border_set_from_border( aDefBorder, pBorder );
1213cdf0e10cSrcweir 		gtk_border_free( pBorder );
1214cdf0e10cSrcweir 	}
1215cdf0e10cSrcweir 	else NW_gtk_border_set_from_border( aDefBorder, &aDefDefBorder );
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir 	x = aAreaRect.Left();
1218cdf0e10cSrcweir 	y = aAreaRect.Top();
1219cdf0e10cSrcweir 	w = aAreaRect.GetWidth();
1220cdf0e10cSrcweir 	h = aAreaRect.GetHeight();
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir 	// If the button is too small, don't ever draw focus or grab more space
1223cdf0e10cSrcweir 	if ( (w < 16) || (h < 16) )
1224cdf0e10cSrcweir 		bDrawFocus = sal_False;
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir 	if ( (nState & CTRL_STATE_DEFAULT) && bDrawFocus )
1227cdf0e10cSrcweir 	{
1228cdf0e10cSrcweir 		x -= aDefBorder.left;
1229cdf0e10cSrcweir 		y -= aDefBorder.top;
1230cdf0e10cSrcweir 		w += aDefBorder.left + aDefBorder.right;
1231cdf0e10cSrcweir 		h += aDefBorder.top + aDefBorder.bottom;
1232cdf0e10cSrcweir 	}
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir     aRect = Rectangle( Point( x, y ), Size( w, h ) );
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir 	return( aRect );
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir //-------------------------------------
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKRadio( GdkDrawable* gdkDrawable,
1242cdf0e10cSrcweir                                       ControlType, ControlPart,
1243cdf0e10cSrcweir                                       const Rectangle& rControlRectangle,
1244cdf0e10cSrcweir                                       const clipList& rClipList,
1245cdf0e10cSrcweir                                       ControlState nState,
1246cdf0e10cSrcweir                                       const ImplControlValue& aValue,
1247cdf0e10cSrcweir                                       const OUString& )
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir 	GtkStateType	stateType;
1250cdf0e10cSrcweir 	GtkShadowType	shadowType;
1251cdf0e10cSrcweir 	sal_Bool			isChecked = (aValue.getTristateVal()==BUTTONVALUE_ON);
1252cdf0e10cSrcweir     gint            x, y;
1253cdf0e10cSrcweir     GdkRectangle	clipRect;
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
1256cdf0e10cSrcweir 	NWEnsureGTKRadio( m_nScreen );
1257cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir     gint indicator_size;
1260cdf0e10cSrcweir     gtk_widget_style_get( gWidgetData[m_nScreen].gRadioWidget, "indicator_size", &indicator_size, (char *)NULL);
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir     x = rControlRectangle.Left() + (rControlRectangle.GetWidth()-indicator_size)/2;
1263cdf0e10cSrcweir     y = rControlRectangle.Top() + (rControlRectangle.GetHeight()-indicator_size)/2;
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir 	// Set the shadow based on if checked or not so we get a freakin checkmark.
1266cdf0e10cSrcweir 	shadowType = isChecked ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
1267cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gRadioWidget, nState, stateType );
1268cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gRadioWidgetSibling, nState, stateType );
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir 	// GTK enforces radio groups, so that if we don't have 2 buttons in the group,
1271cdf0e10cSrcweir 	// the single button will always be active.  So we have to have 2 buttons.
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     // #i59666# set the members directly where we should use
1274cdf0e10cSrcweir     // gtk_toggle_button_set_active. reason: there are animated themes
1275cdf0e10cSrcweir     // which are in active state only after a while leading to painting
1276cdf0e10cSrcweir     // intermediate states between active/inactive. Let's hope that
1277cdf0e10cSrcweir     // GtkToggleButtone stays binary compatible.
1278cdf0e10cSrcweir 	if (!isChecked)
1279cdf0e10cSrcweir 		GTK_TOGGLE_BUTTON(gWidgetData[m_nScreen].gRadioWidgetSibling)->active = sal_True;
1280cdf0e10cSrcweir 	GTK_TOGGLE_BUTTON(gWidgetData[m_nScreen].gRadioWidget)->active = isChecked;
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
1283cdf0e10cSrcweir     {
1284cdf0e10cSrcweir         clipRect.x = it->Left();
1285cdf0e10cSrcweir         clipRect.y = it->Top();
1286cdf0e10cSrcweir         clipRect.width = it->GetWidth();
1287cdf0e10cSrcweir         clipRect.height = it->GetHeight();
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir         gtk_paint_option( gWidgetData[m_nScreen].gRadioWidget->style, gdkDrawable, stateType, shadowType,
1290cdf0e10cSrcweir                           &clipRect, gWidgetData[m_nScreen].gRadioWidget, "radiobutton",
1291cdf0e10cSrcweir                           x, y, indicator_size, indicator_size );
1292cdf0e10cSrcweir     }
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir 	return( sal_True );
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir //-------------------------------------
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKCheck( GdkDrawable* gdkDrawable,
1300cdf0e10cSrcweir                                       ControlType, ControlPart,
1301cdf0e10cSrcweir                                       const Rectangle& rControlRectangle,
1302cdf0e10cSrcweir                                       const clipList& rClipList,
1303cdf0e10cSrcweir                                       ControlState nState,
1304cdf0e10cSrcweir                                       const ImplControlValue& aValue,
1305cdf0e10cSrcweir                                       const OUString& )
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir 	GtkStateType	stateType;
1308cdf0e10cSrcweir 	GtkShadowType	shadowType;
1309cdf0e10cSrcweir 	bool			isChecked = (aValue.getTristateVal() == BUTTONVALUE_ON);
1310cdf0e10cSrcweir 	bool            isInconsistent = (aValue.getTristateVal() == BUTTONVALUE_MIXED);
1311cdf0e10cSrcweir     GdkRectangle	clipRect;
1312cdf0e10cSrcweir     gint			x,y;
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
1315cdf0e10cSrcweir 	NWEnsureGTKCheck( m_nScreen );
1316cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir     gint indicator_size;
1319cdf0e10cSrcweir     gtk_widget_style_get( gWidgetData[m_nScreen].gCheckWidget, "indicator_size", &indicator_size, (char *)NULL);
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir     x = rControlRectangle.Left() + (rControlRectangle.GetWidth()-indicator_size)/2;
1322cdf0e10cSrcweir     y = rControlRectangle.Top() + (rControlRectangle.GetHeight()-indicator_size)/2;
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir 	// Set the shadow based on if checked or not so we get a checkmark.
1325cdf0e10cSrcweir 	shadowType = isChecked ? GTK_SHADOW_IN : isInconsistent ? GTK_SHADOW_ETCHED_IN : GTK_SHADOW_OUT;
1326cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gCheckWidget, nState, stateType );
1327cdf0e10cSrcweir 	GTK_TOGGLE_BUTTON(gWidgetData[m_nScreen].gCheckWidget)->active = isChecked;
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
1330cdf0e10cSrcweir     {
1331cdf0e10cSrcweir         clipRect.x = it->Left();
1332cdf0e10cSrcweir         clipRect.y = it->Top();
1333cdf0e10cSrcweir         clipRect.width = it->GetWidth();
1334cdf0e10cSrcweir         clipRect.height = it->GetHeight();
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir         gtk_paint_check( gWidgetData[m_nScreen].gCheckWidget->style, gdkDrawable, stateType, shadowType,
1337cdf0e10cSrcweir                          &clipRect, gWidgetData[m_nScreen].gCheckWidget, "checkbutton",
1338cdf0e10cSrcweir                          x, y, indicator_size, indicator_size );
1339cdf0e10cSrcweir     }
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir 	return( sal_True );
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir //-------------------------------------
1345cdf0e10cSrcweir static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow )
1346cdf0e10cSrcweir {
1347cdf0e10cSrcweir 	// Size the arrow appropriately
1348cdf0e10cSrcweir     Size aSize( rButton.GetWidth()/2, rButton.GetHeight()/2 );
1349cdf0e10cSrcweir     rArrow.SetSize( aSize );
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir 	rArrow.SetPos( Point(
1352cdf0e10cSrcweir         rButton.Left() + ( rButton.GetWidth()  - rArrow.GetWidth()  ) / 2,
1353cdf0e10cSrcweir         rButton.Top() + ( rButton.GetHeight() - rArrow.GetHeight() ) / 2
1354cdf0e10cSrcweir         ) );
1355cdf0e10cSrcweir }
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKScrollbar( ControlType, ControlPart nPart,
1358cdf0e10cSrcweir                                           const Rectangle& rControlRectangle,
1359cdf0e10cSrcweir                                           const clipList&,
1360cdf0e10cSrcweir                                           ControlState nState,
1361cdf0e10cSrcweir                                           const ImplControlValue& aValue,
1362cdf0e10cSrcweir                                           const OUString& )
1363cdf0e10cSrcweir {
1364cdf0e10cSrcweir     OSL_ASSERT( aValue.getType() == CTRL_SCROLLBAR );
1365cdf0e10cSrcweir 	const ScrollbarValue* pScrollbarVal = static_cast<const ScrollbarValue *>(&aValue);
1366cdf0e10cSrcweir     GdkPixmap*      pixmap = NULL;
1367cdf0e10cSrcweir 	Rectangle		pixmapRect, scrollbarRect;
1368cdf0e10cSrcweir 	GtkStateType	stateType;
1369cdf0e10cSrcweir 	GtkShadowType	shadowType;
1370cdf0e10cSrcweir 	GtkScrollbar *	scrollbarWidget;
1371cdf0e10cSrcweir 	GtkStyle *	style;
1372cdf0e10cSrcweir 	GtkAdjustment* scrollbarValues = NULL;
1373cdf0e10cSrcweir 	GtkOrientation	scrollbarOrientation;
1374cdf0e10cSrcweir 	Rectangle		thumbRect = pScrollbarVal->maThumbRect;
1375cdf0e10cSrcweir 	Rectangle		button11BoundRect = pScrollbarVal->maButton1Rect;   // backward
1376cdf0e10cSrcweir 	Rectangle		button22BoundRect = pScrollbarVal->maButton2Rect;   // forward
1377cdf0e10cSrcweir 	Rectangle		button12BoundRect = pScrollbarVal->maButton1Rect;   // secondary forward
1378cdf0e10cSrcweir 	Rectangle		button21BoundRect = pScrollbarVal->maButton2Rect;   // secondary backward
1379cdf0e10cSrcweir 	GtkArrowType	button1Type;                                        // backward
1380cdf0e10cSrcweir 	GtkArrowType	button2Type;                                        // forward
1381cdf0e10cSrcweir 	gchar *		scrollbarTagH = (gchar *) "hscrollbar";
1382cdf0e10cSrcweir 	gchar *		scrollbarTagV = (gchar *) "vscrollbar";
1383cdf0e10cSrcweir 	gchar *		scrollbarTag = NULL;
1384cdf0e10cSrcweir 	Rectangle		arrowRect;
1385cdf0e10cSrcweir 	gint			slider_width = 0;
1386cdf0e10cSrcweir 	gint			stepper_size = 0;
1387cdf0e10cSrcweir 	gint			stepper_spacing = 0;
1388cdf0e10cSrcweir 	gint			trough_border = 0;
1389cdf0e10cSrcweir 	gint			min_slider_length = 0;
1390cdf0e10cSrcweir 	gint			vShim = 0;
1391cdf0e10cSrcweir 	gint			hShim = 0;
1392cdf0e10cSrcweir 	gint			x,y,w,h;
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir     // make controlvalue rectangles relative to area
1395cdf0e10cSrcweir     thumbRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() );
1396cdf0e10cSrcweir     button11BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() );
1397cdf0e10cSrcweir     button22BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() );
1398cdf0e10cSrcweir     button12BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() );
1399cdf0e10cSrcweir     button21BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() );
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
1402cdf0e10cSrcweir 	NWEnsureGTKScrollbars( m_nScreen );
1403cdf0e10cSrcweir 	NWEnsureGTKArrow( m_nScreen );
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir 	// Find the overall bounding rect of the control
1406cdf0e10cSrcweir 	pixmapRect = rControlRectangle;
1407cdf0e10cSrcweir     pixmapRect.SetSize( Size( pixmapRect.GetWidth() + 1,
1408cdf0e10cSrcweir                               pixmapRect.GetHeight() + 1 ) );
1409cdf0e10cSrcweir 	scrollbarRect = pixmapRect;
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir 	if ( (scrollbarRect.GetWidth() <= 1) || (scrollbarRect.GetHeight() <= 1) )
1412cdf0e10cSrcweir 		return( sal_True );
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir 	// Grab some button style attributes
1415cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[m_nScreen].gScrollHorizWidget,
1416cdf0e10cSrcweir                                       "slider_width", &slider_width,
1417cdf0e10cSrcweir 									  "stepper_size", &stepper_size,
1418cdf0e10cSrcweir 									  "trough_border", &trough_border,
1419cdf0e10cSrcweir 									  "stepper_spacing", &stepper_spacing,
1420cdf0e10cSrcweir 									  "min_slider_length", &min_slider_length, (char *)NULL );
1421cdf0e10cSrcweir     gboolean has_forward;
1422cdf0e10cSrcweir     gboolean has_forward2;
1423cdf0e10cSrcweir     gboolean has_backward;
1424cdf0e10cSrcweir     gboolean has_backward2;
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[m_nScreen].gScrollHorizWidget, "has-forward-stepper", &has_forward,
1427cdf0e10cSrcweir 									  "has-secondary-forward-stepper", &has_forward2,
1428cdf0e10cSrcweir 									  "has-backward-stepper", &has_backward,
1429cdf0e10cSrcweir 	   								  "has-secondary-backward-stepper", &has_backward2, (char *)NULL );
1430cdf0e10cSrcweir 	gint magic = trough_border ? 1 : 0;
1431cdf0e10cSrcweir     gint nFirst = 0;
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir     if ( has_backward )  nFirst  += 1;
1434cdf0e10cSrcweir     if ( has_forward2 )  nFirst  += 1;
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir 	if ( nPart == PART_DRAW_BACKGROUND_HORZ )
1437cdf0e10cSrcweir 	{
1438cdf0e10cSrcweir 		unsigned int sliderHeight = slider_width + (trough_border * 2);
1439cdf0e10cSrcweir 		vShim = (pixmapRect.GetHeight() - sliderHeight) / 2;
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir 		scrollbarRect.Move( 0, vShim );
1442cdf0e10cSrcweir 		scrollbarRect.SetSize( Size( scrollbarRect.GetWidth(), sliderHeight ) );
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir 		scrollbarWidget = GTK_SCROLLBAR( gWidgetData[m_nScreen].gScrollHorizWidget );
1445cdf0e10cSrcweir 		scrollbarOrientation = GTK_ORIENTATION_HORIZONTAL;
1446cdf0e10cSrcweir 		scrollbarTag = scrollbarTagH;
1447cdf0e10cSrcweir 		button1Type = GTK_ARROW_LEFT;
1448cdf0e10cSrcweir 		button2Type = GTK_ARROW_RIGHT;
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir         if ( has_backward )
1451cdf0e10cSrcweir         {
1452cdf0e10cSrcweir             button12BoundRect.Move( stepper_size - trough_border,
1453cdf0e10cSrcweir                                     (scrollbarRect.GetHeight() - slider_width) / 2 );
1454cdf0e10cSrcweir         }
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir         button11BoundRect.Move( trough_border, (scrollbarRect.GetHeight() - slider_width) / 2 );
1457cdf0e10cSrcweir         button11BoundRect.SetSize( Size( stepper_size, slider_width ) );
1458cdf0e10cSrcweir         button12BoundRect.SetSize( Size( stepper_size, slider_width ) );
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir         if ( has_backward2 )
1461cdf0e10cSrcweir         {
1462cdf0e10cSrcweir             button22BoundRect.Move( stepper_size+(trough_border+1)/2, (scrollbarRect.GetHeight() - slider_width) / 2 );
1463cdf0e10cSrcweir             button21BoundRect.Move( (trough_border+1)/2, (scrollbarRect.GetHeight() - slider_width) / 2 );
1464cdf0e10cSrcweir         }
1465cdf0e10cSrcweir         else
1466cdf0e10cSrcweir         {
1467cdf0e10cSrcweir             button22BoundRect.Move( (trough_border+1)/2, (scrollbarRect.GetHeight() - slider_width) / 2 );
1468cdf0e10cSrcweir         }
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir         button21BoundRect.SetSize( Size( stepper_size, slider_width ) );
1471cdf0e10cSrcweir         button22BoundRect.SetSize( Size( stepper_size, slider_width ) );
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir 		thumbRect.Bottom() = thumbRect.Top() + slider_width - 1;
1474cdf0e10cSrcweir 		// Make sure the thumb is at least the default width (so we don't get tiny thumbs),
1475cdf0e10cSrcweir 		// but if the VCL gives us a size smaller than the theme's default thumb size,
1476cdf0e10cSrcweir 		// honor the VCL size
1477cdf0e10cSrcweir #if 0
1478cdf0e10cSrcweir 		if ( (thumbRect.GetWidth() < min_slider_length)
1479cdf0e10cSrcweir 			&& ((scrollbarRect.GetWidth()-button1BoundRect.GetWidth()-button2BoundRect.GetWidth()) > min_slider_length) )
1480cdf0e10cSrcweir 			thumbRect.SetSize( Size( min_slider_length, thumbRect.GetHeight() ) );
1481cdf0e10cSrcweir #endif
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir         thumbRect.Right() += magic;
1484cdf0e10cSrcweir 		// Center vertically in the track
1485cdf0e10cSrcweir 		thumbRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 );
1486cdf0e10cSrcweir 	}
1487cdf0e10cSrcweir 	else
1488cdf0e10cSrcweir 	{
1489cdf0e10cSrcweir 		unsigned int sliderWidth = slider_width + (trough_border * 2);
1490cdf0e10cSrcweir 		hShim = (pixmapRect.GetWidth() - sliderWidth) / 2;
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 		scrollbarRect.Move( hShim, 0 );
1493cdf0e10cSrcweir 		scrollbarRect.SetSize( Size( sliderWidth, scrollbarRect.GetHeight() ) );
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir 		scrollbarWidget = GTK_SCROLLBAR( gWidgetData[m_nScreen].gScrollVertWidget );
1496cdf0e10cSrcweir 		scrollbarOrientation = GTK_ORIENTATION_VERTICAL;
1497cdf0e10cSrcweir 		scrollbarTag = scrollbarTagV;
1498cdf0e10cSrcweir 		button1Type = GTK_ARROW_UP;
1499cdf0e10cSrcweir 		button2Type = GTK_ARROW_DOWN;
1500cdf0e10cSrcweir 
1501cdf0e10cSrcweir         if ( has_backward )
1502cdf0e10cSrcweir         {
1503cdf0e10cSrcweir             button12BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2,
1504cdf0e10cSrcweir                                     stepper_size + trough_border );
1505cdf0e10cSrcweir         }
1506cdf0e10cSrcweir         button11BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, trough_border );
1507cdf0e10cSrcweir         button11BoundRect.SetSize( Size( slider_width, stepper_size ) );
1508cdf0e10cSrcweir 		button12BoundRect.SetSize( Size( slider_width, stepper_size ) );
1509cdf0e10cSrcweir 
1510cdf0e10cSrcweir         if ( has_backward2 )
1511cdf0e10cSrcweir         {
1512cdf0e10cSrcweir             button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, stepper_size+(trough_border+1)/2 );
1513cdf0e10cSrcweir             button21BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, (trough_border+1)/2 );
1514cdf0e10cSrcweir         }
1515cdf0e10cSrcweir         else
1516cdf0e10cSrcweir         {
1517cdf0e10cSrcweir             button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, (trough_border+1)/2 );
1518cdf0e10cSrcweir         }
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir         button21BoundRect.SetSize( Size( slider_width, stepper_size ) );
1521cdf0e10cSrcweir         button22BoundRect.SetSize( Size( slider_width, stepper_size ) );
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 		thumbRect.Right() = thumbRect.Left() + slider_width - 1;
1524cdf0e10cSrcweir #if 0
1525cdf0e10cSrcweir 		// Make sure the thumb is at least the default width (so we don't get tiny thumbs),
1526cdf0e10cSrcweir 		// but if the VCL gives us a size smaller than the theme's default thumb size,
1527cdf0e10cSrcweir 		// honor the VCL size
1528cdf0e10cSrcweir 		if ( (thumbRect.GetHeight() < min_slider_length)
1529cdf0e10cSrcweir 			&& ((scrollbarRect.GetHeight()-button1BoundRect.GetHeight()-button2BoundRect.GetHeight()) > min_slider_length) )
1530cdf0e10cSrcweir 			thumbRect.SetSize( Size( thumbRect.GetWidth(), min_slider_length ) );
1531cdf0e10cSrcweir #endif
1532cdf0e10cSrcweir 
1533cdf0e10cSrcweir         thumbRect.Bottom() += magic;
1534cdf0e10cSrcweir 		// Center horizontally in the track
1535cdf0e10cSrcweir 		thumbRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 );
1536cdf0e10cSrcweir 	}
1537cdf0e10cSrcweir 
1538cdf0e10cSrcweir     sal_Bool has_slider = ( thumbRect.GetWidth() > 0 && thumbRect.GetHeight() > 0 );
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir 	scrollbarValues = gtk_range_get_adjustment( GTK_RANGE(scrollbarWidget) );
1541cdf0e10cSrcweir 	if ( scrollbarValues == NULL )
1542cdf0e10cSrcweir 		scrollbarValues = GTK_ADJUSTMENT( gtk_adjustment_new(0, 0, 0, 0, 0, 0) );
1543cdf0e10cSrcweir 	if ( nPart == PART_DRAW_BACKGROUND_HORZ )
1544cdf0e10cSrcweir 	{
1545cdf0e10cSrcweir 		scrollbarValues->lower = pScrollbarVal->mnMin;
1546cdf0e10cSrcweir 		scrollbarValues->upper = pScrollbarVal->mnMax;
1547cdf0e10cSrcweir 		scrollbarValues->value = pScrollbarVal->mnCur;
1548cdf0e10cSrcweir 		scrollbarValues->page_size = scrollbarRect.GetWidth() / 2;
1549cdf0e10cSrcweir 	}
1550cdf0e10cSrcweir 	else
1551cdf0e10cSrcweir 	{
1552cdf0e10cSrcweir 		scrollbarValues->lower = pScrollbarVal->mnMin;
1553cdf0e10cSrcweir 		scrollbarValues->upper = pScrollbarVal->mnMax;
1554cdf0e10cSrcweir 		scrollbarValues->value = pScrollbarVal->mnCur;
1555cdf0e10cSrcweir 		scrollbarValues->page_size = scrollbarRect.GetHeight() / 2;
1556cdf0e10cSrcweir 	}
1557cdf0e10cSrcweir 	gtk_adjustment_changed( scrollbarValues );
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir     // as multiple paints are required for the scrollbar
1560cdf0e10cSrcweir     // painting them directly to the window flickers
1561cdf0e10cSrcweir     pixmap = NWGetPixmapFromScreen( pixmapRect );
1562cdf0e10cSrcweir     if( ! pixmap )
1563cdf0e10cSrcweir         return sal_False;
1564cdf0e10cSrcweir     x = y = 0;
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir     w = pixmapRect.GetWidth();
1567cdf0e10cSrcweir     h = pixmapRect.GetHeight();
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir     GdkDrawable* const &gdkDrawable = GDK_DRAWABLE( pixmap );
1570cdf0e10cSrcweir     GdkRectangle* gdkRect = NULL;
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
1573cdf0e10cSrcweir 	NWSetWidgetState( GTK_WIDGET(scrollbarWidget), nState, stateType );
1574cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gBtnWidget, nState, stateType );
1575cdf0e10cSrcweir 	style = GTK_WIDGET( scrollbarWidget )->style;
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir 	// ----------------- TROUGH
1578cdf0e10cSrcweir 	gtk_paint_flat_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable,
1579cdf0e10cSrcweir                         GTK_STATE_NORMAL, GTK_SHADOW_NONE, gdkRect,
1580cdf0e10cSrcweir                         m_pWindow, "base", x, y,
1581cdf0e10cSrcweir                         w, h );
1582cdf0e10cSrcweir 	gtk_paint_box( style, gdkDrawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN,
1583cdf0e10cSrcweir                    gdkRect, GTK_WIDGET(scrollbarWidget), "trough",
1584cdf0e10cSrcweir                    x, y,
1585cdf0e10cSrcweir                    scrollbarRect.GetWidth(), scrollbarRect.GetHeight() );
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir 	if ( nState & CTRL_STATE_FOCUSED )
1588cdf0e10cSrcweir 	{
1589cdf0e10cSrcweir 		gtk_paint_focus( style, gdkDrawable, GTK_STATE_ACTIVE,
1590cdf0e10cSrcweir                          gdkRect, GTK_WIDGET(scrollbarWidget), "trough",
1591cdf0e10cSrcweir                          x, y,
1592cdf0e10cSrcweir                          scrollbarRect.GetWidth(), scrollbarRect.GetHeight() );
1593cdf0e10cSrcweir 	}
1594cdf0e10cSrcweir 
1595cdf0e10cSrcweir 	// ----------------- THUMB
1596cdf0e10cSrcweir     if ( has_slider )
1597cdf0e10cSrcweir     {
1598cdf0e10cSrcweir 	    NWConvertVCLStateToGTKState( pScrollbarVal->mnThumbState, &stateType, &shadowType );
1599cdf0e10cSrcweir 	    if ( pScrollbarVal->mnThumbState & CTRL_STATE_PRESSED )  stateType = GTK_STATE_PRELIGHT;
1600cdf0e10cSrcweir 	    gtk_paint_slider( style, gdkDrawable, stateType, GTK_SHADOW_OUT,
1601cdf0e10cSrcweir                         gdkRect, GTK_WIDGET(scrollbarWidget), "slider",
1602cdf0e10cSrcweir                         x+hShim+thumbRect.Left(), y+vShim+thumbRect.Top(),
1603cdf0e10cSrcweir                         thumbRect.GetWidth(), thumbRect.GetHeight(), scrollbarOrientation );
1604cdf0e10cSrcweir     }
1605cdf0e10cSrcweir 	// ----------------- BUTTON 1 //
1606cdf0e10cSrcweir 	if ( has_backward )
1607cdf0e10cSrcweir 	{
1608cdf0e10cSrcweir         NWConvertVCLStateToGTKState( pScrollbarVal->mnButton1State, &stateType, &shadowType );
1609cdf0e10cSrcweir         if ( stateType == GTK_STATE_INSENSITIVE )	stateType = GTK_STATE_NORMAL;
1610cdf0e10cSrcweir         gtk_paint_box( style, gdkDrawable, stateType, shadowType,
1611cdf0e10cSrcweir                        gdkRect, GTK_WIDGET(scrollbarWidget), "stepper",
1612cdf0e10cSrcweir                        x+hShim+button11BoundRect.Left(), y+vShim+button11BoundRect.Top(),
1613cdf0e10cSrcweir                        button11BoundRect.GetWidth(), button11BoundRect.GetHeight() );
1614cdf0e10cSrcweir         // ----------------- ARROW 1
1615cdf0e10cSrcweir     	NWCalcArrowRect( button11BoundRect, arrowRect );
1616cdf0e10cSrcweir     	gtk_paint_arrow( style, gdkDrawable, stateType, shadowType,
1617cdf0e10cSrcweir                          gdkRect, GTK_WIDGET(scrollbarWidget), scrollbarTag, button1Type, sal_True,
1618cdf0e10cSrcweir                          x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(),
1619cdf0e10cSrcweir                          arrowRect.GetWidth(), arrowRect.GetHeight() );
1620cdf0e10cSrcweir     }
1621cdf0e10cSrcweir 	if ( has_forward2 )
1622cdf0e10cSrcweir 	{
1623cdf0e10cSrcweir         NWConvertVCLStateToGTKState( pScrollbarVal->mnButton2State, &stateType, &shadowType );
1624cdf0e10cSrcweir         if ( stateType == GTK_STATE_INSENSITIVE )	stateType = GTK_STATE_NORMAL;
1625cdf0e10cSrcweir         gtk_paint_box( style, gdkDrawable, stateType, shadowType,
1626cdf0e10cSrcweir                        gdkRect, GTK_WIDGET(scrollbarWidget), "stepper",
1627cdf0e10cSrcweir                        x+hShim+button12BoundRect.Left(), y+vShim+button12BoundRect.Top(),
1628cdf0e10cSrcweir                        button12BoundRect.GetWidth(), button12BoundRect.GetHeight() );
1629cdf0e10cSrcweir         // ----------------- ARROW 1
1630cdf0e10cSrcweir     	NWCalcArrowRect( button12BoundRect, arrowRect );
1631cdf0e10cSrcweir     	gtk_paint_arrow( style, gdkDrawable, stateType, shadowType,
1632cdf0e10cSrcweir                          gdkRect, GTK_WIDGET(scrollbarWidget), scrollbarTag, button2Type, sal_True,
1633cdf0e10cSrcweir                          x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(),
1634cdf0e10cSrcweir                          arrowRect.GetWidth(), arrowRect.GetHeight() );
1635cdf0e10cSrcweir     }
1636cdf0e10cSrcweir 	// ----------------- BUTTON 2
1637cdf0e10cSrcweir     if ( has_backward2 )
1638cdf0e10cSrcweir     {
1639cdf0e10cSrcweir         NWConvertVCLStateToGTKState( pScrollbarVal->mnButton1State, &stateType, &shadowType );
1640cdf0e10cSrcweir         if ( stateType == GTK_STATE_INSENSITIVE )	stateType = GTK_STATE_NORMAL;
1641cdf0e10cSrcweir         gtk_paint_box( style, gdkDrawable, stateType, shadowType, gdkRect,
1642cdf0e10cSrcweir                        GTK_WIDGET(scrollbarWidget), "stepper",
1643cdf0e10cSrcweir                        x+hShim+button21BoundRect.Left(), y+vShim+button21BoundRect.Top(),
1644cdf0e10cSrcweir                        button21BoundRect.GetWidth(), button21BoundRect.GetHeight() );
1645cdf0e10cSrcweir     	// ----------------- ARROW 2
1646cdf0e10cSrcweir     	NWCalcArrowRect( button21BoundRect, arrowRect );
1647cdf0e10cSrcweir         gtk_paint_arrow( style, gdkDrawable, stateType, shadowType,
1648cdf0e10cSrcweir                          gdkRect, GTK_WIDGET(scrollbarWidget), scrollbarTag, button1Type, sal_True,
1649cdf0e10cSrcweir                          x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(),
1650cdf0e10cSrcweir                          arrowRect.GetWidth(), arrowRect.GetHeight() );
1651cdf0e10cSrcweir     }
1652cdf0e10cSrcweir     if ( has_forward )
1653cdf0e10cSrcweir     {
1654cdf0e10cSrcweir         NWConvertVCLStateToGTKState( pScrollbarVal->mnButton2State, &stateType, &shadowType );
1655cdf0e10cSrcweir         if ( stateType == GTK_STATE_INSENSITIVE )	stateType = GTK_STATE_NORMAL;
1656cdf0e10cSrcweir         gtk_paint_box( style, gdkDrawable, stateType, shadowType, gdkRect,
1657cdf0e10cSrcweir                        GTK_WIDGET(scrollbarWidget), "stepper",
1658cdf0e10cSrcweir                        x+hShim+button22BoundRect.Left(), y+vShim+button22BoundRect.Top(),
1659cdf0e10cSrcweir                        button22BoundRect.GetWidth(), button22BoundRect.GetHeight() );
1660cdf0e10cSrcweir     	// ----------------- ARROW 2
1661cdf0e10cSrcweir     	NWCalcArrowRect( button22BoundRect, arrowRect );
1662cdf0e10cSrcweir         gtk_paint_arrow( style, gdkDrawable, stateType, shadowType,
1663cdf0e10cSrcweir                          gdkRect, GTK_WIDGET(scrollbarWidget), scrollbarTag, button2Type, sal_True,
1664cdf0e10cSrcweir                          x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(),
1665cdf0e10cSrcweir                          arrowRect.GetWidth(), arrowRect.GetHeight() );
1666cdf0e10cSrcweir     }
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir     if( !NWRenderPixmapToScreen(pixmap, pixmapRect) )
1669cdf0e10cSrcweir     {
1670cdf0e10cSrcweir         g_object_unref( pixmap );
1671cdf0e10cSrcweir         return( sal_False );
1672cdf0e10cSrcweir     }
1673cdf0e10cSrcweir     g_object_unref( pixmap );
1674cdf0e10cSrcweir 
1675cdf0e10cSrcweir 	return( sal_True );
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir //---
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir static Rectangle NWGetScrollButtonRect(	int nScreen, ControlPart nPart, Rectangle aAreaRect )
1681cdf0e10cSrcweir {
1682cdf0e10cSrcweir     gint slider_width;
1683cdf0e10cSrcweir     gint stepper_size;
1684cdf0e10cSrcweir     gint stepper_spacing;
1685cdf0e10cSrcweir     gint trough_border;
1686cdf0e10cSrcweir 
1687cdf0e10cSrcweir     NWEnsureGTKScrollbars( nScreen );
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir 	// Grab some button style attributes
1690cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[nScreen].gScrollHorizWidget,
1691cdf0e10cSrcweir                                       "slider-width", &slider_width,
1692cdf0e10cSrcweir 									  "stepper-size", &stepper_size,
1693cdf0e10cSrcweir 									  "trough-border", &trough_border,
1694cdf0e10cSrcweir 	   								  "stepper-spacing", &stepper_spacing, (char *)NULL );
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir     gboolean has_forward;
1697cdf0e10cSrcweir     gboolean has_forward2;
1698cdf0e10cSrcweir     gboolean has_backward;
1699cdf0e10cSrcweir     gboolean has_backward2;
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[nScreen].gScrollHorizWidget,
1702cdf0e10cSrcweir                                       "has-forward-stepper", &has_forward,
1703cdf0e10cSrcweir 									  "has-secondary-forward-stepper", &has_forward2,
1704cdf0e10cSrcweir 									  "has-backward-stepper", &has_backward,
1705cdf0e10cSrcweir 	   								  "has-secondary-backward-stepper", &has_backward2, (char *)NULL );
1706cdf0e10cSrcweir 	gint       buttonWidth;
1707cdf0e10cSrcweir 	gint       buttonHeight;
1708cdf0e10cSrcweir 	Rectangle  buttonRect;
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir     gint nFirst = 0;
1711cdf0e10cSrcweir     gint nSecond = 0;
1712cdf0e10cSrcweir 
1713cdf0e10cSrcweir     if ( has_forward )   nSecond += 1;
1714cdf0e10cSrcweir     if ( has_forward2 )  nFirst  += 1;
1715cdf0e10cSrcweir     if ( has_backward )  nFirst  += 1;
1716cdf0e10cSrcweir     if ( has_backward2 ) nSecond += 1;
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir     if ( ( nPart == PART_BUTTON_UP ) || ( nPart == PART_BUTTON_DOWN ) )
1719cdf0e10cSrcweir     {
1720cdf0e10cSrcweir         buttonWidth = slider_width + 2 * trough_border;
1721cdf0e10cSrcweir         buttonHeight = stepper_size + trough_border + stepper_spacing;
1722cdf0e10cSrcweir     }
1723cdf0e10cSrcweir     else
1724cdf0e10cSrcweir     {
1725cdf0e10cSrcweir         buttonWidth = stepper_size + trough_border + stepper_spacing;
1726cdf0e10cSrcweir         buttonHeight = slider_width + 2 * trough_border;
1727cdf0e10cSrcweir     }
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir     if ( nPart == PART_BUTTON_UP )
1730cdf0e10cSrcweir     {
1731cdf0e10cSrcweir         buttonHeight *= nFirst;
1732cdf0e10cSrcweir         buttonHeight -= 1;
1733cdf0e10cSrcweir         buttonRect.setX( aAreaRect.Left() );
1734cdf0e10cSrcweir         buttonRect.setY( aAreaRect.Top() );
1735cdf0e10cSrcweir     }
1736cdf0e10cSrcweir     else if ( nPart == PART_BUTTON_LEFT )
1737cdf0e10cSrcweir     {
1738cdf0e10cSrcweir         buttonWidth *= nFirst;
1739cdf0e10cSrcweir         buttonWidth -= 1;
1740cdf0e10cSrcweir         buttonRect.setX( aAreaRect.Left() );
1741cdf0e10cSrcweir         buttonRect.setY( aAreaRect.Top() );
1742cdf0e10cSrcweir     }
1743cdf0e10cSrcweir     else if ( nPart == PART_BUTTON_DOWN )
1744cdf0e10cSrcweir     {
1745cdf0e10cSrcweir         buttonHeight *= nSecond;
1746cdf0e10cSrcweir         buttonRect.setX( aAreaRect.Left() );
1747cdf0e10cSrcweir         buttonRect.setY( aAreaRect.Top() + aAreaRect.GetHeight() - buttonHeight );
1748cdf0e10cSrcweir     }
1749cdf0e10cSrcweir     else if ( nPart == PART_BUTTON_RIGHT )
1750cdf0e10cSrcweir     {
1751cdf0e10cSrcweir         buttonWidth *= nSecond;
1752cdf0e10cSrcweir         buttonRect.setX( aAreaRect.Left() + aAreaRect.GetWidth() - buttonWidth );
1753cdf0e10cSrcweir         buttonRect.setY( aAreaRect.Top() );
1754cdf0e10cSrcweir     }
1755cdf0e10cSrcweir 
1756cdf0e10cSrcweir     buttonRect.SetSize( Size( buttonWidth, buttonHeight ) );
1757cdf0e10cSrcweir 
1758cdf0e10cSrcweir 	return( buttonRect );
1759cdf0e10cSrcweir }
1760cdf0e10cSrcweir 
1761cdf0e10cSrcweir //-------------------------------------
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKEditBox( GdkDrawable* gdkDrawable,
1764cdf0e10cSrcweir                                         ControlType nType, ControlPart nPart,
1765cdf0e10cSrcweir                                         const Rectangle& rControlRectangle,
1766cdf0e10cSrcweir                                         const clipList& rClipList,
1767cdf0e10cSrcweir                                         ControlState nState,
1768cdf0e10cSrcweir                                         const ImplControlValue& aValue,
1769cdf0e10cSrcweir                                         const OUString& rCaption )
1770cdf0e10cSrcweir {
1771cdf0e10cSrcweir 	Rectangle		pixmapRect;
1772cdf0e10cSrcweir     GdkRectangle    clipRect;
1773cdf0e10cSrcweir 
1774cdf0e10cSrcweir 	// Find the overall bounding rect of the buttons's drawing area,
1775cdf0e10cSrcweir 	// plus its actual draw rect excluding adornment
1776cdf0e10cSrcweir 	pixmapRect = NWGetEditBoxPixmapRect( m_nScreen, nType, nPart, rControlRectangle,
1777cdf0e10cSrcweir 					                     nState, aValue, rCaption );
1778cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
1779cdf0e10cSrcweir     {
1780cdf0e10cSrcweir         clipRect.x = it->Left();
1781cdf0e10cSrcweir         clipRect.y = it->Top();
1782cdf0e10cSrcweir         clipRect.width = it->GetWidth();
1783cdf0e10cSrcweir         clipRect.height = it->GetHeight();
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir         NWPaintOneEditBox( m_nScreen, gdkDrawable, &clipRect, nType, nPart, pixmapRect, nState, aValue, rCaption );
1786cdf0e10cSrcweir     }
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir 	return( sal_True );
1789cdf0e10cSrcweir }
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir 
1792cdf0e10cSrcweir /* Take interior/exterior focus into account and return
1793cdf0e10cSrcweir  * the bounding rectangle of the edit box including
1794cdf0e10cSrcweir  * any focus requirements.
1795cdf0e10cSrcweir  */
1796cdf0e10cSrcweir static Rectangle NWGetEditBoxPixmapRect(int nScreen,
1797cdf0e10cSrcweir                                         ControlType,
1798cdf0e10cSrcweir 								        ControlPart,
1799cdf0e10cSrcweir                                         Rectangle aAreaRect,
1800cdf0e10cSrcweir                                         ControlState,
1801cdf0e10cSrcweir                                         const ImplControlValue&,
1802cdf0e10cSrcweir                                         const OUString& )
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir 	Rectangle		pixmapRect = aAreaRect;
1805cdf0e10cSrcweir 	gboolean		interiorFocus;
1806cdf0e10cSrcweir 	gint			focusWidth;
1807cdf0e10cSrcweir 
1808cdf0e10cSrcweir 	NWEnsureGTKEditBox( nScreen );
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir 	// Grab some entry style attributes
1811cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[nScreen].gEditBoxWidget,
1812cdf0e10cSrcweir                                 	"focus-line-width",	&focusWidth,
1813cdf0e10cSrcweir 					 				"interior-focus",	&interiorFocus, (char *)NULL );
1814cdf0e10cSrcweir 
1815cdf0e10cSrcweir 	if ( !interiorFocus )
1816cdf0e10cSrcweir 	{
1817cdf0e10cSrcweir 		pixmapRect.Move( -(focusWidth), -(focusWidth) );
1818cdf0e10cSrcweir         pixmapRect.SetSize( Size( pixmapRect.GetWidth() + (2*(focusWidth)),
1819cdf0e10cSrcweir                                   pixmapRect.GetHeight() + (2*(focusWidth)) ) );
1820cdf0e10cSrcweir 	}
1821cdf0e10cSrcweir 
1822cdf0e10cSrcweir 	return( pixmapRect );
1823cdf0e10cSrcweir }
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir 
1826cdf0e10cSrcweir /* Paint a GTK Entry widget into the specified GdkPixmap.
1827cdf0e10cSrcweir  * All coordinates should be local to the Pixmap, NOT
1828cdf0e10cSrcweir  * screen/window coordinates.
1829cdf0e10cSrcweir  */
1830cdf0e10cSrcweir static void NWPaintOneEditBox(	int nScreen,
1831cdf0e10cSrcweir                                 GdkDrawable * gdkDrawable,
1832cdf0e10cSrcweir                                 GdkRectangle *	gdkRect,
1833cdf0e10cSrcweir                                 ControlType			nType,
1834cdf0e10cSrcweir                                 ControlPart,
1835cdf0e10cSrcweir                                 Rectangle				aEditBoxRect,
1836cdf0e10cSrcweir                                 ControlState			nState,
1837cdf0e10cSrcweir                                 const ImplControlValue&,
1838cdf0e10cSrcweir                                 const OUString& )
1839cdf0e10cSrcweir {
1840cdf0e10cSrcweir 	GtkStateType	stateType;
1841cdf0e10cSrcweir 	GtkShadowType	shadowType;
1842cdf0e10cSrcweir 	GtkWidget      *widget;
1843cdf0e10cSrcweir 
1844cdf0e10cSrcweir 	NWEnsureGTKButton( nScreen );
1845cdf0e10cSrcweir 	NWEnsureGTKEditBox( nScreen );
1846cdf0e10cSrcweir 	NWEnsureGTKSpinButton( nScreen );
1847cdf0e10cSrcweir 	NWEnsureGTKCombo( nScreen );
1848cdf0e10cSrcweir 	NWEnsureGTKScrolledWindow( nScreen );
1849cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir     /* border's shadowType for gtk entries is always GTK_SHADOW_IN (see gtkentry.c)
1852cdf0e10cSrcweir     shadowType = GTK_SHADOW_IN;
1853cdf0e10cSrcweir     */
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir 	switch ( nType )
1856cdf0e10cSrcweir 	{
1857cdf0e10cSrcweir 		case CTRL_SPINBOX:
1858cdf0e10cSrcweir 			widget = gWidgetData[nScreen].gSpinButtonWidget;
1859cdf0e10cSrcweir 			break;
1860cdf0e10cSrcweir 
1861cdf0e10cSrcweir         case CTRL_MULTILINE_EDITBOX:
1862cdf0e10cSrcweir             widget = gWidgetData[nScreen].gScrolledWindowWidget;
1863cdf0e10cSrcweir             break;
1864cdf0e10cSrcweir 		case CTRL_COMBOBOX:
1865cdf0e10cSrcweir 			widget = GTK_COMBO(gWidgetData[nScreen].gComboWidget)->entry;
1866cdf0e10cSrcweir 			break;
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir 		default:
1869cdf0e10cSrcweir 			widget = gWidgetData[nScreen].gEditBoxWidget;
1870cdf0e10cSrcweir 			break;
1871cdf0e10cSrcweir 	}
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir 	if ( stateType == GTK_STATE_PRELIGHT )
1874cdf0e10cSrcweir 		stateType = GTK_STATE_NORMAL;
1875cdf0e10cSrcweir 
1876cdf0e10cSrcweir 	// Blueprint needs to paint entry_bg with a Button widget, not an Entry widget to get
1877cdf0e10cSrcweir 	// a nice white (or whatever default color) background
1878cdf0e10cSrcweir     GtkWidget* pBGWidget = widget;
1879cdf0e10cSrcweir     if( GtkSalGraphics::bNeedButtonStyleAsEditBackgroundWorkaround )
1880cdf0e10cSrcweir     {
1881cdf0e10cSrcweir         NWSetWidgetState( gWidgetData[nScreen].gBtnWidget, nState, stateType );
1882cdf0e10cSrcweir         pBGWidget = gWidgetData[nScreen].gBtnWidget;
1883cdf0e10cSrcweir     }
1884cdf0e10cSrcweir 	NWSetWidgetState( widget, nState, stateType );
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir 	gtk_paint_flat_box( pBGWidget->style, gdkDrawable, stateType, GTK_SHADOW_NONE,
1887cdf0e10cSrcweir                         gdkRect, pBGWidget, "entry_bg",
1888cdf0e10cSrcweir                         aEditBoxRect.Left(), aEditBoxRect.Top(),
1889cdf0e10cSrcweir                         aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
1890cdf0e10cSrcweir 	gtk_paint_shadow( widget->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
1891cdf0e10cSrcweir                       gdkRect, widget, "entry",
1892cdf0e10cSrcweir                       aEditBoxRect.Left(), aEditBoxRect.Top(),
1893cdf0e10cSrcweir                       aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir }
1896cdf0e10cSrcweir 
1897cdf0e10cSrcweir 
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir //-------------------------------------
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKSpinBox( ControlType nType, ControlPart nPart,
1902cdf0e10cSrcweir                                         const Rectangle& rControlRectangle,
1903cdf0e10cSrcweir                                         const clipList&,
1904cdf0e10cSrcweir                                         ControlState nState,
1905cdf0e10cSrcweir                                         const ImplControlValue& aValue,
1906cdf0e10cSrcweir                                         const OUString& rCaption )
1907cdf0e10cSrcweir {
1908cdf0e10cSrcweir 	GdkPixmap	*		pixmap;
1909cdf0e10cSrcweir 	Rectangle			pixmapRect;
1910cdf0e10cSrcweir 	GtkStateType		stateType;
1911cdf0e10cSrcweir 	GtkShadowType		shadowType;
1912cdf0e10cSrcweir 	const SpinbuttonValue *	pSpinVal = (aValue.getType() == CTRL_SPINBUTTONS) ? static_cast<const SpinbuttonValue *>(&aValue) : NULL;
1913cdf0e10cSrcweir 	Rectangle			upBtnRect;
1914cdf0e10cSrcweir 	ControlPart		upBtnPart = PART_BUTTON_UP;
1915cdf0e10cSrcweir 	ControlState		upBtnState = CTRL_STATE_ENABLED;
1916cdf0e10cSrcweir 	Rectangle			downBtnRect;
1917cdf0e10cSrcweir 	ControlPart		downBtnPart = PART_BUTTON_DOWN;
1918cdf0e10cSrcweir 	ControlState		downBtnState = CTRL_STATE_ENABLED;
1919cdf0e10cSrcweir 
1920cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
1921cdf0e10cSrcweir 	NWEnsureGTKSpinButton( m_nScreen );
1922cdf0e10cSrcweir 	NWEnsureGTKArrow( m_nScreen );
1923cdf0e10cSrcweir 
1924cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
1925cdf0e10cSrcweir 
1926cdf0e10cSrcweir 	if ( pSpinVal )
1927cdf0e10cSrcweir 	{
1928cdf0e10cSrcweir 		upBtnPart = pSpinVal->mnUpperPart;
1929cdf0e10cSrcweir 		upBtnState = pSpinVal->mnUpperState;
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir 		downBtnPart = pSpinVal->mnLowerPart;
1932cdf0e10cSrcweir 		downBtnState = pSpinVal->mnLowerState;
1933cdf0e10cSrcweir 	}
1934cdf0e10cSrcweir 
1935cdf0e10cSrcweir 	// CTRL_SPINBUTTONS pass their area in pSpinVal, not in rControlRectangle
1936cdf0e10cSrcweir 	if ( nType == CTRL_SPINBUTTONS )
1937cdf0e10cSrcweir 	{
1938cdf0e10cSrcweir 		if ( !pSpinVal )
1939cdf0e10cSrcweir 		{
1940cdf0e10cSrcweir             std::fprintf( stderr, "Tried to draw CTRL_SPINBUTTONS, but the SpinButtons data structure didn't exist!\n" );
1941cdf0e10cSrcweir 			return( false );
1942cdf0e10cSrcweir 		}
1943cdf0e10cSrcweir 		pixmapRect = pSpinVal->maUpperRect;
1944cdf0e10cSrcweir 		pixmapRect.Union( pSpinVal->maLowerRect );
1945cdf0e10cSrcweir 	}
1946cdf0e10cSrcweir 	else
1947cdf0e10cSrcweir 		pixmapRect = rControlRectangle;
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir 
1950cdf0e10cSrcweir 	pixmap = NWGetPixmapFromScreen( pixmapRect );
1951cdf0e10cSrcweir 	if ( !pixmap )
1952cdf0e10cSrcweir 		return( sal_False );
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir 	upBtnRect = NWGetSpinButtonRect( m_nScreen, nType, upBtnPart, pixmapRect, upBtnState, aValue, rCaption );
1955cdf0e10cSrcweir 	downBtnRect = NWGetSpinButtonRect( m_nScreen, nType, downBtnPart, pixmapRect, downBtnState, aValue, rCaption );
1956cdf0e10cSrcweir 
1957cdf0e10cSrcweir 	if ( (nType==CTRL_SPINBOX) && (nPart!=PART_ALL_BUTTONS) )
1958cdf0e10cSrcweir 	{
1959cdf0e10cSrcweir 		// Draw an edit field for SpinBoxes and ComboBoxes
1960cdf0e10cSrcweir 		Rectangle aEditBoxRect( pixmapRect );
1961cdf0e10cSrcweir 		aEditBoxRect.SetSize( Size( upBtnRect.Left() - pixmapRect.Left(), aEditBoxRect.GetHeight() ) );
1962cdf0e10cSrcweir 		aEditBoxRect.setX( 0 );
1963cdf0e10cSrcweir 		aEditBoxRect.setY( 0 );
1964cdf0e10cSrcweir 
1965cdf0e10cSrcweir 		NWPaintOneEditBox( m_nScreen, pixmap, NULL, nType, nPart, aEditBoxRect, nState, aValue, rCaption );
1966cdf0e10cSrcweir 	}
1967cdf0e10cSrcweir 
1968cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gSpinButtonWidget, nState, stateType );
1969cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[m_nScreen].gSpinButtonWidget, "shadow_type", &shadowType, (char *)NULL );
1970cdf0e10cSrcweir 
1971cdf0e10cSrcweir 	if ( shadowType != GTK_SHADOW_NONE )
1972cdf0e10cSrcweir 	{
1973cdf0e10cSrcweir 		Rectangle		shadowRect( upBtnRect );
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir 		shadowRect.Union( downBtnRect );
1976cdf0e10cSrcweir 		gtk_paint_box( gWidgetData[m_nScreen].gSpinButtonWidget->style, pixmap, GTK_STATE_NORMAL, shadowType, NULL,
1977cdf0e10cSrcweir 			gWidgetData[m_nScreen].gSpinButtonWidget, "spinbutton",
1978cdf0e10cSrcweir 			(shadowRect.Left() - pixmapRect.Left()), (shadowRect.Top() - pixmapRect.Top()),
1979cdf0e10cSrcweir 			shadowRect.GetWidth(), shadowRect.GetHeight() );
1980cdf0e10cSrcweir 	}
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir 	NWPaintOneSpinButton( m_nScreen, pixmap, nType, upBtnPart, pixmapRect, upBtnState, aValue, rCaption );
1983cdf0e10cSrcweir 	NWPaintOneSpinButton( m_nScreen, pixmap, nType, downBtnPart, pixmapRect, downBtnState, aValue, rCaption );
1984cdf0e10cSrcweir 
1985cdf0e10cSrcweir 	if( !NWRenderPixmapToScreen(pixmap, pixmapRect) )
1986cdf0e10cSrcweir 	{
1987cdf0e10cSrcweir 		g_object_unref( pixmap );
1988cdf0e10cSrcweir 		return( sal_False );
1989cdf0e10cSrcweir 	}
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir 	g_object_unref( pixmap );
1992cdf0e10cSrcweir 	return( sal_True );
1993cdf0e10cSrcweir }
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir //---
1996cdf0e10cSrcweir 
1997cdf0e10cSrcweir static Rectangle NWGetSpinButtonRect( int nScreen,
1998cdf0e10cSrcweir                                       ControlType,
1999cdf0e10cSrcweir 								      ControlPart			nPart,
2000cdf0e10cSrcweir                                       Rectangle 			aAreaRect,
2001cdf0e10cSrcweir                                       ControlState,
2002cdf0e10cSrcweir                                       const ImplControlValue&,
2003cdf0e10cSrcweir                                       const OUString& )
2004cdf0e10cSrcweir {
2005cdf0e10cSrcweir 	gint			buttonSize;
2006cdf0e10cSrcweir 	Rectangle		buttonRect;
2007cdf0e10cSrcweir 
2008cdf0e10cSrcweir 	NWEnsureGTKSpinButton( nScreen );
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir 	buttonSize = MAX( PANGO_PIXELS( pango_font_description_get_size(GTK_WIDGET(gWidgetData[nScreen].gSpinButtonWidget)->style->font_desc) ),
2011cdf0e10cSrcweir 				   MIN_SPIN_ARROW_WIDTH );
2012cdf0e10cSrcweir 	buttonSize -= buttonSize % 2 - 1; /* force odd */
2013cdf0e10cSrcweir 	buttonRect.SetSize( Size( buttonSize + 2 * gWidgetData[nScreen].gSpinButtonWidget->style->xthickness,
2014cdf0e10cSrcweir                               buttonRect.GetHeight() ) );
2015cdf0e10cSrcweir 	buttonRect.setX( aAreaRect.Left() + (aAreaRect.GetWidth() - buttonRect.GetWidth()) );
2016cdf0e10cSrcweir 	if ( nPart == PART_BUTTON_UP )
2017cdf0e10cSrcweir 	{
2018cdf0e10cSrcweir 		buttonRect.setY( aAreaRect.Top() );
2019cdf0e10cSrcweir 		buttonRect.Bottom() = buttonRect.Top() + (aAreaRect.GetHeight() / 2);
2020cdf0e10cSrcweir 	}
2021cdf0e10cSrcweir 	else if( nPart == PART_BUTTON_DOWN )
2022cdf0e10cSrcweir 	{
2023cdf0e10cSrcweir 		buttonRect.setY( aAreaRect.Top() + (aAreaRect.GetHeight() / 2) );
2024cdf0e10cSrcweir 		buttonRect.Bottom() = aAreaRect.Bottom(); // cover area completely
2025cdf0e10cSrcweir 	}
2026cdf0e10cSrcweir     else
2027cdf0e10cSrcweir     {
2028cdf0e10cSrcweir         buttonRect.Right()  = buttonRect.Left()-1;
2029cdf0e10cSrcweir         buttonRect.Left()   = aAreaRect.Left();
2030cdf0e10cSrcweir         buttonRect.Top()    = aAreaRect.Top();
2031cdf0e10cSrcweir         buttonRect.Bottom() = aAreaRect.Bottom();
2032cdf0e10cSrcweir     }
2033cdf0e10cSrcweir 
2034cdf0e10cSrcweir 	return( buttonRect );
2035cdf0e10cSrcweir }
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir //---
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir static void NWPaintOneSpinButton( int nScreen,
2040cdf0e10cSrcweir                                   GdkPixmap*			pixmap,
2041cdf0e10cSrcweir                                   ControlType			nType,
2042cdf0e10cSrcweir                                   ControlPart			nPart,
2043cdf0e10cSrcweir                                   Rectangle				aAreaRect,
2044cdf0e10cSrcweir                                   ControlState			nState,
2045cdf0e10cSrcweir                                   const ImplControlValue&	aValue,
2046cdf0e10cSrcweir                                   const OUString&				rCaption )
2047cdf0e10cSrcweir {
2048cdf0e10cSrcweir 	Rectangle			buttonRect;
2049cdf0e10cSrcweir 	GtkStateType		stateType;
2050cdf0e10cSrcweir 	GtkShadowType		shadowType;
2051cdf0e10cSrcweir 	Rectangle			arrowRect;
2052cdf0e10cSrcweir 	gint				arrowSize;
2053cdf0e10cSrcweir 
2054cdf0e10cSrcweir 	NWEnsureGTKSpinButton( nScreen );
2055cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir 	buttonRect = NWGetSpinButtonRect( nScreen, nType, nPart, aAreaRect, nState, aValue, rCaption );
2058cdf0e10cSrcweir 
2059cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[nScreen].gSpinButtonWidget, nState, stateType );
2060cdf0e10cSrcweir 	gtk_paint_box( gWidgetData[nScreen].gSpinButtonWidget->style, pixmap, stateType, shadowType, NULL, gWidgetData[nScreen].gSpinButtonWidget,
2061cdf0e10cSrcweir 			(nPart == PART_BUTTON_UP) ? "spinbutton_up" : "spinbutton_down",
2062cdf0e10cSrcweir 			(buttonRect.Left() - aAreaRect.Left()), (buttonRect.Top() - aAreaRect.Top()),
2063cdf0e10cSrcweir 			buttonRect.GetWidth(), buttonRect.GetHeight() );
2064cdf0e10cSrcweir 
2065cdf0e10cSrcweir 	arrowSize = (buttonRect.GetWidth() - (2 * gWidgetData[nScreen].gSpinButtonWidget->style->xthickness)) - 4;
2066cdf0e10cSrcweir 	arrowSize -= arrowSize % 2 - 1; /* force odd */
2067cdf0e10cSrcweir     arrowRect.SetSize( Size( arrowSize, arrowSize ) );
2068cdf0e10cSrcweir 	arrowRect.setX( buttonRect.Left() + (buttonRect.GetWidth() - arrowRect.GetWidth()) / 2 );
2069cdf0e10cSrcweir 	if ( nPart == PART_BUTTON_UP )
2070cdf0e10cSrcweir 		arrowRect.setY( buttonRect.Top() + (buttonRect.GetHeight() - arrowRect.GetHeight()) / 2 + 1);
2071cdf0e10cSrcweir 	else
2072cdf0e10cSrcweir 		arrowRect.setY( buttonRect.Top() + (buttonRect.GetHeight() - arrowRect.GetHeight()) / 2 - 1);
2073cdf0e10cSrcweir 
2074cdf0e10cSrcweir 	gtk_paint_arrow( gWidgetData[nScreen].gSpinButtonWidget->style, pixmap, stateType, GTK_SHADOW_OUT, NULL, gWidgetData[nScreen].gSpinButtonWidget,
2075cdf0e10cSrcweir 			"spinbutton", (nPart == PART_BUTTON_UP) ? GTK_ARROW_UP : GTK_ARROW_DOWN, sal_True,
2076cdf0e10cSrcweir 			(arrowRect.Left() - aAreaRect.Left()), (arrowRect.Top() - aAreaRect.Top()),
2077cdf0e10cSrcweir 			arrowRect.GetWidth(), arrowRect.GetHeight() );
2078cdf0e10cSrcweir }
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir 
2081cdf0e10cSrcweir //-------------------------------------
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKComboBox( GdkDrawable* gdkDrawable,
2084cdf0e10cSrcweir                                          ControlType nType, ControlPart nPart,
2085cdf0e10cSrcweir                                          const Rectangle& rControlRectangle,
2086cdf0e10cSrcweir                                          const clipList& rClipList,
2087cdf0e10cSrcweir                                          ControlState nState,
2088cdf0e10cSrcweir                                          const ImplControlValue& aValue,
2089cdf0e10cSrcweir                                          const OUString& rCaption )
2090cdf0e10cSrcweir {
2091cdf0e10cSrcweir 	Rectangle		pixmapRect;
2092cdf0e10cSrcweir 	Rectangle		buttonRect;
2093cdf0e10cSrcweir 	GtkStateType	stateType;
2094cdf0e10cSrcweir 	GtkShadowType	shadowType;
2095cdf0e10cSrcweir 	Rectangle		arrowRect;
2096cdf0e10cSrcweir     gint			x,y;
2097cdf0e10cSrcweir     GdkRectangle	clipRect;
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
2100cdf0e10cSrcweir 	NWEnsureGTKArrow( m_nScreen );
2101cdf0e10cSrcweir 	NWEnsureGTKCombo( m_nScreen );
2102cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir 	// Find the overall bounding rect of the buttons's drawing area,
2105cdf0e10cSrcweir 	// plus its actual draw rect excluding adornment
2106cdf0e10cSrcweir 	pixmapRect = rControlRectangle;
2107cdf0e10cSrcweir     x = rControlRectangle.Left();
2108cdf0e10cSrcweir     y = rControlRectangle.Top();
2109cdf0e10cSrcweir 
2110cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gBtnWidget, nState, stateType );
2111cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gComboWidget, nState, stateType );
2112cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gArrowWidget, nState, stateType );
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir     buttonRect = NWGetComboBoxButtonRect( m_nScreen, nType, PART_BUTTON_DOWN, pixmapRect, nState, aValue, rCaption );
2115cdf0e10cSrcweir     if( nPart == PART_BUTTON_DOWN )
2116cdf0e10cSrcweir         buttonRect.Left() += 1;
2117cdf0e10cSrcweir 
2118cdf0e10cSrcweir 	Rectangle		aEditBoxRect( pixmapRect );
2119cdf0e10cSrcweir 	aEditBoxRect.SetSize( Size( pixmapRect.GetWidth() - buttonRect.GetWidth(), aEditBoxRect.GetHeight() ) );
2120cdf0e10cSrcweir 
2121cdf0e10cSrcweir     #define ARROW_EXTENT		0.7
2122cdf0e10cSrcweir 	arrowRect.SetSize( Size( (gint)(MIN_ARROW_SIZE * ARROW_EXTENT),
2123cdf0e10cSrcweir 	                         (gint)(MIN_ARROW_SIZE * ARROW_EXTENT) ) );
2124cdf0e10cSrcweir 	arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2),
2125cdf0e10cSrcweir                              buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) );
2126cdf0e10cSrcweir 
2127cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
2128cdf0e10cSrcweir     {
2129cdf0e10cSrcweir         clipRect.x = it->Left();
2130cdf0e10cSrcweir         clipRect.y = it->Top();
2131cdf0e10cSrcweir         clipRect.width = it->GetWidth();
2132cdf0e10cSrcweir         clipRect.height = it->GetHeight();
2133cdf0e10cSrcweir 
2134cdf0e10cSrcweir         if( nPart == PART_ENTIRE_CONTROL )
2135cdf0e10cSrcweir             NWPaintOneEditBox( m_nScreen, gdkDrawable, &clipRect, nType, nPart, aEditBoxRect,
2136cdf0e10cSrcweir                                nState, aValue, rCaption );
2137cdf0e10cSrcweir 
2138cdf0e10cSrcweir         // Buttons must paint opaque since some themes have alpha-channel enabled buttons
2139cdf0e10cSrcweir         gtk_paint_flat_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
2140cdf0e10cSrcweir                             &clipRect, m_pWindow, "base",
2141cdf0e10cSrcweir                             x+(buttonRect.Left() - pixmapRect.Left()),
2142cdf0e10cSrcweir                             y+(buttonRect.Top() - pixmapRect.Top()),
2143cdf0e10cSrcweir                             buttonRect.GetWidth(), buttonRect.GetHeight() );
2144cdf0e10cSrcweir         gtk_paint_box( GTK_COMBO(gWidgetData[m_nScreen].gComboWidget)->button->style, gdkDrawable, stateType, shadowType,
2145cdf0e10cSrcweir                        &clipRect, GTK_COMBO(gWidgetData[m_nScreen].gComboWidget)->button, "button",
2146cdf0e10cSrcweir                        x+(buttonRect.Left() - pixmapRect.Left()),
2147cdf0e10cSrcweir                        y+(buttonRect.Top() - pixmapRect.Top()),
2148cdf0e10cSrcweir                        buttonRect.GetWidth(), buttonRect.GetHeight() );
2149cdf0e10cSrcweir 
2150cdf0e10cSrcweir         gtk_paint_arrow( gWidgetData[m_nScreen].gArrowWidget->style, gdkDrawable, stateType, shadowType,
2151cdf0e10cSrcweir                          &clipRect, gWidgetData[m_nScreen].gArrowWidget, "arrow", GTK_ARROW_DOWN, sal_True,
2152cdf0e10cSrcweir                          x+(arrowRect.Left() - pixmapRect.Left()), y+(arrowRect.Top() - pixmapRect.Top()),
2153cdf0e10cSrcweir                          arrowRect.GetWidth(), arrowRect.GetHeight() );
2154cdf0e10cSrcweir     }
2155cdf0e10cSrcweir 
2156cdf0e10cSrcweir 	return( sal_True );
2157cdf0e10cSrcweir }
2158cdf0e10cSrcweir 
2159cdf0e10cSrcweir //----
2160cdf0e10cSrcweir 
2161cdf0e10cSrcweir static Rectangle NWGetComboBoxButtonRect( int nScreen,
2162cdf0e10cSrcweir                                           ControlType,
2163cdf0e10cSrcweir 									      ControlPart nPart,
2164cdf0e10cSrcweir                                           Rectangle				aAreaRect,
2165cdf0e10cSrcweir                                           ControlState,
2166cdf0e10cSrcweir                                           const ImplControlValue&,
2167cdf0e10cSrcweir                                           const OUString& )
2168cdf0e10cSrcweir {
2169cdf0e10cSrcweir 	Rectangle	aButtonRect;
2170cdf0e10cSrcweir 	gint		nArrowWidth;
2171cdf0e10cSrcweir     gint        nButtonWidth;
2172cdf0e10cSrcweir 	gint		nFocusWidth;
2173cdf0e10cSrcweir 	gint		nFocusPad;
2174cdf0e10cSrcweir 
2175cdf0e10cSrcweir 	NWEnsureGTKArrow( nScreen );
2176cdf0e10cSrcweir 
2177cdf0e10cSrcweir 	// Grab some button style attributes
2178cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[nScreen].gDropdownWidget,
2179cdf0e10cSrcweir                                   	"focus-line-width",	&nFocusWidth,
2180cdf0e10cSrcweir 									"focus-padding", 	&nFocusPad, (char *)NULL );
2181cdf0e10cSrcweir 
2182cdf0e10cSrcweir 	nArrowWidth = MIN_ARROW_SIZE + (GTK_MISC(gWidgetData[nScreen].gArrowWidget)->xpad * 2);
2183cdf0e10cSrcweir     nButtonWidth = nArrowWidth +
2184cdf0e10cSrcweir                    ((BTN_CHILD_SPACING + gWidgetData[nScreen].gDropdownWidget->style->xthickness) * 2)
2185cdf0e10cSrcweir 				   + (2 * (nFocusWidth+nFocusPad));
2186cdf0e10cSrcweir     if( nPart == PART_BUTTON_DOWN )
2187cdf0e10cSrcweir     {
2188cdf0e10cSrcweir         aButtonRect.SetSize( Size( nButtonWidth, aAreaRect.GetHeight() ) );
2189cdf0e10cSrcweir         aButtonRect.SetPos( Point( aAreaRect.Left() + aAreaRect.GetWidth() - nButtonWidth,
2190cdf0e10cSrcweir                                    aAreaRect.Top() ) );
2191cdf0e10cSrcweir     }
2192cdf0e10cSrcweir     else if( nPart == PART_SUB_EDIT )
2193cdf0e10cSrcweir     {
2194cdf0e10cSrcweir         NWEnsureGTKCombo( nScreen );
2195cdf0e10cSrcweir 
2196cdf0e10cSrcweir         gint adjust_x = GTK_CONTAINER(gWidgetData[nScreen].gComboWidget)->border_width +
2197cdf0e10cSrcweir                         nFocusWidth +
2198cdf0e10cSrcweir                         nFocusPad;
2199cdf0e10cSrcweir         gint adjust_y = adjust_x + gWidgetData[nScreen].gComboWidget->style->ythickness;
2200cdf0e10cSrcweir         adjust_x     += gWidgetData[nScreen].gComboWidget->style->xthickness;
2201cdf0e10cSrcweir         aButtonRect.SetSize( Size( aAreaRect.GetWidth() - nButtonWidth - 2 * adjust_x,
2202cdf0e10cSrcweir                                    aAreaRect.GetHeight() - 2 * adjust_y ) );
2203cdf0e10cSrcweir         Point aEditPos = aAreaRect.TopLeft();
2204cdf0e10cSrcweir         aEditPos.X() += adjust_x;
2205cdf0e10cSrcweir         aEditPos.Y() += adjust_y;
2206cdf0e10cSrcweir         aButtonRect.SetPos( aEditPos );
2207cdf0e10cSrcweir     }
2208cdf0e10cSrcweir 
2209cdf0e10cSrcweir 	return( aButtonRect );
2210cdf0e10cSrcweir }
2211cdf0e10cSrcweir 
2212cdf0e10cSrcweir //-------------------------------------
2213cdf0e10cSrcweir 
2214cdf0e10cSrcweir 
2215cdf0e10cSrcweir 
2216cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKTabItem( ControlType nType, ControlPart,
2217cdf0e10cSrcweir                                         const Rectangle& rControlRectangle,
2218cdf0e10cSrcweir                                         const clipList&,
2219cdf0e10cSrcweir                                         ControlState nState,
2220cdf0e10cSrcweir                                         const ImplControlValue& aValue,
2221cdf0e10cSrcweir                                         const OUString& )
2222cdf0e10cSrcweir {
2223cdf0e10cSrcweir     OSL_ASSERT( nType != CTRL_TAB_ITEM || aValue.getType() == CTRL_TAB_ITEM );
2224cdf0e10cSrcweir 	GdkPixmap *	pixmap;
2225cdf0e10cSrcweir 	Rectangle		pixmapRect;
2226cdf0e10cSrcweir 	Rectangle		tabRect;
2227cdf0e10cSrcweir 	GtkStateType	stateType;
2228cdf0e10cSrcweir 	GtkShadowType	shadowType;
2229cdf0e10cSrcweir     if( ! gWidgetData[ m_nScreen ].gCacheTabItems )
2230cdf0e10cSrcweir     {
2231cdf0e10cSrcweir         gWidgetData[ m_nScreen ].gCacheTabItems = new NWPixmapCache( m_nScreen );
2232cdf0e10cSrcweir         gWidgetData[ m_nScreen ].gCacheTabPages = new NWPixmapCache( m_nScreen );
2233cdf0e10cSrcweir     }
2234cdf0e10cSrcweir     NWPixmapCache& aCacheItems = *gWidgetData[ m_nScreen ].gCacheTabItems;
2235cdf0e10cSrcweir     NWPixmapCache& aCachePage = *gWidgetData[ m_nScreen ].gCacheTabPages;
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir     if( !aCacheItems.GetSize() )
2238cdf0e10cSrcweir         aCacheItems.SetSize( 20 );
2239cdf0e10cSrcweir     if( !aCachePage.GetSize() )
2240cdf0e10cSrcweir         aCachePage.SetSize( 1 );
2241cdf0e10cSrcweir 
2242cdf0e10cSrcweir 	if ( (nType == CTRL_TAB_ITEM) && (aValue.getType() != CTRL_TAB_ITEM) )
2243cdf0e10cSrcweir 	{
2244cdf0e10cSrcweir 		return( false );
2245cdf0e10cSrcweir 	}
2246cdf0e10cSrcweir 
2247cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
2248cdf0e10cSrcweir 	NWEnsureGTKNotebook( m_nScreen );
2249cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2250cdf0e10cSrcweir 
2251cdf0e10cSrcweir 	// Find the overall bounding rect of the buttons's drawing area,
2252cdf0e10cSrcweir 	// plus its actual draw rect excluding adornment
2253cdf0e10cSrcweir 	pixmapRect = rControlRectangle;
2254cdf0e10cSrcweir 	if ( nType == CTRL_TAB_ITEM )
2255cdf0e10cSrcweir 	{
2256cdf0e10cSrcweir         const TabitemValue *	pTabitemValue = static_cast<const TabitemValue *>(&aValue);
2257cdf0e10cSrcweir 		if ( !pTabitemValue->isFirst() )
2258cdf0e10cSrcweir 		{
2259cdf0e10cSrcweir 			// GTK+ tabs overlap on the right edge (the top tab obscures the
2260cdf0e10cSrcweir 			// left edge of the tab right "below" it, so adjust the rectangle
2261cdf0e10cSrcweir 			// to draw tabs slightly large so the overlap happens
2262cdf0e10cSrcweir 			pixmapRect.Move( -2, 0 );
2263cdf0e10cSrcweir 			pixmapRect.SetSize( Size( pixmapRect.GetWidth() + 2, pixmapRect.GetHeight() ) );
2264cdf0e10cSrcweir 		}
2265cdf0e10cSrcweir 		if ( nState & CTRL_STATE_SELECTED )
2266cdf0e10cSrcweir 		{
2267cdf0e10cSrcweir 			// In GTK+, the selected tab is 2px taller than all other tabs
2268cdf0e10cSrcweir 			pixmapRect.Move( 0, -2 );
2269cdf0e10cSrcweir 			pixmapRect.Bottom() += 2;
2270cdf0e10cSrcweir 			tabRect = pixmapRect;
2271cdf0e10cSrcweir 			// Only draw over 1 pixel of the tab pane that this tab is drawn on top of.
2272cdf0e10cSrcweir 			tabRect.Bottom() -= 1;
2273cdf0e10cSrcweir 		}
2274cdf0e10cSrcweir 		else
2275cdf0e10cSrcweir 			tabRect = pixmapRect;
2276cdf0e10cSrcweir 
2277cdf0e10cSrcweir 		// Allow the tab to draw a right border if needed
2278cdf0e10cSrcweir 		tabRect.Right() -= 1;
2279cdf0e10cSrcweir 
2280cdf0e10cSrcweir         // #129732# avoid degenerate cases which might lead to crashes
2281cdf0e10cSrcweir         if( tabRect.GetWidth() <= 1 || tabRect.GetHeight() <= 1 )
2282cdf0e10cSrcweir             return false;
2283cdf0e10cSrcweir 	}
2284cdf0e10cSrcweir 
2285cdf0e10cSrcweir     if( nType == CTRL_TAB_ITEM )
2286cdf0e10cSrcweir     {
2287cdf0e10cSrcweir         if( aCacheItems.Find( nType, nState, pixmapRect, &pixmap ) )
2288cdf0e10cSrcweir             return NWRenderPixmapToScreen( pixmap, pixmapRect );
2289cdf0e10cSrcweir     }
2290cdf0e10cSrcweir     else
2291cdf0e10cSrcweir     {
2292cdf0e10cSrcweir         if( aCachePage.Find( nType, nState, pixmapRect, &pixmap ) )
2293cdf0e10cSrcweir             return NWRenderPixmapToScreen( pixmap, pixmapRect );
2294cdf0e10cSrcweir     }
2295cdf0e10cSrcweir 
2296cdf0e10cSrcweir 
2297cdf0e10cSrcweir //	gtk_widget_set_state( gWidgetData[m_nScreen].gNotebookWidget, stateType );
2298cdf0e10cSrcweir 
2299cdf0e10cSrcweir     pixmap = gdk_pixmap_new( NULL, pixmapRect.GetWidth(), pixmapRect.GetHeight(),
2300cdf0e10cSrcweir                              GetX11SalData()->GetDisplay()->GetVisual( m_nScreen ).GetDepth() );
2301cdf0e10cSrcweir     GdkRectangle paintRect;
2302cdf0e10cSrcweir     paintRect.x = paintRect.y = 0;
2303cdf0e10cSrcweir     paintRect.width = pixmapRect.GetWidth();
2304cdf0e10cSrcweir     paintRect.height = pixmapRect.GetHeight();
2305cdf0e10cSrcweir 
2306cdf0e10cSrcweir     gtk_paint_flat_box( m_pWindow->style, pixmap, GTK_STATE_NORMAL,
2307cdf0e10cSrcweir 		                GTK_SHADOW_NONE, &paintRect, m_pWindow, "base", 0, 0, -1, -1);
2308cdf0e10cSrcweir 
2309cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gNotebookWidget, nState, stateType );
2310cdf0e10cSrcweir 
2311cdf0e10cSrcweir 	switch( nType )
2312cdf0e10cSrcweir 	{
2313cdf0e10cSrcweir 		case CTRL_TAB_BODY:
2314cdf0e10cSrcweir 			break;
2315cdf0e10cSrcweir 
2316cdf0e10cSrcweir 		case CTRL_FIXEDBORDER:
2317cdf0e10cSrcweir 		case CTRL_TAB_PANE:
2318cdf0e10cSrcweir 			gtk_paint_box_gap( gWidgetData[m_nScreen].gNotebookWidget->style, pixmap, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, gWidgetData[m_nScreen].gNotebookWidget,
2319cdf0e10cSrcweir 				(char *)"notebook", 0, 0, pixmapRect.GetWidth(), pixmapRect.GetHeight(), GTK_POS_TOP, 0, 0 );
2320cdf0e10cSrcweir 			break;
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir 		case CTRL_TAB_ITEM:
2323cdf0e10cSrcweir 			stateType = ( nState & CTRL_STATE_SELECTED ) ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE;
2324cdf0e10cSrcweir 
2325cdf0e10cSrcweir 			gtk_paint_extension( gWidgetData[m_nScreen].gNotebookWidget->style, pixmap, stateType, GTK_SHADOW_OUT, NULL, gWidgetData[m_nScreen].gNotebookWidget,
2326cdf0e10cSrcweir 				(char *)"tab", (tabRect.Left() - pixmapRect.Left()), (tabRect.Top() - pixmapRect.Top()),
2327cdf0e10cSrcweir 				tabRect.GetWidth(), tabRect.GetHeight(), GTK_POS_BOTTOM );
2328cdf0e10cSrcweir 
2329cdf0e10cSrcweir 			if ( nState & CTRL_STATE_SELECTED )
2330cdf0e10cSrcweir 			{
2331cdf0e10cSrcweir 				gtk_paint_flat_box( gWidgetData[m_nScreen].gNotebookWidget->style, pixmap, stateType, GTK_SHADOW_NONE, NULL, m_pWindow,
2332cdf0e10cSrcweir 					(char *)"base", 0, (pixmapRect.GetHeight() - 1), pixmapRect.GetWidth(), 1 );
2333cdf0e10cSrcweir 			}
2334cdf0e10cSrcweir 			break;
2335cdf0e10cSrcweir 
2336cdf0e10cSrcweir 		default:
2337cdf0e10cSrcweir 			break;
2338cdf0e10cSrcweir 	}
2339cdf0e10cSrcweir 
2340cdf0e10cSrcweir 	// Crux seems to think it can make the pane without a left edge
2341cdf0e10cSrcweir 	if ( nType == CTRL_FIXEDBORDER )
2342cdf0e10cSrcweir 		pixmapRect.Move( 1, 0 );
2343cdf0e10cSrcweir 
2344cdf0e10cSrcweir     // cache data
2345cdf0e10cSrcweir     if( nType == CTRL_TAB_ITEM )
2346cdf0e10cSrcweir         aCacheItems.Fill( nType, nState, pixmapRect, pixmap );
2347cdf0e10cSrcweir     else
2348cdf0e10cSrcweir         aCachePage.Fill( nType, nState, pixmapRect, pixmap );
2349cdf0e10cSrcweir 
2350cdf0e10cSrcweir 	sal_Bool bSuccess = NWRenderPixmapToScreen(pixmap, pixmapRect);
2351cdf0e10cSrcweir 	g_object_unref( pixmap );
2352cdf0e10cSrcweir 	return bSuccess;
2353cdf0e10cSrcweir }
2354cdf0e10cSrcweir 
2355cdf0e10cSrcweir //-------------------------------------
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKListBox( GdkDrawable* gdkDrawable,
2358cdf0e10cSrcweir                                         ControlType nType, ControlPart nPart,
2359cdf0e10cSrcweir                                         const Rectangle& rControlRectangle,
2360cdf0e10cSrcweir                                         const clipList& rClipList,
2361cdf0e10cSrcweir                                         ControlState nState,
2362cdf0e10cSrcweir                                         const ImplControlValue& aValue,
2363cdf0e10cSrcweir                                         const OUString& rCaption )
2364cdf0e10cSrcweir {
2365cdf0e10cSrcweir 	Rectangle		pixmapRect;
2366cdf0e10cSrcweir 	Rectangle		widgetRect;
2367cdf0e10cSrcweir 	Rectangle		aIndicatorRect;
2368cdf0e10cSrcweir 	GtkStateType	stateType;
2369cdf0e10cSrcweir 	GtkShadowType	shadowType;
2370cdf0e10cSrcweir 	gint			bInteriorFocus;
2371cdf0e10cSrcweir 	gint			nFocusLineWidth;
2372cdf0e10cSrcweir 	gint			nFocusPadding;
2373cdf0e10cSrcweir     gint			x,y;
2374cdf0e10cSrcweir     GdkRectangle    clipRect;
2375cdf0e10cSrcweir 
2376cdf0e10cSrcweir 	NWEnsureGTKButton( m_nScreen );
2377cdf0e10cSrcweir 	NWEnsureGTKOptionMenu( m_nScreen );
2378cdf0e10cSrcweir 	NWEnsureGTKScrolledWindow( m_nScreen );
2379cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2380cdf0e10cSrcweir 
2381cdf0e10cSrcweir 	// Find the overall bounding rect of the buttons's drawing area,
2382cdf0e10cSrcweir 	// plus its actual draw rect excluding adornment
2383cdf0e10cSrcweir 	pixmapRect = rControlRectangle;
2384cdf0e10cSrcweir 	if ( nPart == PART_WINDOW )
2385cdf0e10cSrcweir 	{
2386cdf0e10cSrcweir 		// Make the widget a _bit_ bigger
2387cdf0e10cSrcweir 		pixmapRect.SetPos( Point( pixmapRect.Left() - 1,
2388cdf0e10cSrcweir                                   pixmapRect.Top() - 1 ) );
2389cdf0e10cSrcweir 		pixmapRect.SetSize( Size( pixmapRect.GetWidth() + 2,
2390cdf0e10cSrcweir 		                          pixmapRect.GetHeight() + 2 ) );
2391cdf0e10cSrcweir 	}
2392cdf0e10cSrcweir 
2393cdf0e10cSrcweir 	widgetRect = pixmapRect;
2394cdf0e10cSrcweir     x = pixmapRect.Left();
2395cdf0e10cSrcweir     y = pixmapRect.Top();
2396cdf0e10cSrcweir 
2397cdf0e10cSrcweir     // set up references to correct drawable and cliprect
2398cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gBtnWidget, nState, stateType );
2399cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gOptionMenuWidget, nState, stateType );
2400cdf0e10cSrcweir 	NWSetWidgetState( gWidgetData[m_nScreen].gScrolledWindowWidget, nState, stateType );
2401cdf0e10cSrcweir 
2402cdf0e10cSrcweir 	if ( nPart != PART_WINDOW )
2403cdf0e10cSrcweir 	{
2404cdf0e10cSrcweir 		gtk_widget_style_get( gWidgetData[m_nScreen].gOptionMenuWidget,
2405cdf0e10cSrcweir 			"interior_focus",	&bInteriorFocus,
2406cdf0e10cSrcweir 			"focus_line_width",	&nFocusLineWidth,
2407cdf0e10cSrcweir 			"focus_padding",	&nFocusPadding,
2408cdf0e10cSrcweir 			(char *)NULL);
2409cdf0e10cSrcweir     }
2410cdf0e10cSrcweir 
2411cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
2412cdf0e10cSrcweir     {
2413cdf0e10cSrcweir         clipRect.x = it->Left();
2414cdf0e10cSrcweir         clipRect.y = it->Top();
2415cdf0e10cSrcweir         clipRect.width = it->GetWidth();
2416cdf0e10cSrcweir         clipRect.height = it->GetHeight();
2417cdf0e10cSrcweir 
2418cdf0e10cSrcweir         if ( nPart != PART_WINDOW )
2419cdf0e10cSrcweir         {
2420cdf0e10cSrcweir             // Listboxes must paint opaque since some themes have alpha-channel enabled bodies
2421cdf0e10cSrcweir             gtk_paint_flat_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
2422cdf0e10cSrcweir                                 &clipRect, m_pWindow, "base", x, y,
2423cdf0e10cSrcweir                                 pixmapRect.GetWidth(), pixmapRect.GetHeight() );
2424cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gOptionMenuWidget->style, gdkDrawable, stateType, shadowType, &clipRect,
2425cdf0e10cSrcweir                            gWidgetData[m_nScreen].gOptionMenuWidget, "optionmenu",
2426cdf0e10cSrcweir                            x+(widgetRect.Left() - pixmapRect.Left()),
2427cdf0e10cSrcweir                            y+(widgetRect.Top() - pixmapRect.Top()),
2428cdf0e10cSrcweir                            widgetRect.GetWidth(), widgetRect.GetHeight() );
2429cdf0e10cSrcweir             aIndicatorRect = NWGetListBoxIndicatorRect( m_nScreen, nType, nPart, widgetRect, nState,
2430cdf0e10cSrcweir                                                         aValue, rCaption );
2431cdf0e10cSrcweir             gtk_paint_tab( gWidgetData[m_nScreen].gOptionMenuWidget->style, gdkDrawable, stateType, shadowType, &clipRect,
2432cdf0e10cSrcweir                            gWidgetData[m_nScreen].gOptionMenuWidget, "optionmenutab",
2433cdf0e10cSrcweir                            x+(aIndicatorRect.Left() - pixmapRect.Left()),
2434cdf0e10cSrcweir                            y+(aIndicatorRect.Top() - pixmapRect.Top()),
2435cdf0e10cSrcweir                            aIndicatorRect.GetWidth(), aIndicatorRect.GetHeight() );
2436cdf0e10cSrcweir         }
2437cdf0e10cSrcweir         else
2438cdf0e10cSrcweir         {
2439cdf0e10cSrcweir             shadowType = GTK_SHADOW_IN;
2440cdf0e10cSrcweir 
2441cdf0e10cSrcweir             gtk_paint_shadow( gWidgetData[m_nScreen].gScrolledWindowWidget->style, gdkDrawable, GTK_STATE_NORMAL, shadowType,
2442cdf0e10cSrcweir                 &clipRect, gWidgetData[m_nScreen].gScrolledWindowWidget, "scrolled_window",
2443cdf0e10cSrcweir                 x+(widgetRect.Left() - pixmapRect.Left()), y+(widgetRect.Top() - pixmapRect.Top()),
2444cdf0e10cSrcweir                 widgetRect.GetWidth(), widgetRect.GetHeight() );
2445cdf0e10cSrcweir         }
2446cdf0e10cSrcweir     }
2447cdf0e10cSrcweir 
2448cdf0e10cSrcweir 	return( sal_True );
2449cdf0e10cSrcweir }
2450cdf0e10cSrcweir 
2451cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKToolbar(
2452cdf0e10cSrcweir             GdkDrawable* gdkDrawable,
2453cdf0e10cSrcweir             ControlType, ControlPart nPart,
2454cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
2455cdf0e10cSrcweir             const clipList& rClipList,
2456cdf0e10cSrcweir             ControlState nState, const ImplControlValue& aValue,
2457cdf0e10cSrcweir 			const OUString& )
2458cdf0e10cSrcweir {
2459cdf0e10cSrcweir 	GtkStateType	stateType;
2460cdf0e10cSrcweir 	GtkShadowType	shadowType;
2461cdf0e10cSrcweir 	gint			x, y, w, h;
2462cdf0e10cSrcweir     gint            g_x=0, g_y=0, g_w=10, g_h=10;
2463cdf0e10cSrcweir     bool            bPaintButton = true;
2464cdf0e10cSrcweir     GtkWidget*      pButtonWidget = gWidgetData[m_nScreen].gToolbarButtonWidget;
2465cdf0e10cSrcweir     GdkRectangle	clipRect;
2466cdf0e10cSrcweir 
2467cdf0e10cSrcweir 	NWEnsureGTKToolbar( m_nScreen );
2468cdf0e10cSrcweir     if( nPart == PART_BUTTON ) // toolbar buttons cannot focus in gtk
2469cdf0e10cSrcweir         nState &= ~CTRL_STATE_FOCUSED;
2470cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2471cdf0e10cSrcweir 
2472cdf0e10cSrcweir 	x = rControlRectangle.Left();
2473cdf0e10cSrcweir     y = rControlRectangle.Top();
2474cdf0e10cSrcweir 	w = rControlRectangle.GetWidth();
2475cdf0e10cSrcweir 	h = rControlRectangle.GetHeight();
2476cdf0e10cSrcweir 
2477cdf0e10cSrcweir     // handle toolbar
2478cdf0e10cSrcweir     if( nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT )
2479cdf0e10cSrcweir     {
2480cdf0e10cSrcweir 	    NWSetWidgetState( gWidgetData[m_nScreen].gToolbarWidget, nState, stateType );
2481cdf0e10cSrcweir 
2482cdf0e10cSrcweir         GTK_WIDGET_UNSET_FLAGS( gWidgetData[m_nScreen].gToolbarWidget, GTK_SENSITIVE );
2483cdf0e10cSrcweir         if ( nState & CTRL_STATE_ENABLED )
2484cdf0e10cSrcweir             GTK_WIDGET_SET_FLAGS( gWidgetData[m_nScreen].gToolbarWidget, GTK_SENSITIVE );
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir         if( nPart == PART_DRAW_BACKGROUND_HORZ )
2487cdf0e10cSrcweir             gtk_toolbar_set_orientation( GTK_TOOLBAR(gWidgetData[m_nScreen].gToolbarWidget), GTK_ORIENTATION_HORIZONTAL );
2488cdf0e10cSrcweir         else
2489cdf0e10cSrcweir             gtk_toolbar_set_orientation( GTK_TOOLBAR(gWidgetData[m_nScreen].gToolbarWidget), GTK_ORIENTATION_VERTICAL );
2490cdf0e10cSrcweir     }
2491cdf0e10cSrcweir     // handle grip
2492cdf0e10cSrcweir     else if( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT )
2493cdf0e10cSrcweir     {
2494cdf0e10cSrcweir 	    NWSetWidgetState( gWidgetData[m_nScreen].gHandleBoxWidget, nState, stateType );
2495cdf0e10cSrcweir 
2496cdf0e10cSrcweir         GTK_WIDGET_UNSET_FLAGS( gWidgetData[m_nScreen].gHandleBoxWidget, GTK_SENSITIVE );
2497cdf0e10cSrcweir         if ( nState & CTRL_STATE_ENABLED )
2498cdf0e10cSrcweir             GTK_WIDGET_SET_FLAGS( gWidgetData[m_nScreen].gHandleBoxWidget, GTK_SENSITIVE );
2499cdf0e10cSrcweir 
2500cdf0e10cSrcweir         gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(gWidgetData[m_nScreen].gHandleBoxWidget), shadowType );
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir         // evaluate grip rect
2503cdf0e10cSrcweir         if( aValue.getType() == CTRL_TOOLBAR )
2504cdf0e10cSrcweir         {
2505cdf0e10cSrcweir             const ToolbarValue* pVal = static_cast<const ToolbarValue*>(&aValue);
2506cdf0e10cSrcweir             g_x = pVal->maGripRect.Left();
2507cdf0e10cSrcweir             g_y = pVal->maGripRect.Top();
2508cdf0e10cSrcweir             g_w = pVal->maGripRect.GetWidth();
2509cdf0e10cSrcweir             g_h = pVal->maGripRect.GetHeight();
2510cdf0e10cSrcweir         }
2511cdf0e10cSrcweir     }
2512cdf0e10cSrcweir     // handle button
2513cdf0e10cSrcweir     else if( nPart == PART_BUTTON )
2514cdf0e10cSrcweir     {
2515cdf0e10cSrcweir         bPaintButton =
2516cdf0e10cSrcweir             (GTK_BUTTON(pButtonWidget)->relief != GTK_RELIEF_NONE)
2517cdf0e10cSrcweir             || (nState & CTRL_STATE_PRESSED)
2518cdf0e10cSrcweir 		    || (nState & CTRL_STATE_ROLLOVER);
2519cdf0e10cSrcweir         if( aValue.getTristateVal() == BUTTONVALUE_ON )
2520cdf0e10cSrcweir         {
2521cdf0e10cSrcweir             pButtonWidget = gWidgetData[m_nScreen].gToolbarToggleWidget;
2522cdf0e10cSrcweir             shadowType = GTK_SHADOW_IN;
2523cdf0e10cSrcweir             stateType = GTK_STATE_ACTIVE;
2524cdf0e10cSrcweir             // special case stateType value for depressed toggle buttons
2525cdf0e10cSrcweir             // cf. gtk+/gtk/gtktogglebutton.c (gtk_toggle_button_update_state)
2526cdf0e10cSrcweir             if( (nState & (CTRL_STATE_ROLLOVER|CTRL_STATE_PRESSED)) )
2527cdf0e10cSrcweir             {
2528cdf0e10cSrcweir                 stateType = GTK_STATE_PRELIGHT;
2529cdf0e10cSrcweir                 shadowType = GTK_SHADOW_OUT;
2530cdf0e10cSrcweir             }
2531cdf0e10cSrcweir             bPaintButton = true;
2532cdf0e10cSrcweir         }
2533cdf0e10cSrcweir         else
2534cdf0e10cSrcweir             stateType = GTK_STATE_PRELIGHT; // only for bPaintButton = true, in which case always rollver is meant
2535cdf0e10cSrcweir 
2536cdf0e10cSrcweir         NWSetWidgetState( pButtonWidget, nState, stateType );
2537cdf0e10cSrcweir         gtk_widget_ensure_style( pButtonWidget );
2538cdf0e10cSrcweir     }
2539cdf0e10cSrcweir 
2540cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
2541cdf0e10cSrcweir     {
2542cdf0e10cSrcweir         clipRect.x = it->Left();
2543cdf0e10cSrcweir         clipRect.y = it->Top();
2544cdf0e10cSrcweir         clipRect.width = it->GetWidth();
2545cdf0e10cSrcweir         clipRect.height = it->GetHeight();
2546cdf0e10cSrcweir 
2547cdf0e10cSrcweir         // draw toolbar
2548cdf0e10cSrcweir         if( nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT )
2549cdf0e10cSrcweir         {
2550cdf0e10cSrcweir             gtk_paint_flat_box( gWidgetData[m_nScreen].gToolbarWidget->style,
2551cdf0e10cSrcweir                                 gdkDrawable,
2552cdf0e10cSrcweir                                 (GtkStateType)GTK_STATE_NORMAL,
2553cdf0e10cSrcweir                                 GTK_SHADOW_NONE,
2554cdf0e10cSrcweir                                 &clipRect,
2555cdf0e10cSrcweir                                 gWidgetData[m_nScreen].gToolbarWidget,
2556cdf0e10cSrcweir                                 "base",
2557cdf0e10cSrcweir                                 x, y, w, h );
2558cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gToolbarWidget->style,
2559cdf0e10cSrcweir                            gdkDrawable,
2560cdf0e10cSrcweir                            stateType,
2561cdf0e10cSrcweir                            shadowType,
2562cdf0e10cSrcweir                            &clipRect,
2563cdf0e10cSrcweir                            gWidgetData[m_nScreen].gToolbarWidget,
2564cdf0e10cSrcweir                            "toolbar",
2565cdf0e10cSrcweir                            x, y, w, h );
2566cdf0e10cSrcweir         }
2567cdf0e10cSrcweir         // draw grip
2568cdf0e10cSrcweir         else if( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT )
2569cdf0e10cSrcweir         {
2570cdf0e10cSrcweir             gtk_paint_handle( gWidgetData[m_nScreen].gHandleBoxWidget->style,
2571cdf0e10cSrcweir                               gdkDrawable,
2572cdf0e10cSrcweir                               GTK_STATE_NORMAL,
2573cdf0e10cSrcweir                               GTK_SHADOW_OUT,
2574cdf0e10cSrcweir                               &clipRect,
2575cdf0e10cSrcweir                               gWidgetData[m_nScreen].gHandleBoxWidget,
2576cdf0e10cSrcweir                               "handlebox",
2577cdf0e10cSrcweir                               g_x, g_y, g_w, g_h,
2578cdf0e10cSrcweir                               nPart == PART_THUMB_HORZ ?
2579cdf0e10cSrcweir                               GTK_ORIENTATION_HORIZONTAL :
2580cdf0e10cSrcweir                               GTK_ORIENTATION_VERTICAL
2581cdf0e10cSrcweir                               );
2582cdf0e10cSrcweir         }
2583cdf0e10cSrcweir         // draw button
2584cdf0e10cSrcweir         else if( nPart == PART_BUTTON )
2585cdf0e10cSrcweir         {
2586cdf0e10cSrcweir             if( bPaintButton )
2587cdf0e10cSrcweir             {
2588cdf0e10cSrcweir                 gtk_paint_box( pButtonWidget->style, gdkDrawable,
2589cdf0e10cSrcweir                                stateType,
2590cdf0e10cSrcweir                                shadowType,
2591cdf0e10cSrcweir                                &clipRect,
2592cdf0e10cSrcweir                                pButtonWidget, "button", x, y, w, h );
2593cdf0e10cSrcweir             }
2594cdf0e10cSrcweir         }
2595cdf0e10cSrcweir     }
2596cdf0e10cSrcweir 
2597cdf0e10cSrcweir 	return( sal_True );
2598cdf0e10cSrcweir }
2599cdf0e10cSrcweir 
2600cdf0e10cSrcweir //----
2601cdf0e10cSrcweir 
2602cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKMenubar(
2603cdf0e10cSrcweir             GdkDrawable* gdkDrawable,
2604cdf0e10cSrcweir             ControlType, ControlPart nPart,
2605cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
2606cdf0e10cSrcweir             const clipList& rClipList,
2607cdf0e10cSrcweir             ControlState nState, const ImplControlValue&,
2608cdf0e10cSrcweir 			const OUString& )
2609cdf0e10cSrcweir {
2610cdf0e10cSrcweir 	GtkStateType	stateType;
2611cdf0e10cSrcweir 	GtkShadowType	shadowType;
2612cdf0e10cSrcweir     GtkShadowType   selected_shadow_type = GTK_SHADOW_OUT;
2613cdf0e10cSrcweir 	gint			x, y, w, h;
2614cdf0e10cSrcweir     GdkRectangle	clipRect;
2615cdf0e10cSrcweir 
2616cdf0e10cSrcweir 	NWEnsureGTKMenubar( m_nScreen );
2617cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2618cdf0e10cSrcweir 
2619cdf0e10cSrcweir 	x = rControlRectangle.Left();
2620cdf0e10cSrcweir     y = rControlRectangle.Top();
2621cdf0e10cSrcweir 	w = rControlRectangle.GetWidth();
2622cdf0e10cSrcweir 	h = rControlRectangle.GetHeight();
2623cdf0e10cSrcweir 
2624cdf0e10cSrcweir     if( nPart == PART_MENU_ITEM )
2625cdf0e10cSrcweir     {
2626cdf0e10cSrcweir         if( nState & (CTRL_STATE_SELECTED|CTRL_STATE_ROLLOVER) )
2627cdf0e10cSrcweir         {
2628cdf0e10cSrcweir             gtk_widget_style_get( gWidgetData[m_nScreen].gMenuItemMenubarWidget,
2629cdf0e10cSrcweir                                   "selected_shadow_type", &selected_shadow_type,
2630cdf0e10cSrcweir                                   (char *)NULL);
2631cdf0e10cSrcweir         }
2632cdf0e10cSrcweir     }
2633cdf0e10cSrcweir 
2634cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
2635cdf0e10cSrcweir     {
2636cdf0e10cSrcweir         clipRect.x = it->Left();
2637cdf0e10cSrcweir         clipRect.y = it->Top();
2638cdf0e10cSrcweir         clipRect.width = it->GetWidth();
2639cdf0e10cSrcweir         clipRect.height = it->GetHeight();
2640cdf0e10cSrcweir 
2641cdf0e10cSrcweir         // handle Menubar
2642cdf0e10cSrcweir         if( nPart == PART_ENTIRE_CONTROL )
2643cdf0e10cSrcweir         {
2644cdf0e10cSrcweir             NWSetWidgetState( gWidgetData[m_nScreen].gMenubarWidget, nState, stateType );
2645cdf0e10cSrcweir 
2646cdf0e10cSrcweir             GTK_WIDGET_UNSET_FLAGS( gWidgetData[m_nScreen].gMenubarWidget, GTK_SENSITIVE );
2647cdf0e10cSrcweir             if ( nState & CTRL_STATE_ENABLED )
2648cdf0e10cSrcweir                 GTK_WIDGET_SET_FLAGS( gWidgetData[m_nScreen].gMenubarWidget, GTK_SENSITIVE );
2649cdf0e10cSrcweir 
2650cdf0e10cSrcweir             // #118704# for translucent menubar styles paint background first
2651cdf0e10cSrcweir             gtk_paint_flat_box( gWidgetData[m_nScreen].gMenubarWidget->style,
2652cdf0e10cSrcweir                                 gdkDrawable,
2653cdf0e10cSrcweir                                 GTK_STATE_NORMAL,
2654cdf0e10cSrcweir                                 GTK_SHADOW_NONE,
2655cdf0e10cSrcweir                                 &clipRect,
2656cdf0e10cSrcweir                                 GTK_WIDGET(m_pWindow),
2657cdf0e10cSrcweir                                 "base",
2658cdf0e10cSrcweir                                 x, y, w, h );
2659cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gMenubarWidget->style,
2660cdf0e10cSrcweir                            gdkDrawable,
2661cdf0e10cSrcweir                            stateType,
2662cdf0e10cSrcweir                            shadowType,
2663cdf0e10cSrcweir                            &clipRect,
2664cdf0e10cSrcweir                            gWidgetData[m_nScreen].gMenubarWidget,
2665cdf0e10cSrcweir                            "menubar",
2666cdf0e10cSrcweir                            x, y, w, h );
2667cdf0e10cSrcweir         }
2668cdf0e10cSrcweir         else if( nPart == PART_MENU_ITEM )
2669cdf0e10cSrcweir         {
2670cdf0e10cSrcweir             if( nState & (CTRL_STATE_SELECTED|CTRL_STATE_ROLLOVER) )
2671cdf0e10cSrcweir             {
2672cdf0e10cSrcweir                 gtk_paint_box( gWidgetData[m_nScreen].gMenuItemMenubarWidget->style,
2673cdf0e10cSrcweir                                gdkDrawable,
2674cdf0e10cSrcweir                                GTK_STATE_PRELIGHT,
2675cdf0e10cSrcweir                                selected_shadow_type,
2676cdf0e10cSrcweir                                &clipRect,
2677cdf0e10cSrcweir                                gWidgetData[m_nScreen].gMenuItemMenubarWidget,
2678cdf0e10cSrcweir                                "menuitem",
2679cdf0e10cSrcweir                                x, y, w, h);
2680cdf0e10cSrcweir             }
2681cdf0e10cSrcweir         }
2682cdf0e10cSrcweir     }
2683cdf0e10cSrcweir 
2684cdf0e10cSrcweir 	return( sal_True );
2685cdf0e10cSrcweir }
2686cdf0e10cSrcweir 
2687cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKPopupMenu(
2688cdf0e10cSrcweir             GdkDrawable* gdkDrawable,
2689cdf0e10cSrcweir             ControlType, ControlPart nPart,
2690cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
2691cdf0e10cSrcweir             const clipList& rClipList,
2692cdf0e10cSrcweir             ControlState nState, const ImplControlValue&,
2693cdf0e10cSrcweir 			const OUString& )
2694cdf0e10cSrcweir {
2695cdf0e10cSrcweir     // #i50745# gtk does not draw disabled menu entries (and crux theme
2696cdf0e10cSrcweir     // even crashes), draw them using vcl functionality.
2697cdf0e10cSrcweir     if( nPart == PART_MENU_ITEM && ! (nState & CTRL_STATE_ENABLED) )
2698cdf0e10cSrcweir         return sal_False;
2699cdf0e10cSrcweir 
2700cdf0e10cSrcweir 	GtkStateType	stateType;
2701cdf0e10cSrcweir 	GtkShadowType	shadowType;
2702cdf0e10cSrcweir     GtkShadowType   selected_shadow_type = GTK_SHADOW_OUT;
2703cdf0e10cSrcweir 	gint			x, y, w, h;
2704cdf0e10cSrcweir     GdkRectangle	clipRect;
2705cdf0e10cSrcweir 
2706cdf0e10cSrcweir 	NWEnsureGTKMenu( m_nScreen );
2707cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2708cdf0e10cSrcweir 
2709cdf0e10cSrcweir 	x = rControlRectangle.Left();
2710cdf0e10cSrcweir     y = rControlRectangle.Top();
2711cdf0e10cSrcweir 	w = rControlRectangle.GetWidth();
2712cdf0e10cSrcweir 	h = rControlRectangle.GetHeight();
2713cdf0e10cSrcweir 
2714cdf0e10cSrcweir     if( nPart == PART_MENU_ITEM &&
2715cdf0e10cSrcweir         ( nState & (CTRL_STATE_SELECTED|CTRL_STATE_ROLLOVER) ) )
2716cdf0e10cSrcweir     {
2717cdf0e10cSrcweir         gtk_widget_style_get( gWidgetData[m_nScreen].gMenuItemMenuWidget,
2718cdf0e10cSrcweir                               "selected_shadow_type", &selected_shadow_type,
2719cdf0e10cSrcweir                               (char *)NULL);
2720cdf0e10cSrcweir     }
2721cdf0e10cSrcweir 
2722cdf0e10cSrcweir     NWSetWidgetState( gWidgetData[m_nScreen].gMenuWidget, nState, stateType );
2723cdf0e10cSrcweir 
2724cdf0e10cSrcweir     GTK_WIDGET_UNSET_FLAGS( gWidgetData[m_nScreen].gMenuWidget, GTK_SENSITIVE );
2725cdf0e10cSrcweir     if ( nState & CTRL_STATE_ENABLED )
2726cdf0e10cSrcweir         GTK_WIDGET_SET_FLAGS( gWidgetData[m_nScreen].gMenuWidget, GTK_SENSITIVE );
2727cdf0e10cSrcweir 
2728cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
2729cdf0e10cSrcweir     {
2730cdf0e10cSrcweir         clipRect.x = it->Left();
2731cdf0e10cSrcweir         clipRect.y = it->Top();
2732cdf0e10cSrcweir         clipRect.width = it->GetWidth();
2733cdf0e10cSrcweir         clipRect.height = it->GetHeight();
2734cdf0e10cSrcweir 
2735cdf0e10cSrcweir         if( nPart == PART_ENTIRE_CONTROL )
2736cdf0e10cSrcweir         {
2737cdf0e10cSrcweir             // #118704# for translucent menubar styles paint background first
2738cdf0e10cSrcweir             gtk_paint_flat_box( gWidgetData[m_nScreen].gMenuWidget->style,
2739cdf0e10cSrcweir                                 gdkDrawable,
2740cdf0e10cSrcweir                                 GTK_STATE_NORMAL,
2741cdf0e10cSrcweir                                 GTK_SHADOW_NONE,
2742cdf0e10cSrcweir                                 &clipRect,
2743cdf0e10cSrcweir                                 GTK_WIDGET(m_pWindow),
2744cdf0e10cSrcweir                                 "base",
2745cdf0e10cSrcweir                                 x, y, w, h );
2746cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gMenuWidget->style,
2747cdf0e10cSrcweir                            gdkDrawable,
2748cdf0e10cSrcweir                            GTK_STATE_NORMAL,
2749cdf0e10cSrcweir                            GTK_SHADOW_OUT,
2750cdf0e10cSrcweir                            &clipRect,
2751cdf0e10cSrcweir                            gWidgetData[m_nScreen].gMenuWidget,
2752cdf0e10cSrcweir                            "menu",
2753cdf0e10cSrcweir                            x, y, w, h );
2754cdf0e10cSrcweir         }
2755cdf0e10cSrcweir         else if( nPart == PART_MENU_ITEM )
2756cdf0e10cSrcweir         {
2757cdf0e10cSrcweir             if( nState & (CTRL_STATE_SELECTED|CTRL_STATE_ROLLOVER) )
2758cdf0e10cSrcweir             {
2759cdf0e10cSrcweir                 if( nState & CTRL_STATE_ENABLED )
2760cdf0e10cSrcweir                 gtk_paint_box( gWidgetData[m_nScreen].gMenuItemMenuWidget->style,
2761cdf0e10cSrcweir                                gdkDrawable,
2762cdf0e10cSrcweir                                GTK_STATE_PRELIGHT,
2763cdf0e10cSrcweir                                selected_shadow_type,
2764cdf0e10cSrcweir                                &clipRect,
2765cdf0e10cSrcweir                                gWidgetData[m_nScreen].gMenuItemMenuWidget,
2766cdf0e10cSrcweir                                "menuitem",
2767cdf0e10cSrcweir                                x, y, w, h);
2768cdf0e10cSrcweir             }
2769cdf0e10cSrcweir         }
2770cdf0e10cSrcweir         else if( nPart == PART_MENU_ITEM_CHECK_MARK || nPart == PART_MENU_ITEM_RADIO_MARK )
2771cdf0e10cSrcweir         {
2772cdf0e10cSrcweir             GtkWidget* pWidget = (nPart == PART_MENU_ITEM_CHECK_MARK) ?
2773cdf0e10cSrcweir                                  gWidgetData[m_nScreen].gMenuItemCheckMenuWidget :
2774cdf0e10cSrcweir                                  gWidgetData[m_nScreen].gMenuItemRadioMenuWidget;
2775cdf0e10cSrcweir 
2776cdf0e10cSrcweir             GtkStateType nStateType = GTK_STATE_NORMAL;
2777cdf0e10cSrcweir             GtkShadowType nShadowType;
2778cdf0e10cSrcweir 
2779cdf0e10cSrcweir             if ( nState & CTRL_STATE_SELECTED )
2780cdf0e10cSrcweir                 nStateType = GTK_STATE_PRELIGHT;
2781cdf0e10cSrcweir 
2782cdf0e10cSrcweir             NWSetWidgetState( pWidget, nState, nStateType );
2783cdf0e10cSrcweir 
2784cdf0e10cSrcweir             if ( nState & CTRL_STATE_PRESSED )
2785cdf0e10cSrcweir                 nShadowType = GTK_SHADOW_IN;
2786cdf0e10cSrcweir             else
2787cdf0e10cSrcweir                 nShadowType = GTK_SHADOW_OUT;
2788cdf0e10cSrcweir 
2789cdf0e10cSrcweir             if ( nPart == PART_MENU_ITEM_CHECK_MARK )
2790cdf0e10cSrcweir             {
2791cdf0e10cSrcweir                 gtk_paint_check( pWidget->style,
2792cdf0e10cSrcweir                                  gdkDrawable,
2793cdf0e10cSrcweir                                  nStateType,
2794cdf0e10cSrcweir                                  nShadowType,
2795cdf0e10cSrcweir                                  &clipRect,
2796cdf0e10cSrcweir                                  gWidgetData[m_nScreen].gMenuItemMenuWidget,
2797cdf0e10cSrcweir                                  "check",
2798cdf0e10cSrcweir                                  x, y, w, h );
2799cdf0e10cSrcweir             }
2800cdf0e10cSrcweir             else
2801cdf0e10cSrcweir             {
2802cdf0e10cSrcweir                 gtk_paint_option( pWidget->style,
2803cdf0e10cSrcweir                                   gdkDrawable,
2804cdf0e10cSrcweir                                   nStateType,
2805cdf0e10cSrcweir                                   nShadowType,
2806cdf0e10cSrcweir                                   &clipRect,
2807cdf0e10cSrcweir                                   gWidgetData[m_nScreen].gMenuItemMenuWidget,
2808cdf0e10cSrcweir                                   "option",
2809cdf0e10cSrcweir                                   x, y, w, h );
2810cdf0e10cSrcweir             }
2811cdf0e10cSrcweir         }
2812cdf0e10cSrcweir     }
2813cdf0e10cSrcweir 
2814cdf0e10cSrcweir 	return( sal_True );
2815cdf0e10cSrcweir }
2816cdf0e10cSrcweir 
2817cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKTooltip(
2818cdf0e10cSrcweir             GdkDrawable* gdkDrawable,
2819cdf0e10cSrcweir             ControlType, ControlPart,
2820cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
2821cdf0e10cSrcweir             const clipList& rClipList,
2822cdf0e10cSrcweir             ControlState, const ImplControlValue&,
2823cdf0e10cSrcweir 			const OUString& )
2824cdf0e10cSrcweir {
2825cdf0e10cSrcweir     NWEnsureGTKTooltip( m_nScreen );
2826cdf0e10cSrcweir 
2827cdf0e10cSrcweir 	gint			x, y, w, h;
2828cdf0e10cSrcweir     GdkRectangle	clipRect;
2829cdf0e10cSrcweir 
2830cdf0e10cSrcweir 	x = rControlRectangle.Left();
2831cdf0e10cSrcweir     y = rControlRectangle.Top();
2832cdf0e10cSrcweir 	w = rControlRectangle.GetWidth();
2833cdf0e10cSrcweir 	h = rControlRectangle.GetHeight();
2834cdf0e10cSrcweir 
2835cdf0e10cSrcweir     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
2836cdf0e10cSrcweir     {
2837cdf0e10cSrcweir         clipRect.x = it->Left();
2838cdf0e10cSrcweir         clipRect.y = it->Top();
2839cdf0e10cSrcweir         clipRect.width = it->GetWidth();
2840cdf0e10cSrcweir         clipRect.height = it->GetHeight();
2841cdf0e10cSrcweir 
2842cdf0e10cSrcweir         gtk_paint_flat_box( gWidgetData[m_nScreen].gTooltipPopup->style,
2843cdf0e10cSrcweir                             gdkDrawable,
2844cdf0e10cSrcweir                             GTK_STATE_NORMAL,
2845cdf0e10cSrcweir                             GTK_SHADOW_OUT,
2846cdf0e10cSrcweir                             &clipRect,
2847cdf0e10cSrcweir                             gWidgetData[m_nScreen].gTooltipPopup,
2848cdf0e10cSrcweir                             "tooltip",
2849cdf0e10cSrcweir                             x, y, w, h );
2850cdf0e10cSrcweir     }
2851cdf0e10cSrcweir 
2852cdf0e10cSrcweir 	return( sal_True );
2853cdf0e10cSrcweir }
2854cdf0e10cSrcweir 
2855cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKListNode(
2856cdf0e10cSrcweir             GdkDrawable*,
2857cdf0e10cSrcweir             ControlType, ControlPart,
2858cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
2859cdf0e10cSrcweir             const clipList&,
2860cdf0e10cSrcweir             ControlState nState, const ImplControlValue& rValue,
2861cdf0e10cSrcweir 			const OUString& )
2862cdf0e10cSrcweir {
2863cdf0e10cSrcweir     NWEnsureGTKTreeView( m_nScreen );
2864cdf0e10cSrcweir 
2865cdf0e10cSrcweir     Rectangle aRect( rControlRectangle );
2866cdf0e10cSrcweir     aRect.Left() -= 2;
2867cdf0e10cSrcweir     aRect.Right() += 2;
2868cdf0e10cSrcweir     aRect.Top() -= 2;
2869cdf0e10cSrcweir     aRect.Bottom() += 2;
2870cdf0e10cSrcweir 	gint			w, h;
2871cdf0e10cSrcweir 	w = aRect.GetWidth();
2872cdf0e10cSrcweir 	h = aRect.GetHeight();
2873cdf0e10cSrcweir 
2874cdf0e10cSrcweir 	GtkStateType	stateType;
2875cdf0e10cSrcweir 	GtkShadowType	shadowType;
2876cdf0e10cSrcweir 	NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
2877cdf0e10cSrcweir 
2878cdf0e10cSrcweir     ButtonValue aButtonValue = rValue.getTristateVal();
2879cdf0e10cSrcweir     GtkExpanderStyle eStyle = GTK_EXPANDER_EXPANDED;
2880cdf0e10cSrcweir 
2881cdf0e10cSrcweir     switch( aButtonValue )
2882cdf0e10cSrcweir     {
2883cdf0e10cSrcweir         case BUTTONVALUE_ON: eStyle = GTK_EXPANDER_EXPANDED;break;
2884cdf0e10cSrcweir         case BUTTONVALUE_OFF: eStyle = GTK_EXPANDER_COLLAPSED; break;
2885cdf0e10cSrcweir         default:
2886cdf0e10cSrcweir             break;
2887cdf0e10cSrcweir     }
2888cdf0e10cSrcweir 
2889cdf0e10cSrcweir     GdkPixmap* pixmap = NWGetPixmapFromScreen( aRect );
2890cdf0e10cSrcweir     if( ! pixmap )
2891cdf0e10cSrcweir         return sal_False;
2892cdf0e10cSrcweir 
2893cdf0e10cSrcweir     GdkDrawable* const &pixDrawable = GDK_DRAWABLE( pixmap );
2894cdf0e10cSrcweir     gtk_paint_expander( gWidgetData[m_nScreen].gTreeView->style,
2895cdf0e10cSrcweir                         pixDrawable,
2896cdf0e10cSrcweir                         stateType,
2897cdf0e10cSrcweir                         NULL,
2898cdf0e10cSrcweir                         gWidgetData[m_nScreen].gTreeView,
2899cdf0e10cSrcweir                         "treeview",
2900cdf0e10cSrcweir                         w/2, h/2,
2901cdf0e10cSrcweir                         eStyle );
2902cdf0e10cSrcweir 
2903cdf0e10cSrcweir 	sal_Bool bRet = NWRenderPixmapToScreen( pixmap, aRect );
2904cdf0e10cSrcweir     g_object_unref( pixmap );
2905cdf0e10cSrcweir 
2906cdf0e10cSrcweir 	return bRet;
2907cdf0e10cSrcweir }
2908cdf0e10cSrcweir 
2909cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKProgress(
2910cdf0e10cSrcweir             GdkDrawable*,
2911cdf0e10cSrcweir             ControlType, ControlPart,
2912cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
2913cdf0e10cSrcweir             const clipList&,
2914cdf0e10cSrcweir             ControlState, const ImplControlValue& rValue,
2915cdf0e10cSrcweir 			const OUString& )
2916cdf0e10cSrcweir {
2917cdf0e10cSrcweir     NWEnsureGTKProgressBar( m_nScreen );
2918cdf0e10cSrcweir 
2919cdf0e10cSrcweir 	gint			w, h;
2920cdf0e10cSrcweir 	w = rControlRectangle.GetWidth();
2921cdf0e10cSrcweir 	h = rControlRectangle.GetHeight();
2922cdf0e10cSrcweir 
2923cdf0e10cSrcweir     long nProgressWidth = rValue.getNumericVal();
2924cdf0e10cSrcweir 
2925cdf0e10cSrcweir     GdkPixmap* pixmap = NWGetPixmapFromScreen( Rectangle( Point( 0, 0 ), Size( w, h ) ) );
2926cdf0e10cSrcweir     if( ! pixmap )
2927cdf0e10cSrcweir         return sal_False;
2928cdf0e10cSrcweir 
2929cdf0e10cSrcweir     GdkDrawable* const &pixDrawable = GDK_DRAWABLE( pixmap );
2930cdf0e10cSrcweir 
2931cdf0e10cSrcweir     // paint background
2932cdf0e10cSrcweir     gtk_paint_flat_box( gWidgetData[m_nScreen].gProgressBar->style,
2933cdf0e10cSrcweir                         pixDrawable,
2934cdf0e10cSrcweir                         GTK_STATE_NORMAL,
2935cdf0e10cSrcweir                         GTK_SHADOW_NONE,
2936cdf0e10cSrcweir                         NULL,
2937cdf0e10cSrcweir                         gWidgetData[m_nScreen].gProgressBar,
2938cdf0e10cSrcweir                         "trough",
2939cdf0e10cSrcweir                         0, 0, w, h );
2940cdf0e10cSrcweir     if( nProgressWidth > 0 )
2941cdf0e10cSrcweir     {
2942cdf0e10cSrcweir         // paint progress
2943cdf0e10cSrcweir         if( Application::GetSettings().GetLayoutRTL() )
2944cdf0e10cSrcweir         {
2945cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gProgressBar->style,
2946cdf0e10cSrcweir                            pixDrawable,
2947cdf0e10cSrcweir                            GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
2948cdf0e10cSrcweir                            NULL,
2949cdf0e10cSrcweir                            gWidgetData[m_nScreen].gProgressBar,
2950cdf0e10cSrcweir                            "bar",
2951cdf0e10cSrcweir                            w-nProgressWidth, 0, nProgressWidth, h
2952cdf0e10cSrcweir                            );
2953cdf0e10cSrcweir         }
2954cdf0e10cSrcweir         else
2955cdf0e10cSrcweir         {
2956cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gProgressBar->style,
2957cdf0e10cSrcweir                            pixDrawable,
2958cdf0e10cSrcweir                            GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
2959cdf0e10cSrcweir                            NULL,
2960cdf0e10cSrcweir                            gWidgetData[m_nScreen].gProgressBar,
2961cdf0e10cSrcweir                            "bar",
2962cdf0e10cSrcweir                            0, 0, nProgressWidth, h
2963cdf0e10cSrcweir                            );
2964cdf0e10cSrcweir         }
2965cdf0e10cSrcweir     }
2966cdf0e10cSrcweir 
2967cdf0e10cSrcweir 	sal_Bool bRet = NWRenderPixmapToScreen( pixmap, rControlRectangle );
2968cdf0e10cSrcweir     g_object_unref( pixmap );
2969cdf0e10cSrcweir 
2970cdf0e10cSrcweir 	return bRet;
2971cdf0e10cSrcweir }
2972cdf0e10cSrcweir 
2973cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWPaintGTKSlider(
2974cdf0e10cSrcweir             GdkDrawable*,
2975cdf0e10cSrcweir             ControlType, ControlPart nPart,
2976cdf0e10cSrcweir 			const Rectangle& rControlRectangle,
2977cdf0e10cSrcweir             const clipList&,
2978cdf0e10cSrcweir             ControlState nState, const ImplControlValue& rValue,
2979cdf0e10cSrcweir 			const OUString& )
2980cdf0e10cSrcweir {
2981cdf0e10cSrcweir     OSL_ASSERT( rValue.getType() == CTRL_SLIDER );
2982cdf0e10cSrcweir     NWEnsureGTKSlider( m_nScreen );
2983cdf0e10cSrcweir 
2984cdf0e10cSrcweir 	gint			w, h;
2985cdf0e10cSrcweir 	w = rControlRectangle.GetWidth();
2986cdf0e10cSrcweir 	h = rControlRectangle.GetHeight();
2987cdf0e10cSrcweir 
2988cdf0e10cSrcweir     const SliderValue* pVal = static_cast<const SliderValue*>(&rValue);
2989cdf0e10cSrcweir 
2990cdf0e10cSrcweir     GdkPixmap* pixmap = NWGetPixmapFromScreen( rControlRectangle );
2991cdf0e10cSrcweir     if( ! pixmap )
2992cdf0e10cSrcweir         return sal_False;
2993cdf0e10cSrcweir 
2994cdf0e10cSrcweir     GdkDrawable* const &pixDrawable = GDK_DRAWABLE( pixmap );
2995cdf0e10cSrcweir     GtkWidget* pWidget = (nPart == PART_TRACK_HORZ_AREA)
2996cdf0e10cSrcweir                          ? GTK_WIDGET(gWidgetData[m_nScreen].gHScale)
2997cdf0e10cSrcweir                          : GTK_WIDGET(gWidgetData[m_nScreen].gVScale);
2998cdf0e10cSrcweir     const gchar* pDetail = (nPart == PART_TRACK_HORZ_AREA) ? "hscale" : "vscale";
2999cdf0e10cSrcweir     GtkOrientation eOri = (nPart == PART_TRACK_HORZ_AREA) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
3000cdf0e10cSrcweir     GtkStateType eState = (nState & CTRL_STATE_ENABLED) ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE;
3001cdf0e10cSrcweir     gint slider_width = 10;
3002cdf0e10cSrcweir     gint slider_length = 10;
3003cdf0e10cSrcweir     gint trough_border = 0;
3004cdf0e10cSrcweir     gtk_widget_style_get( pWidget,
3005cdf0e10cSrcweir                           "slider-width", &slider_width,
3006cdf0e10cSrcweir                           "slider-length", &slider_length,
3007cdf0e10cSrcweir                           "trough-border", &trough_border,
3008cdf0e10cSrcweir                           NULL);
3009cdf0e10cSrcweir 
3010cdf0e10cSrcweir     eState = (nState & CTRL_STATE_ENABLED) ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
3011cdf0e10cSrcweir     if( nPart == PART_TRACK_HORZ_AREA )
3012cdf0e10cSrcweir     {
3013cdf0e10cSrcweir         gtk_paint_box( pWidget->style,
3014cdf0e10cSrcweir                        pixDrawable,
3015cdf0e10cSrcweir                        eState,
3016cdf0e10cSrcweir                        GTK_SHADOW_IN,
3017cdf0e10cSrcweir                        NULL,
3018cdf0e10cSrcweir                        pWidget,
3019cdf0e10cSrcweir                        "trough",
3020cdf0e10cSrcweir                        0, (h-slider_width-2*trough_border)/2, w, slider_width + 2*trough_border);
3021cdf0e10cSrcweir         gint x = (w - slider_length + 1) * (pVal->mnCur - pVal->mnMin) / (pVal->mnMax - pVal->mnMin);
3022cdf0e10cSrcweir         gtk_paint_slider( pWidget->style,
3023cdf0e10cSrcweir                           pixDrawable,
3024cdf0e10cSrcweir                           eState,
3025cdf0e10cSrcweir                           GTK_SHADOW_OUT,
3026cdf0e10cSrcweir                           NULL,
3027cdf0e10cSrcweir                           pWidget,
3028cdf0e10cSrcweir                           pDetail,
3029cdf0e10cSrcweir                           x, (h-slider_width)/2,
3030cdf0e10cSrcweir                           slider_length, slider_width,
3031cdf0e10cSrcweir                           eOri );
3032cdf0e10cSrcweir     }
3033cdf0e10cSrcweir     else
3034cdf0e10cSrcweir     {
3035cdf0e10cSrcweir         gtk_paint_box( pWidget->style,
3036cdf0e10cSrcweir                        pixDrawable,
3037cdf0e10cSrcweir                        eState,
3038cdf0e10cSrcweir                        GTK_SHADOW_IN,
3039cdf0e10cSrcweir                        NULL,
3040cdf0e10cSrcweir                        pWidget,
3041cdf0e10cSrcweir                        "trough",
3042cdf0e10cSrcweir                        (w-slider_width-2*trough_border)/2, 0, slider_width + 2*trough_border, h);
3043cdf0e10cSrcweir         gint y = (h - slider_length + 1) * (pVal->mnCur - pVal->mnMin) / (pVal->mnMax - pVal->mnMin);
3044cdf0e10cSrcweir         gtk_paint_slider( pWidget->style,
3045cdf0e10cSrcweir                           pixDrawable,
3046cdf0e10cSrcweir                           eState,
3047cdf0e10cSrcweir                           GTK_SHADOW_OUT,
3048cdf0e10cSrcweir                           NULL,
3049cdf0e10cSrcweir                           pWidget,
3050cdf0e10cSrcweir                           pDetail,
3051cdf0e10cSrcweir                           (w-slider_width)/2, y,
3052cdf0e10cSrcweir                           slider_width, slider_length,
3053cdf0e10cSrcweir                           eOri );
3054cdf0e10cSrcweir     }
3055cdf0e10cSrcweir     #if 0
3056cdf0e10cSrcweir     // paint background
3057cdf0e10cSrcweir     gtk_paint_flat_box( gWidgetData[m_nScreen].gProgressBar->style,
3058cdf0e10cSrcweir                         pixDrawable,
3059cdf0e10cSrcweir                         GTK_STATE_NORMAL,
3060cdf0e10cSrcweir                         GTK_SHADOW_NONE,
3061cdf0e10cSrcweir                         NULL,
3062cdf0e10cSrcweir                         gWidgetData[m_nScreen].gProgressBar,
3063cdf0e10cSrcweir                         "trough",
3064cdf0e10cSrcweir                         0, 0, w, h );
3065cdf0e10cSrcweir     if( nProgressWidth > 0 )
3066cdf0e10cSrcweir     {
3067cdf0e10cSrcweir         // paint progress
3068cdf0e10cSrcweir         if( Application::GetSettings().GetLayoutRTL() )
3069cdf0e10cSrcweir         {
3070cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gProgressBar->style,
3071cdf0e10cSrcweir                            pixDrawable,
3072cdf0e10cSrcweir                            GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
3073cdf0e10cSrcweir                            NULL,
3074cdf0e10cSrcweir                            gWidgetData[m_nScreen].gProgressBar,
3075cdf0e10cSrcweir                            "bar",
3076cdf0e10cSrcweir                            w-nProgressWidth, 0, nProgressWidth, h
3077cdf0e10cSrcweir                            );
3078cdf0e10cSrcweir         }
3079cdf0e10cSrcweir         else
3080cdf0e10cSrcweir         {
3081cdf0e10cSrcweir             gtk_paint_box( gWidgetData[m_nScreen].gProgressBar->style,
3082cdf0e10cSrcweir                            pixDrawable,
3083cdf0e10cSrcweir                            GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
3084cdf0e10cSrcweir                            NULL,
3085cdf0e10cSrcweir                            gWidgetData[m_nScreen].gProgressBar,
3086cdf0e10cSrcweir                            "bar",
3087cdf0e10cSrcweir                            0, 0, nProgressWidth, h
3088cdf0e10cSrcweir                            );
3089cdf0e10cSrcweir         }
3090cdf0e10cSrcweir     }
3091cdf0e10cSrcweir     #endif
3092cdf0e10cSrcweir 
3093cdf0e10cSrcweir 	sal_Bool bRet = NWRenderPixmapToScreen( pixmap, rControlRectangle );
3094cdf0e10cSrcweir     g_object_unref( pixmap );
3095cdf0e10cSrcweir 
3096cdf0e10cSrcweir 	return bRet;
3097cdf0e10cSrcweir }
3098cdf0e10cSrcweir 
3099cdf0e10cSrcweir //----
3100cdf0e10cSrcweir 
3101cdf0e10cSrcweir static Rectangle NWGetListBoxButtonRect( int nScreen,
3102cdf0e10cSrcweir                                          ControlType,
3103cdf0e10cSrcweir                                          ControlPart    nPart,
3104cdf0e10cSrcweir                                          Rectangle      aAreaRect,
3105cdf0e10cSrcweir                                          ControlState,
3106cdf0e10cSrcweir                                          const ImplControlValue&,
3107cdf0e10cSrcweir                                          const OUString& )
3108cdf0e10cSrcweir {
3109cdf0e10cSrcweir 	Rectangle       aPartRect;
3110cdf0e10cSrcweir 	GtkRequisition *pIndicatorSize = NULL;
3111cdf0e10cSrcweir 	GtkBorder      *pIndicatorSpacing = NULL;
3112cdf0e10cSrcweir 	gint            width = 13;	// GTK+ default
3113cdf0e10cSrcweir 	gint            right = 5;	// GTK+ default
3114cdf0e10cSrcweir 	gint            nButtonAreaWidth = 0;
3115cdf0e10cSrcweir     gint            xthickness = 0;
3116cdf0e10cSrcweir 
3117cdf0e10cSrcweir 	NWEnsureGTKOptionMenu( nScreen );
3118cdf0e10cSrcweir 
3119cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[nScreen].gOptionMenuWidget,
3120cdf0e10cSrcweir 			"indicator_size",	&pIndicatorSize,
3121cdf0e10cSrcweir 			"indicator_spacing",&pIndicatorSpacing, (char *)NULL);
3122cdf0e10cSrcweir 
3123cdf0e10cSrcweir 	if ( pIndicatorSize )
3124cdf0e10cSrcweir 		width = pIndicatorSize->width;
3125cdf0e10cSrcweir 
3126cdf0e10cSrcweir 	if ( pIndicatorSpacing )
3127cdf0e10cSrcweir 		right = pIndicatorSpacing->right;
3128cdf0e10cSrcweir 
3129cdf0e10cSrcweir     Size aPartSize( 0, aAreaRect.GetHeight() );
3130cdf0e10cSrcweir     Point aPartPos ( 0, aAreaRect.Top() );
3131cdf0e10cSrcweir 
3132cdf0e10cSrcweir     xthickness = gWidgetData[nScreen].gOptionMenuWidget->style->xthickness;
3133cdf0e10cSrcweir 	nButtonAreaWidth = width + right + (xthickness * 2);
3134cdf0e10cSrcweir 	switch( nPart )
3135cdf0e10cSrcweir 	{
3136cdf0e10cSrcweir 		case PART_BUTTON_DOWN:
3137cdf0e10cSrcweir 			aPartSize.Width() = nButtonAreaWidth;
3138cdf0e10cSrcweir 			aPartPos.X() = aAreaRect.Left() + aAreaRect.GetWidth() - aPartSize.Width();
3139cdf0e10cSrcweir 			break;
3140cdf0e10cSrcweir 
3141cdf0e10cSrcweir 		case PART_SUB_EDIT:
3142cdf0e10cSrcweir 			aPartSize.Width() = aAreaRect.GetWidth() - nButtonAreaWidth - xthickness;
3143cdf0e10cSrcweir 			aPartPos.X() = aAreaRect.Left() + xthickness;
3144cdf0e10cSrcweir 			break;
3145cdf0e10cSrcweir 
3146cdf0e10cSrcweir 		default:
3147cdf0e10cSrcweir 			aPartSize.Width() = aAreaRect.GetWidth();
3148cdf0e10cSrcweir 			aPartPos.X() = aAreaRect.Left();
3149cdf0e10cSrcweir 			break;
3150cdf0e10cSrcweir 	}
3151cdf0e10cSrcweir     aPartRect = Rectangle( aPartPos, aPartSize );
3152cdf0e10cSrcweir 
3153cdf0e10cSrcweir 	if ( pIndicatorSize )
3154cdf0e10cSrcweir 		gtk_requisition_free( pIndicatorSize );
3155cdf0e10cSrcweir 	if ( pIndicatorSpacing )
3156cdf0e10cSrcweir 		gtk_border_free( pIndicatorSpacing );
3157cdf0e10cSrcweir 
3158cdf0e10cSrcweir 	return( aPartRect );
3159cdf0e10cSrcweir }
3160cdf0e10cSrcweir 
3161cdf0e10cSrcweir //----
3162cdf0e10cSrcweir 
3163cdf0e10cSrcweir static Rectangle NWGetListBoxIndicatorRect( int nScreen,
3164cdf0e10cSrcweir                                             ControlType,
3165cdf0e10cSrcweir                                             ControlPart,
3166cdf0e10cSrcweir                                             Rectangle				aAreaRect,
3167cdf0e10cSrcweir                                             ControlState,
3168cdf0e10cSrcweir                                             const ImplControlValue&,
3169cdf0e10cSrcweir                                             const OUString& )
3170cdf0e10cSrcweir {
3171cdf0e10cSrcweir 	Rectangle       aIndicatorRect;
3172cdf0e10cSrcweir 	GtkRequisition *pIndicatorSize = NULL;
3173cdf0e10cSrcweir 	GtkBorder      *pIndicatorSpacing = NULL;
3174cdf0e10cSrcweir 	gint            width = 13;	// GTK+ default
3175cdf0e10cSrcweir 	gint            height = 13;	// GTK+ default
3176cdf0e10cSrcweir 	gint            right = 5;	// GTK+ default
3177cdf0e10cSrcweir 
3178cdf0e10cSrcweir 	NWEnsureGTKOptionMenu( nScreen );
3179cdf0e10cSrcweir 
3180cdf0e10cSrcweir 	gtk_widget_style_get( gWidgetData[nScreen].gOptionMenuWidget,
3181cdf0e10cSrcweir 			"indicator_size",	&pIndicatorSize,
3182cdf0e10cSrcweir 			"indicator_spacing",&pIndicatorSpacing, (char *)NULL);
3183cdf0e10cSrcweir 
3184cdf0e10cSrcweir 	if ( pIndicatorSize )
3185cdf0e10cSrcweir     {
3186cdf0e10cSrcweir 		width = pIndicatorSize->width;
3187cdf0e10cSrcweir 		height = pIndicatorSize->height;
3188cdf0e10cSrcweir     }
3189cdf0e10cSrcweir 
3190cdf0e10cSrcweir 	if ( pIndicatorSpacing )
3191cdf0e10cSrcweir 		right = pIndicatorSpacing->right;
3192cdf0e10cSrcweir 
3193cdf0e10cSrcweir     aIndicatorRect.SetSize( Size( width, height ) );
3194cdf0e10cSrcweir 	aIndicatorRect.SetPos( Point( aAreaRect.Left() + aAreaRect.GetWidth() - width - right - gWidgetData[nScreen].gOptionMenuWidget->style->xthickness,
3195cdf0e10cSrcweir                                   aAreaRect.Top() + ((aAreaRect.GetHeight() - height) / 2) ) );
3196cdf0e10cSrcweir 
3197cdf0e10cSrcweir 	// If height is odd, move the indicator down 1 pixel
3198cdf0e10cSrcweir 	if ( aIndicatorRect.GetHeight() % 2 )
3199cdf0e10cSrcweir 		aIndicatorRect.Move( 0, 1 );
3200cdf0e10cSrcweir 
3201cdf0e10cSrcweir 	if ( pIndicatorSize )
3202cdf0e10cSrcweir 		gtk_requisition_free( pIndicatorSize );
3203cdf0e10cSrcweir 	if ( pIndicatorSpacing )
3204cdf0e10cSrcweir 		gtk_border_free( pIndicatorSpacing );
3205cdf0e10cSrcweir 
3206cdf0e10cSrcweir 	return( aIndicatorRect );
3207cdf0e10cSrcweir }
3208cdf0e10cSrcweir 
3209cdf0e10cSrcweir static Rectangle NWGetToolbarRect(  int nScreen,
3210cdf0e10cSrcweir                                     ControlType,
3211cdf0e10cSrcweir 									ControlPart				nPart,
3212cdf0e10cSrcweir 									Rectangle				aAreaRect,
3213cdf0e10cSrcweir 									ControlState,
3214cdf0e10cSrcweir 									const ImplControlValue&,
3215cdf0e10cSrcweir 									const OUString& )
3216cdf0e10cSrcweir {
3217cdf0e10cSrcweir     Rectangle aRet;
3218cdf0e10cSrcweir 
3219cdf0e10cSrcweir     if( nPart == PART_DRAW_BACKGROUND_HORZ ||
3220cdf0e10cSrcweir         nPart == PART_DRAW_BACKGROUND_VERT )
3221cdf0e10cSrcweir         aRet = aAreaRect;
3222cdf0e10cSrcweir     else if( nPart == PART_THUMB_HORZ )
3223cdf0e10cSrcweir         aRet = Rectangle( Point( 0, 0 ), Size( aAreaRect.GetWidth(), 10 ) );
3224cdf0e10cSrcweir     else if( nPart == PART_THUMB_VERT )
3225cdf0e10cSrcweir         aRet = Rectangle( Point( 0, 0 ), Size( 10, aAreaRect.GetHeight() ) );
3226cdf0e10cSrcweir     else if( nPart == PART_BUTTON )
3227cdf0e10cSrcweir     {
3228cdf0e10cSrcweir         aRet = aAreaRect;
3229cdf0e10cSrcweir 
3230cdf0e10cSrcweir         NWEnsureGTKToolbar( nScreen );
3231cdf0e10cSrcweir 
3232cdf0e10cSrcweir         gint nMinWidth =
3233cdf0e10cSrcweir             2*gWidgetData[nScreen].gToolbarButtonWidget->style->xthickness
3234cdf0e10cSrcweir             + 1 // CHILD_SPACING constant, found in gtk_button.c
3235cdf0e10cSrcweir             + 3*gWidgetData[nScreen].gToolbarButtonWidget->style->xthickness; // Murphy factor
3236cdf0e10cSrcweir         gint nMinHeight =
3237cdf0e10cSrcweir             2*gWidgetData[nScreen].gToolbarButtonWidget->style->ythickness
3238cdf0e10cSrcweir             + 1 // CHILD_SPACING constant, found in gtk_button.c
3239cdf0e10cSrcweir             + 3*gWidgetData[nScreen].gToolbarButtonWidget->style->ythickness; // Murphy factor
3240cdf0e10cSrcweir 
3241cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gToolbarButtonWidget );
3242cdf0e10cSrcweir         if( aAreaRect.GetWidth() < nMinWidth )
3243cdf0e10cSrcweir             aRet.Right() = aRet.Left() + nMinWidth;
3244cdf0e10cSrcweir         if( aAreaRect.GetHeight() < nMinHeight  )
3245cdf0e10cSrcweir             aRet.Bottom() = aRet.Top() + nMinHeight;
3246cdf0e10cSrcweir     }
3247cdf0e10cSrcweir 
3248cdf0e10cSrcweir     return aRet;
3249cdf0e10cSrcweir }
3250cdf0e10cSrcweir 
3251cdf0e10cSrcweir /************************************************************************
3252cdf0e10cSrcweir  * helper for GtkSalFrame
3253cdf0e10cSrcweir  ************************************************************************/
3254cdf0e10cSrcweir static inline Color getColor( const GdkColor& rCol )
3255cdf0e10cSrcweir {
3256cdf0e10cSrcweir     return Color( rCol.red >> 8, rCol.green >> 8, rCol.blue >> 8 );
3257cdf0e10cSrcweir }
3258cdf0e10cSrcweir 
3259cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
3260cdf0e10cSrcweir 
3261cdf0e10cSrcweir void printColor( const char* name, const GdkColor& rCol )
3262cdf0e10cSrcweir {
3263cdf0e10cSrcweir     std::fprintf( stderr, "   %s = 0x%2x 0x%2x 0x%2x\n",
3264cdf0e10cSrcweir              name,
3265cdf0e10cSrcweir              rCol.red >> 8, rCol.green >> 8, rCol.blue >> 8 );
3266cdf0e10cSrcweir }
3267cdf0e10cSrcweir 
3268cdf0e10cSrcweir void printStyleColors( GtkStyle* pStyle )
3269cdf0e10cSrcweir {
3270cdf0e10cSrcweir     static const char* pStates[] = { "NORMAL", "ACTIVE", "PRELIGHT", "SELECTED", "INSENSITIVE" };
3271cdf0e10cSrcweir 
3272cdf0e10cSrcweir     for( int i = 0; i < 5; i++ )
3273cdf0e10cSrcweir     {
3274cdf0e10cSrcweir         std::fprintf( stderr, "state %s colors:\n", pStates[i] );
3275cdf0e10cSrcweir         printColor( "bg     ", pStyle->bg[i] );
3276cdf0e10cSrcweir         printColor( "fg     ", pStyle->fg[i] );
3277cdf0e10cSrcweir         printColor( "light  ", pStyle->light[i] );
3278cdf0e10cSrcweir         printColor( "dark   ", pStyle->dark[i] );
3279cdf0e10cSrcweir         printColor( "mid    ", pStyle->mid[i] );
3280cdf0e10cSrcweir         printColor( "text   ", pStyle->text[i] );
3281cdf0e10cSrcweir         printColor( "base   ", pStyle->base[i] );
3282cdf0e10cSrcweir         printColor( "text_aa", pStyle->text_aa[i] );
3283cdf0e10cSrcweir     }
3284cdf0e10cSrcweir }
3285cdf0e10cSrcweir #endif
3286cdf0e10cSrcweir 
3287cdf0e10cSrcweir void GtkSalGraphics::updateSettings( AllSettings& rSettings )
3288cdf0e10cSrcweir {
3289cdf0e10cSrcweir     // get the widgets in place
3290cdf0e10cSrcweir     NWEnsureGTKMenu( m_nScreen );
3291cdf0e10cSrcweir     NWEnsureGTKMenubar( m_nScreen );
3292cdf0e10cSrcweir     NWEnsureGTKScrollbars( m_nScreen );
3293cdf0e10cSrcweir     NWEnsureGTKEditBox( m_nScreen );
3294cdf0e10cSrcweir     NWEnsureGTKTooltip( m_nScreen );
3295cdf0e10cSrcweir 
3296cdf0e10cSrcweir     gtk_widget_ensure_style( m_pWindow );
3297cdf0e10cSrcweir     GtkStyle* pStyle = gtk_widget_get_style( m_pWindow );
3298cdf0e10cSrcweir 
3299cdf0e10cSrcweir     StyleSettings aStyleSet = rSettings.GetStyleSettings();
3300cdf0e10cSrcweir 
3301cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 2
3302cdf0e10cSrcweir     printStyleColors( pStyle );
3303cdf0e10cSrcweir #endif
3304cdf0e10cSrcweir 
3305cdf0e10cSrcweir     // text colors
3306cdf0e10cSrcweir     Color aTextColor = getColor( pStyle->text[GTK_STATE_NORMAL] );
3307cdf0e10cSrcweir     aStyleSet.SetDialogTextColor( aTextColor );
3308cdf0e10cSrcweir     aStyleSet.SetButtonTextColor( aTextColor );
3309cdf0e10cSrcweir     aStyleSet.SetRadioCheckTextColor( aTextColor );
3310cdf0e10cSrcweir     aStyleSet.SetGroupTextColor( aTextColor );
3311cdf0e10cSrcweir     aStyleSet.SetLabelTextColor( aTextColor );
3312cdf0e10cSrcweir     aStyleSet.SetInfoTextColor( aTextColor );
3313cdf0e10cSrcweir     aStyleSet.SetWindowTextColor( aTextColor );
3314cdf0e10cSrcweir     aStyleSet.SetFieldTextColor( aTextColor );
3315cdf0e10cSrcweir 
3316cdf0e10cSrcweir     // Tooltip colors
3317cdf0e10cSrcweir     GtkStyle* pTooltipStyle = gtk_widget_get_style( gWidgetData[m_nScreen].gTooltipPopup );
3318cdf0e10cSrcweir     aTextColor = getColor( pTooltipStyle->fg[ GTK_STATE_NORMAL ] );
3319cdf0e10cSrcweir     aStyleSet.SetHelpTextColor( aTextColor );
3320cdf0e10cSrcweir 
3321cdf0e10cSrcweir     // mouse over text colors
3322cdf0e10cSrcweir     aTextColor = getColor( pStyle->fg[ GTK_STATE_PRELIGHT ] );
3323cdf0e10cSrcweir     aStyleSet.SetButtonRolloverTextColor( aTextColor );
3324cdf0e10cSrcweir     aStyleSet.SetFieldRolloverTextColor( aTextColor );
3325cdf0e10cSrcweir 
3326cdf0e10cSrcweir     // background colors
3327cdf0e10cSrcweir     Color aBackColor = getColor( pStyle->bg[GTK_STATE_NORMAL] );
3328cdf0e10cSrcweir     Color aBackFieldColor = getColor( pStyle->base[ GTK_STATE_NORMAL ] );
3329cdf0e10cSrcweir     aStyleSet.Set3DColors( aBackColor );
3330cdf0e10cSrcweir     aStyleSet.SetFaceColor( aBackColor );
3331cdf0e10cSrcweir     aStyleSet.SetDialogColor( aBackColor );
3332cdf0e10cSrcweir     aStyleSet.SetWorkspaceColor( aBackColor );
3333cdf0e10cSrcweir     aStyleSet.SetFieldColor( aBackFieldColor );
3334cdf0e10cSrcweir     aStyleSet.SetWindowColor( aBackFieldColor );
3335cdf0e10cSrcweir //    aStyleSet.SetHelpColor( aBackColor );
3336cdf0e10cSrcweir     // ancient wisdom tells us a mystic algorithm how to set checked color
3337cdf0e10cSrcweir     if( aBackColor == COL_LIGHTGRAY )
3338cdf0e10cSrcweir         aStyleSet.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) );
3339cdf0e10cSrcweir     else
3340cdf0e10cSrcweir     {
3341cdf0e10cSrcweir         Color aColor2 = aStyleSet.GetLightColor();
3342cdf0e10cSrcweir         Color aCheck( (sal_uInt8)(((sal_uInt16)aBackColor.GetRed()+(sal_uInt16)aColor2.GetRed())/2),
3343cdf0e10cSrcweir                       (sal_uInt8)(((sal_uInt16)aBackColor.GetGreen()+(sal_uInt16)aColor2.GetGreen())/2),
3344cdf0e10cSrcweir                       (sal_uInt8)(((sal_uInt16)aBackColor.GetBlue()+(sal_uInt16)aColor2.GetBlue())/2)
3345cdf0e10cSrcweir                       );
3346cdf0e10cSrcweir         aStyleSet.SetCheckedColor( aCheck );
3347cdf0e10cSrcweir     }
3348cdf0e10cSrcweir 
3349cdf0e10cSrcweir     // highlighting colors
3350cdf0e10cSrcweir     Color aHighlightColor = getColor( pStyle->base[GTK_STATE_SELECTED] );
3351cdf0e10cSrcweir     Color aHighlightTextColor = getColor( pStyle->text[GTK_STATE_SELECTED] );
3352cdf0e10cSrcweir     aStyleSet.SetHighlightColor( aHighlightColor );
3353cdf0e10cSrcweir     aStyleSet.SetHighlightTextColor( aHighlightTextColor );
3354cdf0e10cSrcweir 
3355cdf0e10cSrcweir     if( ! gtk_check_version( 2, 10, 0 ) ) // link colors came in with 2.10, avoid an assertion
3356cdf0e10cSrcweir     {
3357cdf0e10cSrcweir         // hyperlink colors
3358cdf0e10cSrcweir         GdkColor *link_color = NULL;
3359cdf0e10cSrcweir         gtk_widget_style_get (m_pWindow, "link-color", &link_color, NULL);
3360cdf0e10cSrcweir         if (link_color)
3361cdf0e10cSrcweir         {
3362cdf0e10cSrcweir             aStyleSet.SetLinkColor(getColor(*link_color));
3363cdf0e10cSrcweir             gdk_color_free (link_color);
3364cdf0e10cSrcweir             link_color = NULL;
3365cdf0e10cSrcweir         }
3366cdf0e10cSrcweir         gtk_widget_style_get (m_pWindow, "visited-link-color", &link_color, NULL);
3367cdf0e10cSrcweir         if (link_color)
3368cdf0e10cSrcweir         {
3369cdf0e10cSrcweir             aStyleSet.SetVisitedLinkColor(getColor(*link_color));
3370cdf0e10cSrcweir             gdk_color_free (link_color);
3371cdf0e10cSrcweir         }
3372cdf0e10cSrcweir     }
3373cdf0e10cSrcweir 
3374cdf0e10cSrcweir     // Tab colors
3375cdf0e10cSrcweir     aStyleSet.SetActiveTabColor( aBackFieldColor ); // same as the window color.
3376cdf0e10cSrcweir     Color aSelectedBackColor = getColor( pStyle->bg[GTK_STATE_ACTIVE] );
3377cdf0e10cSrcweir     aStyleSet.SetInactiveTabColor( aSelectedBackColor );
3378cdf0e10cSrcweir 
3379cdf0e10cSrcweir     // menu disabled entries handling
3380cdf0e10cSrcweir     aStyleSet.SetSkipDisabledInMenus( sal_True );
3381cdf0e10cSrcweir     // menu colors
3382cdf0e10cSrcweir     GtkStyle* pMenuStyle = gtk_widget_get_style( gWidgetData[m_nScreen].gMenuWidget );
3383cdf0e10cSrcweir     GtkStyle* pMenuItemStyle = gtk_rc_get_style( gWidgetData[m_nScreen].gMenuItemMenuWidget );
3384cdf0e10cSrcweir     GtkStyle* pMenubarStyle = gtk_rc_get_style( gWidgetData[m_nScreen].gMenubarWidget );
3385cdf0e10cSrcweir     GtkStyle* pMenuTextStyle = gtk_rc_get_style( gtk_bin_get_child( GTK_BIN(gWidgetData[m_nScreen].gMenuItemMenuWidget) ) );
3386cdf0e10cSrcweir 
3387cdf0e10cSrcweir     aBackColor = getColor( pMenubarStyle->bg[GTK_STATE_NORMAL] );
3388cdf0e10cSrcweir     aStyleSet.SetMenuBarColor( aBackColor );
3389cdf0e10cSrcweir     aBackColor = getColor( pMenuStyle->bg[GTK_STATE_NORMAL] );
3390cdf0e10cSrcweir     aTextColor = getColor( pMenuTextStyle->fg[GTK_STATE_NORMAL] );
3391cdf0e10cSrcweir     aStyleSet.SetMenuColor( aBackColor );
3392cdf0e10cSrcweir     aStyleSet.SetMenuTextColor( aTextColor );
3393cdf0e10cSrcweir 
3394cdf0e10cSrcweir     aTextColor = getColor( pMenubarStyle->fg[GTK_STATE_NORMAL] );
3395cdf0e10cSrcweir     aStyleSet.SetMenuBarTextColor( aTextColor );
3396cdf0e10cSrcweir 
3397cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
3398cdf0e10cSrcweir     std::fprintf( stderr, "==\n" );
3399cdf0e10cSrcweir     std::fprintf( stderr, "MenuColor = %x (%d)\n", (int)aStyleSet.GetMenuColor().GetColor(), aStyleSet.GetMenuColor().GetLuminance() );
3400cdf0e10cSrcweir     std::fprintf( stderr, "MenuTextColor = %x (%d)\n", (int)aStyleSet.GetMenuTextColor().GetColor(), aStyleSet.GetMenuTextColor().GetLuminance() );
3401cdf0e10cSrcweir     std::fprintf( stderr, "MenuBarColor = %x (%d)\n", (int)aStyleSet.GetMenuBarColor().GetColor(), aStyleSet.GetMenuBarColor().GetLuminance() );
3402cdf0e10cSrcweir     std::fprintf( stderr, "MenuBarTextColor = %x (%d)\n", (int)aStyleSet.GetMenuBarTextColor().GetColor(), aStyleSet.GetMenuBarTextColor().GetLuminance() );
3403cdf0e10cSrcweir     std::fprintf( stderr, "LightColor = %x (%d)\n", (int)aStyleSet.GetLightColor().GetColor(), aStyleSet.GetLightColor().GetLuminance() );
3404cdf0e10cSrcweir     std::fprintf( stderr, "ShadowColor = %x (%d)\n", (int)aStyleSet.GetShadowColor().GetColor(), aStyleSet.GetShadowColor().GetLuminance() );
3405cdf0e10cSrcweir #endif
3406cdf0e10cSrcweir 
3407cdf0e10cSrcweir     // Awful hack for menu separators in the Sonar and similar themes.
3408cdf0e10cSrcweir     // If the menu color is not too dark, and the menu text color is lighter,
3409cdf0e10cSrcweir     // make the "light" color lighter than the menu color and the "shadow"
3410cdf0e10cSrcweir     // color darker than it.
3411cdf0e10cSrcweir     if ( aStyleSet.GetMenuColor().GetLuminance() >= 32 &&
3412cdf0e10cSrcweir 	 aStyleSet.GetMenuColor().GetLuminance() <= aStyleSet.GetMenuTextColor().GetLuminance() )
3413cdf0e10cSrcweir     {
3414cdf0e10cSrcweir       Color temp = aStyleSet.GetMenuColor();
3415cdf0e10cSrcweir       temp.IncreaseLuminance( 8 );
3416cdf0e10cSrcweir       aStyleSet.SetLightColor( temp );
3417cdf0e10cSrcweir       temp = aStyleSet.GetMenuColor();
3418cdf0e10cSrcweir       temp.DecreaseLuminance( 16 );
3419cdf0e10cSrcweir       aStyleSet.SetShadowColor( temp );
3420cdf0e10cSrcweir     }
3421cdf0e10cSrcweir 
3422cdf0e10cSrcweir     aHighlightColor = getColor( pMenuItemStyle->bg[ GTK_STATE_SELECTED ] );
3423cdf0e10cSrcweir     aHighlightTextColor = getColor( pMenuTextStyle->fg[ GTK_STATE_PRELIGHT ] );
3424cdf0e10cSrcweir     if( aHighlightColor == aHighlightTextColor )
3425cdf0e10cSrcweir         aHighlightTextColor = (aHighlightColor.GetLuminance() < 128) ? Color( COL_WHITE ) : Color( COL_BLACK );
3426cdf0e10cSrcweir     aStyleSet.SetMenuHighlightColor( aHighlightColor );
3427cdf0e10cSrcweir     aStyleSet.SetMenuHighlightTextColor( aHighlightTextColor );
3428cdf0e10cSrcweir 
3429cdf0e10cSrcweir     // UI font
3430cdf0e10cSrcweir     OString	aFamily		= pango_font_description_get_family( pStyle->font_desc );
3431cdf0e10cSrcweir     int nPangoHeight	= pango_font_description_get_size( pStyle->font_desc );
3432cdf0e10cSrcweir     PangoStyle	eStyle	= pango_font_description_get_style( pStyle->font_desc );
3433cdf0e10cSrcweir     PangoWeight	eWeight	= pango_font_description_get_weight( pStyle->font_desc );
3434cdf0e10cSrcweir     PangoStretch eStretch = pango_font_description_get_stretch( pStyle->font_desc );
3435cdf0e10cSrcweir 
3436cdf0e10cSrcweir     psp::FastPrintFontInfo aInfo;
3437cdf0e10cSrcweir     // set family name
3438cdf0e10cSrcweir     aInfo.m_aFamilyName = OStringToOUString( aFamily, RTL_TEXTENCODING_UTF8 );
3439cdf0e10cSrcweir     // set italic
3440cdf0e10cSrcweir     switch( eStyle )
3441cdf0e10cSrcweir     {
3442cdf0e10cSrcweir         case PANGO_STYLE_NORMAL:	aInfo.m_eItalic = psp::italic::Upright;break;
3443cdf0e10cSrcweir         case PANGO_STYLE_ITALIC:	aInfo.m_eItalic = psp::italic::Italic;break;
3444cdf0e10cSrcweir         case PANGO_STYLE_OBLIQUE:	aInfo.m_eItalic = psp::italic::Oblique;break;
3445cdf0e10cSrcweir     }
3446cdf0e10cSrcweir     // set weight
3447cdf0e10cSrcweir     if( eWeight <= PANGO_WEIGHT_ULTRALIGHT )
3448cdf0e10cSrcweir         aInfo.m_eWeight = psp::weight::UltraLight;
3449cdf0e10cSrcweir     else if( eWeight <= PANGO_WEIGHT_LIGHT )
3450cdf0e10cSrcweir         aInfo.m_eWeight = psp::weight::Light;
3451cdf0e10cSrcweir     else if( eWeight <= PANGO_WEIGHT_NORMAL )
3452cdf0e10cSrcweir         aInfo.m_eWeight = psp::weight::Normal;
3453cdf0e10cSrcweir     else if( eWeight <= PANGO_WEIGHT_BOLD )
3454cdf0e10cSrcweir         aInfo.m_eWeight = psp::weight::Bold;
3455cdf0e10cSrcweir     else
3456cdf0e10cSrcweir         aInfo.m_eWeight = psp::weight::UltraBold;
3457cdf0e10cSrcweir     // set width
3458cdf0e10cSrcweir     switch( eStretch )
3459cdf0e10cSrcweir     {
3460cdf0e10cSrcweir         case PANGO_STRETCH_ULTRA_CONDENSED:	aInfo.m_eWidth = psp::width::UltraCondensed;break;
3461cdf0e10cSrcweir         case PANGO_STRETCH_EXTRA_CONDENSED:	aInfo.m_eWidth = psp::width::ExtraCondensed;break;
3462cdf0e10cSrcweir         case PANGO_STRETCH_CONDENSED:		aInfo.m_eWidth = psp::width::Condensed;break;
3463cdf0e10cSrcweir         case PANGO_STRETCH_SEMI_CONDENSED:	aInfo.m_eWidth = psp::width::SemiCondensed;break;
3464cdf0e10cSrcweir         case PANGO_STRETCH_NORMAL:			aInfo.m_eWidth = psp::width::Normal;break;
3465cdf0e10cSrcweir         case PANGO_STRETCH_SEMI_EXPANDED:	aInfo.m_eWidth = psp::width::SemiExpanded;break;
3466cdf0e10cSrcweir         case PANGO_STRETCH_EXPANDED:		aInfo.m_eWidth = psp::width::Expanded;break;
3467cdf0e10cSrcweir         case PANGO_STRETCH_EXTRA_EXPANDED:	aInfo.m_eWidth = psp::width::ExtraExpanded;break;
3468cdf0e10cSrcweir         case PANGO_STRETCH_ULTRA_EXPANDED:	aInfo.m_eWidth = psp::width::UltraExpanded;break;
3469cdf0e10cSrcweir     }
3470cdf0e10cSrcweir 
3471cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
3472cdf0e10cSrcweir     std::fprintf( stderr, "font name BEFORE system match: \"%s\"\n", aFamily.getStr() );
3473cdf0e10cSrcweir #endif
3474cdf0e10cSrcweir 
3475cdf0e10cSrcweir     // match font to e.g. resolve "Sans"
3476cdf0e10cSrcweir     psp::PrintFontManager::get().matchFont( aInfo, rSettings.GetUILocale() );
3477cdf0e10cSrcweir 
3478cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
3479cdf0e10cSrcweir     std::fprintf( stderr, "font match %s, name AFTER: \"%s\"\n",
3480cdf0e10cSrcweir              aInfo.m_nID != 0 ? "succeeded" : "failed",
3481cdf0e10cSrcweir              OUStringToOString( aInfo.m_aFamilyName, RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
3482cdf0e10cSrcweir #endif
3483cdf0e10cSrcweir 
3484cdf0e10cSrcweir     sal_Int32 nDispDPIY = GetDisplay()->GetResolution().B();
3485cdf0e10cSrcweir     int nPointHeight = 0;
3486cdf0e10cSrcweir     static gboolean(*pAbso)(const PangoFontDescription*) =
3487cdf0e10cSrcweir         (gboolean(*)(const PangoFontDescription*))osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "pango_font_description_get_size_is_absolute" );
3488cdf0e10cSrcweir 
3489cdf0e10cSrcweir     if( pAbso && pAbso( pStyle->font_desc ) )
3490cdf0e10cSrcweir         nPointHeight = (nPangoHeight * 72 + nDispDPIY*PANGO_SCALE/2) / (nDispDPIY * PANGO_SCALE);
3491cdf0e10cSrcweir     else
3492cdf0e10cSrcweir         nPointHeight = nPangoHeight/PANGO_SCALE;
3493cdf0e10cSrcweir 
3494cdf0e10cSrcweir     Font aFont( aInfo.m_aFamilyName, Size( 0, nPointHeight ) );
3495cdf0e10cSrcweir     if( aInfo.m_eWeight != psp::weight::Unknown )
3496cdf0e10cSrcweir         aFont.SetWeight( PspGraphics::ToFontWeight( aInfo.m_eWeight ) );
3497cdf0e10cSrcweir     if( aInfo.m_eWidth != psp::width::Unknown )
3498cdf0e10cSrcweir         aFont.SetWidthType( PspGraphics::ToFontWidth( aInfo.m_eWidth ) );
3499cdf0e10cSrcweir     if( aInfo.m_eItalic != psp::italic::Unknown )
3500cdf0e10cSrcweir         aFont.SetItalic( PspGraphics::ToFontItalic( aInfo.m_eItalic ) );
3501cdf0e10cSrcweir     if( aInfo.m_ePitch != psp::pitch::Unknown )
3502cdf0e10cSrcweir         aFont.SetPitch( PspGraphics::ToFontPitch( aInfo.m_ePitch ) );
3503cdf0e10cSrcweir 
3504cdf0e10cSrcweir     aStyleSet.SetAppFont( aFont );
3505cdf0e10cSrcweir     aStyleSet.SetHelpFont( aFont );
3506cdf0e10cSrcweir     aStyleSet.SetTitleFont( aFont );
3507cdf0e10cSrcweir     aStyleSet.SetFloatTitleFont( aFont );
3508cdf0e10cSrcweir     aStyleSet.SetMenuFont( aFont );
3509cdf0e10cSrcweir     aStyleSet.SetToolFont( aFont );
3510cdf0e10cSrcweir     aStyleSet.SetLabelFont( aFont );
3511cdf0e10cSrcweir     aStyleSet.SetInfoFont( aFont );
3512cdf0e10cSrcweir     aStyleSet.SetRadioCheckFont( aFont );
3513cdf0e10cSrcweir     aStyleSet.SetPushButtonFont( aFont );
3514cdf0e10cSrcweir     aStyleSet.SetFieldFont( aFont );
3515cdf0e10cSrcweir     aStyleSet.SetIconFont( aFont );
3516cdf0e10cSrcweir     aStyleSet.SetGroupFont( aFont );
3517cdf0e10cSrcweir 
3518cdf0e10cSrcweir     // get cursor blink time
3519cdf0e10cSrcweir     GtkSettings *pSettings = gtk_widget_get_settings( gWidgetData[m_nScreen].gEditBoxWidget );
3520cdf0e10cSrcweir     gboolean blink = false;
3521cdf0e10cSrcweir 
3522cdf0e10cSrcweir     g_object_get( pSettings, "gtk-cursor-blink", &blink, (char *)NULL );
3523cdf0e10cSrcweir     if( blink )
3524cdf0e10cSrcweir     {
3525cdf0e10cSrcweir         gint blink_time = STYLE_CURSOR_NOBLINKTIME;
3526cdf0e10cSrcweir         g_object_get( pSettings, "gtk-cursor-blink-time", &blink_time, (char *)NULL );
3527cdf0e10cSrcweir         // set the blink_time if there is a setting and it is reasonable
3528cdf0e10cSrcweir         // else leave the default value
3529cdf0e10cSrcweir         if( blink_time > 100 && blink_time != gint(STYLE_CURSOR_NOBLINKTIME) )
3530cdf0e10cSrcweir             aStyleSet.SetCursorBlinkTime( blink_time/2 );
3531cdf0e10cSrcweir     }
3532cdf0e10cSrcweir     else
3533cdf0e10cSrcweir         aStyleSet.SetCursorBlinkTime( STYLE_CURSOR_NOBLINKTIME );
3534cdf0e10cSrcweir 
3535cdf0e10cSrcweir     gboolean showmenuicons = true;
3536cdf0e10cSrcweir     pSettings = gtk_widget_get_settings( gWidgetData[m_nScreen].gImageMenuItem );
3537cdf0e10cSrcweir     g_object_get( pSettings, "gtk-menu-images", &showmenuicons, (char *)NULL );
3538cdf0e10cSrcweir     aStyleSet.SetUseImagesInMenus( showmenuicons );
3539cdf0e10cSrcweir 
3540cdf0e10cSrcweir     // set scrollbar settings
3541cdf0e10cSrcweir     gint slider_width = 14;
3542cdf0e10cSrcweir     gint trough_border = 1;
3543cdf0e10cSrcweir     gint min_slider_length = 21;
3544cdf0e10cSrcweir 
3545cdf0e10cSrcweir     // Grab some button style attributes
3546cdf0e10cSrcweir     gtk_widget_style_get( gWidgetData[m_nScreen].gScrollHorizWidget,
3547cdf0e10cSrcweir                           "slider-width", &slider_width,
3548cdf0e10cSrcweir                           "trough-border", &trough_border,
3549cdf0e10cSrcweir                           "min-slider-length", &min_slider_length,
3550cdf0e10cSrcweir                           (char *)NULL );
3551cdf0e10cSrcweir     gint magic = trough_border ? 1 : 0;
3552cdf0e10cSrcweir     aStyleSet.SetScrollBarSize( slider_width + 2*trough_border );
3553cdf0e10cSrcweir     aStyleSet.SetMinThumbSize( min_slider_length - magic );
3554cdf0e10cSrcweir 
3555cdf0e10cSrcweir     // preferred icon style
3556cdf0e10cSrcweir     gchar* pIconThemeName = NULL;
3557cdf0e10cSrcweir     g_object_get( gtk_settings_get_default(), "gtk-icon-theme-name", &pIconThemeName, (char *)NULL );
3558cdf0e10cSrcweir     aStyleSet.SetPreferredSymbolsStyleName( OUString::createFromAscii( pIconThemeName ) );
3559cdf0e10cSrcweir     g_free( pIconThemeName );
3560cdf0e10cSrcweir 
3561cdf0e10cSrcweir     //  FIXME: need some way of fetching toolbar icon size.
3562cdf0e10cSrcweir //	aStyleSet.SetToolbarIconSize( STYLE_TOOLBAR_ICONSIZE_SMALL );
3563cdf0e10cSrcweir 
3564cdf0e10cSrcweir     const cairo_font_options_t* pNewOptions = NULL;
3565cdf0e10cSrcweir     if( GdkScreen* pScreen = gdk_display_get_screen( gdk_display_get_default(), m_nScreen ) )
3566cdf0e10cSrcweir     {
3567cdf0e10cSrcweir //#if !GTK_CHECK_VERSION(2,8,1)
3568cdf0e10cSrcweir #if !GTK_CHECK_VERSION(2,9,0)
3569cdf0e10cSrcweir 	static cairo_font_options_t* (*gdk_screen_get_font_options)(GdkScreen*) =
3570cdf0e10cSrcweir 		(cairo_font_options_t*(*)(GdkScreen*))osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "gdk_screen_get_font_options" );
3571cdf0e10cSrcweir     if( gdk_screen_get_font_options != NULL )
3572cdf0e10cSrcweir #endif
3573cdf0e10cSrcweir 		pNewOptions = gdk_screen_get_font_options( pScreen );
3574cdf0e10cSrcweir     }
3575cdf0e10cSrcweir     aStyleSet.SetCairoFontOptions( pNewOptions );
3576cdf0e10cSrcweir 
3577cdf0e10cSrcweir     // finally update the collected settings
3578cdf0e10cSrcweir     rSettings.SetStyleSettings( aStyleSet );
3579cdf0e10cSrcweir 
3580cdf0e10cSrcweir     #if OSL_DEBUG_LEVEL > 1
3581cdf0e10cSrcweir     {
3582cdf0e10cSrcweir         GtkSettings* pGtkSettings = gtk_settings_get_default();
3583cdf0e10cSrcweir         GValue aValue;
3584cdf0e10cSrcweir         memset( &aValue, 0, sizeof(GValue) );
3585cdf0e10cSrcweir         g_value_init( &aValue, G_TYPE_STRING );
3586cdf0e10cSrcweir         g_object_get_property( G_OBJECT(pGtkSettings), "gtk-theme-name", &aValue );
3587cdf0e10cSrcweir         const gchar* pThemeName = g_value_get_string( &aValue );
3588cdf0e10cSrcweir         std::fprintf( stderr, "Theme name is \"%s\"\n", pThemeName );
3589cdf0e10cSrcweir         g_value_unset( &aValue );
3590cdf0e10cSrcweir     }
3591cdf0e10cSrcweir     #endif
3592cdf0e10cSrcweir     GtkSettings* pGtkSettings = gtk_settings_get_default();
3593cdf0e10cSrcweir     GValue aValue;
3594cdf0e10cSrcweir     memset( &aValue, 0, sizeof(GValue) );
3595cdf0e10cSrcweir     g_value_init( &aValue, G_TYPE_STRING );
3596cdf0e10cSrcweir     g_object_get_property( G_OBJECT(pGtkSettings), "gtk-theme-name", &aValue );
3597cdf0e10cSrcweir     const gchar* pThemeName = g_value_get_string( &aValue );
3598cdf0e10cSrcweir 
3599cdf0e10cSrcweir     // default behaviour
3600cdf0e10cSrcweir     bNeedPixmapPaint = bGlobalNeedPixmapPaint;
3601cdf0e10cSrcweir     bToolbarGripWorkaround = false;
3602cdf0e10cSrcweir     bNeedButtonStyleAsEditBackgroundWorkaround = false;
3603cdf0e10cSrcweir 
3604cdf0e10cSrcweir     // setup some workarounds for "blueprint" theme
3605cdf0e10cSrcweir     if( pThemeName && strncasecmp( pThemeName, "blueprint", 9 ) == 0 )
3606cdf0e10cSrcweir     {
3607cdf0e10cSrcweir         bNeedButtonStyleAsEditBackgroundWorkaround = true;
3608cdf0e10cSrcweir         if( GetX11SalData()->GetDisplay()->GetServerVendor() == vendor_sun )
3609cdf0e10cSrcweir         {
3610cdf0e10cSrcweir             // #i52570#, #i61532# workaround a weird paint issue;
3611cdf0e10cSrcweir             // on a Sunray Xserver sometimes painting buttons and edits
3612cdf0e10cSrcweir             // won't work when using the blueprint theme
3613cdf0e10cSrcweir             // not reproducible with simpler programs or other themes
3614cdf0e10cSrcweir             if( pThemeName && strncasecmp( pThemeName, "blueprint", 9 ) == 0 )
3615cdf0e10cSrcweir             {
3616cdf0e10cSrcweir                 bNeedPixmapPaint = true;
3617cdf0e10cSrcweir                 bToolbarGripWorkaround = true;
3618cdf0e10cSrcweir             }
3619cdf0e10cSrcweir         }
3620cdf0e10cSrcweir     }
3621cdf0e10cSrcweir     // clean up
3622cdf0e10cSrcweir     g_value_unset( &aValue );
3623cdf0e10cSrcweir }
3624cdf0e10cSrcweir 
3625cdf0e10cSrcweir 
3626cdf0e10cSrcweir /************************************************************************
3627cdf0e10cSrcweir  * Create a GdkPixmap filled with the contents of an area of an Xlib window
3628cdf0e10cSrcweir  ************************************************************************/
3629cdf0e10cSrcweir 
3630cdf0e10cSrcweir GdkPixmap* GtkSalGraphics::NWGetPixmapFromScreen( Rectangle srcRect )
3631cdf0e10cSrcweir {
3632cdf0e10cSrcweir     // Create a new pixmap to hold the composite of the window background and the control
3633cdf0e10cSrcweir     GdkPixmap * pPixmap		= gdk_pixmap_new( GDK_DRAWABLE(GetGdkWindow()), srcRect.GetWidth(), srcRect.GetHeight(), -1 );
3634cdf0e10cSrcweir 	GdkGC *	 pPixmapGC	= gdk_gc_new( pPixmap );
3635cdf0e10cSrcweir 
3636cdf0e10cSrcweir     if( !pPixmap || !pPixmapGC )
3637cdf0e10cSrcweir     {
3638cdf0e10cSrcweir         if ( pPixmap )
3639cdf0e10cSrcweir             g_object_unref( pPixmap );
3640cdf0e10cSrcweir         if ( pPixmapGC )
3641cdf0e10cSrcweir             g_object_unref( pPixmapGC );
3642cdf0e10cSrcweir         std::fprintf( stderr, "salnativewidgets-gtk.cxx: could not get valid pixmap from screen\n" );
3643cdf0e10cSrcweir         return( NULL );
3644cdf0e10cSrcweir     }
3645cdf0e10cSrcweir 
3646cdf0e10cSrcweir     // Copy the background of the screen into a composite pixmap
3647cdf0e10cSrcweir     CopyScreenArea( GetXDisplay(),
3648cdf0e10cSrcweir               GetDrawable(), GetScreenNumber(), GetVisual().GetDepth(),
3649cdf0e10cSrcweir               gdk_x11_drawable_get_xid(pPixmap),
3650cdf0e10cSrcweir               gdk_screen_get_number( gdk_drawable_get_screen( GDK_DRAWABLE(pPixmap) ) ),
3651cdf0e10cSrcweir               gdk_drawable_get_depth( GDK_DRAWABLE( pPixmap ) ),
3652cdf0e10cSrcweir               gdk_x11_gc_get_xgc(pPixmapGC),
3653cdf0e10cSrcweir               srcRect.Left(), srcRect.Top(), srcRect.GetWidth(), srcRect.GetHeight(), 0, 0 );
3654cdf0e10cSrcweir 
3655cdf0e10cSrcweir     g_object_unref( pPixmapGC );
3656cdf0e10cSrcweir     return( pPixmap );
3657cdf0e10cSrcweir }
3658cdf0e10cSrcweir 
3659cdf0e10cSrcweir 
3660cdf0e10cSrcweir 
3661cdf0e10cSrcweir 
3662cdf0e10cSrcweir /************************************************************************
3663cdf0e10cSrcweir  * Copy an alpha pixmap to screen using a gc with clipping
3664cdf0e10cSrcweir  ************************************************************************/
3665cdf0e10cSrcweir 
3666cdf0e10cSrcweir sal_Bool GtkSalGraphics::NWRenderPixmapToScreen( GdkPixmap* pPixmap, Rectangle dstRect )
3667cdf0e10cSrcweir {
3668cdf0e10cSrcweir     // The GC can't be null, otherwise we'd have no clip region
3669cdf0e10cSrcweir     GC aFontGC = GetFontGC();
3670cdf0e10cSrcweir     if( aFontGC == NULL )
3671cdf0e10cSrcweir     {
3672cdf0e10cSrcweir         std::fprintf(stderr, "salnativewidgets.cxx: no valid GC\n" );
3673cdf0e10cSrcweir         return( sal_False );
3674cdf0e10cSrcweir     }
3675cdf0e10cSrcweir 
3676cdf0e10cSrcweir     if ( !pPixmap )
3677cdf0e10cSrcweir         return( sal_False );
3678cdf0e10cSrcweir 
3679cdf0e10cSrcweir     // Copy the background of the screen into a composite pixmap
3680cdf0e10cSrcweir     CopyScreenArea( GetXDisplay(),
3681cdf0e10cSrcweir               GDK_DRAWABLE_XID(pPixmap),
3682cdf0e10cSrcweir               gdk_screen_get_number( gdk_drawable_get_screen( GDK_DRAWABLE(pPixmap) ) ),
3683cdf0e10cSrcweir               gdk_drawable_get_depth( GDK_DRAWABLE(pPixmap) ),
3684cdf0e10cSrcweir               GetDrawable(), m_nScreen, GetVisual().GetDepth(),
3685cdf0e10cSrcweir               aFontGC,
3686cdf0e10cSrcweir               0, 0, dstRect.GetWidth(), dstRect.GetHeight(), dstRect.Left(), dstRect.Top() );
3687cdf0e10cSrcweir 
3688cdf0e10cSrcweir     return( sal_True );
3689cdf0e10cSrcweir }
3690cdf0e10cSrcweir 
3691cdf0e10cSrcweir 
3692cdf0e10cSrcweir /************************************************************************
3693cdf0e10cSrcweir  * State conversion
3694cdf0e10cSrcweir  ************************************************************************/
3695cdf0e10cSrcweir static void NWConvertVCLStateToGTKState( ControlState nVCLState,
3696cdf0e10cSrcweir 			GtkStateType* nGTKState, GtkShadowType* nGTKShadow )
3697cdf0e10cSrcweir {
3698cdf0e10cSrcweir 	*nGTKShadow = GTK_SHADOW_OUT;
3699cdf0e10cSrcweir 	*nGTKState = GTK_STATE_INSENSITIVE;
3700cdf0e10cSrcweir 
3701cdf0e10cSrcweir 	if ( nVCLState & CTRL_STATE_ENABLED )
3702cdf0e10cSrcweir 	{
3703cdf0e10cSrcweir 		if ( nVCLState & CTRL_STATE_PRESSED )
3704cdf0e10cSrcweir 		{
3705cdf0e10cSrcweir 			*nGTKState = GTK_STATE_ACTIVE;
3706cdf0e10cSrcweir 			*nGTKShadow = GTK_SHADOW_IN;
3707cdf0e10cSrcweir 		}
3708cdf0e10cSrcweir 		else if ( nVCLState & CTRL_STATE_ROLLOVER )
3709cdf0e10cSrcweir 		{
3710cdf0e10cSrcweir 			*nGTKState = GTK_STATE_PRELIGHT;
3711cdf0e10cSrcweir 			*nGTKShadow = GTK_SHADOW_OUT;
3712cdf0e10cSrcweir 		}
3713cdf0e10cSrcweir 		else
3714cdf0e10cSrcweir 		{
3715cdf0e10cSrcweir 			*nGTKState = GTK_STATE_NORMAL;
3716cdf0e10cSrcweir 			*nGTKShadow = GTK_SHADOW_OUT;
3717cdf0e10cSrcweir 		}
3718cdf0e10cSrcweir 	}
3719cdf0e10cSrcweir }
3720cdf0e10cSrcweir 
3721cdf0e10cSrcweir /************************************************************************
3722cdf0e10cSrcweir  * Set widget flags
3723cdf0e10cSrcweir  ************************************************************************/
3724cdf0e10cSrcweir static void NWSetWidgetState( GtkWidget* widget, ControlState nState, GtkStateType nGtkState )
3725cdf0e10cSrcweir {
3726cdf0e10cSrcweir 	// Set to default state, then build up from there
3727cdf0e10cSrcweir 	GTK_WIDGET_UNSET_FLAGS( widget, GTK_HAS_DEFAULT );
3728cdf0e10cSrcweir 	GTK_WIDGET_UNSET_FLAGS( widget, GTK_HAS_FOCUS );
3729cdf0e10cSrcweir 	GTK_WIDGET_UNSET_FLAGS( widget, GTK_SENSITIVE );
3730cdf0e10cSrcweir 	GTK_WIDGET_SET_FLAGS( widget, gWidgetDefaultFlags[(long)widget] );
3731cdf0e10cSrcweir 
3732cdf0e10cSrcweir 	if ( nState & CTRL_STATE_DEFAULT )
3733cdf0e10cSrcweir 		GTK_WIDGET_SET_FLAGS( widget, GTK_HAS_DEFAULT );
3734cdf0e10cSrcweir 	if ( !GTK_IS_TOGGLE_BUTTON(widget) && (nState & CTRL_STATE_FOCUSED) )
3735cdf0e10cSrcweir 		GTK_WIDGET_SET_FLAGS( widget, GTK_HAS_FOCUS );
3736cdf0e10cSrcweir 	if ( nState & CTRL_STATE_ENABLED )
3737cdf0e10cSrcweir 		GTK_WIDGET_SET_FLAGS( widget, GTK_SENSITIVE );
3738cdf0e10cSrcweir 	gtk_widget_set_state( widget, nGtkState );
3739cdf0e10cSrcweir }
3740cdf0e10cSrcweir 
3741cdf0e10cSrcweir /************************************************************************
3742cdf0e10cSrcweir  * Widget ensure functions - make sure cached objects are valid
3743cdf0e10cSrcweir  ************************************************************************/
3744cdf0e10cSrcweir 
3745cdf0e10cSrcweir //-------------------------------------
3746cdf0e10cSrcweir 
3747cdf0e10cSrcweir static void NWAddWidgetToCacheWindow( GtkWidget* widget, int nScreen )
3748cdf0e10cSrcweir {
3749cdf0e10cSrcweir     NWFWidgetData& rData = gWidgetData[nScreen];
3750cdf0e10cSrcweir 	if ( !rData.gCacheWindow || !rData.gDumbContainer )
3751cdf0e10cSrcweir 	{
3752cdf0e10cSrcweir 		if ( !rData.gCacheWindow )
3753cdf0e10cSrcweir         {
3754cdf0e10cSrcweir 			rData.gCacheWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
3755cdf0e10cSrcweir             GdkScreen* pScreen = gdk_display_get_screen( gdk_display_get_default(), nScreen );
3756cdf0e10cSrcweir             if( pScreen )
3757cdf0e10cSrcweir                 gtk_window_set_screen( GTK_WINDOW(rData.gCacheWindow), pScreen );
3758cdf0e10cSrcweir         }
3759cdf0e10cSrcweir 		if ( !rData.gDumbContainer )
3760cdf0e10cSrcweir 			rData.gDumbContainer = gtk_fixed_new();
3761cdf0e10cSrcweir 		gtk_container_add( GTK_CONTAINER(rData.gCacheWindow), rData.gDumbContainer );
3762cdf0e10cSrcweir 		gtk_widget_realize( rData.gDumbContainer );
3763cdf0e10cSrcweir 		gtk_widget_realize( rData.gCacheWindow );
3764cdf0e10cSrcweir 	}
3765cdf0e10cSrcweir 
3766cdf0e10cSrcweir 	gtk_container_add( GTK_CONTAINER(rData.gDumbContainer), widget );
3767cdf0e10cSrcweir 	gtk_widget_realize( widget );
3768cdf0e10cSrcweir 	gtk_widget_ensure_style( widget );
3769cdf0e10cSrcweir 
3770cdf0e10cSrcweir 	// Store widget's default flags
3771cdf0e10cSrcweir 	gWidgetDefaultFlags[ (long)widget ] = GTK_WIDGET_FLAGS( widget );
3772cdf0e10cSrcweir }
3773cdf0e10cSrcweir 
3774cdf0e10cSrcweir //-------------------------------------
3775cdf0e10cSrcweir 
3776cdf0e10cSrcweir static void NWEnsureGTKButton( int nScreen )
3777cdf0e10cSrcweir {
3778cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gBtnWidget )
3779cdf0e10cSrcweir 	{
3780cdf0e10cSrcweir 		gWidgetData[nScreen].gBtnWidget = gtk_button_new_with_label( "" );
3781cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gBtnWidget, nScreen );
3782cdf0e10cSrcweir 	}
3783cdf0e10cSrcweir }
3784cdf0e10cSrcweir 
3785cdf0e10cSrcweir //-------------------------------------
3786cdf0e10cSrcweir 
3787cdf0e10cSrcweir static void NWEnsureGTKRadio( int nScreen )
3788cdf0e10cSrcweir {
3789cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gRadioWidget || !gWidgetData[nScreen].gRadioWidgetSibling )
3790cdf0e10cSrcweir 	{
3791cdf0e10cSrcweir 		gWidgetData[nScreen].gRadioWidget = gtk_radio_button_new( NULL );
3792cdf0e10cSrcweir 		gWidgetData[nScreen].gRadioWidgetSibling = gtk_radio_button_new_from_widget( GTK_RADIO_BUTTON(gWidgetData[nScreen].gRadioWidget) );
3793cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gRadioWidget, nScreen );
3794cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gRadioWidgetSibling, nScreen );
3795cdf0e10cSrcweir 	}
3796cdf0e10cSrcweir }
3797cdf0e10cSrcweir 
3798cdf0e10cSrcweir //-------------------------------------
3799cdf0e10cSrcweir 
3800cdf0e10cSrcweir static void NWEnsureGTKCheck( int nScreen )
3801cdf0e10cSrcweir {
3802cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gCheckWidget )
3803cdf0e10cSrcweir 	{
3804cdf0e10cSrcweir 		gWidgetData[nScreen].gCheckWidget = gtk_check_button_new();
3805cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gCheckWidget, nScreen );
3806cdf0e10cSrcweir 	}
3807cdf0e10cSrcweir }
3808cdf0e10cSrcweir 
3809cdf0e10cSrcweir //-------------------------------------
3810cdf0e10cSrcweir 
3811cdf0e10cSrcweir static void NWEnsureGTKScrollbars( int nScreen )
3812cdf0e10cSrcweir {
3813cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gScrollHorizWidget )
3814cdf0e10cSrcweir 	{
3815cdf0e10cSrcweir 		gWidgetData[nScreen].gScrollHorizWidget = gtk_hscrollbar_new( NULL );
3816cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gScrollHorizWidget, nScreen );
3817cdf0e10cSrcweir 	}
3818cdf0e10cSrcweir 
3819cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gScrollVertWidget )
3820cdf0e10cSrcweir 	{
3821cdf0e10cSrcweir 		gWidgetData[nScreen].gScrollVertWidget = gtk_vscrollbar_new( NULL );
3822cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gScrollVertWidget, nScreen );
3823cdf0e10cSrcweir 	}
3824cdf0e10cSrcweir }
3825cdf0e10cSrcweir 
3826cdf0e10cSrcweir //-------------------------------------
3827cdf0e10cSrcweir 
3828cdf0e10cSrcweir static void NWEnsureGTKArrow( int nScreen )
3829cdf0e10cSrcweir {
3830cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gArrowWidget || !gWidgetData[nScreen].gDropdownWidget )
3831cdf0e10cSrcweir 	{
3832cdf0e10cSrcweir 		gWidgetData[nScreen].gDropdownWidget = gtk_toggle_button_new();
3833cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gDropdownWidget, nScreen );
3834cdf0e10cSrcweir 		gWidgetData[nScreen].gArrowWidget = gtk_arrow_new( GTK_ARROW_DOWN, GTK_SHADOW_OUT );
3835cdf0e10cSrcweir 		gtk_container_add( GTK_CONTAINER(gWidgetData[nScreen].gDropdownWidget), gWidgetData[nScreen].gArrowWidget );
3836cdf0e10cSrcweir 		gtk_widget_set_rc_style( gWidgetData[nScreen].gArrowWidget );
3837cdf0e10cSrcweir 		gtk_widget_realize( gWidgetData[nScreen].gArrowWidget );
3838cdf0e10cSrcweir 	}
3839cdf0e10cSrcweir }
3840cdf0e10cSrcweir 
3841cdf0e10cSrcweir //-------------------------------------
3842cdf0e10cSrcweir 
3843cdf0e10cSrcweir static void NWEnsureGTKEditBox( int nScreen )
3844cdf0e10cSrcweir {
3845cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gEditBoxWidget )
3846cdf0e10cSrcweir 	{
3847cdf0e10cSrcweir 		gWidgetData[nScreen].gEditBoxWidget = gtk_entry_new();
3848cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gEditBoxWidget, nScreen );
3849cdf0e10cSrcweir 	}
3850cdf0e10cSrcweir }
3851cdf0e10cSrcweir 
3852cdf0e10cSrcweir //-------------------------------------
3853cdf0e10cSrcweir 
3854cdf0e10cSrcweir static void NWEnsureGTKSpinButton( int nScreen )
3855cdf0e10cSrcweir {
3856cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gSpinButtonWidget )
3857cdf0e10cSrcweir 	{
3858cdf0e10cSrcweir 		GtkAdjustment *adj = GTK_ADJUSTMENT( gtk_adjustment_new(0, 0, 1, 1, 1, 0) );
3859cdf0e10cSrcweir 		gWidgetData[nScreen].gSpinButtonWidget = gtk_spin_button_new( adj, 1, 2 );
3860cdf0e10cSrcweir 
3861cdf0e10cSrcweir 		//Setting non-editable means it doesn't blink, so there's no timeouts
3862cdf0e10cSrcweir 		//running around to nobble us
3863cdf0e10cSrcweir 		gtk_editable_set_editable(GTK_EDITABLE(gWidgetData[nScreen].gSpinButtonWidget), false);
3864cdf0e10cSrcweir 
3865cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gSpinButtonWidget, nScreen );
3866cdf0e10cSrcweir 	}
3867cdf0e10cSrcweir }
3868cdf0e10cSrcweir 
3869cdf0e10cSrcweir //-------------------------------------
3870cdf0e10cSrcweir 
3871cdf0e10cSrcweir static void NWEnsureGTKNotebook( int nScreen )
3872cdf0e10cSrcweir {
3873cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gNotebookWidget )
3874cdf0e10cSrcweir 	{
3875cdf0e10cSrcweir 		gWidgetData[nScreen].gNotebookWidget = gtk_notebook_new();
3876cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gNotebookWidget, nScreen );
3877cdf0e10cSrcweir 	}
3878cdf0e10cSrcweir }
3879cdf0e10cSrcweir 
3880cdf0e10cSrcweir //-------------------------------------
3881cdf0e10cSrcweir 
3882cdf0e10cSrcweir static void NWEnsureGTKOptionMenu( int nScreen )
3883cdf0e10cSrcweir {
3884cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gOptionMenuWidget )
3885cdf0e10cSrcweir 	{
3886cdf0e10cSrcweir 		gWidgetData[nScreen].gOptionMenuWidget = gtk_option_menu_new();
3887cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gOptionMenuWidget, nScreen );
3888cdf0e10cSrcweir 	}
3889cdf0e10cSrcweir }
3890cdf0e10cSrcweir 
3891cdf0e10cSrcweir //-------------------------------------
3892cdf0e10cSrcweir 
3893cdf0e10cSrcweir static void NWEnsureGTKCombo( int nScreen )
3894cdf0e10cSrcweir {
3895cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gComboWidget )
3896cdf0e10cSrcweir 	{
3897cdf0e10cSrcweir 		gWidgetData[nScreen].gComboWidget = gtk_combo_new();
3898cdf0e10cSrcweir 
3899cdf0e10cSrcweir 		// #i59129# Setting non-editable means it doesn't blink, so
3900cdf0e10cSrcweir         // there are no timeouts running around to nobble us
3901cdf0e10cSrcweir 		gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(gWidgetData[nScreen].gComboWidget)->entry), false);
3902cdf0e10cSrcweir 
3903cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gComboWidget, nScreen );
3904cdf0e10cSrcweir 		// Must realize the ComboBox's children, since GTK
3905cdf0e10cSrcweir 		// does not do this for us in GtkCombo::gtk_widget_realize()
3906cdf0e10cSrcweir 		gtk_widget_realize( GTK_COMBO(gWidgetData[nScreen].gComboWidget)->button );
3907cdf0e10cSrcweir 		gtk_widget_realize( GTK_COMBO(gWidgetData[nScreen].gComboWidget)->entry );
3908cdf0e10cSrcweir 	}
3909cdf0e10cSrcweir }
3910cdf0e10cSrcweir 
3911cdf0e10cSrcweir //-------------------------------------
3912cdf0e10cSrcweir 
3913cdf0e10cSrcweir static void NWEnsureGTKScrolledWindow( int nScreen )
3914cdf0e10cSrcweir {
3915cdf0e10cSrcweir 	if ( !gWidgetData[nScreen].gScrolledWindowWidget )
3916cdf0e10cSrcweir 	{
3917cdf0e10cSrcweir 		GtkAdjustment *hadj = GTK_ADJUSTMENT( gtk_adjustment_new(0, 0, 0, 0, 0, 0) );
3918cdf0e10cSrcweir 		GtkAdjustment *vadj = GTK_ADJUSTMENT( gtk_adjustment_new(0, 0, 0, 0, 0, 0) );
3919cdf0e10cSrcweir 
3920cdf0e10cSrcweir 		gWidgetData[nScreen].gScrolledWindowWidget = gtk_scrolled_window_new( hadj, vadj );
3921cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gScrolledWindowWidget, nScreen );
3922cdf0e10cSrcweir 	}
3923cdf0e10cSrcweir }
3924cdf0e10cSrcweir 
3925cdf0e10cSrcweir //-------------------------------------
3926cdf0e10cSrcweir 
3927cdf0e10cSrcweir static void NWEnsureGTKToolbar( int nScreen )
3928cdf0e10cSrcweir {
3929cdf0e10cSrcweir     if( !gWidgetData[nScreen].gToolbarWidget )
3930cdf0e10cSrcweir     {
3931cdf0e10cSrcweir         gWidgetData[nScreen].gToolbarWidget = gtk_toolbar_new();
3932cdf0e10cSrcweir         NWAddWidgetToCacheWindow( gWidgetData[nScreen].gToolbarWidget, nScreen );
3933cdf0e10cSrcweir         gWidgetData[nScreen].gToolbarButtonWidget = gtk_button_new();
3934cdf0e10cSrcweir         gWidgetData[nScreen].gToolbarToggleWidget = gtk_toggle_button_new();
3935cdf0e10cSrcweir 
3936cdf0e10cSrcweir         GtkReliefStyle aRelief = GTK_RELIEF_NORMAL;
3937cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gToolbarWidget );
3938cdf0e10cSrcweir         gtk_widget_style_get( gWidgetData[nScreen].gToolbarWidget,
3939cdf0e10cSrcweir 			                  "button_relief", &aRelief,
3940cdf0e10cSrcweir                               (char *)NULL);
3941cdf0e10cSrcweir 
3942cdf0e10cSrcweir         gtk_button_set_relief( GTK_BUTTON(gWidgetData[nScreen].gToolbarButtonWidget), aRelief );
3943cdf0e10cSrcweir         GTK_WIDGET_UNSET_FLAGS( gWidgetData[nScreen].gToolbarButtonWidget, GTK_CAN_FOCUS );
3944cdf0e10cSrcweir         GTK_WIDGET_UNSET_FLAGS( gWidgetData[nScreen].gToolbarButtonWidget, GTK_CAN_DEFAULT );
3945cdf0e10cSrcweir         NWAddWidgetToCacheWindow( gWidgetData[nScreen].gToolbarButtonWidget, nScreen );
3946cdf0e10cSrcweir 
3947cdf0e10cSrcweir         gtk_button_set_relief( GTK_BUTTON(gWidgetData[nScreen].gToolbarToggleWidget), aRelief );
3948cdf0e10cSrcweir         GTK_WIDGET_UNSET_FLAGS( gWidgetData[nScreen].gToolbarToggleWidget, GTK_CAN_FOCUS );
3949cdf0e10cSrcweir         GTK_WIDGET_UNSET_FLAGS( gWidgetData[nScreen].gToolbarToggleWidget, GTK_CAN_DEFAULT );
3950cdf0e10cSrcweir         NWAddWidgetToCacheWindow( gWidgetData[nScreen].gToolbarToggleWidget, nScreen );
3951cdf0e10cSrcweir     }
3952cdf0e10cSrcweir     if( ! gWidgetData[nScreen].gHandleBoxWidget )
3953cdf0e10cSrcweir     {
3954cdf0e10cSrcweir         gWidgetData[nScreen].gHandleBoxWidget = gtk_handle_box_new();
3955cdf0e10cSrcweir         NWAddWidgetToCacheWindow( gWidgetData[nScreen].gHandleBoxWidget, nScreen );
3956cdf0e10cSrcweir     }
3957cdf0e10cSrcweir }
3958cdf0e10cSrcweir 
3959cdf0e10cSrcweir //-------------------------------------
3960cdf0e10cSrcweir 
3961cdf0e10cSrcweir static void NWEnsureGTKMenubar( int nScreen )
3962cdf0e10cSrcweir {
3963cdf0e10cSrcweir     if( !gWidgetData[nScreen].gMenubarWidget )
3964cdf0e10cSrcweir     {
3965cdf0e10cSrcweir         gWidgetData[nScreen].gMenubarWidget = gtk_menu_bar_new();
3966cdf0e10cSrcweir         gWidgetData[nScreen].gMenuItemMenubarWidget = gtk_menu_item_new_with_label( "b" );
3967cdf0e10cSrcweir         gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenubarWidget ), gWidgetData[nScreen].gMenuItemMenubarWidget );
3968cdf0e10cSrcweir         gtk_widget_show( gWidgetData[nScreen].gMenuItemMenubarWidget );
3969cdf0e10cSrcweir         NWAddWidgetToCacheWindow( gWidgetData[nScreen].gMenubarWidget, nScreen );
3970cdf0e10cSrcweir         gtk_widget_show( gWidgetData[nScreen].gMenubarWidget );
3971cdf0e10cSrcweir 
3972cdf0e10cSrcweir         // do what NWAddWidgetToCacheWindow does except adding to def container
3973cdf0e10cSrcweir         gtk_widget_realize( gWidgetData[nScreen].gMenuItemMenubarWidget );
3974cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gMenuItemMenubarWidget );
3975cdf0e10cSrcweir 
3976cdf0e10cSrcweir         gWidgetDefaultFlags[ (long)gWidgetData[nScreen].gMenuItemMenubarWidget ] = GTK_WIDGET_FLAGS( gWidgetData[nScreen].gMenuItemMenubarWidget );
3977cdf0e10cSrcweir     }
3978cdf0e10cSrcweir }
3979cdf0e10cSrcweir 
3980cdf0e10cSrcweir static void NWEnsureGTKMenu( int nScreen )
3981cdf0e10cSrcweir {
3982cdf0e10cSrcweir     if( !gWidgetData[nScreen].gMenuWidget )
3983cdf0e10cSrcweir     {
3984cdf0e10cSrcweir         gWidgetData[nScreen].gMenuWidget              = gtk_menu_new();
3985cdf0e10cSrcweir         gWidgetData[nScreen].gMenuItemMenuWidget      = gtk_menu_item_new_with_label( "b" );
3986cdf0e10cSrcweir         gWidgetData[nScreen].gMenuItemCheckMenuWidget = gtk_check_menu_item_new_with_label( "b" );
3987cdf0e10cSrcweir         gWidgetData[nScreen].gMenuItemRadioMenuWidget = gtk_radio_menu_item_new_with_label( NULL, "b" );
3988cdf0e10cSrcweir         gWidgetData[nScreen].gImageMenuItem           = gtk_image_menu_item_new();
3989cdf0e10cSrcweir 
3990cdf0e10cSrcweir         gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gMenuItemMenuWidget );
3991cdf0e10cSrcweir         gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gMenuItemCheckMenuWidget );
3992cdf0e10cSrcweir         gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gMenuItemRadioMenuWidget );
3993cdf0e10cSrcweir         gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gImageMenuItem );
3994cdf0e10cSrcweir 
3995cdf0e10cSrcweir         // do what NWAddWidgetToCacheWindow does except adding to def container
3996cdf0e10cSrcweir         gtk_widget_realize( gWidgetData[nScreen].gMenuWidget );
3997cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gMenuWidget );
3998cdf0e10cSrcweir 
3999cdf0e10cSrcweir         gtk_widget_realize( gWidgetData[nScreen].gMenuItemMenuWidget );
4000cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gMenuItemMenuWidget );
4001cdf0e10cSrcweir 
4002cdf0e10cSrcweir         gtk_widget_realize( gWidgetData[nScreen].gMenuItemCheckMenuWidget );
4003cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gMenuItemCheckMenuWidget );
4004cdf0e10cSrcweir 
4005cdf0e10cSrcweir         gtk_widget_realize( gWidgetData[nScreen].gMenuItemRadioMenuWidget );
4006cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gMenuItemRadioMenuWidget );
4007cdf0e10cSrcweir 
4008cdf0e10cSrcweir         gtk_widget_realize( gWidgetData[nScreen].gImageMenuItem );
4009cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gImageMenuItem );
4010cdf0e10cSrcweir 
4011cdf0e10cSrcweir         gWidgetDefaultFlags[ (long)gWidgetData[nScreen].gMenuWidget ] = GTK_WIDGET_FLAGS( gWidgetData[nScreen].gMenuWidget );
4012cdf0e10cSrcweir         gWidgetDefaultFlags[ (long)gWidgetData[nScreen].gMenuItemMenuWidget ] = GTK_WIDGET_FLAGS( gWidgetData[nScreen].gMenuItemMenuWidget );
4013cdf0e10cSrcweir         gWidgetDefaultFlags[ (long)gWidgetData[nScreen].gMenuItemCheckMenuWidget ] = GTK_WIDGET_FLAGS( gWidgetData[nScreen].gMenuItemCheckMenuWidget );
4014cdf0e10cSrcweir         gWidgetDefaultFlags[ (long)gWidgetData[nScreen].gMenuItemRadioMenuWidget ] = GTK_WIDGET_FLAGS( gWidgetData[nScreen].gMenuItemRadioMenuWidget );
4015cdf0e10cSrcweir         gWidgetDefaultFlags[ (long)gWidgetData[nScreen].gImageMenuItem ] = GTK_WIDGET_FLAGS( gWidgetData[nScreen].gImageMenuItem );
4016cdf0e10cSrcweir     }
4017cdf0e10cSrcweir }
4018cdf0e10cSrcweir 
4019cdf0e10cSrcweir static void NWEnsureGTKTooltip( int nScreen )
4020cdf0e10cSrcweir {
4021cdf0e10cSrcweir     if( !gWidgetData[nScreen].gTooltipPopup )
4022cdf0e10cSrcweir     {
4023cdf0e10cSrcweir         gWidgetData[nScreen].gTooltipPopup = gtk_window_new (GTK_WINDOW_POPUP);
4024cdf0e10cSrcweir         GdkScreen* pScreen = gdk_display_get_screen( gdk_display_get_default(), nScreen );
4025cdf0e10cSrcweir         if( pScreen )
4026cdf0e10cSrcweir             gtk_window_set_screen( GTK_WINDOW(gWidgetData[nScreen].gTooltipPopup), pScreen );
4027cdf0e10cSrcweir         gtk_widget_set_name( gWidgetData[nScreen].gTooltipPopup, "gtk-tooltips");
4028cdf0e10cSrcweir         gtk_widget_realize( gWidgetData[nScreen].gTooltipPopup );
4029cdf0e10cSrcweir         gtk_widget_ensure_style( gWidgetData[nScreen].gTooltipPopup );
4030cdf0e10cSrcweir     }
4031cdf0e10cSrcweir }
4032cdf0e10cSrcweir 
4033cdf0e10cSrcweir static void NWEnsureGTKProgressBar( int nScreen )
4034cdf0e10cSrcweir {
4035cdf0e10cSrcweir     if( !gWidgetData[nScreen].gProgressBar )
4036cdf0e10cSrcweir     {
4037cdf0e10cSrcweir         gWidgetData[nScreen].gProgressBar = gtk_progress_bar_new ();
4038cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gProgressBar, nScreen );
4039cdf0e10cSrcweir     }
4040cdf0e10cSrcweir }
4041cdf0e10cSrcweir 
4042cdf0e10cSrcweir static void NWEnsureGTKTreeView( int nScreen )
4043cdf0e10cSrcweir {
4044cdf0e10cSrcweir     if( !gWidgetData[nScreen].gTreeView )
4045cdf0e10cSrcweir     {
4046cdf0e10cSrcweir         gWidgetData[nScreen].gTreeView = gtk_tree_view_new ();
4047cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gTreeView, nScreen );
4048cdf0e10cSrcweir     }
4049cdf0e10cSrcweir }
4050cdf0e10cSrcweir 
4051cdf0e10cSrcweir static void NWEnsureGTKSlider( int nScreen )
4052cdf0e10cSrcweir {
4053cdf0e10cSrcweir     if( !gWidgetData[nScreen].gHScale )
4054cdf0e10cSrcweir     {
4055cdf0e10cSrcweir         gWidgetData[nScreen].gHScale = gtk_hscale_new_with_range(0, 10, 1);
4056cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gHScale, nScreen );
4057cdf0e10cSrcweir     }
4058cdf0e10cSrcweir     if( !gWidgetData[nScreen].gVScale )
4059cdf0e10cSrcweir     {
4060cdf0e10cSrcweir         gWidgetData[nScreen].gVScale = gtk_vscale_new_with_range(0, 10, 1);
4061cdf0e10cSrcweir 		NWAddWidgetToCacheWindow( gWidgetData[nScreen].gVScale, nScreen );
4062cdf0e10cSrcweir     }
4063cdf0e10cSrcweir }
4064