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 #include <svpm.h> 25cdf0e10cSrcweir 26*fc9fd3f1SPedro Giffuni #include <string.h> 27*fc9fd3f1SPedro Giffuni 28*fc9fd3f1SPedro Giffuni #include <tools/debug.hxx> 29*fc9fd3f1SPedro Giffuni #include <tools/svwin.h> 30*fc9fd3f1SPedro Giffuni 31*fc9fd3f1SPedro Giffuni #include "vcl/svapp.hxx" 32*fc9fd3f1SPedro Giffuni 33*fc9fd3f1SPedro Giffuni #include "os2/saldata.hxx" 34*fc9fd3f1SPedro Giffuni #include "os2/salinst.h" 35*fc9fd3f1SPedro Giffuni #include "os2/salframe.h" 36*fc9fd3f1SPedro Giffuni #include "os2/salobj.h" 37cdf0e10cSrcweir 38cdf0e10cSrcweir // ======================================================================= 39cdf0e10cSrcweir 40*fc9fd3f1SPedro Giffuni static sal_Bool ImplIsSysWindowOrChild( HWND hWndParent, HWND hWndChild ) 41cdf0e10cSrcweir { 42cdf0e10cSrcweir if ( hWndParent == hWndChild ) 43cdf0e10cSrcweir return TRUE; 44cdf0e10cSrcweir 45cdf0e10cSrcweir HWND hTempWnd = WinQueryWindow( hWndChild, QW_PARENT ); 46cdf0e10cSrcweir while ( hTempWnd ) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir if ( hTempWnd == hWndParent ) 49cdf0e10cSrcweir return TRUE; 50cdf0e10cSrcweir hTempWnd = WinQueryWindow( hTempWnd, QW_PARENT ); 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir return FALSE; 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir // ----------------------------------------------------------------------- 57cdf0e10cSrcweir 58cdf0e10cSrcweir static Os2SalObject* ImplFindOs2SalObject( HWND hWndChild ) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir SalData* pSalData = GetSalData(); 61cdf0e10cSrcweir Os2SalObject* pObject = pSalData->mpFirstObject; 62cdf0e10cSrcweir while ( pObject ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir if ( ImplIsSysWindowOrChild( pObject->mhWndChild, hWndChild ) ) 65cdf0e10cSrcweir return pObject; 66cdf0e10cSrcweir 67cdf0e10cSrcweir pObject = pObject->mpNextObject; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir return NULL; 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir // ======================================================================= 74cdf0e10cSrcweir 75*fc9fd3f1SPedro Giffuni sal_Bool EXPENTRY SalSysMsgProc( HAB /* hAB */, QMSG* pMsg, ULONG /* fs */ ) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir if ( (pMsg->msg == WM_BUTTON1DOWN) || 78cdf0e10cSrcweir (pMsg->msg == WM_BUTTON2DOWN) || 79cdf0e10cSrcweir (pMsg->msg == WM_BUTTON3DOWN) ) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir SalData* pSalData = GetSalData(); 82cdf0e10cSrcweir Os2SalObject* pObject = ImplFindOs2SalObject( pMsg->hwnd ); 83cdf0e10cSrcweir if ( pObject ) 84cdf0e10cSrcweir WinPostMsg( pObject->mhWnd, SALOBJ_MSG_TOTOP, 0, 0 ); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir // Focus fangen wir hier nicht ab, da wir erstmal davon ausgehen, 88cdf0e10cSrcweir // das unser Os2SalObject-Fenster immer eine WM_FOCUSCHANGE-Message 89cdf0e10cSrcweir // bekommt. 90cdf0e10cSrcweir 91cdf0e10cSrcweir return FALSE; 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir // ----------------------------------------------------------------------- 95cdf0e10cSrcweir 96cdf0e10cSrcweir MRESULT EXPENTRY SalSysObjWndProc( HWND hWnd, ULONG nMsg, 97cdf0e10cSrcweir MPARAM nMP1, MPARAM nMP2 ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir Os2SalObject* pSysObj; 100cdf0e10cSrcweir MRESULT nRet = 0; 101cdf0e10cSrcweir int bDef = TRUE; 102cdf0e10cSrcweir 103cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0 104cdf0e10cSrcweir debug_printf( "SalSysObjWndProc hWnd 0x%x nMsg %d\n", hWnd, nMsg); 105cdf0e10cSrcweir #endif 106cdf0e10cSrcweir 107cdf0e10cSrcweir switch( nMsg ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir case WM_ERASEBACKGROUND: 110cdf0e10cSrcweir nRet = (MRESULT)FALSE; 111cdf0e10cSrcweir bDef = FALSE; 112cdf0e10cSrcweir break; 113cdf0e10cSrcweir case WM_PAINT: 114cdf0e10cSrcweir { 115cdf0e10cSrcweir HPS hPS; 116cdf0e10cSrcweir RECTL aRect; 117cdf0e10cSrcweir hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); 118cdf0e10cSrcweir WinEndPaint( hPS ); 119cdf0e10cSrcweir bDef = FALSE; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir bDef = FALSE; 122cdf0e10cSrcweir break; 123cdf0e10cSrcweir 124cdf0e10cSrcweir case WM_BUTTON1DOWN: 125cdf0e10cSrcweir case WM_BUTTON2DOWN: 126cdf0e10cSrcweir case WM_BUTTON3DOWN: 127cdf0e10cSrcweir case SALOBJ_MSG_TOTOP: 128cdf0e10cSrcweir if ( ImplSalYieldMutexTryToAcquire() ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( hWnd ); 131cdf0e10cSrcweir pSysObj->mpProc( pSysObj->mpInst, pSysObj, 132cdf0e10cSrcweir SALOBJ_EVENT_TOTOP, 0 ); 133cdf0e10cSrcweir ImplSalYieldMutexRelease(); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir else 136cdf0e10cSrcweir WinPostMsg( hWnd, SALOBJ_MSG_TOTOP, 0, 0 ); 137cdf0e10cSrcweir break; 138cdf0e10cSrcweir 139cdf0e10cSrcweir case WM_FOCUSCHANGE: 140cdf0e10cSrcweir case SALOBJ_MSG_POSTFOCUS: 141cdf0e10cSrcweir if ( ImplSalYieldMutexTryToAcquire() ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( hWnd ); 144cdf0e10cSrcweir if ( SHORT1FROMMP( nMP2 ) ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir pSysObj->mhLastFocusWnd = WinQueryFocus( HWND_DESKTOP ); 147cdf0e10cSrcweir pSysObj->mpProc( pSysObj->mpInst, pSysObj, 148cdf0e10cSrcweir SALOBJ_EVENT_GETFOCUS, 0 ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir else 151cdf0e10cSrcweir { 152cdf0e10cSrcweir HWND hWndFocus = HWNDFROMMP( nMP1 ); 153cdf0e10cSrcweir if ( !hWndFocus || !ImplIsSysWindowOrChild( hWnd, hWndFocus ) ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir pSysObj->mpProc( pSysObj->mpInst, pSysObj, 156cdf0e10cSrcweir SALOBJ_EVENT_LOSEFOCUS, 0 ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir } 159cdf0e10cSrcweir ImplSalYieldMutexRelease(); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir else 162cdf0e10cSrcweir WinPostMsg( hWnd, SALOBJ_MSG_POSTFOCUS, nMP1, nMP2 ); 163cdf0e10cSrcweir break; 164cdf0e10cSrcweir 165cdf0e10cSrcweir case WM_SIZE: 166cdf0e10cSrcweir { 167cdf0e10cSrcweir pSysObj = GetSalObjWindowPtr( hWnd ); 168cdf0e10cSrcweir pSysObj->mnHeight = (short)SHORT2FROMMP( nMP2 ); 169cdf0e10cSrcweir WinSetWindowPos( pSysObj->mhWndChild, 0, 170cdf0e10cSrcweir 0, 0, 171cdf0e10cSrcweir (short)SHORT1FROMMP( nMP2 ), (short)SHORT2FROMMP( nMP2 ), 172cdf0e10cSrcweir SWP_SIZE | SWP_MOVE ); 173cdf0e10cSrcweir bDef = FALSE; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir break; 176cdf0e10cSrcweir 177cdf0e10cSrcweir case WM_CREATE: 178cdf0e10cSrcweir { 179cdf0e10cSrcweir // Window-Instanz am Windowhandle speichern 180cdf0e10cSrcweir CREATESTRUCT* pStruct = (CREATESTRUCT*)nMP2; 181cdf0e10cSrcweir pSysObj = (Os2SalObject*)pStruct->pPresParams; 182cdf0e10cSrcweir SetSalObjWindowPtr( hWnd, pSysObj ); 183cdf0e10cSrcweir bDef = FALSE; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir break; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir if ( bDef ) 189cdf0e10cSrcweir nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); 190cdf0e10cSrcweir return nRet; 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir // ----------------------------------------------------------------------- 194cdf0e10cSrcweir 195cdf0e10cSrcweir MRESULT EXPENTRY SalSysObjChildWndProc( HWND hWnd, ULONG nMsg, 196cdf0e10cSrcweir MPARAM nMP1, MPARAM nMP2 ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir MRESULT nRet = 0; 199cdf0e10cSrcweir int bDef = TRUE; 200cdf0e10cSrcweir 201cdf0e10cSrcweir debug_printf( "SalSysObjChildWndProc hWnd 0x%x nMsg %d\n", hWnd, nMsg); 202cdf0e10cSrcweir 203cdf0e10cSrcweir switch( nMsg ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir case WM_ERASEBACKGROUND: 206cdf0e10cSrcweir // Wegen PlugIn's loeschen wir erstmal den Hintergrund 207cdf0e10cSrcweir /* 208cdf0e10cSrcweir nRet = (MRESULT)FALSE; 209cdf0e10cSrcweir bDef = FALSE; 210cdf0e10cSrcweir */ 211cdf0e10cSrcweir break; 212cdf0e10cSrcweir case WM_PAINT: 213cdf0e10cSrcweir { 214cdf0e10cSrcweir HPS hPS; 215cdf0e10cSrcweir RECTL aRect; 216cdf0e10cSrcweir hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); 217cdf0e10cSrcweir WinEndPaint( hPS ); 218cdf0e10cSrcweir bDef = FALSE; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir break; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir if ( bDef ) 224cdf0e10cSrcweir nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); 225cdf0e10cSrcweir return nRet; 226cdf0e10cSrcweir } 227cdf0e10cSrcweir 228cdf0e10cSrcweir // ----------------------------------------------------------------------- 229cdf0e10cSrcweir 230cdf0e10cSrcweir MRESULT EXPENTRY SalSysObjClipWndProc( HWND hWnd, ULONG nMsg, 231cdf0e10cSrcweir MPARAM nMP1, MPARAM nMP2 ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir MRESULT nRet = 0; 234cdf0e10cSrcweir int bDef = TRUE; 235cdf0e10cSrcweir 236cdf0e10cSrcweir debug_printf( "SalSysObjClipWndProc hWnd 0x%x nMsg %d\n", hWnd, nMsg); 237cdf0e10cSrcweir 238cdf0e10cSrcweir switch( nMsg ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir case WM_MOUSEMOVE: 241cdf0e10cSrcweir case WM_BUTTON1DOWN: 242cdf0e10cSrcweir case WM_BUTTON2DOWN: 243cdf0e10cSrcweir case WM_BUTTON3DOWN: 244cdf0e10cSrcweir case WM_BUTTON1DBLCLK: 245cdf0e10cSrcweir case WM_BUTTON2DBLCLK: 246cdf0e10cSrcweir case WM_BUTTON3DBLCLK: 247cdf0e10cSrcweir case WM_BUTTON1UP: 248cdf0e10cSrcweir case WM_BUTTON2UP: 249cdf0e10cSrcweir case WM_BUTTON3UP: 250cdf0e10cSrcweir { 251cdf0e10cSrcweir // Alle Events an den Frame weiterreichen, da diese Bereiche 252cdf0e10cSrcweir // dem Frame gehoeren. Dazu muessen die Mouse-Koordinaaten 253cdf0e10cSrcweir // entsprechend umgerechnet werden 254cdf0e10cSrcweir HWND hWndParent = WinQueryWindow( hWnd, QW_PARENT ); // ergibt SysChild-Fenster 255cdf0e10cSrcweir hWndParent = WinQueryWindow( hWndParent, QW_PARENT ); 256cdf0e10cSrcweir short nX = (short)SHORT1FROMMP( nMP1 ); 257cdf0e10cSrcweir short nY = (short)SHORT2FROMMP( nMP1 ); 258cdf0e10cSrcweir POINTL aPos; 259cdf0e10cSrcweir aPos.x = nX; 260cdf0e10cSrcweir aPos.y = nY; 261cdf0e10cSrcweir WinMapWindowPoints( hWnd, hWndParent, &aPos, 1 ); 262cdf0e10cSrcweir nMP1 = MPFROM2SHORT( (short)aPos.x, (short)aPos.y ); 263cdf0e10cSrcweir bDef = FALSE; 264cdf0e10cSrcweir nRet = WinSendMsg( hWndParent, nMsg, nMP1, nMP2 ); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir break; 267cdf0e10cSrcweir 268cdf0e10cSrcweir case WM_HITTEST: 269cdf0e10cSrcweir // Damit im disablten Zustand die MouseKlicks immer noch 270cdf0e10cSrcweir // an den Frame geschickt werden 271cdf0e10cSrcweir // Dieser Code reicht leider nicht aus, deshalb wir unter 272cdf0e10cSrcweir // OS2 immer das Child-Fenster disablen, im Gegensatz 273cdf0e10cSrcweir // zu Windows, wo immer der Parent disablte wird, da 274cdf0e10cSrcweir // sich das Fenster evtl. anders Darstellen koennte, 275cdf0e10cSrcweir // wenn es disablte wird. Da dieser Fall uns bisher 276cdf0e10cSrcweir // nicht bekannt ist, ignorieren wir das. 277cdf0e10cSrcweir nRet = HT_NORMAL; 278cdf0e10cSrcweir bDef = FALSE; 279cdf0e10cSrcweir break; 280cdf0e10cSrcweir 281cdf0e10cSrcweir case WM_ERASEBACKGROUND: 282cdf0e10cSrcweir nRet = (MRESULT)FALSE; 283cdf0e10cSrcweir bDef = FALSE; 284cdf0e10cSrcweir break; 285cdf0e10cSrcweir case WM_PAINT: 286cdf0e10cSrcweir { 287cdf0e10cSrcweir HPS hPS; 288cdf0e10cSrcweir RECTL aRect; 289cdf0e10cSrcweir hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); 290cdf0e10cSrcweir WinEndPaint( hPS ); 291cdf0e10cSrcweir bDef = FALSE; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir break; 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir if ( bDef ) 297cdf0e10cSrcweir nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); 298cdf0e10cSrcweir return nRet; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir // ======================================================================= 302cdf0e10cSrcweir 303cdf0e10cSrcweir void ImplDestroyAllClipWindows( HWND hWndLast ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir if ( hWndLast == HWND_TOP ) 306cdf0e10cSrcweir return; 307cdf0e10cSrcweir 308cdf0e10cSrcweir HWND hWndPrev; 309cdf0e10cSrcweir while ( hWndLast ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir hWndPrev = WinQueryWindow( hWndLast, QW_PREV ); 312cdf0e10cSrcweir WinDestroyWindow( hWndLast ); 313cdf0e10cSrcweir hWndLast = hWndPrev; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir // ======================================================================= 318cdf0e10cSrcweir 319cdf0e10cSrcweir SalObject* ImplSalCreateObject( Os2SalInstance* pInst, Os2SalFrame* pParent ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir SalData* pSalData = GetSalData(); 322cdf0e10cSrcweir 323cdf0e10cSrcweir if ( !pSalData->mbObjClassInit ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CLASSNAME, 326cdf0e10cSrcweir (PFNWP)SalSysObjWndProc, CS_MOVENOTIFY, 327cdf0e10cSrcweir SAL_OBJECT_WNDEXTRA ) ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CLIPCLASSNAME, 330cdf0e10cSrcweir (PFNWP)SalSysObjClipWndProc, CS_HITTEST | CS_MOVENOTIFY, 0 ) ) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CHILDCLASSNAME, 333cdf0e10cSrcweir (PFNWP)SalSysObjChildWndProc, CS_HITTEST | CS_MOVENOTIFY, 32 ) ) 334cdf0e10cSrcweir pSalData->mbObjClassInit = TRUE; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir if ( pSalData->mbObjClassInit ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir Os2SalObject* pObject = new Os2SalObject; 342cdf0e10cSrcweir HWND hWnd = WinCreateWindow( pParent->mhWndClient, SAL_OBJECT_CLASSNAME, "", 343cdf0e10cSrcweir 0, 344cdf0e10cSrcweir 0, 0, 0, 0, 345cdf0e10cSrcweir pParent->mhWndClient, HWND_TOP, 346cdf0e10cSrcweir 0, NULL, (void*)pObject ); 347cdf0e10cSrcweir HWND hWndChild = WinCreateWindow( hWnd, SAL_OBJECT_CHILDCLASSNAME, "", 348cdf0e10cSrcweir WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, 349cdf0e10cSrcweir 0, 0, 0, 0, 350cdf0e10cSrcweir hWnd, HWND_TOP, 351cdf0e10cSrcweir 0, NULL, NULL ); 352cdf0e10cSrcweir 353cdf0e10cSrcweir if ( !hWndChild ) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir if ( hWnd ) 356cdf0e10cSrcweir WinDestroyWindow( hWnd ); 357cdf0e10cSrcweir delete pObject; 358cdf0e10cSrcweir return NULL; 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir if ( hWnd ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir debug_printf("ImplSalCreateObject hWndChild %x\n", hWndChild); 364cdf0e10cSrcweir debug_printf("ImplSalCreateObject hWnd %x\n", hWnd); 365cdf0e10cSrcweir pObject->mhWnd = hWnd; 366cdf0e10cSrcweir pObject->mhWndChild = hWndChild; 367cdf0e10cSrcweir pObject->maSysData.hWnd = hWndChild; 368cdf0e10cSrcweir return pObject; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir return NULL; 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir // ======================================================================= 376cdf0e10cSrcweir 377cdf0e10cSrcweir long ImplSalObjCallbackDummy( void*, SalObject*, USHORT, const void* ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir return 0; 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir // ======================================================================= 383cdf0e10cSrcweir 384cdf0e10cSrcweir Os2SalObject::Os2SalObject() 385cdf0e10cSrcweir { 386cdf0e10cSrcweir SalData* pSalData = GetSalData(); 387cdf0e10cSrcweir 388cdf0e10cSrcweir mhLastClipWnd = HWND_TOP; 389cdf0e10cSrcweir 390cdf0e10cSrcweir mhWnd = 0; 391cdf0e10cSrcweir mhWndChild = 0; 392cdf0e10cSrcweir mhLastFocusWnd = 0; 393cdf0e10cSrcweir maSysData.nSize = sizeof( SystemEnvData ); 394cdf0e10cSrcweir mnHeight = 0; 395cdf0e10cSrcweir mpInst = NULL; 396cdf0e10cSrcweir mpProc = ImplSalObjCallbackDummy; 397cdf0e10cSrcweir 398cdf0e10cSrcweir // Hook installieren, wenn es das erste Os2SalObject ist 399cdf0e10cSrcweir if ( !pSalData->mpFirstObject ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir WinSetHook( pSalData->mhAB, pSalData->mhMQ, 402cdf0e10cSrcweir HK_INPUT, (PFN)SalSysMsgProc, (HMODULE)0 ); 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405cdf0e10cSrcweir // Insert object in objectlist 406cdf0e10cSrcweir mpNextObject = pSalData->mpFirstObject; 407cdf0e10cSrcweir pSalData->mpFirstObject = this; 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir // ----------------------------------------------------------------------- 411cdf0e10cSrcweir 412cdf0e10cSrcweir Os2SalObject::~Os2SalObject() 413cdf0e10cSrcweir { 414cdf0e10cSrcweir SalData* pSalData = GetSalData(); 415cdf0e10cSrcweir 416cdf0e10cSrcweir // remove frame from framelist 417cdf0e10cSrcweir if ( this == pSalData->mpFirstObject ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir pSalData->mpFirstObject = mpNextObject; 420cdf0e10cSrcweir 421cdf0e10cSrcweir // Wenn letztes Os2SalObject, dann Hook wieder entfernen 422cdf0e10cSrcweir if ( !pSalData->mpFirstObject ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir WinReleaseHook( pSalData->mhAB, pSalData->mhMQ, 425cdf0e10cSrcweir HK_INPUT, (PFN)SalSysMsgProc, (HMODULE)0 ); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir } 428cdf0e10cSrcweir else 429cdf0e10cSrcweir { 430cdf0e10cSrcweir Os2SalObject* pTempObject = pSalData->mpFirstObject; 431cdf0e10cSrcweir while ( pTempObject->mpNextObject != this ) 432cdf0e10cSrcweir pTempObject = pTempObject->mpNextObject; 433cdf0e10cSrcweir 434cdf0e10cSrcweir pTempObject->mpNextObject = mpNextObject; 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir // Cache-Daten zerstoeren 438cdf0e10cSrcweir ImplDestroyAllClipWindows( mhLastClipWnd ); 439cdf0e10cSrcweir 440cdf0e10cSrcweir if ( mhWndChild ) 441cdf0e10cSrcweir WinDestroyWindow( mhWndChild ); 442cdf0e10cSrcweir if ( mhWnd ) 443cdf0e10cSrcweir WinDestroyWindow( mhWnd ); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir // ----------------------------------------------------------------------- 447cdf0e10cSrcweir 448cdf0e10cSrcweir void Os2SalObject::ResetClipRegion() 449cdf0e10cSrcweir { 450cdf0e10cSrcweir ImplDestroyAllClipWindows( mhLastClipWnd ); 451cdf0e10cSrcweir mhLastClipWnd = HWND_TOP; 452cdf0e10cSrcweir } 453cdf0e10cSrcweir 454cdf0e10cSrcweir // ----------------------------------------------------------------------- 455cdf0e10cSrcweir 456cdf0e10cSrcweir USHORT Os2SalObject::GetClipRegionType() 457cdf0e10cSrcweir { 458cdf0e10cSrcweir return SAL_OBJECT_CLIP_EXCLUDERECTS; 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461cdf0e10cSrcweir // ----------------------------------------------------------------------- 462cdf0e10cSrcweir 463cdf0e10cSrcweir void Os2SalObject::BeginSetClipRegion( ULONG nRectCount ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir mhOldLastClipWnd = mhLastClipWnd; 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir // ----------------------------------------------------------------------- 469cdf0e10cSrcweir 470cdf0e10cSrcweir void Os2SalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir HWND hClipWnd = WinCreateWindow( mhWnd, SAL_OBJECT_CLIPCLASSNAME, "", 473cdf0e10cSrcweir WS_VISIBLE, 474cdf0e10cSrcweir nX, mnHeight-(nY+nHeight), nWidth, nHeight, 475cdf0e10cSrcweir mhWnd, mhLastClipWnd, 476cdf0e10cSrcweir 0, NULL, NULL ); 477cdf0e10cSrcweir debug_printf("Os2SalObject::UnionClipRegion hClipWnd %x\n", hClipWnd); 478cdf0e10cSrcweir mhLastClipWnd = hClipWnd; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir // ----------------------------------------------------------------------- 482cdf0e10cSrcweir 483cdf0e10cSrcweir void Os2SalObject::EndSetClipRegion() 484cdf0e10cSrcweir { 485cdf0e10cSrcweir ImplDestroyAllClipWindows( mhOldLastClipWnd ); 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir // ----------------------------------------------------------------------- 489cdf0e10cSrcweir 490cdf0e10cSrcweir void Os2SalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir ULONG nStyle = 0; 493*fc9fd3f1SPedro Giffuni sal_Bool bVisible = WinIsWindowVisible( mhWnd ); 494cdf0e10cSrcweir if ( bVisible ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir WinShowWindow( mhWnd, FALSE ); 497cdf0e10cSrcweir nStyle |= SWP_SHOW; 498cdf0e10cSrcweir } 499cdf0e10cSrcweir SWP aParentSWP; 500cdf0e10cSrcweir WinQueryWindowPos( WinQueryWindow( mhWnd, QW_PARENT ), &aParentSWP ); 501cdf0e10cSrcweir WinSetWindowPos( mhWnd, 0, nX, aParentSWP.cy-(nY+nHeight), nWidth, nHeight, 502cdf0e10cSrcweir SWP_MOVE | SWP_SIZE | nStyle ); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir // ----------------------------------------------------------------------- 506cdf0e10cSrcweir 507*fc9fd3f1SPedro Giffuni void Os2SalObject::Show( sal_Bool bVisible ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir WinShowWindow( mhWnd, bVisible ); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir // ----------------------------------------------------------------------- 513cdf0e10cSrcweir 514*fc9fd3f1SPedro Giffuni void Os2SalObject::Enable( sal_Bool bEnable ) 515cdf0e10cSrcweir { 516cdf0e10cSrcweir // Im Gegensatz zu Windows disablen wir das Childfenster, 517cdf0e10cSrcweir // da ansonsten unser Clippen nicht mehr funktioniert, da 518cdf0e10cSrcweir // wir keine Events mehr bekommen. Dadurch kann sich evtl. 519cdf0e10cSrcweir // das Fenster anders darstellen, was wir eigentlich nicht 520cdf0e10cSrcweir // wollen. Aber da uns bisher kein Fall bekannt ist, 521cdf0e10cSrcweir // ignorieren wir dies. Ansonsten muss ein Fenster dazwischen 522cdf0e10cSrcweir // gezogen werden oder getestet werden, wie wir die 523cdf0e10cSrcweir // Maustransparenz erreichen, wenn mhWnd 524cdf0e10cSrcweir // disablte wird. 525cdf0e10cSrcweir WinEnableWindow( mhWndChild, bEnable ); 526cdf0e10cSrcweir } 527cdf0e10cSrcweir 528cdf0e10cSrcweir // ----------------------------------------------------------------------- 529cdf0e10cSrcweir 530cdf0e10cSrcweir void Os2SalObject::GrabFocus() 531cdf0e10cSrcweir { 532cdf0e10cSrcweir if ( mhLastFocusWnd && 533cdf0e10cSrcweir WinIsWindow( GetSalData()->mhAB, mhLastFocusWnd ) && 534cdf0e10cSrcweir ImplIsSysWindowOrChild( mhWndChild, mhLastFocusWnd ) ) 535cdf0e10cSrcweir WinSetFocus( HWND_DESKTOP, mhLastFocusWnd ); 536cdf0e10cSrcweir else 537cdf0e10cSrcweir WinSetFocus( HWND_DESKTOP, mhWndChild ); 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir // ----------------------------------------------------------------------- 541cdf0e10cSrcweir 542cdf0e10cSrcweir void Os2SalObject::SetBackground() 543cdf0e10cSrcweir { 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir // ----------------------------------------------------------------------- 547cdf0e10cSrcweir 548cdf0e10cSrcweir void Os2SalObject::SetBackground( SalColor nSalColor ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir // ----------------------------------------------------------------------- 553cdf0e10cSrcweir 554cdf0e10cSrcweir const SystemChildData* Os2SalObject::GetSystemData() const 555cdf0e10cSrcweir { 556cdf0e10cSrcweir return &maSysData; 557cdf0e10cSrcweir } 558cdf0e10cSrcweir 559cdf0e10cSrcweir // ----------------------------------------------------------------------- 560cdf0e10cSrcweir #if 0 561cdf0e10cSrcweir void Os2SalObject::SetCallback( void* pInst, SALOBJECTPROC pProc ) 562cdf0e10cSrcweir { 563cdf0e10cSrcweir mpInst = pInst; 564cdf0e10cSrcweir if ( pProc ) 565cdf0e10cSrcweir mpProc = pProc; 566cdf0e10cSrcweir else 567cdf0e10cSrcweir mpProc = ImplSalObjCallbackDummy; 568cdf0e10cSrcweir } 569cdf0e10cSrcweir #endif 570cdf0e10cSrcweir 571cdf0e10cSrcweir // ----------------------------------------------------------------------- 572cdf0e10cSrcweir 573cdf0e10cSrcweir void Os2SalObject::InterceptChildWindowKeyDown( sal_Bool /*bIntercept*/ ) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir } 576cdf0e10cSrcweir 577