1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_vcl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define _SV_SALNATIVEWIDGETS_KDE_CXX 32*cdf0e10cSrcweir #include <shell/kde_headers.h> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <unx/salunx.h> 35*cdf0e10cSrcweir #include <unx/saldata.hxx> 36*cdf0e10cSrcweir #include <unx/saldisp.hxx> 37*cdf0e10cSrcweir #include <unx/salgdi.h> 38*cdf0e10cSrcweir #include <unx/pspgraphics.h> 39*cdf0e10cSrcweir #include <unx/kde/kdedata.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <vcl/settings.hxx> 42*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir using namespace ::rtl; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir /** Cached native widgets. 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir A class which caches and paints the native widgets. 50*cdf0e10cSrcweir */ 51*cdf0e10cSrcweir class WidgetPainter 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir protected: 54*cdf0e10cSrcweir /** Cached push button. 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir It is necessary for the QStyle::drawControl(). The buttons are created 57*cdf0e10cSrcweir on demand and they are still hidden (no QWidget::show() is called). 58*cdf0e10cSrcweir */ 59*cdf0e10cSrcweir QPushButton *m_pPushButton; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir /** Cached radio button. 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir @see m_pPushButton 64*cdf0e10cSrcweir */ 65*cdf0e10cSrcweir QRadioButton *m_pRadioButton; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir /** Cached check box. 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir @see m_pPushButton 70*cdf0e10cSrcweir */ 71*cdf0e10cSrcweir QCheckBox *m_pCheckBox; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir /** Cached combo box. 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir @see m_pPushButton 76*cdf0e10cSrcweir */ 77*cdf0e10cSrcweir QComboBox *m_pComboBox; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir /** Cached editable combo box. 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir Needed, because some styles do not like dynamic changes 82*cdf0e10cSrcweir (QComboBox::setEditable()). 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir @see m_pPushButton 85*cdf0e10cSrcweir */ 86*cdf0e10cSrcweir QComboBox *m_pEditableComboBox; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir /** Cached line edit box. 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir @see m_pPushButton 91*cdf0e10cSrcweir */ 92*cdf0e10cSrcweir QLineEdit *m_pLineEdit; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir /** Cached spin box. 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir @see m_pPushButton 97*cdf0e10cSrcweir */ 98*cdf0e10cSrcweir QSpinWidget *m_pSpinWidget; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir /** Cached spin box'es line edit. 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @see m_pPushButton 103*cdf0e10cSrcweir */ 104*cdf0e10cSrcweir QLineEdit *m_pSpinEdit; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /** Cached tab. 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir Left, middle, right tab and a tab which is alone. 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir @see m_pPushButton 111*cdf0e10cSrcweir */ 112*cdf0e10cSrcweir QTab *m_pTabLeft, *m_pTabMiddle, *m_pTabRight, *m_pTabAlone; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir /** Cached tab bar's parent widget. 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir Needed, because the Qt windows style checks for the availability 117*cdf0e10cSrcweir of tab bar's parent. We cannot use m_pTabWidget, because 118*cdf0e10cSrcweir TabWidget::setTabBar() and TabWidget::tabBar() methods are 119*cdf0e10cSrcweir protected. 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir @see m_pPushButton, m_pTabWidget 122*cdf0e10cSrcweir */ 123*cdf0e10cSrcweir QWidget *m_pTabBarParent; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir /** Cached tab bar widget. 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir @see m_pPushButton 128*cdf0e10cSrcweir */ 129*cdf0e10cSrcweir QTabBar *m_pTabBar; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir /** Cached tab widget. 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir We need it to draw the tab page. It cannot be used to draw the 134*cdf0e10cSrcweir tabs themselves, because the drawing has to be tweaked a little 135*cdf0e10cSrcweir due to not enough information from VCL. 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir @see m_pPushButton, m_pTabBarParent 138*cdf0e10cSrcweir */ 139*cdf0e10cSrcweir QTabWidget *m_pTabWidget; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir /** Cached list view. 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir @see m_pPushButton 144*cdf0e10cSrcweir */ 145*cdf0e10cSrcweir QListView *m_pListView; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /** Cached scroll bar. 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir @see m_pPushButton 150*cdf0e10cSrcweir */ 151*cdf0e10cSrcweir QScrollBar *m_pScrollBar; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir /** Cached dock area. Needed for proper functionality of tool bars. 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir @see m_pPushButton 156*cdf0e10cSrcweir */ 157*cdf0e10cSrcweir QMainWindow *m_pMainWindow; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir /** Cached tool bar. 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir @see m_pPushButton 162*cdf0e10cSrcweir */ 163*cdf0e10cSrcweir QToolBar *m_pToolBarHoriz, *m_pToolBarVert; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir /** Cached tool button. 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir @see m_pPushButton 168*cdf0e10cSrcweir */ 169*cdf0e10cSrcweir QToolButton *m_pToolButton; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir /** Cached menu bar. 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir @see m_pPushButton 174*cdf0e10cSrcweir */ 175*cdf0e10cSrcweir QMenuBar *m_pMenuBar; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir /** Identifiers of menu bar items. 178*cdf0e10cSrcweir */ 179*cdf0e10cSrcweir int m_nMenuBarEnabledItem, m_nMenuBarDisabledItem; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir /** Cached popup menu. 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir @see m_pPushButton 184*cdf0e10cSrcweir */ 185*cdf0e10cSrcweir QPopupMenu *m_pPopupMenu; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir /** Identifiers of popup menu items. 188*cdf0e10cSrcweir */ 189*cdf0e10cSrcweir int m_nPopupMenuEnabledItem, m_nPopupMenuDisabledItem; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir /** cached progress bar 192*cdf0e10cSrcweir */ 193*cdf0e10cSrcweir QProgressBar *m_pProgressBar; 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // TODO other widgets 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir public: 198*cdf0e10cSrcweir /** Implicit constructor. 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir It creates an empty WidgetPainter with all the cached widgets initialized 201*cdf0e10cSrcweir to NULL. The widgets are created on demand and they are still hidden 202*cdf0e10cSrcweir (no QWidget::show()), because they are needed just as a parameter for 203*cdf0e10cSrcweir QStyle::drawControl(). 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir @see m_pPushButton 206*cdf0e10cSrcweir */ 207*cdf0e10cSrcweir WidgetPainter( void ); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir /** Destructor. 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir Destruct all the cached widgets. 212*cdf0e10cSrcweir */ 213*cdf0e10cSrcweir virtual ~WidgetPainter( void ); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir /** Paints the specified widget to the X window. 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir Use X calls to bitblt (bit block transfer) the widget qWidget to 218*cdf0e10cSrcweir the window specified by drawable with the style defined by nStyle. 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir @param qWidget 221*cdf0e10cSrcweir A pointer to the cached widget. 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir @param nState 224*cdf0e10cSrcweir The state of the control (focused, on/off, ...) 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir @param aValue 227*cdf0e10cSrcweir The value (true/false, ...) 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir @param dpy 230*cdf0e10cSrcweir The display to be used by the X calls. 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir @param drawable 233*cdf0e10cSrcweir The destination X window. 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir @param gc 236*cdf0e10cSrcweir The graphics context. 237*cdf0e10cSrcweir */ 238*cdf0e10cSrcweir sal_Bool drawStyledWidget( QWidget *pWidget, 239*cdf0e10cSrcweir ControlState nState, const ImplControlValue& aValue, 240*cdf0e10cSrcweir Display *dpy, XLIB_Window drawable, int nScreen, int nDepth, GC gc, 241*cdf0e10cSrcweir ControlPart nPart = PART_ENTIRE_CONTROL ); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir /** 'Get' method for push button. 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir The method returns the cached push button. It is constructed if it 246*cdf0e10cSrcweir does not exist. It has NULL as a parent and it stays hidden, but it 247*cdf0e10cSrcweir is necessary for the drawStyledWidget() method. 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir @return valid push button. 250*cdf0e10cSrcweir */ 251*cdf0e10cSrcweir QPushButton *pushButton( const Rectangle& rControlRegion, sal_Bool bDefault ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir /** 'Get' method for radio button. 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir @see pushButton() 256*cdf0e10cSrcweir */ 257*cdf0e10cSrcweir QRadioButton *radioButton( const Rectangle& rControlRegion ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir /** 'Get' method for check box. 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir @see pushButton() 262*cdf0e10cSrcweir */ 263*cdf0e10cSrcweir QCheckBox *checkBox( const Rectangle& rControlRegion ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir /** 'Get' method for combo box. 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir It returns m_pComboBox or m_pEditableComboBox according to 268*cdf0e10cSrcweir bEditable. 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir @see pushButton(), m_pEditableComboBox 271*cdf0e10cSrcweir */ 272*cdf0e10cSrcweir QComboBox *comboBox( const Rectangle& rControlRegion, sal_Bool bEditable ); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir /** 'Get' method for line edit box. 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir @see pushButton() 277*cdf0e10cSrcweir */ 278*cdf0e10cSrcweir QLineEdit *lineEdit( const Rectangle& rControlRegion ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir /** 'Get' method for spin box. 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir @see pushButton() 283*cdf0e10cSrcweir */ 284*cdf0e10cSrcweir QSpinWidget *spinWidget( const Rectangle& rControlRegion ); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir /** 'Get' method for tab bar. 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir @see pushButton() 289*cdf0e10cSrcweir */ 290*cdf0e10cSrcweir QTabBar *tabBar( const Rectangle& rControlRegion ); 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir /** 'Get' method for tab widget. 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir @see pushButton() 295*cdf0e10cSrcweir */ 296*cdf0e10cSrcweir QTabWidget *tabWidget( const Rectangle& rControlRegion ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir /** 'Get' method for list view. 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir @see pushButton() 301*cdf0e10cSrcweir */ 302*cdf0e10cSrcweir QListView *listView( const Rectangle& rControlRegion ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir /** 'Get' method for scroll bar. 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir @see pushButton() 307*cdf0e10cSrcweir */ 308*cdf0e10cSrcweir QScrollBar *scrollBar( const Rectangle& rControlRegion, 309*cdf0e10cSrcweir sal_Bool bHorizontal, const ImplControlValue& aValue ); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir /** 'Get' method for tool bar. 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir @see pushButton() 314*cdf0e10cSrcweir */ 315*cdf0e10cSrcweir QToolBar *toolBar( const Rectangle& rControlRegion, sal_Bool bHorizontal ); 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir /** 'Get' method for tool button. 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir @see pushButton() 320*cdf0e10cSrcweir */ 321*cdf0e10cSrcweir QToolButton *toolButton( const Rectangle& rControlRegion ); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir /** 'Get' method for menu bar. 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir @see pushButton() 326*cdf0e10cSrcweir */ 327*cdf0e10cSrcweir QMenuBar *menuBar( const Rectangle& rControlRegion ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir /** 'Get' method for popup menu. 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir @see pushButton() 332*cdf0e10cSrcweir */ 333*cdf0e10cSrcweir QPopupMenu *popupMenu( const Rectangle& rControlRegion ); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir /** 'Get' method for progress bar 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir @see pushButton() 338*cdf0e10cSrcweir */ 339*cdf0e10cSrcweir QProgressBar *progressBar( const Rectangle& rControlRegion ); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir // TODO other widgets 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir protected: 344*cdf0e10cSrcweir /** Style conversion function. 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir Conversion function between VCL ControlState together with 347*cdf0e10cSrcweir ImplControlValue and Qt state flags. 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir @param nState 350*cdf0e10cSrcweir State of the widget (default, focused, ...) as defined in Native 351*cdf0e10cSrcweir Widget Framework. 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir @param aValue 354*cdf0e10cSrcweir Value held by the widget (on, off, ...) 355*cdf0e10cSrcweir */ 356*cdf0e10cSrcweir QStyle::SFlags vclStateValue2SFlags( ControlState nState, const ImplControlValue& aValue ); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir public: 359*cdf0e10cSrcweir /** Convert VCL Rectangle to QRect. 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir @param rControlRegion 362*cdf0e10cSrcweir The region to convert. 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir @return 365*cdf0e10cSrcweir The bounding box of the region. 366*cdf0e10cSrcweir */ 367*cdf0e10cSrcweir static QRect region2QRect( const Rectangle& rControlRegion ); 368*cdf0e10cSrcweir }; 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir WidgetPainter::WidgetPainter( void ) 371*cdf0e10cSrcweir : m_pPushButton( NULL ), 372*cdf0e10cSrcweir m_pRadioButton( NULL ), 373*cdf0e10cSrcweir m_pCheckBox( NULL ), 374*cdf0e10cSrcweir m_pComboBox( NULL ), 375*cdf0e10cSrcweir m_pEditableComboBox( NULL ), 376*cdf0e10cSrcweir m_pLineEdit( NULL ), 377*cdf0e10cSrcweir m_pSpinWidget( NULL ), 378*cdf0e10cSrcweir m_pSpinEdit( NULL ), 379*cdf0e10cSrcweir m_pTabLeft( NULL ), 380*cdf0e10cSrcweir m_pTabMiddle( NULL ), 381*cdf0e10cSrcweir m_pTabRight( NULL ), 382*cdf0e10cSrcweir m_pTabAlone( NULL ), 383*cdf0e10cSrcweir m_pTabBarParent( NULL ), 384*cdf0e10cSrcweir m_pTabBar( NULL ), 385*cdf0e10cSrcweir m_pTabWidget( NULL ), 386*cdf0e10cSrcweir m_pListView( NULL ), 387*cdf0e10cSrcweir m_pScrollBar( NULL ), 388*cdf0e10cSrcweir m_pMainWindow( NULL ), 389*cdf0e10cSrcweir m_pToolBarHoriz( NULL ), 390*cdf0e10cSrcweir m_pToolBarVert( NULL ), 391*cdf0e10cSrcweir m_pToolButton( NULL ), 392*cdf0e10cSrcweir m_pMenuBar( NULL ), 393*cdf0e10cSrcweir m_pPopupMenu( NULL ), 394*cdf0e10cSrcweir m_pProgressBar( NULL ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir WidgetPainter::~WidgetPainter( void ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir delete m_pPushButton, m_pPushButton = NULL; 401*cdf0e10cSrcweir delete m_pRadioButton, m_pRadioButton = NULL; 402*cdf0e10cSrcweir delete m_pCheckBox, m_pCheckBox = NULL; 403*cdf0e10cSrcweir delete m_pComboBox, m_pComboBox = NULL; 404*cdf0e10cSrcweir delete m_pEditableComboBox, m_pEditableComboBox = NULL; 405*cdf0e10cSrcweir delete m_pLineEdit, m_pLineEdit = NULL; 406*cdf0e10cSrcweir delete m_pSpinWidget, m_pSpinWidget = NULL; 407*cdf0e10cSrcweir m_pSpinEdit = NULL; // Deleted in m_pSpinWidget's destructor 408*cdf0e10cSrcweir delete m_pTabAlone, m_pTabAlone = NULL; 409*cdf0e10cSrcweir delete m_pTabBarParent, m_pTabBarParent = NULL; 410*cdf0e10cSrcweir m_pTabBar = NULL; // Deleted in m_pTabBarParent's destructor 411*cdf0e10cSrcweir m_pTabLeft = NULL; 412*cdf0e10cSrcweir m_pTabMiddle = NULL; 413*cdf0e10cSrcweir m_pTabRight = NULL; 414*cdf0e10cSrcweir delete m_pTabWidget, m_pTabWidget = NULL; 415*cdf0e10cSrcweir delete m_pListView, m_pListView = NULL; 416*cdf0e10cSrcweir delete m_pScrollBar, m_pScrollBar = NULL; 417*cdf0e10cSrcweir delete m_pToolBarHoriz, m_pToolBarHoriz = NULL; 418*cdf0e10cSrcweir delete m_pToolBarVert, m_pToolBarVert = NULL; 419*cdf0e10cSrcweir delete m_pMainWindow, m_pMainWindow = NULL; 420*cdf0e10cSrcweir delete m_pToolButton, m_pToolButton = NULL; 421*cdf0e10cSrcweir delete m_pMenuBar, m_pMenuBar = NULL; 422*cdf0e10cSrcweir delete m_pPopupMenu, m_pPopupMenu = NULL; 423*cdf0e10cSrcweir delete m_pProgressBar, m_pProgressBar = NULL; 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir sal_Bool WidgetPainter::drawStyledWidget( QWidget *pWidget, 427*cdf0e10cSrcweir ControlState nState, const ImplControlValue& aValue, 428*cdf0e10cSrcweir Display *dpy, XLIB_Window drawable, int nScreen, int nDepth, GC gc, 429*cdf0e10cSrcweir ControlPart nPart ) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir if ( !pWidget ) 432*cdf0e10cSrcweir return sal_False; 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // Normalize the widget 435*cdf0e10cSrcweir QPoint qWidgetPos( pWidget->pos() ); 436*cdf0e10cSrcweir pWidget->move( 0, 0 ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir // Enable/disable the widget 439*cdf0e10cSrcweir pWidget->setEnabled( nState & CTRL_STATE_ENABLED ); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir // Create pixmap to paint to 442*cdf0e10cSrcweir QPixmap qPixmap( pWidget->width(), pWidget->height() ); 443*cdf0e10cSrcweir QPainter qPainter( &qPixmap ); 444*cdf0e10cSrcweir QRect qRect( 0, 0, pWidget->width(), pWidget->height() ); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir // Use the background of the widget 447*cdf0e10cSrcweir qPixmap.fill( pWidget, QPoint(0, 0) ); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir // Convert the flags 450*cdf0e10cSrcweir QStyle::SFlags nStyle = vclStateValue2SFlags( nState, aValue ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir // Store the widget class 453*cdf0e10cSrcweir const char *pClassName = pWidget->className(); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir // Draw the widget to the pixmap 456*cdf0e10cSrcweir if ( strcmp( "QPushButton", pClassName ) == 0 ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir // Workaround for the Platinum style. 459*cdf0e10cSrcweir // Platinum takes the state directly from the widget, not from SFlags. 460*cdf0e10cSrcweir QPushButton *pPushButton = static_cast<QPushButton *>( pWidget->qt_cast( "QPushButton" ) ); 461*cdf0e10cSrcweir if ( pPushButton ) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir pPushButton->setDown ( nStyle & QStyle::Style_Down ); 464*cdf0e10cSrcweir pPushButton->setOn ( nStyle & QStyle::Style_On ); 465*cdf0e10cSrcweir pPushButton->setEnabled( nStyle & QStyle::Style_Enabled ); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_PushButton, 469*cdf0e10cSrcweir &qPainter, pWidget, qRect, 470*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir else if ( strcmp( "QRadioButton", pClassName ) == 0 ) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir // Bitblt from the screen, because the radio buttons are usually not 475*cdf0e10cSrcweir // rectangular, and there could be a bitmap under them 476*cdf0e10cSrcweir GC aTmpGC = XCreateGC( dpy, qPixmap.handle(), 0, NULL ); 477*cdf0e10cSrcweir X11SalGraphics::CopyScreenArea( dpy, 478*cdf0e10cSrcweir drawable, nScreen, nDepth, 479*cdf0e10cSrcweir qPixmap.handle(), qPixmap.x11Screen(), qPixmap.x11Depth(), 480*cdf0e10cSrcweir aTmpGC, 481*cdf0e10cSrcweir qWidgetPos.x(), qWidgetPos.y(), qRect.width(), qRect.height(), 482*cdf0e10cSrcweir 0, 0 ); 483*cdf0e10cSrcweir XFreeGC( dpy, aTmpGC ); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_RadioButton, 486*cdf0e10cSrcweir &qPainter, pWidget, qRect, 487*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir else if ( strcmp( "QCheckBox", pClassName ) == 0 ) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_CheckBox, 492*cdf0e10cSrcweir &qPainter, pWidget, qRect, 493*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir else if ( strcmp( "QComboBox", pClassName ) == 0 ) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir kapp->style().drawComplexControl( QStyle::CC_ComboBox, 498*cdf0e10cSrcweir &qPainter, pWidget, qRect, 499*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir // Editable combo box uses the background of the associated edit box 502*cdf0e10cSrcweir QComboBox *pComboBox = static_cast<QComboBox *>( pWidget->qt_cast( "QComboBox" ) ); 503*cdf0e10cSrcweir if ( pComboBox && pComboBox->editable() && pComboBox->lineEdit() ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir QColorGroup::ColorRole eColorRole = ( pComboBox->isEnabled() )? 506*cdf0e10cSrcweir QColorGroup::Base: QColorGroup::Background; 507*cdf0e10cSrcweir qPainter.fillRect( 508*cdf0e10cSrcweir kapp->style().querySubControlMetrics( QStyle::CC_ComboBox, 509*cdf0e10cSrcweir pComboBox, QStyle::SC_ComboBoxEditField ), 510*cdf0e10cSrcweir pComboBox->lineEdit()->colorGroup().brush( eColorRole ) ); 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir else if ( strcmp( "QLineEdit", pClassName ) == 0 ) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir kapp->style().drawPrimitive( QStyle::PE_PanelLineEdit, 516*cdf0e10cSrcweir &qPainter, qRect, 517*cdf0e10cSrcweir pWidget->colorGroup(), nStyle | QStyle::Style_Sunken ); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir else if ( strcmp( "QSpinWidget", pClassName ) == 0 ) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir const SpinbuttonValue *pValue = static_cast<const SpinbuttonValue *> ( &aValue ); 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir // Is any of the buttons pressed? 524*cdf0e10cSrcweir QStyle::SCFlags eActive = QStyle::SC_None; 525*cdf0e10cSrcweir if ( pValue ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir if ( pValue->mnUpperState & CTRL_STATE_PRESSED ) 528*cdf0e10cSrcweir eActive = QStyle::SC_SpinWidgetUp; 529*cdf0e10cSrcweir else if ( pValue->mnLowerState & CTRL_STATE_PRESSED ) 530*cdf0e10cSrcweir eActive = QStyle::SC_SpinWidgetDown; 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir // Update the enable/disable state of the widget 533*cdf0e10cSrcweir if ( ( nState & CTRL_STATE_ENABLED ) || 534*cdf0e10cSrcweir ( pValue->mnUpperState & CTRL_STATE_ENABLED ) || 535*cdf0e10cSrcweir ( pValue->mnLowerState & CTRL_STATE_ENABLED ) ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir pWidget->setEnabled( true ); 538*cdf0e10cSrcweir nStyle |= QStyle::Style_Enabled; 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir else 541*cdf0e10cSrcweir pWidget->setEnabled( false ); 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir // Mouse-over effect 544*cdf0e10cSrcweir if ( (pValue->mnUpperState & CTRL_STATE_ROLLOVER) || 545*cdf0e10cSrcweir (pValue->mnLowerState & CTRL_STATE_ROLLOVER) ) 546*cdf0e10cSrcweir nStyle |= QStyle::Style_MouseOver; 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir // Spin widget uses the background of the associated edit box 550*cdf0e10cSrcweir QSpinWidget *pSpinWidget = static_cast<QSpinWidget *>( pWidget->qt_cast( "QSpinWidget" ) ); 551*cdf0e10cSrcweir if ( pSpinWidget && pSpinWidget->editWidget() ) 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir QColorGroup::ColorRole eColorRole = ( pSpinWidget->isEnabled() )? 554*cdf0e10cSrcweir QColorGroup::Base: QColorGroup::Background; 555*cdf0e10cSrcweir qPainter.fillRect( 556*cdf0e10cSrcweir kapp->style().querySubControlMetrics( QStyle::CC_SpinWidget, 557*cdf0e10cSrcweir pSpinWidget, QStyle::SC_SpinWidgetEditField ), 558*cdf0e10cSrcweir pSpinWidget->editWidget()->colorGroup().brush( eColorRole ) ); 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir // Adjust the frame (needed for Motif Plus style) 562*cdf0e10cSrcweir QRect qFrameRect = kapp->style().querySubControlMetrics( QStyle::CC_SpinWidget, 563*cdf0e10cSrcweir pWidget, QStyle::SC_SpinWidgetFrame ); 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir kapp->style().drawComplexControl( QStyle::CC_SpinWidget, 566*cdf0e10cSrcweir &qPainter, pWidget, qFrameRect, 567*cdf0e10cSrcweir pWidget->colorGroup(), nStyle, 568*cdf0e10cSrcweir QStyle::SC_All, eActive ); 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir else if ( strcmp( "QTabBar", pClassName ) == 0 ) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir const TabitemValue *pValue = static_cast<const TabitemValue *> ( &aValue ); 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir QTab *pTab = NULL; 575*cdf0e10cSrcweir if ( pValue ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir if ( ( pValue->isFirst() || pValue->isLeftAligned() ) && ( pValue->isLast() || pValue->isRightAligned() ) ) 578*cdf0e10cSrcweir pTab = m_pTabAlone; 579*cdf0e10cSrcweir else if ( pValue->isFirst() || pValue->isLeftAligned() ) 580*cdf0e10cSrcweir pTab = m_pTabLeft; 581*cdf0e10cSrcweir else if ( pValue->isLast() || pValue->isRightAligned() ) 582*cdf0e10cSrcweir pTab = m_pTabRight; 583*cdf0e10cSrcweir else 584*cdf0e10cSrcweir pTab = m_pTabMiddle; 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir if ( !pTab ) 587*cdf0e10cSrcweir return sal_False; 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir pTab->setRect( qRect ); 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_TabBarTab, 592*cdf0e10cSrcweir &qPainter, pWidget, qRect, 593*cdf0e10cSrcweir pWidget->colorGroup(), nStyle, 594*cdf0e10cSrcweir QStyleOption( pTab ) ); 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir else if ( strcmp( "QTabWidget", pClassName ) == 0 ) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir kapp->style().drawPrimitive( QStyle::PE_PanelTabWidget, 599*cdf0e10cSrcweir &qPainter, qRect, 600*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir else if ( strcmp( "QListView", pClassName ) == 0 ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir kapp->style().drawPrimitive( QStyle::PE_Panel, 605*cdf0e10cSrcweir &qPainter, qRect, 606*cdf0e10cSrcweir pWidget->colorGroup(), nStyle | QStyle::Style_Sunken ); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir else if ( strcmp( "QScrollBar", pClassName ) == 0 ) 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir const ScrollbarValue *pValue = static_cast<const ScrollbarValue *> ( &aValue ); 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir QStyle::SCFlags eActive = QStyle::SC_None; 613*cdf0e10cSrcweir if ( pValue ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir // Workaround for Style_MouseOver-aware themes. 616*cdf0e10cSrcweir // Quite ugly, but I do not know about a better solution. 617*cdf0e10cSrcweir const char *pStyleName = kapp->style().className(); 618*cdf0e10cSrcweir if ( strcmp( "QMotifPlusStyle", pStyleName ) == 0 ) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir nStyle |= QStyle::Style_MouseOver; 621*cdf0e10cSrcweir if ( pValue->mnThumbState & CTRL_STATE_ROLLOVER ) 622*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarSlider; 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir else if ( strcmp( "QSGIStyle", pStyleName ) == 0 ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir nStyle |= QStyle::Style_MouseOver; 627*cdf0e10cSrcweir if ( pValue->mnButton1State & CTRL_STATE_ROLLOVER ) 628*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarSubLine; 629*cdf0e10cSrcweir else if ( pValue->mnButton2State & CTRL_STATE_ROLLOVER ) 630*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarAddLine; 631*cdf0e10cSrcweir else if ( pValue->mnThumbState & CTRL_STATE_ROLLOVER ) 632*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarSlider; 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir if ( pValue->mnButton1State & CTRL_STATE_PRESSED ) 636*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarSubLine; 637*cdf0e10cSrcweir else if ( pValue->mnButton2State & CTRL_STATE_PRESSED ) 638*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarAddLine; 639*cdf0e10cSrcweir else if ( pValue->mnThumbState & CTRL_STATE_PRESSED ) 640*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarSlider; 641*cdf0e10cSrcweir else if ( pValue->mnPage1State & CTRL_STATE_PRESSED ) 642*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarSubPage; 643*cdf0e10cSrcweir else if ( pValue->mnPage2State & CTRL_STATE_PRESSED ) 644*cdf0e10cSrcweir eActive = QStyle::SC_ScrollBarAddPage; 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir // Update the enable/disable state of the widget 647*cdf0e10cSrcweir if ( ( nState & CTRL_STATE_ENABLED ) || 648*cdf0e10cSrcweir ( pValue->mnButton1State & CTRL_STATE_ENABLED ) || 649*cdf0e10cSrcweir ( pValue->mnButton2State & CTRL_STATE_ENABLED ) || 650*cdf0e10cSrcweir ( pValue->mnThumbState & CTRL_STATE_ENABLED ) || 651*cdf0e10cSrcweir ( pValue->mnPage1State & CTRL_STATE_ENABLED ) || 652*cdf0e10cSrcweir ( pValue->mnPage2State & CTRL_STATE_ENABLED ) ) 653*cdf0e10cSrcweir { 654*cdf0e10cSrcweir pWidget->setEnabled( true ); 655*cdf0e10cSrcweir nStyle |= QStyle::Style_Enabled; 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir else 658*cdf0e10cSrcweir pWidget->setEnabled( false ); 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir // Is it a horizontal scroll bar? 662*cdf0e10cSrcweir QScrollBar *pScrollBar = static_cast<QScrollBar *> ( pWidget->qt_cast( "QScrollBar" ) ); 663*cdf0e10cSrcweir QStyle::StyleFlags eHoriz = QStyle::Style_Default; 664*cdf0e10cSrcweir if ( pScrollBar && pScrollBar->orientation() == Qt::Horizontal ) 665*cdf0e10cSrcweir eHoriz = QStyle::Style_Horizontal; 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir kapp->style().drawComplexControl( QStyle::CC_ScrollBar, 668*cdf0e10cSrcweir &qPainter, pWidget, qRect, 669*cdf0e10cSrcweir pWidget->colorGroup(), nStyle | eHoriz, 670*cdf0e10cSrcweir QStyle::SC_All, eActive ); 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir else if ( strcmp( "QToolBar", pClassName ) == 0 ) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir QToolBar *pToolBar = static_cast< QToolBar * >( pWidget->qt_cast( "QToolBar" ) ); 675*cdf0e10cSrcweir bool bIsHorizontal = false; 676*cdf0e10cSrcweir if ( pToolBar && pToolBar->orientation() == Qt::Horizontal ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir nStyle |= QStyle::Style_Horizontal; 679*cdf0e10cSrcweir bIsHorizontal = true; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_DockWindowEmptyArea, 683*cdf0e10cSrcweir &qPainter, pWidget, qRect, 684*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir kapp->style().drawPrimitive( QStyle::PE_PanelDockWindow, 687*cdf0e10cSrcweir &qPainter, qRect, pWidget->colorGroup(), nStyle ); 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir if ( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT ) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir const ToolbarValue *pValue = static_cast< const ToolbarValue * >( &aValue ); 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir QRect qThumbRect = region2QRect( pValue->maGripRect ); 694*cdf0e10cSrcweir qThumbRect.moveBy( -qWidgetPos.x(), -qWidgetPos.y() ); 695*cdf0e10cSrcweir if ( bIsHorizontal ) 696*cdf0e10cSrcweir qThumbRect.addCoords( 0, 2, 0, -3 ); // make the thumb a bit nicer 697*cdf0e10cSrcweir else 698*cdf0e10cSrcweir qThumbRect.addCoords( 2, 0, -3, 0 ); // make the thumb a bit nicer 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir if ( kapp->style().inherits( "HighColorStyle" ) || 701*cdf0e10cSrcweir kapp->style().inherits( "HighContrastStyle" ) || 702*cdf0e10cSrcweir kapp->style().inherits( "KeramikStyle" ) || 703*cdf0e10cSrcweir kapp->style().inherits( "KThemeStyle" ) || 704*cdf0e10cSrcweir kapp->style().inherits( "ThinKeramikStyle" ) ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir // Workaround for the workaround in KStyle::drawPrimitive() 707*cdf0e10cSrcweir KStyle *pStyle = static_cast< KStyle * >( &kapp->style() ); 708*cdf0e10cSrcweir pStyle->drawKStylePrimitive( KStyle::KPE_ToolBarHandle, 709*cdf0e10cSrcweir &qPainter, pToolBar, qThumbRect, 710*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir else 713*cdf0e10cSrcweir kapp->style().drawPrimitive( QStyle::PE_DockWindowHandle, 714*cdf0e10cSrcweir &qPainter, qThumbRect, pWidget->colorGroup(), nStyle ); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir else if ( strcmp( "QToolButton", pClassName ) == 0 ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir if( (nStyle & QStyle::Style_MouseOver) ) 720*cdf0e10cSrcweir nStyle &= ~QStyle::Style_Off; 721*cdf0e10cSrcweir kapp->style().drawComplexControl( QStyle::CC_ToolButton, 722*cdf0e10cSrcweir &qPainter, pWidget, qRect, 723*cdf0e10cSrcweir pWidget->colorGroup(), nStyle, 724*cdf0e10cSrcweir QStyle::SC_ToolButton ); 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir else if ( strcmp( "QMenuBar", pClassName ) == 0 ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir if ( nPart == PART_ENTIRE_CONTROL ) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_MenuBarEmptyArea, 731*cdf0e10cSrcweir &qPainter, pWidget, qRect, 732*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir else if ( nPart == PART_MENU_ITEM ) 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nMenuBarEnabledItem: m_nMenuBarDisabledItem; 737*cdf0e10cSrcweir QMenuItem *pMenuItem = static_cast<QMenuBar*>( pWidget )->findItem( nMenuItem ); 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir if ( nStyle & QStyle::Style_Selected ) 740*cdf0e10cSrcweir nStyle |= QStyle::Style_Active | QStyle::Style_Down | QStyle::Style_HasFocus; 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_MenuBarItem, 743*cdf0e10cSrcweir &qPainter, pWidget, qRect, 744*cdf0e10cSrcweir pWidget->colorGroup(), nStyle, 745*cdf0e10cSrcweir QStyleOption( pMenuItem ) ); 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir else if ( strcmp( "QPopupMenu", pClassName ) == 0 ) 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nPopupMenuEnabledItem: m_nPopupMenuDisabledItem; 751*cdf0e10cSrcweir QMenuItem *pMenuItem = static_cast<QPopupMenu*>( pWidget )->findItem( nMenuItem ); 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir if ( nStyle & QStyle::Style_Selected ) 754*cdf0e10cSrcweir nStyle |= QStyle::Style_Active; 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_PopupMenuItem, 757*cdf0e10cSrcweir &qPainter, pWidget, qRect, 758*cdf0e10cSrcweir pWidget->colorGroup(), nStyle, 759*cdf0e10cSrcweir QStyleOption( pMenuItem, 0, 0 ) ); 760*cdf0e10cSrcweir } 761*cdf0e10cSrcweir else if ( strcmp( "QProgressBar", pClassName ) == 0 ) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir long nProgressWidth = aValue.getNumericVal(); 764*cdf0e10cSrcweir QProgressBar* pProgress = static_cast<QProgressBar*>(pWidget); 765*cdf0e10cSrcweir pProgress->setProgress( nProgressWidth, qRect.width() ); 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_ProgressBarGroove, 768*cdf0e10cSrcweir &qPainter, pWidget, qRect, 769*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 770*cdf0e10cSrcweir kapp->style().drawControl( QStyle::CE_ProgressBarContents, 771*cdf0e10cSrcweir &qPainter, pWidget, qRect, 772*cdf0e10cSrcweir pWidget->colorGroup(), nStyle ); 773*cdf0e10cSrcweir } 774*cdf0e10cSrcweir else 775*cdf0e10cSrcweir return sal_False; 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir // Bitblt it to the screen 778*cdf0e10cSrcweir X11SalGraphics::CopyScreenArea( dpy, 779*cdf0e10cSrcweir qPixmap.handle(), qPixmap.x11Screen(), qPixmap.x11Depth(), 780*cdf0e10cSrcweir drawable, nScreen, nDepth, 781*cdf0e10cSrcweir gc, 782*cdf0e10cSrcweir 0, 0, qRect.width(), qRect.height(), 783*cdf0e10cSrcweir qWidgetPos.x(), qWidgetPos.y() ); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir // Restore widget's position 786*cdf0e10cSrcweir pWidget->move( qWidgetPos ); 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir return sal_True; 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir QPushButton *WidgetPainter::pushButton( const Rectangle& rControlRegion, 792*cdf0e10cSrcweir sal_Bool bDefault ) 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir if ( !m_pPushButton ) 795*cdf0e10cSrcweir m_pPushButton = new QPushButton( NULL, "push_button" ); 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir // Workaround for broken styles which do not add 800*cdf0e10cSrcweir // QStyle::PM_ButtonDefaultIndicator to the size of the default button 801*cdf0e10cSrcweir // (for example Keramik) 802*cdf0e10cSrcweir // FIXME Fix Keramik style to be consistant with Qt built-in styles. Aargh! 803*cdf0e10cSrcweir if ( bDefault ) 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir QSize qContentsSize( 50, 50 ); 806*cdf0e10cSrcweir m_pPushButton->setDefault( false ); 807*cdf0e10cSrcweir QSize qNormalSize = kapp->style().sizeFromContents( QStyle::CT_PushButton, 808*cdf0e10cSrcweir m_pPushButton, qContentsSize ); 809*cdf0e10cSrcweir m_pPushButton->setDefault( true ); 810*cdf0e10cSrcweir QSize qDefSize = kapp->style().sizeFromContents( QStyle::CT_PushButton, 811*cdf0e10cSrcweir m_pPushButton, qContentsSize ); 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir int nIndicatorSize = kapp->style().pixelMetric( 814*cdf0e10cSrcweir QStyle::PM_ButtonDefaultIndicator, m_pPushButton ); 815*cdf0e10cSrcweir if ( qNormalSize.width() == qDefSize.width() ) 816*cdf0e10cSrcweir qRect.addCoords( nIndicatorSize, 0, -nIndicatorSize, 0 ); 817*cdf0e10cSrcweir if ( qNormalSize.height() == qDefSize.height() ) 818*cdf0e10cSrcweir qRect.addCoords( 0, nIndicatorSize, 0, -nIndicatorSize ); 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir m_pPushButton->move( qRect.topLeft() ); 822*cdf0e10cSrcweir m_pPushButton->resize( qRect.size() ); 823*cdf0e10cSrcweir m_pPushButton->setDefault( bDefault ); 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir return m_pPushButton; 826*cdf0e10cSrcweir } 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir QRadioButton *WidgetPainter::radioButton( const Rectangle& rControlRegion ) 829*cdf0e10cSrcweir { 830*cdf0e10cSrcweir if ( !m_pRadioButton ) 831*cdf0e10cSrcweir m_pRadioButton = new QRadioButton( NULL, "radio_button" ); 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 834*cdf0e10cSrcweir 835*cdf0e10cSrcweir // Workaround for broken themes which do not honor the given size. 836*cdf0e10cSrcweir // Quite ugly, but I do not know about a better solution. 837*cdf0e10cSrcweir const char *pStyleName = kapp->style().className(); 838*cdf0e10cSrcweir if ( strcmp( "KThemeStyle", pStyleName ) == 0 ) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir QRect qOldRect( qRect ); 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir qRect.setWidth( kapp->style().pixelMetric( 843*cdf0e10cSrcweir QStyle::PM_ExclusiveIndicatorWidth, m_pRadioButton ) ); 844*cdf0e10cSrcweir qRect.setHeight( kapp->style().pixelMetric( 845*cdf0e10cSrcweir QStyle::PM_ExclusiveIndicatorHeight, m_pRadioButton ) ); 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir qRect.moveBy( ( qOldRect.width() - qRect.width() ) / 2, 848*cdf0e10cSrcweir ( qOldRect.height() - qRect.height() ) / 2 ); 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir m_pRadioButton->move( qRect.topLeft() ); 852*cdf0e10cSrcweir m_pRadioButton->resize( qRect.size() ); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir return m_pRadioButton; 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir QCheckBox *WidgetPainter::checkBox( const Rectangle& rControlRegion ) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir if ( !m_pCheckBox ) 860*cdf0e10cSrcweir m_pCheckBox = new QCheckBox( NULL, "check_box" ); 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir // Workaround for broken themes which do not honor the given size. 865*cdf0e10cSrcweir // Quite ugly, but I do not know about a better solution. 866*cdf0e10cSrcweir const char *pStyleName = kapp->style().className(); 867*cdf0e10cSrcweir if ( strcmp( "KThemeStyle", pStyleName ) == 0 ) 868*cdf0e10cSrcweir { 869*cdf0e10cSrcweir QRect qOldRect( qRect ); 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir qRect.setWidth( kapp->style().pixelMetric( 872*cdf0e10cSrcweir QStyle::PM_IndicatorWidth, m_pCheckBox ) ); 873*cdf0e10cSrcweir qRect.setHeight( kapp->style().pixelMetric( 874*cdf0e10cSrcweir QStyle::PM_IndicatorHeight, m_pCheckBox ) ); 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir qRect.moveBy( ( qOldRect.width() - qRect.width() ) / 2, 877*cdf0e10cSrcweir ( qOldRect.height() - qRect.height() ) / 2 ); 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir m_pCheckBox->move( qRect.topLeft() ); 881*cdf0e10cSrcweir m_pCheckBox->resize( qRect.size() ); 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir return m_pCheckBox; 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir QComboBox *WidgetPainter::comboBox( const Rectangle& rControlRegion, 887*cdf0e10cSrcweir sal_Bool bEditable ) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir QComboBox *pComboBox = NULL; 890*cdf0e10cSrcweir if ( bEditable ) 891*cdf0e10cSrcweir { 892*cdf0e10cSrcweir if ( !m_pEditableComboBox ) 893*cdf0e10cSrcweir m_pEditableComboBox = new QComboBox( true, NULL, "combo_box_edit" ); 894*cdf0e10cSrcweir pComboBox = m_pEditableComboBox; 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir else 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir if ( !m_pComboBox ) 899*cdf0e10cSrcweir m_pComboBox = new QComboBox( false, NULL, "combo_box" ); 900*cdf0e10cSrcweir pComboBox = m_pComboBox; 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir pComboBox->move( qRect.topLeft() ); 906*cdf0e10cSrcweir pComboBox->resize( qRect.size() ); 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir return pComboBox; 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir QLineEdit *WidgetPainter::lineEdit( const Rectangle& rControlRegion ) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir if ( !m_pLineEdit ) 914*cdf0e10cSrcweir m_pLineEdit = new QLineEdit( NULL, "line_edit" ); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir m_pLineEdit->move( qRect.topLeft() ); 919*cdf0e10cSrcweir m_pLineEdit->resize( qRect.size() ); 920*cdf0e10cSrcweir 921*cdf0e10cSrcweir return m_pLineEdit; 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir QSpinWidget *WidgetPainter::spinWidget( const Rectangle& rControlRegion ) 925*cdf0e10cSrcweir { 926*cdf0e10cSrcweir if ( !m_pSpinWidget ) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir m_pSpinWidget = new QSpinWidget( NULL, "spin_widget" ); 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir m_pSpinEdit = new QLineEdit( NULL, "line_edit_spin" ); 931*cdf0e10cSrcweir m_pSpinWidget->setEditWidget( m_pSpinEdit ); 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir m_pSpinWidget->move( qRect.topLeft() ); 937*cdf0e10cSrcweir m_pSpinWidget->resize( qRect.size() ); 938*cdf0e10cSrcweir m_pSpinWidget->arrange(); 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir return m_pSpinWidget; 941*cdf0e10cSrcweir } 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir QTabBar *WidgetPainter::tabBar( const Rectangle& rControlRegion ) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir if ( !m_pTabBar ) 946*cdf0e10cSrcweir { 947*cdf0e10cSrcweir if ( !m_pTabBarParent ) 948*cdf0e10cSrcweir m_pTabBarParent = new QWidget( NULL, "tab_bar_parent" ); 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir m_pTabBar = new QTabBar( m_pTabBarParent, "tab_bar" ); 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir m_pTabLeft = new QTab(); 953*cdf0e10cSrcweir m_pTabMiddle = new QTab(); 954*cdf0e10cSrcweir m_pTabRight = new QTab(); 955*cdf0e10cSrcweir m_pTabAlone = new QTab(); 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir m_pTabBar->addTab( m_pTabLeft ); 958*cdf0e10cSrcweir m_pTabBar->addTab( m_pTabMiddle ); 959*cdf0e10cSrcweir m_pTabBar->addTab( m_pTabRight ); 960*cdf0e10cSrcweir } 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir m_pTabBar->move( qRect.topLeft() ); 965*cdf0e10cSrcweir m_pTabBar->resize( qRect.size() ); 966*cdf0e10cSrcweir 967*cdf0e10cSrcweir m_pTabBar->setShape( QTabBar::RoundedAbove ); 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir return m_pTabBar; 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir QTabWidget *WidgetPainter::tabWidget( const Rectangle& rControlRegion ) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir if ( !m_pTabWidget ) 975*cdf0e10cSrcweir m_pTabWidget = new QTabWidget( NULL, "tab_widget" ); 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 978*cdf0e10cSrcweir --qRect.rTop(); 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir m_pTabWidget->move( qRect.topLeft() ); 981*cdf0e10cSrcweir m_pTabWidget->resize( qRect.size() ); 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir return m_pTabWidget; 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir QListView *WidgetPainter::listView( const Rectangle& rControlRegion ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir if ( !m_pListView ) 989*cdf0e10cSrcweir m_pListView = new QListView( NULL, "list_view" ); 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir m_pListView->move( qRect.topLeft() ); 994*cdf0e10cSrcweir m_pListView->resize( qRect.size() ); 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir return m_pListView; 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir QScrollBar *WidgetPainter::scrollBar( const Rectangle& rControlRegion, 1000*cdf0e10cSrcweir sal_Bool bHorizontal, const ImplControlValue& aValue ) 1001*cdf0e10cSrcweir { 1002*cdf0e10cSrcweir if ( !m_pScrollBar ) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir m_pScrollBar = new QScrollBar( NULL, "scroll_bar" ); 1005*cdf0e10cSrcweir m_pScrollBar->setTracking( false ); 1006*cdf0e10cSrcweir m_pScrollBar->setLineStep( 1 ); 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir m_pScrollBar->move( qRect.topLeft() ); 1012*cdf0e10cSrcweir m_pScrollBar->resize( qRect.size() ); 1013*cdf0e10cSrcweir m_pScrollBar->setOrientation( bHorizontal? Qt::Horizontal: Qt::Vertical ); 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir const ScrollbarValue *pValue = static_cast<const ScrollbarValue *> ( &aValue ); 1016*cdf0e10cSrcweir if ( pValue ) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir m_pScrollBar->setMinValue( pValue->mnMin ); 1019*cdf0e10cSrcweir m_pScrollBar->setMaxValue( pValue->mnMax - pValue->mnVisibleSize ); 1020*cdf0e10cSrcweir m_pScrollBar->setValue( pValue->mnCur ); 1021*cdf0e10cSrcweir m_pScrollBar->setPageStep( pValue->mnVisibleSize ); 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir return m_pScrollBar; 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir QToolBar *WidgetPainter::toolBar( const Rectangle& rControlRegion, sal_Bool bHorizontal ) 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir if ( !m_pMainWindow ) 1030*cdf0e10cSrcweir m_pMainWindow = new QMainWindow( NULL, "main_window" ); 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir QToolBar *pToolBar; 1033*cdf0e10cSrcweir if ( bHorizontal ) 1034*cdf0e10cSrcweir { 1035*cdf0e10cSrcweir if ( !m_pToolBarHoriz ) 1036*cdf0e10cSrcweir { 1037*cdf0e10cSrcweir m_pToolBarHoriz = new QToolBar( m_pMainWindow, "tool_bar_horiz" ); 1038*cdf0e10cSrcweir m_pMainWindow->moveDockWindow( m_pToolBarHoriz, Qt::DockTop ); 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir pToolBar = m_pToolBarHoriz; 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir else 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir if ( !m_pToolBarVert ) 1045*cdf0e10cSrcweir { 1046*cdf0e10cSrcweir m_pToolBarVert = new QToolBar( m_pMainWindow, "tool_bar_horiz" ); 1047*cdf0e10cSrcweir m_pMainWindow->moveDockWindow( m_pToolBarVert, Qt::DockLeft ); 1048*cdf0e10cSrcweir } 1049*cdf0e10cSrcweir pToolBar = m_pToolBarVert; 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir 1052*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir pToolBar->move( qRect.topLeft() ); 1055*cdf0e10cSrcweir pToolBar->resize( qRect.size() ); 1056*cdf0e10cSrcweir 1057*cdf0e10cSrcweir return pToolBar; 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir 1060*cdf0e10cSrcweir QToolButton *WidgetPainter::toolButton( const Rectangle& rControlRegion) 1061*cdf0e10cSrcweir { 1062*cdf0e10cSrcweir if ( !m_pToolButton ) 1063*cdf0e10cSrcweir m_pToolButton = new QToolButton( NULL, "tool_button" ); 1064*cdf0e10cSrcweir 1065*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir m_pToolButton->move( qRect.topLeft() ); 1068*cdf0e10cSrcweir m_pToolButton->resize( qRect.size() ); 1069*cdf0e10cSrcweir 1070*cdf0e10cSrcweir return m_pToolButton; 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir QMenuBar *WidgetPainter::menuBar( const Rectangle& rControlRegion) 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir if ( !m_pMenuBar ) 1076*cdf0e10cSrcweir { 1077*cdf0e10cSrcweir m_pMenuBar = new QMenuBar( NULL, "menu_bar" ); 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir m_nMenuBarEnabledItem = m_pMenuBar->insertItem( "" ); 1080*cdf0e10cSrcweir m_nMenuBarDisabledItem = m_pMenuBar->insertItem( "" ); 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir m_pMenuBar->setItemEnabled( m_nMenuBarEnabledItem, true ); 1083*cdf0e10cSrcweir m_pMenuBar->setItemEnabled( m_nMenuBarDisabledItem, false ); 1084*cdf0e10cSrcweir } 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 1087*cdf0e10cSrcweir 1088*cdf0e10cSrcweir m_pMenuBar->move( qRect.topLeft() ); 1089*cdf0e10cSrcweir m_pMenuBar->resize( qRect.size() ); 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir return m_pMenuBar; 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir QPopupMenu *WidgetPainter::popupMenu( const Rectangle& rControlRegion) 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir if ( !m_pPopupMenu ) 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir m_pPopupMenu = new QPopupMenu( NULL, "popup_menu" ); 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir m_nPopupMenuEnabledItem = m_pPopupMenu->insertItem( "" ); 1101*cdf0e10cSrcweir m_nPopupMenuDisabledItem = m_pPopupMenu->insertItem( "" ); 1102*cdf0e10cSrcweir 1103*cdf0e10cSrcweir m_pPopupMenu->setItemEnabled( m_nPopupMenuEnabledItem, true ); 1104*cdf0e10cSrcweir m_pPopupMenu->setItemEnabled( m_nPopupMenuDisabledItem, false ); 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir 1107*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir m_pPopupMenu->move( qRect.topLeft() ); 1110*cdf0e10cSrcweir m_pPopupMenu->resize( qRect.size() ); 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir return m_pPopupMenu; 1113*cdf0e10cSrcweir } 1114*cdf0e10cSrcweir 1115*cdf0e10cSrcweir QProgressBar *WidgetPainter::progressBar( const Rectangle& rControlRegion ) 1116*cdf0e10cSrcweir { 1117*cdf0e10cSrcweir if ( !m_pProgressBar ) 1118*cdf0e10cSrcweir m_pProgressBar = new QProgressBar( NULL, "progress_bar" ); 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir QRect qRect = region2QRect( rControlRegion ); 1121*cdf0e10cSrcweir 1122*cdf0e10cSrcweir m_pProgressBar->move( qRect.topLeft() ); 1123*cdf0e10cSrcweir m_pProgressBar->resize( qRect.size() ); 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir return m_pProgressBar; 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir QStyle::SFlags WidgetPainter::vclStateValue2SFlags( ControlState nState, 1129*cdf0e10cSrcweir const ImplControlValue& aValue ) 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir QStyle::SFlags nStyle = 1132*cdf0e10cSrcweir ( (nState & CTRL_STATE_DEFAULT)? QStyle::Style_ButtonDefault: QStyle::Style_Default ) | 1133*cdf0e10cSrcweir ( (nState & CTRL_STATE_ENABLED)? QStyle::Style_Enabled: QStyle::Style_Default ) | 1134*cdf0e10cSrcweir ( (nState & CTRL_STATE_FOCUSED)? QStyle::Style_HasFocus: QStyle::Style_Default ) | 1135*cdf0e10cSrcweir ( (nState & CTRL_STATE_PRESSED)? QStyle::Style_Down: QStyle::Style_Raised ) | 1136*cdf0e10cSrcweir ( (nState & CTRL_STATE_SELECTED)? QStyle::Style_Selected : QStyle::Style_Default ) | 1137*cdf0e10cSrcweir ( (nState & CTRL_STATE_ROLLOVER)? QStyle::Style_MouseOver: QStyle::Style_Default ); 1138*cdf0e10cSrcweir //TODO ( (nState & CTRL_STATE_HIDDEN)? QStyle::Style_: QStyle::Style_Default ) | 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir switch ( aValue.getTristateVal() ) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir case BUTTONVALUE_ON: nStyle |= QStyle::Style_On; break; 1143*cdf0e10cSrcweir case BUTTONVALUE_OFF: nStyle |= QStyle::Style_Off; break; 1144*cdf0e10cSrcweir case BUTTONVALUE_MIXED: nStyle |= QStyle::Style_NoChange; break; 1145*cdf0e10cSrcweir default: break; 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir 1148*cdf0e10cSrcweir return nStyle; 1149*cdf0e10cSrcweir } 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir QRect WidgetPainter::region2QRect( const Rectangle& rControlRegion ) 1152*cdf0e10cSrcweir { 1153*cdf0e10cSrcweir return QRect( QPoint( rControlRegion.Left(), rControlRegion.Top() ), 1154*cdf0e10cSrcweir QPoint( rControlRegion.Right(), rControlRegion.Bottom() ) ); 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweir /** Instance of WidgetPainter. 1158*cdf0e10cSrcweir 1159*cdf0e10cSrcweir It is used to paint the widgets requested by NWF. 1160*cdf0e10cSrcweir */ 1161*cdf0e10cSrcweir static WidgetPainter *pWidgetPainter; 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir class KDESalGraphics : public X11SalGraphics 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir public: 1166*cdf0e10cSrcweir KDESalGraphics() {} 1167*cdf0e10cSrcweir virtual ~KDESalGraphics() {} 1168*cdf0e10cSrcweir virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart ); 1169*cdf0e10cSrcweir virtual sal_Bool hitTestNativeControl( ControlType nType, ControlPart nPart, 1170*cdf0e10cSrcweir const Rectangle& rControlRegion, const Point& aPos, 1171*cdf0e10cSrcweir sal_Bool& rIsInside ); 1172*cdf0e10cSrcweir virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart, 1173*cdf0e10cSrcweir const Rectangle& rControlRegion, ControlState nState, 1174*cdf0e10cSrcweir const ImplControlValue& aValue, 1175*cdf0e10cSrcweir const OUString& aCaption ); 1176*cdf0e10cSrcweir virtual sal_Bool drawNativeControlText( ControlType nType, ControlPart nPart, 1177*cdf0e10cSrcweir const Rectangle& rControlRegion, ControlState nState, 1178*cdf0e10cSrcweir const ImplControlValue& aValue, 1179*cdf0e10cSrcweir const OUString& aCaption ); 1180*cdf0e10cSrcweir virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, 1181*cdf0e10cSrcweir const Rectangle& rControlRegion, ControlState nState, 1182*cdf0e10cSrcweir const ImplControlValue& aValue, 1183*cdf0e10cSrcweir const OUString& aCaption, 1184*cdf0e10cSrcweir Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ); 1185*cdf0e10cSrcweir }; 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir /** What widgets can be drawn the native way. 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir @param nType 1190*cdf0e10cSrcweir Type of the widget. 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir @param nPart 1193*cdf0e10cSrcweir Specification of the widget's part if it consists of more than one. 1194*cdf0e10cSrcweir 1195*cdf0e10cSrcweir @return sal_True if the platform supports native drawing of the widget nType 1196*cdf0e10cSrcweir defined by nPart. 1197*cdf0e10cSrcweir */ 1198*cdf0e10cSrcweir sal_Bool KDESalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart ) 1199*cdf0e10cSrcweir { 1200*cdf0e10cSrcweir return 1201*cdf0e10cSrcweir ( (nType == CTRL_PUSHBUTTON) && (nPart == PART_ENTIRE_CONTROL) ) || 1202*cdf0e10cSrcweir ( (nType == CTRL_RADIOBUTTON) && (nPart == PART_ENTIRE_CONTROL) ) || 1203*cdf0e10cSrcweir ( (nType == CTRL_CHECKBOX) && (nPart == PART_ENTIRE_CONTROL) ) || 1204*cdf0e10cSrcweir ( (nType == CTRL_COMBOBOX) && (nPart == PART_ENTIRE_CONTROL || nPart == HAS_BACKGROUND_TEXTURE) ) || 1205*cdf0e10cSrcweir ( (nType == CTRL_EDITBOX) && (nPart == PART_ENTIRE_CONTROL || nPart == HAS_BACKGROUND_TEXTURE) ) || 1206*cdf0e10cSrcweir ( (nType == CTRL_LISTBOX) && (nPart == PART_ENTIRE_CONTROL || nPart == PART_WINDOW || nPart == HAS_BACKGROUND_TEXTURE ) ) || 1207*cdf0e10cSrcweir ( (nType == CTRL_SPINBOX) && (nPart == PART_ENTIRE_CONTROL || nPart == HAS_BACKGROUND_TEXTURE) ) || 1208*cdf0e10cSrcweir // no CTRL_SPINBUTTONS for KDE 1209*cdf0e10cSrcweir ( (nType == CTRL_TAB_ITEM) && (nPart == PART_ENTIRE_CONTROL) ) || 1210*cdf0e10cSrcweir ( (nType == CTRL_TAB_PANE) && (nPart == PART_ENTIRE_CONTROL) ) || 1211*cdf0e10cSrcweir // no CTRL_TAB_BODY for KDE 1212*cdf0e10cSrcweir ( (nType == CTRL_SCROLLBAR) && (nPart == PART_ENTIRE_CONTROL || nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT) ) || 1213*cdf0e10cSrcweir ( (nType == CTRL_SCROLLBAR) && (nPart == HAS_THREE_BUTTONS) ) || // TODO small optimization is possible here: return this only if the style really has 3 buttons 1214*cdf0e10cSrcweir // CTRL_GROUPBOX not supported 1215*cdf0e10cSrcweir // CTRL_FIXEDLINE not supported 1216*cdf0e10cSrcweir // CTRL_FIXEDBORDER not supported 1217*cdf0e10cSrcweir ( (nType == CTRL_TOOLBAR) && (nPart == PART_ENTIRE_CONTROL || 1218*cdf0e10cSrcweir nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT || 1219*cdf0e10cSrcweir nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT || 1220*cdf0e10cSrcweir nPart == PART_BUTTON) ) || 1221*cdf0e10cSrcweir ( (nType == CTRL_MENUBAR) && (nPart == PART_ENTIRE_CONTROL || nPart == PART_MENU_ITEM) ) || 1222*cdf0e10cSrcweir ( (nType == CTRL_MENU_POPUP) && (nPart == PART_ENTIRE_CONTROL || nPart == PART_MENU_ITEM) ) || 1223*cdf0e10cSrcweir ( (nType == CTRL_PROGRESS) && (nPart == PART_ENTIRE_CONTROL) ) 1224*cdf0e10cSrcweir ; 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir /** Test whether the position is in the native widget. 1229*cdf0e10cSrcweir 1230*cdf0e10cSrcweir If the return value is sal_True, bIsInside contains information whether 1231*cdf0e10cSrcweir aPos was or was not inside the native widget specified by the 1232*cdf0e10cSrcweir nType/nPart combination. 1233*cdf0e10cSrcweir */ 1234*cdf0e10cSrcweir sal_Bool KDESalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, 1235*cdf0e10cSrcweir const Rectangle& rControlRegion, const Point& rPos, 1236*cdf0e10cSrcweir sal_Bool& rIsInside ) 1237*cdf0e10cSrcweir { 1238*cdf0e10cSrcweir if ( nType == CTRL_SCROLLBAR ) 1239*cdf0e10cSrcweir { 1240*cdf0e10cSrcweir // make position relative to rControlRegion 1241*cdf0e10cSrcweir Point aPos = rPos - rControlRegion.TopLeft(); 1242*cdf0e10cSrcweir rIsInside = sal_False; 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir sal_Bool bHorizontal = ( nPart == PART_BUTTON_LEFT || nPart == PART_BUTTON_RIGHT ); 1245*cdf0e10cSrcweir 1246*cdf0e10cSrcweir QScrollBar *pScrollBar = pWidgetPainter->scrollBar( rControlRegion, 1247*cdf0e10cSrcweir bHorizontal, ImplControlValue() ); 1248*cdf0e10cSrcweir QRect qRectSubLine = kapp->style().querySubControlMetrics( 1249*cdf0e10cSrcweir QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubLine ); 1250*cdf0e10cSrcweir QRect qRectAddLine = kapp->style().querySubControlMetrics( 1251*cdf0e10cSrcweir QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarAddLine ); 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir // There are 2 buttons on the right/bottom side of the scrollbar 1254*cdf0e10cSrcweir sal_Bool bTwoSubButtons = sal_False; 1255*cdf0e10cSrcweir 1256*cdf0e10cSrcweir // It is a Platinum style scroll bar 1257*cdf0e10cSrcweir sal_Bool bPlatinumStyle = sal_False; 1258*cdf0e10cSrcweir 1259*cdf0e10cSrcweir // Workaround for Platinum and 3 button style scroll bars. 1260*cdf0e10cSrcweir // It makes the right/down button bigger. 1261*cdf0e10cSrcweir if ( bHorizontal ) 1262*cdf0e10cSrcweir { 1263*cdf0e10cSrcweir qRectAddLine.setLeft( kapp->style().querySubControlMetrics( 1264*cdf0e10cSrcweir QStyle::CC_ScrollBar, pScrollBar, 1265*cdf0e10cSrcweir QStyle::SC_ScrollBarAddPage ).right() + 1 ); 1266*cdf0e10cSrcweir if ( qRectAddLine.width() > qRectSubLine.width() ) 1267*cdf0e10cSrcweir bTwoSubButtons = sal_True; 1268*cdf0e10cSrcweir if ( qRectSubLine.left() > kapp->style().querySubControlMetrics( QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubPage ).left() ) 1269*cdf0e10cSrcweir bPlatinumStyle = sal_True; 1270*cdf0e10cSrcweir } 1271*cdf0e10cSrcweir else 1272*cdf0e10cSrcweir { 1273*cdf0e10cSrcweir qRectAddLine.setTop( kapp->style().querySubControlMetrics( 1274*cdf0e10cSrcweir QStyle::CC_ScrollBar, pScrollBar, 1275*cdf0e10cSrcweir QStyle::SC_ScrollBarAddPage ).bottom() + 1 ); 1276*cdf0e10cSrcweir if ( qRectAddLine.height() > qRectSubLine.height() ) 1277*cdf0e10cSrcweir bTwoSubButtons = sal_True; 1278*cdf0e10cSrcweir if ( qRectSubLine.top() > kapp->style().querySubControlMetrics( QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubPage ).top() ) 1279*cdf0e10cSrcweir bPlatinumStyle = sal_True; 1280*cdf0e10cSrcweir } 1281*cdf0e10cSrcweir 1282*cdf0e10cSrcweir switch ( nPart ) 1283*cdf0e10cSrcweir { 1284*cdf0e10cSrcweir case PART_BUTTON_LEFT: 1285*cdf0e10cSrcweir if ( !bPlatinumStyle && qRectSubLine.contains( aPos.getX(), aPos.getY() ) ) 1286*cdf0e10cSrcweir rIsInside = sal_True; 1287*cdf0e10cSrcweir else if ( bTwoSubButtons ) 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir qRectAddLine.setWidth( qRectAddLine.width() / 2 ); 1290*cdf0e10cSrcweir rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); 1291*cdf0e10cSrcweir } 1292*cdf0e10cSrcweir break; 1293*cdf0e10cSrcweir 1294*cdf0e10cSrcweir case PART_BUTTON_UP: 1295*cdf0e10cSrcweir if ( !bPlatinumStyle && qRectSubLine.contains( aPos.getX(), aPos.getY() ) ) 1296*cdf0e10cSrcweir rIsInside = sal_True; 1297*cdf0e10cSrcweir else if ( bTwoSubButtons ) 1298*cdf0e10cSrcweir { 1299*cdf0e10cSrcweir qRectAddLine.setHeight( qRectAddLine.height() / 2 ); 1300*cdf0e10cSrcweir rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir break; 1303*cdf0e10cSrcweir 1304*cdf0e10cSrcweir case PART_BUTTON_RIGHT: 1305*cdf0e10cSrcweir if ( bTwoSubButtons ) 1306*cdf0e10cSrcweir qRectAddLine.setLeft( qRectAddLine.left() + qRectAddLine.width() / 2 ); 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); 1309*cdf0e10cSrcweir break; 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir case PART_BUTTON_DOWN: 1312*cdf0e10cSrcweir if ( bTwoSubButtons ) 1313*cdf0e10cSrcweir qRectAddLine.setTop( qRectAddLine.top() + qRectAddLine.height() / 2 ); 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); 1316*cdf0e10cSrcweir break; 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir // cases PART_TRACK_HORZ_AREA and PART_TRACK_VERT_AREA 1319*cdf0e10cSrcweir default: 1320*cdf0e10cSrcweir return sal_False; 1321*cdf0e10cSrcweir } 1322*cdf0e10cSrcweir 1323*cdf0e10cSrcweir return sal_True; 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir return sal_False; 1327*cdf0e10cSrcweir } 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir 1330*cdf0e10cSrcweir /** Draw the requested control described by nPart/nState. 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir @param rControlRegion 1333*cdf0e10cSrcweir The bounding region of the complete control in VCL frame coordinates. 1334*cdf0e10cSrcweir 1335*cdf0e10cSrcweir @param aValue 1336*cdf0e10cSrcweir An optional value (tristate/numerical/string). 1337*cdf0e10cSrcweir 1338*cdf0e10cSrcweir @param aCaption 1339*cdf0e10cSrcweir A caption or title string (like button text etc.) 1340*cdf0e10cSrcweir */ 1341*cdf0e10cSrcweir sal_Bool KDESalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, 1342*cdf0e10cSrcweir const Rectangle& rControlRegion, ControlState nState, 1343*cdf0e10cSrcweir const ImplControlValue& aValue, 1344*cdf0e10cSrcweir const OUString& ) 1345*cdf0e10cSrcweir { 1346*cdf0e10cSrcweir sal_Bool bReturn = sal_False; 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir Display *dpy = GetXDisplay(); 1349*cdf0e10cSrcweir XLIB_Window drawable = GetDrawable(); 1350*cdf0e10cSrcweir GC gc = SelectPen(); //SelectFont(); // GC with current clipping region set 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweir if ( (nType == CTRL_PUSHBUTTON) && (nPart == PART_ENTIRE_CONTROL) ) 1353*cdf0e10cSrcweir { 1354*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1355*cdf0e10cSrcweir pWidgetPainter->pushButton( rControlRegion, (nState & CTRL_STATE_DEFAULT) ), 1356*cdf0e10cSrcweir nState, aValue, 1357*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir else if ( (nType == CTRL_RADIOBUTTON) && (nPart == PART_ENTIRE_CONTROL) ) 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1362*cdf0e10cSrcweir pWidgetPainter->radioButton( rControlRegion ), 1363*cdf0e10cSrcweir nState, aValue, 1364*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1365*cdf0e10cSrcweir } 1366*cdf0e10cSrcweir else if ( (nType == CTRL_CHECKBOX) && (nPart == PART_ENTIRE_CONTROL) ) 1367*cdf0e10cSrcweir { 1368*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1369*cdf0e10cSrcweir pWidgetPainter->checkBox( rControlRegion ), 1370*cdf0e10cSrcweir nState, aValue, 1371*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1372*cdf0e10cSrcweir } 1373*cdf0e10cSrcweir else if ( (nType == CTRL_COMBOBOX) && (nPart == PART_ENTIRE_CONTROL) ) 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1376*cdf0e10cSrcweir pWidgetPainter->comboBox( rControlRegion, sal_True ), 1377*cdf0e10cSrcweir nState, aValue, 1378*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1379*cdf0e10cSrcweir } 1380*cdf0e10cSrcweir else if ( (nType == CTRL_EDITBOX) && (nPart == PART_ENTIRE_CONTROL) ) 1381*cdf0e10cSrcweir { 1382*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1383*cdf0e10cSrcweir pWidgetPainter->lineEdit( rControlRegion ), 1384*cdf0e10cSrcweir nState, aValue, 1385*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1386*cdf0e10cSrcweir } 1387*cdf0e10cSrcweir else if ( (nType == CTRL_LISTBOX) && (nPart == PART_ENTIRE_CONTROL) ) 1388*cdf0e10cSrcweir { 1389*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1390*cdf0e10cSrcweir pWidgetPainter->comboBox( rControlRegion, sal_False ), 1391*cdf0e10cSrcweir nState, aValue, 1392*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1393*cdf0e10cSrcweir } 1394*cdf0e10cSrcweir else if ( (nType == CTRL_LISTBOX) && (nPart == PART_WINDOW) ) 1395*cdf0e10cSrcweir { 1396*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1397*cdf0e10cSrcweir pWidgetPainter->listView( rControlRegion ), 1398*cdf0e10cSrcweir nState, aValue, 1399*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir else if ( (nType == CTRL_SPINBOX) && (nPart == PART_ENTIRE_CONTROL) ) 1402*cdf0e10cSrcweir { 1403*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1404*cdf0e10cSrcweir pWidgetPainter->spinWidget( rControlRegion ), 1405*cdf0e10cSrcweir nState, aValue, 1406*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1407*cdf0e10cSrcweir } 1408*cdf0e10cSrcweir else if ( (nType==CTRL_TAB_ITEM) && (nPart == PART_ENTIRE_CONTROL) ) 1409*cdf0e10cSrcweir { 1410*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1411*cdf0e10cSrcweir pWidgetPainter->tabBar( rControlRegion ), 1412*cdf0e10cSrcweir nState, aValue, 1413*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir else if ( (nType==CTRL_TAB_PANE) && (nPart == PART_ENTIRE_CONTROL) ) 1416*cdf0e10cSrcweir { 1417*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1418*cdf0e10cSrcweir pWidgetPainter->tabWidget( rControlRegion ), 1419*cdf0e10cSrcweir nState, aValue, 1420*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1421*cdf0e10cSrcweir } 1422*cdf0e10cSrcweir else if ( (nType == CTRL_SCROLLBAR) && (nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT) ) 1423*cdf0e10cSrcweir { 1424*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1425*cdf0e10cSrcweir pWidgetPainter->scrollBar( rControlRegion, nPart == PART_DRAW_BACKGROUND_HORZ, aValue ), 1426*cdf0e10cSrcweir nState, aValue, 1427*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1428*cdf0e10cSrcweir } 1429*cdf0e10cSrcweir else if ( (nType == CTRL_TOOLBAR) && (nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT || nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT) ) 1430*cdf0e10cSrcweir { 1431*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1432*cdf0e10cSrcweir pWidgetPainter->toolBar( rControlRegion, nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_THUMB_VERT ), 1433*cdf0e10cSrcweir nState, aValue, 1434*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc, nPart ); 1435*cdf0e10cSrcweir } 1436*cdf0e10cSrcweir else if ( (nType == CTRL_TOOLBAR) && (nPart == PART_BUTTON) ) 1437*cdf0e10cSrcweir { 1438*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1439*cdf0e10cSrcweir pWidgetPainter->toolButton( rControlRegion ), 1440*cdf0e10cSrcweir nState, aValue, 1441*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc, nPart ); 1442*cdf0e10cSrcweir } 1443*cdf0e10cSrcweir else if ( (nType == CTRL_MENUBAR) && (nPart == PART_ENTIRE_CONTROL || nPart == PART_MENU_ITEM) ) 1444*cdf0e10cSrcweir { 1445*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1446*cdf0e10cSrcweir pWidgetPainter->menuBar( rControlRegion ), 1447*cdf0e10cSrcweir nState, aValue, 1448*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc, nPart ); 1449*cdf0e10cSrcweir } 1450*cdf0e10cSrcweir else if ( (nType == CTRL_MENU_POPUP) && (nPart == PART_ENTIRE_CONTROL || nPart == PART_MENU_ITEM) ) 1451*cdf0e10cSrcweir { 1452*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1453*cdf0e10cSrcweir pWidgetPainter->popupMenu( rControlRegion ), 1454*cdf0e10cSrcweir nState, aValue, 1455*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir else if ( (nType == CTRL_PROGRESS) && (nPart == PART_ENTIRE_CONTROL) ) 1458*cdf0e10cSrcweir { 1459*cdf0e10cSrcweir bReturn = pWidgetPainter->drawStyledWidget( 1460*cdf0e10cSrcweir pWidgetPainter->progressBar( rControlRegion ), 1461*cdf0e10cSrcweir nState, aValue, 1462*cdf0e10cSrcweir dpy, drawable, GetScreenNumber(), GetVisual().GetDepth(), gc ); 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir 1465*cdf0e10cSrcweir return bReturn; 1466*cdf0e10cSrcweir } 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir /** Draw text on the widget. 1470*cdf0e10cSrcweir 1471*cdf0e10cSrcweir OPTIONAL. Draws the requested text for the control described by nPart/nState. 1472*cdf0e10cSrcweir Used if text is not drawn by DrawNativeControl(). 1473*cdf0e10cSrcweir 1474*cdf0e10cSrcweir @param rControlRegion 1475*cdf0e10cSrcweir The bounding region of the complete control in VCL frame coordinates. 1476*cdf0e10cSrcweir 1477*cdf0e10cSrcweir @param aValue 1478*cdf0e10cSrcweir An optional value (tristate/numerical/string) 1479*cdf0e10cSrcweir 1480*cdf0e10cSrcweir @param aCaption 1481*cdf0e10cSrcweir A caption or title string (like button text etc.) 1482*cdf0e10cSrcweir */ 1483*cdf0e10cSrcweir sal_Bool KDESalGraphics::drawNativeControlText( ControlType, ControlPart, 1484*cdf0e10cSrcweir const Rectangle&, ControlState, 1485*cdf0e10cSrcweir const ImplControlValue&, 1486*cdf0e10cSrcweir const OUString& ) 1487*cdf0e10cSrcweir { 1488*cdf0e10cSrcweir return sal_False; 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir 1491*cdf0e10cSrcweir /** Check if the bounding regions match. 1492*cdf0e10cSrcweir 1493*cdf0e10cSrcweir If the return value is sal_True, rNativeBoundingRegion 1494*cdf0e10cSrcweir contains the true bounding region covered by the control 1495*cdf0e10cSrcweir including any adornment, while rNativeContentRegion contains the area 1496*cdf0e10cSrcweir within the control that can be safely drawn into without drawing over 1497*cdf0e10cSrcweir the borders of the control. 1498*cdf0e10cSrcweir 1499*cdf0e10cSrcweir @param rControlRegion 1500*cdf0e10cSrcweir The bounding region of the control in VCL frame coordinates. 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir @param aValue 1503*cdf0e10cSrcweir An optional value (tristate/numerical/string) 1504*cdf0e10cSrcweir 1505*cdf0e10cSrcweir @param aCaption 1506*cdf0e10cSrcweir A caption or title string (like button text etc.) 1507*cdf0e10cSrcweir */ 1508*cdf0e10cSrcweir sal_Bool KDESalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, 1509*cdf0e10cSrcweir const Rectangle& rControlRegion, ControlState nState, 1510*cdf0e10cSrcweir const ImplControlValue&, 1511*cdf0e10cSrcweir const OUString&, 1512*cdf0e10cSrcweir Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ) 1513*cdf0e10cSrcweir { 1514*cdf0e10cSrcweir sal_Bool bReturn = sal_False; 1515*cdf0e10cSrcweir QRect qBoundingRect = WidgetPainter::region2QRect( rControlRegion ); 1516*cdf0e10cSrcweir QRect qRect; 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir QWidget *pWidget = NULL; 1519*cdf0e10cSrcweir switch ( nType ) 1520*cdf0e10cSrcweir { 1521*cdf0e10cSrcweir // Metrics of the push button 1522*cdf0e10cSrcweir case CTRL_PUSHBUTTON: 1523*cdf0e10cSrcweir pWidget = pWidgetPainter->pushButton( rControlRegion, ( nState & CTRL_STATE_DEFAULT ) ); 1524*cdf0e10cSrcweir 1525*cdf0e10cSrcweir switch ( nPart ) 1526*cdf0e10cSrcweir { 1527*cdf0e10cSrcweir case PART_ENTIRE_CONTROL: 1528*cdf0e10cSrcweir qRect = qBoundingRect; 1529*cdf0e10cSrcweir 1530*cdf0e10cSrcweir if ( nState & CTRL_STATE_DEFAULT ) 1531*cdf0e10cSrcweir { 1532*cdf0e10cSrcweir int nIndicatorSize = kapp->style().pixelMetric( 1533*cdf0e10cSrcweir QStyle::PM_ButtonDefaultIndicator, pWidget ); 1534*cdf0e10cSrcweir qBoundingRect.addCoords( -nIndicatorSize, -nIndicatorSize, 1535*cdf0e10cSrcweir nIndicatorSize, nIndicatorSize ); 1536*cdf0e10cSrcweir bReturn = sal_True; 1537*cdf0e10cSrcweir } 1538*cdf0e10cSrcweir break; 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir break; 1541*cdf0e10cSrcweir 1542*cdf0e10cSrcweir // Metrics of the radio button 1543*cdf0e10cSrcweir case CTRL_RADIOBUTTON: 1544*cdf0e10cSrcweir pWidget = pWidgetPainter->radioButton( rControlRegion ); 1545*cdf0e10cSrcweir 1546*cdf0e10cSrcweir if ( nPart == PART_ENTIRE_CONTROL ) 1547*cdf0e10cSrcweir { 1548*cdf0e10cSrcweir qRect.setWidth( kapp->style().pixelMetric( QStyle::PM_ExclusiveIndicatorWidth, pWidget ) ); 1549*cdf0e10cSrcweir qRect.setHeight( kapp->style().pixelMetric( QStyle::PM_ExclusiveIndicatorHeight, pWidget ) ); 1550*cdf0e10cSrcweir 1551*cdf0e10cSrcweir bReturn = sal_True; 1552*cdf0e10cSrcweir } 1553*cdf0e10cSrcweir break; 1554*cdf0e10cSrcweir 1555*cdf0e10cSrcweir // Metrics of the check box 1556*cdf0e10cSrcweir case CTRL_CHECKBOX: 1557*cdf0e10cSrcweir pWidget = pWidgetPainter->checkBox( rControlRegion ); 1558*cdf0e10cSrcweir 1559*cdf0e10cSrcweir if ( nPart == PART_ENTIRE_CONTROL ) 1560*cdf0e10cSrcweir { 1561*cdf0e10cSrcweir qRect.setWidth( kapp->style().pixelMetric( QStyle::PM_IndicatorWidth, pWidget ) ); 1562*cdf0e10cSrcweir qRect.setHeight( kapp->style().pixelMetric( QStyle::PM_IndicatorHeight, pWidget ) ); 1563*cdf0e10cSrcweir 1564*cdf0e10cSrcweir bReturn = sal_True; 1565*cdf0e10cSrcweir } 1566*cdf0e10cSrcweir break; 1567*cdf0e10cSrcweir 1568*cdf0e10cSrcweir // Metrics of the combo box 1569*cdf0e10cSrcweir case CTRL_COMBOBOX: 1570*cdf0e10cSrcweir case CTRL_LISTBOX: 1571*cdf0e10cSrcweir pWidget = pWidgetPainter->comboBox( rControlRegion, ( nType == CTRL_COMBOBOX ) ); 1572*cdf0e10cSrcweir switch ( nPart ) 1573*cdf0e10cSrcweir { 1574*cdf0e10cSrcweir case PART_BUTTON_DOWN: 1575*cdf0e10cSrcweir qRect = kapp->style().querySubControlMetrics( 1576*cdf0e10cSrcweir QStyle::CC_ComboBox, pWidget, QStyle::SC_ComboBoxArrow ); 1577*cdf0e10cSrcweir qRect.setLeft( kapp->style().querySubControlMetrics( 1578*cdf0e10cSrcweir QStyle::CC_ComboBox, pWidget, 1579*cdf0e10cSrcweir QStyle::SC_ComboBoxEditField ).right() + 1 ); 1580*cdf0e10cSrcweir qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); 1581*cdf0e10cSrcweir bReturn = sal_True; 1582*cdf0e10cSrcweir break; 1583*cdf0e10cSrcweir 1584*cdf0e10cSrcweir case PART_SUB_EDIT: 1585*cdf0e10cSrcweir qRect = kapp->style().querySubControlMetrics( 1586*cdf0e10cSrcweir QStyle::CC_ComboBox, pWidget, QStyle::SC_ComboBoxEditField ); 1587*cdf0e10cSrcweir qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); 1588*cdf0e10cSrcweir bReturn = sal_True; 1589*cdf0e10cSrcweir break; 1590*cdf0e10cSrcweir } 1591*cdf0e10cSrcweir break; 1592*cdf0e10cSrcweir 1593*cdf0e10cSrcweir // Metrics of the spin box 1594*cdf0e10cSrcweir case CTRL_SPINBOX: 1595*cdf0e10cSrcweir pWidget = pWidgetPainter->spinWidget( rControlRegion ); 1596*cdf0e10cSrcweir switch ( nPart ) 1597*cdf0e10cSrcweir { 1598*cdf0e10cSrcweir case PART_BUTTON_UP: 1599*cdf0e10cSrcweir qRect = kapp->style().querySubControlMetrics( 1600*cdf0e10cSrcweir QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetUp ); 1601*cdf0e10cSrcweir bReturn = sal_True; 1602*cdf0e10cSrcweir qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); 1603*cdf0e10cSrcweir break; 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweir case PART_BUTTON_DOWN: 1606*cdf0e10cSrcweir qRect = kapp->style().querySubControlMetrics( 1607*cdf0e10cSrcweir QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetDown ); 1608*cdf0e10cSrcweir bReturn = sal_True; 1609*cdf0e10cSrcweir qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); 1610*cdf0e10cSrcweir break; 1611*cdf0e10cSrcweir 1612*cdf0e10cSrcweir case PART_SUB_EDIT: 1613*cdf0e10cSrcweir qRect = kapp->style().querySubControlMetrics( 1614*cdf0e10cSrcweir QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetEditField ); 1615*cdf0e10cSrcweir qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); 1616*cdf0e10cSrcweir bReturn = sal_True; 1617*cdf0e10cSrcweir break; 1618*cdf0e10cSrcweir } 1619*cdf0e10cSrcweir break; 1620*cdf0e10cSrcweir 1621*cdf0e10cSrcweir // Metrics of the scroll bar 1622*cdf0e10cSrcweir case CTRL_SCROLLBAR: 1623*cdf0e10cSrcweir pWidget = pWidgetPainter->scrollBar( rControlRegion, 1624*cdf0e10cSrcweir ( nPart == PART_BUTTON_LEFT || nPart == PART_BUTTON_RIGHT ), 1625*cdf0e10cSrcweir ImplControlValue() ); 1626*cdf0e10cSrcweir switch ( nPart ) 1627*cdf0e10cSrcweir { 1628*cdf0e10cSrcweir case PART_BUTTON_LEFT: 1629*cdf0e10cSrcweir case PART_BUTTON_UP: 1630*cdf0e10cSrcweir qRect = kapp->style().querySubControlMetrics( 1631*cdf0e10cSrcweir QStyle::CC_ScrollBar, pWidget, QStyle::SC_ScrollBarSubLine ); 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir // Workaround for Platinum style scroll bars. It makes the 1634*cdf0e10cSrcweir // left/up button invisible. 1635*cdf0e10cSrcweir if ( nPart == PART_BUTTON_LEFT ) 1636*cdf0e10cSrcweir { 1637*cdf0e10cSrcweir if ( qRect.left() > kapp->style().querySubControlMetrics( 1638*cdf0e10cSrcweir QStyle::CC_ScrollBar, pWidget, 1639*cdf0e10cSrcweir QStyle::SC_ScrollBarSubPage ).left() ) 1640*cdf0e10cSrcweir { 1641*cdf0e10cSrcweir qRect.setLeft( 0 ); 1642*cdf0e10cSrcweir qRect.setRight( 0 ); 1643*cdf0e10cSrcweir } 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir else 1646*cdf0e10cSrcweir { 1647*cdf0e10cSrcweir if ( qRect.top() > kapp->style().querySubControlMetrics( 1648*cdf0e10cSrcweir QStyle::CC_ScrollBar, pWidget, 1649*cdf0e10cSrcweir QStyle::SC_ScrollBarSubPage ).top() ) 1650*cdf0e10cSrcweir { 1651*cdf0e10cSrcweir qRect.setTop( 0 ); 1652*cdf0e10cSrcweir qRect.setBottom( 0 ); 1653*cdf0e10cSrcweir } 1654*cdf0e10cSrcweir } 1655*cdf0e10cSrcweir 1656*cdf0e10cSrcweir qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); 1657*cdf0e10cSrcweir 1658*cdf0e10cSrcweir bReturn = sal_True; 1659*cdf0e10cSrcweir break; 1660*cdf0e10cSrcweir 1661*cdf0e10cSrcweir case PART_BUTTON_RIGHT: 1662*cdf0e10cSrcweir case PART_BUTTON_DOWN: 1663*cdf0e10cSrcweir qRect = kapp->style().querySubControlMetrics( 1664*cdf0e10cSrcweir QStyle::CC_ScrollBar, pWidget, QStyle::SC_ScrollBarAddLine ); 1665*cdf0e10cSrcweir 1666*cdf0e10cSrcweir // Workaround for Platinum and 3 button style scroll bars. 1667*cdf0e10cSrcweir // It makes the right/down button bigger. 1668*cdf0e10cSrcweir if ( nPart == PART_BUTTON_RIGHT ) 1669*cdf0e10cSrcweir qRect.setLeft( kapp->style().querySubControlMetrics( 1670*cdf0e10cSrcweir QStyle::CC_ScrollBar, pWidget, 1671*cdf0e10cSrcweir QStyle::SC_ScrollBarAddPage ).right() + 1 ); 1672*cdf0e10cSrcweir else 1673*cdf0e10cSrcweir qRect.setTop( kapp->style().querySubControlMetrics( 1674*cdf0e10cSrcweir QStyle::CC_ScrollBar, pWidget, 1675*cdf0e10cSrcweir QStyle::SC_ScrollBarAddPage ).bottom() + 1 ); 1676*cdf0e10cSrcweir 1677*cdf0e10cSrcweir qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); 1678*cdf0e10cSrcweir 1679*cdf0e10cSrcweir bReturn = sal_True; 1680*cdf0e10cSrcweir break; 1681*cdf0e10cSrcweir } 1682*cdf0e10cSrcweir break; 1683*cdf0e10cSrcweir } 1684*cdf0e10cSrcweir 1685*cdf0e10cSrcweir // Fill rNativeBoundingRegion and rNativeContentRegion 1686*cdf0e10cSrcweir if ( bReturn ) 1687*cdf0e10cSrcweir { 1688*cdf0e10cSrcweir // Bounding region 1689*cdf0e10cSrcweir Point aBPoint( qBoundingRect.x(), qBoundingRect.y() ); 1690*cdf0e10cSrcweir Size aBSize( qBoundingRect.width(), qBoundingRect.height() ); 1691*cdf0e10cSrcweir rNativeBoundingRegion = Rectangle( aBPoint, aBSize ); 1692*cdf0e10cSrcweir 1693*cdf0e10cSrcweir // Region of the content 1694*cdf0e10cSrcweir Point aPoint( qRect.x(), qRect.y() ); 1695*cdf0e10cSrcweir Size aSize( qRect.width(), qRect.height() ); 1696*cdf0e10cSrcweir rNativeContentRegion = Rectangle( aPoint, aSize ); 1697*cdf0e10cSrcweir } 1698*cdf0e10cSrcweir 1699*cdf0e10cSrcweir return bReturn; 1700*cdf0e10cSrcweir } 1701*cdf0e10cSrcweir 1702*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1703*cdf0e10cSrcweir // KDESalFrame implementation 1704*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1705*cdf0e10cSrcweir 1706*cdf0e10cSrcweir KDESalFrame::KDESalFrame( SalFrame* pParent, sal_uLong nStyle ) : 1707*cdf0e10cSrcweir X11SalFrame( pParent, nStyle ) 1708*cdf0e10cSrcweir { 1709*cdf0e10cSrcweir } 1710*cdf0e10cSrcweir 1711*cdf0e10cSrcweir void KDESalFrame::Show( sal_Bool bVisible, sal_Bool bNoActivate ) 1712*cdf0e10cSrcweir { 1713*cdf0e10cSrcweir if ( !GetParent() && ! (GetStyle() & SAL_FRAME_STYLE_INTRO) ) 1714*cdf0e10cSrcweir { 1715*cdf0e10cSrcweir KDEXLib* pXLib = static_cast<KDEXLib*>(GetDisplay()->GetXLib()); 1716*cdf0e10cSrcweir pXLib->doStartup(); 1717*cdf0e10cSrcweir } 1718*cdf0e10cSrcweir X11SalFrame::Show( bVisible, bNoActivate ); 1719*cdf0e10cSrcweir } 1720*cdf0e10cSrcweir 1721*cdf0e10cSrcweir /** Helper function to convert colors. 1722*cdf0e10cSrcweir */ 1723*cdf0e10cSrcweir static Color toColor( const QColor &rColor ) 1724*cdf0e10cSrcweir { 1725*cdf0e10cSrcweir return Color( rColor.red(), rColor.green(), rColor.blue() ); 1726*cdf0e10cSrcweir } 1727*cdf0e10cSrcweir 1728*cdf0e10cSrcweir /** Helper function to read untranslated text entry from KConfig configuration repository. 1729*cdf0e10cSrcweir */ 1730*cdf0e10cSrcweir static OUString readEntryUntranslated( KConfig *pConfig, const char *pKey ) 1731*cdf0e10cSrcweir { 1732*cdf0e10cSrcweir return OUString::createFromAscii( pConfig->readEntryUntranslated( pKey ).ascii() ); 1733*cdf0e10cSrcweir } 1734*cdf0e10cSrcweir 1735*cdf0e10cSrcweir /** Helper function to read color from KConfig configuration repository. 1736*cdf0e10cSrcweir */ 1737*cdf0e10cSrcweir static Color readColor( KConfig *pConfig, const char *pKey ) 1738*cdf0e10cSrcweir { 1739*cdf0e10cSrcweir return toColor( pConfig->readColorEntry( pKey ) ); 1740*cdf0e10cSrcweir } 1741*cdf0e10cSrcweir 1742*cdf0e10cSrcweir /** Helper function to add information to Font from QFont. 1743*cdf0e10cSrcweir 1744*cdf0e10cSrcweir Mostly grabbed from the Gtk+ vclplug (salnativewidgets-gtk.cxx). 1745*cdf0e10cSrcweir */ 1746*cdf0e10cSrcweir static Font toFont( const QFont &rQFont, const ::com::sun::star::lang::Locale& rLocale ) 1747*cdf0e10cSrcweir { 1748*cdf0e10cSrcweir psp::FastPrintFontInfo aInfo; 1749*cdf0e10cSrcweir QFontInfo qFontInfo( rQFont ); 1750*cdf0e10cSrcweir 1751*cdf0e10cSrcweir // set family name 1752*cdf0e10cSrcweir aInfo.m_aFamilyName = String( rQFont.family().utf8(), RTL_TEXTENCODING_UTF8 ); 1753*cdf0e10cSrcweir 1754*cdf0e10cSrcweir // set italic 1755*cdf0e10cSrcweir aInfo.m_eItalic = ( qFontInfo.italic()? psp::italic::Italic: psp::italic::Upright ); 1756*cdf0e10cSrcweir 1757*cdf0e10cSrcweir // set weight 1758*cdf0e10cSrcweir int nWeight = qFontInfo.weight(); 1759*cdf0e10cSrcweir if ( nWeight <= QFont::Light ) 1760*cdf0e10cSrcweir aInfo.m_eWeight = psp::weight::Light; 1761*cdf0e10cSrcweir else if ( nWeight <= QFont::Normal ) 1762*cdf0e10cSrcweir aInfo.m_eWeight = psp::weight::Normal; 1763*cdf0e10cSrcweir else if ( nWeight <= QFont::DemiBold ) 1764*cdf0e10cSrcweir aInfo.m_eWeight = psp::weight::SemiBold; 1765*cdf0e10cSrcweir else if ( nWeight <= QFont::Bold ) 1766*cdf0e10cSrcweir aInfo.m_eWeight = psp::weight::Bold; 1767*cdf0e10cSrcweir else 1768*cdf0e10cSrcweir aInfo.m_eWeight = psp::weight::UltraBold; 1769*cdf0e10cSrcweir 1770*cdf0e10cSrcweir // set width 1771*cdf0e10cSrcweir int nStretch = rQFont.stretch(); 1772*cdf0e10cSrcweir if ( nStretch <= QFont::UltraCondensed ) 1773*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::UltraCondensed; 1774*cdf0e10cSrcweir else if ( nStretch <= QFont::ExtraCondensed ) 1775*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::ExtraCondensed; 1776*cdf0e10cSrcweir else if ( nStretch <= QFont::Condensed ) 1777*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::Condensed; 1778*cdf0e10cSrcweir else if ( nStretch <= QFont::SemiCondensed ) 1779*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::SemiCondensed; 1780*cdf0e10cSrcweir else if ( nStretch <= QFont::Unstretched ) 1781*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::Normal; 1782*cdf0e10cSrcweir else if ( nStretch <= QFont::SemiExpanded ) 1783*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::SemiExpanded; 1784*cdf0e10cSrcweir else if ( nStretch <= QFont::Expanded ) 1785*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::Expanded; 1786*cdf0e10cSrcweir else if ( nStretch <= QFont::ExtraExpanded ) 1787*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::ExtraExpanded; 1788*cdf0e10cSrcweir else 1789*cdf0e10cSrcweir aInfo.m_eWidth = psp::width::UltraExpanded; 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1792*cdf0e10cSrcweir fprintf( stderr, "font name BEFORE system match: \"%s\"\n", OUStringToOString( aInfo.m_aFamilyName, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); 1793*cdf0e10cSrcweir #endif 1794*cdf0e10cSrcweir 1795*cdf0e10cSrcweir // match font to e.g. resolve "Sans" 1796*cdf0e10cSrcweir psp::PrintFontManager::get().matchFont( aInfo, rLocale ); 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1799*cdf0e10cSrcweir fprintf( stderr, "font match %s, name AFTER: \"%s\"\n", 1800*cdf0e10cSrcweir aInfo.m_nID != 0 ? "succeeded" : "failed", 1801*cdf0e10cSrcweir OUStringToOString( aInfo.m_aFamilyName, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); 1802*cdf0e10cSrcweir #endif 1803*cdf0e10cSrcweir 1804*cdf0e10cSrcweir // font height 1805*cdf0e10cSrcweir int nPointHeight = qFontInfo.pointSize(); 1806*cdf0e10cSrcweir if ( nPointHeight <= 0 ) 1807*cdf0e10cSrcweir nPointHeight = rQFont.pointSize(); 1808*cdf0e10cSrcweir 1809*cdf0e10cSrcweir // Create the font 1810*cdf0e10cSrcweir Font aFont( aInfo.m_aFamilyName, Size( 0, nPointHeight ) ); 1811*cdf0e10cSrcweir if( aInfo.m_eWeight != psp::weight::Unknown ) 1812*cdf0e10cSrcweir aFont.SetWeight( PspGraphics::ToFontWeight( aInfo.m_eWeight ) ); 1813*cdf0e10cSrcweir if( aInfo.m_eWidth != psp::width::Unknown ) 1814*cdf0e10cSrcweir aFont.SetWidthType( PspGraphics::ToFontWidth( aInfo.m_eWidth ) ); 1815*cdf0e10cSrcweir if( aInfo.m_eItalic != psp::italic::Unknown ) 1816*cdf0e10cSrcweir aFont.SetItalic( PspGraphics::ToFontItalic( aInfo.m_eItalic ) ); 1817*cdf0e10cSrcweir if( aInfo.m_ePitch != psp::pitch::Unknown ) 1818*cdf0e10cSrcweir aFont.SetPitch( PspGraphics::ToFontPitch( aInfo.m_ePitch ) ); 1819*cdf0e10cSrcweir 1820*cdf0e10cSrcweir return aFont; 1821*cdf0e10cSrcweir } 1822*cdf0e10cSrcweir 1823*cdf0e10cSrcweir /** Implementation of KDE integration's main method. 1824*cdf0e10cSrcweir */ 1825*cdf0e10cSrcweir void KDESalFrame::UpdateSettings( AllSettings& rSettings ) 1826*cdf0e10cSrcweir { 1827*cdf0e10cSrcweir StyleSettings aStyleSettings( rSettings.GetStyleSettings() ); 1828*cdf0e10cSrcweir bool bSetTitleFont = false; 1829*cdf0e10cSrcweir 1830*cdf0e10cSrcweir // WM settings 1831*cdf0e10cSrcweir KConfig *pConfig = KGlobal::config(); 1832*cdf0e10cSrcweir if ( pConfig ) 1833*cdf0e10cSrcweir { 1834*cdf0e10cSrcweir pConfig->setGroup( "WM" ); 1835*cdf0e10cSrcweir const char *pKey; 1836*cdf0e10cSrcweir 1837*cdf0e10cSrcweir pKey = "activeBackground"; 1838*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1839*cdf0e10cSrcweir aStyleSettings.SetActiveColor( readColor( pConfig, pKey ) ); 1840*cdf0e10cSrcweir 1841*cdf0e10cSrcweir pKey = "activeBlend"; 1842*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1843*cdf0e10cSrcweir aStyleSettings.SetActiveColor2( readColor( pConfig, pKey ) ); 1844*cdf0e10cSrcweir 1845*cdf0e10cSrcweir pKey = "inactiveBackground"; 1846*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1847*cdf0e10cSrcweir aStyleSettings.SetDeactiveColor( readColor( pConfig, pKey ) ); 1848*cdf0e10cSrcweir 1849*cdf0e10cSrcweir pKey = "inactiveBlend"; 1850*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1851*cdf0e10cSrcweir aStyleSettings.SetDeactiveColor2( readColor( pConfig, pKey ) ); 1852*cdf0e10cSrcweir 1853*cdf0e10cSrcweir pKey = "inactiveForeground"; 1854*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1855*cdf0e10cSrcweir aStyleSettings.SetDeactiveTextColor( readColor( pConfig, pKey ) ); 1856*cdf0e10cSrcweir 1857*cdf0e10cSrcweir pKey = "activeForeground"; 1858*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1859*cdf0e10cSrcweir aStyleSettings.SetActiveTextColor( readColor( pConfig, pKey ) ); 1860*cdf0e10cSrcweir 1861*cdf0e10cSrcweir pKey = "titleFont"; 1862*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1863*cdf0e10cSrcweir { 1864*cdf0e10cSrcweir Font aFont = toFont( pConfig->readFontEntry( pKey ), rSettings.GetUILocale() ); 1865*cdf0e10cSrcweir aStyleSettings.SetTitleFont( aFont ); 1866*cdf0e10cSrcweir bSetTitleFont = true; 1867*cdf0e10cSrcweir } 1868*cdf0e10cSrcweir 1869*cdf0e10cSrcweir pConfig->setGroup( "Icons" ); 1870*cdf0e10cSrcweir 1871*cdf0e10cSrcweir pKey = "Theme"; 1872*cdf0e10cSrcweir if ( pConfig->hasKey( pKey ) ) 1873*cdf0e10cSrcweir aStyleSettings.SetPreferredSymbolsStyleName( readEntryUntranslated( pConfig, pKey ) ); 1874*cdf0e10cSrcweir } 1875*cdf0e10cSrcweir 1876*cdf0e10cSrcweir // General settings 1877*cdf0e10cSrcweir QColorGroup qColorGroup = kapp->palette().active(); 1878*cdf0e10cSrcweir 1879*cdf0e10cSrcweir Color aFore = toColor( qColorGroup.foreground() ); 1880*cdf0e10cSrcweir Color aBack = toColor( qColorGroup.background() ); 1881*cdf0e10cSrcweir Color aText = toColor( qColorGroup.text() ); 1882*cdf0e10cSrcweir Color aBase = toColor( qColorGroup.base() ); 1883*cdf0e10cSrcweir 1884*cdf0e10cSrcweir // Foreground 1885*cdf0e10cSrcweir aStyleSettings.SetRadioCheckTextColor( aFore ); 1886*cdf0e10cSrcweir aStyleSettings.SetLabelTextColor( aFore ); 1887*cdf0e10cSrcweir aStyleSettings.SetInfoTextColor( aFore ); 1888*cdf0e10cSrcweir aStyleSettings.SetDialogTextColor( aFore ); 1889*cdf0e10cSrcweir aStyleSettings.SetGroupTextColor( aFore ); 1890*cdf0e10cSrcweir 1891*cdf0e10cSrcweir // Text 1892*cdf0e10cSrcweir aStyleSettings.SetFieldTextColor( aText ); 1893*cdf0e10cSrcweir aStyleSettings.SetFieldRolloverTextColor( aText ); 1894*cdf0e10cSrcweir aStyleSettings.SetWindowTextColor( aText ); 1895*cdf0e10cSrcweir aStyleSettings.SetHelpTextColor( aText ); 1896*cdf0e10cSrcweir 1897*cdf0e10cSrcweir // Base 1898*cdf0e10cSrcweir aStyleSettings.SetFieldColor( aBase ); 1899*cdf0e10cSrcweir aStyleSettings.SetHelpColor( aBase ); 1900*cdf0e10cSrcweir aStyleSettings.SetWindowColor( aBase ); 1901*cdf0e10cSrcweir aStyleSettings.SetActiveTabColor( aBase ); 1902*cdf0e10cSrcweir 1903*cdf0e10cSrcweir // Buttons 1904*cdf0e10cSrcweir aStyleSettings.SetButtonTextColor( toColor( qColorGroup.buttonText() ) ); 1905*cdf0e10cSrcweir aStyleSettings.SetButtonRolloverTextColor( toColor( qColorGroup.buttonText() ) ); 1906*cdf0e10cSrcweir 1907*cdf0e10cSrcweir // Disable color 1908*cdf0e10cSrcweir aStyleSettings.SetDisableColor( toColor( qColorGroup.mid() ) ); 1909*cdf0e10cSrcweir 1910*cdf0e10cSrcweir // Workspace 1911*cdf0e10cSrcweir aStyleSettings.SetWorkspaceColor( toColor( qColorGroup.mid() ) ); 1912*cdf0e10cSrcweir 1913*cdf0e10cSrcweir // Background 1914*cdf0e10cSrcweir aStyleSettings.Set3DColors( aBack ); 1915*cdf0e10cSrcweir aStyleSettings.SetFaceColor( aBack ); 1916*cdf0e10cSrcweir aStyleSettings.SetInactiveTabColor( aBack ); 1917*cdf0e10cSrcweir aStyleSettings.SetDialogColor( aBack ); 1918*cdf0e10cSrcweir if( aBack == COL_LIGHTGRAY ) 1919*cdf0e10cSrcweir aStyleSettings.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) ); 1920*cdf0e10cSrcweir else 1921*cdf0e10cSrcweir { 1922*cdf0e10cSrcweir Color aColor2 = aStyleSettings.GetLightColor(); 1923*cdf0e10cSrcweir aStyleSettings. 1924*cdf0e10cSrcweir SetCheckedColor( Color( (sal_uInt8)(((sal_uInt16)aBack.GetRed()+(sal_uInt16)aColor2.GetRed())/2), 1925*cdf0e10cSrcweir (sal_uInt8)(((sal_uInt16)aBack.GetGreen()+(sal_uInt16)aColor2.GetGreen())/2), 1926*cdf0e10cSrcweir (sal_uInt8)(((sal_uInt16)aBack.GetBlue()+(sal_uInt16)aColor2.GetBlue())/2) 1927*cdf0e10cSrcweir ) ); 1928*cdf0e10cSrcweir } 1929*cdf0e10cSrcweir 1930*cdf0e10cSrcweir // Selection 1931*cdf0e10cSrcweir aStyleSettings.SetHighlightColor( toColor( qColorGroup.highlight() ) ); 1932*cdf0e10cSrcweir aStyleSettings.SetHighlightTextColor( toColor( qColorGroup.highlightedText() ) ); 1933*cdf0e10cSrcweir 1934*cdf0e10cSrcweir // Font 1935*cdf0e10cSrcweir Font aFont = toFont( kapp->font(), rSettings.GetUILocale() ); 1936*cdf0e10cSrcweir 1937*cdf0e10cSrcweir aStyleSettings.SetAppFont( aFont ); 1938*cdf0e10cSrcweir aStyleSettings.SetHelpFont( aFont ); 1939*cdf0e10cSrcweir if( !bSetTitleFont ) 1940*cdf0e10cSrcweir aStyleSettings.SetTitleFont( aFont ); 1941*cdf0e10cSrcweir aStyleSettings.SetFloatTitleFont( aFont ); 1942*cdf0e10cSrcweir aStyleSettings.SetMenuFont( aFont ); // will be changed according to pMenuBar 1943*cdf0e10cSrcweir aStyleSettings.SetToolFont( aFont ); // will be changed according to pToolBar 1944*cdf0e10cSrcweir aStyleSettings.SetLabelFont( aFont ); 1945*cdf0e10cSrcweir aStyleSettings.SetInfoFont( aFont ); 1946*cdf0e10cSrcweir aStyleSettings.SetRadioCheckFont( aFont ); 1947*cdf0e10cSrcweir aStyleSettings.SetPushButtonFont( aFont ); 1948*cdf0e10cSrcweir aStyleSettings.SetFieldFont( aFont ); 1949*cdf0e10cSrcweir aStyleSettings.SetIconFont( aFont ); 1950*cdf0e10cSrcweir aStyleSettings.SetGroupFont( aFont ); 1951*cdf0e10cSrcweir int flash_time = QApplication::cursorFlashTime(); 1952*cdf0e10cSrcweir aStyleSettings.SetCursorBlinkTime( flash_time != 0 ? flash_time/2 : STYLE_CURSOR_NOBLINKTIME ); 1953*cdf0e10cSrcweir 1954*cdf0e10cSrcweir KMainWindow qMainWindow; 1955*cdf0e10cSrcweir qMainWindow.createGUI( "/dev/null" ); // hack 1956*cdf0e10cSrcweir 1957*cdf0e10cSrcweir // Menu 1958*cdf0e10cSrcweir aStyleSettings.SetSkipDisabledInMenus( sal_True ); 1959*cdf0e10cSrcweir KMenuBar *pMenuBar = qMainWindow.menuBar(); 1960*cdf0e10cSrcweir if ( pMenuBar ) 1961*cdf0e10cSrcweir { 1962*cdf0e10cSrcweir // Color 1963*cdf0e10cSrcweir QColorGroup qMenuCG = pMenuBar->colorGroup(); 1964*cdf0e10cSrcweir 1965*cdf0e10cSrcweir // Menu text and background color, theme specific 1966*cdf0e10cSrcweir Color aMenuFore = toColor( qMenuCG.foreground() ); 1967*cdf0e10cSrcweir Color aMenuBack = toColor( qMenuCG.background() ); 1968*cdf0e10cSrcweir if ( kapp->style().inherits( "LightStyleV2" ) || 1969*cdf0e10cSrcweir kapp->style().inherits( "LightStyleV3" ) || 1970*cdf0e10cSrcweir ( kapp->style().inherits( "QMotifStyle" ) && !kapp->style().inherits( "QSGIStyle" ) ) || 1971*cdf0e10cSrcweir kapp->style().inherits( "QWindowsStyle" ) ) 1972*cdf0e10cSrcweir { 1973*cdf0e10cSrcweir aMenuFore = toColor( qMenuCG.buttonText() ); 1974*cdf0e10cSrcweir aMenuBack = toColor( qMenuCG.button() ); 1975*cdf0e10cSrcweir } 1976*cdf0e10cSrcweir 1977*cdf0e10cSrcweir aStyleSettings.SetMenuTextColor( aMenuFore ); 1978*cdf0e10cSrcweir aStyleSettings.SetMenuBarTextColor( aMenuFore ); 1979*cdf0e10cSrcweir aStyleSettings.SetMenuColor( aMenuBack ); 1980*cdf0e10cSrcweir aStyleSettings.SetMenuBarColor( aMenuBack ); 1981*cdf0e10cSrcweir 1982*cdf0e10cSrcweir aStyleSettings.SetMenuHighlightColor( toColor ( qMenuCG.highlight() ) ); 1983*cdf0e10cSrcweir 1984*cdf0e10cSrcweir // Menu items higlight text color, theme specific 1985*cdf0e10cSrcweir if ( kapp->style().inherits( "HighContrastStyle" ) || 1986*cdf0e10cSrcweir kapp->style().inherits( "KeramikStyle" ) || 1987*cdf0e10cSrcweir kapp->style().inherits( "QWindowsStyle" ) || 1988*cdf0e10cSrcweir kapp->style().inherits( "ThinKeramikStyle" ) || 1989*cdf0e10cSrcweir kapp->style().inherits( "PlastikStyle" ) ) 1990*cdf0e10cSrcweir { 1991*cdf0e10cSrcweir aStyleSettings.SetMenuHighlightTextColor( toColor ( qMenuCG.highlightedText() ) ); 1992*cdf0e10cSrcweir } 1993*cdf0e10cSrcweir else 1994*cdf0e10cSrcweir aStyleSettings.SetMenuHighlightTextColor( aMenuFore ); 1995*cdf0e10cSrcweir 1996*cdf0e10cSrcweir // set special menubar higlight text color 1997*cdf0e10cSrcweir if ( kapp->style().inherits( "HighContrastStyle" ) ) 1998*cdf0e10cSrcweir ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.highlightedText() ); 1999*cdf0e10cSrcweir else 2000*cdf0e10cSrcweir ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; 2001*cdf0e10cSrcweir 2002*cdf0e10cSrcweir // Font 2003*cdf0e10cSrcweir aFont = toFont( pMenuBar->font(), rSettings.GetUILocale() ); 2004*cdf0e10cSrcweir aStyleSettings.SetMenuFont( aFont ); 2005*cdf0e10cSrcweir } 2006*cdf0e10cSrcweir 2007*cdf0e10cSrcweir // Tool bar 2008*cdf0e10cSrcweir KToolBar *pToolBar = qMainWindow.toolBar(); 2009*cdf0e10cSrcweir if ( pToolBar ) 2010*cdf0e10cSrcweir { 2011*cdf0e10cSrcweir aFont = toFont( pToolBar->font(), rSettings.GetUILocale() ); 2012*cdf0e10cSrcweir aStyleSettings.SetToolFont( aFont ); 2013*cdf0e10cSrcweir } 2014*cdf0e10cSrcweir 2015*cdf0e10cSrcweir // Scroll bar size 2016*cdf0e10cSrcweir aStyleSettings.SetScrollBarSize( kapp->style().pixelMetric( QStyle::PM_ScrollBarExtent ) ); 2017*cdf0e10cSrcweir 2018*cdf0e10cSrcweir rSettings.SetStyleSettings( aStyleSettings ); 2019*cdf0e10cSrcweir } 2020*cdf0e10cSrcweir 2021*cdf0e10cSrcweir SalGraphics* KDESalFrame::GetGraphics() 2022*cdf0e10cSrcweir { 2023*cdf0e10cSrcweir if( GetWindow() ) 2024*cdf0e10cSrcweir { 2025*cdf0e10cSrcweir for( int i = 0; i < nMaxGraphics; i++ ) 2026*cdf0e10cSrcweir { 2027*cdf0e10cSrcweir if( ! m_aGraphics[i].bInUse ) 2028*cdf0e10cSrcweir { 2029*cdf0e10cSrcweir m_aGraphics[i].bInUse = true; 2030*cdf0e10cSrcweir if( ! m_aGraphics[i].pGraphics ) 2031*cdf0e10cSrcweir { 2032*cdf0e10cSrcweir m_aGraphics[i].pGraphics = new KDESalGraphics(); 2033*cdf0e10cSrcweir m_aGraphics[i].pGraphics->Init( this, GetWindow(), GetScreenNumber() ); 2034*cdf0e10cSrcweir } 2035*cdf0e10cSrcweir return m_aGraphics[i].pGraphics; 2036*cdf0e10cSrcweir } 2037*cdf0e10cSrcweir } 2038*cdf0e10cSrcweir } 2039*cdf0e10cSrcweir 2040*cdf0e10cSrcweir return NULL; 2041*cdf0e10cSrcweir } 2042*cdf0e10cSrcweir 2043*cdf0e10cSrcweir void KDESalFrame::ReleaseGraphics( SalGraphics *pGraphics ) 2044*cdf0e10cSrcweir { 2045*cdf0e10cSrcweir for( int i = 0; i < nMaxGraphics; i++ ) 2046*cdf0e10cSrcweir { 2047*cdf0e10cSrcweir if( m_aGraphics[i].pGraphics == pGraphics ) 2048*cdf0e10cSrcweir { 2049*cdf0e10cSrcweir m_aGraphics[i].bInUse = false; 2050*cdf0e10cSrcweir break; 2051*cdf0e10cSrcweir } 2052*cdf0e10cSrcweir } 2053*cdf0e10cSrcweir } 2054*cdf0e10cSrcweir 2055*cdf0e10cSrcweir void KDESalFrame::updateGraphics( bool bClear ) 2056*cdf0e10cSrcweir { 2057*cdf0e10cSrcweir Drawable aDrawable = bClear ? None : GetWindow(); 2058*cdf0e10cSrcweir for( int i = 0; i < nMaxGraphics; i++ ) 2059*cdf0e10cSrcweir { 2060*cdf0e10cSrcweir if( m_aGraphics[i].bInUse ) 2061*cdf0e10cSrcweir m_aGraphics[i].pGraphics->SetDrawable( aDrawable, GetScreenNumber() ); 2062*cdf0e10cSrcweir } 2063*cdf0e10cSrcweir } 2064*cdf0e10cSrcweir 2065*cdf0e10cSrcweir KDESalFrame::~KDESalFrame() 2066*cdf0e10cSrcweir { 2067*cdf0e10cSrcweir } 2068*cdf0e10cSrcweir 2069*cdf0e10cSrcweir KDESalFrame::GraphicsHolder::~GraphicsHolder() 2070*cdf0e10cSrcweir { 2071*cdf0e10cSrcweir delete pGraphics; 2072*cdf0e10cSrcweir } 2073*cdf0e10cSrcweir 2074*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2075*cdf0e10cSrcweir // KDESalInstance implementation 2076*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2077*cdf0e10cSrcweir 2078*cdf0e10cSrcweir SalFrame * 2079*cdf0e10cSrcweir KDESalInstance::CreateFrame( SalFrame *pParent, sal_uLong nStyle ) 2080*cdf0e10cSrcweir { 2081*cdf0e10cSrcweir return new KDESalFrame( pParent, nStyle ); 2082*cdf0e10cSrcweir } 2083*cdf0e10cSrcweir 2084*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2085*cdf0e10cSrcweir // KDESalData pieces 2086*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2087*cdf0e10cSrcweir 2088*cdf0e10cSrcweir // Create the widget painter so we have some control over 2089*cdf0e10cSrcweir // the destruction sequence, so Qt doesn't die in action. 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir void KDEData::initNWF() 2092*cdf0e10cSrcweir { 2093*cdf0e10cSrcweir ImplSVData *pSVData = ImplGetSVData(); 2094*cdf0e10cSrcweir // draw toolbars on separate lines 2095*cdf0e10cSrcweir pSVData->maNWFData.mbDockingAreaSeparateTB = true; 2096*cdf0e10cSrcweir 2097*cdf0e10cSrcweir pWidgetPainter = new WidgetPainter(); 2098*cdf0e10cSrcweir } 2099*cdf0e10cSrcweir 2100*cdf0e10cSrcweir void KDEData::deInitNWF() 2101*cdf0e10cSrcweir { 2102*cdf0e10cSrcweir delete pWidgetPainter; 2103*cdf0e10cSrcweir pWidgetPainter = NULL; 2104*cdf0e10cSrcweir 2105*cdf0e10cSrcweir // We have to destroy the style early 2106*cdf0e10cSrcweir kapp->setStyle( NULL ); 2107*cdf0e10cSrcweir } 2108