[ooo-build-commit] Branch 'ooo-build-3-1-1' - patches/dev300
René Engelhard
rene at kemper.freedesktop.org
Mon Sep 21 00:08:47 PDT 2009
patches/dev300/apply | 4
patches/dev300/kde4_fpicker_fixes.diff | 204 +++++++++
patches/dev300/kde4_vcl_fixes.diff | 703 +++++++++++++++++++++++++++++++++
3 files changed, 911 insertions(+)
New commits:
commit 1c742022e0e75af570a8c26d3aa0637d206c1862
Author: Roman Shtylman <shtylman at namlyths.(none)>
Date: Mon Sep 21 01:00:49 2009 -0400
kde4 integration fixes (filepicker bugs and vcl flicker)
* patches/dev300/apply:
* patches/dev300/kde4_fpicker_fixes.diff:
* patches/dev300/kde4_vcl_fixes.diff:
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 9dc7a94..c20c8f2 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -2153,6 +2153,10 @@ kde4-vcl-source.diff, i#103284
kde4-oxygen-icons.diff
+# Further fixes on top of existing kde4 support
+kde4_fpicker_fixes.diff
+kde4_vcl_fixes.diff
+
[ KDE4Experimental ]
# Not yet ported to co-exist with the KDE3 stuff
kde4-kab.diff
diff --git a/patches/dev300/kde4_fpicker_fixes.diff b/patches/dev300/kde4_fpicker_fixes.diff
new file mode 100644
index 0000000..456796c
--- /dev/null
+++ b/patches/dev300/kde4_fpicker_fixes.diff
@@ -0,0 +1,204 @@
+diff --git fpicker/source/unx/kde4/KDE4FPEntry.cxx fpicker/source/unx/kde4/KDE4FPEntry.cxx
+index 9a75688..805e6cf 100644
+--- fpicker/source/unx/kde4/KDE4FPEntry.cxx
++++ fpicker/source/unx/kde4/KDE4FPEntry.cxx
+@@ -84,12 +84,12 @@ static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiS
+ // the three uno functions that will be exported
+ extern "C"
+ {
+- void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
++ void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** )
+ {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+- sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
++ sal_Bool SAL_CALL component_writeInfo( void*, void* pRegistryKey )
+ {
+ sal_Bool bRetVal = sal_True;
+
+@@ -110,7 +110,7 @@ extern "C"
+ return bRetVal;
+ }
+
+- void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey )
++ void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* )
+ {
+ void* pRet = 0;
+
+diff --git fpicker/source/unx/kde4/KDE4FilePicker.cxx fpicker/source/unx/kde4/KDE4FilePicker.cxx
+index b5cd83d..6c6db9e 100644
+--- fpicker/source/unx/kde4/KDE4FilePicker.cxx
++++ fpicker/source/unx/kde4/KDE4FilePicker.cxx
+@@ -118,6 +118,8 @@ using namespace ::com::sun::star::uno;
+ // helper functions
+ //////////////////////////////////////////////////////////////////////////
+
++#include <QDebug>
++
+ namespace
+ {
+ // controling event notifications
+@@ -166,7 +168,7 @@ KDE4FilePicker::KDE4FilePicker( const uno::Reference<lang::XMultiServiceFactory>
+
+ _layout = new QGridLayout(_extraControls);
+
+- _dialog = new KFileDialog(KUrl(""), QString(""), 0, _extraControls);
++ _dialog = new KFileDialog(KUrl("~"), QString(""), 0, _extraControls);
+ _dialog->setMode(KFile::File | KFile::LocalOnly);
+
+ //default mode
+@@ -213,21 +215,19 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute()
+ }
+ }
+
++ _dialog->clearFilter();
+ _dialog->setFilter(_filter);
++
+ _dialog->exec();
+
+ //nasty hack to get a local qt event loop going to process the dialog
+ //otherwise the dialog returns immediately
+ while (_dialog->isVisible())
+- {
+ kapp->processEvents(QEventLoop::WaitForMoreEvents);
+- }
+
+ //block and wait for user input
+ if (_dialog->result() == KFileDialog::Accepted)
+- {
+ return ExecutableDialogResults::OK;
+- }
+
+ return ExecutableDialogResults::CANCEL;
+ }
+@@ -236,13 +236,9 @@ void SAL_CALL KDE4FilePicker::setMultiSelectionMode( sal_Bool multiSelect )
+ throw( uno::RuntimeException )
+ {
+ if (multiSelect)
+- {
+ _dialog->setMode(KFile::Files | KFile::LocalOnly);
+- }
+ else
+- {
+ _dialog->setMode(KFile::File | KFile::LocalOnly);
+- }
+ }
+
+ void SAL_CALL KDE4FilePicker::setDefaultName( const ::rtl::OUString &name )
+@@ -256,7 +252,7 @@ void SAL_CALL KDE4FilePicker::setDisplayDirectory( const rtl::OUString &dir )
+ throw( uno::RuntimeException )
+ {
+ const QString url = toQString(dir);
+- _dialog->setStartDir(KUrl(url));
++ _dialog->setUrl(KUrl(url));
+ }
+
+ rtl::OUString SAL_CALL KDE4FilePicker::getDisplayDirectory()
+@@ -269,16 +265,54 @@ rtl::OUString SAL_CALL KDE4FilePicker::getDisplayDirectory()
+ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles()
+ throw( uno::RuntimeException )
+ {
+- QStringList files = _dialog->selectedFiles();
++ QStringList rawFiles = _dialog->selectedFiles();
++ QStringList files;
+
+- uno::Sequence< ::rtl::OUString > seq(files.size());
++ // check if we need to add an extension
++ QString extension = "";
++ if ( _dialog->operationMode() == KFileDialog::Saving )
++ {
++ QCheckBox *cb = dynamic_cast<QCheckBox*> (
++ _customWidgets[ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ]);
++
++ if (cb->isChecked())
++ {
++ extension = _dialog->currentFilter(); // assuming filter value is like this *.ext
++ extension.replace("*","");
++ }
++ }
++
++ // Workaround for the double click selection KDE4 bug
++ // kde file picker returns the file and directories for selectedFiles()
++ // when a file is double clicked
++ // make a true list of files
++ const QString dir = "file://" + KUrl(rawFiles[0]).directory();
+
+- for (int i=0 ; i<files.size() ; ++i)
++ // by appending the dir, we make OO treat all opens like multifile opens
++ // this makes the code for adding the the OO sequence simpler
++ files.append(dir);
++
++ for (USHORT i = 0; i < rawFiles.size(); ++i)
+ {
+- const QString fileName = "file:" + files[i];
+- seq[i] = toOUString(fileName);
++ // if the raw file is not the base directory (see above kde bug)
++ // we add the file to list of avail files
++ if ((dir + "/") != ("file://" + rawFiles[i]))
++ {
++ const QString filename = KUrl(rawFiles[i]).fileName();
++
++ //prevent extension append if we already have one
++ if (filename.endsWith(extension))
++ files.append(filename);
++ else
++ files.append(filename + extension);
++ }
+ }
+
++ // add all files and leading directory to outgoing OO sequence
++ uno::Sequence< ::rtl::OUString > seq(files.size());
++ for (int i = 0; i < files.size(); ++i)
++ seq[i] = toOUString(files[i]);
++
+ return seq;
+ }
+
+@@ -289,9 +323,7 @@ void SAL_CALL KDE4FilePicker::appendFilter( const ::rtl::OUString &title, const
+ QString f = toQString(filter);
+
+ if (!_filter.isNull())
+- {
+ _filter.append("\n");
+- }
+
+ //add to hash map for reverse lookup in getCurrentFilter
+ _filters.insert(f, t);
+@@ -318,17 +350,31 @@ rtl::OUString SAL_CALL KDE4FilePicker::getCurrentFilter()
+
+ //default if not found
+ if (filter.isNull())
+- {
+ filter = "ODF Text Document (.odt)";
+- }
+
+ return toOUString(filter);
+ }
+
+-void SAL_CALL KDE4FilePicker::appendFilterGroup( const rtl::OUString&, const uno::Sequence<beans::StringPair>& )
++void SAL_CALL KDE4FilePicker::appendFilterGroup( const rtl::OUString&, const uno::Sequence<beans::StringPair>&)
+ throw( lang::IllegalArgumentException, uno::RuntimeException )
+-{
+- //TODO
++{
++ //TODO ... don't really like this behavior... Shtylman
++#if 0
++ if (!_filter.isNull())
++ _filter.append(QString("\n"));
++
++ for (USHORT i = 0; i < filters.getLength(); ++i)
++ {
++ beans::StringPair aPair = filters[i];
++
++ _filter.append(QString("%1|%2").arg(
++ toQString(aPair.Second).replace(";", " ")).arg(
++ toQString(aPair.First).replace("/","\\/") + "\n" ));
++ }
++
++ if (filters.getLength() > 0)
++ _filter.append(QString("*.*|*.*"));
++#endif
+ }
+
+ void SAL_CALL KDE4FilePicker::setValue( sal_Int16 controlId, sal_Int16, const uno::Any &value )
diff --git a/patches/dev300/kde4_vcl_fixes.diff b/patches/dev300/kde4_vcl_fixes.diff
new file mode 100644
index 0000000..0410dbe
--- /dev/null
+++ b/patches/dev300/kde4_vcl_fixes.diff
@@ -0,0 +1,703 @@
+diff --git vcl/unx/kde4/KDEData.cxx vcl/unx/kde4/KDEData.cxx
+index 2b1f5bc..e9f4419 100644
+--- vcl/unx/kde4/KDEData.cxx
++++ vcl/unx/kde4/KDEData.cxx
+@@ -45,6 +45,8 @@ void KDEData::initNWF()
+
+ // draw toolbars on separate lines
+ pSVData->maNWFData.mbDockingAreaSeparateTB = true;
++ // no borders for menu, theming does that
++ pSVData->maNWFData.mbFlatMenu = true;
+ }
+
+ void KDEData::deInitNWF()
+diff --git vcl/unx/kde4/KDESalFrame.cxx vcl/unx/kde4/KDESalFrame.cxx
+index c8bccc8..5c18575 100644
+--- vcl/unx/kde4/KDESalFrame.cxx
++++ vcl/unx/kde4/KDESalFrame.cxx
+@@ -318,6 +318,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
+ aMenuBack = toColor( qMenuCG.color( QPalette::Button ) );
+
+ style.SetMenuTextColor( aMenuFore );
++ style.SetMenuBarTextColor( aMenuFore );
+ style.SetMenuColor( aMenuBack );
+ style.SetMenuBarColor( aMenuBack );
+
+diff --git vcl/unx/kde4/KDESalGraphics.cxx vcl/unx/kde4/KDESalGraphics.cxx
+index 35b9330..d3baf56 100644
+--- vcl/unx/kde4/KDESalGraphics.cxx
++++ vcl/unx/kde4/KDESalGraphics.cxx
+@@ -35,6 +35,8 @@
+ #include <QStyle>
+ #include <QStyleOption>
+ #include <QPainter>
++#include <QFrame>
++#include <QLabel>
+
+ #include <kapplication.h>
+
+@@ -42,10 +44,9 @@
+
+ #include "KDESalGraphics.hxx"
+
+-#include <vcl/settings.hxx>
+-#include <rtl/ustrbuf.hxx>
+-
+-#include <stdio.h>
++#include "vcl/settings.hxx"
++#include "vcl/decoview.hxx"
++#include "rtl/ustrbuf.hxx"
+
+ using namespace ::rtl;
+
+@@ -93,89 +94,113 @@ QRect region2QRect( const Region& rControlRegion )
+
+ BOOL KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart part )
+ {
++ //don't do a catch all incase new controls are added
+ 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) return true;
+-
+- if (type == CTRL_SPINBUTTONS) return true;
+-
+- if (type == CTRL_GROUPBOX) return true;
+-
+- if (type == CTRL_FIXEDLINE) return true;
+-
+- if (type == CTRL_FIXEDBORDER) return true;
+-
+- if (type == CTRL_TOOLTIP) return true;
+-
+- if (type == CTRL_RADIOBUTTON) return true;
++ else if (type == CTRL_MENUBAR) return true;
++ else if (type == CTRL_MENU_POPUP) return true;
++ else if (type == CTRL_EDITBOX) return true;
++ else if (type == CTRL_COMBOBOX) return true;
++ else if (type == CTRL_TOOLBAR) return true;
++ else if (type == CTRL_CHECKBOX) return true;
++ else if (type == CTRL_LISTBOX) return true;
++ else if (type == CTRL_LISTNODE) return true;
++ else if (type == CTRL_FRAME) return true;
++ else if (type == CTRL_SCROLLBAR) return true;
++ else if (type == CTRL_WINDOW_BACKGROUND) return true;
++ else 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;
++
++ else if (type == CTRL_GROUPBOX) return true;
++ else if (type == CTRL_FIXEDLINE) return true;
++ else if (type == CTRL_FIXEDBORDER) return true;
++ else if (type == CTRL_TOOLTIP) return true;
++ else if (type == CTRL_RADIOBUTTON) return true;
+
+ return false;
+
+- if ( (type == CTRL_TAB_ITEM) && (part == PART_ENTIRE_CONTROL) ) return true;
+- if ( (type == CTRL_TAB_PANE) && (part == PART_ENTIRE_CONTROL) ) return true;
++ //if ( (type == CTRL_TAB_ITEM) && (part == PART_ENTIRE_CONTROL) ) return true;
++ //if ( (type == CTRL_TAB_PANE) && (part == PART_ENTIRE_CONTROL) ) return true;
+ // no CTRL_TAB_BODY for KDE
+- if ( (type == CTRL_PROGRESS) && (part == PART_ENTIRE_CONTROL) ) return true;
+-
+- return false;
++ //if ( (type == CTRL_PROGRESS) && (part == PART_ENTIRE_CONTROL) ) return true;
+ }
+
+
+-BOOL KDESalGraphics::hitTestNativeControl( ControlType type, ControlPart part,
+- const Region& rControlRegion, const Point& rPos,
+- SalControlHandle&, BOOL& rIsInside )
++BOOL KDESalGraphics::hitTestNativeControl( ControlType, ControlPart,
++ const Region&, const Point&,
++ SalControlHandle&, BOOL& )
+ {
+ return FALSE;
+ }
+
++void lcl_drawFrame( QRect& i_rRect, QPainter& i_rPainter, QStyle::PrimitiveElement i_nElement,
++ ControlState i_nState, const ImplControlValue& i_rValue )
++{
++#if QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 )
++ QStyleOptionFrameV3 styleOption;
++ styleOption.frameShape = QFrame::StyledPanel;
++#else
++ QStyleOptionFrame styleOption;
++ QFrame aFrame( NULL );
++ aFrame.setFrameRect( QRect(0, 0, i_rRect.width(), i_rRect.height()) );
++ aFrame.setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
++ aFrame.ensurePolished();
++ styleOption.initFrom( &aFrame );
++ styleOption.lineWidth = aFrame.lineWidth();
++ styleOption.midLineWidth = aFrame.midLineWidth();
++#endif
++
++ styleOption.rect = QRect(0, 0, i_rRect.width(), i_rRect.height());
++ styleOption.state = vclStateValue2StateFlag( i_nState, i_rValue );
++
++#if ( QT_VERSION < QT_VERSION_CHECK( 4, 5, 0 ) )
++ styleOption.state |= QStyle::State_Sunken;
++#endif
++
++ kapp->style()->drawPrimitive(i_nElement, &styleOption, &i_rPainter);
++}
++
++#include <stdio.h>
++
+ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ const Region& rControlRegion, ControlState nControlState,
+ const ImplControlValue& value, SalControlHandle&,
+ const OUString& )
+ {
++ if (!IsNativeControlSupported(type, part))
++ return false;
++
+ BOOL returnVal = true;
+
++ SelectFont();
++ SelectPen();
++
+ Display* dpy = GetXDisplay();
+ XLIB_Window drawable = GetDrawable();
+ GC gc = SelectPen();
+
+- QRect widgetRect = region2QRect(rControlRegion);
++ QRect widgetRect = region2QRect(rControlRegion.GetBoundRect());
++
++ if( type == CTRL_SPINBOX && part == PART_ALL_BUTTONS )
++ type = CTRL_SPINBUTTONS;
++
++ if( type == CTRL_SPINBUTTONS )
++ {
++ SpinbuttonValue* pSpinVal = (SpinbuttonValue *)(value.getOptionalVal());
++ Rectangle aButtonRect( pSpinVal->maUpperRect);
++ aButtonRect.Union( pSpinVal->maLowerRect );;
++ widgetRect = QRect( aButtonRect.Left(), aButtonRect.Top(),
++ aButtonRect.Right(), aButtonRect.Bottom() );
++ }
+
+- //draw right onto the window
+ QPixmap pixmap(widgetRect.width(), widgetRect.height());
+
+- if (pixmap.isNull())
+- {
+- return false;
+- }
++ // always fill the background
++ // this way we avoid copying the screen contents over to our pixmap
++ pixmap.fill(KApplication::palette().color(QPalette::Window));
+
+ QPainter painter(&pixmap);
+- painter.setBackgroundMode(Qt::OpaqueMode);
+-
+- //copy previous screen contents for proper blending
+- QPixmap screen = QPixmap::fromX11Pixmap(drawable);
+- painter.drawPixmap(0,0, screen, widgetRect.left(), widgetRect.top(), widgetRect.width(), widgetRect.height());
+
+ if (type == CTRL_PUSHBUTTON)
+ {
+@@ -197,9 +222,8 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+
+ kapp->style()->drawControl( QStyle::CE_MenuBarItem, &styleOption, &painter);
+ }
+- else
++ else if (part == PART_ENTIRE_CONTROL)
+ {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+ }
+ }
+ else if (type == CTRL_MENU_POPUP)
+@@ -239,57 +263,73 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ }
+ else
+ {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+
++#if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
+ QStyleOptionFrameV3 styleOption;
++#else
++ QStyleOptionFrameV2 styleOption;
++#endif
+
+ styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+ styleOption.state = vclStateValue2StateFlag( nControlState, value );
++
++#if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
+ styleOption.frameShape = QFrame::StyledPanel;
++#endif
+
+ kapp->style()->drawPrimitive( QStyle::PE_FrameMenu, &styleOption, &painter);
+ }
+ }
+- else if ( (type == CTRL_TOOLBAR) && (part == PART_BUTTON) )
+- {
+- QStyleOptionToolButton styleOption;
+-
+- styleOption.arrowType = Qt::NoArrow;
+- styleOption.subControls = QStyle::SC_ToolButton;
+-
+- styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+- styleOption.state = vclStateValue2StateFlag( nControlState, value );
+- styleOption.state |= QStyle::State_Raised | QStyle::State_Enabled | QStyle::State_AutoRaise;
+-
+- kapp->style()->drawComplexControl( QStyle::CC_ToolButton, &styleOption, &painter);
+- }
+- else if ( (type == CTRL_TOOLBAR) && (part == PART_ENTIRE_CONTROL) )
++ else if (type == CTRL_TOOLBAR)
+ {
+- QStyleOptionToolBar styleOption;
+-
+- styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+- styleOption.state = vclStateValue2StateFlag( nControlState, value );
+-
+- kapp->style()->drawControl( QStyle::CE_ToolBar, &styleOption, &painter);
+- }
+- else if ( (type == CTRL_TOOLBAR) && (part == PART_THUMB_VERT) )
+- {
+- QStyleOption styleOption;
+-
+- int width = kapp->style()->pixelMetric(QStyle::PM_ToolBarHandleExtent);
++ if (part == PART_BUTTON)
++ {
++ QStyleOptionToolButton styleOption;
++
++ styleOption.arrowType = Qt::NoArrow;
++ styleOption.subControls = QStyle::SC_ToolButton;
++
++ styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
++ styleOption.state = vclStateValue2StateFlag( nControlState, value );
++ styleOption.state |= QStyle::State_Raised | QStyle::State_Enabled | QStyle::State_AutoRaise;
++
++ kapp->style()->drawComplexControl( QStyle::CC_ToolButton, &styleOption, &painter);
++ }
++ else if (part == PART_THUMB_VERT)
++ {
++ QStyleOption styleOption;
+
+- styleOption.rect = QRect(0, 0, width, widgetRect.height());
+- styleOption.state = QStyle::State_Horizontal;
++ int width = kapp->style()->pixelMetric(QStyle::PM_ToolBarHandleExtent);
++
++ styleOption.rect = QRect(0, 0, width, widgetRect.height());
++ styleOption.state = QStyle::State_Horizontal;
++
++ kapp->style()->drawPrimitive( QStyle::PE_IndicatorToolBarHandle, &styleOption, &painter);
++ }
++ else if (part == PART_ENTIRE_CONTROL)
++ {
++ QStyleOptionToolBar styleOption;
+
+- kapp->style()->drawPrimitive( QStyle::PE_IndicatorToolBarHandle, &styleOption, &painter);
++ styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
++ styleOption.state = vclStateValue2StateFlag( nControlState, value );
++
++ kapp->style()->drawControl( QStyle::CE_ToolBar, &styleOption, &painter);
++ }
++ else
++ {
++ returnVal = false;
++ }
+ }
+ else if (type == CTRL_EDITBOX)
+ {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+
+ //TODO hover?? OO does not seem to do this for line edits
+
++#if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) )
+ QStyleOptionFrameV3 styleOption;
++#else
++ QStyleOptionFrameV2 styleOption;
++#endif
+
+ styleOption.state = vclStateValue2StateFlag( nControlState, value );
+
+@@ -302,7 +342,6 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ }
+ else if (type == CTRL_COMBOBOX)
+ {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+
+ QStyleOptionComboBox styleOption;
+
+@@ -315,19 +354,26 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ }
+ else if (type == CTRL_LISTBOX)
+ {
+- QStyleOptionComboBox styleOption;
+-
+- styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+- styleOption.state = vclStateValue2StateFlag( nControlState, value );
+-
+- if (part == PART_SUB_EDIT)
+- {
+- kapp->style()->drawControl(QStyle::CE_ComboBoxLabel, &styleOption, &painter);
+- }
+- else
+- {
+- kapp->style()->drawComplexControl(QStyle::CC_ComboBox, &styleOption, &painter);
+- }
++ if( part == PART_WINDOW )
++ {
++ lcl_drawFrame( widgetRect, painter, QStyle::PE_Frame, nControlState, value );
++ }
++ else
++ {
++ QStyleOptionComboBox styleOption;
++
++ styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
++ styleOption.state = vclStateValue2StateFlag( nControlState, value );
++
++ if (part == PART_SUB_EDIT)
++ {
++ kapp->style()->drawControl(QStyle::CE_ComboBoxLabel, &styleOption, &painter);
++ }
++ else
++ {
++ kapp->style()->drawComplexControl(QStyle::CC_ComboBox, &styleOption, &painter);
++ }
++ }
+ }
+ else if (type == CTRL_LISTNODE)
+ {
+@@ -357,8 +403,6 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ }
+ else if (type == CTRL_SCROLLBAR)
+ {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+-
+ if ((part == PART_DRAW_BACKGROUND_VERT) || (part == PART_DRAW_BACKGROUND_HORZ))
+ {
+ ScrollbarValue* sbVal = static_cast<ScrollbarValue *> ( value.getOptionalVal() );
+@@ -401,24 +445,18 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ }
+ else if (type == CTRL_SPINBOX)
+ {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+- //SpinbuttonValue* sbVal = static_cast<SpinbuttonValue *> ( value.getOptionalVal() );
+-
+ QStyleOptionSpinBox styleOption;
+ styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+ styleOption.state = vclStateValue2StateFlag( nControlState, value );
+-
+- kapp->style()->drawComplexControl(QStyle::CC_SpinBox, &styleOption, &painter);
+- }
+- else if (type == CTRL_SPINBUTTONS)
+- {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+-
+- QStyleOptionSpinBox styleOption;
+- styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+- styleOption.state = vclStateValue2StateFlag( nControlState, value );
+-
+- styleOption.subControls = QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown;
++ // determine active control
++ SpinbuttonValue* pSpinVal = (SpinbuttonValue *)(value.getOptionalVal());
++ if( pSpinVal )
++ {
++ if( (pSpinVal->mnUpperState & CTRL_STATE_PRESSED) )
++ styleOption.activeSubControls |= QStyle::SC_SpinBoxUp;
++ if( (pSpinVal->mnLowerState & CTRL_STATE_PRESSED) )
++ styleOption.activeSubControls |= QStyle::SC_SpinBoxDown;
++ }
+
+ kapp->style()->drawComplexControl(QStyle::CC_SpinBox, &styleOption, &painter);
+ }
+@@ -448,25 +486,14 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ }
+ else if (type == CTRL_FRAME)
+ {
+- QStyleOptionFrameV3 styleOption;
+- styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+- styleOption.state = vclStateValue2StateFlag( nControlState, value );
+- styleOption.frameShape = QFrame::StyledPanel;
+-
+- kapp->style()->drawPrimitive(QStyle::PE_FrameWindow, &styleOption, &painter);
++ lcl_drawFrame( widgetRect, painter, QStyle::PE_Frame, nControlState, value );
+ }
+ else if (type == CTRL_FIXEDBORDER)
+ {
+- QStyleOptionFrameV3 styleOption;
+- styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height());
+- styleOption.state = vclStateValue2StateFlag( nControlState, value );
+- styleOption.frameShape = QFrame::StyledPanel;
+-
+- kapp->style()->drawPrimitive(QStyle::PE_FrameWindow, &styleOption, &painter);
++ lcl_drawFrame( widgetRect, painter, QStyle::PE_FrameWindow, nControlState, value );
+ }
+ else if (type == CTRL_WINDOW_BACKGROUND)
+ {
+- pixmap.fill(KApplication::palette().color(QPalette::Window));
+ }
+ else if (type == CTRL_FIXEDLINE)
+ {
+@@ -491,7 +518,7 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
+ drawable, GetScreenNumber(), GetVisual().GetDepth(), gc,
+ 0, 0, widgetRect.width(), widgetRect.height(), widgetRect.left(), widgetRect.top() );
+ }
+-
++
+ return returnVal;
+ }
+
+@@ -503,7 +530,7 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
+ {
+ bool retVal = false;
+
+- QRect boundingRect = region2QRect( controlRegion );
++ QRect boundingRect = region2QRect( controlRegion.GetBoundRect() );
+ QRect contentRect = boundingRect;
+ QStyleOptionComplex styleOption;
+
+@@ -528,14 +555,22 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
+ break;
+ case CTRL_EDITBOX:
+ {
+- styleOption.rect = QRect(0, 0, contentRect.width(), contentRect.height());
+- styleOption.state = vclStateValue2StateFlag(controlState, val);
+-
+- int size = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) - 1;
+-
+- contentRect.adjust( -size, -size, size, size);
+- boundingRect = contentRect;
++ int nFontHeight = kapp->fontMetrics().height();
++ //int nFrameSize = kapp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
++ int nLayoutTop = kapp->style()->pixelMetric(QStyle::PM_LayoutTopMargin);
++ int nLayoutBottom = kapp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
++ int nLayoutLeft = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
++ int nLayoutRight = kapp->style()->pixelMetric(QStyle::PM_LayoutRightMargin);
++
++ int nMinHeight = (nFontHeight + nLayoutTop + nLayoutBottom);
++ if( boundingRect.height() < nMinHeight )
++ {
++ int delta = nMinHeight - boundingRect.height();
++ boundingRect.adjust( 0, 0, 0, delta );
++ }
+
++ contentRect = boundingRect;
++ contentRect.adjust( -nLayoutLeft+1, -nLayoutTop+1, nLayoutRight-1, nLayoutBottom-1 );
+ retVal = true;
+
+ break;
+@@ -550,7 +585,12 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
+ contentRect.setHeight(kapp->style()->pixelMetric(
+ QStyle::PM_IndicatorHeight, &styleOption));
+
+- contentRect.adjust(0, 10, 0, 5);
++ contentRect.adjust(0, 0,
++ 2 * kapp->style()->pixelMetric(
++ QStyle::PM_FocusFrameHMargin, &styleOption),
++ 2 * kapp->style()->pixelMetric(
++ QStyle::PM_FocusFrameVMargin, &styleOption)
++ );
+
+ boundingRect = contentRect;
+
+@@ -571,7 +611,21 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
+ case PART_ENTIRE_CONTROL:
+ {
+ int size = kapp->style()->pixelMetric(QStyle::PM_ComboBoxFrameWidth) - 2;
+- contentRect.adjust(-size,-size,size,size);
++
++ // find out the minimum size that should be used
++ // assume contents is a text ling
++ int nHeight = kapp->fontMetrics().height();
++ QSize aContentSize( contentRect.width(), nHeight );
++ QSize aMinSize = kapp->style()->
++ sizeFromContents( QStyle::CT_ComboBox, &cbo, aContentSize );
++ if( aMinSize.height() > contentRect.height() )
++ contentRect.adjust( 0, 0, 0, aMinSize.height() - contentRect.height() );
++ boundingRect = contentRect;
++ // 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 )
++ contentRect.adjust(-size,-size,size,size);
+ retVal = true;
+ break;
+ }
+@@ -587,6 +641,9 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
+
+ retVal = true;
+ break;
++ case PART_WINDOW:
++ retVal = true;
++ break;
+ }
+ break;
+ }
+@@ -642,23 +699,35 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
+ }
+ break;
+ case CTRL_FRAME:
+- {
+- if (part == PART_BORDER)
+- {
+- int size = kapp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+- //contentRect.adjust(size, size, size, size);
+- boundingRect.adjust(-size, -size, size, size);
+- retVal = true;
+- }
+-
++ {
++ if( part == PART_BORDER )
++ {
++ int size = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
++ USHORT nStyle = val.getNumericVal();
++ if( nStyle & FRAME_DRAW_NODRAW )
++ {
++ // in this case the question is: how thick would a frame be
++ // see brdwin.cxx, decoview.cxx
++ // most probably the behavior in decoview.cxx is wrong.
++ contentRect.adjust(size, size, -size, -size);
++ }
++ retVal = true;
++ }
+ break;
+- }
++ }
+ case CTRL_RADIOBUTTON:
+ {
+ const int h = kapp->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight);
+ const int w = kapp->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth);
+
+ contentRect = QRect(boundingRect.left(), boundingRect.top(), w, h);
++ contentRect.adjust(0, 0,
++ 2 * kapp->style()->pixelMetric(
++ QStyle::PM_FocusFrameHMargin, &styleOption),
++ 2 * kapp->style()->pixelMetric(
++ QStyle::PM_FocusFrameVMargin, &styleOption)
++ );
++ boundingRect = contentRect;
+
+ retVal = true;
+ }
+diff --git vcl/unx/kde4/KDESalGraphics.hxx vcl/unx/kde4/KDESalGraphics.hxx
+index f6e77d7..53f5f8d 100644
+--- vcl/unx/kde4/KDESalGraphics.hxx
++++ vcl/unx/kde4/KDESalGraphics.hxx
+@@ -82,10 +82,10 @@ class KDESalGraphics : public X11SalGraphics
+ @param rControlHandle Carries platform dependent data and is maintained by the SalFrame implementation.
+ @param aCaption A caption or title string (like button text etc.)
+ */
+- virtual BOOL drawNativeControlText( ControlType type, ControlPart part,
+- const Region& rControlRegion, ControlState nControlState,
+- const ImplControlValue& aValue, SalControlHandle& rControlHandle,
+- const rtl::OUString& aCaption ) { return false; }
++ virtual BOOL drawNativeControlText( ControlType, ControlPart,
++ const Region&, ControlState,
++ const ImplControlValue&, SalControlHandle&,
++ const rtl::OUString& ) { return false; }
+ /** Check if the bounding regions match.
+
+ If the return value is TRUE, rNativeBoundingRegion
+diff --git vcl/unx/kde4/KDEXLib.cxx vcl/unx/kde4/KDEXLib.cxx
+index 1e4e367..f7bf04f 100644
+--- vcl/unx/kde4/KDEXLib.cxx
++++ vcl/unx/kde4/KDEXLib.cxx
+@@ -34,6 +34,7 @@
+ #include <kaboutdata.h>
+ #include <kcmdlineargs.h>
+ #include <kstartupinfo.h>
++#include <kmainwindow.h>
+
+ #undef Region
+
+@@ -59,7 +60,7 @@ KDEXLib::KDEXLib() :
+
+ KDEXLib::~KDEXLib()
+ {
+- delete (VCLKDEApplication*)m_pApplication;
++ delete m_pApplication;
+
+ // free the faked cmdline arguments no longer needed by KApplication
+ for( int i = 0; i < m_nFakeCmdLineArgs; i++ )
+@@ -139,7 +140,7 @@ void KDEXLib::Init()
+ Display* pDisp = QX11Info::display();
+ SalKDEDisplay *pSalDisplay = new SalKDEDisplay(pDisp);
+
+- ((VCLKDEApplication*)m_pApplication)->disp = pSalDisplay;
++ m_pApplication->disp = pSalDisplay;
+
+ XSetIOErrorHandler ( (XIOErrorHandler)X11SalData::XIOErrorHdl );
+ XSetErrorHandler ( (XErrorHandler)X11SalData::XErrorHdl );
+diff --git vcl/unx/kde4/KDEXLib.hxx vcl/unx/kde4/KDEXLib.hxx
+index 09a6197..7cd341f 100644
+--- vcl/unx/kde4/KDEXLib.hxx
++++ vcl/unx/kde4/KDEXLib.hxx
+@@ -29,11 +29,13 @@
+
+ #include <saldisp.hxx>
+
++class VCLKDEApplication;
++
+ class KDEXLib : public SalXLib
+ {
+ private:
+ bool m_bStartupDone;
+- void* m_pApplication;
++ VCLKDEApplication* m_pApplication;
+ char** m_pFreeCmdLineArgs;
+ char** m_pAppCmdLineArgs;
+ int m_nFakeCmdLineArgs;
+diff --git vcl/unx/kde4/VCLKDEApplication.cxx vcl/unx/kde4/VCLKDEApplication.cxx
+index ff44d1b..4c4587b 100644
+--- vcl/unx/kde4/VCLKDEApplication.cxx
++++ vcl/unx/kde4/VCLKDEApplication.cxx
+@@ -41,6 +41,9 @@ VCLKDEApplication::VCLKDEApplication() :
+
+ bool VCLKDEApplication::x11EventFilter(XEvent* event)
+ {
++ disp->DispatchInternalEvent();
++ disp->GetXLib()->CheckTimeout(true);
++
+ //if we have a display and the display consumes the event
+ //do not process the event in qt
+ if (disp && disp->Dispatch(event) > 0)
+diff --git vcl/unx/kde4/main.cxx vcl/unx/kde4/main.cxx
+index 848cd09..e31c6d7 100644
+--- vcl/unx/kde4/main.cxx
++++ vcl/unx/kde4/main.cxx
+@@ -45,8 +45,8 @@
+ extern "C" {
+ VCL_DLLPUBLIC SalInstance* create_SalInstance( oslModule )
+ {
+-#if QT_VERSION < 0x040000
+- // Qt 3.x support needs >= 3.2.2 - any 4.x should be ok
++#if QT_VERSION < 0x050000
++ // Qt 4.x support needs >= 4.1.0
+ rtl::OString aVersion( qVersion() );
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "qt version string is \"%s\"\n", aVersion.getStr() );
+@@ -57,7 +57,7 @@ extern "C" {
+ nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32();
+ if( nIndex > 0 )
+ nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32();
+- if( nMajor != 3 || nMinor < 2 || (nMinor == 2 && nMicro < 2) )
++ if( nMajor != 4 || nMinor < 1 )
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "unsuitable qt version %d.%d.%d\n", nMajor, nMinor, nMicro );
More information about the ooo-build-commit
mailing list