xref: /AOO41X/main/svtools/source/table/mousefunction.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * Copyright 2000, 2010 Oracle and/or its affiliates.
5  *
6  * OpenOffice.org - a multi-platform office productivity suite
7  *
8  * This file is part of OpenOffice.org.
9  *
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.
13  *
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).
19  *
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  *
25  ************************************************************************/
26 
27 #ifndef SVTOOLS_MOUSEFUNCTION_HXX
28 #define SVTOOLS_MOUSEFUNCTION_HXX
29 
30 #include "svtools/table/tabletypes.hxx"
31 
32 #include <rtl/ref.hxx>
33 
34 #include <boost/noncopyable.hpp>
35 
36 class MouseEvent;
37 
38 //......................................................................................................................
39 namespace svt { namespace table
40 {
41 //......................................................................................................................
42 
43     class ITableControl;
44 
45 	//==================================================================================================================
46 	//= FunctionResult
47 	//==================================================================================================================
48     enum FunctionResult
49     {
50         ActivateFunction,
51         ContinueFunction,
52         DeactivateFunction,
53 
54         SkipFunction
55     };
56 
57 	//==================================================================================================================
58 	//= IMouseFunction
59 	//==================================================================================================================
60     class IMouseFunction : public ::rtl::IReference, public ::boost::noncopyable
61 	{
62     public:
63         virtual FunctionResult  handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
64         virtual FunctionResult  handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
65         virtual FunctionResult  handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
66 
67     protected:
68         virtual ~IMouseFunction() { }
69 	};
70 
71 	//==================================================================================================================
72 	//= MouseFunction
73 	//==================================================================================================================
74     class MouseFunction : public IMouseFunction
75     {
76     public:
77         MouseFunction()
78             :m_refCount( 0 )
79         {
80         }
81     protected:
82         ~MouseFunction()
83         {
84         }
85 
86     public:
87 	    virtual oslInterlockedCount SAL_CALL acquire();
88 	    virtual oslInterlockedCount SAL_CALL release();
89 
90     private:
91         oslInterlockedCount m_refCount;
92     };
93 
94 	//==================================================================================================================
95 	//= ColumnResize
96 	//==================================================================================================================
97     class ColumnResize : public MouseFunction
98     {
99     public:
100         ColumnResize()
101             :m_nResizingColumn( COL_INVALID )
102         {
103         }
104 
105     public:
106         // IMouseFunction
107         virtual FunctionResult  handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event );
108         virtual FunctionResult  handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event );
109         virtual FunctionResult  handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event );
110 
111     private:
112         ColPos  m_nResizingColumn;
113     };
114 
115 	//==================================================================================================================
116 	//= RowSelection
117 	//==================================================================================================================
118     class RowSelection : public MouseFunction
119     {
120     public:
121         RowSelection()
122             :m_bActive( false )
123         {
124         }
125 
126     public:
127         // IMouseFunction
128         virtual FunctionResult  handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event );
129         virtual FunctionResult  handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event );
130         virtual FunctionResult  handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event );
131 
132     private:
133         bool    m_bActive;
134     };
135 
136 	//==================================================================================================================
137 	//= ColumnSortHandler
138 	//==================================================================================================================
139     class ColumnSortHandler : public MouseFunction
140     {
141     public:
142         ColumnSortHandler()
143             :m_nActiveColumn( COL_INVALID )
144         {
145         }
146 
147     public:
148         // IMouseFunction
149         virtual FunctionResult  handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event );
150         virtual FunctionResult  handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event );
151         virtual FunctionResult  handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event );
152 
153     private:
154         ColPos  m_nActiveColumn;
155     };
156 
157 //......................................................................................................................
158 } } // namespace svt::table
159 //......................................................................................................................
160 
161 #endif // SVTOOLS_MOUSEFUNCTION_HXX
162