1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9f62ea84SAndrew Rist * distributed with this work for additional information
6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
17*9f62ea84SAndrew Rist * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*9f62ea84SAndrew Rist *************************************************************/
21*9f62ea84SAndrew Rist
22*9f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #define _SV_SALNATIVEWIDGETS_KDE_CXX
28cdf0e10cSrcweir
29cdf0e10cSrcweir #define Region QtXRegion
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <QStyle>
32cdf0e10cSrcweir #include <QStyleOption>
33cdf0e10cSrcweir #include <QPainter>
34cdf0e10cSrcweir #include <QFrame>
35cdf0e10cSrcweir #include <QLabel>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <kapplication.h>
38cdf0e10cSrcweir
39cdf0e10cSrcweir #undef Region
40cdf0e10cSrcweir
41cdf0e10cSrcweir #include "KDESalGraphics.hxx"
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include "vcl/settings.hxx"
44cdf0e10cSrcweir #include "vcl/decoview.hxx"
45cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
46cdf0e10cSrcweir
47cdf0e10cSrcweir using namespace ::rtl;
48cdf0e10cSrcweir
49cdf0e10cSrcweir /**
50cdf0e10cSrcweir Conversion function between VCL ControlState together with
51cdf0e10cSrcweir ImplControlValue and Qt state flags.
52cdf0e10cSrcweir @param nControlState State of the widget (default, focused, ...) in Native Widget Framework.
53cdf0e10cSrcweir @param aValue Value held by the widget (on, off, ...)
54cdf0e10cSrcweir */
vclStateValue2StateFlag(ControlState nControlState,const ImplControlValue & aValue)55cdf0e10cSrcweir QStyle::State vclStateValue2StateFlag( ControlState nControlState,
56cdf0e10cSrcweir const ImplControlValue& aValue )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir QStyle::State nState =
59cdf0e10cSrcweir ( (nControlState & CTRL_STATE_DEFAULT)? QStyle::State_None: QStyle::State_None ) |
60cdf0e10cSrcweir ( (nControlState & CTRL_STATE_ENABLED)? QStyle::State_Enabled: QStyle::State_None ) |
61cdf0e10cSrcweir ( (nControlState & CTRL_STATE_FOCUSED)? QStyle::State_HasFocus: QStyle::State_None ) |
62cdf0e10cSrcweir ( (nControlState & CTRL_STATE_PRESSED)? QStyle::State_Sunken: QStyle::State_None ) |
63cdf0e10cSrcweir ( (nControlState & CTRL_STATE_SELECTED)? QStyle::State_Selected : QStyle::State_None ) |
64cdf0e10cSrcweir ( (nControlState & CTRL_STATE_ROLLOVER)? QStyle::State_MouseOver: QStyle::State_None );
65cdf0e10cSrcweir //TODO ( (nControlState & CTRL_STATE_HIDDEN)? QStyle::State_: QStyle::State_None ) |
66cdf0e10cSrcweir
67cdf0e10cSrcweir switch ( aValue.getTristateVal() )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir case BUTTONVALUE_ON: nState |= QStyle::State_On; break;
70cdf0e10cSrcweir case BUTTONVALUE_OFF: nState |= QStyle::State_Off; break;
71cdf0e10cSrcweir case BUTTONVALUE_MIXED: nState |= QStyle::State_NoChange; break;
72cdf0e10cSrcweir default: break;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir return nState;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir /**
79cdf0e10cSrcweir Convert VCL Rectangle to QRect.
80cdf0e10cSrcweir @param rControlRegion The Rectangle to convert.
81cdf0e10cSrcweir @return The matching QRect
82cdf0e10cSrcweir */
region2QRect(const Rectangle & rControlRegion)83cdf0e10cSrcweir QRect region2QRect( const Rectangle& rControlRegion )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir return QRect(rControlRegion.Left(), rControlRegion.Top(), rControlRegion.GetWidth(), rControlRegion.GetHeight());
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
KDESalGraphics()88cdf0e10cSrcweir KDESalGraphics::KDESalGraphics() :
89cdf0e10cSrcweir m_image(0)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
~KDESalGraphics()93cdf0e10cSrcweir KDESalGraphics::~KDESalGraphics()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir if (m_image)
96cdf0e10cSrcweir delete m_image;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
IsNativeControlSupported(ControlType type,ControlPart part)99cdf0e10cSrcweir sal_Bool KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart part )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir if (type == CTRL_PUSHBUTTON) return true;
102cdf0e10cSrcweir
103cdf0e10cSrcweir if (type == CTRL_MENUBAR) return true;
104cdf0e10cSrcweir
105cdf0e10cSrcweir if (type == CTRL_MENU_POPUP) return true;
106cdf0e10cSrcweir
107cdf0e10cSrcweir if (type == CTRL_EDITBOX) return true;
108cdf0e10cSrcweir
109cdf0e10cSrcweir if (type == CTRL_COMBOBOX) return true;
110cdf0e10cSrcweir
111cdf0e10cSrcweir if (type == CTRL_TOOLBAR) return true;
112cdf0e10cSrcweir
113cdf0e10cSrcweir if (type == CTRL_CHECKBOX) return true;
114cdf0e10cSrcweir
115cdf0e10cSrcweir if (type == CTRL_LISTBOX) return true;
116cdf0e10cSrcweir
117cdf0e10cSrcweir if (type == CTRL_LISTNODE) return true;
118cdf0e10cSrcweir
119cdf0e10cSrcweir if (type == CTRL_FRAME) return true;
120cdf0e10cSrcweir
121cdf0e10cSrcweir if (type == CTRL_SCROLLBAR) return true;
122cdf0e10cSrcweir
123cdf0e10cSrcweir if (type == CTRL_WINDOW_BACKGROUND) return true;
124cdf0e10cSrcweir
125cdf0e10cSrcweir if (type == CTRL_SPINBOX && (part == PART_ENTIRE_CONTROL || part == HAS_BACKGROUND_TEXTURE) ) return true;
126cdf0e10cSrcweir
127cdf0e10cSrcweir // no spinbuttons for KDE, paint spinbox complete
128cdf0e10cSrcweir //if (type == CTRL_SPINBUTTONS) return true;
129cdf0e10cSrcweir
130cdf0e10cSrcweir if (type == CTRL_GROUPBOX) return true;
131cdf0e10cSrcweir
132cdf0e10cSrcweir if (type == CTRL_FIXEDLINE) return true;
133cdf0e10cSrcweir
134cdf0e10cSrcweir if (type == CTRL_FIXEDBORDER) return true;
135cdf0e10cSrcweir
136cdf0e10cSrcweir if (type == CTRL_TOOLTIP) return true;
137cdf0e10cSrcweir
138cdf0e10cSrcweir if (type == CTRL_RADIOBUTTON) return true;
139cdf0e10cSrcweir
140cdf0e10cSrcweir if (type == CTRL_SLIDER && (part == PART_TRACK_HORZ_AREA || part == PART_TRACK_VERT_AREA) )
141cdf0e10cSrcweir return true;
142cdf0e10cSrcweir
143cdf0e10cSrcweir return false;
144cdf0e10cSrcweir
145cdf0e10cSrcweir if ( (type == CTRL_TAB_ITEM) && (part == PART_ENTIRE_CONTROL) ) return true;
146cdf0e10cSrcweir if ( (type == CTRL_TAB_PANE) && (part == PART_ENTIRE_CONTROL) ) return true;
147cdf0e10cSrcweir // no CTRL_TAB_BODY for KDE
148cdf0e10cSrcweir if ( (type == CTRL_PROGRESS) && (part == PART_ENTIRE_CONTROL) ) return true;
149cdf0e10cSrcweir
150cdf0e10cSrcweir return false;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
hitTestNativeControl(ControlType,ControlPart,const Rectangle &,const Point &,sal_Bool &)153cdf0e10cSrcweir sal_Bool KDESalGraphics::hitTestNativeControl( ControlType, ControlPart,
154cdf0e10cSrcweir const Rectangle&, const Point&,
155cdf0e10cSrcweir sal_Bool& )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir return FALSE;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir /// helper drawing methods
161cdf0e10cSrcweir namespace
162cdf0e10cSrcweir {
draw(QStyle::ControlElement element,QStyleOption * option,QImage * image,QStyle::State state)163cdf0e10cSrcweir void draw( QStyle::ControlElement element, QStyleOption* option, QImage* image, QStyle::State state )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir option->state |= state;
166cdf0e10cSrcweir option->rect = image->rect();
167cdf0e10cSrcweir
168cdf0e10cSrcweir QPainter painter(image);
169cdf0e10cSrcweir kapp->style()->drawControl(element, option, &painter);
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
draw(QStyle::PrimitiveElement element,QStyleOption * option,QImage * image,QStyle::State state,int nAdjust=0)172cdf0e10cSrcweir void draw( QStyle::PrimitiveElement element, QStyleOption* option, QImage* image, QStyle::State state, int nAdjust = 0 )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir option->state |= state;
175cdf0e10cSrcweir option->rect = image->rect();
176cdf0e10cSrcweir if( nAdjust )
177cdf0e10cSrcweir option->rect.adjust( nAdjust, nAdjust, -nAdjust, -nAdjust );
178cdf0e10cSrcweir
179cdf0e10cSrcweir QPainter painter(image);
180cdf0e10cSrcweir kapp->style()->drawPrimitive(element, option, &painter);
181cdf0e10cSrcweir }
182cdf0e10cSrcweir
draw(QStyle::ComplexControl element,QStyleOptionComplex * option,QImage * image,QStyle::State state)183cdf0e10cSrcweir void draw( QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* image, QStyle::State state )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir option->state |= state;
186cdf0e10cSrcweir option->rect = image->rect();
187cdf0e10cSrcweir
188cdf0e10cSrcweir QPainter painter(image);
189cdf0e10cSrcweir kapp->style()->drawComplexControl(element, option, &painter);
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
getFrameWidth()192cdf0e10cSrcweir int getFrameWidth()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir static int s_nFrameWidth = -1;
195cdf0e10cSrcweir if( s_nFrameWidth < 0 )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir // fill in a default
198cdf0e10cSrcweir s_nFrameWidth = 2;
199cdf0e10cSrcweir QFrame aFrame( NULL );
200cdf0e10cSrcweir aFrame.setFrameRect( QRect(0, 0, 100, 30) );
201cdf0e10cSrcweir aFrame.setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
202cdf0e10cSrcweir aFrame.ensurePolished();
203cdf0e10cSrcweir s_nFrameWidth = aFrame.frameWidth();
204cdf0e10cSrcweir }
205cdf0e10cSrcweir return s_nFrameWidth;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
lcl_drawFrame(QStyle::PrimitiveElement element,QImage * image,QStyle::State state)208cdf0e10cSrcweir void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, QStyle::State state)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
211cdf0e10cSrcweir QStyleOptionFrameV3 option;
212cdf0e10cSrcweir option.frameShape = QFrame::StyledPanel;
213cdf0e10cSrcweir option.state = QStyle::State_Sunken;
214cdf0e10cSrcweir #else
215cdf0e10cSrcweir QStyleOptionFrame option;
216cdf0e10cSrcweir
217cdf0e10cSrcweir QFrame aFrame( NULL );
218cdf0e10cSrcweir aFrame.setFrameRect( QRect(0, 0, image->width(), image->height()) );
219cdf0e10cSrcweir aFrame.setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
220cdf0e10cSrcweir aFrame.ensurePolished();
221cdf0e10cSrcweir
222cdf0e10cSrcweir option.initFrom( &aFrame );
223cdf0e10cSrcweir option.lineWidth = aFrame.lineWidth();
224cdf0e10cSrcweir option.midLineWidth = aFrame.midLineWidth();
225cdf0e10cSrcweir #endif
226cdf0e10cSrcweir
227cdf0e10cSrcweir draw(element, &option, image, state);
228cdf0e10cSrcweir }
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
drawNativeControl(ControlType type,ControlPart part,const Rectangle & rControlRegion,ControlState nControlState,const ImplControlValue & value,const OUString &)231cdf0e10cSrcweir sal_Bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
232cdf0e10cSrcweir const Rectangle& rControlRegion, ControlState nControlState,
233cdf0e10cSrcweir const ImplControlValue& value,
234cdf0e10cSrcweir const OUString& )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir // put not implemented types here
237cdf0e10cSrcweir if (type == CTRL_SPINBUTTONS)
238cdf0e10cSrcweir {
239cdf0e10cSrcweir return false;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242cdf0e10cSrcweir sal_Bool returnVal = true;
243cdf0e10cSrcweir
244cdf0e10cSrcweir QRect widgetRect = region2QRect(rControlRegion);
245cdf0e10cSrcweir if( type == CTRL_SPINBOX && part == PART_ALL_BUTTONS )
246cdf0e10cSrcweir type = CTRL_SPINBUTTONS;
247cdf0e10cSrcweir if( type == CTRL_SPINBUTTONS )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir OSL_ASSERT( value.getType() != CTRL_SPINBUTTONS );
250cdf0e10cSrcweir const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue *>(&value);
251cdf0e10cSrcweir Rectangle aButtonRect( pSpinVal->maUpperRect);
252cdf0e10cSrcweir aButtonRect.Union( pSpinVal->maLowerRect );;
253cdf0e10cSrcweir widgetRect = QRect( aButtonRect.Left(), aButtonRect.Top(),
254cdf0e10cSrcweir aButtonRect.Right(), aButtonRect.Bottom() );
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
257cdf0e10cSrcweir //if no image, or resized, make a new image
258cdf0e10cSrcweir if (!m_image || m_image->size() != widgetRect.size())
259cdf0e10cSrcweir {
260cdf0e10cSrcweir if (m_image)
261cdf0e10cSrcweir delete m_image;
262cdf0e10cSrcweir
263cdf0e10cSrcweir m_image = new QImage( widgetRect.width(),
264cdf0e10cSrcweir widgetRect.height(),
265cdf0e10cSrcweir QImage::Format_ARGB32 );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir m_image->fill(KApplication::palette().color(QPalette::Window).rgb());
268cdf0e10cSrcweir
269cdf0e10cSrcweir
270cdf0e10cSrcweir XLIB_Region pTempClipRegion = 0;
271cdf0e10cSrcweir
272cdf0e10cSrcweir if (type == CTRL_PUSHBUTTON)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir QStyleOptionButton option;
275cdf0e10cSrcweir draw( QStyle::CE_PushButton, &option, m_image,
276cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
277cdf0e10cSrcweir }
278cdf0e10cSrcweir else if ( (type == CTRL_MENUBAR))
279cdf0e10cSrcweir {
280cdf0e10cSrcweir if (part == PART_MENU_ITEM)
281cdf0e10cSrcweir {
282cdf0e10cSrcweir QStyleOptionMenuItem option;
283cdf0e10cSrcweir draw( QStyle::CE_MenuBarItem, &option, m_image,
284cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
285cdf0e10cSrcweir }
286cdf0e10cSrcweir else if (part == PART_ENTIRE_CONTROL)
287cdf0e10cSrcweir {
288cdf0e10cSrcweir }
289cdf0e10cSrcweir else
290cdf0e10cSrcweir {
291cdf0e10cSrcweir returnVal = false;
292cdf0e10cSrcweir }
293cdf0e10cSrcweir }
294cdf0e10cSrcweir else if (type == CTRL_MENU_POPUP)
295cdf0e10cSrcweir {
296cdf0e10cSrcweir if (part == PART_MENU_ITEM)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir QStyleOptionMenuItem option;
299cdf0e10cSrcweir draw( QStyle::CE_MenuItem, &option, m_image,
300cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
301cdf0e10cSrcweir }
302cdf0e10cSrcweir else if (part == PART_MENU_ITEM_CHECK_MARK && (nControlState & CTRL_STATE_PRESSED) )
303cdf0e10cSrcweir {
304cdf0e10cSrcweir QStyleOptionButton option;
305cdf0e10cSrcweir draw( QStyle::PE_IndicatorMenuCheckMark, &option, m_image,
306cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
307cdf0e10cSrcweir }
308cdf0e10cSrcweir else if (part == PART_MENU_ITEM_RADIO_MARK && (nControlState & CTRL_STATE_PRESSED) )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir QStyleOptionButton option;
311cdf0e10cSrcweir draw( QStyle::PE_IndicatorRadioButton, &option, m_image,
312cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
313cdf0e10cSrcweir }
314cdf0e10cSrcweir else
315cdf0e10cSrcweir {
316cdf0e10cSrcweir #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
317cdf0e10cSrcweir QStyleOptionFrameV3 option;
318cdf0e10cSrcweir option.frameShape = QFrame::StyledPanel;
319cdf0e10cSrcweir #else
320cdf0e10cSrcweir QStyleOptionFrameV2 option;
321cdf0e10cSrcweir #endif
322cdf0e10cSrcweir draw( QStyle::PE_FrameMenu, &option, m_image,
323cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
324cdf0e10cSrcweir }
325cdf0e10cSrcweir }
326cdf0e10cSrcweir else if ( (type == CTRL_TOOLBAR) && (part == PART_BUTTON) )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir QStyleOptionToolButton option;
329cdf0e10cSrcweir
330cdf0e10cSrcweir option.arrowType = Qt::NoArrow;
331cdf0e10cSrcweir option.subControls = QStyle::SC_ToolButton;
332cdf0e10cSrcweir
333cdf0e10cSrcweir option.state = vclStateValue2StateFlag( nControlState, value );
334cdf0e10cSrcweir option.state |= QStyle::State_Raised | QStyle::State_Enabled | QStyle::State_AutoRaise;
335cdf0e10cSrcweir
336cdf0e10cSrcweir draw( QStyle::CC_ToolButton, &option, m_image,
337cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir else if ( (type == CTRL_TOOLBAR) && (part == PART_ENTIRE_CONTROL) )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir QStyleOptionToolBar option;
342cdf0e10cSrcweir
343cdf0e10cSrcweir option.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
344cdf0e10cSrcweir option.state = vclStateValue2StateFlag( nControlState, value );
345cdf0e10cSrcweir
346cdf0e10cSrcweir draw( QStyle::CE_ToolBar, &option, m_image,
347cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
348cdf0e10cSrcweir }
349cdf0e10cSrcweir else if ( (type == CTRL_TOOLBAR) && (part == PART_THUMB_VERT) )
350cdf0e10cSrcweir {
351cdf0e10cSrcweir const int tw = widgetRect.width();
352cdf0e10cSrcweir widgetRect.setWidth(kapp->style()->pixelMetric(QStyle::PM_ToolBarHandleExtent));
353cdf0e10cSrcweir
354cdf0e10cSrcweir QStyleOption option;
355cdf0e10cSrcweir option.state = QStyle::State_Horizontal;
356cdf0e10cSrcweir
357cdf0e10cSrcweir draw( QStyle::PE_IndicatorToolBarHandle, &option, m_image,
358cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
359cdf0e10cSrcweir
360cdf0e10cSrcweir widgetRect.setWidth(tw);
361cdf0e10cSrcweir }
362cdf0e10cSrcweir else if (type == CTRL_EDITBOX)
363cdf0e10cSrcweir {
364cdf0e10cSrcweir QStyleOptionFrameV2 option;
365cdf0e10cSrcweir draw( QStyle::PE_PanelLineEdit, &option, m_image,
366cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value), 2 );
367cdf0e10cSrcweir
368cdf0e10cSrcweir draw( QStyle::PE_FrameLineEdit, &option, m_image,
369cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value), 0 );
370cdf0e10cSrcweir }
371cdf0e10cSrcweir else if (type == CTRL_COMBOBOX)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir QStyleOptionComboBox option;
374cdf0e10cSrcweir option.editable = true;
375cdf0e10cSrcweir
376cdf0e10cSrcweir draw( QStyle::CC_ComboBox, &option, m_image,
377cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
378cdf0e10cSrcweir }
379cdf0e10cSrcweir else if (type == CTRL_LISTBOX)
380cdf0e10cSrcweir {
381cdf0e10cSrcweir if( part == PART_WINDOW )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir lcl_drawFrame( QStyle::PE_Frame, m_image,
384cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
385cdf0e10cSrcweir }
386cdf0e10cSrcweir else
387cdf0e10cSrcweir {
388cdf0e10cSrcweir QStyleOptionComboBox option;
389cdf0e10cSrcweir if (part == PART_SUB_EDIT)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir draw( QStyle::CE_ComboBoxLabel, &option, m_image,
392cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
393cdf0e10cSrcweir }
394cdf0e10cSrcweir else
395cdf0e10cSrcweir {
396cdf0e10cSrcweir draw( QStyle::CC_ComboBox, &option, m_image,
397cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
398cdf0e10cSrcweir }
399cdf0e10cSrcweir }
400cdf0e10cSrcweir }
401cdf0e10cSrcweir else if (type == CTRL_LISTNODE)
402cdf0e10cSrcweir {
403cdf0e10cSrcweir QStyleOption option;
404cdf0e10cSrcweir option.state = QStyle::State_Item | QStyle::State_Children;
405cdf0e10cSrcweir
406cdf0e10cSrcweir if (nControlState & CTRL_STATE_PRESSED)
407cdf0e10cSrcweir option.state |= QStyle::State_Open;
408cdf0e10cSrcweir
409cdf0e10cSrcweir draw( QStyle::PE_IndicatorBranch, &option, m_image,
410cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
411cdf0e10cSrcweir }
412cdf0e10cSrcweir else if (type == CTRL_CHECKBOX)
413cdf0e10cSrcweir {
414cdf0e10cSrcweir QStyleOptionButton option;
415cdf0e10cSrcweir draw( QStyle::CE_CheckBox, &option, m_image,
416cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
417cdf0e10cSrcweir }
418cdf0e10cSrcweir else if (type == CTRL_SCROLLBAR)
419cdf0e10cSrcweir {
420cdf0e10cSrcweir if ((part == PART_DRAW_BACKGROUND_VERT) || (part == PART_DRAW_BACKGROUND_HORZ))
421cdf0e10cSrcweir {
422cdf0e10cSrcweir QStyleOptionSlider option;
423cdf0e10cSrcweir OSL_ASSERT( value.getType() == CTRL_SCROLLBAR );
424cdf0e10cSrcweir const ScrollbarValue* sbVal = static_cast<const ScrollbarValue *>(&value);
425cdf0e10cSrcweir
426cdf0e10cSrcweir //if the scroll bar is active (aka not degenrate...allow for hover events
427cdf0e10cSrcweir if (sbVal->mnVisibleSize < sbVal->mnMax)
428cdf0e10cSrcweir option.state = QStyle::State_MouseOver;
429cdf0e10cSrcweir
430cdf0e10cSrcweir //horizontal or vertical
431cdf0e10cSrcweir if (part == PART_DRAW_BACKGROUND_VERT)
432cdf0e10cSrcweir option.orientation = Qt::Vertical;
433cdf0e10cSrcweir else
434cdf0e10cSrcweir option.state |= QStyle::State_Horizontal;
435cdf0e10cSrcweir
436cdf0e10cSrcweir //setup parameters from the OO values
437cdf0e10cSrcweir option.minimum = sbVal->mnMin;
438cdf0e10cSrcweir option.maximum = sbVal->mnMax - sbVal->mnVisibleSize;
439cdf0e10cSrcweir option.sliderValue = sbVal->mnCur;
440cdf0e10cSrcweir option.sliderPosition = sbVal->mnCur;
441cdf0e10cSrcweir option.pageStep = sbVal->mnVisibleSize;
442cdf0e10cSrcweir
443cdf0e10cSrcweir //setup the active control...always the slider
444cdf0e10cSrcweir if (sbVal->mnThumbState & CTRL_STATE_ROLLOVER)
445cdf0e10cSrcweir option.activeSubControls = QStyle::SC_ScrollBarSlider;
446cdf0e10cSrcweir
447cdf0e10cSrcweir draw( QStyle::CC_ScrollBar, &option, m_image,
448cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
449cdf0e10cSrcweir }
450cdf0e10cSrcweir else
451cdf0e10cSrcweir {
452cdf0e10cSrcweir returnVal = false;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir }
455cdf0e10cSrcweir else if (type == CTRL_SPINBOX)
456cdf0e10cSrcweir {
457cdf0e10cSrcweir QStyleOptionSpinBox option;
458cdf0e10cSrcweir
459cdf0e10cSrcweir // determine active control
460cdf0e10cSrcweir if( value.getType() == CTRL_SPINBUTTONS )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue *>(&value);
463cdf0e10cSrcweir if( (pSpinVal->mnUpperState & CTRL_STATE_PRESSED) )
464cdf0e10cSrcweir option.activeSubControls |= QStyle::SC_SpinBoxUp;
465cdf0e10cSrcweir if( (pSpinVal->mnLowerState & CTRL_STATE_PRESSED) )
466cdf0e10cSrcweir option.activeSubControls |= QStyle::SC_SpinBoxDown;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
469cdf0e10cSrcweir draw( QStyle::CC_SpinBox, &option, m_image,
470cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
471cdf0e10cSrcweir }
472cdf0e10cSrcweir else if (type == CTRL_GROUPBOX)
473cdf0e10cSrcweir {
474cdf0e10cSrcweir QStyleOptionGroupBox option;
475cdf0e10cSrcweir draw( QStyle::CC_GroupBox, &option, m_image,
476cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir else if (type == CTRL_RADIOBUTTON)
479cdf0e10cSrcweir {
480cdf0e10cSrcweir QStyleOptionButton option;
481cdf0e10cSrcweir draw( QStyle::CE_RadioButton, &option, m_image,
482cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
483cdf0e10cSrcweir }
484cdf0e10cSrcweir else if (type == CTRL_TOOLTIP)
485cdf0e10cSrcweir {
486cdf0e10cSrcweir QStyleOption option;
487cdf0e10cSrcweir draw( QStyle::PE_PanelTipLabel, &option, m_image,
488cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
489cdf0e10cSrcweir }
490cdf0e10cSrcweir else if (type == CTRL_FRAME)
491cdf0e10cSrcweir {
492cdf0e10cSrcweir lcl_drawFrame( QStyle::PE_Frame, m_image,
493cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
494cdf0e10cSrcweir
495cdf0e10cSrcweir // draw just the border, see http://qa.openoffice.org/issues/show_bug.cgi?id=107945
496cdf0e10cSrcweir int nFrameWidth = getFrameWidth();
497cdf0e10cSrcweir pTempClipRegion = XCreateRegion();
498cdf0e10cSrcweir XRectangle xRect = { widgetRect.left(), widgetRect.top(), widgetRect.width(), widgetRect.height() };
499cdf0e10cSrcweir XUnionRectWithRegion( &xRect, pTempClipRegion, pTempClipRegion );
500cdf0e10cSrcweir xRect.x += nFrameWidth;
501cdf0e10cSrcweir xRect.y += nFrameWidth;
502cdf0e10cSrcweir
503cdf0e10cSrcweir // do not crash for too small widgets, see http://qa.openoffice.org/issues/show_bug.cgi?id=112102
504cdf0e10cSrcweir if( xRect.width > 2*nFrameWidth && xRect.height > 2*nFrameWidth )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir xRect.width -= 2*nFrameWidth;
507cdf0e10cSrcweir xRect.height -= 2*nFrameWidth;
508cdf0e10cSrcweir
509cdf0e10cSrcweir XLIB_Region pSubtract = XCreateRegion();
510cdf0e10cSrcweir XUnionRectWithRegion( &xRect, pSubtract, pSubtract );
511cdf0e10cSrcweir XSubtractRegion( pTempClipRegion, pSubtract, pTempClipRegion );
512cdf0e10cSrcweir XDestroyRegion( pSubtract );
513cdf0e10cSrcweir }
514cdf0e10cSrcweir }
515cdf0e10cSrcweir else if (type == CTRL_FIXEDBORDER)
516cdf0e10cSrcweir {
517cdf0e10cSrcweir lcl_drawFrame( QStyle::PE_FrameWindow, m_image,
518cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
519cdf0e10cSrcweir }
520cdf0e10cSrcweir else if (type == CTRL_WINDOW_BACKGROUND)
521cdf0e10cSrcweir {
522cdf0e10cSrcweir m_image->fill(KApplication::palette().color(QPalette::Window).rgb());
523cdf0e10cSrcweir }
524cdf0e10cSrcweir else if (type == CTRL_FIXEDLINE)
525cdf0e10cSrcweir {
526cdf0e10cSrcweir QStyleOptionMenuItem option;
527cdf0e10cSrcweir option.menuItemType = QStyleOptionMenuItem::Separator;
528cdf0e10cSrcweir option.state |= QStyle::State_Item;
529cdf0e10cSrcweir
530cdf0e10cSrcweir draw( QStyle::CE_MenuItem, &option, m_image,
531cdf0e10cSrcweir vclStateValue2StateFlag(nControlState, value) );
532cdf0e10cSrcweir }
533cdf0e10cSrcweir else if (type == CTRL_SLIDER && (part == PART_TRACK_HORZ_AREA || part == PART_TRACK_VERT_AREA))
534cdf0e10cSrcweir {
535cdf0e10cSrcweir OSL_ASSERT( value.getType() == CTRL_SLIDER );
536cdf0e10cSrcweir const SliderValue* slVal = static_cast<const SliderValue *>(&value);
537cdf0e10cSrcweir QStyleOptionSlider option;
538cdf0e10cSrcweir
539cdf0e10cSrcweir option.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
540cdf0e10cSrcweir option.state = vclStateValue2StateFlag( nControlState, value );
541cdf0e10cSrcweir option.maximum = slVal->mnMax;
542cdf0e10cSrcweir option.minimum = slVal->mnMin;
543cdf0e10cSrcweir option.sliderPosition = option.sliderValue = slVal->mnCur;
544cdf0e10cSrcweir option.orientation = (part == PART_TRACK_HORZ_AREA) ? Qt::Horizontal : Qt::Vertical;
545cdf0e10cSrcweir
546cdf0e10cSrcweir draw( QStyle::CC_Slider, &option, m_image, vclStateValue2StateFlag(nControlState, value) );
547cdf0e10cSrcweir }
548cdf0e10cSrcweir else
549cdf0e10cSrcweir {
550cdf0e10cSrcweir returnVal = false;
551cdf0e10cSrcweir }
552cdf0e10cSrcweir
553cdf0e10cSrcweir if (returnVal)
554cdf0e10cSrcweir {
555cdf0e10cSrcweir GC gc = GetFontGC();
556cdf0e10cSrcweir
557cdf0e10cSrcweir if( gc )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir if( pTempClipRegion )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir if( mpClipRegion )
562cdf0e10cSrcweir XIntersectRegion( pTempClipRegion, mpClipRegion, pTempClipRegion );
563cdf0e10cSrcweir XSetRegion( GetXDisplay(), gc, pTempClipRegion );
564cdf0e10cSrcweir }
565cdf0e10cSrcweir QPixmap pixmap = QPixmap::fromImage(*m_image, Qt::ColorOnly | Qt::OrderedDither | Qt::OrderedAlphaDither);
566cdf0e10cSrcweir X11SalGraphics::CopyScreenArea( GetXDisplay(),
567cdf0e10cSrcweir pixmap.handle(), pixmap.x11Info().screen(), pixmap.x11Info().depth(),
568cdf0e10cSrcweir GetDrawable(), GetScreenNumber(), GetVisual().GetDepth(),
569cdf0e10cSrcweir gc, 0, 0, widgetRect.width(), widgetRect.height(), widgetRect.left(), widgetRect.top());
570cdf0e10cSrcweir
571cdf0e10cSrcweir if( pTempClipRegion )
572cdf0e10cSrcweir {
573cdf0e10cSrcweir if( mpClipRegion )
574cdf0e10cSrcweir XSetRegion( GetXDisplay(), gc, mpClipRegion );
575cdf0e10cSrcweir else
576cdf0e10cSrcweir XSetClipMask( GetXDisplay(), gc, None );
577cdf0e10cSrcweir }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir else
580cdf0e10cSrcweir returnVal = false;
581cdf0e10cSrcweir }
582cdf0e10cSrcweir if( pTempClipRegion )
583cdf0e10cSrcweir XDestroyRegion( pTempClipRegion );
584cdf0e10cSrcweir
585cdf0e10cSrcweir return returnVal;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
getNativeControlRegion(ControlType type,ControlPart part,const Rectangle & controlRegion,ControlState controlState,const ImplControlValue & val,const OUString &,Rectangle & nativeBoundingRegion,Rectangle & nativeContentRegion)588cdf0e10cSrcweir sal_Bool KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
589cdf0e10cSrcweir const Rectangle& controlRegion, ControlState controlState,
590cdf0e10cSrcweir const ImplControlValue& val,
591cdf0e10cSrcweir const OUString&,
592cdf0e10cSrcweir Rectangle &nativeBoundingRegion, Rectangle &nativeContentRegion )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir bool retVal = false;
595cdf0e10cSrcweir
596cdf0e10cSrcweir QRect boundingRect = region2QRect( controlRegion );
597cdf0e10cSrcweir QRect contentRect = boundingRect;
598cdf0e10cSrcweir QStyleOptionComplex styleOption;
599cdf0e10cSrcweir
600cdf0e10cSrcweir switch ( type )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir // Metrics of the push button
603cdf0e10cSrcweir case CTRL_PUSHBUTTON:
604cdf0e10cSrcweir if (part == PART_ENTIRE_CONTROL)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir styleOption.state = vclStateValue2StateFlag(controlState, val);
607cdf0e10cSrcweir
608cdf0e10cSrcweir if ( controlState & CTRL_STATE_DEFAULT )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir int size = kapp->style()->pixelMetric(
611cdf0e10cSrcweir QStyle::PM_ButtonDefaultIndicator, &styleOption );
612cdf0e10cSrcweir
613cdf0e10cSrcweir boundingRect.adjust( -size, -size, size, size );
614cdf0e10cSrcweir
615cdf0e10cSrcweir retVal = true;
616cdf0e10cSrcweir }
617cdf0e10cSrcweir }
618cdf0e10cSrcweir break;
619cdf0e10cSrcweir case CTRL_EDITBOX:
620cdf0e10cSrcweir {
621cdf0e10cSrcweir int nFontHeight = kapp->fontMetrics().height();
622cdf0e10cSrcweir //int nFrameSize = kapp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
623cdf0e10cSrcweir int nLayoutTop = kapp->style()->pixelMetric(QStyle::PM_LayoutTopMargin);
624cdf0e10cSrcweir int nLayoutBottom = kapp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
625cdf0e10cSrcweir int nLayoutLeft = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
626cdf0e10cSrcweir int nLayoutRight = kapp->style()->pixelMetric(QStyle::PM_LayoutRightMargin);
627cdf0e10cSrcweir
628cdf0e10cSrcweir int nMinHeight = (nFontHeight + nLayoutTop + nLayoutBottom);
629cdf0e10cSrcweir if( boundingRect.height() < nMinHeight )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir int delta = nMinHeight - boundingRect.height();
632cdf0e10cSrcweir boundingRect.adjust( 0, 0, 0, delta );
633cdf0e10cSrcweir }
634cdf0e10cSrcweir contentRect = boundingRect;
635cdf0e10cSrcweir contentRect.adjust( -nLayoutLeft+1, -nLayoutTop+1, nLayoutRight-1, nLayoutBottom-1 );
636cdf0e10cSrcweir retVal = true;
637cdf0e10cSrcweir
638cdf0e10cSrcweir break;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir case CTRL_CHECKBOX:
641cdf0e10cSrcweir if (part == PART_ENTIRE_CONTROL)
642cdf0e10cSrcweir {
643cdf0e10cSrcweir styleOption.state = vclStateValue2StateFlag(controlState, val);
644cdf0e10cSrcweir
645cdf0e10cSrcweir contentRect.setWidth(kapp->style()->pixelMetric(
646cdf0e10cSrcweir QStyle::PM_IndicatorWidth, &styleOption));
647cdf0e10cSrcweir contentRect.setHeight(kapp->style()->pixelMetric(
648cdf0e10cSrcweir QStyle::PM_IndicatorHeight, &styleOption));
649cdf0e10cSrcweir
650cdf0e10cSrcweir contentRect.adjust(0, 0,
651cdf0e10cSrcweir 2 * kapp->style()->pixelMetric(
652cdf0e10cSrcweir QStyle::PM_FocusFrameHMargin, &styleOption),
653cdf0e10cSrcweir 2 * kapp->style()->pixelMetric(
654cdf0e10cSrcweir QStyle::PM_FocusFrameVMargin, &styleOption)
655cdf0e10cSrcweir );
656cdf0e10cSrcweir
657cdf0e10cSrcweir boundingRect = contentRect;
658cdf0e10cSrcweir
659cdf0e10cSrcweir retVal = true;
660cdf0e10cSrcweir
661cdf0e10cSrcweir break;
662cdf0e10cSrcweir }
663cdf0e10cSrcweir case CTRL_COMBOBOX:
664cdf0e10cSrcweir case CTRL_LISTBOX:
665cdf0e10cSrcweir {
666cdf0e10cSrcweir QStyleOptionComboBox cbo;
667cdf0e10cSrcweir
668cdf0e10cSrcweir cbo.rect = QRect(0, 0, contentRect.width(), contentRect.height());
669cdf0e10cSrcweir cbo.state = vclStateValue2StateFlag(controlState, val);
670cdf0e10cSrcweir
671cdf0e10cSrcweir switch ( part )
672cdf0e10cSrcweir {
673cdf0e10cSrcweir case PART_ENTIRE_CONTROL:
674cdf0e10cSrcweir {
675cdf0e10cSrcweir int size = kapp->style()->pixelMetric(QStyle::PM_ComboBoxFrameWidth) - 2;
676cdf0e10cSrcweir
677cdf0e10cSrcweir // find out the minimum size that should be used
678cdf0e10cSrcweir // assume contents is a text ling
679cdf0e10cSrcweir int nHeight = kapp->fontMetrics().height();
680cdf0e10cSrcweir QSize aContentSize( contentRect.width(), nHeight );
681cdf0e10cSrcweir QSize aMinSize = kapp->style()->
682cdf0e10cSrcweir sizeFromContents( QStyle::CT_ComboBox, &cbo, aContentSize );
683cdf0e10cSrcweir if( aMinSize.height() > contentRect.height() )
684cdf0e10cSrcweir contentRect.adjust( 0, 0, 0, aMinSize.height() - contentRect.height() );
685cdf0e10cSrcweir boundingRect = contentRect;
686cdf0e10cSrcweir // FIXME: why this difference between comboboxes and listboxes ?
687cdf0e10cSrcweir // because a combobox has a sub edit and that is positioned
688cdf0e10cSrcweir // inside the outer bordered control ?
689cdf0e10cSrcweir if( type == CTRL_COMBOBOX )
690cdf0e10cSrcweir contentRect.adjust(-size,-size,size,size);
691cdf0e10cSrcweir retVal = true;
692cdf0e10cSrcweir break;
693cdf0e10cSrcweir }
694cdf0e10cSrcweir case PART_BUTTON_DOWN:
695cdf0e10cSrcweir //the entire control can be used as the "down" button
696cdf0e10cSrcweir retVal = true;
697cdf0e10cSrcweir break;
698cdf0e10cSrcweir case PART_SUB_EDIT:
699cdf0e10cSrcweir contentRect = kapp->style()->subControlRect(
700cdf0e10cSrcweir QStyle::CC_ComboBox, &cbo, QStyle::SC_ComboBoxEditField );
701cdf0e10cSrcweir
702cdf0e10cSrcweir contentRect.translate( boundingRect.left(), boundingRect.top() );
703cdf0e10cSrcweir
704cdf0e10cSrcweir retVal = true;
705cdf0e10cSrcweir break;
706cdf0e10cSrcweir case PART_WINDOW:
707cdf0e10cSrcweir retVal = true;
708cdf0e10cSrcweir break;
709cdf0e10cSrcweir }
710cdf0e10cSrcweir break;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir case CTRL_SPINBOX:
713cdf0e10cSrcweir {
714cdf0e10cSrcweir QStyleOptionSpinBox sbo;
715cdf0e10cSrcweir
716cdf0e10cSrcweir sbo.rect = QRect(0, 0, contentRect.width(), contentRect.height());
717cdf0e10cSrcweir sbo.state = vclStateValue2StateFlag(controlState, val);
718cdf0e10cSrcweir
719cdf0e10cSrcweir switch ( part )
720cdf0e10cSrcweir {
721cdf0e10cSrcweir case PART_BUTTON_UP:
722cdf0e10cSrcweir contentRect = kapp->style()->subControlRect(
723cdf0e10cSrcweir QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxUp );
724cdf0e10cSrcweir contentRect.translate( boundingRect.left(), boundingRect.top() );
725cdf0e10cSrcweir retVal = true;
726cdf0e10cSrcweir boundingRect = QRect();
727cdf0e10cSrcweir break;
728cdf0e10cSrcweir
729cdf0e10cSrcweir case PART_BUTTON_DOWN:
730cdf0e10cSrcweir contentRect = kapp->style()->subControlRect(
731cdf0e10cSrcweir QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxDown );
732cdf0e10cSrcweir retVal = true;
733cdf0e10cSrcweir contentRect.translate( boundingRect.left(), boundingRect.top() );
734cdf0e10cSrcweir boundingRect = QRect();
735cdf0e10cSrcweir break;
736cdf0e10cSrcweir
737cdf0e10cSrcweir case PART_SUB_EDIT:
738cdf0e10cSrcweir contentRect = kapp->style()->subControlRect(
739cdf0e10cSrcweir QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxEditField );
740cdf0e10cSrcweir retVal = true;
741cdf0e10cSrcweir contentRect.translate( boundingRect.left(), boundingRect.top() );
742cdf0e10cSrcweir break;
743cdf0e10cSrcweir default:
744cdf0e10cSrcweir retVal = true;
745cdf0e10cSrcweir }
746cdf0e10cSrcweir break;
747cdf0e10cSrcweir }
748cdf0e10cSrcweir case CTRL_MENU_POPUP:
749cdf0e10cSrcweir //just limit the widget of the menu items
750cdf0e10cSrcweir //OO isn't very flexible in all reguards with the menu
751cdf0e10cSrcweir //so we do the best we can
752cdf0e10cSrcweir if (part == PART_MENU_ITEM_CHECK_MARK)
753cdf0e10cSrcweir {
754cdf0e10cSrcweir contentRect.setWidth(contentRect.height());
755cdf0e10cSrcweir retVal = true;
756cdf0e10cSrcweir }
757cdf0e10cSrcweir else if (part == PART_MENU_ITEM_RADIO_MARK)
758cdf0e10cSrcweir {
759cdf0e10cSrcweir contentRect.setWidth(contentRect.height());
760cdf0e10cSrcweir retVal = true;
761cdf0e10cSrcweir }
762cdf0e10cSrcweir break;
763cdf0e10cSrcweir case CTRL_FRAME:
764cdf0e10cSrcweir {
765cdf0e10cSrcweir if( part == PART_BORDER )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir int nFrameWidth = getFrameWidth();
768cdf0e10cSrcweir sal_uInt16 nStyle = val.getNumericVal();
769cdf0e10cSrcweir if( nStyle & FRAME_DRAW_NODRAW )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir // in this case the question is: how thick would a frame be
772cdf0e10cSrcweir // see brdwin.cxx, decoview.cxx
773cdf0e10cSrcweir // most probably the behavior in decoview.cxx is wrong.
774cdf0e10cSrcweir contentRect.adjust(nFrameWidth, nFrameWidth, -nFrameWidth, -nFrameWidth);
775cdf0e10cSrcweir }
776cdf0e10cSrcweir retVal = true;
777cdf0e10cSrcweir }
778cdf0e10cSrcweir break;
779cdf0e10cSrcweir }
780cdf0e10cSrcweir case CTRL_RADIOBUTTON:
781cdf0e10cSrcweir {
782cdf0e10cSrcweir const int h = kapp->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight);
783cdf0e10cSrcweir const int w = kapp->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth);
784cdf0e10cSrcweir
785cdf0e10cSrcweir contentRect = QRect(boundingRect.left(), boundingRect.top(), w, h);
786cdf0e10cSrcweir contentRect.adjust(0, 0,
787cdf0e10cSrcweir 2 * kapp->style()->pixelMetric(
788cdf0e10cSrcweir QStyle::PM_FocusFrameHMargin, &styleOption),
789cdf0e10cSrcweir 2 * kapp->style()->pixelMetric(
790cdf0e10cSrcweir QStyle::PM_FocusFrameVMargin, &styleOption)
791cdf0e10cSrcweir );
792cdf0e10cSrcweir boundingRect = contentRect;
793cdf0e10cSrcweir
794cdf0e10cSrcweir retVal = true;
795cdf0e10cSrcweir break;
796cdf0e10cSrcweir }
797cdf0e10cSrcweir case CTRL_SLIDER:
798cdf0e10cSrcweir {
799cdf0e10cSrcweir const int w = kapp->style()->pixelMetric(QStyle::PM_SliderLength);
800cdf0e10cSrcweir if( part == PART_THUMB_HORZ )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir contentRect = QRect(boundingRect.left(), boundingRect.top(), w, boundingRect.height());
803cdf0e10cSrcweir boundingRect = contentRect;
804cdf0e10cSrcweir retVal = true;
805cdf0e10cSrcweir }
806cdf0e10cSrcweir else if( part == PART_THUMB_VERT )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir contentRect = QRect(boundingRect.left(), boundingRect.top(), boundingRect.width(), w);
809cdf0e10cSrcweir boundingRect = contentRect;
810cdf0e10cSrcweir retVal = true;
811cdf0e10cSrcweir }
812cdf0e10cSrcweir break;
813cdf0e10cSrcweir }
814cdf0e10cSrcweir default:
815cdf0e10cSrcweir break;
816cdf0e10cSrcweir }
817cdf0e10cSrcweir #if 0
818cdf0e10cSrcweir
819cdf0e10cSrcweir
820cdf0e10cSrcweir // Metrics of the scroll bar
821cdf0e10cSrcweir case CTRL_SCROLLBAR:
822cdf0e10cSrcweir //pWidget = pWidgetPainter->scrollBar( rControlRegion,
823cdf0e10cSrcweir //( part == PART_BUTTON_LEFT || part == PART_BUTTON_RIGHT ),
824cdf0e10cSrcweir //ImplControlValue() );
825cdf0e10cSrcweir //aStyleOption.initFrom( pWidget );
826cdf0e10cSrcweir
827cdf0e10cSrcweir switch ( part )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir case PART_BUTTON_LEFT:
830cdf0e10cSrcweir case PART_BUTTON_UP:
831cdf0e10cSrcweir qRect = kapp->style()->subControlRect(
832cdf0e10cSrcweir QStyle::CC_ScrollBar, &aStyleOption, QStyle::SC_ScrollBarSubLine );
833cdf0e10cSrcweir
834cdf0e10cSrcweir // Workaround for Platinum style scroll bars. It makes the
835cdf0e10cSrcweir // left/up button invisible.
836cdf0e10cSrcweir if ( part == PART_BUTTON_LEFT )
837cdf0e10cSrcweir {
838cdf0e10cSrcweir if ( qRect.left() > kapp->style()->subControlRect(
839cdf0e10cSrcweir QStyle::CC_ScrollBar, &aStyleOption,
840cdf0e10cSrcweir QStyle::SC_ScrollBarSubPage ).left() )
841cdf0e10cSrcweir {
842cdf0e10cSrcweir qRect.setLeft( 0 );
843cdf0e10cSrcweir qRect.setRight( 0 );
844cdf0e10cSrcweir }
845cdf0e10cSrcweir }
846cdf0e10cSrcweir else
847cdf0e10cSrcweir {
848cdf0e10cSrcweir if ( qRect.top() > kapp->style()->subControlRect(
849cdf0e10cSrcweir QStyle::CC_ScrollBar, &aStyleOption,
850cdf0e10cSrcweir QStyle::SC_ScrollBarSubPage ).top() )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir qRect.setTop( 0 );
853cdf0e10cSrcweir qRect.setBottom( 0 );
854cdf0e10cSrcweir }
855cdf0e10cSrcweir }
856cdf0e10cSrcweir
857cdf0e10cSrcweir qRect.translate( qBoundingRect.left(), qBoundingRect.top() );
858cdf0e10cSrcweir
859cdf0e10cSrcweir bReturn = TRUE;
860cdf0e10cSrcweir break;
861cdf0e10cSrcweir
862cdf0e10cSrcweir case PART_BUTTON_RIGHT:
863cdf0e10cSrcweir case PART_BUTTON_DOWN:
864cdf0e10cSrcweir qRect = kapp->style()->subControlRect(
865cdf0e10cSrcweir QStyle::CC_ScrollBar, &aStyleOption, QStyle::SC_ScrollBarAddLine );
866cdf0e10cSrcweir
867cdf0e10cSrcweir // Workaround for Platinum and 3 button style scroll bars.
868cdf0e10cSrcweir // It makes the right/down button bigger.
869cdf0e10cSrcweir if ( part == PART_BUTTON_RIGHT )
870cdf0e10cSrcweir qRect.setLeft( kapp->style()->subControlRect(
871cdf0e10cSrcweir QStyle::CC_ScrollBar, &aStyleOption,
872cdf0e10cSrcweir QStyle::SC_ScrollBarAddPage ).right() + 1 );
873cdf0e10cSrcweir else
874cdf0e10cSrcweir qRect.setTop( kapp->style()->subControlRect(
875cdf0e10cSrcweir QStyle::CC_ScrollBar, &aStyleOption,
876cdf0e10cSrcweir QStyle::SC_ScrollBarAddPage ).bottom() + 1 );
877cdf0e10cSrcweir
878cdf0e10cSrcweir qRect.translate( qBoundingRect.left(), qBoundingRect.top() );
879cdf0e10cSrcweir
880cdf0e10cSrcweir bReturn = TRUE;
881cdf0e10cSrcweir break;
882cdf0e10cSrcweir }
883cdf0e10cSrcweir break;
884cdf0e10cSrcweir }
885cdf0e10cSrcweir #endif
886cdf0e10cSrcweir
887cdf0e10cSrcweir if (retVal)
888cdf0e10cSrcweir {
889cdf0e10cSrcweir // Bounding region
890cdf0e10cSrcweir Point aBPoint( boundingRect.x(), boundingRect.y() );
891cdf0e10cSrcweir Size aBSize( boundingRect.width(), boundingRect.height() );
892cdf0e10cSrcweir nativeBoundingRegion = Rectangle( aBPoint, aBSize );
893cdf0e10cSrcweir
894cdf0e10cSrcweir // Region of the content
895cdf0e10cSrcweir Point aPoint( contentRect.x(), contentRect.y() );
896cdf0e10cSrcweir Size aSize( contentRect.width(), contentRect.height() );
897cdf0e10cSrcweir nativeContentRegion = Rectangle( aPoint, aSize );
898cdf0e10cSrcweir }
899cdf0e10cSrcweir
900cdf0e10cSrcweir return retVal;
901cdf0e10cSrcweir }
902