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