1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "navtoolbar.hxx"
22 #include "frm_resource.hxx"
23 #include "featuredispatcher.hxx"
24 #include "frm_resource.hrc"
25 #include "commandimageprovider.hxx"
26 #include "commanddescriptionprovider.hxx"
28 #include <com/sun/star/uno/Any.hxx>
29 #include <com/sun/star/form/runtime/FormFeature.hpp>
31 #include <sfx2/imgmgr.hxx>
32 #include <vcl/fixed.hxx>
35 #include <sal/macros.h>
37 #define LID_RECORD_LABEL 1000
38 #define LID_RECORD_FILLER 1001
40 //.........................................................................
43 //.........................................................................
45 using ::com::sun::star::uno::makeAny
;
46 namespace FormFeature
= ::com::sun::star::form::runtime::FormFeature
;
48 //=====================================================================
49 //.....................................................................
52 static bool isArtificialItem( sal_Int16 _nFeatureId
)
54 return ( _nFeatureId
== LID_RECORD_LABEL
)
55 || ( _nFeatureId
== LID_RECORD_FILLER
);
58 static String
getLabelString( sal_uInt16 _nResId
)
60 String sLabel
= OUString( " " );
61 sLabel
+= String( FRM_RES_STRING( _nResId
) );
62 sLabel
+= OUString( " " );
66 OUString
lcl_getCommandURL( const sal_Int16 _nFormFeature
)
68 const sal_Char
* pAsciiCommandName
= NULL
;
69 switch ( _nFormFeature
)
71 case FormFeature::MoveAbsolute
: pAsciiCommandName
= "AbsoluteRecord"; break;
72 case FormFeature::TotalRecords
: pAsciiCommandName
= "RecTotal"; break;
73 case FormFeature::MoveToFirst
: pAsciiCommandName
= "FirstRecord"; break;
74 case FormFeature::MoveToPrevious
: pAsciiCommandName
= "PrevRecord"; break;
75 case FormFeature::MoveToNext
: pAsciiCommandName
= "NextRecord"; break;
76 case FormFeature::MoveToLast
: pAsciiCommandName
= "LastRecord"; break;
77 case FormFeature::SaveRecordChanges
: pAsciiCommandName
= "RecSave"; break;
78 case FormFeature::UndoRecordChanges
: pAsciiCommandName
= "RecUndo"; break;
79 case FormFeature::MoveToInsertRow
: pAsciiCommandName
= "NewRecord"; break;
80 case FormFeature::DeleteRecord
: pAsciiCommandName
= "DeleteRecord"; break;
81 case FormFeature::ReloadForm
: pAsciiCommandName
= "Refresh"; break;
82 case FormFeature::RefreshCurrentControl
: pAsciiCommandName
= "RefreshFormControl"; break;
83 case FormFeature::SortAscending
: pAsciiCommandName
= "Sortup"; break;
84 case FormFeature::SortDescending
: pAsciiCommandName
= "SortDown"; break;
85 case FormFeature::InteractiveSort
: pAsciiCommandName
= "OrderCrit"; break;
86 case FormFeature::AutoFilter
: pAsciiCommandName
= "AutoFilter"; break;
87 case FormFeature::InteractiveFilter
: pAsciiCommandName
= "FilterCrit"; break;
88 case FormFeature::ToggleApplyFilter
: pAsciiCommandName
= "FormFiltered"; break;
89 case FormFeature::RemoveFilterAndSort
: pAsciiCommandName
= "RemoveFilterSort"; break;
91 if ( pAsciiCommandName
!= NULL
)
92 return OUString( ".uno:" ) + OUString::createFromAscii( pAsciiCommandName
);
94 OSL_FAIL( "lcl_getCommandURL: unknown FormFeature!" );
99 //=====================================================================
101 //=====================================================================
102 class ImplNavToolBar
: public ToolBox
105 const IFeatureDispatcher
* m_pDispatcher
;
108 ImplNavToolBar( Window
* _pParent
)
109 :ToolBox( _pParent
, WB_3DLOOK
)
110 ,m_pDispatcher( NULL
)
114 void setDispatcher( const IFeatureDispatcher
* _pDispatcher
)
116 m_pDispatcher
= _pDispatcher
;
120 // ToolBox overridables
121 virtual void Select();
125 //---------------------------------------------------------------------
126 void ImplNavToolBar::Select()
130 if ( !m_pDispatcher
->isEnabled( GetCurItemId() ) )
131 // the toolbox is a little bit buggy: With TIB_REPEAT, it sometimes
132 // happens that a select is reported, even though the respective
133 // item has just been disabled.
135 m_pDispatcher
->dispatch( GetCurItemId() );
139 //=====================================================================
140 //= NavigationToolBar
141 //=====================================================================
142 DBG_NAME( NavigationToolBar
)
143 //---------------------------------------------------------------------
144 NavigationToolBar::NavigationToolBar( Window
* _pParent
, WinBits _nStyle
, const PCommandImageProvider
& _pImageProvider
,
145 const PCommandDescriptionProvider
& _pDescriptionProvider
)
146 :Window( _pParent
, _nStyle
)
147 ,m_pDispatcher( NULL
)
148 ,m_pImageProvider( _pImageProvider
)
149 ,m_pDescriptionProvider( _pDescriptionProvider
)
150 ,m_eImageSize( eSmall
)
153 DBG_CTOR( NavigationToolBar
, NULL
);
157 //---------------------------------------------------------------------
158 NavigationToolBar::~NavigationToolBar( )
160 for ( ::std::vector
< Window
* >::iterator loopChildWins
= m_aChildWins
.begin();
161 loopChildWins
!= m_aChildWins
.end();
165 delete *loopChildWins
;
168 DBG_DTOR( NavigationToolBar
, NULL
);
171 //---------------------------------------------------------------------
172 void NavigationToolBar::setDispatcher( const IFeatureDispatcher
* _pDispatcher
)
174 m_pDispatcher
= _pDispatcher
;
176 m_pToolbar
->setDispatcher( _pDispatcher
);
178 RecordPositionInput
* pPositionWindow
= static_cast< RecordPositionInput
* >( m_pToolbar
->GetItemWindow( FormFeature::MoveAbsolute
) );
179 OSL_ENSURE( pPositionWindow
, "NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" );
180 if ( pPositionWindow
)
181 pPositionWindow
->setDispatcher( _pDispatcher
);
183 updateFeatureStates( );
186 //---------------------------------------------------------------------
187 void NavigationToolBar::updateFeatureStates( )
189 for ( sal_uInt16 nPos
= 0; nPos
< m_pToolbar
->GetItemCount(); ++nPos
)
191 sal_uInt16 nItemId
= m_pToolbar
->GetItemId( nPos
);
193 if ( ( nItemId
== LID_RECORD_LABEL
) || ( nItemId
== LID_RECORD_FILLER
) )
196 // is this item enabled?
197 bool bEnabled
= m_pDispatcher
? m_pDispatcher
->isEnabled( nItemId
) : false;
198 implEnableItem( nItemId
, bEnabled
);
202 //---------------------------------------------------------------------
203 void NavigationToolBar::implEnableItem( sal_uInt16 _nItemId
, bool _bEnabled
)
205 m_pToolbar
->EnableItem( _nItemId
, _bEnabled
);
207 if ( _nItemId
== FormFeature::MoveAbsolute
)
208 m_pToolbar
->EnableItem( LID_RECORD_LABEL
, _bEnabled
);
210 if ( _nItemId
== FormFeature::TotalRecords
)
211 m_pToolbar
->EnableItem( LID_RECORD_FILLER
, _bEnabled
);
214 //---------------------------------------------------------------------
215 void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId
, bool _bEnabled
)
217 DBG_ASSERT( m_pToolbar
->GetItemPos( (sal_uInt16
)_nFeatureId
) != TOOLBOX_ITEM_NOTFOUND
,
218 "NavigationToolBar::enableFeature: invalid id!" );
220 implEnableItem( (sal_uInt16
)_nFeatureId
, _bEnabled
);
223 //---------------------------------------------------------------------
224 void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId
, bool _bEnabled
)
226 DBG_ASSERT( m_pToolbar
->GetItemPos( (sal_uInt16
)_nFeatureId
) != TOOLBOX_ITEM_NOTFOUND
,
227 "NavigationToolBar::checkFeature: invalid id!" );
229 m_pToolbar
->CheckItem( (sal_uInt16
)_nFeatureId
, _bEnabled
);
232 //---------------------------------------------------------------------
233 void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId
, const OUString
& _rText
)
235 DBG_ASSERT( m_pToolbar
->GetItemPos( (sal_uInt16
)_nFeatureId
) != TOOLBOX_ITEM_NOTFOUND
,
236 "NavigationToolBar::checkFeature: invalid id!" );
238 Window
* pItemWindow
= m_pToolbar
->GetItemWindow( (sal_uInt16
)_nFeatureId
);
240 pItemWindow
->SetText( _rText
);
242 m_pToolbar
->SetItemText( (sal_uInt16
)_nFeatureId
, _rText
);
245 //---------------------------------------------------------------------
246 void NavigationToolBar::implInit( )
248 m_pToolbar
= new ImplNavToolBar( this );
249 m_pToolbar
->SetOutStyle( TOOLBOX_STYLE_FLAT
);
252 // need the SfxApplication for retrieving information about our
253 // items. We could duplicate all the information here in our lib
254 // (such as the item text and the image), but why should we?
256 struct FeatureDescription
261 } aSupportedFeatures
[] =
263 { LID_RECORD_LABEL
, false, true },
264 { FormFeature::MoveAbsolute
, false, true },
265 { LID_RECORD_FILLER
, false, true },
266 { FormFeature::TotalRecords
, false, true },
267 { FormFeature::MoveToFirst
, true, false },
268 { FormFeature::MoveToPrevious
, true, false },
269 { FormFeature::MoveToNext
, true, false },
270 { FormFeature::MoveToLast
, true, false },
271 { FormFeature::MoveToInsertRow
, false, false },
273 { FormFeature::SaveRecordChanges
, false, false },
274 { FormFeature::UndoRecordChanges
, false, false },
275 { FormFeature::DeleteRecord
, false, false },
276 { FormFeature::ReloadForm
, false, false },
277 { FormFeature::RefreshCurrentControl
, false, false },
279 { FormFeature::SortAscending
, false, false },
280 { FormFeature::SortDescending
, false, false },
281 { FormFeature::InteractiveSort
, false, false },
282 { FormFeature::AutoFilter
, false, false },
283 { FormFeature::InteractiveFilter
, false, false },
284 { FormFeature::ToggleApplyFilter
, false, false },
285 { FormFeature::RemoveFilterAndSort
, false, false },
288 size_t nSupportedFeatures
= SAL_N_ELEMENTS( aSupportedFeatures
);
289 FeatureDescription
* pSupportedFeatures
= aSupportedFeatures
;
290 FeatureDescription
* pSupportedFeaturesEnd
= aSupportedFeatures
+ nSupportedFeatures
;
291 for ( ; pSupportedFeatures
< pSupportedFeaturesEnd
; ++pSupportedFeatures
)
293 if ( pSupportedFeatures
->nId
)
294 { // it's _not_ a separator
297 m_pToolbar
->InsertItem( pSupportedFeatures
->nId
, String(), pSupportedFeatures
->bRepeat
? TIB_REPEAT
: 0 );
298 m_pToolbar
->SetQuickHelpText( pSupportedFeatures
->nId
, String() ); // TODO
300 if ( !isArtificialItem( pSupportedFeatures
->nId
) )
302 OUString
sCommandURL( lcl_getCommandURL( pSupportedFeatures
->nId
) );
303 m_pToolbar
->SetItemCommand( pSupportedFeatures
->nId
, sCommandURL
);
304 if ( m_pDescriptionProvider
)
305 m_pToolbar
->SetQuickHelpText( pSupportedFeatures
->nId
, m_pDescriptionProvider
->getCommandDescription( sCommandURL
) );
308 if ( pSupportedFeatures
->bItemWindow
)
310 Window
* pItemWindow
= NULL
;
311 if ( FormFeature::MoveAbsolute
== pSupportedFeatures
->nId
)
313 pItemWindow
= new RecordPositionInput( m_pToolbar
);
314 static_cast< RecordPositionInput
* >( pItemWindow
)->setDispatcher( m_pDispatcher
);
316 else if ( LID_RECORD_FILLER
== pSupportedFeatures
->nId
)
318 pItemWindow
= new FixedText( m_pToolbar
, WB_CENTER
| WB_VCENTER
);
319 pItemWindow
->SetBackground(Wallpaper(Color(COL_TRANSPARENT
)));
323 pItemWindow
= new FixedText( m_pToolbar
, WB_VCENTER
);
324 pItemWindow
->SetBackground();
325 pItemWindow
->SetPaintTransparent(sal_True
);
327 m_aChildWins
.push_back( pItemWindow
);
329 switch ( pSupportedFeatures
->nId
)
331 case LID_RECORD_LABEL
:
332 pItemWindow
->SetText( getLabelString( RID_STR_LABEL_RECORD
) );
335 case LID_RECORD_FILLER
:
336 pItemWindow
->SetText( getLabelString( RID_STR_LABEL_OF
) );
340 m_pToolbar
->SetItemWindow( pSupportedFeatures
->nId
, pItemWindow
);
345 m_pToolbar
->InsertSeparator( );
349 forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth
, NULL
);
354 //---------------------------------------------------------------------
355 void NavigationToolBar::implUpdateImages()
357 OSL_ENSURE( m_pImageProvider
, "NavigationToolBar::implUpdateImages: no image provider => no images!" );
358 if ( !m_pImageProvider
)
361 const sal_uInt16 nItemCount
= m_pToolbar
->GetItemCount();
363 // collect the FormFeatures in the toolbar
364 typedef ::std::vector
< sal_Int16
> FormFeatures
;
365 FormFeatures aFormFeatures
;
366 aFormFeatures
.reserve( nItemCount
);
368 for ( sal_uInt16 i
=0; i
<nItemCount
; ++i
)
370 sal_uInt16 nId
= m_pToolbar
->GetItemId( i
);
371 if ( ( TOOLBOXITEM_BUTTON
== m_pToolbar
->GetItemType( i
) ) && !isArtificialItem( nId
) )
372 aFormFeatures
.push_back( nId
);
375 // translate them into command URLs
376 CommandURLs
aCommandURLs( aFormFeatures
.size() );
377 for ( FormFeatures::const_iterator formFeature
= aFormFeatures
.begin();
378 formFeature
!= aFormFeatures
.end();
382 aCommandURLs
[ formFeature
- aFormFeatures
.begin() ] = lcl_getCommandURL( *formFeature
);
385 // retrieve the images for the command URLs
386 CommandImages aCommandImages
= m_pImageProvider
->getCommandImages( aCommandURLs
, m_eImageSize
== eLarge
);
388 // and set them at the toolbar
389 CommandImages::const_iterator commandImage
= aCommandImages
.begin();
390 for ( FormFeatures::const_iterator formFeature
= aFormFeatures
.begin();
391 formFeature
!= aFormFeatures
.end();
392 ++formFeature
, ++commandImage
395 m_pToolbar
->SetItemImage( *formFeature
, *commandImage
);
398 // parts of our layout is dependent on the size of our icons
402 //---------------------------------------------------------------------
403 void NavigationToolBar::implSetImageSize( ImageSize _eSize
)
405 if ( _eSize
!= m_eImageSize
)
407 m_eImageSize
= _eSize
;
412 //---------------------------------------------------------------------
413 void NavigationToolBar::SetImageSize( ImageSize _eSize
)
415 implSetImageSize( _eSize
);
418 //---------------------------------------------------------------------
419 void NavigationToolBar::ShowFunctionGroup( FunctionGroup _eGroup
, bool _bShow
)
421 const sal_uInt16
* pGroupIds
= NULL
;
427 static const sal_uInt16 aPositionIds
[] = {
428 LID_RECORD_LABEL
, FormFeature::MoveAbsolute
, LID_RECORD_FILLER
, FormFeature::TotalRecords
, 0
430 pGroupIds
= aPositionIds
;
435 static const sal_uInt16 aNavigationIds
[] = {
436 FormFeature::MoveToFirst
, FormFeature::MoveToPrevious
, FormFeature::MoveToNext
, FormFeature::MoveToLast
, FormFeature::MoveToInsertRow
, 0
438 pGroupIds
= aNavigationIds
;
443 static const sal_uInt16 aActionIds
[] = {
444 FormFeature::SaveRecordChanges
, FormFeature::UndoRecordChanges
, FormFeature::DeleteRecord
, FormFeature::ReloadForm
, FormFeature::RefreshCurrentControl
, 0
446 pGroupIds
= aActionIds
;
451 static const sal_uInt16 aFilterSortIds
[] = {
452 FormFeature::SortAscending
, FormFeature::SortDescending
, FormFeature::InteractiveSort
, FormFeature::AutoFilter
, FormFeature::InteractiveFilter
, FormFeature::ToggleApplyFilter
, FormFeature::RemoveFilterAndSort
, 0
454 pGroupIds
= aFilterSortIds
;
458 OSL_FAIL( "NavigationToolBar::ShowFunctionGroup: invalid group id!" );
463 m_pToolbar
->ShowItem( *pGroupIds
++, _bShow
);
466 //---------------------------------------------------------------------
467 bool NavigationToolBar::IsFunctionGroupVisible( FunctionGroup _eGroup
)
469 sal_uInt16 nIndicatorItem
= 0;
472 case ePosition
: nIndicatorItem
= LID_RECORD_LABEL
; break;
473 case eNavigation
: nIndicatorItem
= FormFeature::MoveToFirst
; break;
474 case eRecordActions
: nIndicatorItem
= FormFeature::SaveRecordChanges
; break;
475 case eFilterSort
: nIndicatorItem
= FormFeature::SortAscending
; break;
477 OSL_FAIL( "NavigationToolBar::IsFunctionGroupVisible: invalid group id!" );
480 return m_pToolbar
->IsItemVisible( nIndicatorItem
);
483 //------------------------------------------------------------------------------
484 void NavigationToolBar::StateChanged( StateChangedType nType
)
486 Window::StateChanged( nType
);
490 case STATE_CHANGE_ZOOM
:
491 // m_pToolbar->SetZoom( GetZoom() );
492 // forEachItemWindow( setItemWindowZoom, NULL );
493 // the ToolBox class is not zoomable at the moment, so
494 // we better have no zoom at all instead of only half a zoom ...
497 case STATE_CHANGE_CONTROLFONT
:
498 forEachItemWindow( &NavigationToolBar::setItemControlFont
, NULL
);
499 forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth
, NULL
);
502 case STATE_CHANGE_CONTROLFOREGROUND
:
503 forEachItemWindow( &NavigationToolBar::setItemControlForeground
, NULL
);
506 case STATE_CHANGE_MIRRORING
:
508 sal_Bool
bIsRTLEnabled( IsRTLEnabled() );
509 m_pToolbar
->EnableRTL( bIsRTLEnabled
);
510 forEachItemWindow( &NavigationToolBar::enableItemRTL
, &bIsRTLEnabled
);
517 //---------------------------------------------------------------------
518 void NavigationToolBar::Resize()
520 // resize/position the toolbox as a whole
521 sal_Int32 nToolbarHeight
= m_pToolbar
->CalcWindowSizePixel().Height();
523 sal_Int32 nMyHeight
= GetOutputSizePixel().Height();
524 m_pToolbar
->SetPosSizePixel( Point( 0, ( nMyHeight
- nToolbarHeight
) / 2 ),
525 Size( GetSizePixel().Width(), nToolbarHeight
) );
530 //---------------------------------------------------------------------
531 void NavigationToolBar::SetControlBackground()
533 Window::SetControlBackground();
534 m_pToolbar
->SetControlBackground();
535 forEachItemWindow( &NavigationToolBar::setItemBackground
, NULL
);
540 //---------------------------------------------------------------------
541 void NavigationToolBar::SetControlBackground( const Color
& _rColor
)
543 Window::SetControlBackground( _rColor
);
544 m_pToolbar
->SetControlBackground( _rColor
);
545 forEachItemWindow( &NavigationToolBar::setItemBackground
, &_rColor
);
550 //---------------------------------------------------------------------
551 void NavigationToolBar::SetTextLineColor( )
553 Window::SetTextLineColor( );
554 m_pToolbar
->SetTextLineColor( );
555 forEachItemWindow( &NavigationToolBar::setTextLineColor
, NULL
);
558 //---------------------------------------------------------------------
559 void NavigationToolBar::SetTextLineColor( const Color
& _rColor
)
561 Window::SetTextLineColor( _rColor
);
562 m_pToolbar
->SetTextLineColor( _rColor
);
563 forEachItemWindow( &NavigationToolBar::setTextLineColor
, &_rColor
);
566 //---------------------------------------------------------------------
567 void NavigationToolBar::forEachItemWindow( ItemWindowHandler _handler
, const void* _pParam
)
569 for ( sal_uInt16 item
= 0; item
< m_pToolbar
->GetItemCount(); ++item
)
571 sal_uInt16 nItemId
= m_pToolbar
->GetItemId( item
);
572 Window
* pItemWindow
= m_pToolbar
->GetItemWindow( nItemId
);
574 (this->*_handler
)( nItemId
, pItemWindow
, _pParam
);
578 //---------------------------------------------------------------------
579 void NavigationToolBar::setItemBackground( sal_uInt16
/* _nItemId */, Window
* _pItemWindow
, const void* _pColor
) const
582 _pItemWindow
->SetControlBackground( *static_cast< const Color
* >( _pColor
) );
584 _pItemWindow
->SetControlBackground();
587 //---------------------------------------------------------------------
588 void NavigationToolBar::setTextLineColor( sal_uInt16
/* _nItemId */, Window
* _pItemWindow
, const void* _pColor
) const
591 _pItemWindow
->SetTextLineColor( *static_cast< const Color
* >( _pColor
) );
593 _pItemWindow
->SetTextLineColor();
596 //---------------------------------------------------------------------
597 void NavigationToolBar::setItemWindowZoom( sal_uInt16
/* _nItemId */, Window
* _pItemWindow
, const void* /* _pParam */ ) const
599 _pItemWindow
->SetZoom( GetZoom() );
600 _pItemWindow
->SetZoomedPointFont( IsControlFont() ? GetControlFont() : GetPointFont() );
603 //---------------------------------------------------------------------
604 void NavigationToolBar::setItemControlFont( sal_uInt16
/* _nItemId */, Window
* _pItemWindow
, const void* /* _pParam */ ) const
606 if ( IsControlFont() )
607 _pItemWindow
->SetControlFont( GetControlFont() );
609 _pItemWindow
->SetControlFont( );
612 //---------------------------------------------------------------------
613 void NavigationToolBar::setItemControlForeground( sal_uInt16
/* _nItemId */, Window
* _pItemWindow
, const void* /* _pParam */ ) const
615 if ( IsControlForeground() )
616 _pItemWindow
->SetControlForeground( GetControlForeground() );
618 _pItemWindow
->SetControlForeground( );
619 _pItemWindow
->SetTextColor( GetTextColor() );
622 //---------------------------------------------------------------------
623 void NavigationToolBar::adjustItemWindowWidth( sal_uInt16 _nItemId
, Window
* _pItemWindow
, const void* /* _pParam */ ) const
628 case LID_RECORD_LABEL
:
629 sItemText
= getLabelString( RID_STR_LABEL_RECORD
);
632 case LID_RECORD_FILLER
:
633 sItemText
= getLabelString( RID_STR_LABEL_OF
);
636 case FormFeature::MoveAbsolute
:
637 sItemText
= OUString( "12345678" );
640 case FormFeature::TotalRecords
:
641 sItemText
= OUString( "123456" );
645 Size
aSize( _pItemWindow
->GetTextWidth( sItemText
), /* _pItemWindow->GetSizePixel( ).Height() */ _pItemWindow
->GetTextHeight() + 4 );
647 _pItemWindow
->SetSizePixel( aSize
);
649 m_pToolbar
->SetItemWindow( _nItemId
, _pItemWindow
);
652 //---------------------------------------------------------------------
653 void NavigationToolBar::enableItemRTL( sal_uInt16
/*_nItemId*/, Window
* _pItemWindow
, const void* _pIsRTLEnabled
) const
655 _pItemWindow
->EnableRTL( *static_cast< const sal_Bool
* >( _pIsRTLEnabled
) );
658 //=====================================================================
659 //= RecordPositionInput
660 //=====================================================================
661 //---------------------------------------------------------------------
662 RecordPositionInput::RecordPositionInput( Window
* _pParent
)
663 :NumericField( _pParent
, WB_BORDER
| WB_VCENTER
)
664 ,m_pDispatcher( NULL
)
669 SetDecimalDigits( 0 );
670 SetStrictFormat( sal_True
);
671 SetBorderStyle( WINDOW_BORDER_MONO
);
674 //---------------------------------------------------------------------
675 RecordPositionInput::~RecordPositionInput()
679 //---------------------------------------------------------------------
680 void RecordPositionInput::setDispatcher( const IFeatureDispatcher
* _pDispatcher
)
682 m_pDispatcher
= _pDispatcher
;
685 //---------------------------------------------------------------------
686 void RecordPositionInput::FirePosition( sal_Bool _bForce
)
688 if ( _bForce
|| (GetText() != GetSavedValue()) )
690 sal_Int64 nRecord
= GetValue();
691 if ( nRecord
< GetMin() || nRecord
> GetMax() )
695 m_pDispatcher
->dispatchWithArgument( FormFeature::MoveAbsolute
, "Position", makeAny( (sal_Int32
)nRecord
) );
701 //---------------------------------------------------------------------
702 void RecordPositionInput::LoseFocus()
704 FirePosition( sal_False
);
707 //---------------------------------------------------------------------
708 void RecordPositionInput::KeyInput( const KeyEvent
& rKeyEvent
)
710 if( rKeyEvent
.GetKeyCode() == KEY_RETURN
&& !GetText().isEmpty() )
711 FirePosition( sal_True
);
713 NumericField::KeyInput( rKeyEvent
);
717 //.........................................................................
719 //.........................................................................
721 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */