Line 0
Link Here
|
|
|
1 |
/************************************************************************* |
2 |
* |
3 |
* OpenOffice.org - a multi-platform office productivity suite |
4 |
* |
5 |
* $RCSfile: macosxint.cxx,v $ |
6 |
* |
7 |
* $Revision: 1.0 $ |
8 |
* |
9 |
* last change: $Author: mox $ $Date: 2006/01/28 10:39:13 $ |
10 |
* |
11 |
* The Contents of this file are made available subject to |
12 |
* the terms of GNU Lesser General Public License Version 2.1. |
13 |
* |
14 |
* |
15 |
* GNU Lesser General Public License Version 2.1 |
16 |
* ============================================= |
17 |
* Copyright 2005 by Sun Microsystems, Inc. |
18 |
* 901 San Antonio Road, Palo Alto, CA 94303, USA |
19 |
* |
20 |
* This library is free software; you can redistribute it and/or |
21 |
* modify it under the terms of the GNU Lesser General Public |
22 |
* License version 2.1, as published by the Free Software Foundation. |
23 |
* |
24 |
* This library is distributed in the hope that it will be useful, |
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27 |
* Lesser General Public License for more details. |
28 |
* |
29 |
* You should have received a copy of the GNU Lesser General Public |
30 |
* License along with this library; if not, write to the Free Software |
31 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
32 |
* MA 02111-1307 USA |
33 |
* |
34 |
************************************************************************/ |
35 |
|
36 |
#include <macosxint.hxx> |
37 |
#include <tools/config.hxx> |
38 |
#include <settings.hxx> |
39 |
|
40 |
#include <osl/thread.h> |
41 |
|
42 |
#include <unistd.h> |
43 |
#include <cstdio> |
44 |
|
45 |
using namespace rtl; |
46 |
using namespace osl; |
47 |
|
48 |
MACOSXIntegrator::MACOSXIntegrator() |
49 |
{ |
50 |
meType = DtMACOSX; |
51 |
} |
52 |
|
53 |
MACOSXIntegrator::~MACOSXIntegrator() |
54 |
{ |
55 |
} |
56 |
|
57 |
static const char* pTryFiles[] = |
58 |
{ |
59 |
"~/Library/Application Support/OpenOffice.org2/macosxrc" |
60 |
}; |
61 |
|
62 |
void MACOSXIntegrator::GetSystemLook( AllSettings& rSettings ) |
63 |
{ |
64 |
rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); |
65 |
|
66 |
StyleSettings aStyleSettings( rSettings.GetStyleSettings() ); |
67 |
// #i48001# set a default blink rate |
68 |
aStyleSettings.SetCursorBlinkTime( 500 ); |
69 |
|
70 |
for( unsigned int i = 0; (i < sizeof( pTryFiles )/sizeof(pTryFiles[0])); i++ ) |
71 |
{ |
72 |
String aFile; |
73 |
if( pTryFiles[i][0] == '~' ) |
74 |
{ |
75 |
aFile = aHomeDir; |
76 |
aFile += String( pTryFiles[i]+1, aEncoding ); |
77 |
} |
78 |
else |
79 |
aFile = String( ByteString( pTryFiles[i] ), aEncoding ); |
80 |
|
81 |
if( access( ByteString( aFile, aEncoding ).GetBuffer(), R_OK ) ) |
82 |
continue; |
83 |
|
84 |
#if OSL_DEBUG_LEVEL > 1 |
85 |
fprintf( stderr, "using %s for style settings\n", ByteString( aFile, aEncoding ).GetBuffer() ); |
86 |
#endif |
87 |
|
88 |
Config aConfig( aFile ); |
89 |
ByteString aLine; |
90 |
|
91 |
if( aConfig.HasGroup( "General" ) ) |
92 |
{ |
93 |
aConfig.SetGroup( "General" ); |
94 |
|
95 |
aLine = aConfig.ReadKey( "foreground" ); |
96 |
if( aLine.GetTokenCount( ',' ) >= 3 ) |
97 |
{ |
98 |
Color aFore( aLine.GetToken( 0, ',' ).ToInt32(), |
99 |
aLine.GetToken( 1, ',' ).ToInt32(), |
100 |
aLine.GetToken( 2, ',' ).ToInt32() ); |
101 |
aStyleSettings.SetDialogTextColor( aFore ); |
102 |
aStyleSettings.SetMenuTextColor( aFore ); |
103 |
aStyleSettings.SetButtonTextColor( aFore ); |
104 |
aStyleSettings.SetRadioCheckTextColor( aFore ); |
105 |
aStyleSettings.SetGroupTextColor( aFore ); |
106 |
aStyleSettings.SetLabelTextColor( aFore ); |
107 |
aStyleSettings.SetInfoTextColor( aFore ); |
108 |
} |
109 |
|
110 |
aLine = aConfig.ReadKey( "background" ); |
111 |
if( aLine.GetTokenCount( ',' ) >= 3 ) |
112 |
{ |
113 |
Color aBack( aLine.GetToken( 0, ',' ).ToInt32(), |
114 |
aLine.GetToken( 1, ',' ).ToInt32(), |
115 |
aLine.GetToken( 2, ',' ).ToInt32() ); |
116 |
aStyleSettings.Set3DColors( aBack ); |
117 |
aStyleSettings.SetFaceColor( aBack ); |
118 |
aStyleSettings.SetDialogColor( aBack ); |
119 |
aStyleSettings.SetMenuColor( aBack ); |
120 |
aStyleSettings.SetMenuBarColor( aBack ); |
121 |
if( aBack == COL_LIGHTGRAY ) |
122 |
aStyleSettings.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) ); |
123 |
else |
124 |
{ |
125 |
Color aColor2 = aStyleSettings.GetLightColor(); |
126 |
aStyleSettings. |
127 |
SetCheckedColor( Color( (BYTE)(((USHORT)aBack.GetRed()+(USHORT)aColor2.GetRed())/2), |
128 |
(BYTE)(((USHORT)aBack.GetGreen()+(USHORT)aColor2.GetGreen())/2), |
129 |
(BYTE)(((USHORT)aBack.GetBlue()+(USHORT)aColor2.GetBlue())/2) |
130 |
) ); |
131 |
} |
132 |
} |
133 |
|
134 |
aLine = aConfig.ReadKey( "selectForeground" ); |
135 |
if( aLine.GetTokenCount( ',' ) >= 3 ) |
136 |
aStyleSettings. |
137 |
SetHighlightTextColor( Color( aLine.GetToken( 0, ',' ).ToInt32(), |
138 |
aLine.GetToken( 1, ',' ).ToInt32(), |
139 |
aLine.GetToken( 2, ',' ).ToInt32() ) ); |
140 |
|
141 |
aLine = aConfig.ReadKey( "selectBackground" ); |
142 |
if( aLine.GetTokenCount( ',' ) >= 3 ) |
143 |
aStyleSettings. |
144 |
SetHighlightColor( Color( aLine.GetToken( 0, ',' ).ToInt32(), |
145 |
aLine.GetToken( 1, ',' ).ToInt32(), |
146 |
aLine.GetToken( 2, ',' ).ToInt32() ) ); |
147 |
|
148 |
aLine = aConfig.ReadKey( "font" ); |
149 |
if( aLine.Len() ) |
150 |
{ |
151 |
Font aFont = aStyleSettings.GetAppFont(); |
152 |
String aFontName( aLine, RTL_TEXTENCODING_UTF8 ); |
153 |
if( aFontName.GetTokenCount( ',' ) > 0 ) |
154 |
aFontName = aFontName.GetToken( 0, ',' ); |
155 |
aFont.SetName( aFontName ); |
156 |
|
157 |
aStyleSettings.SetAppFont( aFont ); |
158 |
aStyleSettings.SetHelpFont( aFont ); |
159 |
aStyleSettings.SetTitleFont( aFont ); |
160 |
aStyleSettings.SetFloatTitleFont( aFont ); |
161 |
aStyleSettings.SetMenuFont( aFont ); |
162 |
aStyleSettings.SetToolFont( aFont ); |
163 |
aStyleSettings.SetLabelFont( aFont ); |
164 |
aStyleSettings.SetInfoFont( aFont ); |
165 |
aStyleSettings.SetRadioCheckFont( aFont ); |
166 |
aStyleSettings.SetPushButtonFont( aFont ); |
167 |
aStyleSettings.SetFieldFont( aFont ); |
168 |
aStyleSettings.SetIconFont( aFont ); |
169 |
aStyleSettings.SetGroupFont( aFont ); |
170 |
} |
171 |
|
172 |
aLine = aConfig.ReadKey( "cursorFlashTime" ); |
173 |
if( aLine.Len() ) |
174 |
{ |
175 |
sal_Int32 nTime = aLine.ToInt32() / 2; |
176 |
if( nTime == 0 ) |
177 |
nTime = STYLE_CURSOR_NOBLINKTIME; |
178 |
aStyleSettings.SetCursorBlinkTime( nTime ); |
179 |
} |
180 |
} |
181 |
} |
182 |
|
183 |
rSettings.SetStyleSettings( aStyleSettings ); |
184 |
} |