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 "ChartWindow.hxx"
30 #include "ChartController.hxx"
31 #include "HelpIds.hrc"
33 #include <vcl/help.hxx>
35 using namespace ::com::sun::star
;
39 ::Rectangle
lcl_AWTRectToVCLRect( const ::com::sun::star::awt::Rectangle
& rAWTRect
)
42 aResult
.setX( rAWTRect
.X
);
43 aResult
.setY( rAWTRect
.Y
);
44 aResult
.setWidth( rAWTRect
.Width
);
45 aResult
.setHeight( rAWTRect
.Height
);
48 } // anonymous namespace
51 //.............................................................................
54 //.............................................................................
56 ChartWindow::ChartWindow( WindowController
* pWindowController
, Window
* pParent
, WinBits nStyle
)
57 : Window(pParent
, nStyle
)
58 , m_pWindowController( pWindowController
)
61 this->SetHelpId( HID_SCH_WIN_DOCUMENT
);
62 this->SetMapMode( MapMode(MAP_100TH_MM
) );
63 adjustHighContrastMode();
64 // chart does not depend on exact pixel painting => enable antialiased drawing
65 SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW
| GetAntialiasing() );
66 EnableRTL( sal_False
);
68 pParent
->EnableRTL( sal_False
);// #i96215# necessary for a correct position of the context menu in rtl mode
71 ChartWindow::~ChartWindow()
75 void ChartWindow::clear()
77 m_pWindowController
=0;
81 void ChartWindow::PrePaint()
83 // forward VCLs PrePaint window event to DrawingLayer
84 if( m_pWindowController
)
86 m_pWindowController
->PrePaint();
90 void ChartWindow::Paint( const Rectangle
& rRect
)
93 if( m_pWindowController
)
94 m_pWindowController
->execute_Paint( rRect
);
96 Window::Paint( rRect
);
100 void ChartWindow::MouseButtonDown(const MouseEvent
& rMEvt
)
102 if( m_pWindowController
)
103 m_pWindowController
->execute_MouseButtonDown(rMEvt
);
105 Window::MouseButtonDown(rMEvt
);
108 void ChartWindow::MouseMove( const MouseEvent
& rMEvt
)
110 if( m_pWindowController
)
111 m_pWindowController
->execute_MouseMove( rMEvt
);
113 Window::MouseMove( rMEvt
);
116 void ChartWindow::Tracking( const TrackingEvent
& rTEvt
)
118 if( m_pWindowController
)
119 m_pWindowController
->execute_Tracking( rTEvt
);
121 Window::Tracking( rTEvt
);
124 void ChartWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
126 if( m_pWindowController
)
127 m_pWindowController
->execute_MouseButtonUp( rMEvt
);
129 Window::MouseButtonUp( rMEvt
);
132 void ChartWindow::Resize()
134 if( m_pWindowController
)
135 m_pWindowController
->execute_Resize();
140 void ChartWindow::Activate()
142 if( m_pWindowController
)
143 m_pWindowController
->execute_Activate();
147 void ChartWindow::Deactivate()
149 if( m_pWindowController
)
150 m_pWindowController
->execute_Deactivate();
152 Window::Deactivate();
154 void ChartWindow::GetFocus()
156 if( m_pWindowController
)
157 m_pWindowController
->execute_GetFocus();
161 void ChartWindow::LoseFocus()
163 if( m_pWindowController
)
164 m_pWindowController
->execute_LoseFocus();
169 void ChartWindow::Command( const CommandEvent
& rCEvt
)
171 if( m_pWindowController
)
172 m_pWindowController
->execute_Command( rCEvt
);
174 Window::Command( rCEvt
);
177 void ChartWindow::KeyInput( const KeyEvent
& rKEvt
)
179 if( m_pWindowController
)
181 if( !m_pWindowController
->execute_KeyInput(rKEvt
) )
182 Window::KeyInput(rKEvt
);
185 Window::KeyInput( rKEvt
);
188 uno::Reference
< accessibility::XAccessible
> ChartWindow::CreateAccessible()
190 if( m_pWindowController
)
191 return m_pWindowController
->CreateAccessible();
193 return Window::CreateAccessible();
196 void ChartWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
198 ::Window::DataChanged( rDCEvt
);
200 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
201 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
203 adjustHighContrastMode();
207 void ChartWindow::RequestHelp( const HelpEvent
& rHEvt
)
209 bool bHelpHandled
= false;
210 if( ( rHEvt
.GetMode() & HELPMODE_QUICK
) &&
211 m_pWindowController
)
213 // Point aLogicHitPos = PixelToLogic( rHEvt.GetMousePosPixel()); // old chart: GetPointerPosPixel()
214 Point aLogicHitPos
= PixelToLogic( GetPointerPosPixel());
215 ::rtl::OUString aQuickHelpText
;
216 awt::Rectangle aHelpRect
;
217 bool bIsBalloonHelp( Help::IsBalloonHelpEnabled() );
218 bHelpHandled
= m_pWindowController
->requestQuickHelp( aLogicHitPos
, bIsBalloonHelp
, aQuickHelpText
, aHelpRect
);
224 this, rHEvt
.GetMousePosPixel(), lcl_AWTRectToVCLRect( aHelpRect
), String( aQuickHelpText
));
227 this, lcl_AWTRectToVCLRect( aHelpRect
), String( aQuickHelpText
));
232 ::Window::RequestHelp( rHEvt
);
235 void ChartWindow::adjustHighContrastMode()
237 static const sal_Int32 nContrastMode
=
238 DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
|
239 DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
;
241 bool bUseContrast
= GetSettings().GetStyleSettings().GetHighContrastMode();
242 SetDrawMode( bUseContrast
? nContrastMode
: DRAWMODE_DEFAULT
);
245 void ChartWindow::ForceInvalidate()
247 ::Window::Invalidate();
249 void ChartWindow::Invalidate( sal_uInt16 nFlags
)
251 if( m_bInPaint
) // #i101928# superfluous paint calls while entering and editing charts"
253 ::Window::Invalidate( nFlags
);
255 void ChartWindow::Invalidate( const Rectangle
& rRect
, sal_uInt16 nFlags
)
257 if( m_bInPaint
) // #i101928# superfluous paint calls while entering and editing charts"
259 ::Window::Invalidate( rRect
, nFlags
);
261 void ChartWindow::Invalidate( const Region
& rRegion
, sal_uInt16 nFlags
)
263 if( m_bInPaint
) // #i101928# superfluous paint calls while entering and editing charts"
265 ::Window::Invalidate( rRegion
, nFlags
);
268 //.............................................................................
270 //.............................................................................
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */