19f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
59f62ea84SAndrew Rist * distributed with this work for additional information
69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
109f62ea84SAndrew Rist *
119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129f62ea84SAndrew Rist *
139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist * software distributed under the License is distributed on an
159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
179f62ea84SAndrew Rist * specific language governing permissions and limitations
189f62ea84SAndrew Rist * under the License.
199f62ea84SAndrew Rist *
209f62ea84SAndrew Rist *************************************************************/
219f62ea84SAndrew Rist
229f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <string.h>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <tools/svwin.h>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <vcl/svapp.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <win/wincomp.hxx>
35cdf0e10cSrcweir #include <win/saldata.hxx>
36cdf0e10cSrcweir #include <win/salinst.h>
37cdf0e10cSrcweir #include <win/salframe.h>
38cdf0e10cSrcweir #include <win/salobj.h>
39cdf0e10cSrcweir
40cdf0e10cSrcweir // =======================================================================
41cdf0e10cSrcweir
ImplIsSysWindowOrChild(HWND hWndParent,HWND hWndChild)42cdf0e10cSrcweir static sal_Bool ImplIsSysWindowOrChild( HWND hWndParent, HWND hWndChild )
43cdf0e10cSrcweir {
44cdf0e10cSrcweir if ( hWndParent == hWndChild )
45cdf0e10cSrcweir return TRUE;
46cdf0e10cSrcweir
47cdf0e10cSrcweir HWND hTempWnd = ::GetParent( hWndChild );
48cdf0e10cSrcweir while ( hTempWnd )
49cdf0e10cSrcweir {
50cdf0e10cSrcweir // Ab nicht Child-Fenstern hoeren wir auf zu suchen
51cdf0e10cSrcweir if ( !(GetWindowStyle( hTempWnd ) & WS_CHILD) )
52cdf0e10cSrcweir return FALSE;
53cdf0e10cSrcweir if ( hTempWnd == hWndParent )
54cdf0e10cSrcweir return TRUE;
55cdf0e10cSrcweir hTempWnd = ::GetParent( hTempWnd );
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
58cdf0e10cSrcweir return FALSE;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
61cdf0e10cSrcweir // -----------------------------------------------------------------------
62cdf0e10cSrcweir
ImplFindSalObject(HWND hWndChild)63cdf0e10cSrcweir WinSalObject* ImplFindSalObject( HWND hWndChild )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir SalData* pSalData = GetSalData();
66cdf0e10cSrcweir WinSalObject* pObject = pSalData->mpFirstObject;
67cdf0e10cSrcweir while ( pObject )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir if ( ImplIsSysWindowOrChild( pObject->mhWndChild, hWndChild ) )
70cdf0e10cSrcweir return pObject;
71cdf0e10cSrcweir
72cdf0e10cSrcweir pObject = pObject->mpNextObject;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir return NULL;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir // -----------------------------------------------------------------------
79cdf0e10cSrcweir
ImplFindSalObjectFrame(HWND hWnd)80cdf0e10cSrcweir WinSalFrame* ImplFindSalObjectFrame( HWND hWnd )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir WinSalFrame* pFrame = NULL;
83cdf0e10cSrcweir WinSalObject* pObject = ImplFindSalObject( hWnd );
84cdf0e10cSrcweir if ( pObject )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir // Dazugehoerenden Frame suchen
87cdf0e10cSrcweir HWND hWnd = ::GetParent( pObject->mhWnd );
88cdf0e10cSrcweir pFrame = GetSalData()->mpFirstFrame;
89cdf0e10cSrcweir while ( pFrame )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir if ( pFrame->mhWnd == hWnd )
92cdf0e10cSrcweir break;
93cdf0e10cSrcweir
94cdf0e10cSrcweir pFrame = pFrame->mpNextFrame;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir return pFrame;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir // -----------------------------------------------------------------------
102cdf0e10cSrcweir
ImplInterceptChildWindowKeyDown(MSG & rMsg)103cdf0e10cSrcweir sal_Bool ImplInterceptChildWindowKeyDown( MSG& rMsg )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir sal_Bool bResult = sal_False;
106cdf0e10cSrcweir if ( rMsg.message == WM_KEYDOWN )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir wchar_t pClassName[10];
109cdf0e10cSrcweir sal_Int32 nLen = GetClassNameW( rMsg.hwnd, pClassName, 10 );
110cdf0e10cSrcweir if ( !( nLen == 9 && wcsncmp( pClassName, SAL_OBJECT_CLASSNAMEW, nLen ) == 0 ) )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir // look for the first SalObject in the parent hierarchy
113cdf0e10cSrcweir HWND hWin = rMsg.hwnd;
114cdf0e10cSrcweir HWND hLastOLEWindow = hWin;
115cdf0e10cSrcweir WinSalObject* pSalObj = NULL;
116cdf0e10cSrcweir do
117cdf0e10cSrcweir {
118cdf0e10cSrcweir hLastOLEWindow = hWin;
119cdf0e10cSrcweir hWin = ::GetParent( hWin );
120cdf0e10cSrcweir if ( hWin )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir nLen = GetClassNameW( hWin, pClassName, 10 );
123cdf0e10cSrcweir if ( nLen == 9 && wcsncmp( pClassName, SAL_OBJECT_CLASSNAMEW, nLen ) == 0 )
124cdf0e10cSrcweir pSalObj = GetSalObjWindowPtr( hWin );
125cdf0e10cSrcweir }
126cdf0e10cSrcweir } while( hWin && !pSalObj );
127cdf0e10cSrcweir
128cdf0e10cSrcweir if ( pSalObj && pSalObj->mbInterceptChildWindowKeyDown && pSalObj->maSysData.hWnd )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir bResult = ( 1 == ImplSendMessage( pSalObj->maSysData.hWnd, rMsg.message, rMsg.wParam, rMsg.lParam ) );
131cdf0e10cSrcweir }
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir return bResult;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir // -----------------------------------------------------------------------
139cdf0e10cSrcweir
140cdf0e10cSrcweir
141cdf0e10cSrcweir // -----------------------------------------------------------------------
142cdf0e10cSrcweir
SalSysMsgProc(int nCode,WPARAM wParam,LPARAM lParam)143cdf0e10cSrcweir LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir // Used for Unicode and none Unicode
146cdf0e10cSrcweir SalData* pSalData = GetSalData();
147cdf0e10cSrcweir
148cdf0e10cSrcweir if ( (nCode >= 0) && lParam )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir CWPSTRUCT* pData = (CWPSTRUCT*)lParam;
151cdf0e10cSrcweir if ( (pData->message != WM_KEYDOWN) &&
152cdf0e10cSrcweir (pData->message != WM_KEYUP) )
153cdf0e10cSrcweir pSalData->mnSalObjWantKeyEvt = 0;
154cdf0e10cSrcweir
155cdf0e10cSrcweir // Testen, ob wir Daten fuer ein SalObject-Fenster behandeln
156cdf0e10cSrcweir // muessen
157cdf0e10cSrcweir WinSalObject* pObject;
158cdf0e10cSrcweir if ( pData->message == WM_SETFOCUS )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir pObject = ImplFindSalObject( pData->hwnd );
161cdf0e10cSrcweir if ( pObject )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir pObject->mhLastFocusWnd = pData->hwnd;
164cdf0e10cSrcweir if ( ImplSalYieldMutexTryToAcquire() )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir pObject->CallCallback( SALOBJ_EVENT_GETFOCUS, 0 );
167cdf0e10cSrcweir ImplSalYieldMutexRelease();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir else
170cdf0e10cSrcweir ImplPostMessage( pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir else if ( pData->message == WM_KILLFOCUS )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir pObject = ImplFindSalObject( pData->hwnd );
176cdf0e10cSrcweir if ( pObject && !ImplFindSalObject( (HWND)pData->wParam ) )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir // LoseFocus nur rufen, wenn wirklich kein ChildFenster
179cdf0e10cSrcweir // den Focus bekommt
180cdf0e10cSrcweir if ( !pData->wParam || !ImplFindSalObject( (HWND)pData->wParam ) )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir if ( ImplSalYieldMutexTryToAcquire() )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir pObject->CallCallback( SALOBJ_EVENT_LOSEFOCUS, 0 );
185cdf0e10cSrcweir ImplSalYieldMutexRelease();
186cdf0e10cSrcweir }
187cdf0e10cSrcweir else
188cdf0e10cSrcweir ImplPostMessage( pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir else
191cdf0e10cSrcweir pObject->mhLastFocusWnd = (HWND)pData->wParam;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir }
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
196cdf0e10cSrcweir return CallNextHookEx( pSalData->mhSalObjMsgHook, nCode, wParam, lParam );
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir // -----------------------------------------------------------------------
200cdf0e10cSrcweir
ImplSalPreDispatchMsg(MSG * pMsg)201cdf0e10cSrcweir sal_Bool ImplSalPreDispatchMsg( MSG* pMsg )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir // Used for Unicode and none Unicode
204cdf0e10cSrcweir SalData* pSalData = GetSalData();
205cdf0e10cSrcweir WinSalObject* pObject;
206cdf0e10cSrcweir
207cdf0e10cSrcweir if ( (pMsg->message == WM_LBUTTONDOWN) ||
208cdf0e10cSrcweir (pMsg->message == WM_RBUTTONDOWN) ||
209cdf0e10cSrcweir (pMsg->message == WM_MBUTTONDOWN) )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir ImplSalYieldMutexAcquireWithWait();
212cdf0e10cSrcweir pObject = ImplFindSalObject( pMsg->hwnd );
213cdf0e10cSrcweir if ( pObject && !pObject->IsMouseTransparent() )
214cdf0e10cSrcweir ImplPostMessage( pObject->mhWnd, SALOBJ_MSG_TOTOP, 0, 0 );
215cdf0e10cSrcweir ImplSalYieldMutexRelease();
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir if ( (pMsg->message == WM_KEYDOWN) ||
219cdf0e10cSrcweir (pMsg->message == WM_KEYUP) )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir // KeyEvents wollen wir nach Moeglichkeit auch abarbeiten,
222cdf0e10cSrcweir // wenn das Control diese nicht selber auswertet
223cdf0e10cSrcweir // SysKeys werden als WM_SYSCOMMAND verarbeitet
224cdf0e10cSrcweir // Char-Events verarbeiten wir nicht, da wir nur
225cdf0e10cSrcweir // Accelerator relevante Keys verarbeiten wollen
226cdf0e10cSrcweir sal_Bool bWantedKeyCode = FALSE;
227cdf0e10cSrcweir // A-Z, 0-9 nur in Verbindung mit Control-Taste
228cdf0e10cSrcweir if ( ((pMsg->wParam >= 65) && (pMsg->wParam <= 90)) ||
229cdf0e10cSrcweir ((pMsg->wParam >= 48) && (pMsg->wParam <= 57)) )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir if ( GetKeyState( VK_CONTROL ) & 0x8000 )
232cdf0e10cSrcweir bWantedKeyCode = TRUE;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir else if ( ((pMsg->wParam >= VK_F1) && (pMsg->wParam <= VK_F24)) ||
235cdf0e10cSrcweir ((pMsg->wParam >= VK_SPACE) && (pMsg->wParam <= VK_HELP)) ||
236cdf0e10cSrcweir (pMsg->wParam == VK_BACK) || (pMsg->wParam == VK_TAB) ||
237cdf0e10cSrcweir (pMsg->wParam == VK_CLEAR) || (pMsg->wParam == VK_RETURN) ||
238cdf0e10cSrcweir (pMsg->wParam == VK_ESCAPE) )
239cdf0e10cSrcweir bWantedKeyCode = TRUE;
240cdf0e10cSrcweir if ( bWantedKeyCode )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir ImplSalYieldMutexAcquireWithWait();
243cdf0e10cSrcweir pObject = ImplFindSalObject( pMsg->hwnd );
244cdf0e10cSrcweir if ( pObject )
245cdf0e10cSrcweir pSalData->mnSalObjWantKeyEvt = pMsg->wParam;
246cdf0e10cSrcweir ImplSalYieldMutexRelease();
247cdf0e10cSrcweir }
248cdf0e10cSrcweir }
249cdf0e10cSrcweir // Hier WM_SYSCHAR abfangen, um mit Alt+Taste evtl. Menu zu aktivieren
250cdf0e10cSrcweir else if ( pMsg->message == WM_SYSCHAR )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir pSalData->mnSalObjWantKeyEvt = 0;
253cdf0e10cSrcweir
254cdf0e10cSrcweir sal_uInt16 nKeyCode = LOWORD( pMsg->wParam );
255cdf0e10cSrcweir // Nur 0-9 und A-Z
256cdf0e10cSrcweir if ( ((nKeyCode >= 48) && (nKeyCode <= 57)) ||
257cdf0e10cSrcweir ((nKeyCode >= 65) && (nKeyCode <= 90)) ||
258cdf0e10cSrcweir ((nKeyCode >= 97) && (nKeyCode <= 122)) )
259cdf0e10cSrcweir {
260cdf0e10cSrcweir sal_Bool bRet = FALSE;
261cdf0e10cSrcweir ImplSalYieldMutexAcquireWithWait();
262cdf0e10cSrcweir pObject = ImplFindSalObject( pMsg->hwnd );
263cdf0e10cSrcweir if ( pObject )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir if ( pMsg->hwnd == ::GetFocus() )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir WinSalFrame* pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
268cdf0e10cSrcweir if ( pFrame )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir if ( ImplHandleSalObjSysCharMsg( pFrame->mhWnd, pMsg->wParam, pMsg->lParam ) )
271cdf0e10cSrcweir bRet = TRUE;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir }
274cdf0e10cSrcweir }
275cdf0e10cSrcweir ImplSalYieldMutexRelease();
276cdf0e10cSrcweir if ( bRet )
277cdf0e10cSrcweir return TRUE;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir }
280cdf0e10cSrcweir else
281cdf0e10cSrcweir pSalData->mnSalObjWantKeyEvt = 0;
282cdf0e10cSrcweir
283cdf0e10cSrcweir return FALSE;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
286cdf0e10cSrcweir // -----------------------------------------------------------------------
287cdf0e10cSrcweir
ImplSalPostDispatchMsg(MSG * pMsg,LRESULT)288cdf0e10cSrcweir void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT /* nDispatchResult */ )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir // Used for Unicode and none Unicode
291cdf0e10cSrcweir SalData* pSalData = GetSalData();
292cdf0e10cSrcweir WinSalFrame* pFrame;
293cdf0e10cSrcweir
294cdf0e10cSrcweir if ( (pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir if ( pSalData->mnSalObjWantKeyEvt == pMsg->wParam )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir pSalData->mnSalObjWantKeyEvt = 0;
299cdf0e10cSrcweir if ( pMsg->hwnd == ::GetFocus() )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir ImplSalYieldMutexAcquireWithWait();
302cdf0e10cSrcweir pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
303cdf0e10cSrcweir if ( pFrame )
304cdf0e10cSrcweir ImplHandleSalObjKeyMsg( pFrame->mhWnd, pMsg->message, pMsg->wParam, pMsg->lParam );
305cdf0e10cSrcweir ImplSalYieldMutexRelease();
306cdf0e10cSrcweir }
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir
310cdf0e10cSrcweir pSalData->mnSalObjWantKeyEvt = 0;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir // =======================================================================
314cdf0e10cSrcweir
SalSysObjWndProc(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam,int & rDef)315cdf0e10cSrcweir LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir WinSalObject* pSysObj;
318cdf0e10cSrcweir LRESULT nRet = 0;
319cdf0e10cSrcweir
320cdf0e10cSrcweir switch( nMsg )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir case WM_ERASEBKGND:
323cdf0e10cSrcweir nRet = 1;
324cdf0e10cSrcweir rDef = FALSE;
325cdf0e10cSrcweir break;
326cdf0e10cSrcweir case WM_PAINT:
327cdf0e10cSrcweir {
328cdf0e10cSrcweir PAINTSTRUCT aPs;
329cdf0e10cSrcweir BeginPaint( hWnd, &aPs );
330cdf0e10cSrcweir EndPaint( hWnd, &aPs );
331cdf0e10cSrcweir rDef = FALSE;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir break;
334cdf0e10cSrcweir
335cdf0e10cSrcweir case WM_PARENTNOTIFY:
336cdf0e10cSrcweir {
337cdf0e10cSrcweir UINT nNotifyMsg = LOWORD( wParam );
338cdf0e10cSrcweir if ( (nNotifyMsg == WM_LBUTTONDOWN) ||
339cdf0e10cSrcweir (nNotifyMsg == WM_RBUTTONDOWN) ||
340cdf0e10cSrcweir (nNotifyMsg == WM_MBUTTONDOWN) )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir ImplSalYieldMutexAcquireWithWait();
343cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( hWnd );
344cdf0e10cSrcweir if ( pSysObj && !pSysObj->IsMouseTransparent() )
345cdf0e10cSrcweir pSysObj->CallCallback( SALOBJ_EVENT_TOTOP, 0 );
346cdf0e10cSrcweir ImplSalYieldMutexRelease();
347cdf0e10cSrcweir }
348cdf0e10cSrcweir }
349cdf0e10cSrcweir break;
350cdf0e10cSrcweir
351cdf0e10cSrcweir case WM_MOUSEACTIVATE:
352cdf0e10cSrcweir {
353cdf0e10cSrcweir ImplSalYieldMutexAcquireWithWait();
354cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( hWnd );
355cdf0e10cSrcweir if ( pSysObj && !pSysObj->IsMouseTransparent() )
356cdf0e10cSrcweir ImplPostMessage( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
357cdf0e10cSrcweir ImplSalYieldMutexRelease();
358cdf0e10cSrcweir }
359cdf0e10cSrcweir break;
360cdf0e10cSrcweir
361cdf0e10cSrcweir case SALOBJ_MSG_TOTOP:
362cdf0e10cSrcweir if ( ImplSalYieldMutexTryToAcquire() )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( hWnd );
365cdf0e10cSrcweir pSysObj->CallCallback( SALOBJ_EVENT_TOTOP, 0 );
366cdf0e10cSrcweir ImplSalYieldMutexRelease();
367cdf0e10cSrcweir rDef = FALSE;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir else
370cdf0e10cSrcweir ImplPostMessage( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
371cdf0e10cSrcweir break;
372cdf0e10cSrcweir
373cdf0e10cSrcweir case SALOBJ_MSG_POSTFOCUS:
374cdf0e10cSrcweir if ( ImplSalYieldMutexTryToAcquire() )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( hWnd );
377cdf0e10cSrcweir HWND hFocusWnd = ::GetFocus();
378cdf0e10cSrcweir sal_uInt16 nEvent;
379cdf0e10cSrcweir if ( hFocusWnd && ImplIsSysWindowOrChild( hWnd, hFocusWnd ) )
380cdf0e10cSrcweir nEvent = SALOBJ_EVENT_GETFOCUS;
381cdf0e10cSrcweir else
382cdf0e10cSrcweir nEvent = SALOBJ_EVENT_LOSEFOCUS;
383cdf0e10cSrcweir pSysObj->CallCallback( nEvent, 0 );
384cdf0e10cSrcweir ImplSalYieldMutexRelease();
385cdf0e10cSrcweir }
386cdf0e10cSrcweir else
387cdf0e10cSrcweir ImplPostMessage( hWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
388cdf0e10cSrcweir rDef = FALSE;
389cdf0e10cSrcweir break;
390cdf0e10cSrcweir
391cdf0e10cSrcweir case WM_SIZE:
392cdf0e10cSrcweir {
393cdf0e10cSrcweir HWND hWndChild = GetWindow( hWnd, GW_CHILD );
394cdf0e10cSrcweir if ( hWndChild )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir SetWindowPos( hWndChild,
397cdf0e10cSrcweir 0, 0, 0, (int)LOWORD( lParam ), (int)HIWORD( lParam ),
398cdf0e10cSrcweir SWP_NOZORDER | SWP_NOACTIVATE );
399cdf0e10cSrcweir }
400cdf0e10cSrcweir }
401cdf0e10cSrcweir rDef = FALSE;
402cdf0e10cSrcweir break;
403cdf0e10cSrcweir
404cdf0e10cSrcweir case WM_CREATE:
405cdf0e10cSrcweir {
406cdf0e10cSrcweir // Window-Instanz am Windowhandle speichern
407cdf0e10cSrcweir // Can also be used for the W-Version, because the struct
408cdf0e10cSrcweir // to access lpCreateParams is the same structure
409cdf0e10cSrcweir CREATESTRUCTA* pStruct = (CREATESTRUCTA*)lParam;
410cdf0e10cSrcweir pSysObj = (WinSalObject*)pStruct->lpCreateParams;
411cdf0e10cSrcweir SetSalObjWindowPtr( hWnd, pSysObj );
412cdf0e10cSrcweir // HWND schon hier setzen, da schon auf den Instanzdaten
413cdf0e10cSrcweir // gearbeitet werden kann, wenn Messages waehrend
414cdf0e10cSrcweir // CreateWindow() gesendet werden
415cdf0e10cSrcweir pSysObj->mhWnd = hWnd;
416cdf0e10cSrcweir rDef = FALSE;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir break;
419cdf0e10cSrcweir }
420cdf0e10cSrcweir
421cdf0e10cSrcweir return nRet;
422cdf0e10cSrcweir }
423cdf0e10cSrcweir
SalSysObjWndProcA(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam)424cdf0e10cSrcweir LRESULT CALLBACK SalSysObjWndProcA( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir int bDef = TRUE;
427cdf0e10cSrcweir LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef );
428cdf0e10cSrcweir if ( bDef )
429cdf0e10cSrcweir nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam );
430cdf0e10cSrcweir return nRet;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
SalSysObjWndProcW(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam)433cdf0e10cSrcweir LRESULT CALLBACK SalSysObjWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir int bDef = TRUE;
436cdf0e10cSrcweir LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef );
437cdf0e10cSrcweir if ( bDef )
438cdf0e10cSrcweir nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
439cdf0e10cSrcweir return nRet;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir // -----------------------------------------------------------------------
443cdf0e10cSrcweir
SalSysObjChildWndProc(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam,int & rDef)444cdf0e10cSrcweir LRESULT CALLBACK SalSysObjChildWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir LRESULT nRet = 0;
447cdf0e10cSrcweir
448cdf0e10cSrcweir switch( nMsg )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir // Wegen PlugIn's loeschen wir erstmal den Hintergrund
451cdf0e10cSrcweir case WM_ERASEBKGND:
452cdf0e10cSrcweir {
453cdf0e10cSrcweir WinSalObject* pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
454cdf0e10cSrcweir
455cdf0e10cSrcweir if( pSysObj && !pSysObj->IsEraseBackgroundEnabled() )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir // do not erase background
458cdf0e10cSrcweir nRet = 1;
459cdf0e10cSrcweir rDef = FALSE;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir }
462cdf0e10cSrcweir break;
463cdf0e10cSrcweir
464cdf0e10cSrcweir case WM_PAINT:
465cdf0e10cSrcweir {
466cdf0e10cSrcweir PAINTSTRUCT aPs;
467cdf0e10cSrcweir BeginPaint( hWnd, &aPs );
468cdf0e10cSrcweir EndPaint( hWnd, &aPs );
469cdf0e10cSrcweir rDef = FALSE;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir break;
472cdf0e10cSrcweir
473cdf0e10cSrcweir case WM_MOUSEMOVE:
474cdf0e10cSrcweir case WM_LBUTTONDOWN:
475cdf0e10cSrcweir case WM_MBUTTONDOWN:
476cdf0e10cSrcweir case WM_RBUTTONDOWN:
477cdf0e10cSrcweir case WM_LBUTTONUP:
478cdf0e10cSrcweir case WM_MBUTTONUP:
479cdf0e10cSrcweir case WM_RBUTTONUP:
480cdf0e10cSrcweir {
481cdf0e10cSrcweir WinSalObject* pSysObj;
482cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
483cdf0e10cSrcweir
484cdf0e10cSrcweir if( pSysObj && pSysObj->IsMouseTransparent() )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir // forward mouse events to parent frame
487cdf0e10cSrcweir HWND hWndParent = ::GetParent( pSysObj->mhWnd );
488cdf0e10cSrcweir
489cdf0e10cSrcweir // transform coordinates
490cdf0e10cSrcweir POINT pt;
491cdf0e10cSrcweir pt.x = (long) LOWORD( lParam );
492cdf0e10cSrcweir pt.y = (long) HIWORD( lParam );
493cdf0e10cSrcweir MapWindowPoints( hWnd, hWndParent, &pt, 1 );
494cdf0e10cSrcweir lParam = MAKELPARAM( (WORD) pt.x, (WORD) pt.y );
495cdf0e10cSrcweir
496cdf0e10cSrcweir nRet = ImplSendMessage( hWndParent, nMsg, wParam, lParam );
497cdf0e10cSrcweir rDef = FALSE;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir }
500cdf0e10cSrcweir break;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir
503cdf0e10cSrcweir return nRet;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
SalSysObjChildWndProcA(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam)506cdf0e10cSrcweir LRESULT CALLBACK SalSysObjChildWndProcA( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir int bDef = TRUE;
509cdf0e10cSrcweir LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef );
510cdf0e10cSrcweir if ( bDef )
511cdf0e10cSrcweir nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam );
512cdf0e10cSrcweir return nRet;
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
SalSysObjChildWndProcW(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam)515cdf0e10cSrcweir LRESULT CALLBACK SalSysObjChildWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir int bDef = TRUE;
518cdf0e10cSrcweir LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef );
519cdf0e10cSrcweir if ( bDef )
520cdf0e10cSrcweir nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
521cdf0e10cSrcweir return nRet;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir // =======================================================================
525cdf0e10cSrcweir
ImplSalCreateObject(WinSalInstance * pInst,WinSalFrame * pParent)526cdf0e10cSrcweir SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir SalData* pSalData = GetSalData();
529cdf0e10cSrcweir
530cdf0e10cSrcweir // Hook installieren, wenn es das erste SalObject ist
531cdf0e10cSrcweir if ( !pSalData->mpFirstObject )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir pSalData->mhSalObjMsgHook = SetWindowsHookExW( WH_CALLWNDPROC,
534cdf0e10cSrcweir SalSysMsgProc,
535cdf0e10cSrcweir pSalData->mhInst,
536cdf0e10cSrcweir pSalData->mnAppThreadId );
537cdf0e10cSrcweir }
538cdf0e10cSrcweir
539cdf0e10cSrcweir if ( !pSalData->mbObjClassInit )
540cdf0e10cSrcweir {
541cdf0e10cSrcweir // #95301# shockwave plugin has bug; expects ASCII functions to be used
542cdf0e10cSrcweir if ( false )//aSalShlData.mbWNT )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir WNDCLASSEXW aWndClassEx;
545cdf0e10cSrcweir aWndClassEx.cbSize = sizeof( aWndClassEx );
546cdf0e10cSrcweir aWndClassEx.style = 0;
547cdf0e10cSrcweir aWndClassEx.lpfnWndProc = SalSysObjWndProcW;
548cdf0e10cSrcweir aWndClassEx.cbClsExtra = 0;
549cdf0e10cSrcweir aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA;
550cdf0e10cSrcweir aWndClassEx.hInstance = pSalData->mhInst;
551cdf0e10cSrcweir aWndClassEx.hIcon = 0;
552cdf0e10cSrcweir aWndClassEx.hIconSm = 0;
553cdf0e10cSrcweir aWndClassEx.hCursor = LoadCursor( 0, IDC_ARROW );
554cdf0e10cSrcweir aWndClassEx.hbrBackground = 0;
555cdf0e10cSrcweir aWndClassEx.lpszMenuName = 0;
556cdf0e10cSrcweir aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEW;
557cdf0e10cSrcweir if ( RegisterClassExW( &aWndClassEx ) )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir // Wegen PlugIn's loeschen wir erstmal den Hintergrund
560cdf0e10cSrcweir aWndClassEx.cbWndExtra = 0;
561cdf0e10cSrcweir aWndClassEx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
562cdf0e10cSrcweir aWndClassEx.lpfnWndProc = SalSysObjChildWndProcW;
563cdf0e10cSrcweir aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEW;
564cdf0e10cSrcweir if ( RegisterClassExW( &aWndClassEx ) )
565cdf0e10cSrcweir pSalData->mbObjClassInit = TRUE;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir }
568cdf0e10cSrcweir else
569cdf0e10cSrcweir {
570cdf0e10cSrcweir WNDCLASSEXA aWndClassEx;
571cdf0e10cSrcweir aWndClassEx.cbSize = sizeof( aWndClassEx );
572cdf0e10cSrcweir aWndClassEx.style = 0;
573cdf0e10cSrcweir aWndClassEx.lpfnWndProc = SalSysObjWndProcA;
574cdf0e10cSrcweir aWndClassEx.cbClsExtra = 0;
575cdf0e10cSrcweir aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA;
576cdf0e10cSrcweir aWndClassEx.hInstance = pSalData->mhInst;
577cdf0e10cSrcweir aWndClassEx.hIcon = 0;
578cdf0e10cSrcweir aWndClassEx.hIconSm = 0;
579cdf0e10cSrcweir aWndClassEx.hCursor = LoadCursor( 0, IDC_ARROW );
580cdf0e10cSrcweir aWndClassEx.hbrBackground = 0;
581cdf0e10cSrcweir aWndClassEx.lpszMenuName = 0;
582cdf0e10cSrcweir aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEA;
583cdf0e10cSrcweir if ( RegisterClassExA( &aWndClassEx ) )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir // Wegen PlugIn's loeschen wir erstmal den Hintergrund
586cdf0e10cSrcweir aWndClassEx.cbWndExtra = 0;
587cdf0e10cSrcweir aWndClassEx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
588cdf0e10cSrcweir aWndClassEx.lpfnWndProc = SalSysObjChildWndProcA;
589cdf0e10cSrcweir aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEA;
590cdf0e10cSrcweir if ( RegisterClassExA( &aWndClassEx ) )
591cdf0e10cSrcweir pSalData->mbObjClassInit = TRUE;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir }
594cdf0e10cSrcweir }
595cdf0e10cSrcweir
596cdf0e10cSrcweir if ( pSalData->mbObjClassInit )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir WinSalObject* pObject = new WinSalObject;
599cdf0e10cSrcweir
600cdf0e10cSrcweir // #135235# Clip siblings of this
601cdf0e10cSrcweir // SystemChildWindow. Otherwise, DXCanvas (using a hidden
602cdf0e10cSrcweir // SystemChildWindow) clobbers applets/plugins during
603cdf0e10cSrcweir // animations .
604cdf0e10cSrcweir HWND hWnd = CreateWindowExA( 0, SAL_OBJECT_CLASSNAMEA, "",
605cdf0e10cSrcweir WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0,
606cdf0e10cSrcweir pParent->mhWnd, 0,
607cdf0e10cSrcweir pInst->mhInst, (void*)pObject );
608cdf0e10cSrcweir
609cdf0e10cSrcweir HWND hWndChild = 0;
610cdf0e10cSrcweir if ( hWnd )
611cdf0e10cSrcweir {
612*6d53c851Smseidel // #135235# Explicitly stack SystemChildWindows in
613cdf0e10cSrcweir // the order they're created - since there's no notion
614cdf0e10cSrcweir // of zorder.
615cdf0e10cSrcweir SetWindowPos(hWnd,HWND_TOP,0,0,0,0,
616cdf0e10cSrcweir SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOSIZE);
617cdf0e10cSrcweir hWndChild = CreateWindowExA( 0, SAL_OBJECT_CHILDCLASSNAMEA, "",
618cdf0e10cSrcweir WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
619cdf0e10cSrcweir 0, 0, 0, 0,
620cdf0e10cSrcweir hWnd, 0,
621cdf0e10cSrcweir pInst->mhInst, NULL );
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir if ( !hWndChild )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir delete pObject;
627cdf0e10cSrcweir return NULL;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
630cdf0e10cSrcweir if ( hWnd )
631cdf0e10cSrcweir {
632cdf0e10cSrcweir pObject->mhWnd = hWnd;
633cdf0e10cSrcweir pObject->mhWndChild = hWndChild;
634cdf0e10cSrcweir pObject->maSysData.hWnd = hWndChild;
635cdf0e10cSrcweir return pObject;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir }
638cdf0e10cSrcweir
639cdf0e10cSrcweir return NULL;
640cdf0e10cSrcweir }
641cdf0e10cSrcweir
642cdf0e10cSrcweir // =======================================================================
643cdf0e10cSrcweir
WinSalObject()644cdf0e10cSrcweir WinSalObject::WinSalObject()
645cdf0e10cSrcweir {
646cdf0e10cSrcweir SalData* pSalData = GetSalData();
647cdf0e10cSrcweir
648cdf0e10cSrcweir mhWnd = 0;
649cdf0e10cSrcweir mhWndChild = 0;
650cdf0e10cSrcweir mhLastFocusWnd = 0;
651cdf0e10cSrcweir maSysData.nSize = sizeof( SystemEnvData );
652cdf0e10cSrcweir mpStdClipRgnData = NULL;
653cdf0e10cSrcweir mbInterceptChildWindowKeyDown = sal_False;
654cdf0e10cSrcweir
655cdf0e10cSrcweir // Insert object in objectlist
656cdf0e10cSrcweir mpNextObject = pSalData->mpFirstObject;
657cdf0e10cSrcweir pSalData->mpFirstObject = this;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir
660cdf0e10cSrcweir // -----------------------------------------------------------------------
661cdf0e10cSrcweir
~WinSalObject()662cdf0e10cSrcweir WinSalObject::~WinSalObject()
663cdf0e10cSrcweir {
664cdf0e10cSrcweir SalData* pSalData = GetSalData();
665cdf0e10cSrcweir
666cdf0e10cSrcweir // remove frame from framelist
667cdf0e10cSrcweir if ( this == pSalData->mpFirstObject )
668cdf0e10cSrcweir {
669cdf0e10cSrcweir pSalData->mpFirstObject = mpNextObject;
670cdf0e10cSrcweir
671cdf0e10cSrcweir // Wenn letztes SalObject, dann Hook wieder entfernen
672cdf0e10cSrcweir if ( !pSalData->mpFirstObject )
673cdf0e10cSrcweir UnhookWindowsHookEx( pSalData->mhSalObjMsgHook );
674cdf0e10cSrcweir }
675cdf0e10cSrcweir else
676cdf0e10cSrcweir {
677cdf0e10cSrcweir WinSalObject* pTempObject = pSalData->mpFirstObject;
678cdf0e10cSrcweir while ( pTempObject->mpNextObject != this )
679cdf0e10cSrcweir pTempObject = pTempObject->mpNextObject;
680cdf0e10cSrcweir
681cdf0e10cSrcweir pTempObject->mpNextObject = mpNextObject;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir
684cdf0e10cSrcweir // Cache-Daten zerstoeren
685cdf0e10cSrcweir if ( mpStdClipRgnData )
686cdf0e10cSrcweir delete mpStdClipRgnData;
687cdf0e10cSrcweir
688cdf0e10cSrcweir HWND hWndParent = ::GetParent( mhWnd );
689cdf0e10cSrcweir
690cdf0e10cSrcweir if ( mhWndChild )
691cdf0e10cSrcweir DestroyWindow( mhWndChild );
692cdf0e10cSrcweir if ( mhWnd )
693cdf0e10cSrcweir DestroyWindow( mhWnd );
694cdf0e10cSrcweir
695cdf0e10cSrcweir // Palette wieder zuruecksetzen, wenn kein externes Child-Fenster
696cdf0e10cSrcweir // mehr vorhanden ist, da diese unsere Palette ueberschrieben haben
697cdf0e10cSrcweir // koennen
698cdf0e10cSrcweir if ( hWndParent &&
699cdf0e10cSrcweir ::GetActiveWindow() == hWndParent &&
700cdf0e10cSrcweir !GetWindow( hWndParent, GW_CHILD ) )
701cdf0e10cSrcweir ImplSendMessage( hWndParent, SAL_MSG_FORCEPALETTE, 0, 0 );
702cdf0e10cSrcweir }
703cdf0e10cSrcweir
704cdf0e10cSrcweir // -----------------------------------------------------------------------
705cdf0e10cSrcweir
ResetClipRegion()706cdf0e10cSrcweir void WinSalObject::ResetClipRegion()
707cdf0e10cSrcweir {
708cdf0e10cSrcweir SetWindowRgn( mhWnd, 0, TRUE );
709cdf0e10cSrcweir }
710cdf0e10cSrcweir
711cdf0e10cSrcweir // -----------------------------------------------------------------------
712cdf0e10cSrcweir
GetClipRegionType()713cdf0e10cSrcweir sal_uInt16 WinSalObject::GetClipRegionType()
714cdf0e10cSrcweir {
715cdf0e10cSrcweir return SAL_OBJECT_CLIP_INCLUDERECTS;
716cdf0e10cSrcweir }
717cdf0e10cSrcweir
718cdf0e10cSrcweir // -----------------------------------------------------------------------
719cdf0e10cSrcweir
BeginSetClipRegion(sal_uLong nRectCount)720cdf0e10cSrcweir void WinSalObject::BeginSetClipRegion( sal_uLong nRectCount )
721cdf0e10cSrcweir {
722cdf0e10cSrcweir sal_uLong nRectBufSize = sizeof(RECT)*nRectCount;
723cdf0e10cSrcweir if ( nRectCount < SAL_CLIPRECT_COUNT )
724cdf0e10cSrcweir {
725cdf0e10cSrcweir if ( !mpStdClipRgnData )
726cdf0e10cSrcweir mpStdClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+(SAL_CLIPRECT_COUNT*sizeof(RECT))];
727cdf0e10cSrcweir mpClipRgnData = mpStdClipRgnData;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir else
730cdf0e10cSrcweir mpClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+nRectBufSize];
731cdf0e10cSrcweir mpClipRgnData->rdh.dwSize = sizeof( RGNDATAHEADER );
732cdf0e10cSrcweir mpClipRgnData->rdh.iType = RDH_RECTANGLES;
733cdf0e10cSrcweir mpClipRgnData->rdh.nCount = nRectCount;
734cdf0e10cSrcweir mpClipRgnData->rdh.nRgnSize = nRectBufSize;
735cdf0e10cSrcweir SetRectEmpty( &(mpClipRgnData->rdh.rcBound) );
736cdf0e10cSrcweir mpNextClipRect = (RECT*)(&(mpClipRgnData->Buffer));
737cdf0e10cSrcweir mbFirstClipRect = TRUE;
738cdf0e10cSrcweir }
739cdf0e10cSrcweir
740cdf0e10cSrcweir // -----------------------------------------------------------------------
741cdf0e10cSrcweir
UnionClipRegion(long nX,long nY,long nWidth,long nHeight)742cdf0e10cSrcweir void WinSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
743cdf0e10cSrcweir {
744cdf0e10cSrcweir RECT* pRect = mpNextClipRect;
745cdf0e10cSrcweir RECT* pBoundRect = &(mpClipRgnData->rdh.rcBound);
746cdf0e10cSrcweir long nRight = nX + nWidth;
747cdf0e10cSrcweir long nBottom = nY + nHeight;
748cdf0e10cSrcweir
749cdf0e10cSrcweir if ( mbFirstClipRect )
750cdf0e10cSrcweir {
751cdf0e10cSrcweir pBoundRect->left = nX;
752cdf0e10cSrcweir pBoundRect->top = nY;
753cdf0e10cSrcweir pBoundRect->right = nRight;
754cdf0e10cSrcweir pBoundRect->bottom = nBottom;
755cdf0e10cSrcweir mbFirstClipRect = FALSE;
756cdf0e10cSrcweir }
757cdf0e10cSrcweir else
758cdf0e10cSrcweir {
759cdf0e10cSrcweir if ( nX < pBoundRect->left )
760cdf0e10cSrcweir pBoundRect->left = (int)nX;
761cdf0e10cSrcweir
762cdf0e10cSrcweir if ( nY < pBoundRect->top )
763cdf0e10cSrcweir pBoundRect->top = (int)nY;
764cdf0e10cSrcweir
765cdf0e10cSrcweir if ( nRight > pBoundRect->right )
766cdf0e10cSrcweir pBoundRect->right = (int)nRight;
767cdf0e10cSrcweir
768cdf0e10cSrcweir if ( nBottom > pBoundRect->bottom )
769cdf0e10cSrcweir pBoundRect->bottom = (int)nBottom;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir
772cdf0e10cSrcweir pRect->left = (int)nX;
773cdf0e10cSrcweir pRect->top = (int)nY;
774cdf0e10cSrcweir pRect->right = (int)nRight;
775cdf0e10cSrcweir pRect->bottom = (int)nBottom;
776cdf0e10cSrcweir mpNextClipRect++;
777cdf0e10cSrcweir }
778cdf0e10cSrcweir
779cdf0e10cSrcweir // -----------------------------------------------------------------------
780cdf0e10cSrcweir
EndSetClipRegion()781cdf0e10cSrcweir void WinSalObject::EndSetClipRegion()
782cdf0e10cSrcweir {
783cdf0e10cSrcweir HRGN hRegion;
784cdf0e10cSrcweir
785cdf0e10cSrcweir // Aus den Region-Daten muessen wir jetzt eine ClipRegion erzeugen
786cdf0e10cSrcweir if ( mpClipRgnData->rdh.nCount == 1 )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir RECT* pRect = &(mpClipRgnData->rdh.rcBound);
789cdf0e10cSrcweir hRegion = CreateRectRgn( pRect->left, pRect->top,
790cdf0e10cSrcweir pRect->right, pRect->bottom );
791cdf0e10cSrcweir }
792cdf0e10cSrcweir else
793cdf0e10cSrcweir {
794cdf0e10cSrcweir sal_uLong nSize = mpClipRgnData->rdh.nRgnSize+sizeof(RGNDATAHEADER);
795cdf0e10cSrcweir hRegion = ExtCreateRegion( NULL, nSize, mpClipRgnData );
796cdf0e10cSrcweir if ( mpClipRgnData != mpStdClipRgnData )
797cdf0e10cSrcweir delete [] (BYTE*)mpClipRgnData;
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
800cdf0e10cSrcweir DBG_ASSERT( hRegion, "SalObject::EndSetClipRegion() - Can't create ClipRegion" );
801cdf0e10cSrcweir SetWindowRgn( mhWnd, hRegion, TRUE );
802cdf0e10cSrcweir }
803cdf0e10cSrcweir
804cdf0e10cSrcweir // -----------------------------------------------------------------------
805cdf0e10cSrcweir
SetPosSize(long nX,long nY,long nWidth,long nHeight)806cdf0e10cSrcweir void WinSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir sal_uLong nStyle = 0;
809cdf0e10cSrcweir sal_Bool bVisible = (GetWindowStyle( mhWnd ) & WS_VISIBLE) != 0;
810cdf0e10cSrcweir if ( bVisible )
811cdf0e10cSrcweir {
812cdf0e10cSrcweir ShowWindow( mhWnd, SW_HIDE );
813cdf0e10cSrcweir nStyle |= SWP_SHOWWINDOW;
814cdf0e10cSrcweir }
815cdf0e10cSrcweir SetWindowPos( mhWnd, 0,
816cdf0e10cSrcweir (int)nX, (int)nY, (int)nWidth, (int)nHeight,
817cdf0e10cSrcweir SWP_NOZORDER | SWP_NOACTIVATE | nStyle );
818cdf0e10cSrcweir }
819cdf0e10cSrcweir
820cdf0e10cSrcweir // -----------------------------------------------------------------------
821cdf0e10cSrcweir
Show(sal_Bool bVisible)822cdf0e10cSrcweir void WinSalObject::Show( sal_Bool bVisible )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir if ( bVisible )
825cdf0e10cSrcweir ShowWindow( mhWnd, SW_SHOWNORMAL );
826cdf0e10cSrcweir else
827cdf0e10cSrcweir ShowWindow( mhWnd, SW_HIDE );
828cdf0e10cSrcweir }
829cdf0e10cSrcweir
830cdf0e10cSrcweir // -----------------------------------------------------------------------
831cdf0e10cSrcweir
Enable(sal_Bool bEnable)832cdf0e10cSrcweir void WinSalObject::Enable( sal_Bool bEnable )
833cdf0e10cSrcweir {
834cdf0e10cSrcweir EnableWindow( mhWnd, bEnable );
835cdf0e10cSrcweir }
836cdf0e10cSrcweir
837cdf0e10cSrcweir // -----------------------------------------------------------------------
838cdf0e10cSrcweir
GrabFocus()839cdf0e10cSrcweir void WinSalObject::GrabFocus()
840cdf0e10cSrcweir {
841cdf0e10cSrcweir if ( mhLastFocusWnd &&
842cdf0e10cSrcweir IsWindow( mhLastFocusWnd ) &&
843cdf0e10cSrcweir ImplIsSysWindowOrChild( mhWndChild, mhLastFocusWnd ) )
844cdf0e10cSrcweir ::SetFocus( mhLastFocusWnd );
845cdf0e10cSrcweir else
846cdf0e10cSrcweir ::SetFocus( mhWndChild );
847cdf0e10cSrcweir }
848cdf0e10cSrcweir
849cdf0e10cSrcweir // -----------------------------------------------------------------------
850cdf0e10cSrcweir
SetBackground()851cdf0e10cSrcweir void WinSalObject::SetBackground()
852cdf0e10cSrcweir {
853cdf0e10cSrcweir }
854cdf0e10cSrcweir
855cdf0e10cSrcweir // -----------------------------------------------------------------------
856cdf0e10cSrcweir
SetBackground(SalColor)857cdf0e10cSrcweir void WinSalObject::SetBackground( SalColor )
858cdf0e10cSrcweir {
859cdf0e10cSrcweir }
860cdf0e10cSrcweir
861cdf0e10cSrcweir // -----------------------------------------------------------------------
862cdf0e10cSrcweir
GetSystemData() const863cdf0e10cSrcweir const SystemEnvData* WinSalObject::GetSystemData() const
864cdf0e10cSrcweir {
865cdf0e10cSrcweir return &maSysData;
866cdf0e10cSrcweir }
867cdf0e10cSrcweir
868cdf0e10cSrcweir // -----------------------------------------------------------------------
869cdf0e10cSrcweir
InterceptChildWindowKeyDown(sal_Bool bIntercept)870cdf0e10cSrcweir void WinSalObject::InterceptChildWindowKeyDown( sal_Bool bIntercept )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir mbInterceptChildWindowKeyDown = bIntercept;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir
875