vfs: check userland buffers before reading them.
[haiku.git] / src / apps / cortex / MediaRoutingView / MediaWire.h
blob68802ca2c26dae3782e212f0ff42d111773a5b88
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 // MediaWire.h
33 // c.lenz 10oct99
35 // HISTORY
38 #ifndef __MediaWire_H__
39 #define __MediaWire_H__
41 // DiagramView
42 #include "DiagramWire.h"
43 // NodeManager
44 #include "Connection.h"
46 #include "cortex_defs.h"
47 __BEGIN_CORTEX_NAMESPACE
49 class MediaJack;
51 class MediaWire :
52 public DiagramWire {
53 typedef DiagramWire _inherited;
55 public: // *** constans
57 // [e.moon 26oct99] moved definition to MediaWire.cpp
58 static const float M_WIRE_OFFSET;
60 public: // *** ctor/dtor
62 // input and output jack are set connected by this constructor
63 // so be careful to only pass in valid pointers
64 MediaWire(
65 Connection connection,
66 MediaJack *outputJack,
67 MediaJack *inputJack);
69 // special constructor used only in drag&drop sessions for
70 // temporary visual indication of the connection process
71 // the isStartPoint specifies if the given EndPoint is
72 // supposed to be treated as start or end point
73 MediaWire(
74 MediaJack *jack,
75 bool isStartPoint);
77 virtual ~MediaWire();
79 public: // *** accessors
81 Connection connection;
83 public: // *** derived from DiagramWire/Item
85 // init the cached points and the frame rect
86 virtual void attachedToDiagram();
88 // make sure no tooltip is being displayed for this wire
89 // +++ DOES NOT WORK (yet)
90 virtual void detachedFromDiagram();
92 // calculates and returns the frame rectangle of the wire
93 virtual BRect Frame() const;
95 // returns a value > 0.5 for points pretty much close to the
96 // wire
97 virtual float howCloseTo(
98 BPoint point) const;
100 // does the actual drawing
101 virtual void drawWire();
103 // displays the context-menu for right-clicks
104 virtual void MouseDown(
105 BPoint point,
106 uint32 buttons,
107 uint32 clicks);
109 // changes the mouse cursor and starts a tooltip
110 virtual void MouseOver(
111 BPoint point,
112 uint32 transit);
114 // also selects and invalidates the jacks connected by
115 // this wire
116 virtual void selected();
118 // also deselectes and invalidates the jacks connected
119 // by this wire
120 virtual void deselected();
122 // updates the cached start & end points and the frame rect
123 virtual void endPointMoved(
124 DiagramEndPoint *which = 0);
126 protected: // *** operations
128 // display a popup-menu at given point
129 void showContextMenu(
130 BPoint point);
132 private: // *** data members
134 BPoint m_startPoint;
136 BPoint m_endPoint;
138 BPoint m_startOffset;
140 BPoint m_endOffset;
142 BRect m_frame;
145 __END_CORTEX_NAMESPACE
146 #endif /* __MediaWire_H__ */