fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / formula / source / ui / dlg / funcutl.cxx
blob01fc78b45d926e03ca40f7abe97ba6be56d2d4a0
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 .
20 #include <vcl/builder.hxx>
21 #include <vcl/svapp.hxx>
22 #include <vcl/scrbar.hxx>
24 #include "formula/funcutl.hxx"
25 #include "formula/IControlReferenceHandler.hxx"
26 #include "ControlHelper.hxx"
27 #include "ModuleHelper.hxx"
28 #include "ForResId.hrc"
31 namespace formula
33 //============================================================================
34 // class ValWnd
35 //----------------------------------------------------------------------------
37 ValWnd::ValWnd( Window* pParent, const ResId& rId ) : Window( pParent, rId )
39 Font aFnt( GetFont() );
40 aFnt.SetTransparent( sal_True );
41 aFnt.SetWeight( WEIGHT_LIGHT );
42 if ( pParent->IsBackground() )
44 Wallpaper aBack = pParent->GetBackground();
45 SetFillColor( aBack.GetColor() );
46 SetBackground( aBack );
47 aFnt.SetFillColor( aBack.GetColor() );
49 else
51 SetFillColor();
52 SetBackground();
54 SetFont( aFnt );
55 SetLineColor();
57 Size aSzWnd = GetOutputSizePixel();
58 long nHeight = GetTextHeight();
59 long nDiff = aSzWnd.Height()-nHeight;
61 aRectOut = Rectangle( Point( 1, ( nDiff<2 ) ? 1 : nDiff/2),
62 Size ( aSzWnd.Width()-2, nHeight ) );
63 SetClipRegion( Region( aRectOut ) );
66 //----------------------------------------------------------------------------
68 void ValWnd::Paint( const Rectangle& )
70 DrawText( aRectOut.TopLeft(), aStrValue );
73 //----------------------------------------------------------------------------
75 void ValWnd::SetValue( const String& rStrVal )
77 if ( aStrValue != rStrVal )
79 aStrValue = rStrVal;
80 DrawRect( aRectOut ); // alten Text loeschen
81 Paint( aRectOut ); // and neu malen
85 //============================================================================
86 // class ArgEdit
87 //----------------------------------------------------------------------------
89 ArgEdit::ArgEdit( Window* pParent, const ResId& rResId )
90 : RefEdit( pParent, NULL, NULL, rResId ),
91 pEdPrev ( NULL ),
92 pEdNext ( NULL ),
93 pSlider ( NULL ),
94 nArgs ( 0 )
98 //----------------------------------------------------------------------------
100 void ArgEdit::Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit,
101 ScrollBar& rArgSlider, sal_uInt16 nArgCount )
103 pEdPrev = pPrevEdit;
104 pEdNext = pNextEdit;
105 pSlider = &rArgSlider;
106 nArgs = nArgCount;
109 //----------------------------------------------------------------------------
111 // Cursor control for Edit Fields in Argument Dialog
113 void ArgEdit::KeyInput( const KeyEvent& rKEvt )
115 KeyCode aCode = rKEvt.GetKeyCode();
116 sal_Bool bUp = (aCode.GetCode() == KEY_UP);
117 sal_Bool bDown = (aCode.GetCode() == KEY_DOWN);
119 if ( pSlider
120 && ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
121 && ( bUp || bDown ) )
123 if ( nArgs > 1 )
125 ArgEdit* pEd = NULL;
126 long nThumb = pSlider->GetThumbPos();
127 sal_Bool bDoScroll = sal_False;
128 sal_Bool bChangeFocus = sal_False;
130 if ( bDown )
132 if ( nArgs > 4 )
134 if ( !pEdNext )
136 nThumb++;
137 bDoScroll = ( nThumb+3 < (long)nArgs );
139 else
141 pEd = pEdNext;
142 bChangeFocus = sal_True;
145 else if ( pEdNext )
147 pEd = pEdNext;
148 bChangeFocus = sal_True;
151 else // if ( bUp )
153 if ( nArgs > 4 )
155 if ( !pEdPrev )
157 nThumb--;
158 bDoScroll = ( nThumb >= 0 );
160 else
162 pEd = pEdPrev;
163 bChangeFocus = sal_True;
166 else if ( pEdPrev )
168 pEd = pEdPrev;
169 bChangeFocus = sal_True;
173 if ( bDoScroll )
175 pSlider->SetThumbPos( nThumb );
176 ((Link&)pSlider->GetEndScrollHdl()).Call( pSlider );
178 else if ( bChangeFocus )
180 pEd->GrabFocus();
184 else
185 RefEdit::KeyInput( rKEvt );
191 /*************************************************************************
192 #* Member: ArgInput Date:13.01.97
193 #*------------------------------------------------------------------------
195 #* Class: ArgInput
197 #* Function: ArgInput class constructor
199 #* Input: ---
201 #* Output: ---
203 #************************************************************************/
205 ArgInput::ArgInput()
207 pFtArg=NULL;
208 pBtnFx=NULL;
209 pEdArg=NULL;
210 pRefBtn=NULL;
213 /*************************************************************************
214 #* Member: InitArgInput Date:13.01.97
215 #*------------------------------------------------------------------------
217 #* Class: ArgInput
219 #* Function: Initializes the class' Pointer
221 #* Input: ---
223 #* Output: ---
225 #************************************************************************/
227 void ArgInput::InitArgInput(FixedText* pftArg,
228 ImageButton* pbtnFx,
229 ArgEdit* pedArg,
230 RefButton* prefBtn)
232 pFtArg =pftArg;
233 pBtnFx =pbtnFx;
234 pEdArg =pedArg;
235 pRefBtn=prefBtn;
237 if(pBtnFx!=NULL)
239 pBtnFx->SetClickHdl ( LINK( this, ArgInput, FxBtnClickHdl ) );
240 pBtnFx->SetGetFocusHdl( LINK( this, ArgInput, FxBtnFocusHdl ) );
242 if(pRefBtn!=NULL)
244 pRefBtn->SetClickHdl ( LINK( this, ArgInput, RefBtnClickHdl ) );
245 pRefBtn->SetGetFocusHdl( LINK( this, ArgInput, RefBtnFocusHdl ) );
247 if(pEdArg!=NULL)
249 pEdArg->SetGetFocusHdl ( LINK( this, ArgInput, EdFocusHdl ) );
250 pEdArg->SetModifyHdl ( LINK( this, ArgInput, EdModifyHdl ) );
255 /*************************************************************************
256 #* Member: SetArgName Date:13.01.97
257 #*------------------------------------------------------------------------
259 #* Class: ArgInput
261 #* Function: Sets the Name for the Argument
263 #* Input: String
265 #* Output: ---
267 #************************************************************************/
268 void ArgInput::SetArgName(const String &aArg)
270 if(pFtArg !=NULL) pFtArg->SetText(aArg );
273 /*************************************************************************
274 #* Member: GetArgName Date:06.02.97
275 #*------------------------------------------------------------------------
277 #* Class: ArgInput
279 #* Function: Returns the Name for the Argument
281 #* Input: String
283 #* Output: ---
285 #************************************************************************/
286 String ArgInput::GetArgName()
288 String aPrivArgName;
289 if(pFtArg !=NULL)
290 aPrivArgName=pFtArg->GetText();
292 return aPrivArgName;
295 /*************************************************************************
296 #* Member: SetArgName Date:13.01.97
297 #*------------------------------------------------------------------------
299 #* Class: ArgInput
301 #* Function: Sets the Name for the Argument
303 #* Input: String
305 #* Output: ---
307 #************************************************************************/
308 void ArgInput::SetArgNameFont (const Font &aFont)
310 if(pFtArg !=NULL) pFtArg->SetFont(aFont);
313 /*************************************************************************
314 #* Member: SetArgSelection Date:13.01.97
315 #*------------------------------------------------------------------------
317 #* Class: ArgInput
319 #* Function: Sets up the Selection for the EditBox.
321 #* Input: String
323 #* Output: ---
325 #************************************************************************/
326 void ArgInput::SetArgSelection (const Selection& rSel )
328 if(pEdArg !=NULL) pEdArg ->SetSelection(rSel );
332 /*************************************************************************
333 #* Member: SetArgVal Date:13.01.97
334 #*------------------------------------------------------------------------
336 #* Class: ArgInput
338 #* Function: Sets the Value for the Argument
340 #* Input: String
342 #* Output: ---
344 #************************************************************************/
345 void ArgInput::SetArgVal(const String &aVal)
347 if(pEdArg !=NULL)
349 pEdArg ->SetRefString(aVal );
353 /*************************************************************************
354 #* Member: SetArgName Date:13.01.97
355 #*------------------------------------------------------------------------
357 #* Class: ArgInput
359 #* Function: Returns the Value for the Argument
361 #* Input: ---
363 #* Output: String
365 #************************************************************************/
366 String ArgInput::GetArgVal()
368 String aResult;
369 if(pEdArg!=NULL)
371 aResult=pEdArg->GetText();
373 return aResult;
376 /*************************************************************************
377 #* Member: SetArgName Date:13.01.97
378 #*------------------------------------------------------------------------
380 #* Class: ArgInput
382 #* Function: Hides the Controls
384 #* Input: ---
386 #* Output: ---
388 #************************************************************************/
389 void ArgInput::Hide()
391 if ( pFtArg && pBtnFx && pEdArg && pRefBtn)
393 pFtArg->Hide();
394 pBtnFx->Hide();
395 pEdArg->Hide();
396 pRefBtn->Hide();
400 /*************************************************************************
401 #* Member: SetArgName Date:13.01.97
402 #*------------------------------------------------------------------------
404 #* Class: ArgInput
406 #* Function: Casts the Controls again.
408 #* Input: ---
410 #* Output: ---
412 #************************************************************************/
413 void ArgInput::Show()
415 if ( pFtArg && pBtnFx && pEdArg && pRefBtn)
417 pFtArg->Show();
418 pBtnFx->Show();
419 pEdArg->Show();
420 pRefBtn->Show();
424 /*************************************************************************
425 #* Member: FxClick Date:13.01.97
426 #*------------------------------------------------------------------------
428 #* Class: ArgInput
430 #* Function: Forwards the Event.
432 #* Input: ---
434 #* Output: ---
436 #************************************************************************/
437 void ArgInput::FxClick()
439 aFxClickLink.Call(this);
442 /*************************************************************************
443 #* Member: RefClick Date:13.01.97
444 #*------------------------------------------------------------------------
446 #* Class: ArgInput
448 #* Function: Forwards the Event.
450 #* Input: ---
452 #* Output: ---
454 #************************************************************************/
455 void ArgInput::RefClick()
457 aRefClickLink.Call(this);
460 /*************************************************************************
461 #* Member: FxFocus Date:13.01.97
462 #*------------------------------------------------------------------------
464 #* Class: ArgInput
466 #* Function: Forwards the Event.
468 #* Input: ---
470 #* Output: ---
472 #************************************************************************/
473 void ArgInput::FxFocus()
475 aFxFocusLink.Call(this);
478 /*************************************************************************
479 #* Member: RefFocus Date:13.01.97
480 #*------------------------------------------------------------------------
482 #* Class: ArgInput
484 #* Function: Forwards the Event.
486 #* Input: ---
488 #* Output: ---
490 #************************************************************************/
491 void ArgInput::RefFocus()
493 aRefFocusLink.Call(this);
496 /*************************************************************************
497 #* Member: EdFocus Date:13.01.97
498 #*------------------------------------------------------------------------
500 #* Class: ArgInput
502 #* Function: Forwards the Event.
504 #* Input: ---
506 #* Output: ---
508 #************************************************************************/
509 void ArgInput::EdFocus()
511 aEdFocusLink.Call(this);
514 /*************************************************************************
515 #* Member: EdModify Date:13.01.97
516 #*------------------------------------------------------------------------
518 #* Class: ArgInput
520 #* Function: Forwards the Event.
522 #* Input: ---
524 #* Output: ---
526 #************************************************************************/
527 void ArgInput::EdModify()
529 aEdModifyLink.Call(this);
532 /*************************************************************************
533 #* Handle: FxBtnHdl Date:13.01.97
534 #*------------------------------------------------------------------------
536 #* Class: ArgInput
538 #* Function: Handle for Fx-Button Click-Event.
540 #* Input: ---
542 #* Output: ---
544 #************************************************************************/
545 IMPL_LINK( ArgInput, FxBtnClickHdl, ImageButton*, pBtn )
547 if(pBtn==pBtnFx) FxClick();
549 return 0;
552 /*************************************************************************
553 #* Handle: RefBtnClickHdl Date:13.01.97
554 #*------------------------------------------------------------------------
556 #* Class: ArgInput
558 #* Function: Handle for Fx-Button Click-Event.
560 #* Input: ---
562 #* Output: ---
564 #************************************************************************/
565 IMPL_LINK( ArgInput, RefBtnClickHdl,RefButton*, pBtn )
567 if(pRefBtn==pBtn) RefClick();
569 return 0;
572 /*************************************************************************
573 #* Handle: FxBtnFocusHdl Date:13.01.97
574 #*------------------------------------------------------------------------
576 #* Class: ArgInput
578 #* Function: Handle for Fx-Button Focus-Event.
580 #* Input: ---
582 #* Output: ---
584 #************************************************************************/
585 IMPL_LINK( ArgInput, FxBtnFocusHdl, ImageButton*, pBtn )
587 if(pBtn==pBtnFx) FxFocus();
589 return 0;
592 /*************************************************************************
593 #* Handle: RefBtnFocusHdl Date:13.01.97
594 #*------------------------------------------------------------------------
596 #* Class: ArgInput
598 #* Function: Handle for Fx-Button Focus-Event.
600 #* Input: ---
602 #* Output: ---
604 #************************************************************************/
605 IMPL_LINK( ArgInput, RefBtnFocusHdl,RefButton*, pBtn )
607 if(pRefBtn==pBtn) RefFocus();
609 return 0;
612 /*************************************************************************
613 #* Handle: EdFocusHdl Date:13.01.97
614 #*------------------------------------------------------------------------
616 #* Class: ArgInput
618 #* Function: Handle for Fx-Button Focus-Event.
620 #* Input: ---
622 #* Output: ---
624 #************************************************************************/
625 IMPL_LINK( ArgInput, EdFocusHdl, ArgEdit*, pEd )
627 if(pEd==pEdArg) EdFocus();
629 return 0;
632 /*************************************************************************
633 #* Handle: RefBtnClickHdl Date:13.01.97
634 #*------------------------------------------------------------------------
636 #* Class: ArgInput
638 #* Function: Handle for Fx-Button Focus-Event.
640 #* Input: ---
642 #* Output: ---
644 #************************************************************************/
645 IMPL_LINK( ArgInput, EdModifyHdl,ArgEdit*, pEd )
647 if(pEd==pEdArg) EdModify();
649 return 0;
652 /*************************************************************************
653 #* Member: EditBox Date:20.01.97
654 #*------------------------------------------------------------------------
656 #* Class: EditBox
658 #* Function: Constructor from Class ArgInput
660 #* Input: Parent, Resource
662 #* Output: ---
664 #************************************************************************/
665 EditBox::EditBox( Window* pParent, const ResId& rResId )
666 :Control(pParent,rResId),
667 bMouseFlag(sal_False)
669 WinBits nStyle=GetStyle();
670 SetStyle( nStyle| WB_DIALOGCONTROL);
672 pMEdit=new MultiLineEdit(this,WB_LEFT | WB_VSCROLL | (nStyle & WB_TABSTOP) |
673 WB_NOBORDER | WB_NOHIDESELECTION | WB_IGNORETAB);
674 pMEdit->Show();
675 aOldSel=pMEdit->GetSelection();
676 Resize();
677 WinBits nWinStyle=GetStyle() | WB_DIALOGCONTROL;
678 SetStyle(nWinStyle);
680 // #105582# the HelpId from the resource must be set for the MultiLineEdit,
681 // not for the control that contains it.
682 pMEdit->SetHelpId( GetHelpId() );
683 SetHelpId( "" );
686 EditBox::~EditBox()
688 MultiLineEdit* pTheEdit=pMEdit;
689 pMEdit->Disable();
690 pMEdit=NULL;
691 delete pTheEdit;
693 /*************************************************************************
694 #* Member: EditBox Date:20.01.97
695 #*------------------------------------------------------------------------
697 #* Class: EditBox
699 #* Function: When the seleccion is changed this function will be called
701 #* Input: ---
703 #* Output: ---
705 #************************************************************************/
706 void EditBox::SelectionChanged()
708 aSelChangedLink.Call(this);
711 /*************************************************************************
712 #* Member: EditBox Date:20.05.98
713 #*------------------------------------------------------------------------
715 #* Class: EditBox
717 #* Function: When the size is changed, MultiLineEdit must
718 #* be adapted..
720 #* Input: ---
722 #* Output: ---
724 #************************************************************************/
725 void EditBox::Resize()
727 Size aSize=GetOutputSizePixel();
728 if(pMEdit!=NULL) pMEdit->SetOutputSizePixel(aSize);
731 /*************************************************************************
732 #* Member: GetFocus Date:26.05.98
733 #*------------------------------------------------------------------------
735 #* Class: EditBox
737 #* Function: When the Control is activated,
738 #* the Selection is repealed and the Cursor set
739 #* at the end.
741 #* Input: ---
743 #* Output: ---
745 #************************************************************************/
746 void EditBox::GetFocus()
748 if(pMEdit!=NULL)
750 pMEdit->GrabFocus();
756 /*************************************************************************
757 #* Member: EditBox Date:20.01.97
758 #*------------------------------------------------------------------------
760 #* Class: EditBox
762 #* Function: When an Event is cleared, this Routine is
763 #* first called and a PostUserEvent is sent.
765 #* Input: Notify-Event
767 #* Output: ---
769 #************************************************************************/
770 long EditBox::PreNotify( NotifyEvent& rNEvt )
772 long nResult=sal_True;
774 if(pMEdit==NULL) return nResult;
776 sal_uInt16 nSwitch=rNEvt.GetType();
777 if(nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP)
779 const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
780 sal_uInt16 nKey=aKeyCode.GetCode();
781 if( (nKey==KEY_RETURN && !aKeyCode.IsShift()) || nKey==KEY_TAB )
783 nResult=GetParent()->Notify(rNEvt);
785 else
787 nResult=Control::PreNotify(rNEvt);
788 Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ) );
792 else
794 nResult=Control::PreNotify(rNEvt);
796 if(nSwitch==EVENT_MOUSEBUTTONDOWN || nSwitch==EVENT_MOUSEBUTTONUP)
798 bMouseFlag=sal_True;
799 Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ) );
802 return nResult;
805 /*************************************************************************
806 #* Member: EditBox Date:21.01.97
807 #*------------------------------------------------------------------------
809 #* Class: EditBox
811 #* Function: When an Event cleared wurde, this routine is
812 #* first called.
814 #* Input: Key-Event
816 #* Output: ---
818 #************************************************************************/
819 IMPL_LINK_NOARG(EditBox, ChangedHdl)
821 if(pMEdit!=NULL)
823 Selection aNewSel=pMEdit->GetSelection();
825 if(aNewSel.Min()!=aOldSel.Min() || aNewSel.Max()!=aOldSel.Max())
827 SelectionChanged();
828 aOldSel=aNewSel;
831 return 0;
834 void EditBox::UpdateOldSel()
836 // if selection is set for editing a function, store it as aOldSel,
837 // so SelectionChanged isn't called in the next ChangedHdl call
839 if (pMEdit)
840 aOldSel = pMEdit->GetSelection();
842 //----------------------------------------------------------------------------
844 //============================================================================
845 // class RefEdit
846 //----------------------------------------------------------------------------
848 #define SC_ENABLE_TIME 100
850 RefEdit::RefEdit( Window* _pParent,IControlReferenceHandler* pParent,
851 Window* pShrinkModeLabel, const ResId& rResId )
852 : Edit( _pParent, rResId )
853 , pAnyRefDlg( pParent )
854 , pLabelWidget(pShrinkModeLabel)
856 aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
857 aTimer.SetTimeout( SC_ENABLE_TIME );
860 RefEdit::RefEdit( Window* _pParent, Window* pShrinkModeLabel, WinBits nStyle )
861 : Edit( _pParent, nStyle )
862 , pAnyRefDlg( NULL )
863 , pLabelWidget(pShrinkModeLabel)
865 aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
866 aTimer.SetTimeout( SC_ENABLE_TIME );
869 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeRefEdit(Window *pParent, VclBuilder::stringmap &)
871 return new RefEdit(pParent, NULL, WB_BORDER);
874 RefEdit::~RefEdit()
876 aTimer.SetTimeoutHdl( Link() );
877 aTimer.Stop();
880 void RefEdit::SetRefString( const XubString& rStr )
882 Edit::SetText( rStr );
885 void RefEdit::SetRefValid(bool bValid)
887 if (bValid)
889 SetControlForeground();
890 SetControlBackground();
892 else
894 SetControlForeground(COL_WHITE);
895 SetControlBackground(0xff6563);
899 void RefEdit::SetText( const XubString& rStr )
901 Edit::SetText( rStr );
902 UpdateHdl( &aTimer );
905 void RefEdit::StartUpdateData()
907 aTimer.Start();
910 void RefEdit::SetReferences( IControlReferenceHandler* pDlg, Window* pLabel )
912 pAnyRefDlg = pDlg;
913 pLabelWidget = pLabel;
915 if( pDlg )
917 aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
918 aTimer.SetTimeout( SC_ENABLE_TIME );
920 else
922 aTimer.SetTimeoutHdl( Link() );
923 aTimer.Stop();
927 void RefEdit::Modify()
929 Edit::Modify();
930 if( pAnyRefDlg )
931 pAnyRefDlg->HideReference();
934 void RefEdit::KeyInput( const KeyEvent& rKEvt )
936 const KeyCode& rKeyCode = rKEvt.GetKeyCode();
937 if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
938 pAnyRefDlg->ReleaseFocus( this );
939 else
940 Edit::KeyInput( rKEvt );
943 void RefEdit::GetFocus()
945 Edit::GetFocus();
946 StartUpdateData();
949 void RefEdit::LoseFocus()
951 Edit::LoseFocus();
952 if( pAnyRefDlg )
953 pAnyRefDlg->HideReference();
956 IMPL_LINK_NOARG(RefEdit, UpdateHdl)
958 if( pAnyRefDlg )
959 pAnyRefDlg->ShowReference( GetText() );
960 return 0;
964 //============================================================================
965 // class RefButton
966 //----------------------------------------------------------------------------
967 RefButton::RefButton( Window* _pParent, const ResId& rResId) :
968 ImageButton( _pParent, rResId ),
969 aImgRefStart( ModuleRes( RID_BMP_REFBTN1 ) ),
970 aImgRefDone( ModuleRes( RID_BMP_REFBTN2 ) ),
971 aShrinkQuickHelp( ModuleRes( RID_STR_SHRINK ).toString() ),
972 aExpandQuickHelp( ModuleRes( RID_STR_EXPAND ).toString() ),
973 pAnyRefDlg( NULL ),
974 pRefEdit( NULL )
976 SetStartImage();
979 RefButton::RefButton( Window* _pParent, WinBits nStyle ) :
980 ImageButton( _pParent, nStyle ),
981 aImgRefStart( ModuleRes( RID_BMP_REFBTN1 ) ),
982 aImgRefDone( ModuleRes( RID_BMP_REFBTN2 ) ),
983 aShrinkQuickHelp( ModuleRes( RID_STR_SHRINK ).toString() ),
984 aExpandQuickHelp( ModuleRes( RID_STR_EXPAND ).toString() ),
985 pAnyRefDlg( NULL ),
986 pRefEdit( NULL )
988 SetStartImage();
991 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeRefButton(Window *pParent, VclBuilder::stringmap &)
993 return new RefButton(pParent, 0);
996 RefButton::RefButton( Window* _pParent, const ResId& rResId, RefEdit* pEdit, IControlReferenceHandler* _pDlg ) :
997 ImageButton( _pParent, rResId ),
998 aImgRefStart( ModuleRes( RID_BMP_REFBTN1 ) ),
999 aImgRefDone( ModuleRes( RID_BMP_REFBTN2 ) ),
1000 aShrinkQuickHelp( ModuleRes( RID_STR_SHRINK ).toString() ),
1001 aExpandQuickHelp( ModuleRes( RID_STR_EXPAND ).toString() ),
1002 pAnyRefDlg( _pDlg ),
1003 pRefEdit( pEdit )
1005 SetStartImage();
1008 void RefButton::SetStartImage()
1010 SetModeImage( aImgRefStart );
1011 SetQuickHelpText( aShrinkQuickHelp );
1014 void RefButton::SetEndImage()
1016 SetModeImage( aImgRefDone );
1017 SetQuickHelpText( aExpandQuickHelp );
1020 void RefButton::SetReferences( IControlReferenceHandler* pDlg, RefEdit* pEdit )
1022 pAnyRefDlg = pDlg;
1023 pRefEdit = pEdit;
1026 //----------------------------------------------------------------------------
1028 void RefButton::Click()
1030 if( pAnyRefDlg )
1031 pAnyRefDlg->ToggleCollapsed( pRefEdit, this );
1034 void RefButton::KeyInput( const KeyEvent& rKEvt )
1036 const KeyCode& rKeyCode = rKEvt.GetKeyCode();
1037 if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
1038 pAnyRefDlg->ReleaseFocus( pRefEdit );
1039 else
1040 ImageButton::KeyInput( rKEvt );
1043 void RefButton::GetFocus()
1045 ImageButton::GetFocus();
1046 if( pRefEdit )
1047 pRefEdit->StartUpdateData();
1050 void RefButton::LoseFocus()
1052 ImageButton::LoseFocus();
1053 if( pRefEdit )
1054 pRefEdit->Modify();
1058 } // formula
1060 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */