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