1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppTitleWindow.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBAUI_TITLE_WINDOW_HXX
34 #include "AppTitleWindow.hxx"
36 #ifndef _DBAUI_MODULE_DBU_HXX_
37 #include "moduledbu.hxx"
40 #ifndef _SV_SVAPP_HXX //autogen
41 #include <vcl/svapp.hxx>
43 #ifndef _TOOLS_DEBUG_HXX
44 #include <tools/debug.hxx>
50 DBG_NAME(OTitleWindow
)
51 OTitleWindow::OTitleWindow(Window
* _pParent
,USHORT _nTitleId
,WinBits _nBits
,BOOL _bShift
)
52 : Window(_pParent
,_nBits
| WB_DIALOGCONTROL
)
59 DBG_CTOR(OTitleWindow
,NULL
);
62 SetBorderStyle(WINDOW_BORDER_MONO
);
63 ImplInitSettings( sal_True
, sal_True
, sal_True
);
65 Window
* pWindows
[] = { &m_aSpace1
, &m_aSpace2
, &m_aTitle
};
66 for (size_t i
=0; i
< sizeof(pWindows
)/sizeof(pWindows
[0]); ++i
)
69 // -----------------------------------------------------------------------------
70 OTitleWindow::~OTitleWindow()
75 ::std::auto_ptr
<Window
> aTemp(m_pChild
);
79 DBG_DTOR(OTitleWindow
,NULL
);
81 // -----------------------------------------------------------------------------
82 void OTitleWindow::setChildWindow(Window
* _pChild
)
86 #define SPACE_BORDER 1
87 // -----------------------------------------------------------------------------
88 void OTitleWindow::Resize()
90 //////////////////////////////////////////////////////////////////////
91 // Abmessungen parent window
92 Size
aOutputSize( GetOutputSize() );
93 long nOutputWidth
= aOutputSize
.Width();
94 long nOutputHeight
= aOutputSize
.Height();
96 Size aTextSize
= LogicToPixel( Size( 6, 3 ), MAP_APPFONT
);
97 sal_Int32 nXOffset
= aTextSize
.Width();
98 sal_Int32 nYOffset
= aTextSize
.Height();
99 sal_Int32 nHeight
= GetTextHeight() + 2*nYOffset
;
101 m_aSpace1
.SetPosSizePixel( Point(SPACE_BORDER
, SPACE_BORDER
),
102 Size(nXOffset
, nHeight
- SPACE_BORDER
) );
103 m_aSpace2
.SetPosSizePixel( Point(nXOffset
+ SPACE_BORDER
, SPACE_BORDER
),
104 Size(nOutputWidth
- nXOffset
- 2*SPACE_BORDER
, nYOffset
) );
105 m_aTitle
.SetPosSizePixel( Point(nXOffset
+ SPACE_BORDER
, nYOffset
+ SPACE_BORDER
),
106 Size(nOutputWidth
- nXOffset
- 2*SPACE_BORDER
, nHeight
- nYOffset
- SPACE_BORDER
) );
109 m_pChild
->SetPosSizePixel( Point(m_bShift
? (nXOffset
+SPACE_BORDER
) : sal_Int32(SPACE_BORDER
), nHeight
+ nXOffset
+ SPACE_BORDER
),
110 Size(nOutputWidth
- ( m_bShift
? (2*nXOffset
- 2*SPACE_BORDER
) : sal_Int32(SPACE_BORDER
) ), nOutputHeight
- nHeight
- 2*nXOffset
- 2*SPACE_BORDER
) );
113 // -----------------------------------------------------------------------------
114 void OTitleWindow::setTitle(USHORT _nTitleId
)
116 if ( _nTitleId
!= 0 )
118 m_aTitle
.SetText(ModuleRes(_nTitleId
));
121 // -----------------------------------------------------------------------------
122 void OTitleWindow::GetFocus()
126 m_pChild
->GrabFocus();
128 // -----------------------------------------------------------------------------
129 long OTitleWindow::GetWidthPixel() const
131 Size aTextSize
= LogicToPixel( Size( 12, 0 ), MAP_APPFONT
);
132 sal_Int32 nWidth
= GetTextWidth(m_aTitle
.GetText()) + 2*aTextSize
.Width();
136 // -----------------------------------------------------------------------
137 void OTitleWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
139 Window::DataChanged( rDCEvt
);
141 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
142 (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
143 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
144 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
145 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
147 ImplInitSettings( sal_True
, sal_True
, sal_True
);
151 //-----------------------------------------------------------------------------
152 void OTitleWindow::ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
)
154 AllSettings aAllSettings
= GetSettings();
155 StyleSettings aStyle
= aAllSettings
.GetStyleSettings();
156 aStyle
.SetMonoColor(aStyle
.GetActiveBorderColor());//GetMenuBorderColor());
157 aAllSettings
.SetStyleSettings(aStyle
);
158 SetSettings(aAllSettings
);
160 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
164 aFont
= rStyleSettings
.GetFieldFont();
165 aFont
.SetColor( rStyleSettings
.GetWindowTextColor() );
166 SetPointFont( aFont
);
169 if( bForeground
|| bFont
)
171 SetTextColor( rStyleSettings
.GetFieldTextColor() );
176 SetBackground( rStyleSettings
.GetFieldColor() );
179 Window
* pWindows
[] = { &m_aSpace1
, &m_aSpace2
, &m_aTitle
};
180 for (size_t i
=0; i
< sizeof(pWindows
)/sizeof(pWindows
[0]); ++i
)
182 Font aFont
= pWindows
[i
]->GetFont();
183 aFont
.SetWeight(WEIGHT_BOLD
);
184 pWindows
[i
]->SetFont(aFont
);
185 pWindows
[i
]->SetTextColor( aStyle
.GetLightColor() );
186 pWindows
[i
]->SetBackground( Wallpaper( aStyle
.GetShadowColor() ) );
189 // .............................................................
191 // .............................................................