1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*96de5490SAndrew Rist * distributed with this work for additional information
6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist * software distributed under the License is distributed on an
15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the
17*96de5490SAndrew Rist * specific language governing permissions and limitations
18*96de5490SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*96de5490SAndrew Rist *************************************************************/
21*96de5490SAndrew Rist
22*96de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_TITLE_WINDOW_HXX
27cdf0e10cSrcweir #include "AppTitleWindow.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_
30cdf0e10cSrcweir #include "moduledbu.hxx"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include "memory"
33cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX //autogen
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
37cdf0e10cSrcweir #include <tools/debug.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir
40cdf0e10cSrcweir namespace dbaui
41cdf0e10cSrcweir {
42cdf0e10cSrcweir
DBG_NAME(OTitleWindow)43cdf0e10cSrcweir DBG_NAME(OTitleWindow)
44cdf0e10cSrcweir OTitleWindow::OTitleWindow(Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,sal_Bool _bShift)
45cdf0e10cSrcweir : Window(_pParent,_nBits | WB_DIALOGCONTROL)
46cdf0e10cSrcweir , m_aSpace1(this)
47cdf0e10cSrcweir , m_aSpace2(this)
48cdf0e10cSrcweir , m_aTitle(this)
49cdf0e10cSrcweir , m_pChild(NULL)
50cdf0e10cSrcweir , m_bShift(_bShift)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir DBG_CTOR(OTitleWindow,NULL);
53cdf0e10cSrcweir
54cdf0e10cSrcweir setTitle(_nTitleId);
55cdf0e10cSrcweir SetBorderStyle(WINDOW_BORDER_MONO);
56cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True );
57cdf0e10cSrcweir
58cdf0e10cSrcweir Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle };
59cdf0e10cSrcweir for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
60cdf0e10cSrcweir pWindows[i]->Show();
61cdf0e10cSrcweir }
62cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OTitleWindow()63cdf0e10cSrcweir OTitleWindow::~OTitleWindow()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir if ( m_pChild )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir m_pChild->Hide();
68cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pChild);
69cdf0e10cSrcweir m_pChild = NULL;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
72cdf0e10cSrcweir DBG_DTOR(OTitleWindow,NULL);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir // -----------------------------------------------------------------------------
setChildWindow(Window * _pChild)75cdf0e10cSrcweir void OTitleWindow::setChildWindow(Window* _pChild)
76cdf0e10cSrcweir {
77cdf0e10cSrcweir m_pChild = _pChild;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir #define SPACE_BORDER 1
80cdf0e10cSrcweir // -----------------------------------------------------------------------------
Resize()81cdf0e10cSrcweir void OTitleWindow::Resize()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
84cdf0e10cSrcweir // Abmessungen parent window
85cdf0e10cSrcweir Size aOutputSize( GetOutputSize() );
86cdf0e10cSrcweir long nOutputWidth = aOutputSize.Width();
87cdf0e10cSrcweir long nOutputHeight = aOutputSize.Height();
88cdf0e10cSrcweir
89cdf0e10cSrcweir Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT );
90cdf0e10cSrcweir sal_Int32 nXOffset = aTextSize.Width();
91cdf0e10cSrcweir sal_Int32 nYOffset = aTextSize.Height();
92cdf0e10cSrcweir sal_Int32 nHeight = GetTextHeight() + 2*nYOffset;
93cdf0e10cSrcweir
94cdf0e10cSrcweir m_aSpace1.SetPosSizePixel( Point(SPACE_BORDER, SPACE_BORDER ),
95cdf0e10cSrcweir Size(nXOffset , nHeight - SPACE_BORDER) );
96cdf0e10cSrcweir m_aSpace2.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, SPACE_BORDER ),
97cdf0e10cSrcweir Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) );
98cdf0e10cSrcweir m_aTitle.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER),
99cdf0e10cSrcweir Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) );
100cdf0e10cSrcweir if ( m_pChild )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir m_pChild->SetPosSizePixel( Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER),
103cdf0e10cSrcweir Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir // -----------------------------------------------------------------------------
setTitle(sal_uInt16 _nTitleId)107cdf0e10cSrcweir void OTitleWindow::setTitle(sal_uInt16 _nTitleId)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir if ( _nTitleId != 0 )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir m_aTitle.SetText(ModuleRes(_nTitleId));
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetFocus()115cdf0e10cSrcweir void OTitleWindow::GetFocus()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir Window::GetFocus();
118cdf0e10cSrcweir if ( m_pChild )
119cdf0e10cSrcweir m_pChild->GrabFocus();
120cdf0e10cSrcweir }
121cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetWidthPixel() const122cdf0e10cSrcweir long OTitleWindow::GetWidthPixel() const
123cdf0e10cSrcweir {
124cdf0e10cSrcweir Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT );
125cdf0e10cSrcweir sal_Int32 nWidth = GetTextWidth(m_aTitle.GetText()) + 2*aTextSize.Width();
126cdf0e10cSrcweir
127cdf0e10cSrcweir return nWidth;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir // -----------------------------------------------------------------------
DataChanged(const DataChangedEvent & rDCEvt)130cdf0e10cSrcweir void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir Window::DataChanged( rDCEvt );
133cdf0e10cSrcweir
134cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
135cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
136cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
137cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
138cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True );
141cdf0e10cSrcweir Invalidate();
142cdf0e10cSrcweir }
143cdf0e10cSrcweir }
144cdf0e10cSrcweir //-----------------------------------------------------------------------------
ImplInitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)145cdf0e10cSrcweir void OTitleWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir AllSettings aAllSettings = GetSettings();
148cdf0e10cSrcweir StyleSettings aStyle = aAllSettings.GetStyleSettings();
149cdf0e10cSrcweir aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
150cdf0e10cSrcweir aAllSettings.SetStyleSettings(aStyle);
151cdf0e10cSrcweir SetSettings(aAllSettings);
152cdf0e10cSrcweir
153cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
154cdf0e10cSrcweir if( bFont )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir Font aFont;
157cdf0e10cSrcweir aFont = rStyleSettings.GetFieldFont();
158cdf0e10cSrcweir aFont.SetColor( rStyleSettings.GetWindowTextColor() );
159cdf0e10cSrcweir SetPointFont( aFont );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir if( bForeground || bFont )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir SetTextColor( rStyleSettings.GetFieldTextColor() );
165cdf0e10cSrcweir SetTextFillColor();
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
168cdf0e10cSrcweir if( bBackground )
169cdf0e10cSrcweir SetBackground( rStyleSettings.GetFieldColor() );
170cdf0e10cSrcweir
171cdf0e10cSrcweir
172cdf0e10cSrcweir Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle};
173cdf0e10cSrcweir for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir Font aFont = pWindows[i]->GetFont();
176cdf0e10cSrcweir aFont.SetWeight(WEIGHT_BOLD);
177cdf0e10cSrcweir pWindows[i]->SetFont(aFont);
178cdf0e10cSrcweir pWindows[i]->SetTextColor( aStyle.GetLightColor() );
179cdf0e10cSrcweir pWindows[i]->SetBackground( Wallpaper( aStyle.GetShadowColor() ) );
180cdf0e10cSrcweir }
181cdf0e10cSrcweir }
182cdf0e10cSrcweir // .............................................................
183cdf0e10cSrcweir } // namespace dbaui
184cdf0e10cSrcweir // .............................................................
185