Files
haiku-beta6/src/kits/app/Cursor.cpp
T

115 lines
2.3 KiB
C++
Raw Normal View History

/*
2006-02-05 18:14:14 +00:00
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Frans van Nispen ([email protected])
* Gabe Yoder ([email protected])
2006-02-05 18:14:14 +00:00
* Axel Dörfler, [email protected]
*/
/** BCursor describes a view-wide or application-wide cursor. */
2002-07-09 12:24:59 +00:00
/**
@note: As BeOS only supports 16x16 monochrome cursors, and I would like
to see a nice shadowes one, we will need to extend this one.
*/
#include <AppDefs.h>
2002-07-09 12:24:59 +00:00
#include <Cursor.h>
2006-02-05 18:14:14 +00:00
2002-11-02 23:33:33 +00:00
#include <AppServerLink.h>
#include <ServerProtocol.h>
2002-07-09 12:24:59 +00:00
const BCursor *B_CURSOR_SYSTEM_DEFAULT;
const BCursor *B_CURSOR_I_BEAM;
// these are initialized in BApplication::InitData()
2002-07-09 12:24:59 +00:00
BCursor::BCursor(const void *cursorData)
2006-02-05 18:14:14 +00:00
:
fServerToken(-1),
2006-02-26 18:15:31 +00:00
fNeedToFree(false),
fPendingViewCursor(false)
2002-07-09 12:24:59 +00:00
{
2006-02-05 18:14:14 +00:00
const uint8 *data = (const uint8 *)cursorData;
if (data == B_HAND_CURSOR || data == B_I_BEAM_CURSOR) {
// just use the default cursors from the app_server
fServerToken = data == B_HAND_CURSOR ?
B_CURSOR_DEFAULT : B_CURSOR_TEXT;
return;
}
// Create a new cursor in the app_server
if (data == NULL
|| data[0] != 16 // size
|| data[1] != 1 // depth
|| data[2] >= 16 || data[3] >= 16) // hot-spot
2003-09-17 18:36:14 +00:00
return;
2003-09-17 18:36:14 +00:00
// Send data directly to server
2006-02-05 18:14:14 +00:00
BPrivate::AppServerLink link;
link.StartMessage(AS_CREATE_CURSOR);
link.Attach(cursorData, 68);
status_t status;
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
link.Read<int32>(&fServerToken);
fNeedToFree = true;
}
2002-07-09 12:24:59 +00:00
}
2002-07-09 12:24:59 +00:00
BCursor::BCursor(BMessage *data)
{
2006-02-05 18:14:14 +00:00
// undefined on BeOS
fServerToken = -1;
fNeedToFree = false;
2006-02-26 18:15:31 +00:00
fPendingViewCursor = false;
2002-07-09 12:24:59 +00:00
}
2002-07-09 12:24:59 +00:00
BCursor::~BCursor()
{
2003-09-17 18:36:14 +00:00
// Notify server to deallocate server-side objects for this cursor
2006-02-05 18:14:14 +00:00
if (fNeedToFree) {
BPrivate::AppServerLink link;
link.StartMessage(AS_DELETE_CURSOR);
link.Attach<int32>(fServerToken);
2006-02-26 18:15:31 +00:00
link.Attach<bool>(fPendingViewCursor);
2006-02-05 18:14:14 +00:00
link.Flush();
}
2002-07-09 12:24:59 +00:00
}
2006-02-05 18:14:14 +00:00
status_t
BCursor::Archive(BMessage *into, bool deep) const
2002-07-09 12:24:59 +00:00
{
2006-02-05 18:14:14 +00:00
// not implemented on BeOS
2002-07-09 12:24:59 +00:00
return B_OK;
}
2006-02-05 18:14:14 +00:00
BArchivable *
BCursor::Instantiate(BMessage *data)
2002-07-09 12:24:59 +00:00
{
2006-02-05 18:14:14 +00:00
// not implemented on BeOS
2002-07-09 12:24:59 +00:00
return NULL;
}
status_t
BCursor::Perform(perform_code d, void *arg)
2002-07-09 12:24:59 +00:00
{
return B_OK;
}
2002-11-02 23:33:33 +00:00
void BCursor::_ReservedCursor1() {}
void BCursor::_ReservedCursor2() {}
void BCursor::_ReservedCursor3() {}
void BCursor::_ReservedCursor4() {}