Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / app / AppTitleWindow.cxx
bloba9fee272763e1f7e78c850251ec8eef256ec11d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #include "AppTitleWindow.hxx"
30 #include "moduledbu.hxx"
31 #include "memory"
32 #include <vcl/svapp.hxx>
33 #include <tools/debug.hxx>
35 namespace dbaui
38 DBG_NAME(OTitleWindow)
39 OTitleWindow::OTitleWindow(Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,sal_Bool _bShift)
40 : Window(_pParent,_nBits | WB_DIALOGCONTROL)
41 , m_aSpace1(this)
42 , m_aSpace2(this)
43 , m_aTitle(this)
44 , m_pChild(NULL)
45 , m_bShift(_bShift)
47 DBG_CTOR(OTitleWindow,NULL);
49 setTitle(_nTitleId);
50 SetBorderStyle(WINDOW_BORDER_MONO);
51 ImplInitSettings( sal_True, sal_True, sal_True );
53 Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle };
54 for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
55 pWindows[i]->Show();
57 // -----------------------------------------------------------------------------
58 OTitleWindow::~OTitleWindow()
60 if ( m_pChild )
62 m_pChild->Hide();
63 ::std::auto_ptr<Window> aTemp(m_pChild);
64 m_pChild = NULL;
67 DBG_DTOR(OTitleWindow,NULL);
69 // -----------------------------------------------------------------------------
70 void OTitleWindow::setChildWindow(Window* _pChild)
72 m_pChild = _pChild;
74 #define SPACE_BORDER 1
75 // -----------------------------------------------------------------------------
76 void OTitleWindow::Resize()
78 // parent window dimension
79 Size aOutputSize( GetOutputSize() );
80 long nOutputWidth = aOutputSize.Width();
81 long nOutputHeight = aOutputSize.Height();
83 Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT );
84 sal_Int32 nXOffset = aTextSize.Width();
85 sal_Int32 nYOffset = aTextSize.Height();
86 sal_Int32 nHeight = GetTextHeight() + 2*nYOffset;
88 m_aSpace1.SetPosSizePixel( Point(SPACE_BORDER, SPACE_BORDER ),
89 Size(nXOffset , nHeight - SPACE_BORDER) );
90 m_aSpace2.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, SPACE_BORDER ),
91 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) );
92 m_aTitle.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER),
93 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) );
94 if ( m_pChild )
96 m_pChild->SetPosSizePixel( Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER),
97 Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) );
100 // -----------------------------------------------------------------------------
101 void OTitleWindow::setTitle(sal_uInt16 _nTitleId)
103 if ( _nTitleId != 0 )
105 m_aTitle.SetText(ModuleRes(_nTitleId));
108 // -----------------------------------------------------------------------------
109 void OTitleWindow::GetFocus()
111 Window::GetFocus();
112 if ( m_pChild )
113 m_pChild->GrabFocus();
115 // -----------------------------------------------------------------------------
116 long OTitleWindow::GetWidthPixel() const
118 Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT );
119 sal_Int32 nWidth = GetTextWidth(m_aTitle.GetText()) + 2*aTextSize.Width();
121 return nWidth;
123 // -----------------------------------------------------------------------
124 void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt )
126 Window::DataChanged( rDCEvt );
128 if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
129 (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
130 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
131 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
132 (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
134 ImplInitSettings( sal_True, sal_True, sal_True );
135 Invalidate();
138 //-----------------------------------------------------------------------------
139 void OTitleWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
141 AllSettings aAllSettings = GetSettings();
142 StyleSettings aStyle = aAllSettings.GetStyleSettings();
143 aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
144 aAllSettings.SetStyleSettings(aStyle);
145 SetSettings(aAllSettings);
147 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
148 if( bFont )
150 Font aFont;
151 aFont = rStyleSettings.GetFieldFont();
152 aFont.SetColor( rStyleSettings.GetWindowTextColor() );
153 SetPointFont( aFont );
156 if( bForeground || bFont )
158 SetTextColor( rStyleSettings.GetFieldTextColor() );
159 SetTextFillColor();
162 if( bBackground )
163 SetBackground( rStyleSettings.GetFieldColor() );
166 Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle};
167 for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
169 Font aFont = pWindows[i]->GetFont();
170 aFont.SetWeight(WEIGHT_BOLD);
171 pWindows[i]->SetFont(aFont);
172 pWindows[i]->SetTextColor( aStyle.GetLightColor() );
173 pWindows[i]->SetBackground( Wallpaper( aStyle.GetShadowColor() ) );
176 // .............................................................
177 } // namespace dbaui
178 // .............................................................
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */