Update ooo320-m1
[ooovba.git] / svx / source / dialog / radiobtnbox.cxx
blobdd104311094a69613ad9fb565b9bf53b1bde6741
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: radiobtnbox.cxx,v $
10 * $Revision: 1.5 $
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"
35 #ifdef SVX_DLLIMPLEMENTATION
36 #undef SVX_DLLIMPLEMENTATION
37 #endif
40 // include ---------------------------------------------------------------
42 #include "radiobtnbox.hxx"
43 #include <svx/dialmgr.hxx>
45 namespace svx {
47 // class SvxRadioButtonListBox ----------------------------------------------------
49 SvxRadioButtonListBox::SvxRadioButtonListBox( Window* _pParent, const ResId& _rId ) :
51 SvxSimpleTable( _pParent, _rId )
54 EnableCheckButton( new SvLBoxButtonData( this, true ) );
57 SvxRadioButtonListBox::~SvxRadioButtonListBox()
61 void SvxRadioButtonListBox::SetTabs()
63 SvxSimpleTable::SetTabs();
65 USHORT nAdjust = SV_LBOXTAB_ADJUST_RIGHT | SV_LBOXTAB_ADJUST_LEFT |
66 SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_ADJUST_NUMERIC | SV_LBOXTAB_FORCE;
67 if ( aTabs.Count() > 0 )
69 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
70 pTab->nFlags &= ~nAdjust;
71 pTab->nFlags |= SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_FORCE;
76 void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent& _rMEvt )
78 m_aCurMousePoint = _rMEvt.GetPosPixel();
79 SvxSimpleTable::MouseButtonUp( _rMEvt );
82 void SvxRadioButtonListBox::KeyInput( const KeyEvent& rKEvt )
84 if ( !rKEvt.GetKeyCode().GetModifier() && KEY_SPACE == rKEvt.GetKeyCode().GetCode() )
86 SvLBoxEntry* pEntry = FirstSelected();
87 if ( GetCheckButtonState( pEntry ) == SV_BUTTON_UNCHECKED )
89 SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
90 GetCheckButtonHdl().Call( NULL );
91 return ;
95 SvxSimpleTable::KeyInput( rKEvt );
98 void SvxRadioButtonListBox::HandleEntryChecked( SvLBoxEntry* _pEntry )
100 Select( _pEntry, TRUE );
101 SvButtonState eState = GetCheckButtonState( _pEntry );
103 if ( SV_BUTTON_CHECKED == eState )
105 // we have radio button behavior -> so uncheck the other entries
106 SvLBoxEntry* pEntry = First();
107 while ( pEntry )
109 if ( pEntry != _pEntry )
110 SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
111 pEntry = Next( pEntry );
114 else
115 SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
118 const Point& SvxRadioButtonListBox::GetCurMousePoint() const
120 return m_aCurMousePoint;
123 } // end of namespace ::svx