1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2009 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_vcl.hxx"
31 #define _SV_SALNATIVEWIDGETS_KDE_CXX
33 #define Region QtXRegion
36 #include <QStyleOption>
41 #include <kapplication.h>
45 #include "KDESalGraphics.hxx"
47 #include "vcl/settings.hxx"
48 #include "vcl/decoview.hxx"
49 #include "rtl/ustrbuf.hxx"
51 using namespace ::rtl
;
54 Conversion function between VCL ControlState together with
55 ImplControlValue and Qt state flags.
56 @param nControlState State of the widget (default, focused, ...) in Native Widget Framework.
57 @param aValue Value held by the widget (on, off, ...)
59 QStyle::State
vclStateValue2StateFlag( ControlState nControlState
,
60 const ImplControlValue
& aValue
)
62 QStyle::State nState
=
63 ( (nControlState
& CTRL_STATE_DEFAULT
)? QStyle::State_None
: QStyle::State_None
) |
64 ( (nControlState
& CTRL_STATE_ENABLED
)? QStyle::State_Enabled
: QStyle::State_None
) |
65 ( (nControlState
& CTRL_STATE_FOCUSED
)? QStyle::State_HasFocus
: QStyle::State_None
) |
66 ( (nControlState
& CTRL_STATE_PRESSED
)? QStyle::State_Sunken
: QStyle::State_None
) |
67 ( (nControlState
& CTRL_STATE_SELECTED
)? QStyle::State_Selected
: QStyle::State_None
) |
68 ( (nControlState
& CTRL_STATE_ROLLOVER
)? QStyle::State_MouseOver
: QStyle::State_None
);
69 //TODO ( (nControlState & CTRL_STATE_HIDDEN)? QStyle::State_: QStyle::State_None ) |
71 switch ( aValue
.getTristateVal() )
73 case BUTTONVALUE_ON
: nState
|= QStyle::State_On
; break;
74 case BUTTONVALUE_OFF
: nState
|= QStyle::State_Off
; break;
75 case BUTTONVALUE_MIXED
: nState
|= QStyle::State_NoChange
; break;
83 Convert VCL Region to QRect.
84 @param rControlRegion The region to convert.
85 @return The bounding box of the region.
87 QRect
region2QRect( const Region
& rControlRegion
)
89 Rectangle aRect
= rControlRegion
.GetBoundRect();
91 return QRect( QPoint( aRect
.Left(), aRect
.Top() ),
92 QPoint( aRect
.Right(), aRect
.Bottom() ) );
95 BOOL
KDESalGraphics::IsNativeControlSupported( ControlType type
, ControlPart part
)
97 if (type
== CTRL_PUSHBUTTON
) return true;
99 if (type
== CTRL_MENUBAR
) return true;
101 if (type
== CTRL_MENU_POPUP
) return true;
103 if (type
== CTRL_EDITBOX
) return true;
105 if (type
== CTRL_COMBOBOX
) return true;
107 if (type
== CTRL_TOOLBAR
) return true;
109 if (type
== CTRL_CHECKBOX
) return true;
111 if (type
== CTRL_LISTBOX
) return true;
113 if (type
== CTRL_LISTNODE
) return true;
115 if (type
== CTRL_FRAME
) return true;
117 if (type
== CTRL_SCROLLBAR
) return true;
119 if (type
== CTRL_WINDOW_BACKGROUND
) return true;
121 if (type
== CTRL_SPINBOX
&& (part
== PART_ENTIRE_CONTROL
|| part
== HAS_BACKGROUND_TEXTURE
) ) return true;
123 // no spinbuttons for KDE, paint spinbox complete
124 //if (type == CTRL_SPINBUTTONS) return true;
126 if (type
== CTRL_GROUPBOX
) return true;
128 if (type
== CTRL_FIXEDLINE
) return true;
130 if (type
== CTRL_FIXEDBORDER
) return true;
132 if (type
== CTRL_TOOLTIP
) return true;
134 if (type
== CTRL_RADIOBUTTON
) return true;
138 if ( (type
== CTRL_TAB_ITEM
) && (part
== PART_ENTIRE_CONTROL
) ) return true;
139 if ( (type
== CTRL_TAB_PANE
) && (part
== PART_ENTIRE_CONTROL
) ) return true;
140 // no CTRL_TAB_BODY for KDE
141 if ( (type
== CTRL_PROGRESS
) && (part
== PART_ENTIRE_CONTROL
) ) return true;
147 BOOL
KDESalGraphics::hitTestNativeControl( ControlType
, ControlPart
,
148 const Region
&, const Point
&,
149 SalControlHandle
&, BOOL
& )
154 void lcl_drawFrame( QRect
& i_rRect
, QPainter
& i_rPainter
, QStyle::PrimitiveElement i_nElement
,
155 ControlState i_nState
, const ImplControlValue
& i_rValue
)
157 #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
158 QStyleOptionFrameV3 styleOption
;
159 styleOption
.frameShape
= QFrame::StyledPanel
;
161 QStyleOptionFrame styleOption
;
162 QFrame
aFrame( NULL
);
163 aFrame
.setFrameRect( QRect(0, 0, i_rRect
.width(), i_rRect
.height()) );
164 aFrame
.setFrameStyle( QFrame::StyledPanel
| QFrame::Sunken
);
165 aFrame
.ensurePolished();
166 styleOption
.initFrom( &aFrame
);
167 styleOption
.lineWidth
= aFrame
.lineWidth();
168 styleOption
.midLineWidth
= aFrame
.midLineWidth();
170 styleOption
.rect
= QRect(0, 0, i_rRect
.width(), i_rRect
.height());
171 styleOption
.state
= vclStateValue2StateFlag( i_nState
, i_rValue
);
172 #if ( QT_VERSION < QT_VERSION_CHECK( 4, 5, 0 ) )
173 styleOption
.state
|= QStyle::State_Sunken
;
175 kapp
->style()->drawPrimitive(i_nElement
, &styleOption
, &i_rPainter
);
178 BOOL
KDESalGraphics::drawNativeControl( ControlType type
, ControlPart part
,
179 const Region
& rControlRegion
, ControlState nControlState
,
180 const ImplControlValue
& value
, SalControlHandle
&,
183 // put not implemented types here
184 if (type
== CTRL_SPINBUTTONS
)
189 BOOL returnVal
= true;
191 Display
* dpy
= GetXDisplay();
192 XLIB_Window drawable
= GetDrawable();
195 QRect widgetRect
= region2QRect(rControlRegion
);
196 if( type
== CTRL_SPINBOX
&& part
== PART_ALL_BUTTONS
)
197 type
= CTRL_SPINBUTTONS
;
198 if( type
== CTRL_SPINBUTTONS
)
200 SpinbuttonValue
* pSpinVal
= (SpinbuttonValue
*)(value
.getOptionalVal());
201 Rectangle
aButtonRect( pSpinVal
->maUpperRect
);
202 aButtonRect
.Union( pSpinVal
->maLowerRect
);;
203 widgetRect
= QRect( aButtonRect
.Left(), aButtonRect
.Top(),
204 aButtonRect
.Right(), aButtonRect
.Bottom() );
207 //draw right onto the window
208 QPixmap
pixmap(widgetRect
.width(), widgetRect
.height());
215 QPainter
painter(&pixmap
);
216 // painter.setBackgroundMode(Qt::OpaqueMode);
218 //copy previous screen contents for proper blending
219 #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
220 QPixmap screen
= QPixmap::fromX11Pixmap(drawable
);
221 painter
.drawPixmap(0,0, screen
, widgetRect
.left(), widgetRect
.top(), widgetRect
.width(), widgetRect
.height());
223 const QX11Info
& rX11Info( pixmap
.x11Info() );
224 X11SalGraphics::CopyScreenArea( dpy
,
225 drawable
, GetScreenNumber(), GetBitCount(),
226 pixmap
.handle(), rX11Info
.screen(), rX11Info
.depth(),
227 GetDisplay()->GetCopyGC( GetScreenNumber() ),
228 widgetRect
.left(), widgetRect
.top(), widgetRect
.width(), widgetRect
.height(),
232 if (type
== CTRL_PUSHBUTTON
)
234 QStyleOptionButton styleOption
;
236 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
237 styleOption
.state
=vclStateValue2StateFlag( nControlState
, value
);
239 kapp
->style()->drawControl( QStyle::CE_PushButton
, &styleOption
, &painter
);
241 else if ( (type
== CTRL_MENUBAR
))
243 if (part
== PART_MENU_ITEM
)
245 QStyleOptionMenuItem styleOption
;
247 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
248 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
250 kapp
->style()->drawControl( QStyle::CE_MenuBarItem
, &styleOption
, &painter
);
254 pixmap
.fill(KApplication::palette().color(QPalette::Window
));
257 else if (type
== CTRL_MENU_POPUP
)
259 if (part
== PART_MENU_ITEM
)
261 QStyleOptionMenuItem styleOption
;
263 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
264 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
266 kapp
->style()->drawControl( QStyle::CE_MenuItem
, &styleOption
, &painter
);
268 else if (part
== PART_MENU_ITEM_CHECK_MARK
)
270 QStyleOptionButton styleOption
;
272 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
273 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
275 if (nControlState
& CTRL_STATE_PRESSED
)
277 kapp
->style()->drawPrimitive( QStyle::PE_IndicatorMenuCheckMark
, &styleOption
, &painter
);
280 else if (part
== PART_MENU_ITEM_RADIO_MARK
)
282 QStyleOptionButton styleOption
;
284 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
285 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
287 if (nControlState
& CTRL_STATE_PRESSED
)
289 kapp
->style()->drawPrimitive( QStyle::PE_IndicatorRadioButton
, &styleOption
, &painter
);
294 pixmap
.fill(KApplication::palette().color(QPalette::Window
));
296 #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
297 QStyleOptionFrameV3 styleOption
;
299 QStyleOptionFrameV2 styleOption
;
302 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
303 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
304 #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
305 styleOption
.frameShape
= QFrame::StyledPanel
;
308 kapp
->style()->drawPrimitive( QStyle::PE_FrameMenu
, &styleOption
, &painter
);
311 else if ( (type
== CTRL_TOOLBAR
) && (part
== PART_BUTTON
) )
313 QStyleOptionToolButton styleOption
;
315 styleOption
.arrowType
= Qt::NoArrow
;
316 styleOption
.subControls
= QStyle::SC_ToolButton
;
318 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
319 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
320 styleOption
.state
|= QStyle::State_Raised
| QStyle::State_Enabled
| QStyle::State_AutoRaise
;
322 kapp
->style()->drawComplexControl( QStyle::CC_ToolButton
, &styleOption
, &painter
);
324 else if ( (type
== CTRL_TOOLBAR
) && (part
== PART_ENTIRE_CONTROL
) )
326 QStyleOptionToolBar styleOption
;
328 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
329 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
331 kapp
->style()->drawControl( QStyle::CE_ToolBar
, &styleOption
, &painter
);
333 else if ( (type
== CTRL_TOOLBAR
) && (part
== PART_THUMB_VERT
) )
335 QStyleOption styleOption
;
337 int width
= kapp
->style()->pixelMetric(QStyle::PM_ToolBarHandleExtent
);
339 styleOption
.rect
= QRect(0, 0, width
, widgetRect
.height());
340 styleOption
.state
= QStyle::State_Horizontal
;
342 kapp
->style()->drawPrimitive( QStyle::PE_IndicatorToolBarHandle
, &styleOption
, &painter
);
344 else if (type
== CTRL_EDITBOX
)
346 pixmap
.fill(KApplication::palette().color(QPalette::Window
));
348 //TODO hover?? OO does not seem to do this for line edits
350 #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
351 QStyleOptionFrameV3 styleOption
;
353 QStyleOptionFrameV2 styleOption
;
356 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
358 //TODO...how does the line edit draw itself internally??
359 styleOption
.rect
= QRect(2, 2, widgetRect
.width()-4, widgetRect
.height()-4);
360 kapp
->style()->drawPrimitive( QStyle::PE_PanelLineEdit
, &styleOption
, &painter
);
362 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
363 kapp
->style()->drawPrimitive( QStyle::PE_FrameLineEdit
, &styleOption
, &painter
);
365 else if (type
== CTRL_COMBOBOX
)
367 pixmap
.fill(KApplication::palette().color(QPalette::Window
));
369 QStyleOptionComboBox styleOption
;
371 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
372 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
374 styleOption
.editable
= true;
376 kapp
->style()->drawComplexControl(QStyle::CC_ComboBox
, &styleOption
, &painter
);
378 else if (type
== CTRL_LISTBOX
)
380 if( part
== PART_WINDOW
)
382 lcl_drawFrame( widgetRect
, painter
, QStyle::PE_Frame
, nControlState
, value
);
386 QStyleOptionComboBox styleOption
;
388 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
389 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
391 if (part
== PART_SUB_EDIT
)
393 kapp
->style()->drawControl(QStyle::CE_ComboBoxLabel
, &styleOption
, &painter
);
397 kapp
->style()->drawComplexControl(QStyle::CC_ComboBox
, &styleOption
, &painter
);
401 else if (type
== CTRL_LISTNODE
)
403 QStyleOption styleOption
;
405 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
406 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
408 styleOption
.state
|= QStyle::State_Item
;
409 styleOption
.state
|= QStyle::State_Children
;
411 if (nControlState
& CTRL_STATE_PRESSED
)
413 styleOption
.state
|= QStyle::State_Open
;
416 kapp
->style()->drawPrimitive(QStyle::PE_IndicatorBranch
, &styleOption
, &painter
);
418 else if (type
== CTRL_CHECKBOX
)
420 QStyleOptionButton styleOption
;
422 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
423 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
425 kapp
->style()->drawControl(QStyle::CE_CheckBox
, &styleOption
, &painter
);
427 else if (type
== CTRL_SCROLLBAR
)
429 pixmap
.fill(KApplication::palette().color(QPalette::Window
));
431 if ((part
== PART_DRAW_BACKGROUND_VERT
) || (part
== PART_DRAW_BACKGROUND_HORZ
))
433 ScrollbarValue
* sbVal
= static_cast<ScrollbarValue
*> ( value
.getOptionalVal() );
435 QStyleOptionSlider styleOption
;
436 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
438 //if the scroll bar is active (aka not degenrate...allow for hover events
439 if (sbVal
->mnVisibleSize
< sbVal
->mnMax
)
441 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
442 styleOption
.state
|= QStyle::State_MouseOver
;
445 //horizontal or vertical
446 if (part
== PART_DRAW_BACKGROUND_VERT
)
448 styleOption
.orientation
= Qt::Vertical
;
452 styleOption
.state
|= QStyle::State_Horizontal
;
455 //setup parameters from the OO values
456 styleOption
.minimum
= sbVal
->mnMin
;
457 styleOption
.maximum
= sbVal
->mnMax
- sbVal
->mnVisibleSize
;
458 styleOption
.sliderValue
= sbVal
->mnCur
;
459 styleOption
.sliderPosition
= sbVal
->mnCur
;
460 styleOption
.pageStep
= sbVal
->mnVisibleSize
;
462 //setup the active control...always the slider
463 if (sbVal
->mnThumbState
& CTRL_STATE_ROLLOVER
)
465 styleOption
.activeSubControls
= QStyle::SC_ScrollBarSlider
;
468 kapp
->style()->drawComplexControl(QStyle::CC_ScrollBar
, &styleOption
, &painter
);
471 else if (type
== CTRL_SPINBOX
)
473 pixmap
.fill(KApplication::palette().color(QPalette::Window
));
475 QStyleOptionSpinBox styleOption
;
476 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
477 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
478 // determine active control
479 SpinbuttonValue
* pSpinVal
= (SpinbuttonValue
*)(value
.getOptionalVal());
482 if( (pSpinVal
->mnUpperState
& CTRL_STATE_PRESSED
) )
483 styleOption
.activeSubControls
|= QStyle::SC_SpinBoxUp
;
484 if( (pSpinVal
->mnLowerState
& CTRL_STATE_PRESSED
) )
485 styleOption
.activeSubControls
|= QStyle::SC_SpinBoxDown
;
488 kapp
->style()->drawComplexControl(QStyle::CC_SpinBox
, &styleOption
, &painter
);
490 else if (type
== CTRL_GROUPBOX
)
492 QStyleOptionGroupBox styleOption
;
493 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
494 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
496 kapp
->style()->drawComplexControl(QStyle::CC_GroupBox
, &styleOption
, &painter
);
498 else if (type
== CTRL_RADIOBUTTON
)
500 QStyleOptionButton styleOption
;
501 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
502 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
504 kapp
->style()->drawControl(QStyle::CE_RadioButton
, &styleOption
, &painter
);
506 else if (type
== CTRL_TOOLTIP
)
508 QStyleOption styleOption
;
509 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
510 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
512 kapp
->style()->drawPrimitive(QStyle::PE_PanelTipLabel
, &styleOption
, &painter
);
514 else if (type
== CTRL_FRAME
)
516 lcl_drawFrame( widgetRect
, painter
, QStyle::PE_Frame
, nControlState
, value
);
518 else if (type
== CTRL_FIXEDBORDER
)
520 lcl_drawFrame( widgetRect
, painter
, QStyle::PE_FrameWindow
, nControlState
, value
);
522 else if (type
== CTRL_WINDOW_BACKGROUND
)
524 pixmap
.fill(KApplication::palette().color(QPalette::Window
));
526 else if (type
== CTRL_FIXEDLINE
)
528 QStyleOptionMenuItem styleOption
;
530 styleOption
.rect
= QRect(0, 0, widgetRect
.width(), widgetRect
.height());
531 styleOption
.state
= vclStateValue2StateFlag( nControlState
, value
);
532 styleOption
.menuItemType
= QStyleOptionMenuItem::Separator
;
533 styleOption
.state
|= QStyle::State_Item
;
535 kapp
->style()->drawControl( QStyle::CE_MenuItem
, &styleOption
, &painter
);
544 X11SalGraphics::CopyScreenArea( dpy
,
545 pixmap
.handle(), pixmap
.x11Info().screen(), pixmap
.x11Info().depth(),
546 drawable
, GetScreenNumber(), GetVisual().GetDepth(), gc
,
547 0, 0, widgetRect
.width(), widgetRect
.height(), widgetRect
.left(), widgetRect
.top() );
553 BOOL
KDESalGraphics::getNativeControlRegion( ControlType type
, ControlPart part
,
554 const Region
& controlRegion
, ControlState controlState
,
555 const ImplControlValue
& val
, SalControlHandle
&,
557 Region
&nativeBoundingRegion
, Region
&nativeContentRegion
)
561 QRect boundingRect
= region2QRect( controlRegion
);
562 QRect contentRect
= boundingRect
;
563 QStyleOptionComplex styleOption
;
567 // Metrics of the push button
568 case CTRL_PUSHBUTTON
:
569 if (part
== PART_ENTIRE_CONTROL
)
571 styleOption
.state
= vclStateValue2StateFlag(controlState
, val
);
573 if ( controlState
& CTRL_STATE_DEFAULT
)
575 int size
= kapp
->style()->pixelMetric(
576 QStyle::PM_ButtonDefaultIndicator
, &styleOption
);
578 boundingRect
.adjust( -size
, -size
, size
, size
);
586 int nFontHeight
= kapp
->fontMetrics().height();
587 //int nFrameSize = kapp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
588 int nLayoutTop
= kapp
->style()->pixelMetric(QStyle::PM_LayoutTopMargin
);
589 int nLayoutBottom
= kapp
->style()->pixelMetric(QStyle::PM_LayoutBottomMargin
);
590 int nLayoutLeft
= kapp
->style()->pixelMetric(QStyle::PM_LayoutLeftMargin
);
591 int nLayoutRight
= kapp
->style()->pixelMetric(QStyle::PM_LayoutRightMargin
);
593 int nMinHeight
= (nFontHeight
+ nLayoutTop
+ nLayoutBottom
);
594 if( boundingRect
.height() < nMinHeight
)
596 int delta
= nMinHeight
- boundingRect
.height();
597 boundingRect
.adjust( 0, 0, 0, delta
);
599 contentRect
= boundingRect
;
600 contentRect
.adjust( -nLayoutLeft
+1, -nLayoutTop
+1, nLayoutRight
-1, nLayoutBottom
-1 );
606 if (part
== PART_ENTIRE_CONTROL
)
608 styleOption
.state
= vclStateValue2StateFlag(controlState
, val
);
610 contentRect
.setWidth(kapp
->style()->pixelMetric(
611 QStyle::PM_IndicatorWidth
, &styleOption
));
612 contentRect
.setHeight(kapp
->style()->pixelMetric(
613 QStyle::PM_IndicatorHeight
, &styleOption
));
615 contentRect
.adjust(0, 0,
616 2 * kapp
->style()->pixelMetric(
617 QStyle::PM_FocusFrameHMargin
, &styleOption
),
618 2 * kapp
->style()->pixelMetric(
619 QStyle::PM_FocusFrameVMargin
, &styleOption
)
622 boundingRect
= contentRect
;
631 QStyleOptionComboBox cbo
;
633 cbo
.rect
= QRect(0, 0, contentRect
.width(), contentRect
.height());
634 cbo
.state
= vclStateValue2StateFlag(controlState
, val
);
638 case PART_ENTIRE_CONTROL
:
640 int size
= kapp
->style()->pixelMetric(QStyle::PM_ComboBoxFrameWidth
) - 2;
642 // find out the minimum size that should be used
643 // assume contents is a text ling
644 int nHeight
= kapp
->fontMetrics().height();
645 QSize
aContentSize( contentRect
.width(), nHeight
);
646 QSize aMinSize
= kapp
->style()->
647 sizeFromContents( QStyle::CT_ComboBox
, &cbo
, aContentSize
);
648 if( aMinSize
.height() > contentRect
.height() )
649 contentRect
.adjust( 0, 0, 0, aMinSize
.height() - contentRect
.height() );
650 boundingRect
= contentRect
;
651 // FIXME: why this difference between comboboxes and listboxes ?
652 // because a combobox has a sub edit and that is positioned
653 // inside the outer bordered control ?
654 if( type
== CTRL_COMBOBOX
)
655 contentRect
.adjust(-size
,-size
,size
,size
);
659 case PART_BUTTON_DOWN
:
660 //the entire control can be used as the "down" button
664 contentRect
= kapp
->style()->subControlRect(
665 QStyle::CC_ComboBox
, &cbo
, QStyle::SC_ComboBoxEditField
);
667 contentRect
.translate( boundingRect
.left(), boundingRect
.top() );
679 QStyleOptionSpinBox sbo
;
681 sbo
.rect
= QRect(0, 0, contentRect
.width(), contentRect
.height());
682 sbo
.state
= vclStateValue2StateFlag(controlState
, val
);
687 contentRect
= kapp
->style()->subControlRect(
688 QStyle::CC_SpinBox
, &sbo
, QStyle::SC_SpinBoxUp
);
689 contentRect
.translate( boundingRect
.left(), boundingRect
.top() );
691 boundingRect
= QRect();
694 case PART_BUTTON_DOWN
:
695 contentRect
= kapp
->style()->subControlRect(
696 QStyle::CC_SpinBox
, &sbo
, QStyle::SC_SpinBoxDown
);
698 contentRect
.translate( boundingRect
.left(), boundingRect
.top() );
699 boundingRect
= QRect();
703 contentRect
= kapp
->style()->subControlRect(
704 QStyle::CC_SpinBox
, &sbo
, QStyle::SC_SpinBoxEditField
);
706 contentRect
.translate( boundingRect
.left(), boundingRect
.top() );
713 case CTRL_MENU_POPUP
:
714 //just limit the widget of the menu items
715 //OO isn't very flexible in all reguards with the menu
716 //so we do the best we can
717 if (part
== PART_MENU_ITEM_CHECK_MARK
)
719 contentRect
.setWidth(contentRect
.height());
722 else if (part
== PART_MENU_ITEM_RADIO_MARK
)
724 contentRect
.setWidth(contentRect
.height());
730 if( part
== PART_BORDER
)
732 int size
= kapp
->style()->pixelMetric(QStyle::PM_LayoutLeftMargin
);
733 USHORT nStyle
= val
.getNumericVal();
734 if( nStyle
& FRAME_DRAW_NODRAW
)
736 // in this case the question is: how thick would a frame be
737 // see brdwin.cxx, decoview.cxx
738 // most probably the behavior in decoview.cxx is wrong.
739 contentRect
.adjust(size
, size
, -size
, -size
);
745 case CTRL_RADIOBUTTON
:
747 const int h
= kapp
->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight
);
748 const int w
= kapp
->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth
);
750 contentRect
= QRect(boundingRect
.left(), boundingRect
.top(), w
, h
);
751 contentRect
.adjust(0, 0,
752 2 * kapp
->style()->pixelMetric(
753 QStyle::PM_FocusFrameHMargin
, &styleOption
),
754 2 * kapp
->style()->pixelMetric(
755 QStyle::PM_FocusFrameVMargin
, &styleOption
)
757 boundingRect
= contentRect
;
767 // Metrics of the scroll bar
769 //pWidget = pWidgetPainter->scrollBar( rControlRegion,
770 //( part == PART_BUTTON_LEFT || part == PART_BUTTON_RIGHT ),
771 //ImplControlValue() );
772 //aStyleOption.initFrom( pWidget );
776 case PART_BUTTON_LEFT
:
778 qRect
= kapp
->style()->subControlRect(
779 QStyle::CC_ScrollBar
, &aStyleOption
, QStyle::SC_ScrollBarSubLine
);
781 // Workaround for Platinum style scroll bars. It makes the
782 // left/up button invisible.
783 if ( part
== PART_BUTTON_LEFT
)
785 if ( qRect
.left() > kapp
->style()->subControlRect(
786 QStyle::CC_ScrollBar
, &aStyleOption
,
787 QStyle::SC_ScrollBarSubPage
).left() )
795 if ( qRect
.top() > kapp
->style()->subControlRect(
796 QStyle::CC_ScrollBar
, &aStyleOption
,
797 QStyle::SC_ScrollBarSubPage
).top() )
800 qRect
.setBottom( 0 );
804 qRect
.translate( qBoundingRect
.left(), qBoundingRect
.top() );
809 case PART_BUTTON_RIGHT
:
810 case PART_BUTTON_DOWN
:
811 qRect
= kapp
->style()->subControlRect(
812 QStyle::CC_ScrollBar
, &aStyleOption
, QStyle::SC_ScrollBarAddLine
);
814 // Workaround for Platinum and 3 button style scroll bars.
815 // It makes the right/down button bigger.
816 if ( part
== PART_BUTTON_RIGHT
)
817 qRect
.setLeft( kapp
->style()->subControlRect(
818 QStyle::CC_ScrollBar
, &aStyleOption
,
819 QStyle::SC_ScrollBarAddPage
).right() + 1 );
821 qRect
.setTop( kapp
->style()->subControlRect(
822 QStyle::CC_ScrollBar
, &aStyleOption
,
823 QStyle::SC_ScrollBarAddPage
).bottom() + 1 );
825 qRect
.translate( qBoundingRect
.left(), qBoundingRect
.top() );
837 Point
aBPoint( boundingRect
.x(), boundingRect
.y() );
838 Size
aBSize( boundingRect
.width(), boundingRect
.height() );
839 nativeBoundingRegion
= Region( Rectangle( aBPoint
, aBSize
) );
841 // Region of the content
842 Point
aPoint( contentRect
.x(), contentRect
.y() );
843 Size
aSize( contentRect
.width(), contentRect
.height() );
844 nativeContentRegion
= Region( Rectangle( aPoint
, aSize
) );