1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #define _SV_SALNATIVEWIDGETS_CXX 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "rtl/ustring.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "osl/module.h" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "vcl/svapp.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "win/svsys.h" 36cdf0e10cSrcweir #include "win/salgdi.h" 37cdf0e10cSrcweir #include "win/saldata.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "uxtheme.h" 40cdf0e10cSrcweir #include "vssym32.h" 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <map> 43cdf0e10cSrcweir #include <string> 44cdf0e10cSrcweir 45cdf0e10cSrcweir using namespace rtl; 46cdf0e10cSrcweir using namespace std; 47cdf0e10cSrcweir 48cdf0e10cSrcweir typedef map< wstring, HTHEME > ThemeMap; 49cdf0e10cSrcweir static ThemeMap aThemeMap; 50cdf0e10cSrcweir 51cdf0e10cSrcweir 52cdf0e10cSrcweir /**************************************************** 53cdf0e10cSrcweir wrap visual styles API to avoid linking against it 54cdf0e10cSrcweir it is not available on all Windows platforms 55cdf0e10cSrcweir *****************************************************/ 56cdf0e10cSrcweir 57cdf0e10cSrcweir class VisualStylesAPI 58cdf0e10cSrcweir { 59cdf0e10cSrcweir private: 60cdf0e10cSrcweir typedef HTHEME (WINAPI * OpenThemeData_Proc_T) ( HWND hwnd, LPCWSTR pszClassList ); 61cdf0e10cSrcweir typedef HRESULT (WINAPI * CloseThemeData_Proc_T) ( HTHEME hTheme ); 62cdf0e10cSrcweir typedef HRESULT (WINAPI * GetThemeBackgroundContentRect_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect ); 63cdf0e10cSrcweir typedef HRESULT (WINAPI * DrawThemeBackground_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect ); 64cdf0e10cSrcweir typedef HRESULT (WINAPI * DrawThemeText_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect ); 65cdf0e10cSrcweir typedef HRESULT (WINAPI * GetThemePartSize_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir OpenThemeData_Proc_T lpfnOpenThemeData; 68cdf0e10cSrcweir CloseThemeData_Proc_T lpfnCloseThemeData; 69cdf0e10cSrcweir GetThemeBackgroundContentRect_Proc_T lpfnGetThemeBackgroundContentRect; 70cdf0e10cSrcweir DrawThemeBackground_Proc_T lpfnDrawThemeBackground; 71cdf0e10cSrcweir DrawThemeText_Proc_T lpfnDrawThemeText; 72cdf0e10cSrcweir GetThemePartSize_Proc_T lpfnGetThemePartSize; 73cdf0e10cSrcweir 74cdf0e10cSrcweir oslModule mhModule; 75cdf0e10cSrcweir 76cdf0e10cSrcweir public: 77cdf0e10cSrcweir VisualStylesAPI(); 78cdf0e10cSrcweir ~VisualStylesAPI(); 79cdf0e10cSrcweir sal_Bool IsAvailable() { return (mhModule != NULL); } 80cdf0e10cSrcweir 81cdf0e10cSrcweir HTHEME OpenThemeData( HWND hwnd, LPCWSTR pszClassList ); 82cdf0e10cSrcweir HRESULT CloseThemeData( HTHEME hTheme ); 83cdf0e10cSrcweir HRESULT GetThemeBackgroundContentRect( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect ); 84cdf0e10cSrcweir HRESULT DrawThemeBackground( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect ); 85cdf0e10cSrcweir HRESULT DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect ); 86cdf0e10cSrcweir HRESULT GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz ); 87cdf0e10cSrcweir }; 88cdf0e10cSrcweir 89cdf0e10cSrcweir static VisualStylesAPI vsAPI; 90cdf0e10cSrcweir 91cdf0e10cSrcweir VisualStylesAPI::VisualStylesAPI() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM( "uxtheme.dll" ) ); 94cdf0e10cSrcweir mhModule = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT ); 95cdf0e10cSrcweir 96cdf0e10cSrcweir if ( mhModule ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir lpfnOpenThemeData = (OpenThemeData_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "OpenThemeData" ); 99cdf0e10cSrcweir lpfnCloseThemeData = (CloseThemeData_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "CloseThemeData" ); 100cdf0e10cSrcweir lpfnGetThemeBackgroundContentRect = (GetThemeBackgroundContentRect_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "GetThemeBackgroundContentRect" ); 101cdf0e10cSrcweir lpfnDrawThemeBackground = (DrawThemeBackground_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "DrawThemeBackground" ); 102cdf0e10cSrcweir lpfnDrawThemeText = (DrawThemeText_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "DrawThemeText" ); 103cdf0e10cSrcweir lpfnGetThemePartSize = (GetThemePartSize_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "GetThemePartSize" ); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir else 106cdf0e10cSrcweir { 107cdf0e10cSrcweir lpfnOpenThemeData = NULL; 108cdf0e10cSrcweir lpfnCloseThemeData = NULL; 109cdf0e10cSrcweir lpfnGetThemeBackgroundContentRect = NULL; 110cdf0e10cSrcweir lpfnDrawThemeBackground = NULL; 111cdf0e10cSrcweir lpfnDrawThemeText = NULL; 112cdf0e10cSrcweir lpfnGetThemePartSize = NULL; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir } 115cdf0e10cSrcweir VisualStylesAPI::~VisualStylesAPI() 116cdf0e10cSrcweir { 117cdf0e10cSrcweir if( mhModule ) 118cdf0e10cSrcweir osl_unloadModule( mhModule ); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir HTHEME VisualStylesAPI::OpenThemeData( HWND hwnd, LPCWSTR pszClassList ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir if(lpfnOpenThemeData) 123cdf0e10cSrcweir return (*lpfnOpenThemeData) (hwnd, pszClassList); 124cdf0e10cSrcweir else 125cdf0e10cSrcweir return NULL; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir HRESULT VisualStylesAPI::CloseThemeData( HTHEME hTheme ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir if(lpfnCloseThemeData) 131cdf0e10cSrcweir return (*lpfnCloseThemeData) (hTheme); 132cdf0e10cSrcweir else 133cdf0e10cSrcweir return S_FALSE; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir HRESULT VisualStylesAPI::GetThemeBackgroundContentRect( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir if(lpfnGetThemeBackgroundContentRect) 138cdf0e10cSrcweir return (*lpfnGetThemeBackgroundContentRect) ( hTheme, hdc, iPartId, iStateId, pBoundingRect, pContentRect ); 139cdf0e10cSrcweir else 140cdf0e10cSrcweir return S_FALSE; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir HRESULT VisualStylesAPI::DrawThemeBackground( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir if(lpfnDrawThemeBackground) 145cdf0e10cSrcweir return (*lpfnDrawThemeBackground) (hTheme, hdc, iPartId, iStateId, pRect, pClipRect); 146cdf0e10cSrcweir else 147cdf0e10cSrcweir return S_FALSE; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir HRESULT VisualStylesAPI::DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir if(lpfnDrawThemeText) 152cdf0e10cSrcweir return (*lpfnDrawThemeText) (hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, dwTextFlags2, pRect); 153cdf0e10cSrcweir else 154cdf0e10cSrcweir return S_FALSE; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir HRESULT VisualStylesAPI::GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir if(lpfnGetThemePartSize) 159cdf0e10cSrcweir return (*lpfnGetThemePartSize) (hTheme, hdc, iPartId, iStateId, prc, eSize, psz); 160cdf0e10cSrcweir else 161cdf0e10cSrcweir return S_FALSE; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir 165cdf0e10cSrcweir /********************************************************* 166cdf0e10cSrcweir * Initialize XP theming and local stuff 167cdf0e10cSrcweir *********************************************************/ 168cdf0e10cSrcweir void SalData::initNWF( void ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir // the menu bar and the top docking area should have a common background (gradient) 173cdf0e10cSrcweir pSVData->maNWFData.mbMenuBarDockingAreaCommonBG = true; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir 177cdf0e10cSrcweir // ********************************************************* 178cdf0e10cSrcweir // * Release theming handles 179cdf0e10cSrcweir // ******************************************************** 180cdf0e10cSrcweir void SalData::deInitNWF( void ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir ThemeMap::iterator iter = aThemeMap.begin(); 183cdf0e10cSrcweir while( iter != aThemeMap.end() ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir vsAPI.CloseThemeData(iter->second); 186cdf0e10cSrcweir iter++; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir aThemeMap.clear(); 189cdf0e10cSrcweir if( maDwmLib ) 190cdf0e10cSrcweir osl_unloadModule( maDwmLib ); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir static HTHEME getThemeHandle( HWND hWnd, LPCWSTR name ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir if( GetSalData()->mbThemeChanged ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir // throw away invalid theme handles 198cdf0e10cSrcweir GetSalData()->deInitNWF(); 199cdf0e10cSrcweir GetSalData()->mbThemeChanged = FALSE; 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir ThemeMap::iterator iter; 203cdf0e10cSrcweir if( (iter = aThemeMap.find( name )) != aThemeMap.end() ) 204cdf0e10cSrcweir return iter->second; 205cdf0e10cSrcweir // theme not found -> add it to map 206cdf0e10cSrcweir HTHEME hTheme = vsAPI.OpenThemeData( hWnd, name ); 207cdf0e10cSrcweir if( hTheme != NULL ) 208cdf0e10cSrcweir aThemeMap[name] = hTheme; 209cdf0e10cSrcweir return hTheme; 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir /* 213cdf0e10cSrcweir * IsNativeControlSupported() 214cdf0e10cSrcweir * 215cdf0e10cSrcweir * Returns TRUE if the platform supports native 216cdf0e10cSrcweir * drawing of the control defined by nPart 217cdf0e10cSrcweir */ 218cdf0e10cSrcweir sal_Bool WinSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir HTHEME hTheme = NULL; 221cdf0e10cSrcweir 222cdf0e10cSrcweir switch( nType ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir case CTRL_PUSHBUTTON: 225cdf0e10cSrcweir case CTRL_RADIOBUTTON: 226cdf0e10cSrcweir case CTRL_CHECKBOX: 227cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 228cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Button"); 229cdf0e10cSrcweir break; 230cdf0e10cSrcweir case CTRL_SCROLLBAR: 231cdf0e10cSrcweir if( nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT ) 232cdf0e10cSrcweir return FALSE; // no background painting needed 233cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 234cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Scrollbar"); 235cdf0e10cSrcweir break; 236cdf0e10cSrcweir case CTRL_COMBOBOX: 237cdf0e10cSrcweir if( nPart == HAS_BACKGROUND_TEXTURE ) 238cdf0e10cSrcweir return FALSE; // we do not paint the inner part (ie the selection background/focus indication) 239cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 240cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Edit"); 241cdf0e10cSrcweir else if( nPart == PART_BUTTON_DOWN ) 242cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Combobox"); 243cdf0e10cSrcweir break; 244cdf0e10cSrcweir case CTRL_SPINBOX: 245cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 246cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Edit"); 247cdf0e10cSrcweir else if( nPart == PART_ALL_BUTTONS || 248cdf0e10cSrcweir nPart == PART_BUTTON_UP || nPart == PART_BUTTON_DOWN || 249cdf0e10cSrcweir nPart == PART_BUTTON_LEFT|| nPart == PART_BUTTON_RIGHT ) 250cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Spin"); 251cdf0e10cSrcweir break; 252cdf0e10cSrcweir case CTRL_SPINBUTTONS: 253cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || nPart == PART_ALL_BUTTONS ) 254cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Spin"); 255cdf0e10cSrcweir break; 256cdf0e10cSrcweir case CTRL_EDITBOX: 257cdf0e10cSrcweir case CTRL_MULTILINE_EDITBOX: 258cdf0e10cSrcweir if( nPart == HAS_BACKGROUND_TEXTURE ) 259cdf0e10cSrcweir return FALSE; // we do not paint the inner part (ie the selection background/focus indication) 260cdf0e10cSrcweir //return TRUE; 261cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 262cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Edit"); 263cdf0e10cSrcweir break; 264cdf0e10cSrcweir case CTRL_LISTBOX: 265cdf0e10cSrcweir if( nPart == HAS_BACKGROUND_TEXTURE ) 266cdf0e10cSrcweir return FALSE; // we do not paint the inner part (ie the selection background/focus indication) 267cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || nPart == PART_WINDOW ) 268cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Listview"); 269cdf0e10cSrcweir else if( nPart == PART_BUTTON_DOWN ) 270cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Combobox"); 271cdf0e10cSrcweir break; 272cdf0e10cSrcweir case CTRL_TAB_PANE: 273cdf0e10cSrcweir case CTRL_TAB_BODY: 274cdf0e10cSrcweir case CTRL_TAB_ITEM: 275cdf0e10cSrcweir case CTRL_FIXEDBORDER: 276cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 277cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Tab"); 278cdf0e10cSrcweir break; 279cdf0e10cSrcweir case CTRL_TOOLBAR: 280cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || nPart == PART_BUTTON ) 281cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Toolbar"); 282cdf0e10cSrcweir else 283cdf0e10cSrcweir // use rebar theme for grip and background 284cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Rebar"); 285cdf0e10cSrcweir break; 286cdf0e10cSrcweir case CTRL_MENUBAR: 287cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 288cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Rebar"); 289cdf0e10cSrcweir else if( GetSalData()->mbThemeMenuSupport ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir if( nPart == PART_MENU_ITEM ) 292cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Menu" ); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir break; 295cdf0e10cSrcweir case CTRL_MENU_POPUP: 296cdf0e10cSrcweir if( GetSalData()->mbThemeMenuSupport ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || 299cdf0e10cSrcweir nPart == PART_MENU_ITEM || 300cdf0e10cSrcweir nPart == PART_MENU_ITEM_CHECK_MARK || 301cdf0e10cSrcweir nPart == PART_MENU_ITEM_RADIO_MARK || 302cdf0e10cSrcweir nPart == PART_MENU_SEPARATOR ) 303cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Menu" ); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir break; 306cdf0e10cSrcweir case CTRL_PROGRESS: 307cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 308cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Progress"); 309cdf0e10cSrcweir break; 310cdf0e10cSrcweir case CTRL_SLIDER: 311cdf0e10cSrcweir if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) 312cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Trackbar" ); 313cdf0e10cSrcweir break; 314cdf0e10cSrcweir case CTRL_LISTNODE: 315cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 316cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"TreeView" ); 317cdf0e10cSrcweir break; 318cdf0e10cSrcweir default: 319cdf0e10cSrcweir hTheme = NULL; 320cdf0e10cSrcweir break; 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir return (hTheme != NULL); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir 327cdf0e10cSrcweir /* 328cdf0e10cSrcweir * HitTestNativeControl() 329cdf0e10cSrcweir * 330cdf0e10cSrcweir * If the return value is TRUE, bIsInside contains information whether 331cdf0e10cSrcweir * aPos was or was not inside the native widget specified by the 332cdf0e10cSrcweir * nType/nPart combination. 333cdf0e10cSrcweir */ 334cdf0e10cSrcweir sal_Bool WinSalGraphics::hitTestNativeControl( ControlType, 335cdf0e10cSrcweir ControlPart, 336cdf0e10cSrcweir const Rectangle&, 337cdf0e10cSrcweir const Point&, 338cdf0e10cSrcweir sal_Bool& ) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir return FALSE; 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir sal_Bool ImplDrawTheme( HTHEME hTheme, HDC hDC, int iPart, int iState, RECT rc, const OUString& aStr) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir HRESULT hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 346cdf0e10cSrcweir 347cdf0e10cSrcweir if( aStr.getLength() ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir RECT rcContent; 350cdf0e10cSrcweir hr = vsAPI.GetThemeBackgroundContentRect( hTheme, hDC, iPart, iState, &rc, &rcContent); 351cdf0e10cSrcweir hr = vsAPI.DrawThemeText( hTheme, hDC, iPart, iState, 352cdf0e10cSrcweir reinterpret_cast<LPCWSTR>(aStr.getStr()), -1, 353cdf0e10cSrcweir DT_CENTER | DT_VCENTER | DT_SINGLELINE, 354cdf0e10cSrcweir 0, &rcContent); 355cdf0e10cSrcweir } 356cdf0e10cSrcweir return (hr == S_OK); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir 360cdf0e10cSrcweir Rectangle ImplGetThemeRect( HTHEME hTheme, HDC hDC, int iPart, int iState, const Rectangle& aRect, THEMESIZE eTS = TS_TRUE ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir SIZE aSz; 363cdf0e10cSrcweir RECT rc; 364cdf0e10cSrcweir rc.left = aRect.nLeft; 365cdf0e10cSrcweir rc.right = aRect.nRight; 366cdf0e10cSrcweir rc.top = aRect.nTop; 367cdf0e10cSrcweir rc.bottom = aRect.nBottom; 368cdf0e10cSrcweir HRESULT hr = vsAPI.GetThemePartSize( hTheme, hDC, iPart, iState, NULL, eTS, &aSz ); // TS_TRUE returns optimal size 369cdf0e10cSrcweir if( hr == S_OK ) 370cdf0e10cSrcweir return Rectangle( 0, 0, aSz.cx, aSz.cy ); 371cdf0e10cSrcweir else 372cdf0e10cSrcweir return Rectangle(); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir // Helper functions 376cdf0e10cSrcweir // ---- 377cdf0e10cSrcweir 378cdf0e10cSrcweir void ImplConvertSpinbuttonValues( int nControlPart, const ControlState& rState, const Rectangle& rRect, 379cdf0e10cSrcweir int* pLunaPart, int *pLunaState, RECT *pRect ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir if( nControlPart == PART_BUTTON_DOWN ) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir *pLunaPart = SPNP_DOWN; 384cdf0e10cSrcweir if( rState & CTRL_STATE_PRESSED ) 385cdf0e10cSrcweir *pLunaState = DNS_PRESSED; 386cdf0e10cSrcweir else if( !(rState & CTRL_STATE_ENABLED) ) 387cdf0e10cSrcweir *pLunaState = DNS_DISABLED; 388cdf0e10cSrcweir else if( rState & CTRL_STATE_ROLLOVER ) 389cdf0e10cSrcweir *pLunaState = DNS_HOT; 390cdf0e10cSrcweir else 391cdf0e10cSrcweir *pLunaState = DNS_NORMAL; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir if( nControlPart == PART_BUTTON_UP ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir *pLunaPart = SPNP_UP; 396cdf0e10cSrcweir if( rState & CTRL_STATE_PRESSED ) 397cdf0e10cSrcweir *pLunaState = UPS_PRESSED; 398cdf0e10cSrcweir else if( !(rState & CTRL_STATE_ENABLED) ) 399cdf0e10cSrcweir *pLunaState = UPS_DISABLED; 400cdf0e10cSrcweir else if( rState & CTRL_STATE_ROLLOVER ) 401cdf0e10cSrcweir *pLunaState = UPS_HOT; 402cdf0e10cSrcweir else 403cdf0e10cSrcweir *pLunaState = UPS_NORMAL; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir if( nControlPart == PART_BUTTON_RIGHT ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir *pLunaPart = SPNP_UPHORZ; 408cdf0e10cSrcweir if( rState & CTRL_STATE_PRESSED ) 409cdf0e10cSrcweir *pLunaState = DNHZS_PRESSED; 410cdf0e10cSrcweir else if( !(rState & CTRL_STATE_ENABLED) ) 411cdf0e10cSrcweir *pLunaState = DNHZS_DISABLED; 412cdf0e10cSrcweir else if( rState & CTRL_STATE_ROLLOVER ) 413cdf0e10cSrcweir *pLunaState = DNHZS_HOT; 414cdf0e10cSrcweir else 415cdf0e10cSrcweir *pLunaState = DNHZS_NORMAL; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir if( nControlPart == PART_BUTTON_LEFT ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir *pLunaPart = SPNP_DOWNHORZ; 420cdf0e10cSrcweir if( rState & CTRL_STATE_PRESSED ) 421cdf0e10cSrcweir *pLunaState = UPHZS_PRESSED; 422cdf0e10cSrcweir else if( !(rState & CTRL_STATE_ENABLED) ) 423cdf0e10cSrcweir *pLunaState = UPHZS_DISABLED; 424cdf0e10cSrcweir else if( rState & CTRL_STATE_ROLLOVER ) 425cdf0e10cSrcweir *pLunaState = UPHZS_HOT; 426cdf0e10cSrcweir else 427cdf0e10cSrcweir *pLunaState = UPHZS_NORMAL; 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir pRect->left = rRect.Left(); 431cdf0e10cSrcweir pRect->right = rRect.Right()+1; 432cdf0e10cSrcweir pRect->top = rRect.Top(); 433cdf0e10cSrcweir pRect->bottom = rRect.Bottom()+1; 434cdf0e10cSrcweir } 435cdf0e10cSrcweir 436cdf0e10cSrcweir // ---- 437cdf0e10cSrcweir 438cdf0e10cSrcweir sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, 439cdf0e10cSrcweir ControlType nType, 440cdf0e10cSrcweir ControlPart nPart, 441cdf0e10cSrcweir ControlState nState, 442cdf0e10cSrcweir const ImplControlValue& aValue, 443cdf0e10cSrcweir OUString aCaption ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir // a listbox dropdown is actually a combobox dropdown 446cdf0e10cSrcweir if( nType == CTRL_LISTBOX ) 447cdf0e10cSrcweir if( nPart == PART_BUTTON_DOWN ) 448cdf0e10cSrcweir nType = CTRL_COMBOBOX; 449cdf0e10cSrcweir 450cdf0e10cSrcweir // draw entire combobox as a large edit box 451cdf0e10cSrcweir if( nType == CTRL_COMBOBOX ) 452cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 453cdf0e10cSrcweir nType = CTRL_EDITBOX; 454cdf0e10cSrcweir 455cdf0e10cSrcweir // draw entire spinbox as a large edit box 456cdf0e10cSrcweir if( nType == CTRL_SPINBOX ) 457cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 458cdf0e10cSrcweir nType = CTRL_EDITBOX; 459cdf0e10cSrcweir 460cdf0e10cSrcweir int iPart(0), iState(0); 461cdf0e10cSrcweir if( nType == CTRL_SCROLLBAR ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir HRESULT hr; 464cdf0e10cSrcweir if( nPart == PART_BUTTON_UP ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir iPart = SBP_ARROWBTN; 467cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 468cdf0e10cSrcweir iState = ABS_UPPRESSED; 469cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 470cdf0e10cSrcweir iState = ABS_UPDISABLED; 471cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 472cdf0e10cSrcweir iState = ABS_UPHOT; 473cdf0e10cSrcweir else 474cdf0e10cSrcweir iState = ABS_UPNORMAL; 475cdf0e10cSrcweir hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 476cdf0e10cSrcweir return (hr == S_OK); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir if( nPart == PART_BUTTON_DOWN ) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir iPart = SBP_ARROWBTN; 481cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 482cdf0e10cSrcweir iState = ABS_DOWNPRESSED; 483cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 484cdf0e10cSrcweir iState = ABS_DOWNDISABLED; 485cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 486cdf0e10cSrcweir iState = ABS_DOWNHOT; 487cdf0e10cSrcweir else 488cdf0e10cSrcweir iState = ABS_DOWNNORMAL; 489cdf0e10cSrcweir hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 490cdf0e10cSrcweir return (hr == S_OK); 491cdf0e10cSrcweir } 492cdf0e10cSrcweir if( nPart == PART_BUTTON_LEFT ) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir iPart = SBP_ARROWBTN; 495cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 496cdf0e10cSrcweir iState = ABS_LEFTPRESSED; 497cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 498cdf0e10cSrcweir iState = ABS_LEFTDISABLED; 499cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 500cdf0e10cSrcweir iState = ABS_LEFTHOT; 501cdf0e10cSrcweir else 502cdf0e10cSrcweir iState = ABS_LEFTNORMAL; 503cdf0e10cSrcweir hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 504cdf0e10cSrcweir return (hr == S_OK); 505cdf0e10cSrcweir } 506cdf0e10cSrcweir if( nPart == PART_BUTTON_RIGHT ) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir iPart = SBP_ARROWBTN; 509cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 510cdf0e10cSrcweir iState = ABS_RIGHTPRESSED; 511cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 512cdf0e10cSrcweir iState = ABS_RIGHTDISABLED; 513cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 514cdf0e10cSrcweir iState = ABS_RIGHTHOT; 515cdf0e10cSrcweir else 516cdf0e10cSrcweir iState = ABS_RIGHTNORMAL; 517cdf0e10cSrcweir hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 518cdf0e10cSrcweir return (hr == S_OK); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir if( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT ) 521cdf0e10cSrcweir { 522cdf0e10cSrcweir iPart = (nPart == PART_THUMB_HORZ) ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT; 523cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 524cdf0e10cSrcweir iState = SCRBS_PRESSED; 525cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 526cdf0e10cSrcweir iState = SCRBS_DISABLED; 527cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 528cdf0e10cSrcweir iState = SCRBS_HOT; 529cdf0e10cSrcweir else 530cdf0e10cSrcweir iState = SCRBS_NORMAL; 531cdf0e10cSrcweir 532cdf0e10cSrcweir SIZE sz; 533cdf0e10cSrcweir vsAPI.GetThemePartSize(hTheme, hDC, iPart, iState, NULL, TS_MIN, &sz); 534cdf0e10cSrcweir vsAPI.GetThemePartSize(hTheme, hDC, iPart, iState, NULL, TS_TRUE, &sz); 535cdf0e10cSrcweir vsAPI.GetThemePartSize(hTheme, hDC, iPart, iState, NULL, TS_DRAW, &sz); 536cdf0e10cSrcweir 537cdf0e10cSrcweir hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 538cdf0e10cSrcweir // paint gripper on thumb if enough space 539cdf0e10cSrcweir if( ( (nPart == PART_THUMB_VERT) && (rc.bottom-rc.top > 12) ) || 540cdf0e10cSrcweir ( (nPart == PART_THUMB_HORZ) && (rc.right-rc.left > 12) ) ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir iPart = (nPart == PART_THUMB_HORZ) ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT; 543cdf0e10cSrcweir iState = 0; 544cdf0e10cSrcweir vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 545cdf0e10cSrcweir } 546cdf0e10cSrcweir return (hr == S_OK); 547cdf0e10cSrcweir } 548cdf0e10cSrcweir if( nPart == PART_TRACK_HORZ_LEFT || nPart == PART_TRACK_HORZ_RIGHT || nPart == PART_TRACK_VERT_UPPER || nPart == PART_TRACK_VERT_LOWER ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir switch( nPart ) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir case PART_TRACK_HORZ_LEFT: iPart = SBP_UPPERTRACKHORZ; break; 553cdf0e10cSrcweir case PART_TRACK_HORZ_RIGHT: iPart = SBP_LOWERTRACKHORZ; break; 554cdf0e10cSrcweir case PART_TRACK_VERT_UPPER: iPart = SBP_UPPERTRACKVERT; break; 555cdf0e10cSrcweir case PART_TRACK_VERT_LOWER: iPart = SBP_LOWERTRACKVERT; break; 556cdf0e10cSrcweir } 557cdf0e10cSrcweir 558cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 559cdf0e10cSrcweir iState = SCRBS_PRESSED; 560cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 561cdf0e10cSrcweir iState = SCRBS_DISABLED; 562cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 563cdf0e10cSrcweir iState = SCRBS_HOT; 564cdf0e10cSrcweir else 565cdf0e10cSrcweir iState = SCRBS_NORMAL; 566cdf0e10cSrcweir hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0); 567cdf0e10cSrcweir return (hr == S_OK); 568cdf0e10cSrcweir } 569cdf0e10cSrcweir } 570cdf0e10cSrcweir if( nType == CTRL_SPINBUTTONS && nPart == PART_ALL_BUTTONS ) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir if( aValue.getType() == CTRL_SPINBUTTONS ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir const SpinbuttonValue *pValue = static_cast<const SpinbuttonValue*>(&aValue); 575cdf0e10cSrcweir sal_Bool bOk = sal_False; 576cdf0e10cSrcweir 577cdf0e10cSrcweir RECT rect; 578cdf0e10cSrcweir ImplConvertSpinbuttonValues( pValue->mnUpperPart, pValue->mnUpperState, pValue->maUpperRect, &iPart, &iState, &rect ); 579cdf0e10cSrcweir bOk = ImplDrawTheme( hTheme, hDC, iPart, iState, rect, aCaption); 580cdf0e10cSrcweir 581cdf0e10cSrcweir if( bOk ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir ImplConvertSpinbuttonValues( pValue->mnLowerPart, pValue->mnLowerState, pValue->maLowerRect, &iPart, &iState, &rect ); 584cdf0e10cSrcweir bOk = ImplDrawTheme( hTheme, hDC, iPart, iState, rect, aCaption); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir 587cdf0e10cSrcweir return bOk; 588cdf0e10cSrcweir } 589cdf0e10cSrcweir } 590cdf0e10cSrcweir if( nType == CTRL_SPINBOX ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir // decrease spinbutton rects a little 593cdf0e10cSrcweir //rc.right--; 594cdf0e10cSrcweir //rc.bottom--; 595cdf0e10cSrcweir if( nPart == PART_ALL_BUTTONS ) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir if( aValue.getType() == CTRL_SPINBUTTONS ) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir const SpinbuttonValue *pValue = static_cast<const SpinbuttonValue*>(&aValue); 600cdf0e10cSrcweir sal_Bool bOk = sal_False; 601cdf0e10cSrcweir 602cdf0e10cSrcweir RECT rect; 603cdf0e10cSrcweir ImplConvertSpinbuttonValues( pValue->mnUpperPart, pValue->mnUpperState, pValue->maUpperRect, &iPart, &iState, &rect ); 604cdf0e10cSrcweir bOk = ImplDrawTheme( hTheme, hDC, iPart, iState, rect, aCaption); 605cdf0e10cSrcweir 606cdf0e10cSrcweir if( bOk ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir ImplConvertSpinbuttonValues( pValue->mnLowerPart, pValue->mnLowerState, pValue->maLowerRect, &iPart, &iState, &rect ); 609cdf0e10cSrcweir bOk = ImplDrawTheme( hTheme, hDC, iPart, iState, rect, aCaption); 610cdf0e10cSrcweir } 611cdf0e10cSrcweir 612cdf0e10cSrcweir return bOk; 613cdf0e10cSrcweir } 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir if( nPart == PART_BUTTON_DOWN ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir iPart = SPNP_DOWN; 619cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 620cdf0e10cSrcweir iState = DNS_PRESSED; 621cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 622cdf0e10cSrcweir iState = DNS_DISABLED; 623cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 624cdf0e10cSrcweir iState = DNS_HOT; 625cdf0e10cSrcweir else 626cdf0e10cSrcweir iState = DNS_NORMAL; 627cdf0e10cSrcweir } 628cdf0e10cSrcweir if( nPart == PART_BUTTON_UP ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir iPart = SPNP_UP; 631cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 632cdf0e10cSrcweir iState = UPS_PRESSED; 633cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 634cdf0e10cSrcweir iState = UPS_DISABLED; 635cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 636cdf0e10cSrcweir iState = UPS_HOT; 637cdf0e10cSrcweir else 638cdf0e10cSrcweir iState = UPS_NORMAL; 639cdf0e10cSrcweir } 640cdf0e10cSrcweir if( nPart == PART_BUTTON_RIGHT ) 641cdf0e10cSrcweir { 642cdf0e10cSrcweir iPart = SPNP_DOWNHORZ; 643cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 644cdf0e10cSrcweir iState = DNHZS_PRESSED; 645cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 646cdf0e10cSrcweir iState = DNHZS_DISABLED; 647cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 648cdf0e10cSrcweir iState = DNHZS_HOT; 649cdf0e10cSrcweir else 650cdf0e10cSrcweir iState = DNHZS_NORMAL; 651cdf0e10cSrcweir } 652cdf0e10cSrcweir if( nPart == PART_BUTTON_LEFT ) 653cdf0e10cSrcweir { 654cdf0e10cSrcweir iPart = SPNP_UPHORZ; 655cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 656cdf0e10cSrcweir iState = UPHZS_PRESSED; 657cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 658cdf0e10cSrcweir iState = UPHZS_DISABLED; 659cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 660cdf0e10cSrcweir iState = UPHZS_HOT; 661cdf0e10cSrcweir else 662cdf0e10cSrcweir iState = UPHZS_NORMAL; 663cdf0e10cSrcweir } 664cdf0e10cSrcweir if( nPart == PART_BUTTON_LEFT || nPart == PART_BUTTON_RIGHT || nPart == PART_BUTTON_UP || nPart == PART_BUTTON_DOWN ) 665cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir if( nType == CTRL_COMBOBOX ) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir if( nPart == PART_BUTTON_DOWN ) 670cdf0e10cSrcweir { 671cdf0e10cSrcweir iPart = CP_DROPDOWNBUTTON; 672cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 673cdf0e10cSrcweir iState = CBXS_PRESSED; 674cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 675cdf0e10cSrcweir iState = CBXS_DISABLED; 676cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 677cdf0e10cSrcweir iState = CBXS_HOT; 678cdf0e10cSrcweir else 679cdf0e10cSrcweir iState = CBXS_NORMAL; 680cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 681cdf0e10cSrcweir } 682cdf0e10cSrcweir } 683cdf0e10cSrcweir if( nType == CTRL_PUSHBUTTON ) 684cdf0e10cSrcweir { 685cdf0e10cSrcweir iPart = BP_PUSHBUTTON; 686cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 687cdf0e10cSrcweir iState = PBS_PRESSED; 688cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 689cdf0e10cSrcweir iState = PBS_DISABLED; 690cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 691cdf0e10cSrcweir iState = PBS_HOT; 692cdf0e10cSrcweir else if( nState & CTRL_STATE_DEFAULT ) 693cdf0e10cSrcweir iState = PBS_DEFAULTED; 694cdf0e10cSrcweir //else if( nState & CTRL_STATE_FOCUSED ) 695cdf0e10cSrcweir // iState = PBS_DEFAULTED; // may need to draw focus rect 696cdf0e10cSrcweir else 697cdf0e10cSrcweir iState = PBS_NORMAL; 698cdf0e10cSrcweir 699cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 700cdf0e10cSrcweir } 701cdf0e10cSrcweir 702cdf0e10cSrcweir if( nType == CTRL_RADIOBUTTON ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir iPart = BP_RADIOBUTTON; 705cdf0e10cSrcweir sal_Bool bChecked = ( aValue.getTristateVal() == BUTTONVALUE_ON ); 706cdf0e10cSrcweir 707cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 708cdf0e10cSrcweir iState = bChecked ? RBS_CHECKEDPRESSED : RBS_UNCHECKEDPRESSED; 709cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 710cdf0e10cSrcweir iState = bChecked ? RBS_CHECKEDDISABLED : RBS_UNCHECKEDDISABLED; 711cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 712cdf0e10cSrcweir iState = bChecked ? RBS_CHECKEDHOT : RBS_UNCHECKEDHOT; 713cdf0e10cSrcweir else 714cdf0e10cSrcweir iState = bChecked ? RBS_CHECKEDNORMAL : RBS_UNCHECKEDNORMAL; 715cdf0e10cSrcweir 716cdf0e10cSrcweir //if( nState & CTRL_STATE_FOCUSED ) 717cdf0e10cSrcweir // iState |= PBS_DEFAULTED; // may need to draw focus rect 718cdf0e10cSrcweir 719cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 720cdf0e10cSrcweir } 721cdf0e10cSrcweir 722cdf0e10cSrcweir if( nType == CTRL_CHECKBOX ) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir iPart = BP_CHECKBOX; 725cdf0e10cSrcweir ButtonValue v = aValue.getTristateVal(); 726cdf0e10cSrcweir 727cdf0e10cSrcweir if( nState & CTRL_STATE_PRESSED ) 728cdf0e10cSrcweir iState = (v == BUTTONVALUE_ON) ? CBS_CHECKEDPRESSED : 729cdf0e10cSrcweir ( (v == BUTTONVALUE_OFF) ? CBS_UNCHECKEDPRESSED : CBS_MIXEDPRESSED ); 730cdf0e10cSrcweir else if( !(nState & CTRL_STATE_ENABLED) ) 731cdf0e10cSrcweir iState = (v == BUTTONVALUE_ON) ? CBS_CHECKEDDISABLED : 732cdf0e10cSrcweir ( (v == BUTTONVALUE_OFF) ? CBS_UNCHECKEDDISABLED : CBS_MIXEDDISABLED ); 733cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 734cdf0e10cSrcweir iState = (v == BUTTONVALUE_ON) ? CBS_CHECKEDHOT : 735cdf0e10cSrcweir ( (v == BUTTONVALUE_OFF) ? CBS_UNCHECKEDHOT : CBS_MIXEDHOT ); 736cdf0e10cSrcweir else 737cdf0e10cSrcweir iState = (v == BUTTONVALUE_ON) ? CBS_CHECKEDNORMAL : 738cdf0e10cSrcweir ( (v == BUTTONVALUE_OFF) ? CBS_UNCHECKEDNORMAL : CBS_MIXEDNORMAL ); 739cdf0e10cSrcweir 740cdf0e10cSrcweir //if( nState & CTRL_STATE_FOCUSED ) 741cdf0e10cSrcweir // iState |= PBS_DEFAULTED; // may need to draw focus rect 742cdf0e10cSrcweir 743cdf0e10cSrcweir //SIZE sz; 744cdf0e10cSrcweir //THEMESIZE eSize = TS_DRAW; // TS_MIN, TS_TRUE, TS_DRAW 745cdf0e10cSrcweir //vsAPI.GetThemePartSize( hTheme, hDC, iPart, iState, &rc, eSize, &sz); 746cdf0e10cSrcweir 747cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir if( ( nType == CTRL_EDITBOX ) || ( nType == CTRL_MULTILINE_EDITBOX ) ) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir iPart = EP_EDITTEXT; 753cdf0e10cSrcweir if( !(nState & CTRL_STATE_ENABLED) ) 754cdf0e10cSrcweir iState = ETS_DISABLED; 755cdf0e10cSrcweir else if( nState & CTRL_STATE_FOCUSED ) 756cdf0e10cSrcweir iState = ETS_FOCUSED; 757cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 758cdf0e10cSrcweir iState = ETS_HOT; 759cdf0e10cSrcweir else 760cdf0e10cSrcweir iState = ETS_NORMAL; 761cdf0e10cSrcweir 762cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir if( nType == CTRL_LISTBOX ) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || nPart == PART_WINDOW ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir iPart = LVP_EMPTYTEXT; // ??? no idea which part to choose here 770cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 771cdf0e10cSrcweir } 772cdf0e10cSrcweir } 773cdf0e10cSrcweir 774cdf0e10cSrcweir if( nType == CTRL_TAB_PANE ) 775cdf0e10cSrcweir { 776cdf0e10cSrcweir iPart = TABP_PANE; 777cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 778cdf0e10cSrcweir } 779cdf0e10cSrcweir 780cdf0e10cSrcweir if( nType == CTRL_FIXEDBORDER ) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir /* 783cdf0e10cSrcweir iPart = BP_GROUPBOX; 784cdf0e10cSrcweir if( !(nState & CTRL_STATE_ENABLED) ) 785cdf0e10cSrcweir iState = GBS_DISABLED; 786cdf0e10cSrcweir else 787cdf0e10cSrcweir iState = GBS_NORMAL; 788cdf0e10cSrcweir */ 789cdf0e10cSrcweir // The fixed border is only used around the tools->options tabpage where 790cdf0e10cSrcweir // TABP_PANE fits best 791cdf0e10cSrcweir iPart = TABP_PANE; 792cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 793cdf0e10cSrcweir } 794cdf0e10cSrcweir 795cdf0e10cSrcweir if( nType == CTRL_TAB_BODY ) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir iPart = TABP_BODY; 798cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 799cdf0e10cSrcweir } 800cdf0e10cSrcweir 801cdf0e10cSrcweir if( nType == CTRL_TAB_ITEM ) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir iPart = TABP_TABITEMLEFTEDGE; 804cdf0e10cSrcweir rc.bottom--; 805cdf0e10cSrcweir 806cdf0e10cSrcweir OSL_ASSERT( aValue.getType() == CTRL_TAB_ITEM ); 807cdf0e10cSrcweir 808cdf0e10cSrcweir const TabitemValue *pValue = static_cast<const TabitemValue*>(&aValue); 809cdf0e10cSrcweir if( pValue->isBothAligned() ) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir iPart = TABP_TABITEMLEFTEDGE; 812cdf0e10cSrcweir rc.right--; 813cdf0e10cSrcweir } 814cdf0e10cSrcweir else if( pValue->isLeftAligned() ) 815cdf0e10cSrcweir iPart = TABP_TABITEMLEFTEDGE; 816cdf0e10cSrcweir else if( pValue->isRightAligned() ) 817cdf0e10cSrcweir iPart = TABP_TABITEMRIGHTEDGE; 818cdf0e10cSrcweir else iPart = TABP_TABITEM; 819cdf0e10cSrcweir 820cdf0e10cSrcweir if( !(nState & CTRL_STATE_ENABLED) ) 821cdf0e10cSrcweir iState = TILES_DISABLED; 822cdf0e10cSrcweir else if( nState & CTRL_STATE_SELECTED ) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir iState = TILES_SELECTED; 825cdf0e10cSrcweir // increase the selected tab 826cdf0e10cSrcweir rc.left-=2; 827cdf0e10cSrcweir if( pValue && !pValue->isBothAligned() ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir if( pValue->isLeftAligned() || pValue->isNotAligned() ) 830cdf0e10cSrcweir rc.right+=2; 831cdf0e10cSrcweir if( pValue->isRightAligned() ) 832cdf0e10cSrcweir rc.right+=1; 833cdf0e10cSrcweir } 834cdf0e10cSrcweir rc.top-=2; 835cdf0e10cSrcweir rc.bottom+=2; 836cdf0e10cSrcweir } 837cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 838cdf0e10cSrcweir iState = TILES_HOT; 839cdf0e10cSrcweir else if( nState & CTRL_STATE_FOCUSED ) 840cdf0e10cSrcweir iState = TILES_FOCUSED; // may need to draw focus rect 841cdf0e10cSrcweir else 842cdf0e10cSrcweir iState = TILES_NORMAL; 843cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 844cdf0e10cSrcweir } 845cdf0e10cSrcweir 846cdf0e10cSrcweir if( nType == CTRL_TOOLBAR ) 847cdf0e10cSrcweir { 848cdf0e10cSrcweir if( nPart == PART_BUTTON ) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir iPart = TP_BUTTON; 851cdf0e10cSrcweir sal_Bool bChecked = ( aValue.getTristateVal() == BUTTONVALUE_ON ); 852cdf0e10cSrcweir if( !(nState & CTRL_STATE_ENABLED) ) 853cdf0e10cSrcweir //iState = TS_DISABLED; 854cdf0e10cSrcweir // disabled buttons are typically not painted at all but we need visual 855cdf0e10cSrcweir // feedback when travelling by keyboard over disabled entries 856cdf0e10cSrcweir iState = TS_HOT; 857cdf0e10cSrcweir else if( nState & CTRL_STATE_PRESSED ) 858cdf0e10cSrcweir iState = TS_PRESSED; 859cdf0e10cSrcweir else if( nState & CTRL_STATE_ROLLOVER ) 860cdf0e10cSrcweir iState = bChecked ? TS_HOTCHECKED : TS_HOT; 861cdf0e10cSrcweir else 862cdf0e10cSrcweir iState = bChecked ? TS_CHECKED : TS_NORMAL; 863cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 864cdf0e10cSrcweir } 865cdf0e10cSrcweir else if( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT ) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir // the vertical gripper is not supported in most themes and it makes no 868cdf0e10cSrcweir // sense to only support horizontal gripper 869cdf0e10cSrcweir //iPart = (nPart == PART_THUMB_HORZ) ? RP_GRIPPERVERT : RP_GRIPPER; 870cdf0e10cSrcweir //return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 871cdf0e10cSrcweir } 872cdf0e10cSrcweir else if( nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT ) 873cdf0e10cSrcweir { 874cdf0e10cSrcweir if( aValue.getType() == CTRL_TOOLBAR ) 875cdf0e10cSrcweir { 876cdf0e10cSrcweir const ToolbarValue *pValue = static_cast<const ToolbarValue*>(&aValue); 877cdf0e10cSrcweir if( pValue->mbIsTopDockingArea ) 878cdf0e10cSrcweir rc.top = 0; // extend potential gradient to cover menu bar as well 879cdf0e10cSrcweir } 880cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 881cdf0e10cSrcweir } 882cdf0e10cSrcweir } 883cdf0e10cSrcweir 884cdf0e10cSrcweir if( nType == CTRL_MENUBAR ) 885cdf0e10cSrcweir { 886cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 887cdf0e10cSrcweir { 888cdf0e10cSrcweir if( aValue.getType() == CTRL_MENUBAR ) 889cdf0e10cSrcweir { 890cdf0e10cSrcweir const MenubarValue *pValue = static_cast<const MenubarValue*>(&aValue); 891cdf0e10cSrcweir rc.bottom += pValue->maTopDockingAreaHeight; // extend potential gradient to cover docking area as well 892cdf0e10cSrcweir } 893cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); 894cdf0e10cSrcweir } 895cdf0e10cSrcweir else if( nPart == PART_MENU_ITEM ) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir if( (nState & CTRL_STATE_ENABLED) ) 898cdf0e10cSrcweir iState = (nState & CTRL_STATE_SELECTED) ? MBI_HOT : MBI_NORMAL; 899cdf0e10cSrcweir else 900cdf0e10cSrcweir iState = (nState & CTRL_STATE_SELECTED) ? MBI_DISABLEDHOT : MBI_DISABLED; 901cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, MENU_BARITEM, iState, rc, aCaption ); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir } 904cdf0e10cSrcweir 905cdf0e10cSrcweir if( nType == CTRL_PROGRESS ) 906cdf0e10cSrcweir { 907cdf0e10cSrcweir if( nPart != PART_ENTIRE_CONTROL ) 908cdf0e10cSrcweir return FALSE; 909cdf0e10cSrcweir 910cdf0e10cSrcweir if( ! ImplDrawTheme( hTheme, hDC, PP_BAR, iState, rc, aCaption) ) 911cdf0e10cSrcweir return false; 912cdf0e10cSrcweir RECT aProgressRect = rc; 913cdf0e10cSrcweir if( vsAPI.GetThemeBackgroundContentRect( hTheme, hDC, PP_BAR, iState, &rc, &aProgressRect) != S_OK ) 914cdf0e10cSrcweir return false; 915cdf0e10cSrcweir 916cdf0e10cSrcweir long nProgressWidth = aValue.getNumericVal(); 917cdf0e10cSrcweir nProgressWidth *= (aProgressRect.right - aProgressRect.left); 918cdf0e10cSrcweir nProgressWidth /= (rc.right - rc.left); 919cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 920cdf0e10cSrcweir aProgressRect.left = aProgressRect.right - nProgressWidth; 921cdf0e10cSrcweir else 922cdf0e10cSrcweir aProgressRect.right = aProgressRect.left + nProgressWidth; 923cdf0e10cSrcweir 924cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, PP_CHUNK, iState, aProgressRect, aCaption ); 925cdf0e10cSrcweir } 926cdf0e10cSrcweir 927cdf0e10cSrcweir if( nType == CTRL_SLIDER ) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir iPart = (nPart == PART_TRACK_HORZ_AREA) ? TKP_TRACK : TKP_TRACKVERT; 930cdf0e10cSrcweir iState = (nPart == PART_TRACK_HORZ_AREA) ? TRS_NORMAL : TRVS_NORMAL; 931cdf0e10cSrcweir 932cdf0e10cSrcweir Rectangle aTrackRect = ImplGetThemeRect( hTheme, hDC, iPart, iState, Rectangle() ); 933cdf0e10cSrcweir RECT aTRect = rc; 934cdf0e10cSrcweir if( nPart == PART_TRACK_HORZ_AREA ) 935cdf0e10cSrcweir { 936cdf0e10cSrcweir long nH = aTrackRect.GetHeight(); 937cdf0e10cSrcweir aTRect.top += (rc.bottom - rc.top - nH)/2; 938cdf0e10cSrcweir aTRect.bottom = aTRect.top + nH; 939cdf0e10cSrcweir } 940cdf0e10cSrcweir else 941cdf0e10cSrcweir { 942cdf0e10cSrcweir long nW = aTrackRect.GetWidth(); 943cdf0e10cSrcweir aTRect.left += (rc.right - rc.left - nW)/2; 944cdf0e10cSrcweir aTRect.right = aTRect.left + nW; 945cdf0e10cSrcweir } 946cdf0e10cSrcweir ImplDrawTheme( hTheme, hDC, iPart, iState, aTRect, aCaption ); 947cdf0e10cSrcweir 948cdf0e10cSrcweir RECT aThumbRect; 949cdf0e10cSrcweir OSL_ASSERT( aValue.getType() == CTRL_SLIDER ); 950cdf0e10cSrcweir const SliderValue* pVal = static_cast<const SliderValue*>(&aValue); 951cdf0e10cSrcweir aThumbRect.left = pVal->maThumbRect.Left(); 952cdf0e10cSrcweir aThumbRect.top = pVal->maThumbRect.Top(); 953cdf0e10cSrcweir aThumbRect.right = pVal->maThumbRect.Right(); 954cdf0e10cSrcweir aThumbRect.bottom = pVal->maThumbRect.Bottom(); 955cdf0e10cSrcweir iPart = (nPart == PART_TRACK_HORZ_AREA) ? TKP_THUMB : TKP_THUMBVERT; 956cdf0e10cSrcweir iState = (nState & CTRL_STATE_ENABLED) ? TUS_NORMAL : TUS_DISABLED; 957cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, aThumbRect, aCaption ); 958cdf0e10cSrcweir } 959cdf0e10cSrcweir 960cdf0e10cSrcweir if( nType == CTRL_LISTNODE ) 961cdf0e10cSrcweir { 962cdf0e10cSrcweir if( nPart != PART_ENTIRE_CONTROL ) 963cdf0e10cSrcweir return FALSE; 964cdf0e10cSrcweir 965cdf0e10cSrcweir ButtonValue aButtonValue = aValue.getTristateVal(); 966cdf0e10cSrcweir iPart = TVP_GLYPH; 967cdf0e10cSrcweir switch( aButtonValue ) 968cdf0e10cSrcweir { 969cdf0e10cSrcweir case BUTTONVALUE_ON: 970cdf0e10cSrcweir iState = GLPS_OPENED; 971cdf0e10cSrcweir break; 972cdf0e10cSrcweir case BUTTONVALUE_OFF: 973cdf0e10cSrcweir iState = GLPS_CLOSED; 974cdf0e10cSrcweir break; 975cdf0e10cSrcweir default: 976cdf0e10cSrcweir return FALSE; 977cdf0e10cSrcweir } 978cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption ); 979cdf0e10cSrcweir } 980cdf0e10cSrcweir 981cdf0e10cSrcweir if( GetSalData()->mbThemeMenuSupport ) 982cdf0e10cSrcweir { 983cdf0e10cSrcweir if( nType == CTRL_MENU_POPUP ) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 986cdf0e10cSrcweir { 987cdf0e10cSrcweir RECT aGutterRC = rc; 988cdf0e10cSrcweir aGutterRC.left += aValue.getNumericVal(); 989cdf0e10cSrcweir aGutterRC.right = aGutterRC.left+3; 990cdf0e10cSrcweir return 991cdf0e10cSrcweir ImplDrawTheme( hTheme, hDC, MENU_POPUPBACKGROUND, 0, rc, aCaption ) && 992cdf0e10cSrcweir ImplDrawTheme( hTheme, hDC, MENU_POPUPGUTTER, 0, aGutterRC, aCaption ) 993cdf0e10cSrcweir ; 994cdf0e10cSrcweir } 995cdf0e10cSrcweir else if( nPart == PART_MENU_ITEM ) 996cdf0e10cSrcweir { 997cdf0e10cSrcweir if( (nState & CTRL_STATE_ENABLED) ) 998cdf0e10cSrcweir iState = (nState & CTRL_STATE_SELECTED) ? MPI_HOT : MPI_NORMAL; 999cdf0e10cSrcweir else 1000cdf0e10cSrcweir iState = (nState & CTRL_STATE_SELECTED) ? MPI_DISABLEDHOT : MPI_DISABLED; 1001cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, MENU_POPUPITEM, iState, rc, aCaption ); 1002cdf0e10cSrcweir } 1003cdf0e10cSrcweir else if( nPart == PART_MENU_ITEM_CHECK_MARK || nPart == PART_MENU_ITEM_RADIO_MARK ) 1004cdf0e10cSrcweir { 1005cdf0e10cSrcweir if( (nState & CTRL_STATE_PRESSED) ) 1006cdf0e10cSrcweir { 1007cdf0e10cSrcweir RECT aBGRect = rc; 1008cdf0e10cSrcweir if( aValue.getType() == CTRL_MENU_POPUP ) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir const MenupopupValue& rMVal( static_cast<const MenupopupValue&>(aValue) ); 1011cdf0e10cSrcweir aBGRect.left = rMVal.maItemRect.Left(); 1012cdf0e10cSrcweir aBGRect.top = rMVal.maItemRect.Top(); 1013cdf0e10cSrcweir aBGRect.bottom = rMVal.maItemRect.Bottom()+1; // see below in drawNativeControl 1014cdf0e10cSrcweir aBGRect.right = rMVal.getNumericVal(); 1015cdf0e10cSrcweir 1016cdf0e10cSrcweir // FIXME: magic 1017cdf0e10cSrcweir aBGRect.left += 1; aBGRect.top += 1; aBGRect.bottom +=1; 1018cdf0e10cSrcweir } 1019cdf0e10cSrcweir iState = (nState & CTRL_STATE_ENABLED) ? MCB_NORMAL : MCB_DISABLED; 1020cdf0e10cSrcweir ImplDrawTheme( hTheme, hDC, MENU_POPUPCHECKBACKGROUND, iState, aBGRect, aCaption ); 1021cdf0e10cSrcweir if( nPart == PART_MENU_ITEM_CHECK_MARK ) 1022cdf0e10cSrcweir iState = (nState & CTRL_STATE_ENABLED) ? MC_CHECKMARKNORMAL : MC_CHECKMARKDISABLED; 1023cdf0e10cSrcweir else 1024cdf0e10cSrcweir iState = (nState & CTRL_STATE_ENABLED) ? MC_BULLETNORMAL : MC_BULLETDISABLED; 1025cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, MENU_POPUPCHECK, iState, rc, aCaption ); 1026cdf0e10cSrcweir } 1027cdf0e10cSrcweir else 1028cdf0e10cSrcweir return true; // unchecked: do nothing 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir else if( nPart == PART_MENU_SEPARATOR ) 1031cdf0e10cSrcweir { 1032cdf0e10cSrcweir rc.left += aValue.getNumericVal(); // adjust for gutter position 1033cdf0e10cSrcweir Rectangle aRect( ImplGetThemeRect( hTheme, hDC, 1034cdf0e10cSrcweir MENU_POPUPSEPARATOR, 0, Rectangle( rc.left, rc.top, rc.right, rc.bottom ) ) ); 1035cdf0e10cSrcweir // center the separator inside the passed rectangle 1036cdf0e10cSrcweir long nDY = ((rc.bottom - rc.top + 1) - aRect.GetHeight()) / 2; 1037cdf0e10cSrcweir rc.top += nDY; 1038cdf0e10cSrcweir rc.bottom = rc.top+aRect.GetHeight()-1; 1039cdf0e10cSrcweir return ImplDrawTheme( hTheme, hDC, MENU_POPUPSEPARATOR, 0, rc, aCaption ); 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir } 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir return false; 1045cdf0e10cSrcweir } 1046cdf0e10cSrcweir 1047cdf0e10cSrcweir /* 1048cdf0e10cSrcweir * DrawNativeControl() 1049cdf0e10cSrcweir * 1050cdf0e10cSrcweir * Draws the requested control described by nPart/nState. 1051cdf0e10cSrcweir * 1052cdf0e10cSrcweir * rControlRegion: The bounding region of the complete control in VCL frame coordinates. 1053cdf0e10cSrcweir * aValue: An optional value (tristate/numerical/string) 1054cdf0e10cSrcweir * aCaption: A caption or title string (like button text etc) 1055cdf0e10cSrcweir */ 1056cdf0e10cSrcweir sal_Bool WinSalGraphics::drawNativeControl( ControlType nType, 1057cdf0e10cSrcweir ControlPart nPart, 1058cdf0e10cSrcweir const Rectangle& rControlRegion, 1059cdf0e10cSrcweir ControlState nState, 1060cdf0e10cSrcweir const ImplControlValue& aValue, 1061cdf0e10cSrcweir const OUString& aCaption ) 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir sal_Bool bOk = false; 1064cdf0e10cSrcweir HTHEME hTheme = NULL; 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir switch( nType ) 1067cdf0e10cSrcweir { 1068cdf0e10cSrcweir case CTRL_PUSHBUTTON: 1069cdf0e10cSrcweir case CTRL_RADIOBUTTON: 1070cdf0e10cSrcweir case CTRL_CHECKBOX: 1071cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Button"); 1072cdf0e10cSrcweir break; 1073cdf0e10cSrcweir case CTRL_SCROLLBAR: 1074cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Scrollbar"); 1075cdf0e10cSrcweir break; 1076cdf0e10cSrcweir case CTRL_COMBOBOX: 1077cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 1078cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Edit"); 1079cdf0e10cSrcweir else if( nPart == PART_BUTTON_DOWN ) 1080cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Combobox"); 1081cdf0e10cSrcweir break; 1082cdf0e10cSrcweir case CTRL_SPINBOX: 1083cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 1084cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Edit"); 1085cdf0e10cSrcweir else 1086cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Spin"); 1087cdf0e10cSrcweir break; 1088cdf0e10cSrcweir case CTRL_SPINBUTTONS: 1089cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Spin"); 1090cdf0e10cSrcweir break; 1091cdf0e10cSrcweir case CTRL_EDITBOX: 1092cdf0e10cSrcweir case CTRL_MULTILINE_EDITBOX: 1093cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Edit"); 1094cdf0e10cSrcweir break; 1095cdf0e10cSrcweir case CTRL_LISTBOX: 1096cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || nPart == PART_WINDOW ) 1097cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Listview"); 1098cdf0e10cSrcweir else if( nPart == PART_BUTTON_DOWN ) 1099cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Combobox"); 1100cdf0e10cSrcweir break; 1101cdf0e10cSrcweir case CTRL_TAB_PANE: 1102cdf0e10cSrcweir case CTRL_TAB_BODY: 1103cdf0e10cSrcweir case CTRL_TAB_ITEM: 1104cdf0e10cSrcweir case CTRL_FIXEDBORDER: 1105cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Tab"); 1106cdf0e10cSrcweir break; 1107cdf0e10cSrcweir case CTRL_TOOLBAR: 1108cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || nPart == PART_BUTTON ) 1109cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Toolbar"); 1110cdf0e10cSrcweir else 1111cdf0e10cSrcweir // use rebar for grip and background 1112cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Rebar"); 1113cdf0e10cSrcweir break; 1114cdf0e10cSrcweir case CTRL_MENUBAR: 1115cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 1116cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Rebar"); 1117cdf0e10cSrcweir else if( GetSalData()->mbThemeMenuSupport ) 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir if( nPart == PART_MENU_ITEM ) 1120cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Menu" ); 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir break; 1123cdf0e10cSrcweir case CTRL_PROGRESS: 1124cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 1125cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Progress"); 1126cdf0e10cSrcweir break; 1127cdf0e10cSrcweir case CTRL_LISTNODE: 1128cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL ) 1129cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"TreeView"); 1130cdf0e10cSrcweir break; 1131cdf0e10cSrcweir case CTRL_SLIDER: 1132cdf0e10cSrcweir if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) 1133cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Trackbar" ); 1134cdf0e10cSrcweir break; 1135cdf0e10cSrcweir case CTRL_MENU_POPUP: 1136cdf0e10cSrcweir if( GetSalData()->mbThemeMenuSupport ) 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir if( nPart == PART_ENTIRE_CONTROL || nPart == PART_MENU_ITEM || 1139cdf0e10cSrcweir nPart == PART_MENU_ITEM_CHECK_MARK || nPart == PART_MENU_ITEM_RADIO_MARK || 1140cdf0e10cSrcweir nPart == PART_MENU_SEPARATOR 1141cdf0e10cSrcweir ) 1142cdf0e10cSrcweir hTheme = getThemeHandle( mhWnd, L"Menu" ); 1143cdf0e10cSrcweir } 1144cdf0e10cSrcweir break; 1145cdf0e10cSrcweir default: 1146cdf0e10cSrcweir hTheme = NULL; 1147cdf0e10cSrcweir break; 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir if( !hTheme ) 1151cdf0e10cSrcweir return false; 1152cdf0e10cSrcweir 1153cdf0e10cSrcweir Rectangle buttonRect = rControlRegion; 1154cdf0e10cSrcweir RECT rc; 1155cdf0e10cSrcweir rc.left = buttonRect.Left(); 1156cdf0e10cSrcweir rc.right = buttonRect.Right()+1; 1157cdf0e10cSrcweir rc.top = buttonRect.Top(); 1158cdf0e10cSrcweir rc.bottom = buttonRect.Bottom()+1; 1159cdf0e10cSrcweir 1160cdf0e10cSrcweir // set default text alignment 1161cdf0e10cSrcweir int ta = SetTextAlign( mhDC, TA_LEFT|TA_TOP|TA_NOUPDATECP ); 1162cdf0e10cSrcweir 1163cdf0e10cSrcweir OUString aCaptionStr( aCaption.replace('~', '&') ); // translate mnemonics 1164cdf0e10cSrcweir bOk = ImplDrawNativeControl(mhDC, hTheme, rc, 1165cdf0e10cSrcweir nType, nPart, nState, aValue, 1166cdf0e10cSrcweir aCaptionStr ); 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir // restore alignment 1169cdf0e10cSrcweir SetTextAlign( mhDC, ta ); 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir 1172cdf0e10cSrcweir //GdiFlush(); 1173cdf0e10cSrcweir 1174cdf0e10cSrcweir return bOk; 1175cdf0e10cSrcweir } 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir 1178cdf0e10cSrcweir /* 1179cdf0e10cSrcweir * DrawNativeControlText() 1180cdf0e10cSrcweir * 1181cdf0e10cSrcweir * OPTIONAL. Draws the requested text for the control described by nPart/nState. 1182cdf0e10cSrcweir * Used if text not drawn by DrawNativeControl(). 1183cdf0e10cSrcweir * 1184cdf0e10cSrcweir * rControlRegion: The bounding region of the complete control in VCL frame coordinates. 1185cdf0e10cSrcweir * aValue: An optional value (tristate/numerical/string) 1186cdf0e10cSrcweir * aCaption: A caption or title string (like button text etc) 1187cdf0e10cSrcweir */ 1188cdf0e10cSrcweir sal_Bool WinSalGraphics::drawNativeControlText( ControlType, 1189cdf0e10cSrcweir ControlPart, 1190cdf0e10cSrcweir const Rectangle&, 1191cdf0e10cSrcweir ControlState, 1192cdf0e10cSrcweir const ImplControlValue&, 1193cdf0e10cSrcweir const OUString& ) 1194cdf0e10cSrcweir { 1195cdf0e10cSrcweir return( false ); 1196cdf0e10cSrcweir } 1197cdf0e10cSrcweir 1198cdf0e10cSrcweir 1199cdf0e10cSrcweir /* 1200cdf0e10cSrcweir * GetNativeControlRegion() 1201cdf0e10cSrcweir * 1202cdf0e10cSrcweir * If the return value is TRUE, rNativeBoundingRegion 1203cdf0e10cSrcweir * contains the true bounding region covered by the control 1204cdf0e10cSrcweir * including any adornment, while rNativeContentRegion contains the area 1205cdf0e10cSrcweir * within the control that can be safely drawn into without drawing over 1206cdf0e10cSrcweir * the borders of the control. 1207cdf0e10cSrcweir * 1208cdf0e10cSrcweir * rControlRegion: The bounding region of the control in VCL frame coordinates. 1209cdf0e10cSrcweir * aValue: An optional value (tristate/numerical/string) 1210cdf0e10cSrcweir * aCaption: A caption or title string (like button text etc) 1211cdf0e10cSrcweir */ 1212cdf0e10cSrcweir sal_Bool WinSalGraphics::getNativeControlRegion( ControlType nType, 1213cdf0e10cSrcweir ControlPart nPart, 1214cdf0e10cSrcweir const Rectangle& rControlRegion, 1215cdf0e10cSrcweir ControlState nState, 1216cdf0e10cSrcweir const ImplControlValue& rControlValue, 1217cdf0e10cSrcweir const OUString&, 1218cdf0e10cSrcweir Rectangle &rNativeBoundingRegion, 1219cdf0e10cSrcweir Rectangle &rNativeContentRegion ) 1220cdf0e10cSrcweir { 1221cdf0e10cSrcweir sal_Bool bRet = FALSE; 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir HDC hDC = GetDC( mhWnd ); 1224cdf0e10cSrcweir if( nType == CTRL_TOOLBAR ) 1225cdf0e10cSrcweir { 1226cdf0e10cSrcweir if( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT ) 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir /* 1229cdf0e10cSrcweir // the vertical gripper is not supported in most themes and it makes no 1230cdf0e10cSrcweir // sense to only support horizontal gripper 1231cdf0e10cSrcweir 1232cdf0e10cSrcweir HTHEME hTheme = getThemeHandle( mhWnd, L"Rebar"); 1233cdf0e10cSrcweir if( hTheme ) 1234cdf0e10cSrcweir { 1235cdf0e10cSrcweir Rectangle aRect( ImplGetThemeRect( hTheme, hDC, nPart == PART_THUMB_HORZ ? RP_GRIPPERVERT : RP_GRIPPER, 1236cdf0e10cSrcweir 0, rControlRegion.GetBoundRect() ) ); 1237cdf0e10cSrcweir if( nPart == PART_THUMB_HORZ && !aRect.IsEmpty() ) 1238cdf0e10cSrcweir { 1239cdf0e10cSrcweir Rectangle aVertRect( 0, 0, aRect.getHeight(), aRect.getWidth() ); 1240cdf0e10cSrcweir rNativeContentRegion = aVertRect; 1241cdf0e10cSrcweir } 1242cdf0e10cSrcweir else 1243cdf0e10cSrcweir rNativeContentRegion = aRect; 1244cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1245cdf0e10cSrcweir if( !rNativeContentRegion.IsEmpty() ) 1246cdf0e10cSrcweir bRet = TRUE; 1247cdf0e10cSrcweir } 1248cdf0e10cSrcweir */ 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir if( nPart == PART_BUTTON ) 1251cdf0e10cSrcweir { 1252cdf0e10cSrcweir HTHEME hTheme = getThemeHandle( mhWnd, L"Toolbar"); 1253cdf0e10cSrcweir if( hTheme ) 1254cdf0e10cSrcweir { 1255cdf0e10cSrcweir Rectangle aRect( ImplGetThemeRect( hTheme, hDC, TP_SPLITBUTTONDROPDOWN, 1256cdf0e10cSrcweir TS_HOT, rControlRegion ) ); 1257cdf0e10cSrcweir rNativeContentRegion = aRect; 1258cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1259cdf0e10cSrcweir if( !rNativeContentRegion.IsEmpty() ) 1260cdf0e10cSrcweir bRet = TRUE; 1261cdf0e10cSrcweir } 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir } 1264cdf0e10cSrcweir if( nType == CTRL_PROGRESS && nPart == PART_ENTIRE_CONTROL ) 1265cdf0e10cSrcweir { 1266cdf0e10cSrcweir HTHEME hTheme = getThemeHandle( mhWnd, L"Progress"); 1267cdf0e10cSrcweir if( hTheme ) 1268cdf0e10cSrcweir { 1269cdf0e10cSrcweir Rectangle aRect( ImplGetThemeRect( hTheme, hDC, PP_BAR, 1270cdf0e10cSrcweir 0, rControlRegion ) ); 1271cdf0e10cSrcweir rNativeContentRegion = aRect; 1272cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1273cdf0e10cSrcweir if( !rNativeContentRegion.IsEmpty() ) 1274cdf0e10cSrcweir bRet = TRUE; 1275cdf0e10cSrcweir } 1276cdf0e10cSrcweir } 1277cdf0e10cSrcweir if( (nType == CTRL_LISTBOX || nType == CTRL_COMBOBOX ) && nPart == PART_ENTIRE_CONTROL ) 1278cdf0e10cSrcweir { 1279cdf0e10cSrcweir HTHEME hTheme = getThemeHandle( mhWnd, L"Combobox"); 1280cdf0e10cSrcweir if( hTheme ) 1281cdf0e10cSrcweir { 1282cdf0e10cSrcweir Rectangle aBoxRect( rControlRegion ); 1283cdf0e10cSrcweir Rectangle aRect( ImplGetThemeRect( hTheme, hDC, CP_DROPDOWNBUTTON, 1284cdf0e10cSrcweir CBXS_NORMAL, aBoxRect ) ); 1285cdf0e10cSrcweir if( aRect.GetHeight() > aBoxRect.GetHeight() ) 1286cdf0e10cSrcweir aBoxRect.Bottom() = aBoxRect.Top() + aRect.GetHeight(); 1287cdf0e10cSrcweir if( aRect.GetWidth() > aBoxRect.GetWidth() ) 1288cdf0e10cSrcweir aBoxRect.Right() = aBoxRect.Left() + aRect.GetWidth(); 1289cdf0e10cSrcweir rNativeContentRegion = aBoxRect; 1290cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1291cdf0e10cSrcweir if( !aRect.IsEmpty() ) 1292cdf0e10cSrcweir bRet = TRUE; 1293cdf0e10cSrcweir } 1294cdf0e10cSrcweir } 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir if( (nType == CTRL_EDITBOX || nType == CTRL_SPINBOX) && nPart == PART_ENTIRE_CONTROL ) 1297cdf0e10cSrcweir { 1298cdf0e10cSrcweir HTHEME hTheme = getThemeHandle( mhWnd, L"Edit"); 1299cdf0e10cSrcweir if( hTheme ) 1300cdf0e10cSrcweir { 1301cdf0e10cSrcweir // get border size 1302cdf0e10cSrcweir Rectangle aBoxRect( rControlRegion ); 1303cdf0e10cSrcweir Rectangle aRect( ImplGetThemeRect( hTheme, hDC, EP_BACKGROUNDWITHBORDER, 1304cdf0e10cSrcweir EBWBS_HOT, aBoxRect ) ); 1305cdf0e10cSrcweir // ad app font height 1306cdf0e10cSrcweir NONCLIENTMETRICSW aNonClientMetrics; 1307cdf0e10cSrcweir aNonClientMetrics.cbSize = sizeof( aNonClientMetrics ); 1308cdf0e10cSrcweir if ( SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, sizeof( aNonClientMetrics ), &aNonClientMetrics, 0 ) ) 1309cdf0e10cSrcweir { 1310cdf0e10cSrcweir long nFontHeight = aNonClientMetrics.lfMessageFont.lfHeight; 1311cdf0e10cSrcweir if( nFontHeight < 0 ) 1312cdf0e10cSrcweir nFontHeight = -nFontHeight; 1313cdf0e10cSrcweir 1314cdf0e10cSrcweir if( aRect.GetHeight() && nFontHeight ) 1315cdf0e10cSrcweir { 1316cdf0e10cSrcweir aRect.Bottom() += aRect.GetHeight(); 1317cdf0e10cSrcweir aRect.Bottom() += nFontHeight; 1318cdf0e10cSrcweir if( aRect.GetHeight() > aBoxRect.GetHeight() ) 1319cdf0e10cSrcweir aBoxRect.Bottom() = aBoxRect.Top() + aRect.GetHeight(); 1320cdf0e10cSrcweir if( aRect.GetWidth() > aBoxRect.GetWidth() ) 1321cdf0e10cSrcweir aBoxRect.Right() = aBoxRect.Left() + aRect.GetWidth(); 1322cdf0e10cSrcweir rNativeContentRegion = aBoxRect; 1323cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1324cdf0e10cSrcweir bRet = TRUE; 1325cdf0e10cSrcweir } 1326cdf0e10cSrcweir } 1327cdf0e10cSrcweir } 1328cdf0e10cSrcweir } 1329cdf0e10cSrcweir 1330cdf0e10cSrcweir if( GetSalData()->mbThemeMenuSupport ) 1331cdf0e10cSrcweir { 1332cdf0e10cSrcweir if( nType == CTRL_MENU_POPUP ) 1333cdf0e10cSrcweir { 1334cdf0e10cSrcweir if( nPart == PART_MENU_ITEM_CHECK_MARK || 1335cdf0e10cSrcweir nPart == PART_MENU_ITEM_RADIO_MARK ) 1336cdf0e10cSrcweir { 1337cdf0e10cSrcweir HTHEME hTheme = getThemeHandle( mhWnd, L"Menu"); 1338cdf0e10cSrcweir Rectangle aBoxRect( rControlRegion ); 1339cdf0e10cSrcweir Rectangle aRect( ImplGetThemeRect( hTheme, hDC, 1340cdf0e10cSrcweir MENU_POPUPCHECK, 1341cdf0e10cSrcweir MC_CHECKMARKNORMAL, 1342cdf0e10cSrcweir aBoxRect ) ); 1343cdf0e10cSrcweir if( aBoxRect.GetWidth() && aBoxRect.GetHeight() ) 1344cdf0e10cSrcweir { 1345cdf0e10cSrcweir rNativeContentRegion = aRect; 1346cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1347cdf0e10cSrcweir bRet = TRUE; 1348cdf0e10cSrcweir } 1349cdf0e10cSrcweir } 1350cdf0e10cSrcweir } 1351cdf0e10cSrcweir } 1352cdf0e10cSrcweir 1353cdf0e10cSrcweir if( nType == CTRL_SLIDER && ( (nPart == PART_THUMB_HORZ) || (nPart == PART_THUMB_VERT) ) ) 1354cdf0e10cSrcweir { 1355cdf0e10cSrcweir HTHEME hTheme = getThemeHandle( mhWnd, L"Trackbar"); 1356cdf0e10cSrcweir if( hTheme ) 1357cdf0e10cSrcweir { 1358cdf0e10cSrcweir int iPart = (nPart == PART_THUMB_HORZ) ? TKP_THUMB : TKP_THUMBVERT; 1359cdf0e10cSrcweir int iState = (nPart == PART_THUMB_HORZ) ? TUS_NORMAL : TUVS_NORMAL; 1360cdf0e10cSrcweir Rectangle aThumbRect = ImplGetThemeRect( hTheme, hDC, iPart, iState, Rectangle() ); 1361cdf0e10cSrcweir if( nPart == PART_THUMB_HORZ ) 1362cdf0e10cSrcweir { 1363cdf0e10cSrcweir long nW = aThumbRect.GetWidth(); 1364cdf0e10cSrcweir Rectangle aRect( rControlRegion ); 1365cdf0e10cSrcweir aRect.Right() = aRect.Left() + nW - 1; 1366cdf0e10cSrcweir rNativeContentRegion = aRect; 1367cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1368cdf0e10cSrcweir } 1369cdf0e10cSrcweir else 1370cdf0e10cSrcweir { 1371cdf0e10cSrcweir long nH = aThumbRect.GetHeight(); 1372cdf0e10cSrcweir Rectangle aRect( rControlRegion ); 1373cdf0e10cSrcweir aRect.Bottom() = aRect.Top() + nH - 1; 1374cdf0e10cSrcweir rNativeContentRegion = aRect; 1375cdf0e10cSrcweir rNativeBoundingRegion = rNativeContentRegion; 1376cdf0e10cSrcweir } 1377cdf0e10cSrcweir bRet = TRUE; 1378cdf0e10cSrcweir } 1379cdf0e10cSrcweir } 1380cdf0e10cSrcweir 1381cdf0e10cSrcweir if ( ( nType == CTRL_TAB_ITEM ) && ( nPart == PART_ENTIRE_CONTROL ) ) 1382cdf0e10cSrcweir { 1383cdf0e10cSrcweir Rectangle aControlRect( rControlRegion ); 1384cdf0e10cSrcweir rNativeContentRegion = aControlRect; 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir --aControlRect.Bottom(); 1387cdf0e10cSrcweir 1388cdf0e10cSrcweir if( rControlValue.getType() == CTRL_TAB_ITEM ) 1389cdf0e10cSrcweir { 1390cdf0e10cSrcweir const TabitemValue *pValue = static_cast<const TabitemValue*>(&rControlValue); 1391cdf0e10cSrcweir if ( pValue->isBothAligned() ) 1392cdf0e10cSrcweir --aControlRect.Right(); 1393cdf0e10cSrcweir 1394cdf0e10cSrcweir if ( nState & CTRL_STATE_SELECTED ) 1395cdf0e10cSrcweir { 1396cdf0e10cSrcweir aControlRect.Left() -= 2; 1397cdf0e10cSrcweir if ( pValue && !pValue->isBothAligned() ) 1398cdf0e10cSrcweir { 1399cdf0e10cSrcweir if ( pValue->isLeftAligned() || pValue->isNotAligned() ) 1400cdf0e10cSrcweir aControlRect.Right() += 2; 1401cdf0e10cSrcweir if ( pValue->isRightAligned() ) 1402cdf0e10cSrcweir aControlRect.Right() += 1; 1403cdf0e10cSrcweir } 1404cdf0e10cSrcweir aControlRect.Top() -= 2; 1405cdf0e10cSrcweir aControlRect.Bottom() += 2; 1406cdf0e10cSrcweir } 1407cdf0e10cSrcweir } 1408cdf0e10cSrcweir rNativeBoundingRegion = aControlRect; 1409cdf0e10cSrcweir bRet = TRUE; 1410cdf0e10cSrcweir } 1411cdf0e10cSrcweir 1412cdf0e10cSrcweir ReleaseDC( mhWnd, hDC ); 1413cdf0e10cSrcweir return( bRet ); 1414cdf0e10cSrcweir } 1415cdf0e10cSrcweir 1416