xref: /AOO41X/main/forms/source/solar/control/navtoolbar.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_forms.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "navtoolbar.hxx"
32*cdf0e10cSrcweir #include "frm_resource.hxx"
33*cdf0e10cSrcweir #include "featuredispatcher.hxx"
34*cdf0e10cSrcweir #include "frm_resource.hrc"
35*cdf0e10cSrcweir #include "commandimageprovider.hxx"
36*cdf0e10cSrcweir #include "commanddescriptionprovider.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
39*cdf0e10cSrcweir #include <com/sun/star/form/runtime/FormFeature.hpp>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <sfx2/imgmgr.hxx>
42*cdf0e10cSrcweir #include <vcl/fixed.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <memory>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #define LID_RECORD_LABEL    1000
47*cdf0e10cSrcweir #define LID_RECORD_FILLER   1001
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //.........................................................................
50*cdf0e10cSrcweir namespace frm
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir //.........................................................................
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir     using ::com::sun::star::uno::makeAny;
55*cdf0e10cSrcweir     namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir     //=====================================================================
58*cdf0e10cSrcweir     //.....................................................................
59*cdf0e10cSrcweir     namespace
60*cdf0e10cSrcweir     {
61*cdf0e10cSrcweir         static bool isArtificialItem( sal_Int16 _nFeatureId )
62*cdf0e10cSrcweir         {
63*cdf0e10cSrcweir             return ( _nFeatureId == LID_RECORD_LABEL )
64*cdf0e10cSrcweir                 || ( _nFeatureId == LID_RECORD_FILLER );
65*cdf0e10cSrcweir         }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir         static String getLabelString( sal_uInt16 _nResId )
68*cdf0e10cSrcweir         {
69*cdf0e10cSrcweir             String sLabel = String::CreateFromAscii( " " );
70*cdf0e10cSrcweir             sLabel += String( FRM_RES_STRING( _nResId ) );
71*cdf0e10cSrcweir             sLabel += String::CreateFromAscii( " " );
72*cdf0e10cSrcweir             return sLabel;
73*cdf0e10cSrcweir         }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir         ::rtl::OUString lcl_getCommandURL( const sal_Int16 _nFormFeature )
76*cdf0e10cSrcweir         {
77*cdf0e10cSrcweir             const sal_Char* pAsciiCommandName = NULL;
78*cdf0e10cSrcweir             switch ( _nFormFeature )
79*cdf0e10cSrcweir             {
80*cdf0e10cSrcweir                 case FormFeature::MoveAbsolute          : pAsciiCommandName = "AbsoluteRecord";     break;
81*cdf0e10cSrcweir                 case FormFeature::TotalRecords          : pAsciiCommandName = "RecTotal";           break;
82*cdf0e10cSrcweir                 case FormFeature::MoveToFirst           : pAsciiCommandName = "FirstRecord";        break;
83*cdf0e10cSrcweir                 case FormFeature::MoveToPrevious        : pAsciiCommandName = "PrevRecord";         break;
84*cdf0e10cSrcweir                 case FormFeature::MoveToNext            : pAsciiCommandName = "NextRecord";         break;
85*cdf0e10cSrcweir                 case FormFeature::MoveToLast            : pAsciiCommandName = "LastRecord";         break;
86*cdf0e10cSrcweir                 case FormFeature::SaveRecordChanges     : pAsciiCommandName = "RecSave";            break;
87*cdf0e10cSrcweir                 case FormFeature::UndoRecordChanges     : pAsciiCommandName = "RecUndo";            break;
88*cdf0e10cSrcweir                 case FormFeature::MoveToInsertRow       : pAsciiCommandName = "NewRecord";          break;
89*cdf0e10cSrcweir                 case FormFeature::DeleteRecord          : pAsciiCommandName = "DeleteRecord";       break;
90*cdf0e10cSrcweir                 case FormFeature::ReloadForm            : pAsciiCommandName = "Refresh";            break;
91*cdf0e10cSrcweir                 case FormFeature::RefreshCurrentControl : pAsciiCommandName = "RefreshFormControl"; break;
92*cdf0e10cSrcweir                 case FormFeature::SortAscending         : pAsciiCommandName = "Sortup";             break;
93*cdf0e10cSrcweir                 case FormFeature::SortDescending        : pAsciiCommandName = "SortDown";           break;
94*cdf0e10cSrcweir                 case FormFeature::InteractiveSort       : pAsciiCommandName = "OrderCrit";          break;
95*cdf0e10cSrcweir                 case FormFeature::AutoFilter            : pAsciiCommandName = "AutoFilter";         break;
96*cdf0e10cSrcweir                 case FormFeature::InteractiveFilter     : pAsciiCommandName = "FilterCrit";         break;
97*cdf0e10cSrcweir                 case FormFeature::ToggleApplyFilter     : pAsciiCommandName = "FormFiltered";       break;
98*cdf0e10cSrcweir                 case FormFeature::RemoveFilterAndSort   : pAsciiCommandName = "RemoveFilterSort";   break;
99*cdf0e10cSrcweir             }
100*cdf0e10cSrcweir             if ( pAsciiCommandName != NULL )
101*cdf0e10cSrcweir                 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ) + ::rtl::OUString::createFromAscii( pAsciiCommandName );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir             OSL_ENSURE( false, "lcl_getCommandURL: unknown FormFeature!" );
104*cdf0e10cSrcweir             return ::rtl::OUString();
105*cdf0e10cSrcweir         }
106*cdf0e10cSrcweir     }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     //=====================================================================
109*cdf0e10cSrcweir     //= ImplNavToolBar
110*cdf0e10cSrcweir     //=====================================================================
111*cdf0e10cSrcweir     class ImplNavToolBar : public ToolBox
112*cdf0e10cSrcweir     {
113*cdf0e10cSrcweir     protected:
114*cdf0e10cSrcweir         const IFeatureDispatcher*   m_pDispatcher;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     public:
117*cdf0e10cSrcweir         ImplNavToolBar( Window* _pParent )
118*cdf0e10cSrcweir             :ToolBox( _pParent, WB_3DLOOK )
119*cdf0e10cSrcweir             ,m_pDispatcher( NULL )
120*cdf0e10cSrcweir         {
121*cdf0e10cSrcweir         }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir         void setDispatcher( const IFeatureDispatcher* _pDispatcher )
124*cdf0e10cSrcweir         {
125*cdf0e10cSrcweir             m_pDispatcher = _pDispatcher;
126*cdf0e10cSrcweir         }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     protected:
129*cdf0e10cSrcweir         // ToolBox overridables
130*cdf0e10cSrcweir         virtual void        Select();
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     };
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     //---------------------------------------------------------------------
135*cdf0e10cSrcweir     void ImplNavToolBar::Select()
136*cdf0e10cSrcweir     {
137*cdf0e10cSrcweir         if ( m_pDispatcher )
138*cdf0e10cSrcweir         {
139*cdf0e10cSrcweir             if ( !m_pDispatcher->isEnabled( GetCurItemId() ) )
140*cdf0e10cSrcweir                 // the toolbox is a little bit buggy: With TIB_REPEAT, it sometimes
141*cdf0e10cSrcweir                 // happens that a select is reported, even though the respective
142*cdf0e10cSrcweir                 // item has just been disabled.
143*cdf0e10cSrcweir                 return;
144*cdf0e10cSrcweir             m_pDispatcher->dispatch( GetCurItemId() );
145*cdf0e10cSrcweir         }
146*cdf0e10cSrcweir     }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     //=====================================================================
149*cdf0e10cSrcweir     //= NavigationToolBar
150*cdf0e10cSrcweir     //=====================================================================
151*cdf0e10cSrcweir     DBG_NAME( NavigationToolBar )
152*cdf0e10cSrcweir     //---------------------------------------------------------------------
153*cdf0e10cSrcweir     NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const PCommandImageProvider& _pImageProvider,
154*cdf0e10cSrcweir             const PCommandDescriptionProvider& _pDescriptionProvider )
155*cdf0e10cSrcweir         :Window( _pParent, _nStyle )
156*cdf0e10cSrcweir         ,m_pDispatcher( NULL )
157*cdf0e10cSrcweir         ,m_pImageProvider( _pImageProvider )
158*cdf0e10cSrcweir         ,m_pDescriptionProvider( _pDescriptionProvider )
159*cdf0e10cSrcweir         ,m_eImageSize( eSmall )
160*cdf0e10cSrcweir         ,m_pToolbar( NULL )
161*cdf0e10cSrcweir     {
162*cdf0e10cSrcweir         DBG_CTOR( NavigationToolBar, NULL );
163*cdf0e10cSrcweir         implInit( );
164*cdf0e10cSrcweir     }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     //---------------------------------------------------------------------
167*cdf0e10cSrcweir     NavigationToolBar::~NavigationToolBar( )
168*cdf0e10cSrcweir     {
169*cdf0e10cSrcweir         for (   ::std::vector< Window* >::iterator loopChildWins = m_aChildWins.begin();
170*cdf0e10cSrcweir                 loopChildWins != m_aChildWins.end();
171*cdf0e10cSrcweir                 ++loopChildWins
172*cdf0e10cSrcweir             )
173*cdf0e10cSrcweir         {
174*cdf0e10cSrcweir             delete *loopChildWins;
175*cdf0e10cSrcweir         }
176*cdf0e10cSrcweir         delete m_pToolbar;
177*cdf0e10cSrcweir         DBG_DTOR( NavigationToolBar, NULL );
178*cdf0e10cSrcweir     }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     //---------------------------------------------------------------------
181*cdf0e10cSrcweir     void NavigationToolBar::setDispatcher( const IFeatureDispatcher* _pDispatcher )
182*cdf0e10cSrcweir     {
183*cdf0e10cSrcweir         m_pDispatcher = _pDispatcher;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir         m_pToolbar->setDispatcher( _pDispatcher );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir         RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( FormFeature::MoveAbsolute ) );
188*cdf0e10cSrcweir         OSL_ENSURE( pPositionWindow, "NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" );
189*cdf0e10cSrcweir         if ( pPositionWindow )
190*cdf0e10cSrcweir             pPositionWindow->setDispatcher( _pDispatcher );
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir         updateFeatureStates( );
193*cdf0e10cSrcweir     }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     //---------------------------------------------------------------------
196*cdf0e10cSrcweir     void NavigationToolBar::updateFeatureStates( )
197*cdf0e10cSrcweir     {
198*cdf0e10cSrcweir         for ( sal_uInt16 nPos = 0; nPos < m_pToolbar->GetItemCount(); ++nPos )
199*cdf0e10cSrcweir         {
200*cdf0e10cSrcweir             sal_uInt16 nItemId = m_pToolbar->GetItemId( nPos );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir             if ( ( nItemId == LID_RECORD_LABEL ) || ( nItemId == LID_RECORD_FILLER ) )
203*cdf0e10cSrcweir                 continue;
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir             // is this item enabled?
206*cdf0e10cSrcweir             bool bEnabled = m_pDispatcher ? m_pDispatcher->isEnabled( nItemId ) : false;
207*cdf0e10cSrcweir             implEnableItem( nItemId, bEnabled );
208*cdf0e10cSrcweir         }
209*cdf0e10cSrcweir     }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     //---------------------------------------------------------------------
212*cdf0e10cSrcweir     void NavigationToolBar::implEnableItem( sal_uInt16 _nItemId, bool _bEnabled )
213*cdf0e10cSrcweir     {
214*cdf0e10cSrcweir         m_pToolbar->EnableItem( _nItemId, _bEnabled );
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir         if ( _nItemId == FormFeature::MoveAbsolute )
217*cdf0e10cSrcweir             m_pToolbar->EnableItem( LID_RECORD_LABEL, _bEnabled );
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir         if ( _nItemId == FormFeature::TotalRecords )
220*cdf0e10cSrcweir             m_pToolbar->EnableItem( LID_RECORD_FILLER, _bEnabled );
221*cdf0e10cSrcweir     }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     //---------------------------------------------------------------------
224*cdf0e10cSrcweir     void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled )
225*cdf0e10cSrcweir     {
226*cdf0e10cSrcweir         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
227*cdf0e10cSrcweir             "NavigationToolBar::enableFeature: invalid id!" );
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir         implEnableItem( (sal_uInt16)_nFeatureId, _bEnabled );
230*cdf0e10cSrcweir     }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     //---------------------------------------------------------------------
233*cdf0e10cSrcweir     void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled )
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
236*cdf0e10cSrcweir             "NavigationToolBar::checkFeature: invalid id!" );
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir         m_pToolbar->CheckItem( (sal_uInt16)_nFeatureId, _bEnabled );
239*cdf0e10cSrcweir     }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir     //---------------------------------------------------------------------
242*cdf0e10cSrcweir     void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText )
243*cdf0e10cSrcweir     {
244*cdf0e10cSrcweir         DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
245*cdf0e10cSrcweir             "NavigationToolBar::checkFeature: invalid id!" );
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir         Window* pItemWindow = m_pToolbar->GetItemWindow( (sal_uInt16)_nFeatureId );
248*cdf0e10cSrcweir         if ( pItemWindow )
249*cdf0e10cSrcweir             pItemWindow->SetText( _rText );
250*cdf0e10cSrcweir         else
251*cdf0e10cSrcweir             m_pToolbar->SetItemText( (sal_uInt16)_nFeatureId, _rText );
252*cdf0e10cSrcweir     }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir     //---------------------------------------------------------------------
255*cdf0e10cSrcweir     void NavigationToolBar::implInit( )
256*cdf0e10cSrcweir     {
257*cdf0e10cSrcweir         m_pToolbar = new ImplNavToolBar( this );
258*cdf0e10cSrcweir         m_pToolbar->SetOutStyle( TOOLBOX_STYLE_FLAT );
259*cdf0e10cSrcweir         m_pToolbar->Show();
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir         // need the SfxApplication for retrieving informations about our
262*cdf0e10cSrcweir         // items. We could duplicate all the information here in our lib
263*cdf0e10cSrcweir         // (such as the item text and the image), but why should we?
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir         struct FeatureDescription
266*cdf0e10cSrcweir         {
267*cdf0e10cSrcweir             sal_uInt16      nId;
268*cdf0e10cSrcweir             bool        bRepeat;
269*cdf0e10cSrcweir             bool        bItemWindow;
270*cdf0e10cSrcweir         } aSupportedFeatures[] =
271*cdf0e10cSrcweir         {
272*cdf0e10cSrcweir             { LID_RECORD_LABEL,                     false, true },
273*cdf0e10cSrcweir             { FormFeature::MoveAbsolute,            false, true },
274*cdf0e10cSrcweir             { LID_RECORD_FILLER,                    false, true },
275*cdf0e10cSrcweir             { FormFeature::TotalRecords,            false, true },
276*cdf0e10cSrcweir             { FormFeature::MoveToFirst,             true,  false },
277*cdf0e10cSrcweir             { FormFeature::MoveToPrevious,          true,  false },
278*cdf0e10cSrcweir             { FormFeature::MoveToNext,              true,  false },
279*cdf0e10cSrcweir             { FormFeature::MoveToLast,              true,  false },
280*cdf0e10cSrcweir             { FormFeature::MoveToInsertRow,         false, false },
281*cdf0e10cSrcweir             { 0, false, false },
282*cdf0e10cSrcweir             { FormFeature::SaveRecordChanges,       false, false },
283*cdf0e10cSrcweir             { FormFeature::UndoRecordChanges,       false, false },
284*cdf0e10cSrcweir             { FormFeature::DeleteRecord,            false, false },
285*cdf0e10cSrcweir             { FormFeature::ReloadForm,              false, false },
286*cdf0e10cSrcweir             { FormFeature::RefreshCurrentControl,   false, false },
287*cdf0e10cSrcweir             { 0, false, false },
288*cdf0e10cSrcweir             { FormFeature::SortAscending,           false, false },
289*cdf0e10cSrcweir             { FormFeature::SortDescending,          false, false },
290*cdf0e10cSrcweir             { FormFeature::InteractiveSort,         false, false },
291*cdf0e10cSrcweir             { FormFeature::AutoFilter,              false, false },
292*cdf0e10cSrcweir             { FormFeature::InteractiveFilter,       false, false },
293*cdf0e10cSrcweir             { FormFeature::ToggleApplyFilter,       false, false },
294*cdf0e10cSrcweir             { FormFeature::RemoveFilterAndSort,     false, false },
295*cdf0e10cSrcweir         };
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir         size_t nSupportedFeatures = sizeof( aSupportedFeatures ) / sizeof( aSupportedFeatures[0] );
298*cdf0e10cSrcweir         FeatureDescription* pSupportedFeatures = aSupportedFeatures;
299*cdf0e10cSrcweir         FeatureDescription* pSupportedFeaturesEnd = aSupportedFeatures + nSupportedFeatures;
300*cdf0e10cSrcweir         for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures )
301*cdf0e10cSrcweir         {
302*cdf0e10cSrcweir             if ( pSupportedFeatures->nId )
303*cdf0e10cSrcweir             {   // it's _not_ a separator
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir                 // insert the entry
306*cdf0e10cSrcweir                 m_pToolbar->InsertItem( pSupportedFeatures->nId, String(), pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 );
307*cdf0e10cSrcweir                 m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, String() );  // TODO
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir                 if ( !isArtificialItem( pSupportedFeatures->nId ) )
310*cdf0e10cSrcweir                 {
311*cdf0e10cSrcweir                     ::rtl::OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) );
312*cdf0e10cSrcweir                     m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL );
313*cdf0e10cSrcweir                     if ( m_pDescriptionProvider )
314*cdf0e10cSrcweir                         m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, m_pDescriptionProvider->getCommandDescription( sCommandURL ) );
315*cdf0e10cSrcweir                 }
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir                 if ( pSupportedFeatures->bItemWindow )
318*cdf0e10cSrcweir                 {
319*cdf0e10cSrcweir                     Window* pItemWindow = NULL;
320*cdf0e10cSrcweir                     if ( FormFeature::MoveAbsolute == pSupportedFeatures->nId )
321*cdf0e10cSrcweir                     {
322*cdf0e10cSrcweir                         pItemWindow = new RecordPositionInput( m_pToolbar );
323*cdf0e10cSrcweir                         static_cast< RecordPositionInput* >( pItemWindow )->setDispatcher( m_pDispatcher );
324*cdf0e10cSrcweir                     }
325*cdf0e10cSrcweir                     else if ( LID_RECORD_FILLER == pSupportedFeatures->nId )
326*cdf0e10cSrcweir                     {
327*cdf0e10cSrcweir                         pItemWindow = new FixedText( m_pToolbar, WB_CENTER | WB_VCENTER );
328*cdf0e10cSrcweir 						pItemWindow->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
329*cdf0e10cSrcweir                     }
330*cdf0e10cSrcweir                     else
331*cdf0e10cSrcweir                     {
332*cdf0e10cSrcweir                         pItemWindow = new FixedText( m_pToolbar, WB_VCENTER );
333*cdf0e10cSrcweir 						pItemWindow->SetBackground();
334*cdf0e10cSrcweir                         pItemWindow->SetPaintTransparent(sal_True);
335*cdf0e10cSrcweir                     }
336*cdf0e10cSrcweir                     m_aChildWins.push_back( pItemWindow );
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir                     switch ( pSupportedFeatures->nId )
339*cdf0e10cSrcweir                     {
340*cdf0e10cSrcweir                     case LID_RECORD_LABEL:
341*cdf0e10cSrcweir                         pItemWindow->SetText( getLabelString( RID_STR_LABEL_RECORD ) );
342*cdf0e10cSrcweir                         break;
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir                     case LID_RECORD_FILLER:
345*cdf0e10cSrcweir                         pItemWindow->SetText( getLabelString( RID_STR_LABEL_OF ) );
346*cdf0e10cSrcweir                         break;
347*cdf0e10cSrcweir                     }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir                     m_pToolbar->SetItemWindow( pSupportedFeatures->nId, pItemWindow );
350*cdf0e10cSrcweir                 }
351*cdf0e10cSrcweir             }
352*cdf0e10cSrcweir             else
353*cdf0e10cSrcweir             {   // a separator
354*cdf0e10cSrcweir                 m_pToolbar->InsertSeparator( );
355*cdf0e10cSrcweir             }
356*cdf0e10cSrcweir         }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir         implUpdateImages();
361*cdf0e10cSrcweir     }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir     //---------------------------------------------------------------------
364*cdf0e10cSrcweir     void NavigationToolBar::implUpdateImages()
365*cdf0e10cSrcweir     {
366*cdf0e10cSrcweir         OSL_ENSURE( m_pImageProvider, "NavigationToolBar::implUpdateImages: no image provider => no images!" );
367*cdf0e10cSrcweir         if ( !m_pImageProvider )
368*cdf0e10cSrcweir             return;
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir         const bool bIsHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir         const sal_uInt16 nItemCount = m_pToolbar->GetItemCount();
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir         // collect the FormFeatures in the toolbar
375*cdf0e10cSrcweir         typedef ::std::vector< sal_Int16 >  FormFeatures;
376*cdf0e10cSrcweir         FormFeatures aFormFeatures;
377*cdf0e10cSrcweir         aFormFeatures.reserve( nItemCount );
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir         for ( sal_uInt16 i=0; i<nItemCount; ++i )
380*cdf0e10cSrcweir         {
381*cdf0e10cSrcweir             sal_uInt16 nId = m_pToolbar->GetItemId( i );
382*cdf0e10cSrcweir             if ( ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) )
383*cdf0e10cSrcweir                 aFormFeatures.push_back( nId );
384*cdf0e10cSrcweir         }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir         // translate them into command URLs
387*cdf0e10cSrcweir         CommandURLs aCommandURLs( aFormFeatures.size() );
388*cdf0e10cSrcweir         for (   FormFeatures::const_iterator formFeature = aFormFeatures.begin();
389*cdf0e10cSrcweir                 formFeature != aFormFeatures.end();
390*cdf0e10cSrcweir                 ++formFeature
391*cdf0e10cSrcweir             )
392*cdf0e10cSrcweir         {
393*cdf0e10cSrcweir             aCommandURLs[ formFeature - aFormFeatures.begin() ] = lcl_getCommandURL( *formFeature );
394*cdf0e10cSrcweir         }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir         // retrieve the images for the command URLs
397*cdf0e10cSrcweir         CommandImages aCommandImages = m_pImageProvider->getCommandImages( aCommandURLs, m_eImageSize == eLarge, bIsHighContrast );
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir         // and set them at the toolbar
400*cdf0e10cSrcweir         CommandImages::const_iterator commandImage = aCommandImages.begin();
401*cdf0e10cSrcweir         for (   FormFeatures::const_iterator formFeature = aFormFeatures.begin();
402*cdf0e10cSrcweir                 formFeature != aFormFeatures.end();
403*cdf0e10cSrcweir                 ++formFeature, ++commandImage
404*cdf0e10cSrcweir             )
405*cdf0e10cSrcweir         {
406*cdf0e10cSrcweir             m_pToolbar->SetItemImage( *formFeature, *commandImage );
407*cdf0e10cSrcweir         }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir         // parts of our layout is dependent on the size of our icons
410*cdf0e10cSrcweir         Resize();
411*cdf0e10cSrcweir     }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir     //---------------------------------------------------------------------
414*cdf0e10cSrcweir     void NavigationToolBar::implSetImageSize( ImageSize _eSize )
415*cdf0e10cSrcweir     {
416*cdf0e10cSrcweir         if ( _eSize != m_eImageSize )
417*cdf0e10cSrcweir         {
418*cdf0e10cSrcweir             m_eImageSize = _eSize;
419*cdf0e10cSrcweir             implUpdateImages();
420*cdf0e10cSrcweir         }
421*cdf0e10cSrcweir     }
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir     //---------------------------------------------------------------------
424*cdf0e10cSrcweir     void NavigationToolBar::SetImageSize( ImageSize _eSize )
425*cdf0e10cSrcweir     {
426*cdf0e10cSrcweir         implSetImageSize( _eSize );
427*cdf0e10cSrcweir     }
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir     //---------------------------------------------------------------------
430*cdf0e10cSrcweir     void NavigationToolBar::ShowFunctionGroup( FunctionGroup _eGroup, bool _bShow )
431*cdf0e10cSrcweir     {
432*cdf0e10cSrcweir         const sal_uInt16* pGroupIds = NULL;
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir         switch ( _eGroup )
435*cdf0e10cSrcweir         {
436*cdf0e10cSrcweir         case ePosition:
437*cdf0e10cSrcweir         {
438*cdf0e10cSrcweir             static const sal_uInt16 aPositionIds[] = {
439*cdf0e10cSrcweir                 LID_RECORD_LABEL, FormFeature::MoveAbsolute, LID_RECORD_FILLER, FormFeature::TotalRecords, 0
440*cdf0e10cSrcweir             };
441*cdf0e10cSrcweir             pGroupIds = aPositionIds;
442*cdf0e10cSrcweir         }
443*cdf0e10cSrcweir         break;
444*cdf0e10cSrcweir         case eNavigation:
445*cdf0e10cSrcweir         {
446*cdf0e10cSrcweir             static const sal_uInt16 aNavigationIds[] = {
447*cdf0e10cSrcweir                 FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0
448*cdf0e10cSrcweir             };
449*cdf0e10cSrcweir             pGroupIds = aNavigationIds;
450*cdf0e10cSrcweir         }
451*cdf0e10cSrcweir         break;
452*cdf0e10cSrcweir         case eRecordActions:
453*cdf0e10cSrcweir         {
454*cdf0e10cSrcweir             static const sal_uInt16 aActionIds[] = {
455*cdf0e10cSrcweir                 FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0
456*cdf0e10cSrcweir             };
457*cdf0e10cSrcweir             pGroupIds = aActionIds;
458*cdf0e10cSrcweir         }
459*cdf0e10cSrcweir         break;
460*cdf0e10cSrcweir         case eFilterSort:
461*cdf0e10cSrcweir         {
462*cdf0e10cSrcweir             static const sal_uInt16 aFilterSortIds[] = {
463*cdf0e10cSrcweir                 FormFeature::SortAscending, FormFeature::SortDescending, FormFeature::InteractiveSort, FormFeature::AutoFilter, FormFeature::InteractiveFilter, FormFeature::ToggleApplyFilter, FormFeature::RemoveFilterAndSort, 0
464*cdf0e10cSrcweir             };
465*cdf0e10cSrcweir             pGroupIds = aFilterSortIds;
466*cdf0e10cSrcweir         }
467*cdf0e10cSrcweir         break;
468*cdf0e10cSrcweir         default:
469*cdf0e10cSrcweir             OSL_ENSURE( sal_False, "NavigationToolBar::ShowFunctionGroup: invalid group id!" );
470*cdf0e10cSrcweir         }
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir         if ( pGroupIds )
473*cdf0e10cSrcweir             while ( *pGroupIds )
474*cdf0e10cSrcweir                 m_pToolbar->ShowItem( *pGroupIds++, _bShow );
475*cdf0e10cSrcweir     }
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir     //---------------------------------------------------------------------
478*cdf0e10cSrcweir     bool NavigationToolBar::IsFunctionGroupVisible( FunctionGroup _eGroup )
479*cdf0e10cSrcweir     {
480*cdf0e10cSrcweir         sal_uInt16 nIndicatorItem = 0;
481*cdf0e10cSrcweir         switch ( _eGroup )
482*cdf0e10cSrcweir         {
483*cdf0e10cSrcweir         case ePosition      : nIndicatorItem = LID_RECORD_LABEL;    break;
484*cdf0e10cSrcweir         case eNavigation    : nIndicatorItem = FormFeature::MoveToFirst; break;
485*cdf0e10cSrcweir         case eRecordActions : nIndicatorItem = FormFeature::SaveRecordChanges;  break;
486*cdf0e10cSrcweir         case eFilterSort    : nIndicatorItem = FormFeature::SortAscending;       break;
487*cdf0e10cSrcweir         default:
488*cdf0e10cSrcweir             OSL_ENSURE( sal_False, "NavigationToolBar::IsFunctionGroupVisible: invalid group id!" );
489*cdf0e10cSrcweir         }
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir         return m_pToolbar->IsItemVisible( nIndicatorItem );
492*cdf0e10cSrcweir     }
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir     //------------------------------------------------------------------------------
495*cdf0e10cSrcweir     void NavigationToolBar::StateChanged( StateChangedType nType )
496*cdf0e10cSrcweir     {
497*cdf0e10cSrcweir 	    Window::StateChanged( nType );
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir         switch ( nType )
500*cdf0e10cSrcweir 	    {
501*cdf0e10cSrcweir 		    case STATE_CHANGE_ZOOM:
502*cdf0e10cSrcweir //                m_pToolbar->SetZoom( GetZoom() );
503*cdf0e10cSrcweir //                forEachItemWindow( setItemWindowZoom, NULL );
504*cdf0e10cSrcweir                 // the ToolBox class is not zoomable at the moment, so
505*cdf0e10cSrcweir                 // we better have no zoom at all instead of only half a zoom ...
506*cdf0e10cSrcweir                 break;
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir             case STATE_CHANGE_CONTROLFONT:
509*cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::setItemControlFont, NULL );
510*cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
511*cdf0e10cSrcweir                 break;
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir             case STATE_CHANGE_CONTROLFOREGROUND:
514*cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::setItemControlForeground, NULL );
515*cdf0e10cSrcweir                 break;
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir             case STATE_CHANGE_MIRRORING:
518*cdf0e10cSrcweir             {
519*cdf0e10cSrcweir                 sal_Bool bIsRTLEnabled( IsRTLEnabled() );
520*cdf0e10cSrcweir                 m_pToolbar->EnableRTL( bIsRTLEnabled );
521*cdf0e10cSrcweir                 forEachItemWindow( &NavigationToolBar::enableItemRTL, &bIsRTLEnabled );
522*cdf0e10cSrcweir                 Resize();
523*cdf0e10cSrcweir             }
524*cdf0e10cSrcweir             break;
525*cdf0e10cSrcweir         }
526*cdf0e10cSrcweir     }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir     //---------------------------------------------------------------------
529*cdf0e10cSrcweir     void NavigationToolBar::Resize()
530*cdf0e10cSrcweir     {
531*cdf0e10cSrcweir         // resize/position the toolbox as a whole
532*cdf0e10cSrcweir         sal_Int32 nToolbarHeight = m_pToolbar->CalcWindowSizePixel().Height();
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir         sal_Int32 nMyHeight = GetOutputSizePixel().Height();
535*cdf0e10cSrcweir         m_pToolbar->SetPosSizePixel( Point( 0, ( nMyHeight - nToolbarHeight ) / 2 ),
536*cdf0e10cSrcweir                                      Size( GetSizePixel().Width(), nToolbarHeight ) );
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir         Window::Resize();
539*cdf0e10cSrcweir     }
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir     //---------------------------------------------------------------------
542*cdf0e10cSrcweir     void NavigationToolBar::SetControlBackground()
543*cdf0e10cSrcweir     {
544*cdf0e10cSrcweir         Window::SetControlBackground();
545*cdf0e10cSrcweir         m_pToolbar->SetControlBackground();
546*cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setItemBackground, NULL );
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir         // the contrast of the background color may have changed, so force
549*cdf0e10cSrcweir         // the images to be rebuild (high contrast requires a possibly different
550*cdf0e10cSrcweir         // image set)
551*cdf0e10cSrcweir         implUpdateImages();
552*cdf0e10cSrcweir     }
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir     //---------------------------------------------------------------------
555*cdf0e10cSrcweir     void NavigationToolBar::SetControlBackground( const Color& _rColor )
556*cdf0e10cSrcweir     {
557*cdf0e10cSrcweir         Window::SetControlBackground( _rColor );
558*cdf0e10cSrcweir         m_pToolbar->SetControlBackground( _rColor );
559*cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setItemBackground, &_rColor );
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir         // the contrast of the background color may have changed, so force
562*cdf0e10cSrcweir         // the images to be rebuild (high contrast requires a possibly different
563*cdf0e10cSrcweir         // image set)
564*cdf0e10cSrcweir         implUpdateImages();
565*cdf0e10cSrcweir     }
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir     //---------------------------------------------------------------------
568*cdf0e10cSrcweir     void NavigationToolBar::SetTextLineColor( )
569*cdf0e10cSrcweir     {
570*cdf0e10cSrcweir         Window::SetTextLineColor( );
571*cdf0e10cSrcweir         m_pToolbar->SetTextLineColor( );
572*cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setTextLineColor, NULL );
573*cdf0e10cSrcweir     }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir     //---------------------------------------------------------------------
576*cdf0e10cSrcweir     void NavigationToolBar::SetTextLineColor( const Color& _rColor )
577*cdf0e10cSrcweir     {
578*cdf0e10cSrcweir         Window::SetTextLineColor( _rColor );
579*cdf0e10cSrcweir         m_pToolbar->SetTextLineColor( _rColor );
580*cdf0e10cSrcweir         forEachItemWindow( &NavigationToolBar::setTextLineColor, &_rColor );
581*cdf0e10cSrcweir     }
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir     //---------------------------------------------------------------------
584*cdf0e10cSrcweir     void NavigationToolBar::forEachItemWindow( ItemWindowHandler _handler, const void* _pParam )
585*cdf0e10cSrcweir     {
586*cdf0e10cSrcweir         for ( sal_uInt16 item = 0; item < m_pToolbar->GetItemCount(); ++item )
587*cdf0e10cSrcweir         {
588*cdf0e10cSrcweir             sal_uInt16 nItemId = m_pToolbar->GetItemId( item );
589*cdf0e10cSrcweir             Window* pItemWindow = m_pToolbar->GetItemWindow( nItemId );
590*cdf0e10cSrcweir             if ( pItemWindow )
591*cdf0e10cSrcweir                 (this->*_handler)( nItemId, pItemWindow, _pParam );
592*cdf0e10cSrcweir         }
593*cdf0e10cSrcweir     }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir     //---------------------------------------------------------------------
596*cdf0e10cSrcweir     void NavigationToolBar::setItemBackground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
597*cdf0e10cSrcweir     {
598*cdf0e10cSrcweir         if ( _pColor )
599*cdf0e10cSrcweir             _pItemWindow->SetControlBackground( *static_cast< const Color* >( _pColor ) );
600*cdf0e10cSrcweir         else
601*cdf0e10cSrcweir             _pItemWindow->SetControlBackground();
602*cdf0e10cSrcweir     }
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir     //---------------------------------------------------------------------
605*cdf0e10cSrcweir     void NavigationToolBar::setTextLineColor( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const
606*cdf0e10cSrcweir     {
607*cdf0e10cSrcweir         if ( _pColor )
608*cdf0e10cSrcweir             _pItemWindow->SetTextLineColor( *static_cast< const Color* >( _pColor ) );
609*cdf0e10cSrcweir         else
610*cdf0e10cSrcweir             _pItemWindow->SetTextLineColor();
611*cdf0e10cSrcweir     }
612*cdf0e10cSrcweir #if 0
613*cdf0e10cSrcweir     //---------------------------------------------------------------------
614*cdf0e10cSrcweir     void NavigationToolBar::setItemWindowZoom( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
615*cdf0e10cSrcweir     {
616*cdf0e10cSrcweir         _pItemWindow->SetZoom( GetZoom() );
617*cdf0e10cSrcweir         _pItemWindow->SetZoomedPointFont( IsControlFont() ? GetControlFont() : GetPointFont() );
618*cdf0e10cSrcweir     }
619*cdf0e10cSrcweir #endif
620*cdf0e10cSrcweir     //---------------------------------------------------------------------
621*cdf0e10cSrcweir     void NavigationToolBar::setItemControlFont( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
622*cdf0e10cSrcweir     {
623*cdf0e10cSrcweir         if ( IsControlFont() )
624*cdf0e10cSrcweir             _pItemWindow->SetControlFont( GetControlFont() );
625*cdf0e10cSrcweir         else
626*cdf0e10cSrcweir             _pItemWindow->SetControlFont( );
627*cdf0e10cSrcweir     }
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir     //---------------------------------------------------------------------
630*cdf0e10cSrcweir     void NavigationToolBar::setItemControlForeground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const
631*cdf0e10cSrcweir     {
632*cdf0e10cSrcweir         if ( IsControlForeground() )
633*cdf0e10cSrcweir             _pItemWindow->SetControlForeground( GetControlForeground() );
634*cdf0e10cSrcweir         else
635*cdf0e10cSrcweir             _pItemWindow->SetControlForeground( );
636*cdf0e10cSrcweir         _pItemWindow->SetTextColor( GetTextColor() );
637*cdf0e10cSrcweir     }
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir     //---------------------------------------------------------------------
640*cdf0e10cSrcweir     void NavigationToolBar::adjustItemWindowWidth( sal_uInt16 _nItemId, Window* _pItemWindow, const void* /* _pParam */ ) const
641*cdf0e10cSrcweir     {
642*cdf0e10cSrcweir         String sItemText;
643*cdf0e10cSrcweir         switch ( _nItemId )
644*cdf0e10cSrcweir         {
645*cdf0e10cSrcweir         case LID_RECORD_LABEL:
646*cdf0e10cSrcweir             sItemText = getLabelString( RID_STR_LABEL_RECORD );
647*cdf0e10cSrcweir             break;
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir         case LID_RECORD_FILLER:
650*cdf0e10cSrcweir             sItemText = getLabelString( RID_STR_LABEL_OF );
651*cdf0e10cSrcweir             break;
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir         case FormFeature::MoveAbsolute:
654*cdf0e10cSrcweir             sItemText = String::CreateFromAscii( "12345678" );
655*cdf0e10cSrcweir             break;
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir         case FormFeature::TotalRecords:
658*cdf0e10cSrcweir             sItemText = String::CreateFromAscii( "123456" );
659*cdf0e10cSrcweir             break;
660*cdf0e10cSrcweir         }
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir         Size aSize( _pItemWindow->GetTextWidth( sItemText ), /* _pItemWindow->GetSizePixel( ).Height() */ _pItemWindow->GetTextHeight() + 4 );
663*cdf0e10cSrcweir         aSize.Width() += 6;
664*cdf0e10cSrcweir         _pItemWindow->SetSizePixel( aSize );
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir         m_pToolbar->SetItemWindow( _nItemId, _pItemWindow );
667*cdf0e10cSrcweir     }
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir     //---------------------------------------------------------------------
670*cdf0e10cSrcweir     void NavigationToolBar::enableItemRTL( sal_uInt16 /*_nItemId*/, Window* _pItemWindow, const void* _pIsRTLEnabled ) const
671*cdf0e10cSrcweir     {
672*cdf0e10cSrcweir         _pItemWindow->EnableRTL( *static_cast< const sal_Bool* >( _pIsRTLEnabled ) );
673*cdf0e10cSrcweir     }
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir     //=====================================================================
676*cdf0e10cSrcweir     //= RecordPositionInput
677*cdf0e10cSrcweir     //=====================================================================
678*cdf0e10cSrcweir     //---------------------------------------------------------------------
679*cdf0e10cSrcweir     RecordPositionInput::RecordPositionInput( Window* _pParent )
680*cdf0e10cSrcweir 	    :NumericField( _pParent, WB_BORDER | WB_VCENTER )
681*cdf0e10cSrcweir         ,m_pDispatcher( NULL )
682*cdf0e10cSrcweir     {
683*cdf0e10cSrcweir 	    SetMin( 1 );
684*cdf0e10cSrcweir 	    SetFirst( 1 );
685*cdf0e10cSrcweir 	    SetSpinSize( 1 );
686*cdf0e10cSrcweir 	    SetDecimalDigits( 0 );
687*cdf0e10cSrcweir 	    SetStrictFormat( sal_True );
688*cdf0e10cSrcweir         SetBorderStyle( WINDOW_BORDER_MONO );
689*cdf0e10cSrcweir     }
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir     //---------------------------------------------------------------------
692*cdf0e10cSrcweir     RecordPositionInput::~RecordPositionInput()
693*cdf0e10cSrcweir     {
694*cdf0e10cSrcweir     }
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir     //---------------------------------------------------------------------
697*cdf0e10cSrcweir     void RecordPositionInput::setDispatcher( const IFeatureDispatcher* _pDispatcher )
698*cdf0e10cSrcweir     {
699*cdf0e10cSrcweir         m_pDispatcher = _pDispatcher;
700*cdf0e10cSrcweir     }
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir     //---------------------------------------------------------------------
703*cdf0e10cSrcweir     void RecordPositionInput::FirePosition( sal_Bool _bForce )
704*cdf0e10cSrcweir     {
705*cdf0e10cSrcweir 	    if ( _bForce || ( GetText() != GetSavedValue() ) )
706*cdf0e10cSrcweir 	    {
707*cdf0e10cSrcweir 		    sal_Int64 nRecord = GetValue();
708*cdf0e10cSrcweir 		    if ( nRecord < GetMin() || nRecord > GetMax() )
709*cdf0e10cSrcweir 			    return;
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir             if ( m_pDispatcher )
712*cdf0e10cSrcweir                 m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( (sal_Int32)nRecord ) );
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir             SaveValue();
715*cdf0e10cSrcweir 	    }
716*cdf0e10cSrcweir     }
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir     //---------------------------------------------------------------------
719*cdf0e10cSrcweir     void RecordPositionInput::LoseFocus()
720*cdf0e10cSrcweir     {
721*cdf0e10cSrcweir 	    FirePosition( sal_False );
722*cdf0e10cSrcweir     }
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir     //---------------------------------------------------------------------
725*cdf0e10cSrcweir     void RecordPositionInput::KeyInput( const KeyEvent& rKeyEvent )
726*cdf0e10cSrcweir     {
727*cdf0e10cSrcweir 	    if( rKeyEvent.GetKeyCode() == KEY_RETURN && GetText().Len() )
728*cdf0e10cSrcweir 		    FirePosition( sal_True );
729*cdf0e10cSrcweir 	    else
730*cdf0e10cSrcweir 		    NumericField::KeyInput( rKeyEvent );
731*cdf0e10cSrcweir     }
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir //.........................................................................
735*cdf0e10cSrcweir }   // namespace frm
736*cdf0e10cSrcweir //.........................................................................
737