merge the formfield patch from ooo-build
[ooovba.git] / svx / source / tbxctrls / itemwin.cxx
blobd8921d4fe5adc6098faf56a3a7141860e3a584ec
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: itemwin.cxx,v $
10 * $Revision: 1.28 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/shl.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/objsh.hxx>
38 #include <sfx2/viewsh.hxx>
39 #include <sfx2/module.hxx>
40 #include <tools/urlobj.hxx>
42 #define _SVX_ITEMWIN_CXX
44 #include <vcl/svapp.hxx>
46 #include <svx/dialogs.hrc>
48 #define DELAY_TIMEOUT 100
50 #include <svx/xlnclit.hxx>
51 #include <svx/xlnwtit.hxx>
52 #include <svx/xlineit0.hxx>
53 #include <svx/xlndsit.hxx>
54 #include <svx/xtable.hxx>
55 #include "drawitem.hxx"
56 #include <svx/dialmgr.hxx>
57 #include "dlgutil.hxx"
58 #include <svx/itemwin.hxx>
59 #include "linectrl.hxx"
60 #include <svtools/colorcfg.hxx>
62 #include "linectrl.hrc"
64 using namespace ::com::sun::star::uno;
65 using namespace ::com::sun::star::frame;
66 using namespace ::com::sun::star::util;
67 using namespace ::com::sun::star::lang;
68 using namespace ::com::sun::star::beans;
70 #define LOGICAL_EDIT_HEIGHT 12
71 //========================================================================
72 // SvxLineBox
73 //========================================================================
75 SvxLineBox::SvxLineBox( Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
76 LineLB( pParent, nBits ),
77 meBmpMode ( GetDisplayBackground().GetColor().IsDark() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL ),
78 nCurPos ( 0 ),
79 aLogicalSize(40,140),
80 bRelease ( TRUE ),
81 mpSh ( NULL ),
82 mxFrame ( rFrame )
84 SetSizePixel( LogicToPixel( aLogicalSize, MAP_APPFONT ));
85 Show();
87 aDelayTimer.SetTimeout( DELAY_TIMEOUT );
88 aDelayTimer.SetTimeoutHdl( LINK( this, SvxLineBox, DelayHdl_Impl ) );
89 aDelayTimer.Start();
92 // -----------------------------------------------------------------------
94 SvxLineBox::~SvxLineBox()
98 // -----------------------------------------------------------------------
100 IMPL_LINK( SvxLineBox, DelayHdl_Impl, Timer *, EMPTYARG )
102 if ( GetEntryCount() == 0 )
104 mpSh = SfxObjectShell::Current();
105 FillControl();
107 return 0;
110 // -----------------------------------------------------------------------
112 void SvxLineBox::Select()
114 // Call the parent's Select() member to trigger accessibility events.
115 LineLB::Select();
117 if ( !IsTravelSelect() )
119 XLineStyle eXLS;
120 USHORT nPos = GetSelectEntryPos();
121 // SfxDispatcher* pDisp = rBindings.GetDispatcher();
122 //DBG_ASSERT( pDisp, "invalid Dispatcher" );
124 switch ( nPos )
126 case 0:
127 eXLS = XLINE_NONE;
128 break;
130 case 1:
131 eXLS = XLINE_SOLID;
132 break;
134 default:
136 eXLS = XLINE_DASH;
138 if ( nPos != LISTBOX_ENTRY_NOTFOUND &&
139 SfxObjectShell::Current() &&
140 SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) )
142 // LineDashItem wird nur geschickt, wenn es auch einen Dash besitzt.
143 // Notify k"ummert sich darum!
144 SvxDashListItem aItem( *(const SvxDashListItem*)(
145 SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) );
146 XLineDashItem aLineDashItem( GetSelectEntry(),
147 aItem.GetDashList()->GetDash( nPos - 2 )->GetDash() );
149 Any a;
150 Sequence< PropertyValue > aArgs( 1 );
151 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" ));
152 aLineDashItem.QueryValue ( a );
153 aArgs[0].Value = a;
154 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
155 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )),
156 aArgs );
157 // pDisp->Execute( SID_ATTR_LINE_DASH, SFX_CALLMODE_RECORD, &aLineDashItem, 0L );
160 break;
163 XLineStyleItem aLineStyleItem( eXLS );
164 Any a;
165 Sequence< PropertyValue > aArgs( 1 );
166 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XLineStyle" ));
167 aLineStyleItem.QueryValue ( a );
168 aArgs[0].Value = a;
169 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
170 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:XLineStyle" )),
171 aArgs );
172 // pDisp->Execute( SID_ATTR_LINE_STYLE, SFX_CALLMODE_RECORD, &aLineStyleItem, 0L );
174 nCurPos = GetSelectEntryPos();
175 ReleaseFocus_Impl();
179 // -----------------------------------------------------------------------
181 long SvxLineBox::PreNotify( NotifyEvent& rNEvt )
183 USHORT nType = rNEvt.GetType();
185 switch(nType)
187 case EVENT_MOUSEBUTTONDOWN:
188 case EVENT_GETFOCUS:
189 nCurPos = GetSelectEntryPos();
190 break;
191 case EVENT_LOSEFOCUS:
192 SelectEntryPos(nCurPos);
193 break;
194 case EVENT_KEYINPUT:
196 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
197 if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
199 bRelease = FALSE;
200 Select();
203 break;
205 return LineLB::PreNotify( rNEvt );
208 // -----------------------------------------------------------------------
210 long SvxLineBox::Notify( NotifyEvent& rNEvt )
212 long nHandled = LineLB::Notify( rNEvt );
214 if ( rNEvt.GetType() == EVENT_KEYINPUT )
216 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
218 switch ( pKEvt->GetKeyCode().GetCode() )
220 case KEY_RETURN:
221 Select();
222 nHandled = 1;
223 break;
225 case KEY_ESCAPE:
226 SelectEntryPos( nCurPos );
227 ReleaseFocus_Impl();
228 nHandled = 1;
229 break;
232 return nHandled;
235 // -----------------------------------------------------------------------
237 void SvxLineBox::ReleaseFocus_Impl()
239 if(!bRelease)
241 bRelease = TRUE;
242 return;
245 if( SfxViewShell::Current() )
247 Window* pShellWnd = SfxViewShell::Current()->GetWindow();
249 if ( pShellWnd )
250 pShellWnd->GrabFocus();
253 /* -----------------------------08.03.2002 15:39------------------------------
255 ---------------------------------------------------------------------------*/
256 void SvxLineBox::DataChanged( const DataChangedEvent& rDCEvt )
258 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
259 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
261 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
262 Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
263 SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
266 LineLB::DataChanged( rDCEvt );
268 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
269 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
271 BmpColorMode eMode = GetDisplayBackground().GetColor().IsDark() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL;
272 if( eMode != meBmpMode )
274 meBmpMode = eMode;
275 FillControl();
280 void SvxLineBox::FillControl()
282 Clear();
284 InsertEntry( SVX_RESSTR(RID_SVXSTR_INVISIBLE) );
286 Bitmap aBitmap ( SVX_RES ( RID_SVXCTRL_LINECTRL ) );
288 ::Color aSourceColors[2];
289 ::Color aDestColors[2];
291 aSourceColors[0] = ::Color( COL_WHITE );
292 aSourceColors[1] = ::Color( COL_BLACK );
294 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
295 aDestColors[0] = rStyles.GetFieldColor();
296 aDestColors[1] = rStyles.GetFieldTextColor();
298 aBitmap.Replace ( aSourceColors, aDestColors, 2 );
299 Image aSolidLine ( aBitmap );
300 InsertEntry( SVX_RESSTR(RID_SVXSTR_SOLID), aSolidLine );
302 if ( !mpSh )
303 mpSh = SfxObjectShell::Current();
305 if( mpSh )
307 const SvxDashListItem* pItem = (const SvxDashListItem*)( mpSh->GetItem( SID_DASH_LIST ) );
308 if ( pItem )
309 Fill( pItem->GetDashList() );
312 // rBindings.Invalidate( SID_ATTR_LINE_DASH );
314 //========================================================================
315 // SvxColorBox
316 //========================================================================
318 SvxColorBox::SvxColorBox(
319 Window* pParent,
320 const ::rtl::OUString& rCommand,
321 const Reference< XFrame >& rFrame,
322 WinBits nBits ) :
323 ColorLB( pParent, nBits ),
324 nCurPos ( 0 ),
325 aLogicalSize(45,80),
326 bRelease ( TRUE ),
327 maCommand ( rCommand ),
328 mxFrame ( rFrame )
330 SetSizePixel( LogicToPixel( aLogicalSize , MAP_APPFONT));
331 Show();
333 SfxObjectShell* pSh = SfxObjectShell::Current();
335 if ( pSh )
337 const SvxColorTableItem* pItem =
338 (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) );
339 if(pItem)
340 Fill( pItem->GetColorTable() );
344 // -----------------------------------------------------------------------
346 IMPL_LINK( SvxColorBox, DelayHdl_Impl, Timer *, EMPTYARG )
348 SfxObjectShell* pSh = SfxObjectShell::Current();
350 if ( pSh )
352 const SvxColorTableItem* pItem = (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) );
353 if ( pItem )
354 Fill( pItem->GetColorTable() );
355 // rBindings.Invalidate( nId );
357 return 0;
360 // -----------------------------------------------------------------------
362 SvxColorBox::~SvxColorBox()
366 // -----------------------------------------------------------------------
368 void SvxColorBox::Update( const XLineColorItem* pItem )
370 if ( pItem )
371 SelectEntry( pItem->GetColorValue() );
372 else
373 SetNoSelection();
376 // -----------------------------------------------------------------------
378 void SvxColorBox::Select()
380 // OJ: base class call needed here because otherwise no event is send for accessibility
381 ColorLB::Select();
382 if ( !IsTravelSelect() )
384 XLineColorItem aLineColorItem( GetSelectEntry(), GetSelectEntryColor() );
386 INetURLObject aObj( maCommand );
388 Any a;
389 Sequence< PropertyValue > aArgs( 1 );
390 aArgs[0].Name = aObj.GetURLPath();
391 aLineColorItem.QueryValue( a );
392 aArgs[0].Value = a;
393 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
394 maCommand,
395 aArgs );
396 // rBindings.GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, &aLineColorItem, 0L );
398 nCurPos = GetSelectEntryPos();
399 ReleaseFocus_Impl();
403 // -----------------------------------------------------------------------
405 long SvxColorBox::PreNotify( NotifyEvent& rNEvt )
407 USHORT nType = rNEvt.GetType();
409 switch(nType)
411 case EVENT_MOUSEBUTTONDOWN:
412 case EVENT_GETFOCUS:
413 nCurPos = GetSelectEntryPos();
414 break;
415 case EVENT_LOSEFOCUS:
416 SelectEntryPos(nCurPos);
417 break;
418 case EVENT_KEYINPUT:
420 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
422 if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
424 bRelease = FALSE;
425 Select();
430 return ColorLB::PreNotify( rNEvt );
433 // -----------------------------------------------------------------------
435 long SvxColorBox::Notify( NotifyEvent& rNEvt )
437 long nHandled = ColorLB::Notify( rNEvt );
439 if ( rNEvt.GetType() == EVENT_KEYINPUT )
441 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
443 switch ( pKEvt->GetKeyCode().GetCode() )
445 case KEY_RETURN:
446 Select();
447 nHandled = 1;
448 break;
450 case KEY_ESCAPE:
451 SelectEntryPos( nCurPos );
452 ReleaseFocus_Impl();
453 nHandled = 1;
454 break;
457 return nHandled;
459 /* -----------------------------08.03.2002 15:35------------------------------
461 ---------------------------------------------------------------------------*/
462 void SvxColorBox::DataChanged( const DataChangedEvent& rDCEvt )
464 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
465 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
467 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
468 Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
469 SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
472 ColorLB::DataChanged( rDCEvt );
474 // -----------------------------------------------------------------------
476 void SvxColorBox::ReleaseFocus_Impl()
478 if(!bRelease)
480 bRelease = TRUE;
481 return;
484 if( SfxViewShell::Current() )
486 Window* pShellWnd = SfxViewShell::Current()->GetWindow();
488 if ( pShellWnd )
489 pShellWnd->GrabFocus();
493 //========================================================================
494 // SvxMetricField
495 //========================================================================
497 SvxMetricField::SvxMetricField(
498 Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
499 MetricField( pParent, nBits ),
500 aCurTxt( String() ),
501 mxFrame( rFrame )
503 Size aSize = Size(GetTextWidth( String::CreateFromAscii("99,99mm") ),GetTextHeight());
504 aSize.Width() += 20;
505 aSize.Height() += 6;
506 SetSizePixel( aSize );
507 aLogicalSize = PixelToLogic(aSize, MAP_APPFONT);
508 SetUnit( FUNIT_MM );
509 SetDecimalDigits( 2 );
510 SetMax( 5000 );
511 SetMin( 0 );
512 SetLast( 5000 );
513 SetFirst( 0 );
515 eDlgUnit = GetModuleFieldUnit( NULL );
516 SetFieldUnit( *this, eDlgUnit, FALSE );
517 Show();
520 // -----------------------------------------------------------------------
522 SvxMetricField::~SvxMetricField()
526 // -----------------------------------------------------------------------
528 void SvxMetricField::Update( const XLineWidthItem* pItem )
530 if ( pItem )
532 if ( pItem->GetValue() != GetCoreValue( *this, ePoolUnit ) )
533 SetMetricValue( *this, pItem->GetValue(), ePoolUnit );
535 else
536 SetText( String() );
539 // -----------------------------------------------------------------------
541 void SvxMetricField::Modify()
543 MetricField::Modify();
544 long nTmp = GetCoreValue( *this, ePoolUnit );
545 XLineWidthItem aLineWidthItem( nTmp );
547 Any a;
548 Sequence< PropertyValue > aArgs( 1 );
549 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" ));
550 aLineWidthItem.QueryValue( a );
551 aArgs[0].Value = a;
552 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
553 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineWidth" )),
554 aArgs );
555 // rBindings.GetDispatcher()->Execute( SID_ATTR_LINE_WIDTH, SFX_CALLMODE_RECORD, &aLineWidthItem, 0L );
558 // -----------------------------------------------------------------------
560 void SvxMetricField::ReleaseFocus_Impl()
562 if( SfxViewShell::Current() )
564 Window* pShellWnd = SfxViewShell::Current()->GetWindow();
565 if ( pShellWnd )
566 pShellWnd->GrabFocus();
570 // -----------------------------------------------------------------------
572 void SvxMetricField::Down()
574 sal_Int64 nValue = GetValue();
575 nValue -= GetSpinSize();
577 // Um unter OS/2 einen Sprung auf Max zu verhindern
578 if ( nValue >= GetMin() )
579 MetricField::Down();
582 // -----------------------------------------------------------------------
584 void SvxMetricField::Up()
586 MetricField::Up();
589 // -----------------------------------------------------------------------
591 void SvxMetricField::SetCoreUnit( SfxMapUnit eUnit )
593 ePoolUnit = eUnit;
596 // -----------------------------------------------------------------------
598 void SvxMetricField::RefreshDlgUnit()
600 FieldUnit eTmpUnit = GetModuleFieldUnit( NULL );
602 if ( eDlgUnit != eTmpUnit )
604 eDlgUnit = eTmpUnit;
605 SetFieldUnit( *this, eDlgUnit, FALSE );
609 // -----------------------------------------------------------------------
611 long SvxMetricField::PreNotify( NotifyEvent& rNEvt )
613 USHORT nType = rNEvt.GetType();
615 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
616 aCurTxt = GetText();
618 return MetricField::PreNotify( rNEvt );
621 // -----------------------------------------------------------------------
623 long SvxMetricField::Notify( NotifyEvent& rNEvt )
625 long nHandled = MetricField::Notify( rNEvt );
627 if ( rNEvt.GetType() == EVENT_KEYINPUT )
629 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
630 const KeyCode& rKey = pKEvt->GetKeyCode();
631 SfxViewShell* pSh = SfxViewShell::Current();
633 if ( rKey.GetModifier() && rKey.GetGroup() != KEYGROUP_CURSOR && pSh )
634 pSh->KeyInput( *pKEvt );
635 else
637 FASTBOOL bHandled = FALSE;
639 switch ( rKey.GetCode() )
641 case KEY_RETURN:
642 Reformat();
643 bHandled = TRUE;
644 break;
646 case KEY_ESCAPE:
647 SetText( aCurTxt );
648 bHandled = TRUE;
649 break;
652 if ( bHandled )
654 nHandled = 1;
655 Modify();
656 ReleaseFocus_Impl();
660 return nHandled;
662 /* -----------------------------08.03.2002 15:32------------------------------
664 ---------------------------------------------------------------------------*/
665 void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt )
667 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
668 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
670 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
673 MetricField::DataChanged( rDCEvt );
676 //========================================================================
677 // SvxFillTypeBox
678 //========================================================================
680 SvxFillTypeBox::SvxFillTypeBox( Window* pParent, WinBits nBits ) :
681 FillTypeLB( pParent, nBits | WB_TABSTOP ),
682 nCurPos ( 0 ),
683 bSelect ( FALSE ),
684 bRelease(TRUE)
686 SetSizePixel( LogicToPixel( Size(40, 40 ),MAP_APPFONT ));
687 Fill();
688 SelectEntryPos( XFILL_SOLID );
689 Show();
692 // -----------------------------------------------------------------------
694 SvxFillTypeBox::~SvxFillTypeBox()
698 // -----------------------------------------------------------------------
700 long SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt )
702 USHORT nType = rNEvt.GetType();
704 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
705 nCurPos = GetSelectEntryPos();
706 else if ( EVENT_LOSEFOCUS == nType
707 && Application::GetFocusWindow()
708 && !IsWindowOrChild( Application::GetFocusWindow(), TRUE ) )
710 if ( !bSelect )
711 SelectEntryPos( nCurPos );
712 else
713 bSelect = FALSE;
716 return FillTypeLB::PreNotify( rNEvt );
719 // -----------------------------------------------------------------------
721 long SvxFillTypeBox::Notify( NotifyEvent& rNEvt )
723 long nHandled = FillTypeLB::Notify( rNEvt );
725 if ( rNEvt.GetType() == EVENT_KEYINPUT )
727 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
728 switch ( pKEvt->GetKeyCode().GetCode() )
730 case KEY_RETURN:
731 nHandled = 1;
732 ( (Link&)GetSelectHdl() ).Call( this );
733 break;
734 case KEY_TAB:
735 bRelease = FALSE;
736 ( (Link&)GetSelectHdl() ).Call( this );
737 bRelease = TRUE;
738 break;
740 case KEY_ESCAPE:
741 SelectEntryPos( nCurPos );
742 ReleaseFocus_Impl();
743 nHandled = 1;
744 break;
747 return nHandled;
750 // -----------------------------------------------------------------------
752 void SvxFillTypeBox::ReleaseFocus_Impl()
754 if( SfxViewShell::Current() )
756 Window* pShellWnd = SfxViewShell::Current()->GetWindow();
758 if ( pShellWnd )
759 pShellWnd->GrabFocus();
763 //========================================================================
764 // SvxFillAttrBox
765 //========================================================================
767 SvxFillAttrBox::SvxFillAttrBox( Window* pParent, WinBits nBits ) :
769 FillAttrLB( pParent, nBits | WB_TABSTOP ),
771 nCurPos( 0 ),
772 bRelease( TRUE )
775 SetPosPixel( Point( 90, 0 ) );
776 SetSizePixel( LogicToPixel( Size(50, 80 ), MAP_APPFONT ));
777 Show();
780 // -----------------------------------------------------------------------
782 SvxFillAttrBox::~SvxFillAttrBox()
786 // -----------------------------------------------------------------------
788 long SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt )
790 USHORT nType = rNEvt.GetType();
792 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
793 nCurPos = GetSelectEntryPos();
795 return FillAttrLB::PreNotify( rNEvt );
798 // -----------------------------------------------------------------------
800 long SvxFillAttrBox::Notify( NotifyEvent& rNEvt )
802 long nHandled = FillAttrLB::Notify( rNEvt );
804 if ( rNEvt.GetType() == EVENT_KEYINPUT )
806 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
808 switch ( pKEvt->GetKeyCode().GetCode() )
810 case KEY_RETURN:
811 ( (Link&)GetSelectHdl() ).Call( this );
812 nHandled = 1;
813 break;
814 case KEY_TAB:
815 bRelease = FALSE;
816 GetSelectHdl().Call( this );
817 bRelease = TRUE;
818 break;
819 case KEY_ESCAPE:
820 SelectEntryPos( nCurPos );
821 ReleaseFocus_Impl();
822 nHandled = 1;
823 break;
826 return nHandled;
829 // -----------------------------------------------------------------------
831 void SvxFillAttrBox::Select()
833 FillAttrLB::Select();
836 // -----------------------------------------------------------------------
838 void SvxFillAttrBox::ReleaseFocus_Impl()
840 if( SfxViewShell::Current() )
842 Window* pShellWnd = SfxViewShell::Current()->GetWindow();
844 if ( pShellWnd )
845 pShellWnd->GrabFocus();