Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : : #ifndef DBAUI_CONNECTIONLINE_HXX
20 : : #define DBAUI_CONNECTIONLINE_HXX
21 : :
22 : : #include <tools/gen.hxx>
23 : : #include <tools/string.hxx>
24 : : #include "ConnectionLineData.hxx"
25 : : #include <functional>
26 : :
27 : : class OutputDevice;
28 : : namespace dbaui
29 : : {
30 : :
31 : : //==================================================================
32 : : // ConnData ---------->* ConnLineData
33 : : // ^1 ^1
34 : : // | |
35 : : // Conn ---------->* ConnLine
36 : : //==================================================================
37 : :
38 : : /*
39 : : the class OConnectionLine represents the graphical line between the to two windows
40 : : **/
41 : : class OTableConnection;
42 : : class OConnectionLine
43 : : {
44 : : OTableConnection* m_pTabConn;
45 : : OConnectionLineDataRef m_pData;
46 : :
47 : : Point m_aSourceConnPos,
48 : : m_aDestConnPos;
49 : : Point m_aSourceDescrLinePos,
50 : : m_aDestDescrLinePos;
51 : : public:
52 : : OConnectionLine( OTableConnection* pConn, OConnectionLineDataRef pLineData );
53 : : OConnectionLine( const OConnectionLine& rLine );
54 : : virtual ~OConnectionLine();
55 : :
56 : : OConnectionLine& operator=( const OConnectionLine& rLine );
57 : :
58 : : Rectangle GetBoundingRect();
59 : : sal_Bool RecalcLine();
60 : : void Draw( OutputDevice* pOutDev );
61 : : bool CheckHit( const Point& rMousePos ) const;
62 : : String GetSourceFieldName() const { return m_pData->GetSourceFieldName(); }
63 : : String GetDestFieldName() const { return m_pData->GetDestFieldName(); }
64 : :
65 : : sal_Bool IsValid() const;
66 : :
67 : : Rectangle GetSourceTextPos() const;
68 : : Rectangle GetDestTextPos() const;
69 : :
70 : 0 : OConnectionLineDataRef GetData() const { return m_pData; }
71 : :
72 : : Point getMidPoint() const;
73 : : };
74 : : /// unary_function Functor object for class OConnectionLine returntype is void
75 : : /// draws a connectionline object on outputdevice
76 : : struct TConnectionLineDrawFunctor : ::std::unary_function<OConnectionLine*,void>
77 : : {
78 : : OutputDevice* pDevice;
79 : 0 : TConnectionLineDrawFunctor(OutputDevice* _pDevice)
80 : 0 : {
81 : 0 : pDevice = _pDevice;
82 : 0 : }
83 : 0 : inline void operator()(OConnectionLine* _pLine)
84 : : {
85 : 0 : _pLine->Draw(pDevice);
86 : 0 : }
87 : : };
88 : : /// binary_function Functor object for class OConnectionLine returntype is bool
89 : : /// checks if the point is on connectionline
90 : : struct TConnectionLineCheckHitFunctor : ::std::binary_function<OConnectionLine*,Point,bool>
91 : : {
92 : 0 : inline bool operator()(const OConnectionLine* lhs,const Point& rhs) const
93 : : {
94 : 0 : return lhs->CheckHit(rhs);
95 : : }
96 : : };
97 : :
98 : : }
99 : : #endif // DBAUI_CONNECTIONLINE_HXX
100 : :
101 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|