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"
32 #include <vcl/svapp.hxx>
33 #include <tools/debug.hxx>
38 DBG_NAME(OTitleWindow
)
39 OTitleWindow::OTitleWindow(Window
* _pParent
,sal_uInt16 _nTitleId
,WinBits _nBits
,sal_Bool _bShift
)
40 : Window(_pParent
,_nBits
| WB_DIALOGCONTROL
)
47 DBG_CTOR(OTitleWindow
,NULL
);
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
)
57 // -----------------------------------------------------------------------------
58 OTitleWindow::~OTitleWindow()
63 ::std::auto_ptr
<Window
> aTemp(m_pChild
);
67 DBG_DTOR(OTitleWindow
,NULL
);
69 // -----------------------------------------------------------------------------
70 void OTitleWindow::setChildWindow(Window
* _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
) );
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()
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();
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
);
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();
151 aFont
= rStyleSettings
.GetFieldFont();
152 aFont
.SetColor( rStyleSettings
.GetWindowTextColor() );
153 SetPointFont( aFont
);
156 if( bForeground
|| bFont
)
158 SetTextColor( rStyleSettings
.GetFieldTextColor() );
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 // .............................................................
178 // .............................................................
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */