1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_CONNECTIONLINE_HXX
24cdf0e10cSrcweir #define DBAUI_CONNECTIONLINE_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _SV_GEN_HXX
27cdf0e10cSrcweir #include <tools/gen.hxx>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _STRING_HXX
30cdf0e10cSrcweir #include <tools/string.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBAUI_CONNECTIONLINEDATA_HXX
33cdf0e10cSrcweir #include "ConnectionLineData.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <functional>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class OutputDevice;
38cdf0e10cSrcweir namespace dbaui
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 	//==================================================================
42cdf0e10cSrcweir 	// ConnData		---------->*	ConnLineData
43cdf0e10cSrcweir 	//    ^1							^1
44cdf0e10cSrcweir 	//    |								|
45cdf0e10cSrcweir 	//	Conn		---------->*	ConnLine
46cdf0e10cSrcweir 	//==================================================================
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	/*
49cdf0e10cSrcweir 		the class OConnectionLine represents the graphical line between the to two windows
50cdf0e10cSrcweir 	**/
51cdf0e10cSrcweir 	class OConnectionLineData;
52cdf0e10cSrcweir 	class OTableConnection;
53cdf0e10cSrcweir 	class OTableWindow;
54cdf0e10cSrcweir 	class OConnectionLine
55cdf0e10cSrcweir 	{
56cdf0e10cSrcweir 		OTableConnection*		m_pTabConn;
57cdf0e10cSrcweir 		OConnectionLineDataRef	m_pData;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 		Point					m_aSourceConnPos,
60cdf0e10cSrcweir 								m_aDestConnPos;
61cdf0e10cSrcweir 		Point					m_aSourceDescrLinePos,
62cdf0e10cSrcweir 								m_aDestDescrLinePos;
63cdf0e10cSrcweir 	public:
64cdf0e10cSrcweir 		OConnectionLine( OTableConnection* pConn, OConnectionLineDataRef pLineData );
65cdf0e10cSrcweir 		OConnectionLine( const OConnectionLine& rLine );
66cdf0e10cSrcweir 		virtual ~OConnectionLine();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 		virtual OConnectionLine& operator=( const OConnectionLine& rLine );
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		Rectangle			GetBoundingRect();
71cdf0e10cSrcweir 		sal_Bool				RecalcLine();
72cdf0e10cSrcweir 		void				Draw( OutputDevice* pOutDev );
73cdf0e10cSrcweir 		bool				CheckHit( const Point& rMousePos ) const;
GetSourceFieldName() const74cdf0e10cSrcweir 		String				GetSourceFieldName() const { return m_pData->GetSourceFieldName(); }
GetDestFieldName() const75cdf0e10cSrcweir 		String				GetDestFieldName() const { return m_pData->GetDestFieldName(); }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		sal_Bool				IsValid() const;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 		Rectangle			GetSourceTextPos() const;
80cdf0e10cSrcweir 		Rectangle			GetDestTextPos() const;
81cdf0e10cSrcweir 
GetData() const82cdf0e10cSrcweir 		OConnectionLineDataRef	GetData() const { return m_pData; }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 		Point				getMidPoint() const;
85cdf0e10cSrcweir 	};
86cdf0e10cSrcweir 	/// unary_function Functor object for class OConnectionLine returntype is void
87cdf0e10cSrcweir 	/// draws a connectionline object on outputdevice
88cdf0e10cSrcweir 	struct TConnectionLineDrawFunctor : ::std::unary_function<OConnectionLine*,void>
89cdf0e10cSrcweir 	{
90cdf0e10cSrcweir 		OutputDevice* pDevice;
TConnectionLineDrawFunctordbaui::TConnectionLineDrawFunctor91cdf0e10cSrcweir 		TConnectionLineDrawFunctor(OutputDevice* _pDevice)
92cdf0e10cSrcweir 		{
93cdf0e10cSrcweir 			pDevice = _pDevice;
94cdf0e10cSrcweir 		}
operator ()dbaui::TConnectionLineDrawFunctor95cdf0e10cSrcweir 		inline void operator()(OConnectionLine* _pLine)
96cdf0e10cSrcweir 		{
97cdf0e10cSrcweir 			_pLine->Draw(pDevice);
98cdf0e10cSrcweir 		}
99cdf0e10cSrcweir 	};
100cdf0e10cSrcweir 	/// binary_function Functor object for class OConnectionLine returntype is bool
101cdf0e10cSrcweir 	/// checks if the point is on connectionline
102cdf0e10cSrcweir 	struct TConnectionLineCheckHitFunctor : ::std::binary_function<OConnectionLine*,Point,bool>
103cdf0e10cSrcweir 	{
operator ()dbaui::TConnectionLineCheckHitFunctor104cdf0e10cSrcweir 		inline bool operator()(const OConnectionLine* lhs,const Point& rhs)	const
105cdf0e10cSrcweir 		{
106cdf0e10cSrcweir 			return lhs->CheckHit(rhs);
107cdf0e10cSrcweir 		}
108cdf0e10cSrcweir 	};
109cdf0e10cSrcweir 
110cdf0e10cSrcweir }
111cdf0e10cSrcweir #endif // DBAUI_CONNECTIONLINE_HXX
112