1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "radiobtnbox.hxx"
21 #include <dialmgr.hxx>
23 #include "svtools/svlbitm.hxx"
27 // class SvxRadioButtonListBox ----------------------------------------------------
29 SvxRadioButtonListBox::SvxRadioButtonListBox(SvSimpleTableContainer
& rParent
, WinBits nBits
)
30 : SvSimpleTable(rParent
, nBits
)
33 EnableCheckButton( new SvLBoxButtonData( this, true ) );
36 void SvxRadioButtonListBox::SetTabs()
38 SvSimpleTable::SetTabs();
41 void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent
& _rMEvt
)
43 m_aCurMousePoint
= _rMEvt
.GetPosPixel();
44 SvSimpleTable::MouseButtonUp( _rMEvt
);
47 void SvxRadioButtonListBox::KeyInput( const KeyEvent
& rKEvt
)
49 if ( !rKEvt
.GetKeyCode().GetModifier() && KEY_SPACE
== rKEvt
.GetKeyCode().GetCode() )
51 SvTreeListEntry
* pEntry
= FirstSelected();
52 if ( GetCheckButtonState( pEntry
) == SV_BUTTON_UNCHECKED
)
54 SetCheckButtonState( pEntry
, SV_BUTTON_CHECKED
);
55 GetCheckButtonHdl().Call( NULL
);
60 SvSimpleTable::KeyInput( rKEvt
);
63 void SvxRadioButtonListBox::HandleEntryChecked( SvTreeListEntry
* _pEntry
)
65 Select( _pEntry
, true );
66 SvButtonState eState
= GetCheckButtonState( _pEntry
);
68 if ( SV_BUTTON_CHECKED
== eState
)
70 // we have radio button behavior -> so uncheck the other entries
71 SvTreeListEntry
* pEntry
= First();
74 if ( pEntry
!= _pEntry
)
75 SetCheckButtonState( pEntry
, SV_BUTTON_UNCHECKED
);
76 pEntry
= Next( pEntry
);
80 SetCheckButtonState( _pEntry
, SV_BUTTON_CHECKED
);
84 long SvxRadioButtonListBox::GetControlColumnWidth() const
86 return pCheckButtonData
->Width();
89 } // end of namespace ::svx
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */