xref: /trunk/main/cui/source/options/radiobtnbox.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 
31 // include ---------------------------------------------------------------
32 
33 #include "radiobtnbox.hxx"
34 #include <dialmgr.hxx>
35 
36 namespace svx {
37 
38 // class SvxRadioButtonListBox ----------------------------------------------------
39 
40 SvxRadioButtonListBox::SvxRadioButtonListBox( Window* _pParent, const ResId& _rId ) :
41 
42 	SvxSimpleTable( _pParent, _rId )
43 
44 {
45     EnableCheckButton( new SvLBoxButtonData( this, true ) );
46 }
47 
48 SvxRadioButtonListBox::~SvxRadioButtonListBox()
49 {
50 }
51 
52 void SvxRadioButtonListBox::SetTabs()
53 {
54 	SvxSimpleTable::SetTabs();
55 /*
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 )
59 	{
60 		SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
61 		pTab->nFlags &= ~nAdjust;
62 		pTab->nFlags |= SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_FORCE;
63 	}
64 */
65 }
66 
67 void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent& _rMEvt )
68 {
69 	m_aCurMousePoint = _rMEvt.GetPosPixel();
70 	SvxSimpleTable::MouseButtonUp( _rMEvt );
71 }
72 
73 void SvxRadioButtonListBox::KeyInput( const KeyEvent& rKEvt )
74 {
75     if ( !rKEvt.GetKeyCode().GetModifier() && KEY_SPACE == rKEvt.GetKeyCode().GetCode() )
76     {
77 		SvLBoxEntry* pEntry = FirstSelected();
78 		if ( GetCheckButtonState( pEntry ) == SV_BUTTON_UNCHECKED )
79 		{
80 			SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
81 			GetCheckButtonHdl().Call( NULL );
82 			return ;
83 		}
84     }
85 
86 	SvxSimpleTable::KeyInput( rKEvt );
87 }
88 
89 void SvxRadioButtonListBox::HandleEntryChecked( SvLBoxEntry* _pEntry )
90 {
91     Select( _pEntry, sal_True );
92     SvButtonState eState = GetCheckButtonState( _pEntry );
93 
94 	if ( SV_BUTTON_CHECKED == eState )
95 	{
96         // we have radio button behavior -> so uncheck the other entries
97         SvLBoxEntry* pEntry = First();
98 		while ( pEntry )
99 		{
100 			if ( pEntry != _pEntry )
101                 SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
102             pEntry = Next( pEntry );
103 		}
104 	}
105 	else
106         SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
107 }
108 
109 const Point& SvxRadioButtonListBox::GetCurMousePoint() const
110 {
111     return m_aCurMousePoint;
112 }
113 
114 } // end of namespace ::svx
115 
116