Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / options / radiobtnbox.cxx
blob599b573c9835cc1b703d586baf9b47170ea74aab
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 "radiobtnbox.hxx"
21 #include <dialmgr.hxx>
23 #include "svtools/svlbitm.hxx"
25 namespace svx {
27 // class SvxRadioButtonListBox ----------------------------------------------------
29 SvxRadioButtonListBox::SvxRadioButtonListBox(SvxSimpleTableContainer& rParent, WinBits nBits)
30 : SvxSimpleTable(rParent, nBits)
33 EnableCheckButton( new SvLBoxButtonData( this, true ) );
36 SvxRadioButtonListBox::~SvxRadioButtonListBox()
40 void SvxRadioButtonListBox::SetTabs()
42 SvxSimpleTable::SetTabs();
45 void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent& _rMEvt )
47 m_aCurMousePoint = _rMEvt.GetPosPixel();
48 SvxSimpleTable::MouseButtonUp( _rMEvt );
51 void SvxRadioButtonListBox::KeyInput( const KeyEvent& rKEvt )
53 if ( !rKEvt.GetKeyCode().GetModifier() && KEY_SPACE == rKEvt.GetKeyCode().GetCode() )
55 SvTreeListEntry* pEntry = FirstSelected();
56 if ( GetCheckButtonState( pEntry ) == SV_BUTTON_UNCHECKED )
58 SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
59 GetCheckButtonHdl().Call( NULL );
60 return ;
64 SvxSimpleTable::KeyInput( rKEvt );
67 void SvxRadioButtonListBox::HandleEntryChecked( SvTreeListEntry* _pEntry )
69 Select( _pEntry, sal_True );
70 SvButtonState eState = GetCheckButtonState( _pEntry );
72 if ( SV_BUTTON_CHECKED == eState )
74 // we have radio button behavior -> so uncheck the other entries
75 SvTreeListEntry* pEntry = First();
76 while ( pEntry )
78 if ( pEntry != _pEntry )
79 SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
80 pEntry = Next( pEntry );
83 else
84 SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
87 const Point& SvxRadioButtonListBox::GetCurMousePoint() const
89 return m_aCurMousePoint;
92 } // end of namespace ::svx
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */