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 "svsys.h"
30 #include "rtl/ustrbuf.hxx"
31
32 #include "tools/debug.hxx"
33 #include "tools/string.hxx"
34
35 #include "vcl/window.hxx"
36
37 #include "os2/salsys.h"
38 #include "os2/salframe.h"
39 #include "os2/salinst.h"
40 #include "os2/saldata.hxx"
41
42 #include "svdata.hxx"
43
44 #define CHAR_POINTER(THE_OUSTRING) ::rtl::OUStringToOString (THE_OUSTRING, RTL_TEXTENCODING_UTF8).pData->buffer
45
46 class Os2SalSystem : public SalSystem
47 {
48 public:
Os2SalSystem()49 Os2SalSystem() {}
50 virtual ~Os2SalSystem();
51
52 virtual unsigned int GetDisplayScreenCount();
53 virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen );
54 //virtual bool GetSalSystemDisplayInfo( DisplayInfo& rInfo );
55
56 virtual bool IsMultiDisplay();
57 virtual unsigned int GetDefaultDisplayNumber();
58 virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen );
59 virtual rtl::OUString GetScreenName( unsigned int nScreen );
60
61 virtual int ShowNativeMessageBox( const String& rTitle,
62 const String& rMessage,
63 int nButtonCombination,
64 int nDefaultButton);
65 };
66
CreateSalSystem()67 SalSystem* Os2SalInstance::CreateSalSystem()
68 {
69 return new Os2SalSystem();
70 }
71
~Os2SalSystem()72 Os2SalSystem::~Os2SalSystem()
73 {
74 }
75
76 // -----------------------------------------------------------------------
77 #if 0
78 bool Os2SalSystem::GetSalSystemDisplayInfo( DisplayInfo& rInfo )
79 {
80 HDC hDC;
81 if( hDC = WinQueryWindowDC(HWND_DESKTOP) )
82 {
83 LONG bitCount;
84 DevQueryCaps(hDC, CAPS_COLOR_BITCOUNT, CAPS_COLOR_BITCOUNT, &bitCount);
85 rInfo.nWidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
86 rInfo.nHeight = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
87 rInfo.nDepth = bitCount;
88 return true;
89 }
90 else
91 return false;
92 }
93 #endif
94
GetDisplayScreenCount()95 unsigned int Os2SalSystem::GetDisplayScreenCount()
96 {
97 return 1;
98 }
99
GetDisplayScreenPosSizePixel(unsigned int nScreen)100 Rectangle Os2SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
101 {
102 Rectangle aRet;
103 aRet = Rectangle( Point(), Point( WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ),
104 WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) ) );
105 return aRet;
106 }
107
108 // -----------------------------------------------------------------------
109 /* We have to map the button identifier to the identifier used by the Os232
110 Platform SDK to specify the default button for the MessageBox API.
111 The first dimension is the button combination, the second dimension
112 is the button identifier.
113 */
114 static int DEFAULT_BTN_MAPPING_TABLE[][8] =
115 {
116 // Undefined OK CANCEL ABORT RETRY IGNORE YES NO
117 { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //OK
118 { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //OK_CANCEL
119 { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //ABORT_RETRY_IGNO
120 { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON3, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2 }, //YES_NO_CANCEL
121 { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2 }, //YES_NO
122 { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 } //RETRY_CANCEL
123 };
124
125 static int COMBI_BTN_MAPPING_TABLE[] =
126 {
127 MB_OK, MB_OKCANCEL, MB_ABORTRETRYIGNORE, MB_YESNO, MB_YESNOCANCEL, MB_RETRYCANCEL
128 };
129
ShowNativeMessageBox(const String & rTitle,const String & rMessage,int nButtonCombination,int nDefaultButton)130 int Os2SalSystem::ShowNativeMessageBox(const String& rTitle, const String& rMessage, int nButtonCombination, int nDefaultButton)
131 {
132 DBG_ASSERT( nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK &&
133 nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL &&
134 nDefaultButton >= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK &&
135 nDefaultButton <= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO, "Invalid arguments!" );
136
137 int nFlags = MB_APPLMODAL | MB_WARNING | COMBI_BTN_MAPPING_TABLE[nButtonCombination];
138
139 if (nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK &&
140 nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL &&
141 nDefaultButton >= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK &&
142 nDefaultButton <= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO)
143 nFlags |= DEFAULT_BTN_MAPPING_TABLE[nButtonCombination][nDefaultButton];
144
145 //#107209 hide the splash screen if active
146 ImplSVData* pSVData = ImplGetSVData();
147 if (pSVData->mpIntroWindow)
148 pSVData->mpIntroWindow->Hide();
149
150 return WinMessageBox(
151 HWND_DESKTOP, HWND_DESKTOP,
152 (PSZ)CHAR_POINTER(rMessage),
153 (PSZ)CHAR_POINTER(rTitle),
154 0, nFlags);
155 }
156
157
GetDefaultDisplayNumber()158 unsigned int Os2SalSystem::GetDefaultDisplayNumber()
159 {
160 return 0;
161 }
162
IsMultiDisplay()163 bool Os2SalSystem::IsMultiDisplay()
164 {
165 return false;
166 }
167
GetDisplayWorkAreaPosSizePixel(unsigned int nScreen)168 Rectangle Os2SalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen )
169 {
170 return GetDisplayScreenPosSizePixel( nScreen );
171 }
172
GetScreenName(unsigned int nScreen)173 rtl::OUString Os2SalSystem::GetScreenName( unsigned int nScreen )
174 {
175 rtl::OUStringBuffer aBuf( 32 );
176 aBuf.appendAscii( "VirtualScreen " );
177 aBuf.append( sal_Int32(nScreen) );
178 return aBuf.makeStringAndClear();
179 }
180