From 8ab086b6cc054501bfbf7ef6fa509c393691e860 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Mon, 18 Sep 2000 16:07:07 +0000 Subject: initial import --- vcl/os2/inc/saldata.hxx | 278 ++++ vcl/os2/inc/salframe.h | 113 ++ vcl/os2/inc/salgdi.h | 108 ++ vcl/os2/inc/salids.hrc | 134 ++ vcl/os2/inc/salinst.h | 109 ++ vcl/os2/inc/sallang.hxx | 103 ++ vcl/os2/inc/salobj.h | 91 ++ vcl/os2/inc/salprn.h | 119 ++ vcl/os2/inc/salsound.hxx | 125 ++ vcl/os2/inc/salsys.h | 79 ++ vcl/os2/inc/salvd.h | 91 ++ vcl/os2/inc/svsys.h | 69 + vcl/os2/source/app/makefile.mk | 96 ++ vcl/os2/source/app/salinst.cxx | 754 ++++++++++ vcl/os2/source/app/sallang.cxx | 406 ++++++ vcl/os2/source/app/salshl.cxx | 84 ++ vcl/os2/source/app/salsound.cxx | 421 ++++++ vcl/os2/source/app/salsys.cxx | 287 ++++ vcl/os2/source/app/saltimer.cxx | 122 ++ vcl/os2/source/gdi/makefile.mk | 94 ++ vcl/os2/source/gdi/salbmp.cxx | 760 ++++++++++ vcl/os2/source/gdi/salgdi.cxx | 852 +++++++++++ vcl/os2/source/gdi/salgdi2.cxx | 786 ++++++++++ vcl/os2/source/gdi/salgdi3.cxx | 780 ++++++++++ vcl/os2/source/gdi/salogl.cxx | 263 ++++ vcl/os2/source/gdi/salprn.cxx | 1878 ++++++++++++++++++++++++ vcl/os2/source/gdi/salvd.cxx | 230 +++ vcl/os2/source/src/makefile.mk | 147 ++ vcl/os2/source/src/salsrc.rc | 134 ++ vcl/os2/source/window/makefile | 40 + vcl/os2/source/window/makefile.mk | 84 ++ vcl/os2/source/window/salframe.cxx | 2762 ++++++++++++++++++++++++++++++++++++ vcl/os2/source/window/salobj.cxx | 605 ++++++++ 33 files changed, 13004 insertions(+) create mode 100644 vcl/os2/inc/saldata.hxx create mode 100644 vcl/os2/inc/salframe.h create mode 100644 vcl/os2/inc/salgdi.h create mode 100644 vcl/os2/inc/salids.hrc create mode 100644 vcl/os2/inc/salinst.h create mode 100644 vcl/os2/inc/sallang.hxx create mode 100644 vcl/os2/inc/salobj.h create mode 100644 vcl/os2/inc/salprn.h create mode 100644 vcl/os2/inc/salsound.hxx create mode 100644 vcl/os2/inc/salsys.h create mode 100644 vcl/os2/inc/salvd.h create mode 100644 vcl/os2/inc/svsys.h create mode 100644 vcl/os2/source/app/makefile.mk create mode 100644 vcl/os2/source/app/salinst.cxx create mode 100644 vcl/os2/source/app/sallang.cxx create mode 100644 vcl/os2/source/app/salshl.cxx create mode 100644 vcl/os2/source/app/salsound.cxx create mode 100644 vcl/os2/source/app/salsys.cxx create mode 100644 vcl/os2/source/app/saltimer.cxx create mode 100644 vcl/os2/source/gdi/makefile.mk create mode 100644 vcl/os2/source/gdi/salbmp.cxx create mode 100644 vcl/os2/source/gdi/salgdi.cxx create mode 100644 vcl/os2/source/gdi/salgdi2.cxx create mode 100644 vcl/os2/source/gdi/salgdi3.cxx create mode 100644 vcl/os2/source/gdi/salogl.cxx create mode 100644 vcl/os2/source/gdi/salprn.cxx create mode 100644 vcl/os2/source/gdi/salvd.cxx create mode 100644 vcl/os2/source/src/makefile.mk create mode 100644 vcl/os2/source/src/salsrc.rc create mode 100644 vcl/os2/source/window/makefile create mode 100644 vcl/os2/source/window/makefile.mk create mode 100644 vcl/os2/source/window/salframe.cxx create mode 100644 vcl/os2/source/window/salobj.cxx (limited to 'vcl/os2') diff --git a/vcl/os2/inc/saldata.hxx b/vcl/os2/inc/saldata.hxx new file mode 100644 index 000000000000..fb835f8a45cd --- /dev/null +++ b/vcl/os2/inc/saldata.hxx @@ -0,0 +1,278 @@ +/************************************************************************* + * + * $RCSfile: saldata.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALDATA_HXX +#define _SV_SALDATA_HXX + +#ifndef _SV_SV_H +#include +#endif +#ifndef _SV_SVDATA_HXX +#include +#endif +#ifndef _SV_SALWTYPE_HXX +#include +#endif + +class SalFrame; +class SalObject; + +// -------------- +// - SalIMEData - +// -------------- + +#define ENABLE_IME + +#ifdef ENABLE_IME + +struct SalIMEData; + +#ifdef OS2IM_INCLUDED + +typedef APIRET (APIENTRY ImAssociateInstanceFunc)( HWND hwnd, HIMI himi, PHIMI phimiPrev ); +typedef APIRET (APIENTRY ImGetInstanceFunc)( HWND hwnd, PHIMI phimi ); +typedef APIRET (APIENTRY ImReleaseInstanceFunc)( HWND hwnd, HIMI himi ); +typedef APIRET (APIENTRY ImSetConversionFontFunc)( HIMI himi, PFATTRS pFontAttrs ); +typedef APIRET (APIENTRY ImSetConversionFontSizeFunc)( HIMI himi, PSIZEF psizfxBox ); +typedef APIRET (APIENTRY ImGetConversionStringFunc)( HIMI himi, ULONG ulIndex, PVOID pBuf, PULONG pulBufLen ); +typedef APIRET (APIENTRY ImGetResultStringFunc)( HIMI himi, ULONG ulIndex, PVOID pBuf, PULONG pulBufLen ); +typedef APIRET (APIENTRY ImSetCandidateWindowPosFunc)( HIMI himi, PCANDIDATEPOS pCandidatePos ); +typedef APIRET (APIENTRY ImQueryIMEPropertyFunc)( HIMI himi, ULONG ulIndex, PULONG pulProp ); +typedef APIRET (APIENTRY ImRequestIMEFunc)( HIMI himi, ULONG ulAction, ULONG ulIndex, ULONG ulValue ); +typedef APIRET (APIENTRY ImSetIMModeFunc)( HIMI himi, ULONG ulInputMode, ULONG ulConversionMode ); +typedef APIRET (APIENTRY ImQueryIMModeFunc)( HIMI himi, PULONG pulInputMode, PULONG pulConversionMode ); + +struct SalIMEData +{ + HMODULE mhModIME; + ImAssociateInstanceFunc* mpAssocIME; + ImGetInstanceFunc* mpGetIME; + ImReleaseInstanceFunc* mpReleaseIME; + ImSetConversionFontFunc* mpSetConversionFont; + ImSetConversionFontSizeFunc* mpSetConversionFontSize; + ImGetConversionStringFunc* mpGetConversionString; + ImGetResultStringFunc* mpGetResultString; + ImSetCandidateWindowPosFunc* mpSetCandidateWin; + ImQueryIMEPropertyFunc* mpQueryIMEProperty; + ImRequestIMEFunc* mpRequestIME; + ImSetIMModeFunc* mpSetIMEMode; + ImQueryIMModeFunc* mpQueryIMEMode; +}; + +#endif + +#endif + +// ----------- +// - SalData - +// ----------- + +struct SalData +{ + HAB mhAB; // anchor block handle + HMQ mhMQ; // handle of os2 message queue + int mnArgc; // commandline param count + char** mpArgv; // commandline + ULONG mnNewTimerMS; // Neue Zeit, mit dem der Timer gestartet werden soll + PM_ULONG mnTimerId; // os2 timer id + SALTIMERPROC mpTimerProc; // timer callback proc + HWND mhWantLeaveMsg; // window handle, that want a MOUSELEAVE message + AutoTimer* mpMouseLeaveTimer; // Timer for MouseLeave Test + SalInstance* mpFirstInstance; // pointer of first instance + SalFrame* mpFirstFrame; // pointer of first frame + SalFrame* mpDummyFrame; // Dummy-Frame + SalFrame* mpCreateFrame; // Create-Frame for WM_CREATE + SalFrame* mpDefaultFrame; // Default-Frame (App-Fenster) + SalObject* mpFirstObject; // pointer of first object window + ULONG mnAppThreadId; // Id from Applikation-Thread + ULONG mnFontMetricCount; // number of entries in the font list + PFONTMETRICS mpFontMetrics; // cached font list + BOOL mbObjClassInit; // Ist SALOBJECTCLASS initialised +#ifdef ENABLE_IME + SalIMEData* mpIMEData; // SalIME-Data + BOOL mbIMEInit; // SalIME-Data-Init +#endif +}; + +inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; } +inline SalData* GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; } +inline SalData* GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; } + +// -------------- +// - SalShlData - +// -------------- + +#define OS2_VER_211 211 +#define OS2_VER_WARP3 230 +#define OS2_VER_WARP4 240 + +struct SalShlData +{ + HMODULE mhMod; // Module handle of SAL-DLL + USHORT mnVersion; // 211 = OS2 2.11; 230 = OS2 3.0; 240 = OS2 4.0 + PFNWP mpOldFrameProc; // old frame proc +}; + +extern SalShlData aSalShlData; + +BOOL SalImplHandleProcessMenu( HWND hWnd, PM_ULONG nMsg, MPARAM nMP1, MPARAM nMP2 ); + +// SALSHL.CXX - Funktionen fuer DLL-Resource-Zugriffe +HPOINTER ImplLoadPointer( ULONG nId ); + +// -------------- +// - Prototypes - +// -------------- + +// \\OS2\SOURCE\APP\SALINST.CXX +ULONG ImplSalGetCurrentThreadId(); +BOOL ImplSalYieldMutexTryToAcquire(); +void ImplSalYieldMutexAcquire(); +void ImplSalYieldMutexRelease(); + +// \\OS2\SOURCE\WINDOW\SALFRAME.CXX +MRESULT EXPENTRY SalFrameWndProc( HWND hWnd, PM_ULONG nMsg, MPARAM nMP1, MPARAM nMP2 ); +MRESULT EXPENTRY SalFrameFrameProc( HWND hWnd, PM_ULONG nMsg, MPARAM nMP1, MPARAM nMP2 ); + +// \\OS2\SOURCE\WINDOW\SALFRAME.CXX +// return Frame for Message-Handling +SalFrame* GetSalDefaultFrame(); + +// \\OS2\SOURCE\WINDOW\SALFRAME.CXX +// IME-Daten wieder freigeben +#ifdef ENABLE_IME +void ImplReleaseSALIMEData(); +#endif + +// ----------- +// - Defines - +// ----------- + +#define SAL_PROFILE_APPNAME ((PSZ)"StarOffice") +#define SAL_PROFILE_USEDJP ((PSZ)"UseDJP") +#define SAL_PROFILE_PRINTDJP ((PSZ)"PrintDJP") +#define SAL_PROFILE_PRINTRAW ((PSZ)"PrintRAW") + +#define SAL_FRAME_WNDEXTRA sizeof(PM_ULONG) +#define SAL_FRAME_THIS 0 +#define SAL_FRAME_CLASSNAME "SALFRAME" +#define SAL_OBJECT_WNDEXTRA sizeof(PM_ULONG) +#define SAL_OBJECT_THIS 0 +#define SAL_OBJECT_CLASSNAME "SALOBJECT" +#define SAL_OBJECT_CHILDCLASSNAME "SALOBJECTCHILD" +#define SAL_OBJECT_CLIPCLASSNAME "SALOBJECTCLIP" +#define SAL_COM_CLASSNAME "SALCOMWND" + +#define SAL_MOUSELEAVE_TIMEOUT 300 + +// MP1 == 0; MP2 == pData +#define SAL_MSG_USEREVENT (WM_USER+111) +// MP1 == 0; MP2 == MousePosition relativ to upper left of screen +#define SAL_MSG_MOUSELEAVE (WM_USER+112) +// MP1 == hDC; MP2 == 0 +#define SAL_MSG_PRINTABORTJOB (WM_USER+113) +// MP1 == 0; MP2 == 0 +#define SAL_MSG_STARTTIMER (WM_USER+114) +// MP1 == nFrameStyle; MP2 == pParent; lResult pFrame +#define SAL_MSG_CREATEFRAME (WM_USER+115) +// MP1 == 0; MP2 == pParent; lResult pObject +#define SAL_MSG_CREATEOBJECT (WM_USER+116) +// MP1 == bWait; MP2 == pMutex +#define SAL_MSG_THREADYIELD (WM_USER+117) +// MP1 == 0; MP2 == 0 +#define SAL_MSG_RELEASEWAITYIELD (WM_USER+118) +// MP1 == 0; MP2 == pData +#define SAL_MSG_SYSPROCESSMENU (WM_USER+119) +// POSTFOCUS-Message; MP1 == nMP1; MP2 == nMP2 (SHORT1( bFocus ), 0) +#define SAL_MSG_POSTFOCUS (WM_USER+120) +// POSTSIZE-Message; MP1 == nMP1; MP2 == nMP2 +#define SAL_MSG_POSTSIZE (WM_USER+121) + +// SysChild-ToTop; nMP1 = 0; nMP2 = 0 +#define SALOBJ_MSG_TOTOP (WM_USER+150) +// POSTFOCUS-Message; MP1 == nMP1; MP2 == nMP2 (SHORT1( bFocus ), 0) +#define SALOBJ_MSG_POSTFOCUS (WM_USER+151) + +// ----------------- +// - Helpfunctions - +// ----------------- + +inline void SetWindowPtr( HWND hWnd, SalFrame* pThis ) +{ + WinSetWindowULong( hWnd, SAL_FRAME_THIS, (PM_ULONG)pThis ); +} + +inline SalFrame* GetWindowPtr( HWND hWnd ) +{ + return (SalFrame*)WinQueryWindowULong( hWnd, SAL_FRAME_THIS ); +} + +inline void SetSalObjWindowPtr( HWND hWnd, SalObject* pThis ) +{ + WinSetWindowULong( hWnd, SAL_OBJECT_THIS, (PM_ULONG)pThis ); +} + +inline SalObject* GetSalObjWindowPtr( HWND hWnd ) +{ + return (SalObject*)WinQueryWindowULong( hWnd, SAL_OBJECT_THIS ); +} + +#endif // _SV_SALDATA_HXX diff --git a/vcl/os2/inc/salframe.h b/vcl/os2/inc/salframe.h new file mode 100644 index 000000000000..6d71e5c457d4 --- /dev/null +++ b/vcl/os2/inc/salframe.h @@ -0,0 +1,113 @@ +/************************************************************************* + * + * $RCSfile: salframe.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALFRAME_H +#define _SV_SALFRAME_H + +#ifndef _SV_SV_H +#include +#endif + +#ifndef _SV_SYSDATA_HXX +#include +#endif + +class SalFrame; + +// ---------------- +// - SalFrameData - +// ---------------- + +class SalFrameData +{ +public: + HWND mhWndFrame; // HWND-Frame + HWND mhWndClient; // HWND-Client + HAB mhAB; // HAB + HPOINTER mhPointer; // Current MousePointer + void* mpInst; // VCL-Instance + SALFRAMEPROC mpProc; // VCL-Proc + SalGraphics* mpGraphics; // current frame graphics + SalFrame* mpNextFrame; // pointer to next frame + SalFrameState maState; // frame state + SystemEnvData maSysData; // system data + ULONG mnStyle; // SalFrameStyle + PM_ULONG mnOS2Style; // OS2-CreationFrameStyle + long mnWidth; // Window-Witdth + long mnHeight; // Window-Height + SWP maFullScreenRect; // WindowRect befor FullScreenMode + BOOL mbFullScreen; // is in fullscreenmode + BOOL mbGraphics; // is Graphics used + BOOL mbAllwayOnTop; // Allways on top modus + BOOL mbVisible; // Visible Show/Hide-Status + BOOL mbMinHide; // hide called from OS2 + BOOL mbInShow; // innerhalb eines Show/Hide-Aufrufs + BOOL mbRestoreMaximize; // Restore-Maximize + BOOL mbInMoveMsg; // Move-Message wird verarbeitet + BOOL mbInSizeMsg; // Size-Message wird verarbeitet + BOOL mbDefPos; // default-position + BOOL mbOverwriteState; // TRUE: WindowState darf umgesetzt werden + BOOL mbHandleIME; // TRUE: Wir handeln die IME-Messages + BOOL mbConversionMode; // TRUE: Wir befinden uns im Conversion-Modus + BOOL mbCandidateMode; // TRUE: Wir befinden uns im Candidate-Modus +}; + +#endif // _SV_SALFRAME_H diff --git a/vcl/os2/inc/salgdi.h b/vcl/os2/inc/salgdi.h new file mode 100644 index 000000000000..b2afac448744 --- /dev/null +++ b/vcl/os2/inc/salgdi.h @@ -0,0 +1,108 @@ +/************************************************************************* + * + * $RCSfile: salgdi.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALGDI_H +#define _SV_SALGDI_H + +#ifndef _SV_SV_H +#include +#endif + +// ------------------- +// - SalGraphicsData - +// ------------------- + +class SalGraphicsData +{ +public: + HPS mhPS; // HPS + HDC mhDC; // HDC + HWND mhWnd; // HWND + LONG mnHeight; // Height of frame Window + ULONG mnClipElementCount; // number of clip rects in clip rect array + RECTL* mpClipRectlAry; // clip rect array + ULONG mnFontMetricCount; // number of entries in the font list + PFONTMETRICS mpFontMetrics; // cached font list + LONG mnOrientationX; // X-Font orientation + LONG mnOrientationY; // Y-Font orientation + BOOL mbFontIsOutline; // is outline font + BOOL mbFontIsFixed; // is fixed font + BOOL mbLine; // draw lines + BOOL mbFill; // fill areas + BOOL mbPrinter; // is Printer + BOOL mbVirDev; // is VirDev + BOOL mbWindow; // is Window + BOOL mbScreen; // is Screen compatible + BOOL mbXORMode; // _every_ output with RasterOp XOR +}; + +// Init/Deinit Graphics +void ImplSalInitGraphics( SalGraphicsData* mpData ); +void ImplSalDeInitGraphics( SalGraphicsData* mpData ); + +// ----------- +// - Defines - +// ----------- + +#define RGBCOLOR(r,g,b) ((ULONG)(((BYTE)(b)|((USHORT)(g)<<8))|(((ULONG)(BYTE)(r))<<16))) +#define TY( y ) (maGraphicsData.mnHeight-(y)-1) + +#endif // _SV_SALGDI_H diff --git a/vcl/os2/inc/salids.hrc b/vcl/os2/inc/salids.hrc new file mode 100644 index 000000000000..0a04771edd9a --- /dev/null +++ b/vcl/os2/inc/salids.hrc @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: salids.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALIDS_HRC +#define _SV_SALIDS_HRC + +// Pointer +#define SAL_RESID_POINTER_NULL 10000 +#define SAL_RESID_POINTER_HELP 10001 +#define SAL_RESID_POINTER_CROSS 10002 +#define SAL_RESID_POINTER_MOVE 10003 +#define SAL_RESID_POINTER_HSPLIT 10004 +#define SAL_RESID_POINTER_VSPLIT 10005 +#define SAL_RESID_POINTER_HSIZEBAR 10006 +#define SAL_RESID_POINTER_VSIZEBAR 10007 +#define SAL_RESID_POINTER_HAND 10008 +#define SAL_RESID_POINTER_REFHAND 10009 +#define SAL_RESID_POINTER_PEN 10010 +#define SAL_RESID_POINTER_MAGNIFY 10011 +#define SAL_RESID_POINTER_FILL 10012 +#define SAL_RESID_POINTER_ROTATE 10013 +#define SAL_RESID_POINTER_HSHEAR 10014 +#define SAL_RESID_POINTER_VSHEAR 10015 +#define SAL_RESID_POINTER_MIRROR 10016 +#define SAL_RESID_POINTER_CROOK 10017 +#define SAL_RESID_POINTER_CROP 10018 +#define SAL_RESID_POINTER_MOVEPOINT 10019 +#define SAL_RESID_POINTER_MOVEBEZIERWEIGHT 10020 +#define SAL_RESID_POINTER_MOVEDATA 10021 +#define SAL_RESID_POINTER_COPYDATA 10022 +#define SAL_RESID_POINTER_LINKDATA 10023 +#define SAL_RESID_POINTER_MOVEDATALINK 10024 +#define SAL_RESID_POINTER_COPYDATALINK 10025 +#define SAL_RESID_POINTER_MOVEFILE 10026 +#define SAL_RESID_POINTER_COPYFILE 10027 +#define SAL_RESID_POINTER_LINKFILE 10028 +#define SAL_RESID_POINTER_MOVEFILELINK 10029 +#define SAL_RESID_POINTER_COPYFILELINK 10030 +#define SAL_RESID_POINTER_MOVEFILES 10031 +#define SAL_RESID_POINTER_COPYFILES 10032 +#define SAL_RESID_POINTER_DRAW_LINE 10033 +#define SAL_RESID_POINTER_DRAW_RECT 10034 +#define SAL_RESID_POINTER_DRAW_POLYGON 10035 +#define SAL_RESID_POINTER_DRAW_BEZIER 10036 +#define SAL_RESID_POINTER_DRAW_ARC 10037 +#define SAL_RESID_POINTER_DRAW_PIE 10038 +#define SAL_RESID_POINTER_DRAW_CIRCLECUT 10039 +#define SAL_RESID_POINTER_DRAW_ELLIPSE 10040 +#define SAL_RESID_POINTER_DRAW_FREEHAND 10041 +#define SAL_RESID_POINTER_DRAW_CONNECT 10042 +#define SAL_RESID_POINTER_DRAW_TEXT 10043 +#define SAL_RESID_POINTER_DRAW_CAPTION 10044 +#define SAL_RESID_POINTER_CHART 10045 +#define SAL_RESID_POINTER_DETECTIVE 10046 +#define SAL_RESID_POINTER_PIVOT_COL 10047 +#define SAL_RESID_POINTER_PIVOT_ROW 10048 +#define SAL_RESID_POINTER_PIVOT_FIELD 10049 +#define SAL_RESID_POINTER_CHAIN 10050 +#define SAL_RESID_POINTER_CHAIN_NOTALLOWED 10051 +#define SAL_RESID_POINTER_TIMEEVENT_MOVE 10052 +#define SAL_RESID_POINTER_TIMEEVENT_SIZE 10053 +#define SAL_RESID_POINTER_AUTOSCROLL_N 10054 +#define SAL_RESID_POINTER_AUTOSCROLL_S 10055 +#define SAL_RESID_POINTER_AUTOSCROLL_W 10056 +#define SAL_RESID_POINTER_AUTOSCROLL_E 10057 +#define SAL_RESID_POINTER_AUTOSCROLL_NW 10058 +#define SAL_RESID_POINTER_AUTOSCROLL_NE 10059 +#define SAL_RESID_POINTER_AUTOSCROLL_SW 10060 +#define SAL_RESID_POINTER_AUTOSCROLL_SE 10061 +#define SAL_RESID_POINTER_AUTOSCROLL_NS 10062 +#define SAL_RESID_POINTER_AUTOSCROLL_WE 10063 +#define SAL_RESID_POINTER_AUTOSCROLL_NSWE 10064 + +#define SAL_RESID_ICON_SD 12000 + +#endif // _SV_SALIDS_HRC diff --git a/vcl/os2/inc/salinst.h b/vcl/os2/inc/salinst.h new file mode 100644 index 000000000000..cae8cb62c3ee --- /dev/null +++ b/vcl/os2/inc/salinst.h @@ -0,0 +1,109 @@ +/************************************************************************* + * + * $RCSfile: salinst.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALINST_H +#define _SV_SALINST_H + +#ifndef _SV_SV_H +#include +#endif + +#ifdef _VOS_NO_NAMESPACE +class OMutex; +#else +namespace vos { class OMutex; } +#endif +class SalYieldMutex; +class SalInstance; +class SalFrame; +class SalObject; + +// ------------------- +// - SalInstanceData - +// ------------------- + +#define SAL_COMMANDLINENOINIT ((USHORT)0xFFFF) +#define SAL_MAXPARAM 40 + +class SalInstanceData +{ +public: + HAB mhAB; // anchor block handle + HMQ mhMQ; // handle of os2 message queue + HPOINTER mhAppIcon; // app icon + int mnArgc; // commandline param count + char** mpArgv; // commandline + HWND mhComWnd; // window, for communication (between threads and the main thread) + void* mpFilterInst; // hack for clipboard + void* mpFilterCallback; // hack for clipboard + SalYieldMutex* mpSalYieldMutex; // Sal-Yield-Mutex +#ifdef _VOS_NO_NAMESPACE + OMutex* mpSalWaitMutex; // Sal-Wait-Mutex +#else + vos::OMutex* mpSalWaitMutex; // Sal-Wait-Mutex +#endif +}; + +SalFrame* ImplSalCreateFrame( SalInstance* pInst, SalFrame* pParent, ULONG nSalFrameStyle ); +SalObject* ImplSalCreateObject( SalInstance* pInst, SalFrame* pParent ); +void ImplSalStartTimer(); + +#endif // _SV_SALINST_H diff --git a/vcl/os2/inc/sallang.hxx b/vcl/os2/inc/sallang.hxx new file mode 100644 index 000000000000..736613e59ec3 --- /dev/null +++ b/vcl/os2/inc/sallang.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * $RCSfile: sallang.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SALLANG_HXX +#define _SALLANG_HXX + +#ifndef _TOOLS_LANG_HXX +#include +#endif + +// -------------------- +// - Language Strings - +// -------------------- + +// --- Key-Namen --- +#define LSTR_KEY_SHIFT 0 +#define LSTR_KEY_CTRL 1 +#define LSTR_KEY_ALT 2 +#define LSTR_KEY_UP 3 +#define LSTR_KEY_DOWN 4 +#define LSTR_KEY_LEFT 5 +#define LSTR_KEY_RIGHT 6 +#define LSTR_KEY_HOME 7 +#define LSTR_KEY_END 8 +#define LSTR_KEY_PAGEUP 9 +#define LSTR_KEY_PAGEDOWN 10 +#define LSTR_KEY_RETURN 11 +#define LSTR_KEY_ESC 12 +#define LSTR_KEY_TAB 13 +#define LSTR_KEY_BACKSPACE 14 +#define LSTR_KEY_SPACE 15 +#define LSTR_KEY_INSERT 16 +#define LSTR_KEY_DELETE 17 + +// --- Anzahl der Texte --- + +#define LSTR_COUNT 18 + +// -------------------------------------------- +// - Methoden zum Abfragen der Sprach-Strings - +// -------------------------------------------- + +const char** ImplGetLangTab( LanguageType eLang ); + +#endif // _SALLANG_HXX diff --git a/vcl/os2/inc/salobj.h b/vcl/os2/inc/salobj.h new file mode 100644 index 000000000000..a8c80f474e88 --- /dev/null +++ b/vcl/os2/inc/salobj.h @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: salobj.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALOBJ_H +#define _SV_SALOBJ_H + +#ifndef _SV_SV_H +#include +#endif +#ifndef _SV_SYSDATA_HXX +#include +#endif + +// ----------------- +// - SalObjectData - +// ----------------- + +class SalObjectData +{ +public: + HWND mhWnd; // Window handle + HWND mhWndChild; // Child Window handle + HWND mhLastFocusWnd; // Child-Window, welches als letztes den Focus hatte + SystemChildData maSysData; // SystemEnvData + HWND mhLastClipWnd; // LastClip-Window + HWND mhOldLastClipWnd; // LastClip-Window befor BeginSetClipRegion + long mnHeight; // Fenster-Hoehe fuer Positionsumrechnung + SalObject* mpNextObject; // pointer to next object + void* mpInst; // instance handle for callback + SALOBJECTPROC mpProc; // callback proc +}; + +#endif // _SV_SALOBJ_H diff --git a/vcl/os2/inc/salprn.h b/vcl/os2/inc/salprn.h new file mode 100644 index 000000000000..1b151ad1ae2e --- /dev/null +++ b/vcl/os2/inc/salprn.h @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: salprn.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALPRN_H +#define _SV_SALPRN_H + +#ifndef _SV_SV_H +#include +#endif + +class SalGraphics; +class SalInfoPrinter; + +struct ImplFormInfo; +typedef ImplFormInfo* PIMPLFORMINFO; +struct ImplTrayInfo; +typedef ImplTrayInfo* PIMPLTRAYINFO; + +// ---------------------- +// - SalInfoPrinterData - +// ---------------------- + +class SalInfoPrinterData +{ +public: + SalGraphics* mpGraphics; // Graphics + HDC mhDC; // printer hdc + HPS mhPS; // printer hps + String maPrinterName; // pszPrinters + String maName; // pszName bzw. LogAdress + String maDriverName; // pszDriverName nach . + String maDeviceName; // pszDriverName bis . + String maJobSetupDeviceName; // DeviceName aus pDriverData + PIMPLFORMINFO* mpFormArray; // PaperForm-Names + USHORT mnFormCount; // PaperForm-Count + PIMPLTRAYINFO* mpTrayArray; // PaperTray-Names + USHORT mnTrayCount; // PaperTray-Count + BOOL mbDJPSupported; // is driver DJP enabled + BOOL mbGraphics; // is Graphics used +}; + +// ------------------ +// - SalPrinterData - +// ------------------ + +class SalPrinterData +{ +public: + SalGraphics* mpGraphics; // current Printer graphics + SalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter + HDC mhDC; // printer hdc + HPS mhPS; // printer hps + ULONG mnError; // Error Code + BOOL mbFirstPage; // IsFirstPage + BOOL mbAbort; // JobAborted + BOOL mbPrintDJPSupported; // is driver PrintDJP enabled (DEVESC_NEWFRAME_WPROP) + char maCommentBuf[33]; // Comment + char maCopyBuf[10]; // Kopien +}; + +#endif // _SV_SALPRN_H diff --git a/vcl/os2/inc/salsound.hxx b/vcl/os2/inc/salsound.hxx new file mode 100644 index 000000000000..e766d8df869f --- /dev/null +++ b/vcl/os2/inc/salsound.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: salsound.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALSOUND_HXX +#define _SV_SALSOUND_HXX + +#ifndef _GEN_HXX +#include +#endif +#ifndef _SV_SV_H +#include +#endif +#ifndef _STRING_HXX +#include +#endif +#ifndef _SV_SALFRAME_HXX +#include +#endif +#ifndef _SV_SALOTYPE_HXX +#include +#endif + +// ------------ +// - SalSound - +// ------------ + +class SalSound +{ +private: + + static HMODULE mhMCILib; + static ULONG mnSoundState; + static void* mpMCIFnc; + SALSOUNDPROC mpProc; + void* mpInst; + ULONG mnStartTime; + ULONG mnPlayLen; + HWND mhSoundWnd; + USHORT mnDeviceId; + BOOL mbLoop; + BOOL mbPaused; + +public: + + void ImplSetError( ULONG nMciErr ); + void ImplNotify( SoundNotification eNotification, ULONG nError ); + +public: + + SalSound(); + ~SalSound(); + + BOOL Create(); + static void Release(); + static BOOL IsValid() { return( SOUND_STATE_VALID == SalSound::mnSoundState ); } + + BOOL Init( SalFrame* pFrame, const String& rSoundName, ULONG& rSoundLen ); + BOOL Init( SalFrame* pFrame, const BYTE* pSound, ULONG nDataLen, ULONG& rSoundLen ); + void Play( ULONG nStartTime, ULONG nPlayTime, BOOL bLoop ); + void Stop(); + void Pause(); + + void SetNotifyProc( void* pInst, SALSOUNDPROC pProc ) + { mpInst = pInst; mpProc = pProc; } +}; + +#endif // _SV_SALSOUND_HXX diff --git a/vcl/os2/inc/salsys.h b/vcl/os2/inc/salsys.h new file mode 100644 index 000000000000..49f5e0659f58 --- /dev/null +++ b/vcl/os2/inc/salsys.h @@ -0,0 +1,79 @@ +/************************************************************************* + * + * $RCSfile: salsys.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALSYS_H +#define _SV_SALSYS_H + +#ifndef _SV_SV_H +#include +#endif + +class SalFrame; + +// ----------------- +// - SalSystemData - +// ----------------- + +class SalSystemData +{ +}; + +#endif // _SV_SALSYS_H diff --git a/vcl/os2/inc/salvd.h b/vcl/os2/inc/salvd.h new file mode 100644 index 000000000000..e95248eec69e --- /dev/null +++ b/vcl/os2/inc/salvd.h @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: salvd.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SALVD_H +#define _SV_SALVD_H + +#ifndef _SV_SV_H +#include +#endif + +class SalGraphics; + +// ----------------- +// - SalVirDevData - +// ----------------- + +class SalVirDevData +{ +public: + HPS mhPS; // HPS + HDC mhDC; // HDC + HBITMAP mhBmp; // Memory Bitmap + HBITMAP mhDefBmp; // Default Bitmap + SalGraphics* mpGraphics; // current VirDev graphics + USHORT mnBitCount; // BitCount (0 or 1) + BOOL mbGraphics; // is Graphics used +}; + +// Help-Functions +HBITMAP ImplCreateVirDevBitmap( HDC hDC, HPS hPS, long nDX, long nDY, + USHORT nBitCount ); + +#endif // _SV_SALVD_H diff --git a/vcl/os2/inc/svsys.h b/vcl/os2/inc/svsys.h new file mode 100644 index 000000000000..23f834d48550 --- /dev/null +++ b/vcl/os2/inc/svsys.h @@ -0,0 +1,69 @@ +/************************************************************************* + * + * $RCSfile: svsys.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SVSYS_H +#define _SV_SVSYS_H + +#ifndef _SVPM_H +#include +#endif + +#endif // _SV_SVSYS_H diff --git a/vcl/os2/source/app/makefile.mk b/vcl/os2/source/app/makefile.mk new file mode 100644 index 000000000000..e83b8f3a4f11 --- /dev/null +++ b/vcl/os2/source/app/makefile.mk @@ -0,0 +1,96 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=SV +TARGET=salapp + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + +# --- Files -------------------------------------------------------- + +CXXFILES= salmain.cxx \ + salshl.cxx \ + salinst.cxx \ + sallang.cxx \ + saltimer.cxx \ + salsound.cxx \ + salsys.cxx + +OBJFILES= $(OBJ)$/salmain.obj + +SLOFILES= $(SLO)$/salshl.obj \ + $(SLO)$/salinst.obj \ + $(SLO)$/sallang.obj \ + $(SLO)$/saltimer.obj \ + $(SLO)$/salsound.obj \ + $(SLO)$/salsys.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/vcl/os2/source/app/salinst.cxx b/vcl/os2/source/app/salinst.cxx new file mode 100644 index 000000000000..8a3ef0d1315f --- /dev/null +++ b/vcl/os2/source/app/salinst.cxx @@ -0,0 +1,754 @@ +/************************************************************************* + * + * $RCSfile: salinst.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#define INCL_DOSMISC +#define INCL_DOSMODULEMGR +#define INCL_DOSPROCESS + +#include +#include +#include + +#define _SV_SALINST_CXX + +#ifndef _VOS_MUTEX_HXX +#include +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +#ifndef _SV_SALIDS_HRC +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_HXX +#include +#endif +#ifndef _SV_SALFRAME_HXX +#include +#endif +#ifndef _SV_SALTIMER_HXX +#include +#endif +#ifndef _SV_SVAPP_HXX +#include +#endif + +#ifndef _SV_TIMER_HXX +#include +#endif + +#define SVMODULENAME "VCL" MAKE_NUMSTR( SUPD ) __DLLEXTENSION + +// ======================================================================= + +void SalSetExceptionHandler( SALEXCEPTIONPROC pProc ) +{ +} + +// ----------------------------------------------------------------------- + +void SalAbort( const XubString& rErrorText ) +{ +} + +// ----------------------------------------------------------------------- + +ULONG ImplSalGetCurrentThreadId() +{ + PTIB pptib = NULL; + PPIB pppib = NULL; + + DosGetInfoBlocks( &pptib, &pppib ); + return pptib->tib_ptib2->tib2_ultid; +} + +// ======================================================================= + +class SalYieldMutex : public NAMESPACE_VOS(OMutex) +{ +public: + SalInstanceData* mpInstData; + ULONG mnCount; + ULONG mnWaitCount; + ULONG mnThreadId; + +public: + SalYieldMutex( SalInstanceData* pInstData ); + + virtual void acquire(); + virtual void release(); + virtual Boolean tryToAcquire(); + + ULONG GetAcquireCount( ULONG nThreadId ); +}; + +// ----------------------------------------------------------------------- + +SalYieldMutex::SalYieldMutex( SalInstanceData* pInstData ) +{ + mpInstData = pInstData; + mnCount = 0; + mnThreadId = 0; + mnWaitCount = 0; +} + +// ----------------------------------------------------------------------- + +void SalYieldMutex::acquire() +{ + OMutex::acquire(); + mnCount++; + mnThreadId = ImplSalGetCurrentThreadId(); +} + +// ----------------------------------------------------------------------- + +void SalYieldMutex::release() +{ + ULONG nThreadId = ImplSalGetCurrentThreadId(); + if ( mnThreadId != nThreadId ) + OMutex::release(); + else + { + SalData* pSalData = GetSalData(); + if ( pSalData->mnAppThreadId != nThreadId ) + { + NAMESPACE_VOS(OGuard) aGuard( mpInstData->mpSalWaitMutex ); + if ( mnCount == 1 ) + { + if ( mnWaitCount && WinPostMsg( mpInstData->mhComWnd, SAL_MSG_RELEASEWAITYIELD, 0, 0 ) ) + mnWaitCount--; + mnThreadId = 0; + } + mnCount--; + OMutex::release(); + } + else + { + if ( mnCount == 1 ) + mnThreadId = 0; + mnCount--; + OMutex::release(); + } + } +} + +// ----------------------------------------------------------------------- + +Boolean SalYieldMutex::tryToAcquire() +{ + if ( OMutex::tryToAcquire() ) + { + mnCount++; + mnThreadId = ImplSalGetCurrentThreadId(); + return True; + } + else + return False; +} + +// ----------------------------------------------------------------------- + +ULONG SalYieldMutex::GetAcquireCount( ULONG nThreadId ) +{ + if ( nThreadId == mnThreadId ) + return mnCount; + else + return 0; +} + +// ----------------------------------------------------------------------- + +BOOL ImplSalYieldMutexTryToAcquire() +{ + SalData* pSalData = GetSalData(); + if ( pSalData->mpFirstInstance ) + return pSalData->mpFirstInstance->maInstData.mpSalYieldMutex->tryToAcquire(); + else + return FALSE; +} + +// ----------------------------------------------------------------------- + +void ImplSalYieldMutexAcquire() +{ + SalData* pSalData = GetSalData(); + if ( pSalData->mpFirstInstance ) + pSalData->mpFirstInstance->maInstData.mpSalYieldMutex->acquire(); +} + +// ----------------------------------------------------------------------- + +void ImplSalYieldMutexRelease() +{ + SalData* pSalData = GetSalData(); + if ( pSalData->mpFirstInstance ) + pSalData->mpFirstInstance->maInstData.mpSalYieldMutex->release(); +} + +// ----------------------------------------------------------------------- + +#ifdef DBG_UTIL + +void ImplDbgTestSolarMutex() +{ + SalData* pSalData = GetSalData(); + ULONG nCurThreadId = ImplSalGetCurrentThreadId(); + if ( pSalData->mnAppThreadId != nCurThreadId ) + { + if ( pSalData->mpFirstInstance ) + { + SalYieldMutex* pYieldMutex = pSalData->mpFirstInstance->maInstData.mpSalYieldMutex; + if ( pYieldMutex->mnThreadId != nCurThreadId ) + { + DBG_ERROR( "SolarMutex not locked, and not thread save code in VCL is called from outside of the main thread" ); + } + } + } + else + { + if ( pSalData->mpFirstInstance ) + { + SalYieldMutex* pYieldMutex = pSalData->mpFirstInstance->maInstData.mpSalYieldMutex; + if ( pYieldMutex->mnThreadId != nCurThreadId ) + { + DBG_ERROR( "SolarMutex not locked in the main thread" ); + } + } + } +} + +#endif + +// ======================================================================= + +void InitSalSystemData() +{ +} + +// ----------------------------------------------------------------------- + +static void ImplSalYield( BOOL bWait, BOOL bMainThread, SalYieldMutex* pYieldMutex ) +{ + QMSG aMsg; + QMSG aTmpMsg; + BOOL bDispatch = FALSE; + USHORT nPostReleaseWait = 0; + static QMSG* pMsg = NULL; + SalData* pSalData = GetSalData(); + + do + { + if ( !pMsg ) + { + BOOL bQuit = FALSE; + if ( bWait ) + { + if ( WinGetMsg( pSalData->mhAB, &aMsg, 0, 0, 0 ) ) + pMsg = &aMsg; + else + bQuit = TRUE; + } + else + { + if ( WinPeekMsg( pSalData->mhAB, &aMsg, 0, 0, 0, PM_REMOVE ) ) + { + if ( aMsg.msg == WM_QUIT ) + bQuit = TRUE; + else + pMsg = &aMsg; + } + } + + // ShutDown-Event ausloesen (ist immer dann der Fall, + // wenn wir eine Quit-Message bekommen) + if ( bQuit && pSalData->mpDefaultFrame ) + { + SalFrame* pDefaultFrame = pSalData->mpDefaultFrame; + if ( pDefaultFrame->maFrameData.mpProc( pDefaultFrame->maFrameData.mpInst, pDefaultFrame, + SALEVENT_SHUTDOWN, 0 ) ) + WinCancelShutdown( pSalData->mhAB, FALSE ); + } + + // ReleaseWaitYield ignorieren wir, da diese fuer andere + // Yield-Aufrufe gedacht sind + if ( pMsg ) + { + if ( pMsg->msg == SAL_MSG_RELEASEWAITYIELD ) + { + nPostReleaseWait++; + pMsg = NULL; + continue; + } + } + } + + if ( pMsg ) + { + // Darf ich die Message dispatchen + pYieldMutex->mpInstData->mpSalWaitMutex->acquire(); + if ( pYieldMutex->tryToAcquire() ) + { + pYieldMutex->mpInstData->mpSalWaitMutex->release(); + bDispatch = TRUE; + } + else + { + pYieldMutex->mnWaitCount++; + pYieldMutex->mpInstData->mpSalWaitMutex->release(); + WinGetMsg( pSalData->mhAB, &aTmpMsg, pYieldMutex->mpInstData->mhComWnd, SAL_MSG_RELEASEWAITYIELD, SAL_MSG_RELEASEWAITYIELD ); + if ( !pMsg ) + bDispatch = TRUE; + } + } + else + bDispatch = TRUE; + } + while( !bDispatch ); + + if ( pMsg ) + { + // acquire ist nicht notwendig, da dies schon in der oberen + // Schleife bei tryToAcquire() gemacht wurde + QMSG* pTmpMsg = pMsg; + pMsg = NULL; + WinDispatchMsg( pSalData->mhAB, pTmpMsg ); + pYieldMutex->release(); + } + + while ( nPostReleaseWait ) + { + WinPostMsg( pYieldMutex->mpInstData->mhComWnd, SAL_MSG_RELEASEWAITYIELD, 0, 0 ); + nPostReleaseWait--; + } +} + +// ----------------------------------------------------------------------- + +MRESULT EXPENTRY SalComWndProc( HWND hWnd, PM_ULONG nMsg, + MPARAM nMP1, MPARAM nMP2 ) +{ + switch ( nMsg ) + { + case SAL_MSG_STARTTIMER: + ImplSalStartTimer(); + return 0; + case SAL_MSG_CREATEFRAME: + return (MRESULT)ImplSalCreateFrame( GetSalData()->mpFirstInstance, (SalFrame*)(ULONG)nMP2, (ULONG)nMP1 ); + case SAL_MSG_CREATEOBJECT: + return (MRESULT)ImplSalCreateObject( GetSalData()->mpFirstInstance, (SalFrame*)(ULONG)nMP2 ); + case SAL_MSG_THREADYIELD: + ImplSalYield( (BOOL)(LONG)nMP1, FALSE, (SalYieldMutex*)(LONG)nMP2 ); + return 0; + } + + return WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); +} + +// ======================================================================= + +void InitSalData() +{ + SalData* pSalData = new SalData; + memset( pSalData, 0, sizeof( SalData ) ); + SetSalData( pSalData ); +} + +// ----------------------------------------------------------------------- + +void DeInitSalData() +{ + SalData* pSalData = GetSalData(); + if ( pSalData->mpFontMetrics ) + delete pSalData->mpFontMetrics; + delete pSalData; + SetSalData( NULL ); +} + +// ----------------------------------------------------------------------- + +void SetFilterCallback( void* pCallback, void* pInst ) +{ + SalData* pSalData = GetSalData(); + pSalData->mpFirstInstance->maInstData.mpFilterCallback = pCallback; + pSalData->mpFirstInstance->maInstData.mpFilterInst = pInst; +} + +// ----------------------------------------------------------------------- + +SalInstance* CreateSalInstance() +{ + SalData* pSalData = GetSalData(); + SalInstance* pInst = new SalInstance; + + // determine Module-Handle for SVDLL + DosQueryModuleHandle( (PSZ)SVMODULENAME, &aSalShlData.mhMod ); + + // determine the os2 version + PM_ULONG nMayor; + PM_ULONG nMinor; + DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MAJOR, &nMayor, sizeof( nMayor ) ); + DosQuerySysInfo( QSV_VERSION_MINOR, QSV_VERSION_MINOR, &nMinor, sizeof( nMinor ) ); + aSalShlData.mnVersion = (USHORT)(nMayor*10 + nMinor); + + pSalData->mnAppThreadId = ImplSalGetCurrentThreadId(); + + // register frame class + if ( !WinRegisterClass( pSalData->mhAB, (PSZ)SAL_FRAME_CLASSNAME, + (PFNWP)SalFrameWndProc, CS_HITTEST | CS_MOVENOTIFY, + SAL_FRAME_WNDEXTRA ) ) + { + delete pInst; + return NULL; + } + + // register frame class + if ( !WinRegisterClass( pSalData->mhAB, (PSZ)SAL_COM_CLASSNAME, + (PFNWP)SalComWndProc, 0, 0 )) + { + delete pInst; + return NULL; + } + + HWND hComWnd = WinCreateWindow( HWND_OBJECT, (PSZ)SAL_COM_CLASSNAME, + "", 0, 0, 0, 0, 0, + HWND_OBJECT, HWND_TOP, + 222, NULL, NULL); + + // init system data + InitSalSystemData(); + + // init instance (only one instance in this version !!!) + pSalData->mpFirstInstance = pInst; + pInst->maInstData.mhAB = pSalData->mhAB; + pInst->maInstData.mhMQ = pSalData->mhMQ; + pInst->maInstData.mnArgc = pSalData->mnArgc; + pInst->maInstData.mpArgv = pSalData->mpArgv; + pInst->maInstData.mhComWnd = hComWnd; + + // AppIcon ermitteln + pInst->maInstData.mhAppIcon = WinLoadPointer( HWND_DESKTOP, pSalData->mhAB, 1 ); + if ( !pInst->maInstData.mhAppIcon ) + pInst->maInstData.mhAppIcon = ImplLoadPointer( SAL_RESID_ICON_SD ); + + return pInst; +} + +// ----------------------------------------------------------------------- + +void DestroySalInstance( SalInstance* pInst ) +{ + SalData* pSalData = GetSalData(); + + // (only one instance in this version !!!) + +#ifdef ENABLE_IME + // IME-Daten freigeben + if ( pSalData->mpIMEData ) + ImplReleaseSALIMEData(); +#endif + + // Destroy Dummy Frame + if ( pSalData->mpDummyFrame ) + pInst->DestroyFrame( pSalData->mpDummyFrame ); + + // reset instance + if ( pSalData->mpFirstInstance == pInst ) + pSalData->mpFirstInstance = NULL; + + delete pInst; +} + +// ----------------------------------------------------------------------- + +SalInstance::SalInstance() +{ + maInstData.mpFilterCallback = NULL; + maInstData.mpFilterInst = NULL; + + maInstData.mpSalWaitMutex = new NAMESPACE_VOS(OMutex); + maInstData.mpSalYieldMutex = new SalYieldMutex( &maInstData ); + maInstData.mpSalYieldMutex->acquire(); +} + +// ----------------------------------------------------------------------- + +SalInstance::~SalInstance() +{ + maInstData.mpSalYieldMutex->release(); + delete maInstData.mpSalYieldMutex; + delete maInstData.mpSalWaitMutex; +} + +// ----------------------------------------------------------------------- + +BOOL SalInstance::AnyInput( USHORT nType ) +{ + SalData* pSalData = GetSalData(); + QMSG aQMSG; + + if ( (nType & (INPUT_ANY)) == INPUT_ANY ) + { + // Any Input + if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, 0, 0, PM_NOREMOVE ) ) + return TRUE; + } + else + { + if ( nType & INPUT_MOUSE ) + { + // Test auf Mouseinput + if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, + WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE ) ) + return TRUE; + } + + if ( nType & INPUT_KEYBOARD ) + { + // Test auf Keyinput + if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, + WM_CHAR, WM_CHAR, PM_NOREMOVE ) ) + return !(SHORT1FROMMP( aQMSG.mp1 ) & KC_KEYUP); + } + + if ( nType & INPUT_PAINT ) + { + // Test auf Paintinput + if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, + WM_PAINT, WM_PAINT, PM_NOREMOVE ) ) + return TRUE; + } + + if ( nType & INPUT_TIMER ) + { + // Test auf Timerinput + if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, + WM_TIMER, WM_TIMER, PM_NOREMOVE ) ) + return TRUE; + } + + if ( nType & INPUT_OTHER ) + { + // Test auf sonstigen Input + if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, 0, 0, PM_NOREMOVE ) ) + return TRUE; + } + } + + return FALSE; +} + +// ----------------------------------------------------------------------- + +void SalInstance::Yield( BOOL bWait ) +{ + SalYieldMutex* pYieldMutex = maInstData.mpSalYieldMutex; + SalData* pSalData = GetSalData(); + ULONG nCurThreadId = ImplSalGetCurrentThreadId(); + ULONG nCount = pYieldMutex->GetAcquireCount( nCurThreadId ); + ULONG n = nCount; + while ( n ) + { + pYieldMutex->release(); + n--; + } + if ( pSalData->mnAppThreadId != nCurThreadId ) + { + WinSendMsg( maInstData.mhComWnd, SAL_MSG_THREADYIELD, + (MPARAM)bWait, (MPARAM)(void*)pYieldMutex ); + + n = nCount; + while ( n ) + { + pYieldMutex->acquire(); + n--; + } + } + else + { + ImplSalYield( bWait, TRUE, pYieldMutex ); + + n = nCount; + while ( n ) + { + // Wenn wir den Mutex nicht bekommen, muessen wir solange + // warten, bis wir Ihn bekommen + pYieldMutex->mpInstData->mpSalWaitMutex->acquire(); + if ( pYieldMutex->tryToAcquire() ) + { + pYieldMutex->mpInstData->mpSalWaitMutex->release(); + n--; + } + else + { + pYieldMutex->mnWaitCount++; + pYieldMutex->mpInstData->mpSalWaitMutex->release(); + QMSG aTmpMsg; + WinGetMsg( pSalData->mhAB, &aTmpMsg, maInstData.mhComWnd, SAL_MSG_RELEASEWAITYIELD, SAL_MSG_RELEASEWAITYIELD ); + } + } +} + +// ----------------------------------------------------------------------- + +XubString SalInstance::GetFileName() +{ + String aFileName( maInstData.mpArgv[0] ); + return aFileName; +} + +// ----------------------------------------------------------------------- + +USHORT SalInstance::GetCommandLineParamCount() +{ + return maInstData.mnArgc-1; +} + +// ----------------------------------------------------------------------- + +XubString SalInstance::GetCommandLineParam( USHORT nParam ) +{ + if ( nParam < maInstData.mnArgc-1 ) + { + String aParam( maInstData.mpArgv[nParam+1] ); + return aParam; + } + else + return ImplGetSVEmptyStr(); +} + +// ----------------------------------------------------------------------- + +#ifdef _VOS_NO_NAMESPACE +IMutex* SalInstance::GetYieldMutex() +#else +vos::IMutex* SalInstance::GetYieldMutex() +#endif +{ + return maInstData.mpSalYieldMutex; +} + +// ----------------------------------------------------------------------- + +ULONG SalInstance::ReleaseYieldMutex() +{ + SalYieldMutex* pYieldMutex = maInstData.mpSalYieldMutex; + ULONG nCount = pYieldMutex->GetAcquireCount( ImplSalGetCurrentThreadId() ); + ULONG n = nCount; + while ( n ) + { + pYieldMutex->release(); + n--; + } + + return nCount; +} + +// ----------------------------------------------------------------------- + +void SalInstance::AcquireYieldMutex( ULONG nCount ) +{ + SalYieldMutex* pYieldMutex = maInstData.mpSalYieldMutex; + while ( nCount ) + { + pYieldMutex->acquire(); + nCount--; + } +} + +// ----------------------------------------------------------------------- + +SalFrame* SalInstance::CreateFrame( SalFrame* pParent, USHORT nSalFrameStyle ) +{ + // Um auf Main-Thread umzuschalten + return (SalFrame*)WinSendMsg( maInstData.mhComWnd, SAL_MSG_CREATEFRAME, (MPARAM)nSalFrameStyle, (MPARAM)pParent ); +} + +// ----------------------------------------------------------------------- + +SalObject* SalInstance::CreateObject( SalFrame* pParent ) +{ + // Um auf Main-Thread umzuschalten + return (SalObject*)WinSendMsg( maInstData.mhComWnd, SAL_MSG_CREATEOBJECT, 0, (MPARAM)pParent ); +} + +// ----------------------------------------------------------------------- + +void SalTimer::Start( ULONG nMS ) +{ + // Um auf Main-Thread umzuschalten + SalData* pSalData = GetSalData(); + pSalData->mnNewTimerMS = nMS; + if ( pSalData->mpFirstInstance ) + { + if ( pSalData->mnAppThreadId != ImplSalGetCurrentThreadId() ) + WinPostMsg( pSalData->mpFirstInstance->maInstData.mhComWnd, SAL_MSG_STARTTIMER, 0, 0 ); + else + WinSendMsg( pSalData->mpFirstInstance->maInstData.mhComWnd, SAL_MSG_STARTTIMER, 0, 0 ); + } + else + ImplSalStartTimer(); +} diff --git a/vcl/os2/source/app/sallang.cxx b/vcl/os2/source/app/sallang.cxx new file mode 100644 index 000000000000..ba8be275ec4b --- /dev/null +++ b/vcl/os2/source/app/sallang.cxx @@ -0,0 +1,406 @@ +/************************************************************************* + * + * $RCSfile: sallang.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _TOOLS_INTN_HXX +#include +#endif + +#ifndef _SALLANG_HXX +#include +#endif + +// ======================================================================= + +// ----------------------------------------------------------------------- +// Danish + +static const char* aImplLangDanishTab[LSTR_COUNT] = +{ + "Skift", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Op", // LSTR_KEY_UP + "Ned", // LSTR_KEY_DOWN + "Venstre", // LSTR_KEY_LEFT + "H›jre", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "End", // LSTR_KEY_END + "PageUp", // LSTR_KEY_PAGEUP + "PageDown", // LSTR_KEY_PAGEDOWN + "Enter", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Tilbage", // LSTR_KEY_BACKSPACE + "Mellemrum", // LSTR_KEY_SPACE + "Insert", // LSTR_KEY_INSERT + "Delete", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// Dutch (Netherland/Belgian) + +static const char* aImplLangDutchTab[LSTR_COUNT] = +{ + "Shift", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Boven", // LSTR_KEY_UP + "Onder", // LSTR_KEY_DOWN + "Links", // LSTR_KEY_LEFT + "Links", // LSTR_KEY_RIGHT + "Pos1", // LSTR_KEY_HOME + "Einde", // LSTR_KEY_END + "PageUp", // LSTR_KEY_PAGEUP + "PageDown", // LSTR_KEY_PAGEDOWN + "Return", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Backspace", // LSTR_KEY_BACKSPACE + "Spatiebalk", // LSTR_KEY_SPACE + "Ins", // LSTR_KEY_INSERT + "Verwijderen", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// English (US/UK/AUS/CAN/NZ/EIRE/SAFRICA/JAMAICA/CARRIBEAN) + +static const char* aImplLangEnglishTab[LSTR_COUNT] = +{ + "Shift", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Up", // LSTR_KEY_UP + "Down", // LSTR_KEY_DOWN + "Left", // LSTR_KEY_LEFT + "Right", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "End", // LSTR_KEY_END + "PageUp", // LSTR_KEY_PAGEUP + "PageDown", // LSTR_KEY_PAGEDOWN + "Enter", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Backspace", // LSTR_KEY_BACKSPACE + "Space", // LSTR_KEY_SPACE + "Insert", // LSTR_KEY_INSERT + "Del", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// Finnish + +static const char* aImplLangFinnishTab[LSTR_COUNT] = +{ + "Vaihton„ppain", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Yl„", // LSTR_KEY_UP + "Ala", // LSTR_KEY_DOWN + "Vasen", // LSTR_KEY_LEFT + "Oikea", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "End", // LSTR_KEY_END + "PageUp", // LSTR_KEY_PAGEUP + "PageDown", // LSTR_KEY_PAGEDOWN + "Enter", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Sarkain", // LSTR_KEY_TAB + "Askelpalautin", // LSTR_KEY_BACKSPACE + "V„lin„pp„in", // LSTR_KEY_SPACE + "Insert", // LSTR_KEY_INSERT + "Delete", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// French (French/Belgian/Canadian/Swiss/Luxenbourg) + +static const char* aImplLangFrenchTab[LSTR_COUNT] = +{ + "Maj", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Haut", // LSTR_KEY_UP + "Bas", // LSTR_KEY_DOWN + "Gauche", // LSTR_KEY_LEFT + "Droite", // LSTR_KEY_RIGHT + "Origine", // LSTR_KEY_HOME + "Fin", // LSTR_KEY_END + "Pg. Pr‚c", // LSTR_KEY_PAGEUP + "Pg. Suiv", // LSTR_KEY_PAGEDOWN + "Entr‚e", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Ret. Arr", // LSTR_KEY_BACKSPACE + "Espace", // LSTR_KEY_SPACE + "Ins‚rer", // LSTR_KEY_INSERT + "Suppr", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// German (German/Swiss/Austrian/Luxembourg/Liechtenstein) + +static const char* aImplLangGermanTab[LSTR_COUNT] = +{ + "Umschalt", // LSTR_KEY_SHIFT + "Strg", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Nach-Oben", // LSTR_KEY_UP + "Nach-Unten", // LSTR_KEY_DOWN + "Nach-Links", // LSTR_KEY_LEFT + "Nach-Rechts", // LSTR_KEY_RIGHT + "Pos1", // LSTR_KEY_HOME + "Ende", // LSTR_KEY_END + "Bild-Nach-Oben", // LSTR_KEY_PAGEUP + "Bild-Nach-Unten", // LSTR_KEY_PAGEDOWN + "Eingabe", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Rck", // LSTR_KEY_BACKSPACE + "Leer", // LSTR_KEY_SPACE + "Einfg", // LSTR_KEY_INSERT + "Entf", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// Italian (Italian/Swiss) + +static const char* aImplLangItalianTab[LSTR_COUNT] = +{ + "Maiusc", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Sposta verso l'alto", // LSTR_KEY_UP + "Sposta verso il basso", // LSTR_KEY_DOWN + "A sinistra", // LSTR_KEY_LEFT + "A destra", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "Fine", // LSTR_KEY_END + "PgSu", // LSTR_KEY_PAGEUP + "PgGi—", // LSTR_KEY_PAGEDOWN + "Invio", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Backspace", // LSTR_KEY_BACKSPACE + "Spaziatrice", // LSTR_KEY_SPACE + "Ins", // LSTR_KEY_INSERT + "Canc", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// Norwegian (Bokmal) + +static const char* aImplLangNorwegianTab[LSTR_COUNT] = +{ + "Skift", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Opp", // LSTR_KEY_UP + "Ned", // LSTR_KEY_DOWN + "Venstre", // LSTR_KEY_LEFT + "H›yre", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "End", // LSTR_KEY_END + "PageUp", // LSTR_KEY_PAGEUP + "PageDown", // LSTR_KEY_PAGEDOWN + "Enter", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Tilbake", // LSTR_KEY_BACKSPACE + "Mellomrom", // LSTR_KEY_SPACE + "Insert", // LSTR_KEY_INSERT + "Delete", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// Portuguse (Portuguse/Brazilian) + +static const char* aImplLangPortugueseTab[LSTR_COUNT] = +{ + "Shift", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Acima", // LSTR_KEY_UP + "Abaixo", // LSTR_KEY_DOWN + "Esquerda", // LSTR_KEY_LEFT + "Direita", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "End", // LSTR_KEY_END + "PageUp", // LSTR_KEY_PAGEUP + "PageDown", // LSTR_KEY_PAGEDOWN + "Enter", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Backspace", // LSTR_KEY_BACKSPACE + "Space", // LSTR_KEY_SPACE + "Insert", // LSTR_KEY_INSERT + "Delete", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// Spanish (Spanish/Mexican/Modern/Guatemala/Costarica/Panama/Dominican/ +// Venezuela/Colombia/Peru/Argentina/Ecuador/Chile/Uruguay/ +// Paraguay/Bolivia) + +static const char* aImplLangSpanishTab[LSTR_COUNT] = +{ + "May—s", // LSTR_KEY_SHIFT + "Control", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Hacia arriba", // LSTR_KEY_UP + "Hacia abajo", // LSTR_KEY_DOWN + "Hacia la izquierda", // LSTR_KEY_LEFT + "Hacia la derecha", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "Fin", // LSTR_KEY_END + "ReP g", // LSTR_KEY_PAGEUP + "AvP g", // LSTR_KEY_PAGEDOWN + "Entrada", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Ret", // LSTR_KEY_BACKSPACE + "Espacio", // LSTR_KEY_SPACE + "Insert", // LSTR_KEY_INSERT + "Supr", // LSTR_KEY_DELETE +}; + +// ----------------------------------------------------------------------- +// Swedish + +static const char* aImplLangSwedishTab[LSTR_COUNT] = +{ + "Skift", // LSTR_KEY_SHIFT + "Ctrl", // LSTR_KEY_CTRL + "Alt", // LSTR_KEY_ALT + "Up", // LSTR_KEY_UP + "Ned", // LSTR_KEY_DOWN + "V„nster", // LSTR_KEY_LEFT + "H”ger", // LSTR_KEY_RIGHT + "Home", // LSTR_KEY_HOME + "End", // LSTR_KEY_END + "PageUp", // LSTR_KEY_PAGEUP + "PageDown", // LSTR_KEY_PAGEDOWN + "Retur", // LSTR_KEY_RETURN + "Esc", // LSTR_KEY_ESC + "Tab", // LSTR_KEY_TAB + "Backsteg", // LSTR_KEY_BACKSPACE + "Blank", // LSTR_KEY_SPACE + "Insert", // LSTR_KEY_INSERT + "Delete", // LSTR_KEY_DELETE +}; + +// ======================================================================= + +const char** ImplGetLangTab( LanguageType eLang ) +{ + // Sprachtabelle ermitteln + const char** pLangTab; + switch ( International::GetNeutralLanguage( eLang ) ) + { + case LANGUAGE_DANISH: + pLangTab = aImplLangDanishTab; + break; + + case LANGUAGE_DUTCH: + case LANGUAGE_DUTCH_BELGIAN: + pLangTab = aImplLangDutchTab; + break; + + case LANGUAGE_FINNISH: + pLangTab = aImplLangFinnishTab; + break; + + case LANGUAGE_FRENCH: + pLangTab = aImplLangFrenchTab; + break; + + case LANGUAGE_GERMAN: + pLangTab = aImplLangGermanTab; + break; + + case LANGUAGE_ITALIAN: + pLangTab = aImplLangItalianTab; + break; + + case LANGUAGE_NORWEGIAN: + case LANGUAGE_NORWEGIAN_BOKMAL: + pLangTab = aImplLangNorwegianTab; + break; + + case LANGUAGE_PORTUGUESE: + case LANGUAGE_PORTUGUESE_BRAZILIAN: + pLangTab = aImplLangPortugueseTab; + break; + + case LANGUAGE_SPANISH: + pLangTab = aImplLangSpanishTab; + break; + + case LANGUAGE_SWEDISH: + pLangTab = aImplLangSwedishTab; + break; + + default: + pLangTab = aImplLangEnglishTab; + break; + } + + return pLangTab; +} diff --git a/vcl/os2/source/app/salshl.cxx b/vcl/os2/source/app/salshl.cxx new file mode 100644 index 000000000000..c81cee1c67f1 --- /dev/null +++ b/vcl/os2/source/app/salshl.cxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * $RCSfile: salshl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#define _SV_SALSHL_CXX + +#ifndef _SV_SALDATA_HXX +#include +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +// ======================================================================= + +SalShlData aSalShlData; + +// ======================================================================= + +HPOINTER ImplLoadPointer( ULONG nId ) +{ + return WinLoadPointer( HWND_DESKTOP, aSalShlData.mhMod, nId ); +} + diff --git a/vcl/os2/source/app/salsound.cxx b/vcl/os2/source/app/salsound.cxx new file mode 100644 index 000000000000..45bf1ee67153 --- /dev/null +++ b/vcl/os2/source/app/salsound.cxx @@ -0,0 +1,421 @@ +/************************************************************************* + * + * $RCSfile: salsound.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#define _SV_SALSOUND_CXX + +// ------------ +// - Includes - +// ------------ + +#include + +#define INCL_DOSMODULEMGR +#include + +#ifndef _SV_SALSOUND_HXX +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif + +#define INCL_MCIOS2 +#include + +// --------- +// - Names - +// --------- + +#define SOUND_LIBNAME "MDM" +#define SOUND_PROCNAME "mciSendCommand" + +// ------------ +// - Fnc cast - +// ------------ + +typedef ULONG (_cdecl *SALMCIPROC)( USHORT nDeviceId, USHORT nMessage, ULONG nFlags, void* pParam, USHORT ); +#define MCIFNC ( (SALMCIPROC) SalSound::mpMCIFnc ) + +// ----------------- +// - Statics init. - +// ----------------- + +HMODULE SalSound::mhMCILib = 0; +ULONG SalSound::mnSoundState = SOUND_STATE_UNLOADED; +void* SalSound::mpMCIFnc = NULL; + +// ------------------- +// - Window-Callback - +// ------------------- + +MRESULT EXPENTRY SoundWndProc( HWND hWnd, ULONG nMsg, MPARAM nPar1, MPARAM nPar2 ) +{ + if( MM_MCINOTIFY == nMsg ) + { + USHORT nNotify = (USHORT)(ULONG) nPar1; + SoundNotification eNotification; + BOOL bNotify = TRUE; + + switch( nNotify ) + { + case( MCI_NOTIFY_SUCCESSFUL ): + eNotification = SOUND_NOTIFY_SUCCESS; + break; + + case( MCI_NOTIFY_ABORTED ): + eNotification = SOUND_NOTIFY_ABORTED; + break; + + case( MCI_NOTIFY_SUPERSEDED ): + bNotify = FALSE; + break; + + default: + eNotification = SOUND_NOTIFY_ERROR; + break; + } + + if( bNotify ) + ( (SalSound*) WinQueryWindowULong( hWnd, 0 ) )->ImplNotify( eNotification, 0 ); + } + + return WinDefWindowProc( hWnd, nMsg, nPar1, nPar2 ); +} + +// ------------ +// - SalSound - +// ------------ + +SalSound::SalSound() : + mpProc ( NULL ), + mhSoundWnd ( 0 ), + mnDeviceId ( 0 ), + mbLoop ( FALSE ), + mbPaused ( FALSE ) +{ +} + +// ------------------------------------------------------------------------ + +SalSound::~SalSound() +{ + Stop(); + + if( mnDeviceId ) + { + MCI_GENERIC_PARMS aGenericParams; + memset( &aGenericParams, 0, sizeof( aGenericParams ) ); + aGenericParams.hwndCallback = mhSoundWnd; + MCIFNC( mnDeviceId, MCI_CLOSE, MCI_WAIT, &aGenericParams, 0 ); + } + + if( mhSoundWnd ) + WinDestroyWindow( mhSoundWnd ); +} + +// ------------------------------------------------------------------------ + +void SalSound::ImplSetError( ULONG nMciErr ) +{ + struct aMapper { DWORD nMci; ULONG nSv; }; + + ULONG nError = SOUNDERR_GENERAL_ERROR; + static aMapper aErrArr[] = + { + { 0, SOUNDERR_SUCCESS }, + { MCIERR_CANNOT_LOAD_DRIVER, SOUNDERR_CANNOT_LOAD_DRIVER }, + { MCIERR_DEVICE_LOCKED, SOUNDERR_DEVICE_LOCKED }, + { MCIERR_DEVICE_NOT_READY, SOUNDERR_DEVICE_NOT_READY }, + { MCIERR_DEVICE_TYPE_REQUIRED, SOUNDERR_DEVICE_NOT_FOUND }, + { MCIERR_DRIVER, SOUNDERR_CANNOT_LOAD_DRIVER }, + { MCIERR_DRIVER_INTERNAL, SOUNDERR_CANNOT_LOAD_DRIVER }, + { MCIERR_EXTENSION_NOT_FOUND, SOUNDERR_SOUND_NOT_FOUND }, + { MCIERR_FILE_NOT_FOUND, SOUNDERR_SOUND_NOT_FOUND }, + { MCIERR_HARDWARE, SOUNDERR_HARDWARE_ERROR }, + { MCIERR_INVALID_DEVICE_NAME, SOUNDERR_DEVICE_NOT_FOUND }, + { MCIERR_OUT_OF_MEMORY, SOUNDERR_OUT_OF_MEMORY }, + { MCIERR_UNSUPPORTED_FUNCTION, SOUNDERR_UNSUPPORTED_FUNCTION } + }; + + for( USHORT n=0; n < (sizeof( aErrArr ) / sizeof( aMapper ) ); n++ ) + { + if( aErrArr[ n ].nMci == nMciErr ) + { + nError = aErrArr[ n ].nSv; + break; + } + } + + if( nError ) + ImplNotify( SOUND_NOTIFY_ERROR, nError ); +} + +// ------------------------------------------------------------------------ + +void SalSound::ImplNotify( SoundNotification eNotification, ULONG nError ) +{ + if( mbLoop && ( SOUND_NOTIFY_SUCCESS == eNotification ) && !nError ) + Play( mnStartTime, mnPlayLen, TRUE ); + + if( mpProc && mpInst ) + mpProc( mpInst, eNotification, nError ); +} + +// ------------------------------------------------------------------------ + +BOOL SalSound::Create() +{ + SalData* pData = GetSalData(); + BOOL bRet = FALSE; + + if( SOUND_STATE_UNLOADED == SalSound::mnSoundState ) + { + if( DosLoadModule( 0, 0, SOUND_LIBNAME, &SalSound::mhMCILib ) == 0 && + DosQueryProcAddr( SalSound::mhMCILib, 0, SOUND_PROCNAME, (PFN*) &SalSound::mpMCIFnc ) == 0 ) + { + char* pszClassName = "SoundWin"; + PFNWP pWindowProc = SoundWndProc; + + WinRegisterClass( pData->mhAB, pszClassName, pWindowProc, 0L, 4 ); + SalSound::mnSoundState = SOUND_STATE_VALID; + bRet = TRUE; + } + else + { + if( SalSound::mhMCILib ) + DosFreeModule( SalSound::mhMCILib ); + + SalSound::mnSoundState = SOUND_STATE_INVALID; + ImplNotify( SOUND_NOTIFY_ERROR, SOUNDERR_CANNOT_LOAD_DRIVER ); + } + } + else if( SOUND_STATE_VALID == SalSound::mnSoundState ) + bRet = TRUE; + + if( bRet ) + { + mhSoundWnd = WinCreateWindow( HWND_OBJECT, "SoundWin", "Sound", 0, 0, 0, 0, 0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 ); + WinSetWindowULong( mhSoundWnd, 0, (ULONG) this ); + } + else + mhSoundWnd = 0; + + return bRet; +} + +// ------------------------------------------------------------------------ + +void SalSound::Release() +{ + if( SalSound::mhMCILib ) + DosFreeModule( SalSound::mhMCILib ); + + SalSound::mnSoundState = SOUND_STATE_UNLOADED; +} + +// ------------------------------------------------------------------------ + +BOOL SalSound::Init( SalFrame* pFrame, const String& rSoundName, ULONG& rSoundLen ) +{ + MCI_OPEN_PARMS aOpenParams; + ULONG nMciErr = 0; + + rSoundLen = 0; + + // clear old device + if( mnDeviceId ) + { + Stop(); + + MCI_GENERIC_PARMS aGenericParams; + memset( &aGenericParams, 0, sizeof( aGenericParams ) ); + aGenericParams.hwndCallback = mhSoundWnd; + nMciErr = MCIFNC( mnDeviceId, MCI_CLOSE, MCI_WAIT, &aGenericParams, 0 ); + mnDeviceId = 0; + } + + if( rSoundName.Len() ) + { + // init new device with sound name + memset( &aOpenParams, 0, sizeof( aOpenParams ) ); + aOpenParams.pszElementName = (char*) rSoundName.GetStr(); + aOpenParams.hwndCallback = mhSoundWnd; + nMciErr = MCIFNC( 0, MCI_OPEN, MCI_WAIT | MCI_OPEN_ELEMENT, &aOpenParams, 0 ); + + if( !nMciErr ) + { + // set time format + MCI_SET_PARMS aSetParams; + memset( &aSetParams, 0, sizeof( aSetParams ) ); + mnDeviceId = aOpenParams.usDeviceID; + aSetParams.ulTimeFormat = MCI_FORMAT_MILLISECONDS; + nMciErr = MCIFNC( mnDeviceId, MCI_SET, MCI_WAIT | MCI_SET_TIME_FORMAT, &aSetParams, 0 ); + + if( !nMciErr ) + { + // get length of sound + MCI_STATUS_PARMS aStatus; + memset( &aStatus, 0, sizeof( aStatus ) ); + aStatus.ulItem = MCI_STATUS_LENGTH; + MCIFNC( mnDeviceId, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, &aStatus, 0 ); + rSoundLen = (ULONG) aStatus.ulReturn; + } + } + } + + if( nMciErr ) + ImplSetError( nMciErr ); + + return( nMciErr ? FALSE : TRUE ); +} + +// ------------------------------------------------------------------------ + +BOOL SalSound::Init( SalFrame* pFrame, const BYTE* pSound, ULONG nDataLen, ULONG& rSoundLen ) +{ + rSoundLen = 0UL; + ImplSetError( MCIERR_FILE_NOT_FOUND ); + + return FALSE; +} + +// ------------------------------------------------------------------------ + +void SalSound::Play( ULONG nStartTime, ULONG nPlayLen, BOOL bLoop ) +{ + if( mnDeviceId ) + { + ULONG nMciErr = 0; + + if( !mbPaused ) + { + MCI_SEEK_PARMS aSeekParams; + memset( &aSeekParams, 0, sizeof( aSeekParams ) ); + aSeekParams.hwndCallback = mhSoundWnd; + aSeekParams.ulTo = 0; + nMciErr = MCIFNC( mnDeviceId, MCI_SEEK,MCI_WAIT | MCI_TO, &aSeekParams, 0 ); + } + + mnStartTime = nStartTime; + mnPlayLen = nPlayLen; + mbLoop = bLoop; + mbPaused = FALSE; + + if( !nMciErr ) + { + MCI_PLAY_PARMS aPlayParams; + DWORD nFlags = MCI_NOTIFY; + + memset( &aPlayParams, 0, sizeof( aPlayParams ) ); + aPlayParams.hwndCallback = mhSoundWnd; + + if( nStartTime ) + { + aPlayParams.ulFrom = nStartTime; + nFlags |= MCI_FROM; + } + + if( nPlayLen != SOUND_PLAYALL ) + { + aPlayParams.ulTo = nStartTime + nPlayLen; + nFlags |= MCI_TO; + } + + nMciErr = MCIFNC( mnDeviceId, MCI_PLAY, nFlags, &aPlayParams, 0 ); + + if( !nMciErr ) + mbPaused = FALSE; + } + + if( nMciErr ) + ImplSetError( nMciErr ); + } + else + ImplSetError( MCIERR_EXTENSION_NOT_FOUND ); +} + +// ------------------------------------------------------------------------ + +void SalSound::Stop() +{ + if( mnDeviceId ) + { + MCI_GENERIC_PARMS aGenericParams; + memset( &aGenericParams, 0, sizeof( aGenericParams ) ); + aGenericParams.hwndCallback = mhSoundWnd; + mbLoop = mbPaused = FALSE; + MCIFNC( mnDeviceId, MCI_STOP, MCI_WAIT, &aGenericParams, 0 ); + } +} + +// ------------------------------------------------------------------------ + +void SalSound::Pause() +{ + if( mnDeviceId ) + { + MCI_GENERIC_PARMS aGenericParams; + memset( &aGenericParams, 0, sizeof( aGenericParams ) ); + aGenericParams.hwndCallback = mhSoundWnd; + mbPaused = TRUE; + MCIFNC( mnDeviceId, MCI_PAUSE, MCI_WAIT, &aGenericParams, 0 ); + } +} diff --git a/vcl/os2/source/app/salsys.cxx b/vcl/os2/source/app/salsys.cxx new file mode 100644 index 000000000000..54244723be33 --- /dev/null +++ b/vcl/os2/source/app/salsys.cxx @@ -0,0 +1,287 @@ +/************************************************************************* + * + * $RCSfile: salsys.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#define _SV_SALSYS_CXX + +#include + +#define INCL_DOS +#define INCL_DOSERRORS +#ifndef _SVPM_H +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_HXX +#include +#endif +#ifndef _SV_SALFRAME_HXX +#include +#endif +#ifndef _SV_SALBMP_HXX +#include +#endif +#ifndef _SV_SALSYS_HXX +#include +#endif +#ifndef _VOS_PROCESS_HXX +#include +#endif +#ifndef _TOOLS_FASTFSYS_HXX +#include +#endif + +#include +#include +#include +#include + +// ======================================================================= + +SalSystem* SalInstance::CreateSystem() +{ + return new SalSystem(); +} + +// ----------------------------------------------------------------------- + +void SalInstance::DestroySystem( SalSystem* pSystem ) +{ + delete pSystem; +} + +// ----------------------------------------------------------------------- + +SalSystem::SalSystem() +{ +} + +// ----------------------------------------------------------------------- + +SalSystem::~SalSystem() +{ +} + +// ----------------------------------------------------------------------- + +BOOL SalSystem::StartProcess( SalFrame* pFrame, const XubString& rFileName, + const XubString& rParam, + const XubString& rWorkingDirectory ) +{ + ItemIDPath aFile(rFileName); + + // + // first check if item has a context menu with open command + // + + ItemIDPath aParent, aChild; + + if(aFile.Split(aParent, aChild)) + { + IfcContextMenu *pConMenu = Folder(aParent).GetContextMenu(1, &aChild); + + if(pConMenu) + { + UINT32 nCount = pConMenu->GetItemCount(); + + for(UINT32 n = 0; n < nCount; n++) + { + MenuItem aMenuItem; + + if(pConMenu->GetMenuItem(n, aMenuItem) && + aMenuItem.aVerb.Compare("open") == COMPARE_EQUAL) + { + return pConMenu->ExecuteCommand(aMenuItem.aCommand); + } + } + } + } + + // Dateinamen mit Wildcards lehnen wir ab + if ( (rFileName.Search( '*' ) != STRING_NOTFOUND) || + (rFileName.Search( '?' ) != STRING_NOTFOUND) ) + return FALSE; + + XubString aFileName = aFile.GetHostNotationPath(); + char* aStdExtAry[] = { "exe", "com", "cmd", "bat" }; + const char* pStdExt; + const xub_Unicode* pFileName = aFileName.GetStr(); + const xub_Unicode* pParam = rParam.GetStr(); + XubString aSearchFileName; + XubString aExt; + BOOL bExe = FALSE; + BOOL bProcess = FALSE; + BOOL bRet = FALSE; + BOOL bExtension; + int i; + + // Parameter und Extension ermitteln + if ( !rParam.Len() ) + pParam = NULL; + // Wenn keine Extension, dann versuchen wir eine zu ermitteln, + // indem wir nach EXE-, COM-, CMD- oder BAT-Dateien suchen. + bExtension = ImplSalGetExtension( aFileName, aExt ); + if ( !bExtension ) + { + i = 0; + do + { + pStdExt = aStdExtAry[i]; + aSearchFileName = aFileName; + aSearchFileName += '.'; + aSearchFileName += pStdExt; + if ( ImplSalFindFile( aSearchFileName.GetStr(), aSearchFileName ) ) + { + pFileName = aSearchFileName.GetStr(); + bExtension = ImplSalGetExtension( aSearchFileName, aExt ); + break; + } + i++; + } + while ( i < 4 ); + } + else + { + // Ansonsten Filename im Pfad suchen + if ( ImplSalFindFile( pFileName, aSearchFileName ) ) + { + pFileName = aSearchFileName.GetStr(); + bExtension = ImplSalGetExtension( aSearchFileName, aExt ); + } + } + // Wenn wir eine Extension haben, testen wir, ob es eine + // Standard-Extension ist, womit wir einen Process starten koennen + if ( bExtension ) + { + aExt.ToLower(); + i = 0; + do + { + if ( aExt == aStdExtAry[i] ) + { + bExe = TRUE; + break; + } + i++; + } + while ( i < 4 ); + } + + // change to path of executable if no working dir set + XubString aWorkingDir(rWorkingDirectory); + + if(aWorkingDir.Len() == 0) + { + USHORT nIndex; + + aWorkingDir = pFileName; + nIndex = aWorkingDir.SearchCharBackward("\\/:"); + + if(nIndex == STRING_NOTFOUND) + nIndex = 0; + else if(aWorkingDir.GetChar(nIndex) == ':') + aWorkingDir[nIndex++] = '\\'; + + aWorkingDir.Erase(nIndex); + } + + // start executables with process execute + if ( bExe ) + { + NAMESPACE_VOS( OProcess )::TProcessError nProcessError; + NAMESPACE_VOS( OProcess ) aProcess( pFileName, pParam ); + + aProcess.setDirectory(aWorkingDir.GetStr()); + + nProcessError = aProcess.execute( (NAMESPACE_VOS(OProcess)::TProcessOption) + (NAMESPACE_VOS(OProcess)::TOption_Detached) ); + bRet = nProcessError == NAMESPACE_VOS( OProcess )::E_None; + } + + // when not startet, start programm with WPS + if ( !bRet ) + { + HOBJECT hObject = WinQueryObject( pFileName ); + if ( hObject ) + { + if ( WinOpenObject( hObject, 0, FALSE ) ) + bRet = TRUE; + } + } + + return bRet; +} + +// ----------------------------------------------------------------------- + +BOOL SalSystem::AddRecentDoc( SalFrame* pFrame, const XubString& rFileName ) +{ + return FALSE; +} + +// ----------------------------------------------------------------------- + +String SalSystem::GetSummarySystemInfos( ULONG nFlags ) +{ + return String(); +} + diff --git a/vcl/os2/source/app/saltimer.cxx b/vcl/os2/source/app/saltimer.cxx new file mode 100644 index 000000000000..284c987c4250 --- /dev/null +++ b/vcl/os2/source/app/saltimer.cxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: saltimer.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#define _SV_SALTIMER_CXX + +#ifndef _SV_SALINST_H +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALFRAME_HXX +#include +#endif +#ifndef _SV_SALTIMER_HXX +#include +#endif + +// ======================================================================= + +// Maximale Periode +#define MAX_SYSPERIOD 65533 + +// ======================================================================= + +void ImplSalStartTimer() +{ + SalData* pSalData = GetSalData(); + SalFrame* pSalFrame = GetSalDefaultFrame(); + + // Periode darf nicht zu gross sein, da OS2 2.11 mit USHORT arbeitet + ULONG nMS = pSalData->mnNewTimerMS; + if ( nMS > MAX_SYSPERIOD ) + nMS = MAX_SYSPERIOD; + + // Gibt es einen Timer, dann zerstoren + if ( pSalData->mnTimerId ) + WinStopTimer( pSalData->mhAB, pSalFrame->maFrameData.mhWndClient, pSalData->mnTimerId ); + + // Make a new timer with new period + pSalData->mnTimerId = WinStartTimer( pSalData->mhAB, pSalFrame->maFrameData.mhWndClient, 10, nMS ); +} + +// ----------------------------------------------------------------------- + +void SalTimer::Stop() +{ + SalData* pSalData = GetSalData(); + SalFrame* pSalFrame = GetSalDefaultFrame(); + + // Exitstiert ein Timer, dann diesen zerstoeren + if ( pSalData->mnTimerId ) + WinStopTimer( pSalData->mhAB, pSalFrame->maFrameData.mhWndClient, pSalData->mnTimerId ); +} + +// ----------------------------------------------------------------------- + +void SalTimer::SetCallback( SALTIMERPROC pProc ) +{ + SalData* pSalData = GetSalData(); + pSalData->mpTimerProc = pProc; +} diff --git a/vcl/os2/source/gdi/makefile.mk b/vcl/os2/source/gdi/makefile.mk new file mode 100644 index 000000000000..e3a50cad9c94 --- /dev/null +++ b/vcl/os2/source/gdi/makefile.mk @@ -0,0 +1,94 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=SV +TARGET=salgdi + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +CXXFILES= salgdi.cxx \ + salgdi2.cxx \ + salgdi3.cxx \ + salvd.cxx \ + salprn.cxx \ + salbmp.cxx \ + salogl.cxx + +SLOFILES= $(SLO)$/salgdi.obj \ + $(SLO)$/salgdi2.obj \ + $(SLO)$/salgdi3.obj \ + $(SLO)$/salvd.obj \ + $(SLO)$/salprn.obj \ + $(SLO)$/salbmp.obj \ + $(SLO)$/salogl.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/vcl/os2/source/gdi/salbmp.cxx b/vcl/os2/source/gdi/salbmp.cxx new file mode 100644 index 000000000000..d53814a481a5 --- /dev/null +++ b/vcl/os2/source/gdi/salbmp.cxx @@ -0,0 +1,760 @@ +/************************************************************************* + * + * $RCSfile: salbmp.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#define _SV_SALBMP_CXX + +#ifndef _RTL_ALLOC_H_ +#include +#endif +#ifndef _SV_SALBTYPE_HXX +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALBMP_HXX +#include +#endif +#include + +// ----------- +// - Inlines - +// ----------- + +inline void ImplSetPixel4( const HPBYTE pScanline, long nX, const BYTE cIndex ) +{ + BYTE& rByte = pScanline[ nX >> 1 ]; + + ( nX & 1 ) ? ( rByte &= 0xf0, rByte |= ( cIndex & 0x0f ) ) : + ( rByte &= 0x0f, rByte |= ( cIndex << 4 ) ); +} + +// ------------- +// - SalBitmap - +// ------------- + +SalBitmap::SalBitmap() : + mhDIB ( 0 ), + mhDIB1Subst ( 0 ), + mhDDB ( 0 ), + mnBitCount ( 0 ) +{ +} + +// ------------------------------------------------------------------ + +SalBitmap::~SalBitmap() +{ + Destroy(); +} + +// ------------------------------------------------------------------ + +BOOL SalBitmap::Create( HANDLE hBitmap, BOOL bDIB, BOOL bCopyHandle ) +{ + BOOL bRet = TRUE; + + if( bDIB ) + mhDIB = (HANDLE) ( bCopyHandle ? ImplCopyDIBOrDDB( hBitmap, TRUE ) : hBitmap ); + else + mhDDB = (HBITMAP) ( bCopyHandle ? ImplCopyDIBOrDDB( hBitmap, FALSE ) : hBitmap ); + + if( mhDIB ) + { + // bitmap-header is the beginning of memory block + PBITMAPINFOHEADER2 pBIH = (PBITMAPINFOHEADER2) mhDIB; + + maSize = Size( pBIH->cx, pBIH->cy ); + mnBitCount = pBIH->cBitCount; + + if( mnBitCount ) + mnBitCount = ( mnBitCount <= 1 ) ? 1 : ( mnBitCount <= 4 ) ? 4 : ( mnBitCount <= 8 ) ? 8 : 24; + } + else if( mhDDB ) + { + BITMAPINFOHEADER2 aDDBInfoHeader; + + aDDBInfoHeader.cbFix = sizeof( aDDBInfoHeader ); + + if( GpiQueryBitmapInfoHeader( mhDDB, &aDDBInfoHeader ) ) + { + maSize = Size( aDDBInfoHeader.cx, aDDBInfoHeader.cy ); + mnBitCount = aDDBInfoHeader.cPlanes * aDDBInfoHeader.cBitCount; + + if( mnBitCount ) + { + mnBitCount = ( mnBitCount <= 1 ) ? 1 : + ( mnBitCount <= 4 ) ? 4 : + ( mnBitCount <= 8 ) ? 8 : 24; + } + } + else + { + mhDDB = 0; + bRet = FALSE; + } + + } + else + bRet = FALSE; + + return bRet; +} + +// ------------------------------------------------------------------ + +BOOL SalBitmap::Create( const Size& rSize, USHORT nBitCount, const BitmapPalette& rPal ) +{ + BOOL bRet = FALSE; + + mhDIB = ImplCreateDIB( rSize, nBitCount, rPal ); + + if( mhDIB ) + { + maSize = rSize; + mnBitCount = nBitCount; + bRet = TRUE; + } + + return bRet; +} + +// ------------------------------------------------------------------ + +BOOL SalBitmap::Create( const SalBitmap& rSalBitmap ) +{ + BOOL bRet = FALSE; + + if ( rSalBitmap.mhDIB || rSalBitmap.mhDDB ) + { + HANDLE hNewHdl = ImplCopyDIBOrDDB( rSalBitmap.mhDIB ? rSalBitmap.mhDIB : rSalBitmap.mhDDB, + rSalBitmap.mhDIB != 0 ); + + if( hNewHdl ) + { + if( rSalBitmap.mhDIB ) + mhDIB = (HANDLE) hNewHdl; + else if( rSalBitmap.mhDDB ) + mhDDB = (HBITMAP) hNewHdl; + + maSize = rSalBitmap.maSize; + mnBitCount = rSalBitmap.mnBitCount; + bRet = TRUE; + } + } + + return bRet; +} + +// ------------------------------------------------------------------ + +BOOL SalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) +{ + BOOL bRet = FALSE; + + if( rSalBmp.mhDIB ) + { + HPS hPS = pGraphics->maGraphicsData.mhPS; + HBITMAP hNewDDB; + BITMAPINFOHEADER2 aInfoHeader; + const Size aSize( rSalBmp.GetSize() ); + long nFormat[ 2 ]; + + memset( &aInfoHeader, 0, sizeof( aInfoHeader ) ); + aInfoHeader.cbFix = 16; + aInfoHeader.cx = aSize.Width(); + aInfoHeader.cy = aSize.Height(); + + GpiQueryDeviceBitmapFormats( hPS, 2L, (PLONG) &nFormat ); + aInfoHeader.cPlanes = nFormat[ 0 ]; + aInfoHeader.cBitCount = nFormat[ 1 ]; + + // ! wegen Postscript-Treiber + if( !aInfoHeader.cBitCount ) + aInfoHeader.cBitCount = 24; + else if( ( aInfoHeader.cPlanes == 1 ) && ( aInfoHeader.cBitCount == 1 ) ) + aInfoHeader.cBitCount = 4; + + // BitCount == 1 ist wegen aller moeglichen Treiberfehler nicht moeglich + if( rSalBmp.GetBitCount() == 1 ) + { + HANDLE hTmp = ImplCreateDIB4FromDIB1( rSalBmp.mhDIB ); + PBYTE pBits = (PBYTE) hTmp + *(ULONG*) hTmp + ImplGetDIBColorCount( hTmp ) * sizeof( RGB2 ); + + hNewDDB = GpiCreateBitmap( hPS, &aInfoHeader, CBM_INIT, pBits, (PBITMAPINFO2) hTmp ); + rtl_freeMemory( hTmp ); + } + else + { + PBYTE pBits = (PBYTE) rSalBmp.mhDIB + *(ULONG*) rSalBmp.mhDIB + ImplGetDIBColorCount( rSalBmp.mhDIB ) * sizeof( RGB2 ); + hNewDDB = GpiCreateBitmap( hPS, &aInfoHeader, CBM_INIT, pBits, (PBITMAPINFO2) rSalBmp.mhDIB ); + } + + aInfoHeader.cbFix = sizeof( aInfoHeader ); + + if( hNewDDB && GpiQueryBitmapInfoHeader( hNewDDB, &aInfoHeader ) ) + { + mhDDB = hNewDDB; + maSize = Size( aInfoHeader.cx, aInfoHeader.cy ); + mnBitCount = aInfoHeader.cPlanes * aInfoHeader.cBitCount; + + if( mnBitCount ) + { + mnBitCount = ( mnBitCount <= 1 ) ? 1 : + ( mnBitCount <= 4 ) ? 4 : + ( mnBitCount <= 8 ) ? 8 : 24; + } + + bRet = TRUE; + } + else if( hNewDDB ) + GpiDeleteBitmap( hNewDDB ); + } + + return bRet; +} + +// ------------------------------------------------------------------ + +BOOL SalBitmap::Create( const SalBitmap& rSalBmp, USHORT nNewBitCount ) +{ + BOOL bRet = FALSE; + + if( rSalBmp.mhDDB ) + { + mhDIB = ImplCreateDIB( rSalBmp.maSize, nNewBitCount, BitmapPalette() ); + + if( mhDIB ) + { + // bitmap-header is the beginning of memory block + PBITMAPINFO2 pBI = (PBITMAPINFO2) mhDIB; + const int nLines = (int) rSalBmp.maSize.Height(); + PBYTE pBits = (PBYTE) pBI + *(ULONG*) pBI + ImplGetDIBColorCount( mhDIB ) * sizeof( RGB2 ); + SIZEL aSizeL = { rSalBmp.maSize.Width(), nLines }; + HAB hAB = GetSalData()->mhAB; + DEVOPENSTRUC aDevOpenStruc = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + HDC hMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 ); + HPS hMemPS = GpiCreatePS( hAB, hMemDC, &aSizeL, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); + HBITMAP hMemOld = (HBITMAP) GpiSetBitmap( hMemPS, rSalBmp.mhDDB ); + + if( GpiQueryBitmapBits( hMemPS, 0, nLines, pBits, pBI ) == nLines ) + { + maSize = rSalBmp.maSize; + mnBitCount = nNewBitCount; + bRet = TRUE; + } + else + { + rtl_freeMemory( mhDIB ); + mhDIB = 0; + } + + GpiSetBitmap( hMemPS, hMemOld ); + GpiDestroyPS( hMemPS ); + DevCloseDC( hMemDC ); + } + } + + return bRet; +} + +// ------------------------------------------------------------------ + +void SalBitmap::Destroy() +{ + if( mhDIB ) + rtl_FreeMemory( mhDIB ); + else if( mhDDB ) + GpiDeleteBitmap( mhDDB ); + + if( mhDIB1Subst ) + { + rtl_FreeMemory( mhDIB1Subst ); + mhDIB1Subst = NULL; + } + + maSize = Size(); + mnBitCount = 0; +} + +// ------------------------------------------------------------------ + +void SalBitmap::ImplReplacehDIB1Subst( HANDLE hDIB1Subst ) +{ + if( mhDIB1Subst ) + rtl_FreeMemory( mhDIB1Subst ); + + mhDIB1Subst = hDIB1Subst; +} + +// ------------------------------------------------------------------ + +USHORT SalBitmap::ImplGetDIBColorCount( HANDLE hDIB ) +{ + USHORT nColors = 0; + + if( hDIB ) + { + // bitmap infos can be found at the beginning of the memory + PBITMAPINFOHEADER2 pBIH = (PBITMAPINFOHEADER2) hDIB; + + if( pBIH->cBitCount <= 8 ) + { + if( pBIH->cclrUsed ) + nColors = (USHORT) pBIH->cclrUsed; + else + nColors = 1 << pBIH->cBitCount; + } + } + + return nColors; +} + +// ------------------------------------------------------------------ + +HANDLE SalBitmap::ImplCreateDIB( const Size& rSize, USHORT nBits, const BitmapPalette& rPal ) +{ + DBG_ASSERT( nBits == 1 || nBits == 4 || nBits == 8 || nBits == 24, "Unsupported BitCount!" ); + + HANDLE hDIB = 0; + + if ( rSize.Width() && rSize.Height() && ( nBits == 1 || nBits == 4 || nBits == 8 || nBits == 24 ) ) + { + const ULONG nImageSize = AlignedWidth4Bytes( nBits * rSize.Width() ) * rSize.Height(); + const USHORT nColors = ( nBits <= 8 ) ? ( 1 << nBits ) : 0; + + hDIB = (HANDLE) rtl_allocateZeroMemory( sizeof( BITMAPINFOHEADER2 ) + nColors * sizeof( RGB2 ) + nImageSize ); + + if( hDIB ) + { + // bitmap infos can be found at the beginning of the memory + PBITMAPINFO2 pBI = (PBITMAPINFO2) hDIB; + PBITMAPINFOHEADER2 pBIH = (PBITMAPINFOHEADER2) pBI; + + pBIH->cbFix = sizeof( BITMAPINFOHEADER2 ); + pBIH->cx = rSize.Width(); + pBIH->cy = rSize.Height(); + pBIH->cPlanes = 1; + pBIH->cBitCount = nBits; + pBIH->ulCompression = BCA_UNCOMP; // BI_RGB; + pBIH->cbImage = nImageSize; + pBIH->cxResolution = 0; + pBIH->cyResolution = 0; + pBIH->cclrUsed = 0; + pBIH->cclrImportant = 0; + + // Rest auf 0 setzen + memset( (PBYTE) &pBIH->usUnits, 0, (PBYTE) pBI->argbColor - (PBYTE) &pBIH->usUnits ); + + if( nColors ) + { + const USHORT nMinCount = Min( nColors, rPal.GetEntryCount() ); + + if( nMinCount ) + HMEMCPY( pBI->argbColor, rPal.ImplGetColorBuffer(), nMinCount * sizeof( RGB2 ) ); + } + } + } + + return hDIB; +} + +// ------------------------------------------------------------------ + +HANDLE SalBitmap::ImplCreateDIB4FromDIB1( HANDLE hDIB1 ) +{ + PBITMAPINFO2 pBI = (PBITMAPINFO2) hDIB1; + PBITMAPINFOHEADER2 pBIH = (PBITMAPINFOHEADER2) pBI; + PBYTE pBits = (PBYTE) pBI + *(ULONG*) pBIH + SalBitmap::ImplGetDIBColorCount( hDIB1 ) * sizeof( RGB2 ); + ULONG nWidth = pBIH->cx, nHeight = pBIH->cy; + ULONG nAligned = AlignedWidth4Bytes( nWidth ); + ULONG nAligned4 = AlignedWidth4Bytes( nWidth << 2 ); + ULONG nSize4 = sizeof( BITMAPINFOHEADER2 ) + ( sizeof( RGB2 ) << 4 ) + nAligned4 * nHeight; + PBYTE pDIB4 = (PBYTE) rtl_allocateZeroMemory( nSize4 ); + PBITMAPINFO2 pBI4 = (PBITMAPINFO2) pDIB4; + PBITMAPINFOHEADER2 pBIH4 = (PBITMAPINFOHEADER2) pBI4; + BYTE aMap[ 4 ] = { 0x00, 0x01, 0x10, 0x11 }; + + memset( pBIH4, 0, sizeof( BITMAPINFOHEADER2 ) ); + pBIH4->cbFix = sizeof( BITMAPINFOHEADER2 ); + pBIH4->cx = nWidth; + pBIH4->cy = nHeight; + pBIH4->cPlanes = 1; + pBIH4->cBitCount = 4; + + // die ersten beiden Eintraege der 1Bit-Farbtabelle kopieren + memcpy( pBI4->argbColor, pBI->argbColor, sizeof( RGB2 ) << 1 ); + + PBYTE pBits4 = (PBYTE) pBI4 + *(ULONG*) pBIH4 + ( sizeof( RGB2 ) << 4 ); + + // 4Bit-DIB-Bilddaten setzen + for( ULONG nY = 0UL; nY < nHeight; nY++ ) + { + PBYTE pTmp = pBits; pBits += nAligned; + PBYTE pTmp4 = pBits4; pBits4 += nAligned4; + + for( ULONG nX = 0UL; nX < nWidth; nX += 8UL ) + { + *pTmp4++ = aMap[ ( *pTmp >> 6 ) & 3 ]; + *pTmp4++ = aMap[ ( *pTmp >> 4 ) & 3 ]; + *pTmp4++ = aMap[ ( *pTmp >> 2 ) & 3 ]; + *pTmp4++ = aMap[ *pTmp++ & 3 ]; + } + } + + return (HANDLE) pDIB4; +} + +// ------------------------------------------------------------------ + +HANDLE SalBitmap::ImplCopyDIBOrDDB( HANDLE hHdl, BOOL bDIB ) +{ + HANDLE hCopy = 0; + + if( bDIB && hHdl ) + { + PBITMAPINFOHEADER2 pBIH = (PBITMAPINFOHEADER2) hHdl; + const ULONG nSize = sizeof( BITMAPINFOHEADER2 ) + + ImplGetDIBColorCount( hHdl ) * sizeof( RGB2 ) + + ( pBIH->cbImage ? pBIH->cbImage : AlignedWidth4Bytes( pBIH->cx * pBIH->cBitCount ) ); + + BYTE* pCopy = rtl_allocateZeroMemory( nSize ); + memcpy( pCopy, (BYTE*) hHdl, nSize ); + hCopy = (HANDLE) pCopy; + } + else if( hHdl ) + { + HAB hAB = GetSalData()->mhAB; + HDC hSrcMemDC; + HDC hDestMemDC; + HPS hSrcMemPS; + HPS hDestMemPS; + HBITMAP hCopyBitmap; + BITMAPINFOHEADER2 aInfoHeader; + DEVOPENSTRUC aDevOpenStruc; + SIZEL size; + + aInfoHeader.cbFix = sizeof( BITMAPINFOHEADER2 ); + GpiQueryBitmapInfoHeader( hHdl, &aInfoHeader ); + size.cx = aInfoHeader.cx; + size.cy = aInfoHeader.cy; + + // Memory DCs erzeugen + aDevOpenStruc.pszLogAddress = 0; + aDevOpenStruc.pszDriverName = (PSZ)"DISPLAY"; + + hSrcMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 2, (PDEVOPENDATA)&aDevOpenStruc, 0 ); + hDestMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 2, (PDEVOPENDATA)&aDevOpenStruc, 0 ); + + // Memory PSs erzeugen + hSrcMemPS = GpiCreatePS( hAB, hSrcMemDC, &size, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); + hDestMemPS = GpiCreatePS( hAB, hDestMemDC, &size, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); + + GpiSetBitmap( hSrcMemPS, hHdl ); + + if( !hHdl ) + { + memset( &aInfoHeader, 0, sizeof( BITMAPINFOHEADER2 ) ); + aInfoHeader.cbFix = sizeof( BITMAPINFOHEADER2 ); + aInfoHeader.cx = 0; + aInfoHeader.cy = 0; + aInfoHeader.cPlanes = 1; + aInfoHeader.cBitCount = 1; + } + + hCopy = GpiCreateBitmap( hDestMemPS, &aInfoHeader, 0, NULL, NULL ); + GpiSetBitmap( hDestMemPS, hCopy ); + + POINTL pts[3]; + + pts[0].x = 0; + pts[0].y = 0; + pts[1].x = size.cx; + pts[1].y = size.cy; + pts[2].x = 0; + pts[2].y = 0; + + GpiBitBlt( hDestMemPS, hSrcMemPS, 3, pts, ROP_SRCCOPY, BBO_IGNORE ); + + GpiSetBitmap( hSrcMemPS, (HBITMAP)0L); + GpiSetBitmap( hDestMemPS, (HBITMAP)0L); + GpiAssociate( hSrcMemPS, NULLHANDLE ); + GpiAssociate( hDestMemPS, NULLHANDLE ); + GpiDestroyPS( hSrcMemPS ); + GpiDestroyPS( hDestMemPS ); + DevCloseDC( hSrcMemDC ); + DevCloseDC( hDestMemDC ); + } + + return hCopy; +} + +// ------------------------------------------------------------------ + +BitmapBuffer* SalBitmap::AcquireBuffer( BOOL bReadOnly ) +{ + BitmapBuffer* pBuffer = NULL; + + if( mhDIB ) + { + // bitmap infos can be found at the beginning of the memory + PBITMAPINFO2 pBI = (PBITMAPINFO2) mhDIB; + PBITMAPINFOHEADER2 pBIH = (PBITMAPINFOHEADER2) pBI; + + if( ( pBIH->ulCompression == BCA_RLE4 ) || ( pBIH->ulCompression == BCA_RLE8 ) ) + { + Size aSizePix( pBIH->cx, pBIH->cy ); + HANDLE hNewDIB = ImplCreateDIB( aSizePix, pBIH->cBitCount, BitmapPalette() ); + + if( hNewDIB ) + { + // bitmap infos can be found at the beginning of the memory + PBITMAPINFO2 pNewBI = (PBITMAPINFO2) hNewDIB; + PBITMAPINFOHEADER2 pNewBIH = (PBITMAPINFOHEADER2) pNewBI; + const USHORT nColorCount = ImplGetDIBColorCount( hNewDIB ); + const ULONG nOffset = *(ULONG*) pBI + nColorCount * sizeof( RGB2 ); + BYTE* pOldBits = (BYTE*) pBI + nOffset; + BYTE* pNewBits = (BYTE*) pNewBI + nOffset; + + memcpy( pNewBI, pBI, nOffset ); + pNewBIH->ulCompression = 0; + ImplDecodeRLEBuffer( pOldBits, pNewBits, aSizePix, pBIH->ulCompression == BCA_RLE4 ); + + rtl_freeMemory( mhDIB ); + + mhDIB = hNewDIB; + pBI = pNewBI; + pBIH = pNewBIH; + } + } + + if( pBIH->cPlanes == 1 ) + { + pBuffer = new BitmapBuffer; + + pBuffer->mnFormat = BMP_FORMAT_BOTTOM_UP | + ( pBIH->cBitCount == 1 ? BMP_FORMAT_1BIT_MSB_PAL : + pBIH->cBitCount == 4 ? BMP_FORMAT_4BIT_MSN_PAL : + pBIH->cBitCount == 8 ? BMP_FORMAT_8BIT_PAL : + pBIH->cBitCount == 16 ? BMP_FORMAT_16BIT_TC_MASK : + pBIH->cBitCount == 24 ? BMP_FORMAT_24BIT_TC_BGR : + pBIH->cBitCount == 32 ? BMP_FORMAT_32BIT_TC_MASK : 0UL ); + + if( BMP_SCANLINE_FORMAT( pBuffer->mnFormat ) ) + { + pBuffer->mnWidth = maSize.Width(); + pBuffer->mnHeight = maSize.Height(); + pBuffer->mnScanlineSize = AlignedWidth4Bytes( maSize.Width() * pBIH->cBitCount ); + pBuffer->mnBitCount = (USHORT) pBIH->cBitCount; + + if( pBuffer->mnBitCount <= 8 ) + { + const USHORT nPalCount = ImplGetDIBColorCount( mhDIB ); + + pBuffer->maPalette.SetEntryCount( nPalCount ); + + if( nPalCount ) + memcpy( pBuffer->maPalette.ImplGetColorBuffer(), pBI->argbColor, nPalCount * sizeof( RGB2 ) ); + + pBuffer->mpBits = (BYTE*) pBI + *(ULONG*) pBI + nPalCount * sizeof( RGB2 ); + } + else + pBuffer->mpBits = (BYTE*) pBI + *(ULONG*) pBI; + } + else + { + delete pBuffer; + pBuffer = NULL; + } + } + } + + if( pBuffer && mhDIB1Subst ) + { + rtl_FreeMemory( mhDIB1Subst ); + mhDIB1Subst = 0; + } + + return pBuffer; +} + +// ------------------------------------------------------------------ + +void SalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BOOL bReadOnly ) +{ + if( pBuffer ) + { + if( mhDIB ) + { + if( !bReadOnly && !!pBuffer->maPalette ) + { + // bitmap infos can be found at the beginning of the memory + PBITMAPINFO2 pBI = (PBITMAPINFO2) mhDIB; + const USHORT nCount = pBuffer->maPalette.GetEntryCount(); + + if( nCount ) + memcpy( pBI->argbColor, pBuffer->maPalette.ImplGetColorBuffer(), nCount * sizeof( RGB2 ) ); + } + } + + delete pBuffer; + } +} + +// ------------------------------------------------------------------ + +void SalBitmap::ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf, + const Size& rSizePixel, BOOL bRLE4 ) +{ + HPBYTE pRLE = (HPBYTE) pSrcBuf; + HPBYTE pDIB = (HPBYTE) pDstBuf; + HPBYTE pRow = (HPBYTE) pDstBuf; + ULONG nWidthAl = AlignedWidth4Bytes( rSizePixel.Width() * ( bRLE4 ? 4UL : 8UL ) ); + HPBYTE pLast = pDIB + rSizePixel.Height() * nWidthAl - 1; + ULONG nCountByte; + ULONG nRunByte; + ULONG nX = 0; + ULONG i; + BYTE cTmp; + BOOL bEndDecoding = FALSE; + + if( pRLE && pDIB ) + { + do + { + if( !( nCountByte = *pRLE++ ) ) + { + nRunByte = *pRLE++; + + if( nRunByte > 2UL ) + { + if( bRLE4 ) + { + nCountByte = nRunByte >> 1UL; + + for( i = 0; i < nCountByte; i++ ) + { + cTmp = *pRLE++; + ImplSetPixel4( pDIB, nX++, cTmp >> 4 ); + ImplSetPixel4( pDIB, nX++, cTmp & 0x0f ); + } + + if( nRunByte & 1 ) + ImplSetPixel4( pDIB, nX++, *pRLE++ >> 4 ); + + if( ( ( nRunByte + 1 ) >> 1 ) & 1 ) + pRLE++; + } + else + { + HMEMCPY( &pDIB[ nX ], pRLE, nRunByte ); + pRLE += nRunByte; + nX += nRunByte; + + if( nRunByte & 1 ) + pRLE++; + } + } + else if( !nRunByte ) + { + pDIB = ( pRow += nWidthAl ); + nX = 0UL; + } + else if( nRunByte == 1 ) + bEndDecoding = TRUE; + else + { + nX += *pRLE++; + pDIB = ( pRow += ( *pRLE++ ) * nWidthAl ); + } + } + else + { + cTmp = *pRLE++; + + if( bRLE4 ) + { + nRunByte = nCountByte >> 1; + + for( i = 0; i < nRunByte; i++ ) + { + ImplSetPixel4( pDIB, nX++, cTmp >> 4 ); + ImplSetPixel4( pDIB, nX++, cTmp & 0x0f ); + } + + if( nCountByte & 1 ) + ImplSetPixel4( pDIB, nX++, cTmp >> 4 ); + } + else + { + for( i = 0; i < nCountByte; i++ ) + pDIB[ nX++ ] = cTmp; + } + } + } + while( !bEndDecoding && ( pDIB <= pLast ) ); + } +} diff --git a/vcl/os2/source/gdi/salgdi.cxx b/vcl/os2/source/gdi/salgdi.cxx new file mode 100644 index 000000000000..f501f8da303e --- /dev/null +++ b/vcl/os2/source/gdi/salgdi.cxx @@ -0,0 +1,852 @@ +/************************************************************************* + * + * $RCSfile: salgdi.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#define _SV_SALGDI_CXX + +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALVD_HXX +#include +#endif + +// ----------- +// - Defines - +// ----------- + +// ClipRegions funktionieren immer noch nicht auf allen getesteten Druckern +#define SAL_PRINTER_CLIPPATH 1 +// #define SAL_PRINTER_POLYPATH 1 + +// ======================================================================= + +void ImplInitSalGDI() +{ +} + +// ----------------------------------------------------------------------- + +void ImplFreeSalGDI() +{ +} + +// ======================================================================= + +void ImplSalInitGraphics( SalGraphicsData* pData ) +{ + GpiCreateLogColorTable( pData->mhPS, LCOL_RESET, LCOLF_RGB, 0, 0, NULL ); +} + +// ----------------------------------------------------------------------- + +void ImplSalDeInitGraphics( SalGraphicsData* pData ) +{ +} + +// ======================================================================= + +SalGraphics::SalGraphics() +{ + maGraphicsData.mhPS = 0; + maGraphicsData.mhDC = 0; + maGraphicsData.mbLine = FALSE; + maGraphicsData.mbFill = FALSE; + maGraphicsData.mbXORMode = FALSE; + maGraphicsData.mbFontIsOutline = FALSE; + maGraphicsData.mbFontIsFixed = FALSE; + maGraphicsData.mnFontMetricCount = 0; + maGraphicsData.mpFontMetrics = NULL; + maGraphicsData.mpClipRectlAry = NULL; +} + +// ----------------------------------------------------------------------- + +SalGraphics::~SalGraphics() +{ + if ( maGraphicsData.mpFontMetrics ) + delete maGraphicsData.mpFontMetrics; +} + +// ----------------------------------------------------------------------- + +static SalColor ImplGetROPSalColor( SalROPColor nROPColor ) +{ + SalColor nSalColor; + + switch( nROPColor ) + { + case SAL_ROP_0: + nSalColor = MAKE_SALCOLOR( 0, 0, 0 ); + break; + + case SAL_ROP_1: + case SAL_ROP_INVERT: + nSalColor = MAKE_SALCOLOR( 255, 255, 255 ); + break; + } + + return nSalColor; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::GetResolution( long& rDPIX, long& rDPIY ) +{ + long nResolution; + + // convert resolution from pels per meter to pels per inch + DevQueryCaps( maGraphicsData.mhDC, CAPS_HORIZONTAL_RESOLUTION, 1, &nResolution ); + rDPIX = (nResolution * 100) / 3937; + + // convert resolution from pels per meter to pels per inch + DevQueryCaps( maGraphicsData.mhDC, CAPS_VERTICAL_RESOLUTION, 1, &nResolution ); + rDPIY = (nResolution * 100) / 3937; + + if ( rDPIY < 96 ) + { + rDPIX = (rDPIX*96) / rDPIY; + rDPIY = 96; + } +} + +// ----------------------------------------------------------------------- + +void SalGraphics::GetScreenFontResolution( long& rDPIX, long& rDPIY ) +{ + DevQueryCaps( maGraphicsData.mhDC, CAPS_HORIZONTAL_FONT_RES, 1, &rDPIX ); + DevQueryCaps( maGraphicsData.mhDC, CAPS_VERTICAL_FONT_RES, 1, &rDPIY ); +} + +// ----------------------------------------------------------------------- + +USHORT SalGraphics::GetBitCount() +{ + LONG nBitCount; + DevQueryCaps( maGraphicsData.mhDC, CAPS_COLOR_BITCOUNT, 1, &nBitCount ); + return (USHORT)nBitCount; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::ResetClipRegion() +{ +#ifdef SAL_PRINTER_CLIPPATH + if ( maGraphicsData.mbPrinter ) + GpiSetClipPath( maGraphicsData.mhPS, 0, SCP_RESET ); + else +#endif + { + HRGN hOldRegion; + + GpiSetClipRegion( maGraphicsData.mhPS, NULL, &hOldRegion ); + if ( hOldRegion ) + GpiDestroyRegion( maGraphicsData.mhPS, hOldRegion ); + } +} + +// ----------------------------------------------------------------------- + +void SalGraphics::BeginSetClipRegion( ULONG nCount ) +{ + maGraphicsData.mpClipRectlAry = new RECTL[ nCount ]; + maGraphicsData.mnClipElementCount = 0; +} + +// ----------------------------------------------------------------------- + +BOOL SalGraphics::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) +{ + RECTL* pClipRect = &maGraphicsData.mpClipRectlAry[ maGraphicsData.mnClipElementCount ]; + pClipRect->xLeft = nX; + pClipRect->yTop = maGraphicsData.mnHeight - nY; + pClipRect->xRight = nX + nWidth; + pClipRect->yBottom = maGraphicsData.mnHeight - (nY + nHeight); + maGraphicsData.mnClipElementCount++; + + return TRUE; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::EndSetClipRegion() +{ +#ifdef SAL_PRINTER_CLIPPATH + if ( maGraphicsData.mbPrinter ) + { + GpiSetClipPath( maGraphicsData.mhPS, 0, SCP_RESET ); + GpiBeginPath( maGraphicsData.mhPS, 1L ); + + for( int i = 0; i < maGraphicsData.mnClipElementCount; i++ ) + { + POINTL aPt; + RECTL* pClipRect = &maGraphicsData.mpClipRectlAry[ i ]; + + aPt.x = pClipRect->xLeft; + aPt.y = pClipRect->yTop-1; + GpiMove( maGraphicsData.mhPS, &aPt ); + + aPt.x = pClipRect->xRight-1; + aPt.y = pClipRect->yBottom; + + GpiBox( maGraphicsData.mhPS, DRO_OUTLINE, &aPt, 0, 0 ); + } + + GpiEndPath( maGraphicsData.mhPS ); + GpiSetClipPath( maGraphicsData.mhPS, 1L, SCP_ALTERNATE | SCP_AND ); + } + else +#endif + { + HRGN hClipRegion = GpiCreateRegion( maGraphicsData.mhPS, + maGraphicsData.mnClipElementCount, + maGraphicsData.mpClipRectlAry ); + HRGN hOldRegion; + + GpiSetClipRegion( maGraphicsData.mhPS, hClipRegion, &hOldRegion ); + if( hOldRegion ) + GpiDestroyRegion( maGraphicsData.mhPS, hOldRegion ); + } + + delete [] maGraphicsData.mpClipRectlAry; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::SetLineColor() +{ + // don't draw line! + maGraphicsData.mbLine = FALSE; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::SetLineColor( SalColor nSalColor ) +{ + LINEBUNDLE lb; + + // set color + lb.lColor = RGBCOLOR( SALCOLOR_RED( nSalColor ), + SALCOLOR_GREEN( nSalColor ), + SALCOLOR_BLUE( nSalColor ) ); + + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_LINE, + LBB_COLOR, + 0, + &lb ); + + // draw line! + maGraphicsData.mbLine = TRUE; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::SetFillColor() +{ + // don't fill area! + maGraphicsData.mbFill = FALSE; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::SetFillColor( SalColor nSalColor ) +{ + AREABUNDLE ab; + + // set color + ab.lColor = RGBCOLOR( SALCOLOR_RED( nSalColor ), + SALCOLOR_GREEN( nSalColor ), + SALCOLOR_BLUE( nSalColor ) ); + + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_AREA, + ABB_COLOR, + 0, + &ab ); + + // fill area! + maGraphicsData.mbFill = TRUE; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::SetXORMode( BOOL bSet ) +{ + maGraphicsData.mbXORMode = bSet; + LONG nMixMode = bSet ? FM_XOR : FM_OVERPAINT; + + // set mix mode for lines + LINEBUNDLE lb; + lb.usMixMode = nMixMode; + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_LINE, + LBB_MIX_MODE, + 0, + &lb ); + + // set mix mode for areas + AREABUNDLE ab; + ab.usMixMode = nMixMode; + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_AREA, + ABB_MIX_MODE, + 0, + &ab ); + + // set mix mode for text + CHARBUNDLE cb; + cb.usMixMode = nMixMode; + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_CHAR, + CBB_MIX_MODE, + 0, + &cb ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::SetROPLineColor( SalROPColor nROPColor ) +{ + SetLineColor( ImplGetROPSalColor( nROPColor ) ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::SetROPFillColor( SalROPColor nROPColor ) +{ + SetFillColor( ImplGetROPSalColor( nROPColor ) ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawPixel( long nX, long nY ) +{ + POINTL aPt; + + aPt.x = nX; + aPt.y = TY( nY ); + + // set color + GpiSetPel( maGraphicsData.mhPS, &aPt ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor ) +{ + // save old color + LINEBUNDLE oldLb; + GpiQueryAttrs( maGraphicsData.mhPS, + PRIM_LINE, + LBB_COLOR, + &oldLb ); + + // set new color + LINEBUNDLE lb; + lb.lColor = RGBCOLOR( SALCOLOR_RED( nSalColor ), + SALCOLOR_GREEN( nSalColor ), + SALCOLOR_BLUE( nSalColor ) ); + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_LINE, + LBB_COLOR, + 0, + &lb ); + + // set color of pixel + POINTL aPt; + aPt.x = nX; + aPt.y = TY( nY ); + GpiSetPel( maGraphicsData.mhPS, &aPt ); + + // restore old color + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_LINE, + LBB_COLOR, + 0, + &oldLb ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2 ) +{ + // OS2 zeichnet den Endpunkt mit + POINTL aPt; + aPt.x = nX1; + aPt.y = TY( nY1 ); + GpiMove( maGraphicsData.mhPS, &aPt ); + aPt.x = nX2; + aPt.y = TY( nY2 ); + GpiLine( maGraphicsData.mhPS, &aPt ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight ) +{ + POINTL aPt; + long lControl; + + if ( maGraphicsData.mbFill ) + { + if ( maGraphicsData.mbLine ) + lControl = DRO_OUTLINEFILL; + else + lControl = DRO_FILL; + } + else + { + if ( maGraphicsData.mbLine ) + lControl = DRO_OUTLINE; + else + return; + } + + aPt.x = nX; + aPt.y = TY( nY ); + GpiMove( maGraphicsData.mhPS, &aPt ); + aPt.x = nX + nWidth - 1; + aPt.y = TY( nY + nHeight - 1 ); + GpiBox( maGraphicsData.mhPS, lControl, &aPt, 0, 0 ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawPolyLine( ULONG nPoints, const SalPoint* pPtAry ) +{ + // convert all points to sys orientation + POINTL* pOS2PtAry = new POINTL[ nPoints ]; + POINTL* pTempOS2PtAry = pOS2PtAry; + const SalPoint* pTempPtAry = pPtAry; + ULONG nTempPoints = nPoints; + long nHeight = maGraphicsData.mnHeight - 1; + + while( nTempPoints-- ) + { + (*pTempOS2PtAry).x = (*pTempPtAry).mnX; + (*pTempOS2PtAry).y = nHeight - (*pTempPtAry).mnY; + pTempOS2PtAry++; + pTempPtAry++; + } + + GpiMove( maGraphicsData.mhPS, pOS2PtAry ); + GpiPolyLine( maGraphicsData.mhPS, nPoints, pOS2PtAry ); + delete [] pOS2PtAry; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawPolygon( ULONG nPoints, const SalPoint* pPtAry ) +{ + POLYGON aPolygon; + + // create polygon + aPolygon.aPointl = new POINTL[ nPoints ]; + aPolygon.ulPoints = nPoints; + + // convert all points to sys orientation + POINTL* pTempOS2PtAry = aPolygon.aPointl; + const SalPoint* pTempPtAry = pPtAry; + ULONG nTempPoints = nPoints; + long nHeight = maGraphicsData.mnHeight - 1; + + while( nTempPoints-- ) + { + (*pTempOS2PtAry).x = (*pTempPtAry).mnX; + (*pTempOS2PtAry).y = nHeight - (*pTempPtAry).mnY; + pTempOS2PtAry++; + pTempPtAry++; + } + + // Innenleben zeichnen + if ( maGraphicsData.mbFill ) + { +#ifdef SAL_PRINTER_POLYPATH + if ( maGraphicsData.mbPrinter ) + { + GpiBeginPath( maGraphicsData.mhPS, 1 ); + GpiMove( maGraphicsData.mhPS, aPolygon.aPointl ); + GpiPolyLine( maGraphicsData.mhPS, aPolygon.ulPoints, aPolygon.aPointl ); + GpiEndPath( maGraphicsData.mhPS ); + GpiFillPath( maGraphicsData.mhPS, 1, 0 ); + + if ( maGraphicsData.mbLine ) + { + GpiMove( maGraphicsData.mhPS, aPolygon.aPointl ); + GpiPolyLine( maGraphicsData.mhPS, aPolygon.ulPoints, aPolygon.aPointl ); + } + } + else +#endif + { + ULONG nOptions = POLYGON_ALTERNATE; + + if ( maGraphicsData.mbLine ) + nOptions |= POLYGON_BOUNDARY; + else + nOptions |= POLYGON_NOBOUNDARY; + + GpiMove( maGraphicsData.mhPS, aPolygon.aPointl ); + GpiPolygons( maGraphicsData.mhPS, 1, &aPolygon, nOptions, POLYGON_EXCL ); + } + } + else + { + if ( maGraphicsData.mbLine ) + { + GpiMove( maGraphicsData.mhPS, aPolygon.aPointl ); + GpiPolyLine( maGraphicsData.mhPS, nPoints, aPolygon.aPointl ); + } + } + + delete [] aPolygon.aPointl; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawPolyPolygon( ULONG nPoly, const ULONG* pPoints, + PCONSTSALPOINT* pPtAry ) +{ + ULONG i; + long nHeight = maGraphicsData.mnHeight - 1; + POLYGON* aPolygonAry = new POLYGON[ nPoly ]; + + for( i = 0; i < nPoly; i++ ) + { + const SalPoint * pTempPtAry = (const SalPoint*)pPtAry[ i ]; + + // create polygon + ULONG nTempPoints = pPoints[ i ]; + POINTL * pTempOS2PtAry = new POINTL[ nTempPoints ]; + + // convert all points to sys orientation + aPolygonAry[ i ].ulPoints = nTempPoints; + aPolygonAry[ i ].aPointl = pTempOS2PtAry; + + while( nTempPoints-- ) + { + (*pTempOS2PtAry).x = (*pTempPtAry).mnX; + (*pTempOS2PtAry).y = nHeight - (*pTempPtAry).mnY; + pTempOS2PtAry++; + pTempPtAry++; + } + } + + // Innenleben zeichnen + if ( maGraphicsData.mbFill ) + { +#ifdef SAL_PRINTER_POLYPATH + if ( maGraphicsData.mbPrinter ) + { + GpiBeginPath( maGraphicsData.mhPS, 1 ); + for ( i = 0; i < nPoly; i++ ) + { + GpiMove( maGraphicsData.mhPS, aPolygonAry[i].aPointl ); + GpiPolyLine( maGraphicsData.mhPS, aPolygonAry[i].ulPoints, aPolygonAry[i].aPointl ); + } + GpiEndPath( maGraphicsData.mhPS ); + GpiFillPath( maGraphicsData.mhPS, 1, 0 ); + } + else +#endif + { + ULONG nOptions = POLYGON_ALTERNATE; + + if ( maGraphicsData.mbLine ) + nOptions |= POLYGON_BOUNDARY; + else + nOptions |= POLYGON_NOBOUNDARY; + + GpiMove( maGraphicsData.mhPS, aPolygonAry[ 0 ].aPointl ); + GpiPolygons( maGraphicsData.mhPS, nPoly, aPolygonAry, nOptions, POLYGON_EXCL ); + } + } + else + { + if ( maGraphicsData.mbLine ) + { + for( i = 0; i < nPoly; i++ ) + { + GpiMove( maGraphicsData.mhPS, aPolygonAry[ i ].aPointl ); + GpiPolyLine( maGraphicsData.mhPS, aPolygonAry[ i ].ulPoints, aPolygonAry[ i ].aPointl ); + } + } + } + + // cleanup + for( i = 0; i < nPoly; i++ ) + delete [] aPolygonAry[ i ].aPointl; + delete [] aPolygonAry; +} + +// ======================================================================= + +// MAXIMUM BUFSIZE EQ 0xFFFF +#define POSTSCRIPT_BUFSIZE 0x1024 +// we only try to get the BoundingBox in the first 4096 bytes +#define POSTSCRIPT_BOUNDINGSEARCH 0x1000 + +static BYTE* ImplSearchEntry( BYTE* pSource, BYTE* pDest, ULONG nComp, ULONG nSize ) +{ + while ( nComp-- >= nSize ) + { + for ( ULONG i = 0; i < nSize; i++ ) + { + if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) ) + break; + } + if ( i == nSize ) + return pSource; + pSource++; + } + return NULL; +} + + +static BOOL ImplGetBoundingBox( double* nNumb, BYTE* pSource, ULONG nSize ) +{ + BOOL bRetValue = FALSE; + ULONG nBytesRead; + + if ( nSize < 256 ) // we assume that the file is greater than 256 bytes + return FALSE; + + if ( nSize < POSTSCRIPT_BOUNDINGSEARCH ) + nBytesRead = nSize; + else + nBytesRead = POSTSCRIPT_BOUNDINGSEARCH; + + BYTE* pDest = ImplSearchEntry( pSource, (BYTE*)"%%BoundingBox:", nBytesRead, 14 ); + if ( pDest ) + { + int nSecurityCount = 100; // only 100 bytes following the bounding box will be checked + nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0; + pDest += 14; + for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ ) + { + int nDivision = 1; + BOOL bDivision = FALSE; + BOOL bNegative = FALSE; + BOOL bValid = TRUE; + + while ( ( --nSecurityCount ) && ( *pDest == ' ' ) || ( *pDest == 0x9 ) ) pDest++; + BYTE nByte = *pDest; + while ( nSecurityCount && ( nByte != ' ' ) && ( nByte != 0x9 ) && ( nByte != 0xd ) && ( nByte != 0xa ) ) + { + switch ( nByte ) + { + case '.' : + if ( bDivision ) + bValid = FALSE; + else + bDivision = TRUE; + break; + case '-' : + bNegative = TRUE; + break; + default : + if ( ( nByte < '0' ) || ( nByte > '9' ) ) + nSecurityCount = 1; // error parsing the bounding box values + else if ( bValid ) + { + if ( bDivision ) + nDivision*=10; + nNumb[i] *= 10; + nNumb[i] += nByte - '0'; + } + break; + } + nSecurityCount--; + nByte = *(++pDest); + } + if ( bNegative ) + nNumb[i] = -nNumb[i]; + if ( bDivision && ( nDivision != 1 ) ) + nNumb[i] /= nDivision; + } + if ( nSecurityCount) + bRetValue = TRUE; + } + return bRetValue; +} + +static void ImplWriteDouble( BYTE** pBuf, double nNumber ) +{ +// *pBuf += sprintf( (char*)*pBuf, "%f", nNumber ); + + if ( nNumber < 0 ) + { + *(*pBuf)++ = (BYTE)'-'; + nNumber = -nNumber; + } + ULONG nTemp = (ULONG)nNumber; + const String aNumber1( nTemp ); + ULONG nLen = aNumber1.Len(); + + for ( USHORT n = 0; n < nLen; n++ ) + *(*pBuf)++ = aNumber1[ n ]; + + nTemp = (ULONG)( ( nNumber - nTemp ) * 100000 ); + if ( nTemp ) + { + *(*pBuf)++ = (BYTE)'.'; + const String aNumber2( nTemp ); + + ULONG nLen = aNumber2.Len(); + if ( nLen < 8 ) + { + for ( n = 0; n < ( 5 - nLen ); n++ ) + { + *(*pBuf)++ = (BYTE)'0'; + } + } + for ( USHORT n = 0; n < nLen; n++ ) + { + *(*pBuf)++ = aNumber2[ n ]; + } + } + *(*pBuf)++ = ' '; +} + +inline void ImplWriteString( BYTE** pBuf, const char* sString ) +{ + strcpy( (char*)*pBuf, sString ); + *pBuf += strlen( sString ); +} + +BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize ) +{ + if ( !maGraphicsData.mbPrinter ) + return FALSE; + + BOOL bRet = FALSE; + LONG nLong = 0; + if ( !(DevQueryCaps( maGraphicsData.mhDC, CAPS_TECHNOLOGY, 1, &nLong ) && + (CAPS_TECH_POSTSCRIPT == nLong)) ) + return FALSE; + + BYTE* pBuf = new BYTE[ POSTSCRIPT_BUFSIZE ]; + double nBoundingBox[4]; + + if ( pBuf && ImplGetBoundingBox( nBoundingBox, (BYTE*)pPtr, nSize ) ) + { + LONG pOS2DXAry[4]; // hack -> print always 2 white space + POINTL aPt; + aPt.x = 0; + aPt.y = 0; + PCH pStr = " "; + for( long i = 0; i < 4; i++ ) + pOS2DXAry[i] = i; + GpiCharStringPosAt( maGraphicsData.mhPS, &aPt, NULL, 0, 2, (PCH)pStr,(PLONG)&pOS2DXAry[0] ); + + double dM11 = nWidth / ( nBoundingBox[2] - nBoundingBox[0] ); + double dM22 = - ( nHeight / (nBoundingBox[1] - nBoundingBox[3] ) ); + + BYTE* pTemp = pBuf; + ImplWriteString( &pTemp, "save\n[ " ); + ImplWriteDouble( &pTemp, dM11 ); + ImplWriteDouble( &pTemp, 0 ); + ImplWriteDouble( &pTemp, 0 ); + ImplWriteDouble( &pTemp, dM22 ); + ImplWriteDouble( &pTemp, nX - ( dM11 * nBoundingBox[0] ) ); + ImplWriteDouble( &pTemp, maGraphicsData.mnHeight - nY - ( dM22 * nBoundingBox[3] ) ); + ImplWriteString( &pTemp, "] concat /showpage {} def\n" ); + + if ( DevEscape( maGraphicsData.mhDC, DEVESC_RAWDATA, pTemp - pBuf, + (PBYTE)pBuf, 0, NULL ) == DEV_OK ) + { + UINT32 nToDo = nSize; + UINT32 nDoNow; + bRet = TRUE; + while( nToDo && bRet ) + { + nDoNow = 0x4000; + if ( nToDo < nDoNow ) + nDoNow = nToDo; + + if ( DevEscape( maGraphicsData.mhDC, DEVESC_RAWDATA, nDoNow, (PBYTE)pPtr + nSize - nToDo, + 0, NULL ) == -1 ) + bRet = FALSE; + nToDo -= nDoNow; + } + + if ( bRet ) + { + strcpy ( (char*)pBuf, "\nrestore\n" ); + if ( DevEscape( maGraphicsData.mhDC, DEVESC_RAWDATA, 9, (PBYTE)pBuf, + 0, NULL ) == DEV_OK ) bRet = TRUE; + } + } + } + delete pBuf; + return bRet; +} + diff --git a/vcl/os2/source/gdi/salgdi2.cxx b/vcl/os2/source/gdi/salgdi2.cxx new file mode 100644 index 000000000000..ccc966d13aa3 --- /dev/null +++ b/vcl/os2/source/gdi/salgdi2.cxx @@ -0,0 +1,786 @@ +/************************************************************************* + * + * $RCSfile: salgdi2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#define _SV_SALGDI2_CXX + +#ifndef _SV_SALBMP_HXX +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALIDS_HRC +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALVD_HXX +#include +#endif +#ifndef _SV_SALBTYPE_HXX +#include +#endif + +BOOL bFastTransparent = FALSE; + +// ----------- +// - Defines - +// ----------- + +#define RGBCOLOR( r, g, b ) ((ULONG)(((BYTE)(b)|((USHORT)(g)<<8))|(((ULONG)(BYTE)(r))<<16))) +#define TY( y ) (maGraphicsData.mnHeight-(y)-1) + +// --------------- +// - SalGraphics - +// --------------- + +void SalGraphics::CopyBits( const SalTwoRect* pPosAry, SalGraphics* pSrcGraphics ) +{ + HPS hSrcPS; + POINTL thePoints[4]; + long nSrcHeight; + + if ( pSrcGraphics ) + { + hSrcPS = pSrcGraphics->maGraphicsData.mhPS; + nSrcHeight = pSrcGraphics->maGraphicsData.mnHeight; + } + else + { + hSrcPS = maGraphicsData.mhPS; + nSrcHeight = maGraphicsData.mnHeight; + } + + // lower-left corner of target + thePoints[0].x = pPosAry->mnDestX; + thePoints[0].y = TY( pPosAry->mnDestY + pPosAry->mnDestHeight - 1 ); + + // upper-right corner of target + thePoints[1].x = pPosAry->mnDestX + pPosAry->mnDestWidth; + thePoints[1].y = TY( pPosAry->mnDestY - 1 ); + + // lower-left corner of source + thePoints[2].x = pPosAry->mnSrcX; + thePoints[2].y = nSrcHeight - ( pPosAry->mnSrcY + pPosAry->mnSrcHeight ); + + if ( ( pPosAry->mnDestWidth != pPosAry->mnSrcWidth ) || ( pPosAry->mnDestHeight != pPosAry->mnSrcHeight ) ) + { + // upper-right corner of Source + thePoints[3].x = pPosAry->mnSrcX + pPosAry->mnSrcWidth; + thePoints[3].y = nSrcHeight - pPosAry->mnSrcY + pPosAry->mnSrcHeight; + + GpiBitBlt( maGraphicsData.mhPS, hSrcPS, 4, thePoints, + maGraphicsData.mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY, BBO_IGNORE ); + } + else + { + GpiBitBlt( maGraphicsData.mhPS, hSrcPS, 3, thePoints, + maGraphicsData.mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY, BBO_IGNORE ); + } +} + +// ----------------------------------------------------------------------- + +void SalGraphics::CopyArea( long nDestX, long nDestY, + long nSrcX, long nSrcY, + long nSrcWidth, long nSrcHeight, + USHORT nFlags ) +{ + POINTL thePoints[3]; + + // lower-left corner of target + thePoints[0].x = nDestX; + thePoints[0].y = TY( nDestY + nSrcHeight - 1 ); + + // upper-right corner of target + thePoints[1].x = nDestX + nSrcWidth; + thePoints[1].y = TY( nDestY - 1 ); + + // lower-left corner of source + thePoints[2].x = nSrcX; + thePoints[2].y = TY( nSrcY + nSrcHeight - 1); + + GpiBitBlt( maGraphicsData.mhPS, maGraphicsData.mhPS, 3, thePoints, + ROP_SRCCOPY, BBO_IGNORE ); + + if ( (nFlags & SAL_COPYAREA_WINDOWINVALIDATE) && maGraphicsData.mbWindow ) + { + // Overlap-Bereich berechnen und invalidieren + Point aVCLSrcPos( nSrcX, nSrcY ); + Size aVCLSrcSize( nSrcWidth, nSrcHeight ); + Rectangle aVCLSrcRect( aVCLSrcPos, aVCLSrcSize ); + Rectangle aVCLClipRect; + SWP aSWP; + + WinQueryWindowPos( maGraphicsData.mhWnd, &aSWP ); + aVCLClipRect.Right() = aSWP.cx-1; + aVCLClipRect.Bottom() = aSWP.cy-1; + if ( !aVCLSrcRect.Intersection( aVCLClipRect ).IsEmpty() ) + { + RECTL aSrcRect; + RECTL aTempRect; + HRGN hInvalidateRgn; + HRGN hTempRgn; + HWND hWnd; + long nRgnType; + + long nVCLScrHeight = aVCLSrcRect.GetHeight(); + aSrcRect.xLeft = aVCLSrcRect.Left(); + aSrcRect.yBottom = TY( aVCLSrcRect.Top()+nVCLScrHeight-1 ); + aSrcRect.xRight = aSrcRect.xLeft+aVCLSrcRect.GetWidth(); + aSrcRect.yTop = aSrcRect.yBottom+nVCLScrHeight; + + // Rechteck in Screen-Koordinaaten umrechnen + POINTL aPt; + long nScreenDX = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); + long nScreenDY = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); + aPt.x = 0; + aPt.y = 0; + WinMapWindowPoints( maGraphicsData.mhWnd, HWND_DESKTOP, &aPt, 1 ); + aSrcRect.xLeft += aPt.x; + aSrcRect.yTop += aPt.y; + aSrcRect.xRight += aPt.x; + aSrcRect.yBottom += aPt.y; + hInvalidateRgn = 0; + // Bereiche ausserhalb des sichtbaren Bereiches berechnen + if ( aSrcRect.xLeft < 0 ) + { + if ( !hInvalidateRgn ) + hInvalidateRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aSrcRect ); + aTempRect.xLeft = -31999; + aTempRect.yBottom = 0; + aTempRect.xRight = 0; + aTempRect.yTop = 31999; + hTempRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aTempRect ); + GpiCombineRegion( maGraphicsData.mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); + GpiDestroyRegion( maGraphicsData.mhPS, hTempRgn ); + } + if ( aSrcRect.yBottom < 0 ) + { + if ( !hInvalidateRgn ) + hInvalidateRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aSrcRect ); + aTempRect.xLeft = 0; + aTempRect.yBottom = -31999; + aTempRect.xRight = 31999; + aTempRect.yTop = 0; + hTempRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aTempRect ); + GpiCombineRegion( maGraphicsData.mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); + GpiDestroyRegion( maGraphicsData.mhPS, hTempRgn ); + } + if ( aSrcRect.xRight > nScreenDX ) + { + if ( !hInvalidateRgn ) + hInvalidateRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aSrcRect ); + aTempRect.xLeft = nScreenDX; + aTempRect.yBottom = 0; + aTempRect.xRight = 31999; + aTempRect.yTop = 31999; + hTempRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aTempRect ); + GpiCombineRegion( maGraphicsData.mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); + GpiDestroyRegion( maGraphicsData.mhPS, hTempRgn ); + } + if ( aSrcRect.yTop > nScreenDY ) + { + if ( !hInvalidateRgn ) + hInvalidateRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aSrcRect ); + aTempRect.xLeft = 0; + aTempRect.yBottom = nScreenDY; + aTempRect.xRight = 31999; + aTempRect.yTop = 31999; + hTempRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aTempRect ); + GpiCombineRegion( maGraphicsData.mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); + GpiDestroyRegion( maGraphicsData.mhPS, hTempRgn ); + } + + // Bereiche die von anderen Fenstern ueberlagert werden berechnen + HWND hWndParent = WinQueryWindow( maGraphicsData.mhWnd, QW_PARENT ); + hWnd = WinQueryWindow( HWND_DESKTOP, QW_TOP ); + aVCLSrcRect = Rectangle( aSrcRect.xLeft, aSrcRect.yBottom, aSrcRect.xRight, aSrcRect.yTop ); + while ( hWnd ) + { + if ( hWnd == hWndParent ) + break; + if ( WinIsWindowVisible( hWnd ) ) + { + WinQueryWindowPos( hWnd, &aSWP ); + if ( !(aSWP.fl & SWP_MINIMIZE) ) + { + aVCLClipRect = Rectangle( Point( aSWP.x, aSWP.y ), Size( aSWP.cx, aSWP.cy ) ); + if ( aVCLSrcRect.IsOver( aVCLClipRect ) ) + { + if ( !hInvalidateRgn ) + hInvalidateRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aSrcRect ); + aTempRect.xLeft = aSWP.x; + aTempRect.yBottom = aSWP.y; + aTempRect.xRight = aTempRect.xLeft+aSWP.cx; + aTempRect.yTop = aTempRect.yBottom+aSWP.cy; + hTempRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aTempRect ); + GpiCombineRegion( maGraphicsData.mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); + GpiDestroyRegion( maGraphicsData.mhPS, hTempRgn ); + } + } + } + hWnd = WinQueryWindow( hWnd, QW_NEXT ); + } + + if ( hInvalidateRgn ) + { + hTempRgn = GpiCreateRegion( maGraphicsData.mhPS, 1, &aSrcRect ); + nRgnType = GpiCombineRegion( maGraphicsData.mhPS, hInvalidateRgn, hTempRgn, hInvalidateRgn, CRGN_DIFF ); + GpiDestroyRegion( maGraphicsData.mhPS, hTempRgn ); + if ( (nRgnType != RGN_ERROR) && (nRgnType != RGN_NULL) ) + { + long nOffX = (nDestX-nSrcX); + long nOffY = (nSrcY-nDestY); + aPt.x = nOffX-aPt.x; + aPt.y = nOffY-aPt.y; + GpiOffsetRegion( maGraphicsData.mhPS, hInvalidateRgn, &aPt ); + WinInvalidateRegion( maGraphicsData.mhWnd, hInvalidateRgn, TRUE ); + // Hier loesen wir nur ein Update aus, wenn es der + // MainThread ist, damit es beim Bearbeiten der + // Paint-Message keinen Deadlock gibt, da der + // SolarMutex durch diesen Thread schon gelockt ist + SalData* pSalData = GetSalData(); + ULONG nCurThreadId = ImplSalGetCurrentThreadId(); + if ( pSalData->mnAppThreadId != nCurThreadId ) + WinUpdateWindow( maGraphicsData.mhWnd ); + } + GpiDestroyRegion( maGraphicsData.mhPS, hInvalidateRgn ); + } + } + } +} + +// ----------------------------------------------------------------------- + +void ImplDrawBitmap( HPS hPS, long nScreenHeight, + const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap, + BOOL bPrinter, int nDrawMode ) +{ + if( hPS ) + { + HANDLE hDrawDIB; + HBITMAP hDrawDDB = rSalBitmap.ImplGethDDB(); + SalBitmap* pTmpSalBmp = NULL; + BOOL bPrintDDB = ( bPrinter && hDrawDDB ); + BOOL bDrawDDB1 = ( ( rSalBitmap.GetBitCount() == 1 ) && hDrawDDB ); + + if( bPrintDDB || bDrawDDB1 ) + { + pTmpSalBmp = new SalBitmap; + pTmpSalBmp->Create( rSalBitmap, rSalBitmap.GetBitCount() ); + hDrawDIB = pTmpSalBmp->ImplGethDIB(); + } + else + hDrawDIB = rSalBitmap.ImplGethDIB(); + + if( hDrawDIB ) + { + HANDLE hSubst = rSalBitmap.ImplGethDIB1Subst(); + POINTL pts[ 4 ]; + BITMAPINFO2* pBI = (BITMAPINFO2*) hDrawDIB; + BITMAPINFOHEADER2* pBIH = (BITMAPINFOHEADER2*) pBI; + const long nHeight = pBIH->cy; + long nInfoSize = *(ULONG*) pBI + rSalBitmap.ImplGetDIBColorCount( hDrawDIB ) * sizeof( RGB2 ); + BYTE* pBits = (BYTE*) pBI + nInfoSize; + + pts[0].x = pPosAry->mnDestX; + pts[0].y = nScreenHeight - pPosAry->mnDestY - pPosAry->mnDestHeight; + pts[1].x = pPosAry->mnDestX + pPosAry->mnDestWidth - 1; + pts[1].y = nScreenHeight - pPosAry->mnDestY - 1; + + pts[2].x = pPosAry->mnSrcX; + pts[2].y = nHeight - ( pPosAry->mnSrcY + pPosAry->mnSrcHeight ); + pts[3].x = pPosAry->mnSrcX + pPosAry->mnSrcWidth; + pts[3].y = nHeight - pPosAry->mnSrcY; + + // if we've got a 1Bit DIB, we create a 4Bit substitute + if( ( pBIH->cBitCount == 1 ) && !hSubst ) + { + // create 4Bit substitute + hSubst = SalBitmap::ImplCreateDIB4FromDIB1( hDrawDIB ); + + // replace substitute only, if it is no temporary SalBitmap + if( !( bPrintDDB || bDrawDDB1 ) ) + ( (SalBitmap&) rSalBitmap ).ImplReplacehDIB1Subst( hSubst ); + } + + if( hSubst ) + { + pBI = (BITMAPINFO2*) hSubst; + pBIH = (BITMAPINFOHEADER2*) pBI; + nInfoSize = *(ULONG*) pBI + rSalBitmap.ImplGetDIBColorCount( hSubst ) * sizeof( RGB2 ); + pBits = (BYTE*) pBI + nInfoSize; + } + + if( bPrinter ) + { + BYTE* pDummy; + + // expand 8Bit-DIB's to 24Bit-DIB's, because some printer drivers + // have problems to print these DIB's (strange) + if( pBIH->cBitCount == 8 && pBIH->ulCompression == BCA_UNCOMP ) + { + const long nWidth = pBIH->cx; + const long nHeight = pBIH->cy; + const long nWidthAl8 = AlignedWidth4Bytes( nWidth * 8 ); + const long nWidthAl24 = AlignedWidth4Bytes( nWidth * 24 ); + const long nNewImageSize = nHeight * nWidthAl24; + BITMAPINFOHEADER2* pNewInfo; + + pDummy = new BYTE[ sizeof( BITMAPINFO2 ) + nNewImageSize ]; + memset( pDummy, 0, sizeof( BITMAPINFO2 ) ); + + pNewInfo = (BITMAPINFOHEADER2*) pDummy; + pNewInfo->cbFix = sizeof( BITMAPINFOHEADER2 ); + pNewInfo->cx = nWidth; + pNewInfo->cy = nHeight; + pNewInfo->cPlanes = 1; + pNewInfo->cBitCount = 24; + pNewInfo->ulCompression = BCA_UNCOMP; + pNewInfo->cbImage = nNewImageSize; + + BYTE* pBitsSrc = (BYTE*) pBIH + nInfoSize; + BYTE* pBitsDst = pDummy + sizeof( BITMAPINFO2 ); + + for( long nY = 0UL; nY < nHeight; nY++ ) + { + BYTE* pSrcLine = pBitsSrc + nY * nWidthAl8; + BYTE* pDstLine = pBitsDst + nY * nWidthAl24; + + for( long nX = 0UL; nX < nWidth; nX++ ) + { + const RGB2& rQuad = pBI->argbColor[ *pSrcLine++ ]; + + *pDstLine++ = rQuad.bBlue; + *pDstLine++ = rQuad.bGreen; + *pDstLine++ = rQuad.bRed; + } + } + + nInfoSize = sizeof( BITMAPINFO2 ); + } + else + { + const long nImageSize = ( pBIH->cbImage ? pBIH->cbImage : ( pBIH->cy * AlignedWidth4Bytes( pBIH->cx * pBIH->cBitCount ) ) ); + const long nTotalSize = nInfoSize + nImageSize; + + pDummy = new BYTE[ nTotalSize ]; + memcpy( pDummy, pBI, nTotalSize ); + } + + GpiDrawBits( hPS, pDummy + nInfoSize, (BITMAPINFO2*) pDummy, 4L, pts, nDrawMode, BBO_IGNORE ); + delete[] pDummy; + } + else + GpiDrawBits( hPS, pBits, pBI, 4L, pts, nDrawMode, BBO_IGNORE ); + } + else if( hDrawDDB && !bPrintDDB ) + { + POINTL pts[ 4 ]; + + pts[0].x = pPosAry->mnDestX; + pts[0].y = nScreenHeight - pPosAry->mnDestY - pPosAry->mnDestHeight; + pts[1].x = pPosAry->mnDestX + pPosAry->mnDestWidth - 1; + pts[1].y = nScreenHeight - pPosAry->mnDestY - 1; + + pts[2].x = pPosAry->mnSrcX; + pts[2].y = rSalBitmap.GetSize().Height() - ( pPosAry->mnSrcY + pPosAry->mnSrcHeight ); + pts[3].x = pPosAry->mnSrcX + pPosAry->mnSrcWidth; + pts[3].y = rSalBitmap.GetSize().Height() - pPosAry->mnSrcY; + + GpiWCBitBlt( hPS, hDrawDDB, 4L, pts, nDrawMode, BBO_IGNORE ); +/* + HPS hDrawPS = ImplGetCachedPS( CACHED_HPS_DRAW, hDrawDDB ); + GpiBitBlt( hPS, hDrawPS, 4, pts, nDrawMode, BBO_IGNORE ); + ImplReleaseCachedPS( CACHED_HPS_DRAW ); +*/ + } + + if( bPrintDDB || bDrawDDB1 ) + delete pTmpSalBmp; + } +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap ) +{ + ImplDrawBitmap( maGraphicsData.mhPS, maGraphicsData.mnHeight, + pPosAry, rSalBitmap, + maGraphicsData.mbPrinter, + maGraphicsData.mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nTransparentColor ) +{ + // an FM: kann erst einmal unberuecksichtigt bleiben + DrawBitmap( pPosAry, rSalBitmap ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + const SalBitmap& rTransparentBitmap ) +{ + if( bFastTransparent ) + { + ImplDrawBitmap( maGraphicsData.mhPS, maGraphicsData.mnHeight, pPosAry, rTransparentBitmap, FALSE, ROP_SRCAND ); + ImplDrawBitmap( maGraphicsData.mhPS, maGraphicsData.mnHeight, pPosAry, rSalBitmap, FALSE, ROP_SRCPAINT ); + } + else + { + SalTwoRect aPosAry = *pPosAry; + int nDstX = (int) aPosAry.mnDestX; + int nDstY = (int) aPosAry.mnDestY; + int nDstWidth = (int) aPosAry.mnDestWidth; + int nDstHeight = (int) aPosAry.mnDestHeight; + HAB hAB = GetSalData()->mhAB; + HPS hPS = maGraphicsData.mhPS; + DEVOPENSTRUC aDevOpenStruc = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + SIZEL aSizeL = { nDstWidth, nDstHeight }; + POINTL aPtL[ 3 ]; + + HDC hMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 ); + HPS hMemPS = GpiCreatePS( hAB, hMemDC, &aSizeL, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); + HBITMAP hMemBitmap = ImplCreateVirDevBitmap( hMemDC, hMemPS, nDstWidth, nDstHeight, 0 ); + HBITMAP hMemOld = (HBITMAP) GpiSetBitmap( hMemPS, hMemBitmap ); + HDC hMaskDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 ); + HPS hMaskPS = GpiCreatePS( hAB, hMaskDC, &aSizeL, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); + HBITMAP hMaskBitmap = ImplCreateVirDevBitmap( hMaskDC, hMaskPS, nDstWidth, nDstHeight, 0 ); + HBITMAP hMaskOld = (HBITMAP) GpiSetBitmap( hMaskPS, hMaskBitmap ); +/* + HPS hMemPS = ImplGetCachedPS( CACHED_HPS_1, 0 ); + HPS hMaskPS = ImplGetCachedPS( CACHED_HPS_2, 0 ); +*/ + aPosAry.mnDestX = aPosAry.mnDestY = 0L; + + aPtL[ 0 ].x = 0; + aPtL[ 0 ].y = 0; + aPtL[ 1 ].x = nDstWidth; + aPtL[ 1 ].y = nDstHeight; + aPtL[ 2 ].x = nDstX; + aPtL[ 2 ].y = TY( nDstY + nDstHeight - 1 ); + + GpiBitBlt( hMemPS, hPS, 3, aPtL, ROP_SRCCOPY, BBO_IGNORE ); + ImplDrawBitmap( hMaskPS, nDstHeight, &aPosAry, rTransparentBitmap, FALSE, ROP_SRCCOPY ); + + aPtL[ 2 ].x = 0; + aPtL[ 2 ].y = 0; + + GpiBitBlt( hMemPS, hMaskPS, 3, aPtL, ROP_SRCAND, BBO_IGNORE ); + ImplDrawBitmap( hMaskPS, nDstHeight, &aPosAry, rSalBitmap, FALSE, ROP_SRCERASE ); + GpiBitBlt( hMemPS, hMaskPS, 3, aPtL, ROP_SRCPAINT, BBO_IGNORE ); + + aPtL[ 0 ].x = nDstX; + aPtL[ 0 ].y = TY( nDstY + nDstHeight - 1 ); + aPtL[ 1 ].x = nDstX + nDstWidth; + aPtL[ 1 ].y = TY( nDstY - 1 ); + + GpiBitBlt( hPS, hMemPS, 3, aPtL, ROP_SRCCOPY, BBO_IGNORE ); + + GpiSetBitmap( hMaskPS, hMaskOld ); + GpiDestroyPS( hMaskPS ); + DevCloseDC( hMaskDC ); + GpiDeleteBitmap( hMaskBitmap ); + + GpiSetBitmap( hMemPS, hMemOld ); + GpiDestroyPS( hMemPS ); + DevCloseDC( hMemDC ); + GpiDeleteBitmap( hMemBitmap ); + +/* + ImplReleaseCachedPS( CACHED_HPS_1 ); + ImplReleaseCachedPS( CACHED_HPS_2 ); +*/ + } +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawMask( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nMaskColor ) +{ + SalTwoRect aPosAry = *pPosAry; + HPS hPS = maGraphicsData.mhPS; + IMAGEBUNDLE aBundle, aOldBundle; + AREABUNDLE aAreaBundle, aOldAreaBundle; + const ULONG nColor = RGBCOLOR( SALCOLOR_RED( nMaskColor ), + SALCOLOR_GREEN( nMaskColor ), + SALCOLOR_BLUE( nMaskColor ) ); + + GpiQueryAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, &aOldBundle ); + aBundle.lColor = RGBCOLOR( 0, 0, 0 ); + aBundle.lBackColor = RGBCOLOR( 0xFF, 0xFF, 0xFF ); + GpiSetAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, 0, &aBundle ); + + GpiQueryAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL | + ABB_MIX_MODE | ABB_BACK_MIX_MODE, &aOldAreaBundle ); + aAreaBundle.lColor = nColor; + aAreaBundle.lBackColor = nColor; + aAreaBundle.usSymbol = PATSYM_SOLID; + aAreaBundle.usMixMode = FM_OVERPAINT; + aAreaBundle.usBackMixMode = BM_OVERPAINT; + GpiSetAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL | + ABB_MIX_MODE | ABB_BACK_MIX_MODE, 0, &aAreaBundle ); + + ImplDrawBitmap( hPS, maGraphicsData.mnHeight, &aPosAry, rSalBitmap, FALSE, 0x00B8L ); + + GpiSetAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, 0, &aOldBundle ); + GpiSetAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL | + ABB_MIX_MODE | ABB_BACK_MIX_MODE, 0, &aOldAreaBundle ); +} + +// ----------------------------------------------------------------------- + +SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nDX, long nDY ) +{ + HAB hAB = GetSalData()->mhAB; + SIZEL size = { nDX, nDY }; + SalBitmap* pSalBitmap = NULL; + + // create device context (at this time allways display compatible) + DEVOPENSTRUC aDevOpenStruc = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + HDC hMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 ); + HPS hMemPS = GpiCreatePS( hAB, hMemDC, &size, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); + HBITMAP hMemBmp = ImplCreateVirDevBitmap( hMemDC, hMemPS, nDX, nDY, 0 ); + HBITMAP hMemOld = GpiSetBitmap( hMemPS, hMemBmp ); + + // creation successfull? + if( hMemDC && hMemPS && hMemBmp ) + { + POINTL thePoints[ 3 ]; + + // lower-left corner of target + thePoints[ 0 ].x = 0; + thePoints[ 0 ].y = 0; + + // upper-right corner of target + thePoints[ 1 ].x = nDX; + thePoints[ 1 ].y = nDY; + + // lower-left corner of source + thePoints[ 2 ].x = nX; + thePoints[ 2 ].y = TY( nY + nDY - 1 ); + + long lHits = GpiBitBlt( hMemPS, maGraphicsData.mhPS, 3, thePoints, + maGraphicsData.mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY, BBO_IGNORE ); + + if( hMemPS ) + { + GpiSetBitmap( hMemPS, hMemOld ); + GpiDestroyPS( hMemPS ); + } + + if( hMemDC ) + DevCloseDC( hMemDC ); + + if( lHits == GPI_OK ) + { + pSalBitmap = new SalBitmap; + + if( !pSalBitmap->Create( hMemBmp, FALSE, FALSE ) ) + { + delete pSalBitmap; + pSalBitmap = NULL; + } + } + } + + if( !pSalBitmap ) + GpiDeleteBitmap( hMemBmp ); + + // return pointer to SAL-Bitmap + return pSalBitmap; +} + +// ----------------------------------------------------------------------- + +SalColor SalGraphics::GetPixel( long nX, long nY ) +{ + POINTL aPt = { nX, TY( nY ) }; + LONG nColor = GpiQueryPel( maGraphicsData.mhPS, &aPt ); + + return MAKE_SALCOLOR( (BYTE) ( nColor >> 16 ), (BYTE) ( nColor >> 8 ), (BYTE) nColor ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) +{ + if( nFlags & SAL_INVERT_TRACKFRAME ) + { + // save old vylues + LINEBUNDLE oldLb; + LINEBUNDLE lb; + GpiQueryAttrs( maGraphicsData.mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, &oldLb ); + + // set linetype to short dash + lb.lColor = RGBCOLOR( 255, 255, 255 ); + lb.usMixMode = FM_XOR; + lb.usType = LINETYPE_ALTERNATE; + GpiSetAttrs( maGraphicsData.mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &lb ); + + // draw inverted box + POINTL aPt; + + aPt.x = nX; + aPt.y = TY( nY ); + + GpiMove( maGraphicsData.mhPS, &aPt ); + + aPt.x = nX + nWidth - 1; + aPt.y = TY( nY + nHeight - 1 ); + + GpiBox( maGraphicsData.mhPS, DRO_OUTLINE, &aPt, 0, 0 ); + + // restore old values + GpiSetAttrs( maGraphicsData.mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &oldLb ); + + } + else + { + // save old values + AREABUNDLE oldAb; + AREABUNDLE ab; + + GpiQueryAttrs( maGraphicsData.mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, &oldAb ); + + // set fill color to black + ab.lColor = RGBCOLOR( 255, 255, 255 ); + ab.usMixMode = FM_XOR; + ab.usSymbol = (nFlags & SAL_INVERT_50) ? PATSYM_DENSE5 : PATSYM_SOLID; + GpiSetAttrs( maGraphicsData.mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &ab ); + + // draw inverted box + POINTL aPt; + + aPt.x = nX; + aPt.y = TY( nY ); + + GpiMove( maGraphicsData.mhPS, &aPt ); + + aPt.x = nX + nWidth - 1; + aPt.y = TY( nY + nHeight - 1 ); + + GpiBox( maGraphicsData.mhPS, DRO_FILL, &aPt, 0, 0 ); + + // restore old values + GpiSetAttrs( maGraphicsData.mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &oldAb ); + } +} + +// ----------------------------------------------------------------------- + +void SalGraphics::Invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nFlags ) +{ + if( nFlags & SAL_INVERT_TRACKFRAME ) + { + // save old vylues + LINEBUNDLE oldLb; + LINEBUNDLE lb; + GpiQueryAttrs( maGraphicsData.mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, &oldLb ); + + // set linetype to short dash + lb.lColor = RGBCOLOR( 255, 255, 255 ); + lb.usMixMode = FM_XOR; + lb.usType = LINETYPE_ALTERNATE; + GpiSetAttrs( maGraphicsData.mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &lb ); + + // Draw Polyline + DrawPolyLine( nPoints, pPtAry ); + + // restore old values + GpiSetAttrs( maGraphicsData.mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &oldLb ); + } + else + { + // save old values + AREABUNDLE oldAb; + AREABUNDLE ab; + + GpiQueryAttrs( maGraphicsData.mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, &oldAb ); + + // set fill color to black + ab.lColor = RGBCOLOR( 255, 255, 255 ); + ab.usMixMode = FM_XOR; + ab.usSymbol = (nFlags & SAL_INVERT_50) ? PATSYM_DENSE5 : PATSYM_SOLID; + GpiSetAttrs( maGraphicsData.mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &ab ); + + // Draw Polyline + DrawPolygon( nPoints, pPtAry ); + + // restore old values + GpiSetAttrs( maGraphicsData.mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &oldAb ); + } +} + diff --git a/vcl/os2/source/gdi/salgdi3.cxx b/vcl/os2/source/gdi/salgdi3.cxx new file mode 100644 index 000000000000..0876f5c4f606 --- /dev/null +++ b/vcl/os2/source/gdi/salgdi3.cxx @@ -0,0 +1,780 @@ +/************************************************************************* + * + * $RCSfile: salgdi3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#define INCL_GRE_STRINGS + +#include +#include +#include +#include + +#define _SV_SALGDI3_CXX + +#ifndef _DEBUG_HXX +#include +#endif + +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_OUTFONT_HXX +#include +#endif + +// ----------- +// - Defines - +// ----------- + +#define SAL_DRAWTEXT_STACKBUF 128 + +#define FONTTAB_FACTOR_PRINTER 18 +#define FONTTAB_FACTOR_DISPLAY 9 +static unsigned char aFontCharTab32[32] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 +}; + +// ======================================================================= + +static PM_USHORT ImplSalToCharSet( CharSet eCharSet ) +{ + // !!! Fuer DBCS-Systeme muss dieser Code auskommentiert werden und 0 + // !!! zurueckgegeben werden, solange die DBCS-Charsets nicht + // !!! durchgereicht werden + + switch ( eCharSet ) + { + case CHARSET_IBMPC_437: + return 437; + + case CHARSET_IBMPC_850: + return 850; + + case CHARSET_IBMPC_860: + return 860; + + case CHARSET_IBMPC_861: + return 861; + + case CHARSET_IBMPC_863: + return 863; + + case CHARSET_IBMPC_865: + return 865; + + case CHARSET_ANSI: + return 1004; + + case CHARSET_SYMBOL: + return 65400; + } + + return 0; +} + +// ----------------------------------------------------------------------- + +static CharSet ImplCharSetToSal( PM_USHORT usCodePage ) +{ + switch ( usCodePage ) + { + case 437: + return CHARSET_IBMPC_437; + + case 850: + return CHARSET_IBMPC_850; + + case 860: + return CHARSET_IBMPC_860; + + case 861: + return CHARSET_IBMPC_861; + + case 863: + return CHARSET_IBMPC_863; + + case 865: + return CHARSET_IBMPC_865; + + case 1004: + return CHARSET_ANSI; + + case 65400: + return CHARSET_SYMBOL; + + } + + return CHARSET_DONTKNOW; +} + +// ----------------------------------------------------------------------- + +static FontWeight ImplWeightToSal( PM_USHORT nWeight ) +{ + // Falls sich jemand an die alte Doku gehalten hat + if ( nWeight > 999 ) + nWeight /= 1000; + + switch ( nWeight ) + { + case 1: + return WEIGHT_THIN; + + case 2: + return WEIGHT_ULTRALIGHT; + + case 3: + return WEIGHT_LIGHT; + + case 4: + return WEIGHT_SEMILIGHT; + + case 5: + return WEIGHT_NORMAL; + + case 6: + return WEIGHT_SEMIBOLD; + + case 7: + return WEIGHT_BOLD; + + case 8: + return WEIGHT_ULTRABOLD; + + case 9: + return WEIGHT_BLACK; + } + + return WEIGHT_DONTKNOW; +} + +// ----------------------------------------------------------------------- + +static XubString ImpStyleNameToSal( const xub_Unicode* pFamilyName, + const xub_Unicode* pFaceName, + USHORT nLen ) +{ + if ( !nLen ) + nLen = WSstrlen( pFamilyName ); + + // FamilyName gegebenenfalls abschneiden + if ( WSstrncmp( pFamilyName, pFaceName, nLen ) == 0 ) + { + USHORT nFaceLen = (USHORT)WSstrlen( pFaceName+nLen ); + // Ist Facename laenger, schneiden wir den FamilyName ab + if ( nFaceLen > 1 ) + return XubString( pFaceName+(nLen+1), nFaceLen-1 ); + else + return XubString(); + } + else + return XubString( pFaceName ); +} + +// ======================================================================= + +void SalGraphics::SetTextColor( SalColor nSalColor ) +{ + CHARBUNDLE cb; + + cb.lColor = RGBCOLOR( SALCOLOR_RED( nSalColor ), + SALCOLOR_GREEN( nSalColor ), + SALCOLOR_BLUE( nSalColor ) ); + + // set default color attributes + GpiSetAttrs( maGraphicsData.mhPS, + PRIM_CHAR, + CBB_COLOR, + 0, + &cb ); +} + +// ----------------------------------------------------------------------- + +USHORT SalGraphics::SetFont( ImplFontSelectData* pFont ) +{ + ImplFontData* pFontData = pFont->mpFontData; + FATTRS aFAttrs; + BOOL bOutline; + + memset( &aFAttrs, 0, sizeof( FATTRS ) ); + aFAttrs.usRecordLength = sizeof( FATTRS ); + + aFAttrs.usCodePage = ImplSalToCharSet( pFont->meCharSet ); + aFAttrs.lMaxBaselineExt = pFont->mnHeight; + aFAttrs.lAveCharWidth = pFont->mnWidth; + + // do we have a pointer to the FONTMETRICS of the selected font? -> use it! + if ( pFontData ) + { + PFONTMETRICS pFontMetric = (PFONTMETRICS)pFontData->mpSysData; + strcpy( (char*)(aFAttrs.szFacename), pFontMetric->szFacename ); + aFAttrs.lMatch = pFontMetric->lMatch; + aFAttrs.idRegistry = pFontMetric->idRegistry; + + bOutline = (pFontMetric->fsDefn & FM_DEFN_OUTLINE) != 0; + maGraphicsData.mbFontIsFixed = (pFontMetric->fsType & FM_TYPE_FIXED) != 0; + + if ( bOutline ) + { + aFAttrs.fsFontUse |= FATTR_FONTUSE_OUTLINE; + if ( pFont->mnOrientation ) + aFAttrs.fsFontUse |= FATTR_FONTUSE_TRANSFORMABLE; + } + else + { + aFAttrs.lMaxBaselineExt = pFontData->mnHeight; + aFAttrs.lAveCharWidth = pFontData->mnWidth; + } + + if ( (pFont->mpFontData->meItalic == ITALIC_NONE) && (pFont->meItalic != ITALIC_NONE) ) + aFAttrs.fsSelection |= FATTR_SEL_ITALIC; + if ( ((short)pFont->meWeight - (short)pFont->mpFontData->meWeight >= 2) ) + aFAttrs.fsSelection |= FATTR_SEL_BOLD; + } + else + { + String aName = pFont->maName.GetToken( 0 ); + strncpy( (char*)(aFAttrs.szFacename), aName, sizeof( aFAttrs.szFacename ) ); + + bOutline = FALSE; + maGraphicsData.mbFontIsFixed = FALSE; + + if ( pFont->meItalic != ITALIC_NONE ) + aFAttrs.fsSelection |= FATTR_SEL_ITALIC; + if ( pFont->meWeight > WEIGHT_MEDIUM ) + aFAttrs.fsSelection |= FATTR_SEL_BOLD; + } + + if ( GpiCreateLogFont( maGraphicsData.mhPS, NULL, 10, &aFAttrs ) == GPI_ERROR ) + return SAL_SETFONT_REMOVEANDMATCHNEW; + + CHARBUNDLE aBundle; + + PM_ULONG nAttrsDefault = 0; + PM_ULONG nAttrs = CBB_SET; + aBundle.usSet = 10; + + nAttrs |= CBB_BOX; + if ( bOutline ) + { + aBundle.sizfxCell.cy = MAKEFIXED( pFont->mnHeight, 0 ); + + if ( !pFont->mnWidth ) + { + LONG nXFontRes; + LONG nYFontRes; + LONG nHeight; + + // Auf die Aufloesung achten, damit das Ergebnis auch auf + // Drucken mit 180*360 DPI stimmt. Ausserdem muss gerundet + // werden, da auf meinem OS2 beispielsweise als + // Bildschirmaufloesung 3618*3622 PixelPerMeter zurueck- + // gegeben wird + DevQueryCaps( maGraphicsData.mhDC, CAPS_HORIZONTAL_RESOLUTION, 1, &nXFontRes ); + DevQueryCaps( maGraphicsData.mhDC, CAPS_VERTICAL_RESOLUTION, 1, &nYFontRes ); + nHeight = pFont->mnHeight; + nHeight *= nXFontRes; + nHeight += nYFontRes/2; + nHeight /= nYFontRes; + aBundle.sizfxCell.cx = MAKEFIXED( nHeight, 0 ); + } + else + aBundle.sizfxCell.cx = MAKEFIXED( pFont->mnWidth, 0 ); + } + else + nAttrsDefault |= CBB_BOX; + + // set orientation for outlinefonts + nAttrs |= CBB_ANGLE; + if ( pFont->mnOrientation ) + { + if ( bOutline ) + { + double alpha = (double)(pFont->mnOrientation); + alpha *= 0.0017453292; // *PI / 1800 + maGraphicsData.mnOrientationY = (long) (1000.0 * sin( alpha )); + maGraphicsData.mnOrientationX = (long) (1000.0 * cos( alpha )); + aBundle.ptlAngle.x = maGraphicsData.mnOrientationX; + aBundle.ptlAngle.y = maGraphicsData.mnOrientationY; + } + else + { + nAttrsDefault |= CBB_ANGLE; + maGraphicsData.mnOrientationX = 1; + maGraphicsData.mnOrientationY = 0; + } + } + else + { + nAttrsDefault |= CBB_ANGLE; + maGraphicsData.mnOrientationX = 1; + maGraphicsData.mnOrientationY = 0; + } + + GpiSetAttrs( maGraphicsData.mhPS, PRIM_CHAR, + nAttrs, + nAttrsDefault, + &aBundle ); + + // save info about font + maGraphicsData.mbFontIsOutline = bOutline; + + return SAL_SETFONT_USEDRAWTEXTARRAY; +} + +// ----------------------------------------------------------------------- + +long SalGraphics::GetCharWidth( USHORT nChar1, USHORT nChar2, long* pWidthAry ) +{ + POINTL aNullPt = { 0, 0 }; + POINTL aFontCharPtBuf[33]; + unsigned char aFontCharTabBuf[FONTTAB_FACTOR_PRINTER]; + long nFontTabFactor = maGraphicsData.mbPrinter + ? FONTTAB_FACTOR_PRINTER + : FONTTAB_FACTOR_DISPLAY; + + // Orientation? -> rotate to 0 degree! + if ( (maGraphicsData.mnOrientationY != 0) && (maGraphicsData.mnOrientationX != 1) ) + { + CHARBUNDLE aBundle; + aBundle.ptlAngle.x = 1; + aBundle.ptlAngle.y = 0; + GpiSetAttrs( maGraphicsData.mhPS, PRIM_CHAR, CBB_ANGLE, 0, &aBundle ); + } + + // Fixed-Font und Fontbreitentabelle bestimmen + // Wir benutzen GpiQueryCharStringPos() (und nicht GpiQueryWidthTable()) + // um die Genauigkeit zu erhoehen. In dem String stehen bis auf die + // ersten 32-Zeichen FONTATB_FACTOR* in der Tabelle um die Genauigkeit + // um den Faktor FONTTAB_FACTOR (9 bzw. 18) zu steigern. Dies muessen wir tun, + // da auf einen ganzen String die Genauigkeit der Zeichenbreiten + // groesser als Pixel ist. Somit muessen die Werte, die in der Tabelle + // abgefragt werden durch FONTTAB_FACTOR dividiert werden. + USHORT i = 0; + if ( maGraphicsData.mbFontIsFixed ) + { + // Bei FixedFonts brauchen wir nicht soviele Zeichen + // uebergeben, da alle gleich breit sind + memset( aFontCharTabBuf, 'x', nFontTabFactor ); + GpiQueryCharStringPosAt( maGraphicsData.mhPS, &aNullPt, 0, nFontTabFactor, + (PCH)aFontCharTabBuf, NULL, aFontCharPtBuf ); + + long nWidth = aFontCharPtBuf[nFontTabFactor].x - aFontCharPtBuf[0].x; + long nFontTabFactor2 = nFontTabFactor/2; + // Breite auf ganze Pixel alignen, damit Schriftbild besser aussieht + nWidth = (nWidth+nFontTabFactor2)/nFontTabFactor; + for ( ; i < 256; i++ ) + pWidthAry[i] = nWidth; + nFontTabFactor = 1; + } + else + { + // Die ersten 32 Zeichen haben nur eine einfache Genauigkeit, damit + // wir nicht soviele Werte abfragen muessen + GpiQueryCharStringPosAt( maGraphicsData.mhPS, &aNullPt, 0, 32, + (PCH)aFontCharTab32, NULL, aFontCharPtBuf ); + for ( ; i < 32; i++ ) + pWidthAry[ i ] = (aFontCharPtBuf[i+1].x - aFontCharPtBuf[i].x) * nFontTabFactor; + + // Die restlichen Zeichen mit (fast) genauer Aufloesung + for ( ; i < 256; i++ ) + { + memset( aFontCharTabBuf, i, nFontTabFactor ); + GpiQueryCharStringPosAt( maGraphicsData.mhPS, &aNullPt, 0, nFontTabFactor, + (PCH)aFontCharTabBuf, NULL, aFontCharPtBuf ); + pWidthAry[ i ] = aFontCharPtBuf[nFontTabFactor].x - aFontCharPtBuf[0].x; + } + } + + // Orientation? -> rotate back! + if ( (maGraphicsData.mnOrientationY != 0) && (maGraphicsData.mnOrientationX != 1) ) + { + CHARBUNDLE aBundle; + aBundle.ptlAngle.x = maGraphicsData.mnOrientationX; + aBundle.ptlAngle.y = maGraphicsData.mnOrientationY; + GpiSetAttrs( maGraphicsData.mhPS, PRIM_CHAR, CBB_ANGLE, 0, &aBundle ); + } + + return nFontTabFactor; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) +{ + FONTMETRICS aOS2Metric; + GpiQueryFontMetrics( maGraphicsData.mhPS, sizeof( aOS2Metric ), &aOS2Metric ); + + pMetric->maName = aOS2Metric.szFamilyname; + pMetric->maStyleName = ImpStyleNameToSal( aOS2Metric.szFamilyname, + aOS2Metric.szFacename, + strlen( aOS2Metric.szFamilyname ) ); + + pMetric->meCharSet = ImplCharSetToSal( aOS2Metric.usCodePage ); + pMetric->meWeight = ImplWeightToSal( aOS2Metric.usWeightClass ); + + if ( aOS2Metric.panose.bFamilyType == 3 ) + pMetric->meFamily = FAMILY_SCRIPT; + else + pMetric->meFamily = FAMILY_DONTKNOW; + + if ( aOS2Metric.fsType & FM_TYPE_FIXED ) + pMetric->mePitch = PITCH_FIXED; + else + pMetric->mePitch = PITCH_VARIABLE; + + if ( aOS2Metric.fsSelection & FM_SEL_ITALIC ) + pMetric->meItalic = ITALIC_NORMAL; + else + pMetric->meItalic = ITALIC_NONE; + + if ( aOS2Metric.fsDefn & FM_DEFN_OUTLINE ) + { + pMetric->meType = TYPE_SCALABLE; + pMetric->mnWidth = aOS2Metric.lEmInc; + } + else + { + pMetric->meType = TYPE_RASTER; + pMetric->mnWidth = aOS2Metric.lAveCharWidth; + pMetric->mnOrientation = 0; + } + + if ( aOS2Metric.fsDefn & FM_DEFN_GENERIC ) + pMetric->mbDevice = FALSE; + else + pMetric->mbDevice = TRUE; + + pMetric->mnAscent = aOS2Metric.lMaxAscender; + pMetric->mnDescent = aOS2Metric.lMaxDescender; + pMetric->mnLeading = aOS2Metric.lInternalLeading; + pMetric->mnSlant = 0; + pMetric->mnFirstChar = aOS2Metric.sFirstChar; + pMetric->mnLastChar = aOS2Metric.sLastChar; +} + +// ----------------------------------------------------------------------- + +ULONG SalGraphics::GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ) +{ + if ( !nPairs || !pKernPairs ) + { + FONTMETRICS aOS2Metric; + GpiQueryFontMetrics( maGraphicsData.mhPS, sizeof( aOS2Metric ), &aOS2Metric ); + return aOS2Metric.sKerningPairs; + } + + DBG_ASSERT( sizeof( KERNINGPAIRS ) == sizeof( ImplKernPairData ), + "SalGraphics::GetKernPairs(): KERNINGPAIRS != ImplKernPairData" ); + // Einige Treiber liefern weniger Kerning-Paare, als wir mit + // GpiQueryFontMetrics() ermittelt haben. Deshalb hier den Rueckgabewert + // anpassen, damit der unabhaengige Teil entsprechend darauf reagieren + // kann + nPairs = GpiQueryKerningPairs( maGraphicsData.mhPS, nPairs, (KERNINGPAIRS*)pKernPairs ); + return nPairs; +} + +// ----------------------------------------------------------------------- + +void SalGraphics::GetDevFontList( ImplDevFontList* pList ) +{ + PFONTMETRICS pFontMetrics; + ULONG nFontMetricCount; + SalData* pSalData; + + if ( !maGraphicsData.mbPrinter ) + { + // Bei Bildschirm-Devices cachen wir die Liste global, da + // dies im unabhaengigen Teil auch so gemacht wird und wir + // ansonsten auf geloeschten Systemdaten arbeiten koennten + pSalData = GetSalData(); + nFontMetricCount = pSalData->mnFontMetricCount; + pFontMetrics = pSalData->mpFontMetrics; + // Bei Bildschirm-Devices holen wir uns die Fontliste jedesmal neu + if ( pFontMetrics ) + { + delete pFontMetrics; + pFontMetrics = NULL; + nFontMetricCount = 0; + } + } + else + { + nFontMetricCount = maGraphicsData.mnFontMetricCount; + pFontMetrics = maGraphicsData.mpFontMetrics; + } + + // do we have to create the cached font list first? + if ( !pFontMetrics ) + { + // query the number of fonts available + LONG nTemp = 0; + nFontMetricCount = GpiQueryFonts( maGraphicsData.mhPS, + QF_PUBLIC | QF_PRIVATE, + NULL, &nTemp, + sizeof( FONTMETRICS ), NULL ); + + // procede only if at least one is available! + if ( nFontMetricCount ) + { + // allocate memory for font list + pFontMetrics = new FONTMETRICS[nFontMetricCount]; + + // query font list + GpiQueryFonts( maGraphicsData.mhPS, + QF_PUBLIC | QF_PRIVATE, + NULL, + (PLONG)&nFontMetricCount, + (LONG) sizeof( FONTMETRICS ), + pFontMetrics ); + } + + if ( !maGraphicsData.mbPrinter ) + { + pSalData->mnFontMetricCount = nFontMetricCount; + pSalData->mpFontMetrics = pFontMetrics; + } + else + { + maGraphicsData.mnFontMetricCount = nFontMetricCount; + maGraphicsData.mpFontMetrics = pFontMetrics; + } + } + + // copy data from the font list + for( ULONG i = 0; i < nFontMetricCount; i++ ) + { + PFONTMETRICS pFontMetric = &pFontMetrics[i]; + + // Bildschirm-Bitmap-Font's werden nicht fuer den Drucker angeboten + if ( maGraphicsData.mbPrinter ) + { + if ( (pFontMetric->fsDefn & (FM_DEFN_OUTLINE | FM_DEFN_GENERIC)) == FM_DEFN_GENERIC ) + // Font nicht aufnehmen + continue; + } + + // create new font list element + ImplFontData* pData = new ImplFontData; + pData->maName = pFontMetric->szFamilyname; + pData->maStyleName = ImpStyleNameToSal( pFontMetric->szFamilyname, + pFontMetric->szFacename, + strlen( pFontMetric->szFamilyname) ); + pData->mpSysData = (void*)pFontMetric; + pData->meCharSet = ImplCharSetToSal( pFontMetric->usCodePage ); + pData->meWeight = ImplWeightToSal( pFontMetric->usWeightClass ); + pData->meWidthType = WIDTH_DONTKNOW; + if ( pFontMetric->panose.bFamilyType == 3 ) + pData->meFamily = FAMILY_SCRIPT; + else + pData->meFamily = FAMILY_DONTKNOW; + if ( pFontMetric->fsType & FM_TYPE_FIXED ) + pData->mePitch = PITCH_FIXED; + else + pData->mePitch = PITCH_VARIABLE; + if ( pFontMetric->fsSelection & FM_SEL_ITALIC ) + pData->meItalic = ITALIC_NORMAL; + else + pData->meItalic = ITALIC_NONE; + if ( pFontMetric->fsDefn & FM_DEFN_OUTLINE ) + pData->meType = TYPE_SCALABLE; + else + pData->meType = TYPE_RASTER; + if ( pFontMetric->fsDefn & FM_DEFN_GENERIC ) + pData->mbDevice = FALSE; + else + pData->mbDevice = TRUE; + if ( pData->meType != TYPE_RASTER ) + { + pData->mnWidth = 0; + pData->mnHeight = 0; + pData->mbOrientation = TRUE; + } + else + { + pData->mnWidth = pFontMetric->lAveCharWidth; + pData->mnHeight = pFontMetric->lMaxBaselineExt; + pData->mbOrientation = FALSE; + } + pData->mnQuality = 0; + + // add font list element to font list + pList->Add( pData ); + } +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawText( long nX, long nY, const xub_Unicode* pStr, USHORT nLen ) +{ + DBG_ERROR( "SalGraphics::DrawText called!" ); +} + +// ----------------------------------------------------------------------- + +void SalGraphics::DrawTextArray( long nX, long nY, + const xub_Unicode* pStr, USHORT nLen, + const long* pDXAry ) +{ + POINTL aPt; + LONG aStackAry[ SAL_DRAWTEXT_STACKBUF ]; + LONG* pOS2DXAry; + + if ( nLen <= SAL_DRAWTEXT_STACKBUF ) + pOS2DXAry = aStackAry; + else + pOS2DXAry = new LONG[nLen]; + + aPt.x = nX; + aPt.y = maGraphicsData.mnHeight - nY; + + pOS2DXAry[0] = (LONG)pDXAry[0]; + for ( USHORT i = 1; i < nLen-1; i++ ) + pOS2DXAry[i] = (LONG)pDXAry[i]-pDXAry[i-1]; + pOS2DXAry[nLen-1] = 0; + + // OS2 kann max. 512-Zeichen lange Strings ausgeben, deshalb kuerzen + // wir den String auf eine Laenge von 512-Zeichen + if ( nLen > 512 ) + { + // Wir versuchen links die Zeichen zu ueberspringen, die evtl. im + // nicht sichtbaren Bereich liegen + LONG nWidth = 0; + LONG nCharWidth; + while ( nLen > 512 ) + { + nCharWidth = *pOS2DXAry; + if ( (aPt.x+nWidth+nCharWidth) >= -999 ) + break; + nWidth += nCharWidth; + pStr++; + pOS2DXAry++; + nLen--; + } + + if ( nLen > 512 ) + nLen = 512; + + aPt.x = aPt.x + nWidth; + } + + GpiCharStringPosAt( maGraphicsData.mhPS, &aPt, NULL, CHS_VECTOR, nLen, (PCH)pStr, pOS2DXAry ); + + if ( pOS2DXAry != aStackAry ) + delete pOS2DXAry; +} + +// ----------------------------------------------------------------------- + +BOOL SalGraphics::GetGlyphBoundRect( xub_Unicode cChar, long* pX, long* pY, + long* pWidth, long* pHeight ) +{ + return FALSE; +} + +// ----------------------------------------------------------------------- + +///---------------------------- PUBLIC ROUTINE ------------------------------- +// Using the following macro in PMDDIM.H you can use a GRE call to get the char outline +// of system outline fonts. This call does not work for system bitmap fonts or device fonts. +// Truetype fonts should also work however the data returned for truetype fonts will be mostly +// scanline data until you install the latest fixpak ("31 or 32" I Think). The fix pak will improve +// the data returned for truetype fonts to include curves. This call was +// implemented in merlin and should be in fix pak 26 for Warp as well. +// +// #define GreQueryCharOutline(a,b,c,d,e) +// (LONG)Gre32Entry7((HDC)(a),(ULONG)(b),(ULONG)(PBYTE)(c),(ULONG)(d),(ULONG)(e),0L,0x00004256L) +// #define NGreQueryCharOutline 0x00004256L +// +// LONG APIENTRY QueryCharOutline32 (HDC hdc, ULONG ulCode, PBYTE pBuffer, +// ULONG ulLen, ULONG fl, ULONG hddc, +// ULONG ulFunN) +// +// This function returns outline data information of the specified +// character glyph +// +// Parameters: hdc Device context handle +// ulCode Code point +// pBuffer Pointer to outline data to be returned +// ulLen Length in bytes of pBuffer +// fl Options flags +// QCO_FORMAT_GOCA +// QCO_FORMAT_IFI +// QCO_NO_TRANSFORM +// hddc +// ulFunN +// Returns: +// The number of bytes needed to store character outline +// GPI_ALTERROR +// + +// ----------------------------------------------------------------------- + +ULONG SalGraphics::GetGlyphOutline( xub_Unicode cChar, USHORT** ppPolySizes, + SalPoint** ppPoints, BYTE** ppFlags ) +{ + return 0; +} diff --git a/vcl/os2/source/gdi/salogl.cxx b/vcl/os2/source/gdi/salogl.cxx new file mode 100644 index 000000000000..bae6bc3f8222 --- /dev/null +++ b/vcl/os2/source/gdi/salogl.cxx @@ -0,0 +1,263 @@ +/************************************************************************* + * + * $RCSfile: salogl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#define INCL_DOSMODULEMGR +#include +#define _SV_SALOGL_CXX +#ifndef _SV_SALOGL_HXX +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif + +// ------------ +// - Typedefs - +// ------------ + +typedef VISUALCONFIG* PCFG; + +// ------------ +// - Lib-Name - +// ------------ + +#define OGL_LIBNAME "OPENGL" + +// ---------- +// - Macros - +// ---------- + +#define GET_OGLFNC_PGL( FncName ) \ + nResult = DosQueryProcAddr( mhOGLLib, 0, "pgl" #FncName, (PFN*)&pFnc##FncName ); \ +if( nResult != 0 ) \ + bRet = FALSE; + +// ------------------------------------------------------------------------ + +#define GET_OGLFNC_GL( FncName ) \ + nResult = DosQueryProcAddr( mhOGLLib, 0, "gl" #FncName, (PFN*)&pFnc##FncName ); \ +if( nResult != 0 ) \ + bRet = FALSE; + +// ----------------- +// - Statics init. - +// ----------------- + +// Members +HMODULE SalOpenGL::mhOGLLib = 0; +HGC SalOpenGL::mhOGLContext = 0; +HDC SalOpenGL::mhOGLLastDC = 0; +ULONG SalOpenGL::mnOGLState = OGL_STATE_UNLOADED; + +// Internal use +INIT_OGLFNC( SalOpenGL, ChooseConfig ); +INIT_OGLFNC( SalOpenGL, QueryConfigs ); +INIT_OGLFNC( SalOpenGL, CreateContext ); +INIT_OGLFNC( SalOpenGL, DestroyContext ); +INIT_OGLFNC( SalOpenGL, GetCurrentContext ); +INIT_OGLFNC( SalOpenGL, MakeCurrent ); +INIT_OGLFNC( SalOpenGL, QueryCapability ); + +// ------------- +// - SalOpenGL - +// ------------- + +SalOpenGL::SalOpenGL( SalGraphics* pGraphics ) +{ + // Set mhOGLLastDC only the first time a + // SalOpenGL object is created; we need + // this DC in SalOpenGL::Create(); + if( OGL_STATE_UNLOADED == mnOGLState ) + mhOGLLastDC = pGraphics->maGraphicsData.mhDC; +} + +// ------------------------------------------------------------------------ + +SalOpenGL::~SalOpenGL() +{ +} + +// ------------------------------------------------------------------------ + +BOOL SalOpenGL::Create() +{ + BOOL bRet = FALSE; + + if( OGL_STATE_UNLOADED == mnOGLState ) + { + if( ImplInitLib() ) + { +/* + if( ImplInit() ) + { + HAB hAB = GetSalData()->mhAB; + VISUALCONFIG aCfg = { PGL_RGBA, PGL_RED_SIZE, 4, PGL_GREEN_SIZE, 4,PGL_BLUE_SIZE, 4, PGL_DOUBLEBUFFER, 0 }; + PCFG* ppCfgs = pFncQueryConfigs( hAB ); + + if( *ppCfgs ) + { + if( ( mhOGLContext = pFncCreateContext( hAB, *ppCfgs, NULL, FALSE ) ) != 0 ) + { + pFncMakeCurrent( hAB, mhOGLContext, WinWindowFromDC( mhOGLLastDC ) ); + mnOGLState = OGL_STATE_VALID; + bRet = TRUE; + } + } + } +*/ + + if( !bRet ) + { + ImplFreeLib(); + mnOGLState = OGL_STATE_INVALID; + } + } + else + mnOGLState = OGL_STATE_INVALID; + } + else if( OGL_STATE_VALID == mnOGLState ) + bRet = TRUE; + + return bRet; +} + +// ------------------------------------------------------------------------ + +void SalOpenGL::Release() +{ + ImplFreeLib(); +} + +// ------------------------------------------------------------------------ + +void* SalOpenGL::GetOGLFnc( const String& rFncName ) +{ + void* pRet; + + if( mhOGLLib ) + { + APIRET rc; + PFN pFunction; + + rc = DosQueryProcAddr( mhOGLLib, 0, rFncName, &pFunction ); + pRet = rc == NULL ? pFunction : NULL; + } + else + pRet = NULL; + + return pRet; +} + +// ------------------------------------------------------------------------ + +void SalOpenGL::OGLEntry( SalGraphics* pGraphics ) +{ + if( pGraphics->maGraphicsData.mhDC != mhOGLLastDC ) + { + mhOGLLastDC = pGraphics->maGraphicsData.mhDC; + pFncMakeCurrent( GetSalData()->mhAB, mhOGLContext, WinWindowFromDC( mhOGLLastDC ) ); + } +} + +// ------------------------------------------------------------------------ + +void SalOpenGL::OGLExit( SalGraphics* pGraphics ) +{ +} + +// ------------------------------------------------------------------------ + +BOOL SalOpenGL::ImplInitLib() +{ + DosLoadModule ((PSZ)0, 0, OGL_LIBNAME, &mhOGLLib ); + return( mhOGLLib != NULL ); +} + +// ------------------------------------------------------------------------ + +void SalOpenGL::ImplFreeLib() +{ + if( mhOGLLib ) + DosFreeModule( mhOGLLib ); +} + +// ------------------------------------------------------------------------ + +BOOL SalOpenGL::ImplInit() +{ + ULONG nResult; + BOOL bRet = TRUE; + + // Internal use + GET_OGLFNC_PGL( ChooseConfig ); + GET_OGLFNC_PGL( QueryConfigs ); + GET_OGLFNC_PGL( CreateContext ); + GET_OGLFNC_PGL( DestroyContext ); + GET_OGLFNC_PGL( GetCurrentContext ); + GET_OGLFNC_PGL( MakeCurrent ); + GET_OGLFNC_PGL( QueryCapability ); + + return bRet; +} diff --git a/vcl/os2/source/gdi/salprn.cxx b/vcl/os2/source/gdi/salprn.cxx new file mode 100644 index 000000000000..95e6baa2d6fb --- /dev/null +++ b/vcl/os2/source/gdi/salprn.cxx @@ -0,0 +1,1878 @@ +/************************************************************************* + * + * $RCSfile: salprn.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// use this define to disable the DJP support +// #define NO_DJP + +#define INCL_DOSMODULEMGR +#define INCL_DEV +#define INCL_SPL +#define INCL_SPLDOSPRINT +#define INCL_DEVDJP + +#define BOOL PM_BOOL +#define BYTE PM_BYTE +#define USHORT PM_USHORT +#define ULONG PM_ULONG + +#define INCL_PM +#include +#include "pmdjp.h" + +#undef BOOL +#undef BYTE +#undef USHORT +#undef ULONG + +#include + +#define _SV_SALPRN_CXX + +#ifndef _NEW_HXX +#include +#endif +#ifndef _DEBUG_HXX +#include +#endif + +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_HXX +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALFRAME_HXX +#include +#endif +#ifndef _SV_SALPTYPE_HXX +#include +#endif +#ifndef _SV_SALPRN_HXX +#include +#endif + +#ifndef _SV_PRINT_H +#include +#endif +#ifndef _SV_JOBSET_H +#include +#endif + +// ======================================================================= + +// ----------------------- +// - struct ImplFormInfo - +// ----------------------- + +struct ImplFormInfo +{ + long mnPaperWidth; + long mnPaperHeight; + DJPT_PAPERSIZE mnId; +}; + +// ======================================================================= + +// ----------------------- +// - struct ImplTrayInfo - +// ----------------------- + +struct ImplTrayInfo +{ + XubString maName; + XubString maDisplayName; + DJPT_TRAYTYPE mnId; + + ImplTrayInfo( const char* pTrayName, + const char* pTrayDisplayName ) : + maName( pTrayName ), + maDisplayName( pTrayDisplayName ) + {} +}; + +// ======================================================================= + +struct ImplQueueSalSysData +{ + String maPrinterName; // pszPrinters + String maName; // pszName bzw. LogAddress + String maOrgDriverName; // pszDriverName (maDriverName.maDeviceName) + String maDriverName; // pszDriverName bis . + String maDeviceName; // pszDriverName nach . + PDRIVDATA mpDrivData; + + ImplQueueSalSysData( const String& rPrinterName, + const String& rName, + const String& rDriverName, + const String& rDeviceName, + const String& rOrgDriverName, + PDRIVDATA pDrivData ); + ~ImplQueueSalSysData(); +}; + +// ----------------------------------------------------------------------- + +ImplQueueSalSysData::ImplQueueSalSysData( const String& rPrinterName, + const String& rName, + const String& rOrgDriverName, + const String& rDriverName, + const String& rDeviceName, + PDRIVDATA pDrivData ) : + maPrinterName( rPrinterName ), + maName( rName ), + maOrgDriverName( rName ), + maDriverName( rDriverName ), + maDeviceName( rDeviceName ) +{ + if ( pDrivData ) + { + mpDrivData = (PDRIVDATA)new BYTE[pDrivData->cb]; + memcpy( mpDrivData, pDrivData, pDrivData->cb ); + } + else + mpDrivData = NULL; +} + +// ----------------------------------------------------------------------- + +ImplQueueSalSysData::~ImplQueueSalSysData() +{ + delete mpDrivData; +} + +// ======================================================================= + +static ULONG ImplPMQueueStatusToSal( PM_USHORT nPMStatus ) +{ + ULONG nStatus = 0; + if ( nPMStatus & PRQ3_PAUSED ) + nStatus |= QUEUE_STATUS_PAUSED; + if ( nPMStatus & PRQ3_PENDING ) + nStatus |= QUEUE_STATUS_PENDING_DELETION; + if ( !nStatus ) + nStatus |= QUEUE_STATUS_READY; + return nStatus; +} + +// ----------------------------------------------------------------------- + +void SalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) +{ + APIRET rc; + ULONG nNeeded; + ULONG nReturned; + ULONG nTotal; + + // query needed size of the buffer for the QueueInfo + rc = SplEnumQueue( (PSZ)NULL, 3, NULL, 0, &nReturned, &nTotal, &nNeeded, NULL ); + if( nNeeded == 0 ) + return; + + // create the buffer for the QueueInfo + PCHAR pQueueData = new CHAR[nNeeded]; + + // query QueueInfos + rc = SplEnumQueue( (PSZ)NULL, 3, pQueueData, nNeeded, &nReturned, &nTotal, &nNeeded, NULL ); + + PPRQINFO3 pPrqInfo = (PPRQINFO3)pQueueData; + for ( int i = 0; i < nReturned; i++ ) + { + // create entry for the QueueInfo array + SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo; + + String aOrgDriverName( pPrqInfo->pszDriverName ); + String aName( pPrqInfo->pszName ); + pInfo->maDriver = aOrgDriverName; + pInfo->maPrinterName = pPrqInfo->pszComment; + pInfo->maLocation = aName; + pInfo->mnStatus = ImplPMQueueStatusToSal( pPrqInfo->fsStatus ); + pInfo->mnJobs = pPrqInfo->cJobs; + // pInfo->maComment = !!! + + // Feststellen, ob Name doppelt + PPRQINFO3 pTempPrqInfo = (PPRQINFO3)pQueueData; + for ( int j = 0; j < nReturned; j++ ) + { + // Wenn Name doppelt, erweitern wir diesen um die Location + if ( (j != i) && + (strcmp( pPrqInfo->pszComment, pTempPrqInfo->pszComment ) == 0) ) + { + pInfo->maPrinterName += ';'; + pInfo->maPrinterName += pInfo->maLocation; + } + pTempPrqInfo++; + } + + // pszDriver in DriverName (bis .) und DeviceName (nach .) aufsplitten + PSZ pDriverName; + PSZ pDeviceName; + if ( (pDriverName = strchr( pPrqInfo->pszDriverName, '.' )) != 0 ) + { + *pDriverName = 0; + pDeviceName = pDriverName + 1; + } + else + pDeviceName = NULL; + + // Alle Bytes hinter dem DeviceNamen auf 0 initialisieren, damit + // ein memcmp vom JobSetup auch funktioniert + if ( pPrqInfo->pDriverData && + (pPrqInfo->pDriverData->cb >= sizeof( pPrqInfo->pDriverData )) ) + { + int nDeviceNameLen = strlen( pPrqInfo->pDriverData->szDeviceName ); + memset( pPrqInfo->pDriverData->szDeviceName+nDeviceNameLen, + 0, + sizeof( pPrqInfo->pDriverData->szDeviceName )-nDeviceNameLen ); + } + + // save driver data and driver names + String aPrinterName( pPrqInfo->pszPrinters ); + String aDriverName( pPrqInfo->pszDriverName ); + String aDeviceName; + if ( pDeviceName ) + aDeviceName = pDeviceName; + pInfo->mpSysData = new ImplQueueSalSysData( aPrinterName, aName, + aOrgDriverName, + aDriverName, aDeviceName, + pPrqInfo->pDriverData ); + + // add queue to the list + pList->Add( pInfo ); + + // increment to next element of the QueueInfo array + pPrqInfo++; + } + + delete [] pQueueData; +} + +// ----------------------------------------------------------------------- + +void SalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) +{ + APIRET rc; + ULONG nNeeded; + ULONG nReturned; + ULONG nTotal; + + // query needed size of the buffer for the QueueInfo + rc = SplEnumQueue( (PSZ)NULL, 3, NULL, 0, &nReturned, &nTotal, &nNeeded, NULL ); + if( nNeeded == 0 ) + return; + + // create the buffer for the QueueInfo + PCHAR pQueueData = new CHAR[nNeeded]; + + // query QueueInfos + rc = SplEnumQueue( (PSZ)NULL, 3, pQueueData, nNeeded, &nReturned, &nTotal, &nNeeded, NULL ); + + PPRQINFO3 pPrqInfo = (PPRQINFO3)pQueueData; + for ( int i = 0; i < nReturned; i++ ) + { + ImplQueueSalSysData* pSysData = (ImplQueueSalSysData*)(pInfo->mpSysData); + if ( (strcmp( pSysData->maPrinterName, pPrqInfo->pszPrinters ) == 0) && + (strcmp( pSysData->maName, pPrqInfo->pszName ) == 0) && + (strcmp( pSysData->maOrgDriverName, pPrqInfo->pszDriverName ) == 0) ) + { + pInfo->mnStatus = ImplPMQueueStatusToSal( pPrqInfo->fsStatus ); + pInfo->mnJobs = pPrqInfo->cJobs; + break; + } + + // increment to next element of the QueueInfo array + pPrqInfo++; + } + + delete [] pQueueData; +} + +// ----------------------------------------------------------------------- + +void SalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) +{ + delete ((ImplQueueSalSysData*)(pInfo->mpSysData)); + delete pInfo; +} + +// ----------------------------------------------------------------------- + +XubString SalInstance::GetDefaultPrinter() +{ + APIRET rc; + ULONG nNeeded; + ULONG nReturned; + ULONG nTotal; + char szQueueName[255]; + XubString aDefaultName; + + // query default queue + if ( !PrfQueryProfileString( HINI_PROFILE, SPL_INI_SPOOLER, "QUEUE", 0, szQueueName, sizeof( szQueueName ) ) ) + return aDefaultName; + + // extract first queue name + PSZ pStr; + if ( (pStr = strchr( szQueueName, ';' )) != 0 ) + *pStr = 0; + + // query needed size of the buffer for the QueueInfo + rc = SplEnumQueue( (PSZ)NULL, 3, NULL, 0, &nReturned, &nTotal, &nNeeded, NULL ); + if ( nNeeded == 0 ) + return aDefaultName; + + // create the buffer for the QueueInfo + PCHAR pQueueData = new CHAR[ nNeeded ]; + + // query QueueInfos + rc = SplEnumQueue ((PSZ)NULL, 3, pQueueData, nNeeded, &nReturned, &nTotal, &nNeeded, NULL ); + + // find printer name for default queue + PPRQINFO3 pPrqInfo = (PPRQINFO3) pQueueData; + for ( int i = 0; i < nReturned; i++ ) + { + if ( strcmp( pPrqInfo->pszName, szQueueName ) == 0 ) + { + aDefaultName = pPrqInfo->pszComment; + + // Feststellen, ob Name doppelt + PPRQINFO3 pTempPrqInfo = (PPRQINFO3)pQueueData; + for ( int j = 0; j < nReturned; j++ ) + { + // Wenn Name doppelt, erweitern wir diesen um die Location + if ( (j != i) && + (strcmp( pPrqInfo->pszComment, pTempPrqInfo->pszComment ) == 0) ) + { + aDefaultName += ';'; + aDefaultName += pPrqInfo->pszName; + } + pTempPrqInfo++; + } + break; + } + + // increment to next element of the QueueInfo array + pPrqInfo++; + } + + delete [] pQueueData; + + return aDefaultName; +} + +// ======================================================================= + +static void* ImplAllocPrnMemory( size_t n ) +{ + PVOID pVoid = 0; + + if ( DosAllocMem( &pVoid, n, PAG_COMMIT | PAG_READ | PAG_WRITE ) ) + return 0; + + return pVoid; +} + +// ----------------------------------------------------------------------- + +inline void ImplFreePrnMemory( void* p ) +{ + DosFreeMem( p ); +} + +// ----------------------------------------------------------------------- + +static PDRIVDATA ImplPrnDrivData( const ImplJobSetup* pSetupData ) +{ + // Diese Funktion wird eingesetzt, damit Druckertreiber nicht auf + // unseren Daten arbeiten, da es durch Konfigurationsprobleme + // sein kann, das der Druckertreiber bei uns Daten ueberschreibt. + // Durch diese vorgehensweise werden einige Abstuerze vermieden, bzw. + // sind dadurch leichter zu finden + + if ( !pSetupData->mpDriverData ) + return NULL; + + DBG_ASSERT( ((PRIVDATA)(pSetupData->mpDriverData))->cb == pSetupData->mnDriverDataLen, + "ImplPrnDrivData() - SetupDataLen != DriverDataLen" ); + + PDRIVDATA pDrivData = (PDRIVDATA)ImplAllocPrnMemory( pSetupData->mnDriverDataLen ); + memcpy( pDrivData, pSetupData->mpDriverData, pSetupData->mnDriverDataLen ); + return pDrivData; +} + +// ----------------------------------------------------------------------- + +static void ImplUpdateSetupData( const PDRIVDATA pDrivData, ImplJobSetup* pSetupData ) +{ + // Diese Funktion wird eingesetzt, damit Druckertreiber nicht auf + // unseren Daten arbeiten, da es durch Konfigurationsprobleme + // sein kann, das der Druckertreiber bei uns Daten ueberschreibt. + // Durch diese vorgehensweise werden einige Abstuerze vermieden, bzw. + // sind dadurch leichter zu finden + + if ( !pDrivData || !pDrivData->cb ) + { + if ( pSetupData->mpDriverData ) + delete pSetupData->mpDriverData; + pSetupData->mnDriverDataLen = 0; + } + else + { + // Alle Bytes hinter dem DeviceNamen auf 0 initialisieren, damit + // ein memcmp vom JobSetup auch funktioniert + if ( pDrivData->cb >= sizeof( pDrivData ) ) + { + int nDeviceNameLen = strlen( pDrivData->szDeviceName ); + memset( pDrivData->szDeviceName+nDeviceNameLen, + 0, + sizeof( pDrivData->szDeviceName )-nDeviceNameLen ); + } + + if ( pSetupData->mpDriverData ) + { + if ( pSetupData->mnDriverDataLen != pDrivData->cb ) + delete pSetupData->mpDriverData; + pSetupData->mpDriverData = new BYTE[pDrivData->cb]; + } + else + pSetupData->mpDriverData = new BYTE[pDrivData->cb]; + pSetupData->mnDriverDataLen = pDrivData->cb; + memcpy( pSetupData->mpDriverData, pDrivData, pDrivData->cb ); + } + + if ( pDrivData ) + ImplFreePrnMemory( pDrivData ); +} + +// ----------------------------------------------------------------------- + +static BOOL ImplPaperSizeEqual( long nPaperWidth1, long nPaperHeight1, + long nPaperWidth2, long nPaperHeight2 ) +{ + return (((nPaperWidth1 >= nPaperWidth2-1) && (nPaperWidth1 <= nPaperWidth2+1)) && + ((nPaperHeight1 >= nPaperHeight2-1) && (nPaperHeight1 <= nPaperHeight2+1))); +} + +// ----------------------------------------------------------------------- + +static BOOL ImplIsDriverDJPEnabled( HDC hDC ) +{ +#ifdef NO_DJP + return FALSE; +#else + // Ueber OS2-Ini kann DJP disablte werden + if ( !PrfQueryProfileInt( HINI_PROFILE, SAL_PROFILE_APPNAME, SAL_PROFILE_USEDJP, 1 ) ) + return FALSE; + + // Testen, ob DJP-Interface am Drucker vorhanden + LONG lQuery; + APIRET rc; + + lQuery = DEVESC_QUERYSIZE; + rc = DevEscape( hDC, + DEVESC_QUERYESCSUPPORT, + sizeof( lQuery ), + (PBYTE)&lQuery, + 0, + (PBYTE)NULL ); + if ( DEV_OK != rc ) + return FALSE; + + lQuery = DEVESC_QUERYJOBPROPERTIES; + rc = DevEscape( hDC, + DEVESC_QUERYESCSUPPORT, + sizeof( lQuery ), + (PBYTE)&lQuery, + 0, + (PBYTE)NULL ); + if ( DEV_OK != rc ) + return FALSE; + + lQuery = DEVESC_SETJOBPROPERTIES; + rc = DevEscape( hDC, + DEVESC_QUERYESCSUPPORT, + sizeof( lQuery ), + (PBYTE)&lQuery, + 0, + (PBYTE)NULL ); + if ( DEV_OK != rc ) + return FALSE; + + return TRUE; +#endif +} + +// ----------------------------------------------------------------------- + +static void ImplFormatInputList( PDJP_ITEM pDJP, PQUERYTUPLE pTuple ) +{ + // Loop through the query elements + BOOL fContinue = TRUE; + do + { + pDJP->cb = sizeof (DJP_ITEM); + pDJP->ulProperty = pTuple->ulProperty; + pDJP->lType = pTuple->lType; + pDJP->ulNumReturned = 0; + pDJP->ulValue = DJP_NONE; + + // at EOL? + fContinue = DJP_NONE != pTuple->ulProperty; + + // Move to next item structure and tuplet + pDJP++; + pTuple++; + } + while ( fContinue ); +} + +// ----------------------------------------------------------------------- + +static void ImplFreeFormAndTrayList( SalInfoPrinter* pSalInfoPrinter ) +{ + if ( pSalInfoPrinter->maPrinterData.mnFormCount ) + { + for ( USHORT i = 0; i < pSalInfoPrinter->maPrinterData.mnFormCount; i++ ) + delete pSalInfoPrinter->maPrinterData.mpFormArray[i]; + delete [] pSalInfoPrinter->maPrinterData.mpFormArray; + pSalInfoPrinter->maPrinterData.mnFormCount = 0; + } + + if ( pSalInfoPrinter->maPrinterData.mnTrayCount ) + { + for ( USHORT i = 0; i < pSalInfoPrinter->maPrinterData.mnTrayCount; i++ ) + delete pSalInfoPrinter->maPrinterData.mpTrayArray[i]; + delete [] pSalInfoPrinter->maPrinterData.mpTrayArray; + pSalInfoPrinter->maPrinterData.mnTrayCount = 0; + } +} + +// ----------------------------------------------------------------------- + +static void ImplGetFormAndTrayList( SalInfoPrinter* pSalInfoPrinter, const ImplJobSetup* pSetupData ) +{ + ImplFreeFormAndTrayList( pSalInfoPrinter ); + + LONG alQuery[] = + { + 0, 0, // First two members of QUERYSIZE + DJP_CJ_FORM, DJP_ALL, + DJP_CJ_TRAYNAME, DJP_ALL, + DJP_NONE, DJP_NONE // EOL marker + }; + + APIRET rc; + PQUERYSIZE pQuerySize = (PQUERYSIZE)alQuery; + PBYTE pBuffer = NULL; + LONG nAlloc = 0; + PDRIVDATA pCopyDrivData = ImplPrnDrivData( pSetupData ); + LONG nDrivDataSize = pCopyDrivData->cb; + PBYTE pDrivData = (PBYTE)pCopyDrivData; + + // find out how many bytes to allocate + pQuerySize->cb = sizeof( alQuery ); + rc = DevEscape( pSalInfoPrinter->maPrinterData.mhDC, + DEVESC_QUERYSIZE, + sizeof( alQuery ), + (PBYTE)pQuerySize, + &nDrivDataSize, + pDrivData ); + if ( DEV_OK != rc ) + { + ImplFreePrnMemory( pCopyDrivData ); + return; + } + + // allocate the memory + nAlloc = pQuerySize->ulSizeNeeded; + pBuffer = (PBYTE)new BYTE[nAlloc]; + + // set up the input + PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer; + ImplFormatInputList( pDJP, pQuerySize->aTuples ); + + // do it! + rc = DevEscape( pSalInfoPrinter->maPrinterData.mhDC, + DEVESC_QUERYJOBPROPERTIES, + nAlloc, + pBuffer, + &nDrivDataSize, + pDrivData ); + ImplFreePrnMemory( pCopyDrivData ); + + if ( (DEV_OK == rc) || (DEV_WARNING == rc) ) + { + // Loop through the query elements + PQUERYTUPLE pTuple = pQuerySize->aTuples; + while ( DJP_NONE != pTuple->ulProperty ) + { + if ( pDJP->ulProperty == DJP_CJ_FORM ) + { + if ( pDJP->ulNumReturned ) + { + PDJPT_FORM pElm = DJP_ELEMENTP( *pDJP, DJPT_FORM ); + + pSalInfoPrinter->maPrinterData.mnFormCount = pDJP->ulNumReturned; + pSalInfoPrinter->maPrinterData.mpFormArray = new PIMPLFORMINFO[pSalInfoPrinter->maPrinterData.mnFormCount]; + for( int i = 0; i < pDJP->ulNumReturned; i++, pElm++ ) + { + ImplFormInfo* pInfo = new ImplFormInfo; + pInfo->mnPaperWidth = pElm->hcInfo.cx; + pInfo->mnPaperHeight = pElm->hcInfo.cy; + pInfo->mnId = pElm->djppsFormID; + pSalInfoPrinter->maPrinterData.mpFormArray[i] = pInfo; + } + } + } + else if ( pDJP->ulProperty == DJP_CJ_TRAYNAME ) + { + if ( pDJP->ulNumReturned ) + { + PDJPT_TRAYNAME pElm = DJP_ELEMENTP( *pDJP, DJPT_TRAYNAME ); + + pSalInfoPrinter->maPrinterData.mnTrayCount = pDJP->ulNumReturned; + pSalInfoPrinter->maPrinterData.mpTrayArray = new PIMPLTRAYINFO[pSalInfoPrinter->maPrinterData.mnTrayCount]; + for( int i = 0; i < pDJP->ulNumReturned; i++, pElm++ ) + { + ImplTrayInfo* pInfo = new ImplTrayInfo( pElm->szTrayname, pElm->szDisplayTrayname ); + pInfo->mnId = pElm->djpttTrayID; + pSalInfoPrinter->maPrinterData.mpTrayArray[i] = pInfo; + } + } + } + + pDJP = DJP_NEXT_STRUCTP( pDJP ); + pTuple++; + } + } + + delete [] pBuffer; +} + +// ----------------------------------------------------------------------- + +static BOOL ImplGetCurrentSettings( SalInfoPrinter* pSalInfoPrinter, ImplJobSetup* pSetupData ) +{ + // Um den aktuellen Tray zu ermitteln, brauchen wir auch die Listen dazu + if ( !pSalInfoPrinter->maPrinterData.mnFormCount ) + ImplGetFormAndTrayList( pSalInfoPrinter, pSetupData ); + + LONG alQuery[] = + { + 0, 0, // First two members of QUERYSIZE + DJP_SJ_ORIENTATION, DJP_CURRENT, + DJP_CJ_FORM, DJP_CURRENT, + DJP_NONE, DJP_NONE // EOL marker + }; + + APIRET rc; + PQUERYSIZE pQuerySize = (PQUERYSIZE)alQuery; + PBYTE pBuffer = NULL; + LONG nAlloc = 0; + PDRIVDATA pCopyDrivData = ImplPrnDrivData( pSetupData ); + LONG nDrivDataSize = pCopyDrivData->cb; + PBYTE pDrivData = (PBYTE)pCopyDrivData; + BOOL bResult; + + // find out how many bytes to allocate + pQuerySize->cb = sizeof( alQuery ); + rc = DevEscape( pSalInfoPrinter->maPrinterData.mhDC, + DEVESC_QUERYSIZE, + sizeof( alQuery ), + (PBYTE)pQuerySize, + &nDrivDataSize, + pDrivData ); + if ( DEV_OK != rc ) + { + ImplFreePrnMemory( pCopyDrivData ); + return FALSE; + } + + // allocate the memory + nAlloc = pQuerySize->ulSizeNeeded; + pBuffer = (PBYTE)new BYTE[nAlloc]; + + // set up the input + PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer; + ImplFormatInputList( pDJP, pQuerySize->aTuples ); + + rc = DevEscape( pSalInfoPrinter->maPrinterData.mhDC, + DEVESC_QUERYJOBPROPERTIES, + nAlloc, + pBuffer, + &nDrivDataSize, + pDrivData ); + if ( (DEV_OK == rc) || (DEV_WARNING == rc) ) + { + // aktuelle Setup-Daten uebernehmen + ImplUpdateSetupData( pCopyDrivData, pSetupData ); + + // Loop through the query elements + PQUERYTUPLE pTuple = pQuerySize->aTuples; + while ( DJP_NONE != pTuple->ulProperty ) + { + if ( pDJP->ulProperty == DJP_SJ_ORIENTATION ) + { + if ( pDJP->ulNumReturned ) + { + PDJPT_ORIENTATION pElm = DJP_ELEMENTP( *pDJP, DJPT_ORIENTATION ); + if ( (DJP_ORI_PORTRAIT == *pElm) || (DJP_ORI_REV_PORTRAIT == *pElm) ) + pSetupData->meOrientation = ORIENTATION_PORTRAIT; + else + pSetupData->meOrientation = ORIENTATION_LANDSCAPE; + } + } + else if ( pDJP->ulProperty == DJP_CJ_FORM ) + { + if ( pDJP->ulNumReturned ) + { + PDJPT_FORM pElm = DJP_ELEMENTP( *pDJP, DJPT_FORM ); + + pSetupData->mnPaperWidth = pElm->hcInfo.cx*100; + pSetupData->mnPaperHeight = pElm->hcInfo.cy*100; + switch( pElm->djppsFormID ) + { + case DJP_PSI_A3: + pSetupData->mePaperFormat = PAPER_A3; + break; + + case DJP_PSI_A4: + pSetupData->mePaperFormat = PAPER_A4; + break; + + case DJP_PSI_A5: + pSetupData->mePaperFormat = PAPER_A5; + break; + + case DJP_PSI_B4: + pSetupData->mePaperFormat = PAPER_B4; + break; + + case DJP_PSI_B5: + pSetupData->mePaperFormat = PAPER_B5; + break; + + case DJP_PSI_LETTER: + pSetupData->mePaperFormat = PAPER_LETTER; + break; + + case DJP_PSI_LEGAL: + pSetupData->mePaperFormat = PAPER_LEGAL; + break; + + case DJP_PSI_TABLOID: + pSetupData->mePaperFormat = PAPER_TABLOID; + break; + + default: + pSetupData->mePaperFormat = PAPER_USER; + break; + } + + // Wir suchen zuerst ueber den Namen/Id und dann ueber die Id + BOOL bTrayFound = FALSE; + USHORT j; + for ( j = 0; j < pSalInfoPrinter->maPrinterData.mnTrayCount; j++ ) + { + if ( (pSalInfoPrinter->maPrinterData.mpTrayArray[j]->mnId == pElm->djpttTrayID) && + (pSalInfoPrinter->maPrinterData.mpTrayArray[j]->maName == pElm->szTrayname) ) + { + pSetupData->mnPaperBin = j; + bTrayFound = TRUE; + break; + } + } + if ( !bTrayFound ) + { + for ( j = 0; j < pSalInfoPrinter->maPrinterData.mnTrayCount; j++ ) + { + if ( pSalInfoPrinter->maPrinterData.mpTrayArray[j]->mnId == pElm->djpttTrayID ) + { + pSetupData->mnPaperBin = j; + bTrayFound = TRUE; + break; + } + } + } + // Wenn wir Ihn immer noch nicht gefunden haben, setzen + // wir ihn auf DontKnow + if ( !bTrayFound ) + pSetupData->mnPaperBin = 0xFFFF; + } + } + + pDJP = DJP_NEXT_STRUCTP( pDJP ); + pTuple++; + } + + bResult = TRUE; + } + else + { + ImplFreePrnMemory( pCopyDrivData ); + bResult = FALSE; + } + + delete [] pBuffer; + + return bResult; +} + +// ----------------------------------------------------------------------- + +static BOOL ImplSetOrientation( HDC hPrinterDC, PDRIVDATA pDriverData, + Orientation eOrientation ) +{ + LONG alQuery[] = + { + 0, 0, // First two members of QUERYSIZE + DJP_SJ_ORIENTATION, DJP_CURRENT, + DJP_NONE, DJP_NONE // EOL marker + }; + + APIRET rc; + PQUERYSIZE pQuerySize = (PQUERYSIZE)alQuery; + PBYTE pBuffer = NULL; + LONG nAlloc = 0; + LONG nDrivDataSize = pDriverData->cb; + + // find out how many bytes to allocate + pQuerySize->cb = sizeof( alQuery ); + rc = DevEscape( hPrinterDC, + DEVESC_QUERYSIZE, + sizeof( alQuery ), + (PBYTE)pQuerySize, + &nDrivDataSize, + (PBYTE)pDriverData ); + if ( DEV_OK != rc ) + return FALSE; + + // allocate the memory + nAlloc = pQuerySize->ulSizeNeeded; + pBuffer = (PBYTE)new BYTE[nAlloc]; + + // set up the input + PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer; + ImplFormatInputList( pDJP, pQuerySize->aTuples ); + + pDJP->cb = sizeof( DJP_ITEM ); + pDJP->ulProperty = DJP_SJ_ORIENTATION; + pDJP->lType = DJP_CURRENT; + pDJP->ulValue = (eOrientation == ORIENTATION_PORTRAIT) + ? DJP_ORI_PORTRAIT + : DJP_ORI_LANDSCAPE; + + // do it! + rc = DevEscape( hPrinterDC, + DEVESC_SETJOBPROPERTIES, + nAlloc, + pBuffer, + &nDrivDataSize, + (PBYTE)pDriverData ); + + delete [] pBuffer; + + return ((DEV_OK == rc) || (DEV_WARNING == rc)); +} + +// ----------------------------------------------------------------------- + +static BOOL ImplSetPaperSize( HDC hPrinterDC, PDRIVDATA pDriverData, + DJPT_PAPERSIZE nOS2PaperFormat ) +{ + LONG alQuery[] = + { + 0, 0, // First two members of QUERYSIZE + DJP_SJ_PAPERSIZE, DJP_CURRENT, + DJP_NONE, DJP_NONE // EOL marker + }; + + APIRET rc; + PQUERYSIZE pQuerySize = (PQUERYSIZE)alQuery; + PBYTE pBuffer = NULL; + LONG nAlloc = 0; + LONG nDrivDataSize = pDriverData->cb; + + // find out how many bytes to allocate + pQuerySize->cb = sizeof( alQuery ); + rc = DevEscape( hPrinterDC, + DEVESC_QUERYSIZE, + sizeof( alQuery ), + (PBYTE)pQuerySize, + &nDrivDataSize, + (PBYTE)pDriverData ); + if ( DEV_OK != rc ) + return FALSE; + + // allocate the memory + nAlloc = pQuerySize->ulSizeNeeded; + pBuffer = (PBYTE)new BYTE[nAlloc]; + + // set up the input + PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer; + PDJP_ITEM pStartDJP = pDJP; + ImplFormatInputList( pDJP, pQuerySize->aTuples ); + + // Neue Daten zuweisen + pDJP->cb = sizeof( DJP_ITEM ); + pDJP->ulProperty = DJP_SJ_PAPERSIZE; + pDJP->lType = DJP_CURRENT; + pDJP->ulValue = nOS2PaperFormat; + + // und setzen + rc = DevEscape( hPrinterDC, + DEVESC_SETJOBPROPERTIES, + nAlloc, + pBuffer, + &nDrivDataSize, + (PBYTE)pDriverData ); + + delete [] pBuffer; + + return ((DEV_OK == rc) || (DEV_WARNING == rc)); +} + +// ----------------------------------------------------------------------- + +static BOOL ImplSetPaperBin( HDC hPrinterDC, PDRIVDATA pDriverData, + ImplTrayInfo* pTrayInfo ) +{ + LONG alQuery[] = + { + 0, 0, // First two members of QUERYSIZE + DJP_SJ_TRAYTYPE, DJP_CURRENT, + DJP_NONE, DJP_NONE // EOL marker + }; + + APIRET rc; + PQUERYSIZE pQuerySize = (PQUERYSIZE)alQuery; + PBYTE pBuffer = NULL; + LONG nAlloc = 0; + LONG nDrivDataSize = pDriverData->cb; + + // find out how many bytes to allocate + pQuerySize->cb = sizeof( alQuery ); + rc = DevEscape( hPrinterDC, + DEVESC_QUERYSIZE, + sizeof( alQuery ), + (PBYTE)pQuerySize, + &nDrivDataSize, + (PBYTE)pDriverData ); + if ( DEV_OK != rc ) + return FALSE; + + // allocate the memory + nAlloc = pQuerySize->ulSizeNeeded; + pBuffer = (PBYTE)new BYTE[nAlloc]; + + // set up the input + PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer; + ImplFormatInputList( pDJP, pQuerySize->aTuples ); + + // Neue Daten zuweisen + pDJP->cb = sizeof( DJP_ITEM ); + pDJP->ulProperty = DJP_SJ_TRAYTYPE; + pDJP->lType = DJP_CURRENT; + pDJP->ulValue = pTrayInfo->mnId; + + // und setzen + rc = DevEscape( hPrinterDC, + DEVESC_SETJOBPROPERTIES, + nAlloc, + pBuffer, + &nDrivDataSize, + (PBYTE)pDriverData ); + + delete [] pBuffer; + + return ((DEV_OK == rc) || (DEV_WARNING == rc)); +} + +// ======================================================================= + +static BOOL ImplSalCreateInfoPrn( SalInfoPrinter* pPrinter, PDRIVDATA pDriverData, + HDC& rDC, HPS& rPS ) +{ + SalData* pSalData = GetSalData(); + + // create info context + DEVOPENSTRUC devOpenStruc; + memset( &devOpenStruc, 0, sizeof( devOpenStruc ) ); + devOpenStruc.pszLogAddress = (char*)(const char*)pPrinter->maPrinterData.maName; + devOpenStruc.pszDriverName = (char*)(const char*)pPrinter->maPrinterData.maDriverName; + devOpenStruc.pdriv = pDriverData; + devOpenStruc.pszDataType = "PM_Q_STD"; + + HDC hDC = DevOpenDC( pSalData->mhAB, OD_INFO, "*", + 4, (PDEVOPENDATA)&devOpenStruc, (HDC)NULL); + if ( !hDC ) + return FALSE; + + // create presentation space + SIZEL sizel; + sizel.cx = 0; + sizel.cy = 0; + HPS hPS = GpiCreatePS( pSalData->mhAB, hDC, &sizel, GPIA_ASSOC | GPIT_MICRO | PU_PELS ); + if ( !hPS ) + { + DevCloseDC( hDC ); + return FALSE; + } + + rDC = hDC; + rPS = hPS; + return TRUE; +} + +// ----------------------------------------------------------------------- + +static void ImplSalDestroyInfoPrn( SalInfoPrinter* pPrinter ) +{ + ImplSalDeInitGraphics( &(pPrinter->maPrinterData.mpGraphics->maGraphicsData) ); + GpiAssociate( pPrinter->maPrinterData.mhPS, 0 ); + GpiDestroyPS( pPrinter->maPrinterData.mhPS ); + DevCloseDC( pPrinter->maPrinterData.mhDC ); +} + +// ======================================================================= + +SalInfoPrinter* SalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, + ImplJobSetup* pSetupData ) +{ + ImplQueueSalSysData* pSysQueueData = (ImplQueueSalSysData*)(pQueueInfo->mpSysData); + SalInfoPrinter* pPrinter = new SalInfoPrinter; + pPrinter->maPrinterData.maPrinterName = pSysQueueData->maPrinterName; + pPrinter->maPrinterData.maName = pSysQueueData->maName; + pPrinter->maPrinterData.maDriverName = pSysQueueData->maDriverName; + pPrinter->maPrinterData.maDeviceName = pSysQueueData->maDeviceName; + + // Nur Setup-Daten uebernehmen, wenn Treiber und Laenge der Treiberdaten + // uebereinstimmt + PDRIVDATA pDriverData; + BOOL bUpdateDriverData; + if ( pSetupData->mpDriverData && pSysQueueData->mpDrivData && + (pSetupData->mnSystem == JOBSETUP_SYSTEM_OS2) && + (pSetupData->mnDriverDataLen == pSysQueueData->mpDrivData->cb) && + (strcmp( ((PDRIVDATA)pSetupData->mpDriverData)->szDeviceName, + pSysQueueData->mpDrivData->szDeviceName ) == 0) ) + { + pDriverData = PDRIVDATA( pSetupData->mpDriverData ); + bUpdateDriverData = FALSE; + } + else + { + pDriverData = pSysQueueData->mpDrivData; + bUpdateDriverData = TRUE; + } + if ( pDriverData ) + pPrinter->maPrinterData.maJobSetupDeviceName = pDriverData->szDeviceName; + + if ( !ImplSalCreateInfoPrn( pPrinter, pDriverData, + pPrinter->maPrinterData.mhDC, + pPrinter->maPrinterData.mhPS ) ) + { + delete pPrinter; + return NULL; + } + + // create graphics object for output + SalGraphics* pGraphics = new SalGraphics; + pGraphics->maGraphicsData.mhDC = pPrinter->maPrinterData.mhDC; + pGraphics->maGraphicsData.mhPS = pPrinter->maPrinterData.mhPS; + pGraphics->maGraphicsData.mhWnd = 0; + pGraphics->maGraphicsData.mbPrinter = TRUE; + pGraphics->maGraphicsData.mbVirDev = FALSE; + pGraphics->maGraphicsData.mbWindow = FALSE; + pGraphics->maGraphicsData.mbScreen = FALSE; + + ImplSalInitGraphics( &(pGraphics->maGraphicsData) ); + pPrinter->maPrinterData.mpGraphics = pGraphics; + + // check printer driver for DJP support + pPrinter->maPrinterData.mbDJPSupported = ImplIsDriverDJPEnabled( pPrinter->maPrinterData.mhDC ); + + if ( bUpdateDriverData ) + { + if ( pSetupData->mpDriverData ) + delete pSetupData->mpDriverData; + pSetupData->mpDriverData = new BYTE[pDriverData->cb]; + memcpy( pSetupData->mpDriverData, pDriverData, pDriverData->cb ); + pSetupData->mnDriverDataLen = pDriverData->cb; + } + + // retrieve current settings from printer driver and store them to system independend data! + if ( pPrinter->maPrinterData.mbDJPSupported ) + ImplGetCurrentSettings( pPrinter, pSetupData ); + pSetupData->mnSystem = JOBSETUP_SYSTEM_OS2; + + return pPrinter; +} + +// ----------------------------------------------------------------------- + +void SalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter ) +{ + delete pPrinter; +} + +// ======================================================================= + +SalInfoPrinter::SalInfoPrinter() +{ + maPrinterData.mhDC = 0; + maPrinterData.mhPS = 0; + maPrinterData.mpGraphics = NULL; + maPrinterData.mbGraphics = FALSE; + maPrinterData.mbDJPSupported = FALSE; + maPrinterData.mnFormCount = 0; + maPrinterData.mpFormArray = NULL; + maPrinterData.mnTrayCount = 0; + maPrinterData.mpTrayArray = NULL; +} + +// ----------------------------------------------------------------------- + +SalInfoPrinter::~SalInfoPrinter() +{ + if ( maPrinterData.mpGraphics ) + { + ImplSalDestroyInfoPrn( this ); + delete maPrinterData.mpGraphics; + } + + ImplFreeFormAndTrayList( this ); +} + +// ----------------------------------------------------------------------- + +SalGraphics* SalInfoPrinter::GetGraphics() +{ + if ( maPrinterData.mbGraphics ) + return NULL; + + if ( maPrinterData.mpGraphics ) + maPrinterData.mbGraphics = TRUE; + + return maPrinterData.mpGraphics; +} + +// ----------------------------------------------------------------------- + +void SalInfoPrinter::ReleaseGraphics( SalGraphics* ) +{ + maPrinterData.mbGraphics = FALSE; +} + +// ----------------------------------------------------------------------- + +BOOL SalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ) +{ + PDRIVDATA pDrivData = ImplPrnDrivData( pSetupData ); + if ( !pDrivData ) + return FALSE; + + APIRET rc = DevPostDeviceModes( GetSalData()->mhAB, pDrivData, + maPrinterData.maDriverName.GetStr(), + maPrinterData.maDeviceName.GetStr(), + maPrinterData.maPrinterName.GetStr(), + DPDM_POSTJOBPROP ); + if ( rc == DEV_OK ) + { + ImplUpdateSetupData( pDrivData, pSetupData ); + + // update DC and PS + HDC hDC; + HPS hPS; + if ( !ImplSalCreateInfoPrn( this, (PDRIVDATA)(pSetupData->mpDriverData), hDC, hPS ) ) + return FALSE; + + // Alten Printer DC/PS zerstoeren + ImplSalDestroyInfoPrn( this ); + + // Neue Daten setzen und initialisieren + maPrinterData.mhDC = hDC; + maPrinterData.mhPS = hPS; + maPrinterData.mpGraphics->maGraphicsData.mhDC = maPrinterData.mhDC; + maPrinterData.mpGraphics->maGraphicsData.mhPS = maPrinterData.mhPS; + ImplSalInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); + + // retrieve current settings from printer driver and store them to system independend data! + ImplFreeFormAndTrayList( this ); + if ( maPrinterData.mbDJPSupported ) + ImplGetCurrentSettings( this, pSetupData ); + + return TRUE; + } + else + { + ImplFreePrnMemory( pDrivData ); + return FALSE; + } +} + +// ----------------------------------------------------------------------- + +BOOL SalInfoPrinter::SetPrinterData( ImplJobSetup* pSetupData ) +{ + // Wir koennen nur Treiberdaten von OS2 setzen + if ( pSetupData->mnSystem != JOBSETUP_SYSTEM_OS2 ) + return FALSE; + + PDRIVDATA pNewDrivData = (PDRIVDATA)(pSetupData->mpDriverData); + if ( !pNewDrivData ) + return FALSE; + + // Testen, ob Printerdaten fuer den gleichen Printer uebergeben werden, + // da einige Treiber zu Abstuerzen neigen, wenn Daten von einem anderen + // Printer gesetzt werden + if ( strcmp( maPrinterData.maJobSetupDeviceName, pNewDrivData->szDeviceName ) != 0 ) + return FALSE; + + // update DC and PS + HDC hDC; + HPS hPS; + if ( !ImplSalCreateInfoPrn( this, pNewDrivData, hDC, hPS ) ) + return FALSE; + + // Alten Printer DC/PS zerstoeren + ImplSalDestroyInfoPrn( this ); + + // Neue Daten setzen und initialisieren + maPrinterData.mhDC = hDC; + maPrinterData.mhPS = hPS; + maPrinterData.mpGraphics->maGraphicsData.mhDC = maPrinterData.mhDC; + maPrinterData.mpGraphics->maGraphicsData.mhPS = maPrinterData.mhPS; + ImplSalInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); + + // retrieve current settings from printer driver and store them to system independend data! + ImplFreeFormAndTrayList( this ); + if ( maPrinterData.mbDJPSupported ) + ImplGetCurrentSettings( this, pSetupData ); + + return TRUE; +} + +// ----------------------------------------------------------------------- + +BOOL SalInfoPrinter::SetData( ULONG nFlags, ImplJobSetup* pSetupData ) +{ + // needs DJP support + if ( !maPrinterData.mbDJPSupported ) + return FALSE; + + PDRIVDATA pDrivData = ImplPrnDrivData( pSetupData ); + + if ( !pDrivData ) + return FALSE; + + BOOL bOK = FALSE; + + // set orientation + if ( nFlags & SAL_JOBSET_ORIENTATION ) + { + if ( ImplSetOrientation( maPrinterData.mhDC, pDrivData, pSetupData->meOrientation ) ) + bOK = TRUE; + } + + // set paper size + if ( nFlags & SAL_JOBSET_PAPERSIZE ) + { + // Papierformat ermitteln + DJPT_PAPERSIZE nOS2PaperFormat; + switch ( pSetupData->mePaperFormat ) + { + case PAPER_A3: + nOS2PaperFormat = DJP_PSI_A3; + break; + + case PAPER_A4: + nOS2PaperFormat = DJP_PSI_A4; + break; + + case PAPER_A5: + nOS2PaperFormat = DJP_PSI_A5; + break; + + case PAPER_B4: + nOS2PaperFormat = DJP_PSI_B4; + break; + + case PAPER_B5: + nOS2PaperFormat = DJP_PSI_B5; + break; + + case PAPER_LETTER: + nOS2PaperFormat = DJP_PSI_LETTER; + break; + + case PAPER_LEGAL: + nOS2PaperFormat = DJP_PSI_LEGAL; + break; + + case PAPER_TABLOID: + nOS2PaperFormat = DJP_PSI_TABLOID; + break; + + default: + { + nOS2PaperFormat = DJP_PSI_NONE; + // OS2 rechnet in Millimetern + long nPaperWidth = pSetupData->mnPaperWidth / 100; + long nPaperHeight = pSetupData->mnPaperHeight / 100; + // Ansonsten ueber die Papiergroesse suchen + for( int i = 0; i < maPrinterData.mnFormCount; i++ ) + { + ImplFormInfo* pFormInfo = maPrinterData.mpFormArray[i]; + if ( ImplPaperSizeEqual( nPaperWidth, nPaperHeight, + pFormInfo->mnPaperWidth, pFormInfo->mnPaperHeight ) ) + { + nOS2PaperFormat = pFormInfo->mnId; + break; + } + } + } + break; + } + + if ( nOS2PaperFormat != DJP_PSI_NONE ) + { + if ( ImplSetPaperSize( maPrinterData.mhDC, pDrivData, nOS2PaperFormat ) ) + bOK = TRUE; + } + } + + // set paper tray + if ( (nFlags & SAL_JOBSET_PAPERBIN) && (pSetupData->mnPaperBin < maPrinterData.mnTrayCount) ) + { + if ( ImplSetPaperBin( maPrinterData.mhDC, pDrivData, + maPrinterData.mpTrayArray[pSetupData->mnPaperBin] ) ) + bOK = TRUE; + } + + if ( bOK ) + { + ImplUpdateSetupData( pDrivData, pSetupData ); + + // query current driver settings + ImplFreeFormAndTrayList( this ); + if ( ImplGetCurrentSettings( this, pSetupData ) ) + { + // update DC and PS + HDC hDC; + HPS hPS; + if ( ImplSalCreateInfoPrn( this, (PDRIVDATA)(pSetupData->mpDriverData), hDC, hPS ) ) + { + // Alten Printer DC/PS zerstoeren + ImplSalDestroyInfoPrn( this ); + + // Neue Daten setzen und initialisieren + maPrinterData.mhDC = hDC; + maPrinterData.mhPS = hPS; + maPrinterData.mpGraphics->maGraphicsData.mhDC = maPrinterData.mhDC; + maPrinterData.mpGraphics->maGraphicsData.mhPS = maPrinterData.mhPS; + ImplSalInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); + } + else + bOK = FALSE; + } + else + bOK = FALSE; + } + + return bOK; +} + +// ----------------------------------------------------------------------- + +ULONG SalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup ) +{ + if ( !maPrinterData.mbDJPSupported ) + return 1; + + // init paperbinlist if empty + if ( !maPrinterData.mnTrayCount ) + ImplGetFormAndTrayList( this, pJobSetup ); + + // Wir haben immer einen PaperTray und wenn, das eben einen ohne + // Namen + if ( !maPrinterData.mnTrayCount ) + return 1; + else + return maPrinterData.mnTrayCount; +} + +// ----------------------------------------------------------------------- + +XubString SalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, + ULONG nPaperBin ) +{ + XubString aPaperBinName; + + if ( maPrinterData.mbDJPSupported ) + { + // init paperbinlist if empty + if ( !maPrinterData.mnTrayCount ) + ImplGetFormAndTrayList( this, pJobSetup ); + + if ( nPaperBin < maPrinterData.mnTrayCount ) + aPaperBinName = maPrinterData.mpTrayArray[nPaperBin]->maDisplayName; + } + + return aPaperBinName; +} + +// ----------------------------------------------------------------------- + +ULONG SalInfoPrinter::GetCapabilities( const ImplJobSetup*, USHORT nType ) +{ + switch ( nType ) + { + case PRINTER_CAPABILITIES_SUPPORTDIALOG: + return TRUE; + case PRINTER_CAPABILITIES_COPIES: + return 0xFFFF; + case PRINTER_CAPABILITIES_COLLATECOPIES: + return 0; + case PRINTER_CAPABILITIES_SETORIENTATION: + case PRINTER_CAPABILITIES_SETPAPERBIN: + case PRINTER_CAPABILITIES_SETPAPERSIZE: + case PRINTER_CAPABILITIES_SETPAPER: + return maPrinterData.mbDJPSupported; + } + + return 0; +} + +// ----------------------------------------------------------------------- + +void SalInfoPrinter::GetPageInfo( const ImplJobSetup*, + long& rOutWidth, long& rOutHeight, + long& rPageOffX, long& rPageOffY, + long& rPageWidth, long& rPageHeight ) +{ + HDC hDC = maPrinterData.mhDC; + + // search current form + HCINFO aInfo; + int nForms = DevQueryHardcopyCaps( hDC, 0, 0, &aInfo ); + for( int i = 0; i < nForms; i++ ) + { + if ( DevQueryHardcopyCaps( hDC, i, 1, &aInfo ) >= 0 ) + { + if ( aInfo.flAttributes & HCAPS_CURRENT ) + { + // query resolution + long nXResolution; + long nYResolution; + DevQueryCaps( hDC, CAPS_HORIZONTAL_RESOLUTION, 1, &nXResolution ); + DevQueryCaps( hDC, CAPS_VERTICAL_RESOLUTION, 1, &nYResolution ); + rPageOffX = aInfo.xLeftClip * nXResolution / 1000; + rPageOffY = (aInfo.cy-aInfo.yTopClip) * nYResolution / 1000; + rPageWidth = aInfo.cx * nXResolution / 1000; + rPageHeight = aInfo.cy * nYResolution / 1000; + rOutWidth = aInfo.xPels; + rOutHeight = aInfo.yPels; + return; + } + } + } + + // use device caps if no form selected/found + long lCapsWidth = 0; + long lCapsHeight = 0; + DevQueryCaps( hDC, CAPS_WIDTH, 1L, &lCapsWidth ); + DevQueryCaps( hDC, CAPS_HEIGHT, 1L, &lCapsHeight ); + rPageOffX = 0; + rPageOffY = 0; + rOutWidth = lCapsWidth; + rOutHeight = lCapsHeight; + rPageWidth = rOutWidth; + rPageHeight = rOutHeight; +} + +// ======================================================================= + +static BOOL ImplIsDriverPrintDJPEnabled( HDC hDC ) +{ +#ifdef NO_DJP + return FALSE; +#else + // Ueber OS2-Ini kann DJP disablte werden + if ( !PrfQueryProfileInt( HINI_PROFILE, SAL_PROFILE_APPNAME, SAL_PROFILE_PRINTDJP, 1 ) ) + return FALSE; + + // Testen, ob DJP-Interface am Drucker vorhanden + LONG lQuery; + APIRET rc; + + lQuery = DEVESC_QUERYSIZE; + rc = DevEscape( hDC, + DEVESC_QUERYESCSUPPORT, + sizeof( lQuery ), + (PBYTE)&lQuery, + 0, + (PBYTE)NULL ); + if ( DEV_OK != rc ) + return FALSE; + + return TRUE; +#endif +} + +// ======================================================================= + +SalPrinter* SalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter ) +{ + SalPrinter* pPrinter = new SalPrinter; + pPrinter->maPrinterData.mpInfoPrinter = pInfoPrinter; + return pPrinter; +} + +// ----------------------------------------------------------------------- + +void SalInstance::DestroyPrinter( SalPrinter* pPrinter ) +{ + delete pPrinter; +} + +// ======================================================================= + +SalPrinter::SalPrinter() +{ + maPrinterData.mhDC = 0; + maPrinterData.mhPS = 0; + maPrinterData.mpGraphics = NULL; + maPrinterData.mbAbort = FALSE; + maPrinterData.mbPrintDJPSupported = FALSE; +} + +// ----------------------------------------------------------------------- + +SalPrinter::~SalPrinter() +{ +} + +// ----------------------------------------------------------------------- + +BOOL SalPrinter::StartJob( const XubString* pFileName, + const XubString& rJobName, + const XubString& rAppName, + ULONG nCopies, BOOL bCollate, + ImplJobSetup* pSetupData ) +{ + DEVOPENSTRUC aDevOpenStruc; + LONG lType; + APIRET rc; + + // prepare queue information + memset( &aDevOpenStruc, 0, sizeof( aDevOpenStruc ) ); + aDevOpenStruc.pszDriverName = (PSZ)(maPrinterData.mpInfoPrinter->maPrinterData.maDriverName.GetStr()); + + // print into file? + if ( pFileName ) + { + aDevOpenStruc.pszLogAddress = (PSZ)pFileName->GetStr(); + aDevOpenStruc.pszDataType = "PM_Q_RAW"; + lType = OD_DIRECT; + } + else + { + aDevOpenStruc.pszLogAddress = (PSZ)(maPrinterData.mpInfoPrinter->maPrinterData.maName.GetStr()); + if ( PrfQueryProfileInt( HINI_PROFILE, SAL_PROFILE_APPNAME, SAL_PROFILE_PRINTRAW, 0 ) ) + aDevOpenStruc.pszDataType = "PM_Q_RAW"; + else + aDevOpenStruc.pszDataType = "PM_Q_STD"; + lType = OD_QUEUED; + } + + // Set comment (AppName nur bis zum 1. Space-Zeichen nehmen) + const xub_Unicode* pComment = rAppName; + USHORT nCommentLen = 0; + memset( maPrinterData.maCommentBuf, 0, sizeof( maPrinterData.maCommentBuf ) ); + while ( (nCommentLen < 32) && + (((*pComment >= 'a') && (*pComment <= 'z')) || + ((*pComment >= 'A') && (*pComment <= 'Z')) || + ((*pComment >= '0') && (*pComment <= '9')) || + (*pComment == '-'))) + { + maPrinterData.maCommentBuf[nCommentLen] = (char)(*pComment); + nCommentLen++; + pComment++; + } + aDevOpenStruc.pszComment = (PSZ)maPrinterData.maCommentBuf; + + // Kopien + if ( nCopies > 1 ) + { + // OS2 kann maximal 999 Kopien + if ( nCopies > 999 ) + nCopies = 999; + String aCopyStr( nCopies ); + strcpy( maPrinterData.maCopyBuf, "COP=" ); + strcat( maPrinterData.maCopyBuf+4, aCopyStr.GetStr() ); + aDevOpenStruc.pszQueueProcParams = (PSZ)maPrinterData.maCopyBuf; + } + + // open device context + SalData* pSalData = GetSalData(); + HAB hAB = pSalData->mhAB; + aDevOpenStruc.pdriv = (PDRIVDATA)pSetupData->mpDriverData; + maPrinterData.mhDC = DevOpenDC( hAB, + lType, + "*", + 7, + (PDEVOPENDATA)&aDevOpenStruc, + 0 ); + if ( maPrinterData.mhDC == 0 ) + { + ERRORID nLastError = WinGetLastError( hAB ); + if ( (nLastError & 0xFFFF) == PMERR_SPL_PRINT_ABORT ) + maPrinterData.mnError = SAL_PRINTER_ERROR_ABORT; + else + maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; + return FALSE; + } + + // open presentation space + SIZEL sizel; + sizel.cx = 0; + sizel.cy = 0; + maPrinterData.mhPS = GpiCreatePS( hAB, maPrinterData.mhDC, &sizel, GPIA_ASSOC | GPIT_MICRO | PU_PELS ); + if ( !maPrinterData.mhPS ) + { + DevCloseDC( maPrinterData.mhDC ); + maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; + return NULL; + } + + // Can we print with DJP + maPrinterData.mbPrintDJPSupported = ImplIsDriverPrintDJPEnabled( maPrinterData.mhDC ); + + // JobName ermitteln und Job starten + PSZ pszJobName = NULL; + int nJobNameLen = 0; + if ( rJobName.Len() > 0 ) + { + pszJobName = (PSZ)rJobName.GetStr(); + nJobNameLen = rJobName.Len(); + } + rc = DevEscape( maPrinterData.mhDC, + DEVESC_STARTDOC, + nJobNameLen, pszJobName, + 0, NULL ); + + if ( rc != DEV_OK ) + { + ERRORID nLastError = WinGetLastError( hAB ); + if ( (nLastError & 0xFFFF) == PMERR_SPL_PRINT_ABORT ) + maPrinterData.mnError = SAL_PRINTER_ERROR_ABORT; + else + maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; + GpiAssociate( maPrinterData.mhPS, NULL ); + GpiDestroyPS( maPrinterData.mhPS ); + DevCloseDC( maPrinterData.mhDC ); + return FALSE; + } + + // init for first page + maPrinterData.mbFirstPage = TRUE; + maPrinterData.mnError = 0; + + return TRUE; +} + +// ----------------------------------------------------------------------- + +BOOL SalPrinter::EndJob() +{ + APIRET rc; + rc = DevEscape( maPrinterData.mhDC, + DEVESC_ENDDOC, + 0, NULL, + 0, NULL); + + // destroy presentation space and device context + GpiAssociate( maPrinterData.mhPS, NULL ); + GpiDestroyPS( maPrinterData.mhPS ); + DevCloseDC( maPrinterData.mhDC ); + return TRUE; +} + +// ----------------------------------------------------------------------- + +BOOL SalPrinter::AbortJob() +{ + APIRET rc; + + rc = DevEscape( maPrinterData.mhDC, + DEVESC_ABORTDOC, + 0, NULL, + 0, NULL ); + + // destroy SalGraphics + if ( maPrinterData.mpGraphics ) + { + ImplSalDeInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); + delete maPrinterData.mpGraphics; + maPrinterData.mpGraphics = NULL; + } + + // destroy presentation space and device context + GpiAssociate( maPrinterData.mhPS, NULL ); + GpiDestroyPS( maPrinterData.mhPS ); + DevCloseDC( maPrinterData.mhDC ); + return TRUE; +} + +// ----------------------------------------------------------------------- + +SalGraphics* SalPrinter::StartPage( ImplJobSetup* pSetupData, BOOL bNewJobSetup ) +{ + APIRET rc; + + if ( maPrinterData.mbFirstPage ) + maPrinterData.mbFirstPage = FALSE; + else + { + PBYTE pJobData; + LONG nJobDataSize; + LONG nEscape; + if ( maPrinterData.mbPrintDJPSupported && bNewJobSetup ) + { + nEscape = DEVESC_NEWFRAME_WPROP; + nJobDataSize = ((PDRIVDATA)(pSetupData->mpDriverData))->cb; + pJobData = (PBYTE)(pSetupData->mpDriverData); + } + else + { + nEscape = DEVESC_NEWFRAME; + nJobDataSize = 0; + pJobData = NULL; + } + rc = DevEscape( maPrinterData.mhDC, + nEscape, + 0, NULL, + &nJobDataSize, pJobData ); + + if ( rc != DEV_OK ) + { + DevEscape( maPrinterData.mhDC, DEVESC_ENDDOC, 0, NULL, 0, NULL); + GpiAssociate( maPrinterData.mhPS, NULL ); + GpiDestroyPS( maPrinterData.mhPS ); + DevCloseDC( maPrinterData.mhDC ); + maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; + return NULL; + } + } + + // create SalGraphics with copy of hPS + SalGraphics* pGraphics = new SalGraphics; + pGraphics->maGraphicsData.mhDC = maPrinterData.mhDC; + pGraphics->maGraphicsData.mhPS = maPrinterData.mhPS; + pGraphics->maGraphicsData.mhWnd = 0; + pGraphics->maGraphicsData.mbPrinter = TRUE; + pGraphics->maGraphicsData.mbVirDev = FALSE; + pGraphics->maGraphicsData.mbWindow = FALSE; + pGraphics->maGraphicsData.mbScreen = FALSE; + pGraphics->maGraphicsData.mnHeight = 0; + // search current form for actual page height + HCINFO aInfo; + int nForms = DevQueryHardcopyCaps( maPrinterData.mhDC, 0, 0, &aInfo ); + for( int i = 0; i < nForms; i++ ) + { + if ( DevQueryHardcopyCaps( maPrinterData.mhDC, i, 1, &aInfo ) >= 0 ) + { + if ( aInfo.flAttributes & HCAPS_CURRENT ) + pGraphics->maGraphicsData.mnHeight = aInfo.yPels; + } + } + // use device caps if no form selected/found + if ( !pGraphics->maGraphicsData.mnHeight ) + DevQueryCaps( maPrinterData.mhDC, CAPS_HEIGHT, 1L, &pGraphics->maGraphicsData.mnHeight ); + + ImplSalInitGraphics( &(pGraphics->maGraphicsData) ); + maPrinterData.mpGraphics = pGraphics; + + return pGraphics; +} + +// ----------------------------------------------------------------------- + +BOOL SalPrinter::EndPage() +{ + if ( maPrinterData.mpGraphics ) + { + // destroy SalGraphics + ImplSalDeInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); + delete maPrinterData.mpGraphics; + maPrinterData.mpGraphics = NULL; + } + + return TRUE; +} + +// ----------------------------------------------------------------------- + +ULONG SalPrinter::GetErrorCode() +{ + return maPrinterData.mnError; +} diff --git a/vcl/os2/source/gdi/salvd.cxx b/vcl/os2/source/gdi/salvd.cxx new file mode 100644 index 000000000000..9014913f7415 --- /dev/null +++ b/vcl/os2/source/gdi/salvd.cxx @@ -0,0 +1,230 @@ +/************************************************************************* + * + * $RCSfile: salvd.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#include + +#define _SV_SALVD_CXX + +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_HXX +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALVD_HXX +#include +#endif + +// ======================================================================= + +HBITMAP ImplCreateVirDevBitmap( HDC hDC, HPS hPS, long nDX, long nDY, + USHORT nBitCount ) +{ + if( !nBitCount ) + { + LONG nDevBitCount; + DevQueryCaps( hDC, CAPS_COLOR_BITCOUNT, 1, &nDevBitCount ); + nBitCount = nDevBitCount; + } + + LONG nPlanes; + DevQueryCaps( hDC, CAPS_COLOR_PLANES, 1, &nPlanes ); + + // entsprechende Bitmap zum OutputDevice erzeugen + HBITMAP hBitmap; + BITMAPINFOHEADER2 aBitmapInfo; + memset( &aBitmapInfo, 0, sizeof( BITMAPINFOHEADER2 ) ); + aBitmapInfo.cbFix = sizeof( BITMAPINFOHEADER2 ); + aBitmapInfo.cx = nDX; + aBitmapInfo.cy = nDY; + aBitmapInfo.cPlanes = nPlanes; + aBitmapInfo.cBitCount = (nBitCount < 4) ? 4 : nBitCount; + hBitmap = GpiCreateBitmap( hPS, &aBitmapInfo, 0, NULL, NULL ); + return hBitmap; +} + +// ----------------------------------------------------------------------- + +SalVirtualDevice* SalInstance::CreateVirtualDevice( SalGraphics* pGraphics, + long nDX, long nDY, + USHORT nBitCount ) +{ + HAB hAB = GetSalData()->mhAB; + SIZEL size; + + // create device context (at this time allways display compatible) + DEVOPENSTRUC aDevOpenStruc = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + HDC hDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5, (PDEVOPENDATA)&aDevOpenStruc, 0 ); + if ( !hDC ) + return NULL; + + // create presentation space + size.cx = nDX; + size.cy = nDY; + HPS hPS = GpiCreatePS( hAB, hDC, &size, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); + if ( !hPS ) + { + DevCloseDC( hDC ); + return NULL; + } + + // create bitmap for the virtual device + HBITMAP hBmp = ImplCreateVirDevBitmap( hDC, hPS, nDX, nDY, nBitCount ); + if ( !hBmp ) + { + GpiDestroyPS( hPS ); + DevCloseDC( hDC ); + return NULL; + } + + // init data + SalVirtualDevice* pVDev = new SalVirtualDevice; + SalGraphics* pVirGraphics = new SalGraphics; + + pVirGraphics->maGraphicsData.mhDC = hDC; + pVirGraphics->maGraphicsData.mhPS = hPS; + pVirGraphics->maGraphicsData.mhWnd = 0; + pVirGraphics->maGraphicsData.mnHeight = nDY; + pVirGraphics->maGraphicsData.mbPrinter = FALSE; + pVirGraphics->maGraphicsData.mbVirDev = TRUE; + pVirGraphics->maGraphicsData.mbWindow = FALSE; + pVirGraphics->maGraphicsData.mbScreen = pGraphics->maGraphicsData.mbScreen; + ImplSalInitGraphics( &(pVirGraphics->maGraphicsData) ); + + pVDev->maVirDevData.mhDC = hDC; + pVDev->maVirDevData.mhPS = hPS; + pVDev->maVirDevData.mhBmp = hBmp; + pVDev->maVirDevData.mhDefBmp = GpiSetBitmap( hPS, hBmp ); + pVDev->maVirDevData.mpGraphics = pVirGraphics; + pVDev->maVirDevData.mnBitCount = nBitCount; + pVDev->maVirDevData.mbGraphics = FALSE; + return pVDev; +} + +// ----------------------------------------------------------------------- + +void SalInstance::DestroyVirtualDevice( SalVirtualDevice* pDevice ) +{ + delete pDevice; +} + +// ======================================================================= + +SalVirtualDevice::SalVirtualDevice() +{ +} + +// ----------------------------------------------------------------------- + +SalVirtualDevice::~SalVirtualDevice() +{ + ImplSalDeInitGraphics( &(maVirDevData.mpGraphics->maGraphicsData) ); + + GpiSetBitmap( maVirDevData.mpGraphics->maGraphicsData.mhPS, maVirDevData.mhDefBmp ); + GpiDeleteBitmap( maVirDevData.mhBmp ); + GpiDestroyPS( maVirDevData.mpGraphics->maGraphicsData.mhPS ); + DevCloseDC( maVirDevData.mpGraphics->maGraphicsData.mhDC ); + delete maVirDevData.mpGraphics; +} + +// ----------------------------------------------------------------------- + +SalGraphics* SalVirtualDevice::GetGraphics() +{ + if ( maVirDevData.mbGraphics ) + return NULL; + + if ( maVirDevData.mpGraphics ) + maVirDevData.mbGraphics = TRUE; + + return maVirDevData.mpGraphics; +} + +// ----------------------------------------------------------------------- + +void SalVirtualDevice::ReleaseGraphics( SalGraphics* ) +{ + maVirDevData.mbGraphics = FALSE; +} + +// ----------------------------------------------------------------------- + +BOOL SalVirtualDevice::SetSize( long nDX, long nDY ) +{ + HBITMAP hNewBmp = ImplCreateVirDevBitmap( maVirDevData.mhDC, + maVirDevData.mhPS, nDX, nDY, + maVirDevData.mnBitCount ); + if ( hNewBmp ) + { + GpiSetBitmap( maVirDevData.mhPS, hNewBmp ); + GpiDeleteBitmap( maVirDevData.mhBmp ); + maVirDevData.mhBmp = hNewBmp; + maVirDevData.mpGraphics->maGraphicsData.mnHeight = nDY; + return TRUE; + } + else + return FALSE; +} diff --git a/vcl/os2/source/src/makefile.mk b/vcl/os2/source/src/makefile.mk new file mode 100644 index 000000000000..f9c8e73f40af --- /dev/null +++ b/vcl/os2/source/src/makefile.mk @@ -0,0 +1,147 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=SV +TARGET=salsrc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +RCDEPN= nullptr.ptr \ + help.ptr \ + cross.ptr \ + move.ptr \ + hsplit.ptr \ + vsplit.ptr \ + hsizebar.ptr \ + vsizebar.ptr \ + hand.ptr \ + refhand.ptr \ + pen.ptr \ + magnify.ptr \ + fill.ptr \ + rotate.ptr \ + hshear.ptr \ + vshear.ptr \ + mirror.ptr \ + crook.ptr \ + crop.ptr \ + movept.ptr \ + movebw.ptr \ + movedata.ptr \ + copydata.ptr \ + linkdata.ptr \ + movedlnk.ptr \ + copydlnk.ptr \ + movef.ptr \ + copyf.ptr \ + linkf.ptr \ + moveflnk.ptr \ + copyflnk.ptr \ + movef2.ptr \ + copyf2.ptr \ + dline.ptr \ + drect.ptr \ + dpolygon.ptr \ + dbezier.ptr \ + darc.ptr \ + dpie.ptr \ + dcirccut.ptr \ + dellipse.ptr \ + dfree.ptr \ + dconnect.ptr \ + dtext.ptr \ + dcapt.ptr \ + chart.ptr \ + detectiv.ptr \ + pivotcol.ptr \ + pivotrow.ptr \ + pivotfld.ptr \ + chain.ptr \ + chainnot.ptr \ + timemove.ptr \ + timesize.ptr \ + asn.ptr \ + ass.ptr \ + asw.ptr \ + ase.ptr \ + asnw.ptr \ + asne.ptr \ + assw.ptr \ + asse.ptr \ + asns.ptr \ + aswe.ptr \ + asnswe.ptr \ + sd.ico + +RCFILES= salsrc.rc + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/vcl/os2/source/src/salsrc.rc b/vcl/os2/source/src/salsrc.rc new file mode 100644 index 000000000000..26b936bd4e44 --- /dev/null +++ b/vcl/os2/source/src/salsrc.rc @@ -0,0 +1,134 @@ +/************************************************************************* +* +* $RCSfile: salsrc.rc,v $ +* +* $Revision: 1.1.1.1 $ +* +* last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ +* +* The Contents of this file are made available subject to the terms of +* either of the following licenses +* +* - GNU Lesser General Public License Version 2.1 +* - Sun Industry Standards Source License Version 1.1 +* +* Sun Microsystems Inc., October, 2000 +* +* GNU Lesser General Public License Version 2.1 +* ============================================= +* Copyright 2000 by Sun Microsystems, Inc. +* 901 San Antonio Road, Palo Alto, CA 94303, USA +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1, as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +* +* Sun Industry Standards Source License Version 1.1 +* ================================================= +* The contents of this file are subject to the Sun Industry Standards +* Source License Version 1.1 (the "License"); You may not use this file +* except in compliance with the License. You may obtain a copy of the +* License at http://www.openoffice.org/license.html. +* +* Software provided under this License is provided on an "AS IS" basis, +* WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +* WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +* See the License for the specific provisions governing your rights and +* obligations concerning the Software. +* +* The Initial Developer of the Original Code is: Sun Microsystems, Inc.. +* +* Copyright: 2000 by Sun Microsystems, Inc. +* +* All Rights Reserved. +* +* Contributor(s): _______________________________________ +* +* +* +**************************************************************************/ + +#ifndef _SV_SALIDS_HRC +#include +#endif + +POINTER SAL_RESID_POINTER_NULL NULLPTR.PTR +POINTER SAL_RESID_POINTER_HELP HELP.PTR +POINTER SAL_RESID_POINTER_CROSS CROSS.PTR +POINTER SAL_RESID_POINTER_MOVE MOVE.PTR +POINTER SAL_RESID_POINTER_HSPLIT HSPLIT.PTR +POINTER SAL_RESID_POINTER_VSPLIT VSPLIT.PTR +POINTER SAL_RESID_POINTER_HSIZEBAR HSIZEBAR.PTR +POINTER SAL_RESID_POINTER_VSIZEBAR VSIZEBAR.PTR +POINTER SAL_RESID_POINTER_HAND HAND.PTR +POINTER SAL_RESID_POINTER_REFHAND REFHAND.PTR +POINTER SAL_RESID_POINTER_PEN PEN.PTR +POINTER SAL_RESID_POINTER_MAGNIFY MAGNIFY.PTR +POINTER SAL_RESID_POINTER_FILL FILL.PTR +POINTER SAL_RESID_POINTER_ROTATE ROTATE.PTR +POINTER SAL_RESID_POINTER_HSHEAR HSHEAR.PTR +POINTER SAL_RESID_POINTER_VSHEAR VSHEAR.PTR +POINTER SAL_RESID_POINTER_MIRROR MIRROR.PTR +POINTER SAL_RESID_POINTER_CROOK CROOK.PTR +POINTER SAL_RESID_POINTER_CROP CROP.PTR +POINTER SAL_RESID_POINTER_MOVEPOINT MOVEPT.PTR +POINTER SAL_RESID_POINTER_MOVEBEZIERWEIGHT MOVEBW.PTR +POINTER SAL_RESID_POINTER_MOVEDATA MOVEDATA.PTR +POINTER SAL_RESID_POINTER_COPYDATA COPYDATA.PTR +POINTER SAL_RESID_POINTER_LINKDATA LINKDATA.PTR +POINTER SAL_RESID_POINTER_MOVEDATALINK MOVEDLNK.PTR +POINTER SAL_RESID_POINTER_COPYDATALINK COPYDLNK.PTR +POINTER SAL_RESID_POINTER_MOVEFILE MOVEF.PTR +POINTER SAL_RESID_POINTER_COPYFILE COPYF.PTR +POINTER SAL_RESID_POINTER_LINKFILE LINKF.PTR +POINTER SAL_RESID_POINTER_MOVEFILELINK MOVEFLNK.PTR +POINTER SAL_RESID_POINTER_COPYFILELINK COPYFLNK.PTR +POINTER SAL_RESID_POINTER_MOVEFILES MOVEF2.PTR +POINTER SAL_RESID_POINTER_COPYFILES COPYF2.PTR +POINTER SAL_RESID_POINTER_DRAW_LINE DLINE.PTR +POINTER SAL_RESID_POINTER_DRAW_RECT DRECT.PTR +POINTER SAL_RESID_POINTER_DRAW_POLYGON DPOLYGON.PTR +POINTER SAL_RESID_POINTER_DRAW_BEZIER DBEZIER.PTR +POINTER SAL_RESID_POINTER_DRAW_ARC DARC.PTR +POINTER SAL_RESID_POINTER_DRAW_PIE DPIE.PTR +POINTER SAL_RESID_POINTER_DRAW_CIRCLECUT DCIRCCUT.PTR +POINTER SAL_RESID_POINTER_DRAW_ELLIPSE DELLIPSE.PTR +POINTER SAL_RESID_POINTER_DRAW_FREEHAND DFREE.PTR +POINTER SAL_RESID_POINTER_DRAW_CONNECT DCONNECT.PTR +POINTER SAL_RESID_POINTER_DRAW_TEXT DTEXT.PTR +POINTER SAL_RESID_POINTER_DRAW_CAPTION DCAPT.PTR +POINTER SAL_RESID_POINTER_CHART CHART.PTR +POINTER SAL_RESID_POINTER_DETECTIVE DETECTIV.PTR +POINTER SAL_RESID_POINTER_PIVOT_COL PIVOTCOL.PTR +POINTER SAL_RESID_POINTER_PIVOT_ROW PIVOTROW.PTR +POINTER SAL_RESID_POINTER_PIVOT_FIELD PIVOTFLD.PTR +POINTER SAL_RESID_POINTER_CHAIN CHAIN.PTR +POINTER SAL_RESID_POINTER_CHAIN_NOTALLOWED CHAINNOT.PTR +POINTER SAL_RESID_POINTER_TIMEEVENT_MOVE TIMEMOVE.PTR +POINTER SAL_RESID_POINTER_TIMEEVENT_SIZE TIMESIZE.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_N ASN.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_S ASS.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_W ASW.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_E ASE.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_NW ASNW.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_NE ASNE.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_SW ASSW.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_SE ASSE.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_NS ASNS.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_WE ASWE.PTR +POINTER SAL_RESID_POINTER_AUTOSCROLL_NSWE ASNSWE.PTR + +ICON SAL_RESID_ICON_SD SD.ICO + diff --git a/vcl/os2/source/window/makefile b/vcl/os2/source/window/makefile new file mode 100644 index 000000000000..4b811da766cd --- /dev/null +++ b/vcl/os2/source/window/makefile @@ -0,0 +1,40 @@ +#************************************************************************* +#* +#* $Workfile: makefile $ +#* +#* Ersterstellung TH 01.04.97 +#* Letzte Aenderung $Author: hr $ $Date: 2000-09-18 17:05:35 $ +#* $Revision: 1.1.1.1 $ +#* +#* $Logfile: T:/vcl/os2/source/window/makefile.__v $ +#* +#* Copyright (c) 1990 - 1998, STAR DIVISION +#* +#************************************************************************* + +PRJ=..\..\.. + +PRJNAME=SV +TARGET=salwin + +# --- Settings ----------------------------------------------------- + +!INCLUDE +!INCLUDE +!INCLUDE + +!IF "$(COM)"=="ICC" +ENVCFLAGS=$(ENVCFLAGS) -D_STD_NO_NAMESPACE -D_VOS_NO_NAMESPACE -D_UNO_NO_NAMESPACE +!ENDIF + +# --- Files -------------------------------------------------------- + +CXXFILES= salframe.cxx \ + salobj.cxx + +SLOFILES= $(SLO)\salframe.obj \ + $(SLO)\salobj.obj + +# --- Targets ------------------------------------------------------ + +!INCLUDE diff --git a/vcl/os2/source/window/makefile.mk b/vcl/os2/source/window/makefile.mk new file mode 100644 index 000000000000..71f60055e8ef --- /dev/null +++ b/vcl/os2/source/window/makefile.mk @@ -0,0 +1,84 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 17:05:35 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=SV +TARGET=salwin + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +CXXFILES= salframe.cxx \ + salobj.cxx + +SLOFILES= $(SLO)$/salframe.obj \ + $(SLO)$/salobj.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/vcl/os2/source/window/salframe.cxx b/vcl/os2/source/window/salframe.cxx new file mode 100644 index 000000000000..f17d3c5ecd8c --- /dev/null +++ b/vcl/os2/source/window/salframe.cxx @@ -0,0 +1,2762 @@ +/************************************************************************* + * + * $RCSfile: salframe.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __ZTC__ +#define _Seg16 _far16 +#define _Far16 _far16 +#define _System _syscall +#define _Pascal _pascal +#define _Cdecl _cdecl +#endif + +#define BOOL PM_BOOL +#define BYTE PM_BYTE +#define USHORT PM_USHORT +#define ULONG PM_ULONG + +#define INCL_DOS +#define INCL_PM +#include +#include + +#undef BOOL +#undef BYTE +#undef USHORT +#undef ULONG + +#ifdef __cplusplus +} +#endif + +// ======================================================================= + +#define _SV_SALFRAME_CXX + +#ifndef DEBUG_HXX +#include +#endif + +#define private public + +#ifndef _SV_SALLANG_HXX +#include +#endif +#ifndef _SV_SALIDS_HRC +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_HXX +#include +#endif +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALFRAME_HXX +#include +#endif + +#ifndef _SV_TIMER_HXX +#include +#endif +#ifndef _SV_SETTINGS_HXX +#include +#endif +#ifndef _SV_KEYCOES_HXX +#include +#endif + +// ======================================================================= + +// Toolkit4 defines +#ifndef SV_FULLWINDOWDRAG +#define SV_FULLWINDOWDRAG 99 +#endif + +// ======================================================================= + +static eImplKeyboardLanguage = LANGUAGE_DONTKNOW; + +// ======================================================================= + +#ifdef ENABLE_IME + +struct ImplSalIMEProc +{ + ULONG nOrd; + PFN* pProc; +}; + +#define SAL_IME_PROC_COUNT 12 + +// ----------------------------------------------------------------------- + +static SalIMEData* GetSalIMEData() +{ + SalData* pSalData = GetSalData(); + + if ( !pSalData->mbIMEInit ) + { + pSalData->mbIMEInit = TRUE; + + HMODULE hMod = 0; + if ( 0 == DosLoadModule( NULL, 0, "OS2IM", &hMod ) ) + { + SalIMEData* pIMEData = new SalIMEData; + BOOL bError = FALSE; + ImplSalIMEProc aProcAry[SAL_IME_PROC_COUNT] = + { + { 101, (PFN*)&(pIMEData->mpAssocIME) }, + { 104, (PFN*)&(pIMEData->mpGetIME) }, + { 106, (PFN*)&(pIMEData->mpReleaseIME) }, + { 117, (PFN*)&(pIMEData->mpSetConversionFont) }, + { 144, (PFN*)&(pIMEData->mpSetConversionFontSize) }, + { 118, (PFN*)&(pIMEData->mpGetConversionString) }, + { 122, (PFN*)&(pIMEData->mpGetResultString) }, + { 115, (PFN*)&(pIMEData->mpSetCandidateWin) }, + { 130, (PFN*)&(pIMEData->mpQueryIMEProperty) }, + { 131, (PFN*)&(pIMEData->mpRequestIME) }, + { 128, (PFN*)&(pIMEData->mpSetIMEMode) }, + { 127, (PFN*)&(pIMEData->mpQueryIMEMode) } + }; + + pIMEData->mhModIME = hMod; + for ( USHORT i = 0; i < SAL_IME_PROC_COUNT; i++ ) + { + if ( 0 != DosQueryProcAddr( pIMEData->mhModIME, aProcAry[i].nOrd, 0, aProcAry[i].pProc ) ) + { + bError = TRUE; + break; + } + } + + if ( bError ) + { + DosFreeModule( pIMEData->mhModIME ); + delete pIMEData; + } + else + pSalData->mpIMEData = pIMEData; + } + } + + return pSalData->mpIMEData; +} + +// ----------------------------------------------------------------------- + +void ImplReleaseSALIMEData() +{ + SalData* pSalData = GetSalData(); + + if ( pSalData->mpIMEData ) + { + DosFreeModule( pSalData->mpIMEData->mhModIME ); + delete pSalData->mpIMEData; + } +} + +#endif + +// ======================================================================= + +static void ImplSaveFrameState( SalFrame* pFrame ) +{ + if ( !pFrame->maFrameData.mbFullScreen ) + { + SWP aSWP; + + // Query actual state + WinQueryWindowPos( pFrame->maFrameData.mhWndFrame, &aSWP ); + + if ( aSWP.fl & SWP_MINIMIZE ) + pFrame->maFrameData.maState.mnState |= SAL_FRAMESTATE_MINIMIZED; + else if ( aSWP.fl & SWP_MAXIMIZE ) + { + pFrame->maFrameData.maState.mnState &= ~SAL_FRAMESTATE_MINIMIZED; + pFrame->maFrameData.maState.mnState |= SAL_FRAMESTATE_MAXIMIZED; + pFrame->maFrameData.mbRestoreMaximize = TRUE; + } + else + { + pFrame->maFrameData.maState.mnState &= ~(SAL_FRAMESTATE_MINIMIZED | SAL_FRAMESTATE_MAXIMIZED); + pFrame->maFrameData.maState.mnX = aSWP.x; + pFrame->maFrameData.maState.mnY = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN )-(aSWP.y+aSWP.cy); + pFrame->maFrameData.maState.mnWidth = aSWP.cx; + pFrame->maFrameData.maState.mnHeight = aSWP.cy; + pFrame->maFrameData.mbRestoreMaximize = FALSE; + } + } +} + +// ----------------------------------------------------------------------- + +long ImplSalCallbackDummy( void*, SalFrame*, USHORT, const void* ) +{ + return 0; +} + +// ----------------------------------------------------------------------- + +SalFrame* GetSalDefaultFrame() +{ + SalData* pSalData = GetSalData(); + + // Wenn kein Dummy-Frame existiert, dann legen wir uns einen an + if ( !pSalData->mpDummyFrame ) + pSalData->mpDummyFrame = pSalData->mpFirstInstance->CreateFrame( NULL, 0 ); + + return pSalData->mpDummyFrame; +} + +// ----------------------------------------------------------------------- + +static void ImplSalCalcFrameSize( const SalFrame* pFrame, + LONG& rFrameX, LONG& rFrameY, LONG& rCaptionY ) +{ + if ( pFrame->maFrameData.mnOS2Style & FCF_SIZEBORDER ) + { + rFrameX = WinQuerySysValue( HWND_DESKTOP, SV_CXSIZEBORDER ); + rFrameY = WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER ); + } + else if ( pFrame->maFrameData.mnOS2Style & FCF_DLGBORDER ) + { + rFrameX = WinQuerySysValue( HWND_DESKTOP, SV_CXDLGFRAME ); + rFrameY = WinQuerySysValue( HWND_DESKTOP, SV_CYDLGFRAME ); + } + else if ( pFrame->maFrameData.mnOS2Style & FCF_BORDER ) + { + rFrameX = WinQuerySysValue( HWND_DESKTOP, SV_CXBORDER ); + rFrameY = WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER ); + } + else + { + rFrameX = 0; + rFrameY = 0; + } + if ( pFrame->maFrameData.mnOS2Style & (FCF_TITLEBAR | FCF_SYSMENU) ) + rCaptionY = WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ); + else + rCaptionY = 0; +} + +// ----------------------------------------------------------------------- + +static void ImplSalCalcFullScreenSize( const SalFrame* pFrame, + LONG& rX, LONG& rY, LONG& rDX, LONG& rDY ) +{ + // set window to screen size + LONG nFrameX; + LONG nFrameY; + LONG nCaptionY; + LONG nScreenDX = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); + LONG nScreenDY = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); + + // Framegroessen berechnen + ImplSalCalcFrameSize( pFrame, nFrameX, nFrameY, nCaptionY ); + + rX = -nFrameX; + rY = -nFrameY; + rDX = nScreenDX+(nFrameX*2); + rDY = nScreenDY+(nFrameY*2)+nCaptionY; +} + +// ----------------------------------------------------------------------- + +static void ImplSalFrameFullScreenPos( SalFrame* pFrame, BOOL bAlways = FALSE ) +{ + SWP aSWP; + WinQueryWindowPos( pFrame->maFrameData.mhWndFrame, &aSWP ); + if ( bAlways || !(aSWP.fl & SWP_MINIMIZE) ) + { + // set window to screen size + LONG nX; + LONG nY; + LONG nWidth; + LONG nHeight; + ImplSalCalcFullScreenSize( pFrame, nX, nY, nWidth, nHeight ); + WinSetWindowPos( pFrame->maFrameData.mhWndFrame, 0, + nX, nY, nWidth, nHeight, + SWP_MOVE | SWP_SIZE ); + } +} + +// ----------------------------------------------------------------------- + +// Uebersetzungstabelle von System-Keycodes in StarView-Keycodes +#define KEY_TAB_SIZE (VK_ENDDRAG+1) + +static USHORT TranslateKey[KEY_TAB_SIZE] = +{ + // StarView-Code System-Code Index + 0, // 0x00 + 0, // VK_BUTTON1 0x01 + 0, // VK_BUTTON2 0x02 + 0, // VK_BUTTON3 0x03 + 0, // VK_BREAK 0x04 + KEY_BACKSPACE, // VK_BACKSPACE 0x05 + KEY_TAB, // VK_TAB 0x06 + KEY_TAB, // VK_BACKTAB 0x07 + KEY_RETURN, // VK_NEWLINE 0x08 + 0, // VK_SHIFT 0x09 + 0, // VK_CTRL 0x0A + 0, // VK_ALT 0x0B + 0, // VK_ALTGRAF 0x0C + 0, // VK_PAUSE 0x0D + 0, // VK_CAPSLOCK 0x0E + KEY_ESCAPE, // VK_ESC 0x0F + KEY_SPACE, // VK_SPACE 0x10 + KEY_PAGEUP, // VK_PAGEUP 0x11 + KEY_PAGEDOWN, // VK_PAGEDOWN 0x12 + KEY_END, // VK_END 0x13 + KEY_HOME, // VK_HOME 0x14 + KEY_LEFT, // VK_LEFT 0x15 + KEY_UP, // VK_UP 0x16 + KEY_RIGHT, // VK_RIGHT 0x17 + KEY_DOWN, // VK_DOWN 0x18 + 0, // VK_PRINTSCRN 0x19 + KEY_INSERT, // VK_INSERT 0x1A + KEY_DELETE, // VK_DELETE 0x1B + 0, // VK_SCRLLOCK 0x1C + 0, // VK_NUMLOCK 0x1D + KEY_RETURN, // VK_ENTER 0x1E + 0, // VK_SYSRQ 0x1F + KEY_F1, // VK_F1 0x20 + KEY_F2, // VK_F2 0x21 + KEY_F3, // VK_F3 0x22 + KEY_F4, // VK_F4 0x23 + KEY_F5, // VK_F5 0x24 + KEY_F6, // VK_F6 0x25 + KEY_F7, // VK_F7 0x26 + KEY_F8, // VK_F8 0x27 + KEY_F9, // VK_F9 0x28 + KEY_F10, // VK_F10 0x29 + KEY_F11, // VK_F11 0x2A + KEY_F12, // VK_F12 0x2B + KEY_F13, // VK_F13 0x2C + KEY_F14, // VK_F14 0x2D + KEY_F15, // VK_F15 0x2E + KEY_F16, // VK_F16 0x2F + KEY_F17, // VK_F17 0x30 + KEY_F18, // VK_F18 0x31 + KEY_F19, // VK_F19 0x32 + KEY_F20, // VK_F20 0x33 + KEY_F21, // VK_F21 0x34 + KEY_F22, // VK_F22 0x35 + KEY_F23, // VK_F23 0x36 + KEY_F24, // VK_F24 0x37 + 0 // VK_ENDDRAG 0x38 +}; + +// ======================================================================= + +SalFrame* ImplSalCreateFrame( SalInstance* pInst, SalFrame* pParent, ULONG nSalFrameStyle ) +{ + SalData* pSalData = GetSalData(); + SalFrame* pFrame = new SalFrame; + HWND hWndFrame; + HWND hWndClient; + PM_ULONG nFrameFlags = FCF_NOBYTEALIGN | FCF_NOMOVEWITHOWNER | FCF_SCREENALIGN; + PM_ULONG nFrameStyle = 0; + PM_ULONG nClientStyle = WS_CLIPSIBLINGS; + + // determine creation data (bei Moveable nehmen wir DLG-Border, damit + // es besser aussieht) + if ( nSalFrameStyle & SAL_FRAME_STYLE_SIZEABLE ) + nFrameFlags |= FCF_SIZEBORDER | FCF_SYSMENU; + else if ( nSalFrameStyle & SAL_FRAME_STYLE_MOVEABLE ) + nFrameFlags |= FCF_DLGBORDER; + else if ( nSalFrameStyle & SAL_FRAME_STYLE_BORDER ) + nFrameFlags |= FCF_BORDER; + if ( nSalFrameStyle & SAL_FRAME_STYLE_MOVEABLE ) + nFrameFlags |= FCF_TITLEBAR | FCF_SYSMENU; + if ( nSalFrameStyle & SAL_FRAME_STYLE_MINABLE ) + nFrameFlags |= FCF_MINBUTTON | FCF_SYSMENU; + if ( nSalFrameStyle & SAL_FRAME_STYLE_MAXABLE ) + nFrameFlags |= FCF_MAXBUTTON | FCF_SYSMENU; + if ( nSalFrameStyle & SAL_FRAME_STYLE_DEFAULT ) + nFrameFlags |= FCF_TASKLIST; + + // create frame + pSalData->mpCreateFrame = pFrame; + hWndFrame = WinCreateStdWindow( HWND_DESKTOP, nFrameStyle, &nFrameFlags, + (PSZ)SAL_FRAME_CLASSNAME, (PSZ)"", + nClientStyle, 0, 0, &hWndClient ); + + if ( !hWndFrame ) + { + delete pFrame; + return NULL; + } + + // Parent setzen (Owner) + if ( pParent ) + WinSetOwner( hWndFrame, pParent->maFrameData.mhWndClient ); + + // Icon setzen + if ( nFrameFlags & FCF_MINBUTTON ) + WinSendMsg( hWndFrame, WM_SETICON, (MPARAM)pInst->maInstData.mhAppIcon, (MPARAM)0 ); + + // Frames subclassen, da wir auch dort die eine oder andere Message + // abfangen wollen oder anders behandeln wollen + aSalShlData.mpOldFrameProc = WinSubclassWindow( hWndFrame, SalFrameFrameProc ); + + // init frame data + pFrame->maFrameData.mhWndFrame = hWndFrame; + pFrame->maFrameData.mhWndClient = hWndClient; + pFrame->maFrameData.mhAB = pInst->maInstData.mhAB; + pFrame->maFrameData.mnStyle = nSalFrameStyle; + pFrame->maFrameData.mnOS2Style = nFrameFlags; + pFrame->maFrameData.maSysData.hWnd = hWndClient; + + // determine show style + if ( nSalFrameStyle & SAL_FRAME_STYLE_DEFAULT ) + { + pSalData->mpDefaultFrame = pFrame; + + // restore saved position + SWP aSWP; + memset( &aSWP, 0, sizeof( aSWP ) ); + WinQueryTaskSizePos( pInst->maInstData.mhAB, 0, &aSWP ); + WinSetWindowPos( hWndFrame, HWND_TOP, + aSWP.x, aSWP.y, aSWP.cx, aSWP.cy, + SWP_ZORDER | SWP_MOVE | SWP_SIZE | + (aSWP.fl & (SWP_RESTORE | SWP_MINIMIZE | SWP_MAXIMIZE)) ); + if ( aSWP.fl & (SWP_MINIMIZE | SWP_MAXIMIZE) ) + pFrame->maFrameData.mbOverwriteState = FALSE; + if ( !(aSWP.fl & SWP_MINIMIZE) ) + WinSetWindowPos( hWndFrame, 0, 0, 0, 0, 0, SWP_MAXIMIZE ); + } + else + { + SWP aSWP; + RECTL rectl; + memset( &aSWP, 0, sizeof( aSWP ) ); + WinQueryWindowRect( HWND_DESKTOP, &rectl ); + aSWP.x = rectl.xLeft + 10; + aSWP.y = rectl.yBottom + 10; + aSWP.cx = rectl.xRight - rectl.xLeft - 20; + aSWP.cy = rectl.yTop - rectl.yBottom - 20; + WinSetWindowPos( hWndFrame, HWND_TOP, + aSWP.x, aSWP.y, aSWP.cx, aSWP.cy, + SWP_MOVE | SWP_SIZE | SWP_ZORDER ); + } + + // disable close + if ( !(nSalFrameStyle & SAL_FRAME_STYLE_CLOSEABLE) ) + { + HWND hSysMenu = WinWindowFromID( hWndFrame, FID_SYSMENU ); + if ( hSysMenu ) + { + WinSendMsg( hSysMenu, + MM_SETITEMATTR, + MPFROM2SHORT( SC_CLOSE, TRUE ), + MPFROM2SHORT( MIA_DISABLED, MIA_DISABLED ) ); + } + } + +#ifdef ENABLE_IME +/* + // Input-Context einstellen + SalIMEData* pIMEData = GetSalIMEData(); + if ( pIMEData ) + { + pFrame->maFrameData.mhIMEContext = 0; + if ( 0 != pIMEData->mpAssocIME( hWndClient, pFrame->maFrameData.mhIMEContext, &pFrame->maFrameData.mhDefIMEContext ) ) + pFrame->maFrameData.mhDefIMEContext = 0; + } + else + { + pFrame->maFrameData.mhIMEContext = 0; + pFrame->maFrameData.mhDefIMEContext = 0; + } +*/ +#endif + + ImplSaveFrameState( pFrame ); + pFrame->maFrameData.mbDefPos = TRUE; + + return pFrame; +} + +// ----------------------------------------------------------------------- + +void SalInstance::DestroyFrame( SalFrame* pFrame ) +{ + delete pFrame; +} + +// ======================================================================= + +SalFrame::SalFrame() +{ + SalData* pSalData = GetSalData(); + + maFrameData.mbGraphics = NULL; + maFrameData.mhPointer = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE ); + maFrameData.mpGraphics = NULL; + maFrameData.mpInst = NULL; + maFrameData.mpProc = ImplSalCallbackDummy; + maFrameData.mbFullScreen = FALSE; + maFrameData.mbAllwayOnTop = FALSE; + maFrameData.mbVisible = FALSE; + maFrameData.mbMinHide = FALSE; + maFrameData.mbInShow = FALSE; + maFrameData.mbRestoreMaximize = FALSE; + maFrameData.mbInMoveMsg = FALSE; + maFrameData.mbInSizeMsg = FALSE; + maFrameData.mbDefPos = TRUE; + maFrameData.mbOverwriteState = TRUE; + maFrameData.mbHandleIME = FALSE; + maFrameData.mbConversionMode = FALSE; + maFrameData.mbCandidateMode = FALSE; + memset( &maFrameData.maState, 0, sizeof( SalFrameState ) ); + maFrameData.maSysData.nSize = sizeof( SystemEnvData ); + + // insert frame in framelist + maFrameData.mpNextFrame = pSalData->mpFirstFrame; + pSalData->mpFirstFrame = this; +} + +// ----------------------------------------------------------------------- + +SalFrame::~SalFrame() +{ + SalData* pSalData = GetSalData(); + + // destroy DC + if ( maFrameData.mpGraphics ) + { + ImplSalDeInitGraphics( &(maFrameData.mpGraphics->maGraphicsData) ); + WinReleasePS( maFrameData.mpGraphics->maGraphicsData.mhPS ); + delete maFrameData.mpGraphics; + } + + // destroy system frame + WinDestroyWindow( maFrameData.mhWndFrame ); + + // reset default and dummy frame + if ( pSalData->mpDefaultFrame == this ) + pSalData->mpDefaultFrame = 0; + if ( pSalData->mpDummyFrame == this ) + pSalData->mpDummyFrame = 0; + + // remove frame from framelist + if ( this == pSalData->mpFirstFrame ) + pSalData->mpFirstFrame = maFrameData.mpNextFrame; + else + { + SalFrame* pTempFrame = pSalData->mpFirstFrame; + while ( pTempFrame->maFrameData.mpNextFrame != this ) + pTempFrame = pTempFrame->maFrameData.mpNextFrame; + + pTempFrame->maFrameData.mpNextFrame = maFrameData.mpNextFrame; + } +} + +// ----------------------------------------------------------------------- + +static HDC ImplWinGetDC( HWND hWnd ) +{ + HDC hDC = WinQueryWindowDC( hWnd ); + if ( !hDC ) + hDC = WinOpenWindowDC( hWnd ); + return hDC; +} + +// ----------------------------------------------------------------------- + +SalGraphics* SalFrame::GetGraphics() +{ + if ( maFrameData.mbGraphics ) + return NULL; + + if ( !maFrameData.mpGraphics ) + { + SalData* pSalData = GetSalData(); + maFrameData.mpGraphics = new SalGraphics; + maFrameData.mpGraphics->maGraphicsData.mhPS = WinGetPS( maFrameData.mhWndClient ); + maFrameData.mpGraphics->maGraphicsData.mhDC = ImplWinGetDC( maFrameData.mhWndClient ); + maFrameData.mpGraphics->maGraphicsData.mhWnd = maFrameData.mhWndClient; + maFrameData.mpGraphics->maGraphicsData.mnHeight = maFrameData.mnHeight; + maFrameData.mpGraphics->maGraphicsData.mbPrinter = FALSE; + maFrameData.mpGraphics->maGraphicsData.mbVirDev = FALSE; + maFrameData.mpGraphics->maGraphicsData.mbWindow = TRUE; + maFrameData.mpGraphics->maGraphicsData.mbScreen = TRUE; + ImplSalInitGraphics( &(maFrameData.mpGraphics->maGraphicsData) ); + maFrameData.mbGraphics = TRUE; + } + else + maFrameData.mbGraphics = TRUE; + + return maFrameData.mpGraphics; +} + +// ----------------------------------------------------------------------- + +void SalFrame::ReleaseGraphics( SalGraphics* ) +{ + maFrameData.mbGraphics = FALSE; +} + +// ----------------------------------------------------------------------- + +BOOL SalFrame::PostEvent( void* pData ) +{ + return (BOOL)WinPostMsg( maFrameData.mhWndClient, SAL_MSG_USEREVENT, 0, (MPARAM)pData ); +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetTitle( const XubString& rTitle ) +{ + // set window title + WinSetWindowText( maFrameData.mhWndFrame, (PSZ)(const char*)rTitle ); +} + +// ----------------------------------------------------------------------- + +void SalFrame::Show( BOOL bVisible ) +{ + maFrameData.mbVisible = bVisible; + if ( bVisible ) + { + maFrameData.mbOverwriteState = TRUE; + maFrameData.mbInShow = TRUE; + WinSetWindowPos( maFrameData.mhWndFrame, 0, 0, 0, 0, 0, SWP_SHOW | SWP_ACTIVATE ); + maFrameData.mbInShow = FALSE; + WinUpdateWindow( maFrameData.mhWndClient ); + } + else + { + maFrameData.mbInShow = TRUE; + WinSetWindowPos( maFrameData.mhWndFrame, 0, 0, 0, 0, 0, SWP_HIDE ); + maFrameData.mbInShow = FALSE; + } +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetClientSize( long nWidth, long nHeight ) +{ + // calculation frame size + LONG nX; + LONG nY; + LONG nFrameX; + LONG nFrameY; + LONG nCaptionY; + LONG nScreenWidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); + LONG nScreenHeight = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); + + // Framegroessen berechnen + ImplSalCalcFrameSize( this, nFrameX, nFrameY, nCaptionY ); + + // adjust give size + nWidth += 2*nFrameX; + nHeight += 2*nFrameY + nCaptionY; + + // Default-Position, dann zentrieren, ansonsten Position beibehalten + if ( maFrameData.mbDefPos ) + { + // calculate bottom left corner of frame + nX = (nScreenWidth-nWidth)/2; + nY = (nScreenHeight-nHeight)/2; + maFrameData.mbDefPos = FALSE; + } + else + { + SWP aSWP; + WinQueryWindowPos( maFrameData.mhWndFrame, &aSWP ); + + nX = aSWP.x; + nY = aSWP.y+(aSWP.cy-nHeight); + + // Fenster einpassen + if ( nX + nWidth > nScreenWidth ) + nX = nScreenWidth - nWidth; + if ( nY < 0 ) + nY = 0; + } + + // Fenster einpassen + if ( nX < 0 ) + nX = 0; + if ( nY > nScreenHeight-nHeight ) + nY = nScreenHeight-nHeight; + + // set new position + WinSetWindowPos( maFrameData.mhWndFrame, + 0, + nX, nY, + nWidth, nHeight, + SWP_MOVE | SWP_SIZE | SWP_RESTORE ); +} + +// ----------------------------------------------------------------------- + +void SalFrame::GetClientSize( long& rWidth, long& rHeight ) +{ + // Wenn wir von aussen gehidet werden (beispielsweise Hide-Button) + // muessen wir eine Groesse von 0,0 vorgaukeln, damit Dialoge noch + // als System-Fenster angezeigt werden + if ( maFrameData.mbMinHide ) + { + rWidth = 0; + rHeight = 0; + } + else + { + rWidth = maFrameData.mnWidth; + rHeight = maFrameData.mnHeight; + } +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetWindowState( const SalFrameState* pState ) +{ + LONG nX = pState->mnX; + LONG nY = pState->mnY; + LONG nCX = pState->mnWidth; + LONG nCY = pState->mnHeight; + + // Fenster-Position/Groesse in den Bildschirm einpassen + LONG nScreenWidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); + LONG nScreenHeight = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); + if ( nCX > nScreenWidth ) + { + nX = 0; + nCX = nScreenWidth; + } + if ( nCY > nScreenHeight ) + { + nY = 0; + nCY = nScreenHeight; + } + + // Y is under OS2 bottom align + nY = nScreenHeight-(nY+nCY); + + if ( !maFrameData.mbOverwriteState || + (pState->mnState & (SAL_FRAMESTATE_MINIMIZED | SAL_FRAMESTATE_MAXIMIZED)) ) + { + if ( maFrameData.mbOverwriteState ) + { + PM_ULONG nSizeStyle; + if ( pState->mnState & SAL_FRAMESTATE_MINIMIZED ) + nSizeStyle = SWP_MINIMIZE; + else + nSizeStyle = SWP_MAXIMIZE; + WinSetWindowPos( maFrameData.mhWndFrame, 0, 0, 0, 0, 0, nSizeStyle ); + } + + WinSetWindowUShort( maFrameData.mhWndFrame, QWS_XRESTORE, nX ); + WinSetWindowUShort( maFrameData.mhWndFrame, QWS_YRESTORE, nY ); + WinSetWindowUShort( maFrameData.mhWndFrame, QWS_CXRESTORE, nCX ); + WinSetWindowUShort( maFrameData.mhWndFrame, QWS_CYRESTORE, nCY ); + } + else + { + PM_ULONG nSizeStyle = SWP_MOVE | SWP_SIZE | SWP_RESTORE; + WinSetWindowPos( maFrameData.mhWndFrame, 0, nX, nY, nCX, nCY, nSizeStyle ); + } +} + +// ----------------------------------------------------------------------- + +BOOL SalFrame::GetWindowState( SalFrameState* pState ) +{ + if ( maFrameData.maState.mnWidth && maFrameData.maState.mnHeight ) + { + *pState = maFrameData.maState; + return TRUE; + } + + return FALSE; +} + +// ----------------------------------------------------------------------- + +void SalFrame::ShowFullScreen( BOOL bFullScreen ) +{ + if ( maFrameData.mbFullScreen == bFullScreen ) + return; + + maFrameData.mbFullScreen = bFullScreen; + if ( bFullScreen ) + { + // save old position + memset( &maFrameData.maFullScreenRect, 0, sizeof( SWP ) ); + WinQueryWindowPos( maFrameData.mhWndFrame, &maFrameData.maFullScreenRect ); + + // set window to screen size + ImplSalFrameFullScreenPos( this, TRUE ); + } + else + { + WinSetWindowPos( maFrameData.mhWndFrame, + 0, + maFrameData.maFullScreenRect.x, maFrameData.maFullScreenRect.y, + maFrameData.maFullScreenRect.cx, maFrameData.maFullScreenRect.cy, + SWP_MOVE | SWP_SIZE ); + } +} + +// ----------------------------------------------------------------------- + +void SalFrame::StartPresentation( BOOL bStart ) +{ + // SysSetObjectData("","Autolockup=no"); oder OS2.INI: PM_Lockup +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetAlwaysOnTop( BOOL bOnTop ) +{ + maFrameData.mbAllwayOnTop = bOnTop; +} + +// ----------------------------------------------------------------------- + +void SalFrame::ToTop( USHORT nFlags ) +{ + PM_ULONG nStyle = 0; + SWP aSWP; + WinQueryWindowPos( maFrameData.mhWndFrame, &aSWP ); + if ( aSWP.fl & SWP_MINIMIZE ) + { + if ( !(nFlags & SAL_FRAME_TOTOP_RESTOREWHENMIN) ) + return; + + if ( maFrameData.mbRestoreMaximize ) + nStyle |= SWP_MAXIMIZE; + else + nStyle |= SWP_RESTORE; + } + + WinSetWindowPos( maFrameData.mhWndFrame, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER | nStyle ); + WinSetFocus( HWND_DESKTOP, maFrameData.mhWndClient ); +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetPointer( PointerStyle ePointerStyle ) +{ + struct ImplPtrData + { + HPOINTER mhPointer; + PM_ULONG mnSysId; + PM_ULONG mnOwnId; + }; + + static ImplPtrData aImplPtrTab[POINTER_COUNT] = + { + { 0, SPTR_ARROW, 0 }, // POINTER_ARROW + { 0, 0, SAL_RESID_POINTER_NULL }, // POINTER_NULL + { 0, SPTR_WAIT, 0 }, // POINTER_WAIT + { 0, SPTR_TEXT, 0 }, // POINTER_BEAM + { 0, 0, SAL_RESID_POINTER_HELP }, // POINTER_HELP + { 0, 0, SAL_RESID_POINTER_CROSS }, // POINTER_CROSS + { 0, 0, SAL_RESID_POINTER_MOVE }, // POINTER_MOVE + { 0, SPTR_SIZENS, 0 }, // POINTER_NSIZE + { 0, SPTR_SIZENS, 0 }, // POINTER_SSIZE + { 0, SPTR_SIZEWE, 0 }, // POINTER_WSIZE + { 0, SPTR_SIZEWE, 0 }, // POINTER_ESIZE + { 0, SPTR_SIZENWSE, 0 }, // POINTER_NWSIZE + { 0, SPTR_SIZENESW, 0 }, // POINTER_NESIZE + { 0, SPTR_SIZENESW, 0 }, // POINTER_SWSIZE + { 0, SPTR_SIZENWSE, 0 }, // POINTER_SESIZE + { 0, SPTR_SIZENS, 0 }, // POINTER_WINDOW_NSIZE + { 0, SPTR_SIZENS, 0 }, // POINTER_WINDOW_SSIZE + { 0, SPTR_SIZEWE, 0 }, // POINTER_WINDOW_WSIZE + { 0, SPTR_SIZEWE, 0 }, // POINTER_WINDOW_ESIZE + { 0, SPTR_SIZENWSE, 0 }, // POINTER_WINDOW_NWSIZE + { 0, SPTR_SIZENESW, 0 }, // POINTER_WINDOW_NESIZE + { 0, SPTR_SIZENESW, 0 }, // POINTER_WINDOW_SWSIZE + { 0, SPTR_SIZENWSE, 0 }, // POINTER_WINDOW_SESIZE + { 0, 0, SAL_RESID_POINTER_HSPLIT }, // POINTER_HSPLIT + { 0, 0, SAL_RESID_POINTER_VSPLIT }, // POINTER_VSPLIT + { 0, 0, SAL_RESID_POINTER_HSIZEBAR }, // POINTER_HSIZEBAR + { 0, 0, SAL_RESID_POINTER_VSIZEBAR }, // POINTER_VSIZEBAR + { 0, 0, SAL_RESID_POINTER_HAND }, // POINTER_HAND + { 0, 0, SAL_RESID_POINTER_REFHAND }, // POINTER_REFHAND + { 0, 0, SAL_RESID_POINTER_PEN }, // POINTER_PEN + { 0, 0, SAL_RESID_POINTER_MAGNIFY }, // POINTER_MAGNIFY + { 0, 0, SAL_RESID_POINTER_FILL }, // POINTER_FILL + { 0, 0, SAL_RESID_POINTER_ROTATE }, // POINTER_ROTATE + { 0, 0, SAL_RESID_POINTER_HSHEAR }, // POINTER_HSHEAR + { 0, 0, SAL_RESID_POINTER_VSHEAR }, // POINTER_VSHEAR + { 0, 0, SAL_RESID_POINTER_MIRROR }, // POINTER_MIRROR + { 0, 0, SAL_RESID_POINTER_CROOK }, // POINTER_CROOK + { 0, 0, SAL_RESID_POINTER_CROP }, // POINTER_CROP + { 0, 0, SAL_RESID_POINTER_MOVEPOINT }, // POINTER_MOVEPOINT + { 0, 0, SAL_RESID_POINTER_MOVEBEZIERWEIGHT }, // POINTER_MOVEBEZIERWEIGHT + { 0, 0, SAL_RESID_POINTER_MOVEDATA }, // POINTER_MOVEDATA + { 0, 0, SAL_RESID_POINTER_COPYDATA }, // POINTER_COPYDATA + { 0, 0, SAL_RESID_POINTER_LINKDATA }, // POINTER_LINKDATA + { 0, 0, SAL_RESID_POINTER_MOVEDATALINK }, // POINTER_MOVEDATALINK + { 0, 0, SAL_RESID_POINTER_COPYDATALINK }, // POINTER_COPYDATALINK + { 0, 0, SAL_RESID_POINTER_MOVEFILE }, // POINTER_MOVEFILE + { 0, 0, SAL_RESID_POINTER_COPYFILE }, // POINTER_COPYFILE + { 0, 0, SAL_RESID_POINTER_LINKFILE }, // POINTER_LINKFILE + { 0, 0, SAL_RESID_POINTER_MOVEFILELINK }, // POINTER_MOVEFILELINK + { 0, 0, SAL_RESID_POINTER_COPYFILELINK }, // POINTER_COPYFILELINK + { 0, 0, SAL_RESID_POINTER_MOVEFILES }, // POINTER_MOVEFILES + { 0, 0, SAL_RESID_POINTER_COPYFILES }, // POINTER_COPYFILES + { 0, SPTR_ILLEGAL, 0 }, // POINTER_NOTALLOWED + { 0, 0, SAL_RESID_POINTER_DRAW_LINE }, // POINTER_DRAW_LINE + { 0, 0, SAL_RESID_POINTER_DRAW_RECT }, // POINTER_DRAW_RECT + { 0, 0, SAL_RESID_POINTER_DRAW_POLYGON }, // POINTER_DRAW_POLYGON + { 0, 0, SAL_RESID_POINTER_DRAW_BEZIER }, // POINTER_DRAW_BEZIER + { 0, 0, SAL_RESID_POINTER_DRAW_ARC }, // POINTER_DRAW_ARC + { 0, 0, SAL_RESID_POINTER_DRAW_PIE }, // POINTER_DRAW_PIE + { 0, 0, SAL_RESID_POINTER_DRAW_CIRCLECUT }, // POINTER_DRAW_CIRCLECUT + { 0, 0, SAL_RESID_POINTER_DRAW_ELLIPSE }, // POINTER_DRAW_ELLIPSE + { 0, 0, SAL_RESID_POINTER_DRAW_FREEHAND }, // POINTER_DRAW_FREEHAND + { 0, 0, SAL_RESID_POINTER_DRAW_CONNECT }, // POINTER_DRAW_CONNECT + { 0, 0, SAL_RESID_POINTER_DRAW_TEXT }, // POINTER_DRAW_TEXT + { 0, 0, SAL_RESID_POINTER_DRAW_CAPTION }, // POINTER_DRAW_CAPTION + { 0, 0, SAL_RESID_POINTER_CHART }, // POINTER_CHART + { 0, 0, SAL_RESID_POINTER_DETECTIVE }, // POINTER_DETECTIVE + { 0, 0, SAL_RESID_POINTER_PIVOT_COL }, // POINTER_PIVOT_COL + { 0, 0, SAL_RESID_POINTER_PIVOT_ROW }, // POINTER_PIVOT_ROW + { 0, 0, SAL_RESID_POINTER_PIVOT_FIELD }, // POINTER_PIVOT_FIELD + { 0, 0, SAL_RESID_POINTER_CHAIN }, // POINTER_CHAIN + { 0, 0, SAL_RESID_POINTER_CHAIN_NOTALLOWED }, // POINTER_CHAIN_NOTALLOWED + { 0, 0, SAL_RESID_POINTER_TIMEEVENT_MOVE }, // POINTER_TIMEEVENT_MOVE + { 0, 0, SAL_RESID_POINTER_TIMEEVENT_SIZE }, // POINTER_TIMEEVENT_SIZE + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_N }, // POINTER_AUTOSCROLL_N + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_S }, // POINTER_AUTOSCROLL_S + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_W }, // POINTER_AUTOSCROLL_W + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_E }, // POINTER_AUTOSCROLL_E + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NW }, // POINTER_AUTOSCROLL_NW + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NE }, // POINTER_AUTOSCROLL_NE + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_SW }, // POINTER_AUTOSCROLL_SW + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_SE }, // POINTER_AUTOSCROLL_SE + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NS }, // POINTER_AUTOSCROLL_NS + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_WE }, // POINTER_AUTOSCROLL_WE + { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NSWE } // POINTER_AUTOSCROLL_NSWE + }; + +#if POINTER_COUNT != 85 +#error New Pointer must be defined! +#endif + + // Mousepointer loaded ? + if ( !aImplPtrTab[ePointerStyle].mhPointer ) + { + if ( aImplPtrTab[ePointerStyle].mnOwnId ) + aImplPtrTab[ePointerStyle].mhPointer = ImplLoadPointer( aImplPtrTab[ePointerStyle].mnOwnId ); + else + aImplPtrTab[ePointerStyle].mhPointer = WinQuerySysPointer( HWND_DESKTOP, aImplPtrTab[ePointerStyle].mnSysId, FALSE ); + } + + // Unterscheidet sich der Mauspointer, dann den neuen setzen + if ( maFrameData.mhPointer != aImplPtrTab[ePointerStyle].mhPointer ) + { + maFrameData.mhPointer = aImplPtrTab[ePointerStyle].mhPointer; + WinSetPointer( HWND_DESKTOP, maFrameData.mhPointer ); + } +} + +// ----------------------------------------------------------------------- + +void SalFrame::CaptureMouse( BOOL bCapture ) +{ + if ( bCapture ) + WinSetCapture( HWND_DESKTOP, maFrameData.mhWndClient ); + else + WinSetCapture( HWND_DESKTOP, 0 ); +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetPointerPos( long nX, long nY ) +{ + POINTL aPt; + aPt.x = nX; + aPt.y = maFrameData.mnHeight - nY - 1; // convert sal coords to sys + WinMapWindowPoints( maFrameData.mhWndClient, HWND_DESKTOP, &aPt, 1 ); + WinSetPointerPos( HWND_DESKTOP, aPt.x, aPt.y ); +} + +// ----------------------------------------------------------------------- + +void SalFrame::Flush() +{ +} + +// ----------------------------------------------------------------------- + +void SalFrame::Sync() +{ +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetInputContext( SalInputContext* pContext ) +{ +#ifdef ENABLE_IME + SalIMEData* pIMEData = GetSalIMEData(); + if ( pIMEData ) + { + HWND hWnd = maFrameData.mhWndClient; + HIMI hIMI = 0; + pIMEData->mpGetIME( hWnd, &hIMI ); + if ( hIMI ) + { + PM_ULONG nInputMode; + PM_ULONG nConversionMode; + if ( 0 == pIMEData->mpQueryIMEMode( hIMI, &nInputMode, &nConversionMode ) ) + { + if ( pContext->mnOptions & SAL_INPUTCONTEXT_TEXT ) + { + nInputMode &= ~IMI_IM_IME_DISABLE; + if ( pContext->mnOptions & SAL_INPUTCONTEXT_EXTTEXTINPUT_OFF ) + nInputMode &= ~IMI_IM_IME_ON; +// !!! Da derzeit ueber das OS2-IME-UI der IME-Mode nicht einschaltbar ist !!! +// if ( SAL_INPUTCONTEXT_EXTTEXTINPUT_ON ) + nInputMode |= IMI_IM_IME_ON; + } + else + nInputMode |= IMI_IM_IME_DISABLE; + pIMEData->mpSetIMEMode( hIMI, nInputMode, nConversionMode ); + } + + pIMEData->mpReleaseIME( hWnd, hIMI ); + } + } +#endif +} + +// ----------------------------------------------------------------------- + +void SalFrame::UpdateExtTextInputArea() +{ +#ifdef ENABLE_IME +#endif +} + +// ----------------------------------------------------------------------- + +void SalFrame::EndExtTextInput( USHORT nFlags ) +{ +#ifdef ENABLE_IME + SalIMEData* pIMEData = GetSalIMEData(); + if ( pIMEData ) + { + HWND hWnd = maFrameData.mhWndClient; + HIMI hIMI = 0; + pIMEData->mpGetIME( hWnd, &hIMI ); + if ( hIMI ) + { + PM_ULONG nIndex; + if ( nFlags & SAL_FRAME_ENDEXTTEXTINPUT_COMPLETE ) + nIndex = CNV_COMPLETE; + else + nIndex = CNV_CANCEL; + + pIMEData->mpRequestIME( hIMI, REQ_CONVERSIONSTRING, nIndex, 0 ); + pIMEData->mpReleaseIME( hWnd, hIMI ); + } + } +#endif +} + +// ----------------------------------------------------------------------- + +XubString SalFrame::GetKeyName( USHORT nCode ) +{ + if ( eImplKeyboardLanguage == LANGUAGE_DONTKNOW ) + eImplKeyboardLanguage = GetSystemLanguage(); + + XubString aKeyCode; + XubString aCode; + const char** pLangTab = ImplGetLangTab( eImplKeyboardLanguage ); + + if ( nCode & KEY_SHIFT ) + aKeyCode = pLangTab[LSTR_KEY_SHIFT]; + + if ( nCode & KEY_MOD1 ) + { + if ( !aKeyCode ) + aKeyCode = pLangTab[LSTR_KEY_CTRL]; + else + { + aKeyCode += '+'; + aKeyCode += pLangTab[LSTR_KEY_CTRL]; + } + } + + if ( nCode & KEY_MOD2 ) + { + if ( !aKeyCode ) + aKeyCode = pLangTab[LSTR_KEY_ALT]; + else + { + aKeyCode += '+'; + aKeyCode += pLangTab[LSTR_KEY_ALT]; + } + } + + USHORT nKeyCode = nCode & 0x0FFF; + switch ( nKeyCode ) + { + case KEY_0: + case KEY_1: + case KEY_2: + case KEY_3: + case KEY_4: + case KEY_5: + case KEY_6: + case KEY_7: + case KEY_8: + case KEY_9: + aCode += (char)('0' + (nKeyCode - KEY_0)); + break; + + case KEY_A: + case KEY_B: + case KEY_C: + case KEY_D: + case KEY_E: + case KEY_F: + case KEY_G: + case KEY_H: + case KEY_I: + case KEY_J: + case KEY_K: + case KEY_L: + case KEY_M: + case KEY_N: + case KEY_O: + case KEY_P: + case KEY_Q: + case KEY_R: + case KEY_S: + case KEY_T: + case KEY_U: + case KEY_V: + case KEY_W: + case KEY_X: + case KEY_Y: + case KEY_Z: + aCode += (char)('A' + (nKeyCode - KEY_A)); + break; + + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + case KEY_F11: + case KEY_F12: + case KEY_F13: + case KEY_F14: + case KEY_F15: + case KEY_F16: + case KEY_F17: + case KEY_F18: + case KEY_F19: + case KEY_F20: + case KEY_F21: + case KEY_F22: + case KEY_F23: + case KEY_F24: + case KEY_F25: + case KEY_F26: + aCode += 'F'; + aCode += (USHORT)nKeyCode - KEY_F1 + 1; + break; + + case KEY_DOWN: + aCode = pLangTab[LSTR_KEY_DOWN]; + break; + case KEY_UP: + aCode = pLangTab[LSTR_KEY_UP]; + break; + case KEY_LEFT: + aCode = pLangTab[LSTR_KEY_LEFT]; + break; + case KEY_RIGHT: + aCode = pLangTab[LSTR_KEY_RIGHT]; + break; + case KEY_HOME: + aCode = pLangTab[LSTR_KEY_HOME]; + break; + case KEY_END: + aCode = pLangTab[LSTR_KEY_END]; + break; + case KEY_PAGEUP: + aCode = pLangTab[LSTR_KEY_PAGEUP]; + break; + case KEY_PAGEDOWN: + aCode = pLangTab[LSTR_KEY_PAGEDOWN]; + break; + case KEY_RETURN: + aCode = pLangTab[LSTR_KEY_RETURN]; + break; + case KEY_ESCAPE: + aCode = pLangTab[LSTR_KEY_ESC]; + break; + case KEY_TAB: + aCode = pLangTab[LSTR_KEY_TAB]; + break; + case KEY_BACKSPACE: + aCode = pLangTab[LSTR_KEY_BACKSPACE]; + break; + case KEY_SPACE: + aCode = pLangTab[LSTR_KEY_SPACE]; + break; + case KEY_INSERT: + aCode = pLangTab[LSTR_KEY_INSERT]; + break; + case KEY_DELETE: + aCode = pLangTab[LSTR_KEY_DELETE]; + break; + + case KEY_ADD: + aCode += '+'; + break; + case KEY_SUBTRACT: + aCode += '-'; + break; + case KEY_MULTIPLY: + aCode += '*'; + break; + case KEY_DIVIDE: + aCode += '/'; + break; + case KEY_POINT: + aCode += '.'; + break; + case KEY_COMMA: + aCode += ','; + break; + case KEY_LESS: + aCode += '<'; + break; + case KEY_GREATER: + aCode += '>'; + break; + case KEY_EQUAL: + aCode += '='; + break; + } + + if ( aCode.Len() ) + { + if ( !aKeyCode ) + aKeyCode = aCode; + else + { + aKeyCode += '+'; + aKeyCode += aCode; + } + } + + return aKeyCode; +} + +// ----------------------------------------------------------------------- + +XubString SalFrame::GetSymbolKeyName( const XubString&, USHORT nKeyCode ) +{ + return GetKeyName( nKeyCode ); +} + +// ----------------------------------------------------------------------- + +inline long ImplOS2ColorToSal( long nOS2Color ) +{ + return MAKE_SALCOLOR( (BYTE)( nOS2Color>>16), (BYTE)(nOS2Color>>8), (BYTE)nOS2Color ); +} + +// ----------------------------------------------------------------------- + +static USHORT ImplMouseSysValueToSAL( int iSysValue, USHORT& rCode, USHORT& rClicks, BOOL& rDown ) +{ + LONG lValue = WinQuerySysValue( HWND_DESKTOP, iSysValue ); + + rCode = 0; + rClicks = 1; + rDown = TRUE; + + switch ( lValue & 0xFFFF ) + { + case WM_BUTTON1UP: + case WM_BUTTON1CLICK: + rCode = MOUSE_LEFT; + rDown = FALSE; + break; + case WM_BUTTON1DOWN: + case WM_BUTTON1MOTIONSTART: + rCode = MOUSE_LEFT; + break; + case WM_BUTTON1DBLCLK: + rCode = MOUSE_LEFT; + rClicks = 2; + break; + + case WM_BUTTON2UP: + case WM_BUTTON2CLICK: + rCode = MOUSE_RIGHT; + rDown = FALSE; + break; + case WM_BUTTON2DOWN: + case WM_BUTTON2MOTIONSTART: + rCode = MOUSE_RIGHT; + break; + case WM_BUTTON2DBLCLK: + rCode = MOUSE_RIGHT; + rClicks = 2; + break; + + case WM_BUTTON3UP: + case WM_BUTTON3CLICK: + rCode = MOUSE_MIDDLE; + rDown = FALSE; + break; + case WM_BUTTON3DOWN: + case WM_BUTTON3MOTIONSTART: + rCode = MOUSE_MIDDLE; + break; + case WM_BUTTON3DBLCLK: + rCode = MOUSE_MIDDLE; + rClicks = 2; + break; + } + + if ( !rCode ) + return FALSE; + + lValue = (lValue & 0xFFFF0000) >> 16; + if ( lValue != 0xFFFF ) + { + if ( lValue & KC_SHIFT ) + rCode |= KEY_SHIFT; + if ( lValue & KC_CTRL ) + rCode |= KEY_MOD1; + if ( lValue & KC_ALT ) + rCode |= KEY_MOD2; + } + + return TRUE; +} + +// ----------------------------------------------------------------------- + +static BOOL ImplSalIsSameColor( const Color& rColor1, const Color& rColor2 ) +{ + ULONG nWrong = 0; + nWrong += Abs( (short)rColor1.GetRed()-(short)rColor2.GetRed() ); + nWrong += Abs( (short)rColor1.GetGreen()-(short)rColor2.GetGreen() ); + nWrong += Abs( (short)rColor1.GetBlue()-(short)rColor2.GetBlue() ); + return (nWrong < 30); +} + +// ----------------------------------------------------------------------- + +static BOOL ImplOS2NameFontToVCLFont( const char* pFontName, Font& rFont ) +{ + char aNumBuf[10]; + int nNumBufLen = 0; + + while ( *pFontName && (*pFontName != '.') && + (nNumBufLen < sizeof(aNumBuf)-1) ) + { + aNumBuf[nNumBufLen] = *pFontName; + nNumBufLen++; + pFontName++; + } + aNumBuf[nNumBufLen] = '\0'; + + pFontName++; + while ( *pFontName == ' ' ) + pFontName++; + + int nFontHeight = atoi( aNumBuf ); + int nFontNameLen = strlen( pFontName ); + if ( nFontHeight && nFontNameLen ) + { + rFont.SetName( pFontName ); + rFont.SetSize( Size( 0, nFontHeight ) ); + rFont.SetFamily( FAMILY_DONTKNOW ); + rFont.SetWeight( WEIGHT_NORMAL ); + rFont.SetItalic( ITALIC_NONE ); + return TRUE; + } + else + return FALSE; +} + +// ----------------------------------------------------------------------- + +void SalFrame::UpdateSettings( AllSettings& rSettings ) +{ + static char aControlPanel[] = "PM_ControlPanel"; + static char aSystemFonts[] = "PM_SystemFonts"; + char aDummyStr[] = ""; + + // --- Mouse setting --- + USHORT nCode; + USHORT nClicks; + BOOL bDown; + MouseSettings aMouseSettings = rSettings.GetMouseSettings(); + aMouseSettings.SetDoubleClickTime( WinQuerySysValue( HWND_DESKTOP, SV_DBLCLKTIME ) ); + if ( ImplMouseSysValueToSAL( SV_BEGINDRAG, nCode, nClicks, bDown ) ) + aMouseSettings.SetStartDragCode( nCode ); + if ( ImplMouseSysValueToSAL( SV_CONTEXTMENU, nCode, nClicks, bDown ) ) + { + aMouseSettings.SetContextMenuCode( nCode ); + aMouseSettings.SetContextMenuClicks( nClicks ); + aMouseSettings.SetContextMenuDown( bDown ); + } + aMouseSettings.SetButtonStartRepeat( WinQuerySysValue( HWND_DESKTOP, SV_FIRSTSCROLLRATE ) ); + aMouseSettings.SetButtonRepeat( WinQuerySysValue( HWND_DESKTOP, SV_SCROLLRATE ) ); + rSettings.SetMouseSettings( aMouseSettings ); + + // --- Style settings --- + StyleSettings aStyleSettings = rSettings.GetStyleSettings(); + BOOL bCompBorder = (aStyleSettings.GetOptions() & (STYLE_OPTION_MACSTYLE | STYLE_OPTION_UNIXSTYLE)) == 0; + + // General settings + LONG nDisplayTime = PrfQueryProfileInt( HINI_PROFILE, (PSZ)aControlPanel, (PSZ)"LogoDisplayTime", -1 ); + ULONG nSalDisplayTime; + if ( nDisplayTime < 0 ) + nSalDisplayTime = LOGO_DISPLAYTIME_STARTTIME; + else if ( !nDisplayTime ) + nSalDisplayTime = LOGO_DISPLAYTIME_NOLOGO; + else + nSalDisplayTime = (ULONG)nDisplayTime; + aStyleSettings.SetLogoDisplayTime( nSalDisplayTime ); + + aStyleSettings.SetCursorBlinkTime( WinQuerySysValue( HWND_DESKTOP, SV_CURSORRATE ) ); + ULONG nDragFullOptions = aStyleSettings.GetDragFullOptions(); + if ( WinQuerySysValue( HWND_DESKTOP, SV_FULLWINDOWDRAG ) ) + nDragFullOptions |= DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE | DRAGFULL_OPTION_DOCKING | DRAGFULL_OPTION_SPLIT; + else + nDragFullOptions &= ~(DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE | DRAGFULL_OPTION_DOCKING | DRAGFULL_OPTION_SPLIT); + aStyleSettings.SetDragFullOptions( nDragFullOptions ); + + // Size settings + aStyleSettings.SetScrollBarSize( WinQuerySysValue( HWND_DESKTOP, SV_CYHSCROLL ) ); + if ( bCompBorder ) + { + aStyleSettings.SetTitleHeight( WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) ); + } + + // Color settings + if ( bCompBorder ) + { + aStyleSettings.SetFaceColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONMIDDLE, 0 ) ) ); + aStyleSettings.SetLightColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONLIGHT, 0 ) ) ); + aStyleSettings.SetLightBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONMIDDLE, 0 ) ) ); + aStyleSettings.SetShadowColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONDARK, 0 ) ) ); + aStyleSettings.SetDarkShadowColor( Color( COL_BLACK ) ); + aStyleSettings.SetDialogColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0 ) ) ); + aStyleSettings.SetButtonTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUTEXT, 0 ) ) ); + aStyleSettings.SetActiveColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ACTIVETITLE, 0 ) ) ); + aStyleSettings.SetActiveTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ACTIVETITLETEXT, 0 ) ) ); + aStyleSettings.SetActiveBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ACTIVEBORDER, 0 ) ) ); + aStyleSettings.SetDeactiveColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_INACTIVETITLE, 0 ) ) ); + aStyleSettings.SetDeactiveTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_INACTIVETITLETEXT, 0 ) ) ); + aStyleSettings.SetDeactiveBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_INACTIVEBORDER, 0 ) ) ); + aStyleSettings.SetMenuColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENU, 0 ) ) ); + aStyleSettings.SetMenuTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUTEXT, 0 ) ) ); + } + aStyleSettings.SetDialogTextColor( aStyleSettings.GetButtonTextColor() ); + aStyleSettings.SetRadioCheckTextColor( aStyleSettings.GetButtonTextColor() ); + aStyleSettings.SetGroupTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_WINDOWSTATICTEXT, 0 ) ) ); + aStyleSettings.SetLabelTextColor( aStyleSettings.GetGroupTextColor() ); + aStyleSettings.SetInfoTextColor( aStyleSettings.GetGroupTextColor() ); + aStyleSettings.SetWindowColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_WINDOW, 0 ) ) ); + aStyleSettings.SetWindowTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_WINDOWTEXT, 0 ) ) ); + aStyleSettings.SetFieldColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ENTRYFIELD, 0 ) ) ); + aStyleSettings.SetFieldTextColor( aStyleSettings.GetWindowTextColor() ); + aStyleSettings.SetDisableColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUDISABLEDTEXT, 0 ) ) ); + aStyleSettings.SetHighlightColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_HILITEBACKGROUND, 0 ) ) ); + aStyleSettings.SetHighlightTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_HILITEFOREGROUND, 0 ) ) ); + Color aMenuHighColor = ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUHILITEBGND, 0 ) ); + if ( ImplSalIsSameColor( aMenuHighColor, aStyleSettings.GetMenuColor() ) ) + { + if ( bCompBorder ) + { + aStyleSettings.SetMenuHighlightColor( Color( COL_BLUE ) ); + aStyleSettings.SetMenuHighlightTextColor( Color( COL_WHITE ) ); + } + } + else + { + aStyleSettings.SetMenuHighlightColor( aMenuHighColor ); + aStyleSettings.SetMenuHighlightTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUHILITE, 0 ) ) ); + } + // Checked-Color berechnen + Color aColor1 = aStyleSettings.GetFaceColor(); + Color aColor2 = aStyleSettings.GetLightColor(); + BYTE nRed = (BYTE)(((USHORT)aColor1.GetRed() + (USHORT)aColor2.GetRed())/2); + BYTE nGreen = (BYTE)(((USHORT)aColor1.GetGreen() + (USHORT)aColor2.GetGreen())/2); + BYTE nBlue = (BYTE)(((USHORT)aColor1.GetBlue() + (USHORT)aColor2.GetBlue())/2); + aStyleSettings.SetCheckedColor( Color( nRed, nGreen, nBlue ) ); + + // Fonts updaten + Font aFont; + char aFontNameBuf[255]; + aFont = aStyleSettings.GetMenuFont(); + if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"Menus", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 ) + { + if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) ) + aStyleSettings.SetMenuFont( aFont ); + } + aFont = aStyleSettings.GetIconFont(); + if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"IconText", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 ) + { + if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) ) + aStyleSettings.SetIconFont( aFont ); + } + aFont = aStyleSettings.GetTitleFont(); + if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"WindowTitles", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 ) + { + if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) ) + { + aStyleSettings.SetTitleFont( aFont ); + aStyleSettings.SetFloatTitleFont( aFont ); + } + } + aFont = aStyleSettings.GetAppFont(); + if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"WindowText", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 ) + { + if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) ) + { + Font aHelpFont = aFont; + aHelpFont.SetName( "Helv;WarpSans" ); + aHelpFont.SetSize( Size( 0, 8 ) ); + aHelpFont.SetWeight( WEIGHT_NORMAL ); + aHelpFont.SetItalic( ITALIC_NONE ); + aStyleSettings.SetHelpFont( aHelpFont ); + + // Bei System mappen wir direkt auf WarpSans/Helv, da diese + // unserer Meinung besser aussehen + if ( aFont.GetName().Search( "System" ) != STRING_NOTFOUND ) + { + XubString aFontName = aFont.GetName(); + aFontName.Insert( "WarpSans;Helv;" ); + aFont.SetName( aFontName ); + aFont.SetSize( Size( 0, 9 ) ); + } + aStyleSettings.SetAppFont( aFont ); + aStyleSettings.SetToolFont( aFont ); + aStyleSettings.SetLabelFont( aFont ); + aStyleSettings.SetInfoFont( aFont ); + aStyleSettings.SetRadioCheckFont( aFont ); + aStyleSettings.SetPushButtonFont( aFont ); + aStyleSettings.SetFieldFont( aFont ); + aStyleSettings.SetGroupFont( aFont ); + } + } + + rSettings.SetStyleSettings( aStyleSettings ); +} + +// ----------------------------------------------------------------------- + +const SystemEnvData* SalFrame::GetSystemData() const +{ + return &maFrameData.maSysData; +} + +// ----------------------------------------------------------------------- + +void SalFrame::Beep( SoundType eSoundType ) +{ + static PM_ULONG aImplSoundTab[5] = + { + WA_NOTE, // SOUND_DEFAULT + WA_NOTE, // SOUND_INFO + WA_WARNING, // SOUND_WARNING + WA_ERROR, // SOUND_ERROR + WA_NOTE // SOUND_QUERY + }; + +#if SOUND_COUNT != 5 +#error New Sound must be defined! +#endif + + WinAlarm( HWND_DESKTOP, aImplSoundTab[eSoundType] ); +} + +// ----------------------------------------------------------------------- + +void SalFrame::SetCallback( void* pInst, SALFRAMEPROC pProc ) +{ + if( pProc == NULL ) + maFrameData.mpProc = ImplSalCallbackDummy; + else + { + maFrameData.mpInst = pInst; + maFrameData.mpProc = pProc; + } +} + +// ----------------------------------------------------------------------- + +static void SalTestMouseLeave() +{ + SalData* pSalData = GetSalData(); + + if ( pSalData->mhWantLeaveMsg && !::WinQueryCapture( HWND_DESKTOP ) ) + { + POINTL aPt; + WinQueryPointerPos( HWND_DESKTOP, &aPt ); + if ( pSalData->mhWantLeaveMsg != WinWindowFromPoint( HWND_DESKTOP, &aPt, TRUE ) ) + WinSendMsg( pSalData->mhWantLeaveMsg, SAL_MSG_MOUSELEAVE, 0, MPFROM2SHORT( aPt.x, aPt.y ) ); + } +} + +// ----------------------------------------------------------------------- + +static long ImplHandleMouseMsg( SalFrame* pFrame, + UINT nMsg, MPARAM nMP1, MPARAM nMP2 ) +{ + SalMouseEvent aMouseEvt; + long nRet; + USHORT nEvent; + BOOL bRetTRUE = FALSE; + BOOL bCall = TRUE; + BOOL bActivate = FALSE; + USHORT nFlags = SHORT2FROMMP( nMP2 ); + + aMouseEvt.mnX = (short)SHORT1FROMMP( nMP1 ); + aMouseEvt.mnY = pFrame->maFrameData.mnHeight - (short)SHORT2FROMMP( nMP1 ) - 1; + aMouseEvt.mnCode = 0; + aMouseEvt.mnTime = WinQueryMsgTime( pFrame->maFrameData.mhAB ); + + // MausModus feststellen und setzen + if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON1 ) & 0x8000 ) + aMouseEvt.mnCode |= MOUSE_LEFT; + if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON2 ) & 0x8000 ) + aMouseEvt.mnCode |= MOUSE_RIGHT; + if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON3 ) & 0x8000 ) + aMouseEvt.mnCode |= MOUSE_MIDDLE; + // Modifier-Tasten setzen + if ( WinGetKeyState( HWND_DESKTOP, VK_SHIFT ) & 0x8000 ) + aMouseEvt.mnCode |= KEY_SHIFT; + if ( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 ) + aMouseEvt.mnCode |= KEY_MOD1; + if ( WinGetKeyState( HWND_DESKTOP, VK_ALT ) & 0x8000 ) + aMouseEvt.mnCode |= KEY_MOD2; + + switch ( nMsg ) + { + case WM_MOUSEMOVE: + { + SalData* pSalData = GetSalData(); + + // Da bei Druecken von Modifier-Tasten die MouseEvents + // nicht zusammengefast werden (da diese durch KeyEvents + // unterbrochen werden), machen wir dieses hier selber + if ( aMouseEvt.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2) ) + { + QMSG aTempMsg; + if ( WinPeekMsg( pSalData->mhAB, &aTempMsg, + pFrame->maFrameData.mhWndClient, + WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE ) ) + { + if ( (aTempMsg.msg == WM_MOUSEMOVE) && + (aTempMsg.mp2 == nMP2) ) + return 1; + } + } + + // Test for MouseLeave + if ( pSalData->mhWantLeaveMsg && + (pSalData->mhWantLeaveMsg != pFrame->maFrameData.mhWndClient) ) + { + POINTL aMousePoint; + WinQueryMsgPos( pFrame->maFrameData.mhAB, &aMousePoint ); + WinSendMsg( pSalData->mhWantLeaveMsg, + SAL_MSG_MOUSELEAVE, + 0, MPFROM2SHORT( aMousePoint.x, aMousePoint.y ) ); + } + pSalData->mhWantLeaveMsg = pFrame->maFrameData.mhWndClient; + // Start MouseLeave-Timer + if ( !pSalData->mpMouseLeaveTimer ) + { + pSalData->mpMouseLeaveTimer = new AutoTimer; + pSalData->mpMouseLeaveTimer->SetTimeout( SAL_MOUSELEAVE_TIMEOUT ); + pSalData->mpMouseLeaveTimer->Start(); + // We dont need to set a timeout handler, because we test + // for mouseleave in the timeout callback + } + aMouseEvt.mnButton = 0; + nEvent = SALEVENT_MOUSEMOVE; + } + break; + + case SAL_MSG_MOUSELEAVE: + { + SalData* pSalData = GetSalData(); + if ( pSalData->mhWantLeaveMsg == pFrame->maFrameData.mhWndClient ) + { + pSalData->mhWantLeaveMsg = 0; + if ( pSalData->mpMouseLeaveTimer ) + { + delete pSalData->mpMouseLeaveTimer; + pSalData->mpMouseLeaveTimer = NULL; + } + + // Mouse-Coordinaates are relativ to the screen + POINTL aPt; + aPt.x = (short)SHORT1FROMMP( nMP2 ); + aPt.y = (short)SHORT2FROMMP( nMP2 ); + WinMapWindowPoints( HWND_DESKTOP, pFrame->maFrameData.mhWndClient, &aPt, 1 ); + aPt.y = pFrame->maFrameData.mnHeight - aPt.y - 1; + aMouseEvt.mnX = aPt.x; + aMouseEvt.mnY = aPt.y; + aMouseEvt.mnButton = 0; + nEvent = SALEVENT_MOUSELEAVE; + } + else + bCall = FALSE; + } + break; + + case WM_BUTTON1DBLCLK: + case WM_BUTTON1DOWN: + aMouseEvt.mnButton = MOUSE_LEFT; + nEvent = SALEVENT_MOUSEBUTTONDOWN; + bActivate = TRUE; + break; + + case WM_BUTTON2DBLCLK: + case WM_BUTTON2DOWN: + aMouseEvt.mnButton = MOUSE_RIGHT; + nEvent = SALEVENT_MOUSEBUTTONDOWN; + bActivate = TRUE; + break; + + case WM_BUTTON3DBLCLK: + case WM_BUTTON3DOWN: + aMouseEvt.mnButton = MOUSE_MIDDLE; + nEvent = SALEVENT_MOUSEBUTTONDOWN; + bActivate = TRUE; + break; + + case WM_BUTTON1UP: + aMouseEvt.mnButton = MOUSE_LEFT; + nEvent = SALEVENT_MOUSEBUTTONUP; + break; + + case WM_BUTTON2UP: + aMouseEvt.mnButton = MOUSE_RIGHT; + nEvent = SALEVENT_MOUSEBUTTONUP; + break; + + case WM_BUTTON3UP: + aMouseEvt.mnButton = MOUSE_MIDDLE; + nEvent = SALEVENT_MOUSEBUTTONUP; + break; + } + + // Vorsichtshalber machen wir dies hier noch und gehen ueber + // den neuen SAL-Event. Eigentlich muesste dies immer durch + // den unabhaengigen Teil ausgeloest werden! + if ( bActivate ) + { + SalMouseActivateEvent aMouseActivateEvt; + aMouseActivateEvt.mnX = aMouseEvt.mnX; + aMouseActivateEvt.mnY = aMouseEvt.mnY; + if ( !pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_MOUSEACTIVATE, &aMouseActivateEvt ) ) + WinSetWindowPos( pFrame->maFrameData.mhWndFrame, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER ); + else + bRetTRUE = TRUE; + } + + if ( bCall ) + { + if ( nEvent == SALEVENT_MOUSEBUTTONDOWN ) + WinUpdateWindow( pFrame->maFrameData.mhWndClient ); + + nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + nEvent, &aMouseEvt ); + if ( nMsg == WM_MOUSEMOVE ) + { + WinSetPointer( HWND_DESKTOP, pFrame->maFrameData.mhPointer ); + nRet = TRUE; + } + } + else + nRet = 0; + + if ( bRetTRUE ) + nRet = TRUE; + + return nRet; +} + +// ----------------------------------------------------------------------- + +static void ImplConvertKey( MPARAM aMP1, MPARAM aMP2, USHORT& rSVCode, xub_Unicode& rSVCharCode ) +{ + USHORT nKeyFlags = SHORT1FROMMP( aMP1 ); + UCHAR nCharCode = (UCHAR)SHORT1FROMMP( aMP2 ); + USHORT nKeyCode = (UCHAR)SHORT2FROMMP( aMP2 ); + + // Ist virtueller KeyCode gesetzt und befindet sich der KeyCode in der + // Tabelle, dann mappen + if ( (nKeyFlags & KC_VIRTUALKEY) && (nKeyCode < KEY_TAB_SIZE) ) + rSVCode = TranslateKey[nKeyCode]; + + // Ist Character-Code gesetzt + // !!! Bei CTRL/ALT ist KC_CHAR nicht gesetzt, jedoch moechten wir + // !!! dann auch einen CharCode und machen die Behandlung deshalb + // !!! selber + if ( (nKeyFlags & KC_CHAR) || (nKeyFlags & KC_CTRL) || (nKeyFlags & KC_ALT) ) + rSVCharCode = (xub_Unicode)nCharCode; + + // Bei KeyUp muessen wir ein paar andere Ausnahmen machen, da + // uns in den meisten Faellen kein KeyCode geliefert wird, aber + // dafuer ein CharCode, wo jedoch nicht KC_CHAR gesetzt ist. + if ( nKeyFlags & KC_KEYUP ) + { + if ( !rSVCode ) + { + // Hier nur CharCode zuweisen, der KeyCode wird im unteren + // Teil dieser Function dann aus dem CharCode ermittelt + if ( !rSVCharCode && nCharCode ) + rSVCharCode = (xub_Unicode)nCharCode; + } + } + + // Wenn kein KeyCode ermittelt werden konnte, versuchen wir aus dem + // CharCode einen zu erzeugen + if ( !rSVCode && rSVCharCode ) + { + // Bei 0-9, a-z und A-Z auch KeyCode setzen + if ( (rSVCharCode >= '0') && (rSVCharCode <= '9') && (!rSVCode || !(nKeyFlags & KC_SHIFT)) ) + rSVCode = KEY_0 + (rSVCharCode-'0'); + else if ( (rSVCharCode >= 'a') && (rSVCharCode <= 'z') ) + rSVCode = KEY_A + (rSVCharCode-'a'); + else if ( (rSVCharCode >= 'A') && (rSVCharCode <= 'Z') ) + rSVCode = KEY_A + (rSVCharCode-'A'); + else + { + switch ( rSVCharCode ) + { + case '+': + rSVCode = KEY_ADD; + break; + case '-': + rSVCode = KEY_SUBTRACT; + break; + case '*': + rSVCode = KEY_MULTIPLY; + break; + case '/': + rSVCode = KEY_DIVIDE; + break; + case '.': + rSVCode = KEY_POINT; + break; + case ',': + rSVCode = KEY_COMMA; + break; + case '<': + rSVCode = KEY_LESS; + break; + case '>': + rSVCode = KEY_GREATER; + break; + case '=': + rSVCode = KEY_EQUAL; + break; + } + } + } + + // "Numlock-Hack": we want to get correct keycodes from the numpad + if ( (rSVCharCode >= '0') && (rSVCharCode <= '9') ) + rSVCode = KEY_0 + (rSVCharCode-'0'); + if ( rSVCharCode == ',' ) + rSVCode = KEY_COMMA; + if ( rSVCharCode == '.' ) + rSVCode = KEY_POINT; + + if ( nKeyFlags & KC_CTRL ) + { + // Ist CTRL-Taste gedrueckt, dann Char-Code korrigieren + if ( (rSVCharCode >= 'a') && (rSVCharCode <= 'z') ) + rSVCharCode -= ('a' - 1); + + // Ist CTRL-Taste gedrueckt, dann Char-Code auf 0 setzen, wenn + // der CharCode nicht < 32 ist + if ( ((unsigned char)rSVCharCode) >= 32 ) + rSVCharCode = 0; + } +} + +// ----------------------------------------------------------------------- + +static long ImplHandleKeyMsg( SalFrame* pFrame, + UINT nMsg, MPARAM nMP1, MPARAM nMP2 ) +{ + static USHORT nLastOS2KeyChar = 0; + static xub_Unicode nLastChar = 0; + USHORT nRepeat = CHAR3FROMMP( nMP1 ) - 1; + SHORT nFlags = SHORT1FROMMP( nMP1 ); + USHORT nModCode = 0; + USHORT nSVCode = 0; + USHORT nOS2KeyCode = (UCHAR)SHORT2FROMMP( nMP2 ); + xub_Unicode nSVCharCode = 0; + long nRet = 0; + + // determine modifiers + if ( nFlags & KC_SHIFT ) + nModCode |= KEY_SHIFT; + if ( nFlags & KC_CTRL ) + nModCode |= KEY_MOD1; + if ( nFlags & KC_ALT ) + { + nModCode |= KEY_MOD2; + // Nur wenn nicht Control und kein auswertbarer CharCode + // Wegen AltGr (vorallem wegen 122-Tastaturen auch KC_CHAR testen) + if ( !(nModCode & KEY_MOD1) && !(nFlags & KC_CHAR) ) + nModCode |= KEY_CONTROLMOD; + } + + // Bei Shift, Control und Alt schicken wir einen KeyModChange-Event + if ( (nOS2KeyCode == VK_SHIFT) || (nOS2KeyCode == VK_CTRL) || + (nOS2KeyCode == VK_ALT) || (nOS2KeyCode == VK_ALTGRAF) ) + { + SalKeyModEvent aModEvt; + aModEvt.mnTime = WinQueryMsgTime( pFrame->maFrameData.mhAB ); + aModEvt.mnCode = nModCode; + nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_KEYMODCHANGE, &aModEvt ); + } + else + { + ImplConvertKey( nMP1, nMP2, nSVCode, nSVCharCode ); + + // Fuer Java muessen wir bei KeyUp einen CharCode liefern + if ( nFlags & KC_KEYUP ) + { + if ( !nSVCharCode ) + { + if ( nLastOS2KeyChar == nOS2KeyCode ) + { + nSVCharCode = nLastChar; + nLastOS2KeyChar = 0; + nLastChar = 0; + } + } + else + { + nLastOS2KeyChar = 0; + nLastChar = 0; + } + } + else + { + nLastOS2KeyChar = nOS2KeyCode; + nLastChar = nSVCharCode; + } + + if ( nSVCode || nSVCharCode ) + { + SalKeyEvent aKeyEvt; + aKeyEvt.mnCode = nSVCode; + aKeyEvt.mnTime = WinQueryMsgTime( pFrame->maFrameData.mhAB ); + aKeyEvt.mnCode |= nModCode; + aKeyEvt.mnCharCode = nSVCharCode; + aKeyEvt.mnRepeat = nRepeat; + + nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + (nFlags & KC_KEYUP) ? SALEVENT_KEYUP : SALEVENT_KEYINPUT, + &aKeyEvt ); + } + } + + return nRet; +} + +// ----------------------------------------------------------------------- + +static void ImplHandlePaintMsg( SalFrame* pFrame ) +{ + HPS hPS; + RECTL aRect; + + hPS = WinBeginPaint( pFrame->maFrameData.mhWndClient, NULLHANDLE, &aRect ); + + // convert rectangle sys -> sal + aRect.yTop = pFrame->maFrameData.mnHeight - aRect.yTop; + aRect.yBottom = pFrame->maFrameData.mnHeight - aRect.yBottom; + + // Paint + SalPaintEvent aPEvt; + aPEvt.mnBoundX = aRect.xLeft; + aPEvt.mnBoundY = aRect.yTop; + aPEvt.mnBoundWidth = aRect.xRight - aRect.xLeft; + aPEvt.mnBoundHeight = aRect.yBottom - aRect.yTop; + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_PAINT, &aPEvt ); + + WinEndPaint( hPS ); +} + +// ----------------------------------------------------------------------- + +static void ImplHandleMoveMsg( SalFrame* pFrame ) +{ + pFrame->maFrameData.mbDefPos = FALSE; + + // Gegen moegliche Rekursionen sichern + if ( !pFrame->maFrameData.mbInMoveMsg ) + { + // Fenster im FullScreenModus wieder einpassen + pFrame->maFrameData.mbInMoveMsg = TRUE; + if ( pFrame->maFrameData.mbFullScreen ) + ImplSalFrameFullScreenPos( pFrame ); + pFrame->maFrameData.mbInMoveMsg = FALSE; + } + + // Status merken + ImplSaveFrameState( pFrame ); +} + +// ----------------------------------------------------------------------- + +static long ImplHandleSizeMsg( SalFrame* pFrame, MPARAM nMP2 ) +{ + pFrame->maFrameData.mbDefPos = FALSE; + pFrame->maFrameData.mnWidth = (short)SHORT1FROMMP( nMP2 ); + pFrame->maFrameData.mnHeight = (short)SHORT2FROMMP( nMP2 ); + if ( pFrame->maFrameData.mpGraphics ) + pFrame->maFrameData.mpGraphics->maGraphicsData.mnHeight = (int)SHORT2FROMMP(nMP2); + // Status merken + ImplSaveFrameState( pFrame ); + long nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_RESIZE, 0 ); + if ( WinIsWindowVisible( pFrame->maFrameData.mhWndFrame ) && !pFrame->maFrameData.mbInShow ) + WinUpdateWindow( pFrame->maFrameData.mhWndClient ); + return nRet; +} + +// ----------------------------------------------------------------------- + +static void ImplHandleShowMsg( SalFrame* pFrame, MPARAM nMP1 ) +{ + if ( !pFrame->maFrameData.mbInShow ) + { + // Wenn wir von aussen gehidet/geshowed werden (beispielsweise + // Hide-Button oder Taskleiste), loesen wir einen Resize mit 0,0 aus, + // damit Dialoge trotzdem als System-Fenster angezeigt werden, oder + // lehnen das Show ab + if ( SHORT1FROMMP( nMP1 ) ) + { + // Show ablehen, wenn wir garnicht sichtbar sind + if ( !pFrame->maFrameData.mbVisible ) + { + pFrame->maFrameData.mbInShow = TRUE; + WinSetWindowPos( pFrame->maFrameData.mhWndFrame, 0, 0, 0, 0, 0, SWP_HIDE ); + pFrame->maFrameData.mbInShow = FALSE; + } + else + { + // Resize ausloesen, damit alter Status wieder + // hergestellt wird + pFrame->maFrameData.mbMinHide = FALSE; + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_RESIZE, 0 ); + } + } + else + { + // Resize ausloesen, damit VCL mitbekommt, das Fenster + // gehidet ist, bzw. keine Groesse mehr hat + pFrame->maFrameData.mbMinHide = TRUE; + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_RESIZE, 0 ); + } + } +} + +// ----------------------------------------------------------------------- + +static long ImplHandleFocusMsg( SalFrame* pFrame, MPARAM nMP2 ) +{ + if ( SHORT1FROMMP( nMP2 ) ) + { + if ( WinIsWindowVisible( pFrame->maFrameData.mhWndFrame ) && !pFrame->maFrameData.mbInShow ) + WinUpdateWindow( pFrame->maFrameData.mhWndClient ); + return pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_GETFOCUS, 0 ); + } + else + { + return pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_LOSEFOCUS, 0 ); + } +} + +// ----------------------------------------------------------------------- + +inline long ImplHandleCloseMsg( SalFrame* pFrame ) +{ + return pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_CLOSE, 0 ); +} + +// ----------------------------------------------------------------------- + +inline void ImplHandleUserEvent( SalFrame* pFrame, MPARAM nMP2 ) +{ + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_USEREVENT, (void*)nMP2 ); +} + +// ----------------------------------------------------------------------- + +#ifdef ENABLE_IME + +static long ImplHandleIMEStartConversion( SalFrame* pFrame ) +{ + long nRet = FALSE; + SalIMEData* pIMEData = GetSalIMEData(); + if ( pIMEData ) + { + HWND hWnd = pFrame->maFrameData.mhWndClient; + HIMI hIMI = 0; + pIMEData->mpGetIME( hWnd, &hIMI ); + if ( hIMI ) + { + PM_ULONG nProp; + if ( 0 != pIMEData->mpQueryIMEProperty( hIMI, QIP_PROPERTY, &nProp ) ) + pFrame->maFrameData.mbHandleIME = FALSE; + else + { + pFrame->maFrameData.mbHandleIME = !(nProp & PRP_SPECIALUI); + + } + if ( pFrame->maFrameData.mbHandleIME ) + { +/* Windows-Code, der noch nicht angepasst wurde !!! + // Cursor-Position ermitteln und aus der die Default-Position fuer + // das Composition-Fenster berechnen + SalCursorPosEvent aCursorPosEvt; + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_CURSORPOS, (void*)&aCursorPosEvt ); + COMPOSITIONFORM aForm; + memset( &aForm, 0, sizeof( aForm ) ); + if ( !aCursorPosEvt.mnWidth || !aCursorPosEvt.mnHeight ) + aForm.dwStyle |= CFS_DEFAULT; + else + { + aForm.dwStyle |= CFS_POINT; + aForm.ptCurrentPos.x = aCursorPosEvt.mnX; + aForm.ptCurrentPos.y = aCursorPosEvt.mnY; + } + ImmSetCompositionWindow( hIMC, &aForm ); + + // Den InputContect-Font ermitteln und diesem dem Composition-Fenster + // bekannt machen +*/ + + pFrame->maFrameData.mbConversionMode = TRUE; + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_STARTEXTTEXTINPUT, (void*)NULL ); + nRet = TRUE; + } + + pIMEData->mpReleaseIME( hWnd, hIMI ); + } + } + + return nRet; +} + +// ----------------------------------------------------------------------- + +static long ImplHandleIMEConversion( SalFrame* pFrame, MPARAM nMP2Param ) +{ + long nRet = FALSE; + SalIMEData* pIMEData = GetSalIMEData(); + if ( pIMEData ) + { + HWND hWnd = pFrame->maFrameData.mhWndClient; + HIMI hIMI = 0; + PM_ULONG nMP2 = (PM_ULONG)nMP2Param; + pIMEData->mpGetIME( hWnd, &hIMI ); + if ( hIMI ) + { + if ( nMP2 & (IMR_RESULT_RESULTSTRING | + IMR_CONV_CONVERSIONSTRING | IMR_CONV_CONVERSIONATTR | + IMR_CONV_CURSORPOS | IMR_CONV_CURSORATTR) ) + { + SalExtTextInputEvent aEvt; + aEvt.mnTime = WinQueryMsgTime( pFrame->maFrameData.mhAB ); + aEvt.mpTextAttr = NULL; + aEvt.mnCursorPos = 0; + aEvt.mnDeltaStart = 0; + aEvt.mbOnlyCursor = FALSE; + aEvt.mbCursorVisible = TRUE; + + PM_ULONG nBufLen = 0; + xub_Unicode* pBuf = NULL; + PM_ULONG nAttrBufLen = 0; + PM_BYTE* pAttrBuf = NULL; + BOOL bLastCursor = FALSE; + if ( nMP2 & IMR_RESULT_RESULTSTRING ) + { + pIMEData->mpGetResultString( hIMI, IMR_RESULT_RESULTSTRING, 0, &nBufLen ); + if ( nBufLen > 0 ) + { + pBuf = new xub_Unicode[nBufLen]; + pIMEData->mpGetResultString( hIMI, IMR_RESULT_RESULTSTRING, pBuf, &nBufLen ); + } + + bLastCursor = TRUE; + aEvt.mbCursorVisible = TRUE; + } + else if ( nMP2 & (IMR_CONV_CONVERSIONSTRING | IMR_CONV_CONVERSIONATTR | + IMR_CONV_CURSORPOS | IMR_CONV_CURSORATTR) ) + { + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONSTRING, 0, &nBufLen ); + if ( nBufLen > 0 ) + { + pBuf = new xub_Unicode[nBufLen]; + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONSTRING, pBuf, &nBufLen ); + } + + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONATTR, 0, &nAttrBufLen ); + if ( nAttrBufLen > 0 ) + { + pAttrBuf = new PM_BYTE[nAttrBufLen]; + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONATTR, pAttrBuf, &nAttrBufLen ); + } + +/* !!! Wir bekommen derzeit nur falsche Daten, deshalb zeigen wir derzeit + !!! auch keine Cursor an + PM_ULONG nTempBufLen; + PM_ULONG nCursorPos = 0; + PM_ULONG nCursorAttr = 0; + PM_ULONG nChangePos = 0; + nTempBufLen = sizeof( PM_ULONG ); + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORPOS, &nCursorPos, &nTempBufLen ); + nTempBufLen = sizeof( PM_ULONG ); + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORATTR, &nCursorAttr, &nTempBufLen ); + nTempBufLen = sizeof( PM_ULONG ); + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CHANGESTART, &nChangePos, &nTempBufLen ); + + aEvt.mnCursorPos = nCursorPos; + aEvt.mnDeltaStart = nChangePos; + if ( nCursorAttr & CP_CURSORATTR_INVISIBLE ) + aEvt.mbCursorVisible = FALSE; +*/ + aEvt.mnCursorPos = 0; + aEvt.mnDeltaStart = 0; + aEvt.mbCursorVisible = FALSE; + + if ( (nMP2 == IMR_CONV_CURSORPOS) || + (nMP2 == IMR_CONV_CURSORATTR) ) + aEvt.mbOnlyCursor = TRUE; + } + + USHORT* pSalAttrAry = NULL; + if ( pBuf ) + { + aEvt.maText = XubString( pBuf, (USHORT)nBufLen ); + delete pBuf; + if ( pAttrBuf ) + { + USHORT nTextLen = aEvt.maText.Len(); + if ( nTextLen ) + { + pSalAttrAry = new USHORT[nTextLen]; + memset( pSalAttrAry, 0, nTextLen*sizeof( USHORT ) ); + for ( USHORT i = 0; (i < nTextLen) && (i < nAttrBufLen); i++ ) + { + PM_BYTE nOS2Attr = pAttrBuf[i]; + USHORT nSalAttr; + if ( nOS2Attr == CP_ATTR_TARGET_CONVERTED ) + nSalAttr = SAL_EXTTEXTINPUT_ATTR_TARGETCONVERTED | SAL_EXTTEXTINPUT_ATTR_UNDERLINE | SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT; + else if ( nOS2Attr == CP_ATTR_CONVERTED ) + nSalAttr = SAL_EXTTEXTINPUT_ATTR_CONVERTED | SAL_EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE; + else if ( nOS2Attr == CP_ATTR_TARGET_NOTCONVERTED ) + nSalAttr = SAL_EXTTEXTINPUT_ATTR_TARGETNOTCONVERTED | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE; + else if ( nOS2Attr == CP_ATTR_INPUT_ERROR ) + nSalAttr = SAL_EXTTEXTINPUT_ATTR_INPUTERROR | SAL_EXTTEXTINPUT_ATTR_REDTEXT | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE; + else /* ( nOS2Attr == CP_ATTR_INPUT ) */ + nSalAttr = SAL_EXTTEXTINPUT_ATTR_INPUT | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE; + pSalAttrAry[i] = nSalAttr; + } + aEvt.mpTextAttr = pSalAttrAry; + } + delete pAttrBuf; + } + if ( bLastCursor ) + aEvt.mnCursorPos = aEvt.maText.Len(); + } + + pIMEData->mpReleaseIME( hWnd, hIMI ); + + // Handler rufen und wenn wir ein Attribute-Array haben, danach + // wieder zerstoeren + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_EXTTEXTINPUT, (void*)&aEvt ); + if ( pSalAttrAry ) + delete pSalAttrAry; + } + else + pIMEData->mpReleaseIME( hWnd, hIMI ); + } + + nRet = TRUE; + } + + return nRet; +} + +// ----------------------------------------------------------------------- + +inline long ImplHandleIMEEndConversion( SalFrame* pFrame ) +{ + pFrame->maFrameData.mbConversionMode = FALSE; + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_ENDEXTTEXTINPUT, (void*)NULL ); + return TRUE; +} + +// ----------------------------------------------------------------------- + +static void ImplHandleIMEOpenCandidate( SalFrame* pFrame ) +{ + pFrame->maFrameData.mbCandidateMode = TRUE; + + long nRet = FALSE; + SalIMEData* pIMEData = GetSalIMEData(); + if ( pIMEData ) + { + HWND hWnd = pFrame->maFrameData.mhWndClient; + HIMI hIMI = 0; + pIMEData->mpGetIME( hWnd, &hIMI ); + if ( hIMI ) + { + PM_ULONG nBufLen = 0; + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONSTRING, 0, &nBufLen ); + if ( nBufLen > 0 ) + { +/* !!! Wir bekommen derzeit nur falsche Daten steht der Cursor immer bei 0 + PM_ULONG nTempBufLen = sizeof( PM_ULONG ); + PM_ULONG nCursorPos = 0; + pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORPOS, &nCursorPos, &nTempBufLen ); +*/ + PM_ULONG nCursorPos = 0; + + SalExtTextInputPosEvent aEvt; + aEvt.mnTime = WinQueryMsgTime( pFrame->maFrameData.mhAB ); + aEvt.mnFirstPos = nCursorPos; + aEvt.mnChars = nBufLen-nCursorPos; + aEvt.mpPosAry = new SalExtCharPos[aEvt.mnChars]; + memset( aEvt.mpPosAry, 0, aEvt.mnChars*sizeof(SalExtCharPos) ); + + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_EXTTEXTINPUTPOS, (void*)&aEvt ); + + long nMinLeft = aEvt.mpPosAry[0].mnX; + long nMinTop = aEvt.mpPosAry[0].mnY; + long nMaxBottom = aEvt.mpPosAry[0].mnY+aEvt.mpPosAry[0].mnHeight; + long nMaxRight = nMinLeft; + USHORT i = 0; + while ( i < aEvt.mnChars ) + { + // Solange wir uns auf der gleichen Zeile bewegen, + // ermitteln wir die Rechteck-Grenzen + if ( !aEvt.mpPosAry[i].mnHeight || + (aEvt.mpPosAry[i].mnY < nMaxBottom-1) ) + { + if ( aEvt.mpPosAry[i].mnX < nMinLeft ) + nMinLeft = aEvt.mpPosAry[i].mnX; + if ( aEvt.mpPosAry[i].mnX+aEvt.mpPosAry[0].mnWidth > nMaxRight ) + nMaxRight = aEvt.mpPosAry[i].mnX+aEvt.mpPosAry[0].mnWidth; + if ( aEvt.mpPosAry[i].mnY < nMinTop ) + nMinTop = aEvt.mpPosAry[i].mnY; + i++; + } + else + break; + } + + CANDIDATEPOS aForm; + aForm.ulIndex = 0; + aForm.ulStyle = CPS_EXCLUDE; + aForm.ptCurrentPos.x = aEvt.mpPosAry[0].mnX; + aForm.ptCurrentPos.y = pFrame->maFrameData.mnHeight - (nMaxBottom+1) - 1; + aForm.rcArea.xLeft = nMinLeft; + aForm.rcArea.yBottom = pFrame->maFrameData.mnHeight - nMaxBottom - 1; + aForm.rcArea.xRight = nMaxRight+1; + aForm.rcArea.yTop = pFrame->maFrameData.mnHeight - nMinTop - 1; + pIMEData->mpSetCandidateWin( hIMI, &aForm ); + + delete aEvt.mpPosAry; + } + + pIMEData->mpReleaseIME( hWnd, hIMI ); + } + } +} + +// ----------------------------------------------------------------------- + +inline void ImplHandleIMECloseCandidate( SalFrame* pFrame ) +{ + pFrame->maFrameData.mbCandidateMode = FALSE; +} + +#endif + +// ----------------------------------------------------------------------- + +MRESULT EXPENTRY SalFrameWndProc( HWND hWnd, PM_ULONG nMsg, + MPARAM nMP1, MPARAM nMP2 ) +{ + SalFrame* pFrame = GetWindowPtr( hWnd ); + MRESULT nRet = (MRESULT)0; + BOOL bDef = TRUE; + + switch( nMsg ) + { + case WM_MOUSEMOVE: + case WM_BUTTON1DOWN: + case WM_BUTTON2DOWN: + case WM_BUTTON3DOWN: + case WM_BUTTON1DBLCLK: + case WM_BUTTON2DBLCLK: + case WM_BUTTON3DBLCLK: + case WM_BUTTON1UP: + case WM_BUTTON2UP: + case WM_BUTTON3UP: + case SAL_MSG_MOUSELEAVE: + // ButtonUp/Down nie an die WinDefWindowProc weiterleiten, weil sonst + // die Message an den Owner weitergeleitet wird + bDef = !ImplHandleMouseMsg( pFrame, nMsg, nMP1, nMP2 ); + break; + + case WM_CHAR: + if ( pFrame->maFrameData.mbConversionMode ) + bDef = FALSE; + else + bDef = !ImplHandleKeyMsg( pFrame, nMsg, nMP1, nMP2 ); + break; + + case WM_ERASEBACKGROUND: + nRet = (MRESULT)FALSE; + bDef = FALSE; + break; + + case WM_PAINT: + ImplSalYieldMutexAcquire(); + ImplHandlePaintMsg( pFrame ); + ImplSalYieldMutexRelease(); + bDef = FALSE; + break; + + case WM_TIMER: + { + SalData* pSalData = GetSalData(); + // Test for MouseLeave + SalTestMouseLeave(); + if ( pSalData->mnTimerId == SHORT1FROMMP( nMP1 ) ) + pSalData->mpTimerProc(); + } + break; + + case WM_MOVE: + ImplHandleMoveMsg( pFrame ); + bDef = FALSE; + break; + + case WM_SIZE: + if ( ImplSalYieldMutexTryToAcquire() ) + { + ImplHandleSizeMsg( pFrame, nMP2 ); + ImplSalYieldMutexRelease(); + } + else + WinPostMsg( hWnd, SAL_MSG_POSTSIZE, nMP1, nMP2 ); + break; + case SAL_MSG_POSTSIZE: + ImplHandleSizeMsg( pFrame, nMP2 ); + break; + + case WM_CALCVALIDRECTS: + return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP); + + case WM_SETFOCUS: + if ( ImplSalYieldMutexTryToAcquire() ) + { + ImplHandleFocusMsg( pFrame, nMP2 ); + ImplSalYieldMutexRelease(); + } + else + WinPostMsg( hWnd, SAL_MSG_POSTFOCUS, 0, nMP2 ); + break; + case SAL_MSG_POSTFOCUS: + ImplHandleFocusMsg( pFrame, nMP2 ); + break; + + case WM_TRANSLATEACCEL: + { + // Da uns OS/2 zu viele Tasten abfaegnt, unternehmen wir etwas, + // damit wir Shift+F1, Shift+F10 und Shift+Enter bekommen + PQMSG pMsg = (PQMSG)nMP1; + USHORT nKeyFlags = SHORT1FROMMP( pMsg->mp1 ); + USHORT nKeyCode = (UCHAR)SHORT2FROMMP( pMsg->mp2 ); + + if ( !(nKeyFlags & KC_KEYUP) && (nKeyFlags & KC_VIRTUALKEY) && + (nKeyFlags & KC_SHIFT) && (nKeyCode != VK_ESC) ) + return (MRESULT)FALSE; + + if ( nKeyCode == VK_F1 ) + return (MRESULT)FALSE; + } + break; + + case WM_CREATE: + { + SalData* pSalData = GetSalData(); + // Window-Instanz am Windowhandle speichern + pFrame = pSalData->mpCreateFrame; + pSalData->mpCreateFrame = NULL; + SetWindowPtr( hWnd, pFrame ); + } + break; + + case WM_CLOSE: + ImplSalYieldMutexAcquire(); + ImplHandleCloseMsg( pFrame ); + ImplSalYieldMutexRelease(); + bDef = FALSE; + break; + + case WM_SYSVALUECHANGED: + if ( pFrame->maFrameData.mbFullScreen ) + ImplSalFrameFullScreenPos( pFrame ); + // kein break, da der Rest auch noch verarbeitet werden soll + case PL_ALTERED: + case WM_SYSCOLORCHANGE: + ImplSalYieldMutexAcquire(); + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_SETTINGSCHANGED, 0 ); + ImplSalYieldMutexRelease(); + break; + + case SAL_MSG_USEREVENT: + ImplHandleUserEvent( pFrame, nMP2 ); + bDef = FALSE; + break; + + case WM_COMMAND: + case SAL_MSG_SYSPROCESSMENU: + if ( SalImplHandleProcessMenu( hWnd, nMsg, nMP1, nMP2 ) ) + { + bDef = FALSE; + nRet = (MRESULT)1; + } + break; + +#ifdef ENABLE_IME + case WM_IMEREQUEST: + if ( (PM_ULONG)nMP1 == IMR_CONVRESULT ) + { + if ( pFrame->maFrameData.mbHandleIME ) + { + // Nur im Conversionmodus akzeptieren wir den IME-Input + if ( pFrame->maFrameData.mbConversionMode ) + { + ImplSalYieldMutexAcquire(); + if ( ImplHandleIMEConversion( pFrame, nMP2 ) ) + { + bDef = FALSE; + nRet = (MRESULT)TRUE; + } + ImplSalYieldMutexRelease(); + } + } + } + else if ( (PM_ULONG)nMP1 == IMR_CANDIDATE ) + { + if ( pFrame->maFrameData.mbHandleIME ) + { + ImplSalYieldMutexAcquire(); + if ( (PM_ULONG)nMP2 & IMR_CANDIDATE_SHOW ) + ImplHandleIMEOpenCandidate( pFrame ); + else if ( (PM_ULONG)nMP2 & IMR_CANDIDATE_HIDE ) + ImplHandleIMECloseCandidate( pFrame ); + ImplSalYieldMutexRelease(); + } + } + break; + + case WM_IMENOTIFY: + if ( (PM_ULONG)nMP1 == IMN_STARTCONVERSION ) + { + ImplSalYieldMutexAcquire(); + if ( ImplHandleIMEStartConversion( pFrame ) ) + { + bDef = FALSE; + nRet = (MRESULT)TRUE; + } + ImplSalYieldMutexRelease(); + } + else if ( (PM_ULONG)nMP1 == IMN_ENDCONVERSION ) + { + if ( pFrame->maFrameData.mbHandleIME ) + { + ImplSalYieldMutexAcquire(); + if ( ImplHandleIMEEndConversion( pFrame ) ) + { + bDef = FALSE; + nRet = (MRESULT)TRUE; + } + ImplSalYieldMutexRelease(); + } + } + break; +#endif + } + + if ( bDef ) + nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); + + return nRet; +} + +// ----------------------------------------------------------------------- + +MRESULT EXPENTRY SalFrameFrameProc( HWND hWnd, PM_ULONG nMsg, + MPARAM nMP1, MPARAM nMP2 ) +{ + if ( nMsg == WM_SYSCOMMAND ) + { + HWND hWndClient = WinWindowFromID( hWnd, FID_CLIENT ); + if( hWndClient ) + { + SalFrame* pFrame = GetWindowPtr( hWndClient ); + if ( pFrame ) + { + USHORT nCmd = SHORT1FROMMP( nMP1 ); + if ( pFrame->maFrameData.mbFullScreen ) + { + if ( (nCmd == SC_SIZE) || (nCmd == SC_MOVE) || + (nCmd == SC_RESTORE) || + (nCmd == SC_MINIMIZE) || (nCmd == SC_MAXIMIZE) ) + { + WinAlarm( HWND_DESKTOP, WA_NOTE ); + return 0; + } + } + + if ( nCmd == SC_APPMENU ) + { + // KeyInput mit MENU-Key rufen + SalKeyEvent aKeyEvt; + aKeyEvt.mnTime = WinQueryMsgTime( pFrame->maFrameData.mhAB ); + aKeyEvt.mnCode = KEY_MENU; + aKeyEvt.mnCharCode = 0; + aKeyEvt.mnRepeat = 0; + long nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_KEYINPUT, &aKeyEvt ); + pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, + SALEVENT_KEYUP, &aKeyEvt ); + if ( nRet ) + return (MRESULT)0; + } + } + } + } + else if ( nMsg == WM_SHOW ) + { + HWND hWndClient = WinWindowFromID( hWnd, FID_CLIENT ); + if( hWndClient ) + { + SalFrame* pFrame = GetWindowPtr( hWndClient ); + if ( pFrame ) + ImplHandleShowMsg( pFrame, nMP1 ); + } + } + + return aSalShlData.mpOldFrameProc( hWnd, nMsg, nMP1, nMP2 ); +} diff --git a/vcl/os2/source/window/salobj.cxx b/vcl/os2/source/window/salobj.cxx new file mode 100644 index 000000000000..a5023e3e4301 --- /dev/null +++ b/vcl/os2/source/window/salobj.cxx @@ -0,0 +1,605 @@ +/************************************************************************* + * + * $RCSfile: salobj.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:05:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#define _SV_SALOBJ_CXX + +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_HXX +#include +#endif +#ifndef _SV_SALFRAME_HXX +#include +#endif +#ifndef _SV_SALOBJ_HXX +#include +#endif + +// ======================================================================= + +static BOOL ImplIsSysWindowOrChild( HWND hWndParent, HWND hWndChild ) +{ + if ( hWndParent == hWndChild ) + return TRUE; + + HWND hTempWnd = WinQueryWindow( hWndChild, QW_PARENT ); + while ( hTempWnd ) + { + if ( hTempWnd == hWndParent ) + return TRUE; + hTempWnd = WinQueryWindow( hTempWnd, QW_PARENT ); + } + + return FALSE; +} + +// ----------------------------------------------------------------------- + +static SalObject* ImplFindSalObject( HWND hWndChild ) +{ + SalData* pSalData = GetSalData(); + SalObject* pObject = pSalData->mpFirstObject; + while ( pObject ) + { + if ( ImplIsSysWindowOrChild( pObject->maObjectData.mhWndChild, hWndChild ) ) + return pObject; + + pObject = pObject->maObjectData.mpNextObject; + } + + return NULL; +} + +// ======================================================================= + +PM_BOOL EXPENTRY SalSysMsgProc( HAB /* hAB */, QMSG* pMsg, PM_ULONG /* fs */ ) +{ + if ( (pMsg->msg == WM_BUTTON1DOWN) || + (pMsg->msg == WM_BUTTON2DOWN) || + (pMsg->msg == WM_BUTTON3DOWN) ) + { + SalData* pSalData = GetSalData(); + SalObject* pObject = ImplFindSalObject( pMsg->hwnd ); + if ( pObject ) + WinPostMsg( pObject->maObjectData.mhWnd, SALOBJ_MSG_TOTOP, 0, 0 ); + } + + // Focus fangen wir hier nicht ab, da wir erstmal davon ausgehen, + // das unser SalObject-Fenster immer eine WM_FOCUSCHANGE-Message + // bekommt. + + return FALSE; +} + +// ----------------------------------------------------------------------- + +MRESULT EXPENTRY SalSysObjWndProc( HWND hWnd, PM_ULONG nMsg, + MPARAM nMP1, MPARAM nMP2 ) +{ + SalObject* pSysObj; + MRESULT nRet = 0; + int bDef = TRUE; + + switch( nMsg ) + { + case WM_ERASEBACKGROUND: + nRet = (MRESULT)FALSE; + bDef = FALSE; + break; + case WM_PAINT: + { + HPS hPS; + RECTL aRect; + hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); + WinEndPaint( hPS ); + bDef = FALSE; + } + bDef = FALSE; + break; + + case WM_BUTTON1DOWN: + case WM_BUTTON2DOWN: + case WM_BUTTON3DOWN: + case SALOBJ_MSG_TOTOP: + if ( ImplSalYieldMutexTryToAcquire() ) + { + pSysObj = GetSalObjWindowPtr( hWnd ); + pSysObj->maObjectData.mpProc( pSysObj->maObjectData.mpInst, pSysObj, + SALOBJ_EVENT_TOTOP, 0 ); + ImplSalYieldMutexRelease(); + } + else + WinPostMsg( hWnd, SALOBJ_MSG_TOTOP, 0, 0 ); + break; + + case WM_FOCUSCHANGE: + case SALOBJ_MSG_POSTFOCUS: + if ( ImplSalYieldMutexTryToAcquire() ) + { + pSysObj = GetSalObjWindowPtr( hWnd ); + if ( SHORT1FROMMP( nMP2 ) ) + { + pSysObj->maObjectData.mhLastFocusWnd = WinQueryFocus( HWND_DESKTOP ); + pSysObj->maObjectData.mpProc( pSysObj->maObjectData.mpInst, pSysObj, + SALOBJ_EVENT_GETFOCUS, 0 ); + } + else + { + HWND hWndFocus = HWNDFROMMP( nMP1 ); + if ( !hWndFocus || !ImplIsSysWindowOrChild( hWnd, hWndFocus ) ) + { + pSysObj->maObjectData.mpProc( pSysObj->maObjectData.mpInst, pSysObj, + SALOBJ_EVENT_LOSEFOCUS, 0 ); + } + } + ImplSalYieldMutexRelease(); + } + else + WinPostMsg( hWnd, SALOBJ_MSG_POSTFOCUS, nMP1, nMP2 ); + break; + + case WM_SIZE: + { + pSysObj = GetSalObjWindowPtr( hWnd ); + pSysObj->maObjectData.mnHeight = (short)SHORT2FROMMP( nMP2 ); + WinSetWindowPos( pSysObj->maObjectData.mhWndChild, 0, + 0, 0, + (short)SHORT1FROMMP( nMP2 ), (short)SHORT2FROMMP( nMP2 ), + SWP_SIZE | SWP_MOVE ); + bDef = FALSE; + } + break; + + case WM_CREATE: + { + // Window-Instanz am Windowhandle speichern + CREATESTRUCT* pStruct = (CREATESTRUCT*)nMP2; + pSysObj = (SalObject*)pStruct->pPresParams; + SetSalObjWindowPtr( hWnd, pSysObj ); + bDef = FALSE; + } + break; + } + + if ( bDef ) + nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); + return nRet; +} + +// ----------------------------------------------------------------------- + +MRESULT EXPENTRY SalSysObjChildWndProc( HWND hWnd, PM_ULONG nMsg, + MPARAM nMP1, MPARAM nMP2 ) +{ + MRESULT nRet = 0; + int bDef = TRUE; + + switch( nMsg ) + { + case WM_ERASEBACKGROUND: + // Wegen PlugIn's loeschen wir erstmal den Hintergrund +/* + nRet = (MRESULT)FALSE; + bDef = FALSE; +*/ + break; + case WM_PAINT: + { + HPS hPS; + RECTL aRect; + hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); + WinEndPaint( hPS ); + bDef = FALSE; + } + break; + } + + if ( bDef ) + nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); + return nRet; +} + +// ----------------------------------------------------------------------- + +MRESULT EXPENTRY SalSysObjClipWndProc( HWND hWnd, PM_ULONG nMsg, + MPARAM nMP1, MPARAM nMP2 ) +{ + MRESULT nRet = 0; + int bDef = TRUE; + + switch( nMsg ) + { + case WM_MOUSEMOVE: + case WM_BUTTON1DOWN: + case WM_BUTTON2DOWN: + case WM_BUTTON3DOWN: + case WM_BUTTON1DBLCLK: + case WM_BUTTON2DBLCLK: + case WM_BUTTON3DBLCLK: + case WM_BUTTON1UP: + case WM_BUTTON2UP: + case WM_BUTTON3UP: + { + // Alle Events an den Frame weiterreichen, da diese Bereiche + // dem Frame gehoeren. Dazu muessen die Mouse-Koordinaaten + // entsprechend umgerechnet werden + HWND hWndParent = WinQueryWindow( hWnd, QW_PARENT ); // ergibt SysChild-Fenster + hWndParent = WinQueryWindow( hWndParent, QW_PARENT ); + short nX = (short)SHORT1FROMMP( nMP1 ); + short nY = (short)SHORT2FROMMP( nMP1 ); + POINTL aPos; + aPos.x = nX; + aPos.y = nY; + WinMapWindowPoints( hWnd, hWndParent, &aPos, 1 ); + nMP1 = MPFROM2SHORT( (short)aPos.x, (short)aPos.y ); + bDef = FALSE; + nRet = WinSendMsg( hWndParent, nMsg, nMP1, nMP2 ); + } + break; + + case WM_HITTEST: + // Damit im disablten Zustand die MouseKlicks immer noch + // an den Frame geschickt werden + // Dieser Code reicht leider nicht aus, deshalb wir unter + // OS2 immer das Child-Fenster disablen, im Gegensatz + // zu Windows, wo immer der Parent disablte wird, da + // sich das Fenster evtl. anders Darstellen koennte, + // wenn es disablte wird. Da dieser Fall uns bisher + // nicht bekannt ist, ignorieren wir das. + nRet = HT_NORMAL; + bDef = FALSE; + break; + + case WM_ERASEBACKGROUND: + nRet = (MRESULT)FALSE; + bDef = FALSE; + break; + case WM_PAINT: + { + HPS hPS; + RECTL aRect; + hPS = WinBeginPaint( hWnd, NULLHANDLE, &aRect ); + WinEndPaint( hPS ); + bDef = FALSE; + } + break; + } + + if ( bDef ) + nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); + return nRet; +} + +// ======================================================================= + +void ImplDestroyAllClipWindows( HWND hWndLast ) +{ + if ( hWndLast == HWND_TOP ) + return; + + HWND hWndPrev; + while ( hWndLast ) + { + hWndPrev = WinQueryWindow( hWndLast, QW_PREV ); + WinDestroyWindow( hWndLast ); + hWndLast = hWndPrev; + } +} + +// ======================================================================= + +SalObject* ImplSalCreateObject( SalInstance* pInst, SalFrame* pParent ) +{ + SalData* pSalData = GetSalData(); + + if ( !pSalData->mbObjClassInit ) + { + if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CLASSNAME, + (PFNWP)SalSysObjWndProc, CS_MOVENOTIFY, + SAL_OBJECT_WNDEXTRA ) ) + { + if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CLIPCLASSNAME, + (PFNWP)SalSysObjClipWndProc, CS_HITTEST | CS_MOVENOTIFY, 0 ) ) + { + if ( WinRegisterClass( pSalData->mhAB, (PSZ)SAL_OBJECT_CHILDCLASSNAME, + (PFNWP)SalSysObjChildWndProc, CS_HITTEST | CS_MOVENOTIFY, 32 ) ) + pSalData->mbObjClassInit = TRUE; + } + } + } + + if ( pSalData->mbObjClassInit ) + { + SalObject* pObject = new SalObject; + HWND hWnd = WinCreateWindow( pParent->maFrameData.mhWndClient, SAL_OBJECT_CLASSNAME, "", + 0, + 0, 0, 0, 0, + pParent->maFrameData.mhWndClient, HWND_TOP, + 0, NULL, (void*)pObject ); + HWND hWndChild = WinCreateWindow( hWnd, SAL_OBJECT_CHILDCLASSNAME, "", + WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, + 0, 0, 0, 0, + hWnd, HWND_TOP, + 0, NULL, NULL ); + + if ( !hWndChild ) + { + if ( hWnd ) + WinDestroyWindow( hWnd ); + delete pObject; + return NULL; + } + + if ( hWnd ) + { + pObject->maObjectData.mhWnd = hWnd; + pObject->maObjectData.mhWndChild = hWndChild; + pObject->maObjectData.maSysData.hWnd = hWndChild; + return pObject; + } + } + + return NULL; +} + +// ----------------------------------------------------------------------- + +void SalInstance::DestroyObject( SalObject* pObject ) +{ + delete pObject; +} + +// ======================================================================= + +long ImplSalObjCallbackDummy( void*, SalObject*, USHORT, const void* ) +{ + return 0; +} + +// ======================================================================= + +SalObject::SalObject() +{ + SalData* pSalData = GetSalData(); + + maObjectData.mhLastClipWnd = HWND_TOP; + + maObjectData.mhWnd = 0; + maObjectData.mhWndChild = 0; + maObjectData.mhLastFocusWnd = 0; + maObjectData.maSysData.nSize = sizeof( SystemEnvData ); + maObjectData.mnHeight = 0; + maObjectData.mpInst = NULL; + maObjectData.mpProc = ImplSalObjCallbackDummy; + + // Hook installieren, wenn es das erste SalObject ist + if ( !pSalData->mpFirstObject ) + { + WinSetHook( pSalData->mhAB, pSalData->mhMQ, + HK_INPUT, (PFN)SalSysMsgProc, (HMODULE)0 ); + } + + // Insert object in objectlist + maObjectData.mpNextObject = pSalData->mpFirstObject; + pSalData->mpFirstObject = this; +} + +// ----------------------------------------------------------------------- + +SalObject::~SalObject() +{ + SalData* pSalData = GetSalData(); + + // remove frame from framelist + if ( this == pSalData->mpFirstObject ) + { + pSalData->mpFirstObject = maObjectData.mpNextObject; + + // Wenn letztes SalObject, dann Hook wieder entfernen + if ( !pSalData->mpFirstObject ) + { + WinReleaseHook( pSalData->mhAB, pSalData->mhMQ, + HK_INPUT, (PFN)SalSysMsgProc, (HMODULE)0 ); + } + } + else + { + SalObject* pTempObject = pSalData->mpFirstObject; + while ( pTempObject->maObjectData.mpNextObject != this ) + pTempObject = pTempObject->maObjectData.mpNextObject; + + pTempObject->maObjectData.mpNextObject = maObjectData.mpNextObject; + } + + // Cache-Daten zerstoeren + ImplDestroyAllClipWindows( maObjectData.mhLastClipWnd ); + + if ( maObjectData.mhWndChild ) + WinDestroyWindow( maObjectData.mhWndChild ); + if ( maObjectData.mhWnd ) + WinDestroyWindow( maObjectData.mhWnd ); +} + +// ----------------------------------------------------------------------- + +void SalObject::ResetClipRegion() +{ + ImplDestroyAllClipWindows( maObjectData.mhLastClipWnd ); + maObjectData.mhLastClipWnd = HWND_TOP; +} + +// ----------------------------------------------------------------------- + +USHORT SalObject::GetClipRegionType() +{ + return SAL_OBJECT_CLIP_EXCLUDERECTS; +} + +// ----------------------------------------------------------------------- + +void SalObject::BeginSetClipRegion( ULONG nRectCount ) +{ + maObjectData.mhOldLastClipWnd = maObjectData.mhLastClipWnd; +} + +// ----------------------------------------------------------------------- + +void SalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) +{ + HWND hClipWnd = WinCreateWindow( maObjectData.mhWnd, SAL_OBJECT_CLIPCLASSNAME, "", + WS_VISIBLE, + nX, maObjectData.mnHeight-(nY+nHeight), nWidth, nHeight, + maObjectData.mhWnd, maObjectData.mhLastClipWnd, + 0, NULL, NULL ); + maObjectData.mhLastClipWnd = hClipWnd; +} + +// ----------------------------------------------------------------------- + +void SalObject::EndSetClipRegion() +{ + ImplDestroyAllClipWindows( maObjectData.mhOldLastClipWnd ); +} + +// ----------------------------------------------------------------------- + +void SalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) +{ + PM_ULONG nStyle = 0; + PM_BOOL bVisible = WinIsWindowVisible( maObjectData.mhWnd ); + if ( bVisible ) + { + WinShowWindow( maObjectData.mhWnd, FALSE ); + nStyle |= SWP_SHOW; + } + SWP aParentSWP; + WinQueryWindowPos( WinQueryWindow( maObjectData.mhWnd, QW_PARENT ), &aParentSWP ); + WinSetWindowPos( maObjectData.mhWnd, 0, nX, aParentSWP.cy-(nY+nHeight), nWidth, nHeight, + SWP_MOVE | SWP_SIZE | nStyle ); +} + +// ----------------------------------------------------------------------- + +void SalObject::Show( BOOL bVisible ) +{ + WinShowWindow( maObjectData.mhWnd, bVisible ); +} + +// ----------------------------------------------------------------------- + +void SalObject::Enable( BOOL bEnable ) +{ + // Im Gegensatz zu Windows disablen wir das Childfenster, + // da ansonsten unser Clippen nicht mehr funktioniert, da + // wir keine Events mehr bekommen. Dadurch kann sich evtl. + // das Fenster anders darstellen, was wir eigentlich nicht + // wollen. Aber da uns bisher kein Fall bekannt ist, + // ignorieren wir dies. Ansonsten muss ein Fenster dazwischen + // gezogen werden oder getestet werden, wie wir die + // Maustransparenz erreichen, wenn maObjectData.mhWnd + // disablte wird. + WinEnableWindow( maObjectData.mhWndChild, bEnable ); +} + +// ----------------------------------------------------------------------- + +void SalObject::GrabFocus() +{ + if ( maObjectData.mhLastFocusWnd && + WinIsWindow( GetSalData()->mhAB, maObjectData.mhLastFocusWnd ) && + ImplIsSysWindowOrChild( maObjectData.mhWndChild, maObjectData.mhLastFocusWnd ) ) + WinSetFocus( HWND_DESKTOP, maObjectData.mhLastFocusWnd ); + else + WinSetFocus( HWND_DESKTOP, maObjectData.mhWndChild ); +} + +// ----------------------------------------------------------------------- + +void SalObject::SetBackground() +{ +} + +// ----------------------------------------------------------------------- + +void SalObject::SetBackground( SalColor nSalColor ) +{ +} + +// ----------------------------------------------------------------------- + +const SystemChildData* SalObject::GetSystemData() const +{ + return &maObjectData.maSysData; +} + +// ----------------------------------------------------------------------- + +void SalObject::SetCallback( void* pInst, SALOBJECTPROC pProc ) +{ + maObjectData.mpInst = pInst; + if ( pProc ) + maObjectData.mpProc = pProc; + else + maObjectData.mpProc = ImplSalObjCallbackDummy; +} -- cgit v1.2.3