2003-01-23 17:25:16 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-07-01 14:13:50 +04:00
|
|
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
2003-01-23 17:25:16 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: CursorManager.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Description: Handles the system's cursor infrastructure
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2005-07-18 01:26:28 +04:00
|
|
|
#include <Directory.h>
|
|
|
|
#include <String.h>
|
|
|
|
#include "CursorData.h"
|
2003-01-23 17:25:16 +03:00
|
|
|
#include "CursorManager.h"
|
|
|
|
#include "ServerCursor.h"
|
2003-07-24 23:38:24 +04:00
|
|
|
#include "ServerConfig.h"
|
2005-07-18 04:22:08 +04:00
|
|
|
#include "HaikuSystemCursor.h"
|
2003-01-24 17:00:48 +03:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
//! Initializes the CursorManager
|
2005-07-12 21:41:22 +04:00
|
|
|
CursorManager::CursorManager()
|
2005-11-04 19:56:15 +03:00
|
|
|
: BLocker("CursorManager")
|
2003-01-23 17:25:16 +03:00
|
|
|
{
|
|
|
|
// Error code for AddCursor
|
2004-06-26 06:15:48 +04:00
|
|
|
fTokenizer.ExcludeValue(B_ERROR);
|
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
|
|
|
|
#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);
|
|
|
|
AddCursor(fDefaultCursor);
|
2005-07-18 04:22:08 +04:00
|
|
|
#endif
|
2003-07-16 03:27:50 +04:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fTextCursor = new ServerCursor(default_text_data);
|
|
|
|
AddCursor(fTextCursor);
|
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++) {
|
|
|
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(i);
|
|
|
|
if (cursor)
|
|
|
|
delete cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
// Note that it is not necessary to remove and delete the system
|
2005-07-18 01:26:28 +04:00
|
|
|
// cursors. These cursors are kept in the list with a empty application
|
2003-01-23 17:25:16 +03:00
|
|
|
// signature so they cannot be removed very easily except via
|
|
|
|
// SetCursor(cursor_which). At shutdown, they are removed with the
|
|
|
|
// above loop.
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
CursorManager::AddCursor(ServerCursor *cursor)
|
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);
|
|
|
|
int32 token = fTokenizer.GetToken();
|
|
|
|
cursor->fToken = token;
|
|
|
|
|
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
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
/*!
|
|
|
|
\brief Removes a cursor from the internal list and deletes it
|
|
|
|
\param token ID value of the cursor to be deleted
|
|
|
|
|
|
|
|
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
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
for (int32 i = 0; i < fCursorList.CountItems(); i++) {
|
|
|
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(i);
|
|
|
|
|
|
|
|
if (cursor && cursor->fToken == token) {
|
2005-01-19 19:46:36 +03:00
|
|
|
fCursorList.RemoveItem(i);
|
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
|
|
|
|
CursorManager::RemoveAppCursors(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
|
|
|
|
2005-07-01 14:13:50 +04:00
|
|
|
int32 index = 0;
|
2005-07-18 01:26:28 +04:00
|
|
|
while (index < fCursorList.CountItems()) {
|
|
|
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(index);
|
|
|
|
if (!cursor)
|
|
|
|
break;
|
|
|
|
|
2005-07-01 14:13:50 +04:00
|
|
|
if (cursor->OwningTeam() == team) {
|
|
|
|
fCursorList.RemoveItem(index);
|
|
|
|
delete cursor;
|
|
|
|
} else
|
|
|
|
index++;
|
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
|
|
|
{
|
|
|
|
Lock();
|
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
|
|
|
}
|
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 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
|
|
|
{
|
2005-07-18 01:26:28 +04:00
|
|
|
ServerCursor *cursor = NULL;
|
2003-07-24 23:38:24 +04:00
|
|
|
Lock();
|
2005-07-18 01:26:28 +04:00
|
|
|
|
|
|
|
switch (which) {
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_DEFAULT:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fDefaultCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_TEXT:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fTextCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_MOVE:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fMoveCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_DRAG:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fDragCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fResizeCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_NWSE:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fNWSECursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_NESW:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fNESWCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_NS:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fNSCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
case B_CURSOR_RESIZE_EW:
|
2005-07-18 01:26:28 +04:00
|
|
|
cursor = fEWCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
2005-07-18 01:26:28 +04:00
|
|
|
|
2003-01-23 17:25:16 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
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 cursor;
|
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-07-18 01:26:28 +04:00
|
|
|
if (fDefaultCursor)
|
2004-06-26 06:15:48 +04:00
|
|
|
delete fDefaultCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fDefaultCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_TEXT:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fTextCursor)
|
|
|
|
delete fTextCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fTextCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_MOVE:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fMoveCursor)
|
|
|
|
delete fMoveCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fMoveCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_DRAG:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fDragCursor)
|
|
|
|
delete fDragCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fDragCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_RESIZE:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fResizeCursor)
|
|
|
|
delete fResizeCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fResizeCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_RESIZE_NWSE:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fNWSECursor)
|
|
|
|
delete fNWSECursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fNWSECursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_RESIZE_NESW:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fNESWCursor)
|
|
|
|
delete fNESWCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fNESWCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_RESIZE_NS:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fNSCursor)
|
|
|
|
delete fNSCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fNSCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_CURSOR_RESIZE_EW:
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fEWCursor)
|
|
|
|
delete fEWCursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
|
2005-07-18 01:26:28 +04:00
|
|
|
fEWCursor = cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
if (cursor->GetAppSignature())
|
|
|
|
cursor->SetAppSignature("");
|
|
|
|
|
|
|
|
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-07-18 01:26:28 +04:00
|
|
|
for (int32 i = 0; i < fCursorList.CountItems(); i++) {
|
|
|
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(i);
|
|
|
|
if (cursor && cursor->fToken == token)
|
|
|
|
return cursor;
|
2003-01-23 17:25:16 +03:00
|
|
|
}
|
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();
|
|
|
|
}
|