Merged upstream commits: 88e16529fc7b0e312b68e38295348c93b437aad8 "tdf#92110 KDE4: cleanup IsNativeControlSupported" 57792314c7b05f71c66834ee47bfaa09003df765 "tdf#92115 KDE4: better listbox theming" diff -u b/vcl/unx/kde4/KDESalGraphics.cxx b/vcl/unx/kde4/KDESalGraphics.cxx --- b/vcl/unx/kde4/KDESalGraphics.cxx +++ b/vcl/unx/kde4/KDESalGraphics.cxx @@ -85,47 +85,43 @@ bool KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart part ) { - if (type == CTRL_PUSHBUTTON) return true; - - if (type == CTRL_MENUBAR) return true; - - if (type == CTRL_MENU_POPUP) return true; - - if (type == CTRL_EDITBOX) return true; - - if (type == CTRL_COMBOBOX) return true; - - if (type == CTRL_TOOLBAR) return true; - - if (type == CTRL_CHECKBOX) return true; - - if (type == CTRL_LISTBOX) return true; - - if (type == CTRL_LISTNODE) return true; - - if (type == CTRL_FRAME) return true; - - if (type == CTRL_SCROLLBAR) return true; - - if (type == CTRL_WINDOW_BACKGROUND) return true; - - if (type == CTRL_SPINBOX && (part == PART_ENTIRE_CONTROL || part == HAS_BACKGROUND_TEXTURE) ) return true; - - // no spinbuttons for KDE, paint spinbox complete - //if (type == CTRL_SPINBUTTONS) return true; - - if (type == CTRL_GROUPBOX) return true; - - if (type == CTRL_FIXEDLINE) return true; - - if (type == CTRL_TOOLTIP) return true; + switch (type) + { + case CTRL_PUSHBUTTON: + case CTRL_RADIOBUTTON: + case CTRL_CHECKBOX: + case CTRL_TOOLTIP: + case CTRL_PROGRESS: + case CTRL_LISTNODE: + return (part == PART_ENTIRE_CONTROL); + + case CTRL_MENUBAR: + case CTRL_MENU_POPUP: + case CTRL_EDITBOX: + case CTRL_COMBOBOX: + case CTRL_TOOLBAR: + case CTRL_FRAME: + case CTRL_SCROLLBAR: + case CTRL_WINDOW_BACKGROUND: + case CTRL_GROUPBOX: + case CTRL_FIXEDLINE: + return true; + + case CTRL_LISTBOX: + return (part == PART_ENTIRE_CONTROL + || part == PART_SUB_EDIT + || part == PART_WINDOW + || part == PART_BUTTON_DOWN); - if (type == CTRL_RADIOBUTTON) return true; + case CTRL_SPINBOX: + return (part == PART_ENTIRE_CONTROL || part == HAS_BACKGROUND_TEXTURE); - if (type == CTRL_SLIDER && (part == PART_TRACK_HORZ_AREA || part == PART_TRACK_VERT_AREA) ) - return true; + case CTRL_SLIDER: + return (part == PART_TRACK_HORZ_AREA || part == PART_TRACK_VERT_AREA); - if ( (type == CTRL_PROGRESS) && (part == PART_ENTIRE_CONTROL) ) return true; + default: + break; + } return false; } @@ -221,15 +217,15 @@ const ImplControlValue& value, const OUString& ) { - if( lastPopupRect.isValid() && ( type != CTRL_MENU_POPUP || part != PART_MENU_ITEM )) - lastPopupRect = QRect(); - - // put not implemented types here - if (type == CTRL_SPINBUTTONS) - { + bool nativeSupport = IsNativeControlSupported( type, part ); + if( ! nativeSupport ) { + assert( ! nativeSupport && "drawNativeControl called without native support!" ); return false; } + if( lastPopupRect.isValid() && ( type != CTRL_MENU_POPUP || part != PART_MENU_ITEM )) + lastPopupRect = QRect(); + bool returnVal = true; QRect widgetRect = region2QRect(rControlRegion); @@ -414,24 +410,26 @@ } else if (type == CTRL_LISTBOX) { - if( part == PART_WINDOW ) - { - lcl_drawFrame( QStyle::PE_Frame, m_image, - vclStateValue2StateFlag(nControlState, value) ); - } - else - { - QStyleOptionComboBox option; - if (part == PART_SUB_EDIT) - { + QStyleOptionComboBox option; + switch (part) { + case PART_WINDOW: + lcl_drawFrame( QStyle::PE_Frame, m_image, + vclStateValue2StateFlag(nControlState, value) ); + break; + case PART_SUB_EDIT: draw( QStyle::CE_ComboBoxLabel, &option, m_image, vclStateValue2StateFlag(nControlState, value) ); - } - else - { + break; + case PART_ENTIRE_CONTROL: + draw( QStyle::CC_ComboBox, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); + break; + case PART_BUTTON_DOWN: + m_image->fill( Qt::transparent ); + option.subControls = QStyle::SC_ComboBoxArrow; draw( QStyle::CC_ComboBox, &option, m_image, vclStateValue2StateFlag(nControlState, value) ); - } + break; } } else if (type == CTRL_LISTNODE) @@ -652,6 +650,12 @@ const OUString&, Rectangle &nativeBoundingRegion, Rectangle &nativeContentRegion ) { + bool nativeSupport = IsNativeControlSupported( type, part ); + if( ! nativeSupport ) { + assert( ! nativeSupport && "drawNativeControl called without native support!" ); + return false; + } + bool retVal = false; QRect boundingRect = region2QRect( controlRegion ); @@ -733,8 +737,6 @@ { case PART_ENTIRE_CONTROL: { - int size = QApplication::style()->pixelMetric(QStyle::PM_ComboBoxFrameWidth) - 2; - // find out the minimum size that should be used // assume contents is a text ling int nHeight = QApplication::fontMetrics().height(); @@ -747,8 +749,10 @@ // FIXME: why this difference between comboboxes and listboxes ? // because a combobox has a sub edit and that is positioned // inside the outer bordered control ? - if( type == CTRL_COMBOBOX ) + if( type == CTRL_COMBOBOX ) { + int size = QApplication::style()->pixelMetric(QStyle::PM_ComboBoxFrameWidth) - 2; contentRect.adjust(-size,-size,size,size); + } retVal = true; break; } @@ -761,13 +765,22 @@ retVal = true; break; case PART_SUB_EDIT: + { contentRect = QApplication::style()->subControlRect( QStyle::CC_ComboBox, &cbo, QStyle::SC_ComboBoxEditField ); - contentRect.translate( boundingRect.left(), boundingRect.top() ); + int hmargin = QApplication::style()->pixelMetric( + QStyle::PM_FocusFrameHMargin, &styleOption); + int vmargin = QApplication::style()->pixelMetric( + QStyle::PM_FocusFrameVMargin, &styleOption); + + contentRect.translate( boundingRect.left() + hmargin, boundingRect.top() + vmargin ); + contentRect.adjust( 0, 0, -2 * hmargin, -2 * vmargin ); + boundingRect = contentRect; retVal = true; break; + } case PART_WINDOW: retVal = true; break;