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 INCLUDED_DBACCESS_SOURCE_UI_INC_CONNECTIONLINE_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_CONNECTIONLINE_HXX
21 :
22 : #include <tools/gen.hxx>
23 : #include "ConnectionLineData.hxx"
24 : #include <functional>
25 :
26 : class OutputDevice;
27 : namespace dbaui
28 : {
29 :
30 : // ConnData ---------->* ConnLineData
31 : // ^1 ^1
32 : // | |
33 : // Conn ---------->* ConnLine
34 :
35 : /*
36 : the class OConnectionLine represents the graphical line between the to two windows
37 : **/
38 : class OTableConnection;
39 : class OConnectionLine
40 : {
41 : OTableConnection* m_pTabConn;
42 : OConnectionLineDataRef m_pData;
43 :
44 : Point m_aSourceConnPos,
45 : m_aDestConnPos;
46 : Point m_aSourceDescrLinePos,
47 : m_aDestDescrLinePos;
48 : public:
49 : OConnectionLine( OTableConnection* pConn, OConnectionLineDataRef pLineData );
50 : OConnectionLine( const OConnectionLine& rLine );
51 : virtual ~OConnectionLine();
52 :
53 : OConnectionLine& operator=( const OConnectionLine& rLine );
54 :
55 : Rectangle GetBoundingRect();
56 : sal_Bool RecalcLine();
57 : void Draw( OutputDevice* pOutDev );
58 : bool CheckHit( const Point& rMousePos ) const;
59 : OUString GetSourceFieldName() const { return m_pData->GetSourceFieldName(); }
60 : OUString GetDestFieldName() const { return m_pData->GetDestFieldName(); }
61 :
62 : sal_Bool IsValid() const;
63 :
64 : Rectangle GetSourceTextPos() const;
65 : Rectangle GetDestTextPos() const;
66 :
67 0 : OConnectionLineDataRef GetData() const { return m_pData; }
68 :
69 : Point getMidPoint() const;
70 : };
71 : /// unary_function Functor object for class OConnectionLine returntype is void
72 : /// draws a connectionline object on outputdevice
73 : struct TConnectionLineDrawFunctor : ::std::unary_function<OConnectionLine*,void>
74 : {
75 : OutputDevice* pDevice;
76 0 : TConnectionLineDrawFunctor(OutputDevice* _pDevice)
77 0 : {
78 0 : pDevice = _pDevice;
79 0 : }
80 0 : inline void operator()(OConnectionLine* _pLine)
81 : {
82 0 : _pLine->Draw(pDevice);
83 0 : }
84 : };
85 : /// binary_function Functor object for class OConnectionLine returntype is bool
86 : /// checks if the point is on connectionline
87 : struct TConnectionLineCheckHitFunctor : ::std::binary_function<OConnectionLine*,Point,bool>
88 : {
89 0 : inline bool operator()(const OConnectionLine* lhs,const Point& rhs) const
90 : {
91 0 : return lhs->CheckHit(rhs);
92 : }
93 : };
94 :
95 : }
96 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_CONNECTIONLINE_HXX
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|