Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / app / AppTitleWindow.cxx
blob19da267be74982d7775b299b03b3d441d94b25ec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
22 #include <vcl/svapp.hxx>
23 #include <vcl/settings.hxx>
24 #include <tools/debug.hxx>
25 #include <boost/scoped_ptr.hpp>
27 namespace dbaui
30 OTitleWindow::OTitleWindow(vcl::Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,bool _bShift)
31 : Window(_pParent,_nBits | WB_DIALOGCONTROL)
32 , m_aSpace1(VclPtr<FixedText>::Create(this))
33 , m_aSpace2(VclPtr<FixedText>::Create(this))
34 , m_aTitle(VclPtr<FixedText>::Create(this))
35 , m_pChild(NULL)
36 , m_bShift(_bShift)
39 setTitle(_nTitleId);
40 SetBorderStyle(WindowBorderStyle::MONO);
41 ImplInitSettings( true, true, true );
43 const StyleSettings& rStyle = Application::GetSettings().GetStyleSettings();
44 vcl::Window* pWindows[] = { m_aSpace1.get(), m_aSpace2.get(), m_aTitle.get() };
45 for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
47 vcl::Font aFont = pWindows[i]->GetControlFont();
48 aFont.SetWeight(WEIGHT_BOLD);
49 pWindows[i]->SetControlFont(aFont);
50 pWindows[i]->SetControlForeground(rStyle.GetLightColor());
51 pWindows[i]->SetControlBackground(rStyle.GetShadowColor());
52 pWindows[i]->Show();
56 OTitleWindow::~OTitleWindow()
58 disposeOnce();
61 void OTitleWindow::dispose()
63 if ( m_pChild )
65 m_pChild->Hide();
67 m_pChild.disposeAndClear();
68 m_aSpace1.disposeAndClear();
69 m_aSpace2.disposeAndClear();
70 m_aTitle.disposeAndClear();
71 vcl::Window::dispose();
74 void OTitleWindow::setChildWindow(vcl::Window* _pChild)
76 m_pChild = _pChild;
79 #define SPACE_BORDER 1
80 void OTitleWindow::Resize()
82 // parent window dimension
83 Size aOutputSize( GetOutputSize() );
84 long nOutputWidth = aOutputSize.Width();
85 long nOutputHeight = aOutputSize.Height();
87 Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT );
88 sal_Int32 nXOffset = aTextSize.Width();
89 sal_Int32 nYOffset = aTextSize.Height();
90 sal_Int32 nHeight = GetTextHeight() + 2*nYOffset;
92 m_aSpace1->SetPosSizePixel( Point(SPACE_BORDER, SPACE_BORDER ),
93 Size(nXOffset , nHeight - SPACE_BORDER) );
94 m_aSpace2->SetPosSizePixel( Point(nXOffset + SPACE_BORDER, SPACE_BORDER ),
95 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) );
96 m_aTitle->SetPosSizePixel( Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER),
97 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) );
98 if ( m_pChild )
100 m_pChild->SetPosSizePixel( Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER),
101 Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) );
105 void OTitleWindow::setTitle(sal_uInt16 _nTitleId)
107 if ( _nTitleId != 0 )
109 m_aTitle->SetText(ModuleRes(_nTitleId));
113 void OTitleWindow::GetFocus()
115 Window::GetFocus();
116 if ( m_pChild )
117 m_pChild->GrabFocus();
120 long OTitleWindow::GetWidthPixel() const
122 Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT );
123 sal_Int32 nWidth = GetTextWidth(m_aTitle->GetText()) + 2*aTextSize.Width();
125 return nWidth;
128 void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt )
130 Window::DataChanged( rDCEvt );
132 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
133 (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
134 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
135 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
136 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
138 ImplInitSettings( true, true, true );
139 Invalidate();
143 void OTitleWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
145 // FIXME RenderContext
146 AllSettings aAllSettings = GetSettings();
147 StyleSettings aStyle = aAllSettings.GetStyleSettings();
148 aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
149 aAllSettings.SetStyleSettings(aStyle);
150 SetSettings(aAllSettings);
152 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
153 if( bFont )
155 vcl::Font aFont;
156 aFont = rStyleSettings.GetFieldFont();
157 aFont.SetColor( rStyleSettings.GetWindowTextColor() );
158 SetPointFont(*this, aFont);
161 if( bForeground || bFont )
163 SetTextColor( rStyleSettings.GetFieldTextColor() );
164 SetTextFillColor();
167 if( bBackground )
168 SetBackground( rStyleSettings.GetFieldColor() );
171 void OTitleWindow::ApplySettings(vcl::RenderContext& rRenderContext)
173 // FIXME RenderContext
174 AllSettings aAllSettings = rRenderContext.GetSettings();
175 StyleSettings aStyle = aAllSettings.GetStyleSettings();
176 aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
177 aAllSettings.SetStyleSettings(aStyle);
178 rRenderContext.SetSettings(aAllSettings);
180 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
181 vcl::Font aFont;
182 aFont = rStyleSettings.GetFieldFont();
183 aFont.SetColor(rStyleSettings.GetWindowTextColor());
184 SetPointFont(*this, aFont);
186 rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
187 rRenderContext.SetTextFillColor();
189 rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
192 } // namespace dbaui
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */