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