Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <unx/salunx.h>
31 : : #include <unx/saldata.hxx>
32 : : #include <unx/salinst.h>
33 : : #include <unx/saldisp.hxx>
34 : : #include <unx/x11/x11sys.hxx>
35 : :
36 : : #include <vcl/msgbox.hxx>
37 : : #include <vcl/button.hxx>
38 : :
39 : : #include <svdata.hxx>
40 : :
41 : : #include <rtl/ustrbuf.hxx>
42 : : #include <osl/thread.h>
43 : :
44 : :
45 : 0 : SalSystem* X11SalInstance::CreateSalSystem()
46 : : {
47 : 0 : return new X11SalSystem();
48 : : }
49 : :
50 : : // -----------------------------------------------------------------------
51 : :
52 : 0 : X11SalSystem::~X11SalSystem()
53 : : {
54 : 0 : }
55 : :
56 : : // for the moment only handle xinerama case
57 : 0 : unsigned int X11SalSystem::GetDisplayScreenCount()
58 : : {
59 : 0 : SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
60 : 0 : return pSalDisp->IsXinerama() ? pSalDisp->GetXineramaScreens().size() :
61 : 0 : pSalDisp->GetXScreenCount();
62 : : }
63 : :
64 : 0 : bool X11SalSystem::IsUnifiedDisplay()
65 : : {
66 : 0 : SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
67 : 0 : unsigned int nScreenCount = pSalDisp->GetXScreenCount();
68 : 0 : return pSalDisp->IsXinerama() ? true : (nScreenCount == 1);
69 : : }
70 : :
71 : 0 : unsigned int X11SalSystem::GetDisplayBuiltInScreen()
72 : : {
73 : 0 : SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
74 : 0 : return pSalDisp->GetDefaultXScreen().getXScreen();
75 : : }
76 : :
77 : 0 : Rectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
78 : : {
79 : 0 : Rectangle aRet;
80 : 0 : SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
81 : 0 : if( pSalDisp->IsXinerama() )
82 : : {
83 : 0 : const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
84 : 0 : if( nScreen < rScreens.size() )
85 : 0 : aRet = rScreens[nScreen];
86 : : }
87 : : else
88 : : {
89 : : const SalDisplay::ScreenData& rScreen =
90 : 0 : pSalDisp->getDataForScreen( SalX11Screen( nScreen ) );
91 : 0 : aRet = Rectangle( Point( 0, 0 ), rScreen.m_aSize );
92 : : }
93 : :
94 : 0 : return aRet;
95 : : }
96 : :
97 : 0 : Rectangle X11SalSystem::GetDisplayScreenWorkAreaPosSizePixel( unsigned int nScreen )
98 : : {
99 : : // FIXME: workareas
100 : 0 : return GetDisplayScreenPosSizePixel( nScreen );
101 : : }
102 : :
103 : 0 : rtl::OUString X11SalSystem::GetDisplayScreenName( unsigned int nScreen )
104 : : {
105 : 0 : rtl::OUString aScreenName;
106 : 0 : SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
107 : 0 : if( pSalDisp->IsXinerama() )
108 : : {
109 : 0 : const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
110 : 0 : if( nScreen >= rScreens.size() )
111 : 0 : nScreen = 0;
112 : 0 : rtl::OUStringBuffer aBuf( 256 );
113 : 0 : aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
114 : 0 : aBuf.appendAscii( " [" );
115 : 0 : aBuf.append( static_cast<sal_Int32>(nScreen) );
116 : 0 : aBuf.append( sal_Unicode(']') );
117 : 0 : aScreenName = aBuf.makeStringAndClear();
118 : : }
119 : : else
120 : : {
121 : 0 : if( nScreen >= static_cast<unsigned int>(pSalDisp->GetXScreenCount()) )
122 : 0 : nScreen = 0;
123 : 0 : rtl::OUStringBuffer aBuf( 256 );
124 : 0 : aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
125 : : // search backwards for ':'
126 : 0 : int nPos = aBuf.getLength();
127 : 0 : if( nPos > 0 )
128 : 0 : nPos--;
129 : 0 : while( nPos > 0 && aBuf[nPos] != ':' )
130 : 0 : nPos--;
131 : : // search forward to '.'
132 : 0 : while( nPos < aBuf.getLength() && aBuf[nPos] != '.' )
133 : 0 : nPos++;
134 : 0 : if( nPos < aBuf.getLength() )
135 : 0 : aBuf.setLength( nPos+1 );
136 : : else
137 : 0 : aBuf.append( sal_Unicode('.') );
138 : 0 : aBuf.append( static_cast<sal_Int32>(nScreen) );
139 : 0 : aScreenName = aBuf.makeStringAndClear();
140 : : }
141 : 0 : return aScreenName;
142 : : }
143 : :
144 : 0 : int X11SalSystem::ShowNativeDialog( const rtl::OUString& rTitle, const rtl::OUString& rMessage, const std::list< rtl::OUString >& rButtons, int nDefButton )
145 : : {
146 : 0 : int nRet = -1;
147 : :
148 : 0 : ImplSVData* pSVData = ImplGetSVData();
149 : 0 : if( pSVData->mpIntroWindow )
150 : 0 : pSVData->mpIntroWindow->Hide();
151 : :
152 : 0 : WarningBox aWarn( NULL, WB_STDWORK, rMessage );
153 : 0 : aWarn.SetText( rTitle );
154 : 0 : aWarn.Clear();
155 : :
156 : 0 : sal_uInt16 nButton = 0;
157 : 0 : for( std::list< rtl::OUString >::const_iterator it = rButtons.begin(); it != rButtons.end(); ++it )
158 : : {
159 : 0 : aWarn.AddButton( *it, nButton+1, nButton == (sal_uInt16)nDefButton ? BUTTONDIALOG_DEFBUTTON : 0 );
160 : 0 : nButton++;
161 : : }
162 : 0 : aWarn.SetFocusButton( (sal_uInt16)nDefButton+1 );
163 : :
164 : 0 : nRet = ((int)aWarn.Execute()) - 1;
165 : :
166 : : // normalize behaviour, actually this should never happen
167 : 0 : if( nRet < -1 || nRet >= int(rButtons.size()) )
168 : 0 : nRet = -1;
169 : :
170 : 0 : return nRet;
171 : : }
172 : :
173 : :
174 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|