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 10cdf0e10cSrcweir * 119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 209f62ea84SAndrew Rist *************************************************************/ 219f62ea84SAndrew Rist 229f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include <svpm.h> 25cdf0e10cSrcweir 26fc9fd3f1SPedro Giffuni #include <string.h> 27fc9fd3f1SPedro Giffuni 28fc9fd3f1SPedro Giffuni #include <tools/debug.hxx> 29fc9fd3f1SPedro Giffuni #include <tools/svwin.h> 30fc9fd3f1SPedro Giffuni 31fc9fd3f1SPedro Giffuni #include "vcl/svapp.hxx" 32fc9fd3f1SPedro Giffuni 33fc9fd3f1SPedro Giffuni #include "os2/saldata.hxx" 34fc9fd3f1SPedro Giffuni #include "os2/salinst.h" 35fc9fd3f1SPedro Giffuni #include "os2/salframe.h" 36fc9fd3f1SPedro Giffuni #include "os2/salobj.h" 37cdf0e10cSrcweir 38cdf0e10cSrcweir // ======================================================================= 39cdf0e10cSrcweir 40fc9fd3f1SPedro 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 75fc9fd3f1SPedro 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 201*dcefce6cSYuri Dario #if OSL_DEBUG_LEVEL>0 202cdf0e10cSrcweir debug_printf( "SalSysObjChildWndProc hWnd 0x%x nMsg %d\n", hWnd, nMsg); 203*dcefce6cSYuri Dario #endif 204cdf0e10cSrcweir 205cdf0e10cSrcweir switch( nMsg ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir case WM_ERASEBACKGROUND: 208cdf0e10cSrcweir // Wegen PlugIn's loeschen wir erstmal den Hintergrund 209cdf0e10cSrcweir /* 210cdf0e10cSrcweir nRet = (MRESULT)FALSE; 211cdf0e10cSrcweir bDef = FALSE; 212cdf0e10cSrcweir */ 213cdf0e10cSrcweir break; 214cdf0e10cSrcweir case WM_PAINT: 215cdf0e10cSrcweir { 216cdf0e10cSrcweir HPS hPS; 217cdf0e10cSrcweir RECTL aRect; 218cdf0e10cSrcweir hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); 219cdf0e10cSrcweir WinEndPaint( hPS ); 220cdf0e10cSrcweir bDef = FALSE; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir break; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir if ( bDef ) 226cdf0e10cSrcweir nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); 227cdf0e10cSrcweir return nRet; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir // ----------------------------------------------------------------------- 231cdf0e10cSrcweir 232cdf0e10cSrcweir MRESULT EXPENTRY SalSysObjClipWndProc( HWND hWnd, ULONG nMsg, 233cdf0e10cSrcweir MPARAM nMP1, MPARAM nMP2 ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir MRESULT nRet = 0; 236cdf0e10cSrcweir int bDef = TRUE; 237cdf0e10cSrcweir 238*dcefce6cSYuri Dario #if OSL_DEBUG_LEVEL>0 239cdf0e10cSrcweir debug_printf( "SalSysObjClipWndProc hWnd 0x%x nMsg %d\n", hWnd, nMsg); 240*dcefce6cSYuri Dario #endif 241cdf0e10cSrcweir 242cdf0e10cSrcweir switch( nMsg ) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir case WM_MOUSEMOVE: 245cdf0e10cSrcweir case WM_BUTTON1DOWN: 246cdf0e10cSrcweir case WM_BUTTON2DOWN: 247cdf0e10cSrcweir case WM_BUTTON3DOWN: 248cdf0e10cSrcweir case WM_BUTTON1DBLCLK: 249cdf0e10cSrcweir case WM_BUTTON2DBLCLK: 250cdf0e10cSrcweir case WM_BUTTON3DBLCLK: 251cdf0e10cSrcweir case WM_BUTTON1UP: 252cdf0e10cSrcweir case WM_BUTTON2UP: 253cdf0e10cSrcweir case WM_BUTTON3UP: 254cdf0e10cSrcweir { 255cdf0e10cSrcweir // Alle Events an den Frame weiterreichen, da diese Bereiche 256cdf0e10cSrcweir // dem Frame gehoeren. Dazu muessen die Mouse-Koordinaaten 257cdf0e10cSrcweir // entsprechend umgerechnet werden 258cdf0e10cSrcweir HWND hWndParent = WinQueryWindow( hWnd, QW_PARENT ); // ergibt SysChild-Fenster 259cdf0e10cSrcweir hWndParent = WinQueryWindow( hWndParent, QW_PARENT ); 260cdf0e10cSrcweir short nX = (short)SHORT1FROMMP( nMP1 ); 261cdf0e10cSrcweir short nY = (short)SHORT2FROMMP( nMP1 ); 262cdf0e10cSrcweir POINTL aPos; 263cdf0e10cSrcweir aPos.x = nX; 264cdf0e10cSrcweir aPos.y = nY; 265cdf0e10cSrcweir WinMapWindowPoints( hWnd, hWndParent, &aPos, 1 ); 266cdf0e10cSrcweir nMP1 = MPFROM2SHORT( (short)aPos.x, (short)aPos.y ); 267cdf0e10cSrcweir bDef = FALSE; 268cdf0e10cSrcweir nRet = WinSendMsg( hWndParent, nMsg, nMP1, nMP2 ); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir break; 271cdf0e10cSrcweir 272cdf0e10cSrcweir case WM_HITTEST: 273cdf0e10cSrcweir // Damit im disablten Zustand die MouseKlicks immer noch 274cdf0e10cSrcweir // an den Frame geschickt werden 275cdf0e10cSrcweir // Dieser Code reicht leider nicht aus, deshalb wir unter 276cdf0e10cSrcweir // OS2 immer das Child-Fenster disablen, im Gegensatz 277cdf0e10cSrcweir // zu Windows, wo immer der Parent disablte wird, da 278cdf0e10cSrcweir // sich das Fenster evtl. anders Darstellen koennte, 279cdf0e10cSrcweir // wenn es disablte wird. Da dieser Fall uns bisher 280cdf0e10cSrcweir // nicht bekannt ist, ignorieren wir das. 281cdf0e10cSrcweir nRet = HT_NORMAL; 282cdf0e10cSrcweir bDef = FALSE; 283cdf0e10cSrcweir break; 284cdf0e10cSrcweir 285cdf0e10cSrcweir case WM_ERASEBACKGROUND: 286cdf0e10cSrcweir nRet = (MRESULT)FALSE; 287cdf0e10cSrcweir bDef = FALSE; 288cdf0e10cSrcweir break; 289cdf0e10cSrcweir case WM_PAINT: 290cdf0e10cSrcweir { 291cdf0e10cSrcweir HPS hPS; 292cdf0e10cSrcweir RECTL aRect; 293cdf0e10cSrcweir hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); 294cdf0e10cSrcweir WinEndPaint( hPS ); 295cdf0e10cSrcweir bDef = FALSE; 296cdf0e10cSrcweir } 297cdf0e10cSrcweir break; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir if ( bDef ) 301cdf0e10cSrcweir nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); 302cdf0e10cSrcweir return nRet; 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir // ======================================================================= 306cdf0e10cSrcweir 307cdf0e10cSrcweir void ImplDestroyAllClipWindows( HWND hWndLast ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir if ( hWndLast == HWND_TOP ) 310cdf0e10cSrcweir return; 311cdf0e10cSrcweir 312cdf0e10cSrcweir HWND hWndPrev; 313cdf0e10cSrcweir while ( hWndLast ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir hWndPrev = WinQueryWindow( hWndLast, QW_PREV ); 316cdf0e10cSrcweir WinDestroyWindow( hWndLast ); 317cdf0e10cSrcweir hWndLast = hWndPrev; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir // ======================================================================= 322cdf0e10cSrcweir 323cdf0e10cSrcweir SalObject* ImplSalCreateObject( Os2SalInstance* pInst, Os2SalFrame* pParent ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir SalData* pSalData = GetSalData(); 326cdf0e10cSrcweir 327cdf0e10cSrcweir if ( !pSalData->mbObjClassInit ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CLASSNAME, 330cdf0e10cSrcweir (PFNWP)SalSysObjWndProc, CS_MOVENOTIFY, 331cdf0e10cSrcweir SAL_OBJECT_WNDEXTRA ) ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CLIPCLASSNAME, 334cdf0e10cSrcweir (PFNWP)SalSysObjClipWndProc, CS_HITTEST | CS_MOVENOTIFY, 0 ) ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CHILDCLASSNAME, 337cdf0e10cSrcweir (PFNWP)SalSysObjChildWndProc, CS_HITTEST | CS_MOVENOTIFY, 32 ) ) 338cdf0e10cSrcweir pSalData->mbObjClassInit = TRUE; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir } 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir if ( pSalData->mbObjClassInit ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir Os2SalObject* pObject = new Os2SalObject; 346cdf0e10cSrcweir HWND hWnd = WinCreateWindow( pParent->mhWndClient, SAL_OBJECT_CLASSNAME, "", 347cdf0e10cSrcweir 0, 348cdf0e10cSrcweir 0, 0, 0, 0, 349cdf0e10cSrcweir pParent->mhWndClient, HWND_TOP, 350cdf0e10cSrcweir 0, NULL, (void*)pObject ); 351cdf0e10cSrcweir HWND hWndChild = WinCreateWindow( hWnd, SAL_OBJECT_CHILDCLASSNAME, "", 352cdf0e10cSrcweir WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, 353cdf0e10cSrcweir 0, 0, 0, 0, 354cdf0e10cSrcweir hWnd, HWND_TOP, 355cdf0e10cSrcweir 0, NULL, NULL ); 356cdf0e10cSrcweir 357cdf0e10cSrcweir if ( !hWndChild ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir if ( hWnd ) 360cdf0e10cSrcweir WinDestroyWindow( hWnd ); 361cdf0e10cSrcweir delete pObject; 362cdf0e10cSrcweir return NULL; 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir if ( hWnd ) 366cdf0e10cSrcweir { 367*dcefce6cSYuri Dario #if OSL_DEBUG_LEVEL>0 368cdf0e10cSrcweir debug_printf("ImplSalCreateObject hWndChild %x\n", hWndChild); 369cdf0e10cSrcweir debug_printf("ImplSalCreateObject hWnd %x\n", hWnd); 370*dcefce6cSYuri Dario #endif 371cdf0e10cSrcweir pObject->mhWnd = hWnd; 372cdf0e10cSrcweir pObject->mhWndChild = hWndChild; 373cdf0e10cSrcweir pObject->maSysData.hWnd = hWndChild; 374cdf0e10cSrcweir return pObject; 375cdf0e10cSrcweir } 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir return NULL; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir // ======================================================================= 382cdf0e10cSrcweir 383cdf0e10cSrcweir long ImplSalObjCallbackDummy( void*, SalObject*, USHORT, const void* ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir return 0; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir // ======================================================================= 389cdf0e10cSrcweir 390cdf0e10cSrcweir Os2SalObject::Os2SalObject() 391cdf0e10cSrcweir { 392cdf0e10cSrcweir SalData* pSalData = GetSalData(); 393cdf0e10cSrcweir 394cdf0e10cSrcweir mhLastClipWnd = HWND_TOP; 395cdf0e10cSrcweir 396cdf0e10cSrcweir mhWnd = 0; 397cdf0e10cSrcweir mhWndChild = 0; 398cdf0e10cSrcweir mhLastFocusWnd = 0; 399cdf0e10cSrcweir maSysData.nSize = sizeof( SystemEnvData ); 400cdf0e10cSrcweir mnHeight = 0; 401cdf0e10cSrcweir mpInst = NULL; 402cdf0e10cSrcweir mpProc = ImplSalObjCallbackDummy; 403cdf0e10cSrcweir 404cdf0e10cSrcweir // Hook installieren, wenn es das erste Os2SalObject ist 405cdf0e10cSrcweir if ( !pSalData->mpFirstObject ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir WinSetHook( pSalData->mhAB, pSalData->mhMQ, 408cdf0e10cSrcweir HK_INPUT, (PFN)SalSysMsgProc, (HMODULE)0 ); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir // Insert object in objectlist 412cdf0e10cSrcweir mpNextObject = pSalData->mpFirstObject; 413cdf0e10cSrcweir pSalData->mpFirstObject = this; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir // ----------------------------------------------------------------------- 417cdf0e10cSrcweir 418cdf0e10cSrcweir Os2SalObject::~Os2SalObject() 419cdf0e10cSrcweir { 420cdf0e10cSrcweir SalData* pSalData = GetSalData(); 421cdf0e10cSrcweir 422cdf0e10cSrcweir // remove frame from framelist 423cdf0e10cSrcweir if ( this == pSalData->mpFirstObject ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir pSalData->mpFirstObject = mpNextObject; 426cdf0e10cSrcweir 427cdf0e10cSrcweir // Wenn letztes Os2SalObject, dann Hook wieder entfernen 428cdf0e10cSrcweir if ( !pSalData->mpFirstObject ) 429cdf0e10cSrcweir { 430cdf0e10cSrcweir WinReleaseHook( pSalData->mhAB, pSalData->mhMQ, 431cdf0e10cSrcweir HK_INPUT, (PFN)SalSysMsgProc, (HMODULE)0 ); 432cdf0e10cSrcweir } 433cdf0e10cSrcweir } 434cdf0e10cSrcweir else 435cdf0e10cSrcweir { 436cdf0e10cSrcweir Os2SalObject* pTempObject = pSalData->mpFirstObject; 437cdf0e10cSrcweir while ( pTempObject->mpNextObject != this ) 438cdf0e10cSrcweir pTempObject = pTempObject->mpNextObject; 439cdf0e10cSrcweir 440cdf0e10cSrcweir pTempObject->mpNextObject = mpNextObject; 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir // Cache-Daten zerstoeren 444cdf0e10cSrcweir ImplDestroyAllClipWindows( mhLastClipWnd ); 445cdf0e10cSrcweir 446cdf0e10cSrcweir if ( mhWndChild ) 447cdf0e10cSrcweir WinDestroyWindow( mhWndChild ); 448cdf0e10cSrcweir if ( mhWnd ) 449cdf0e10cSrcweir WinDestroyWindow( mhWnd ); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir // ----------------------------------------------------------------------- 453cdf0e10cSrcweir 454cdf0e10cSrcweir void Os2SalObject::ResetClipRegion() 455cdf0e10cSrcweir { 456cdf0e10cSrcweir ImplDestroyAllClipWindows( mhLastClipWnd ); 457cdf0e10cSrcweir mhLastClipWnd = HWND_TOP; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir // ----------------------------------------------------------------------- 461cdf0e10cSrcweir 462cdf0e10cSrcweir USHORT Os2SalObject::GetClipRegionType() 463cdf0e10cSrcweir { 464cdf0e10cSrcweir return SAL_OBJECT_CLIP_EXCLUDERECTS; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir // ----------------------------------------------------------------------- 468cdf0e10cSrcweir 469cdf0e10cSrcweir void Os2SalObject::BeginSetClipRegion( ULONG nRectCount ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir mhOldLastClipWnd = mhLastClipWnd; 472cdf0e10cSrcweir } 473cdf0e10cSrcweir 474cdf0e10cSrcweir // ----------------------------------------------------------------------- 475cdf0e10cSrcweir 476cdf0e10cSrcweir void Os2SalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir HWND hClipWnd = WinCreateWindow( mhWnd, SAL_OBJECT_CLIPCLASSNAME, "", 479cdf0e10cSrcweir WS_VISIBLE, 480cdf0e10cSrcweir nX, mnHeight-(nY+nHeight), nWidth, nHeight, 481cdf0e10cSrcweir mhWnd, mhLastClipWnd, 482cdf0e10cSrcweir 0, NULL, NULL ); 483*dcefce6cSYuri Dario #if OSL_DEBUG_LEVEL>0 484cdf0e10cSrcweir debug_printf("Os2SalObject::UnionClipRegion hClipWnd %x\n", hClipWnd); 485*dcefce6cSYuri Dario #endif 486cdf0e10cSrcweir mhLastClipWnd = hClipWnd; 487cdf0e10cSrcweir } 488cdf0e10cSrcweir 489cdf0e10cSrcweir // ----------------------------------------------------------------------- 490cdf0e10cSrcweir 491cdf0e10cSrcweir void Os2SalObject::EndSetClipRegion() 492cdf0e10cSrcweir { 493cdf0e10cSrcweir ImplDestroyAllClipWindows( mhOldLastClipWnd ); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir // ----------------------------------------------------------------------- 497cdf0e10cSrcweir 498cdf0e10cSrcweir void Os2SalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir ULONG nStyle = 0; 501fc9fd3f1SPedro Giffuni sal_Bool bVisible = WinIsWindowVisible( mhWnd ); 502cdf0e10cSrcweir if ( bVisible ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir WinShowWindow( mhWnd, FALSE ); 505cdf0e10cSrcweir nStyle |= SWP_SHOW; 506cdf0e10cSrcweir } 507cdf0e10cSrcweir SWP aParentSWP; 508cdf0e10cSrcweir WinQueryWindowPos( WinQueryWindow( mhWnd, QW_PARENT ), &aParentSWP ); 509cdf0e10cSrcweir WinSetWindowPos( mhWnd, 0, nX, aParentSWP.cy-(nY+nHeight), nWidth, nHeight, 510cdf0e10cSrcweir SWP_MOVE | SWP_SIZE | nStyle ); 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir // ----------------------------------------------------------------------- 514cdf0e10cSrcweir 515fc9fd3f1SPedro Giffuni void Os2SalObject::Show( sal_Bool bVisible ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir WinShowWindow( mhWnd, bVisible ); 518cdf0e10cSrcweir } 519cdf0e10cSrcweir 520cdf0e10cSrcweir // ----------------------------------------------------------------------- 521cdf0e10cSrcweir 522fc9fd3f1SPedro Giffuni void Os2SalObject::Enable( sal_Bool bEnable ) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir // Im Gegensatz zu Windows disablen wir das Childfenster, 525cdf0e10cSrcweir // da ansonsten unser Clippen nicht mehr funktioniert, da 526cdf0e10cSrcweir // wir keine Events mehr bekommen. Dadurch kann sich evtl. 527cdf0e10cSrcweir // das Fenster anders darstellen, was wir eigentlich nicht 528cdf0e10cSrcweir // wollen. Aber da uns bisher kein Fall bekannt ist, 529cdf0e10cSrcweir // ignorieren wir dies. Ansonsten muss ein Fenster dazwischen 530cdf0e10cSrcweir // gezogen werden oder getestet werden, wie wir die 531cdf0e10cSrcweir // Maustransparenz erreichen, wenn mhWnd 532cdf0e10cSrcweir // disablte wird. 533cdf0e10cSrcweir WinEnableWindow( mhWndChild, bEnable ); 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir // ----------------------------------------------------------------------- 537cdf0e10cSrcweir 538cdf0e10cSrcweir void Os2SalObject::GrabFocus() 539cdf0e10cSrcweir { 540cdf0e10cSrcweir if ( mhLastFocusWnd && 541cdf0e10cSrcweir WinIsWindow( GetSalData()->mhAB, mhLastFocusWnd ) && 542cdf0e10cSrcweir ImplIsSysWindowOrChild( mhWndChild, mhLastFocusWnd ) ) 543cdf0e10cSrcweir WinSetFocus( HWND_DESKTOP, mhLastFocusWnd ); 544cdf0e10cSrcweir else 545cdf0e10cSrcweir WinSetFocus( HWND_DESKTOP, mhWndChild ); 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 548cdf0e10cSrcweir // ----------------------------------------------------------------------- 549cdf0e10cSrcweir 550cdf0e10cSrcweir void Os2SalObject::SetBackground() 551cdf0e10cSrcweir { 552cdf0e10cSrcweir } 553cdf0e10cSrcweir 554cdf0e10cSrcweir // ----------------------------------------------------------------------- 555cdf0e10cSrcweir 556cdf0e10cSrcweir void Os2SalObject::SetBackground( SalColor nSalColor ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir // ----------------------------------------------------------------------- 561cdf0e10cSrcweir 562cdf0e10cSrcweir const SystemChildData* Os2SalObject::GetSystemData() const 563cdf0e10cSrcweir { 564cdf0e10cSrcweir return &maSysData; 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir // ----------------------------------------------------------------------- 568cdf0e10cSrcweir #if 0 569cdf0e10cSrcweir void Os2SalObject::SetCallback( void* pInst, SALOBJECTPROC pProc ) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir mpInst = pInst; 572cdf0e10cSrcweir if ( pProc ) 573cdf0e10cSrcweir mpProc = pProc; 574cdf0e10cSrcweir else 575cdf0e10cSrcweir mpProc = ImplSalObjCallbackDummy; 576cdf0e10cSrcweir } 577cdf0e10cSrcweir #endif 578cdf0e10cSrcweir 579cdf0e10cSrcweir // ----------------------------------------------------------------------- 580cdf0e10cSrcweir 581cdf0e10cSrcweir void Os2SalObject::InterceptChildWindowKeyDown( sal_Bool /*bIntercept*/ ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585