xref: /trunk/main/cui/source/options/radiobtnbox.cxx (revision 2ee96f1c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26 
27 // include ---------------------------------------------------------------
28 
29 #include "radiobtnbox.hxx"
30 #include <dialmgr.hxx>
31 
32 namespace svx {
33 
34 // class SvxRadioButtonListBox ----------------------------------------------------
35 
SvxRadioButtonListBox(Window * _pParent,const ResId & _rId)36 SvxRadioButtonListBox::SvxRadioButtonListBox( Window* _pParent, const ResId& _rId ) :
37 
38 	SvxSimpleTable( _pParent, _rId )
39 
40 {
41     EnableCheckButton( new SvLBoxButtonData( this, true ) );
42 }
43 
~SvxRadioButtonListBox()44 SvxRadioButtonListBox::~SvxRadioButtonListBox()
45 {
46 }
47 
SetTabs()48 void SvxRadioButtonListBox::SetTabs()
49 {
50 	SvxSimpleTable::SetTabs();
51 /*
52 	sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT | SV_LBOXTAB_ADJUST_LEFT |
53 					 SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_ADJUST_NUMERIC | SV_LBOXTAB_FORCE;
54 	if ( aTabs.Count() > 0 )
55 	{
56 		SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
57 		pTab->nFlags &= ~nAdjust;
58 		pTab->nFlags |= SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_FORCE;
59 	}
60 */
61 }
62 
MouseButtonUp(const MouseEvent & _rMEvt)63 void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent& _rMEvt )
64 {
65 	m_aCurMousePoint = _rMEvt.GetPosPixel();
66 	SvxSimpleTable::MouseButtonUp( _rMEvt );
67 }
68 
KeyInput(const KeyEvent & rKEvt)69 void SvxRadioButtonListBox::KeyInput( const KeyEvent& rKEvt )
70 {
71     if ( !rKEvt.GetKeyCode().GetModifier() && KEY_SPACE == rKEvt.GetKeyCode().GetCode() )
72     {
73 		SvLBoxEntry* pEntry = FirstSelected();
74 		if ( GetCheckButtonState( pEntry ) == SV_BUTTON_UNCHECKED )
75 		{
76 			SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
77 			GetCheckButtonHdl().Call( NULL );
78 			return ;
79 		}
80     }
81 
82 	SvxSimpleTable::KeyInput( rKEvt );
83 }
84 
HandleEntryChecked(SvLBoxEntry * _pEntry)85 void SvxRadioButtonListBox::HandleEntryChecked( SvLBoxEntry* _pEntry )
86 {
87     Select( _pEntry, sal_True );
88     SvButtonState eState = GetCheckButtonState( _pEntry );
89 
90 	if ( SV_BUTTON_CHECKED == eState )
91 	{
92         // we have radio button behavior -> so uncheck the other entries
93         SvLBoxEntry* pEntry = First();
94 		while ( pEntry )
95 		{
96 			if ( pEntry != _pEntry )
97                 SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
98             pEntry = Next( pEntry );
99 		}
100 	}
101 	else
102         SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
103 }
104 
GetCurMousePoint() const105 const Point& SvxRadioButtonListBox::GetCurMousePoint() const
106 {
107     return m_aCurMousePoint;
108 }
109 
110 } // end of namespace ::svx
111 
112