2006-03-18 19:42:14 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2006, Haiku.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
*/
|
|
|
|
#ifndef SERVER_CURSOR_H
|
|
|
|
#define SERVER_CURSOR_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "ServerBitmap.h"
|
|
|
|
|
|
|
|
#include <Point.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
class ServerApp;
|
|
|
|
class CursorManager;
|
|
|
|
|
|
|
|
|
|
|
|
class ServerCursor : public ServerBitmap {
|
|
|
|
public:
|
|
|
|
ServerCursor(BRect r, color_space space,
|
|
|
|
int32 flags, BPoint hotspot,
|
|
|
|
int32 bytesperrow = -1,
|
|
|
|
screen_id screen = B_MAIN_SCREEN_ID);
|
|
|
|
ServerCursor(const uint8* cursorDataFromR5);
|
|
|
|
ServerCursor(const uint8* alreadyPaddedData,
|
|
|
|
uint32 width, uint32 height,
|
|
|
|
color_space format);
|
|
|
|
ServerCursor(const ServerCursor* cursor);
|
|
|
|
|
|
|
|
virtual ~ServerCursor();
|
2008-04-02 15:12:39 +04:00
|
|
|
|
2006-03-18 19:42:14 +03:00
|
|
|
//! Returns the cursor's hot spot
|
|
|
|
void SetHotSpot(BPoint pt);
|
|
|
|
BPoint GetHotSpot() const
|
|
|
|
{ return fHotSpot; }
|
|
|
|
|
|
|
|
void SetOwningTeam(team_id tid)
|
|
|
|
{ fOwningTeam = tid; }
|
|
|
|
team_id OwningTeam() const
|
|
|
|
{ return fOwningTeam; }
|
|
|
|
|
|
|
|
int32 Token() const
|
|
|
|
{ return fToken; }
|
|
|
|
|
|
|
|
void Acquire()
|
|
|
|
{ atomic_add(&fReferenceCount, 1); }
|
|
|
|
bool Release();
|
2007-01-04 15:28:31 +03:00
|
|
|
int32 ReferenceCount() { return fReferenceCount; }
|
2006-03-18 19:42:14 +03:00
|
|
|
|
|
|
|
void AttachedToManager(CursorManager* manager);
|
|
|
|
|
|
|
|
const uint8* CursorData() const
|
|
|
|
{ return fCursorData; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class CursorManager;
|
|
|
|
|
|
|
|
BPoint fHotSpot;
|
|
|
|
team_id fOwningTeam;
|
2007-01-04 15:28:31 +03:00
|
|
|
vint32 fReferenceCount;
|
2006-03-18 19:42:14 +03:00
|
|
|
uint8* fCursorData;
|
|
|
|
CursorManager* fManager;
|
|
|
|
};
|
|
|
|
|
2008-04-02 15:12:39 +04:00
|
|
|
|
|
|
|
class ServerCursorReference {
|
|
|
|
public:
|
|
|
|
ServerCursorReference()
|
|
|
|
: fCursor(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
ServerCursorReference(ServerCursor* cursor)
|
|
|
|
: fCursor(cursor)
|
|
|
|
{
|
|
|
|
if (fCursor)
|
|
|
|
fCursor->Acquire();
|
|
|
|
}
|
|
|
|
ServerCursorReference(const ServerCursorReference& other)
|
|
|
|
: fCursor(other.fCursor)
|
|
|
|
{
|
|
|
|
if (fCursor)
|
|
|
|
fCursor->Acquire();
|
|
|
|
}
|
|
|
|
virtual ~ServerCursorReference()
|
|
|
|
{
|
|
|
|
if (fCursor)
|
|
|
|
fCursor->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
ServerCursorReference& operator=(const ServerCursorReference& other)
|
|
|
|
{
|
|
|
|
SetCursor(other.fCursor);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCursor(ServerCursor* cursor)
|
|
|
|
{
|
|
|
|
if (fCursor == cursor)
|
|
|
|
return;
|
2008-04-08 12:12:38 +04:00
|
|
|
if (cursor)
|
|
|
|
cursor->Acquire();
|
|
|
|
ServerCursor* oldCursor = fCursor;
|
2008-04-02 15:12:39 +04:00
|
|
|
fCursor = cursor;
|
2008-04-08 12:12:38 +04:00
|
|
|
if (oldCursor)
|
|
|
|
oldCursor->Release();
|
2008-04-02 15:12:39 +04:00
|
|
|
}
|
|
|
|
ServerCursor* Cursor() const
|
|
|
|
{
|
|
|
|
return fCursor;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
ServerCursor* fCursor;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-03-18 19:42:14 +03:00
|
|
|
#endif // SERVER_CURSOR_H
|