1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SVTOOLS_MOUSEFUNCTION_HXX 25 #define SVTOOLS_MOUSEFUNCTION_HXX 26 27 #include "svtools/table/tabletypes.hxx" 28 29 #include <rtl/ref.hxx> 30 31 #include <boost/noncopyable.hpp> 32 33 class MouseEvent; 34 35 //...................................................................................................................... 36 namespace svt { namespace table 37 { 38 //...................................................................................................................... 39 40 class ITableControl; 41 42 //================================================================================================================== 43 //= FunctionResult 44 //================================================================================================================== 45 enum FunctionResult 46 { 47 ActivateFunction, 48 ContinueFunction, 49 DeactivateFunction, 50 51 SkipFunction 52 }; 53 54 //================================================================================================================== 55 //= IMouseFunction 56 //================================================================================================================== 57 class IMouseFunction : public ::rtl::IReference, public ::boost::noncopyable 58 { 59 public: 60 virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; 61 virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; 62 virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; 63 64 protected: ~IMouseFunction()65 virtual ~IMouseFunction() { } 66 }; 67 68 //================================================================================================================== 69 //= MouseFunction 70 //================================================================================================================== 71 class MouseFunction : public IMouseFunction 72 { 73 public: MouseFunction()74 MouseFunction() 75 :m_refCount( 0 ) 76 { 77 } 78 protected: ~MouseFunction()79 ~MouseFunction() 80 { 81 } 82 83 public: 84 virtual oslInterlockedCount SAL_CALL acquire(); 85 virtual oslInterlockedCount SAL_CALL release(); 86 87 private: 88 oslInterlockedCount m_refCount; 89 }; 90 91 //================================================================================================================== 92 //= ColumnResize 93 //================================================================================================================== 94 class ColumnResize : public MouseFunction 95 { 96 public: ColumnResize()97 ColumnResize() 98 :m_nResizingColumn( COL_INVALID ) 99 { 100 } 101 102 public: 103 // IMouseFunction 104 virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ); 105 virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ); 106 virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ); 107 108 private: 109 ColPos m_nResizingColumn; 110 }; 111 112 //================================================================================================================== 113 //= RowSelection 114 //================================================================================================================== 115 class RowSelection : public MouseFunction 116 { 117 public: RowSelection()118 RowSelection() 119 :m_bActive( false ) 120 { 121 } 122 123 public: 124 // IMouseFunction 125 virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ); 126 virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ); 127 virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ); 128 129 private: 130 bool m_bActive; 131 }; 132 133 //================================================================================================================== 134 //= ColumnSortHandler 135 //================================================================================================================== 136 class ColumnSortHandler : public MouseFunction 137 { 138 public: ColumnSortHandler()139 ColumnSortHandler() 140 :m_nActiveColumn( COL_INVALID ) 141 { 142 } 143 144 public: 145 // IMouseFunction 146 virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ); 147 virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ); 148 virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ); 149 150 private: 151 ColPos m_nActiveColumn; 152 }; 153 154 //...................................................................................................................... 155 } } // namespace svt::table 156 //...................................................................................................................... 157 158 #endif // SVTOOLS_MOUSEFUNCTION_HXX 159