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