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 : SvxRadioButtonListBox::~SvxRadioButtonListBox()
37 : {
38 0 : }
39 :
40 0 : void SvxRadioButtonListBox::SetTabs()
41 : {
42 0 : SvSimpleTable::SetTabs();
43 0 : }
44 :
45 0 : void SvxRadioButtonListBox::MouseButtonUp( const MouseEvent& _rMEvt )
46 : {
47 0 : m_aCurMousePoint = _rMEvt.GetPosPixel();
48 0 : SvSimpleTable::MouseButtonUp( _rMEvt );
49 0 : }
50 :
51 0 : void SvxRadioButtonListBox::KeyInput( const KeyEvent& rKEvt )
52 : {
53 0 : if ( !rKEvt.GetKeyCode().GetModifier() && KEY_SPACE == rKEvt.GetKeyCode().GetCode() )
54 : {
55 0 : SvTreeListEntry* pEntry = FirstSelected();
56 0 : if ( GetCheckButtonState( pEntry ) == SV_BUTTON_UNCHECKED )
57 : {
58 0 : SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
59 0 : GetCheckButtonHdl().Call( NULL );
60 0 : return ;
61 : }
62 : }
63 :
64 0 : SvSimpleTable::KeyInput( rKEvt );
65 : }
66 :
67 0 : void SvxRadioButtonListBox::HandleEntryChecked( SvTreeListEntry* _pEntry )
68 : {
69 0 : Select( _pEntry, true );
70 0 : SvButtonState eState = GetCheckButtonState( _pEntry );
71 :
72 0 : if ( SV_BUTTON_CHECKED == eState )
73 : {
74 : // we have radio button behavior -> so uncheck the other entries
75 0 : SvTreeListEntry* pEntry = First();
76 0 : while ( pEntry )
77 : {
78 0 : if ( pEntry != _pEntry )
79 0 : SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
80 0 : pEntry = Next( pEntry );
81 : }
82 : }
83 : else
84 0 : SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
85 0 : }
86 :
87 0 : const Point& SvxRadioButtonListBox::GetCurMousePoint() const
88 : {
89 0 : return m_aCurMousePoint;
90 : }
91 :
92 0 : long SvxRadioButtonListBox::GetControlColumnWidth() const
93 : {
94 0 : return pCheckButtonData->Width();
95 : }
96 :
97 : } // end of namespace ::svx
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|