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