2005-11-14 22:46:20 +03:00
|
|
|
/*
|
2006-02-05 21:14:14 +03:00
|
|
|
* Copyright 2001-2006, Haiku.
|
2005-11-14 22:46:20 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Handles the system's cursor infrastructure */
|
|
|
|
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
#include "CursorData.h"
|
2003-01-23 17:25:16 +03:00
|
|
|
#include "CursorManager.h"
|
2005-11-14 22:46:20 +03:00
|
|
|
#include "HaikuSystemCursor.h"
|
2003-01-23 17:25:16 +03:00
|
|
|
#include "ServerCursor.h"
|
2003-07-24 23:38:24 +04:00
|
|
|
#include "ServerConfig.h"
|
2005-11-14 22:46:20 +03:00
|
|
|
#include "ServerTokenSpace.h"
|
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
#include <Autolock.h>
|
|
|
|
#include <Directory.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2003-01-24 17:00:48 +03:00
|
|
|
|
2005-07-12 21:41:22 +04:00
|
|
|
CursorManager::CursorManager()
|
2006-02-05 21:14:14 +03:00
|
|
|
: BLocker("CursorManager")
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
|
|
|
// Set system cursors to "unassigned"
|
2005-07-18 04:22:08 +04:00
|
|
|
// ToDo: decide about default cursor
|
2005-11-14 22:46:20 +03:00
|
|
|
|
2005-07-18 04:22:08 +04:00
|
|
|
#if 1
|
|
|
|
fDefaultCursor = new ServerCursor(kHaikuCursorBits, kHaikuCursorWidth,
|
|
|
|
kHaikuCursorHeight, kHaikuCursorFormat);
|
|
|
|
// we just happen to know where the hotspot is
|
|
|
|
fDefaultCursor->SetHotSpot(BPoint(1, 0));
|
|
|
|
#else
|
2005-07-18 01:26:28 +04:00
|
|
|
fDefaultCursor = new ServerCursor(default_cursor_data);
|
2005-07-18 04:22:08 +04:00
|
|
|
#endif
|
2006-02-05 21:14:14 +03:00
|
|
|
AddCursor(fDefaultCursor, B_CURSOR_DEFAULT);
|
2003-07-16 03:27:50 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fTextCursor = new ServerCursor(default_text_data);
|
2006-02-05 21:14:14 +03:00
|
|
|
AddCursor(fTextCursor, B_CURSOR_TEXT);
|
2003-07-16 03:27:50 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fMoveCursor = new ServerCursor(default_move_data);
|
|
|
|
AddCursor(fMoveCursor);
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fDragCursor = new ServerCursor(default_drag_data);
|
|
|
|
AddCursor(fDragCursor);
|
2003-07-16 03:27:50 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fResizeCursor = new ServerCursor(default_resize_data);
|
|
|
|
AddCursor(fResizeCursor);
|
2003-07-16 03:27:50 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fNWSECursor = new ServerCursor(default_resize_nwse_data);
|
|
|
|
AddCursor(fNWSECursor);
|
2003-07-16 03:27:50 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fNESWCursor = new ServerCursor(default_resize_nesw_data);
|
|
|
|
AddCursor(fNESWCursor);
|
2003-07-16 03:27:50 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fNSCursor = new ServerCursor(default_resize_ns_data);
|
|
|
|
AddCursor(fNSCursor);
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fEWCursor = new ServerCursor(default_resize_ew_data);
|
|
|
|
AddCursor(fEWCursor);
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
//! Does all the teardown
|
2005-07-12 21:41:22 +04:00
|
|
|
CursorManager::~CursorManager()
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2005-07-18 01:26:28 +04:00
|
|
|
for (int32 i = 0; i < fCursorList.CountItems(); i++) {
|
2006-02-05 21:14:14 +03:00
|
|
|
delete (ServerCursor *)fCursorList.ItemAt(i);
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Registers a cursor with the manager.
|
|
|
|
\param sc ServerCursor object to register
|
|
|
|
\return The token assigned to the cursor or B_ERROR if sc is NULL
|
|
|
|
*/
|
2005-07-18 01:26:28 +04:00
|
|
|
int32
|
2006-02-05 21:14:14 +03:00
|
|
|
CursorManager::AddCursor(ServerCursor* cursor, int32 token)
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2005-07-18 01:26:28 +04:00
|
|
|
if (!cursor)
|
2003-01-23 17:25:16 +03:00
|
|
|
return B_ERROR;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
Lock();
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
fCursorList.AddItem(cursor);
|
2006-02-05 21:14:14 +03:00
|
|
|
if (token == -1)
|
|
|
|
cursor->fToken = fTokenSpace.NewToken(kCursorToken, cursor);
|
|
|
|
else {
|
|
|
|
fTokenSpace.SetToken(token, kCursorToken, cursor);
|
|
|
|
cursor->fToken = token;
|
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
Unlock();
|
2005-07-18 01:26:28 +04:00
|
|
|
return token;
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
ServerCursor*
|
|
|
|
CursorManager::_RemoveCursor(int32 index)
|
|
|
|
{
|
|
|
|
ServerCursor* cursor = (ServerCursor *)fCursorList.RemoveItem(index);
|
|
|
|
if (cursor != NULL)
|
|
|
|
fTokenSpace.RemoveToken(cursor->fToken);
|
|
|
|
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Removes a cursor from the internal list and deletes it
|
2006-02-05 21:14:14 +03:00
|
|
|
\param token Token of the cursor to be deleted
|
2003-01-23 17:25:16 +03:00
|
|
|
|
|
|
|
If the cursor is not found, this call does nothing
|
|
|
|
*/
|
2005-07-18 01:26:28 +04:00
|
|
|
void
|
|
|
|
CursorManager::DeleteCursor(int32 token)
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2003-07-24 23:38:24 +04:00
|
|
|
Lock();
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
for (int32 index = 0; index < fCursorList.CountItems(); index++) {
|
|
|
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(index);
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursor && cursor->fToken == token) {
|
2006-02-05 21:14:14 +03:00
|
|
|
_RemoveCursor(index);
|
2005-07-18 01:26:28 +04:00
|
|
|
delete cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
Unlock();
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Removes and deletes all of an application's cursors
|
|
|
|
\param signature Signature to which the cursors belong
|
|
|
|
*/
|
2005-07-01 14:13:50 +04:00
|
|
|
void
|
2006-02-05 21:14:14 +03:00
|
|
|
CursorManager::DeleteCursors(team_id team)
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2003-07-24 23:38:24 +04:00
|
|
|
Lock();
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
for (int32 index = fCursorList.CountItems(); index-- > 0;) {
|
2005-07-18 01:26:28 +04:00
|
|
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(index);
|
2006-02-05 21:14:14 +03:00
|
|
|
if (cursor->OwningTeam() != team)
|
|
|
|
continue;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
_RemoveCursor(index);
|
|
|
|
delete cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
2005-07-01 14:13:50 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
Unlock();
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
/*!
|
|
|
|
\brief Sets all the cursors from a specified CursorSet
|
|
|
|
\param path Path to the cursor set
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
All cursors in the set will be assigned. If the set does not specify a
|
|
|
|
cursor for a particular cursor specifier, it will remain unchanged.
|
|
|
|
This function will fail if passed a NULL path, an invalid path, or the
|
|
|
|
path to a non-CursorSet file.
|
2003-07-24 23:38:24 +04:00
|
|
|
*/
|
2005-07-18 01:26:28 +04:00
|
|
|
void
|
|
|
|
CursorManager::SetCursorSet(const char *path)
|
2003-07-24 23:38:24 +04:00
|
|
|
{
|
2006-02-05 21:14:14 +03:00
|
|
|
BAutolock locker (this);
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
CursorSet cursorSet(NULL);
|
|
|
|
|
|
|
|
if (!path || cursorSet.Load(path) != B_OK)
|
2003-07-24 23:38:24 +04:00
|
|
|
return;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
ServerCursor *cursor = NULL;
|
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_DEFAULT, &cursor) == B_OK) {
|
|
|
|
if (fDefaultCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fDefaultCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fDefaultCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_TEXT, &cursor) == B_OK) {
|
|
|
|
if (fTextCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fTextCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fTextCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_MOVE, &cursor) == B_OK) {
|
|
|
|
if (fMoveCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fMoveCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fMoveCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_DRAG, &cursor) == B_OK) {
|
|
|
|
if (fDragCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fDragCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fDragCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE, &cursor) == B_OK) {
|
|
|
|
if (fResizeCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fResizeCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fResizeCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_NWSE, &cursor) == B_OK) {
|
|
|
|
if (fNWSECursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fNWSECursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fNWSECursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_NESW, &cursor) == B_OK) {
|
|
|
|
if (fNESWCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fNESWCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fNESWCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_NS, &cursor) == B_OK) {
|
|
|
|
if (fNSCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fNSCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fNSCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_EW, &cursor) == B_OK) {
|
|
|
|
if (fEWCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fEWCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fEWCursor = cursor;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Acquire the cursor which is used for a particular system cursor
|
|
|
|
\param which Which system cursor to get
|
|
|
|
\return Pointer to the particular cursor used or NULL if which is
|
|
|
|
invalid or the cursor has not been assigned
|
|
|
|
*/
|
2005-07-18 01:26:28 +04:00
|
|
|
ServerCursor *
|
|
|
|
CursorManager::GetCursor(cursor_which which)
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2006-02-05 21:14:14 +03:00
|
|
|
BAutolock locker(this);
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
switch (which) {
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_DEFAULT:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fDefaultCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_TEXT:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fTextCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_MOVE:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fMoveCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_DRAG:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fDragCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fResizeCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_NWSE:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fNWSECursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_NESW:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fNESWCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_NS:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fNSCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_EW:
|
2006-02-05 21:14:14 +03:00
|
|
|
return fEWCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
default:
|
2006-02-05 21:14:14 +03:00
|
|
|
return NULL;
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Gets the current system cursor value
|
|
|
|
\return The current cursor value or CURSOR_OTHER if some non-system cursor
|
|
|
|
*/
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor_which
|
|
|
|
CursorManager::GetCursorWhich()
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2003-07-24 23:38:24 +04:00
|
|
|
Lock();
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
// ToDo: Where is fCurrentWhich set?
|
|
|
|
cursor_which which;
|
|
|
|
which = fCurrentWhich;
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
Unlock();
|
2005-07-18 01:26:28 +04:00
|
|
|
return which;
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Sets the specified system cursor to the a particular cursor
|
|
|
|
\param which Which system cursor to change
|
|
|
|
\param token The ID of the cursor to become the new one
|
|
|
|
|
|
|
|
A word of warning: once a cursor has been assigned to the system, the
|
|
|
|
system will take ownership of the cursor and deleting the cursor
|
2005-07-12 21:41:22 +04:00
|
|
|
will have no effect on the system.
|
2003-01-23 17:25:16 +03:00
|
|
|
*/
|
2005-07-18 01:26:28 +04:00
|
|
|
void
|
|
|
|
CursorManager::ChangeCursor(cursor_which which, int32 token)
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2003-07-24 23:38:24 +04:00
|
|
|
Lock();
|
2003-01-23 17:25:16 +03:00
|
|
|
|
|
|
|
// Find the cursor, based on the token
|
2005-07-18 01:26:28 +04:00
|
|
|
ServerCursor *cursor = FindCursor(token);
|
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
// Did we find a cursor with this token?
|
2005-07-18 01:26:28 +04:00
|
|
|
if (!cursor) {
|
2003-07-24 23:38:24 +04:00
|
|
|
Unlock();
|
2003-01-23 17:25:16 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do the assignment
|
2005-07-18 01:26:28 +04:00
|
|
|
switch (which) {
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_DEFAULT:
|
2005-11-14 22:46:20 +03:00
|
|
|
delete fDefaultCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fDefaultCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_TEXT:
|
|
|
|
delete fTextCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fTextCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_MOVE:
|
|
|
|
delete fMoveCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fMoveCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_DRAG:
|
|
|
|
delete fDragCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fDragCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_RESIZE:
|
|
|
|
delete fResizeCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fResizeCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_RESIZE_NWSE:
|
|
|
|
delete fNWSECursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fNWSECursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_RESIZE_NESW:
|
|
|
|
delete fNESWCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fNESWCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_RESIZE_NS:
|
|
|
|
delete fNSCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fNSCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
|
2005-11-14 22:46:20 +03:00
|
|
|
case B_CURSOR_RESIZE_EW:
|
|
|
|
delete fEWCursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
fEWCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-11-14 22:46:20 +03:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
default:
|
2005-07-18 01:26:28 +04:00
|
|
|
Unlock();
|
|
|
|
return;
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
fCursorList.RemoveItem(cursor);
|
2003-07-24 23:38:24 +04:00
|
|
|
Unlock();
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Internal function which finds the cursor with a particular ID
|
|
|
|
\param token ID of the cursor to find
|
|
|
|
\return The cursor or NULL if not found
|
|
|
|
*/
|
2005-07-18 01:26:28 +04:00
|
|
|
ServerCursor *
|
|
|
|
CursorManager::FindCursor(int32 token)
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
2005-11-14 22:46:20 +03:00
|
|
|
ServerCursor* cursor;
|
2006-02-05 21:14:14 +03:00
|
|
|
if (fTokenSpace.GetToken(token, kCursorToken, (void**)&cursor) == B_OK)
|
2005-11-14 22:46:20 +03:00
|
|
|
return cursor;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
//! Sets the cursors to the defaults and saves them to CURSOR_SETTINGS_DIR/"d
|
2005-07-18 01:26:28 +04:00
|
|
|
void
|
|
|
|
CursorManager::SetDefaults()
|
2003-07-24 23:38:24 +04:00
|
|
|
{
|
|
|
|
Lock();
|
2005-07-18 01:26:28 +04:00
|
|
|
CursorSet cursorSet("Default");
|
|
|
|
cursorSet.AddCursor(B_CURSOR_DEFAULT, default_cursor_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_TEXT, default_text_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_MOVE, default_move_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_DRAG, default_drag_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_RESIZE, default_resize_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_RESIZE_NWSE, default_resize_nwse_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_RESIZE_NESW, default_resize_nesw_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_RESIZE_NS, default_resize_ns_data);
|
|
|
|
cursorSet.AddCursor(B_CURSOR_RESIZE_EW, default_resize_ew_data);
|
2003-07-24 23:38:24 +04:00
|
|
|
|
|
|
|
BDirectory dir;
|
2005-07-18 01:26:28 +04:00
|
|
|
if (dir.SetTo(CURSOR_SET_DIR) == B_ENTRY_NOT_FOUND)
|
|
|
|
create_directory(CURSOR_SET_DIR, 0777);
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
BString string(CURSOR_SET_DIR);
|
2005-07-18 01:26:28 +04:00
|
|
|
string += "Default";
|
|
|
|
cursorSet.Save(string.String(), B_CREATE_FILE | B_FAIL_IF_EXISTS);
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
SetCursorSet(string.String());
|
|
|
|
Unlock();
|
|
|
|
}
|