1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "AppTitleWindow.hxx"
21 #include "moduledbu.hxx"
23 #include <vcl/svapp.hxx>
24 #include <tools/debug.hxx>
29 DBG_NAME(OTitleWindow
)
30 OTitleWindow::OTitleWindow(Window
* _pParent
,sal_uInt16 _nTitleId
,WinBits _nBits
,sal_Bool _bShift
)
31 : Window(_pParent
,_nBits
| WB_DIALOGCONTROL
)
38 DBG_CTOR(OTitleWindow
,NULL
);
41 SetBorderStyle(WINDOW_BORDER_MONO
);
42 ImplInitSettings( sal_True
, sal_True
, sal_True
);
44 Window
* pWindows
[] = { &m_aSpace1
, &m_aSpace2
, &m_aTitle
};
45 for (size_t i
=0; i
< sizeof(pWindows
)/sizeof(pWindows
[0]); ++i
)
48 // -----------------------------------------------------------------------------
49 OTitleWindow::~OTitleWindow()
54 ::std::auto_ptr
<Window
> aTemp(m_pChild
);
58 DBG_DTOR(OTitleWindow
,NULL
);
60 // -----------------------------------------------------------------------------
61 void OTitleWindow::setChildWindow(Window
* _pChild
)
65 #define SPACE_BORDER 1
66 // -----------------------------------------------------------------------------
67 void OTitleWindow::Resize()
69 // parent window dimension
70 Size
aOutputSize( GetOutputSize() );
71 long nOutputWidth
= aOutputSize
.Width();
72 long nOutputHeight
= aOutputSize
.Height();
74 Size aTextSize
= LogicToPixel( Size( 6, 3 ), MAP_APPFONT
);
75 sal_Int32 nXOffset
= aTextSize
.Width();
76 sal_Int32 nYOffset
= aTextSize
.Height();
77 sal_Int32 nHeight
= GetTextHeight() + 2*nYOffset
;
79 m_aSpace1
.SetPosSizePixel( Point(SPACE_BORDER
, SPACE_BORDER
),
80 Size(nXOffset
, nHeight
- SPACE_BORDER
) );
81 m_aSpace2
.SetPosSizePixel( Point(nXOffset
+ SPACE_BORDER
, SPACE_BORDER
),
82 Size(nOutputWidth
- nXOffset
- 2*SPACE_BORDER
, nYOffset
) );
83 m_aTitle
.SetPosSizePixel( Point(nXOffset
+ SPACE_BORDER
, nYOffset
+ SPACE_BORDER
),
84 Size(nOutputWidth
- nXOffset
- 2*SPACE_BORDER
, nHeight
- nYOffset
- SPACE_BORDER
) );
87 m_pChild
->SetPosSizePixel( Point(m_bShift
? (nXOffset
+SPACE_BORDER
) : sal_Int32(SPACE_BORDER
), nHeight
+ nXOffset
+ SPACE_BORDER
),
88 Size(nOutputWidth
- ( m_bShift
? (2*nXOffset
- 2*SPACE_BORDER
) : sal_Int32(SPACE_BORDER
) ), nOutputHeight
- nHeight
- 2*nXOffset
- 2*SPACE_BORDER
) );
91 // -----------------------------------------------------------------------------
92 void OTitleWindow::setTitle(sal_uInt16 _nTitleId
)
96 m_aTitle
.SetText(ModuleRes(_nTitleId
));
99 // -----------------------------------------------------------------------------
100 void OTitleWindow::GetFocus()
104 m_pChild
->GrabFocus();
106 // -----------------------------------------------------------------------------
107 long OTitleWindow::GetWidthPixel() const
109 Size aTextSize
= LogicToPixel( Size( 12, 0 ), MAP_APPFONT
);
110 sal_Int32 nWidth
= GetTextWidth(m_aTitle
.GetText()) + 2*aTextSize
.Width();
114 // -----------------------------------------------------------------------
115 void OTitleWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
117 Window::DataChanged( rDCEvt
);
119 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
120 (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
121 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
122 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
123 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
125 ImplInitSettings( sal_True
, sal_True
, sal_True
);
129 //-----------------------------------------------------------------------------
130 void OTitleWindow::ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
)
132 AllSettings aAllSettings
= GetSettings();
133 StyleSettings aStyle
= aAllSettings
.GetStyleSettings();
134 aStyle
.SetMonoColor(aStyle
.GetActiveBorderColor());//GetMenuBorderColor());
135 aAllSettings
.SetStyleSettings(aStyle
);
136 SetSettings(aAllSettings
);
138 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
142 aFont
= rStyleSettings
.GetFieldFont();
143 aFont
.SetColor( rStyleSettings
.GetWindowTextColor() );
144 SetPointFont( aFont
);
147 if( bForeground
|| bFont
)
149 SetTextColor( rStyleSettings
.GetFieldTextColor() );
154 SetBackground( rStyleSettings
.GetFieldColor() );
157 Window
* pWindows
[] = { &m_aSpace1
, &m_aSpace2
, &m_aTitle
};
158 for (size_t i
=0; i
< sizeof(pWindows
)/sizeof(pWindows
[0]); ++i
)
160 Font aFont
= pWindows
[i
]->GetFont();
161 aFont
.SetWeight(WEIGHT_BOLD
);
162 pWindows
[i
]->SetFont(aFont
);
163 pWindows
[i
]->SetTextColor( aStyle
.GetLightColor() );
164 pWindows
[i
]->SetBackground( Wallpaper( aStyle
.GetShadowColor() ) );
167 // .............................................................
169 // .............................................................
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */