BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / cortex / DiagramView / DiagramWire.h
blobac80346bd1204380f1b6bef479abf864b5d9d5f8
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // DiagramWire.h (Cortex/DiagramView)
34 // * PURPOSE
35 // DiagramItem subclass serving as a graphical connection
36 // between two DiagramEndPoints
38 // * HISTORY
39 // c.lenz 25sep99 Begun
42 #ifndef __DiagramWire_H__
43 #define __DiagramWire_H__
45 #include "DiagramItem.h"
47 #include <Region.h>
48 #include <Window.h>
50 #include "cortex_defs.h"
51 __BEGIN_CORTEX_NAMESPACE
53 class DiagramView;
54 class DiagramEndPoint;
56 class DiagramWire : public DiagramItem
58 friend class DiagramView;
60 public: // *** ctor/dtor
62 // both endpoints are set connected by this constructor
63 // so be careful to only pass in valid pointers
64 DiagramWire(
65 DiagramEndPoint *fromWhich,
66 DiagramEndPoint *toWhich);
68 // special constructor used only in drag&drop sessions for
69 // temporary visual indication of the connection process
70 // the isStartPoint lets you specify if the given EndPoint
71 // is supposed to be treated as start or end point
72 DiagramWire(
73 DiagramEndPoint *fromWhich,
74 bool isStartPoint = true);
76 virtual ~DiagramWire();
78 public: // *** accessors
80 bool isDragging() const
81 { return m_temporary; }
83 // returns a pointer to the "start/source" endpoint
84 DiagramEndPoint *startPoint() const
85 { return m_fromEndPoint; }
87 // returns the point from the m_fromEndPoints connectionPoint() method
88 BPoint startConnectionPoint() const;
90 // returns a pointer the "end/target" endpoint
91 DiagramEndPoint *endPoint() const
92 { return m_toEndPoint; }
94 // returns the point from the m_toEndPoints connectionPoint() method
95 BPoint endConnectionPoint() const;
97 public: // *** hook functions
99 // is called from Draw() to do the actual drawing
100 virtual void drawWire() = 0;
102 // is called by the connected diagramEndPoints whenever one is moved
103 // if the argument is NULL then both endpoints should be evaluated
104 virtual void endPointMoved(
105 DiagramEndPoint *which = 0)
106 { /* does nothing */ }
108 public: // *** derived from DiagramItem
110 // returns the area in which the wire displays
111 virtual BRect Frame() const
112 { return BRect(startConnectionPoint(), endConnectionPoint()); }
114 // returns how close a given point is to the wire; the current
115 // implementation returns a wide array of values, those above
116 // approx. 0.5 are quite close to the wire
117 float howCloseTo(
118 BPoint point) const;
120 // prepares the drawing stack and clipping region, then
121 // calls drawWire
122 void Draw(
123 BRect updateRect);
125 // is called from the parent DiagramViews MouseDown() implementation
126 // if the Wire was hit; this version initiates selection and dragging
127 virtual void MouseDown(
128 BPoint point,
129 uint32 buttons,
130 uint32 clicks);
132 // is called from the DiagramViews MouseMoved() when no message is being
133 // dragged, but the mouse has moved above the wire
134 virtual void MouseOver(
135 BPoint point,
136 uint32 transit)
137 { /* does nothing */ }
140 // is called from the DiagramViews MouseMoved() when a message is being
141 // dragged over the DiagramWire
142 virtual void MessageDragged(
143 BPoint point,
144 uint32 transit,
145 const BMessage *message);
147 // is called from the DiagramViews MessageReceived() function when a
148 // message has been dropped on the DiagramWire
149 virtual void MessageDropped(
150 BPoint point,
151 BMessage *message)
152 { /* does nothing */ }
154 private: // *** data
156 // pointer to the "from" EndPoint as assigned in the ctor
157 DiagramEndPoint *m_fromEndPoint;
159 // pointer to the "to" EndPoint as assigned in the ctor
160 DiagramEndPoint *m_toEndPoint;
162 // indicates that this is a connection used in a drag&drop session
163 // and will be deleted after that
164 bool m_temporary;
166 // contains a BPoint for "temporary connections"
167 BPoint m_dragEndPoint;
170 __END_CORTEX_NAMESPACE
171 #endif // __DiagramWire_H__