1*5900e8ecSAndrew Rist /**************************************************************
2*5900e8ecSAndrew Rist  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5900e8ecSAndrew Rist  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19*5900e8ecSAndrew Rist  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_svtools.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
30cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <vcl/dockwin.hxx>
33cdf0e10cSrcweir #include <vcl/decoview.hxx>
34cdf0e10cSrcweir #include <vcl/image.hxx>
35cdf0e10cSrcweir #include <vcl/taskpanelist.hxx>
36cdf0e10cSrcweir #include <vcl/toolbox.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include "svtools/valueset.hxx"
39cdf0e10cSrcweir #include "svtools/toolbarmenu.hxx"
40cdf0e10cSrcweir #include "toolbarmenuimp.hxx"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir using ::rtl::OUString;
43cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44cdf0e10cSrcweir using namespace ::com::sun::star::lang;
45cdf0e10cSrcweir using namespace ::com::sun::star::frame;
46cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace svtools {
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // --------------------------------------------------------------------
51cdf0e10cSrcweir 
GetTopMostParentSystemWindow(Window * pWindow)52cdf0e10cSrcweir static Window* GetTopMostParentSystemWindow( Window* pWindow )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir     OSL_ASSERT( pWindow );
55cdf0e10cSrcweir     if ( pWindow )
56cdf0e10cSrcweir     {
57cdf0e10cSrcweir         // ->manually search topmost system window
58cdf0e10cSrcweir         // required because their might be another system window between this and the top window
59cdf0e10cSrcweir         pWindow = pWindow->GetParent();
60cdf0e10cSrcweir         SystemWindow* pTopMostSysWin = NULL;
61cdf0e10cSrcweir         while ( pWindow )
62cdf0e10cSrcweir         {
63cdf0e10cSrcweir             if ( pWindow->IsSystemWindow() )
64cdf0e10cSrcweir                 pTopMostSysWin = (SystemWindow*)pWindow;
65cdf0e10cSrcweir             pWindow = pWindow->GetParent();
66cdf0e10cSrcweir         }
67cdf0e10cSrcweir         pWindow = pTopMostSysWin;
68cdf0e10cSrcweir         OSL_ASSERT( pWindow );
69cdf0e10cSrcweir         return pWindow;
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     return NULL;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir // --------------------------------------------------------------------
76cdf0e10cSrcweir 
init(int nEntryId,MenuItemBits nBits)77cdf0e10cSrcweir void ToolbarMenuEntry::init( int nEntryId, MenuItemBits nBits )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	mnEntryId = nEntryId;
80cdf0e10cSrcweir 	mnBits = nBits;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	mbHasText = false;
83cdf0e10cSrcweir 	mbHasImage = false;
84cdf0e10cSrcweir 	mbChecked = false;
85cdf0e10cSrcweir 	mbEnabled = true;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	mpControl = NULL;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // --------------------------------------------------------------------
91cdf0e10cSrcweir 
ToolbarMenuEntry(ToolbarMenu & rMenu,int nEntryId,const String & rText,MenuItemBits nBits)92cdf0e10cSrcweir ToolbarMenuEntry::ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, const String& rText, MenuItemBits nBits )
93cdf0e10cSrcweir : mrMenu( rMenu )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	init( nEntryId, nBits );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	maText = rText;
98cdf0e10cSrcweir 	mbHasText = true;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir // --------------------------------------------------------------------
102cdf0e10cSrcweir 
ToolbarMenuEntry(ToolbarMenu & rMenu,int nEntryId,const Image & rImage,MenuItemBits nBits)103cdf0e10cSrcweir ToolbarMenuEntry::ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, const Image& rImage, MenuItemBits nBits )
104cdf0e10cSrcweir : mrMenu( rMenu )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	init( nEntryId, nBits );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	maImage = rImage;
109cdf0e10cSrcweir 	mbHasImage = true;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // --------------------------------------------------------------------
113cdf0e10cSrcweir 
ToolbarMenuEntry(ToolbarMenu & rMenu,int nEntryId,const Image & rImage,const String & rText,MenuItemBits nBits)114cdf0e10cSrcweir ToolbarMenuEntry::ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, const Image& rImage, const String& rText, MenuItemBits nBits )
115cdf0e10cSrcweir : mrMenu( rMenu )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 	init( nEntryId, nBits );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	maText = rText;
120cdf0e10cSrcweir 	mbHasText = true;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	maImage = rImage;
123cdf0e10cSrcweir 	mbHasImage = true;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // --------------------------------------------------------------------
127cdf0e10cSrcweir 
ToolbarMenuEntry(ToolbarMenu & rMenu,int nEntryId,Control * pControl,MenuItemBits nBits)128cdf0e10cSrcweir ToolbarMenuEntry::ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, Control* pControl, MenuItemBits nBits )
129cdf0e10cSrcweir : mrMenu( rMenu )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	init( nEntryId, nBits );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	if( pControl )
134cdf0e10cSrcweir 	{
135cdf0e10cSrcweir 		mpControl = pControl;
136cdf0e10cSrcweir 		mpControl->Show();
137cdf0e10cSrcweir 	}
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir // --------------------------------------------------------------------
141cdf0e10cSrcweir 
~ToolbarMenuEntry()142cdf0e10cSrcweir ToolbarMenuEntry::~ToolbarMenuEntry()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	if( mxAccContext.is() )
145cdf0e10cSrcweir 	{
146cdf0e10cSrcweir 		Reference< XComponent > xComponent( mxAccContext, UNO_QUERY );
147cdf0e10cSrcweir 		if( xComponent.is() )
148cdf0e10cSrcweir 			xComponent->dispose();
149cdf0e10cSrcweir 		mxAccContext.clear();
150cdf0e10cSrcweir 	}
151cdf0e10cSrcweir 	delete mpControl;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir // --------------------------------------------------------------------
155cdf0e10cSrcweir 
GetAccessible(bool bCreate)156cdf0e10cSrcweir const Reference< XAccessibleContext >& ToolbarMenuEntry::GetAccessible( bool bCreate /* = false */ )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir 	if( !mxAccContext.is() && bCreate )
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir 		if( mpControl )
161cdf0e10cSrcweir 		{
162cdf0e10cSrcweir 			mxAccContext = Reference< XAccessibleContext >( mpControl->GetAccessible( sal_True ), UNO_QUERY );
163cdf0e10cSrcweir 		}
164cdf0e10cSrcweir 		else
165cdf0e10cSrcweir 		{
166cdf0e10cSrcweir 			mxAccContext = Reference< XAccessibleContext >( new ToolbarMenuEntryAcc( this ) );
167cdf0e10cSrcweir 		}
168cdf0e10cSrcweir 	}
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	return mxAccContext;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir // --------------------------------------------------------------------
174cdf0e10cSrcweir 
getAccessibleChildCount()175cdf0e10cSrcweir sal_Int32 ToolbarMenuEntry::getAccessibleChildCount() throw (RuntimeException)
176cdf0e10cSrcweir {
177cdf0e10cSrcweir 	if( mpControl )
178cdf0e10cSrcweir 	{
179cdf0e10cSrcweir 		const Reference< XAccessibleContext >& xContext = GetAccessible( true );
180cdf0e10cSrcweir 		if( xContext.is() )
181cdf0e10cSrcweir 		{
182cdf0e10cSrcweir 			return xContext->getAccessibleChildCount();
183cdf0e10cSrcweir 		}
184cdf0e10cSrcweir 	}
185cdf0e10cSrcweir 	return 1;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir // --------------------------------------------------------------------
189cdf0e10cSrcweir 
getAccessibleChild(sal_Int32 index)190cdf0e10cSrcweir Reference< XAccessible > ToolbarMenuEntry::getAccessibleChild( sal_Int32 index ) throw (IndexOutOfBoundsException, RuntimeException)
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	const Reference< XAccessibleContext >& xContext = GetAccessible( true );
193cdf0e10cSrcweir 	if( mpControl )
194cdf0e10cSrcweir 	{
195cdf0e10cSrcweir 		if( xContext.is() )
196cdf0e10cSrcweir 		{
197cdf0e10cSrcweir 			return xContext->getAccessibleChild(index);
198cdf0e10cSrcweir 		}
199cdf0e10cSrcweir 	}
200cdf0e10cSrcweir 	else if( index == 0 )
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir 		Reference< XAccessible > xRet( xContext, UNO_QUERY );
203cdf0e10cSrcweir 		if( xRet.is() )
204cdf0e10cSrcweir 			return xRet;
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir // --------------------------------------------------------------------
211cdf0e10cSrcweir 
ToolbarMenu_Impl(ToolbarMenu & rMenu,const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & xFrame)212cdf0e10cSrcweir ToolbarMenu_Impl::ToolbarMenu_Impl( ToolbarMenu& rMenu, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
213cdf0e10cSrcweir : mrMenu( rMenu )
214cdf0e10cSrcweir , mxFrame( xFrame )
215cdf0e10cSrcweir , mxServiceManager( ::comphelper::getProcessServiceFactory() )
216cdf0e10cSrcweir , mnCheckPos(0)
217cdf0e10cSrcweir , mnImagePos(0)
218cdf0e10cSrcweir , mnTextPos(0)
219cdf0e10cSrcweir , mnHighlightedEntry(-1)
220cdf0e10cSrcweir , mnSelectedEntry(-1)
221cdf0e10cSrcweir , mnLastColumn(0)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir // --------------------------------------------------------------------
226cdf0e10cSrcweir 
~ToolbarMenu_Impl()227cdf0e10cSrcweir ToolbarMenu_Impl::~ToolbarMenu_Impl()
228cdf0e10cSrcweir {
229cdf0e10cSrcweir 	setAccessible( 0 );
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir // --------------------------------------------------------------------
233cdf0e10cSrcweir 
setAccessible(ToolbarMenuAcc * pAccessible)234cdf0e10cSrcweir void ToolbarMenu_Impl::setAccessible( ToolbarMenuAcc* pAccessible )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir 	if( mxAccessible.get() != pAccessible )
237cdf0e10cSrcweir 	{
238cdf0e10cSrcweir 		if( mxAccessible.is() )
239cdf0e10cSrcweir 			mxAccessible->dispose();
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 		mxAccessible.set( pAccessible );
242cdf0e10cSrcweir 	}
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir // -----------------------------------------------------------------------
246cdf0e10cSrcweir 
fireAccessibleEvent(short nEventId,const::com::sun::star::uno::Any & rOldValue,const::com::sun::star::uno::Any & rNewValue)247cdf0e10cSrcweir void ToolbarMenu_Impl::fireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     if( mxAccessible.is() )
250cdf0e10cSrcweir         mxAccessible->FireAccessibleEvent( nEventId, rOldValue, rNewValue );
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir // -----------------------------------------------------------------------
254cdf0e10cSrcweir 
hasAccessibleListeners()255cdf0e10cSrcweir bool ToolbarMenu_Impl::hasAccessibleListeners()
256cdf0e10cSrcweir {
257cdf0e10cSrcweir     return( mxAccessible.is() && mxAccessible->HasAccessibleListeners() );
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir // --------------------------------------------------------------------
261cdf0e10cSrcweir 
getAccessibleChildCount()262cdf0e10cSrcweir sal_Int32 ToolbarMenu_Impl::getAccessibleChildCount() throw (RuntimeException)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir 	sal_Int32 nCount = 0;
265cdf0e10cSrcweir 	const int nEntryCount = maEntryVector.size();
266cdf0e10cSrcweir 	for( int nEntry = 0; nEntry < nEntryCount; nEntry++ )
267cdf0e10cSrcweir 	{
268cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = maEntryVector[nEntry];
269cdf0e10cSrcweir 		if( pEntry )
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir 			if( pEntry->mpControl )
272cdf0e10cSrcweir 			{
273cdf0e10cSrcweir 				nCount += pEntry->getAccessibleChildCount();
274cdf0e10cSrcweir 			}
275cdf0e10cSrcweir 			else
276cdf0e10cSrcweir 			{
277cdf0e10cSrcweir 				nCount += 1;
278cdf0e10cSrcweir 			}
279cdf0e10cSrcweir 		}
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	return nCount;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir // --------------------------------------------------------------------
286cdf0e10cSrcweir 
getAccessibleChild(sal_Int32 index)287cdf0e10cSrcweir Reference< XAccessible > ToolbarMenu_Impl::getAccessibleChild( sal_Int32 index ) throw (IndexOutOfBoundsException, RuntimeException)
288cdf0e10cSrcweir {
289cdf0e10cSrcweir 	const int nEntryCount = maEntryVector.size();
290cdf0e10cSrcweir 	for( int nEntry = 0; nEntry < nEntryCount; nEntry++ )
291cdf0e10cSrcweir 	{
292cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = maEntryVector[nEntry];
293cdf0e10cSrcweir 		if( pEntry )
294cdf0e10cSrcweir 		{
295cdf0e10cSrcweir 			const sal_Int32 nCount = pEntry->getAccessibleChildCount();
296cdf0e10cSrcweir 			if( index < nCount )
297cdf0e10cSrcweir 			{
298cdf0e10cSrcweir 				return pEntry->getAccessibleChild( index );
299cdf0e10cSrcweir 			}
300cdf0e10cSrcweir 			index -= nCount;
301cdf0e10cSrcweir 		}
302cdf0e10cSrcweir 	}
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir // --------------------------------------------------------------------
308cdf0e10cSrcweir 
getAccessibleChild(Control * pControl,sal_Int32 childIndex)309cdf0e10cSrcweir Reference< XAccessible > ToolbarMenu_Impl::getAccessibleChild( Control* pControl, sal_Int32 childIndex ) throw (IndexOutOfBoundsException, RuntimeException)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	const int nEntryCount = maEntryVector.size();
312cdf0e10cSrcweir 	for( int nEntry = 0; nEntry < nEntryCount; nEntry++ )
313cdf0e10cSrcweir 	{
314cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = maEntryVector[nEntry];
315cdf0e10cSrcweir 		if( pEntry && (pEntry->mpControl == pControl) )
316cdf0e10cSrcweir 		{
317cdf0e10cSrcweir 			return pEntry->getAccessibleChild( childIndex );
318cdf0e10cSrcweir 		}
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir // --------------------------------------------------------------------
325cdf0e10cSrcweir 
selectAccessibleChild(sal_Int32 nChildIndex)326cdf0e10cSrcweir void ToolbarMenu_Impl::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	const int nEntryCount = maEntryVector.size();
329cdf0e10cSrcweir 	for( int nEntry = 0; nEntry < nEntryCount; nEntry++ )
330cdf0e10cSrcweir 	{
331cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = maEntryVector[nEntry];
332cdf0e10cSrcweir 		if( pEntry )
333cdf0e10cSrcweir 		{
334cdf0e10cSrcweir 			const sal_Int32 nCount = pEntry->getAccessibleChildCount();
335cdf0e10cSrcweir 			if( nChildIndex < nCount )
336cdf0e10cSrcweir 			{
337cdf0e10cSrcweir 				if( pEntry->mpControl )
338cdf0e10cSrcweir 				{
339cdf0e10cSrcweir 					Reference< XAccessibleSelection > xSel( pEntry->GetAccessible(true), UNO_QUERY_THROW );
340cdf0e10cSrcweir 					xSel->selectAccessibleChild(nChildIndex);
341cdf0e10cSrcweir 				}
342cdf0e10cSrcweir 				else if( pEntry->mnEntryId != TITLE_ID )
343cdf0e10cSrcweir 				{
344cdf0e10cSrcweir 					mrMenu.implSelectEntry( nEntry );
345cdf0e10cSrcweir 				}
346cdf0e10cSrcweir 				return;
347cdf0e10cSrcweir 			}
348cdf0e10cSrcweir 			nChildIndex -= nCount;
349cdf0e10cSrcweir 		}
350cdf0e10cSrcweir 	}
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
353cdf0e10cSrcweir }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir // --------------------------------------------------------------------
356cdf0e10cSrcweir 
isAccessibleChildSelected(sal_Int32 nChildIndex)357cdf0e10cSrcweir sal_Bool ToolbarMenu_Impl::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir 	const int nEntryCount = maEntryVector.size();
360cdf0e10cSrcweir 	for( int nEntry = 0; nEntry < nEntryCount; nEntry++ )
361cdf0e10cSrcweir 	{
362cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = maEntryVector[nEntry];
363cdf0e10cSrcweir 		if( pEntry )
364cdf0e10cSrcweir 		{
365cdf0e10cSrcweir 			const sal_Int32 nCount = pEntry->getAccessibleChildCount();
366cdf0e10cSrcweir 			if( nChildIndex < nCount )
367cdf0e10cSrcweir 			{
368cdf0e10cSrcweir 				if( mnHighlightedEntry == nEntry )
369cdf0e10cSrcweir 				{
370cdf0e10cSrcweir 					if( pEntry->mpControl )
371cdf0e10cSrcweir 					{
372cdf0e10cSrcweir 						Reference< XAccessibleSelection > xSel( pEntry->GetAccessible(true), UNO_QUERY_THROW );
373cdf0e10cSrcweir 						xSel->isAccessibleChildSelected(nChildIndex);
374cdf0e10cSrcweir 					}
375cdf0e10cSrcweir 					return true;
376cdf0e10cSrcweir 				}
377cdf0e10cSrcweir 				else
378cdf0e10cSrcweir 				{
379cdf0e10cSrcweir 					return false;
380cdf0e10cSrcweir 				}
381cdf0e10cSrcweir 			}
382cdf0e10cSrcweir 			nChildIndex -= nCount;
383cdf0e10cSrcweir 		}
384cdf0e10cSrcweir 	}
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir // --------------------------------------------------------------------
390cdf0e10cSrcweir 
clearAccessibleSelection()391cdf0e10cSrcweir void ToolbarMenu_Impl::clearAccessibleSelection()
392cdf0e10cSrcweir {
393cdf0e10cSrcweir 	if( mnHighlightedEntry != -1 )
394cdf0e10cSrcweir 	{
395cdf0e10cSrcweir 		mrMenu.implHighlightEntry( mnHighlightedEntry, false );
396cdf0e10cSrcweir 		mnHighlightedEntry = -1;
397cdf0e10cSrcweir 	}
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 
401cdf0e10cSrcweir // --------------------------------------------------------------------
402cdf0e10cSrcweir 
notifyHighlightedEntry()403cdf0e10cSrcweir void ToolbarMenu_Impl::notifyHighlightedEntry()
404cdf0e10cSrcweir {
405cdf0e10cSrcweir 	if( hasAccessibleListeners() )
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = implGetEntry( mnHighlightedEntry );
408cdf0e10cSrcweir 		if( pEntry && pEntry->mbEnabled && (pEntry->mnEntryId != TITLE_ID) )
409cdf0e10cSrcweir 		{
410cdf0e10cSrcweir 			Any aNew;
411cdf0e10cSrcweir 			Any aOld( mxOldSelection );
412cdf0e10cSrcweir 			if( pEntry->mpControl )
413cdf0e10cSrcweir 			{
414cdf0e10cSrcweir 				sal_Int32 nChildIndex = 0;
415cdf0e10cSrcweir 				// todo: if other controls than ValueSet are allowed, addapt this code
416cdf0e10cSrcweir 				ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl );
417cdf0e10cSrcweir 				if( pValueSet )
418cdf0e10cSrcweir 					nChildIndex = static_cast< sal_Int32 >( pValueSet->GetItemPos( pValueSet->GetSelectItemId() ) );
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 				if( nChildIndex >= pEntry->getAccessibleChildCount() )
421cdf0e10cSrcweir 					return;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 				aNew <<= getAccessibleChild( pEntry->mpControl, nChildIndex );
424cdf0e10cSrcweir 			}
425cdf0e10cSrcweir 			else
426cdf0e10cSrcweir 			{
427cdf0e10cSrcweir 				aNew <<= pEntry->GetAccessible(true);
428cdf0e10cSrcweir 			}
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 			fireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOld, aNew );
431cdf0e10cSrcweir 			fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOld, aNew );
432cdf0e10cSrcweir 			fireAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), Any( AccessibleStateType::FOCUSED ) );
433cdf0e10cSrcweir 			aNew >>= mxOldSelection;
434cdf0e10cSrcweir 		}
435cdf0e10cSrcweir 	}
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir // --------------------------------------------------------------------
439cdf0e10cSrcweir 
implGetEntry(int nEntry) const440cdf0e10cSrcweir ToolbarMenuEntry* ToolbarMenu_Impl::implGetEntry( int nEntry ) const
441cdf0e10cSrcweir {
442cdf0e10cSrcweir 	if( (nEntry < 0) || (nEntry >= (int)maEntryVector.size() ) )
443cdf0e10cSrcweir 		return NULL;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	return maEntryVector[nEntry];
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 
449cdf0e10cSrcweir // --------------------------------------------------------------------
450cdf0e10cSrcweir 
IMPL_LINK(ToolbarMenu,HighlightHdl,Control *,pControl)451cdf0e10cSrcweir IMPL_LINK( ToolbarMenu, HighlightHdl, Control *, pControl )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir 	(void)pControl;
454cdf0e10cSrcweir 	mpImpl->notifyHighlightedEntry();
455cdf0e10cSrcweir 	return 0;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir // ====================================================================
459cdf0e10cSrcweir 
ToolbarMenu(const Reference<XFrame> & rFrame,Window * pParentWindow,WinBits nBits)460cdf0e10cSrcweir ToolbarMenu::ToolbarMenu( const Reference< XFrame >& rFrame, Window* pParentWindow, WinBits nBits )
461cdf0e10cSrcweir : DockingWindow(pParentWindow, nBits)
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     implInit(rFrame);
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir // --------------------------------------------------------------------
467cdf0e10cSrcweir 
ToolbarMenu(const Reference<XFrame> & rFrame,Window * pParentWindow,const ResId & rResId)468cdf0e10cSrcweir ToolbarMenu::ToolbarMenu( const Reference< XFrame >& rFrame, Window* pParentWindow, const ResId& rResId )
469cdf0e10cSrcweir : DockingWindow(pParentWindow, rResId)
470cdf0e10cSrcweir {
471cdf0e10cSrcweir     implInit(rFrame);
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir // --------------------------------------------------------------------
475cdf0e10cSrcweir 
implInit(const Reference<XFrame> & rFrame)476cdf0e10cSrcweir void ToolbarMenu::implInit(const Reference< XFrame >& rFrame)
477cdf0e10cSrcweir {
478cdf0e10cSrcweir 	mpImpl = new ToolbarMenu_Impl( *this, rFrame );
479cdf0e10cSrcweir 
480cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
481cdf0e10cSrcweir 	SetControlBackground( rStyleSettings.GetMenuColor() );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir     initWindow();
484cdf0e10cSrcweir 
485cdf0e10cSrcweir     Window* pWindow = GetTopMostParentSystemWindow( this );
486cdf0e10cSrcweir     if ( pWindow )
487cdf0e10cSrcweir         ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir // --------------------------------------------------------------------
491cdf0e10cSrcweir 
~ToolbarMenu()492cdf0e10cSrcweir ToolbarMenu::~ToolbarMenu()
493cdf0e10cSrcweir {
494cdf0e10cSrcweir     Window* pWindow = GetTopMostParentSystemWindow( this );
495cdf0e10cSrcweir     if ( pWindow )
496cdf0e10cSrcweir         ((SystemWindow *)pWindow)->GetTaskPaneList()->RemoveWindow( this );
497cdf0e10cSrcweir 
498cdf0e10cSrcweir     if ( mpImpl->mxStatusListener.is() )
499cdf0e10cSrcweir     {
500cdf0e10cSrcweir         mpImpl->mxStatusListener->dispose();
501cdf0e10cSrcweir         mpImpl->mxStatusListener.clear();
502cdf0e10cSrcweir     }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 	// delete all menu entries
505cdf0e10cSrcweir 	const int nEntryCount = mpImpl->maEntryVector.size();
506cdf0e10cSrcweir 	int nEntry;
507cdf0e10cSrcweir 	for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
508cdf0e10cSrcweir 	{
509cdf0e10cSrcweir 		delete mpImpl->maEntryVector[nEntry];
510cdf0e10cSrcweir 	}
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 	delete mpImpl;
513cdf0e10cSrcweir }
514cdf0e10cSrcweir 
515cdf0e10cSrcweir // --------------------------------------------------------------------
516cdf0e10cSrcweir 
getSelectedEntryId() const517cdf0e10cSrcweir int ToolbarMenu::getSelectedEntryId() const
518cdf0e10cSrcweir {
519cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implGetEntry( mpImpl->mnSelectedEntry );
520cdf0e10cSrcweir 	return pEntry ? pEntry->mnEntryId : -1;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir // --------------------------------------------------------------------
524cdf0e10cSrcweir 
getHighlightedEntryId() const525cdf0e10cSrcweir int ToolbarMenu::getHighlightedEntryId() const
526cdf0e10cSrcweir {
527cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implGetEntry( mpImpl->mnHighlightedEntry );
528cdf0e10cSrcweir 	return pEntry ? pEntry->mnEntryId : -1;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
531cdf0e10cSrcweir // --------------------------------------------------------------------
532cdf0e10cSrcweir 
checkEntry(int nEntryId,bool bChecked)533cdf0e10cSrcweir void ToolbarMenu::checkEntry( int nEntryId, bool bChecked )
534cdf0e10cSrcweir {
535cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
536cdf0e10cSrcweir 	if( pEntry && pEntry->mbChecked != bChecked )
537cdf0e10cSrcweir 	{
538cdf0e10cSrcweir 		pEntry->mbChecked = bChecked;
539cdf0e10cSrcweir 		Invalidate();
540cdf0e10cSrcweir 	}
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir // --------------------------------------------------------------------
544cdf0e10cSrcweir 
isEntryChecked(int nEntryId) const545cdf0e10cSrcweir bool ToolbarMenu::isEntryChecked( int nEntryId ) const
546cdf0e10cSrcweir {
547cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
548cdf0e10cSrcweir 	return pEntry && pEntry->mbChecked;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir // --------------------------------------------------------------------
552cdf0e10cSrcweir 
enableEntry(int nEntryId,bool bEnable)553cdf0e10cSrcweir void ToolbarMenu::enableEntry( int nEntryId, bool bEnable )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
556cdf0e10cSrcweir 	if( pEntry && pEntry->mbEnabled != bEnable )
557cdf0e10cSrcweir 	{
558cdf0e10cSrcweir 		pEntry->mbEnabled = bEnable;
559cdf0e10cSrcweir 		if( pEntry->mpControl )
560cdf0e10cSrcweir 		{
561cdf0e10cSrcweir 			pEntry->mpControl->Enable( bEnable );
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 			// hack for the valueset to make it paint itself anew
564cdf0e10cSrcweir 			pEntry->mpControl->Resize();
565cdf0e10cSrcweir 		}
566cdf0e10cSrcweir 		Invalidate();
567cdf0e10cSrcweir 	}
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir // --------------------------------------------------------------------
571cdf0e10cSrcweir 
isEntryEnabled(int nEntryId) const572cdf0e10cSrcweir bool ToolbarMenu::isEntryEnabled( int nEntryId ) const
573cdf0e10cSrcweir {
574cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
575cdf0e10cSrcweir 	return pEntry && pEntry->mbEnabled;
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir // --------------------------------------------------------------------
579cdf0e10cSrcweir 
setEntryText(int nEntryId,const String & rStr)580cdf0e10cSrcweir void ToolbarMenu::setEntryText( int nEntryId, const String& rStr )
581cdf0e10cSrcweir {
582cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
583cdf0e10cSrcweir 	if( pEntry && pEntry->maText != rStr )
584cdf0e10cSrcweir 	{
585cdf0e10cSrcweir 		pEntry->maText = rStr;
586cdf0e10cSrcweir 		mpImpl->maSize = implCalcSize();
587cdf0e10cSrcweir 		if( IsVisible() )
588cdf0e10cSrcweir 			Invalidate();
589cdf0e10cSrcweir 	}
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
592cdf0e10cSrcweir // --------------------------------------------------------------------
593cdf0e10cSrcweir 
getEntryText(int nEntryId) const594cdf0e10cSrcweir const String& ToolbarMenu::getEntryText( int nEntryId ) const
595cdf0e10cSrcweir {
596cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
597cdf0e10cSrcweir 	if( pEntry )
598cdf0e10cSrcweir 		return pEntry->maText;
599cdf0e10cSrcweir 	else
600cdf0e10cSrcweir 	{
601cdf0e10cSrcweir 		static String aEmptyStr;
602cdf0e10cSrcweir         return aEmptyStr;
603cdf0e10cSrcweir 	}
604cdf0e10cSrcweir }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir // --------------------------------------------------------------------
607cdf0e10cSrcweir 
setEntryImage(int nEntryId,const Image & rImage)608cdf0e10cSrcweir void ToolbarMenu::setEntryImage( int nEntryId, const Image& rImage )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
611cdf0e10cSrcweir 	if( pEntry && pEntry->maImage != rImage )
612cdf0e10cSrcweir 	{
613cdf0e10cSrcweir 		pEntry->maImage = rImage;
614cdf0e10cSrcweir 		mpImpl->maSize = implCalcSize();
615cdf0e10cSrcweir 		if( IsVisible() )
616cdf0e10cSrcweir 			Invalidate();
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir }
619cdf0e10cSrcweir 
620cdf0e10cSrcweir // --------------------------------------------------------------------
621cdf0e10cSrcweir 
getEntryImage(int nEntryId) const622cdf0e10cSrcweir const Image& ToolbarMenu::getEntryImage( int nEntryId ) const
623cdf0e10cSrcweir {
624cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = implSearchEntry( nEntryId );
625cdf0e10cSrcweir 	if( pEntry )
626cdf0e10cSrcweir 		return pEntry->maImage;
627cdf0e10cSrcweir 	else
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir 		static Image aEmptyImage;
630cdf0e10cSrcweir         return aEmptyImage;
631cdf0e10cSrcweir 	}
632cdf0e10cSrcweir }
633cdf0e10cSrcweir 
634cdf0e10cSrcweir // --------------------------------------------------------------------
635cdf0e10cSrcweir 
initWindow()636cdf0e10cSrcweir void ToolbarMenu::initWindow()
637cdf0e10cSrcweir {
638cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 	SetPointFont( rStyleSettings.GetMenuFont() );
641cdf0e10cSrcweir     SetBackground( Wallpaper( GetControlBackground() ) );
642cdf0e10cSrcweir     SetTextColor( rStyleSettings.GetMenuTextColor() );
643cdf0e10cSrcweir     SetTextFillColor();
644cdf0e10cSrcweir     SetLineColor();
645cdf0e10cSrcweir 
646cdf0e10cSrcweir 	mpImpl->maSize = implCalcSize();
647cdf0e10cSrcweir }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir // --------------------------------------------------------------------
650cdf0e10cSrcweir 
implCalcSize()651cdf0e10cSrcweir Size ToolbarMenu::implCalcSize()
652cdf0e10cSrcweir {
653cdf0e10cSrcweir 	const long nFontHeight = GetTextHeight();
654cdf0e10cSrcweir 	long nExtra = nFontHeight/4;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     Size aSz;
657cdf0e10cSrcweir     Size aMaxImgSz;
658cdf0e10cSrcweir     long nMaxTextWidth = 0;
659cdf0e10cSrcweir     long nMinMenuItemHeight = nFontHeight+2;
660cdf0e10cSrcweir 	sal_Bool bCheckable = sal_False;
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 	const int nEntryCount = mpImpl->maEntryVector.size();
663cdf0e10cSrcweir 	int nEntry;
664cdf0e10cSrcweir 
665cdf0e10cSrcweir 	const StyleSettings& rSettings = GetSettings().GetStyleSettings();
666cdf0e10cSrcweir 	const bool bUseImages = rSettings.GetUseImagesInMenus();
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	// get maximum image size
669cdf0e10cSrcweir 	if( bUseImages )
670cdf0e10cSrcweir 	{
671cdf0e10cSrcweir 		for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
672cdf0e10cSrcweir 		{
673cdf0e10cSrcweir 			ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
674cdf0e10cSrcweir 			if( pEntry && pEntry->mbHasImage )
675cdf0e10cSrcweir 			{
676cdf0e10cSrcweir 				Size aImgSz( pEntry->maImage.GetSizePixel() );
677cdf0e10cSrcweir 				nMinMenuItemHeight = std::max( nMinMenuItemHeight, aImgSz.Height() + 6 );
678cdf0e10cSrcweir 			    aMaxImgSz.Width() = std::max( aMaxImgSz.Width(), aImgSz.Width() );
679cdf0e10cSrcweir 			}
680cdf0e10cSrcweir 		}
681cdf0e10cSrcweir 	}
682cdf0e10cSrcweir 
683cdf0e10cSrcweir 	mpImpl->mnCheckPos = nExtra;
684cdf0e10cSrcweir 	mpImpl->mnImagePos = nExtra;
685cdf0e10cSrcweir 	mpImpl->mnTextPos = mpImpl->mnImagePos + aMaxImgSz.Width();
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 	if ( aMaxImgSz.Width() )
688cdf0e10cSrcweir 		mpImpl->mnTextPos += std::max( nExtra, 7L );
689cdf0e10cSrcweir 	if ( bCheckable	)
690cdf0e10cSrcweir 		mpImpl->mnTextPos += 16;
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 	// set heights, calc maximum width
693cdf0e10cSrcweir     for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
694cdf0e10cSrcweir     {
695cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 		if( pEntry )
698cdf0e10cSrcweir 		{
699cdf0e10cSrcweir 			if ( ( pEntry->mnBits ) & ( MIB_RADIOCHECK | MIB_CHECKABLE ) )
700cdf0e10cSrcweir 				bCheckable = sal_True;
701cdf0e10cSrcweir 
702cdf0e10cSrcweir             // Text:
703cdf0e10cSrcweir             if( pEntry->mbHasText || pEntry->mbHasImage )
704cdf0e10cSrcweir             {
705cdf0e10cSrcweir 				pEntry->maSize.Height() = nMinMenuItemHeight;
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 				if( pEntry->mbHasText )
708cdf0e10cSrcweir 				{
709cdf0e10cSrcweir 					long nTextWidth = GetCtrlTextWidth( pEntry->maText ) + mpImpl->mnTextPos + nExtra;
710cdf0e10cSrcweir 					nMaxTextWidth = std::max( nTextWidth, nMaxTextWidth );
711cdf0e10cSrcweir 				}
712cdf0e10cSrcweir 			}
713cdf0e10cSrcweir 			// Control:
714cdf0e10cSrcweir             else if( pEntry->mpControl )
715cdf0e10cSrcweir 			{
716cdf0e10cSrcweir 				Size aControlSize( pEntry->mpControl->GetOutputSizePixel() );
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 				nMaxTextWidth = std::max( aControlSize.Width(), nMaxTextWidth );
719cdf0e10cSrcweir                 pEntry->maSize.Height() = aControlSize.Height() + 1;
720cdf0e10cSrcweir 			}
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 		}
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 	aSz.Width() = nMaxTextWidth + (BORDER_X<<1);
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	// positionate controls
728cdf0e10cSrcweir 	int nY = BORDER_Y;
729cdf0e10cSrcweir     for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
730cdf0e10cSrcweir     {
731cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 		if( pEntry )
734cdf0e10cSrcweir 		{
735cdf0e10cSrcweir 			pEntry->maSize.Width() = nMaxTextWidth;
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 			if( pEntry->mpControl )
738cdf0e10cSrcweir 			{
739cdf0e10cSrcweir 				Size aControlSize( pEntry->mpControl->GetOutputSizePixel() );
740cdf0e10cSrcweir 				Point aControlPos( (aSz.Width() - aControlSize.Width())>>1, nY);
741cdf0e10cSrcweir 
742cdf0e10cSrcweir 				pEntry->mpControl->SetPosPixel( aControlPos );
743cdf0e10cSrcweir 
744cdf0e10cSrcweir 				pEntry->maRect = Rectangle( aControlPos, aControlSize );
745cdf0e10cSrcweir 			}
746cdf0e10cSrcweir 			else
747cdf0e10cSrcweir 			{
748cdf0e10cSrcweir 				pEntry->maRect = Rectangle( Point( 0, nY ), pEntry->maSize );
749cdf0e10cSrcweir 			}
750cdf0e10cSrcweir 
751cdf0e10cSrcweir 			nY += pEntry->maSize.Height();
752cdf0e10cSrcweir 		}
753cdf0e10cSrcweir 		else
754cdf0e10cSrcweir 		{
755cdf0e10cSrcweir 			nY += SEPARATOR_HEIGHT;
756cdf0e10cSrcweir 		}
757cdf0e10cSrcweir 	}
758cdf0e10cSrcweir 
759cdf0e10cSrcweir 	aSz.Height() += nY + BORDER_Y;
760cdf0e10cSrcweir 
761cdf0e10cSrcweir     return aSz;
762cdf0e10cSrcweir }
763cdf0e10cSrcweir 
764cdf0e10cSrcweir // --------------------------------------------------------------------
765cdf0e10cSrcweir 
highlightFirstEntry()766cdf0e10cSrcweir void ToolbarMenu::highlightFirstEntry()
767cdf0e10cSrcweir {
768cdf0e10cSrcweir 	implChangeHighlightEntry( 0 );
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir // --------------------------------------------------------------------
772cdf0e10cSrcweir 
GetFocus()773cdf0e10cSrcweir void ToolbarMenu::GetFocus()
774cdf0e10cSrcweir {
775cdf0e10cSrcweir 	if( mpImpl->mnHighlightedEntry == -1 )
776cdf0e10cSrcweir 		implChangeHighlightEntry( 0 );
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 	DockingWindow::GetFocus();
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
781cdf0e10cSrcweir // --------------------------------------------------------------------
782cdf0e10cSrcweir 
LoseFocus()783cdf0e10cSrcweir void ToolbarMenu::LoseFocus()
784cdf0e10cSrcweir {
785cdf0e10cSrcweir 	if( mpImpl->mnHighlightedEntry != -1 )
786cdf0e10cSrcweir 		implChangeHighlightEntry( -1 );
787cdf0e10cSrcweir 
788cdf0e10cSrcweir 	DockingWindow::LoseFocus();
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir // --------------------------------------------------------------------
792cdf0e10cSrcweir 
appendEntry(int nEntryId,const String & rStr,MenuItemBits nItemBits)793cdf0e10cSrcweir void ToolbarMenu::appendEntry( int nEntryId, const String& rStr, MenuItemBits nItemBits )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir 	appendEntry( new ToolbarMenuEntry( *this, nEntryId, rStr, nItemBits ) );
796cdf0e10cSrcweir }
797cdf0e10cSrcweir 
798cdf0e10cSrcweir // --------------------------------------------------------------------
799cdf0e10cSrcweir 
appendEntry(int nEntryId,const Image & rImage,MenuItemBits nItemBits)800cdf0e10cSrcweir void ToolbarMenu::appendEntry( int nEntryId, const Image& rImage, MenuItemBits nItemBits )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir 	appendEntry( new ToolbarMenuEntry( *this, nEntryId, rImage, nItemBits ) );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
805cdf0e10cSrcweir // --------------------------------------------------------------------
806cdf0e10cSrcweir 
appendEntry(int nEntryId,const String & rStr,const Image & rImage,MenuItemBits nItemBits)807cdf0e10cSrcweir void ToolbarMenu::appendEntry( int nEntryId, const String& rStr, const Image& rImage, MenuItemBits nItemBits )
808cdf0e10cSrcweir {
809cdf0e10cSrcweir 	appendEntry( new ToolbarMenuEntry( *this, nEntryId, rImage, rStr, nItemBits ) );
810cdf0e10cSrcweir }
811cdf0e10cSrcweir 
812cdf0e10cSrcweir // --------------------------------------------------------------------
813cdf0e10cSrcweir 
appendEntry(int nEntryId,Control * pControl,MenuItemBits nItemBits)814cdf0e10cSrcweir void ToolbarMenu::appendEntry( int nEntryId, Control* pControl, MenuItemBits nItemBits )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	appendEntry( new ToolbarMenuEntry( *this, nEntryId, pControl, nItemBits ) );
817cdf0e10cSrcweir }
818cdf0e10cSrcweir 
819cdf0e10cSrcweir // --------------------------------------------------------------------
820cdf0e10cSrcweir 
appendEntry(ToolbarMenuEntry * pEntry)821cdf0e10cSrcweir void ToolbarMenu::appendEntry( ToolbarMenuEntry* pEntry )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir 	mpImpl->maEntryVector.push_back( pEntry );
824cdf0e10cSrcweir 	mpImpl->maSize = implCalcSize();
825cdf0e10cSrcweir 	if( IsVisible() )
826cdf0e10cSrcweir 		Invalidate();
827cdf0e10cSrcweir }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir // --------------------------------------------------------------------
830cdf0e10cSrcweir 
appendSeparator()831cdf0e10cSrcweir void ToolbarMenu::appendSeparator()
832cdf0e10cSrcweir {
833cdf0e10cSrcweir 	appendEntry( 0 );
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
836cdf0e10cSrcweir // --------------------------------------------------------------------
837cdf0e10cSrcweir 
838cdf0e10cSrcweir /** creates an empty ValueSet that is initialized and can be inserted with appendEntry. */
createEmptyValueSetControl()839cdf0e10cSrcweir ValueSet* ToolbarMenu::createEmptyValueSetControl()
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	ValueSet* pSet = new ValueSet( this, WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT );
842cdf0e10cSrcweir 	pSet->EnableFullItemMode( sal_False );
843cdf0e10cSrcweir 	pSet->SetColor( GetControlBackground() );
844cdf0e10cSrcweir 	pSet->SetHighlightHdl( LINK( this, ToolbarMenu, HighlightHdl ) );
845cdf0e10cSrcweir 	return pSet;
846cdf0e10cSrcweir }
847cdf0e10cSrcweir 
848cdf0e10cSrcweir // --------------------------------------------------------------------
849cdf0e10cSrcweir 
implGetEntry(int nEntry) const850cdf0e10cSrcweir ToolbarMenuEntry* ToolbarMenu::implGetEntry( int nEntry ) const
851cdf0e10cSrcweir {
852cdf0e10cSrcweir 	return mpImpl->implGetEntry( nEntry );
853cdf0e10cSrcweir }
854cdf0e10cSrcweir 
855cdf0e10cSrcweir // --------------------------------------------------------------------
856cdf0e10cSrcweir 
implSearchEntry(int nEntryId) const857cdf0e10cSrcweir ToolbarMenuEntry* ToolbarMenu::implSearchEntry( int nEntryId ) const
858cdf0e10cSrcweir {
859cdf0e10cSrcweir 	const int nEntryCount = mpImpl->maEntryVector.size();
860cdf0e10cSrcweir 	int nEntry;
861cdf0e10cSrcweir 	for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
862cdf0e10cSrcweir     {
863cdf0e10cSrcweir         ToolbarMenuEntry* p = mpImpl->maEntryVector[nEntry];
864cdf0e10cSrcweir         if( p && p->mnEntryId == nEntryId )
865cdf0e10cSrcweir 		{
866cdf0e10cSrcweir 			return p;
867cdf0e10cSrcweir 		}
868cdf0e10cSrcweir 	}
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 	return NULL;
871cdf0e10cSrcweir }
872cdf0e10cSrcweir 
873cdf0e10cSrcweir // --------------------------------------------------------------------
874cdf0e10cSrcweir 
implHighlightEntry(int nHighlightEntry,bool bHighlight)875cdf0e10cSrcweir void ToolbarMenu::implHighlightEntry( int nHighlightEntry, bool bHighlight )
876cdf0e10cSrcweir {
877cdf0e10cSrcweir     Size    aSz( GetOutputSizePixel() );
878cdf0e10cSrcweir     long    nX = 0, nY = 0;
879cdf0e10cSrcweir 
880cdf0e10cSrcweir 	const int nEntryCount = mpImpl->maEntryVector.size();
881cdf0e10cSrcweir 	int nEntry;
882cdf0e10cSrcweir 	for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
883cdf0e10cSrcweir     {
884cdf0e10cSrcweir         ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
885cdf0e10cSrcweir         if( pEntry && (nEntry == nHighlightEntry) )
886cdf0e10cSrcweir         {
887cdf0e10cSrcweir 			// no highlights for controls only items
888cdf0e10cSrcweir 			if( pEntry->mpControl )
889cdf0e10cSrcweir 			{
890cdf0e10cSrcweir 				if( !bHighlight )
891cdf0e10cSrcweir 				{
892cdf0e10cSrcweir 					ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl );
893cdf0e10cSrcweir 					if( pValueSet )
894cdf0e10cSrcweir 					{
895cdf0e10cSrcweir 						pValueSet->SetNoSelection();
896cdf0e10cSrcweir 					}
897cdf0e10cSrcweir 				}
898cdf0e10cSrcweir 				break;
899cdf0e10cSrcweir 			}
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 			bool bRestoreLineColor = false;
902cdf0e10cSrcweir             Color oldLineColor;
903cdf0e10cSrcweir             bool bDrawItemRect = true;
904cdf0e10cSrcweir 
905cdf0e10cSrcweir             Rectangle aItemRect( Point( nX, nY ), Size( aSz.Width(), pEntry->maSize.Height() ) );
906cdf0e10cSrcweir             if ( pEntry->mnBits & MIB_POPUPSELECT )
907cdf0e10cSrcweir             {
908cdf0e10cSrcweir                 long nFontHeight = GetTextHeight();
909cdf0e10cSrcweir                 aItemRect.Right() -= nFontHeight + nFontHeight/4;
910cdf0e10cSrcweir             }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir             if( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) )
913cdf0e10cSrcweir             {
914cdf0e10cSrcweir                 Size aPxSize( GetOutputSizePixel() );
915cdf0e10cSrcweir                 Push( PUSH_CLIPREGION );
916cdf0e10cSrcweir                 IntersectClipRegion( Rectangle( Point( nX, nY ), Size( aSz.Width(), pEntry->maSize.Height() ) ) );
917cdf0e10cSrcweir                 Rectangle aCtrlRect( Point( nX, 0 ), Size( aPxSize.Width()-nX, aPxSize.Height() ) );
918cdf0e10cSrcweir                 DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL,
919cdf0e10cSrcweir                                    aCtrlRect,
920cdf0e10cSrcweir                                    CTRL_STATE_ENABLED,
921cdf0e10cSrcweir                                    ImplControlValue(),
922cdf0e10cSrcweir                                    OUString() );
923cdf0e10cSrcweir                 if( bHighlight && IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM ) )
924cdf0e10cSrcweir                 {
925cdf0e10cSrcweir                     bDrawItemRect = false;
926cdf0e10cSrcweir                     if( sal_False == DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_ITEM,
927cdf0e10cSrcweir                                                     aItemRect,
928cdf0e10cSrcweir                                                     CTRL_STATE_SELECTED | ( pEntry->mbEnabled? CTRL_STATE_ENABLED: 0 ),
929cdf0e10cSrcweir                                                     ImplControlValue(),
930cdf0e10cSrcweir                                                     OUString() ) )
931cdf0e10cSrcweir                     {
932cdf0e10cSrcweir                         bDrawItemRect = bHighlight;
933cdf0e10cSrcweir                     }
934cdf0e10cSrcweir                 }
935cdf0e10cSrcweir                 else
936cdf0e10cSrcweir                     bDrawItemRect = bHighlight;
937cdf0e10cSrcweir                 Pop();
938cdf0e10cSrcweir             }
939cdf0e10cSrcweir             if( bDrawItemRect )
940cdf0e10cSrcweir             {
941cdf0e10cSrcweir                 if ( bHighlight )
942cdf0e10cSrcweir                 {
943cdf0e10cSrcweir                     if( pEntry->mbEnabled )
944cdf0e10cSrcweir                         SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() );
945cdf0e10cSrcweir                     else
946cdf0e10cSrcweir                     {
947cdf0e10cSrcweir                         SetFillColor();
948cdf0e10cSrcweir                         oldLineColor = GetLineColor();
949cdf0e10cSrcweir                         SetLineColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() );
950cdf0e10cSrcweir                         bRestoreLineColor = true;
951cdf0e10cSrcweir                     }
952cdf0e10cSrcweir                 }
953cdf0e10cSrcweir                 else
954cdf0e10cSrcweir                     SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
955cdf0e10cSrcweir 
956cdf0e10cSrcweir                 DrawRect( aItemRect );
957cdf0e10cSrcweir             }
958cdf0e10cSrcweir             implPaint( pEntry, bHighlight );
959cdf0e10cSrcweir             if( bRestoreLineColor )
960cdf0e10cSrcweir                 SetLineColor( oldLineColor );
961cdf0e10cSrcweir             break;
962cdf0e10cSrcweir         }
963cdf0e10cSrcweir 
964cdf0e10cSrcweir         nY += pEntry ? pEntry->maSize.Height() : SEPARATOR_HEIGHT;
965cdf0e10cSrcweir     }
966cdf0e10cSrcweir }
967cdf0e10cSrcweir 
968cdf0e10cSrcweir // --------------------------------------------------------------------
969cdf0e10cSrcweir 
implSelectEntry(int nSelectedEntry)970cdf0e10cSrcweir void ToolbarMenu::implSelectEntry( int nSelectedEntry )
971cdf0e10cSrcweir {
972cdf0e10cSrcweir 	mpImpl->mnSelectedEntry = nSelectedEntry;
973cdf0e10cSrcweir 
974cdf0e10cSrcweir 	ToolbarMenuEntry* pEntry = NULL;
975cdf0e10cSrcweir 	if( nSelectedEntry != -1 )
976cdf0e10cSrcweir 		pEntry = mpImpl->maEntryVector[ nSelectedEntry ];
977cdf0e10cSrcweir 
978cdf0e10cSrcweir 	if( pEntry )
979cdf0e10cSrcweir 		mpImpl->maSelectHdl.Call( this );
980cdf0e10cSrcweir }
981cdf0e10cSrcweir 
982cdf0e10cSrcweir // --------------------------------------------------------------------
983cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)984cdf0e10cSrcweir void ToolbarMenu::MouseButtonDown( const MouseEvent& rMEvt )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir 	implHighlightEntry( rMEvt, true );
987cdf0e10cSrcweir 
988cdf0e10cSrcweir 	implSelectEntry( mpImpl->mnHighlightedEntry );
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir // --------------------------------------------------------------------
992cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent &)993cdf0e10cSrcweir void ToolbarMenu::MouseButtonUp( const MouseEvent& )
994cdf0e10cSrcweir {
995cdf0e10cSrcweir }
996cdf0e10cSrcweir 
997cdf0e10cSrcweir // --------------------------------------------------------------------
998cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)999cdf0e10cSrcweir void ToolbarMenu::MouseMove( const MouseEvent& rMEvt )
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir 	if ( !IsVisible() )
1002cdf0e10cSrcweir         return;
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 	implHighlightEntry( rMEvt, false );
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir // --------------------------------------------------------------------
1008cdf0e10cSrcweir 
implHighlightEntry(const MouseEvent & rMEvt,bool bMBDown)1009cdf0e10cSrcweir void ToolbarMenu::implHighlightEntry( const MouseEvent& rMEvt, bool bMBDown )
1010cdf0e10cSrcweir {
1011cdf0e10cSrcweir     long nY = 0;
1012cdf0e10cSrcweir     long nMouseY = rMEvt.GetPosPixel().Y();
1013cdf0e10cSrcweir     Size aOutSz = GetOutputSizePixel();
1014cdf0e10cSrcweir     if ( ( nMouseY >= 0 ) && ( nMouseY < aOutSz.Height() ) )
1015cdf0e10cSrcweir     {
1016cdf0e10cSrcweir         bool bHighlighted = sal_False;
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir 		const int nEntryCount = mpImpl->maEntryVector.size();
1019cdf0e10cSrcweir 		int nEntry;
1020cdf0e10cSrcweir 		for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
1021cdf0e10cSrcweir 		{
1022cdf0e10cSrcweir 			ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
1023cdf0e10cSrcweir             if( pEntry )
1024cdf0e10cSrcweir             {
1025cdf0e10cSrcweir                 long nOldY = nY;
1026cdf0e10cSrcweir                 nY += pEntry->maSize.Height();
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 				if( pEntry->mnEntryId != TITLE_ID )
1029cdf0e10cSrcweir 				{
1030cdf0e10cSrcweir 					if ( ( nOldY <= nMouseY ) && ( nY > nMouseY ) )
1031cdf0e10cSrcweir 					{
1032cdf0e10cSrcweir 						if( bMBDown )
1033cdf0e10cSrcweir 						{
1034cdf0e10cSrcweir 							if( nEntry != mpImpl->mnHighlightedEntry )
1035cdf0e10cSrcweir 							{
1036cdf0e10cSrcweir 								implChangeHighlightEntry( nEntry );
1037cdf0e10cSrcweir 							}
1038cdf0e10cSrcweir 						}
1039cdf0e10cSrcweir 						else
1040cdf0e10cSrcweir 						{
1041cdf0e10cSrcweir 							if ( nEntry != mpImpl->mnHighlightedEntry )
1042cdf0e10cSrcweir 							{
1043cdf0e10cSrcweir 								implChangeHighlightEntry( nEntry );
1044cdf0e10cSrcweir 							}
1045cdf0e10cSrcweir 						}
1046cdf0e10cSrcweir 						bHighlighted = true;
1047cdf0e10cSrcweir 					}
1048cdf0e10cSrcweir                 }
1049cdf0e10cSrcweir             }
1050cdf0e10cSrcweir 			else
1051cdf0e10cSrcweir 			{
1052cdf0e10cSrcweir 				nY += SEPARATOR_HEIGHT;
1053cdf0e10cSrcweir 			}
1054cdf0e10cSrcweir         }
1055cdf0e10cSrcweir         if ( !bHighlighted )
1056cdf0e10cSrcweir             implChangeHighlightEntry( -1 );
1057cdf0e10cSrcweir     }
1058cdf0e10cSrcweir     else
1059cdf0e10cSrcweir     {
1060cdf0e10cSrcweir         implChangeHighlightEntry( -1 );
1061cdf0e10cSrcweir     }
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir // --------------------------------------------------------------------
1065cdf0e10cSrcweir 
implChangeHighlightEntry(int nEntry)1066cdf0e10cSrcweir void ToolbarMenu::implChangeHighlightEntry( int nEntry )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir     if( mpImpl->mnHighlightedEntry != -1 )
1069cdf0e10cSrcweir     {
1070cdf0e10cSrcweir         implHighlightEntry( mpImpl->mnHighlightedEntry, false );
1071cdf0e10cSrcweir     }
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 	mpImpl->mnHighlightedEntry = nEntry;
1074cdf0e10cSrcweir 	Invalidate();
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir 	if( mpImpl->mnHighlightedEntry != -1 )
1077cdf0e10cSrcweir     {
1078cdf0e10cSrcweir 		implHighlightEntry( mpImpl->mnHighlightedEntry, true );
1079cdf0e10cSrcweir     }
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir 	mpImpl->notifyHighlightedEntry();
1082cdf0e10cSrcweir }
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir // --------------------------------------------------------------------
1085cdf0e10cSrcweir 
implCheckSubControlCursorMove(Control * pControl,bool bUp,int & nLastColumn)1086cdf0e10cSrcweir static bool implCheckSubControlCursorMove( Control* pControl, bool bUp, int& nLastColumn )
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir 	ValueSet* pValueSet = dynamic_cast< ValueSet* >( pControl );
1089cdf0e10cSrcweir 	if( pValueSet )
1090cdf0e10cSrcweir 	{
1091cdf0e10cSrcweir 		sal_uInt16 nItemPos = pValueSet->GetItemPos( pValueSet->GetSelectItemId() );
1092cdf0e10cSrcweir 		if( nItemPos != VALUESET_ITEM_NOTFOUND )
1093cdf0e10cSrcweir 		{
1094cdf0e10cSrcweir 			const sal_uInt16 nColCount = pValueSet->GetColCount();
1095cdf0e10cSrcweir 			const sal_uInt16 nLine = nItemPos / nColCount;
1096cdf0e10cSrcweir 
1097cdf0e10cSrcweir 			nLastColumn = nItemPos - (nLine * nColCount);
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 			if( bUp )
1100cdf0e10cSrcweir 			{
1101cdf0e10cSrcweir 				return nLine > 0;
1102cdf0e10cSrcweir 			}
1103cdf0e10cSrcweir 			else
1104cdf0e10cSrcweir 			{
1105cdf0e10cSrcweir 				const sal_uInt16 nLineCount = (pValueSet->GetItemCount() + nColCount - 1) / nColCount;
1106cdf0e10cSrcweir 				return (nLine+1) < nLineCount;
1107cdf0e10cSrcweir 			}
1108cdf0e10cSrcweir 		}
1109cdf0e10cSrcweir 	}
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 	return false;
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir // --------------------------------------------------------------------
1115cdf0e10cSrcweir 
implCursorUpDown(bool bUp,bool bHomeEnd)1116cdf0e10cSrcweir ToolbarMenuEntry* ToolbarMenu::implCursorUpDown( bool bUp, bool bHomeEnd )
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir     int n = 0, nLoop = 0;
1119cdf0e10cSrcweir 	if( !bHomeEnd )
1120cdf0e10cSrcweir 	{
1121cdf0e10cSrcweir 		n = mpImpl->mnHighlightedEntry;
1122cdf0e10cSrcweir 		if( n == -1 )
1123cdf0e10cSrcweir 		{
1124cdf0e10cSrcweir 			if( bUp )
1125cdf0e10cSrcweir 				n = 0;
1126cdf0e10cSrcweir 			else
1127cdf0e10cSrcweir 				n = mpImpl->maEntryVector.size()-1;
1128cdf0e10cSrcweir 		}
1129cdf0e10cSrcweir 		else
1130cdf0e10cSrcweir 		{
1131cdf0e10cSrcweir 			// if we have a currently selected entry and
1132cdf0e10cSrcweir 			// cursor keys are used than check if this entry
1133cdf0e10cSrcweir 			// has a control that can use those cursor keys
1134cdf0e10cSrcweir 			ToolbarMenuEntry* pData = mpImpl->maEntryVector[n];
1135cdf0e10cSrcweir 			if( pData && pData->mpControl && !pData->mbHasText )
1136cdf0e10cSrcweir 			{
1137cdf0e10cSrcweir 				if( implCheckSubControlCursorMove( pData->mpControl, bUp, mpImpl->mnLastColumn ) )
1138cdf0e10cSrcweir 					return pData;
1139cdf0e10cSrcweir 			}
1140cdf0e10cSrcweir 		}
1141cdf0e10cSrcweir 		nLoop = n;
1142cdf0e10cSrcweir 	}
1143cdf0e10cSrcweir 	else
1144cdf0e10cSrcweir 	{
1145cdf0e10cSrcweir 		// absolute positioning
1146cdf0e10cSrcweir 		if( bUp )
1147cdf0e10cSrcweir 		{
1148cdf0e10cSrcweir             n = mpImpl->maEntryVector.size();
1149cdf0e10cSrcweir 			nLoop = n-1;
1150cdf0e10cSrcweir 		}
1151cdf0e10cSrcweir 		else
1152cdf0e10cSrcweir 		{
1153cdf0e10cSrcweir 			n = -1;
1154cdf0e10cSrcweir 			nLoop = mpImpl->maEntryVector.size()-1;
1155cdf0e10cSrcweir 		}
1156cdf0e10cSrcweir 	}
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir     do
1159cdf0e10cSrcweir     {
1160cdf0e10cSrcweir         if( bUp )
1161cdf0e10cSrcweir         {
1162cdf0e10cSrcweir             if ( n )
1163cdf0e10cSrcweir                 n--;
1164cdf0e10cSrcweir             else
1165cdf0e10cSrcweir                 if( mpImpl->mnHighlightedEntry == -1 )
1166cdf0e10cSrcweir                     n = mpImpl->maEntryVector.size()-1;
1167cdf0e10cSrcweir                 else
1168cdf0e10cSrcweir                     break;
1169cdf0e10cSrcweir         }
1170cdf0e10cSrcweir         else
1171cdf0e10cSrcweir         {
1172cdf0e10cSrcweir 			if( n < ((int)mpImpl->maEntryVector.size()-1) )
1173cdf0e10cSrcweir 				n++;
1174cdf0e10cSrcweir 			else
1175cdf0e10cSrcweir                 if( mpImpl->mnHighlightedEntry == -1 )
1176cdf0e10cSrcweir                     n = 0;
1177cdf0e10cSrcweir                 else
1178cdf0e10cSrcweir                     break;
1179cdf0e10cSrcweir         }
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir         ToolbarMenuEntry* pData = mpImpl->maEntryVector[n];
1182cdf0e10cSrcweir         if( pData && (pData->mnEntryId != TITLE_ID) )
1183cdf0e10cSrcweir         {
1184cdf0e10cSrcweir 			implChangeHighlightEntry( n );
1185cdf0e10cSrcweir 			return pData;
1186cdf0e10cSrcweir 		}
1187cdf0e10cSrcweir     } while ( n != nLoop );
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir 	return 0;
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir // --------------------------------------------------------------------
1193cdf0e10cSrcweir 
implHighlightControl(sal_uInt16 nCode,Control * pControl)1194cdf0e10cSrcweir void ToolbarMenu_Impl::implHighlightControl( sal_uInt16 nCode, Control* pControl )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir 	ValueSet* pValueSet = dynamic_cast< ValueSet* >( pControl );
1197cdf0e10cSrcweir 	if( pValueSet )
1198cdf0e10cSrcweir 	{
1199cdf0e10cSrcweir 		const sal_uInt16 nItemCount = pValueSet->GetItemCount();
1200cdf0e10cSrcweir 		sal_uInt16 nItemPos = VALUESET_ITEM_NOTFOUND;
1201cdf0e10cSrcweir 		switch( nCode )
1202cdf0e10cSrcweir 		{
1203cdf0e10cSrcweir         case KEY_UP:
1204cdf0e10cSrcweir 		{
1205cdf0e10cSrcweir 			const sal_uInt16 nColCount = pValueSet->GetColCount();
1206cdf0e10cSrcweir 			const sal_uInt16 nLastLine = nItemCount / nColCount;
1207cdf0e10cSrcweir 			nItemPos = std::min( ((nLastLine-1) * nColCount) + mnLastColumn, nItemCount-1 );
1208cdf0e10cSrcweir 			break;
1209cdf0e10cSrcweir 		}
1210cdf0e10cSrcweir         case KEY_DOWN:
1211cdf0e10cSrcweir 			nItemPos = std::min( mnLastColumn, nItemCount-1 );
1212cdf0e10cSrcweir 			break;
1213cdf0e10cSrcweir         case KEY_END:
1214cdf0e10cSrcweir 			nItemPos = nItemCount -1;
1215cdf0e10cSrcweir 			break;
1216cdf0e10cSrcweir         case KEY_HOME:
1217cdf0e10cSrcweir 			nItemPos = 0;
1218cdf0e10cSrcweir 			break;
1219cdf0e10cSrcweir 		}
1220cdf0e10cSrcweir 		pValueSet->SelectItem( pValueSet->GetItemId( nItemPos ) );
1221cdf0e10cSrcweir 		notifyHighlightedEntry();
1222cdf0e10cSrcweir 	}
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir // --------------------------------------------------------------------
1226cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvent)1227cdf0e10cSrcweir void ToolbarMenu::KeyInput( const KeyEvent& rKEvent )
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir 	Control* pForwardControl = 0;
1230cdf0e10cSrcweir     sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode();
1231cdf0e10cSrcweir     switch ( nCode )
1232cdf0e10cSrcweir     {
1233cdf0e10cSrcweir         case KEY_UP:
1234cdf0e10cSrcweir         case KEY_DOWN:
1235cdf0e10cSrcweir         {
1236cdf0e10cSrcweir 			int nOldEntry = mpImpl->mnHighlightedEntry;
1237cdf0e10cSrcweir 			ToolbarMenuEntry*p = implCursorUpDown( nCode == KEY_UP, false );
1238cdf0e10cSrcweir 			if( p && p->mpControl )
1239cdf0e10cSrcweir 			{
1240cdf0e10cSrcweir 				if( nOldEntry != mpImpl->mnHighlightedEntry )
1241cdf0e10cSrcweir 				{
1242cdf0e10cSrcweir 					mpImpl->implHighlightControl( nCode, p->mpControl );
1243cdf0e10cSrcweir 				}
1244cdf0e10cSrcweir 				else
1245cdf0e10cSrcweir 				{
1246cdf0e10cSrcweir 					// in case we are in a system floating window, GrabFocus does not work :-/
1247cdf0e10cSrcweir 					pForwardControl = p->mpControl;
1248cdf0e10cSrcweir 				}
1249cdf0e10cSrcweir 			}
1250cdf0e10cSrcweir         }
1251cdf0e10cSrcweir         break;
1252cdf0e10cSrcweir         case KEY_END:
1253cdf0e10cSrcweir         case KEY_HOME:
1254cdf0e10cSrcweir 		{
1255cdf0e10cSrcweir 			ToolbarMenuEntry* p = implCursorUpDown( nCode == KEY_END, true );
1256cdf0e10cSrcweir 			if( p && p->mpControl )
1257cdf0e10cSrcweir 			{
1258cdf0e10cSrcweir 				mpImpl->implHighlightControl( nCode, p->mpControl );
1259cdf0e10cSrcweir 			}
1260cdf0e10cSrcweir 		}
1261cdf0e10cSrcweir 		break;
1262cdf0e10cSrcweir         case KEY_F6:
1263cdf0e10cSrcweir         case KEY_ESCAPE:
1264cdf0e10cSrcweir 		{
1265cdf0e10cSrcweir             // Ctrl-F6 acts like ESC here, the menu bar however will then put the focus in the document
1266cdf0e10cSrcweir             if( nCode == KEY_F6 && !rKEvent.GetKeyCode().IsMod1() )
1267cdf0e10cSrcweir                 break;
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir 			implSelectEntry( -1 );
1270cdf0e10cSrcweir 		}
1271cdf0e10cSrcweir 		break;
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir         case KEY_RETURN:
1274cdf0e10cSrcweir         {
1275cdf0e10cSrcweir 			ToolbarMenuEntry* pEntry = implGetEntry( mpImpl->mnHighlightedEntry );
1276cdf0e10cSrcweir 			if ( pEntry && pEntry->mbEnabled && (pEntry->mnEntryId != TITLE_ID) )
1277cdf0e10cSrcweir 			{
1278cdf0e10cSrcweir 				if( pEntry->mpControl )
1279cdf0e10cSrcweir 				{
1280cdf0e10cSrcweir 					pForwardControl = pEntry->mpControl;
1281cdf0e10cSrcweir 				}
1282cdf0e10cSrcweir 				else
1283cdf0e10cSrcweir 				{
1284cdf0e10cSrcweir 					implSelectEntry( mpImpl->mnHighlightedEntry );
1285cdf0e10cSrcweir 				}
1286cdf0e10cSrcweir 			}
1287cdf0e10cSrcweir         }
1288cdf0e10cSrcweir         break;
1289cdf0e10cSrcweir         default:
1290cdf0e10cSrcweir         {
1291cdf0e10cSrcweir 			ToolbarMenuEntry* pEntry = implGetEntry( mpImpl->mnHighlightedEntry );
1292cdf0e10cSrcweir 			if ( pEntry && pEntry->mbEnabled && pEntry->mpControl && !pEntry->mbHasText )
1293cdf0e10cSrcweir 			{
1294cdf0e10cSrcweir 				pForwardControl = pEntry->mpControl;
1295cdf0e10cSrcweir 			}
1296cdf0e10cSrcweir         }
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir     }
1299cdf0e10cSrcweir 	if( pForwardControl )
1300cdf0e10cSrcweir 		pForwardControl->KeyInput( rKEvent );
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir }
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir // --------------------------------------------------------------------
ImplPaintCheckBackground(Window * i_pWindow,const Rectangle & i_rRect,bool i_bHighlight)1305cdf0e10cSrcweir static void ImplPaintCheckBackground( Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight )
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir     sal_Bool bNativeOk = sal_False;
1308cdf0e10cSrcweir     if( i_pWindow->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) )
1309cdf0e10cSrcweir     {
1310cdf0e10cSrcweir         ImplControlValue    aControlValue;
1311cdf0e10cSrcweir         ControlState        nState = CTRL_STATE_PRESSED | CTRL_STATE_ENABLED;
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir         aControlValue.setTristateVal( BUTTONVALUE_ON );
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir         bNativeOk = i_pWindow->DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON,
1316cdf0e10cSrcweir                                                   i_rRect, nState, aControlValue,
1317cdf0e10cSrcweir                                                   rtl::OUString() );
1318cdf0e10cSrcweir     }
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir     if( ! bNativeOk )
1321cdf0e10cSrcweir     {
1322cdf0e10cSrcweir         const StyleSettings& rSettings = i_pWindow->GetSettings().GetStyleSettings();
1323cdf0e10cSrcweir         Color aColor( i_bHighlight ? rSettings.GetMenuHighlightTextColor() : rSettings.GetHighlightColor() );
1324cdf0e10cSrcweir         i_pWindow->DrawSelectionBackground( i_rRect, 0, i_bHighlight, sal_True, sal_False, 2, NULL, &aColor );
1325cdf0e10cSrcweir     }
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
ImplGetNativeCheckAndRadioSize(Window * pWin,long & rCheckHeight,long & rRadioHeight,long & rMaxWidth)1328cdf0e10cSrcweir static long ImplGetNativeCheckAndRadioSize( Window* pWin, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir     rMaxWidth = rCheckHeight = rRadioHeight = 0;
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir     ImplControlValue aVal;
1333cdf0e10cSrcweir     Rectangle aNativeBounds;
1334cdf0e10cSrcweir     Rectangle aNativeContent;
1335cdf0e10cSrcweir     Point tmp( 0, 0 );
1336cdf0e10cSrcweir     Rectangle aCtrlRegion( tmp, Size( 100, 15 ) );
1337cdf0e10cSrcweir     if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) )
1338cdf0e10cSrcweir     {
1339cdf0e10cSrcweir         if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP),
1340cdf0e10cSrcweir                                           ControlPart(PART_MENU_ITEM_CHECK_MARK),
1341cdf0e10cSrcweir                                           aCtrlRegion,
1342cdf0e10cSrcweir                                           ControlState(CTRL_STATE_ENABLED),
1343cdf0e10cSrcweir                                           aVal,
1344cdf0e10cSrcweir                                           OUString(),
1345cdf0e10cSrcweir                                           aNativeBounds,
1346cdf0e10cSrcweir                                           aNativeContent )
1347cdf0e10cSrcweir         )
1348cdf0e10cSrcweir         {
1349cdf0e10cSrcweir             rCheckHeight = aNativeBounds.GetHeight();
1350cdf0e10cSrcweir 			rMaxWidth = aNativeContent.GetWidth();
1351cdf0e10cSrcweir         }
1352cdf0e10cSrcweir     }
1353cdf0e10cSrcweir     if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) )
1354cdf0e10cSrcweir     {
1355cdf0e10cSrcweir         if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP),
1356cdf0e10cSrcweir                                           ControlPart(PART_MENU_ITEM_RADIO_MARK),
1357cdf0e10cSrcweir                                           aCtrlRegion,
1358cdf0e10cSrcweir                                           ControlState(CTRL_STATE_ENABLED),
1359cdf0e10cSrcweir                                           aVal,
1360cdf0e10cSrcweir                                           OUString(),
1361cdf0e10cSrcweir                                           aNativeBounds,
1362cdf0e10cSrcweir                                           aNativeContent )
1363cdf0e10cSrcweir         )
1364cdf0e10cSrcweir         {
1365cdf0e10cSrcweir             rRadioHeight = aNativeBounds.GetHeight();
1366cdf0e10cSrcweir 			rMaxWidth = Max (rMaxWidth, aNativeContent.GetWidth());
1367cdf0e10cSrcweir         }
1368cdf0e10cSrcweir     }
1369cdf0e10cSrcweir     return (rCheckHeight > rRadioHeight) ? rCheckHeight : rRadioHeight;
1370cdf0e10cSrcweir }
1371cdf0e10cSrcweir 
implPaint(ToolbarMenuEntry * pThisOnly,bool bHighlighted)1372cdf0e10cSrcweir void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir 	sal_uInt16 nBorder = 0; long nStartY = 0; // from Menu implementations, needed when we support native menu background & scrollable menu
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir     long nFontHeight = GetTextHeight();
1377cdf0e10cSrcweir //    long nExtra = nFontHeight/4;
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir     long nCheckHeight = 0, nRadioHeight = 0, nMaxCheckWidth = 0;
1380cdf0e10cSrcweir     ImplGetNativeCheckAndRadioSize( this, nCheckHeight, nRadioHeight, nMaxCheckWidth );
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir     DecorationView aDecoView( this );
1383cdf0e10cSrcweir     const StyleSettings& rSettings = GetSettings().GetStyleSettings();
1384cdf0e10cSrcweir 	const bool bUseImages = rSettings.GetUseImagesInMenus();
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir 	int nOuterSpace = 0; // ImplGetSVData()->maNWFData.mnMenuFormatExtraBorder;
1387cdf0e10cSrcweir 	Point aTopLeft( nOuterSpace, nOuterSpace ), aTmpPos;
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir     Size aOutSz( GetOutputSizePixel() );
1390cdf0e10cSrcweir 	const int nEntryCount = mpImpl->maEntryVector.size();
1391cdf0e10cSrcweir 	int nEntry;
1392cdf0e10cSrcweir 	for( nEntry = 0; nEntry < nEntryCount; nEntry++ )
1393cdf0e10cSrcweir 	{
1394cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir         Point aPos( aTopLeft );
1397cdf0e10cSrcweir         aPos.Y() += nBorder;
1398cdf0e10cSrcweir         aPos.Y() += nStartY;
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir 		if( (pEntry == 0) && !pThisOnly )
1402cdf0e10cSrcweir 		{
1403cdf0e10cSrcweir 	        // Separator
1404cdf0e10cSrcweir             aTmpPos.Y() = aPos.Y() + ((SEPARATOR_HEIGHT-2)/2);
1405cdf0e10cSrcweir             aTmpPos.X() = aPos.X() + 2 + nOuterSpace;
1406cdf0e10cSrcweir             SetLineColor( rSettings.GetShadowColor() );
1407cdf0e10cSrcweir             DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpace, aTmpPos.Y() ) );
1408cdf0e10cSrcweir             aTmpPos.Y()++;
1409cdf0e10cSrcweir             SetLineColor( rSettings.GetLightColor() );
1410cdf0e10cSrcweir             DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpace, aTmpPos.Y() ) );
1411cdf0e10cSrcweir             SetLineColor();
1412cdf0e10cSrcweir 		}
1413cdf0e10cSrcweir 		else if( !pThisOnly || ( pEntry == pThisOnly ) )
1414cdf0e10cSrcweir         {
1415cdf0e10cSrcweir 			const bool bTitle = pEntry->mnEntryId == TITLE_ID;
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir             if ( pThisOnly && bHighlighted )
1418cdf0e10cSrcweir                 SetTextColor( rSettings.GetMenuHighlightTextColor() );
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir             if( aPos.Y() >= 0 )
1421cdf0e10cSrcweir             {
1422cdf0e10cSrcweir 				long nTextOffsetY = ((pEntry->maSize.Height()-nFontHeight)/2);
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir 				sal_uInt16  nTextStyle   = 0;
1425cdf0e10cSrcweir 				sal_uInt16  nSymbolStyle = 0;
1426cdf0e10cSrcweir 				sal_uInt16  nImageStyle  = 0;
1427cdf0e10cSrcweir 
1428cdf0e10cSrcweir 				if( !pEntry->mbEnabled )
1429cdf0e10cSrcweir 				{
1430cdf0e10cSrcweir 					nTextStyle   |= TEXT_DRAW_DISABLE;
1431cdf0e10cSrcweir 					nSymbolStyle |= SYMBOL_DRAW_DISABLE;
1432cdf0e10cSrcweir 					nImageStyle  |= IMAGE_DRAW_DISABLE;
1433cdf0e10cSrcweir 				}
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir 				Rectangle aOuterCheckRect( Point( aPos.X()+mpImpl->mnCheckPos, aPos.Y() ), Size( pEntry->maSize.Height(), pEntry->maSize.Height() ) );
1436cdf0e10cSrcweir 				aOuterCheckRect.Left()      += 1;
1437cdf0e10cSrcweir 				aOuterCheckRect.Right()     -= 1;
1438cdf0e10cSrcweir 				aOuterCheckRect.Top()       += 1;
1439cdf0e10cSrcweir 				aOuterCheckRect.Bottom()    -= 1;
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir 				if( bTitle )
1442cdf0e10cSrcweir 				{
1443cdf0e10cSrcweir 					// fill the background
1444cdf0e10cSrcweir 					Rectangle aRect( aTopLeft, Size( aOutSz.Width(), pEntry->maSize.Height() ) );
1445cdf0e10cSrcweir 					SetFillColor(rSettings.GetDialogColor());
1446cdf0e10cSrcweir 					SetLineColor();
1447cdf0e10cSrcweir 					DrawRect(aRect);
1448cdf0e10cSrcweir 					SetLineColor( rSettings.GetLightColor() );
1449cdf0e10cSrcweir 					DrawLine( aRect.TopLeft(), aRect.TopRight() );
1450cdf0e10cSrcweir 					SetLineColor( rSettings.GetShadowColor() );
1451cdf0e10cSrcweir 					DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
1452cdf0e10cSrcweir 				}
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 				// CheckMark
1455cdf0e10cSrcweir 				if ( pEntry->HasCheck() )
1456cdf0e10cSrcweir 				{
1457cdf0e10cSrcweir 					// draw selection transparent marker if checked
1458cdf0e10cSrcweir 					// onto that either a checkmark or the item image
1459cdf0e10cSrcweir 					// will be painted
1460cdf0e10cSrcweir 					// however do not do this if native checks will be painted since
1461cdf0e10cSrcweir 					// the selection color too often does not fit the theme's check and/or radio
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir 					if( !pEntry->mbHasImage )
1464cdf0e10cSrcweir 					{
1465cdf0e10cSrcweir 						if( this->IsNativeControlSupported( CTRL_MENU_POPUP,
1466cdf0e10cSrcweir 															 (pEntry->mnBits & MIB_RADIOCHECK)
1467cdf0e10cSrcweir 															 ? PART_MENU_ITEM_CHECK_MARK
1468cdf0e10cSrcweir 															 : PART_MENU_ITEM_RADIO_MARK ) )
1469cdf0e10cSrcweir 						{
1470cdf0e10cSrcweir 							ControlPart nPart = ((pEntry->mnBits & MIB_RADIOCHECK)
1471cdf0e10cSrcweir 												 ? PART_MENU_ITEM_RADIO_MARK
1472cdf0e10cSrcweir 												 : PART_MENU_ITEM_CHECK_MARK);
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir 							ControlState nState = 0;
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir 							if ( pEntry->mbChecked )
1477cdf0e10cSrcweir 								nState |= CTRL_STATE_PRESSED;
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir 							if ( pEntry->mbEnabled )
1480cdf0e10cSrcweir 								nState |= CTRL_STATE_ENABLED;
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir 							if ( bHighlighted )
1483cdf0e10cSrcweir 								nState |= CTRL_STATE_SELECTED;
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir 							long nCtrlHeight = (pEntry->mnBits & MIB_RADIOCHECK) ? nCheckHeight : nRadioHeight;
1486cdf0e10cSrcweir 							aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - nCtrlHeight)/2;
1487cdf0e10cSrcweir 							aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - nCtrlHeight)/2;
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir 							Rectangle aCheckRect( aTmpPos, Size( nCtrlHeight, nCtrlHeight ) );
1490cdf0e10cSrcweir 							DrawNativeControl( CTRL_MENU_POPUP, nPart, aCheckRect, nState, ImplControlValue(), OUString() );
1491cdf0e10cSrcweir 						}
1492cdf0e10cSrcweir 						else if ( pEntry->mbChecked ) // by default do nothing for unchecked items
1493cdf0e10cSrcweir 						{
1494cdf0e10cSrcweir 							ImplPaintCheckBackground( this, aOuterCheckRect, pThisOnly && bHighlighted );
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 							SymbolType eSymbol;
1497cdf0e10cSrcweir 							Size aSymbolSize;
1498cdf0e10cSrcweir 							if ( pEntry->mnBits & MIB_RADIOCHECK )
1499cdf0e10cSrcweir 							{
1500cdf0e10cSrcweir 								eSymbol = SYMBOL_RADIOCHECKMARK;
1501cdf0e10cSrcweir 								aSymbolSize = Size( nFontHeight/2, nFontHeight/2 );
1502cdf0e10cSrcweir 							}
1503cdf0e10cSrcweir 							else
1504cdf0e10cSrcweir 							{
1505cdf0e10cSrcweir 								eSymbol = SYMBOL_CHECKMARK;
1506cdf0e10cSrcweir 								aSymbolSize = Size( (nFontHeight*25)/40, nFontHeight/2 );
1507cdf0e10cSrcweir 							}
1508cdf0e10cSrcweir 							aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width())/2;
1509cdf0e10cSrcweir 							aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height())/2;
1510cdf0e10cSrcweir 							Rectangle aRect( aTmpPos, aSymbolSize );
1511cdf0e10cSrcweir 							aDecoView.DrawSymbol( aRect, eSymbol, GetTextColor(), nSymbolStyle );
1512cdf0e10cSrcweir 						}
1513cdf0e10cSrcweir 					}
1514cdf0e10cSrcweir 				}
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir 				// Image:
1517cdf0e10cSrcweir 				if( pEntry->mbHasImage && bUseImages )
1518cdf0e10cSrcweir 				{
1519cdf0e10cSrcweir 					// Don't render an image for a check thing
1520cdf0e10cSrcweir 					 /* if((nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) || !pEntry->HasCheck() )*/
1521cdf0e10cSrcweir 					{
1522cdf0e10cSrcweir 						if( pEntry->mbChecked )
1523cdf0e10cSrcweir 							ImplPaintCheckBackground( this, aOuterCheckRect, pThisOnly && bHighlighted );
1524cdf0e10cSrcweir 						aTmpPos = aOuterCheckRect.TopLeft();
1525cdf0e10cSrcweir 						aTmpPos.X() += (aOuterCheckRect.GetWidth()-pEntry->maImage.GetSizePixel().Width())/2;
1526cdf0e10cSrcweir 						aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pEntry->maImage.GetSizePixel().Height())/2;
1527cdf0e10cSrcweir 						DrawImage( aTmpPos, pEntry->maImage, nImageStyle );
1528cdf0e10cSrcweir 					}
1529cdf0e10cSrcweir 				}
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir 				// Text:
1532cdf0e10cSrcweir 				if( pEntry->mbHasText )
1533cdf0e10cSrcweir 				{
1534cdf0e10cSrcweir 					aTmpPos.X() = aPos.X() + (bTitle ? 4 : mpImpl->mnTextPos);
1535cdf0e10cSrcweir 					aTmpPos.Y() = aPos.Y();
1536cdf0e10cSrcweir 					aTmpPos.Y() += nTextOffsetY;
1537cdf0e10cSrcweir 					sal_uInt16 nStyle = nTextStyle|TEXT_DRAW_MNEMONIC;
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir 					DrawCtrlText( aTmpPos, pEntry->maText, 0, pEntry->maText.Len(), nStyle, NULL, NULL ); // pVector, pDisplayText );
1540cdf0e10cSrcweir 				}
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir /*
1543cdf0e10cSrcweir 				// Accel
1544cdf0e10cSrcweir 				if ( !bLayout && !bIsMenuBar && pData->aAccelKey.GetCode() && !ImplAccelDisabled() )
1545cdf0e10cSrcweir 				{
1546cdf0e10cSrcweir 					XubString aAccText = pData->aAccelKey.GetName();
1547cdf0e10cSrcweir 					aTmpPos.X() = aOutSz.Width() - this->GetTextWidth( aAccText );
1548cdf0e10cSrcweir 					aTmpPos.X() -= 4*nExtra;
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir 					aTmpPos.X() -= nOuterSpace;
1551cdf0e10cSrcweir 					aTmpPos.Y() = aPos.Y();
1552cdf0e10cSrcweir 					aTmpPos.Y() += nTextOffsetY;
1553cdf0e10cSrcweir 					this->DrawCtrlText( aTmpPos, aAccText, 0, aAccText.Len(), nTextStyle );
1554cdf0e10cSrcweir 				}
1555cdf0e10cSrcweir */
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir /*
1558cdf0e10cSrcweir 				// SubMenu?
1559cdf0e10cSrcweir 				if ( !bLayout && !bIsMenuBar && pData->pSubMenu )
1560cdf0e10cSrcweir 				{
1561cdf0e10cSrcweir 					aTmpPos.X() = aOutSz.Width() - nFontHeight + nExtra - nOuterSpace;
1562cdf0e10cSrcweir 					aTmpPos.Y() = aPos.Y();
1563cdf0e10cSrcweir 					aTmpPos.Y() += nExtra/2;
1564cdf0e10cSrcweir 					aTmpPos.Y() += ( pEntry->maSize.Height() / 2 ) - ( nFontHeight/4 );
1565cdf0e10cSrcweir 					if ( pEntry->mnBits & MIB_POPUPSELECT )
1566cdf0e10cSrcweir 					{
1567cdf0e10cSrcweir 						this->SetTextColor( rSettings.GetMenuTextColor() );
1568cdf0e10cSrcweir 						Point aTmpPos2( aPos );
1569cdf0e10cSrcweir 						aTmpPos2.X() = aOutSz.Width() - nFontHeight - nFontHeight/4;
1570cdf0e10cSrcweir 						aDecoView.DrawFrame(
1571cdf0e10cSrcweir 							Rectangle( aTmpPos2, Size( nFontHeight+nFontHeight/4, pEntry->maSize.Height() ) ), FRAME_DRAW_GROUP );
1572cdf0e10cSrcweir 					}
1573cdf0e10cSrcweir 					aDecoView.DrawSymbol(
1574cdf0e10cSrcweir 						Rectangle( aTmpPos, Size( nFontHeight/2, nFontHeight/2 ) ),
1575cdf0e10cSrcweir 						SYMBOL_SPIN_RIGHT, this->GetTextColor(), nSymbolStyle );
1576cdf0e10cSrcweir //                  if ( pEntry->mnBits & MIB_POPUPSELECT )
1577cdf0e10cSrcweir //                  {
1578cdf0e10cSrcweir //                      aTmpPos.Y() += nFontHeight/2 ;
1579cdf0e10cSrcweir //                      this->SetLineColor( rSettings.GetShadowColor() );
1580cdf0e10cSrcweir //                      this->DrawLine( aTmpPos, Point( aTmpPos.X() + nFontHeight/3, aTmpPos.Y() ) );
1581cdf0e10cSrcweir //                      this->SetLineColor( rSettings.GetLightColor() );
1582cdf0e10cSrcweir //                      aTmpPos.Y()++;
1583cdf0e10cSrcweir //                      this->DrawLine( aTmpPos, Point( aTmpPos.X() + nFontHeight/3, aTmpPos.Y() ) );
1584cdf0e10cSrcweir //                      this->SetLineColor();
1585cdf0e10cSrcweir //                  }
1586cdf0e10cSrcweir 				}
1587cdf0e10cSrcweir */
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir 				if ( pThisOnly && bHighlighted )
1590cdf0e10cSrcweir 				{
1591cdf0e10cSrcweir 					// This restores the normal menu or menu bar text
1592cdf0e10cSrcweir 					// color for when it is no longer highlighted.
1593cdf0e10cSrcweir 					SetTextColor( rSettings.GetMenuTextColor() );
1594cdf0e10cSrcweir 				 }
1595cdf0e10cSrcweir 			}
1596cdf0e10cSrcweir         }
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir 		aTopLeft.Y() += pEntry ? pEntry->maSize.Height() : SEPARATOR_HEIGHT;
1599cdf0e10cSrcweir     }
1600cdf0e10cSrcweir }
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir // --------------------------------------------------------------------
1603cdf0e10cSrcweir 
Paint(const Rectangle &)1604cdf0e10cSrcweir void ToolbarMenu::Paint( const Rectangle& )
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir     SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir 	implPaint();
1609cdf0e10cSrcweir 
1610cdf0e10cSrcweir     if( mpImpl->mnHighlightedEntry != -1 )
1611cdf0e10cSrcweir         implHighlightEntry( mpImpl->mnHighlightedEntry, true );
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir // --------------------------------------------------------------------
1615cdf0e10cSrcweir 
RequestHelp(const HelpEvent & rHEvt)1616cdf0e10cSrcweir void ToolbarMenu::RequestHelp( const HelpEvent& rHEvt )
1617cdf0e10cSrcweir {
1618cdf0e10cSrcweir 	DockingWindow::RequestHelp( rHEvt );
1619cdf0e10cSrcweir }
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir // --------------------------------------------------------------------
1622cdf0e10cSrcweir 
StateChanged(StateChangedType nType)1623cdf0e10cSrcweir void ToolbarMenu::StateChanged( StateChangedType nType )
1624cdf0e10cSrcweir {
1625cdf0e10cSrcweir     DockingWindow::StateChanged( nType );
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir     if ( ( nType == STATE_CHANGE_CONTROLFOREGROUND ) || ( nType == STATE_CHANGE_CONTROLBACKGROUND ) )
1628cdf0e10cSrcweir     {
1629cdf0e10cSrcweir 		initWindow();
1630cdf0e10cSrcweir         Invalidate();
1631cdf0e10cSrcweir     }
1632cdf0e10cSrcweir }
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir // --------------------------------------------------------------------
1635cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)1636cdf0e10cSrcweir void ToolbarMenu::DataChanged( const DataChangedEvent& rDCEvt )
1637cdf0e10cSrcweir {
1638cdf0e10cSrcweir     DockingWindow::DataChanged( rDCEvt );
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
1641cdf0e10cSrcweir          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
1642cdf0e10cSrcweir          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1643cdf0e10cSrcweir           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
1644cdf0e10cSrcweir     {
1645cdf0e10cSrcweir         initWindow();
1646cdf0e10cSrcweir         Invalidate();
1647cdf0e10cSrcweir     }
1648cdf0e10cSrcweir }
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir // --------------------------------------------------------------------
1651cdf0e10cSrcweir 
Command(const CommandEvent & rCEvt)1652cdf0e10cSrcweir void ToolbarMenu::Command( const CommandEvent& rCEvt )
1653cdf0e10cSrcweir {
1654cdf0e10cSrcweir     if ( rCEvt.GetCommand() == COMMAND_WHEEL )
1655cdf0e10cSrcweir     {
1656cdf0e10cSrcweir         const CommandWheelData* pData = rCEvt.GetWheelData();
1657cdf0e10cSrcweir         if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) )
1658cdf0e10cSrcweir         {
1659cdf0e10cSrcweir 			implCursorUpDown( pData->GetDelta() > 0L, false );
1660cdf0e10cSrcweir         }
1661cdf0e10cSrcweir     }
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir // --------------------------------------------------------------------
1665cdf0e10cSrcweir 
CreateAccessible()1666cdf0e10cSrcweir Reference< ::com::sun::star::accessibility::XAccessible > ToolbarMenu::CreateAccessible()
1667cdf0e10cSrcweir {
1668cdf0e10cSrcweir 	mpImpl->setAccessible( new ToolbarMenuAcc( *mpImpl ) );
1669cdf0e10cSrcweir 	return Reference< XAccessible >( mpImpl->mxAccessible.get() );
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir // --------------------------------------------------------------------
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir // todo: move to new base class that will replace SfxPopupWindo
AddStatusListener(const rtl::OUString & rCommandURL)1675cdf0e10cSrcweir void ToolbarMenu::AddStatusListener( const rtl::OUString& rCommandURL )
1676cdf0e10cSrcweir {
1677cdf0e10cSrcweir 	initStatusListener();
1678cdf0e10cSrcweir 	mpImpl->mxStatusListener->addStatusListener( rCommandURL );
1679cdf0e10cSrcweir }
1680cdf0e10cSrcweir 
1681cdf0e10cSrcweir // --------------------------------------------------------------------
1682cdf0e10cSrcweir 
RemoveStatusListener(const rtl::OUString & rCommandURL)1683cdf0e10cSrcweir void ToolbarMenu::RemoveStatusListener( const rtl::OUString& rCommandURL )
1684cdf0e10cSrcweir {
1685cdf0e10cSrcweir 	mpImpl->mxStatusListener->removeStatusListener( rCommandURL );
1686cdf0e10cSrcweir }
1687cdf0e10cSrcweir // --------------------------------------------------------------------
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir 
UpdateStatus(const rtl::OUString & rCommandURL)1690cdf0e10cSrcweir void ToolbarMenu::UpdateStatus( const rtl::OUString& rCommandURL )
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir 	mpImpl->mxStatusListener->updateStatus( rCommandURL );
1693cdf0e10cSrcweir }
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir // --------------------------------------------------------------------
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir // XStatusListener (subclasses must override this one to get the status updates
statusChanged(const::com::sun::star::frame::FeatureStateEvent &)1698cdf0e10cSrcweir void SAL_CALL ToolbarMenu::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& /*Event*/ ) throw ( ::com::sun::star::uno::RuntimeException )
1699cdf0e10cSrcweir {
1700cdf0e10cSrcweir }
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir // --------------------------------------------------------------------
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir class ToolbarMenuStatusListener : public svt::FrameStatusListener
1705cdf0e10cSrcweir {
1706cdf0e10cSrcweir public:
1707cdf0e10cSrcweir 	ToolbarMenuStatusListener( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager,
1708cdf0e10cSrcweir 							   const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
1709cdf0e10cSrcweir 							   ToolbarMenu& rToolbarMenu );
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir 	virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
1712cdf0e10cSrcweir 	virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir 	ToolbarMenu* mpMenu;
1715cdf0e10cSrcweir };
1716cdf0e10cSrcweir 
1717cdf0e10cSrcweir // --------------------------------------------------------------------
1718cdf0e10cSrcweir 
ToolbarMenuStatusListener(const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> & xServiceManager,const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & xFrame,ToolbarMenu & rToolbarMenu)1719cdf0e10cSrcweir ToolbarMenuStatusListener::ToolbarMenuStatusListener(
1720cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager,
1721cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
1722cdf0e10cSrcweir 	ToolbarMenu& rToolbarMenu )
1723cdf0e10cSrcweir : svt::FrameStatusListener( xServiceManager, xFrame )
1724cdf0e10cSrcweir , mpMenu( &rToolbarMenu )
1725cdf0e10cSrcweir {
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir // --------------------------------------------------------------------
1729cdf0e10cSrcweir 
dispose()1730cdf0e10cSrcweir void SAL_CALL ToolbarMenuStatusListener::dispose() throw (::com::sun::star::uno::RuntimeException)
1731cdf0e10cSrcweir {
1732cdf0e10cSrcweir 	mpMenu = 0;
1733cdf0e10cSrcweir 	svt::FrameStatusListener::dispose();
1734cdf0e10cSrcweir }
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir // --------------------------------------------------------------------
1737cdf0e10cSrcweir 
statusChanged(const::com::sun::star::frame::FeatureStateEvent & Event)1738cdf0e10cSrcweir void SAL_CALL ToolbarMenuStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
1739cdf0e10cSrcweir {
1740cdf0e10cSrcweir 	if( mpMenu )
1741cdf0e10cSrcweir 		mpMenu->statusChanged( Event );
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir // --------------------------------------------------------------------
1745cdf0e10cSrcweir 
initStatusListener()1746cdf0e10cSrcweir void ToolbarMenu::initStatusListener()
1747cdf0e10cSrcweir {
1748cdf0e10cSrcweir 	if( !mpImpl->mxStatusListener.is() )
1749cdf0e10cSrcweir 		mpImpl->mxStatusListener.set( new ToolbarMenuStatusListener( mpImpl->mxServiceManager, mpImpl->mxFrame, *this ) );
1750cdf0e10cSrcweir }
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir // --------------------------------------------------------------------
1753cdf0e10cSrcweir 
IsInPopupMode()1754cdf0e10cSrcweir bool ToolbarMenu::IsInPopupMode()
1755cdf0e10cSrcweir {
1756cdf0e10cSrcweir 	return GetDockingManager()->IsInPopupMode(this);
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir 
1759cdf0e10cSrcweir // --------------------------------------------------------------------
1760cdf0e10cSrcweir 
EndPopupMode()1761cdf0e10cSrcweir void ToolbarMenu::EndPopupMode()
1762cdf0e10cSrcweir {
1763cdf0e10cSrcweir 	GetDockingManager()->EndPopupMode(this);
1764cdf0e10cSrcweir }
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir // --------------------------------------------------------------------
1767cdf0e10cSrcweir 
getMenuSize() const1768cdf0e10cSrcweir const Size& ToolbarMenu::getMenuSize() const
1769cdf0e10cSrcweir {
1770cdf0e10cSrcweir 	return mpImpl->maSize;
1771cdf0e10cSrcweir }
1772cdf0e10cSrcweir 
1773cdf0e10cSrcweir // --------------------------------------------------------------------
1774cdf0e10cSrcweir 
SetSelectHdl(const Link & rLink)1775cdf0e10cSrcweir void ToolbarMenu::SetSelectHdl( const Link& rLink )
1776cdf0e10cSrcweir {
1777cdf0e10cSrcweir 	mpImpl->maSelectHdl = rLink;
1778cdf0e10cSrcweir }
1779cdf0e10cSrcweir 
1780cdf0e10cSrcweir // --------------------------------------------------------------------
1781cdf0e10cSrcweir 
GetSelectHdl() const1782cdf0e10cSrcweir const Link& ToolbarMenu::GetSelectHdl() const
1783cdf0e10cSrcweir {
1784cdf0e10cSrcweir 	return mpImpl->maSelectHdl;
1785cdf0e10cSrcweir }
1786cdf0e10cSrcweir 
1787cdf0e10cSrcweir // --------------------------------------------------------------------
1788cdf0e10cSrcweir 
GetFrame() const1789cdf0e10cSrcweir Reference< XFrame >	ToolbarMenu::GetFrame() const
1790cdf0e10cSrcweir {
1791cdf0e10cSrcweir 	return mpImpl->mxFrame;
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir // --------------------------------------------------------------------
1795cdf0e10cSrcweir 
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir // --------------------------------------------------------------------
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir }
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir 
1802