1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir #ifndef DBAUI_TITLE_WINDOW_HXX 31*cdf0e10cSrcweir #include "AppTitleWindow.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 34*cdf0e10cSrcweir #include "moduledbu.hxx" 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #include "memory" 37*cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX //autogen 38*cdf0e10cSrcweir #include <vcl/svapp.hxx> 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX 41*cdf0e10cSrcweir #include <tools/debug.hxx> 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir namespace dbaui 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir DBG_NAME(OTitleWindow) 48*cdf0e10cSrcweir OTitleWindow::OTitleWindow(Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,sal_Bool _bShift) 49*cdf0e10cSrcweir : Window(_pParent,_nBits | WB_DIALOGCONTROL) 50*cdf0e10cSrcweir , m_aSpace1(this) 51*cdf0e10cSrcweir , m_aSpace2(this) 52*cdf0e10cSrcweir , m_aTitle(this) 53*cdf0e10cSrcweir , m_pChild(NULL) 54*cdf0e10cSrcweir , m_bShift(_bShift) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir DBG_CTOR(OTitleWindow,NULL); 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir setTitle(_nTitleId); 59*cdf0e10cSrcweir SetBorderStyle(WINDOW_BORDER_MONO); 60*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle }; 63*cdf0e10cSrcweir for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i) 64*cdf0e10cSrcweir pWindows[i]->Show(); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 67*cdf0e10cSrcweir OTitleWindow::~OTitleWindow() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir if ( m_pChild ) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir m_pChild->Hide(); 72*cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pChild); 73*cdf0e10cSrcweir m_pChild = NULL; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir DBG_DTOR(OTitleWindow,NULL); 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 79*cdf0e10cSrcweir void OTitleWindow::setChildWindow(Window* _pChild) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir m_pChild = _pChild; 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir #define SPACE_BORDER 1 84*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 85*cdf0e10cSrcweir void OTitleWindow::Resize() 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 88*cdf0e10cSrcweir // Abmessungen parent window 89*cdf0e10cSrcweir Size aOutputSize( GetOutputSize() ); 90*cdf0e10cSrcweir long nOutputWidth = aOutputSize.Width(); 91*cdf0e10cSrcweir long nOutputHeight = aOutputSize.Height(); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT ); 94*cdf0e10cSrcweir sal_Int32 nXOffset = aTextSize.Width(); 95*cdf0e10cSrcweir sal_Int32 nYOffset = aTextSize.Height(); 96*cdf0e10cSrcweir sal_Int32 nHeight = GetTextHeight() + 2*nYOffset; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir m_aSpace1.SetPosSizePixel( Point(SPACE_BORDER, SPACE_BORDER ), 99*cdf0e10cSrcweir Size(nXOffset , nHeight - SPACE_BORDER) ); 100*cdf0e10cSrcweir m_aSpace2.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, SPACE_BORDER ), 101*cdf0e10cSrcweir Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) ); 102*cdf0e10cSrcweir m_aTitle.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER), 103*cdf0e10cSrcweir Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) ); 104*cdf0e10cSrcweir if ( m_pChild ) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir m_pChild->SetPosSizePixel( Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER), 107*cdf0e10cSrcweir Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 111*cdf0e10cSrcweir void OTitleWindow::setTitle(sal_uInt16 _nTitleId) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir if ( _nTitleId != 0 ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir m_aTitle.SetText(ModuleRes(_nTitleId)); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 119*cdf0e10cSrcweir void OTitleWindow::GetFocus() 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir Window::GetFocus(); 122*cdf0e10cSrcweir if ( m_pChild ) 123*cdf0e10cSrcweir m_pChild->GrabFocus(); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 126*cdf0e10cSrcweir long OTitleWindow::GetWidthPixel() const 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT ); 129*cdf0e10cSrcweir sal_Int32 nWidth = GetTextWidth(m_aTitle.GetText()) + 2*aTextSize.Width(); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir return nWidth; 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir // ----------------------------------------------------------------------- 134*cdf0e10cSrcweir void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_FONTS) || 139*cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_DISPLAY) || 140*cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || 141*cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && 142*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 145*cdf0e10cSrcweir Invalidate(); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir //----------------------------------------------------------------------------- 149*cdf0e10cSrcweir void OTitleWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir AllSettings aAllSettings = GetSettings(); 152*cdf0e10cSrcweir StyleSettings aStyle = aAllSettings.GetStyleSettings(); 153*cdf0e10cSrcweir aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor()); 154*cdf0e10cSrcweir aAllSettings.SetStyleSettings(aStyle); 155*cdf0e10cSrcweir SetSettings(aAllSettings); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 158*cdf0e10cSrcweir if( bFont ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir Font aFont; 161*cdf0e10cSrcweir aFont = rStyleSettings.GetFieldFont(); 162*cdf0e10cSrcweir aFont.SetColor( rStyleSettings.GetWindowTextColor() ); 163*cdf0e10cSrcweir SetPointFont( aFont ); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir if( bForeground || bFont ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir SetTextColor( rStyleSettings.GetFieldTextColor() ); 169*cdf0e10cSrcweir SetTextFillColor(); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if( bBackground ) 173*cdf0e10cSrcweir SetBackground( rStyleSettings.GetFieldColor() ); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle}; 177*cdf0e10cSrcweir for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir Font aFont = pWindows[i]->GetFont(); 180*cdf0e10cSrcweir aFont.SetWeight(WEIGHT_BOLD); 181*cdf0e10cSrcweir pWindows[i]->SetFont(aFont); 182*cdf0e10cSrcweir pWindows[i]->SetTextColor( aStyle.GetLightColor() ); 183*cdf0e10cSrcweir pWindows[i]->SetBackground( Wallpaper( aStyle.GetShadowColor() ) ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir // ............................................................. 187*cdf0e10cSrcweir } // namespace dbaui 188*cdf0e10cSrcweir // ............................................................. 189