masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / options / radiobtnbox.cxx
blobb7ec9164c3d806ac6d94fd2270d8a035e31b3735
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
33 #include "radiobtnbox.hxx"
34 #include <dialmgr.hxx>
36 namespace svx {
38 // class SvxRadioButtonListBox ----------------------------------------------------
40 SvxRadioButtonListBox::SvxRadioButtonListBox( Window* _pParent, const ResId& _rId ) :
42 SvxSimpleTable( _pParent, _rId )
45 EnableCheckButton( new SvLBoxButtonData( this, true ) );
48 SvxRadioButtonListBox::~SvxRadioButtonListBox()
52 void SvxRadioButtonListBox::SetTabs()
54 SvxSimpleTable::SetTabs();
56 sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT | SV_LBOXTAB_ADJUST_LEFT |
57 SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_ADJUST_NUMERIC | SV_LBOXTAB_FORCE;
58 if ( aTabs.Count() > 0 )
60 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
61 pTab->nFlags &= ~nAdjust;
62 pTab->nFlags |= SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_FORCE;
67 void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent& _rMEvt )
69 m_aCurMousePoint = _rMEvt.GetPosPixel();
70 SvxSimpleTable::MouseButtonUp( _rMEvt );
73 void SvxRadioButtonListBox::KeyInput( const KeyEvent& rKEvt )
75 if ( !rKEvt.GetKeyCode().GetModifier() && KEY_SPACE == rKEvt.GetKeyCode().GetCode() )
77 SvLBoxEntry* pEntry = FirstSelected();
78 if ( GetCheckButtonState( pEntry ) == SV_BUTTON_UNCHECKED )
80 SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
81 GetCheckButtonHdl().Call( NULL );
82 return ;
86 SvxSimpleTable::KeyInput( rKEvt );
89 void SvxRadioButtonListBox::HandleEntryChecked( SvLBoxEntry* _pEntry )
91 Select( _pEntry, sal_True );
92 SvButtonState eState = GetCheckButtonState( _pEntry );
94 if ( SV_BUTTON_CHECKED == eState )
96 // we have radio button behavior -> so uncheck the other entries
97 SvLBoxEntry* pEntry = First();
98 while ( pEntry )
100 if ( pEntry != _pEntry )
101 SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
102 pEntry = Next( pEntry );
105 else
106 SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
109 const Point& SvxRadioButtonListBox::GetCurMousePoint() const
111 return m_aCurMousePoint;
114 } // end of namespace ::svx