merge the formfield patch from ooo-build
[ooovba.git] / vcl / win / source / window / salobj.cxx
blob649edf9e6fb0249788ca15a9b3a21f3b88756897
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salobj.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <string.h>
36 #ifndef _SVWIN_HXX
37 #include <tools/svwin.h>
38 #endif
39 #include <wincomp.hxx>
40 #include <saldata.hxx>
41 #include <salinst.h>
42 #include <salframe.h>
43 #include <salobj.h>
44 #include <tools/debug.hxx>
46 // =======================================================================
48 static BOOL ImplIsSysWindowOrChild( HWND hWndParent, HWND hWndChild )
50 if ( hWndParent == hWndChild )
51 return TRUE;
53 HWND hTempWnd = ::GetParent( hWndChild );
54 while ( hTempWnd )
56 // Ab nicht Child-Fenstern hoeren wir auf zu suchen
57 if ( !(GetWindowStyle( hTempWnd ) & WS_CHILD) )
58 return FALSE;
59 if ( hTempWnd == hWndParent )
60 return TRUE;
61 hTempWnd = ::GetParent( hTempWnd );
64 return FALSE;
67 // -----------------------------------------------------------------------
69 WinSalObject* ImplFindSalObject( HWND hWndChild )
71 SalData* pSalData = GetSalData();
72 WinSalObject* pObject = pSalData->mpFirstObject;
73 while ( pObject )
75 if ( ImplIsSysWindowOrChild( pObject->mhWndChild, hWndChild ) )
76 return pObject;
78 pObject = pObject->mpNextObject;
81 return NULL;
84 // -----------------------------------------------------------------------
86 WinSalFrame* ImplFindSalObjectFrame( HWND hWnd )
88 WinSalFrame* pFrame = NULL;
89 WinSalObject* pObject = ImplFindSalObject( hWnd );
90 if ( pObject )
92 // Dazugehoerenden Frame suchen
93 HWND hWnd = ::GetParent( pObject->mhWnd );
94 pFrame = GetSalData()->mpFirstFrame;
95 while ( pFrame )
97 if ( pFrame->mhWnd == hWnd )
98 break;
100 pFrame = pFrame->mpNextFrame;
104 return pFrame;
107 // -----------------------------------------------------------------------
109 LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
111 // Used for Unicode and none Unicode
112 SalData* pSalData = GetSalData();
114 if ( (nCode >= 0) && lParam )
116 CWPSTRUCT* pData = (CWPSTRUCT*)lParam;
117 if ( (pData->message != WM_KEYDOWN) &&
118 (pData->message != WM_KEYUP) )
119 pSalData->mnSalObjWantKeyEvt = 0;
121 // Testen, ob wir Daten fuer ein SalObject-Fenster behandeln
122 // muessen
123 WinSalObject* pObject;
124 if ( pData->message == WM_SETFOCUS )
126 pObject = ImplFindSalObject( pData->hwnd );
127 if ( pObject )
129 pObject->mhLastFocusWnd = pData->hwnd;
130 if ( ImplSalYieldMutexTryToAcquire() )
132 pObject->CallCallback( SALOBJ_EVENT_GETFOCUS, 0 );
133 ImplSalYieldMutexRelease();
135 else
136 ImplPostMessage( pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
139 else if ( pData->message == WM_KILLFOCUS )
141 pObject = ImplFindSalObject( pData->hwnd );
142 if ( pObject && !ImplFindSalObject( (HWND)pData->wParam ) )
144 // LoseFocus nur rufen, wenn wirklich kein ChildFenster
145 // den Focus bekommt
146 if ( !pData->wParam || !ImplFindSalObject( (HWND)pData->wParam ) )
148 if ( ImplSalYieldMutexTryToAcquire() )
150 pObject->CallCallback( SALOBJ_EVENT_LOSEFOCUS, 0 );
151 ImplSalYieldMutexRelease();
153 else
154 ImplPostMessage( pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
156 else
157 pObject->mhLastFocusWnd = (HWND)pData->wParam;
162 return CallNextHookEx( pSalData->mhSalObjMsgHook, nCode, wParam, lParam );
165 // -----------------------------------------------------------------------
167 BOOL ImplSalPreDispatchMsg( MSG* pMsg )
169 // Used for Unicode and none Unicode
170 SalData* pSalData = GetSalData();
171 WinSalObject* pObject;
173 if ( (pMsg->message == WM_LBUTTONDOWN) ||
174 (pMsg->message == WM_RBUTTONDOWN) ||
175 (pMsg->message == WM_MBUTTONDOWN) )
177 ImplSalYieldMutexAcquireWithWait();
178 pObject = ImplFindSalObject( pMsg->hwnd );
179 if ( pObject && !pObject->IsMouseTransparent() )
180 ImplPostMessage( pObject->mhWnd, SALOBJ_MSG_TOTOP, 0, 0 );
181 ImplSalYieldMutexRelease();
184 if ( (pMsg->message == WM_KEYDOWN) ||
185 (pMsg->message == WM_KEYUP) )
187 // KeyEvents wollen wir nach Moeglichkeit auch abarbeiten,
188 // wenn das Control diese nicht selber auswertet
189 // SysKeys werden als WM_SYSCOMMAND verarbeitet
190 // Char-Events verarbeiten wir nicht, da wir nur
191 // Accelerator relevante Keys verarbeiten wollen
192 BOOL bWantedKeyCode = FALSE;
193 // A-Z, 0-9 nur in Verbindung mit Control-Taste
194 if ( ((pMsg->wParam >= 65) && (pMsg->wParam <= 90)) ||
195 ((pMsg->wParam >= 48) && (pMsg->wParam <= 57)) )
197 if ( GetKeyState( VK_CONTROL ) & 0x8000 )
198 bWantedKeyCode = TRUE;
200 else if ( ((pMsg->wParam >= VK_F1) && (pMsg->wParam <= VK_F24)) ||
201 ((pMsg->wParam >= VK_SPACE) && (pMsg->wParam <= VK_HELP)) ||
202 (pMsg->wParam == VK_BACK) || (pMsg->wParam == VK_TAB) ||
203 (pMsg->wParam == VK_CLEAR) || (pMsg->wParam == VK_RETURN) ||
204 (pMsg->wParam == VK_ESCAPE) )
205 bWantedKeyCode = TRUE;
206 if ( bWantedKeyCode )
208 ImplSalYieldMutexAcquireWithWait();
209 pObject = ImplFindSalObject( pMsg->hwnd );
210 if ( pObject )
211 pSalData->mnSalObjWantKeyEvt = pMsg->wParam;
212 ImplSalYieldMutexRelease();
215 // Hier WM_SYSCHAR abfangen, um mit Alt+Taste evtl. Menu zu aktivieren
216 else if ( pMsg->message == WM_SYSCHAR )
218 pSalData->mnSalObjWantKeyEvt = 0;
220 USHORT nKeyCode = LOWORD( pMsg->wParam );
221 // Nur 0-9 und A-Z
222 if ( ((nKeyCode >= 48) && (nKeyCode <= 57)) ||
223 ((nKeyCode >= 65) && (nKeyCode <= 90)) ||
224 ((nKeyCode >= 97) && (nKeyCode <= 122)) )
226 BOOL bRet = FALSE;
227 ImplSalYieldMutexAcquireWithWait();
228 pObject = ImplFindSalObject( pMsg->hwnd );
229 if ( pObject )
231 if ( pMsg->hwnd == ::GetFocus() )
233 WinSalFrame* pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
234 if ( pFrame )
236 if ( ImplHandleSalObjSysCharMsg( pFrame->mhWnd, pMsg->wParam, pMsg->lParam ) )
237 bRet = TRUE;
241 ImplSalYieldMutexRelease();
242 if ( bRet )
243 return TRUE;
246 else
247 pSalData->mnSalObjWantKeyEvt = 0;
249 return FALSE;
252 // -----------------------------------------------------------------------
254 void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT /* nDispatchResult */ )
256 // Used for Unicode and none Unicode
257 SalData* pSalData = GetSalData();
258 WinSalFrame* pFrame;
260 if ( (pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) )
262 if ( pSalData->mnSalObjWantKeyEvt == pMsg->wParam )
264 pSalData->mnSalObjWantKeyEvt = 0;
265 if ( pMsg->hwnd == ::GetFocus() )
267 ImplSalYieldMutexAcquireWithWait();
268 pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
269 if ( pFrame )
270 ImplHandleSalObjKeyMsg( pFrame->mhWnd, pMsg->message, pMsg->wParam, pMsg->lParam );
271 ImplSalYieldMutexRelease();
276 pSalData->mnSalObjWantKeyEvt = 0;
279 // =======================================================================
281 LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
283 WinSalObject* pSysObj;
284 LRESULT nRet = 0;
286 switch( nMsg )
288 case WM_ERASEBKGND:
289 nRet = 1;
290 rDef = FALSE;
291 break;
292 case WM_PAINT:
294 PAINTSTRUCT aPs;
295 BeginPaint( hWnd, &aPs );
296 EndPaint( hWnd, &aPs );
297 rDef = FALSE;
299 break;
301 case WM_PARENTNOTIFY:
303 UINT nNotifyMsg = LOWORD( wParam );
304 if ( (nNotifyMsg == WM_LBUTTONDOWN) ||
305 (nNotifyMsg == WM_RBUTTONDOWN) ||
306 (nNotifyMsg == WM_MBUTTONDOWN) )
308 ImplSalYieldMutexAcquireWithWait();
309 pSysObj = GetSalObjWindowPtr( hWnd );
310 if ( pSysObj && !pSysObj->IsMouseTransparent() )
311 pSysObj->CallCallback( SALOBJ_EVENT_TOTOP, 0 );
312 ImplSalYieldMutexRelease();
315 break;
317 case WM_MOUSEACTIVATE:
319 ImplSalYieldMutexAcquireWithWait();
320 pSysObj = GetSalObjWindowPtr( hWnd );
321 if ( pSysObj && !pSysObj->IsMouseTransparent() )
322 ImplPostMessage( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
323 ImplSalYieldMutexRelease();
325 break;
327 case SALOBJ_MSG_TOTOP:
328 if ( ImplSalYieldMutexTryToAcquire() )
330 pSysObj = GetSalObjWindowPtr( hWnd );
331 pSysObj->CallCallback( SALOBJ_EVENT_TOTOP, 0 );
332 ImplSalYieldMutexRelease();
333 rDef = FALSE;
335 else
336 ImplPostMessage( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
337 break;
339 case SALOBJ_MSG_POSTFOCUS:
340 if ( ImplSalYieldMutexTryToAcquire() )
342 pSysObj = GetSalObjWindowPtr( hWnd );
343 HWND hFocusWnd = ::GetFocus();
344 USHORT nEvent;
345 if ( hFocusWnd && ImplIsSysWindowOrChild( hWnd, hFocusWnd ) )
346 nEvent = SALOBJ_EVENT_GETFOCUS;
347 else
348 nEvent = SALOBJ_EVENT_LOSEFOCUS;
349 pSysObj->CallCallback( nEvent, 0 );
350 ImplSalYieldMutexRelease();
352 else
353 ImplPostMessage( hWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
354 rDef = FALSE;
355 break;
357 case WM_SIZE:
359 HWND hWndChild = GetWindow( hWnd, GW_CHILD );
360 if ( hWndChild )
362 SetWindowPos( hWndChild,
363 0, 0, 0, (int)LOWORD( lParam ), (int)HIWORD( lParam ),
364 SWP_NOZORDER | SWP_NOACTIVATE );
367 rDef = FALSE;
368 break;
370 case WM_CREATE:
372 // Window-Instanz am Windowhandle speichern
373 // Can also be used for the W-Version, because the struct
374 // to access lpCreateParams is the same structure
375 CREATESTRUCTA* pStruct = (CREATESTRUCTA*)lParam;
376 pSysObj = (WinSalObject*)pStruct->lpCreateParams;
377 SetSalObjWindowPtr( hWnd, pSysObj );
378 // HWND schon hier setzen, da schon auf den Instanzdaten
379 // gearbeitet werden kann, wenn Messages waehrend
380 // CreateWindow() gesendet werden
381 pSysObj->mhWnd = hWnd;
382 rDef = FALSE;
384 break;
387 return nRet;
390 LRESULT CALLBACK SalSysObjWndProcA( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
392 int bDef = TRUE;
393 LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef );
394 if ( bDef )
395 nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam );
396 return nRet;
399 LRESULT CALLBACK SalSysObjWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
401 int bDef = TRUE;
402 LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef );
403 if ( bDef )
404 nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
405 return nRet;
408 // -----------------------------------------------------------------------
410 LRESULT CALLBACK SalSysObjChildWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
412 LRESULT nRet = 0;
414 switch( nMsg )
416 // Wegen PlugIn's loeschen wir erstmal den Hintergrund
417 case WM_ERASEBKGND:
419 WinSalObject* pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
421 if( pSysObj && !pSysObj->IsEraseBackgroundEnabled() )
423 // do not erase background
424 nRet = 1;
425 rDef = FALSE;
428 break;
430 case WM_PAINT:
432 PAINTSTRUCT aPs;
433 BeginPaint( hWnd, &aPs );
434 EndPaint( hWnd, &aPs );
435 rDef = FALSE;
437 break;
439 case WM_MOUSEMOVE:
440 case WM_LBUTTONDOWN:
441 case WM_MBUTTONDOWN:
442 case WM_RBUTTONDOWN:
443 case WM_LBUTTONUP:
444 case WM_MBUTTONUP:
445 case WM_RBUTTONUP:
447 WinSalObject* pSysObj;
448 pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
450 if( pSysObj && pSysObj->IsMouseTransparent() )
452 // forward mouse events to parent frame
453 HWND hWndParent = ::GetParent( pSysObj->mhWnd );
455 // transform coordinates
456 POINT pt;
457 pt.x = (long) LOWORD( lParam );
458 pt.y = (long) HIWORD( lParam );
459 MapWindowPoints( hWnd, hWndParent, &pt, 1 );
460 lParam = MAKELPARAM( (WORD) pt.x, (WORD) pt.y );
462 nRet = ImplSendMessage( hWndParent, nMsg, wParam, lParam );
463 rDef = FALSE;
466 break;
469 return nRet;
472 LRESULT CALLBACK SalSysObjChildWndProcA( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
474 int bDef = TRUE;
475 LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef );
476 if ( bDef )
477 nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam );
478 return nRet;
481 LRESULT CALLBACK SalSysObjChildWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
483 int bDef = TRUE;
484 LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef );
485 if ( bDef )
486 nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
487 return nRet;
490 // =======================================================================
492 SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent )
494 SalData* pSalData = GetSalData();
496 // Hook installieren, wenn es das erste SalObject ist
497 if ( !pSalData->mpFirstObject )
499 if ( aSalShlData.mbWNT )
501 pSalData->mhSalObjMsgHook = SetWindowsHookExW( WH_CALLWNDPROC,
502 SalSysMsgProc,
503 pSalData->mhInst,
504 pSalData->mnAppThreadId );
506 else
508 pSalData->mhSalObjMsgHook = SetWindowsHookExA( WH_CALLWNDPROC,
509 SalSysMsgProc,
510 pSalData->mhInst,
511 pSalData->mnAppThreadId );
515 if ( !pSalData->mbObjClassInit )
517 // #95301# shockwave plugin has bug; expects ASCII functions to be used
518 if ( false )//aSalShlData.mbWNT )
520 WNDCLASSEXW aWndClassEx;
521 aWndClassEx.cbSize = sizeof( aWndClassEx );
522 aWndClassEx.style = 0;
523 aWndClassEx.lpfnWndProc = SalSysObjWndProcW;
524 aWndClassEx.cbClsExtra = 0;
525 aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA;
526 aWndClassEx.hInstance = pSalData->mhInst;
527 aWndClassEx.hIcon = 0;
528 aWndClassEx.hIconSm = 0;
529 aWndClassEx.hCursor = LoadCursor( 0, IDC_ARROW );
530 aWndClassEx.hbrBackground = 0;
531 aWndClassEx.lpszMenuName = 0;
532 aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEW;
533 if ( RegisterClassExW( &aWndClassEx ) )
535 // Wegen PlugIn's loeschen wir erstmal den Hintergrund
536 aWndClassEx.cbWndExtra = 0;
537 aWndClassEx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
538 aWndClassEx.lpfnWndProc = SalSysObjChildWndProcW;
539 aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEW;
540 if ( RegisterClassExW( &aWndClassEx ) )
541 pSalData->mbObjClassInit = TRUE;
544 else
546 WNDCLASSEXA aWndClassEx;
547 aWndClassEx.cbSize = sizeof( aWndClassEx );
548 aWndClassEx.style = 0;
549 aWndClassEx.lpfnWndProc = SalSysObjWndProcA;
550 aWndClassEx.cbClsExtra = 0;
551 aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA;
552 aWndClassEx.hInstance = pSalData->mhInst;
553 aWndClassEx.hIcon = 0;
554 aWndClassEx.hIconSm = 0;
555 aWndClassEx.hCursor = LoadCursor( 0, IDC_ARROW );
556 aWndClassEx.hbrBackground = 0;
557 aWndClassEx.lpszMenuName = 0;
558 aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEA;
559 if ( RegisterClassExA( &aWndClassEx ) )
561 // Wegen PlugIn's loeschen wir erstmal den Hintergrund
562 aWndClassEx.cbWndExtra = 0;
563 aWndClassEx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
564 aWndClassEx.lpfnWndProc = SalSysObjChildWndProcA;
565 aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEA;
566 if ( RegisterClassExA( &aWndClassEx ) )
567 pSalData->mbObjClassInit = TRUE;
572 if ( pSalData->mbObjClassInit )
574 WinSalObject* pObject = new WinSalObject;
576 // #135235# Clip siblings of this
577 // SystemChildWindow. Otherwise, DXCanvas (using a hidden
578 // SystemChildWindow) clobbers applets/plugins during
579 // animations .
580 HWND hWnd = CreateWindowExA( 0, SAL_OBJECT_CLASSNAMEA, "",
581 WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0,
582 pParent->mhWnd, 0,
583 pInst->mhInst, (void*)pObject );
585 HWND hWndChild = 0;
586 if ( hWnd )
588 // #135235# Explicitely stack SystemChildWindows in
589 // the order they're created - since there's no notion
590 // of zorder.
591 SetWindowPos(hWnd,HWND_TOP,0,0,0,0,
592 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOSIZE);
593 hWndChild = CreateWindowExA( 0, SAL_OBJECT_CHILDCLASSNAMEA, "",
594 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
595 0, 0, 0, 0,
596 hWnd, 0,
597 pInst->mhInst, NULL );
600 if ( !hWndChild )
602 delete pObject;
603 return NULL;
606 if ( hWnd )
608 pObject->mhWnd = hWnd;
609 pObject->mhWndChild = hWndChild;
610 pObject->maSysData.hWnd = hWndChild;
611 return pObject;
615 return NULL;
618 // =======================================================================
620 WinSalObject::WinSalObject()
622 SalData* pSalData = GetSalData();
624 mhWnd = 0;
625 mhWndChild = 0;
626 mhLastFocusWnd = 0;
627 maSysData.nSize = sizeof( SystemEnvData );
628 mpStdClipRgnData = NULL;
630 // Insert object in objectlist
631 mpNextObject = pSalData->mpFirstObject;
632 pSalData->mpFirstObject = this;
635 // -----------------------------------------------------------------------
637 WinSalObject::~WinSalObject()
639 SalData* pSalData = GetSalData();
641 // remove frame from framelist
642 if ( this == pSalData->mpFirstObject )
644 pSalData->mpFirstObject = mpNextObject;
646 // Wenn letztes SalObject, dann Hook wieder entfernen
647 if ( !pSalData->mpFirstObject )
648 UnhookWindowsHookEx( pSalData->mhSalObjMsgHook );
650 else
652 WinSalObject* pTempObject = pSalData->mpFirstObject;
653 while ( pTempObject->mpNextObject != this )
654 pTempObject = pTempObject->mpNextObject;
656 pTempObject->mpNextObject = mpNextObject;
659 // Cache-Daten zerstoeren
660 if ( mpStdClipRgnData )
661 delete mpStdClipRgnData;
663 HWND hWndParent = ::GetParent( mhWnd );
665 if ( mhWndChild )
666 DestroyWindow( mhWndChild );
667 if ( mhWnd )
668 DestroyWindow( mhWnd );
670 // Palette wieder zuruecksetzen, wenn kein externes Child-Fenster
671 // mehr vorhanden ist, da diese unsere Palette ueberschrieben haben
672 // koennen
673 if ( hWndParent &&
674 ::GetActiveWindow() == hWndParent &&
675 !GetWindow( hWndParent, GW_CHILD ) )
676 ImplSendMessage( hWndParent, SAL_MSG_FORCEPALETTE, 0, 0 );
679 // -----------------------------------------------------------------------
681 void WinSalObject::ResetClipRegion()
683 SetWindowRgn( mhWnd, 0, TRUE );
686 // -----------------------------------------------------------------------
688 USHORT WinSalObject::GetClipRegionType()
690 return SAL_OBJECT_CLIP_INCLUDERECTS;
693 // -----------------------------------------------------------------------
695 void WinSalObject::BeginSetClipRegion( ULONG nRectCount )
697 ULONG nRectBufSize = sizeof(RECT)*nRectCount;
698 if ( nRectCount < SAL_CLIPRECT_COUNT )
700 if ( !mpStdClipRgnData )
701 mpStdClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+(SAL_CLIPRECT_COUNT*sizeof(RECT))];
702 mpClipRgnData = mpStdClipRgnData;
704 else
705 mpClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+nRectBufSize];
706 mpClipRgnData->rdh.dwSize = sizeof( RGNDATAHEADER );
707 mpClipRgnData->rdh.iType = RDH_RECTANGLES;
708 mpClipRgnData->rdh.nCount = nRectCount;
709 mpClipRgnData->rdh.nRgnSize = nRectBufSize;
710 SetRectEmpty( &(mpClipRgnData->rdh.rcBound) );
711 mpNextClipRect = (RECT*)(&(mpClipRgnData->Buffer));
712 mbFirstClipRect = TRUE;
715 // -----------------------------------------------------------------------
717 void WinSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
719 RECT* pRect = mpNextClipRect;
720 RECT* pBoundRect = &(mpClipRgnData->rdh.rcBound);
721 long nRight = nX + nWidth;
722 long nBottom = nY + nHeight;
724 if ( mbFirstClipRect )
726 pBoundRect->left = nX;
727 pBoundRect->top = nY;
728 pBoundRect->right = nRight;
729 pBoundRect->bottom = nBottom;
730 mbFirstClipRect = FALSE;
732 else
734 if ( nX < pBoundRect->left )
735 pBoundRect->left = (int)nX;
737 if ( nY < pBoundRect->top )
738 pBoundRect->top = (int)nY;
740 if ( nRight > pBoundRect->right )
741 pBoundRect->right = (int)nRight;
743 if ( nBottom > pBoundRect->bottom )
744 pBoundRect->bottom = (int)nBottom;
747 pRect->left = (int)nX;
748 pRect->top = (int)nY;
749 pRect->right = (int)nRight;
750 pRect->bottom = (int)nBottom;
751 mpNextClipRect++;
754 // -----------------------------------------------------------------------
756 void WinSalObject::EndSetClipRegion()
758 HRGN hRegion;
760 // Aus den Region-Daten muessen wir jetzt eine ClipRegion erzeugen
761 if ( mpClipRgnData->rdh.nCount == 1 )
763 RECT* pRect = &(mpClipRgnData->rdh.rcBound);
764 hRegion = CreateRectRgn( pRect->left, pRect->top,
765 pRect->right, pRect->bottom );
767 else
769 ULONG nSize = mpClipRgnData->rdh.nRgnSize+sizeof(RGNDATAHEADER);
770 hRegion = ExtCreateRegion( NULL, nSize, mpClipRgnData );
771 if ( mpClipRgnData != mpStdClipRgnData )
772 delete [] (BYTE*)mpClipRgnData;
775 DBG_ASSERT( hRegion, "SalObject::EndSetClipRegion() - Can't create ClipRegion" );
776 SetWindowRgn( mhWnd, hRegion, TRUE );
779 // -----------------------------------------------------------------------
781 void WinSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight )
783 ULONG nStyle = 0;
784 BOOL bVisible = (GetWindowStyle( mhWnd ) & WS_VISIBLE) != 0;
785 if ( bVisible )
787 ShowWindow( mhWnd, SW_HIDE );
788 nStyle |= SWP_SHOWWINDOW;
790 SetWindowPos( mhWnd, 0,
791 (int)nX, (int)nY, (int)nWidth, (int)nHeight,
792 SWP_NOZORDER | SWP_NOACTIVATE | nStyle );
795 // -----------------------------------------------------------------------
797 void WinSalObject::Show( BOOL bVisible )
799 if ( bVisible )
800 ShowWindow( mhWnd, SW_SHOWNORMAL );
801 else
802 ShowWindow( mhWnd, SW_HIDE );
805 // -----------------------------------------------------------------------
807 void WinSalObject::Enable( BOOL bEnable )
809 EnableWindow( mhWnd, bEnable );
812 // -----------------------------------------------------------------------
814 void WinSalObject::GrabFocus()
816 if ( mhLastFocusWnd &&
817 IsWindow( mhLastFocusWnd ) &&
818 ImplIsSysWindowOrChild( mhWndChild, mhLastFocusWnd ) )
819 ::SetFocus( mhLastFocusWnd );
820 else
821 ::SetFocus( mhWndChild );
824 // -----------------------------------------------------------------------
826 void WinSalObject::SetBackground()
830 // -----------------------------------------------------------------------
832 void WinSalObject::SetBackground( SalColor )
836 // -----------------------------------------------------------------------
838 const SystemEnvData* WinSalObject::GetSystemData() const
840 return &maSysData;