* Copyright (c) 1999-2000, Eric Moon.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __MouseTrackingHelpers_H__
#define __MouseTrackingHelpers_H__
#include <View.h>
#include "cortex_defs.h"
__BEGIN_CORTEX_NAMESPACE
class MouseTrackingSourceView;
class IMouseTrackingDestination {
public:
IMouseTrackingDestination() { }
virtual ~IMouseTrackingDestination() { }
virtual void mouseTrackingBegin(
MouseTrackingSourceView* pSource,
uint32 buttons,
BPoint point)=0;
virtual void mouseTrackingUpdate(
uint32 buttons,
float xDelta,
float yDelta,
BPoint point)=0;
virtual void mouseTrackingEnd()=0;
};
class MouseTrackingSourceView : public BView {
typedef BView _inherited;
public:
enum mouse_tracking_flag_t {
TRACK_HORIZONTAL = 1,
TRACK_VERTICAL = 2
};
public:
MouseTrackingSourceView(
BRect frame,
const char* pName,
uint32 resizeMode=B_FOLLOW_LEFT|B_FOLLOW_TOP,
uint32 flags=B_WILL_DRAW|B_FRAME_EVENTS,
uint32 trackingFlags=TRACK_HORIZONTAL|TRACK_VERTICAL);
~MouseTrackingSourceView();
bool isTracking() const { return m_bTracking; }
status_t getTrackingOrigin(BPoint* poPoint) const;
IMouseTrackingDestination* trackingDestination() const {
return m_pDest;
}
status_t setTrackingDestination(IMouseTrackingDestination* pDest);
public:
virtual void MouseDown(BPoint point);
virtual void MouseMoved(BPoint point, uint32 transit,
const BMessage* pMsg);
virtual void MouseUp(BPoint point);
virtual void AttachedToWindow();
// track current frame rectangle
virtual void FrameResized(float width, float height);
*/
protected:
IMouseTrackingDestination* m_pDest;
uint32 m_trackingFlags;
bool m_bTracking;
BPoint m_prevPoint;
BPoint m_initPoint;
};
__END_CORTEX_NAMESPACE
#endif