Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "radiobtnbox.hxx"
21 : #include <dialmgr.hxx>
22 :
23 : #include "svtools/svlbitm.hxx"
24 :
25 : namespace svx {
26 :
27 : // class SvxRadioButtonListBox ----------------------------------------------------
28 :
29 0 : SvxRadioButtonListBox::SvxRadioButtonListBox(SvSimpleTableContainer& rParent, WinBits nBits)
30 0 : : SvSimpleTable(rParent, nBits)
31 :
32 : {
33 0 : EnableCheckButton( new SvLBoxButtonData( this, true ) );
34 0 : }
35 :
36 0 : void SvxRadioButtonListBox::SetTabs()
37 : {
38 0 : SvSimpleTable::SetTabs();
39 0 : }
40 :
41 0 : void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent& _rMEvt )
42 : {
43 0 : m_aCurMousePoint = _rMEvt.GetPosPixel();
44 0 : SvSimpleTable::MouseButtonUp( _rMEvt );
45 0 : }
46 :
47 0 : void SvxRadioButtonListBox::KeyInput( const KeyEvent& rKEvt )
48 : {
49 0 : if ( !rKEvt.GetKeyCode().GetModifier() && KEY_SPACE == rKEvt.GetKeyCode().GetCode() )
50 : {
51 0 : SvTreeListEntry* pEntry = FirstSelected();
52 0 : if ( GetCheckButtonState( pEntry ) == SV_BUTTON_UNCHECKED )
53 : {
54 0 : SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
55 0 : GetCheckButtonHdl().Call( NULL );
56 0 : return ;
57 : }
58 : }
59 :
60 0 : SvSimpleTable::KeyInput( rKEvt );
61 : }
62 :
63 0 : void SvxRadioButtonListBox::HandleEntryChecked( SvTreeListEntry* _pEntry )
64 : {
65 0 : Select( _pEntry, true );
66 0 : SvButtonState eState = GetCheckButtonState( _pEntry );
67 :
68 0 : if ( SV_BUTTON_CHECKED == eState )
69 : {
70 : // we have radio button behavior -> so uncheck the other entries
71 0 : SvTreeListEntry* pEntry = First();
72 0 : while ( pEntry )
73 : {
74 0 : if ( pEntry != _pEntry )
75 0 : SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
76 0 : pEntry = Next( pEntry );
77 : }
78 : }
79 : else
80 0 : SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
81 0 : }
82 :
83 :
84 0 : long SvxRadioButtonListBox::GetControlColumnWidth() const
85 : {
86 0 : return pCheckButtonData->Width();
87 : }
88 :
89 0 : } // end of namespace ::svx
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|