1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #define INCL_PM 25cdf0e10cSrcweir #define INCL_DOS 26cdf0e10cSrcweir #define INCL_GPI 27cdf0e10cSrcweir #include <svpm.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <tools/string.hxx> 30cdf0e10cSrcweir #include <salsys.h> 31cdf0e10cSrcweir #include <salframe.h> 32cdf0e10cSrcweir #include <salinst.h> 33cdf0e10cSrcweir #include "saldata.hxx" 34cdf0e10cSrcweir #include <tools/debug.hxx> 35cdf0e10cSrcweir #include <vcl/svdata.hxx> 36cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 37cdf0e10cSrcweir #include "vcl/window.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #ifndef _SV_SALGTYPE_HXX 40cdf0e10cSrcweir //#include <salgtype.hxx> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir 43cdf0e10cSrcweir #define CHAR_POINTER(THE_OUSTRING) ::rtl::OUStringToOString (THE_OUSTRING, RTL_TEXTENCODING_UTF8).pData->buffer 44cdf0e10cSrcweir 45cdf0e10cSrcweir class Os2SalSystem : public SalSystem 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir Os2SalSystem() {} 49cdf0e10cSrcweir virtual ~Os2SalSystem(); 50cdf0e10cSrcweir 51cdf0e10cSrcweir virtual unsigned int GetDisplayScreenCount(); 52cdf0e10cSrcweir virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ); 53cdf0e10cSrcweir //virtual bool GetSalSystemDisplayInfo( DisplayInfo& rInfo ); 54cdf0e10cSrcweir 55cdf0e10cSrcweir virtual bool IsMultiDisplay(); 56cdf0e10cSrcweir virtual unsigned int GetDefaultDisplayNumber(); 57cdf0e10cSrcweir virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen ); 58cdf0e10cSrcweir virtual rtl::OUString GetScreenName( unsigned int nScreen ); 59cdf0e10cSrcweir 60cdf0e10cSrcweir virtual int ShowNativeMessageBox( const String& rTitle, 61cdf0e10cSrcweir const String& rMessage, 62cdf0e10cSrcweir int nButtonCombination, 63cdf0e10cSrcweir int nDefaultButton); 64cdf0e10cSrcweir }; 65cdf0e10cSrcweir 66cdf0e10cSrcweir SalSystem* Os2SalInstance::CreateSalSystem() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir return new Os2SalSystem(); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir Os2SalSystem::~Os2SalSystem() 72cdf0e10cSrcweir { 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir // ----------------------------------------------------------------------- 76cdf0e10cSrcweir #if 0 77cdf0e10cSrcweir bool Os2SalSystem::GetSalSystemDisplayInfo( DisplayInfo& rInfo ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir HDC hDC; 80cdf0e10cSrcweir if( hDC = WinQueryWindowDC(HWND_DESKTOP) ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir LONG bitCount; 83cdf0e10cSrcweir DevQueryCaps(hDC, CAPS_COLOR_BITCOUNT, CAPS_COLOR_BITCOUNT, &bitCount); 84cdf0e10cSrcweir rInfo.nWidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); 85cdf0e10cSrcweir rInfo.nHeight = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); 86cdf0e10cSrcweir rInfo.nDepth = bitCount; 87cdf0e10cSrcweir return true; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir else 90cdf0e10cSrcweir return false; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir #endif 93cdf0e10cSrcweir 94cdf0e10cSrcweir unsigned int Os2SalSystem::GetDisplayScreenCount() 95cdf0e10cSrcweir { 96cdf0e10cSrcweir return 1; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir Rectangle Os2SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir Rectangle aRet; 102cdf0e10cSrcweir aRet = Rectangle( Point(), Point( WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ), 103cdf0e10cSrcweir WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) ) ); 104cdf0e10cSrcweir return aRet; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir // ----------------------------------------------------------------------- 108cdf0e10cSrcweir /* We have to map the button identifier to the identifier used by the Os232 109cdf0e10cSrcweir Platform SDK to specify the default button for the MessageBox API. 110cdf0e10cSrcweir The first dimension is the button combination, the second dimension 111cdf0e10cSrcweir is the button identifier. 112cdf0e10cSrcweir */ 113cdf0e10cSrcweir static int DEFAULT_BTN_MAPPING_TABLE[][8] = 114cdf0e10cSrcweir { 115cdf0e10cSrcweir // Undefined OK CANCEL ABORT RETRY IGNORE YES NO 116cdf0e10cSrcweir { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //OK 117cdf0e10cSrcweir { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //OK_CANCEL 118cdf0e10cSrcweir { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //ABORT_RETRY_IGNO 119cdf0e10cSrcweir { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON3, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2 }, //YES_NO_CANCEL 120cdf0e10cSrcweir { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2 }, //YES_NO 121cdf0e10cSrcweir { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 } //RETRY_CANCEL 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir static int COMBI_BTN_MAPPING_TABLE[] = 125cdf0e10cSrcweir { 126cdf0e10cSrcweir MB_OK, MB_OKCANCEL, MB_ABORTRETRYIGNORE, MB_YESNO, MB_YESNOCANCEL, MB_RETRYCANCEL 127cdf0e10cSrcweir }; 128cdf0e10cSrcweir 129cdf0e10cSrcweir int Os2SalSystem::ShowNativeMessageBox(const String& rTitle, const String& rMessage, int nButtonCombination, int nDefaultButton) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir DBG_ASSERT( nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK && 132cdf0e10cSrcweir nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL && 133cdf0e10cSrcweir nDefaultButton >= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK && 134cdf0e10cSrcweir nDefaultButton <= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO, "Invalid arguments!" ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir int nFlags = MB_APPLMODAL | MB_WARNING | COMBI_BTN_MAPPING_TABLE[nButtonCombination]; 137cdf0e10cSrcweir 138cdf0e10cSrcweir if (nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK && 139cdf0e10cSrcweir nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL && 140cdf0e10cSrcweir nDefaultButton >= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK && 141cdf0e10cSrcweir nDefaultButton <= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO) 142cdf0e10cSrcweir nFlags |= DEFAULT_BTN_MAPPING_TABLE[nButtonCombination][nDefaultButton]; 143cdf0e10cSrcweir 144cdf0e10cSrcweir //#107209 hide the splash screen if active 145cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 146cdf0e10cSrcweir if (pSVData->mpIntroWindow) 147cdf0e10cSrcweir pSVData->mpIntroWindow->Hide(); 148cdf0e10cSrcweir 149cdf0e10cSrcweir return WinMessageBox( 150cdf0e10cSrcweir HWND_DESKTOP, HWND_DESKTOP, 151cdf0e10cSrcweir (PSZ)CHAR_POINTER(rMessage), 152cdf0e10cSrcweir (PSZ)CHAR_POINTER(rTitle), 153cdf0e10cSrcweir 0, nFlags); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir 157cdf0e10cSrcweir unsigned int Os2SalSystem::GetDefaultDisplayNumber() 158cdf0e10cSrcweir { 159cdf0e10cSrcweir return 0; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir bool Os2SalSystem::IsMultiDisplay() 163cdf0e10cSrcweir { 164cdf0e10cSrcweir return false; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir Rectangle Os2SalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir return GetDisplayScreenPosSizePixel( nScreen ); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir rtl::OUString Os2SalSystem::GetScreenName( unsigned int nScreen ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir rtl::OUStringBuffer aBuf( 32 ); 175cdf0e10cSrcweir aBuf.appendAscii( "VirtualScreen " ); 176cdf0e10cSrcweir aBuf.append( sal_Int32(nScreen) ); 177cdf0e10cSrcweir return aBuf.makeStringAndClear(); 178cdf0e10cSrcweir } 179