update credits
[LibreOffice.git] / forms / source / solar / control / navtoolbar.cxx
blob4820154e596875555860b716570179944c96a0b2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
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>
34 #include <memory>
35 #include <sal/macros.h>
37 #define LID_RECORD_LABEL 1000
38 #define LID_RECORD_FILLER 1001
40 //.........................................................................
41 namespace frm
43 //.........................................................................
45 using ::com::sun::star::uno::makeAny;
46 namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
48 //=====================================================================
49 //.....................................................................
50 namespace
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( " " );
63 return sLabel;
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!" );
95 return OUString();
99 //=====================================================================
100 //= ImplNavToolBar
101 //=====================================================================
102 class ImplNavToolBar : public ToolBox
104 protected:
105 const IFeatureDispatcher* m_pDispatcher;
107 public:
108 ImplNavToolBar( Window* _pParent )
109 :ToolBox( _pParent, WB_3DLOOK )
110 ,m_pDispatcher( NULL )
114 void setDispatcher( const IFeatureDispatcher* _pDispatcher )
116 m_pDispatcher = _pDispatcher;
119 protected:
120 // ToolBox overridables
121 virtual void Select();
125 //---------------------------------------------------------------------
126 void ImplNavToolBar::Select()
128 if ( m_pDispatcher )
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.
134 return;
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 )
151 ,m_pToolbar( NULL )
153 DBG_CTOR( NavigationToolBar, NULL );
154 implInit( );
157 //---------------------------------------------------------------------
158 NavigationToolBar::~NavigationToolBar( )
160 for ( ::std::vector< Window* >::iterator loopChildWins = m_aChildWins.begin();
161 loopChildWins != m_aChildWins.end();
162 ++loopChildWins
165 delete *loopChildWins;
167 delete m_pToolbar;
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 ) )
194 continue;
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 );
239 if ( pItemWindow )
240 pItemWindow->SetText( _rText );
241 else
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 );
250 m_pToolbar->Show();
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
258 sal_uInt16 nId;
259 bool bRepeat;
260 bool bItemWindow;
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 },
272 { 0, 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 },
278 { 0, 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
296 // insert the entry
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)));
321 else
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 ) );
333 break;
335 case LID_RECORD_FILLER:
336 pItemWindow->SetText( getLabelString( RID_STR_LABEL_OF ) );
337 break;
340 m_pToolbar->SetItemWindow( pSupportedFeatures->nId, pItemWindow );
343 else
344 { // a separator
345 m_pToolbar->InsertSeparator( );
349 forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
351 implUpdateImages();
354 //---------------------------------------------------------------------
355 void NavigationToolBar::implUpdateImages()
357 OSL_ENSURE( m_pImageProvider, "NavigationToolBar::implUpdateImages: no image provider => no images!" );
358 if ( !m_pImageProvider )
359 return;
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();
379 ++formFeature
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
399 Resize();
402 //---------------------------------------------------------------------
403 void NavigationToolBar::implSetImageSize( ImageSize _eSize )
405 if ( _eSize != m_eImageSize )
407 m_eImageSize = _eSize;
408 implUpdateImages();
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;
423 switch ( _eGroup )
425 case ePosition:
427 static const sal_uInt16 aPositionIds[] = {
428 LID_RECORD_LABEL, FormFeature::MoveAbsolute, LID_RECORD_FILLER, FormFeature::TotalRecords, 0
430 pGroupIds = aPositionIds;
432 break;
433 case eNavigation:
435 static const sal_uInt16 aNavigationIds[] = {
436 FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0
438 pGroupIds = aNavigationIds;
440 break;
441 case eRecordActions:
443 static const sal_uInt16 aActionIds[] = {
444 FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0
446 pGroupIds = aActionIds;
448 break;
449 case eFilterSort:
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;
456 break;
457 default:
458 OSL_FAIL( "NavigationToolBar::ShowFunctionGroup: invalid group id!" );
461 if ( pGroupIds )
462 while ( *pGroupIds )
463 m_pToolbar->ShowItem( *pGroupIds++, _bShow );
466 //---------------------------------------------------------------------
467 bool NavigationToolBar::IsFunctionGroupVisible( FunctionGroup _eGroup )
469 sal_uInt16 nIndicatorItem = 0;
470 switch ( _eGroup )
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;
476 default:
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 );
488 switch ( 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 ...
495 break;
497 case STATE_CHANGE_CONTROLFONT:
498 forEachItemWindow( &NavigationToolBar::setItemControlFont, NULL );
499 forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
500 break;
502 case STATE_CHANGE_CONTROLFOREGROUND:
503 forEachItemWindow( &NavigationToolBar::setItemControlForeground, NULL );
504 break;
506 case STATE_CHANGE_MIRRORING:
508 sal_Bool bIsRTLEnabled( IsRTLEnabled() );
509 m_pToolbar->EnableRTL( bIsRTLEnabled );
510 forEachItemWindow( &NavigationToolBar::enableItemRTL, &bIsRTLEnabled );
511 Resize();
513 break;
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 ) );
527 Window::Resize();
530 //---------------------------------------------------------------------
531 void NavigationToolBar::SetControlBackground()
533 Window::SetControlBackground();
534 m_pToolbar->SetControlBackground();
535 forEachItemWindow( &NavigationToolBar::setItemBackground, NULL );
537 implUpdateImages();
540 //---------------------------------------------------------------------
541 void NavigationToolBar::SetControlBackground( const Color& _rColor )
543 Window::SetControlBackground( _rColor );
544 m_pToolbar->SetControlBackground( _rColor );
545 forEachItemWindow( &NavigationToolBar::setItemBackground, &_rColor );
547 implUpdateImages();
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 );
573 if ( pItemWindow )
574 (this->*_handler)( nItemId, pItemWindow, _pParam );
578 //---------------------------------------------------------------------
579 void NavigationToolBar::setItemBackground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
581 if ( _pColor )
582 _pItemWindow->SetControlBackground( *static_cast< const Color* >( _pColor ) );
583 else
584 _pItemWindow->SetControlBackground();
587 //---------------------------------------------------------------------
588 void NavigationToolBar::setTextLineColor( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
590 if ( _pColor )
591 _pItemWindow->SetTextLineColor( *static_cast< const Color* >( _pColor ) );
592 else
593 _pItemWindow->SetTextLineColor();
595 #if 0
596 //---------------------------------------------------------------------
597 void NavigationToolBar::setItemWindowZoom( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
599 _pItemWindow->SetZoom( GetZoom() );
600 _pItemWindow->SetZoomedPointFont( IsControlFont() ? GetControlFont() : GetPointFont() );
602 #endif
603 //---------------------------------------------------------------------
604 void NavigationToolBar::setItemControlFont( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
606 if ( IsControlFont() )
607 _pItemWindow->SetControlFont( GetControlFont() );
608 else
609 _pItemWindow->SetControlFont( );
612 //---------------------------------------------------------------------
613 void NavigationToolBar::setItemControlForeground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
615 if ( IsControlForeground() )
616 _pItemWindow->SetControlForeground( GetControlForeground() );
617 else
618 _pItemWindow->SetControlForeground( );
619 _pItemWindow->SetTextColor( GetTextColor() );
622 //---------------------------------------------------------------------
623 void NavigationToolBar::adjustItemWindowWidth( sal_uInt16 _nItemId, Window* _pItemWindow, const void* /* _pParam */ ) const
625 String sItemText;
626 switch ( _nItemId )
628 case LID_RECORD_LABEL:
629 sItemText = getLabelString( RID_STR_LABEL_RECORD );
630 break;
632 case LID_RECORD_FILLER:
633 sItemText = getLabelString( RID_STR_LABEL_OF );
634 break;
636 case FormFeature::MoveAbsolute:
637 sItemText = OUString( "12345678" );
638 break;
640 case FormFeature::TotalRecords:
641 sItemText = OUString( "123456" );
642 break;
645 Size aSize( _pItemWindow->GetTextWidth( sItemText ), /* _pItemWindow->GetSizePixel( ).Height() */ _pItemWindow->GetTextHeight() + 4 );
646 aSize.Width() += 6;
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 )
666 SetMin( 1 );
667 SetFirst( 1 );
668 SetSpinSize( 1 );
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() )
692 return;
694 if ( m_pDispatcher )
695 m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( (sal_Int32)nRecord ) );
697 SaveValue();
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 );
712 else
713 NumericField::KeyInput( rKeyEvent );
717 //.........................................................................
718 } // namespace frm
719 //.........................................................................
721 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */