BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / cortex / DiagramView / DiagramEndPoint.h
blob3a50a25d2791ebfca9f42ae742b22562996ffa58
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 // DiagramItem.h (Cortex/DiagramView)
34 // * PURPOSE
35 // DiagramItem subclass providing a basic implementation
36 // of 'connectable' points inside a DiagramBox
38 // * HISTORY
39 // c.lenz 25sep99 Begun
42 #ifndef __DiagramEndPoint_H__
43 #define __DiagramEndPoint_H__
45 #include <Looper.h>
46 #include <Region.h>
48 #include "DiagramItem.h"
50 #include "cortex_defs.h"
51 __BEGIN_CORTEX_NAMESPACE
53 class DiagramWire;
55 class DiagramEndPoint : public DiagramItem
58 public: // *** ctor/dtor
60 DiagramEndPoint(
61 BRect frame);
63 virtual ~DiagramEndPoint();
65 public: // *** accessors
67 DiagramWire *wire() const
68 { return m_wire; }
70 public: // *** hook functions
72 // is called from Draw() to do the actual drawing
73 virtual void drawEndPoint() = 0;
75 // should return the BPoint that a connected wire uses as
76 // a drawing offset; this implementation returns the center
77 // point of the EndPoint
78 virtual BPoint connectionPoint() const;
80 // is called from MessageDragged() and MessageDropped() to
81 // let you verify that a connection is okay
82 virtual bool connectionRequested(
83 DiagramEndPoint *fromWhich);
85 // is called whenever a connection has been made or a
86 // temporary wire drag has been accepted
87 virtual void connected()
88 { /* does nothing */ }
90 // is called whenever a connection has been broken or a
91 // temporary wire drag has finished
92 virtual void disconnected()
93 { /* does nothing */ }
95 public: // *** derived from DiagramItem
97 // returns the EndPoints frame rectangle
98 BRect Frame() const
99 { return m_frame; }
101 // prepares the drawing stack and clipping region, then
102 // calls drawEndPoint
103 void Draw(
104 BRect updateRect);
106 // is called from the parent DiagramBox's MouseDown()
107 // implementation if the EndPoint was hit; this version
108 // initiates selection and dragging (i.e. connecting)
109 virtual void MouseDown(
110 BPoint point,
111 uint32 buttons,
112 uint32 clicks);
114 // is called from the parent DiagramBox's MouseOver()
115 // implementation if the mouse is over the EndPoint
116 virtual void MouseOver(
117 BPoint point,
118 uint32 transit)
119 { /* does nothing */ }
121 // is called from the parent DiagramBox's MessageDragged()
122 // implementation of a message is being dragged of the
123 // EndPoint; this implementation handles only wire drags
124 // (i.e. M_WIRE_DRAGGED messages)
125 virtual void MessageDragged(
126 BPoint point,
127 uint32 transit,
128 const BMessage *message);
130 // is called from the parent DiagramBox's MessageDropped()
131 // implementation if the message was dropped on the EndPoint;
132 // this version handles wire dropping (connecting)
133 virtual void MessageDropped(
134 BPoint point,
135 BMessage *message);
137 // moves the EndPoint by the specified amount and returns in
138 // updateRegion the frames of connected wires if there are any
139 // NOTE: no drawing/refreshing is done in this method, that's
140 // up to the parent
141 void MoveBy(
142 float x,
143 float y,
144 BRegion *updateRegion);
146 // resize the EndPoints frame rectangle without redraw
147 virtual void ResizeBy(
148 float horizontal,
149 float vertical);
151 public: // *** connection methods
153 // connect/disconnect and set the wire pointer accordingly
154 void connect(
155 DiagramWire *wire);
156 void disconnect();
158 // returns true if the EndPoint is currently connected
159 bool isConnected() const
160 { return m_connected; }
162 // returns true if the EndPoint is currently in a connection
163 // process (i.e. it is either being dragged somewhere, or a
164 // M_WIRE_DRAGGED message is being dragged over it
165 bool isConnecting() const
166 { return m_connecting; }
168 private: // *** data
170 // the endpoints' frame rectangle
171 BRect m_frame;
173 // pointer to the wire object this endpoint might be
174 // connected to
175 DiagramWire *m_wire;
177 // indicates if the endpoint is currently connected
178 // to another endpoint
179 bool m_connected;
181 // indicates that a connection is currently being made
182 // but has not been confirmed yet
183 bool m_connecting;
186 __END_CORTEX_NAMESPACE
187 #endif // __DiagramEndPoint_H__