bump product version to 4.1.6.2
[LibreOffice.git] / dbaccess / source / ui / app / AppTitleWindow.cxx
bloba75d6e5604dc068f14adb8ee590ab68b1b956ae9
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 "memory"
23 #include <vcl/svapp.hxx>
24 #include <tools/debug.hxx>
26 namespace dbaui
29 DBG_NAME(OTitleWindow)
30 OTitleWindow::OTitleWindow(Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,sal_Bool _bShift)
31 : Window(_pParent,_nBits | WB_DIALOGCONTROL)
32 , m_aSpace1(this)
33 , m_aSpace2(this)
34 , m_aTitle(this)
35 , m_pChild(NULL)
36 , m_bShift(_bShift)
38 DBG_CTOR(OTitleWindow,NULL);
40 setTitle(_nTitleId);
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)
46 pWindows[i]->Show();
48 // -----------------------------------------------------------------------------
49 OTitleWindow::~OTitleWindow()
51 if ( m_pChild )
53 m_pChild->Hide();
54 ::std::auto_ptr<Window> aTemp(m_pChild);
55 m_pChild = NULL;
58 DBG_DTOR(OTitleWindow,NULL);
60 // -----------------------------------------------------------------------------
61 void OTitleWindow::setChildWindow(Window* _pChild)
63 m_pChild = _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) );
85 if ( m_pChild )
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)
94 if ( _nTitleId != 0 )
96 m_aTitle.SetText(ModuleRes(_nTitleId));
99 // -----------------------------------------------------------------------------
100 void OTitleWindow::GetFocus()
102 Window::GetFocus();
103 if ( m_pChild )
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();
112 return nWidth;
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 );
126 Invalidate();
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();
139 if( bFont )
141 Font aFont;
142 aFont = rStyleSettings.GetFieldFont();
143 aFont.SetColor( rStyleSettings.GetWindowTextColor() );
144 SetPointFont( aFont );
147 if( bForeground || bFont )
149 SetTextColor( rStyleSettings.GetFieldTextColor() );
150 SetTextFillColor();
153 if( bBackground )
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 // .............................................................
168 } // namespace dbaui
169 // .............................................................
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */