1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * Copyright 2009 by Sun Microsystems, Inc.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * This file is part of OpenOffice.org.
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org. If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
26 // MARKER(update_precomp.py): autogen include statement, do not remove
27 #include "precompiled_svtools.hxx"
29 #include "svtools/table/defaultinputhandler.hxx"
30 #include "svtools/table/abstracttablecontrol.hxx"
32 #include <tools/debug.hxx>
33 #include <vcl/event.hxx>
34 #include <vcl/cursor.hxx>
35 #include "svtools/table/tabledatawindow.hxx"
37 //........................................................................
38 namespace svt
{ namespace table
40 //.......................................................................
42 struct DefaultInputHandler_Impl
46 //====================================================================
47 //= DefaultInputHandler
48 //====================================================================
49 //--------------------------------------------------------------------
50 DefaultInputHandler::DefaultInputHandler()
51 :m_pImpl( new DefaultInputHandler_Impl
)
55 //--------------------------------------------------------------------
56 DefaultInputHandler::~DefaultInputHandler()
61 //--------------------------------------------------------------------
62 bool DefaultInputHandler::MouseMove( IAbstractTableControl
& _rControl
, const MouseEvent
& _rMEvt
)
69 //--------------------------------------------------------------------
70 bool DefaultInputHandler::MouseButtonDown( IAbstractTableControl
& _rControl
, const MouseEvent
& _rMEvt
)
72 bool bHandled
= false;
73 Point aPoint
= _rMEvt
.GetPosPixel();
74 if(_rControl
.isClickInVisibleArea(aPoint
))
76 if(_rControl
.getSelEngine()->GetSelectionMode() == NO_SELECTION
)
79 _rControl
.setCursorAtCurrentCell(aPoint
);
84 bHandled
= _rControl
.getSelEngine()->SelMouseButtonDown(_rMEvt
);
90 //--------------------------------------------------------------------
91 bool DefaultInputHandler::MouseButtonUp( IAbstractTableControl
& _rControl
, const MouseEvent
& _rMEvt
)
93 bool bHandled
= false;
94 Point aPoint
= _rMEvt
.GetPosPixel();
95 if(_rControl
.isClickInVisibleArea(aPoint
))
97 if(_rControl
.getSelEngine()->GetSelectionMode() == NO_SELECTION
)
100 _rControl
.setCursorAtCurrentCell(aPoint
);
104 bHandled
= _rControl
.getSelEngine()->SelMouseButtonUp(_rMEvt
);
109 //--------------------------------------------------------------------
110 bool DefaultInputHandler::KeyInput( IAbstractTableControl
& _rControl
, const KeyEvent
& rKEvt
)
112 bool bHandled
= false;
114 const KeyCode
& rKeyCode
= rKEvt
.GetKeyCode();
115 USHORT nKeyCode
= rKeyCode
.GetCode();
117 struct _ActionMapEntry
121 TableControlAction eAction
;
123 static aKnownActions
[] = {
124 { KEY_DOWN
, 0, cursorDown
},
125 { KEY_UP
, 0, cursorUp
},
126 { KEY_LEFT
, 0, cursorLeft
},
127 { KEY_RIGHT
, 0, cursorRight
},
128 { KEY_HOME
, 0, cursorToLineStart
},
129 { KEY_END
, 0, cursorToLineEnd
},
130 { KEY_PAGEUP
, 0, cursorPageUp
},
131 { KEY_PAGEDOWN
, 0, cursorPageDown
},
132 { KEY_PAGEUP
, KEY_MOD1
, cursorToFirstLine
},
133 { KEY_PAGEDOWN
, KEY_MOD1
, cursorToLastLine
},
134 { KEY_HOME
, KEY_MOD1
, cursorTopLeft
},
135 { KEY_END
, KEY_MOD1
, cursorBottomRight
},
136 { KEY_SPACE
, KEY_MOD1
, cursorSelectRow
},
137 { KEY_UP
, KEY_SHIFT
, cursorSelectRowUp
},
138 { KEY_DOWN
, KEY_SHIFT
, cursorSelectRowDown
},
139 { KEY_END
, KEY_SHIFT
, cursorSelectRowAreaBottom
},
140 { KEY_HOME
, KEY_SHIFT
, cursorSelectRowAreaTop
},
142 { 0, 0, invalidTableControlAction
}
145 const _ActionMapEntry
* pActions
= aKnownActions
;
146 for ( ; pActions
->eAction
!= invalidTableControlAction
; ++pActions
)
148 if ( ( pActions
->nKeyCode
== nKeyCode
) && ( pActions
->nKeyModifier
== rKeyCode
.GetAllModifier() ) )
150 bHandled
= _rControl
.dispatchAction( pActions
->eAction
);
158 //--------------------------------------------------------------------
159 bool DefaultInputHandler::GetFocus( IAbstractTableControl
& _rControl
)
161 _rControl
.showCursor();
162 return false; // continue processing
165 //--------------------------------------------------------------------
166 bool DefaultInputHandler::LoseFocus( IAbstractTableControl
& _rControl
)
168 _rControl
.hideCursor();
169 return false; // continue processing
172 //--------------------------------------------------------------------
173 bool DefaultInputHandler::RequestHelp( IAbstractTableControl
& _rControl
, const HelpEvent
& _rHEvt
)
181 //--------------------------------------------------------------------
182 bool DefaultInputHandler::Command( IAbstractTableControl
& _rControl
, const CommandEvent
& _rCEvt
)
190 //--------------------------------------------------------------------
191 bool DefaultInputHandler::PreNotify( IAbstractTableControl
& _rControl
, NotifyEvent
& _rNEvt
)
199 //--------------------------------------------------------------------
200 bool DefaultInputHandler::Notify( IAbstractTableControl
& _rControl
, NotifyEvent
& _rNEvt
)
208 //........................................................................
209 } } // namespace svt::table
210 //........................................................................