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