1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salinfo.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
36 #include <tools/string.hxx>
40 #include "saldata.hxx"
41 #include <tools/debug.hxx>
42 #include <vcl/svdata.hxx>
43 #include <rtl/ustrbuf.hxx>
44 #include "vcl/window.hxx"
46 #ifndef _SV_SALGTYPE_HXX
47 //#include <salgtype.hxx>
50 #define CHAR_POINTER(THE_OUSTRING) ::rtl::OUStringToOString (THE_OUSTRING, RTL_TEXTENCODING_UTF8).pData->buffer
52 class Os2SalSystem
: public SalSystem
56 virtual ~Os2SalSystem();
58 virtual unsigned int GetDisplayScreenCount();
59 virtual Rectangle
GetDisplayScreenPosSizePixel( unsigned int nScreen
);
60 //virtual bool GetSalSystemDisplayInfo( DisplayInfo& rInfo );
62 virtual bool IsMultiDisplay();
63 virtual unsigned int GetDefaultDisplayNumber();
64 virtual Rectangle
GetDisplayWorkAreaPosSizePixel( unsigned int nScreen
);
65 virtual rtl::OUString
GetScreenName( unsigned int nScreen
);
67 virtual int ShowNativeMessageBox( const String
& rTitle
,
68 const String
& rMessage
,
69 int nButtonCombination
,
73 SalSystem
* Os2SalInstance::CreateSalSystem()
75 return new Os2SalSystem();
78 Os2SalSystem::~Os2SalSystem()
82 // -----------------------------------------------------------------------
84 bool Os2SalSystem::GetSalSystemDisplayInfo( DisplayInfo
& rInfo
)
87 if( hDC
= WinQueryWindowDC(HWND_DESKTOP
) )
90 DevQueryCaps(hDC
, CAPS_COLOR_BITCOUNT
, CAPS_COLOR_BITCOUNT
, &bitCount
);
91 rInfo
.nWidth
= WinQuerySysValue( HWND_DESKTOP
, SV_CXSCREEN
);
92 rInfo
.nHeight
= WinQuerySysValue( HWND_DESKTOP
, SV_CYSCREEN
);
93 rInfo
.nDepth
= bitCount
;
101 unsigned int Os2SalSystem::GetDisplayScreenCount()
106 Rectangle
Os2SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen
)
109 aRet
= Rectangle( Point(), Point( WinQuerySysValue( HWND_DESKTOP
, SV_CXSCREEN
),
110 WinQuerySysValue( HWND_DESKTOP
, SV_CYSCREEN
) ) );
114 // -----------------------------------------------------------------------
115 /* We have to map the button identifier to the identifier used by the Os232
116 Platform SDK to specify the default button for the MessageBox API.
117 The first dimension is the button combination, the second dimension
118 is the button identifier.
120 static int DEFAULT_BTN_MAPPING_TABLE
[][8] =
122 // Undefined OK CANCEL ABORT RETRY IGNORE YES NO
123 { MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
}, //OK
124 { MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON2
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
}, //OK_CANCEL
125 { MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON2
, MB_DEFBUTTON3
, MB_DEFBUTTON1
, MB_DEFBUTTON1
}, //ABORT_RETRY_IGNO
126 { MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON3
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON2
}, //YES_NO_CANCEL
127 { MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON2
}, //YES_NO
128 { MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON2
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
, MB_DEFBUTTON1
} //RETRY_CANCEL
131 static int COMBI_BTN_MAPPING_TABLE
[] =
133 MB_OK
, MB_OKCANCEL
, MB_ABORTRETRYIGNORE
, MB_YESNO
, MB_YESNOCANCEL
, MB_RETRYCANCEL
136 int Os2SalSystem::ShowNativeMessageBox(const String
& rTitle
, const String
& rMessage
, int nButtonCombination
, int nDefaultButton
)
138 DBG_ASSERT( nButtonCombination
>= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK
&&
139 nButtonCombination
<= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL
&&
140 nDefaultButton
>= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK
&&
141 nDefaultButton
<= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO
, "Invalid arguments!" );
143 int nFlags
= MB_APPLMODAL
| MB_WARNING
| COMBI_BTN_MAPPING_TABLE
[nButtonCombination
];
145 if (nButtonCombination
>= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK
&&
146 nButtonCombination
<= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL
&&
147 nDefaultButton
>= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK
&&
148 nDefaultButton
<= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO
)
149 nFlags
|= DEFAULT_BTN_MAPPING_TABLE
[nButtonCombination
][nDefaultButton
];
151 //#107209 hide the splash screen if active
152 ImplSVData
* pSVData
= ImplGetSVData();
153 if (pSVData
->mpIntroWindow
)
154 pSVData
->mpIntroWindow
->Hide();
156 return WinMessageBox(
157 HWND_DESKTOP
, HWND_DESKTOP
,
158 (PSZ
)CHAR_POINTER(rMessage
),
159 (PSZ
)CHAR_POINTER(rTitle
),
164 unsigned int Os2SalSystem::GetDefaultDisplayNumber()
169 bool Os2SalSystem::IsMultiDisplay()
174 Rectangle
Os2SalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen
)
176 return GetDisplayScreenPosSizePixel( nScreen
);
179 rtl::OUString
Os2SalSystem::GetScreenName( unsigned int nScreen
)
181 rtl::OUStringBuffer
aBuf( 32 );
182 aBuf
.appendAscii( "VirtualScreen " );
183 aBuf
.append( sal_Int32(nScreen
) );
184 return aBuf
.makeStringAndClear();