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 #ifndef DBAUI_CONNECTIONLINE_HXX
24 #define DBAUI_CONNECTIONLINE_HXX
25 
26 #ifndef _SV_GEN_HXX
27 #include <tools/gen.hxx>
28 #endif
29 #ifndef _STRING_HXX
30 #include <tools/string.hxx>
31 #endif
32 #ifndef DBAUI_CONNECTIONLINEDATA_HXX
33 #include "ConnectionLineData.hxx"
34 #endif
35 #include <functional>
36 
37 class OutputDevice;
38 namespace dbaui
39 {
40 
41 	//==================================================================
42 	// ConnData		---------->*	ConnLineData
43 	//    ^1							^1
44 	//    |								|
45 	//	Conn		---------->*	ConnLine
46 	//==================================================================
47 
48 	/*
49 		the class OConnectionLine represents the graphical line between the to two windows
50 	**/
51 	class OConnectionLineData;
52 	class OTableConnection;
53 	class OTableWindow;
54 	class OConnectionLine
55 	{
56 		OTableConnection*		m_pTabConn;
57 		OConnectionLineDataRef	m_pData;
58 
59 		Point					m_aSourceConnPos,
60 								m_aDestConnPos;
61 		Point					m_aSourceDescrLinePos,
62 								m_aDestDescrLinePos;
63 	public:
64 		OConnectionLine( OTableConnection* pConn, OConnectionLineDataRef pLineData );
65 		OConnectionLine( const OConnectionLine& rLine );
66 		virtual ~OConnectionLine();
67 
68 		virtual OConnectionLine& operator=( const OConnectionLine& rLine );
69 
70 		Rectangle			GetBoundingRect();
71 		sal_Bool				RecalcLine();
72 		void				Draw( OutputDevice* pOutDev );
73 		bool				CheckHit( const Point& rMousePos ) const;
GetSourceFieldName() const74 		String				GetSourceFieldName() const { return m_pData->GetSourceFieldName(); }
GetDestFieldName() const75 		String				GetDestFieldName() const { return m_pData->GetDestFieldName(); }
76 
77 		sal_Bool				IsValid() const;
78 
79 		Rectangle			GetSourceTextPos() const;
80 		Rectangle			GetDestTextPos() const;
81 
GetData() const82 		OConnectionLineDataRef	GetData() const { return m_pData; }
83 
84 		Point				getMidPoint() const;
85 	};
86 	/// unary_function Functor object for class OConnectionLine returntype is void
87 	/// draws a connectionline object on outputdevice
88 	struct TConnectionLineDrawFunctor : ::std::unary_function<OConnectionLine*,void>
89 	{
90 		OutputDevice* pDevice;
TConnectionLineDrawFunctordbaui::TConnectionLineDrawFunctor91 		TConnectionLineDrawFunctor(OutputDevice* _pDevice)
92 		{
93 			pDevice = _pDevice;
94 		}
operator ()dbaui::TConnectionLineDrawFunctor95 		inline void operator()(OConnectionLine* _pLine)
96 		{
97 			_pLine->Draw(pDevice);
98 		}
99 	};
100 	/// binary_function Functor object for class OConnectionLine returntype is bool
101 	/// checks if the point is on connectionline
102 	struct TConnectionLineCheckHitFunctor : ::std::binary_function<OConnectionLine*,Point,bool>
103 	{
operator ()dbaui::TConnectionLineCheckHitFunctor104 		inline bool operator()(const OConnectionLine* lhs,const Point& rhs)	const
105 		{
106 			return lhs->CheckHit(rhs);
107 		}
108 	};
109 
110 }
111 #endif // DBAUI_CONNECTIONLINE_HXX
112