GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svtools / source / uno / popupwindowcontroller.cxx
blob772577aa4f2597dc587f37f47400e8a9ed5952b8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <cppuhelper/supportsservice.hxx>
21 #include <toolkit/helper/vclunohelper.hxx>
23 #include <vcl/toolbox.hxx>
24 #include <vcl/svapp.hxx>
26 #include "svtools/popupwindowcontroller.hxx"
27 #include "svtools/toolbarmenu.hxx"
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::lang;
34 namespace svt
37 class PopupWindowControllerImpl
39 public:
40 PopupWindowControllerImpl();
41 ~PopupWindowControllerImpl();
43 void SetPopupWindow( ::Window* pPopupWindow, ToolBox* pToolBox );
45 DECL_LINK( WindowEventListener, VclSimpleEvent* );
46 DECL_STATIC_LINK( PopupWindowControllerImpl, AsyncDeleteWindowHdl, Window* );
48 private:
49 ::Window* mpPopupWindow;
50 ToolBox* mpToolBox;
53 PopupWindowControllerImpl::PopupWindowControllerImpl()
54 : mpPopupWindow( 0 )
55 , mpToolBox( 0 )
59 PopupWindowControllerImpl::~PopupWindowControllerImpl()
61 if( mpPopupWindow )
62 SetPopupWindow(0,0);
65 void PopupWindowControllerImpl::SetPopupWindow( ::Window* pPopupWindow, ToolBox* pToolBox )
67 if( mpPopupWindow )
69 mpPopupWindow->RemoveEventListener( LINK( this, PopupWindowControllerImpl, WindowEventListener ) );
70 Application::PostUserEvent( STATIC_LINK( this, PopupWindowControllerImpl, AsyncDeleteWindowHdl ), mpPopupWindow );
72 mpPopupWindow = pPopupWindow;
73 mpToolBox = pToolBox;
75 if( mpPopupWindow )
77 mpPopupWindow->AddEventListener( LINK( this, PopupWindowControllerImpl, WindowEventListener ));
81 IMPL_LINK( PopupWindowControllerImpl, WindowEventListener, VclSimpleEvent*, pEvent )
83 VclWindowEvent* pWindowEvent = dynamic_cast< VclWindowEvent* >( pEvent );
84 if( pWindowEvent )
86 switch( pWindowEvent->GetId() )
88 case VCLEVENT_WINDOW_CLOSE:
89 case VCLEVENT_WINDOW_ENDPOPUPMODE:
90 SetPopupWindow(0,0);
91 break;
93 case VCLEVENT_WINDOW_SHOW:
95 if( mpPopupWindow )
97 if( mpToolBox )
98 mpToolBox->CallEventListeners( VCLEVENT_DROPDOWN_OPEN, (void*)mpPopupWindow );
99 mpPopupWindow->CallEventListeners( VCLEVENT_WINDOW_GETFOCUS, 0 );
101 svtools::ToolbarMenu* pToolbarMenu = dynamic_cast< svtools::ToolbarMenu* >( mpPopupWindow );
102 if( pToolbarMenu )
103 pToolbarMenu->highlightFirstEntry();
104 break;
106 break;
108 case VCLEVENT_WINDOW_HIDE:
110 if( mpPopupWindow )
112 mpPopupWindow->CallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS, 0 );
113 if( mpToolBox )
114 mpToolBox->CallEventListeners( VCLEVENT_DROPDOWN_CLOSE, (void*)mpPopupWindow );
116 break;
120 return 1;
123 //--------------------------------------------------------------------
125 IMPL_STATIC_LINK( PopupWindowControllerImpl, AsyncDeleteWindowHdl, Window*, pWindow )
127 (void)*pThis;
128 delete pWindow;
129 return 0;
132 //========================================================================
133 // class PopupWindowController
134 //========================================================================
136 PopupWindowController::PopupWindowController( const Reference< uno::XComponentContext >& rxContext,
137 const Reference< frame::XFrame >& xFrame,
138 const OUString& aCommandURL )
139 : svt::ToolboxController( rxContext, xFrame, aCommandURL )
140 , mpImpl( new PopupWindowControllerImpl() )
144 PopupWindowController::~PopupWindowController()
148 // XInterface
149 Any SAL_CALL PopupWindowController::queryInterface( const Type& aType )
150 throw (RuntimeException)
152 Any a( ToolboxController::queryInterface( aType ) );
153 if ( a.hasValue() )
154 return a;
156 return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this ));
159 void SAL_CALL PopupWindowController::acquire() throw ()
161 ToolboxController::acquire();
164 void SAL_CALL PopupWindowController::release() throw ()
166 ToolboxController::release();
169 // XServiceInfo
170 sal_Bool SAL_CALL PopupWindowController::supportsService( const OUString& ServiceName ) throw(RuntimeException)
172 return cppu::supportsService(this, ServiceName);
175 // XInitialization
176 void SAL_CALL PopupWindowController::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
178 svt::ToolboxController::initialize( aArguments );
179 if( !m_aCommandURL.isEmpty() )
180 addStatusListener( m_aCommandURL );
183 // XComponent
184 void SAL_CALL PopupWindowController::dispose() throw (RuntimeException)
186 if( !m_aCommandURL.isEmpty() )
187 removeStatusListener( m_aCommandURL );
189 svt::ToolboxController::dispose();
193 // XStatusListener
194 void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEvent& rEvent ) throw ( RuntimeException )
196 svt::ToolboxController::statusChanged(rEvent);
197 enable( rEvent.IsEnabled );
200 // XToolbarController
201 void SAL_CALL PopupWindowController::execute( sal_Int16 KeyModifier ) throw (RuntimeException)
203 svt::ToolboxController::execute( KeyModifier );
206 void SAL_CALL PopupWindowController::click() throw (RuntimeException)
208 svt::ToolboxController::click();
211 void SAL_CALL PopupWindowController::doubleClick() throw (RuntimeException)
213 svt::ToolboxController::doubleClick();
216 Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow() throw (RuntimeException)
218 ToolBox* pToolBox = dynamic_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
219 if( pToolBox )
221 ::Window* pItemWindow = pToolBox->GetItemWindow( pToolBox->GetDownItemId() );
222 ::Window* pWin = createPopupWindow( pItemWindow ? pItemWindow : pToolBox );
223 if( pWin )
225 pWin->EnableDocking(true);
226 mpImpl->SetPopupWindow(pWin,pToolBox);
227 ::Window::GetDockingManager()->StartPopupMode( pToolBox, pWin,
228 FLOATWIN_POPUPMODE_GRABFOCUS |
229 FLOATWIN_POPUPMODE_NOFOCUSCLOSE |
230 FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE |
231 FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
234 return Reference< awt::XWindow >();
237 Reference< awt::XWindow > SAL_CALL PopupWindowController::createItemWindow( const Reference< awt::XWindow >& /*Parent*/ )
238 throw (RuntimeException)
240 return Reference< awt::XWindow >();
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */