xref: /trunk/main/dbaccess/source/ui/inc/ConnectionLine.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_CONNECTIONLINE_HXX
28 #define DBAUI_CONNECTIONLINE_HXX
29 
30 #ifndef _SV_GEN_HXX
31 #include <tools/gen.hxx>
32 #endif
33 #ifndef _STRING_HXX
34 #include <tools/string.hxx>
35 #endif
36 #ifndef DBAUI_CONNECTIONLINEDATA_HXX
37 #include "ConnectionLineData.hxx"
38 #endif
39 #include <functional>
40 
41 class OutputDevice;
42 namespace dbaui
43 {
44 
45     //==================================================================
46     // ConnData     ---------->*    ConnLineData
47     //    ^1                            ^1
48     //    |                             |
49     //  Conn        ---------->*    ConnLine
50     //==================================================================
51 
52     /*
53         the class OConnectionLine represents the graphical line between the to two windows
54     **/
55     class OConnectionLineData;
56     class OTableConnection;
57     class OTableWindow;
58     class OConnectionLine
59     {
60         OTableConnection*       m_pTabConn;
61         OConnectionLineDataRef  m_pData;
62 
63         Point                   m_aSourceConnPos,
64                                 m_aDestConnPos;
65         Point                   m_aSourceDescrLinePos,
66                                 m_aDestDescrLinePos;
67     public:
68         OConnectionLine( OTableConnection* pConn, OConnectionLineDataRef pLineData );
69         OConnectionLine( const OConnectionLine& rLine );
70         virtual ~OConnectionLine();
71 
72         virtual OConnectionLine& operator=( const OConnectionLine& rLine );
73 
74         Rectangle           GetBoundingRect();
75         sal_Bool                RecalcLine();
76         void                Draw( OutputDevice* pOutDev );
77         bool                CheckHit( const Point& rMousePos ) const;
78         String              GetSourceFieldName() const { return m_pData->GetSourceFieldName(); }
79         String              GetDestFieldName() const { return m_pData->GetDestFieldName(); }
80 
81         sal_Bool                IsValid() const;
82 
83         Rectangle           GetSourceTextPos() const;
84         Rectangle           GetDestTextPos() const;
85 
86         OConnectionLineDataRef  GetData() const { return m_pData; }
87 
88         Point               getMidPoint() const;
89     };
90     /// unary_function Functor object for class OConnectionLine returntype is void
91     /// draws a connectionline object on outputdevice
92     struct TConnectionLineDrawFunctor : ::std::unary_function<OConnectionLine*,void>
93     {
94         OutputDevice* pDevice;
95         TConnectionLineDrawFunctor(OutputDevice* _pDevice)
96         {
97             pDevice = _pDevice;
98         }
99         inline void operator()(OConnectionLine* _pLine)
100         {
101             _pLine->Draw(pDevice);
102         }
103     };
104     /// binary_function Functor object for class OConnectionLine returntype is bool
105     /// checks if the point is on connectionline
106     struct TConnectionLineCheckHitFunctor : ::std::binary_function<OConnectionLine*,Point,bool>
107     {
108         inline bool operator()(const OConnectionLine* lhs,const Point& rhs) const
109         {
110             return lhs->CheckHit(rhs);
111         }
112     };
113 
114 }
115 #endif // DBAUI_CONNECTIONLINE_HXX
116