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: ChartWindow.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_chart2.hxx"
33 #include "ChartWindow.hxx"
34 #include "ChartController.hxx"
35 #include "HelpIds.hrc"
37 #include <vcl/help.hxx>
39 using namespace ::com::sun::star
;
43 ::Rectangle
lcl_AWTRectToVCLRect( const ::com::sun::star::awt::Rectangle
& rAWTRect
)
46 aResult
.setX( rAWTRect
.X
);
47 aResult
.setY( rAWTRect
.Y
);
48 aResult
.setWidth( rAWTRect
.Width
);
49 aResult
.setHeight( rAWTRect
.Height
);
52 } // anonymous namespace
55 //.............................................................................
58 //.............................................................................
60 ChartWindow::ChartWindow( WindowController
* pWindowController
, Window
* pParent
, WinBits nStyle
)
61 : Window(pParent
, nStyle
)
62 , m_pWindowController( pWindowController
)
65 this->SetSmartHelpId( SmartId( HID_SCH_WIN_DOCUMENT
) );
66 this->SetMapMode( MapMode(MAP_100TH_MM
) );
67 adjustHighContrastMode();
68 // chart does not depend on exact pixel painting => enable antialiased drawing
69 SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW
| GetAntialiasing() );
72 pParent
->EnableRTL( FALSE
);// #i96215# necessary for a correct position of the context menu in rtl mode
75 ChartWindow::~ChartWindow()
79 void ChartWindow::clear()
81 m_pWindowController
=0;
85 void ChartWindow::PrePaint()
87 // forward VCLs PrePaint window event to DrawingLayer
88 if( m_pWindowController
)
90 m_pWindowController
->PrePaint();
94 void ChartWindow::Paint( const Rectangle
& rRect
)
97 if( m_pWindowController
)
98 m_pWindowController
->execute_Paint( rRect
);
100 Window::Paint( rRect
);
104 void ChartWindow::MouseButtonDown(const MouseEvent
& rMEvt
)
106 if( m_pWindowController
)
107 m_pWindowController
->execute_MouseButtonDown(rMEvt
);
109 Window::MouseButtonDown(rMEvt
);
112 void ChartWindow::MouseMove( const MouseEvent
& rMEvt
)
114 if( m_pWindowController
)
115 m_pWindowController
->execute_MouseMove( rMEvt
);
117 Window::MouseMove( rMEvt
);
120 void ChartWindow::Tracking( const TrackingEvent
& rTEvt
)
122 if( m_pWindowController
)
123 m_pWindowController
->execute_Tracking( rTEvt
);
125 Window::Tracking( rTEvt
);
128 void ChartWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
130 if( m_pWindowController
)
131 m_pWindowController
->execute_MouseButtonUp( rMEvt
);
133 Window::MouseButtonUp( rMEvt
);
136 void ChartWindow::Resize()
138 if( m_pWindowController
)
139 m_pWindowController
->execute_Resize();
144 void ChartWindow::Activate()
146 if( m_pWindowController
)
147 m_pWindowController
->execute_Activate();
151 void ChartWindow::Deactivate()
153 if( m_pWindowController
)
154 m_pWindowController
->execute_Deactivate();
156 Window::Deactivate();
158 void ChartWindow::GetFocus()
160 if( m_pWindowController
)
161 m_pWindowController
->execute_GetFocus();
165 void ChartWindow::LoseFocus()
167 if( m_pWindowController
)
168 m_pWindowController
->execute_LoseFocus();
173 void ChartWindow::Command( const CommandEvent
& rCEvt
)
175 if( m_pWindowController
)
176 m_pWindowController
->execute_Command( rCEvt
);
178 Window::Command( rCEvt
);
181 void ChartWindow::KeyInput( const KeyEvent
& rKEvt
)
183 if( m_pWindowController
)
185 if( !m_pWindowController
->execute_KeyInput(rKEvt
) )
186 Window::KeyInput(rKEvt
);
189 Window::KeyInput( rKEvt
);
192 uno::Reference
< accessibility::XAccessible
> ChartWindow::CreateAccessible()
194 if( m_pWindowController
)
195 return m_pWindowController
->CreateAccessible();
197 return Window::CreateAccessible();
200 void ChartWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
202 ::Window::DataChanged( rDCEvt
);
204 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
205 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
207 adjustHighContrastMode();
211 void ChartWindow::RequestHelp( const HelpEvent
& rHEvt
)
213 bool bHelpHandled
= false;
214 if( ( rHEvt
.GetMode() & HELPMODE_QUICK
) &&
215 m_pWindowController
)
217 // Point aLogicHitPos = PixelToLogic( rHEvt.GetMousePosPixel()); // old chart: GetPointerPosPixel()
218 Point aLogicHitPos
= PixelToLogic( GetPointerPosPixel());
219 ::rtl::OUString aQuickHelpText
;
220 awt::Rectangle aHelpRect
;
221 bool bIsBalloonHelp( Help::IsBalloonHelpEnabled() );
222 bHelpHandled
= m_pWindowController
->requestQuickHelp( aLogicHitPos
, bIsBalloonHelp
, aQuickHelpText
, aHelpRect
);
228 this, rHEvt
.GetMousePosPixel(), lcl_AWTRectToVCLRect( aHelpRect
), String( aQuickHelpText
));
231 this, lcl_AWTRectToVCLRect( aHelpRect
), String( aQuickHelpText
));
236 ::Window::RequestHelp( rHEvt
);
239 void ChartWindow::adjustHighContrastMode()
241 static const sal_Int32 nContrastMode
=
242 DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
|
243 DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
;
245 bool bUseContrast
= GetSettings().GetStyleSettings().GetHighContrastMode();
246 SetDrawMode( bUseContrast
? nContrastMode
: DRAWMODE_DEFAULT
);
249 void ChartWindow::ForceInvalidate()
251 ::Window::Invalidate();
253 void ChartWindow::Invalidate( USHORT nFlags
)
255 if( m_bInPaint
) // #i101928# superfluous paint calls while entering and editing charts"
257 ::Window::Invalidate( nFlags
);
259 void ChartWindow::Invalidate( const Rectangle
& rRect
, USHORT nFlags
)
261 if( m_bInPaint
) // #i101928# superfluous paint calls while entering and editing charts"
263 ::Window::Invalidate( rRect
, nFlags
);
265 void ChartWindow::Invalidate( const Region
& rRegion
, USHORT nFlags
)
267 if( m_bInPaint
) // #i101928# superfluous paint calls while entering and editing charts"
269 ::Window::Invalidate( rRegion
, nFlags
);
272 //.............................................................................
274 //.............................................................................