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