2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
34 #include "DiagramItem.h"
35 #include "DiagramView.h"
37 __USE_CORTEX_NAMESPACE
40 #define D_METHOD(x) //PRINT(x)
42 // -------------------------------------------------------- //
43 // *** static member initialization
44 // -------------------------------------------------------- //
46 bigtime_t
DiagramItem::m_lastSelectionTime
= 0;
47 int32
DiagramItem::m_countSelected
= 0;
49 // -------------------------------------------------------- //
50 // *** ctor/dtor (public)
51 // -------------------------------------------------------- //
53 DiagramItem::DiagramItem(
61 m_selectionTime(system_time())
63 D_METHOD(("DiagramItem::DiagramItem()\n"));
66 DiagramItem::~DiagramItem()
68 D_METHOD(("DiagramItem::~DiagramItem()\n"));
71 // -------------------------------------------------------- //
72 // *** operations (public)
73 // -------------------------------------------------------- //
75 void DiagramItem::select()
77 D_METHOD(("DiagramItem::select()\n"));
81 m_lastSelectionTime
= m_selectionTime
= system_time();
84 view()->Invalidate(Frame());
88 void DiagramItem::selectAdding()
90 D_METHOD(("DiagramItem::selectAdding()\n"));
94 m_selectionTime
= m_lastSelectionTime
- m_countSelected
++;
96 view()->Invalidate(Frame());
100 void DiagramItem::deselect()
102 D_METHOD(("DiagramItem::deselect()\n"));
107 view()->Invalidate(Frame());
111 // -------------------------------------------------------- //
112 // *** hook functions (public)
113 // -------------------------------------------------------- //
115 float DiagramItem::howCloseTo(
118 D_METHOD(("DiagramItem::howCloseTo()\n"));
119 if (Frame().Contains(point
))
126 // -------------------------------------------------------- //
127 // *** compare functions (friend)
128 // -------------------------------------------------------- //
130 int __CORTEX_NAMESPACE__
compareSelectionTime(
134 D_METHOD(("compareSelectionTime()\n"));
136 const DiagramItem
*lItem
= *(reinterpret_cast<const DiagramItem
* const*>(reinterpret_cast<const void* const*>(lValue
)));
137 const DiagramItem
*rItem
= *(reinterpret_cast<const DiagramItem
* const*>(reinterpret_cast<const void* const*>(rValue
)));
138 if (lItem
->m_selectionTime
< rItem
->m_selectionTime
)
142 else if (lItem
->m_selectionTime
> rItem
->m_selectionTime
)
149 // END -- DiagramItem.cpp --