diff options
author | Patrick Luby <pluby@openoffice.org> | 2000-11-01 21:12:34 +0000 |
---|---|---|
committer | Patrick Luby <pluby@openoffice.org> | 2000-11-01 21:12:34 +0000 |
commit | 4d9bd2d3d910f32cd3a57af45e42e89c6a93fa55 (patch) | |
tree | 7f51f5c8ed3dd77c5e3a7aa3dfda700f6be84646 | |
parent | a99f4e4fe1dc1ff04f459079d9f226052aba4af0 (diff) |
Removed all unused Windows code and data types from vcl/aqua code
-rw-r--r-- | vcl/aqua/inc/saldata.hxx | 251 | ||||
-rw-r--r-- | vcl/aqua/inc/salframe.h | 15 | ||||
-rw-r--r-- | vcl/aqua/inc/salgdi.h | 51 | ||||
-rw-r--r-- | vcl/aqua/inc/salinst.h | 15 | ||||
-rw-r--r-- | vcl/aqua/inc/salobj.h | 23 | ||||
-rw-r--r-- | vcl/aqua/inc/salprn.h | 28 | ||||
-rw-r--r-- | vcl/aqua/inc/salsys.h | 7 | ||||
-rw-r--r-- | vcl/aqua/inc/salvd.h | 13 | ||||
-rw-r--r-- | vcl/aqua/source/app/makefile.mk | 9 | ||||
-rw-r--r-- | vcl/aqua/source/app/saldata.cxx | 262 | ||||
-rw-r--r-- | vcl/aqua/source/app/salinst.cxx | 725 | ||||
-rw-r--r-- | vcl/aqua/source/app/salsys.cxx | 124 | ||||
-rw-r--r-- | vcl/aqua/source/app/saltimer.cxx | 77 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/makefile.mk | 8 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salbmp.cxx | 574 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 1371 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salogl.cxx | 250 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salprn.cxx | 1291 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salvd.cxx | 121 | ||||
-rw-r--r-- | vcl/aqua/source/window/salframe.cxx | 3672 | ||||
-rw-r--r-- | vcl/aqua/source/window/salobj.cxx | 676 |
21 files changed, 285 insertions, 9278 deletions
diff --git a/vcl/aqua/inc/saldata.hxx b/vcl/aqua/inc/saldata.hxx index b9ac1e22c420..db43931c5296 100644 --- a/vcl/aqua/inc/saldata.hxx +++ b/vcl/aqua/inc/saldata.hxx @@ -2,9 +2,9 @@ * * $RCSfile: saldata.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,8 +71,8 @@ #ifndef _SV_SALWTYPE_HXX #include <salwtype.hxx> #endif -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> +#ifndef _SV_VCLWINDOW_H +#include <VCLWindow.h> #endif class AutoTimer; @@ -84,14 +84,6 @@ class SalPrinter; class Font; struct VCLVIEWCache; -// -------------------- -// - Standard-Defines - -// -------------------- - -#define MAX_STOCKPEN 4 -#define MAX_STOCKBRUSH 4 -#define SAL_CLIPRECT_COUNT 16 - // ----------- // - SalData - // ----------- @@ -101,8 +93,6 @@ struct SalData int mnCmdShow; // default frame show style // Erst hier koennen Daten kompatible eingefuegt werden, da die // oberen Daten in salmain.cxx modifiziert werden - HPALETTE mhDitherPal; // dither palette - HGLOBAL mhDitherDIB; // dither memory handle BYTE* mpDitherDIB; // dither memory BYTE* mpDitherDIBData; // beginning of DIB data long* mpDitherDiff; // Dither mapping table @@ -110,249 +100,28 @@ struct SalData BYTE* mpDitherHigh; // Dither mapping table ULONG mnTimerMS; // Current Time (in MS) of the Timer ULONG mnTimerOrgMS; // Current Original Time (in MS) - UINT mnTimerId; // windows timer id + UINT32 mnTimerId; // windows timer id SALTIMERPROC mpTimerProc; // timer callback proc - HHOOK mhSalObjMsgHook; // hook um SalObject relevante Message mitzubekommen - VCLWINDOW mhWantLeaveMsg; // window handle, that want a MOUSELEAVE message + VCLWINDOW 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 SalObject* mpFirstObject; // pointer of first object window SalVirtualDevice* mpFirstVD; // first VirDev SalPrinter* mpFirstPrinter; // first printing printer - VCLVIEWCache* mpVCLVIEWCache; // Cache for three DC's - HBITMAP mh50Bmp; // 50% Bitmap - HBRUSH mh50Brush; // 50% Brush - COLORREF maStockPenColorAry[MAX_STOCKPEN]; - COLORREF maStockBrushColorAry[MAX_STOCKBRUSH]; - HPEN mhStockPenAry[MAX_STOCKPEN]; - HBRUSH mhStockBrushAry[MAX_STOCKBRUSH]; + VCLVIEWCache* mpVCLVIEWCache; // Cache for three DC's USHORT mnStockPenCount; // Anzahl statischer Pens USHORT mnStockBrushCount; // Anzahl statischer Brushes - WPARAM mnSalObjWantKeyEvt; // KeyEvent, welcher vom SalObj-Hook verarbeitet werden soll + INT32 mnSalObjWantKeyEvt; // KeyEvent, welcher vom SalObj-Hook verarbeitet werden soll BOOL mbObjClassInit; // Ist SALOBJECTCLASS initialised BOOL mbInPalChange; // is in WM_QUERYNEWPALETTE - DWORD mnAppThreadId; // Id from Applikation-Thread - WIN_BOOL mbScrSvrEnabled; // ScreenSaver enabled + INT32 mnAppThreadId; // Id from Applikation-Thread + BOOL mbScrSvrEnabled; // ScreenSaver enabled int mnSageStatus; // Status der Sage-DLL (DISABLE_AGENT == nicht vorhanden) - SysAgt_Enable_PROC mpSageEnableProc; // Funktion zum deaktivieren des Systemagenten }; inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; } inline SalData* GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; } inline SalData* GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; } -// -------------- -// - SalShlData - -// -------------- - -struct SalShlData -{ - UINT mnVKAdd; // VK-Code von KEY_ADD - UINT mnVKSubtract; // VK-Code von KEY_SUBTRACT - UINT mnVKMultiply; // VK-Code von KEY_MULTIPLY - UINT mnVKDivide; // VK-Code von KEY_DIVIDE - UINT mnVKPoint; // VK-Code von KEY_POINT - UINT mnVKComma; // VK-Code von KEY_KOMMA - UINT mnVKLess; // VK-Code von KEY_LESS - UINT mnVKGreater; // VK-Code von KEY_GREATER - UINT mnVKEqual; // VK-Code von KEY_EQUAL - UINT mnWheelScrollLines; // WheelScrollLines - UINT mnWheelMsgId; // Wheel-Message-Id fuer W95 -}; - -extern SalShlData aSalShlData; - -// ------------ -// - GDICache - -// ------------ - -#define CACHESIZE_VCLVIEW 3 -#define CACHED_VCLVIEW_1 0 -#define CACHED_VCLVIEW_2 1 -#define CACHED_VCLVIEW_DRAW 2 -#define CACHED_VCLVIEW_DEFEXT 64 - -struct VCLVIEWCache -{ - VCLVIEW mhDC; - HPALETTE mhDefPal; - HBITMAP mhDefBmp; - HBITMAP mhSelBmp; - HBITMAP mhActBmp; -}; - -void ImplClearVCLVIEWCache( SalData* pData ); -VCLVIEW ImplGetCachedDC( ULONG nID, HBITMAP hBmp = 0 ); -void ImplReleaseCachedDC( ULONG nID ); - -// ------------------------------------------------------ -// - salshl.cxx - Funktionen fuer DLL-Resource-Zugriffe - -// ------------------------------------------------------ - -HCURSOR ImplLoadSalCursor( int nId ); -HBITMAP ImplLoadSalBitmap( int nId ); -BOOL ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon ); - -void ImplInitSalGDI(); -void ImplFreeSalGDI(); - -// -------------- -// - Prototypes - -// -------------- - -void ImplSalYieldMutexAcquireWithWait(); -BOOL ImplSalYieldMutexTryToAcquire(); -void ImplSalYieldMutexAcquire(); -void ImplSalYieldMutexRelease(); -ULONG ImplSalReleaseYieldMutex(); -void ImplSalAcquireYieldMutex( ULONG nCount ); - -LRESULT CALLBACK SalFrameWndProcA( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ); -LRESULT CALLBACK SalFrameWndProcW( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ); -void CALLBACK SalTimerProc( VCLWINDOW hWnd, UINT nMsg, UINT nId, DWORD nTime ); - -void SalTestMouseLeave(); - -long ImplHandleSalObjKeyMsg( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ); -long ImplHandleSalObjSysCharMsg( VCLWINDOW hWnd, WPARAM wParam, LPARAM lParam ); -BOOL ImplHandleGlobalMsg( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT& rlResult ); - -SalObject* ImplFindSalObject( VCLWINDOW hWndChild ); -#ifdef WIN -BOOL ImplSalPreDispatchMsg( MSG* pMsg ); -void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT nDispatchResult ); - -void ImplSalLogFontToFontA( const LOGFONTA& rLogFont, Font& rFont ); -void ImplSalLogFontToFontW( const LOGFONTW& rLogFont, Font& rFont ); -#endif - -rtl_TextEncoding ImplSalGetSystemEncoding(); -ByteString ImplSalGetWinAnsiString( const UniString& rStr, BOOL bFileName = FALSE ); -UniString ImplSalGetUniString( const sal_Char* pStr, xub_StrLen nLen = STRING_LEN ); -int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 ); - -// ----------- -// - Defines - -// ----------- - -#define SAL_FRAME_WNDEXTRA sizeof( DWORD ) -#define SAL_FRAME_THIS 0 -#define SAL_FRAME_CLASSNAMEA "SALFRAME" -#define SAL_FRAME_CLASSNAMEW L"SALFRAME" -#define SAL_FRAME_CLASSNAME_SBA "SALFRAMESB" -#define SAL_FRAME_CLASSNAME_SBW L"SALFRAMESB" -#define SAL_OBJECT_WNDEXTRA sizeof( DWORD ) -#define SAL_OBJECT_THIS 0 -#define SAL_OBJECT_CLASSNAMEA "SALOBJECT" -#define SAL_OBJECT_CLASSNAMEW L"SALOBJECT" -#define SAL_OBJECT_CHILDCLASSNAMEA "SALOBJECTCHILD" -#define SAL_OBJECT_CHILDCLASSNAMEW L"SALOBJECTCHILD" -#define SAL_COM_CLASSNAMEA "SALCOMWND" -#define SAL_COM_CLASSNAMEW L"SALCOMWND" - -#define SAL_MOUSELEAVE_TIMEOUT 300 - -// wParam == hDC; lParam == 0 -#define SAL_MSG_PRINTABORTJOB (WM_USER+110) -// wParam == bWait; lParam == 0 -#define SAL_MSG_THREADYIELD (WM_USER+111) -// wParam == 0; lParam == 0 -#define SAL_MSG_RELEASEWAITYIELD (WM_USER+112) -// wParam == 0; lParam == nMS -#define SAL_MSG_STARTTIMER (WM_USER+113) -// wParam == nFrameStyle; lParam == pParent; lResult == pFrame -#define SAL_MSG_CREATEFRAME (WM_USER+114) -// wParam == 0; lParam == 0 -#define SAL_MSG_DESTROYFRAME (WM_USER+115) -// wParam == 0; lParam == pParent; lResult == pObject -#define SAL_MSG_CREATEOBJECT (WM_USER+116) -// wParam == 0; lParam == pObject; -#define SAL_MSG_DESTROYOBJECT (WM_USER+117) -// wParam == 0; lParam == this; lResult == bRet -#define SAL_MSG_CREATESOUND (WM_USER+118) -// wParam == 0; lParam == this -#define SAL_MSG_DESTROYSOUND (WM_USER+119) - -// wParam == 0; lParam == pData -#define SAL_MSG_USEREVENT (WM_USER+130) -// wParam == 0; lParam == MousePosition relativ to upper left of screen -#define SAL_MSG_MOUSELEAVE (WM_USER+131) -// NULL-Message, soll nicht verarbeitet werden -#define SAL_MSG_DUMMY (WM_USER+132) -// wParam == 0; lParam == 0 -#define SAL_MSG_POSTFOCUS (WM_USER+133) -// wParam == wParam; lParam == lParam -#define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134) -// wParam == wParam; lParam == lParam -#define SAL_MSG_POSTPALCHANGED (WM_USER+135) -// wParam == wParam; lParam == lParam -#define SAL_MSG_POSTMOVE (WM_USER+136) -// wParam == wParam; lParam == lParam -#define SAL_MSG_POSTCALLSIZE (WM_USER+137) -// wParam == pRECT -#define SAL_MSG_POSTPAINT (WM_USER+138) -// wParam == 0; lParam == pFrame; lResult 0 -#define SAL_MSG_FORCEPALETTE (WM_USER+139) -// wParam == 0; lParam == 0; -#define SAL_MSG_CAPTUREMOUSE (WM_USER+140) -// wParam == 0; lParam == 0 -#define SAL_MSG_RELEASEMOUSE (WM_USER+141) -// wParam == nFlags; lParam == 0 -#define SAL_MSG_TOTOP (WM_USER+142) -// wParam == bVisible; lParam == 0 -#define SAL_MSG_SHOW (WM_USER+143) - -// SysChild-ToTop; wParam = 0; lParam = 0 -#define SALOBJ_MSG_TOTOP (WM_USER+160) -// POSTFOCUS-Message; wParam == bFocus; lParam == 0 -#define SALOBJ_MSG_POSTFOCUS (WM_USER+161) - -// ----------------- -// - Helpfunctions - -// ----------------- - -// A/W-Wrapper -#ifdef WIN -LONG ImplSetWindowLong( VCLWINDOW hWnd, int nIndex, DWORD dwNewLong ); -LONG ImplGetWindowLong( VCLWINDOW hWnd, int nIndex ); -WIN_BOOL ImplPostMessage( VCLWINDOW hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); -WIN_BOOL ImplSendMessage( VCLWINDOW hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); -WIN_BOOL ImplGetMessage( LPMSG lpMsg, VCLWINDOW hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax ); -WIN_BOOL ImplPeekMessage( LPMSG lpMsg, VCLWINDOW hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg ); -LONG ImplDispatchMessage( const MSG *pMsg ); -#endif - -inline void SetWindowPtr( VCLWINDOW hWnd, SalFrame* pThis ) -{ -#ifdef WIN - ImplSetWindowLong( hWnd, SAL_FRAME_THIS, (LONG)pThis ); -#endif -} - -inline SalFrame* GetWindowPtr( VCLWINDOW hWnd ) -{ -#ifdef WIN - return (SalFrame*)ImplGetWindowLong( hWnd, SAL_FRAME_THIS ); -#else - return NULL; -#endif -} - -inline void SetSalObjWindowPtr( VCLWINDOW hWnd, SalObject* pThis ) -{ -#ifdef WIN - ImplSetWindowLong( hWnd, SAL_OBJECT_THIS, (LONG)pThis ); -#endif -} - -inline SalObject* GetSalObjWindowPtr( VCLWINDOW hWnd ) -{ -#ifdef WIN - return (SalObject*)ImplGetWindowLong( hWnd, SAL_OBJECT_THIS ); -#else - return NULL; -#endif -} - #endif // _SV_SALDATA_HXX diff --git a/vcl/aqua/inc/salframe.h b/vcl/aqua/inc/salframe.h index 2bacd51e0d06..080445517869 100644 --- a/vcl/aqua/inc/salframe.h +++ b/vcl/aqua/inc/salframe.h @@ -2,9 +2,9 @@ * * $RCSfile: salframe.h,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,12 +80,10 @@ // - SalFrameData - // ---------------- -class SalFrameData +struct SalFrameData { public: - VCLWINDOW mhWnd; // Window handle - HCURSOR mhCursor; // cursor handle - HIMC mhDefIMEContext; // default IME-Context + VCLWINDOW mhWnd; // Window handle SalGraphics* mpGraphics; // current frame graphics SalFrame* mpNextFrame; // pointer to next frame void* mpInst; // instance handle for callback @@ -95,10 +93,9 @@ public: int mnShowState; // show state long mnWidth; // client width in pixeln long mnHeight; // client height in pixeln - RECT maFullScreenRect; // fullscreen rect int mnFullScreenShowState; // fullscreen restore show state - UINT mnInputLang; // current Input Language - UINT mnInputCodePage; // current Input CodePage + UINT32 mnInputLang; // current Input Language + UINT32 mnInputCodePage; // current Input CodePage USHORT mnStyle; // style BOOL mbGraphics; // is Graphics used BOOL mbCaption; // has window a caption diff --git a/vcl/aqua/inc/salgdi.h b/vcl/aqua/inc/salgdi.h index d54fe404fc31..3466f013c0ac 100644 --- a/vcl/aqua/inc/salgdi.h +++ b/vcl/aqua/inc/salgdi.h @@ -2,9 +2,9 @@ * * $RCSfile: salgdi.h,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,47 +70,18 @@ #include <VCLWindow.h> #endif -// ----------- -// - Defines - -// ----------- - -#define RGB_TO_PALRGB(nRGB) ((nRGB)|0x02000000) -#define PALRGB_TO_RGB(nPalRGB) ((nPalRGB)&0x00ffffff) - // ------------------- // - SalGraphicsData - // ------------------- -class SalGraphicsData +struct SalGraphicsData { public: - VCLVIEW mhDC; // VCLVIEW - VCLWINDOW mhWnd; // Window-Handle, when Window-Graphics - HPEN mhPen; // Pen - HBRUSH mhBrush; // Brush - HFONT mhFont; // Font - HRGN mhRegion; // Region Handle - HPEN mhDefPen; // DefaultPen - HBRUSH mhDefBrush; // DefaultBrush - HFONT mhDefFont; // DefaultFont - HPALETTE mhDefPal; // DefaultPalette - COLORREF mnPenColor; // PenColor - COLORREF mnBrushColor; // BrushColor - COLORREF mnTextColor; // TextColor -#ifdef WIN - RGNDATA* mpClipRgnData; // ClipRegion-Data - RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data -#endif - RECT* mpNextClipRect; // Naechstes ClipRegion-Rect + VCLVIEW mhDC; // VCLVIEW + VCLWINDOW mhWnd; // Window-Handle, when Window-Graphics BOOL mbFirstClipRect; // Flag for first cliprect to insert -#ifdef WIN - LOGFONTA* mpLogFont; // LOG-Font which is currently selected (only W9x) -#endif BYTE* mpFontCharSets; // All Charsets for the current font BYTE mnFontCharSetCount; // Number of Charsets of the current font; 0 - if not queried -#ifdef WIN - KERNINGPAIR* mpFontKernPairs; // Kerning Pairs of the current Font -#endif ULONG mnFontKernPairCount;// Number of Kerning Pairs of the current Font BOOL mbFontKernInit; // FALSE: FontKerns must be queried int mnFontOverhang; // Font-Overhang @@ -127,16 +98,4 @@ public: BOOL mbCalcOverhang; // calc overhang }; -// Init/Deinit Graphics -void ImplSalInitGraphics( SalGraphicsData* mpData ); -void ImplSalDeInitGraphics( SalGraphicsData* mpData ); -void ImplUpdateSysColorEntries(); -int ImplIsSysColorEntry( SalColor nSalColor ); - -// ----------- -// - Defines - -// ----------- - -#define MAX_64KSALPOINTS ((((USHORT)0xFFFF)-4)/sizeof(POINT)) - #endif // _SV_SALGDI_H diff --git a/vcl/aqua/inc/salinst.h b/vcl/aqua/inc/salinst.h index ad7f82c56740..1db8930f82cb 100644 --- a/vcl/aqua/inc/salinst.h +++ b/vcl/aqua/inc/salinst.h @@ -2,9 +2,9 @@ * * $RCSfile: salinst.h,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,7 +86,7 @@ class SalObject; // - SalInstanceData - // ------------------- -class SalInstanceData +struct SalInstanceData { public: VCLWINDOW mhComWnd; // window, for communication (between threads and the main thread) @@ -101,15 +101,6 @@ public: USHORT mnYieldWaitCount; // Wait-Count }; -// -------------- -// - Prototypen - -// -------------- - -SalFrame* ImplSalCreateFrame( SalInstance* pInst, VCLWINDOW hWndParent, ULONG nSalFrameStyle ); -SalObject* ImplSalCreateObject( SalInstance* pInst, SalFrame* pParent ); -void ImplSalStartTimer( ULONG nMS, BOOL bMutex = FALSE ); -void ImplSalPrinterAbortJobAsync( VCLVIEW hPrnDC ); - #endif // __cplusplus #endif // _SV_SALINST_H diff --git a/vcl/aqua/inc/salobj.h b/vcl/aqua/inc/salobj.h index f6e7c3a9d26b..6db147295a9d 100644 --- a/vcl/aqua/inc/salobj.h +++ b/vcl/aqua/inc/salobj.h @@ -2,9 +2,9 @@ * * $RCSfile: salobj.h,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,11 @@ #ifndef _SV_SV_H #include <sv.h> #endif + +#ifndef _SV_VCLWINDOW_H +#include <VCLWindow.h> +#endif + #ifndef _SV_SYSDATA_HXX #include <sysdata.hxx> #endif @@ -73,18 +78,12 @@ // - SalObjectData - // ----------------- -class SalObjectData +struct SalObjectData { -public: - VCLWINDOW mhWnd; // Window handle - VCLWINDOW mhWndChild; // Child Window handle - VCLWINDOW mhLastFocusWnd; // Child-Window, welches als letztes den Focus hatte + VCLWINDOW mhWnd; // Window handle + VCLWINDOW mhWndChild; // Child Window handle + VCLWINDOW mhLastFocusWnd; // Child-Window, welches als letztes den Focus hatte SystemChildData maSysData; // SystemEnvData -#ifdef WIN - RGNDATA* mpClipRgnData; // ClipRegion-Data - RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data -#endif - RECT* mpNextClipRect; // Naechstes ClipRegion-Rect BOOL mbFirstClipRect; // Flag for first cliprect to insert SalObject* mpNextObject; // pointer to next object void* mpInst; // instance handle for callback diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index 2028dfbd322a..149b61a2c412 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -2,9 +2,9 @@ * * $RCSfile: salprn.h,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,19 +66,13 @@ #include <sv.h> #endif + class SalGraphics; class SalInfoPrinter; -// ----------------- +// ------------------- // - SalDriverData - -// ----------------- - -// WNT3 -#define SAL_DRIVERDATA_SYSSIGN ((ULONG)0x574E5433) -#define SAL_DRIVERDATA_VERSION 1 -#define SAL_DEVMODE( pSetupData ) ((LPDEVMODE)((pSetupData->mpDriverData) + (((SalDriverData*)(pSetupData->mpDriverData))->mnDriverOffset))) - -#pragma pack( 1 ) +// ------------------- struct SalDriverData { @@ -88,8 +82,6 @@ struct SalDriverData BYTE maDriverData[1]; }; -#pragma pack() - // ------------------- // - SalSysQueueData - // ------------------- @@ -109,9 +101,8 @@ struct SalSysQueueData // - SalInfoPrinterData - // ---------------------- -class SalInfoPrinterData +struct SalInfoPrinterData { -public: SalGraphics* mpGraphics; // current Printer graphics XubString maDriverName; // printer driver name XubString maDeviceName; // printer device name @@ -119,7 +110,7 @@ public: ByteString maDriverNameA; // printer driver name ByteString maDeviceNameA; // printer device name ByteString maPortNameA; // printer port name - VCLVIEW mhDC; // printer hdc + VCLVIEW mhDC; // printer hdc BOOL mbGraphics; // is Graphics used BOOL mbAnsi; }; @@ -128,13 +119,12 @@ public: // - SalPrinterData - // ------------------ -class SalPrinterData +struct SalPrinterData { -public: SalGraphics* mpGraphics; // current Printer graphics SalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter SalPrinter* mpNextPrinter; // next printing printer - VCLVIEW mhDC; // printer hdc + VCLVIEW mhDC; // printer hdc ULONG mnError; // Error Code ULONG mnCopies; // Kopien BOOL mbCollate; // Sortierte Kopien diff --git a/vcl/aqua/inc/salsys.h b/vcl/aqua/inc/salsys.h index 3660ee45051f..10524d388a29 100644 --- a/vcl/aqua/inc/salsys.h +++ b/vcl/aqua/inc/salsys.h @@ -2,9 +2,9 @@ * * $RCSfile: salsys.h,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 17:05:26 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,13 +66,12 @@ #include <sv.h> #endif -class SalFrame; // ----------------- // - SalSystemData - // ----------------- -class SalSystemData +struct SalSystemData { }; diff --git a/vcl/aqua/inc/salvd.h b/vcl/aqua/inc/salvd.h index d95e5f816388..28fe4b8dd44b 100644 --- a/vcl/aqua/inc/salvd.h +++ b/vcl/aqua/inc/salvd.h @@ -2,9 +2,9 @@ * * $RCSfile: salvd.h,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,19 +66,14 @@ #include <sv.h> #endif -class SalGraphics; -class SalVirtualDevice; // ----------------- // - SalVirDevData - // ----------------- -class SalVirDevData +struct SalVirDevData { -public: - VCLVIEW mhDC; // VCLVIEW or 0 for Cache Device - HBITMAP mhBmp; // Memory Bitmap - HBITMAP mhDefBmp; // Default Bitmap + VCLVIEW mhDC; // VCLVIEW or 0 for Cache Device SalGraphics* mpGraphics; // current VirDev graphics SalVirtualDevice* mpNext; // next VirDev USHORT mnBitCount; // BitCount (0 or 1) diff --git a/vcl/aqua/source/app/makefile.mk b/vcl/aqua/source/app/makefile.mk index 02b32b590840..1a8f0cd9ccf9 100644 --- a/vcl/aqua/source/app/makefile.mk +++ b/vcl/aqua/source/app/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.6 $ +# $Revision: 1.7 $ # -# last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ +# last change: $Author: pluby $ $Date: 2000-11-01 22:12:30 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -85,12 +85,9 @@ OBJFILES= $(OBJ)$/salmain.obj \ $(OBJ)$/VCLApplication.obj \ $(OBJ)$/VCLAutoreleasePool.obj -SLOFILES= $(SLO)$/salshl.obj \ - $(SLO)$/saldata.obj \ - $(SLO)$/salinst.obj \ +SLOFILES= $(SLO)$/salinst.obj \ $(SLO)$/saltimer.obj \ $(SLO)$/salsound.obj \ - $(SLO)$/salinfo.obj \ $(SLO)$/salsys.obj \ $(SLO)$/salmain.obj \ $(SLO)$/VCLApplication.obj \ diff --git a/vcl/aqua/source/app/saldata.cxx b/vcl/aqua/source/app/saldata.cxx deleted file mode 100644 index a185bce05456..000000000000 --- a/vcl/aqua/source/app/saldata.cxx +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************************* - * - * $RCSfile: saldata.cxx,v $ - * - * $Revision: 1.2 $ - * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ - * - * 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 _SVWIN_H -#include <tools/svwin.h> -#endif - -#define _SV_SALDATA_CXX - -#ifndef _SV_SALDATA_HXX -#include <saldata.hxx> -#endif - -// ======================================================================= - -rtl_TextEncoding ImplSalGetSystemEncoding() -{ - static UINT nOldAnsiCodePage = 0; - static rtl_TextEncoding eEncoding = RTL_TEXTENCODING_MS_1252; - -#ifdef WIN - UINT nAnsiCodePage = GetACP(); - if ( nAnsiCodePage != nOldAnsiCodePage ) - { - switch ( nAnsiCodePage ) - { - case 1252: - eEncoding = RTL_TEXTENCODING_MS_1252; - break; - case 1250: - eEncoding = RTL_TEXTENCODING_MS_1250; - break; - case 1251: - eEncoding = RTL_TEXTENCODING_MS_1251; - break; - case 1253: - eEncoding = RTL_TEXTENCODING_MS_1253; - break; - case 1254: - eEncoding = RTL_TEXTENCODING_MS_1254; - break; - case 1255: - eEncoding = RTL_TEXTENCODING_MS_1255; - break; - case 1256: - eEncoding = RTL_TEXTENCODING_MS_1256; - break; - case 1257: - eEncoding = RTL_TEXTENCODING_MS_1257; - break; - case 1258: - eEncoding = RTL_TEXTENCODING_MS_1258; - break; - case 874: - eEncoding = RTL_TEXTENCODING_MS_874; - break; - case 932: - eEncoding = RTL_TEXTENCODING_MS_932; - break; - case 936: - eEncoding = RTL_TEXTENCODING_MS_936; - break; - case 949: - eEncoding = RTL_TEXTENCODING_MS_949; - break; - case 950: - eEncoding = RTL_TEXTENCODING_MS_950; - break; -// case 1381: -// eEncoding = RTL_TEXTENCODING_MS_1381; -// break; - } - } -#endif - - return eEncoding; -} - -// ----------------------------------------------------------------------- - -ByteString ImplSalGetWinAnsiString( const UniString& rStr, BOOL bFileName ) -{ - rtl_TextEncoding eEncoding = ImplSalGetSystemEncoding(); - if ( bFileName ) - { - return ByteString( rStr, eEncoding, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE | - RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE | - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE | - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR | - RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ); - } - else - { - return ByteString( rStr, eEncoding, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT | - RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT | - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE | - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR | - RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ); - } -} - -// ----------------------------------------------------------------------- - -UniString ImplSalGetUniString( const sal_Char* pStr, xub_StrLen nLen ) -{ - return UniString( pStr, nLen, ImplSalGetSystemEncoding(), - RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT | - RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT | - RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT ); -} - -// ======================================================================= - -int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 ) -{ - int nRet; - wchar_t c1; - char c2; - do - { - // Ist das Zeichen zwischen 'A' und 'Z' dann umwandeln - c1 = *pStr1; - c2 = *pStr2; - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2)); - if ( nRet != 0 ) - break; - - pStr1++; - pStr2++; - } - while ( c2 ); - - return nRet; -} - -// ======================================================================= - -#ifdef WIN -LONG ImplSetWindowLong( VCLWINDOW hWnd, int nIndex, DWORD dwNewLong ) -{ - return SetWindowLongA( hWnd, nIndex, dwNewLong ); -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -LONG ImplGetWindowLong( VCLWINDOW hWnd, int nIndex ) -{ - return GetWindowLongA( hWnd, nIndex ); -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -WIN_BOOL ImplPostMessage( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - return PostMessageA( hWnd, nMsg, wParam, lParam ); -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -WIN_BOOL ImplSendMessage( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - return SendMessageA( hWnd, nMsg, wParam, lParam ); -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -WIN_BOOL ImplGetMessage( LPMSG lpMsg, VCLWINDOW hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax ) -{ - return GetMessageA( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax ); -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -WIN_BOOL ImplPeekMessage( LPMSG lpMsg, VCLWINDOW hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg ) -{ - return PeekMessageA( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg ); -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -LONG ImplDispatchMessage( const MSG *lpMsg ) -{ - return DispatchMessageA( lpMsg ); -} -#endif - diff --git a/vcl/aqua/source/app/salinst.cxx b/vcl/aqua/source/app/salinst.cxx index fbcc17b32843..9ccfd65af81a 100644 --- a/vcl/aqua/source/app/salinst.cxx +++ b/vcl/aqua/source/app/salinst.cxx @@ -2,15 +2,15 @@ * * $RCSfile: salinst.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:30 $ * * 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 + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * @@ -59,28 +59,10 @@ * ************************************************************************/ -#include <string.h> -#include <tools/svwin.h> -#ifdef WNT -#include <process.h> -#endif +#include <stdio.h> #define _SV_SALINST_CXX -#ifndef _VOS_MUTEX_HXX -#include <vos/mutex.hxx> -#endif - -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif - -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> -#endif -#ifndef _SV_SALIDS_HRC -#include <salids.hrc> -#endif #ifndef _SV_SALDATA_HXX #include <saldata.hxx> #endif @@ -93,27 +75,9 @@ #ifndef _SV_SALOBJ_HXX #include <salobj.hxx> #endif -#ifndef _SV_SALSYS_HXX +#ifndef _SV_SALSYS_H #include <salsys.hxx> #endif -#ifndef _SV_SALTIMER_HXX -#include <saltimer.hxx> -#endif -#ifndef _SV_SALSOUND_HXX -#include <salsound.hxx> -#endif -#ifndef _SV_SALATYPE_HXX -#include <salatype.hxx> -#endif -#ifndef _SV_SYSDATA_HXX -#include <sysdata.hxx> -#endif -#ifndef _SV_TIMER_HXX -#include <timer.hxx> -#endif -#ifndef _SV_SVAPP_HXX -#include <svapp.hxx> -#endif #ifndef _SV_VCLAPPLICATION_H #include <VCLApplication.h> #endif @@ -122,324 +86,27 @@ void SalAbort( const XubString& rErrorText ) { - ImplFreeSalGDI(); - -#ifdef WIN - if ( !rErrorText.Len() ) - FatalAppExit( 0, "Application Error" ); - else - { - ByteString aErrorText( ImplSalGetWinAnsiString( rErrorText ) ); - FatalAppExit( 0, aErrorText.GetBuffer() ); - } -#endif -} - -// ======================================================================= - -LRESULT CALLBACK SalComWndProcA( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ); -LRESULT CALLBACK SalComWndProcW( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ); - -// ======================================================================= - -class SalYieldMutex : public NAMESPACE_VOS(OMutex) -{ -public: // for ImplSalYield() - SalInstanceData* mpInstData; - ULONG mnCount; - DWORD mnThreadId; - -public: - SalYieldMutex( SalInstanceData* pInstData ); - - virtual void SAL_CALL acquire(); - virtual void SAL_CALL release(); - virtual sal_Bool SAL_CALL tryToAcquire(); - - ULONG GetAcquireCount( ULONG nThreadId ); -}; - -// ----------------------------------------------------------------------- - -SalYieldMutex::SalYieldMutex( SalInstanceData* pInstData ) -{ - mpInstData = pInstData; - mnCount = 0; - mnThreadId = 0; -} - -// ----------------------------------------------------------------------- - -void SAL_CALL SalYieldMutex::acquire() -{ - OMutex::acquire(); - mnCount++; -#ifdef WIN - mnThreadId = GetCurrentThreadId(); -#endif -} - -// ----------------------------------------------------------------------- - -void SAL_CALL SalYieldMutex::release() -{ -#ifdef WIN - DWORD nThreadId = GetCurrentThreadId(); - if ( mnThreadId != nThreadId ) - OMutex::release(); - else - { - // If we don't call these message, the Output from the - // Java clients doesn't come in the right order - GdiFlush(); - - SalData* pSalData = GetSalData(); - if ( pSalData->mnAppThreadId != nThreadId ) - { - if ( mnCount == 1 ) - { - mpInstData->mpSalWaitMutex->acquire(); - if ( mpInstData->mnYieldWaitCount ) - ImplPostMessage( mpInstData->mhComWnd, SAL_MSG_RELEASEWAITYIELD, 0, 0 ); - mnThreadId = 0; - mnCount--; - OMutex::release(); - mpInstData->mpSalWaitMutex->release(); - } - else - { - mnCount--; - OMutex::release(); - } - } - else - { - if ( mnCount == 1 ) - mnThreadId = 0; - mnCount--; - OMutex::release(); - } - } -#endif -} - -// ----------------------------------------------------------------------- - -sal_Bool SAL_CALL SalYieldMutex::tryToAcquire() -{ - if( OMutex::tryToAcquire() ) - { - mnCount++; -#ifdef WIN - mnThreadId = GetCurrentThreadId(); -#endif - return True; - } - else - return False; -} - -// ----------------------------------------------------------------------- - -ULONG SalYieldMutex::GetAcquireCount( ULONG nThreadId ) -{ - if ( nThreadId == mnThreadId ) - return mnCount; + if( !rErrorText.Len() ) + fprintf( stderr, "Application Error" ); else - return 0; + fprintf( stderr, + ByteString( rErrorText, gsl_getSystemTextEncoding() ).GetBuffer() ); + abort(); } // ----------------------------------------------------------------------- -void ImplSalYieldMutexAcquireWithWait() -{ - SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( !pInst ) - return; - - // If we are the main thread, then we must wait with wait, because - // in if we don't reschedule, then we create deadlocks if a Windows - // Function is called from another thread. If we arn't the main thread, - // than we call qcquire directly. -#ifdef WIN - DWORD nThreadId = GetCurrentThreadId(); - SalData* pSalData = GetSalData(); - if ( pSalData->mnAppThreadId == nThreadId ) - { - // Wenn wir den Mutex nicht bekommen, muessen wir solange - // warten, bis wir Ihn bekommen - BOOL bAcquire = FALSE; - do - { - if ( pInst->maInstData.mpSalYieldMutex->tryToAcquire() ) - bAcquire = TRUE; - else - { - pInst->maInstData.mpSalWaitMutex->acquire(); - if ( pInst->maInstData.mpSalYieldMutex->tryToAcquire() ) - { - bAcquire = TRUE; - pInst->maInstData.mpSalWaitMutex->release(); - } - else - { - pInst->maInstData.mnYieldWaitCount++; - pInst->maInstData.mpSalWaitMutex->release(); - MSG aTmpMsg; - ImplGetMessage( &aTmpMsg, pInst->maInstData.mhComWnd, SAL_MSG_RELEASEWAITYIELD, SAL_MSG_RELEASEWAITYIELD ); - pInst->maInstData.mnYieldWaitCount--; - if ( pInst->maInstData.mnYieldWaitCount ) - ImplPostMessage( pInst->maInstData.mhComWnd, SAL_MSG_RELEASEWAITYIELD, 0, 0 ); - } - } - } - while ( !bAcquire ); - } - else -#endif - pInst->maInstData.mpSalYieldMutex->acquire(); -} - -// ----------------------------------------------------------------------- - -BOOL ImplSalYieldMutexTryToAcquire() -{ - SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst ) - return pInst->maInstData.mpSalYieldMutex->tryToAcquire(); - else - return FALSE; -} - -// ----------------------------------------------------------------------- - -void ImplSalYieldMutexAcquire() -{ - SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst ) - pInst->maInstData.mpSalYieldMutex->acquire(); -} - -// ----------------------------------------------------------------------- - -void ImplSalYieldMutexRelease() -{ - SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst ) - pInst->maInstData.mpSalYieldMutex->release(); -} - -// ----------------------------------------------------------------------- - -ULONG ImplSalReleaseYieldMutex() -{ - SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( !pInst ) - return 0; - -#ifdef WIN - SalYieldMutex* pYieldMutex = pInst->maInstData.mpSalYieldMutex; - ULONG nCount = pYieldMutex->GetAcquireCount( GetCurrentThreadId() ); - ULONG n = nCount; - while ( n ) - { - pYieldMutex->release(); - n--; - } - - return nCount; -#endif -} - -// ----------------------------------------------------------------------- - -void ImplSalAcquireYieldMutex( ULONG nCount ) -{ - SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( !pInst ) - return; - - SalYieldMutex* pYieldMutex = pInst->maInstData.mpSalYieldMutex; - while ( nCount ) - { - pYieldMutex->acquire(); - nCount--; - } -} - -// ----------------------------------------------------------------------- - -#ifdef DBG_UTIL - -void ImplDbgTestSolarMutex() -{ -#ifdef WIN - SalData* pSalData = GetSalData(); - DWORD nCurThreadId = GetCurrentThreadId(); - 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 -} - -#endif - -// ======================================================================= - -static void InitSalShlData() -{ -#ifdef WIN - aSalShlData.mnVKAdd = LOWORD( VkKeyScan( '+' ) ); - aSalShlData.mnVKSubtract = LOWORD( VkKeyScan( '-' ) ); - aSalShlData.mnVKMultiply = LOWORD( VkKeyScan( '*' ) ); - aSalShlData.mnVKDivide = LOWORD( VkKeyScan( '/' ) ); - aSalShlData.mnVKPoint = LOWORD( VkKeyScan( '.' ) ); - aSalShlData.mnVKComma = LOWORD( VkKeyScan( ',' ) ); - aSalShlData.mnVKLess = LOWORD( VkKeyScan( '<' ) ); - aSalShlData.mnVKGreater = LOWORD( VkKeyScan( '>' ) ); - aSalShlData.mnVKEqual = LOWORD( VkKeyScan( '=' ) ); -#endif -} - -// ======================================================================= - void InitSalData() { - SalData* pSalData = new SalData; - memset( pSalData, 0, sizeof( SalData ) ); + SalData *pSalData = new SalData; SetSalData( pSalData ); -#ifdef WIN - CoInitialize(0); -#endif } // ----------------------------------------------------------------------- void DeInitSalData() { -#ifdef WIN - CoUninitialize(); -#endif - SalData* pSalData = GetSalData(); + SalData *pSalData = GetSalData(); delete pSalData; SetSalData( NULL ); } @@ -448,90 +115,20 @@ void DeInitSalData() void SetFilterCallback( void* pCallback, void* pInst ) { - SalData* pSalData = GetSalData(); - + SalData *pSalData = GetSalData(); pSalData->mpFirstInstance->maInstData.mpFilterCallback = pCallback; pSalData->mpFirstInstance->maInstData.mpFilterInst = pInst; } -// ----------------------------------------------------------------------- +// ======================================================================= SalInstance* CreateSalInstance() { SalData* pSalData = GetSalData(); - -#ifdef WIN - // determine the windows version - WORD nVer = (WORD)GetVersion(); - aSalShlData.mnVersion = (((WORD)LOBYTE(nVer)) * 100) + HIBYTE(nVer); - if ( aSalShlData.mnVersion >= W95_VERSION ) - aSalShlData.mbW40 = 1; - WORD nVer = (WORD)GetVersion(); - OSVERSIONINFO aVerInfo; - aVerInfo.dwOSVersionInfoSize = sizeof( aVerInfo ); - if ( GetVersionEx( &aVerInfo ) ) - { - if ( aVerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) - aSalShlData.mbWNT = 1; - } - - pSalData->mnAppThreadId = GetCurrentThreadId(); -#endif - -#ifdef WIN - // register frame class - if ( !pSalData->mhPrevInst ) - { - WNDCLASSEXA aWndClassEx; - aWndClassEx.cbSize = sizeof( aWndClassEx ); - aWndClassEx.style = CS_OWNDC; - aWndClassEx.lpfnWndProc = SalFrameWndProcA; - aWndClassEx.cbClsExtra = 0; - aWndClassEx.cbWndExtra = SAL_FRAME_WNDEXTRA; - aWndClassEx.hInstance = pSalData->mhInst; - aWndClassEx.hCursor = 0; - aWndClassEx.hbrBackground = 0; - aWndClassEx.lpszMenuName = 0; - aWndClassEx.lpszClassName = SAL_FRAME_CLASSNAMEA; - ImplLoadSalIcon( SAL_RESID_ICON_DEFAULT, aWndClassEx.hIcon, aWndClassEx.hIconSm ); - if ( !RegisterClassExA( &aWndClassEx ) ) - return NULL; - aWndClassEx.style |= CS_SAVEBITS; - aWndClassEx.lpszClassName = SAL_FRAME_CLASSNAME_SBA; - if ( !RegisterClassExA( &aWndClassEx ) ) - return NULL; - - aWndClassEx.style = 0; - aWndClassEx.lpfnWndProc = SalComWndProcA; - aWndClassEx.cbWndExtra = 0; - aWndClassEx.hIcon = 0; - aWndClassEx.hIconSm = 0; - aWndClassEx.lpszClassName = SAL_COM_CLASSNAMEA; - if ( !RegisterClassExA( &aWndClassEx ) ) - return NULL; - } -#endif - - VCLWINDOW hComWnd; -#ifdef WIN - hComWnd = CreateWindowExA( WS_EX_TOOLWINDOW, SAL_COM_CLASSNAMEA, - "", WS_POPUP, 0, 0, 0, 0, 0, 0, - pSalData->mhInst, NULL ); -#endif - if ( !hComWnd ) - return NULL; - SalInstance* pInst = new SalInstance; - // init shl data - InitSalShlData(); - // init instance (only one instance in this version !!!) - pSalData->mpFirstInstance = pInst; - pInst->maInstData.mhComWnd = hComWnd; - - // init static GDI Data - ImplInitSalGDI(); + pSalData->mpFirstInstance = pInst; return pInst; } @@ -540,16 +137,6 @@ SalInstance* CreateSalInstance() void DestroySalInstance( SalInstance* pInst ) { - SalData* pSalData = GetSalData(); - - // (only one instance in this version !!!) - - ImplFreeSalGDI(); - - // reset instance - if ( pSalData->mpFirstInstance == pInst ) - pSalData->mpFirstInstance = NULL; - delete pInst; } @@ -557,313 +144,143 @@ void DestroySalInstance( SalInstance* pInst ) SalInstance::SalInstance() { - maInstData.mhComWnd = 0; - maInstData.mpFilterCallback = NULL; - maInstData.mpFilterInst = NULL; - maInstData.mpSalYieldMutex = new SalYieldMutex( &maInstData ); - maInstData.mpSalWaitMutex = new NAMESPACE_VOS(OMutex); - maInstData.mnYieldWaitCount = 0; - maInstData.mpSalYieldMutex->acquire(); } // ----------------------------------------------------------------------- SalInstance::~SalInstance() { - maInstData.mpSalYieldMutex->release(); - delete maInstData.mpSalYieldMutex; - delete maInstData.mpSalWaitMutex; -#ifdef WIN - DestroyWindow( maInstData.mhComWnd ); -#endif } // ----------------------------------------------------------------------- -#ifdef _VOS_NO_NAMESPACE -IMutex* SalInstance::GetYieldMutex() -#else vos::IMutex* SalInstance::GetYieldMutex() -#endif { - return maInstData.mpSalYieldMutex; + return NULL; } // ----------------------------------------------------------------------- ULONG SalInstance::ReleaseYieldMutex() { - return ImplSalReleaseYieldMutex(); + return 0; } // ----------------------------------------------------------------------- void SalInstance::AcquireYieldMutex( ULONG nCount ) { - ImplSalAcquireYieldMutex( nCount ); } // ----------------------------------------------------------------------- -#ifdef WIN -static void ImplSalDispatchMessage( MSG *pMsg ) +void SalInstance::Yield( BOOL bWait ) { - SalData* pSalData = GetSalData(); - if ( pSalData->mpFirstObject ) - { - if ( ImplSalPreDispatchMsg( pMsg ) ) - return; - } - LONG lResult = ImplDispatchMessage( pMsg ); - if ( pSalData->mpFirstObject ) - ImplSalPostDispatchMsg( pMsg, lResult ); + // Start the event queue. Note that VCLApplication_run() will not return + // until the application shuts down. On other platforms, this function + // returns after each event is pulled off the event queue and dispatched. + // Instead, we have enter this method only once and let VCLApplication_run + // do all of the pulling and dispatching of events. + VCLApplication_run(); } -#endif // ----------------------------------------------------------------------- -void SalInstance::Yield( BOOL bWait ) +BOOL SalInstance::AnyInput( USHORT nType ) { - // Start the event queue. Note that VCLApplication_run() will not return until - // the application shuts down. On other platforms, this function returns - // after each event is pulled off the event queue and dispatched. - // Instead, we have enter this method only once and let VCLApplication_run do - // all of the pulling and dispatching of events. - VCLApplication_run(); + return FALSE; } // ----------------------------------------------------------------------- -LRESULT CALLBACK SalComWndProc( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef ) +SalFrame* SalInstance::CreateChildFrame( SystemParentData* pSystemParentData, ULONG nSalFrameStyle ) { - LRESULT nRet = 0; - -#ifdef WIN - switch ( nMsg ) - { - case SAL_MSG_PRINTABORTJOB: - ImplSalPrinterAbortJobAsync( (VCLVIEW)wParam ); - rDef = FALSE; - break; - case SAL_MSG_THREADYIELD: - ImplSalYield( (BOOL)wParam ); - rDef = FALSE; - break; - // If we get this message, because another GetMessage() call - // has recieved this message, we must post this message to - // us again, because in the other case we wait forever. - case SAL_MSG_RELEASEWAITYIELD: - { - SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst && pInst->maInstData.mnYieldWaitCount ) - ImplPostMessage( hWnd, SAL_MSG_RELEASEWAITYIELD, wParam, lParam ); - } - rDef = FALSE; - break; - case SAL_MSG_STARTTIMER: - ImplSalStartTimer( (ULONG) lParam, FALSE ); - rDef = FALSE; - break; - case SAL_MSG_CREATEFRAME: - nRet = (LRESULT)ImplSalCreateFrame( GetSalData()->mpFirstInstance, (VCLWINDOW)lParam, (ULONG)wParam ); - rDef = FALSE; - break; - case SAL_MSG_DESTROYFRAME: - delete (SalFrame*)lParam; - rDef = FALSE; - break; - case SAL_MSG_CREATEOBJECT: - nRet = (LRESULT)ImplSalCreateObject( GetSalData()->mpFirstInstance, (SalFrame*)lParam ); - rDef = FALSE; - break; - case SAL_MSG_DESTROYOBJECT: - delete (SalObject*)lParam; - rDef = FALSE; - break; - case SAL_MSG_CREATESOUND: - nRet = ((SalSound*)lParam)->ImplCreate(); - rDef = FALSE; - break; - case SAL_MSG_DESTROYSOUND: - ((SalSound*)lParam)->ImplDestroy(); - rDe - break; - } -#endif + return NULL; +} + +// ----------------------------------------------------------------------- + +SalFrame* SalInstance::CreateFrame( SalFrame* pParent, ULONG nSalFrameStyle ) +{ + // Stub code: Mac OS X does not support child windows so retrun NULL until + // we figure how to implement a good substitute for a child window + if ( pParent ) + return NULL; + + SalFrame *pFrame = new SalFrame; + + pFrame->maFrameData.mhWnd = VCLWindow_new( nSalFrameStyle, NULL ); - return nRet; + return pFrame; } -#ifdef WIN -LRESULT CALLBACK SalComWndProcA( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) +// ----------------------------------------------------------------------- + +void SalInstance::DestroyFrame( SalFrame* pFrame ) { - int bDef = TRUE; - LRESULT nRet = SalComWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - { - if ( !ImplHandleGlobalMsg( hWnd, nMsg, wParam, lParam, nRet ) ) - nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam ); - } - return nRet; + VCLWindow_release( pFrame->maFrameData.mhWnd ); } -#endif -#ifdef WIN -LRESULT CALLBACK SalComWndProcW( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) +// ----------------------------------------------------------------------- + +SalObject* SalInstance::CreateObject( SalFrame* pParent ) { - int bDef = TRUE; - LRESULT nRet = SalComWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - { - if ( !ImplHandleGlobalMsg( hWnd, nMsg, wParam, lParam, nRet ) ) - nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam ); - } - return nRet; + return NULL; } -#endif // ----------------------------------------------------------------------- -BOOL SalInstance::AnyInput( USHORT nType ) +void SalInstance::DestroyObject( SalObject* pObject ) { -#ifdef WIN - MSG aMsg; - - if ( (nType & (INPUT_ANY)) == (INPUT_ANY) ) - { - // Any Input - if ( ImplPeekMessage( &aMsg, 0, 0, 0, PM_NOREMOVE | PM_NOYIELD ) ) - return TRUE; - } - else - { - if ( nType & INPUT_MOUSE ) - { - // Test auf Mouseinput - if ( ImplPeekMessage( &aMsg, 0, WM_MOUSEFIRST, WM_MOUSELAST, - PM_NOREMOVE | PM_NOYIELD ) ) - return TRUE; - } - - if ( nType & INPUT_KEYBOARD ) - { - // Test auf Keyinput -#ifdef WIN - if ( ImplPeekMessage( &aMsg, 0, WM_KEYDOWN, WM_KEYDOWN, - PM_NOREMOVE | PM_NOYIELD ) ) - { - if ( (aMsg.wParam == VK_SHIFT) || - (aMsg.wParam == VK_CONTROL) || - (aMsg.wParam == VK_MENU) ) - return FALSE; - else - return TRUE; - } -#endif - } - - if ( nType & INPUT_PAINT ) - { - // Test auf Paintinput - if ( ImplPeekMessage( &aMsg, 0, WM_PAINT, WM_PAINT, - PM_NOREMOVE | PM_NOYIELD ) ) - return TRUE; - } - - if ( nType & INPUT_TIMER ) - { - // Test auf Timerinput - if ( ImplPeekMessage( &aMsg, 0, WM_TIMER, WM_TIMER, - PM_NOREMOVE | PM_NOYIELD ) ) - return TRUE; - } - - if ( nType & INPUT_OTHER ) - { - // Test auf sonstigen Input - if ( ImplPeekMessage( &aMsg, 0, 0, 0, PM_NOREMOVE | PM_NOYIELD ) ) - return TRUE; - } - } -#endif +} - return FALSE; +void SalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) +{ } // ----------------------------------------------------------------------- -void SalTimer::Start( ULONG nMS ) +void SalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) { - // Um auf Main-Thread umzuschalten - SalData* pSalData = GetSalData(); - if ( pSalData->mpFirstInstance ) - { -#ifdef WIN - if ( pSalData->mnAppThreadId != GetCurrentThreadId() ) - ImplPostMessage( pSalData->mpFirstInstance->maInstData.mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS ); - else - ImplSendMessage( pSalData->mpFirstInstance->maInstData.mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS ); -#endif - } - else - ImplSalStartTimer( nMS, FALSE ); } // ----------------------------------------------------------------------- -SalFrame* SalInstance::CreateChildFrame( SystemParentData* pSystemParentData, ULONG nSalFrameStyle ) +void SalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) { - // Um auf Main-Thread umzuschalten -#ifdef WIN - return (SalFrame*)ImplSendMessage( maInstData.mhComWnd, SAL_MSG_CREATEFRAME, nSalFrameStyle, (LPARAM)pSystemParentData->hWnd ); -#else - return NULL; -#endif } // ----------------------------------------------------------------------- -SalFrame* SalInstance::CreateFrame( SalFrame* pParent, ULONG nSalFrameStyle ) +XubString SalInstance::GetDefaultPrinter() { - SalFrame *pFrame = new SalFrame; - - // Stub code: Mac OS X does not support child windows so return NULL until - // we figure how to implement a good substitute for a child window - VCLWINDOW hWndParent; - if( pParent ) - hWndParent = pParent->maFrameData.mhWnd; - else - hWndParent = NULL; + return XubString(); +} - pFrame->maFrameData.mhWnd = VCLWindow_new( nSalFrameStyle, hWndParent ); +// ----------------------------------------------------------------------- - return pFrame; +SalInfoPrinter* SalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, + ImplJobSetup* pSetupData ) +{ + return NULL; } // ----------------------------------------------------------------------- -void SalInstance::DestroyFrame( SalFrame* pFrame ) +void SalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter ) { - VCLWindow_release( pFrame->maFrameData.mhWnd ); } // ----------------------------------------------------------------------- -SalObject* SalInstance::CreateObject( SalFrame* pParent ) +SalSystem* SalInstance::CreateSystem() { - // Um auf Main-Thread umzuschalten -#ifdef WIN - return (SalObject*)ImplSendMessage( maInstData.mhComWnd, SAL_MSG_CREATEOBJECT, 0, (LPARAM)pParent ); -#else - return NULL; -#endif + return new SalSystem(); } // ----------------------------------------------------------------------- -void SalInstance::DestroyObject( SalObject* pObject ) +void SalInstance::DestroySystem( SalSystem* pSystem ) { -#ifdef WIN - ImplSendMessage( maInstData.mhComWnd, SAL_MSG_DESTROYOBJECT, 0, (LPARAM)pObject ); -#endif + delete pSystem; } diff --git a/vcl/aqua/source/app/salsys.cxx b/vcl/aqua/source/app/salsys.cxx index be5914ba7d9e..efe7bfcc0398 100644 --- a/vcl/aqua/source/app/salsys.cxx +++ b/vcl/aqua/source/app/salsys.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salsys.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 17:05:26 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,144 +59,46 @@ * ************************************************************************/ -#include <string.h> - -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif - #define _SV_SALSYS_CXX -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> -#endif -#ifndef _SV_SALBMP_HXX -#include <salbmp.hxx> -#endif -#ifndef _SV_SALDATA_HXX -#include <saldata.hxx> -#endif -#ifndef _SV_SALINST_HXX -#include <salinst.hxx> -#endif -#ifndef _SV_SALFRAME_HXX -#include <salframe.hxx> -#endif #ifndef _SV_SALSYS_HXX #include <salsys.hxx> #endif -#ifndef _SV_KEYCOES_HXX -#include <keycodes.hxx> -#endif // ======================================================================= -SalSystem* SalInstance::CreateSystem() +SalSystem::SalSystem() { - return new SalSystem(); } // ----------------------------------------------------------------------- -void SalInstance::DestroySystem( SalSystem* pSystem ) -{ - delete pSystem; -} - -// ======================================================================= - -SalSystem::SalSystem() +SalSystem::~SalSystem() { } // ----------------------------------------------------------------------- -SalSystem::~SalSystem() +BOOL SalSystem::StartProcess( SalFrame* pFrame, + const XubString& rFileName, + const XubString& rParam, + const XubString& rWorkDir ) { + return FALSE; } // ----------------------------------------------------------------------- -BOOL SalSystem::StartProcess( SalFrame* pFrame, const XubString& rFileName, - const XubString& rParam, const XubString& rWorkDir ) +BOOL SalSystem::AddRecentDoc( SalFrame*, const XubString& rFileName ) { return FALSE; - // !!! UNICODE Was ist ... --> Mit HRO nach seinem Urlaub klaeren -/* - XubString aParam = rParam; - XubString aFileName = rFileName; - - // HRO: #75283# - // Hack for Office2000 Links - // We can only start the lnk-file, so we packed it within the arguments - xub_StrLen nIndex = aParam.Search( (sal_Unicode)0x07 ); - if ( nIndex != STRING_NOTFOUND ) - { - aFileName = aParam.Copy( nIndex + 1 ); - aParam.Erase( nIndex ); - } - - BOOL bSuccess; - if ( aSalShlData.mbWNT ) - { - LPCWSTR pszWorkDir = NULL; - if ( rWorkDir.Len() ) - pszWorkDir = rWorkDir.GetBuffer(); - bSuccess = SHInvokeCommandW( pFrame->maFrameData.mhWnd, 0, - aFileName.GetBuffer(), - CMDSTR_DEFAULT, - aParam.GetBuffer(), pszWorkDir, - SW_SHOWNORMAL ); - } - else - { - ByteString aFileNameA = ImplSalGetWinAnsiString( aFileName, TRUE ); - ByteString aParamA = ImplSalGetWinAnsiString( aParam, TRUE ); - ByteString aWorkDirA = ImplSalGetWinAnsiString( rWorkDir, TRUE ); - LPCSTR pszWorkDir = NULL; - if ( aWorkDirA.Len() ) - pszWorkDir = aWorkDirA.GetBuffer(); - bSuccess = SHInvokeCommandA( pFrame->maFrameData.mhWnd, 0, - aFileNameA.GetBuffer(), - CMDSTR_DEFAULT, - aParamA.GetBuffer(), pszWorkDir, - SW_SHOWNORMAL ); - } -*/ -/* - // HRO: Tasks #62485# #64619# - // Weil ein paar Naddels jeden Scheiss hier reinstopfen und sich nicht - // entscheiden koennen, was sie wie und wann aufrufen, darf ich - // um die BUGs drumrumkurven. GRRRRR !!! - - if ( !bSuccess ) - { - ItemIDPath aIDPath( aFileName ); - - if ( aIDPath.GetTokenCount() ) - bSuccess = WIN_SHInvokeCommand( pFrame->maFrameData.mhWnd, SHIC_PIDL, - (LPCTSTR)aIDPath.GetDataPtr(), CMDSTR_DEFAULT, aParam.GetStr(), - pszWorkDir, SW_SHOWNORMAL ); - } -*/ -// return bSuccess; } // ----------------------------------------------------------------------- -BOOL SalSystem::AddRecentDoc( SalFrame*, const XubString& rFileName ) +XubString SalSystem::GetSummarySystemInfos( ULONG nFlags ) { - return FALSE; - // !!! UNICODE Was ist ... --> Mit HRO nach seinem Urlaub klaeren -/* - if ( aSalShlData.mbWNT ) - SHAddToRecentDocsW( SHARD_PATH, (LPCVOID)rFileName.GetBuffer() ); - else - { - ByteString aFileNameA = ImplSalGetWinAnsiString( rFileName, TRUE ); - SHAddToRecentDocsA( SHARD_PATH, (LPCVOID)aFileNameA.GetBuffer() ); - } - return TRUE; -*/ + return XubString(); } + diff --git a/vcl/aqua/source/app/saltimer.cxx b/vcl/aqua/source/app/saltimer.cxx index 41c4d51a148d..663667633f83 100644 --- a/vcl/aqua/source/app/saltimer.cxx +++ b/vcl/aqua/source/app/saltimer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: saltimer.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:44 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,98 +59,27 @@ * ************************************************************************/ -#ifndef _SVWIN_H -#include <tools/svwin.h> -#endif - #define _SV_SALTIMER_CXX -#ifndef _SV_SALDATA_HXX -#include <saldata.hxx> -#endif #ifndef _SV_SALTIMER_HXX #include <saltimer.hxx> #endif -// ======================================================================= - -// Maximale Periode -#define MAX_SYSPERIOD 65533 // ======================================================================= -void ImplSalStartTimer( ULONG nMS, BOOL bMutex ) +void SalTimer::Start( ULONG nMS ) { - SalData* pSalData = GetSalData(); - - // Remenber the time of the timer - pSalData->mnTimerMS = nMS; - if ( !bMutex ) - pSalData->mnTimerOrgMS = nMS; - - // Periode darf nicht zu gross sein, da Windows mit USHORT arbeitet - if ( nMS > MAX_SYSPERIOD ) - nMS = MAX_SYSPERIOD; - -#ifdef WIN - // Gibt es einen Timer, dann zerstoren - if ( pSalData->mnTimerId ) - KillTimer( 0, pSalData->mnTimerId ); - - // Make a new timer with new period - pSalData->mnTimerId = SetTimer( 0, 0, (UINT)nMS, SalTimerProc ); -#endif } // ----------------------------------------------------------------------- void SalTimer::Stop() { - SalData* pSalData = GetSalData(); - -#ifdef WIN - // If we have a timer, than - if ( pSalData->mnTimerId ) - { - KillTimer( 0, pSalData->mnTimerId ); - pSalData->mnTimerId = 0; - } -#endif } // ----------------------------------------------------------------------- void SalTimer::SetCallback( SALTIMERPROC pProc ) { - SalData* pSalData = GetSalData(); - pSalData->mpTimerProc = pProc; -} - -// ----------------------------------------------------------------------- - -void CALLBACK SalTimerProc( VCLWINDOW, UINT, UINT, DWORD ) -{ - SalData* pSalData = GetSalData(); - - // Test for MouseLeave - SalTestMouseLeave(); - - if ( pSalData->mpTimerProc ) - { - // Try to aquire the mutex. If we don't get the mutex then we - // try this a short time later again. - if ( ImplSalYieldMutexTryToAcquire() ) - { - pSalData->mpTimerProc(); - ImplSalYieldMutexRelease(); - - // Run the timer in the correct time, if we start this - // with a small timeout, because we don't get the mutex - if ( pSalData->mnTimerId && - (pSalData->mnTimerMS != pSalData->mnTimerOrgMS) ) - ImplSalStartTimer( pSalData->mnTimerOrgMS, FALSE ); - } - else - ImplSalStartTimer( 10, TRUE ); - } } diff --git a/vcl/aqua/source/gdi/makefile.mk b/vcl/aqua/source/gdi/makefile.mk index ab638e6a1eb7..3a5bf8f6ad17 100644 --- a/vcl/aqua/source/gdi/makefile.mk +++ b/vcl/aqua/source/gdi/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: patrick.luby $ $Date: 2000-09-22 04:26:34 $ +# last change: $Author: pluby $ $Date: 2000-11-01 22:12:32 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -82,8 +82,6 @@ dummy: .ELSE # "$(OS)"!="MACOSX" SLOFILES= $(SLO)$/salgdi.obj \ - $(SLO)$/salgdi2.obj \ - $(SLO)$/salgdi3.obj \ $(SLO)$/salvd.obj \ $(SLO)$/salprn.obj \ $(SLO)$/salbmp.obj \ @@ -91,8 +89,6 @@ SLOFILES= $(SLO)$/salgdi.obj \ .IF "$(UPDATER)"=="YES" OBJFILES= $(OBJ)$/salgdi.obj \ - $(OBJ)$/salgdi2.obj \ - $(OBJ)$/salgdi3.obj \ $(OBJ)$/salvd.obj \ $(OBJ)$/salprn.obj \ $(OBJ)$/salbmp.obj \ diff --git a/vcl/aqua/source/gdi/salbmp.cxx b/vcl/aqua/source/gdi/salbmp.cxx index 3eb2c50d0803..ae542ec4a5e5 100644 --- a/vcl/aqua/source/gdi/salbmp.cxx +++ b/vcl/aqua/source/gdi/salbmp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salbmp.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:45 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,52 +59,16 @@ * ************************************************************************/ -#ifndef _SVWIN_H -#include <tools/svwin.h> -#endif - #define _SV_SALBMP_CXX -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> -#endif -#ifndef _SV_SALBTYPE_HXX -#include <salbtype.hxx> -#endif -#ifndef _SV_SALGDI_HXX -#include <salgdi.hxx> -#endif -#ifndef _SV_SALDATA_HXX -#include <saldata.hxx> -#endif #ifndef _SV_SALBMP_HXX #include <salbmp.hxx> #endif -#include <string.h> - -#ifdef WIN -#define BI_BITFIELDS 3 -#endif -// ----------- -// - 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 ), - mhDDB ( 0 ), mnBitCount ( 0 ) { } @@ -118,569 +82,47 @@ SalBitmap::~SalBitmap() // ------------------------------------------------------------------ -BOOL SalBitmap::Create( HANDLE hBitmap, BOOL bDIB, BOOL bCopyHandle ) -{ - BOOL bRet = TRUE; - - if( bDIB ) - mhDIB = (HGLOBAL) ( bCopyHandle ? ImplCopyDIBOrDDB( hBitmap, TRUE ) : hBitmap ); - else - mhDDB = (HBITMAP) ( bCopyHandle ? ImplCopyDIBOrDDB( hBitmap, FALSE ) : hBitmap ); - -#ifdef WIN - if( mhDIB ) - { - PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER) GlobalLock( mhDIB ); - - maSize = Size( pBIH->biWidth, pBIH->biHeight ); - mnBitCount = pBIH->biBitCount; - - if( mnBitCount ) - mnBitCount = ( mnBitCount <= 1 ) ? 1 : ( mnBitCount <= 4 ) ? 4 : ( mnBitCount <= 8 ) ? 8 : 24; - - GlobalUnlock( mhDIB ); - } - else if( mhDDB ) - { - BITMAP aDDBInfo; - - if( WIN_GetObject( mhDDB, sizeof( BITMAP ), &aDDBInfo ) ) - { - maSize = Size( aDDBInfo.bmWidth, aDDBInfo.bmHeight ); - mnBitCount = aDDBInfo.bmPlanes * aDDBInfo.bmBitsPixel; - - if( mnBitCount ) - { - mnBitCount = ( mnBitCount <= 1 ) ? 1 : - ( mnBitCount <= 4 ) ? 4 : - ( mnBitCount <= 8 ) ? 8 : 24; - } - } - else - { - mhDDB = 0; - bRet = FALSE; - } - } - else -#endif - 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; + return FALSE; } // ------------------------------------------------------------------ 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 = (HGLOBAL) hNewHdl; - else if( rSalBitmap.mhDDB ) - mhDDB = (HBITMAP) hNewHdl; - - maSize = rSalBitmap.maSize; - mnBitCount = rSalBitmap.mnBitCount; - - bRet = TRUE; - } - } - - return bRet; + return FALSE; } // ------------------------------------------------------------------ BOOL SalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) { - BOOL bRet = FALSE; - - if( rSalBmp.mhDIB ) - { -#ifdef WIN - PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( rSalBmp.mhDIB ); - PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER) pBI; - VCLVIEW hDC = pGraphics->maGraphicsData.mhDC; - HBITMAP hNewDDB; - BITMAP aDDBInfo; - PBYTE pBits = (PBYTE) pBI + *(DWORD*) pBI + - ImplGetDIBColorCount( rSalBmp.mhDIB ) * sizeof( RGBQUAD ); - - if( pBIH->biBitCount == 1 ) - { - hNewDDB = CreateBitmap( pBIH->biWidth, pBIH->biHeight, 1, 1, NULL ); - - if( hNewDDB ) - SetDIBits( hDC, hNewDDB, 0, pBIH->biHeight, pBits, pBI, DIB_RGB_COLORS ); - } - else - hNewDDB = CreateDIBitmap( hDC, (PBITMAPINFOHEADER) pBI, CBM_INIT, pBits, pBI, DIB_RGB_COLORS ); - - GlobalUnlock( rSalBmp.mhDIB ); - - if( hNewDDB && WIN_GetObject( hNewDDB, sizeof( BITMAP ), &aDDBInfo ) ) - { - mhDDB = hNewDDB; - maSize = Size( aDDBInfo.bmWidth, aDDBInfo.bmHeight ); - mnBitCount = aDDBInfo.bmPlanes * aDDBInfo.bmBitsPixel; - - if( mnBitCount ) - { - mnBitCount = ( mnBitCount <= 1 ) ? 1 : - ( mnBitCount <= 4 ) ? 4 : - ( mnBitCount <= 8 ) ? 8 : 24; - } - - bRet = TRUE; - } - else if( hNewDDB ) - DeleteObject( hNewDDB ); -#endif - } - - return bRet; + return FALSE; } // ------------------------------------------------------------------ BOOL SalBitmap::Create( const SalBitmap& rSalBmp, USHORT nNewBitCount ) { - BOOL bRet = FALSE; - - if( rSalBmp.mhDDB ) - { - mhDIB = ImplCreateDIB( rSalBmp.maSize, nNewBitCount, BitmapPalette() ); - - if( mhDIB ) - { -#ifdef WIN - PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( mhDIB ); - const int nLines = (int) rSalBmp.maSize.Height(); - VCLVIEW hDC = GetDC( 0 ); - PBYTE pBits = (PBYTE) pBI + *(DWORD*) pBI + - ImplGetDIBColorCount( mhDIB ) * sizeof( RGBQUAD ); - SalData* pSalData = GetSalData(); - HPALETTE hOldPal = 0; - - if ( pSalData->mhDitherPal ) - { - hOldPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE ); - RealizePalette( hDC ); - } - - if( GetDIBits( hDC, rSalBmp.mhDDB, 0, nLines, pBits, pBI, DIB_RGB_COLORS ) == nLines ) - { - GlobalUnlock( mhDIB ); - maSize = rSalBmp.maSize; - mnBitCount = nNewBitCount; - bRet = TRUE; - } - else - { - GlobalUnlock( mhDIB ); - GlobalFree( mhDIB ); - mhDIB = 0; - } - - if( hOldPal ) - SelectPalette( hDC, hOldPal, TRUE ); - - ReleaseDC( 0, hDC ); -#endif - } - } - - return bRet; + return FALSE; } // ------------------------------------------------------------------ void SalBitmap::Destroy() { -#ifdef WIN - if( mhDIB ) - GlobalFree( mhDIB ); - else if( mhDDB ) - DeleteObject( mhDDB ); -#endif - - maSize = Size(); - mnBitCount = 0; -} - -// ------------------------------------------------------------------ - -USHORT SalBitmap::ImplGetDIBColorCount( HGLOBAL hDIB ) -{ - USHORT nColors = 0; - - if( hDIB ) - { -#ifdef WIN - PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( hDIB ); - PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER) pBI; - - if ( pBIH->biSize != sizeof( BITMAPCOREHEADER ) ) - { - if( pBIH->biBitCount <= 8 ) - { - if ( pBIH->biClrUsed ) - nColors = (USHORT) pBIH->biClrUsed; - else - nColors = 1 << pBIH->biBitCount; - } - } - else if( ( (PBITMAPCOREHEADER) pBI )->bcBitCount <= 8 ) - nColors = 1 << ( (PBITMAPCOREHEADER) pBI )->bcBitCount; - - GlobalUnlock( hDIB ); -#endif - } - - return nColors; -} - -// ------------------------------------------------------------------ - -HGLOBAL SalBitmap::ImplCreateDIB( const Size& rSize, USHORT nBits, const BitmapPalette& rPal ) -{ - DBG_ASSERT( nBits == 1 || nBits == 4 || nBits == 8 || nBits == 24, "Unsupported BitCount!" ); - - HGLOBAL hDIB = 0; - - if ( rSize.Width() && rSize.Height() && ( nBits == 1 || nBits == 4 || nBits == 8 || nBits == 24 ) ) - { -#ifdef WIN - const ULONG nImageSize = AlignedWidth4Bytes( nBits * rSize.Width() ) * rSize.Height(); - const USHORT nColors = ( nBits <= 8 ) ? ( 1 << nBits ) : 0; - - hDIB = GlobalAlloc( GHND, sizeof( BITMAPINFOHEADER ) + nColors * sizeof( RGBQUAD ) + nImageSize ); - - if( hDIB ) - { - PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( hDIB ); - PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER) pBI; - - pBIH->biSize = sizeof( BITMAPINFOHEADER ); - pBIH->biWidth = rSize.Width(); - pBIH->biHeight = rSize.Height(); - pBIH->biPlanes = 1; - pBIH->biBitCount = nBits; - pBIH->biCompression = BI_RGB; - pBIH->biSizeImage = nImageSize; - pBIH->biXPelsPerMeter = 0; - pBIH->biYPelsPerMeter = 0; - pBIH->biClrUsed = 0; - pBIH->biClrImportant = 0; - - if ( nColors ) - { - const USHORT nMinCount = Min( nColors, rPal.GetEntryCount() ); - - if( nMinCount ) - HMEMCPY( pBI->bmiColors, rPal.ImplGetColorBuffer(), nMinCount * sizeof( RGBQUAD ) ); - } - - GlobalUnlock( hDIB ); - } -#endif - } - - return hDIB; -} - -// ------------------------------------------------------------------ - -HANDLE SalBitmap::ImplCopyDIBOrDDB( HANDLE hHdl, BOOL bDIB ) -{ - HANDLE hCopy = 0; - -#ifdef WIN - if ( bDIB && hHdl ) - { - const ULONG nSize = GlobalSize( hHdl ); - - if ( hCopy = GlobalAlloc( GHND, nSize ) ) - { - HMEMCPY( (LPSTR) GlobalLock( hCopy ), (LPSTR) GlobalLock( hHdl ), nSize ); - - GlobalUnlock( hCopy ); - GlobalUnlock( hHdl ); - } - } - else if ( hHdl ) - { - BITMAP aBmp; - - // Source-Bitmap nach Groesse befragen - WIN_GetObject( hHdl, sizeof( BITMAP ), (LPSTR) &aBmp ); - - // Destination-Bitmap erzeugen - if ( hCopy = CreateBitmapIndirect( &aBmp ) ) - { - VCLVIEW hBmpDC = CreateCompatibleDC( 0 ); - HBITMAP hBmpOld = (HBITMAP) SelectObject( hBmpDC, hHdl ); - VCLVIEW hCopyDC = CreateCompatibleDC( hBmpDC ); - HBITMAP hCopyOld = (HBITMAP) SelectObject( hCopyDC, hCopy ); - - BitBlt( hCopyDC, 0, 0, aBmp.bmWidth, aBmp.bmHeight, hBmpDC, 0, 0, SRCCOPY ); - - SelectObject( hCopyDC, hCopyOld ); - DeleteDC( hCopyDC ); - - SelectObject( hBmpDC, hBmpOld ); - DeleteDC( hBmpDC ); - } - } -#endif - - return hCopy; } // ------------------------------------------------------------------ BitmapBuffer* SalBitmap::AcquireBuffer( BOOL bReadOnly ) { - BitmapBuffer* pBuffer = NULL; - - if( mhDIB ) - { -#ifdef WIN - PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( mhDIB ); - PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER) pBI; - - if( ( pBIH->biCompression == BI_RLE4 ) || ( pBIH->biCompression == BI_RLE8 ) ) - { - Size aSizePix( pBIH->biWidth, pBIH->biHeight ); - HGLOBAL hNewDIB = ImplCreateDIB( aSizePix, pBIH->biBitCount, BitmapPalette() ); - - if( hNewDIB ) - { - PBITMAPINFO pNewBI = (PBITMAPINFO) GlobalLock( hNewDIB ); - PBITMAPINFOHEADER pNewBIH = (PBITMAPINFOHEADER) pNewBI; - const USHORT nColorCount = ImplGetDIBColorCount( hNewDIB ); - const ULONG nOffset = *(DWORD*) pBI + nColorCount * sizeof( RGBQUAD ); - BYTE* pOldBits = (PBYTE) pBI + nOffset; - BYTE* pNewBits = (PBYTE) pNewBI + nOffset; - - HMEMCPY( pNewBI, pBI, nOffset ); - pNewBIH->biCompression = 0; - ImplDecodeRLEBuffer( pOldBits, pNewBits, aSizePix, pBIH->biCompression == BI_RLE4 ); - - GlobalUnlock( mhDIB ); - GlobalFree( mhDIB ); - mhDIB = hNewDIB; - pBI = pNewBI; - pBIH = pNewBIH; - } - } - - if( pBIH->biPlanes == 1 ) - { - pBuffer = new BitmapBuffer; - - pBuffer->mnFormat = BMP_FORMAT_BOTTOM_UP | - ( pBIH->biBitCount == 1 ? BMP_FORMAT_1BIT_MSB_PAL : - pBIH->biBitCount == 4 ? BMP_FORMAT_4BIT_MSN_PAL : - pBIH->biBitCount == 8 ? BMP_FORMAT_8BIT_PAL : - pBIH->biBitCount == 16 ? BMP_FORMAT_16BIT_TC_MASK : - pBIH->biBitCount == 24 ? BMP_FORMAT_24BIT_TC_BGR : - pBIH->biBitCount == 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->biBitCount ); - pBuffer->mnBitCount = (USHORT) pBIH->biBitCount; - - if( pBuffer->mnBitCount <= 8 ) - { - const USHORT nPalCount = ImplGetDIBColorCount( mhDIB ); - - pBuffer->maPalette.SetEntryCount( nPalCount ); - HMEMCPY( pBuffer->maPalette.ImplGetColorBuffer(), pBI->bmiColors, nPalCount * sizeof( RGBQUAD ) ); - pBuffer->mpBits = (PBYTE) pBI + *(DWORD*) pBI + nPalCount * sizeof( RGBQUAD ); - } - else if( ( pBIH->biBitCount == 16 ) || ( pBIH->biBitCount == 32 ) ) - { - ULONG nOffset = 0UL; - - if( pBIH->biCompression == BI_BITFIELDS ) - { - nOffset = 3 * sizeof( RGBQUAD ); - pBuffer->maColorMask = ColorMask( *(UINT32*) &pBI->bmiColors[ 0 ], - *(UINT32*) &pBI->bmiColors[ 1 ], - *(UINT32*) &pBI->bmiColors[ 2 ] ); - } - else if( pBIH->biCompression == 16 ) - pBuffer->maColorMask = ColorMask( 0x00007c00UL, 0x000003e0UL, 0x0000001fUL ); - else - pBuffer->maColorMask = ColorMask( 0x00ff0000UL, 0x0000ff00UL, 0x000000ffUL ); - - pBuffer->mpBits = (PBYTE) pBI + *(DWORD*) pBI + nOffset; - } - else - pBuffer->mpBits = (PBYTE) pBI + *(DWORD*) pBI; - } - else - { - GlobalUnlock( mhDIB ); - delete pBuffer; - pBuffer = NULL; - } - } - else - GlobalUnlock( mhDIB ); -#endif - } - - return pBuffer; + return NULL; } // ------------------------------------------------------------------ void SalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BOOL bReadOnly ) { - if( pBuffer ) - { - if( mhDIB ) - { -#ifdef WIN - if( !bReadOnly && !!pBuffer->maPalette ) - { - PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( mhDIB ); - const USHORT nCount = pBuffer->maPalette.GetEntryCount(); - - HMEMCPY( pBI->bmiColors, pBuffer->maPalette.ImplGetColorBuffer(), nCount * sizeof( RGBQUAD ) ); - GlobalUnlock( mhDIB ); - } - - GlobalUnlock( mhDIB ); -#endif - } - - 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/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index 03a6699135fe..996cd497e9ce 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salgdi.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:45 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,16 +59,10 @@ * ************************************************************************/ -#include <stdio.h> -#include <string.h> - -#ifndef _SVWIN_H -#include <tools/svwin.h> -#endif #define _SV_SALGDI_CXX -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> +#ifndef _SV_SALBMP_HXX +#include <salbmp.hxx> #endif #ifndef _SV_SALDATA_HXX #include <saldata.hxx> @@ -76,1461 +70,296 @@ #ifndef _SV_SALGDI_HXX #include <salgdi.hxx> #endif -#ifndef _DEBUG_HXX -#include <tools/debug.hxx> -#endif -// ======================================================================= - -#define DITHER_PAL_DELTA 51 -#define DITHER_PAL_STEPS 6 -#define DITHER_PAL_COUNT (DITHER_PAL_STEPS*DITHER_PAL_STEPS*DITHER_PAL_STEPS) -#define DITHER_MAX_SYSCOLOR 16 -#define DITHER_EXTRA_COLORS 1 -#define DMAP( _def_nVal, _def_nThres ) ((pDitherDiff[_def_nVal]>(_def_nThres))?pDitherHigh[_def_nVal]:pDitherLow[_def_nVal]) // ======================================================================= -struct SysColorEntry +SalGraphics::SalGraphics() { - DWORD nRGB; - SysColorEntry* pNext; -}; - -// ======================================================================= - -static SysColorEntry* pFirstSysColor = NULL; -static SysColorEntry* pActSysColor = NULL; +} -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------- -// Blue7 -#ifdef WIN -static PALETTEENTRY aImplExtraColor1 = +SalGraphics::~SalGraphics() { - 0, 184, 255, 0 -}; -#endif +} -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------- -#ifdef WIN -static PALETTEENTRY aImplSalSysPalEntryAry[ DITHER_MAX_SYSCOLOR ] = +void SalGraphics::GetResolution( long& rDPIX, long& rDPIY ) { -{ 0, 0, 0, 0 }, -{ 0, 0, 0x80, 0 }, -{ 0, 0x80, 0, 0 }, -{ 0, 0x80, 0x80, 0 }, -{ 0x80, 0, 0, 0 }, -{ 0x80, 0, 0x80, 0 }, -{ 0x80, 0x80, 0, 0 }, -{ 0x80, 0x80, 0x80, 0 }, -{ 0xC0, 0xC0, 0xC0, 0 }, -{ 0, 0, 0xFF, 0 }, -{ 0, 0xFF, 0, 0 }, -{ 0, 0xFF, 0xFF, 0 }, -{ 0xFF, 0, 0, 0 }, -{ 0xFF, 0, 0xFF, 0 }, -{ 0xFF, 0xFF, 0, 0 }, -{ 0xFF, 0xFF, 0xFF, 0 } -}; -#endif +} -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------- -static BYTE aOrdDither8Bit[8][8] = -{ - 0, 38, 9, 48, 2, 40, 12, 50, - 25, 12, 35, 22, 28, 15, 37, 24, - 6, 44, 3, 41, 8, 47, 5, 44, - 32, 19, 28, 16, 34, 21, 31, 18, - 1, 40, 11, 49, 0, 39, 10, 48, - 27, 14, 36, 24, 26, 13, 36, 23, - 8, 46, 4, 43, 7, 45, 4, 42, - 33, 20, 30, 17, 32, 20, 29, 16 -}; - -// ----------------------------------------------------------------------------- - -static BYTE aOrdDither16Bit[8][8] = +void SalGraphics::GetScreenFontResolution( long& rDPIX, long& rDPIY ) { - 0, 6, 1, 7, 0, 6, 1, 7, - 4, 2, 5, 3, 4, 2, 5, 3, - 1, 7, 0, 6, 1, 7, 0, 6, - 5, 3, 4, 2, 5, 3, 4, 2, - 0, 6, 1, 7, 0, 6, 1, 7, - 4, 2, 5, 3, 4, 2, 5, 3, - 1, 7, 0, 6, 1, 7, 0, 6, - 5, 3, 4, 2, 5, 3, 4, 2 -}; - -// ======================================================================= - -// Pens muessen wir mit 1 Pixel-Breite erzeugen, da ansonsten die S3-Karte -// viele Paintprobleme hat, wenn Polygone/PolyLines gezeichnet werden und -// eine komplexe ClipRegion gesetzt ist -#define GSL_PEN_WIDTH 1 - -// ======================================================================= - -#define SAL_POLYPOLYCOUNT_STACKBUF 8 -#define SAL_POLYPOLYPOINTS_STACKBUF 64 +} -// ======================================================================= +// ----------------------------------------------------------------------- -void ImplInitSalGDI() +USHORT SalGraphics::GetBitCount() { - SalData* pSalData = GetSalData(); - -#ifdef WIN - // init stock brushes - pSalData->maStockPenColorAry[0] = PALETTERGB( 0, 0, 0 ); - pSalData->maStockPenColorAry[1] = PALETTERGB( 0xFF, 0xFF, 0xFF ); - pSalData->maStockPenColorAry[2] = PALETTERGB( 0xC0, 0xC0, 0xC0 ); - pSalData->maStockPenColorAry[3] = PALETTERGB( 0x80, 0x80, 0x80 ); - pSalData->mhStockPenAry[0] = CreatePen( PS_SOLID, GSL_PEN_WIDTH, pSalData->maStockPenColorAry[0] ); - pSalData->mhStockPenAry[1] = CreatePen( PS_SOLID, GSL_PEN_WIDTH, pSalData->maStockPenColorAry[1] ); - pSalData->mhStockPenAry[2] = CreatePen( PS_SOLID, GSL_PEN_WIDTH, pSalData->maStockPenColorAry[2] ); - pSalData->mhStockPenAry[3] = CreatePen( PS_SOLID, GSL_PEN_WIDTH, pSalData->maStockPenColorAry[3] ); - pSalData->mnStockPenCount = 4; - - pSalData->maStockBrushColorAry[0] = PALETTERGB( 0, 0, 0 ); - pSalData->maStockBrushColorAry[1] = PALETTERGB( 0xFF, 0xFF, 0xFF ); - pSalData->maStockBrushColorAry[2] = PALETTERGB( 0xC0, 0xC0, 0xC0 ); - pSalData->maStockBrushColorAry[3] = PALETTERGB( 0x80, 0x80, 0x80 ); - pSalData->mhStockBrushAry[0] = CreateSolidBrush( pSalData->maStockBrushColorAry[0] ); - pSalData->mhStockBrushAry[1] = CreateSolidBrush( pSalData->maStockBrushColorAry[1] ); - pSalData->mhStockBrushAry[2] = CreateSolidBrush( pSalData->maStockBrushColorAry[2] ); - pSalData->mhStockBrushAry[3] = CreateSolidBrush( pSalData->maStockBrushColorAry[3] ); - pSalData->mnStockBrushCount = 4; -#endif - - // DC-Cache aufbauen - pSalData->mpVCLVIEWCache = new VCLVIEWCache[ CACHESIZE_VCLVIEW ]; - memset( pSalData->mpVCLVIEWCache, 0, CACHESIZE_VCLVIEW * sizeof( VCLVIEWCache ) ); - -#ifdef WIN - // Nur bei 256 Farben Displays, die Paletten unterstuetzen - VCLVIEW hDC = GetDC( 0 ); - int nBitsPixel = GetDeviceCaps( hDC, BITSPIXEL ); - int nPlanes = GetDeviceCaps( hDC, PLANES ); - int nRasterCaps = GetDeviceCaps( hDC, RASTERCAPS ); - int nBitCount = nBitsPixel * nPlanes; - - if ( (nBitCount > 8) && (nBitCount < 24) ) - { - // test, if we have to dither - VCLVIEW hMemDC = ::CreateCompatibleDC( hDC ); - HBITMAP hMemBmp = ::CreateCompatibleBitmap( hDC, 8, 8 ); - HBITMAP hBmpOld = (HBITMAP) ::SelectObject( hMemDC, hMemBmp ); - HBRUSH hMemBrush = ::CreateSolidBrush( PALETTERGB( 175, 171, 169 ) ); - HBRUSH hBrushOld = (HBRUSH) ::SelectObject( hMemDC, hMemBrush ); - BOOL bDither16 = TRUE; - - ::PatBlt( hMemDC, 0, 0, 8, 8, PATCOPY ); - const COLORREF aCol( ::GetPixel( hMemDC, 0, 0 ) ); - - for( int nY = 0; ( nY < 8 ) && bDither16; nY++ ) - for( int nX = 0; ( nX < 8 ) && bDither16; nX++ ) - if( ::GetPixel( hMemDC, nX, nY ) != aCol ) - bDither16 = FALSE; - - ::SelectObject( hMemDC, hBrushOld ), ::DeleteObject( hMemBrush ); - ::SelectObject( hMemDC, hBmpOld ), ::DeleteObject( hMemBmp ); - ::DeleteDC( hMemDC ); - - if( bDither16 ) - { - // create DIBPattern for 16Bit dithering - long n; - - pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, sizeof( BITMAPINFOHEADER ) + 192 ); - pSalData->mpDitherDIB = (BYTE*) GlobalLock( pSalData->mhDitherDIB ); - pSalData->mpDitherDiff = new long[ 256 ]; - pSalData->mpDitherLow = new BYTE[ 256 ]; - pSalData->mpDitherHigh = new BYTE[ 256 ]; - pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( BITMAPINFOHEADER ); - memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) ); - - BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) pSalData->mpDitherDIB; - - pBIH->biSize = sizeof( BITMAPINFOHEADER ); - pBIH->biWidth = 8; - pBIH->biHeight = 8; - pBIH->biPlanes = 1; - pBIH->biBitCount = 24; - - for( n = 0; n < 256L; n++ ) - pSalData->mpDitherDiff[ n ] = n - ( n & 248L ); - - for( n = 0; n < 256L; n++ ) - pSalData->mpDitherLow[ n ] = (BYTE) ( n & 248 ); - - for( n = 0; n < 256L; n++ ) - pSalData->mpDitherHigh[ n ] = (BYTE) Min( pSalData->mpDitherLow[ n ] + 8L, 255L ); - } - } - else if ( (nRasterCaps & RC_PALETTE) && (nBitCount == 8) ) - { - BYTE nRed, nGreen, nBlue; - BYTE nR, nG, nB; - PALETTEENTRY* pPalEntry; - LOGPALETTE* pLogPal; - const USHORT nDitherPalCount = DITHER_PAL_COUNT; - ULONG nTotalCount = DITHER_MAX_SYSCOLOR + nDitherPalCount + DITHER_EXTRA_COLORS; - - // create logical palette - pLogPal = (LOGPALETTE*) new char[ sizeof( LOGPALETTE ) + ( nTotalCount * sizeof( PALETTEENTRY ) ) ]; - pLogPal->palVersion = 0x0300; - pLogPal->palNumEntries = (USHORT) nTotalCount; - pPalEntry = pLogPal->palPalEntry; - - // Standard colors - memcpy( pPalEntry, aImplSalSysPalEntryAry, DITHER_MAX_SYSCOLOR * sizeof( PALETTEENTRY ) ); - pPalEntry += DITHER_MAX_SYSCOLOR; - - // own palette (6/6/6) - for( nB=0, nBlue=0; nB < DITHER_PAL_STEPS; nB++, nBlue += DITHER_PAL_DELTA ) - { - for( nG=0, nGreen=0; nG < DITHER_PAL_STEPS; nG++, nGreen += DITHER_PAL_DELTA ) - { - for( nR=0, nRed=0; nR < DITHER_PAL_STEPS; nR++, nRed += DITHER_PAL_DELTA ) - { - pPalEntry->peRed = nRed; - pPalEntry->peGreen = nGreen; - pPalEntry->peBlue = nBlue; - pPalEntry->peFlags = 0; - pPalEntry++; - } - } - } - - // insert special 'Blue' as standard drawing color - *pPalEntry++ = aImplExtraColor1; - - // create palette - pSalData->mhDitherPal = CreatePalette( pLogPal ); - delete[] (char*) pLogPal; - - if( pSalData->mhDitherPal ) - { - // create DIBPattern for 8Bit dithering - long nSize = sizeof( BITMAPINFOHEADER ) + ( 256 * sizeof( short ) ) + 64; - long n; - - pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, nSize ); - pSalData->mpDitherDIB = (BYTE*) GlobalLock( pSalData->mhDitherDIB ); - pSalData->mpDitherDiff = new long[ 256 ]; - pSalData->mpDitherLow = new BYTE[ 256 ]; - pSalData->mpDitherHigh = new BYTE[ 256 ]; - pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( BITMAPINFOHEADER ) + ( 256 * sizeof( short ) ); - memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) ); - - BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) pSalData->mpDitherDIB; - short* pColors = (short*) ( pSalData->mpDitherDIB + sizeof( BITMAPINFOHEADER ) ); - - pBIH->biSize = sizeof( BITMAPINFOHEADER ); - pBIH->biWidth = 8; - pBIH->biHeight = 8; - pBIH->biPlanes = 1; - pBIH->biBitCount = 8; - - for( n = 0; n < nDitherPalCount; n++ ) - pColors[ n ] = (short)( n + DITHER_MAX_SYSCOLOR ); - - for( n = 0; n < 256L; n++ ) - pSalData->mpDitherDiff[ n ] = n % 51L; - - for( n = 0; n < 256L; n++ ) - pSalData->mpDitherLow[ n ] = (BYTE) ( n / 51L ); - - for( n = 0; n < 256L; n++ ) - pSalData->mpDitherHigh[ n ] = Min( pSalData->mpDitherLow[ n ] + 1, 5 ); - } - - // get system color entries - ImplUpdateSysColorEntries(); - } - - ReleaseDC( 0, hDC ); -#endif + return 0; } // ----------------------------------------------------------------------- -void ImplFreeSalGDI() +void SalGraphics::ResetClipRegion() { - SalData* pSalData = GetSalData(); - USHORT i; - - // destroy stock objects - for ( i = 0; i < pSalData->mnStockPenCount; i++ ) - DeletePen( pSalData->mhStockPenAry[i] ); - for ( i = 0; i < pSalData->mnStockBrushCount; i++ ) - DeleteBrush( pSalData->mhStockBrushAry[i] ); - - // 50% Brush loeschen - if ( pSalData->mh50Brush ) - { - DeleteBrush( pSalData->mh50Brush ); - pSalData->mh50Brush = 0; - } - - // 50% Bitmap loeschen - if ( pSalData->mh50Bmp ) - { - DeleteBitmap( pSalData->mh50Bmp ); - pSalData->mh50Bmp = 0; - } - - ImplClearVCLVIEWCache( pSalData ); - delete[] pSalData->mpVCLVIEWCache; - - // Ditherpalette loeschen, wenn vorhanden - if ( pSalData->mhDitherPal ) - { -#ifdef WIN - DeleteObject( pSalData->mhDitherPal ); -#endif - pSalData->mhDitherPal = 0; - } - - // delete buffers for dithering DIB patterns, if neccessary - if ( pSalData->mhDitherDIB ) - { -#ifdef WIN - GlobalUnlock( pSalData->mhDitherDIB ); - GlobalFree( pSalData->mhDitherDIB ); -#endif - pSalData->mhDitherDIB = 0; - delete[] pSalData->mpDitherDiff; - delete[] pSalData->mpDitherLow; - delete[] pSalData->mpDitherHigh; - } - - // delete SysColorList - SysColorEntry* pEntry = pFirstSysColor; - while( pEntry ) - { - SysColorEntry* pTmp = pEntry->pNext; - delete pEntry; - pEntry = pTmp; - } - pFirstSysColor = NULL; } // ----------------------------------------------------------------------- -static int ImplIsPaletteEntry( BYTE nRed, BYTE nGreen, BYTE nBlue ) +void SalGraphics::BeginSetClipRegion( ULONG nRectCount ) { - // dither color? - if ( !(nRed % DITHER_PAL_DELTA) && !(nGreen % DITHER_PAL_DELTA) && !(nBlue % DITHER_PAL_DELTA) ) - return TRUE; - -#ifdef WIN - PALETTEENTRY* pPalEntry = aImplSalSysPalEntryAry; - - // standard palette color? - for ( USHORT i = 0; i < DITHER_MAX_SYSCOLOR; i++, pPalEntry++ ) - { - if( pPalEntry->peRed == nRed && pPalEntry->peGreen == nGreen && pPalEntry->peBlue == nBlue ) - return TRUE; - } - - // extra color? - if ( aImplExtraColor1.peRed == nRed && - aImplExtraColor1.peGreen == nGreen && - aImplExtraColor1.peBlue == nBlue ) - { - return TRUE; - } - -#endif - return FALSE; } -// ======================================================================= -int ImplIsSysColorEntry( SalColor nSalColor ) -{ - SysColorEntry* pEntry = pFirstSysColor; -#ifdef WIN - const DWORD nTestRGB = (DWORD)RGB( SALCOLOR_RED( nSalColor ), - SALCOLOR_GREEN( nSalColor ), - SALCOLOR_BLUE( nSalColor ) ); - - while ( pEntry ) - { - if ( pEntry->nRGB == nTestRGB ) - return TRUE; - pEntry = pEntry->pNext; - } -#endif +// ----------------------------------------------------------------------- - return FALSE; +BOOL SalGraphics::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) +{ + return TRUE; } -// ======================================================================= +// ----------------------------------------------------------------------- -static void ImplInsertSysColorEntry( int nSysIndex ) +void SalGraphics::EndSetClipRegion() { -#ifdef WIN - const DWORD nRGB = GetSysColor( nSysIndex ); - - if ( !ImplIsPaletteEntry( GetRValue( nRGB ), GetGValue( nRGB ), GetBValue( nRGB ) ) ) - { - if ( !pFirstSysColor ) - { - pActSysColor = pFirstSysColor = new SysColorEntry; - pFirstSysColor->nRGB = nRGB; - pFirstSysColor->pNext = NULL; - } - else - { - pActSysColor = pActSysColor->pNext = new SysColorEntry; - pActSysColor->nRGB = nRGB; - pActSysColor->pNext = NULL; - } - } -#endif } -// ======================================================================= +// ----------------------------------------------------------------------- -void ImplUpdateSysColorEntries() +void SalGraphics::SetLineColor() { - // delete old SysColorList - SysColorEntry* pEntry = pFirstSysColor; - while( pEntry ) - { - SysColorEntry* pTmp = pEntry->pNext; - delete pEntry; - pEntry = pTmp; - } - pActSysColor = pFirstSysColor = NULL; - -#ifdef WIN - // create new sys color list - ImplInsertSysColorEntry( COLOR_ACTIVEBORDER ); - ImplInsertSysColorEntry( COLOR_INACTIVEBORDER ); - if( aSalShlData.mnVersion >= 410 ) - { - ImplInsertSysColorEntry( COLOR_GRADIENTACTIVECAPTION ); - ImplInsertSysColorEntry( COLOR_GRADIENTINACTIVECAPTION ); - } - ImplInsertSysColorEntry( COLOR_3DFACE ); - ImplInsertSysColorEntry( COLOR_3DHILIGHT ); - ImplInsertSysColorEntry( COLOR_3DLIGHT ); - ImplInsertSysColorEntry( COLOR_3DSHADOW ); - ImplInsertSysColorEntry( COLOR_3DDKSHADOW ); - ImplInsertSysColorEntry( COLOR_INFOBK ); - ImplInsertSysColorEntry( COLOR_INFOTEXT ); - ImplInsertSysColorEntry( COLOR_BTNTEXT ); - ImplInsertSysColorEntry( COLOR_WINDOW ); - ImplInsertSysColorEntry( COLOR_WINDOWTEXT ); - ImplInsertSysColorEntry( COLOR_HIGHLIGHT ); - ImplInsertSysColorEntry( COLOR_HIGHLIGHTTEXT ); - ImplInsertSysColorEntry( COLOR_MENU ); - ImplInsertSysColorEntry( COLOR_MENUTEXT ); - ImplInsertSysColorEntry( COLOR_ACTIVECAPTION ); - ImplInsertSysColorEntry( COLOR_CAPTIONTEXT ); - ImplInsertSysColorEntry( COLOR_INACTIVECAPTION ); - ImplInsertSysColorEntry( COLOR_INACTIVECAPTIONTEXT ); -#endif } // ----------------------------------------------------------------------- -static SalColor ImplGetROPSalColor( SalROPColor nROPColor ) +void SalGraphics::SetLineColor( SalColor nSalColor ) { - SalColor nSalColor; - if ( nROPColor == SAL_ROP_0 ) - nSalColor = MAKE_SALCOLOR( 0, 0, 0 ); - else - nSalColor = MAKE_SALCOLOR( 255, 255, 255 ); - return nSalColor; } -// ======================================================================= +// ----------------------------------------------------------------------- -void ImplSalInitGraphics( SalGraphicsData* pData ) +void SalGraphics::SetFillColor() { -#ifdef WIN - // Beim Printer berechnen wir die minimale Linienstaerke - if ( pData->mbPrinter ) - { - int nDPIX = GetDeviceCaps( pData->mhDC, LOGPIXELSX ); - if ( nDPIX <= 300 ) - pData->mnPenWidth = 0; - else - pData->mnPenWidth = nDPIX/300; - } - - ::SetTextAlign( pData->mhDC, TA_BASELINE | TA_LEFT | TA_NOUPDATECP ); - ::SetBkMode( pData->mhDC, TRANSPARENT ); - ::SetROP2( pData->mhDC, R2_COPYPEN ); -#endif } // ----------------------------------------------------------------------- -void ImplSalDeInitGraphics( SalGraphicsData* pData ) +void SalGraphics::SetFillColor( SalColor nSalColor ) { - // Default Objekte selektieren - if ( pData->mhDefPen ) - SelectPen( pData->mhDC, pData->mhDefPen ); - if ( pData->mhDefBrush ) - SelectBrush( pData->mhDC, pData->mhDefBrush ); - if ( pData->mhDefFont ) - SelectFont( pData->mhDC, pData->mhDefFont ); } -// ======================================================================= +// ----------------------------------------------------------------------- -VCLVIEW ImplGetCachedDC( ULONG nID, HBITMAP hBmp ) +void SalGraphics::SetXORMode( BOOL bSet ) { - SalData* pSalData = GetSalData(); - VCLVIEWCache* pC = &pSalData->mpVCLVIEWCache[ nID ]; - -#ifdef WIN - if( !pC->mhDC ) - { - VCLVIEW hDC = GetDC( 0 ); - - // neuen DC mit DefaultBitmap anlegen - pC->mhDC = CreateCompatibleDC( hDC ); - - if( pSalData->mhDitherPal ) - { - pC->mhDefPal = SelectPalette( pC->mhDC, pSalData->mhDitherPal, TRUE ); - RealizePalette( pC->mhDC ); - } - - pC->mhSelBmp = CreateCompatibleBitmap( hDC, CACHED_VCLVIEW_DEFEXT, CACHED_VCLVIEW_DEFEXT ); - pC->mhDefBmp = (HBITMAP) SelectObject( pC->mhDC, pC->mhSelBmp ); - - ReleaseDC( 0, hDC ); - } - - if ( hBmp ) - SelectObject( pC->mhDC, pC->mhActBmp = hBmp ); - else -#endif - pC->mhActBmp = 0; - - return pC->mhDC; } -// ======================================================================= +// ----------------------------------------------------------------------- -void ImplReleaseCachedDC( ULONG nID ) +void SalGraphics::SetROPLineColor( SalROPColor nROPColor ) { - SalData* pSalData = GetSalData(); - VCLVIEWCache* pC = &pSalData->mpVCLVIEWCache[ nID ]; - -#ifdef WIN - if ( pC->mhActBmp ) - SelectObject( pC->mhDC, pC->mhSelBmp ); -#endif } -// ======================================================================= +// ----------------------------------------------------------------------- -void ImplClearVCLVIEWCache( SalData* pData ) +void SalGraphics::SetROPFillColor( SalROPColor nROPColor ) { - for( ULONG i = 0; i < CACHESIZE_VCLVIEW; i++ ) - { - VCLVIEWCache* pC = &pData->mpVCLVIEWCache[ i ]; - -#ifdef WIN - if( pC->mhDC ) - { - SelectObject( pC->mhDC, pC->mhDefBmp ); - - if( pC->mhDefPal ) - SelectPalette( pC->mhDC, pC->mhDefPal, TRUE ); - - DeleteDC( pC->mhDC ); - DeleteObject( pC->mhSelBmp ); - } -#endif - } } -// ======================================================================= +// ----------------------------------------------------------------------- -SalGraphics::SalGraphics() +void SalGraphics::DrawPixel( long nX, long nY ) { - maGraphicsData.mhDC = 0; - maGraphicsData.mhPen = 0; - maGraphicsData.mhBrush = 0; - maGraphicsData.mhFont = 0; - maGraphicsData.mhRegion = 0; - maGraphicsData.mhDefPen = 0; - maGraphicsData.mhDefBrush = 0; - maGraphicsData.mhDefFont = 0; - maGraphicsData.mhDefPal = 0; -#ifdef WIN - maGraphicsData.mpStdClipRgnData = NULL; - maGraphicsData.mpLogFont = NULL; -#endif - maGraphicsData.mpFontCharSets = NULL; - maGraphicsData.mnFontCharSetCount = 0; -#ifdef WIN - maGraphicsData.mpFontKernPairs = NULL; -#endif - maGraphicsData.mnFontKernPairCount = 0; - maGraphicsData.mbFontKernInit = FALSE; - maGraphicsData.mnFontOverhang = 0; - maGraphicsData.mbXORMode = FALSE; - maGraphicsData.mnPenWidth = GSL_PEN_WIDTH; - maGraphicsData.mbCalcOverhang = TRUE; } // ----------------------------------------------------------------------- -SalGraphics::~SalGraphics() +void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor ) { - // Objekte zerstoeren - if ( maGraphicsData.mhPen ) - { - if ( !maGraphicsData.mbStockPen ) - DeletePen( maGraphicsData.mhPen ); - } - if ( maGraphicsData.mhBrush ) - { - if ( !maGraphicsData.mbStockBrush ) - DeleteBrush( maGraphicsData.mhBrush ); - } - if ( maGraphicsData.mhFont ) - DeleteFont( maGraphicsData.mhFont ); - - if ( maGraphicsData.mhRegion ) - { - DeleteRegion( maGraphicsData.mhRegion ); - maGraphicsData.mhRegion = 0; - } - - // Cache-Daten zerstoeren -#ifdef WIN - if ( maGraphicsData.mpStdClipRgnData ) - delete maGraphicsData.mpStdClipRgnData; - - if ( maGraphicsData.mpLogFont ) - delete maGraphicsData.mpLogFont; -#endif - - if ( maGraphicsData.mpFontCharSets ) - delete maGraphicsData.mpFontCharSets; - -#ifdef WIN - if ( maGraphicsData.mpFontKernPairs ) - delete maGraphicsData.mpFontKernPairs; -#endif } // ----------------------------------------------------------------------- -void SalGraphics::GetResolution( long& rDPIX, long& rDPIY ) +void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2 ) { -#ifdef WIN - rDPIX = GetDeviceCaps( maGraphicsData.mhDC, LOGPIXELSX ); - rDPIY = GetDeviceCaps( maGraphicsData.mhDC, LOGPIXELSY ); -#endif } // ----------------------------------------------------------------------- -void SalGraphics::GetScreenFontResolution( long& rDPIX, long& rDPIY ) +void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight ) { -#ifdef WIN - rDPIX = GetDeviceCaps( maGraphicsData.mhDC, LOGPIXELSX ); - rDPIY = GetDeviceCaps( maGraphicsData.mhDC, LOGPIXELSY ); -#endif } // ----------------------------------------------------------------------- -USHORT SalGraphics::GetBitCount() +void SalGraphics::DrawPolyLine( ULONG nPoints, const SalPoint* pPtAry ) { -#ifdef WIN - return (USHORT)GetDeviceCaps( maGraphicsData.mhDC, BITSPIXEL ); -#else - return 0; -#endif } // ----------------------------------------------------------------------- -void SalGraphics::ResetClipRegion() +void SalGraphics::DrawPolygon( ULONG nPoints, const SalPoint* pPtAry ) { - if ( maGraphicsData.mhRegion ) - { - DeleteRegion( maGraphicsData.mhRegion ); - maGraphicsData.mhRegion = 0; - } - -#ifdef WIN - SelectClipRgn( maGraphicsData.mhDC, 0 ); -#endif } // ----------------------------------------------------------------------- -void SalGraphics::BeginSetClipRegion( ULONG nRectCount ) +void SalGraphics::DrawPolyPolygon( ULONG nPoly, const ULONG* pPoints, + PCONSTSALPOINT* pPtAry ) { - if ( maGraphicsData.mhRegion ) - { - DeleteRegion( maGraphicsData.mhRegion ); - maGraphicsData.mhRegion = 0; - } - - ULONG nRectBufSize = sizeof(RECT)*nRectCount; -#ifdef WIN - if ( nRectCount < SAL_CLIPRECT_COUNT ) - { - if ( !maGraphicsData.mpStdClipRgnData ) - maGraphicsData.mpStdClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+(SAL_CLIPRECT_COUNT*sizeof(RECT))]; - maGraphicsData.mpClipRgnData = maGraphicsData.mpStdClipRgnData; - } - else - maGraphicsData.mpClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+nRectBufSize]; - maGraphicsData.mpClipRgnData->rdh.dwSize = sizeof( RGNDATAHEADER ); - maGraphicsData.mpClipRgnData->rdh.iType = RDH_RECTANGLES; - maGraphicsData.mpClipRgnData->rdh.nCount = nRectCount; - maGraphicsData.mpClipRgnData->rdh.nRgnSize = nRectBufSize; - SetRectEmpty( &(maGraphicsData.mpClipRgnData->rdh.rcBound) ); - maGraphicsData.mpNextClipRect = (RECT*)(&(maGraphicsData.mpClipRgnData->Buffer)); - maGraphicsData.mbFirstClipRect = TRUE; -#endif } - // ----------------------------------------------------------------------- -BOOL SalGraphics::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) +void SalGraphics::CopyBits( const SalTwoRect* pPosAry, + SalGraphics* pSrcGraphics ) { -#ifdef WIN - if ( nWidth && nHeight ) - { - RECT* pRect = maGraphicsData.mpNextClipRect; - RECT* pBoundRect = &(maGraphicsData.mpClipRgnData->rdh.rcBound); - long nRight = nX + nWidth; - long nBottom = nY + nHeight; - - if ( maGraphicsData.mbFirstClipRect ) - { - pBoundRect->left = nX; - pBoundRect->top = nY; - pBoundRect->right = nRight; - pBoundRect->bottom = nBottom; - maGraphicsData.mbFirstClipRect = FALSE; - } - else - { - if ( nX < pBoundRect->left ) - pBoundRect->left = (int)nX; - - if ( nY < pBoundRect->top ) - pBoundRect->top = (int)nY; - - if ( nRight > pBoundRect->right ) - pBoundRect->right = (int)nRight; - - if ( nBottom > pBoundRect->bottom ) - pBoundRect->bottom = (int)nBottom; - } - - pRect->left = (int)nX; - pRect->top = (int)nY; - pRect->right = (int)nRight; - pRect->bottom = (int)nBottom; - maGraphicsData.mpNextClipRect++; - } - else - { - maGraphicsData.mpClipRgnData->rdh.nCount--; - maGraphicsData.mpClipRgnData->rdh.nRgnSize -= sizeof( RECT ); - } -#endif - - return TRUE; } // ----------------------------------------------------------------------- -void SalGraphics::EndSetClipRegion() +void SalGraphics::CopyArea( long nDestX, long nDestY, + long nSrcX, long nSrcY, + long nSrcWidth, long nSrcHeight, + USHORT nFlags ) { -#ifdef WIN - // Aus den Region-Daten muessen wir jetzt eine ClipRegion erzeugen - if ( maGraphicsData.mpClipRgnData->rdh.nCount == 1 ) - { - RECT* pRect = &(maGraphicsData.mpClipRgnData->rdh.rcBound); - maGraphicsData.mhRegion = CreateRectRgn( pRect->left, pRect->top, - pRect->right, pRect->bottom ); - } - else - { - ULONG nSize = maGraphicsData.mpClipRgnData->rdh.nRgnSize+sizeof(RGNDATAHEADER); - maGraphicsData.mhRegion = ExtCreateRegion( NULL, nSize, maGraphicsData.mpClipRgnData ); - - // if ExtCreateRegion(...) is not supported - if( !maGraphicsData.mhRegion ) - { - RGNDATAHEADER* pHeader = (RGNDATAHEADER*) maGraphicsData.mpClipRgnData; - - if( pHeader->nCount ) - { - RECT* pRect = (RECT*) maGraphicsData.mpClipRgnData->Buffer; - maGraphicsData.mhRegion = CreateRectRgn( pRect->left, pRect->top, pRect->right, pRect->bottom ); - pRect++; - - for( ULONG n = 1; n < pHeader->nCount; n++, pRect++ ) - { - HRGN hRgn = CreateRectRgn( pRect->left, pRect->top, pRect->right, pRect->bottom ); - CombineRgn( maGraphicsData.mhRegion, maGraphicsData.mhRegion, hRgn, RGN_OR ); - DeleteRegion( hRgn ); - } - } - } - - if ( maGraphicsData.mpClipRgnData != maGraphicsData.mpStdClipRgnData ) - delete maGraphicsData.mpClipRgnData; - } - - SelectClipRgn( maGraphicsData.mhDC, maGraphicsData.mhRegion ); -#endif } // ----------------------------------------------------------------------- -void SalGraphics::SetLineColor() +void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap ) { -#ifdef WIN - // create and select new pen - HPEN hNewPen = GetStockPen( NULL_PEN ); - HPEN hOldPen = SelectPen( maGraphicsData.mhDC, hNewPen ); - - // destory or save old pen - if ( maGraphicsData.mhPen ) - { - if ( !maGraphicsData.mbStockPen ) - DeletePen( maGraphicsData.mhPen ); - } - else - maGraphicsData.mhDefPen = hOldPen; - - // set new data - maGraphicsData.mhPen = hNewPen; - maGraphicsData.mbPen = FALSE; - maGraphicsData.mbStockPen = TRUE; -#endif } // ----------------------------------------------------------------------- -void SalGraphics::SetLineColor( SalColor nSalColor ) +void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nTransparentColor ) { -#ifdef WIN - COLORREF nPenColor = PALETTERGB( SALCOLOR_RED( nSalColor ), - SALCOLOR_GREEN( nSalColor ), - SALCOLOR_BLUE( nSalColor ) ); - HPEN hNewPen = 0; - BOOL bStockPen; - - // search for stock pen (only screen, because printer have problems, - // when we use stock objects) - if ( !maGraphicsData.mbPrinter ) - { - SalData* pSalData = GetSalData(); - for ( USHORT i = 0; i < pSalData->mnStockPenCount; i++ ) - { - if ( nPenColor == pSalData->maStockPenColorAry[i] ) - { - hNewPen = pSalData->mhStockPenAry[i]; - bStockPen = TRUE; - break; - } - } - } - - // create new pen - if ( !hNewPen ) - { - if ( !maGraphicsData.mbPrinter ) - { - if ( GetSalData()->mhDitherPal && ImplIsSysColorEntry( nSalColor ) ) - nPenColor = PALRGB_TO_RGB( nPenColor ); - } - - hNewPen = CreatePen( PS_SOLID, maGraphicsData.mnPenWidth, nPenColor ); - bStockPen = FALSE; - } - - // select new pen - HPEN hOldPen = SelectPen( maGraphicsData.mhDC, hNewPen ); - - // destory or save old pen - if ( maGraphicsData.mhPen ) - { - if ( !maGraphicsData.mbStockPen ) - DeletePen( maGraphicsData.mhPen ); - } - else - maGraphicsData.mhDefPen = hOldPen; - - // set new data - maGraphicsData.mnPenColor = nPenColor; - maGraphicsData.mhPen = hNewPen; - maGraphicsData.mbPen = TRUE; - maGraphicsData.mbStockPen = bStockPen; -#endif } // ----------------------------------------------------------------------- -void SalGraphics::SetFillColor() +void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + const SalBitmap& rTransparentBitmap ) { - // create and select new brush -#ifdef WIN - HBRUSH hNewBrush = GetStockBrush( NULL_BRUSH ); - HBRUSH hOldBrush = SelectBrush( maGraphicsData.mhDC, hNewBrush ); -#endif - - // destory or save old brush - if ( maGraphicsData.mhBrush ) - { - if ( !maGraphicsData.mbStockBrush ) - DeleteBrush( maGraphicsData.mhBrush ); - } -#ifdef WIN - else - maGraphicsData.mhDefBrush = hOldBrush; - - // set new data - maGraphicsData.mhBrush = hNewBrush; -#endif - maGraphicsData.mbBrush = FALSE; - maGraphicsData.mbStockBrush = TRUE; } // ----------------------------------------------------------------------- -void SalGraphics::SetFillColor( SalColor nSalColor ) +void SalGraphics::DrawMask( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nMaskColor ) { -#ifdef WIN - SalData* pSalData = GetSalData(); - BYTE nRed = SALCOLOR_RED( nSalColor ); - BYTE nGreen = SALCOLOR_GREEN( nSalColor ); - BYTE nBlue = SALCOLOR_BLUE( nSalColor ); - COLORREF nBrushColor = PALETTERGB( nRed, nGreen, nBlue ); - HBRUSH hNewBrush = 0; - BOOL bStockBrush; - - // search for stock brush (only screen, because printer have problems, - // when we use stock objects) - if ( !maGraphicsData.mbPrinter ) - { - for ( USHORT i = 0; i < pSalData->mnStockBrushCount; i++ ) - { - if ( nBrushColor == pSalData->maStockBrushColorAry[ i ] ) - { - hNewBrush = pSalData->mhStockBrushAry[i]; - bStockBrush = TRUE; - break; - } - } - } - - // create new brush - if ( !hNewBrush ) - { - if ( maGraphicsData.mbPrinter || !pSalData->mhDitherDIB ) - hNewBrush = CreateSolidBrush( nBrushColor ); - else - { - if ( 24 == ((BITMAPINFOHEADER*)pSalData->mpDitherDIB)->biBitCount ) - { - BYTE* pTmp = pSalData->mpDitherDIBData; - long* pDitherDiff = pSalData->mpDitherDiff; - BYTE* pDitherLow = pSalData->mpDitherLow; - BYTE* pDitherHigh = pSalData->mpDitherHigh; - - for( long nY = 0L; nY < 8L; nY++ ) - { - for( long nX = 0L; nX < 8L; nX++ ) - { - const long nThres = aOrdDither16Bit[ nY ][ nX ]; - *pTmp++ = DMAP( nBlue, nThres ); - *pTmp++ = DMAP( nGreen, nThres ); - *pTmp++ = DMAP( nRed, nThres ); - } - } - - hNewBrush = CreateDIBPatternBrush( pSalData->mhDitherDIB, DIB_RGB_COLORS ); - } - else if ( ImplIsSysColorEntry( nSalColor ) ) - { - nBrushColor = PALRGB_TO_RGB( nBrushColor ); - hNewBrush = CreateSolidBrush( nBrushColor ); - } - else if ( ImplIsPaletteEntry( nRed, nGreen, nBlue ) ) - hNewBrush = CreateSolidBrush( nBrushColor ); - else - { - BYTE* pTmp = pSalData->mpDitherDIBData; - long* pDitherDiff = pSalData->mpDitherDiff; - BYTE* pDitherLow = pSalData->mpDitherLow; - BYTE* pDitherHigh = pSalData->mpDitherHigh; - - for ( long nY = 0L; nY < 8L; nY++ ) - { - for ( long nX = 0L; nX < 8L; nX++ ) - { - const long nThres = aOrdDither8Bit[ nY ][ nX ]; - *pTmp = DMAP( nRed, nThres ) + DMAP( nGreen, nThres ) * 6 + DMAP( nBlue, nThres ) * 36; - pTmp++; - } - } - - hNewBrush = CreateDIBPatternBrush( pSalData->mhDitherDIB, DIB_PAL_COLORS ); - } - } - - bStockBrush = FALSE; - } - - // select new brush - HBRUSH hOldBrush = SelectBrush( maGraphicsData.mhDC, hNewBrush ); - - // destory or save old brush - if ( maGraphicsData.mhBrush ) - { - if ( !maGraphicsData.mbStockBrush ) - DeleteBrush( maGraphicsData.mhBrush ); - } - else - maGraphicsData.mhDefBrush = hOldBrush; - - // set new data - maGraphicsData.mnBrushColor = nBrushColor; - maGraphicsData.mhBrush = hNewBrush; - maGraphicsData.mbBrush = FALSE; - maGraphicsData.mbStockBrush = bStockBrush; -#endif } // ----------------------------------------------------------------------- -void SalGraphics::SetXORMode( BOOL bSet ) +SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nDX, long nDY ) { - maGraphicsData.mbXORMode = bSet; -#ifdef WIn - ::SetROP2( maGraphicsData.mhDC, bSet ? R2_XORPEN : R2_COPYPEN ); -#endif + return NULL; } // ----------------------------------------------------------------------- -void SalGraphics::SetROPLineColor( SalROPColor nROPColor ) +SalColor SalGraphics::GetPixel( long nX, long nY ) { - SetLineColor( ImplGetROPSalColor( nROPColor ) ); } // ----------------------------------------------------------------------- -void SalGraphics::SetROPFillColor( SalROPColor nROPColor ) +void SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) { - SetFillColor( ImplGetROPSalColor( nROPColor ) ); } // ----------------------------------------------------------------------- -void SalGraphics::DrawPixel( long nX, long nY ) +void SalGraphics::Invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ) { -#ifdef WIN - if ( maGraphicsData.mbXORMode ) - { - HBRUSH hBrush = CreateSolidBrush( maGraphicsData.mnPenColor ); - HBRUSH hOldBrush = SelectBrush( maGraphicsData.mhDC, hBrush ); - PatBlt( maGraphicsData.mhDC, (int)nX, (int)nY, (int)1, (int)1, PATINVERT ); - SelectBrush( maGraphicsData.mhDC, hOldBrush ); - DeleteBrush( hBrush ); - } - else - SetPixel( maGraphicsData.mhDC, (int)nX, (int)nY, maGraphicsData.mnPenColor ); -#endif } // ----------------------------------------------------------------------- -void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor ) +BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, + void* pPtr, ULONG nSize ) { -#ifdef WIN - COLORREF nCol = PALETTERGB( SALCOLOR_RED( nSalColor ), - SALCOLOR_GREEN( nSalColor ), - SALCOLOR_BLUE( nSalColor ) ); - - if ( !maGraphicsData.mbPrinter && - GetSalData()->mhDitherPal && - ImplIsSysColorEntry( nSalColor ) ) - nCol = PALRGB_TO_RGB( nCol ); - - if ( maGraphicsData.mbXORMode ) - { - HBRUSH hBrush = CreateSolidBrush( nCol ); - HBRUSH hOldBrush = SelectBrush( maGraphicsData.mhDC, hBrush ); - PatBlt( maGraphicsData.mhDC, (int)nX, (int)nY, (int)1, (int)1, PATINVERT ); - SelectBrush( maGraphicsData.mhDC, hOldBrush ); - DeleteBrush( hBrush ); - } - else - ::SetPixel( maGraphicsData.mhDC, (int)nX, (int)nY, nCol ); -#endif + return FALSE; } // ----------------------------------------------------------------------- -void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2 ) +void SalGraphics::SetTextColor( SalColor nSalColor ) { -#ifdef WIN - MoveToEx( maGraphicsData.mhDC, (int)nX1, (int)nY1, NULL ); -#endif - - // we must paint the endpoint - int bPaintEnd = TRUE; - if ( nX1 == nX2 ) - { - bPaintEnd = FALSE; - if ( nY1 <= nY2 ) - nY2++; - else - nY2--; - } - if ( nY1 == nY2 ) - { - bPaintEnd = FALSE; - if ( nX1 <= nX2 ) - nX2++; - else - nX2--; - } - -#ifdef WIN - LineTo( maGraphicsData.mhDC, (int)nX2, (int)nY2 ); -#endif - - if ( bPaintEnd && !maGraphicsData.mbPrinter ) - { -#ifdef WIN - if ( maGraphicsData.mbXORMode ) - { - HBRUSH hBrush = CreateSolidBrush( maGraphicsData.mnPenColor ); - HBRUSH hOldBrush = SelectBrush( maGraphicsData.mhDC, hBrush ); - PatBlt( maGraphicsData.mhDC, (int)nX2, (int)nY2, (int)1, (int)1, PATINVERT ); - SelectBrush( maGraphicsData.mhDC, hOldBrush ); - DeleteBrush( hBrush ); - } - else - SetPixel( maGraphicsData.mhDC, (int)nX2, (int)nY2, maGraphicsData.mnPenColor ); -#endif - } } // ----------------------------------------------------------------------- -void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight ) +USHORT SalGraphics::SetFont( ImplFontSelectData* pFont ) { - if ( !maGraphicsData.mbPen ) - { - if ( !maGraphicsData.mbPrinter ) - { -#ifdef WIN - PatBlt( maGraphicsData.mhDC, (int)nX, (int)nY, (int)nWidth, (int)nHeight, maGraphicsData.mbXORMode ? PATINVERT : PATCOPY ); -#endif - } - else - { - RECT aWinRect; - aWinRect.left = nX; - aWinRect.top = nY; - aWinRect.right = nX+nWidth; - aWinRect.bottom = nY+nHeight; -#ifdef WIN - ::FillRect( maGraphicsData.mhDC, &aWinRect, maGraphicsData.mhBrush ); -#endif - } - } -#ifdef WIN - else - WIN_Rectangle( maGraphicsData.mhDC, (int)nX, (int)nY, (int)(nX+nWidth), (int)(nY+nHeight) ); -#endif + return 0; } // ----------------------------------------------------------------------- -void SalGraphics::DrawPolyLine( ULONG nPoints, const SalPoint* pPtAry ) +long SalGraphics::GetCharWidth( sal_Unicode nChar1, sal_Unicode nChar2, long* pWidthAry ) { - // Unter NT koennen wir das Array direkt weiterreichen - DBG_ASSERT( sizeof( POINT ) == sizeof( SalPoint ), - "SalGraphics::DrawPolyLine(): POINT != SalPoint" ); - - POINT* pWinPtAry = (POINT*)pPtAry; - // Wegen Windows 95 und der Beschraenkung auf eine maximale Anzahl - // von Punkten -#ifdef WIN - if ( !Polyline( maGraphicsData.mhDC, pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) - Polyline( maGraphicsData.mhDC, pWinPtAry, MAX_64KSALPOINTS ); -#endif + return 1; } // ----------------------------------------------------------------------- -void SalGraphics::DrawPolygon( ULONG nPoints, const SalPoint* pPtAry ) +void SalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) { - // Unter NT koennen wir das Array direkt weiterreichen - DBG_ASSERT( sizeof( POINT ) == sizeof( SalPoint ), - "SalGraphics::DrawPolygon(): POINT != SalPoint" ); - - POINT* pWinPtAry = (POINT*)pPtAry; -#ifdef WIN - // Wegen Windows 95 und der Beschraenkung auf eine maximale Anzahl - // von Punkten - if ( !WIN_Polygon( maGraphicsData.mhDC, pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) - WIN_Polygon( maGraphicsData.mhDC, pWinPtAry, MAX_64KSALPOINTS ); -#endif } // ----------------------------------------------------------------------- -void SalGraphics::DrawPolyPolygon( ULONG nPoly, const ULONG* pPoints, - PCONSTSALPOINT* pPtAry ) +ULONG SalGraphics::GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ) { - UINT aWinPointAry[SAL_POLYPOLYCOUNT_STACKBUF]; - UINT* pWinPointAry; - UINT nPolyPolyPoints = 0; - UINT nPoints; - UINT i; - - if ( nPoly <= SAL_POLYPOLYCOUNT_STACKBUF ) - pWinPointAry = aWinPointAry; - else - pWinPointAry = new UINT[nPoly]; - - for ( i = 0; i < (UINT)nPoly; i++ ) - { - nPoints = (UINT)pPoints[i]+1; - pWinPointAry[i] = nPoints; - nPolyPolyPoints += nPoints; - } - - POINT aWinPointAryAry[SAL_POLYPOLYPOINTS_STACKBUF]; - POINT* pWinPointAryAry; - if ( nPolyPolyPoints <= SAL_POLYPOLYPOINTS_STACKBUF ) - pWinPointAryAry = aWinPointAryAry; - else - pWinPointAryAry = new POINT[nPolyPolyPoints]; - // Unter NT koennen wir das Array direkt weiterreichen - DBG_ASSERT( sizeof( POINT ) == sizeof( SalPoint ), - "SalGraphics::DrawPolyPolygon(): POINT != SalPoint" ); - const SalPoint* pPolyAry; - UINT n = 0; - for ( i = 0; i < (UINT)nPoly; i++ ) - { - nPoints = pWinPointAry[i]; - pPolyAry = pPtAry[i]; - memcpy( pWinPointAryAry+n, pPolyAry, (nPoints-1)*sizeof(POINT) ); - pWinPointAryAry[n+nPoints-1] = pWinPointAryAry[n]; - n += nPoints; - } - -#ifdef WIN - if ( !WIN_PolyPolygon( maGraphicsData.mhDC, pWinPointAryAry, (int*)pWinPointAry, (UINT)nPoly ) && - (nPolyPolyPoints > MAX_64KSALPOINTS) ) - { - nPolyPolyPoints = 0; - nPoly = 0; - do - { - nPolyPolyPoints += pWinPointAry[(UINT)nPoly]; - nPoly++; - } - while ( nPolyPolyPoints < MAX_64KSALPOINTS ); - nPoly--; - if ( pWinPointAry[(UINT)nPoly] > MAX_64KSALPOINTS ) - pWinPointAry[(UINT)nPoly] = MAX_64KSALPOINTS; - if ( nPoly == 1 ) - WIN_Polygon( maGraphicsData.mhDC, pWinPointAryAry, *pWinPointAry ); - else - WIN_PolyPolygon( maGraphicsData.mhDC, pWinPointAryAry, (int*)pWinPointAry, nPoly ); - } -#endif - - if ( pWinPointAry != aWinPointAry ) - delete pWinPointAry; - if ( pWinPointAryAry != aWinPointAryAry ) - delete pWinPointAryAry; + return 0; } - // ----------------------------------------------------------------------- -#define POSTSCRIPT_BUFSIZE 0x4000 // MAXIMUM BUFSIZE EQ 0xFFFF -#define POSTSCRIPT_BOUNDINGSEARCH 0x1000 // we only try to get the BoundingBox - // in the first 4096 bytes - -static BYTE* ImplSearchEntry( BYTE* pSource, BYTE* pDest, ULONG nComp, ULONG nSize ) +void SalGraphics::GetDevFontList( ImplDevFontList* pList ) { - 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 ) +// ----------------------------------------------------------------------- + +void SalGraphics::DrawText( long nX, long nY, + const xub_Unicode* pStr, xub_StrLen nLen ) { - 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; } -inline void ImplWriteDouble( BYTE** pBuf, double nNumb ) +// ----------------------------------------------------------------------- + +void SalGraphics::DrawTextArray( long nX, long nY, + const xub_Unicode* pStr, xub_StrLen nLen, + const long* pDXAry ) { - *pBuf += sprintf( (char*)*pBuf, "%f", nNumb ); - *(*pBuf)++ = ' '; } -inline void ImplWriteString( BYTE** pBuf, const char* sString ) +// ----------------------------------------------------------------------- + +BOOL SalGraphics::GetGlyphBoundRect( xub_Unicode cChar, long* pX, long* pY, + long* pWidth, long* pHeight ) { - strcpy( (char*)*pBuf, sString ); - *pBuf += strlen( sString ); + return FALSE; } -BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize ) -{ - BOOL bRetValue = FALSE; - - if ( maGraphicsData.mbPrinter ) - { -#ifdef WIN - int nEscape = POSTSCRIPT_PASSTHROUGH; - - if ( Escape( maGraphicsData.mhDC, QUERYESCSUPPORT, sizeof( int ), ( LPSTR )&nEscape, 0 ) ) - { - BYTE* pBuf = new BYTE[ POSTSCRIPT_BUFSIZE ]; - - double nBoundingBox[4]; - - if ( pBuf && ImplGetBoundingBox( nBoundingBox, (BYTE*)pPtr, nSize ) ) - { - double dM11 = nWidth / ( nBoundingBox[2] - nBoundingBox[0] ); - double dM22 = nHeight / (nBoundingBox[1] - nBoundingBox[3] ); - BYTE* pTemp = pBuf + 2; // +2 because we want to insert the size later - ImplWriteString( &pTemp, "\n\nsave\n[ " ); - ImplWriteDouble( &pTemp, dM11 ); - ImplWriteDouble( &pTemp, 0 ); - ImplWriteDouble( &pTemp, 0 ); - ImplWriteDouble( &pTemp, dM22 ); - ImplWriteDouble( &pTemp, nX - ( dM11 * nBoundingBox[0] ) ); - ImplWriteDouble( &pTemp, nY - ( dM22 * nBoundingBox[3] ) ); - ImplWriteString( &pTemp, "] concat /showpage {} def\n" ); - ImplWriteString( &pTemp, "%%BeginDocument:\n" ); - *((USHORT*)pBuf) = (USHORT)( pTemp - pBuf - 2 ); - Escape ( maGraphicsData.mhDC, nEscape, pTemp - pBuf, (LPTSTR)((BYTE*)pBuf), 0 ); - - ULONG nToDo = nSize; - ULONG nDoNow; - while ( nToDo ) - { - nDoNow = nToDo; - if ( nToDo > POSTSCRIPT_BUFSIZE - 2 ) - nDoNow = POSTSCRIPT_BUFSIZE - 2; - *((USHORT*)pBuf) = (USHORT)nDoNow; - memcpy( pBuf + 2, (BYTE*)pPtr + nSize - nToDo, nDoNow ); - ULONG nResult = Escape ( maGraphicsData.mhDC, nEscape, nDoNow + 2, (LPTSTR)((BYTE*)pBuf), 0 ); - if (!nResult ) - break; - nToDo -= nResult; - } - pTemp = pBuf + 2; - ImplWriteString( &pTemp, "%%EndDocument\n" ); - ImplWriteString( &pTemp, "restore\n\n" ); - *((USHORT*)pBuf) = (USHORT)( pTemp - pBuf - 2 ); - Escape ( maGraphicsData.mhDC, nEscape, pTemp - pBuf, (LPTSTR)((BYTE*)pBuf), 0 ); - bRetValue = TRUE; - } - delete pBuf; - } -#endif - } +// ----------------------------------------------------------------------- - return bRetValue; +ULONG SalGraphics::GetGlyphOutline( xub_Unicode cChar, USHORT** ppPolySizes, + SalPoint** ppPoints, BYTE** ppFlags ) +{ + return 0; } diff --git a/vcl/aqua/source/gdi/salogl.cxx b/vcl/aqua/source/gdi/salogl.cxx index f4bc6def0789..9fb5283d4914 100644 --- a/vcl/aqua/source/gdi/salogl.cxx +++ b/vcl/aqua/source/gdi/salogl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salogl.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:45 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,85 +59,26 @@ * ************************************************************************/ -#ifndef _SVWIN_H -#include <tools/svwin.h> -#endif - #define _SV_SALOGL_CXX -#ifndef _SV_SALOGL_HXX -#include <salogl.hxx> -#endif #ifndef _SV_SALGDI_HXX #include <salgdi.hxx> #endif - -// ------------------------------- -// - Additional typedefs for init. -// ------------------------------- - -typedef HGLRC ( *OGLFncCreateContext )( VCLVIEW hDC ); -typedef BOOL ( *OGLFncDeleteContext )( HGLRC hContext ); -typedef HGLRC ( *OGLFncGetCurrentContext )( void ); -typedef void ( *OGLFncMakeCurrent )( VCLVIEW hDC, HGLRC hContext ); - -// ------------ -// - Lib-Name - -// ------------ - -#ifdef WIN -#define OGL_LIBNAME "OPENGL32.DLL" +#ifndef _SV_SALOGL_HXX +#include <salogl.hxx> #endif -// ---------- -// - Macros - -// ---------- -#ifdef WIN -#define INIT_OGLFNC_WGL( FncName ) static OGLFnc##FncName pImplOpenWGLFnc##FncName = NULL; -#define GET_OGLFNC_WGL( FncName ) \ -pImplOpenWGLFnc##FncName = (OGLFnc##FncName##) GetProcAddress( hImplOGLLib, "wgl" #FncName ); \ -if( !pImplOpenWGLFnc##FncName ) bRet = FALSE; -#endif - -// ----------------- -// - Statics init. - -// ----------------- +// ======================================================================== -// Members -HGLRC SalOpenGL::mhOGLContext = 0; +// Initialize static data members VCLVIEW SalOpenGL::mhOGLLastDC = 0; ULONG SalOpenGL::mnOGLState = OGL_STATE_UNLOADED; -#ifdef WIN -INIT_OGLFNC_WGL( CreateContext ); -INIT_OGLFNC_WGL( DeleteContext ); -INIT_OGLFNC_WGL( GetCurrentContext ); -INIT_OGLFNC_WGL( MakeCurrent ); -#endif - -// ----------- -// - WndProc - -// ----------- - -#ifdef WIN -LRESULT CALLBACK OpenGLWndProc( VCLWINDOW hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) -{ - return DefWindowProc( hWnd, nMsg, nPar1, nPar2 ); -} -#endif - -// ------------- -// - 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; } // ------------------------------------------------------------------------ @@ -150,157 +91,26 @@ SalOpenGL::~SalOpenGL() BOOL SalOpenGL::Create() { - BOOL bRet = FALSE; - - if ( OGL_STATE_UNLOADED == mnOGLState ) - { - if( ImplInitLib() ) - { -#ifdef WIN - USHORT nBitCount = GetDeviceCaps( mhOGLLastDC, BITSPIXEL ); - PIXELFORMATDESCRIPTOR pfd = - { - sizeof( PIXELFORMATDESCRIPTOR ), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL, - PFD_TYPE_RGBA, - (BYTE) nBitCount, - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 16, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - const int nIndex = ChoosePixelFormat( mhOGLLastDC, &pfd ); - - if( nIndex && SetPixelFormat( mhOGLLastDC, nIndex, &pfd ) ) - { - if ( (nBitCount > 8) && ImplInit() && - (mhOGLContext = pImplOpenWGLFncCreateContext( mhOGLLastDC )) != 0 ) - { - WNDCLASS aWc; - VCLWINDOW hDummyWnd; - - SaveDC( mhOGLLastDC ); - SelectClipRgn( mhOGLLastDC, NULL ); - pImplOpenWGLFncMakeCurrent( mhOGLLastDC, mhOGLContext ); - RestoreDC( mhOGLLastDC, -1 ); - mnOGLState = OGL_STATE_VALID; - bRet = TRUE; - - memset( &aWc, 0, sizeof( aWc ) ); - aWc.hInstance = GetModuleHandle( NULL ); - aWc.lpfnWndProc = OpenGLWndProc; - aWc.lpszClassName = "OpenGLWnd"; - RegisterClass( &aWc ); - hDummyWnd = CreateWindow( aWc.lpszClassName, NULL, WS_OVERLAPPED, 0, -50, 1, 1, VCLWINDOW_DESKTOP, NULL, aWc.hInstance, 0 ); - ShowWindow( hDummyWnd, SW_SHOW ); - DestroyWindow( hDummyWnd ); - UnregisterClass( aWc.lpszClassName, aWc.hInstance ); - } - else - { - ImplFreeLib(); - mnOGLState = OGL_STATE_INVALID; - } - } - else - mnOGLState = OGL_STATE_INVALID; -#endif - } - else - mnOGLState = OGL_STATE_INVALID; - } - else if( OGL_STATE_VALID == mnOGLState ) - bRet = TRUE; - - return bRet; + return FALSE; } // ------------------------------------------------------------------------ void SalOpenGL::Release() { - ImplFreeLib(); } // ------------------------------------------------------------------------ -void* SalOpenGL::GetOGLFnc( const char* pFncName ) +void *SalOpenGL::GetOGLFnc( const char* pFncName ) { -#ifdef WIN - if ( hImplOGLLib ) - return (void*)GetProcAddress( hImplOGLLib, pFncName ); - else -#endif - return NULL; + return NULL; } // ------------------------------------------------------------------------ -#ifdef WIN -typedef BOOL (WINAPI *MyFuncType)(VCLVIEW, HGLRC); -#endif - void SalOpenGL::OGLEntry( SalGraphics* pGraphics ) { - if ( pGraphics->maGraphicsData.mhDC != mhOGLLastDC ) - { -#ifdef WIN - PIXELFORMATDESCRIPTOR pfd = - { - sizeof( PIXELFORMATDESCRIPTOR ), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL, - PFD_TYPE_RGBA, - GetDeviceCaps( pGraphics->maGraphicsData.mhDC, BITSPIXEL ), - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 16, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - const int nIndex = ChoosePixelFormat( pGraphics->maGraphicsData.mhDC, &pfd ); - if ( nIndex && SetPixelFormat( pGraphics->maGraphicsData.mhDC, nIndex, &pfd ) ) - { - WNDCLASS aWc; - VCLWINDOW hDummyWnd; - - pImplOpenWGLFncDeleteContext( mhOGLContext ); - mhOGLLastDC = pGraphics->maGraphicsData.mhDC; - mhOGLContext = pImplOpenWGLFncCreateContext( mhOGLLastDC ); - - SaveDC( mhOGLLastDC ); - SelectClipRgn( mhOGLLastDC, NULL ); - pImplOpenWGLFncMakeCurrent( mhOGLLastDC, mhOGLContext ); - RestoreDC( mhOGLLastDC, -1 ); - - memset( &aWc, 0, sizeof( aWc ) ); - aWc.hInstance = GetModuleHandle( NULL ); - aWc.lpfnWndProc = OpenGLWndProc; - aWc.lpszClassName = "OpenGLWnd"; - RegisterClass( &aWc ); - hDummyWnd = CreateWindow( aWc.lpszClassName, NULL, WS_OVERLAPPED, 0, -50, 1, 1, VCLWINDOW_DESKTOP, NULL, aWc.hInstance, 0 ); - ShowWindow( hDummyWnd, SW_SHOW ); - DestroyWindow( hDummyWnd ); - UnregisterClass( aWc.lpszClassName, aWc.hInstance ); - } -#endif - } } // ------------------------------------------------------------------------ @@ -308,43 +118,3 @@ void SalOpenGL::OGLEntry( SalGraphics* pGraphics ) void SalOpenGL::OGLExit( SalGraphics* pGraphics ) { } - -// ------------------------------------------------------------------------ - -BOOL SalOpenGL::ImplInitLib() -{ -#ifdef WIN - return ((hImplOGLLib = LoadLibrary( OGL_LIBNAME )) != NULL); -#endif -} - -// ------------------------------------------------------------------------ - -void SalOpenGL::ImplFreeLib() -{ -#ifdef WIN - if ( hImplOGLLib ) - { - FreeLibrary( hImplOGLLib ); - hImplOGLLib = NULL; - mnOGLState = OGL_STATE_UNLOADED; - } -#endif -} - -// ------------------------------------------------------------------------ - -BOOL SalOpenGL::ImplInit() -{ - BOOL bRet = TRUE; - -#ifdef WIN - // Internal use - GET_OGLFNC_WGL( CreateContext ); - GET_OGLFNC_WGL( DeleteContext ); - GET_OGLFNC_WGL( GetCurrentContext ); - GET_OGLFNC_WGL( MakeCurrent ); -#endif - - return bRet; -} diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index cb8e40859128..19b76358985f 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salprn.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:45 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,894 +59,48 @@ * ************************************************************************/ -#include <string.h> -#ifndef _SVWIN_H -#include <tools/svwin.h> -#endif - #define _SV_SALPRN_CXX -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> -#endif -#ifndef _SV_SALDATA_HXX -#include <saldata.hxx> -#endif -#ifndef _SV_SALINST_HXX +#ifndef _SV_SALINST_H #include <salinst.hxx> #endif -#ifndef _SV_SALGDI_HXX +#ifndef _SV_SALGDI_H #include <salgdi.hxx> #endif -#ifndef _SV_SALFRAME_HXX -#include <salframe.hxx> -#endif -#ifndef _SV_SALPTYPE_HXX -#include <salptype.hxx> -#endif #ifndef _SV_SALPRN_HXX #include <salprn.hxx> #endif -#ifndef _NEW_HXX -#include <tools/new.hxx> -#endif - -#ifndef _SV_PRINT_H -#include <print.h> -#endif -#ifndef _SV_JOBSET_H -#include <jobset.h> -#endif - -// ======================================================================= - -static char aImplWindows[] = "windows"; -static char aImplDevices[] = "devices"; -static char aImplDevice[] = "device"; - -// ======================================================================= - -static ULONG ImplWinQueueStatusToSal( DWORD nWinStatus ) -{ - ULONG nStatus = 0; -#ifdef WIN - if ( nWinStatus & PRINTER_STATUS_PAUSED ) - nStatus |= QUEUE_STATUS_PAUSED; - if ( nWinStatus & PRINTER_STATUS_ERROR ) - nStatus |= QUEUE_STATUS_ERROR; - if ( nWinStatus & PRINTER_STATUS_PENDING_DELETION ) - nStatus |= QUEUE_STATUS_PENDING_DELETION; - if ( nWinStatus & PRINTER_STATUS_PAPER_JAM ) - nStatus |= QUEUE_STATUS_PAPER_JAM; - if ( nWinStatus & PRINTER_STATUS_PAPER_OUT ) - nStatus |= QUEUE_STATUS_PAPER_OUT; - if ( nWinStatus & PRINTER_STATUS_MANUAL_FEED ) - nStatus |= QUEUE_STATUS_MANUAL_FEED; - if ( nWinStatus & PRINTER_STATUS_PAPER_PROBLEM ) - nStatus |= QUEUE_STATUS_PAPER_PROBLEM; - if ( nWinStatus & PRINTER_STATUS_OFFLINE ) - nStatus |= QUEUE_STATUS_OFFLINE; - if ( nWinStatus & PRINTER_STATUS_IO_ACTIVE ) - nStatus |= QUEUE_STATUS_IO_ACTIVE; - if ( nWinStatus & PRINTER_STATUS_BUSY ) - nStatus |= QUEUE_STATUS_BUSY; - if ( nWinStatus & PRINTER_STATUS_PRINTING ) - nStatus |= QUEUE_STATUS_PRINTING; - if ( nWinStatus & PRINTER_STATUS_OUTPUT_BIN_FULL ) - nStatus |= QUEUE_STATUS_OUTPUT_BIN_FULL; - if ( nWinStatus & PRINTER_STATUS_WAITING ) - nStatus |= QUEUE_STATUS_WAITING; - if ( nWinStatus & PRINTER_STATUS_PROCESSING ) - nStatus |= QUEUE_STATUS_PROCESSING; - if ( nWinStatus & PRINTER_STATUS_INITIALIZING ) - nStatus |= QUEUE_STATUS_INITIALIZING; - if ( nWinStatus & PRINTER_STATUS_WARMING_UP ) - nStatus |= QUEUE_STATUS_WARMING_UP; - if ( nWinStatus & PRINTER_STATUS_TONER_LOW ) - nStatus |= QUEUE_STATUS_TONER_LOW; - if ( nWinStatus & PRINTER_STATUS_NO_TONER ) - nStatus |= QUEUE_STATUS_NO_TONER; - if ( nWinStatus & PRINTER_STATUS_PAGE_PUNT ) - nStatus |= QUEUE_STATUS_PAGE_PUNT; - if ( nWinStatus & PRINTER_STATUS_USER_INTERVENTION ) - nStatus |= QUEUE_STATUS_USER_INTERVENTION; - if ( nWinStatus & PRINTER_STATUS_OUT_OF_MEMORY ) - nStatus |= QUEUE_STATUS_OUT_OF_MEMORY; - if ( nWinStatus & PRINTER_STATUS_DOOR_OPEN ) - nStatus |= QUEUE_STATUS_DOOR_OPEN; - if ( nWinStatus & PRINTER_STATUS_SERVER_UNKNOWN ) - nStatus |= QUEUE_STATUS_SERVER_UNKNOWN; - if ( nWinStatus & PRINTER_STATUS_POWER_SAVE ) - nStatus |= QUEUE_STATUS_POWER_SAVE; - if ( !nStatus && !(nWinStatus & PRINTER_STATUS_NOT_AVAILABLE) ) - nStatus |= QUEUE_STATUS_READY; -#endif - return nStatus; -} - -// ----------------------------------------------------------------------- - -void SalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) -{ -// !!! UNICODE - NT Optimierung !!! - DWORD i; - DWORD n; - DWORD nBytes = 0; -// DWORD nInfoRet; - DWORD nInfoPrn2; - BOOL bFound = FALSE; -#ifdef WIN - PRINTER_INFO_2* pWinInfo2 = NULL; - PRINTER_INFO_2* pGetInfo2; - EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &nBytes, &nInfoPrn2 ); -#endif - if ( nBytes ) - { -#ifdef WIN - pWinInfo2 = (PRINTER_INFO_2*)new BYTE[nBytes]; - if ( EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pWinInfo2, nBytes, &nBytes, &nInfoPrn2 ) ) - { - pGetInfo2 = pWinInfo2; - for ( i = 0; i < nInfoPrn2; i++ ) - { - SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo; - pInfo->maPrinterName = ImplSalGetUniString( pGetInfo2->pPrinterName ); - pInfo->maDriver = ImplSalGetUniString( pGetInfo2->pDriverName ); - XubString aPortName; - if ( pGetInfo2->pPortName ) - aPortName = ImplSalGetUniString( pGetInfo2->pPortName ); - // pLocation can be 0 (the Windows docu doesn't describe this) - if ( pGetInfo2->pLocation && strlen( pGetInfo2->pLocation ) ) - pInfo->maLocation = ImplSalGetUniString( pGetInfo2->pLocation ); - else - pInfo->maLocation = aPortName; - // pComment can be 0 (the Windows docu doesn't describe this) - if ( pGetInfo2->pComment ) - pInfo->maComment = ImplSalGetUniString( pGetInfo2->pComment ); - pInfo->mnStatus = ImplWinQueueStatusToSal( pGetInfo2->Status ); - pInfo->mnJobs = pGetInfo2->cJobs; - pInfo->mpSysData = new XubString( aPortName ); - pList->Add( pInfo ); - pGetInfo2++; - } - - bFound = TRUE; - } -#endif - } - -/* Siehe Kommentar unten !!! - EnumPrinters( PRINTER_ENUM_NETWORK | PRINTER_ENUM_REMOTE, NULL, 1, NULL, 0, &nBytes, &nInfoRet ); - if ( nBytes ) - { - PRINTER_INFO_1* pWinInfo1 = (PRINTER_INFO_1*)new BYTE[nBytes]; - if ( EnumPrinters( PRINTER_ENUM_NETWORK | PRINTER_ENUM_REMOTE, NULL, 1, (LPBYTE)pWinInfo1, nBytes, &nBytes, &nInfoRet ) ) - { - PRINTER_INFO_1* pGetInfo1 = pWinInfo1; - for ( i = 0; i < nInfoRet; i++ ) - { - // Feststellen, ob Printer durch erste Abfrage schon gefunden - // wurde - BOOL bAdd = TRUE; -#ifdef WIN - if ( pWinInfo2 ) - { - pGetInfo2 = pWinInfo2; - for ( n = 0; n < nInfoPrn2; n++ ) - { - if ( strcmp( pGetInfo1->pName, pGetInfo2->pPrinterName ) == 0 ) - { - bAdd = FALSE; - break; - } - pGetInfo2++; - } - } -#endif - // Wenn neuer Printer, dann aufnehmen - if ( bAdd ) - { - SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo; - XubString aPrnName( pGetInfo1->pName ); - pInfo->maPrinterName = aPrnName; - pInfo->maDriver = "winspool"; - pInfo->maComment = pGetInfo1->pComment; - pInfo->mnStatus = 0; - pInfo->mnJobs = QUEUE_JOBS_DONTKNOW; - pInfo->mpSysData = new String(); - pList->Add( pInfo ); - } - pGetInfo1++; - } - - bFound = TRUE; - } - - delete pWinInfo1; - } -*/ - -// if ( bFound ) -// return; - -#ifdef WIN -// !!! UNICODE - NT Optimierung !!! - // Drucker aus WIN.INI lesen - UINT nSize = 4096; - char* pBuf = new char[nSize]; - UINT nRead = GetProfileStringA( aImplDevices, NULL, "", pBuf, nSize ); - while ( nRead >= nSize-2 ) - { - nSize += 2048; - delete pBuf; - pBuf = new char[nSize]; - nRead = GetProfileStringA( aImplDevices, NULL, "", pBuf, nSize ); - } - - // Druckernamen aus Buffer extrahieren und Liste aufbauen - char* pName = pBuf; - while ( *pName ) - { - char* pPortName; - char* pTmp; - char aPortBuf[256]; - GetProfileStringA( aImplDevices, pName, "", aPortBuf, sizeof( aPortBuf ) ); - - pPortName = aPortBuf; - - // Namen anlegen - xub_StrLen nNameLen = strlen( pName ); - XubString aName( ImplSalGetUniString( pName, nNameLen ) ); - - // Treibernamen rausfischen - pTmp = pPortName; - while ( *pTmp != ',' ) - pTmp++; - XubString aDriver( ImplSalGetUniString( pPortName, (USHORT)(pTmp-pPortName) ) ); - pPortName = pTmp; - - // Alle Portnamen raussuchen - do - { - pPortName++; - pTmp = pPortName; - while ( *pTmp && (*pTmp != ',') ) - pTmp++; - - String aPortName( ImplSalGetUniString( pPortName, (USHORT)(pTmp-pPortName) ) ); - - // Neuen Eintrag anlegen - // !!! Da ich zu bloeb bin, die Netzwerk-Printer zur 5.0 - // !!! richtig zu integrieren, gehen wir zusaetzlich - // !!! noch ueber das W16-Interface, da uns dort die - // !!! Drucker noch einfach und schnell geliefert werden - // !!! ohne das wir jetzt zu grossen Aufwand treiben muessen. - // !!! Somit sollten wir dann jedenfalls nicht schlechter sein - // !!! als in einer 4.0 SP2. - // Feststellen, ob Printer durch erste Abfrage schon gefunden - // wurde - BOOL bAdd = TRUE; - if ( pWinInfo2 ) - { - pGetInfo2 = pWinInfo2; - for ( n = 0; n < nInfoPrn2; n++ ) - { - if ( aName.EqualsIgnoreCaseAscii( pGetInfo2->pPrinterName ) ) - { - bAdd = FALSE; - break; - } - pGetInfo2++; - } - } - // Wenn neuer Printer, dann aufnehmen - if ( bAdd ) - { - SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo; - pInfo->maPrinterName = aName; - pInfo->maDriver = aDriver; - pInfo->maLocation = aPortName; - pInfo->mnStatus = 0; - pInfo->mnJobs = QUEUE_JOBS_DONTKNOW; - pInfo->mpSysData = new XubString( aPortName ); - pList->Add( pInfo ); - } - } - while ( *pTmp == ',' ); - - pName += nNameLen + 1; - } - - delete pBuf; - delete pWinInfo2; -#endif -} - -// ----------------------------------------------------------------------- - -void SalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) -{ -// !!! UNICODE - NT Optimierung !!! - DWORD nBytes = 0; - DWORD nInfoRet; -#ifdef WIN - PRINTER_INFO_2* pWinInfo2; - EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &nBytes, &nInfoRet ); -#endif - if ( nBytes ) - { -#ifdef WIN - pWinInfo2 = (PRINTER_INFO_2*)new BYTE[nBytes]; - if ( EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pWinInfo2, nBytes, &nBytes, &nInfoRet ) ) - { - PRINTER_INFO_2* pGetInfo2 = pWinInfo2; - for ( DWORD i = 0; i < nInfoRet; i++ ) - { - if ( pInfo->maPrinterName.EqualsAscii( pGetInfo2->pPrinterName ) && - pInfo->maDriver.EqualsAscii( pGetInfo2->pDriverName ) ) - { - if ( pGetInfo2->pLocation && strlen( pGetInfo2->pLocation ) ) - pInfo->maLocation = ImplSalGetUniString( pGetInfo2->pLocation ); - else - pInfo->maLocation = ImplSalGetUniString( pGetInfo2->pPortName ); - pInfo->mnStatus = ImplWinQueueStatusToSal( pGetInfo2->Status ); - pInfo->mnJobs = pGetInfo2->cJobs; - break; - } - - pGetInfo2++; - } - } - - delete pWinInfo2; -#endif - } -} - -// ----------------------------------------------------------------------- - -void SalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) -{ - delete (String*)(pInfo->mpSysData); - delete pInfo; -} - -// ----------------------------------------------------------------------- - -// !!! UNICODE - NT Optimierung !!! -XubString SalInstance::GetDefaultPrinter() -{ - // Default-Printer-String aus win.ini holen - char szBuffer[256]; -#ifdef WIN - GetProfileStringA( aImplWindows, aImplDevice, "", szBuffer, sizeof( szBuffer ) ); -#endif - if ( szBuffer[0] ) - { - // Printername suchen - char* pBuf = szBuffer; - char* pTmp = pBuf; - while ( *pTmp && (*pTmp != ',') ) - pTmp++; - return ImplSalGetUniString( pBuf, (xub_StrLen)(pTmp-pBuf) ); - } - else - return XubString(); -} - -// ======================================================================= - -static DWORD ImplDeviceCaps( SalInfoPrinter* pPrinter, WORD nCaps, - LPTSTR pOutput, const ImplJobSetup* pSetupData ) -{ -#ifdef WIN - DEVMODE* pDevMode; - if ( !pSetupData || !pSetupData->mpDriverData ) - pDevMode = NULL; - else - pDevMode = SAL_DEVMODE( pSetupData ); - -// !!! UNICODE - NT Optimierung !!! - return DeviceCapabilitiesA( ImplSalGetWinAnsiString( pPrinter->maPrinterData.maDeviceName, TRUE ).GetBuffer(), - ImplSalGetWinAnsiString( pPrinter->maPrinterData.maPortName, TRUE ).GetBuffer(), - nCaps, (LPSTR)pOutput, pDevMode ); -#else - return 0; -#endif -} - -// ----------------------------------------------------------------------- - -static BOOL ImplTestSalJobSetup( SalInfoPrinter* pPrinter, - ImplJobSetup* pSetupData, BOOL bDelete ) -{ - if ( pSetupData && pSetupData->mpDriverData ) - { - // Signature und Groesse muss uebereinstimmen, damit wir keine - // JobSetup's von anderen Systemen setzen - if ( (pSetupData->mnSystem == JOBSETUP_SYSTEM_WINDOWS) && - (pSetupData->mnDriverDataLen > sizeof( SalDriverData )) && - (((SalDriverData*)(pSetupData->mpDriverData))->mnSysSignature == SAL_DRIVERDATA_SYSSIGN) ) - return TRUE; - else if ( bDelete ) - { - delete pSetupData->mpDriverData; - pSetupData->mpDriverData = NULL; - pSetupData->mnDriverDataLen = 0; - } - } - - return FALSE; -} - -// ----------------------------------------------------------------------- - -static BOOL ImplUpdateSalJobSetup( SalInfoPrinter* pPrinter, ImplJobSetup* pSetupData, - BOOL bIn, SalFrame* pVisibleDlgParent ) -{ -#ifdef WIN - HANDLE hPrn; -// !!! UNICODE - NT Optimierung !!! - if ( !OpenPrinterA( (LPSTR)ImplSalGetWinAnsiString( pPrinter->maPrinterData.maDeviceName, TRUE ).GetBuffer(), &hPrn, NULL ) ) - return FALSE; - - LONG nRet; - LONG nSysJobSize; - VCLWINDOW hWnd = 0; - DWORD nMode = DM_OUT_BUFFER; - ULONG nDriverDataLen = 0; - SalDriverData* pOutBuffer = NULL; - DEVMODE* pInDevBuffer = NULL; - DEVMODE* pOutDevBuffer = NULL; - -// !!! UNICODE - NT Optimierung !!! - nSysJobSize = DocumentPropertiesA( hWnd, hPrn, - (LPSTR)ImplSalGetWinAnsiString( pPrinter->maPrinterData.maDeviceName, TRUE ).GetBuffer(), - NULL, NULL, 0 ); - if ( nSysJobSize < 0 ) - { - ClosePrinter( hPrn ); - return FALSE; - } - - // Outputbuffer anlegen - nDriverDataLen = sizeof(SalDriverData)+nSysJobSize-1; - pOutBuffer = (SalDriverData*)SvMemAlloc( nDriverDataLen ); - memset( pOutBuffer, 0, nDriverDataLen ); - pOutDevBuffer = (LPDEVMODE)(pOutBuffer->maDriverData); - pOutBuffer->mnSysSignature = SAL_DRIVERDATA_SYSSIGN; - pOutBuffer->mnVersion = SAL_DRIVERDATA_VERSION; - pOutBuffer->mnDriverOffset = (USHORT)(((SalDriverData*)NULL)->maDriverData); - - // Testen, ob wir einen geeigneten Inputbuffer haben - if ( bIn && ImplTestSalJobSetup( pPrinter, pSetupData, FALSE ) ) - { - pInDevBuffer = SAL_DEVMODE( pSetupData ); - nMode |= DM_IN_BUFFER; - } - - // Testen, ob Dialog angezeigt werden soll - if ( pVisibleDlgParent ) - { - hWnd = pVisibleDlgParent->maFrameData.mhWnd; - nMode |= DM_IN_PROMPT; - } - -// !!! UNICODE - NT Optimierung !!! - // Release mutex, in the other case we don't get paints and so on - ULONG nMutexCount = ImplSalReleaseYieldMutex(); - nRet = DocumentPropertiesA( hWnd, hPrn, - (LPSTR)ImplSalGetWinAnsiString( pPrinter->maPrinterData.maDeviceName, TRUE ).GetBuffer(), - pOutDevBuffer, pInDevBuffer, nMode ); - ImplSalAcquireYieldMutex( nMutexCount ); - ClosePrinter( hPrn ); - - if ( (nRet < 0) || (pVisibleDlgParent && (nRet == IDCANCEL)) ) - { - SvMemFree( pOutBuffer ); - return FALSE; - } - - // String-Buffer am Ende immer mit 0 initialisieren, damit - // die JobSetups nach Moeglichkeit bei memcmp immer - // identisch sind - if ( pOutDevBuffer->dmSize >= 32 ) - { - USHORT nLen = strlen( (const char*)pOutDevBuffer->dmDeviceName ); - if ( nLen < sizeof( pOutDevBuffer->dmDeviceName ) ) - memset( pOutDevBuffer->dmDeviceName+nLen, 0, sizeof( pOutDevBuffer->dmDeviceName )-nLen ); - } - if ( pOutDevBuffer->dmSize >= 102 ) - { - USHORT nLen = strlen( (const char*)pOutDevBuffer->dmFormName ); - if ( nLen < sizeof( pOutDevBuffer->dmFormName ) ) - memset( pOutDevBuffer->dmFormName+nLen, 0, sizeof( pOutDevBuffer->dmFormName )-nLen ); - } - - // Daten updaten - if ( pSetupData->mpDriverData ) - delete pSetupData->mpDriverData; - pSetupData->mnDriverDataLen = nDriverDataLen; - pSetupData->mpDriverData = (BYTE*)pOutBuffer; - pSetupData->mnSystem = JOBSETUP_SYSTEM_WINDOWS; - - return TRUE; -#else - return FALSE; -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplDevModeToJobSetup( SalInfoPrinter* pPrinter, ImplJobSetup* pSetupData, ULONG nFlags ) -{ -#ifdef WIN - if ( !pSetupData || !pSetupData->mpDriverData ) - return; - - DEVMODE* pDevMode = SAL_DEVMODE( pSetupData ); - - // Orientation - if ( nFlags & SAL_JOBSET_ORIENTATION ) - { - if ( pDevMode->dmOrientation == DMORIENT_PORTRAIT ) - pSetupData->meOrientation = ORIENTATION_PORTRAIT; - else if ( pDevMode->dmOrientation == DMORIENT_LANDSCAPE ) - pSetupData->meOrientation = ORIENTATION_LANDSCAPE; - } - - // PaperBin - if ( nFlags & SAL_JOBSET_PAPERBIN ) - { - ULONG nCount = ImplDeviceCaps( pPrinter, DC_BINS, NULL, pSetupData ); - - if ( nCount && (nCount != ((ULONG)-1)) ) - { - WORD* pBins = new WORD[nCount]; - memset( (BYTE*)pBins, 0, nCount*sizeof(WORD) ); - ImplDeviceCaps( pPrinter, DC_BINS, (LPTSTR)pBins, pSetupData ); - pSetupData->mnPaperBin = 0; - - // search the right bin and assign index to mnPaperBin - for( ULONG i = 0; i < nCount; i++ ) - { - if( pDevMode->dmDefaultSource == pBins[ i ] ) - { - pSetupData->mnPaperBin = (USHORT)i; - break; - } - } - - delete[] pBins; - } - } - - // PaperSize - if ( nFlags & SAL_JOBSET_PAPERSIZE ) - { - pSetupData->mnPaperWidth = pDevMode->dmPaperWidth*10; - pSetupData->mnPaperHeight = pDevMode->dmPaperLength*10; - switch( pDevMode->dmPaperSize ) - { - case( DMPAPER_A3 ): - pSetupData->mePaperFormat = PAPER_A3; - break; - case( DMPAPER_A4 ): - pSetupData->mePaperFormat = PAPER_A4; - break; - case( DMPAPER_A5 ): - pSetupData->mePaperFormat = PAPER_A5; - break; - case( DMPAPER_B4 ): - pSetupData->mePaperFormat = PAPER_B4; - break; - case( DMPAPER_B5 ): - pSetupData->mePaperFormat = PAPER_B5; - break; - case( DMPAPER_LETTER ): - pSetupData->mePaperFormat = PAPER_LETTER; - break; - case( DMPAPER_LEGAL ): - pSetupData->mePaperFormat = PAPER_LEGAL; - break; - case( DMPAPER_TABLOID ): - pSetupData->mePaperFormat = PAPER_TABLOID; - break; - default: - pSetupData->mePaperFormat = PAPER_USER; - break; - } - } -#endif -} - -// ----------------------------------------------------------------------- - -static BOOL ImplPaperSizeEqual( short nPaperWidth1, short nPaperHeight1, - short nPaperWidth2, short nPaperHeight2 ) -{ - return (((nPaperWidth1 >= nPaperWidth2-1) && (nPaperWidth1 <= nPaperWidth2+1)) && - ((nPaperHeight1 >= nPaperHeight2-1) && (nPaperHeight1 <= nPaperHeight2+1))); -} - -// ----------------------------------------------------------------------- - -static void ImplJobSetupToDevMode( SalInfoPrinter* pPrinter, ImplJobSetup* pSetupData, ULONG nFlags ) -{ -#ifdef WIN - if ( !pSetupData || !pSetupData->mpDriverData ) - return; - - DEVMODE* pDevMode = SAL_DEVMODE( pSetupData ); - - // Orientation - if ( nFlags & SAL_JOBSET_ORIENTATION ) - { - pDevMode->dmFields |= DM_ORIENTATION; - if ( pSetupData->meOrientation == ORIENTATION_PORTRAIT ) - pDevMode->dmOrientation = DMORIENT_PORTRAIT; - else - pDevMode->dmOrientation = DMORIENT_LANDSCAPE; - } - - // PaperBin - if ( nFlags & SAL_JOBSET_PAPERBIN ) - { - ULONG nCount = ImplDeviceCaps( pPrinter, DC_BINS, NULL, pSetupData ); - - if ( nCount && (nCount != ((ULONG)-1)) ) - { - WORD* pBins = new WORD[nCount]; - memset( pBins, 0, nCount*sizeof(WORD) ); - ImplDeviceCaps( pPrinter, DC_BINS, (LPTSTR)pBins, pSetupData ); - pDevMode->dmFields |= DM_DEFAULTSOURCE; - pDevMode->dmDefaultSource = pBins[ pSetupData->mnPaperBin ]; - delete[] pBins; - } - } - - // PaperSize - if ( nFlags & SAL_JOBSET_PAPERSIZE ) - { - pDevMode->dmFields |= DM_PAPERSIZE; - pDevMode->dmPaperWidth = 0; - pDevMode->dmPaperLength = 0; - - switch( pDevMode->dmPaperSize ) - { - case( PAPER_A3 ): - pDevMode->dmPaperSize = DMPAPER_A3; - break; - case( PAPER_A4 ): - pDevMode->dmPaperSize = DMPAPER_A4; - break; - case( PAPER_A5 ): - pDevMode->dmPaperSize = DMPAPER_A5; - break; - case( PAPER_B4 ): - pDevMode->dmPaperSize = DMPAPER_B4; - break; - case( PAPER_B5 ): - pDevMode->dmPaperSize = DMPAPER_B5; - break; - case( PAPER_LETTER ): - pDevMode->dmPaperSize = DMPAPER_LETTER; - break; - case( PAPER_LEGAL ): - pDevMode->dmPaperSize = DMPAPER_LEGAL; - break; - case( PAPER_TABLOID ): - pDevMode->dmPaperSize = DMPAPER_TABLOID; - break; - default: - { - short nPaper = 0; - ULONG nPaperCount = ImplDeviceCaps( pPrinter, DC_PAPERS, NULL, pSetupData ); - WORD* pPapers = NULL; - ULONG nPaperSizeCount = ImplDeviceCaps( pPrinter, DC_PAPERSIZE, NULL, pSetupData ); - POINT* pPaperSizes = NULL; - if ( nPaperCount && (nPaperCount != ((ULONG)-1)) ) - { - pPapers = new WORD[nPaperCount]; - memset( pPapers, 0, nPaperCount*sizeof(WORD) ); - ImplDeviceCaps( pPrinter, DC_PAPERS, (LPTSTR)pPapers, pSetupData ); - } - if ( nPaperSizeCount && (nPaperSizeCount != ((ULONG)-1)) ) - { - pPaperSizes = new POINT[nPaperSizeCount]; - memset( pPaperSizes, 0, nPaperSizeCount*sizeof(POINT) ); - ImplDeviceCaps( pPrinter, DC_PAPERSIZE, (LPTSTR)pPaperSizes, pSetupData ); - } - if ( (nPaperSizeCount == nPaperCount) && pPapers && pPaperSizes ) - { - // Alle Papierformate vergleichen und ein passendes - // raussuchen - for ( ULONG i = 0; i < nPaperCount; i++ ) - { - if ( ImplPaperSizeEqual( (short)(pSetupData->mnPaperWidth/10), - (short)(pSetupData->mnPaperHeight/10), - (short)pPaperSizes[i].x, - (short)pPaperSizes[i].y ) ) - { - nPaper = pPapers[i]; - break; - } - } - } - if ( pPapers ) - delete pPapers; - if ( pPaperSizes ) - delete pPaperSizes; - - if ( nPaper ) - pDevMode->dmPaperSize = nPaper; - else - { - pDevMode->dmFields |= DM_PAPERLENGTH | DM_PAPERWIDTH; - pDevMode->dmPaperSize = DMPAPER_USER; - pDevMode->dmPaperWidth = pSetupData->mnPaperWidth/10; - pDevMode->dmPaperLength = pSetupData->mnPaperHeight/10; - } - } - break; - } - } -#endif -} - -// ----------------------------------------------------------------------- - -static VCLVIEW ImplCreateSalPrnIC( SalInfoPrinter* pPrinter, ImplJobSetup* pSetupData ) -{ -#ifdef WIN - LPDEVMODE pDevMode; - if ( pSetupData && pSetupData->mpDriverData ) - pDevMode = SAL_DEVMODE( pSetupData ); - else - pDevMode = NULL; -// !!! UNICODE - NT Optimierung !!! - VCLVIEW hDC = CreateICA( ImplSalGetWinAnsiString( pPrinter->maPrinterData.maDriverName, TRUE ).GetBuffer(), - ImplSalGetWinAnsiString( pPrinter->maPrinterData.maDeviceName, TRUE ).GetBuffer(), - 0, - (LPDEVMODE)pDevMode ); - return hDC; -#else - return NULL; -#endif -} - -// ----------------------------------------------------------------------- - -static SalGraphics* ImplCreateSalPrnGraphics( VCLVIEW hDC ) -{ - SalGraphics* pGraphics = new SalGraphics; - pGraphics->maGraphicsData.mhDC = hDC; - pGraphics->maGraphicsData.mhWnd = 0; - pGraphics->maGraphicsData.mbPrinter = TRUE; - pGraphics->maGraphicsData.mbVirDev = FALSE; - pGraphics->maGraphicsData.mbWindow = FALSE; - pGraphics->maGraphicsData.mbScreen = FALSE; - ImplSalInitGraphics( &(pGraphics->maGraphicsData) ); - return pGraphics; -} - -// ----------------------------------------------------------------------- - -static BOOL ImplUpdateSalPrnIC( SalInfoPrinter* pPrinter, ImplJobSetup* pSetupData ) -{ - VCLVIEW hNewDC = ImplCreateSalPrnIC( pPrinter, pSetupData ); - if ( !hNewDC ) - return FALSE; - - if ( pPrinter->maPrinterData.mpGraphics ) - { - ImplSalDeInitGraphics( &(pPrinter->maPrinterData.mpGraphics->maGraphicsData) ); -#ifdef WIN - DeleteDC( pPrinter->maPrinterData.mpGraphics->maGraphicsData.mhDC ); -#endif - delete pPrinter->maPrinterData.mpGraphics; - } - - SalGraphics* pGraphics = ImplCreateSalPrnGraphics( hNewDC ); - pPrinter->maPrinterData.mhDC = hNewDC; - pPrinter->maPrinterData.mpGraphics = pGraphics; - - return TRUE; -} - -// ======================================================================= - -SalInfoPrinter* SalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, - ImplJobSetup* pSetupData ) -{ - SalInfoPrinter* pPrinter = new SalInfoPrinter; - pPrinter->maPrinterData.maDriverName = pQueueInfo->maDriver; - pPrinter->maPrinterData.maDeviceName = pQueueInfo->maPrinterName; - pPrinter->maPrinterData.maPortName = *(String*)(pQueueInfo->mpSysData); - - // Testen, ob Setupdaten zum Drucker gehoeren (erst aufrufen, nachdem - // die Member gesetzt sind, da diese in dieser Routine abgefragt werden) - ImplTestSalJobSetup( pPrinter, pSetupData, TRUE ); - - VCLVIEW hDC = ImplCreateSalPrnIC( pPrinter, pSetupData ); - if ( !hDC ) - { - delete pPrinter; - return NULL; - } - - SalGraphics* pGraphics = ImplCreateSalPrnGraphics( hDC ); - pPrinter->maPrinterData.mhDC = hDC; - pPrinter->maPrinterData.mpGraphics = pGraphics; - if ( !pSetupData->mpDriverData ) - ImplUpdateSalJobSetup( pPrinter, pSetupData, FALSE, NULL ); - ImplDevModeToJobSetup( pPrinter, pSetupData, SAL_JOBSET_ALL ); - pSetupData->mnSystem = JOBSETUP_SYSTEM_WINDOWS; - - return pPrinter; -} - -// ----------------------------------------------------------------------- - -void SalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter ) -{ - delete pPrinter; -} // ======================================================================= SalInfoPrinter::SalInfoPrinter() { - maPrinterData.mhDC = 0; - maPrinterData.mpGraphics = NULL; - maPrinterData.mbGraphics = FALSE; } // ----------------------------------------------------------------------- SalInfoPrinter::~SalInfoPrinter() { - if ( maPrinterData.mpGraphics ) - { - ImplSalDeInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); -#ifdef WIN - DeleteDC( maPrinterData.mpGraphics->maGraphicsData.mhDC ); -#endif - delete maPrinterData.mpGraphics; - } } // ----------------------------------------------------------------------- SalGraphics* SalInfoPrinter::GetGraphics() { - if ( maPrinterData.mbGraphics ) - return NULL; - - if ( maPrinterData.mpGraphics ) - maPrinterData.mbGraphics = TRUE; - - return maPrinterData.mpGraphics; + return NULL; } // ----------------------------------------------------------------------- void SalInfoPrinter::ReleaseGraphics( SalGraphics* ) { - maPrinterData.mbGraphics = FALSE; } // ----------------------------------------------------------------------- BOOL SalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ) { - if ( ImplUpdateSalJobSetup( this, pSetupData, TRUE, pFrame ) ) - { - ImplDevModeToJobSetup( this, pSetupData, SAL_JOBSET_ALL ); - return ImplUpdateSalPrnIC( this, pSetupData ); - } - return FALSE; } @@ -954,22 +108,13 @@ BOOL SalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ) BOOL SalInfoPrinter::SetPrinterData( ImplJobSetup* pSetupData ) { - if ( !ImplTestSalJobSetup( this, pSetupData, FALSE ) ) - return FALSE; - return ImplUpdateSalPrnIC( this, pSetupData ); + return FALSE; } // ----------------------------------------------------------------------- BOOL SalInfoPrinter::SetData( ULONG nFlags, ImplJobSetup* pSetupData ) { - ImplJobSetupToDevMode( this, pSetupData, nFlags ); - if ( ImplUpdateSalJobSetup( this, pSetupData, TRUE, NULL ) ) - { - ImplDevModeToJobSetup( this, pSetupData, nFlags ); - return ImplUpdateSalPrnIC( this, pSetupData ); - } - return FALSE; } @@ -977,84 +122,20 @@ BOOL SalInfoPrinter::SetData( ULONG nFlags, ImplJobSetup* pSetupData ) ULONG SalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pSetupData ) { -#ifdef WIN - DWORD nRet = ImplDeviceCaps( this, DC_BINS, NULL, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - return nRet; - else -#endif - return 0; + return 0; } // ----------------------------------------------------------------------- XubString SalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ) { -// !!! UNICODE - NT Optimierung !!! - XubString aPaperBinName; - -#ifdef WIN - DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, NULL, pSetupData ); - if ( (nPaperBin < nBins) && (nBins != ((ULONG)-1)) ) - { - char* pBuffer = new char[nBins*24]; - DWORD nRet = ImplDeviceCaps( this, DC_BINNAMES, pBuffer, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - aPaperBinName = ImplSalGetUniString( (const char*)(pBuffer + (nPaperBin*24)) ); - delete pBuffer; - } -#endif - - return aPaperBinName; + return XubString(); } // ----------------------------------------------------------------------- ULONG SalInfoPrinter::GetCapabilities( const ImplJobSetup* pSetupData, USHORT nType ) { -#ifdef WIN - DWORD nRet; - - switch ( nType ) - { - case PRINTER_CAPABILITIES_SUPPORTDIALOG: - return TRUE; - case PRINTER_CAPABILITIES_COPIES: - nRet = ImplDeviceCaps( this, DC_COPIES, NULL, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - return nRet; - return 0; - case PRINTER_CAPABILITIES_COLLATECOPIES: - nRet = ImplDeviceCaps( this, DC_COLLATE, NULL, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - { - nRet = ImplDeviceCaps( this, DC_COPIES, NULL, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - return nRet; - } - return 0; - - case PRINTER_CAPABILITIES_SETORIENTATION: - nRet = ImplDeviceCaps( this, DC_ORIENTATION, NULL, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - return TRUE; - return FALSE; - - case PRINTER_CAPABILITIES_SETPAPERBIN: - nRet = ImplDeviceCaps( this, DC_BINS, NULL, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - return TRUE; - return FALSE; - - case PRINTER_CAPABILITIES_SETPAPERSIZE: - case PRINTER_CAPABILITIES_SETPAPER: - nRet = ImplDeviceCaps( this, DC_PAPERS, NULL, pSetupData ); - if ( nRet && (nRet != ((ULONG)-1)) ) - return TRUE; - return FALSE; - } -#endif - return 0; } @@ -1065,158 +146,31 @@ void SalInfoPrinter::GetPageInfo( const ImplJobSetup*, long& rPageOffX, long& rPageOffY, long& rPageWidth, long& rPageHeight ) { - VCLVIEW hDC = maPrinterData.mhDC; - -#ifdef WIN - rOutWidth = GetDeviceCaps( hDC, HORZRES ); - rOutHeight = GetDeviceCaps( hDC, VERTRES ); - - rPageOffX = GetDeviceCaps( hDC, PHYSICALOFFSETX ); - rPageOffY = GetDeviceCaps( hDC, PHYSICALOFFSETY ); - rPageWidth = GetDeviceCaps( hDC, PHYSICALWIDTH ); - rPageHeight = GetDeviceCaps( hDC, PHYSICALHEIGHT ); -#endif } // ======================================================================= SalPrinter* SalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter ) { - SalPrinter* pPrinter = new SalPrinter; - pPrinter->maPrinterData.mpInfoPrinter = pInfoPrinter; - return pPrinter; + return NULL; } // ----------------------------------------------------------------------- void SalInstance::DestroyPrinter( SalPrinter* pPrinter ) { - delete pPrinter; -} - -// ======================================================================= - -WIN_BOOL CALLBACK SalPrintAbortProc( VCLVIEW hPrnDC, int /* nError */ ) -{ - SalData* pSalData = GetSalData(); - SalPrinter* pPrinter; - BOOL bWhile = TRUE; - int i = 0; - - do - { -#ifdef WIN - // Messages verarbeiten - MSG aMsg; - if ( ImplPeekMessage( &aMsg, 0, 0, 0, PM_REMOVE ) ) - { - TranslateMessage( &aMsg ); - ImplDispatchMessage( &aMsg ); - i++; - if ( i > 15 ) - bWhile = FALSE; - } - else -#endif - bWhile = FALSE; - - pPrinter = pSalData->mpFirstPrinter; - while ( pPrinter ) - { - if( pPrinter->maPrinterData.mhDC == hPrnDC ) - break; - - pPrinter = pPrinter->maPrinterData.mpNextPrinter; - } - - if ( !pPrinter || pPrinter->maPrinterData.mbAbort ) - return FALSE; - } - while ( bWhile ); - - return TRUE; } // ----------------------------------------------------------------------- -#ifdef WIN -static LPDEVMODE ImplSalSetCopies( LPDEVMODE pDevMode, ULONG nCopies, BOOL bCollate ) -{ - LPDEVMODE pNewDevMode = pDevMode; - if ( pDevMode && (nCopies > 1) ) - { - if ( nCopies > 32765 ) - nCopies = 32765; - ULONG nDevSize = pDevMode->dmSize+pDevMode->dmDriverExtra; - pNewDevMode = (LPDEVMODE)new BYTE[nDevSize]; - memcpy( pNewDevMode, pDevMode, nDevSize ); - pDevMode = pNewDevMode; - pDevMode->dmFields |= DM_COPIES; - pDevMode->dmCopies = (short)(USHORT)nCopies; - if ( aSalShlData.mbW40 ) - { - pDevMode->dmFields |= DM_COLLATE; - if ( bCollate ) - pDevMode->dmCollate = DMCOLLATE_TRUE; - else - pDevMode->dmCollate = DMCOLLATE_FALSE; - } - } - - return pNewDevMode; -} -#endif - -// ----------------------------------------------------------------------- - SalPrinter::SalPrinter() { - SalData* pSalData = GetSalData(); - - maPrinterData.mhDC = 0; - maPrinterData.mpGraphics = NULL; - maPrinterData.mbAbort = FALSE; - maPrinterData.mnCopies = 0; - maPrinterData.mbCollate = FALSE; - - // insert frame in framelist - maPrinterData.mpNextPrinter = pSalData->mpFirstPrinter; - pSalData->mpFirstPrinter = this; } // ----------------------------------------------------------------------- SalPrinter::~SalPrinter() { - SalData* pSalData = GetSalData(); - - // DC freigeben, wenn er noch durch ein AbortJob existiert - VCLVIEW hDC = maPrinterData.mhDC; - if ( hDC ) - { - if ( maPrinterData.mpGraphics ) - { - ImplSalDeInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); - delete maPrinterData.mpGraphics; - } - -#ifdef WIN - DeleteDC( hDC ); -#endif - } - - // remove printer from printerlist - if ( this == pSalData->mpFirstPrinter ) - pSalData->mpFirstPrinter = maPrinterData.mpNextPrinter; - else - { - SalPrinter* pTempPrinter = pSalData->mpFirstPrinter; - - while( pTempPrinter->maPrinterData.mpNextPrinter != this ) - pTempPrinter = pTempPrinter->maPrinterData.mpNextPrinter; - - pTempPrinter->maPrinterData.mpNextPrinter = maPrinterData.mpNextPrinter; - } } // ----------------------------------------------------------------------- @@ -1227,130 +181,13 @@ BOOL SalPrinter::StartJob( const XubString* pFileName, ULONG nCopies, BOOL bCollate, ImplJobSetup* pSetupData ) { -#ifdef WIN - maPrinterData.mnError = 0; - maPrinterData.mbAbort = FALSE; - maPrinterData.mnCopies = nCopies; - maPrinterData.mbCollate = bCollate; - - LPDEVMODE pOrgDevMode = NULL; - LPDEVMODE pDevMode; - BOOL bOwnDevMode = FALSE; - if ( pSetupData && pSetupData->mpDriverData ) - { - pOrgDevMode = SAL_DEVMODE( pSetupData ); - pDevMode = ImplSalSetCopies( pOrgDevMode, nCopies, bCollate ); - } - else - pDevMode = NULL; - -// !!! UNICODE - NT Optimierung !!! - VCLVIEW hDC = CreateDCA( ImplSalGetWinAnsiString( maPrinterData.mpInfoPrinter->maPrinterData.maDriverName, TRUE ).GetBuffer(), - ImplSalGetWinAnsiString( maPrinterData.mpInfoPrinter->maPrinterData.maDeviceName, TRUE ).GetBuffer(), - 0, - (LPDEVMODEA)pDevMode ); - - if ( pDevMode != pOrgDevMode ) - delete pDevMode; - - if ( !hDC ) - { - maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; - return FALSE; - } - - if ( SetAbortProc( hDC, SalPrintAbortProc ) <= 0 ) - { - maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; - return FALSE; - } - - maPrinterData.mnError = 0; - maPrinterData.mbAbort = FALSE; - -// !!! UNICODE - NT Optimierung !!! - // Both strings must be exist, if StartJob() is called - ByteString aJobName( ImplSalGetWinAnsiString( rJobName, TRUE ) ); - ByteString aFileName; - - DOCINFO aInfo; - memset( &aInfo, 0, sizeof( DOCINFO ) ); - aInfo.cbSize = sizeof( aInfo ); - aInfo.lpszDocName = (LPCSTR)aJobName.GetBuffer(); - if ( pFileName ) - { - if ( pFileName->Len() ) - { - aFileName = ImplSalGetWinAnsiString( *pFileName, TRUE ); - aInfo.lpszOutput = (LPCSTR)aFileName.GetBuffer(); - } - else - aInfo.lpszOutput = "FILE:"; - } - else - aInfo.lpszOutput = NULL; - - // Wegen Telocom Balloon Fax-Treiber, der uns unsere Messages - // ansonsten oefters schickt, versuchen wir vorher alle - // zu verarbeiten und dann eine Dummy-Message reinstellen - BOOL bWhile = TRUE; - int i = 0; - do - { - // Messages verarbeiten - MSG aMsg; - if ( ImplPeekMessage( &aMsg, 0, 0, 0, PM_REMOVE ) ) - { - TranslateMessage( &aMsg ); - ImplDispatchMessage( &aMsg ); - i++; - if ( i > 15 ) - bWhile = FALSE; - } - else - bWhile = FALSE; - } - while ( bWhile ); - ImplPostMessage( GetSalData()->mpFirstInstance->maInstData.mhComWnd, SAL_MSG_DUMMY, 0, 0 ); - - // Job starten - int nRet = ::StartDoc( hDC, &aInfo ); - if ( nRet <= 0 ) - { - if ( (nRet == SP_USERABORT) || (nRet == SP_APPABORT) || (GetLastError() == ERROR_PRINT_CANCELLED) ) - maPrinterData.mnError = SAL_PRINTER_ERROR_ABORT; - else - maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; - return FALSE; - } - - maPrinterData.mhDC = hDC; - return TRUE; -#else return FALSE; -#endif } // ----------------------------------------------------------------------- BOOL SalPrinter::EndJob() { - VCLVIEW hDC = maPrinterData.mhDC; - if ( hDC ) - { - if ( maPrinterData.mpGraphics ) - { - ImplSalDeInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); - delete maPrinterData.mpGraphics; - maPrinterData.mpGraphics = NULL; - } - -#ifdef WIN - ::EndDoc( hDC ); - DeleteDC( hDC ); -#endif - } - return TRUE; } @@ -1358,130 +195,26 @@ BOOL SalPrinter::EndJob() BOOL SalPrinter::AbortJob() { - maPrinterData.mbAbort = TRUE; - - // Abort asyncron ausloesen - VCLVIEW hDC = maPrinterData.mhDC; - if ( hDC ) - { - SalData* pSalData = GetSalData(); -#ifdef WIN - ImplPostMessage( pSalData->mpFirstInstance->maInstData.mhComWnd, - SAL_MSG_PRINTABORTJOB, (WPARAM)hDC, 0 ); -#endif - } - return TRUE; } // ----------------------------------------------------------------------- -void ImplSalPrinterAbortJobAsync( VCLVIEW hPrnDC ) -{ - SalData* pSalData = GetSalData(); - SalPrinter* pPrinter = pSalData->mpFirstPrinter; - - // Feststellen, ob Printer noch existiert - while ( pPrinter ) - { - if ( pPrinter->maPrinterData.mhDC == hPrnDC ) - break; - - pPrinter = pPrinter->maPrinterData.mpNextPrinter; - } - - // Wenn Printer noch existiert, dann den Job abbrechen - if ( pPrinter ) - { - VCLVIEW hDC = pPrinter->maPrinterData.mhDC; - if ( hDC ) - { - if ( pPrinter->maPrinterData.mpGraphics ) - { - ImplSalDeInitGraphics( &(pPrinter->maPrinterData.mpGraphics->maGraphicsData) ); - delete pPrinter->maPrinterData.mpGraphics; - pPrinter->maPrinterData.mpGraphics = NULL; - } - -#ifdef WIN - ::AbortDoc( hDC ); - DeleteDC( hDC ); -#endif - } - } -} - -// ----------------------------------------------------------------------- - SalGraphics* SalPrinter::StartPage( ImplJobSetup* pSetupData, BOOL bNewJobData ) { - VCLVIEW hDC = maPrinterData.mhDC; -#ifdef WIN - if ( pSetupData && pSetupData->mpDriverData && bNewJobData ) - { - LPDEVMODE pOrgDevMode; - LPDEVMODE pDevMode; - pOrgDevMode = SAL_DEVMODE( pSetupData ); - pDevMode = ImplSalSetCopies( pOrgDevMode, maPrinterData.mnCopies, maPrinterData.mbCollate ); - ResetDC( hDC, pDevMode ); - if ( pDevMode != pOrgDevMode ) - delete pDevMode; - } - int nRet = ::StartPage( hDC ); - if ( nRet <= 0 ) - { - maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; - return NULL; - } - - // Hack, damit alte PS-Treiber Leerseiten nicht wegoptimieren - HPEN hTempPen = SelectPen( hDC, GetStockPen( NULL_PEN ) ); - HBRUSH hTempBrush = SelectBrush( hDC, GetStockBrush( NULL_BRUSH ) ); - WIN_Rectangle( hDC, -8000, -8000, -7999, -7999 ); - SelectPen( hDC, hTempPen ); - SelectBrush( hDC, hTempBrush ); -#endif - - SalGraphics* pGraphics = new SalGraphics; - pGraphics->maGraphicsData.mhDC = hDC; - pGraphics->maGraphicsData.mhWnd = 0; - pGraphics->maGraphicsData.mbPrinter = TRUE; - pGraphics->maGraphicsData.mbVirDev = FALSE; - pGraphics->maGraphicsData.mbWindow = FALSE; - pGraphics->maGraphicsData.mbScreen = FALSE; - ImplSalInitGraphics( &(pGraphics->maGraphicsData) ); - maPrinterData.mpGraphics = pGraphics; - return pGraphics; + return NULL; } // ----------------------------------------------------------------------- BOOL SalPrinter::EndPage() { - VCLVIEW hDC = maPrinterData.mhDC; - if ( hDC && maPrinterData.mpGraphics ) - { - ImplSalDeInitGraphics( &(maPrinterData.mpGraphics->maGraphicsData) ); - delete maPrinterData.mpGraphics; - maPrinterData.mpGraphics = NULL; - } -#ifdef WIN - int nRet = ::EndPage( hDC ); - if ( nRet > 0 ) - return TRUE; - else - { - maPrinterData.mnError = SAL_PRINTER_ERROR_GENERALERROR; - return FALSE; - } -#else - return FALSE; -#endif + return TRUE; } // ----------------------------------------------------------------------- ULONG SalPrinter::GetErrorCode() { - return maPrinterData.mnError; + return 0; } diff --git a/vcl/aqua/source/gdi/salvd.cxx b/vcl/aqua/source/gdi/salvd.cxx index 14662e16c228..e673ca934d38 100644 --- a/vcl/aqua/source/gdi/salvd.cxx +++ b/vcl/aqua/source/gdi/salvd.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salvd.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:45 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,15 +59,8 @@ * ************************************************************************/ -#ifndef _SVWIN_H -#include <tools/svwin.h> -#endif - #define _SV_SALVD_CXX -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> -#endif #ifndef _SV_SALDATA_HXX #include <saldata.hxx> #endif @@ -83,79 +76,17 @@ // ======================================================================= -static HBITMAP ImplCreateVirDevBitmap( VCLVIEW hDC, long nDX, long nDY, - USHORT nBitCount ) -{ - HBITMAP hBitmap; - -#ifdef WIN - if ( nBitCount == 1 ) - hBitmap = CreateBitmap( (int)nDX, (int)nDY, 1, 1, NULL ); - else - hBitmap = CreateCompatibleBitmap( hDC, (int)nDX, (int)nDY ); -#endif - - return hBitmap; -} - -// ======================================================================= - SalVirtualDevice* SalInstance::CreateVirtualDevice( SalGraphics* pGraphics, long nDX, long nDY, USHORT nBitCount ) { -#ifdef WIN - VCLVIEW hDC = CreateCompatibleDC( pGraphics->maGraphicsData.mhDC ); - HBITMAP hBmp = ImplCreateVirDevBitmap( pGraphics->maGraphicsData.mhDC, - nDX, nDY, nBitCount ); - - if ( hDC && hBmp ) - { - SalVirtualDevice* pVDev = new SalVirtualDevice; - SalData* pSalData = GetSalData(); - SalGraphics* pVirGraphics = new SalGraphics; - pVirGraphics->maGraphicsData.mhDC = hDC; - pVirGraphics->maGraphicsData.mhWnd = 0; - pVirGraphics->maGraphicsData.mbPrinter = FALSE; - pVirGraphics->maGraphicsData.mbVirDev = TRUE; - pVirGraphics->maGraphicsData.mbWindow = FALSE; - pVirGraphics->maGraphicsData.mbScreen = pGraphics->maGraphicsData.mbScreen; - if ( pSalData->mhDitherPal && pVirGraphics->maGraphicsData.mbScreen ) - { - pVirGraphics->maGraphicsData.mhDefPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE ); - RealizePalette( hDC ); - } - ImplSalInitGraphics( &(pVirGraphics->maGraphicsData) ); - - pVDev->maVirDevData.mhDC = hDC; - pVDev->maVirDevData.mhBmp = hBmp; - pVDev->maVirDevData.mhDefBmp = SelectBitmap( hDC, hBmp ); - pVDev->maVirDevData.mpGraphics = pVirGraphics; - pVDev->maVirDevData.mnBitCount = nBitCount; - pVDev->maVirDevData.mbGraphics = FALSE; - - // insert VirDev in VirDevList - pVDev->maVirDevData.mpNext = pSalData->mpFirstVD; - pSalData->mpFirstVD = pVDev; - - return pVDev; - } - else - { - if ( hDC ) - DeleteDC( hDC ); - if ( hBmp ) - DeleteBitmap( hBmp ); - return NULL; - } -#endif + return NULL; } // ----------------------------------------------------------------------- void SalInstance::DestroyVirtualDevice( SalVirtualDevice* pDevice ) { - delete pDevice; } // ======================================================================= @@ -168,67 +99,23 @@ SalVirtualDevice::SalVirtualDevice() SalVirtualDevice::~SalVirtualDevice() { - SalData* pSalData = GetSalData(); - -#ifdef WIN - // destroy saved DC - if ( maVirDevData.mpGraphics->maGraphicsData.mhDefPal ) - SelectPalette( maVirDevData.mpGraphics->maGraphicsData.mhDC, maVirDevData.mpGraphics->maGraphicsData.mhDefPal, TRUE ); -#endif - ImplSalDeInitGraphics( &(maVirDevData.mpGraphics->maGraphicsData) ); - SelectBitmap( maVirDevData.mpGraphics->maGraphicsData.mhDC, maVirDevData.mhDefBmp ); -#ifdef WIN - DeleteDC( maVirDevData.mpGraphics->maGraphicsData.mhDC ); -#endif - DeleteBitmap( maVirDevData.mhBmp ); - delete maVirDevData.mpGraphics; - - // remove VirDev from VirDevList - if ( this == pSalData->mpFirstVD ) - pSalData->mpFirstVD = maVirDevData.mpNext; - else - { - SalVirtualDevice* pTempVD = pSalData->mpFirstVD; - while ( pTempVD->maVirDevData.mpNext != this ) - pTempVD = pTempVD->maVirDevData.mpNext; - - pTempVD->maVirDevData.mpNext = maVirDevData.mpNext; - } } // ----------------------------------------------------------------------- SalGraphics* SalVirtualDevice::GetGraphics() { - if ( maVirDevData.mbGraphics ) - return NULL; - - if ( maVirDevData.mpGraphics ) - maVirDevData.mbGraphics = TRUE; - - return maVirDevData.mpGraphics; + return NULL; } // ----------------------------------------------------------------------- void SalVirtualDevice::ReleaseGraphics( SalGraphics* ) { - maVirDevData.mbGraphics = FALSE; } // ----------------------------------------------------------------------- BOOL SalVirtualDevice::SetSize( long nDX, long nDY ) { - HBITMAP hNewBmp = ImplCreateVirDevBitmap( maVirDevData.mhDC, nDX, nDY, - maVirDevData.mnBitCount ); - if ( hNewBmp ) - { - SelectBitmap( maVirDevData.mhDC, hNewBmp ); - DeleteBitmap( maVirDevData.mhBmp ); - maVirDevData.mhBmp = hNewBmp; - return TRUE; - } - else - return FALSE; } diff --git a/vcl/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx index c6e391516145..a48d3658f68e 100644 --- a/vcl/aqua/source/window/salframe.cxx +++ b/vcl/aqua/source/window/salframe.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salframe.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:46 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,488 +60,32 @@ ************************************************************************/ #include <string.h> -#include <limits.h> - -#ifdef DBG_UTIL -#include <stdio.h> -#endif - -#ifndef _SVWIN_HXX -#include <tools/svwin.h> -#endif #define _SV_SALFRAME_CXX -#ifndef _DEBUG_HXX -#include <tools/debug.hxx> -#endif - -#define private public -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> -#endif -#ifndef _SV_SALIDS_HRC -#include <salids.hrc> -#endif -#ifndef _SV_SYSDATA_HXX -#include <sysdata.hxx> -#endif #ifndef _SV_SALDATA_HXX #include <saldata.hxx> #endif -#ifndef _SV_SALINST_HXX -#include <salinst.hxx> -#endif #ifndef _SV_SALGDI_HXX #include <salgdi.hxx> #endif -#ifndef _SV_SALSYS_HXX -#include <salsys.hxx> -#endif #ifndef _SV_SALFRAME_HXX #include <salframe.hxx> #endif -#ifndef _SV_SALVD_HXX -#include <salvd.hxx> -#endif -#ifndef _SV_TIMER_HXX -#include <timer.hxx> -#endif -#ifndef _SV_SETTINGS_HXX -#include <settings.hxx> -#endif -#ifndef _SV_KEYCOES_HXX -#include <keycodes.hxx> -#endif #ifndef _SV_VCLWINDOW_H #include <VCLWindow.h> #endif // ======================================================================= -// Wegen Fehler in Windows-Headerfiles -#ifndef IMN_OPENCANDIDATE -#define IMN_OPENCANDIDATE 0x0005 -#endif -#ifndef IMN_CLOSECANDIDATE -#define IMN_CLOSECANDIDATE 0x0004 -#endif - -// ======================================================================= - -static void ImplSaveFrameState( SalFrame* pFrame ) -{ -#ifdef WIN - // Position, Groesse und Status fuer GetWindowState() merken - if ( !pFrame->maFrameData.mbFullScreen ) - { - BOOL bVisible = (GetWindowStyle( pFrame->maFrameData.mhWnd ) & WS_VISIBLE) != 0; - if ( IsIconic( pFrame->maFrameData.mhWnd ) ) - { - pFrame->maFrameData.maState.mnState |= SAL_FRAMESTATE_MINIMIZED; - if ( bVisible ) - pFrame->maFrameData.mnShowState = SW_SHOWMAXIMIZED; - } - else if ( IsZoomed( pFrame->maFrameData.mhWnd ) ) - { - pFrame->maFrameData.maState.mnState &= ~SAL_FRAMESTATE_MINIMIZED; - pFrame->maFrameData.maState.mnState |= SAL_FRAMESTATE_MAXIMIZED; - if ( bVisible ) - pFrame->maFrameData.mnShowState = SW_SHOWMAXIMIZED; - pFrame->maFrameData.mbRestoreMaximize = TRUE; - } - else - { - RECT aRect; - GetWindowRect( pFrame->maFrameData.mhWnd, &aRect ); - pFrame->maFrameData.maState.mnState &= ~(SAL_FRAMESTATE_MINIMIZED | SAL_FRAMESTATE_MAXIMIZED); - pFrame->maFrameData.maState.mnX = aRect.left; - pFrame->maFrameData.maState.mnY = aRect.top; - pFrame->maFrameData.maState.mnWidth = aRect.right-aRect.left; - pFrame->maFrameData.maState.mnHeight = aRect.bottom-aRect.top; - if ( bVisible ) - pFrame->maFrameData.mnShowState = SW_SHOWNORMAL; - pFrame->maFrameData.mbRestoreMaximize = FALSE; - } - } -#endif -} - -// ======================================================================= - -SalFrame* ImplSalCreateFrame( SalInstance* pInst, - VCLWINDOW hWndParent, ULONG nSalFrameStyle ) -{ - SalFrame* pFrame = new SalFrame; -#ifdef WIN - VCLWINDOW hWnd; - DWORD nSysStyle = 0; - DWORD nExSysStyle = 0; - BOOL bSaveBits = FALSE; - - // determine creation data - if ( nSalFrameStyle & SAL_FRAME_STYLE_CHILD ) - nSysStyle |= WS_CHILD; - else if ( nSalFrameStyle & SAL_FRAME_STYLE_DEFAULT ) - { - pFrame->maFrameData.mbCaption = TRUE; - nSysStyle |= WS_OVERLAPPED; - nExSysStyle |= WS_EX_APPWINDOW; - } - else - nSysStyle |= WS_POPUP; - if ( nSalFrameStyle & SAL_FRAME_STYLE_SIZEABLE ) - { - pFrame->maFrameData.mbSizeBorder = TRUE; - nSysStyle |= WS_THICKFRAME | WS_SYSMENU; - } - else if ( nSalFrameStyle & SAL_FRAME_STYLE_BORDER ) - { - pFrame->maFrameData.mbBorder = TRUE; - nSysStyle |= WS_BORDER; - } - if ( nSalFrameStyle & SAL_FRAME_STYLE_MOVEABLE ) - { - pFrame->maFrameData.mbCaption = TRUE; - nSysStyle |= WS_CAPTION | WS_SYSMENU; - } - else - nExSysStyle |= WS_EX_TOOLWINDOW; - if ( nSalFrameStyle & SAL_FRAME_STYLE_MINABLE ) - nSysStyle |= WS_MINIMIZEBOX | WS_SYSMENU; - if ( nSalFrameStyle & SAL_FRAME_STYLE_MAXABLE ) - nSysStyle |= WS_MAXIMIZEBOX | WS_SYSMENU; - - // init frame data - pFrame->maFrameData.mnStyle = nSalFrameStyle; - - // determine show style - if ( nSalFrameStyle & SAL_FRAME_STYLE_DEFAULT ) - { - SalData* pSalData = GetSalData(); - pFrame->maFrameData.mnShowState = pSalData->mnCmdShow; - if ( (pFrame->maFrameData.mnShowState != SW_SHOWMINIMIZED) && - (pFrame->maFrameData.mnShowState != SW_MINIMIZE) && - (pFrame->maFrameData.mnShowState != SW_SHOWMINNOACTIVE) ) - { - if ( (pFrame->maFrameData.mnShowState == SW_SHOWMAXIMIZED) || - (pFrame->maFrameData.mnShowState == SW_MAXIMIZE) ) - pFrame->maFrameData.mbOverwriteState = FALSE; - pFrame->maFrameData.mnShowState = SW_SHOWMAXIMIZED; - } - else - pFrame->maFrameData.mbOverwriteState = FALSE; - } - else - pFrame->maFrameData.mnShowState = SW_SHOWNORMAL; - - // create frame - LPCSTR pClassName; - if ( bSaveBits ) - pClassName = SAL_FRAME_CLASSNAME_SBA; - else - pClassName = SAL_FRAME_CLASSNAMEA; - hWnd = CreateWindowExA( nExSysStyle, pClassName, "", nSysStyle, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, - hWndParent, 0, pInst->maInstData.mhInst, (void*)pFrame ); - } - if ( !hWnd ) - { - delete pFrame; - return NULL; - } - - // disable close - if ( !(nSalFrameStyle & SAL_FRAME_STYLE_CLOSEABLE) ) - { - HMENU hSysMenu = GetSystemMenu( hWnd, FALSE ); - if ( hSysMenu ) - EnableMenuItem( hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED ); - } - - // reset input context -#ifdef WIN - pFrame->maFrameData.mhDefIMEContext = ImmAssociateContext( hWnd, 0 ); -#endif - - // determine output size and state - RECT aRect; - GetClientRect( hWnd, &aRect ); - pFrame->maFrameData.mnWidth = aRect.right; - pFrame->maFrameData.mnHeight = aRect.bottom; - ImplSaveFrameState( pFrame ); - pFrame->maFrameData.mbDefPos = TRUE; - - // CreateVCLVIEW in the main thread - pFrame->ReleaseGraphics( pFrame->GetGraphics() ); -#endif - - return pFrame; -} - -// ======================================================================= - -// Uebersetzungstabelle von System-Keycodes in StarView-Keycodes -#define KEY_TAB_SIZE 146 - -static USHORT aImplTranslateKeyTab[KEY_TAB_SIZE] = -{ - // StarView-Code System-Code Index - 0, // 0 - 0, // VK_LBUTTON 1 - 0, // VK_RBUTTON 2 - 0, // VK_CANCEL 3 - 0, // VK_MBUTTON 4 - 0, // 5 - 0, // 6 - 0, // 7 - KEY_BACKSPACE, // VK_BACK 8 - KEY_TAB, // VK_TAB 9 - 0, // 10 - 0, // 11 - 0, // VK_CLEAR 12 - KEY_RETURN, // VK_RETURN 13 - 0, // 14 - 0, // 15 - 0, // VK_SHIFT 16 - 0, // VK_CONTROL 17 - 0, // VK_MENU 18 - 0, // VK_PAUSE 19 - 0, // VK_CAPITAL 20 - 0, // 21 - 0, // 22 - 0, // 23 - 0, // 24 - 0, // 25 - 0, // 26 - KEY_ESCAPE, // VK_ESCAPE 27 - 0, // 28 - 0, // 29 - 0, // 30 - 0, // 31 - KEY_SPACE, // VK_SPACE 32 - KEY_PAGEUP, // VK_PRIOR 33 - KEY_PAGEDOWN, // VK_NEXT 34 - KEY_END, // VK_END 35 - KEY_HOME, // VK_HOME 36 - KEY_LEFT, // VK_LEFT 37 - KEY_UP, // VK_UP 38 - KEY_RIGHT, // VK_RIGHT 39 - KEY_DOWN, // VK_DOWN 40 - 0, // VK_SELECT 41 - 0, // VK_PRINT 42 - 0, // VK_EXECUTE 43 - 0, // VK_SNAPSHOT 44 - KEY_INSERT, // VK_INSERT 45 - KEY_DELETE, // VK_DELETE 46 - KEY_HELP, // VK_HELP 47 - KEY_0, // 48 - KEY_1, // 49 - KEY_2, // 50 - KEY_3, // 51 - KEY_4, // 52 - KEY_5, // 53 - KEY_6, // 54 - KEY_7, // 55 - KEY_8, // 56 - KEY_9, // 57 - 0, // 58 - 0, // 59 - 0, // 60 - 0, // 61 - 0, // 62 - 0, // 63 - 0, // 64 - KEY_A, // 65 - KEY_B, // 66 - KEY_C, // 67 - KEY_D, // 68 - KEY_E, // 69 - KEY_F, // 70 - KEY_G, // 71 - KEY_H, // 72 - KEY_I, // 73 - KEY_J, // 74 - KEY_K, // 75 - KEY_L, // 76 - KEY_M, // 77 - KEY_N, // 78 - KEY_O, // 79 - KEY_P, // 80 - KEY_Q, // 81 - KEY_R, // 82 - KEY_S, // 83 - KEY_T, // 84 - KEY_U, // 85 - KEY_V, // 86 - KEY_W, // 87 - KEY_X, // 88 - KEY_Y, // 89 - KEY_Z, // 90 - 0, // VK_LWIN 91 - 0, // VK_RWIN 92 - KEY_CONTEXTMENU, // VK_APPS 93 - 0, // 94 - 0, // 95 - KEY_0, // VK_NUMPAD0 96 - KEY_1, // VK_NUMPAD1 97 - KEY_2, // VK_NUMPAD2 98 - KEY_3, // VK_NUMPAD3 99 - KEY_4, // VK_NUMPAD4 100 - KEY_5, // VK_NUMPAD5 101 - KEY_6, // VK_NUMPAD6 102 - KEY_7, // VK_NUMPAD7 103 - KEY_8, // VK_NUMPAD8 104 - KEY_9, // VK_NUMPAD9 105 - KEY_MULTIPLY, // VK_MULTIPLY 106 - KEY_ADD, // VK_ADD 107 - KEY_COMMA, // VK_SEPARATOR 108 - KEY_SUBTRACT, // VK_SUBTRACT 109 - KEY_POINT, // VK_DECIMAL 110 - KEY_DIVIDE, // VK_DIVIDE 111 - KEY_F1, // VK_F1 112 - KEY_F2, // VK_F2 113 - KEY_F3, // VK_F3 114 - KEY_F4, // VK_F4 115 - KEY_F5, // VK_F5 116 - KEY_F6, // VK_F6 117 - KEY_F7, // VK_F7 118 - KEY_F8, // VK_F8 119 - KEY_F9, // VK_F9 120 - KEY_F10, // VK_F10 121 - KEY_F11, // VK_F11 122 - KEY_F12, // VK_F12 123 - KEY_F13, // VK_F13 124 - KEY_F14, // VK_F14 125 - KEY_F15, // VK_F15 126 - KEY_F16, // VK_F16 127 - KEY_F17, // VK_F17 128 - KEY_F18, // VK_F18 129 - KEY_F19, // VK_F19 130 - KEY_F20, // VK_F20 131 - KEY_F21, // VK_F21 132 - KEY_F22, // VK_F22 133 - KEY_F23, // VK_F23 134 - KEY_F24, // VK_F24 135 - 0, // 136 - 0, // 137 - 0, // 138 - 0, // 139 - 0, // 140 - 0, // 141 - 0, // 142 - 0, // 143 - 0, // NUMLOCK 144 - 0 // SCROLLLOCK 145 -}; - -// ======================================================================= - -long ImplSalCallbackDummy( void*, SalFrame*, USHORT, const void* ) -{ - return 0; -} - -// ----------------------------------------------------------------------- - -static UINT ImplSalGetWheelScrollLines() -{ - UINT nScrLines = 0; -#ifdef WIN - VCLWINDOW hWndMsWheel = WIN_FindWindow( MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE ); - if ( hWndMsWheel ) - { - UINT nGetScrollLinesMsgId = RegisterWindowMessage( MSH_SCROLL_LINES ); - nScrLines = (UINT)ImplSendMessage( hWndMsWheel, nGetScrollLinesMsgId, 0, 0 ); - } - - if ( !nScrLines ) - nScrLines = SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &nScrLines, 0 ); - - if ( !nScrLines ) - nScrLines = 3; -#endif - - return nScrLines; -} - -// ----------------------------------------------------------------------- - -static void ImplSalCalcFullScreenSize( const SalFrame* pFrame, - int& rX, int& rY, int& rDX, int& rDY ) -{ -#ifdef WIN - // set window to screen size - int nFrameX; - int nFrameY; - int nCaptionY; - int nScreenDX; - int nScreenDY; - - if ( pFrame->maFrameData.mbSizeBorder ) - { - nFrameX = GetSystemMetrics( SM_CXFRAME ); - nFrameY = GetSystemMetrics( SM_CYFRAME ); - } - else if ( pFrame->maFrameData.mbBorder ) - { - nFrameX = GetSystemMetrics( SM_CXBORDER ); - nFrameY = GetSystemMetrics( SM_CYBORDER ); - } - else - { - nFrameX = 0; - nFrameY = 0; - } - if ( pFrame->maFrameData.mbCaption ) - nCaptionY = GetSystemMetrics( SM_CYCAPTION ); - else - nCaptionY = 0; - - nScreenDX = GetSystemMetrics( SM_CXSCREEN ); - nScreenDY = GetSystemMetrics( SM_CYSCREEN ); - - rX = -nFrameX; - rY = -(nFrameY+nCaptionY); - rDX = nScreenDX+(nFrameX*2); - rDY = nScreenDY+(nFrameY*2)+nCaptionY; -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplSalFrameFullScreenPos( SalFrame* pFrame, BOOL bAlways = FALSE ) -{ -#ifdef WIN - if ( bAlways || !IsIconic( pFrame->maFrameData.mhWnd ) ) - { - // set window to screen size - int nX; - int nY; - int nWidth; - int nHeight; - ImplSalCalcFullScreenSize( pFrame, nX, nY, nWidth, nHeight ); - SetWindowPos( pFrame->maFrameData.mhWnd, 0, - nX, nY, nWidth, nHeight, - SWP_NOZORDER | SWP_NOACTIVATE ); - } -#endif -} - -// ----------------------------------------------------------------------- - SalFrame::SalFrame() { SalData* pSalData = GetSalData(); maFrameData.mhWnd = 0; -#ifdef WIN - maFrameData.mhCursor = LoadCursor( 0, IDC_ARROW ); -#endif - maFrameData.mhDefIMEContext = 0; maFrameData.mpGraphics = NULL; maFrameData.mpInst = NULL; - maFrameData.mpProc = ImplSalCallbackDummy; + maFrameData.mpProc = NULL; maFrameData.mnInputLang = 0; maFrameData.mnInputCodePage = 0; maFrameData.mbGraphics = FALSE; @@ -565,74 +109,12 @@ SalFrame::SalFrame() maFrameData.mbCandidateMode = FALSE; memset( &maFrameData.maState, 0, sizeof( SalFrameState ) ); maFrameData.maSysData.nSize = sizeof( SystemEnvData ); - - // Daten ermitteln, wenn erster Frame angelegt wird - if ( !pSalData->mpFirstFrame ) - { -#ifdef WIN - if ( !aSalShlData.mnWheelMsgId ) - aSalShlData.mnWheelMsgId = RegisterWindowMessage( MSH_MOUSEWHEEL ); -#endif - if ( !aSalShlData.mnWheelScrollLines ) - aSalShlData.mnWheelScrollLines = ImplSalGetWheelScrollLines(); - } - - // insert frame in framelist - maFrameData.mpNextFrame = pSalData->mpFirstFrame; - pSalData->mpFirstFrame = this; } // ----------------------------------------------------------------------- SalFrame::~SalFrame() { - SalData* pSalData = GetSalData(); - - // destroy saved DC - if ( maFrameData.mpGraphics ) - { -#ifdef WIN - if ( maFrameData.mpGraphics->maGraphicsData.mhDefPal ) - SelectPalette( maFrameData.mpGraphics->maGraphicsData.mhDC, maFrameData.mpGraphics->maGraphicsData.mhDefPal, TRUE ); -#endif - ImplSalDeInitGraphics( &(maFrameData.mpGraphics->maGraphicsData) ); -#ifdef WIN - ReleaseDC( maFrameData.mhWnd, maFrameData.mpGraphics->maGraphicsData.mhDC ); -#endif - delete maFrameData.mpGraphics; - } - - if ( maFrameData.mhWnd ) - { - // reset mouse leave data - if ( pSalData->mhWantLeaveMsg == maFrameData.mhWnd ) - { - pSalData->mhWantLeaveMsg = 0; - if ( pSalData->mpMouseLeaveTimer ) - { - delete pSalData->mpMouseLeaveTimer; - pSalData->mpMouseLeaveTimer = NULL; - } - } - -#ifdef WIN - // destroy system frame - if ( !DestroyWindow( maFrameData.mhWnd ) ) - SetWindowPtr( maFrameData.mhWnd, 0 ); -#endif - } - - // 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; - } } // ----------------------------------------------------------------------- @@ -655,14 +137,6 @@ SalGraphics* SalFrame::GetGraphics() maFrameData.mpGraphics->maGraphicsData.mbVirDev = FALSE; maFrameData.mpGraphics->maGraphicsData.mbWindow = TRUE; maFrameData.mpGraphics->maGraphicsData.mbScreen = TRUE; -#ifdef WIN - if ( pSalData->mhDitherPal ) - { - maFrameData.mpGraphics->maGraphicsData.mhDefPal = SelectPalette( hView, pSalData->mhDitherPal, TRUE ); - RealizePalette( hView ); - } - ImplSalInitGraphics( &(maFrameData.mpGraphics->maGraphicsData) ); -#endif maFrameData.mbGraphics = TRUE; } } @@ -676,109 +150,25 @@ SalGraphics* SalFrame::GetGraphics() void SalFrame::ReleaseGraphics( SalGraphics* ) { - maFrameData.mbGraphics = FALSE; } // ----------------------------------------------------------------------- BOOL SalFrame::PostEvent( void* pData ) { -#ifdef WIN - return (BOOL)ImplPostMessage( maFrameData.mhWnd, SAL_MSG_USEREVENT, 0, (LPARAM)pData ); -#else return FALSE; -#endif } // ----------------------------------------------------------------------- void SalFrame::SetTitle( const XubString& rTitle ) { - DBG_ASSERT( sizeof( wchar_t ) == sizeof( xub_Unicode ), "SalFrame::SetTitle(): wchar_t != sal_Unicode" ); - -#ifdef WIN - if ( !SetWindowTextW( maFrameData.mhWnd, rTitle.GetBuffer() ) ) - { - ByteString aAnsiTitle = ImplSalGetWinAnsiString( rTitle ); - SetWindowTextA( maFrameData.mhWnd, aAnsiTitle.GetBuffer() ); - } -#endif } // ----------------------------------------------------------------------- void SalFrame::SetIcon( USHORT nIcon ) { -// ImplSendMessage( maFrameData.mhWnd, WM_SETICON, FALSE, hSmIcon ); -// ImplSendMessage( maFrameData.mhWnd, WM_SETICON, TRUE, hIcon ); -} - -// ----------------------------------------------------------------------- - -static void ImplSalShow( VCLWINDOW hWnd, BOOL bVisible ) -{ - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( !pFrame ) - return; - - if ( bVisible ) - { - pFrame->maFrameData.mbDefPos = FALSE; - pFrame->maFrameData.mbOverwriteState = TRUE; - pFrame->maFrameData.mbInShow = TRUE; -#ifdef WIN - ShowWindow( hWnd, pFrame->maFrameData.mnShowState ); -#endif - // Damit Taskleiste unter W98 auch gleich ausgeblendet wird - if ( pFrame->maFrameData.mbPresentation ) - { -#ifdef WIN - VCLWINDOW hWndParent = ::GetParent( hWnd ); - if ( hWndParent ) - SetForegroundWindow( hWndParent ); - SetForegroundWindow( hWnd ); -#endif - } -#ifdef WIN - pFrame->maFrameData.mnShowState = SW_SHOW; - pFrame->maFrameData.mbInShow = FALSE; - UpdateWindow( hWnd ); -#endif - } - else - { -#ifdef WIN - if ( pFrame->maFrameData.mbFullScreen && - pFrame->maFrameData.mbPresentation && - !::GetParent( hWnd ) ) - { - // Damit im Impress-Player in der Taskleiste nicht durch - // einen Windows-Fehler hin- und wieder mal ein leerer - // Button stehen bleibt, muessen wir hier die Taskleiste - // etwas austricksen. Denn wenn wir im FullScreenMode sind - // und das Fenster hiden kommt Windows anscheinend etwas aus - // dem tritt und somit minimieren wir das Fenster damit es - // nicht flackert - ANIMATIONINFO aInfo; - aInfo.cbSize = sizeof( aInfo ); - SystemParametersInfo( SPI_GETANIMATION, 0, &aInfo, 0 ); - if ( aInfo.iMinAnimate ) - { - int nOldAni = aInfo.iMinAnimate; - aInfo.iMinAnimate = 0; - SystemParametersInfo( SPI_SETANIMATION, 0, &aInfo, 0 ); - ShowWindow( pFrame->maFrameData.mhWnd, SW_SHOWMINNOACTIVE ); - aInfo.iMinAnimate = nOldAni; - SystemParametersInfo( SPI_SETANIMATION, 0, &aInfo, 0 ); - } - else - ShowWindow( hWnd, SW_SHOWMINNOACTIVE ); - ShowWindow( hWnd, SW_HIDE ); - } - else - ShowWindow( hWnd, SW_HIDE ); -#endif - } } // ----------------------------------------------------------------------- @@ -795,9 +185,6 @@ void SalFrame::Show( BOOL bVisible ) void SalFrame::Enable( BOOL bEnable ) { -#ifdef WIN - EnableWindow( maFrameData.mhWnd, bEnable ); -#endif } // ----------------------------------------------------------------------- @@ -810,184 +197,24 @@ void SalFrame::SetMinClientSize( long nWidth, long nHeight ) void SalFrame::SetClientSize( long nWidth, long nHeight ) { -#ifdef WIN - BOOL bVisible = (GetWindowStyle( maFrameData.mhWnd ) & WS_VISIBLE) != 0; - if ( !bVisible ) - maFrameData.mnShowState = SW_SHOWNORMAL; - else - { - if ( IsIconic( maFrameData.mhWnd ) || IsZoomed( maFrameData.mhWnd ) ) - ShowWindow( maFrameData.mhWnd, SW_RESTORE ); - } - - // Fenstergroesse berechnen - RECT aWinRect; - aWinRect.left = 0; - aWinRect.right = (int)nWidth-1; - aWinRect.top = 0; - aWinRect.bottom = (int)nHeight-1; - AdjustWindowRectEx( &aWinRect, - GetWindowStyle( maFrameData.mhWnd ), - FALSE, - GetWindowExStyle( maFrameData.mhWnd ) ); - nWidth = aWinRect.right - aWinRect.left + 1; - nHeight = aWinRect.bottom - aWinRect.top + 1; - - // Position so berechnen, das Fenster zentiert auf dem Desktop - // angezeigt wird - int nX; - int nY; - int nScreenX; - int nScreenY; - int nScreenWidth; - int nScreenHeight; - - RECT aRect; - SystemParametersInfo( SPI_GETWORKAREA, 0, &aRect, 0 ); - nScreenX = aRect.left; - nScreenY = aRect.top; - nScreenWidth = aRect.right-aRect.left; - nScreenHeight = aRect.bottom-aRect.top; - - if ( maFrameData.mbDefPos ) - { - nX = (nScreenWidth-nWidth)/2 + nScreenX; - nY = (nScreenHeight-nHeight)/2 + nScreenY; - if ( bVisible ) - maFrameData.mbDefPos = FALSE; - } - else - { - RECT aWinRect; - GetWindowRect( maFrameData.mhWnd, &aWinRect ); - nX = aWinRect.left; - nY = aWinRect.top; - if ( nX+nWidth > nScreenX+nScreenWidth ) - nX = (nScreenX+nScreenWidth) - nWidth; - if ( nY+nHeight > nScreenY+nScreenHeight ) - nY = (nScreenY+nScreenHeight) - nHeight; - if ( nX < nScreenX ) - nX = nScreenX; - if ( nY < nScreenY ) - nY = nScreenY; - } - - SetWindowPos( maFrameData.mhWnd, 0, nX, nY, (int)nWidth, (int)nHeight, SWP_NOZORDER | SWP_NOACTIVATE ); -#endif } // ----------------------------------------------------------------------- void SalFrame::GetClientSize( long& rWidth, long& rHeight ) { - rWidth = maFrameData.mnWidth; - rHeight = maFrameData.mnHeight; } // ----------------------------------------------------------------------- void SalFrame::SetWindowState( const SalFrameState* pState ) { -#ifdef WIN - // Wir testen, ob das Fenster ueberhaupt auf den Bildschirm passt, damit - // nicht wenn die Bildschirm-Aufloesung geaendert wurde, das Fenster aus - // diesem herausragt - int nX; - int nY; - int nWidth; - int nHeight; - int nScreenX; - int nScreenY; - int nScreenWidth; - int nScreenHeight; - - RECT aRect; - SystemParametersInfo( SPI_GETWORKAREA, 0, &aRect, 0 ); - nScreenX = aRect.left; - nScreenY = aRect.top; - nScreenWidth = aRect.right-aRect.left; - nScreenHeight = aRect.bottom-aRect.top; - - // Fenster-Position/Groesse in den Bildschirm einpassen - nX = (int)pState->mnX; - nY = (int)pState->mnY; - nWidth = (int)pState->mnWidth; - nHeight = (int)pState->mnHeight; - if ( nX < nScreenX ) - nX = nScreenX; - if ( nY < nScreenY ) - nY = nScreenY; - if ( nScreenWidth < nWidth ) - nWidth = nScreenWidth; - if ( nScreenHeight < nHeight ) - nHeight = nScreenHeight; - - // Restore-Position setzen - WINDOWPLACEMENT aPlacement; - aPlacement.length = sizeof( aPlacement ); - GetWindowPlacement( maFrameData.mhWnd, &aPlacement ); - - // Status setzen - BOOL bVisible = (GetWindowStyle( maFrameData.mhWnd ) & WS_VISIBLE) != 0; - if ( !bVisible ) - { - aPlacement.showCmd = SW_HIDE; - - if ( maFrameData.mbOverwriteState ) - { - if ( pState->mnState & SAL_FRAMESTATE_MINIMIZED ) - maFrameData.mnShowState = SW_SHOWMINIMIZED; - else if ( pState->mnState & SAL_FRAMESTATE_MAXIMIZED ) - maFrameData.mnShowState = SW_SHOWMAXIMIZED; - else - maFrameData.mnShowState = SW_SHOWNORMAL; - } - } - else - { - if ( pState->mnState & SAL_FRAMESTATE_MINIMIZED ) - { - if ( pState->mnState & SAL_FRAMESTATE_MAXIMIZED ) - aPlacement.flags |= WPF_RESTORETOMAXIMIZED; - aPlacement.showCmd = SW_SHOWMINIMIZED; - } - else if ( pState->mnState & SAL_FRAMESTATE_MAXIMIZED ) - aPlacement.showCmd = SW_SHOWMAXIMIZED; - else - aPlacement.showCmd = SW_RESTORE; - } - - // Wenn Fenster nicht minimiert/maximiert ist oder nicht optisch - // umgesetzt werden muss, dann SetWindowPos() benutzen, da - // SetWindowPlacement() die TaskBar mit einrechnet - if ( !IsIconic( maFrameData.mhWnd ) && !IsZoomed( maFrameData.mhWnd ) && - (!bVisible || (aPlacement.showCmd == SW_RESTORE)) ) - { - SetWindowPos( maFrameData.mhWnd, 0, - nX, nY, nWidth, nHeight, - SWP_NOZORDER | SWP_NOACTIVATE ); - } - else - { - aPlacement.rcNormalPosition.left = nX-nScreenX; - aPlacement.rcNormalPosition.top = nY-nScreenY; - aPlacement.rcNormalPosition.right = nX+nWidth-nScreenX; - aPlacement.rcNormalPosition.bottom = nY+nHeight-nScreenY; - SetWindowPlacement( maFrameData.mhWnd, &aPlacement ); - } -#endif } // ----------------------------------------------------------------------- BOOL SalFrame::GetWindowState( SalFrameState* pState ) { - if ( maFrameData.maState.mnWidth && maFrameData.maState.mnHeight ) - { - *pState = maFrameData.maState; - return TRUE; - } - return FALSE; } @@ -995,379 +222,60 @@ BOOL SalFrame::GetWindowState( SalFrameState* pState ) void SalFrame::ShowFullScreen( BOOL bFullScreen ) { - if ( maFrameData.mbFullScreen == bFullScreen ) - return; - - maFrameData.mbFullScreen = bFullScreen; -#ifdef WIN - if ( bFullScreen ) - { - // Damit Taskleiste von Windows ausgeblendet wird - DWORD nExStyle = GetWindowExStyle( maFrameData.mhWnd ); - if ( nExStyle & WS_EX_TOOLWINDOW ) - { - maFrameData.mbFullScreenToolWin = TRUE; - nExStyle &= ~WS_EX_TOOLWINDOW; - SetWindowExStyle( maFrameData.mhWnd, nExStyle ); - } - - // save old position - GetWindowRect( maFrameData.mhWnd, &maFrameData.maFullScreenRect ); - - // save show state - maFrameData.mnFullScreenShowState = maFrameData.mnShowState; - if ( !(GetWindowStyle( maFrameData.mhWnd ) & WS_VISIBLE) ) - maFrameData.mnShowState = SW_SHOW; - - // set window to screen size - ImplSalFrameFullScreenPos( this, TRUE ); - } - else - { - // wenn ShowState wieder hergestellt werden muss, hiden wir zuerst - // das Fenster, damit es nicht so sehr flackert - BOOL bVisible = (GetWindowStyle( maFrameData.mhWnd ) & WS_VISIBLE) != 0; - if ( bVisible && (maFrameData.mnShowState != maFrameData.mnFullScreenShowState) ) - ShowWindow( maFrameData.mhWnd, SW_HIDE ); - - if ( maFrameData.mbFullScreenToolWin ) - SetWindowExStyle( maFrameData.mhWnd, GetWindowExStyle( maFrameData.mhWnd ) | WS_EX_TOOLWINDOW ); - maFrameData.mbFullScreenToolWin = FALSE; - - SetWindowPos( maFrameData.mhWnd, 0, - maFrameData.maFullScreenRect.left, - maFrameData.maFullScreenRect.top, - maFrameData.maFullScreenRect.right-maFrameData.maFullScreenRect.left, - maFrameData.maFullScreenRect.bottom-maFrameData.maFullScreenRect.top, - SWP_NOZORDER | SWP_NOACTIVATE ); - - // restore show state - if ( maFrameData.mnShowState != maFrameData.mnFullScreenShowState ) - { - maFrameData.mnShowState = maFrameData.mnFullScreenShowState; - if ( bVisible ) - { - maFrameData.mbInShow = TRUE; - ShowWindow( maFrameData.mhWnd, maFrameData.mnShowState ); - maFrameData.mbInShow = FALSE; - UpdateWindow( maFrameData.mhWnd ); - } - } - } -#endif } // ----------------------------------------------------------------------- void SalFrame::StartPresentation( BOOL bStart ) { -#ifdef WIN - if ( maFrameData.mbPresentation == bStart ) - return; - - maFrameData.mbPresentation = bStart; - - SalData* pSalData = GetSalData(); - if ( bStart ) - { - if ( !pSalData->mpSageEnableProc ) - { - if ( pSalData->mnSageStatus != DISABLE_AGENT ) - { - OFSTRUCT aOS; - OpenFile( "SAGE.DLL", &aOS, OF_EXIST ); - - if ( !aOS.nErrCode ) - { - pSalData->mhSageInst = LoadLibrary( aOS.szPathName ); - pSalData->mpSageEnableProc = (SysAgt_Enable_PROC)GetProcAddress( pSalData->mhSageInst, "System_Agent_Enable" ); - } - else - pSalData->mnSageStatus = DISABLE_AGENT; - } - } - - if ( pSalData->mpSageEnableProc ) - { - pSalData->mnSageStatus = pSalData->mpSageEnableProc( GET_AGENT_STATUS ); - if ( pSalData->mnSageStatus == ENABLE_AGENT ) - pSalData->mpSageEnableProc( DISABLE_AGENT ); - } - - // Bildschirmschoner ausschalten, wenn Praesentation laueft - SystemParametersInfo( SPI_GETSCREENSAVEACTIVE, 0, - &(pSalData->mbScrSvrEnabled), 0 ); - if ( pSalData->mbScrSvrEnabled ) - SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, FALSE, 0, 0 ); - } - else - { - // Bildschirmschoner wieder einschalten - if ( pSalData->mbScrSvrEnabled ) - SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, pSalData->mbScrSvrEnabled, 0, 0 ); - - // Systemagenten wieder aktivieren - if ( pSalData->mnSageStatus == ENABLE_AGENT ) - pSalData->mpSageEnableProc( pSalData->mnSageStatus ); - } -#endif } // ----------------------------------------------------------------------- void SalFrame::SetAlwaysOnTop( BOOL bOnTop ) { -#ifdef WIN - VCLWINDOW hWnd; - if ( bOnTop ) - hWnd = VCLWINDOW_TOPMOST; - else - hWnd = VCLWINDOW_NOTOPMOST; - SetWindowPos( maFrameData.mhWnd, hWnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE ); -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplSalToTop( VCLWINDOW hWnd, USHORT nFlags ) -{ -#ifdef WIN - if ( nFlags & SAL_FRAME_TOTOP_FOREGROUNDTASK ) - SetForegroundWindow( hWnd ); - if ( !IsIconic( hWnd ) ) - { - SetFocus( hWnd ); - - // Windows behauptet oefters mal, das man den Focus hat, obwohl - // man diesen nicht hat. Wenn dies der Fall ist, dann versuchen - // wir diesen auch ganz richtig zu bekommen. - if ( ::GetFocus() == hWnd ) - SetForegroundWindow( hWnd ); - } - else - { - if ( nFlags & SAL_FRAME_TOTOP_RESTOREWHENMIN ) - { - if ( GetWindowPtr( hWnd )->maFrameData.mbRestoreMaximize ) - ShowWindow( hWnd, SW_MAXIMIZE ); - else - ShowWindow( hWnd, SW_RESTORE ); - } - } -#endif } // ----------------------------------------------------------------------- void SalFrame::ToTop( USHORT nFlags ) { -#ifdef WIN - // Send this Message to the window, because SetFocus() only work - // in the thread of the window, which has create this window - ImplSendMessage( maFrameData.mhWnd, SAL_MSG_TOTOP, nFlags, 0 ); -#endif } // ----------------------------------------------------------------------- void SalFrame::SetPointer( PointerStyle ePointerStyle ) { -#ifdef WIN - struct ImplPtrData - { - HCURSOR mhCursor; - LPCSTR mnSysId; - UINT mnOwnId; - }; - - static ImplPtrData aImplPtrTab[POINTER_COUNT] = - { - { 0, IDC_ARROW, 0 }, // POINTER_ARROW - { 0, 0, SAL_RESID_POINTER_NULL }, // POINTER_NULL - { 0, IDC_WAIT, 0 }, // POINTER_WAIT - { 0, IDC_IBEAM, 0 }, // POINTER_TEXT - { 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, IDC_SIZENS, 0 }, // POINTER_NSIZE - { 0, IDC_SIZENS, 0 }, // POINTER_SSIZE - { 0, IDC_SIZEWE, 0 }, // POINTER_WSIZE - { 0, IDC_SIZEWE, 0 }, // POINTER_ESIZE - { 0, IDC_SIZENWSE, 0 }, // POINTER_NWSIZE - { 0, IDC_SIZENESW, 0 }, // POINTER_NESIZE - { 0, IDC_SIZENESW, 0 }, // POINTER_SWSIZE - { 0, IDC_SIZENWSE, 0 }, // POINTER_SESIZE - { 0, IDC_SIZENS, 0 }, // POINTER_WINDOW_NSIZE - { 0, IDC_SIZENS, 0 }, // POINTER_WINDOW_SSIZE - { 0, IDC_SIZEWE, 0 }, // POINTER_WINDOW_WSIZE - { 0, IDC_SIZEWE, 0 }, // POINTER_WINDOW_ESIZE - { 0, IDC_SIZENWSE, 0 }, // POINTER_WINDOW_NWSIZE - { 0, IDC_SIZENESW, 0 }, // POINTER_WINDOW_NESIZE - { 0, IDC_SIZENESW, 0 }, // POINTER_WINDOW_SWSIZE - { 0, IDC_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, 0, SAL_RESID_POINTER_NOTALLOWED }, // 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 - { 0, 0, SAL_RESID_POINTER_AIRBRUSH } // POINTER_AIRBRUSH - }; - -#if POINTER_COUNT != 86 -#error New Pointer must be defined! -#endif - - // Mousepointer loaded ? - if ( !aImplPtrTab[ePointerStyle].mhCursor ) - { - if ( aImplPtrTab[ePointerStyle].mnOwnId ) - aImplPtrTab[ePointerStyle].mhCursor = ImplLoadSalCursor( aImplPtrTab[ePointerStyle].mnOwnId ); - else - aImplPtrTab[ePointerStyle].mhCursor = LoadCursor( 0, aImplPtrTab[ePointerStyle].mnSysId ); - } - - // Unterscheidet sich der Mauspointer, dann den neuen setzen - if ( maFrameData.mhCursor != aImplPtrTab[ePointerStyle].mhCursor ) - { - maFrameData.mhCursor = aImplPtrTab[ePointerStyle].mhCursor; - SetCursor( maFrameData.mhCursor ); - } -#endif } // ----------------------------------------------------------------------- void SalFrame::CaptureMouse( BOOL bCapture ) { -#ifdef WIN - // Send this Message to the window, because CaptureMouse() only work - // in the thread of the window, which has create this window - int nMsg; - if ( bCapture ) - nMsg = SAL_MSG_CAPTUREMOUSE; - else - nMsg = SAL_MSG_RELEASEMOUSE; - ImplSendMessage( maFrameData.mhWnd, nMsg, 0, 0 ); -#endif } // ----------------------------------------------------------------------- void SalFrame::SetPointerPos( long nX, long nY ) { - POINT aPt; - aPt.x = (int)nX; - aPt.y = (int)nY; -#ifdef WIN - ClientToScreen( maFrameData.mhWnd, &aPt ); - SetCursorPos( aPt.x, aPt.y ); -#endif } // ----------------------------------------------------------------------- void SalFrame::Flush() { -#ifdef WIN - GdiFlush(); -#endif } // ----------------------------------------------------------------------- void SalFrame::Sync() { -#ifdef WIN - GdiFlush(); -#endif } // ----------------------------------------------------------------------- void SalFrame::SetInputContext( SalInputContext* pContext ) { - BOOL bIME = pContext->mnOptions != 0; - if ( bIME == maFrameData.mbIME ) - return; - - maFrameData.mbIME = bIME; - if ( !bIME ) - { -#ifdef WIN - ImmAssociateContext( maFrameData.mhWnd, 0 ); -#endif - maFrameData.mbHandleIME = FALSE; - } - else - { - if ( maFrameData.mhDefIMEContext ) - { -#ifdef WIN - ImmAssociateContext( maFrameData.mhWnd, maFrameData.mhDefIMEContext ); - UINT nImeProps = ImmGetProperty( GetKeyboardLayout( 0 ), IGP_PROPERTY ); - maFrameData.mbSpezIME = (nImeProps & IME_PROP_SPECIAL_UI) != 0; - maFrameData.mbAtCursorIME = (nImeProps & IME_PROP_AT_CARET) != 0; - maFrameData.mbHandleIME = !maFrameData.mbSpezIME; -#endif - } - } } // ----------------------------------------------------------------------- @@ -1380,316 +288,13 @@ void SalFrame::UpdateExtTextInputArea() void SalFrame::EndExtTextInput( USHORT nFlags ) { -#ifdef WIN - VCLWINDOW hWnd = maFrameData.mhWnd; - HIMC hIMC = ImmGetContext( hWnd ); - if ( hIMC ) - { - DWORD nIndex; - if ( nFlags & SAL_FRAME_ENDEXTTEXTINPUT_COMPLETE ) - nIndex = CPS_COMPLETE; - else - nIndex = CPS_CANCEL; - - ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, nIndex, 0 ); - ImmReleaseContext( hWnd, hIMC ); - } -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplGetKeyNameText( LONG lParam, sal_Unicode* pBuf, - UINT& rCount, UINT nMaxSize, - const sal_Char* pReplace ) -{ -#ifdef WIN - DBG_ASSERT( sizeof( wchar_t ) == sizeof( xub_Unicode ), "SalFrame::ImplGetKeyNameTextW(): wchar_t != sal_Unicode" ); - - wchar_t aKeyBuf[350]; - int nKeyLen = 0; - if ( lParam ) - { - nKeyLen = GetKeyNameTextW( lParam, aKeyBuf, sizeof( aKeyBuf ) / sizeof( sal_Unicode ) ); - if ( nKeyLen > 0 ) - { - // Convert name, so that the keyname start with an upper - // char and the rest of the word are in lower chars - CharLowerBuffW( aKeyBuf, nKeyLen ); - CharUpperBuffW( aKeyBuf, 1 ); - wchar_t cTempChar; - wchar_t* pKeyBuf = aKeyBuf; - while ( (cTempChar = *pKeyBuf) != 0 ) - { - if ( (cTempChar == '+') || (cTempChar == '-') || - (cTempChar == ' ') || (cTempChar == '.') ) - CharUpperBuffW( pKeyBuf+1, 1 ); - pKeyBuf++; - } - } - else - { - sal_Char aAnsiKeyBuf[250]; - int nAnsiKeyLen = GetKeyNameTextA( lParam, aAnsiKeyBuf, sizeof( aAnsiKeyBuf ) / sizeof( sal_Char ) ); - if ( nAnsiKeyLen ) - { - // Convert name, so that the keyname start with an upper - // char and the rest of the word are in lower chars - CharLowerBuffA( aAnsiKeyBuf, nAnsiKeyLen ); - CharUpperBuffA( aAnsiKeyBuf, 1 ); - sal_Char cTempChar; - sal_Char* pAnsiKeyBuf = aAnsiKeyBuf; - while ( (cTempChar = *pAnsiKeyBuf) != 0 ) - { - if ( (cTempChar == '+') || (cTempChar == '-') || - (cTempChar == ' ') || (cTempChar == '.') ) - CharUpperBuffA( pAnsiKeyBuf+1, 1 ); - pAnsiKeyBuf++; - } - - // Convert to Unicode and copy the data in the Unicode Buffer - nKeyLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, aAnsiKeyBuf, nAnsiKeyLen, aKeyBuf, sizeof( aKeyBuf ) / sizeof( sal_Unicode ) ); - } - } - } - - if ( (nKeyLen > 0) || pReplace ) - { - if ( rCount ) - { - pBuf[rCount] = '+'; - rCount++; - } - - if ( nKeyLen ) - { - memcpy( pBuf+rCount, aKeyBuf, nKeyLen*sizeof( sal_Unicode ) ); - rCount += nKeyLen; - } - else - { - while ( *pReplace ) - { - pBuf[rCount] = *pReplace; - rCount++; - pReplace++; - } - } - } - else - rCount = 0; -#endif } // ----------------------------------------------------------------------- XubString SalFrame::GetKeyName( USHORT nKeyCode ) { - XubString aKeyCode; -#ifdef WIN - sal_Unicode aKeyBuf[350]; - UINT nKeyBufLen = 0; - UINT nSysCode; - - if ( nKeyCode & KEY_MOD2 ) - { - nSysCode = MapVirtualKey( VK_MENU, 0 ); - nSysCode = (nSysCode << 16) | (((ULONG)1) << 25); - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, - sizeof( aKeyBuf ) / sizeof( sal_Unicode ), - "Alt" ); - } - - if ( nKeyCode & KEY_MOD1 ) - { - nSysCode = MapVirtualKey( VK_CONTROL, 0 ); - nSysCode = (nSysCode << 16) | (((ULONG)1) << 25); - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, - sizeof( aKeyBuf ) / sizeof( sal_Unicode ), - "Ctrl" ); - } - - if ( nKeyCode & KEY_SHIFT ) - { - nSysCode = MapVirtualKey( VK_SHIFT, 0 ); - nSysCode = (nSysCode << 16) | (((ULONG)1) << 25); - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, - sizeof( aKeyBuf ) / sizeof( sal_Unicode ), - "Shift" ); - } - - USHORT nCode = nKeyCode & 0x0FFF; - ULONG nSysCode2 = 0; - sal_Char* pReplace = NULL; - sal_Unicode cSVCode = 0; - sal_Char aFBuf[4]; - nSysCode = 0; - - if ( (nCode >= KEY_0) && (nCode <= KEY_9) ) - cSVCode = '0' + (nCode - KEY_0); - else if ( (nCode >= KEY_A) && (nCode <= KEY_Z) ) - cSVCode = 'A' + (nCode - KEY_A); - else if ( (nCode >= KEY_F1) && (nCode <= KEY_F26) ) - { - nSysCode = VK_F1 + (nCode - KEY_F1); - aFBuf[0] = 'F'; - if ( (nCode >= KEY_F1) && (nCode <= KEY_F9) ) - { - aFBuf[1] = '1' + (nCode - KEY_F1); - aFBuf[2] = 0; - } - else if ( (nCode >= KEY_F10) && (nCode <= KEY_F19) ) - { - aFBuf[1] = '1'; - aFBuf[2] = '0' + (nCode - KEY_F10); - aFBuf[3] = 0; - } - else - { - aFBuf[1] = '2'; - aFBuf[2] = '0' + (nCode - KEY_F20); - aFBuf[3] = 0; - } - pReplace = aFBuf; - } - else - { - switch ( nCode ) - { - case KEY_DOWN: - nSysCode = VK_DOWN; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Down"; - break; - case KEY_UP: - nSysCode = VK_UP; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Up"; - break; - case KEY_LEFT: - nSysCode = VK_LEFT; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Left"; - break; - case KEY_RIGHT: - nSysCode = VK_RIGHT; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Right"; - break; - case KEY_HOME: - nSysCode = VK_HOME; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Home"; - break; - case KEY_END: - nSysCode = VK_END; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "End"; - break; - case KEY_PAGEUP: - nSysCode = VK_PRIOR; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Page Up"; - break; - case KEY_PAGEDOWN: - nSysCode = VK_NEXT; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Page Down"; - break; - case KEY_RETURN: - nSysCode = VK_RETURN; - pReplace = "Enter"; - break; - case KEY_ESCAPE: - nSysCode = VK_ESCAPE; - pReplace = "Escape"; - break; - case KEY_TAB: - nSysCode = VK_TAB; - pReplace = "Tab"; - break; - case KEY_BACKSPACE: - nSysCode = VK_BACK; - pReplace = "Backspace"; - break; - case KEY_SPACE: - nSysCode = VK_SPACE; - pReplace = "Space"; - break; - case KEY_INSERT: - nSysCode = VK_INSERT; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Insert"; - break; - case KEY_DELETE: - nSysCode = VK_DELETE; - nSysCode2 = (((ULONG)1) << 24); - pReplace = "Delete"; - break; - - case KEY_ADD: - cSVCode = '+'; - break; - case KEY_SUBTRACT: - cSVCode = '-'; - break; - case KEY_MULTIPLY: - cSVCode = '*'; - break; - case KEY_DIVIDE: - cSVCode = '/'; - break; - case KEY_POINT: - cSVCode = '.'; - break; - case KEY_COMMA: - cSVCode = ','; - break; - case KEY_LESS: - cSVCode = '<'; - break; - case KEY_GREATER: - cSVCode = '>'; - break; - case KEY_EQUAL: - cSVCode = '='; - break; - } - } - - if ( nSysCode ) - { - nSysCode = MapVirtualKey( (UINT)nSysCode, 0 ); - if ( nSysCode ) - nSysCode = (nSysCode << 16) | nSysCode2; - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, - sizeof( aKeyBuf ) / sizeof( sal_Unicode ), - pReplace ); - } - else - { - if ( cSVCode ) - { - if ( !nKeyBufLen ) - { - aKeyBuf[0] = cSVCode; - nKeyBufLen = 1; - } - else - { - aKeyBuf[nKeyBufLen] = '+'; - nKeyBufLen++; - aKeyBuf[nKeyBufLen] = cSVCode; - nKeyBufLen++; - } - } - } - - if ( nKeyBufLen ) - aKeyCode.Assign( (const sal_Unicode*)aKeyBuf, nKeyBufLen ); -#endif - - return aKeyCode; + return XubString(); } // ----------------------------------------------------------------------- @@ -1701,2292 +306,25 @@ XubString SalFrame::GetSymbolKeyName( const XubString&, USHORT nKeyCode ) // ----------------------------------------------------------------------- -inline Color ImplWinColorToSal( COLORREF nColor ) -{ -#ifdef WIN - return Color( GetRValue( nColor ), GetGValue( nColor ), GetBValue( nColor ) ); -#else - return NULL; -#endif -} - -// ----------------------------------------------------------------------- - -#ifdef WIN -static void ImplSalUpdateStyleFontA( const LOGFONTA& rLogFont, Font& rFont, - BOOL bOverwriteSystemCharSet ) -{ - ImplSalLogFontToFontA( rLogFont, rFont ); - if ( bOverwriteSystemCharSet && (rFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL) ) - rFont.SetCharSet( gsl_getSystemTextEncoding() ); - // Da bei einigen Windows-Einstellungen 6 Punkt eingetragen ist, - // obwohl im Dialog 8 Punkt angezeigt werden (da MS Sans Serif - // nicht skalierbar ist) vergroessern wir hier das als Hack, da - // ansonsten in russisch Symbolunterschriften nicht lesbar sind - if ( (rFont.GetName().EqualsIgnoreCaseAscii( "MS Sans Serif" ) ) && - (rFont.GetHeight() < 8) ) - rFont.SetHeight( 8 ); -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -static void ImplSalUpdateStyleFontW( const LOGFONTW& rLogFont, Font& rFont, - BOOL bOverwriteSystemCharSet ) -{ - ImplSalLogFontToFontW( rLogFont, rFont ); - if ( bOverwriteSystemCharSet && (rFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL) ) - rFont.SetCharSet( gsl_getSystemTextEncoding() ); - // Da bei einigen Windows-Einstellungen 6 Punkt eingetragen ist, - // obwohl im Dialog 8 Punkt angezeigt werden (da MS Sans Serif - // nicht skalierbar ist) vergroessern wir hier das als Hack, da - // ansonsten in russisch Symbolunterschriften nicht lesbar sind - if ( (rFont.GetName().EqualsIgnoreCaseAscii( "MS Sans Serif" ) ) && - (rFont.GetHeight() < 8) ) - rFont.SetHeight( 8 ); -} -#endif - -// ----------------------------------------------------------------------- - -static long ImplA2I( const BYTE* pStr ) -{ - long n = 0; - int nSign = 1; - - if ( *pStr == '-' ) - { - nSign = -1; - pStr++; - } - - while( (*pStr >= 48) && (*pStr <= 57) ) - { - n *= 10; - n += ((*pStr) - 48); - pStr++; - } - - n *= nSign; - - return n; -} - -// ----------------------------------------------------------------------- - void SalFrame::UpdateSettings( AllSettings& rSettings ) { -#ifdef WIN - MouseSettings aMouseSettings = rSettings.GetMouseSettings(); - aMouseSettings.SetDoubleClickTime( GetDoubleClickTime() ); - aMouseSettings.SetDoubleClickWidth( GetSystemMetrics( SM_CXDOUBLECLK ) ); - aMouseSettings.SetDoubleClickHeight( GetSystemMetrics( SM_CYDOUBLECLK ) ); - long nDragWidth = GetSystemMetrics( SM_CXDRAG ); - long nDragHeight = GetSystemMetrics( SM_CYDRAG ); - if ( nDragWidth ) - aMouseSettings.SetStartDragWidth( nDragWidth ); - if ( nDragHeight ) - aMouseSettings.SetStartDragHeight( nDragHeight ); - HKEY hRegKey; - if ( RegOpenKey( HKEY_CURRENT_USER, - "Control Panel\\Desktop", - &hRegKey ) == ERROR_SUCCESS ) - { - BYTE aValueBuf[10]; - DWORD nValueSize = sizeof( aValueBuf ); - DWORD nType; - if ( RegQueryValueEx( hRegKey, "MenuShowDelay", 0, - &nType, aValueBuf, &nValueSize ) == ERROR_SUCCESS ) - { - if ( nType == REG_SZ ) - aMouseSettings.SetMenuDelay( (ULONG)ImplA2I( aValueBuf ) ); - } - - RegCloseKey( hRegKey ); - } - - StyleSettings aStyleSettings = rSettings.GetStyleSettings(); - BOOL bCompBorder = (aStyleSettings.GetOptions() & (STYLE_OPTION_MACSTYLE | STYLE_OPTION_UNIXSTYLE)) == 0; - aStyleSettings.SetScrollBarSize( GetSystemMetrics( SM_CXVSCROLL ) ); - aStyleSettings.SetSpinSize( GetSystemMetrics( SM_CXVSCROLL ) ); - aStyleSettings.SetCursorBlinkTime( GetCaretBlinkTime() ); - if ( bCompBorder ) - { - aStyleSettings.SetFloatTitleHeight( GetSystemMetrics( SM_CYSMCAPTION ) ); - aStyleSettings.SetTitleHeight( GetSystemMetrics( SM_CYCAPTION ) ); - aStyleSettings.SetActiveBorderColor( ImplWinColorToSal( GetSysColor( COLOR_ACTIVEBORDER ) ) ); - aStyleSettings.SetDeactiveBorderColor( ImplWinColorToSal( GetSysColor( COLOR_INACTIVEBORDER ) ) ); - if ( aSalShlData.mnVersion >= 410 ) - { - aStyleSettings.SetActiveColor2( ImplWinColorToSal( GetSysColor( COLOR_GRADIENTACTIVECAPTION ) ) ); - aStyleSettings.SetDeactiveColor( ImplWinColorToSal( GetSysColor( COLOR_GRADIENTINACTIVECAPTION ) ) ); - } - aStyleSettings.SetFaceColor( ImplWinColorToSal( GetSysColor( COLOR_3DFACE ) ) ); - aStyleSettings.SetLightColor( ImplWinColorToSal( GetSysColor( COLOR_3DHILIGHT ) ) ); - aStyleSettings.SetLightBorderColor( ImplWinColorToSal( GetSysColor( COLOR_3DLIGHT ) ) ); - aStyleSettings.SetShadowColor( ImplWinColorToSal( GetSysColor( COLOR_3DSHADOW ) ) ); - aStyleSettings.SetDarkShadowColor( ImplWinColorToSal( GetSysColor( COLOR_3DDKSHADOW ) ) ); - } - aStyleSettings.SetHelpColor( ImplWinColorToSal( GetSysColor( COLOR_INFOBK ) ) ); - aStyleSettings.SetHelpTextColor( ImplWinColorToSal( GetSysColor( COLOR_INFOTEXT ) ) ); - aStyleSettings.SetDialogColor( aStyleSettings.GetFaceColor() ); - aStyleSettings.SetDialogTextColor( aStyleSettings.GetButtonTextColor() ); - aStyleSettings.SetButtonTextColor( ImplWinColorToSal( GetSysColor( COLOR_BTNTEXT ) ) ); - aStyleSettings.SetRadioCheckTextColor( ImplWinColorToSal( GetSysColor( COLOR_WINDOWTEXT ) ) ); - aStyleSettings.SetGroupTextColor( aStyleSettings.GetRadioCheckTextColor() ); - aStyleSettings.SetLabelTextColor( aStyleSettings.GetRadioCheckTextColor() ); - aStyleSettings.SetInfoTextColor( aStyleSettings.GetRadioCheckTextColor() ); - aStyleSettings.SetWindowColor( ImplWinColorToSal( GetSysColor( COLOR_WINDOW ) ) ); - aStyleSettings.SetWindowTextColor( ImplWinColorToSal( GetSysColor( COLOR_WINDOWTEXT ) ) ); - aStyleSettings.SetFieldColor( aStyleSettings.GetWindowColor() ); - aStyleSettings.SetFieldTextColor( aStyleSettings.GetWindowTextColor() ); - aStyleSettings.SetHighlightColor( ImplWinColorToSal( GetSysColor( COLOR_HIGHLIGHT ) ) ); - aStyleSettings.SetHighlightTextColor( ImplWinColorToSal( GetSysColor( COLOR_HIGHLIGHTTEXT ) ) ); - aStyleSettings.SetMenuHighlightColor( aStyleSettings.GetHighlightColor() ); - aStyleSettings.SetMenuHighlightTextColor( aStyleSettings.GetHighlightTextColor() ); - if ( bCompBorder ) - { - aStyleSettings.SetMenuColor( ImplWinColorToSal( GetSysColor( COLOR_MENU ) ) ); - aStyleSettings.SetMenuTextColor( ImplWinColorToSal( GetSysColor( COLOR_MENUTEXT ) ) ); - aStyleSettings.SetActiveColor( ImplWinColorToSal( GetSysColor( COLOR_ACTIVECAPTION ) ) ); - aStyleSettings.SetActiveTextColor( ImplWinColorToSal( GetSysColor( COLOR_CAPTIONTEXT ) ) ); - aStyleSettings.SetDeactiveColor( ImplWinColorToSal( GetSysColor( COLOR_INACTIVECAPTION ) ) ); - aStyleSettings.SetDeactiveTextColor( ImplWinColorToSal( GetSysColor( COLOR_INACTIVECAPTIONTEXT ) ) ); - } - // Bei hellgrau geben wir die Farbe vor, damit es besser aussieht - if ( aStyleSettings.GetFaceColor() == COL_LIGHTGRAY ) - aStyleSettings.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) ); - else - { - // 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 ) ); - } - - // Query Fonts - int bOverwriteSystemCharSet = getenv("LC_CHARSET") != 0; - Font aMenuFont = aStyleSettings.GetMenuFont(); - Font aTitleFont = aStyleSettings.GetTitleFont(); - Font aFloatTitleFont = aStyleSettings.GetFloatTitleFont(); - Font aHelpFont = aStyleSettings.GetHelpFont(); - Font aAppFont = aStyleSettings.GetAppFont(); - Font aIconFont = aStyleSettings.GetIconFont(); - if ( aSalShlData.mbWNT ) - { - NONCLIENTMETRICSW aNonClientMetrics; - aNonClientMetrics.cbSize = sizeof( aNonClientMetrics ); - if ( SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, sizeof( aNonClientMetrics ), &aNonClientMetrics, 0 ) ) - { - ImplSalUpdateStyleFontW( aNonClientMetrics.lfMenuFont, aMenuFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontW( aNonClientMetrics.lfCaptionFont, aTitleFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontW( aNonClientMetrics.lfSmCaptionFont, aFloatTitleFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontW( aNonClientMetrics.lfStatusFont, aHelpFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontW( aNonClientMetrics.lfMessageFont, aAppFont, bOverwriteSystemCharSet ); - - LOGFONTW aLogFont; - if ( SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &aLogFont, 0 ) ) - ImplSalUpdateStyleFontW( aLogFont, aIconFont, bOverwriteSystemCharSet ); - } - } - else - { - NONCLIENTMETRICSA aNonClientMetrics; - aNonClientMetrics.cbSize = sizeof( aNonClientMetrics ); - if ( SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof( aNonClientMetrics ), &aNonClientMetrics, 0 ) ) - { - ImplSalUpdateStyleFontA( aNonClientMetrics.lfMenuFont, aMenuFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontA( aNonClientMetrics.lfCaptionFont, aTitleFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontA( aNonClientMetrics.lfSmCaptionFont, aFloatTitleFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontA( aNonClientMetrics.lfStatusFont, aHelpFont, bOverwriteSystemCharSet ); - ImplSalUpdateStyleFontA( aNonClientMetrics.lfMessageFont, aAppFont, bOverwriteSystemCharSet ); - - LOGFONTA aLogFont; - if ( SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &aLogFont, 0 ) ) - ImplSalUpdateStyleFontA( aLogFont, aIconFont, bOverwriteSystemCharSet ); - } - } - aStyleSettings.SetMenuFont( aMenuFont ); - aStyleSettings.SetTitleFont( aTitleFont ); - aStyleSettings.SetFloatTitleFont( aFloatTitleFont ); - aStyleSettings.SetHelpFont( aHelpFont ); - aStyleSettings.SetIconFont( aIconFont ); - // We prefer Arial in the russian version, because MS Sans Serif - // is to wide for the dialogs - if ( rSettings.GetInternational().GetLanguage() == LANGUAGE_RUSSIAN ) - { - XubString aFontName = aAppFont.GetName(); - XubString aFirstName = aFontName.GetToken( 0, ';' ); - if ( aFirstName.EqualsIgnoreCaseAscii( "MS Sans Serif" ) ) - { - aFontName.InsertAscii( "Arial;", 0 ); - aAppFont.SetName( aFontName ); - } - } - aStyleSettings.SetAppFont( aAppFont ); - aStyleSettings.SetGroupFont( aAppFont ); - aStyleSettings.SetLabelFont( aAppFont ); - aStyleSettings.SetRadioCheckFont( aAppFont ); - aStyleSettings.SetPushButtonFont( aAppFont ); - aStyleSettings.SetFieldFont( aAppFont ); - if ( aAppFont.GetWeight() > WEIGHT_NORMAL ) - aAppFont.SetWeight( WEIGHT_NORMAL ); - aStyleSettings.SetInfoFont( aAppFont ); - aStyleSettings.SetToolFont( aAppFont ); - - WIN_BOOL bDragFull; - if ( SystemParametersInfo( SPI_GETDRAGFULLWINDOWS, 0, &bDragFull, 0 ) ) - { - ULONG nDragFullOptions = aStyleSettings.GetDragFullOptions(); - if ( bDragFull ) - 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 ); - } - - aStyleSettings.SetIconHorzSpace( GetSystemMetrics( SM_CXICONSPACING ) ); - aStyleSettings.SetIconVertSpace( GetSystemMetrics( SM_CYICONSPACING ) ); - if ( RegOpenKey( HKEY_CURRENT_USER, - "Control Panel\\International\\Calendars\\TwoDigitYearMax", - &hRegKey ) == ERROR_SUCCESS ) - { - BYTE aValueBuf[10]; - DWORD nValue; - DWORD nValueSize = sizeof( aValueBuf ); - DWORD nType; - if ( RegQueryValueEx( hRegKey, "1", 0, - &nType, aValueBuf, &nValueSize ) == ERROR_SUCCESS ) - { - if ( nType == REG_SZ ) - { - nValue = (ULONG)ImplA2I( aValueBuf ); - if ( (nValue > 1000) && (nValue < 10000) ) - { - MiscSettings aMiscSettings = rSettings.GetMiscSettings(); - aMiscSettings.SetTwoDigitYearStart( (USHORT)(nValue-99) ); - rSettings.SetMiscSettings( aMiscSettings ); - } - } - } - - RegCloseKey( hRegKey ); - } - - rSettings.SetMouseSettings( aMouseSettings ); - rSettings.SetStyleSettings( aStyleSettings ); -#endif } // ----------------------------------------------------------------------- const SystemEnvData* SalFrame::GetSystemData() const { - return &maFrameData.maSysData; + return NULL; } // ----------------------------------------------------------------------- void SalFrame::Beep( SoundType eSoundType ) { -#ifdef WIN - static UINT aImplSoundTab[5] = - { - 0, // SOUND_DEFAULT - MB_ICONASTERISK, // SOUND_INFO - MB_ICONEXCLAMATION, // SOUND_WARNING - MB_ICONHAND, // SOUND_ERROR - MB_ICONQUESTION // SOUND_QUERY - }; - -#if SOUND_COUNT != 5 -#error New Sound must be defined! -#endif - - MessageBeep( aImplSoundTab[eSoundType] ); -#endif } // ----------------------------------------------------------------------- void SalFrame::SetCallback( void* pInst, SALFRAMEPROC pProc ) { - maFrameData.mpInst = pInst; - if ( pProc ) - maFrameData.mpProc = pProc; - else - maFrameData.mpProc = ImplSalCallbackDummy; -} - -// ----------------------------------------------------------------------- - -static long ImplHandleMouseMsg( VCLWINDOW hWnd, UINT nMsg, - WPARAM wParam, LPARAM lParam ) -{ - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( !pFrame ) - return 0; - - SalMouseEvent aMouseEvt; - long nRet; -#ifdef WIN - USHORT nEvent; - BOOL bCall = TRUE; - - aMouseEvt.mnX = (short)LOWORD( lParam ); - aMouseEvt.mnY = (short)HIWORD( lParam ); - aMouseEvt.mnCode = 0; - aMouseEvt.mnTime = GetMessageTime(); - - // Wegen (Logitech-)MouseTreiber ueber GetKeyState() gehen, die auf - // mittlerer Maustaste Doppelklick simulieren und den KeyStatus nicht - // beruecksichtigen - - if ( GetKeyState( VK_LBUTTON ) & 0x8000 ) - aMouseEvt.mnCode |= MOUSE_LEFT; - if ( GetKeyState( VK_MBUTTON ) & 0x8000 ) - aMouseEvt.mnCode |= MOUSE_MIDDLE; - if ( GetKeyState( VK_RBUTTON ) & 0x8000 ) - aMouseEvt.mnCode |= MOUSE_RIGHT; - if ( GetKeyState( VK_SHIFT ) & 0x8000 ) - aMouseEvt.mnCode |= KEY_SHIFT; - if ( GetKeyState( VK_CONTROL ) & 0x8000 ) - aMouseEvt.mnCode |= KEY_MOD1; - if ( GetKeyState( VK_MENU ) & 0x8000 ) - aMouseEvt.mnCode |= KEY_MOD2; - - switch ( nMsg ) - { - case WM_MOUSEMOVE: - { - // 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) ) - { - MSG aTempMsg; - if ( ImplPeekMessage( &aTempMsg, hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE | PM_NOYIELD ) ) - { - if ( (aTempMsg.message == WM_MOUSEMOVE) && - (aTempMsg.wParam == wParam) ) - return 1; - } - } - - SalData* pSalData = GetSalData(); - // Test for MouseLeave - if ( pSalData->mhWantLeaveMsg && (pSalData->mhWantLeaveMsg != hWnd) ) - ImplSendMessage( pSalData->mhWantLeaveMsg, SAL_MSG_MOUSELEAVE, 0, GetMessagePos() ); - pSalData->mhWantLeaveMsg = hWnd; - // 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 WM_NCMOUSEMOVE: - case SAL_MSG_MOUSELEAVE: - { - SalData* pSalData = GetSalData(); - if ( pSalData->mhWantLeaveMsg == hWnd ) - { - pSalData->mhWantLeaveMsg = 0; - if ( pSalData->mpMouseLeaveTimer ) - { - delete pSalData->mpMouseLeaveTimer; - pSalData->mpMouseLeaveTimer = NULL; - } - // Mouse-Coordinaates are relativ to the screen - POINT aPt; - aPt.x = (short)LOWORD( lParam ); - aPt.y = (short)HIWORD( lParam ); - ScreenToClient( hWnd, &aPt ); - aMouseEvt.mnX = aPt.x; - aMouseEvt.mnY = aPt.y; - aMouseEvt.mnButton = 0; - nEvent = SALEVENT_MOUSELEAVE; - } - else - bCall = FALSE; - } - break; - - case WM_LBUTTONDOWN: - aMouseEvt.mnButton = MOUSE_LEFT; - nEvent = SALEVENT_MOUSEBUTTONDOWN; - break; - - case WM_MBUTTONDOWN: - aMouseEvt.mnButton = MOUSE_MIDDLE; - nEvent = SALEVENT_MOUSEBUTTONDOWN; - break; - - case WM_RBUTTONDOWN: - aMouseEvt.mnButton = MOUSE_RIGHT; - nEvent = SALEVENT_MOUSEBUTTONDOWN; - break; - - case WM_LBUTTONUP: - aMouseEvt.mnButton = MOUSE_LEFT; - nEvent = SALEVENT_MOUSEBUTTONUP; - break; - - case WM_MBUTTONUP: - aMouseEvt.mnButton = MOUSE_MIDDLE; - nEvent = SALEVENT_MOUSEBUTTONUP; - break; - - case WM_RBUTTONUP: - aMouseEvt.mnButton = MOUSE_RIGHT; - nEvent = SALEVENT_MOUSEBUTTONUP; - break; - } - - if ( bCall ) - { - if ( nEvent == SALEVENT_MOUSEBUTTONDOWN ) - UpdateWindow( hWnd ); - - nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - nEvent, &aMouseEvt ); - if ( nMsg == WM_MOUSEMOVE ) - SetCursor( pFrame->maFrameData.mhCursor ); - } - else - nRet = 0; - - return nRet; -#endif -} - -// ----------------------------------------------------------------------- - -static long ImplHandleMouseActivateMsg( VCLWINDOW hWnd ) -{ - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( !pFrame ) - return 0; - - SalMouseActivateEvent aMouseActivateEvt; - POINT aPt; -#ifdef WIN - GetCursorPos( &aPt ); - ScreenToClient( hWnd, &aPt ); -#endif - aMouseActivateEvt.mnX = aPt.x; - aMouseActivateEvt.mnY = aPt.y; - return pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_MOUSEACTIVATE, &aMouseActivateEvt ); -} - -// ----------------------------------------------------------------------- - -static long ImplHandleWheelMsg( VCLWINDOW hWnd, WPARAM wParam, LPARAM lParam ) -{ - ImplSalYieldMutexAcquireWithWait(); - - long nRet = 0; -#ifdef WIN - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - WORD nWinModCode = LOWORD( wParam ); - POINT aWinPt; - aWinPt.x = (short)LOWORD( lParam ); - aWinPt.y = (short)HIWORD( lParam ); - ScreenToClient( hWnd, &aWinPt ); - - SalWheelMouseEvent aWheelEvt; - aWheelEvt.mnTime = GetMessageTime(); - aWheelEvt.mnX = aWinPt.x; - aWheelEvt.mnY = aWinPt.y; - aWheelEvt.mnCode = 0; - aWheelEvt.mnDelta = (short)HIWORD( wParam ); - aWheelEvt.mnNotchDelta = aWheelEvt.mnDelta/WHEEL_DELTA; - if ( aSalShlData.mnWheelScrollLines == WHEEL_PAGESCROLL ) - aWheelEvt.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; - else - aWheelEvt.mnScrollLines = aSalShlData.mnWheelScrollLines; - aWheelEvt.mbHorz = FALSE; - - if ( nWinModCode & MK_SHIFT ) - aWheelEvt.mnCode |= KEY_SHIFT; - if ( nWinModCode & MK_CONTROL ) - aWheelEvt.mnCode |= KEY_MOD1; - if ( GetKeyState( VK_MENU ) & 0x8000 ) - aWheelEvt.mnCode |= KEY_MOD2; - - nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_WHEELMOUSE, &aWheelEvt ); - } - - ImplSalYieldMutexRelease(); -#endif - - return nRet; -} - -// ----------------------------------------------------------------------- - -static USHORT ImplSalGetKeyCode( WPARAM wParam ) -{ - USHORT nKeyCode; - - // convert KeyCode - if ( wParam < KEY_TAB_SIZE ) - nKeyCode = aImplTranslateKeyTab[wParam]; - else if ( wParam == aSalShlData.mnVKAdd ) - nKeyCode = KEY_ADD; - else if ( wParam == aSalShlData.mnVKSubtract ) - nKeyCode = KEY_SUBTRACT; - else if ( wParam == aSalShlData.mnVKMultiply ) - nKeyCode = KEY_MULTIPLY; - else if ( wParam == aSalShlData.mnVKDivide ) - nKeyCode = KEY_DIVIDE; - else if ( wParam == aSalShlData.mnVKPoint ) - nKeyCode = KEY_POINT; - else if ( wParam == aSalShlData.mnVKComma ) - nKeyCode = KEY_COMMA; - else if ( wParam == aSalShlData.mnVKLess ) - nKeyCode = KEY_LESS; - else if ( wParam == aSalShlData.mnVKGreater ) - nKeyCode = KEY_GREATER; - else if ( wParam == aSalShlData.mnVKEqual ) - nKeyCode = KEY_EQUAL; - else - nKeyCode = 0; - - return nKeyCode; -} - -// ----------------------------------------------------------------------- - -static UINT ImplStrToNum( const sal_Char* pStr ) -{ - USHORT n = 0; - - // Solange es sich um eine Ziffer handelt, String umwandeln - while( (*pStr >= 48) && (*pStr <= 57) ) - { - n *= 10; - n += ((*pStr) - 48); - pStr++; - } - - return n; -} - -// ----------------------------------------------------------------------- - -static sal_Unicode ImplGetCharCode( SalFrame* pFrame, WPARAM nCharCode ) -{ -#ifdef WIN - UINT nLang = LOWORD( GetKeyboardLayout( 0 ) ); - if ( !nLang ) - { - pFrame->maFrameData.mnInputLang = 0; - pFrame->maFrameData.mnInputCodePage = GetACP(); - } - else if ( nLang != pFrame->maFrameData.mnInputLang ) - { - pFrame->maFrameData.mnInputLang = nLang; - sal_Char aBuf[10]; - if ( GetLocaleInfoA( MAKELCID( nLang, SORT_DEFAULT ), LOCALE_IDEFAULTANSICODEPAGE, - aBuf, sizeof(aBuf) ) > 0 ) - { - pFrame->maFrameData.mnInputCodePage = ImplStrToNum( aBuf ); - if ( !pFrame->maFrameData.mnInputCodePage ) - pFrame->maFrameData.mnInputCodePage = GetACP(); - } - else - pFrame->maFrameData.mnInputCodePage = GetACP(); - } - - sal_Char aCharBuf[2]; - int nCharLen; - wchar_t c; - if ( nCharCode > 0xFF ) - { - aCharBuf[0] = (sal_Char)(nCharCode>>8); - aCharBuf[1] = (sal_Char)nCharCode; - nCharLen = 2; - } - else - { - aCharBuf[0] = (sal_Char)nCharCode; - nCharLen = 1; - } - if ( ::MultiByteToWideChar( pFrame->maFrameData.mnInputCodePage, - MB_PRECOMPOSED, - aCharBuf, nCharLen, &c, 1 ) ) - return (sal_Unicode)c; - else -#endif - return (sal_Unicode)nCharCode; -} - -// ----------------------------------------------------------------------- - -static long ImplHandleKeyMsg( VCLWINDOW hWnd, UINT nMsg, - WPARAM wParam, LPARAM lParam ) -{ -#ifdef WIN - static BOOL bIgnoreCharMsg = FALSE; - static WPARAM nDeadChar = 0; - static WPARAM nLastVKChar = 0; - static USHORT nLastChar = 0; - USHORT nRepeat = LOWORD( lParam )-1; - USHORT nModCode = 0; - - // Key wurde evtl. durch SysChild an uns weitergeleitet und - // darf somit dann nicht doppelt verarbeitet werden - GetSalData()->mnSalObjWantKeyEvt = 0; - - if ( nMsg == WM_DEADCHAR ) - { - nDeadChar = wParam; - return 0; - } - - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( !pFrame ) - return 0; - - // Wir restaurieren den Background-Modus bei jeder Texteingabe, - // da einige Tools wie RichWin uns diesen hin- und wieder umsetzen - if ( pFrame->maFrameData.mpGraphics && - pFrame->maFrameData.mpGraphics->maGraphicsData.mhDC ) - SetBkMode( pFrame->maFrameData.mpGraphics->maGraphicsData.mhDC, TRANSPARENT ); - - // determine modifiers - if ( GetKeyState( VK_SHIFT ) & 0x8000 ) - nModCode |= KEY_SHIFT; - if ( GetKeyState( VK_CONTROL ) & 0x8000 ) - nModCode |= KEY_MOD1; - if ( GetKeyState( VK_MENU ) & 0x8000 ) - { - nModCode |= KEY_MOD2; - if ( !(nModCode & KEY_MOD1) && - ((nMsg == WM_SYSKEYDOWN) || (nMsg == WM_SYSKEYUP)) ) - nModCode |= KEY_CONTROLMOD; - } - - if ( (nMsg == WM_CHAR) || (nMsg == WM_SYSCHAR) ) - { - nDeadChar = 0; - - if ( bIgnoreCharMsg ) - { - bIgnoreCharMsg = FALSE; - return 0; - } - - // Backspace ignorieren wir als eigenstaendige Taste, - // damit wir keine Probleme in Kombination mit einem - // DeadKey bekommen - if ( wParam == 0x08 ) // BACKSPACE - return 0; - - // Hier kommen nur "freifliegende" WM_CHAR Message an, die durch - // eintippen einer ALT-NUMPAD Kombination erzeugt wurden - SalKeyEvent aKeyEvt; - - if ( (wParam >= '0') && (wParam <= '9') ) - aKeyEvt.mnCode = KEYGROUP_NUM + wParam - '0'; - else if ( (wParam >= 'A') && (wParam <= 'Z') ) - aKeyEvt.mnCode = KEYGROUP_ALPHA + wParam - 'A'; - else if ( (wParam >= 'a') && (wParam <= 'z') ) - aKeyEvt.mnCode = KEYGROUP_ALPHA + wParam - 'a'; - else if ( wParam == 0x0D ) // RETURN - aKeyEvt.mnCode = KEY_RETURN; - else if ( wParam == 0x1B ) // ESCAPE - aKeyEvt.mnCode = KEY_ESCAPE; - else if ( wParam == 0x09 ) // TAB - aKeyEvt.mnCode = KEY_TAB; - else if ( wParam == 0x20 ) // SPACE - aKeyEvt.mnCode = KEY_SPACE; - else - aKeyEvt.mnCode = 0; - - aKeyEvt.mnTime = GetMessageTime(); - aKeyEvt.mnCode |= nModCode; - aKeyEvt.mnCharCode = ImplGetCharCode( pFrame, wParam ); - aKeyEvt.mnRepeat = nRepeat; - nLastChar = 0; - nLastVKChar = 0; - long nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_KEYINPUT, &aKeyEvt ); - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_KEYUP, &aKeyEvt ); - return nRet; - } - else - { - // Bei Shift, Control und Menu schicken wir einen KeyModChange-Event - if ( (wParam == VK_SHIFT) || (wParam == VK_CONTROL) || (wParam == VK_MENU) ) - { - SalKeyModEvent aModEvt; - aModEvt.mnTime = GetMessageTime(); - aModEvt.mnCode = nModCode; - return pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_KEYMODCHANGE, &aModEvt ); - } - else - { - SalKeyEvent aKeyEvt; - USHORT nEvent; - MSG aCharMsg; - WIN_BOOL bCharPeek = FALSE; - UINT nCharMsg = WM_CHAR; - BOOL bKeyUp = (nMsg == WM_KEYUP) || (nMsg == WM_SYSKEYUP); - - aKeyEvt.mnCode = ImplSalGetKeyCode( wParam ); - if ( !bKeyUp ) - { - // check for charcode - // Mit Hilfe von PeekMessage holen wir uns jetzt die - // zugehoerige WM_CHAR Message, wenn vorhanden. - // Diese WM_CHAR Message steht immer am Anfang der - // Messagequeue. Ausserdem ist sichergestellt, dass immer - // nur eine WM_CHAR Message in der Queue steht. - bCharPeek = ImplPeekMessage( &aCharMsg, hWnd, - WM_CHAR, WM_CHAR, PM_NOREMOVE | PM_NOYIELD ); - if ( bCharPeek && (nDeadChar == aCharMsg.wParam) ) - { - bCharPeek = FALSE; - nDeadChar = 0; - - if ( wParam == VK_BACK ) - { - ImplPeekMessage( &aCharMsg, hWnd, - nCharMsg, nCharMsg, PM_REMOVE | PM_NOYIELD ); - return 0; - } - } - else - { - if ( !bCharPeek ) - { - bCharPeek = ImplPeekMessage( &aCharMsg, hWnd, - WM_SYSCHAR, WM_SYSCHAR, PM_NOREMOVE | PM_NOYIELD ); - nCharMsg = WM_SYSCHAR; - } - } - if ( bCharPeek ) - aKeyEvt.mnCharCode = ImplGetCharCode( pFrame, aCharMsg.wParam ); - else - aKeyEvt.mnCharCode = 0; - - nLastChar = aKeyEvt.mnCharCode; - nLastVKChar = wParam; - } - else - { - if ( wParam == nLastVKChar ) - { - aKeyEvt.mnCharCode = nLastChar; - nLastChar = 0; - nLastVKChar = 0; - } - } - - if ( aKeyEvt.mnCode || aKeyEvt.mnCharCode ) - { - if ( bKeyUp ) - nEvent = SALEVENT_KEYUP; - else - nEvent = SALEVENT_KEYINPUT; - - aKeyEvt.mnTime = GetMessageTime(); - aKeyEvt.mnCode |= nModCode; - aKeyEvt.mnRepeat = nRepeat; - bIgnoreCharMsg = bCharPeek; - long nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - nEvent, &aKeyEvt ); - bIgnoreCharMsg = FALSE; - - // char-message, than remove or ignore - if ( bCharPeek ) - { - nDeadChar = 0; - if ( nRet ) - { - ImplPeekMessage( &aCharMsg, hWnd, - nCharMsg, nCharMsg, PM_REMOVE | PM_NOYIELD ); - } - else - bIgnoreCharMsg = TRUE; - } - - return nRet; - } - else - return 0; - } - } -#else - return 0; -#endif -} - -// ----------------------------------------------------------------------- - -long ImplHandleSalObjKeyMsg( VCLWINDOW hWnd, UINT nMsg, - WPARAM wParam, LPARAM lParam ) -{ -#ifdef WIN - if ( (nMsg == WM_KEYDOWN) || (nMsg == WM_KEYUP) ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( !pFrame ) - return 0; - - USHORT nRepeat = LOWORD( lParam )-1; - USHORT nModCode = 0; - - // determine modifiers - if ( GetKeyState( VK_SHIFT ) & 0x8000 ) - nModCode |= KEY_SHIFT; - if ( GetKeyState( VK_CONTROL ) & 0x8000 ) - nModCode |= KEY_MOD1; - if ( GetKeyState( VK_MENU ) & 0x8000 ) - { - nModCode |= KEY_MOD2; - if ( !(nModCode & KEY_MOD1) ) - nModCode |= KEY_CONTROLMOD; - } - - if ( (wParam != VK_SHIFT) && (wParam != VK_CONTROL) && (wParam != VK_MENU) ) - { - SalKeyEvent aKeyEvt; - USHORT nEvent; - BOOL bKeyUp = (nMsg == WM_KEYUP) || (nMsg == WM_SYSKEYUP); - - // convert KeyCode - aKeyEvt.mnCode = ImplSalGetKeyCode( wParam ); - aKeyEvt.mnCharCode = 0; - - if ( aKeyEvt.mnCode ) - { - if ( bKeyUp ) - nEvent = SALEVENT_KEYUP; - else - nEvent = SALEVENT_KEYINPUT; - - aKeyEvt.mnTime = GetMessageTime(); - aKeyEvt.mnCode |= nModCode; - aKeyEvt.mnRepeat = nRepeat; - long nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - nEvent, &aKeyEvt ); - return nRet; - } - else - return 0; - } - } -#endif - - return 0; -} - -// ----------------------------------------------------------------------- - -long ImplHandleSalObjSysCharMsg( VCLWINDOW hWnd, WPARAM wParam, LPARAM lParam ) -{ - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( !pFrame ) - return 0; - -#ifdef WIN - USHORT nRepeat = LOWORD( lParam )-1; - USHORT nModCode = 0; - USHORT cKeyCode = (USHORT)wParam; - - // determine modifiers - if ( GetKeyState( VK_SHIFT ) & 0x8000 ) - nModCode |= KEY_SHIFT; - if ( GetKeyState( VK_CONTROL ) & 0x8000 ) - nModCode |= KEY_MOD1; - nModCode |= KEY_MOD2; - if ( !(nModCode & KEY_MOD1) ) - nModCode |= KEY_CONTROLMOD; - - // KeyEvent zusammenbauen - SalKeyEvent aKeyEvt; - aKeyEvt.mnTime = GetMessageTime(); - if ( (cKeyCode >= 48) && (cKeyCode <= 57) ) - aKeyEvt.mnCode = KEY_0+(cKeyCode-48); - else if ( (cKeyCode >= 65) && (cKeyCode <= 90) ) - aKeyEvt.mnCode = KEY_A+(cKeyCode-65); - else if ( (cKeyCode >= 97) && (cKeyCode <= 122) ) - aKeyEvt.mnCode = KEY_A+(cKeyCode-97); - else - aKeyEvt.mnCode = 0; - aKeyEvt.mnCode |= nModCode; - aKeyEvt.mnCharCode = ImplGetCharCode( pFrame, cKeyCode ); - aKeyEvt.mnRepeat = nRepeat; - long nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_KEYINPUT, &aKeyEvt ); - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_KEYUP, &aKeyEvt ); - return nRet; -#else - return 0; -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplHandlePaintMsg( VCLWINDOW hWnd ) -{ - // Clip-Region muss zurueckgesetzt werden, da wir sonst kein - // ordentliches Bounding-Rectangle bekommen - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame && pFrame->maFrameData.mpGraphics ) - { -#ifdef WIN - if ( pFrame->maFrameData.mpGraphics->maGraphicsData.mhRegion ) - SelectClipRgn( pFrame->maFrameData.mpGraphics->maGraphicsData.mhDC, 0 ); -#endif - } - ImplSalYieldMutexRelease(); - } - -#ifdef WIN - // Laut Window-Doku soll man erst abfragen, ob ueberhaupt eine - // Paint-Region anliegt - if ( !GetUpdateRect( hWnd, NULL, FALSE ) ) - return; - - // BeginPaint - PAINTSTRUCT aPs; - BeginPaint( hWnd, &aPs ); - - // Paint - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - // ClipRegion wieder herstellen - if ( pFrame->maFrameData.mpGraphics ) - { - if ( pFrame->maFrameData.mpGraphics->maGraphicsData.mhRegion ) - { -#ifdef WIN - SelectClipRgn( pFrame->maFrameData.mpGraphics->maGraphicsData.mhDC, - pFrame->maFrameData.mpGraphics->maGraphicsData.mhRegion ); -#endif - } - } - - SalPaintEvent aPEvt; - aPEvt.mnBoundX = aPs.rcPaint.left; - aPEvt.mnBoundY = aPs.rcPaint.top; - aPEvt.mnBoundWidth = aPs.rcPaint.right-aPs.rcPaint.left; - aPEvt.mnBoundHeight = aPs.rcPaint.bottom-aPs.rcPaint.top; - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_PAINT, &aPEvt ); - } - - ImplSalYieldMutexRelease(); - } - else - { - RECT* pRect = new RECT; - *pRect = aPs.rcPaint; - ImplPostMessage( hWnd, SAL_MSG_POSTPAINT, (WPARAM)pRect, 0 ); - } - - // EndPaint - EndPaint( hWnd, &aPs ); -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplHandlePaintMsg2( VCLWINDOW hWnd, RECT* pRect ) -{ - // Paint - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - SalPaintEvent aPEvt; - aPEvt.mnBoundX = pRect->left; - aPEvt.mnBoundY = pRect->top; - aPEvt.mnBoundWidth = pRect->right-pRect->left; - aPEvt.mnBoundHeight = pRect->bottom-pRect->top; - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_PAINT, &aPEvt ); - } - ImplSalYieldMutexRelease(); - delete pRect; - } -#ifdef WIN - else - ImplPostMessage( hWnd, SAL_MSG_POSTPAINT, (WPARAM)pRect, 0 ); -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplHandleMoveMsg( VCLWINDOW hWnd ) -{ - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { -#ifdef WIN - if ( GetWindowStyle( hWnd ) & WS_VISIBLE ) - pFrame->maFrameData.mbDefPos = FALSE; -#endif - - // 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 ); - } - - ImplSalYieldMutexRelease(); - } -#ifdef WIN - else - ImplPostMessage( hWnd, SAL_MSG_POSTMOVE, 0, 0 ); -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplCallSizeHdl( VCLWINDOW hWnd ) -{ - // Da Windows diese Messages auch senden kann, muss hier auch die - // Solar-Semaphore beruecksichtigt werden - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_RESIZE, 0 ); -#ifdef WIN - // Um doppelte Paints von VCL und SAL zu vermeiden - if ( IsWindowVisible( hWnd ) && !pFrame->maFrameData.mbInShow ) - UpdateWindow( hWnd ); -#endif - } - - ImplSalYieldMutexRelease(); - } -#ifdef WIN - else - ImplPostMessage( hWnd, SAL_MSG_POSTCALLSIZE, 0, 0 ); -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplHandleSizeMsg( VCLWINDOW hWnd, WPARAM wParam, LPARAM lParam ) -{ -#ifdef WIN - if ( (wParam != SIZE_MAXSHOW) && (wParam != SIZE_MAXHIDE) ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - pFrame->maFrameData.mnWidth = (int)LOWORD(lParam); - pFrame->maFrameData.mnHeight = (int)HIWORD(lParam); - // Status merken - ImplSaveFrameState( pFrame ); - // Call Hdl - ImplCallSizeHdl( hWnd ); - } - } -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplHandleFocusMsg( VCLWINDOW hWnd ) -{ -#ifdef WIN - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - // Query the actual status - if ( ::GetFocus() == hWnd ) - { - if ( IsWindowVisible( hWnd ) && !pFrame->maFrameData.mbInShow ) - UpdateWindow( hWnd ); - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_GETFOCUS, 0 ); - } - else - { - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_LOSEFOCUS, 0 ); - } - } - - ImplSalYieldMutexRelease(); - } - else - ImplPostMessage( hWnd, SAL_MSG_POSTFOCUS, 0, 0 ); -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplHandleCloseMsg( VCLWINDOW hWnd ) -{ - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_CLOSE, 0 ); - } - - ImplSalYieldMutexRelease(); - } -#ifdef WIN - else - ImplPostMessage( hWnd, WM_CLOSE, 0, 0 ); -#endif -} - -// ----------------------------------------------------------------------- - -static long ImplHandleShutDownMsg( VCLWINDOW hWnd ) -{ - ImplSalYieldMutexAcquireWithWait(); - long nRet = 0; - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - nRet = pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_SHUTDOWN, 0 ); - } - ImplSalYieldMutexRelease(); - return nRet; -} - -// ----------------------------------------------------------------------- - -static void ImplHandleSettingsChangeMsg( VCLWINDOW hWnd, UINT nMsg, - WPARAM wParam, LPARAM lParam ) -{ -#ifdef WIN - USHORT nSalEvent = SALEVENT_SETTINGSCHANGED; - - if ( nMsg == WM_DEVMODECHANGE ) - nSalEvent = SALEVENT_PRINTERCHANGED; - else if ( nMsg == WM_DISPLAYCHANGE ) - nSalEvent = SALEVENT_DISPLAYCHANGED; - else if ( nMsg == WM_FONTCHANGE ) - nSalEvent = SALEVENT_FONTCHANGED; - else if ( nMsg == WM_TIMECHANGE ) - nSalEvent = SALEVENT_DATETIMECHANGED; - else if ( nMsg == WM_WININICHANGE ) - { - if ( lParam ) - { - if ( aSalShlData.mbWNT ) - { - if ( ImplSalWICompareAscii( (const wchar_t*)lParam, "devices" ) == 0 ) - nSalEvent = SALEVENT_PRINTERCHANGED; - } - else - { - if ( stricmp( (const char*)lParam, "devices" ) == 0 ) - nSalEvent = SALEVENT_PRINTERCHANGED; - } - } - } - - if ( nMsg == WM_SETTINGCHANGE ) - { - if ( wParam == SPI_SETWHEELSCROLLLINES ) - aSalShlData.mnWheelScrollLines = ImplSalGetWheelScrollLines(); - } - - if ( WM_SYSCOLORCHANGE == nMsg && GetSalData()->mhDitherPal ) - ImplUpdateSysColorEntries(); - - ImplSalYieldMutexAcquireWithWait(); - - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - if ( (nMsg == WM_DISPLAYCHANGE) || (nMsg == WM_WININICHANGE) ) - { - if ( pFrame->maFrameData.mbFullScreen ) - ImplSalFrameFullScreenPos( pFrame ); - } - - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - nSalEvent, 0 ); - } - - ImplSalYieldMutexRelease(); -#endif -} - -// ----------------------------------------------------------------------- - -static void ImplHandleUserEvent( VCLWINDOW hWnd, LPARAM lParam ) -{ - ImplSalYieldMutexAcquireWithWait(); - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_USEREVENT, (void*)lParam ); - } - ImplSalYieldMutexRelease(); -} - -// ----------------------------------------------------------------------- - -static void ImplHandleForcePalette( VCLWINDOW hWnd ) -{ - SalData* pSalData = GetSalData(); - HPALETTE hPal = pSalData->mhDitherPal; - if ( hPal ) - { - if ( !ImplSalYieldMutexTryToAcquire() ) - { -#ifdef WIN - ImplPostMessage( hWnd, SAL_MSG_FORCEPALETTE, 0, 0 ); -#endif - return; - } - - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame && pFrame->maFrameData.mpGraphics ) - { - SalGraphics* pGraphics = pFrame->maFrameData.mpGraphics; - if ( pGraphics && pGraphics->maGraphicsData.mhDefPal ) - { -#ifdef WIN - SelectPalette( pGraphics->maGraphicsData.mhDC, hPal, FALSE ); - if ( RealizePalette( pGraphics->maGraphicsData.mhDC ) ) - { - InvalidateRect( hWnd, NULL, FALSE ); - UpdateWindow( hWnd ); - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_DISPLAYCHANGED, 0 ); - } -#endif - } - } - - ImplSalYieldMutexRelease(); - } -} - -// ----------------------------------------------------------------------- - -static LRESULT ImplHandlePalette( BOOL bFrame, VCLWINDOW hWnd, UINT nMsg, - WPARAM wParam, LPARAM lParam, int& rDef ) -{ - SalData* pSalData = GetSalData(); - HPALETTE hPal = pSalData->mhDitherPal; - if ( !hPal ) - return 0; - - rDef = FALSE; - if ( pSalData->mbInPalChange ) - return 0; -#ifdef WIN - if ( (nMsg == WM_PALETTECHANGED) || (nMsg == SAL_MSG_POSTPALCHANGED) ) - { - if ( (VCLWINDOW)wParam == hWnd ) - return 0; - } - - BOOL bReleaseMutex = FALSE; - if ( (nMsg == WM_QUERYNEWPALETTE) || (nMsg == WM_PALETTECHANGED) ) - { - // Da Windows diese Messages auch sendet, muss hier auch die - // Solar-Semaphore beruecksichtigt werden - if ( ImplSalYieldMutexTryToAcquire() ) - bReleaseMutex = TRUE; - else if ( nMsg == WM_QUERYNEWPALETTE ) - ImplPostMessage( hWnd, SAL_MSG_POSTQUERYNEWPAL, wParam, lParam ); - else /* ( nMsg == WM_PALETTECHANGED ) */ - ImplPostMessage( hWnd, SAL_MSG_POSTPALCHANGED, wParam, lParam ); - } - - SalVirtualDevice* pTempVD; - SalFrame* pTempFrame; - SalGraphics* pGraphics; - VCLVIEW hDC; - HPALETTE hOldPal; - UINT nCols; - BOOL bStdDC; - BOOL bUpdate; - - pSalData->mbInPalChange = TRUE; - - // Alle Paletten in VirDevs und Frames zuruecksetzen - pTempVD = pSalData->mpFirstVD; - while ( pTempVD ) - { - pGraphics = pTempVD->maVirDevData.mpGraphics; - if ( pGraphics->maGraphicsData.mhDefPal ) - { - SelectPalette( pGraphics->maGraphicsData.mhDC, - pGraphics->maGraphicsData.mhDefPal, - TRUE ); - } - pTempVD = pTempVD->maVirDevData.mpNext; - } - pTempFrame = pSalData->mpFirstFrame; - while ( pTempFrame ) - { - pGraphics = pTempFrame->maFrameData.mpGraphics; - if ( pGraphics && pGraphics->maGraphicsData.mhDefPal ) - { - SelectPalette( pGraphics->maGraphicsData.mhDC, - pGraphics->maGraphicsData.mhDefPal, - TRUE ); - } - pTempFrame = pTempFrame->maFrameData.mpNextFrame; - } - - // Palette neu realizen - SalFrame* pFrame = NULL; - if ( bFrame ) - pFrame = GetWindowPtr( hWnd ); - if ( pFrame && pFrame->maFrameData.mpGraphics ) - { - hDC = pFrame->maFrameData.mpGraphics->maGraphicsData.mhDC; - bStdDC = TRUE; - } - else - { - hDC = GetDC( hWnd ); - bStdDC = FALSE; - } - UnrealizeObject( hPal ); - hOldPal = SelectPalette( hDC, hPal, TRUE ); - nCols = RealizePalette( hDC ); - bUpdate = nCols != 0; - if ( !bStdDC ) - { - SelectPalette( hDC, hOldPal, TRUE ); - ReleaseDC( hWnd, hDC ); - } - - // Alle Paletten in VirDevs und Frames neu setzen - pTempVD = pSalData->mpFirstVD; - while ( pTempVD ) - { - pGraphics = pTempVD->maVirDevData.mpGraphics; - if ( pGraphics->maGraphicsData.mhDefPal ) - { - SelectPalette( pGraphics->maGraphicsData.mhDC, hPal, TRUE ); - RealizePalette( pGraphics->maGraphicsData.mhDC ); - } - pTempVD = pTempVD->maVirDevData.mpNext; - } - pTempFrame = pSalData->mpFirstFrame; - while ( pTempFrame ) - { - if ( pTempFrame != pFrame ) - { - pGraphics = pTempFrame->maFrameData.mpGraphics; - if ( pGraphics && pGraphics->maGraphicsData.mhDefPal ) - { - SelectPalette( pGraphics->maGraphicsData.mhDC, hPal, TRUE ); - if ( RealizePalette( pGraphics->maGraphicsData.mhDC ) ) - bUpdate = TRUE; - } - } - pTempFrame = pTempFrame->maFrameData.mpNextFrame; - } - - // Wenn sich Farben geaendert haben, dann die Fenster updaten - if ( bUpdate ) - { - pTempFrame = pSalData->mpFirstFrame; - while ( pTempFrame ) - { - pGraphics = pTempFrame->maFrameData.mpGraphics; - if ( pGraphics && pGraphics->maGraphicsData.mhDefPal ) - { - InvalidateRect( pTempFrame->maFrameData.mhWnd, NULL, FALSE ); - UpdateWindow( pTempFrame->maFrameData.mhWnd ); - pTempFrame->maFrameData.mpProc( pTempFrame->maFrameData.mpInst, pTempFrame, - SALEVENT_DISPLAYCHANGED, 0 ); - } - pTempFrame = pTempFrame->maFrameData.mpNextFrame; - } - } - - pSalData->mbInPalChange = FALSE; - - if ( bReleaseMutex ) - ImplSalYieldMutexRelease(); - - if ( nMsg == WM_PALETTECHANGED ) - return 0; - else - return nCols; -#else - return 0; -#endif -} - -// ----------------------------------------------------------------------- - -static int ImplHandleMinMax( VCLWINDOW hWnd, LPARAM lParam ) -{ - int bRet = FALSE; - - if ( ImplSalYieldMutexTryToAcquire() ) - { - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - if ( pFrame->maFrameData.mbFullScreen ) - { -#ifdef WIN - MINMAXINFO* pMinMax = (MINMAXINFO*)lParam; - int nX; - int nY; - int nDX; - int nDY; - ImplSalCalcFullScreenSize( pFrame, nX, nY, nDX, nDY ); - - if ( pMinMax->ptMaxPosition.x > nX ) - pMinMax->ptMaxPosition.x = nX; - if ( pMinMax->ptMaxPosition.y > nY ) - pMinMax->ptMaxPosition.y = nY; - - if ( pMinMax->ptMaxSize.x < nDX ) - pMinMax->ptMaxSize.x = nDX; - if ( pMinMax->ptMaxSize.y < nDY ) - pMinMax->ptMaxSize.y = nDY; - if ( pMinMax->ptMaxTrackSize.x < nDX ) - pMinMax->ptMaxTrackSize.x = nDX; - if ( pMinMax->ptMaxTrackSize.y < nDY ) - pMinMax->ptMaxTrackSize.y = nDY; - - pMinMax->ptMinTrackSize.x = nDX; - pMinMax->ptMinTrackSize.y = nDY; - - bRet = TRUE; -#endif - } - } - - ImplSalYieldMutexRelease(); - } - - return bRet; -} - -// ----------------------------------------------------------------------- - -static int ImplHandleSysCommand( VCLWINDOW hWnd, WPARAM wParam, LPARAM lParam ) -{ - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( !pFrame ) - return 0; - - WPARAM nCommand = wParam & 0xFFF0; - -#ifdef WIN - if ( pFrame->maFrameData.mbFullScreen ) - { - WIN_BOOL bMaximize = IsZoomed( pFrame->maFrameData.mhWnd ); - WIN_BOOL bMinimize = IsIconic( pFrame->maFrameData.mhWnd ); - if ( (nCommand == SC_SIZE) || - (!bMinimize && (nCommand == SC_MOVE)) || - (!bMaximize && (nCommand == SC_MAXIMIZE)) || - (bMaximize && (nCommand == SC_RESTORE)) ) - { - MessageBeep( 0 ); - return TRUE; - } - } - - if ( nCommand == SC_KEYMENU ) - { - // Hier verarbeiten wir nur KeyMenu-Events fuer Alt um - // den MenuBar zu aktivieren, oder wenn ein SysChild-Fenster - // den Focus hat, da diese Alt+Tasten-Kombinationen nur - // ueber diesen Event verarbeitet werden - if ( !LOWORD( lParam ) ) - { - // Nur ausloesen, wenn keine weitere Taste gedrueckt ist. Im - // Gegensatz zur Doku wird in der X-Koordinaate der CharCode - // geliefert, der zusaetzlich gedrueckt ist - // Also 32 fuer Space, 99 fuer c, 100 fuer d, ... - // Da dies nicht dokumentiert ist, fragen wir vorsichtshalber - // auch den Status der Space-Taste ab - if ( GetKeyState( VK_SPACE ) & 0x8000 ) - return 0; - - // Damit nicht bei Alt+Maustaste auch der MenuBar aktiviert wird - if ( (GetKeyState( VK_LBUTTON ) & 0x8000) || - (GetKeyState( VK_RBUTTON ) & 0x8000) || - (GetKeyState( VK_MBUTTON ) & 0x8000) ) - return 1; - - SalKeyEvent aKeyEvt; - aKeyEvt.mnTime = GetMessageTime(); - 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 ); - return (nRet != 0); - } - else - { - // Testen, ob ein SysChild den Focus hat - VCLWINDOW hFocusWnd = ::GetFocus(); - if ( hFocusWnd && ImplFindSalObject( hFocusWnd ) ) - { - char cKeyCode = (char)(unsigned char)LOWORD( lParam ); - // LowerCase - if ( (cKeyCode >= 65) && (cKeyCode <= 90) ) - cKeyCode += 32; - // Wir nehmen nur 0-9 und A-Z, alle anderen Tasten muessen durch - // den Hook vom SalObj verarbeitet werden - if ( ((cKeyCode >= 48) && (cKeyCode <= 57)) || - ((cKeyCode >= 97) && (cKeyCode <= 122)) ) - { - USHORT nModCode = 0; - if ( GetKeyState( VK_SHIFT ) & 0x8000 ) - nModCode |= KEY_SHIFT; - if ( GetKeyState( VK_CONTROL ) & 0x8000 ) - nModCode |= KEY_MOD1; - nModCode |= KEY_MOD2; - if ( !(nModCode & KEY_MOD1) ) - nModCode |= KEY_CONTROLMOD; - - SalKeyEvent aKeyEvt; - aKeyEvt.mnTime = GetMessageTime(); - if ( (cKeyCode >= 48) && (cKeyCode <= 57) ) - aKeyEvt.mnCode = KEY_0+(cKeyCode-48); - else - aKeyEvt.mnCode = KEY_A+(cKeyCode-97); - aKeyEvt.mnCode |= nModCode; - aKeyEvt.mnCharCode = cKeyCode; - 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 ); - return (nRet != 0); - } - } - } - } -#endif - - return FALSE; -} - -// ----------------------------------------------------------------------- - -static void ImplHandleInputLangChange( VCLWINDOW hWnd, WPARAM wParam, LPARAM lParam ) -{ - ImplSalYieldMutexAcquireWithWait(); - - // Feststellen, ob wir IME unterstuetzen - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame && pFrame->maFrameData.mbIME && pFrame->maFrameData.mhDefIMEContext ) - { -#ifdef WIN - VCLWINDOW hWnd = pFrame->maFrameData.mhWnd; - HKL hKL = (HKL)lParam; - UINT nImeProps = ImmGetProperty( hKL, IGP_PROPERTY ); - - pFrame->maFrameData.mbSpezIME = (nImeProps & IME_PROP_SPECIAL_UI) != 0; - pFrame->maFrameData.mbAtCursorIME = (nImeProps & IME_PROP_AT_CARET) != 0; - pFrame->maFrameData.mbHandleIME = !pFrame->maFrameData.mbSpezIME; -#endif - } - - ImplSalYieldMutexRelease(); -} - -// ----------------------------------------------------------------------- - -static BOOL ImplHandleIMEStartComposition( VCLWINDOW hWnd ) -{ - BOOL bDef = TRUE; - - ImplSalYieldMutexAcquireWithWait(); - - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - { - if ( pFrame->maFrameData.mbHandleIME ) - { -#ifdef WIN - HIMC hIMC = ImmGetContext( hWnd ); - if ( hIMC ) - { - // 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 - - ImmReleaseContext( hWnd, hIMC ); - } - - pFrame->maFrameData.mbCompositionMode = TRUE; - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_STARTEXTTEXTINPUT, (void*)NULL ); - if ( pFrame->maFrameData.mbAtCursorIME ) - bDef = FALSE; -#endif - } - } - - ImplSalYieldMutexRelease(); - - return bDef; -} - -// ----------------------------------------------------------------------- - -static BOOL ImplHandleIMEComposition( VCLWINDOW hWnd, LPARAM lParam ) -{ - BOOL bDef = TRUE; -#ifdef WIN - if ( lParam & (GCS_RESULTSTR | GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS) ) - { - ImplSalYieldMutexAcquireWithWait(); - - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame && pFrame->maFrameData.mbHandleIME && - (pFrame->maFrameData.mbCompositionMode || !(lParam & GCS_RESULTSTR)) ) - { - HIMC hIMC = ImmGetContext( hWnd ); - if ( hIMC ) - { - SalExtTextInputEvent aEvt; - aEvt.mnTime = GetMessageTime(); - aEvt.mpTextAttr = NULL; - aEvt.mnCursorPos = 0; - aEvt.mnDeltaStart = 0; - aEvt.mbOnlyCursor = FALSE; - aEvt.mbCursorVisible = !pFrame->maFrameData.mbCandidateMode; - - LONG nTextLen; - xub_Unicode* pTextBuf = NULL; - LONG nAttrLen; - WIN_BYTE* pAttrBuf = NULL; - BOOL bLastCursor = FALSE; - if ( lParam & GCS_RESULTSTR ) - { - nTextLen = ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, 0, 0 ) / sizeof( wchar_t ); - if ( nTextLen >= 0 ) - { - pTextBuf = new xub_Unicode[nTextLen]; - ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, pTextBuf, nTextLen*sizeof( wchar_t ) ); - } - - bLastCursor = TRUE; - aEvt.mbCursorVisible = TRUE; - bDef = FALSE; - } - else if ( pFrame->maFrameData.mbAtCursorIME ) - { - bDef = FALSE; - if ( lParam & (GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS) ) - { - nTextLen = ImmGetCompositionStringW( hIMC, GCS_COMPSTR, 0, 0 ) / sizeof( wchar_t ); - if ( nTextLen >= 0 ) - { - pTextBuf = new xub_Unicode[nTextLen]; - ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf, nTextLen*sizeof( wchar_t ) ); - } - - nAttrLen = ImmGetCompositionStringW( hIMC, GCS_COMPATTR, 0, 0 ); - if ( nAttrLen >= 0 ) - { - pAttrBuf = new WIN_BYTE[nAttrLen]; - ImmGetCompositionStringW( hIMC, GCS_COMPATTR, pAttrBuf, nAttrLen ); - } - - aEvt.mnCursorPos = LOWORD( ImmGetCompositionStringW( hIMC, GCS_CURSORPOS, 0, 0 ) ); - aEvt.mnDeltaStart = LOWORD( ImmGetCompositionStringW( hIMC, GCS_DELTASTART, 0, 0 ) ); - - if ( lParam == GCS_CURSORPOS ) - aEvt.mbOnlyCursor = TRUE; - } - } - - USHORT* pSalAttrAry = NULL; - if ( pTextBuf ) - { - aEvt.maText = XubString( pTextBuf, (USHORT)nTextLen ); - delete pTextBuf; - if ( pAttrBuf ) - { - xub_StrLen nTextLen = aEvt.maText.Len(); - if ( nTextLen ) - { - pSalAttrAry = new USHORT[nTextLen]; - memset( pSalAttrAry, 0, nTextLen*sizeof( USHORT ) ); - for ( xub_StrLen i = 0; (i < nTextLen) && (i < nAttrLen); i++ ) - { - WIN_BYTE nWinAttr = pAttrBuf[i]; - USHORT nSalAttr; - if ( nWinAttr == ATTR_TARGET_CONVERTED ) - { - nSalAttr = SAL_EXTTEXTINPUT_ATTR_TARGETCONVERTED | SAL_EXTTEXTINPUT_ATTR_UNDERLINE | SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT; - aEvt.mbCursorVisible = FALSE; - } - else if ( nWinAttr == ATTR_CONVERTED ) - nSalAttr = SAL_EXTTEXTINPUT_ATTR_CONVERTED | SAL_EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE; - else if ( nWinAttr == ATTR_TARGET_NOTCONVERTED ) - nSalAttr = SAL_EXTTEXTINPUT_ATTR_TARGETNOTCONVERTED | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE; - else if ( nWinAttr == ATTR_INPUT_ERROR ) - nSalAttr = SAL_EXTTEXTINPUT_ATTR_INPUTERROR | SAL_EXTTEXTINPUT_ATTR_REDTEXT | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE; - else /* ( nWinAttr == 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(); - } - - ImmReleaseContext( hWnd, hIMC ); - - // Handler rufen und wenn wir ein Attribute-Array haben, danach - // wieder zerstoeren - if ( !bDef ) - { - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_EXTTEXTINPUT, (void*)&aEvt ); - } - if ( pSalAttrAry ) - delete pSalAttrAry; - } - - ImplSalYieldMutexRelease(); - } - } -#endif - - return bDef; -} - -// ----------------------------------------------------------------------- - -static BOOL ImplHandleIMEEndComposition( VCLWINDOW hWnd ) -{ - BOOL bDef = TRUE; - - ImplSalYieldMutexAcquireWithWait(); - - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame && pFrame->maFrameData.mbHandleIME ) - { -#ifdef WIN - // Wir restaurieren den Background-Modus bei jeder Texteingabe, - // da einige Tools wie RichWin uns diesen hin- und wieder umsetzen - if ( pFrame->maFrameData.mpGraphics && - pFrame->maFrameData.mpGraphics->maGraphicsData.mhDC ) - SetBkMode( pFrame->maFrameData.mpGraphics->maGraphicsData.mhDC, TRANSPARENT ); - - pFrame->maFrameData.mbCompositionMode = FALSE; - pFrame->maFrameData.mpProc( pFrame->maFrameData.mpInst, pFrame, - SALEVENT_ENDEXTTEXTINPUT, (void*)NULL ); - if ( pFrame->maFrameData.mbAtCursorIME ) - bDef = FALSE; -#endif - } - - ImplSalYieldMutexRelease(); - - return bDef; -} - -// ----------------------------------------------------------------------- - -static void ImplHandleIMENotify( VCLWINDOW hWnd, WPARAM wParam ) -{ - if ( wParam == (WPARAM)IMN_OPENCANDIDATE ) - { - ImplSalYieldMutexAcquireWithWait(); - - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame && pFrame->maFrameData.mbHandleIME && - pFrame->maFrameData.mbAtCursorIME ) - { -#ifdef WIN - // Wir wollen den Cursor hiden - pFrame->maFrameData.mbCandidateMode = TRUE; - ImplHandleIMEComposition( hWnd, GCS_CURSORPOS ); - - VCLWINDOW hWnd = pFrame->maFrameData.mhWnd; - HIMC hIMC = ImmGetContext( hWnd ); - if ( hIMC ) - { - LONG nBufLen = ImmGetCompositionStringW( hIMC, GCS_COMPSTR, 0, 0 ); - if ( nBufLen >= 1 ) - { - USHORT nCursorPos = LOWORD( ImmGetCompositionStringW( hIMC, GCS_CURSORPOS, 0, 0 ) ); - SalExtTextInputPosEvent aEvt; - aEvt.mnTime = GetMessageTime(); - aEvt.mnFirstPos = nCursorPos; - aEvt.mnChars = nBufLen/sizeof(sal_Unicode) - 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; - } - - CANDIDATEFORM aForm; - aForm.dwIndex = 0; - aForm.dwStyle = CFS_EXCLUDE; - aForm.ptCurrentPos.x = aEvt.mpPosAry[0].mnX; - aForm.ptCurrentPos.y = nMaxBottom+1; - aForm.rcArea.left = nMinLeft; - aForm.rcArea.top = nMinTop; - aForm.rcArea.right = nMaxRight+1; - aForm.rcArea.bottom = nMaxBottom+1; - ImmSetCandidateWindow( hIMC, &aForm ); - - delete aEvt.mpPosAry; - } - - ImmReleaseContext( hWnd, hIMC ); - } -#endif - } - - ImplSalYieldMutexRelease(); - } - else if ( wParam == (WPARAM)IMN_CLOSECANDIDATE ) - { - ImplSalYieldMutexAcquireWithWait(); - SalFrame* pFrame = GetWindowPtr( hWnd ); - if ( pFrame ) - pFrame->maFrameData.mbCandidateMode = FALSE; - ImplSalYieldMutexRelease(); - } -} - - -// ----------------------------------------------------------------------- - -void SalTestMouseLeave() -{ - SalData* pSalData = GetSalData(); - -#ifdef WIN - if ( pSalData->mhWantLeaveMsg && !::GetCapture() ) - { - POINT aPt; - GetCursorPos( &aPt ); - if ( pSalData->mhWantLeaveMsg != WindowFromPoint( aPt ) ) - ImplSendMessage( pSalData->mhWantLeaveMsg, SAL_MSG_MOUSELEAVE, 0, MAKELPARAM( aPt.x, aPt.y ) ); - } -#endif -} - -// ----------------------------------------------------------------------- - -static int ImplSalWheelMousePos( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, - LPARAM lParam, LRESULT& rResult ) -{ -#ifdef WIN - POINT aPt; - POINT aScreenPt; - aScreenPt.x = (short)LOWORD( lParam ); - aScreenPt.y = (short)HIWORD( lParam ); - // Child-Fenster suchen, welches an der entsprechenden - // Position liegt - VCLWINDOW hChildWnd; - VCLWINDOW hWheelWnd = hWnd; - do - { - hChildWnd = hWheelWnd; - aPt = aScreenPt; - ScreenToClient( hChildWnd, &aPt ); - hWheelWnd = ChildWindowFromPointEx( hChildWnd, aPt, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT ); - } - while ( hWheelWnd && (hWheelWnd != hChildWnd) ); - if ( hWheelWnd && (hWheelWnd != hWnd) && - (hWheelWnd != ::GetFocus()) && IsWindowEnabled( hWheelWnd ) ) - { - rResult = ImplSendMessage( hWheelWnd, nMsg, wParam, lParam ); - return FALSE; - } -#endif - - return TRUE; -} - -// ----------------------------------------------------------------------- - -LRESULT CALLBACK SalFrameWndProc( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef ) -{ - LRESULT nRet = 0; -#ifdef WIN - static int bInWheelMsg = FALSE; - - // By WM_CRETAE we connect the frame with the window handle - if ( nMsg == WM_CREATE ) - { - // Window-Instanz am Windowhandle speichern - // Can also be used for the W-Version, because the struct - // to access lpCreateParams is the same structure - CREATESTRUCTA* pStruct = (CREATESTRUCTA*)lParam; - SalFrame* pFrame = (SalFrame*)pStruct->lpCreateParams; - SetWindowPtr( hWnd, pFrame ); - // VCLWINDOW schon hier setzen, da schon auf den Instanzdaten - // gearbeitet werden kann, wenn Messages waehrend - // CreateWindow() gesendet werden - pFrame->maFrameData.mhWnd = hWnd; - pFrame->maFrameData.maSysData.hWnd = hWnd; - return 0; - } - - switch( nMsg ) - { - case WM_MOUSEMOVE: - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - case WM_NCMOUSEMOVE: - case SAL_MSG_MOUSELEAVE: - ImplSalYieldMutexAcquireWithWait(); - rDef = !ImplHandleMouseMsg( hWnd, nMsg, wParam, lParam ); - ImplSalYieldMutexRelease(); - break; - - case WM_MOUSEACTIVATE: - if ( LOWORD( lParam ) == HTCLIENT ) - { - ImplSalYieldMutexAcquireWithWait(); - nRet = ImplHandleMouseActivateMsg( hWnd ); - ImplSalYieldMutexRelease(); - if ( nRet ) - { - nRet = MA_NOACTIVATE; - rDef = FALSE; - } - } - break; - - case WM_KEYDOWN: - case WM_KEYUP: - case WM_DEADCHAR: - case WM_CHAR: - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - case WM_SYSCHAR: - ImplSalYieldMutexAcquireWithWait(); - rDef = !ImplHandleKeyMsg( hWnd, nMsg, wParam, lParam ); - ImplSalYieldMutexRelease(); - break; - - case WM_MOUSEWHEEL: - // Gegen Rekursion absichern, falls wir vom IE oder dem externen - // Fenster die Message wieder zurueckbekommen - if ( !bInWheelMsg ) - { - bInWheelMsg++; - rDef = !ImplHandleWheelMsg( hWnd, wParam, lParam ); - // Wenn wir die Message nicht ausgewertet haben, schauen wir - // noch einmal nach, ob dort ein geplugtes Fenster steht, - // welches wir dann benachrichtigen - if ( rDef ) - rDef = ImplSalWheelMousePos( hWnd, nMsg, wParam, lParam, nRet ); - bInWheelMsg--; - } - break; - - case WM_SYSCOMMAND: - ImplSalYieldMutexAcquireWithWait(); - nRet = ImplHandleSysCommand( hWnd, wParam, lParam ); - ImplSalYieldMutexRelease(); - if ( nRet ) - rDef = FALSE; - break; - - case WM_MOVE: - case SAL_MSG_POSTMOVE: - ImplHandleMoveMsg( hWnd ); - rDef = FALSE; - break; - case WM_SIZE: - ImplHandleSizeMsg( hWnd, wParam, lParam ); - rDef = FALSE; - break; - case SAL_MSG_POSTCALLSIZE: - ImplCallSizeHdl( hWnd ); - rDef = FALSE; - break; - - case WM_GETMINMAXINFO: - if ( ImplHandleMinMax( hWnd, lParam ) ) - rDef = FALSE; - break; - - case WM_ERASEBKGND: - nRet = 1; - rDef = FALSE; - break; - case WM_PAINT: - ImplHandlePaintMsg( hWnd ); - rDef = FALSE; - break; - case SAL_MSG_POSTPAINT: - ImplHandlePaintMsg2( hWnd, (RECT*)wParam ); - rDef = FALSE; - break; - - case SAL_MSG_FORCEPALETTE: - ImplHandleForcePalette( hWnd ); - rDef = FALSE; - break; - - case WM_QUERYNEWPALETTE: - case SAL_MSG_POSTQUERYNEWPAL: - nRet = ImplHandlePalette( TRUE, hWnd, nMsg, wParam, lParam, rDef ); - break; - - case WM_ACTIVATE: - // Wenn wir aktiviert werden, dann wollen wir auch unsere - // Palette setzen. Wir machen dieses in Activate, - // damit andere externe Child-Fenster auch unsere Palette - // ueberschreiben koennen. So wird unsere jedenfalls nur einmal - // gesetzt und nicht immer rekursiv, da an allen anderen Stellen - // diese nur als Background-Palette gesetzt wird - if ( LOWORD( wParam ) != WA_INACTIVE ) - ImplSendMessage( hWnd, SAL_MSG_FORCEPALETTE, 0, 0 ); - break; - - case WM_SETFOCUS: - case WM_KILLFOCUS: - case SAL_MSG_POSTFOCUS: - ImplHandleFocusMsg( hWnd ); - rDef = FALSE; - break; - - case WM_CLOSE: - ImplHandleCloseMsg( hWnd ); - rDef = FALSE; - break; - - case WM_QUERYENDSESSION: - nRet = !ImplHandleShutDownMsg( hWnd ); - rDef = FALSE; - break; - - case WM_DISPLAYCHANGE: - case WM_SETTINGCHANGE: - case WM_DEVMODECHANGE: - case WM_FONTCHANGE: - case WM_SYSCOLORCHANGE: - case WM_TIMECHANGE: - ImplHandleSettingsChangeMsg( hWnd, nMsg, wParam, lParam ); - break; - - case SAL_MSG_USEREVENT: - ImplHandleUserEvent( hWnd, lParam ); - rDef = FALSE; - break; - - case SAL_MSG_CAPTUREMOUSE: - SetCapture( hWnd ); - rDef = FALSE; - break; - case SAL_MSG_RELEASEMOUSE: - if ( ::GetCapture() == hWnd ) - ReleaseCapture(); - rDef = FALSE; - break; - case SAL_MSG_TOTOP: - ImplSalToTop( hWnd, (USHORT)wParam ); - rDef = FALSE; - break; - case SAL_MSG_SHOW: - ImplSalShow( hWnd, (BOOL)wParam ); - rDef = FALSE; - break; - - case WM_INPUTLANGCHANGE: - ImplHandleInputLangChange( hWnd, wParam, lParam ); - break; - - case WM_IME_STARTCOMPOSITION: - rDef = ImplHandleIMEStartComposition( hWnd ); - break; - - case WM_IME_COMPOSITION: - rDef = ImplHandleIMEComposition( hWnd, lParam ); - break; - - case WM_IME_ENDCOMPOSITION: - rDef = ImplHandleIMEEndComposition( hWnd ); - break; - - case WM_IME_NOTIFY: - ImplHandleIMENotify( hWnd, wParam ); - break; - } - - // WheelMouse-Message abfangen - if ( rDef && (nMsg == aSalShlData.mnWheelMsgId) && aSalShlData.mnWheelMsgId ) - { - // Gegen Rekursion absichern, falls wir vom IE oder dem externen - // Fenster die Message wieder zurueckbekommen - if ( !bInWheelMsg ) - { - bInWheelMsg++; - // Zuerst wollen wir die Message dispatchen und dann darf auch - // das SystemWindow drankommen - WORD nKeyState = 0; - if ( GetKeyState( VK_SHIFT ) & 0x8000 ) - nKeyState |= MK_SHIFT; - if ( GetKeyState( VK_CONTROL ) & 0x8000 ) - nKeyState |= MK_CONTROL; - // Mutex handling is inside from this call - rDef = !ImplHandleWheelMsg( hWnd, MAKEWPARAM( nKeyState, (WORD)wParam ), lParam ); - if ( rDef ) - { - VCLWINDOW hWheelWnd = ::GetFocus(); - if ( hWheelWnd && (hWheelWnd != hWnd) ) - { - nRet = ImplSendMessage( hWheelWnd, nMsg, wParam, lParam ); - rDef = FALSE; - } - else - rDef = ImplSalWheelMousePos( hWnd, nMsg, wParam, lParam, nRet ); - } - bInWheelMsg--; - } - } -#endif - - return nRet; -} - -#ifdef WIN -LRESULT CALLBACK SalFrameWndProcA( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - int bDef = TRUE; - LRESULT nRet = SalFrameWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam ); - return nRet; -} -#endif - -#ifdef WIN -LRESULT CALLBACK SalFrameWndProcW( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - int bDef = TRUE; - LRESULT nRet = SalFrameWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam ); - return nRet; -} -#endif - -// ----------------------------------------------------------------------- - -BOOL ImplHandleGlobalMsg( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT& rlResult ) -{ -#ifdef WIN - // Hier verarbeiten wir alle Messages, die fuer alle Frame-Fenster gelten, - // damit diese nur einmal verarbeitet werden - // Must work for Unicode and none Unicode - if ( (nMsg == WM_PALETTECHANGED) || (nMsg == SAL_MSG_POSTPALCHANGED) ) - { - int bDef = TRUE; - rlResult = ImplHandlePalette( FALSE, hWnd, nMsg, wParam, lParam, bDef ); - return (bDef != 0); - } - else -#endif - return FALSE; } diff --git a/vcl/aqua/source/window/salobj.cxx b/vcl/aqua/source/window/salobj.cxx index 1a9a93a85987..054f07fa0481 100644 --- a/vcl/aqua/source/window/salobj.cxx +++ b/vcl/aqua/source/window/salobj.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salobj.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:46 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,541 +61,15 @@ #include <string.h> -#ifndef _SVWIN_HXX -#include <tools/svwin.h> -#endif - #define _SV_SALOBJ_CXX -#ifndef _SV_SALAQUA_HXX -#include <salaqua.hxx> -#endif #ifndef _SV_SALDATA_HXX #include <saldata.hxx> #endif -#ifndef _SV_SALINST_HXX -#include <salinst.hxx> -#endif -#ifndef _SV_SALFRAME_HXX -#include <salframe.hxx> -#endif #ifndef _SV_SALOBJ_HXX #include <salobj.hxx> #endif -#ifndef _DEBUG_HXX -#include <tools/debug.hxx> -#endif - -// ======================================================================= - -static BOOL ImplIsSysWindowOrChild( VCLWINDOW hWndParent, VCLWINDOW hWndChild ) -{ - if ( hWndParent == hWndChild ) - return TRUE; - -#ifdef WIN - VCLWINDOW hTempWnd = ::GetParent( hWndChild ); - while ( hTempWnd ) - { - // Ab nicht Child-Fenstern hoeren wir auf zu suchen - if ( !(GetWindowStyle( hTempWnd ) & WS_CHILD) ) - return FALSE; - if ( hTempWnd == hWndParent ) - return TRUE; - hTempWnd = ::GetParent( hTempWnd ); - } -#endif - - return FALSE; -} - -// ----------------------------------------------------------------------- - -SalObject* ImplFindSalObject( VCLWINDOW hWndChild ) -{ - SalData* pSalData = GetSalData(); - SalObject* pObject = pSalData->mpFirstObject; - while ( pObject ) - { - if ( ImplIsSysWindowOrChild( pObject->maObjectData.mhWndChild, hWndChild ) ) - return pObject; - - pObject = pObject->maObjectData.mpNextObject; - } - - return NULL; -} - -// ----------------------------------------------------------------------- - -SalFrame* ImplFindSalObjectFrame( VCLWINDOW hWnd ) -{ - SalFrame* pFrame = NULL; - SalObject* pObject = ImplFindSalObject( hWnd ); - if ( pObject ) - { -#ifdef WIN - // Dazugehoerenden Frame suchen - VCLWINDOW hWnd = ::GetParent( pObject->maObjectData.mhWnd ); - pFrame = GetSalData()->mpFirstFrame; - while ( pFrame ) - { - if ( pFrame->maFrameData.mhWnd == hWnd ) - break; - - pFrame = pFrame->maFrameData.mpNextFrame; - } -#endif - } - - return pFrame; -} - -// ----------------------------------------------------------------------- - -LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam ) -{ - // Used for Unicode and none Unicode - SalData* pSalData = GetSalData(); - -#ifdef WIN - if ( (nCode >= 0) && lParam ) - { - CWPSTRUCT* pData = (CWPSTRUCT*)lParam; - if ( (pData->message != WM_KEYDOWN) && - (pData->message != WM_KEYUP) ) - pSalData->mnSalObjWantKeyEvt = 0; - - // Testen, ob wir Daten fuer ein SalObject-Fenster behandeln - // muessen - SalObject* pObject; - if ( pData->message == WM_SETFOCUS ) - { - pObject = ImplFindSalObject( pData->hwnd ); - if ( pObject ) - { - pObject->maObjectData.mhLastFocusWnd = pData->hwnd; - if ( ImplSalYieldMutexTryToAcquire() ) - { - pObject->maObjectData.mpProc( pObject->maObjectData.mpInst, pObject, - SALOBJ_EVENT_GETFOCUS, 0 ); - ImplSalYieldMutexRelease(); - } - else - ImplPostMessage( pObject->maObjectData.mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 ); - } - } - else if ( pData->message == WM_KILLFOCUS ) - { - pObject = ImplFindSalObject( pData->hwnd ); - if ( pObject && !ImplFindSalObject( (VCLWINDOW)pData->wParam ) ) - { - // LoseFocus nur rufen, wenn wirklich kein ChildFenster - // den Focus bekommt - if ( !pData->wParam || !ImplFindSalObject( (VCLWINDOW)pData->wParam ) ) - { - if ( ImplSalYieldMutexTryToAcquire() ) - { - pObject->maObjectData.mpProc( pObject->maObjectData.mpInst, pObject, - SALOBJ_EVENT_LOSEFOCUS, 0 ); - ImplSalYieldMutexRelease(); - } - else - ImplPostMessage( pObject->maObjectData.mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 ); - } - else - pObject->maObjectData.mhLastFocusWnd = (VCLWINDOW)pData->wParam; - } - } - } - - return CallNextHookEx( pSalData->mhSalObjMsgHook, nCode, wParam, lParam ); -#else - return 0; -#endif -} - -// ----------------------------------------------------------------------- - -#ifdef WIN -BOOL ImplSalPreDispatchMsg( MSG* pMsg ) -{ - // Used for Unicode and none Unicode - SalData* pSalData = GetSalData(); - SalObject* pObject; - - if ( (pMsg->message == WM_LBUTTONDOWN) || - (pMsg->message == WM_RBUTTONDOWN) || - (pMsg->message == WM_MBUTTONDOWN) ) - - ImplSalYieldMutexAcquireWithWait(); - pObject = ImplFindSalObject( pMsg->hwnd ); - if ( pObject ) - ImplPostMessage( pObject->maObjectData.mhWnd, SALOBJ_MSG_TOTOP, 0, 0 ); - ImplSalYieldMutexRelease(); - } - - if ( (pMsg->message == WM_KEYDOWN) || - (pMsg->message == WM_KEYUP) ) - { - // KeyEvents wollen wir nach Moeglichkeit auch abarbeiten, - // wenn das Control diese nicht selber auswertet - // SysKeys werden als WM_SYSCOMMAND verarbeitet - // Char-Events verarbeiten wir nicht, da wir nur - // Accelerator relevante Keys verarbeiten wollen - BOOL bWantedKeyCode = FALSE; - // A-Z, 0-9 nur in Verbindung mit Control-Taste - if ( ((pMsg->wParam >= 65) && (pMsg->wParam <= 90)) || - ((pMsg->wParam >= 48) && (pMsg->wParam <= 57)) ) - { - if ( GetKeyState( VK_CONTROL ) & 0x8000 ) - bWantedKeyCode = TRUE; - } - else if ( ((pMsg->wParam >= VK_F1) && (pMsg->wParam <= VK_F24)) || - ((pMsg->wParam >= VK_SPACE) && (pMsg->wParam <= VK_HELP)) || - (pMsg->wParam == VK_BACK) || (pMsg->wParam == VK_TAB) || - (pMsg->wParam == VK_CLEAR) || (pMsg->wParam == VK_RETURN) || - (pMsg->wParam == VK_ESCAPE) ) - bWantedKeyCode = TRUE; - if ( bWantedKeyCode ) - { - ImplSalYieldMutexAcquireWithWait(); - pObject = ImplFindSalObject( pMsg->hwnd ); - if ( pObject ) - pSalData->mnSalObjWantKeyEvt = pMsg->wParam; - ImplSalYieldMutexRelease(); - } - } - // Hier WM_SYSCHAR abfangen, um mit Alt+Taste evtl. Menu zu aktivieren - else if ( pMsg->message == WM_SYSCHAR ) - { - pSalData->mnSalObjWantKeyEvt = 0; - - USHORT nKeyCode = LOWORD( pMsg->wParam ); - // Nur 0-9 und A-Z - if ( ((nKeyCode >= 48) && (nKeyCode <= 57)) || - ((nKeyCode >= 65) && (nKeyCode <= 90)) || - ((nKeyCode >= 97) && (nKeyCode <= 122)) ) - { - BOOL bRet = FALSE; - ImplSalYieldMutexAcquireWithWait(); - pObject = ImplFindSalObject( pMsg->hwnd ); - if ( pObject ) - { - if ( pMsg->hwnd == ::GetFocus() ) - { - SalFrame* pFrame = ImplFindSalObjectFrame( pMsg->hwnd ); - if ( pFrame ) - { - if ( ImplHandleSalObjSysCharMsg( pFrame->maFrameData.mhWnd, pMsg->wParam, pMsg->lParam ) ) - bRet = TRUE; - } - } - } - ImplSalYieldMutexRelease(); - if ( bRet ) - return TRUE; - } - } - else - pSalData->mnSalObjWantKeyEvt = 0; - - return FALSE; -} -#endif - -// ----------------------------------------------------------------------- - -#ifdef WIN -void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT /* nDispatchResult */ ) -{ - // Used for Unicode and none Unicode - SalData* pSalData = GetSalData(); - SalFrame* pFrame; - - if ( (pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) ) - { - if ( pSalData->mnSalObjWantKeyEvt == pMsg->wParam ) - { - pSalData->mnSalObjWantKeyEvt = 0; - if ( pMsg->hwnd == ::GetFocus() ) - { - ImplSalYieldMutexAcquireWithWait(); - pFrame = ImplFindSalObjectFrame( pMsg->hwnd ); - if ( pFrame ) - ImplHandleSalObjKeyMsg( pFrame->maFrameData.mhWnd, pMsg->message, pMsg->wParam, pMsg->lParam ); - ImplSalYieldMutexRelease(); - } - } - } - - pSalData->mnSalObjWantKeyEvt = 0; -} -#endif - -// ======================================================================= - -LRESULT CALLBACK SalSysObjWndProc( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef ) -{ - SalObject* pSysObj; - LRESULT nRet = 0; - -#ifdef WIN - switch( nMsg ) - { - case WM_ERASEBKGND: - nRet = 1; - rDef = FALSE; - break; - case WM_PAINT: - { - PAINTSTRUCT aPs; - BeginPaint( hWnd, &aPs ); - EndPaint( hWnd, &aPs ); - rDef = FALSE; - } - break; - - case WM_PARENTNOTIFY: - { - UINT nNotifyMsg = LOWORD( wParam ); - if ( (nNotifyMsg == WM_LBUTTONDOWN) || - (nNotifyMsg == WM_RBUTTONDOWN) || - (nNotifyMsg == WM_MBUTTONDOWN) ) - { - ImplSalYieldMutexAcquireWithWait(); - pSysObj = GetSalObjWindowPtr( hWnd ); - if ( pSysObj ) - pSysObj->maObjectData.mpProc( pSysObj->maObjectData.mpInst, pSysObj, SALOBJ_EVENT_TOTOP, 0 ); - ImplSalYieldMutexRelease(); - } - } - break; - - case WM_MOUSEACTIVATE: - ImplPostMessage( hWnd, SALOBJ_MSG_TOTOP, 0, 0 ); - break; - - case SALOBJ_MSG_TOTOP: - if ( ImplSalYieldMutexTryToAcquire() ) - { - pSysObj = GetSalObjWindowPtr( hWnd ); - pSysObj->maObjectData.mpProc( pSysObj->maObjectData.mpInst, pSysObj, - SALOBJ_EVENT_TOTOP, 0 ); - ImplSalYieldMutexRelease(); - rDef = FALSE; - } - else - ImplPostMessage( hWnd, SALOBJ_MSG_TOTOP, 0, 0 ); - break; - - case SALOBJ_MSG_POSTFOCUS: - if ( ImplSalYieldMutexTryToAcquire() ) - { - pSysObj = GetSalObjWindowPtr( hWnd ); - VCLWINDOW hFocusWnd = ::GetFocus(); - USHORT nEvent; - if ( hFocusWnd && ImplIsSysWindowOrChild( hWnd, hFocusWnd ) ) - nEvent = SALOBJ_EVENT_GETFOCUS; - else - nEvent = SALOBJ_EVENT_LOSEFOCUS; - pSysObj->maObjectData.mpProc( pSysObj->maObjectData.mpInst, pSysObj, - nEvent, 0 ); - ImplSalYieldMutexRelease(); - } - else - ImplPostMessage( hWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 ); - rDef = FALSE; - break; - - case WM_SIZE: - { - VCLWINDOW hWndChild = GetWindow( hWnd, GW_CHILD ); - if ( hWndChild ) - { - SetWindowPos( hWndChild, - 0, 0, 0, (int)LOWORD( lParam ), (int)HIWORD( lParam ), - SWP_NOZORDER | SWP_NOACTIVATE ); - } - } - rDef = FALSE; - break; - - case WM_CREATE: - { - // Window-Instanz am Windowhandle speichern - // Can also be used for the W-Version, because the struct - // to access lpCreateParams is the same structure - CREATESTRUCTA* pStruct = (CREATESTRUCTA*)lParam; - pSysObj = (SalObject*)pStruct->lpCreateParams; - SetSalObjWindowPtr( hWnd, pSysObj ); - // VCLWINDOW schon hier setzen, da schon auf den Instanzdaten - // gearbeitet werden kann, wenn Messages waehrend - // CreateWindow() gesendet werden - pSysObj->maObjectData.mhWnd = hWnd; - rDef = FALSE; - } - break; - } -#endif - - return nRet; -} - -#ifdef WIN -LRESULT CALLBACK SalSysObjWndProcA( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - int bDef = TRUE; - LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam ); - return nRet; -} -#endif - -#ifdef WIN -LRESULT CALLBACK SalSysObjWndProcW( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - int bDef = TRUE; - LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam ); - return nRet; -} -#endif - -// ----------------------------------------------------------------------- - -LRESULT CALLBACK SalSysObjChildWndProc( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef ) -{ - LRESULT nRet = 0; - -#ifdef WIN - switch( nMsg ) - { - // Wegen PlugIn's loeschen wir erstmal den Hintergrund - case WM_ERASEBKGND: - nRet = 1; - rDef = FALSE; - break; - case WM_PAINT: - { - PAINTSTRUCT aPs; - BeginPaint( hWnd, &aPs ); - EndPaint( hWnd, &aPs ); - rDef = FALSE; - } - break; - } -#endif - - return nRet; -} - -#ifdef WIN -LRESULT CALLBACK SalSysObjChildWndProcA( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - int bDef = TRUE; - LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam ); - return nRet; -} -#endif - -#ifdef WIN -LRESULT CALLBACK SalSysObjChildWndProcW( VCLWINDOW hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) -{ - int bDef = TRUE; - LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef ); - if ( bDef ) - nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam ); - return nRet; -} -#endif - -// ======================================================================= - -SalObject* ImplSalCreateObject( SalInstance* pInst, SalFrame* pParent ) -{ - SalData* pSalData = GetSalData(); - -#ifdef WIN - // Hook installieren, wenn es das erste SalObject ist - if ( !pSalData->mpFirstObject ) - { - pSalData->mhSalObjMsgHook = SetWindowsHookExA( WH_CALLWNDPROC, - SalSysMsgProc, - pSalData->mhInst, - pSalData->mnAppThreadId ); - } - - if ( !pSalData->mbObjClassInit ) - { - WNDCLASSEXA aWndClassEx; - aWndClassEx.cbSize = sizeof( aWndClassEx ); - aWndClassEx.style = 0; - aWndClassEx.lpfnWndProc = SalSysObjWndProcA; - aWndClassEx.cbClsExtra = 0; - aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA; - aWndClassEx.hInstance = pSalData->mhInst; - aWndClassEx.hIcon = 0; - aWndClassEx.hIconSm = 0; - aWndClassEx.hCursor = LoadCursor( 0, IDC_ARROW ); - aWndClassEx.hbrBackground = 0; - aWndClassEx.lpszMenuName = 0; - aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEA; - if ( RegisterClassExA( &aWndClassEx ) ) - { - // Wegen PlugIn's loeschen wir erstmal den Hintergrund - aWndClassEx.cbWndExtra = 0; - aWndClassEx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - aWndClassEx.lpfnWndProc = SalSysObjChildWndProcA; - aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEA; - if ( RegisterClassExA( &aWndClassEx ) ) - pSalData->mbObjClassInit = TRUE; - } - } -#endif - - if ( pSalData->mbObjClassInit ) - { -#ifdef WIN - SalObject* pObject = new SalObject; - VCLWINDOW hWnd; - VCLWINDOW hWndChild = 0; - hWnd = CreateWindowExA( 0, SAL_OBJECT_CLASSNAMEA, "", WS_CHILD, 0, 0, 0, 0, pParent->maFrameData.mhWnd, 0, pInst->maInstData.mhInst, (void*)pObject ); - if ( hWnd ) - { - hWndChild = CreateWindowExA( 0, SAL_OBJECT_CHILDCLASSNAMEA, "", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, 0, 0, 0, 0, hWnd, 0, pInst->maInstData.mhInst, NULL ); - } - } - if ( !hWndChild ) - { - delete pObject; - return NULL; - } - - if ( hWnd ) - { - pObject->maObjectData.mhWnd = hWnd; - pObject->maObjectData.mhWndChild = hWndChild; - pObject->maObjectData.maSysData.hWnd = hWndChild; - return pObject; - } -#endif - } - - return NULL; -} - -// ======================================================================= - -long ImplSalObjCallbackDummy( void*, SalObject*, USHORT, const void* ) -{ - return 0; -} // ======================================================================= @@ -608,10 +82,7 @@ SalObject::SalObject() maObjectData.mhLastFocusWnd = 0; maObjectData.maSysData.nSize = sizeof( SystemEnvData ); maObjectData.mpInst = NULL; - maObjectData.mpProc = ImplSalObjCallbackDummy; -#ifdef WIN - maObjectData.mpStdClipRgnData = NULL; -#endif + maObjectData.mpProc = NULL; // Insert object in objectlist maObjectData.mpNextObject = pSalData->mpFirstObject; @@ -626,15 +97,7 @@ SalObject::~SalObject() // remove frame from framelist if ( this == pSalData->mpFirstObject ) - { pSalData->mpFirstObject = maObjectData.mpNextObject; - -#ifdef WIN - // Wenn letztes SalObject, dann Hook wieder entfernen - if ( !pSalData->mpFirstObject ) - UnhookWindowsHookEx( pSalData->mhSalObjMsgHook ); -#endif - } else { SalObject* pTempObject = pSalData->mpFirstObject; @@ -643,36 +106,12 @@ SalObject::~SalObject() pTempObject->maObjectData.mpNextObject = maObjectData.mpNextObject; } - -#ifdef WIN - // Cache-Daten zerstoeren - if ( maObjectData.mpStdClipRgnData ) - delete maObjectData.mpStdClipRgnData; - - VCLWINDOW hWndParent = ::GetParent( maObjectData.mhWnd ); - - if ( maObjectData.mhWndChild ) - DestroyWindow( maObjectData.mhWndChild ); - if ( maObjectData.mhWnd ) - DestroyWindow( maObjectData.mhWnd ); - - // Palette wieder zuruecksetzen, wenn kein externes Child-Fenster - // mehr vorhanden ist, da diese unsere Palette ueberschrieben haben - // koennen - if ( hWndParent && - ::GetActiveWindow() == hWndParent && - !GetWindow( hWndParent, GW_CHILD ) ) - ImplSendMessage( hWndParent, SAL_MSG_FORCEPALETTE, 0, 0 ); -#endif } // ----------------------------------------------------------------------- void SalObject::ResetClipRegion() { -#ifdef WIN - SetWindowRgn( maObjectData.mhWnd, 0, TRUE ); -#endif } // ----------------------------------------------------------------------- @@ -686,145 +125,42 @@ USHORT SalObject::GetClipRegionType() void SalObject::BeginSetClipRegion( ULONG nRectCount ) { -#ifdef WIN - ULONG nRectBufSize = sizeof(RECT)*nRectCount; - if ( nRectCount < SAL_CLIPRECT_COUNT ) - { - if ( !maObjectData.mpStdClipRgnData ) - maObjectData.mpStdClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+(SAL_CLIPRECT_COUNT*sizeof(RECT))]; - maObjectData.mpClipRgnData = maObjectData.mpStdClipRgnData; - } - else - maObjectData.mpClipRgnData = (RGNDATA*)new BYTE[sizeof(RGNDATA)-1+nRectBufSize]; - maObjectData.mpClipRgnData->rdh.dwSize = sizeof( RGNDATAHEADER ); - maObjectData.mpClipRgnData->rdh.iType = RDH_RECTANGLES; - maObjectData.mpClipRgnData->rdh.nCount = nRectCount; - maObjectData.mpClipRgnData->rdh.nRgnSize = nRectBufSize; - SetRectEmpty( &(maObjectData.mpClipRgnData->rdh.rcBound) ); - maObjectData.mpNextClipRect = (RECT*)(&(maObjectData.mpClipRgnData->Buffer)); - maObjectData.mbFirstClipRect = TRUE; -#endif } // ----------------------------------------------------------------------- void SalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) { -#ifdef WIN - RECT* pRect = maObjectData.mpNextClipRect; - RECT* pBoundRect = &(maObjectData.mpClipRgnData->rdh.rcBound); - long nRight = nX + nWidth; - long nBottom = nY + nHeight; - - if ( maObjectData.mbFirstClipRect ) - { - pBoundRect->left = nX; - pBoundRect->top = nY; - pBoundRect->right = nRight; - pBoundRect->bottom = nBottom; - maObjectData.mbFirstClipRect = FALSE; - } - else - { - if ( nX < pBoundRect->left ) - pBoundRect->left = (int)nX; - - if ( nY < pBoundRect->top ) - pBoundRect->top = (int)nY; - - if ( nRight > pBoundRect->right ) - pBoundRect->right = (int)nRight; - - if ( nBottom > pBoundRect->bottom ) - pBoundRect->bottom = (int)nBottom; - } - - pRect->left = (int)nX; - pRect->top = (int)nY; - pRect->right = (int)nRight; - pRect->bottom = (int)nBottom; - maObjectData.mpNextClipRect++; -#endif } // ----------------------------------------------------------------------- void SalObject::EndSetClipRegion() { -#ifdef WIN - HRGN hRegion; - - // Aus den Region-Daten muessen wir jetzt eine ClipRegion erzeugen - if ( maObjectData.mpClipRgnData->rdh.nCount == 1 ) - { - RECT* pRect = &(maObjectData.mpClipRgnData->rdh.rcBound); - hRegion = CreateRectRgn( pRect->left, pRect->top, - pRect->right, pRect->bottom ); - } - else - { - ULONG nSize = maObjectData.mpClipRgnData->rdh.nRgnSize+sizeof(RGNDATAHEADER); - hRegion = ExtCreateRegion( NULL, nSize, maObjectData.mpClipRgnData ); - if ( maObjectData.mpClipRgnData != maObjectData.mpStdClipRgnData ) - delete maObjectData.mpClipRgnData; - } - - DBG_ASSERT( hRegion, "SalObject::EndSetClipRegion() - Can't create ClipRegion" ); - SetWindowRgn( maObjectData.mhWnd, hRegion, TRUE ); -#endif } // ----------------------------------------------------------------------- void SalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) { -#ifdef WIN - ULONG nStyle = 0; - BOOL bVisible = (GetWindowStyle( maObjectData.mhWnd ) & WS_VISIBLE) != 0; - if ( bVisible ) - { - ShowWindow( maObjectData.mhWnd, SW_HIDE ); - nStyle |= SWP_SHOWWINDOW; - } - SetWindowPos( maObjectData.mhWnd, 0, - (int)nX, (int)nY, (int)nWidth, (int)nHeight, - SWP_NOZORDER | SWP_NOACTIVATE | nStyle ); -#endif } // ----------------------------------------------------------------------- void SalObject::Show( BOOL bVisible ) { -#ifdef WIN - if ( bVisible ) - ShowWindow( maObjectData.mhWnd, SW_SHOWNORMAL ); - else - ShowWindow( maObjectData.mhWnd, SW_HIDE ); -#endif } // ----------------------------------------------------------------------- void SalObject::Enable( BOOL bEnable ) { -#ifdef WIN - EnableWindow( maObjectData.mhWnd, bEnable ); -#endif } // ----------------------------------------------------------------------- void SalObject::GrabFocus() { -#ifdef WIN - if ( maObjectData.mhLastFocusWnd && - IsWindow( maObjectData.mhLastFocusWnd ) && - ImplIsSysWindowOrChild( maObjectData.mhWndChild, maObjectData.mhLastFocusWnd ) ) - ::SetFocus( maObjectData.mhLastFocusWnd ); - else - ::SetFocus( maObjectData.mhWndChild ); -#endif } // ----------------------------------------------------------------------- @@ -843,16 +179,10 @@ void SalObject::SetBackground( SalColor nSalColor ) const SystemEnvData* 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; } |