Cleanup and style changes. Removed global cursormanager as each RootLayer has it's own.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13724 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+191
-240
@@ -24,18 +24,12 @@
|
|||||||
// Description: Handles the system's cursor infrastructure
|
// Description: Handles the system's cursor infrastructure
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include "CursorManager.h"
|
|
||||||
#include "ServerCursor.h"
|
|
||||||
#include "CursorData.h"
|
|
||||||
#include "ServerScreen.h"
|
|
||||||
#include "ServerConfig.h"
|
|
||||||
#include <Errors.h>
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <string.h>
|
#include "CursorData.h"
|
||||||
|
#include "CursorManager.h"
|
||||||
//! The global cursor manager object. Allocated and freed by AppServer class
|
#include "ServerCursor.h"
|
||||||
CursorManager *cursormanager;
|
#include "ServerConfig.h"
|
||||||
|
|
||||||
//! Initializes the CursorManager
|
//! Initializes the CursorManager
|
||||||
CursorManager::CursorManager()
|
CursorManager::CursorManager()
|
||||||
@@ -44,105 +38,99 @@ CursorManager::CursorManager()
|
|||||||
fTokenizer.ExcludeValue(B_ERROR);
|
fTokenizer.ExcludeValue(B_ERROR);
|
||||||
|
|
||||||
// Set system cursors to "unassigned"
|
// Set system cursors to "unassigned"
|
||||||
ServerCursor *cdefault=new ServerCursor(default_cursor_data);
|
fDefaultCursor = new ServerCursor(default_cursor_data);
|
||||||
AddCursor(cdefault);
|
AddCursor(fDefaultCursor);
|
||||||
fDefaultCursor=cdefault;
|
|
||||||
|
|
||||||
ServerCursor *ctext=new ServerCursor(default_text_data);
|
|
||||||
AddCursor(ctext);
|
|
||||||
fTextCursor=ctext;
|
|
||||||
|
|
||||||
ServerCursor *cmove=new ServerCursor(default_move_data);
|
fTextCursor = new ServerCursor(default_text_data);
|
||||||
AddCursor(cmove);
|
AddCursor(fTextCursor);
|
||||||
fMoveCursor=cmove;
|
|
||||||
|
|
||||||
ServerCursor *cdrag=new ServerCursor(default_drag_data);
|
fMoveCursor = new ServerCursor(default_move_data);
|
||||||
AddCursor(cdrag);
|
AddCursor(fMoveCursor);
|
||||||
fDragCursor=cdrag;
|
|
||||||
|
|
||||||
ServerCursor *cresize=new ServerCursor(default_resize_data);
|
fDragCursor = new ServerCursor(default_drag_data);
|
||||||
AddCursor(cresize);
|
AddCursor(fDragCursor);
|
||||||
fResizeCursor=cresize;
|
|
||||||
|
|
||||||
ServerCursor *cresizenwse=new ServerCursor(default_resize_nwse_data);
|
fResizeCursor = new ServerCursor(default_resize_data);
|
||||||
AddCursor(cresizenwse);
|
AddCursor(fResizeCursor);
|
||||||
fNWSECursor=cresizenwse;
|
|
||||||
|
|
||||||
ServerCursor *cresizenesw=new ServerCursor(default_resize_nesw_data);
|
fNWSECursor = new ServerCursor(default_resize_nwse_data);
|
||||||
AddCursor(cresizenesw);
|
AddCursor(fNWSECursor);
|
||||||
fNESWCursor=cresizenesw;
|
|
||||||
|
|
||||||
ServerCursor *cresizens=new ServerCursor(default_resize_ns_data);
|
fNESWCursor = new ServerCursor(default_resize_nesw_data);
|
||||||
AddCursor(cresizens);
|
AddCursor(fNESWCursor);
|
||||||
fNSCursor=cresizens;
|
|
||||||
|
|
||||||
ServerCursor *cresizeew=new ServerCursor(default_resize_ew_data);
|
fNSCursor = new ServerCursor(default_resize_ns_data);
|
||||||
AddCursor(cresizeew);
|
AddCursor(fNSCursor);
|
||||||
fEWCursor=cresizeew;
|
|
||||||
|
|
||||||
|
fEWCursor = new ServerCursor(default_resize_ew_data);
|
||||||
|
AddCursor(fEWCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Does all the teardown
|
//! Does all the teardown
|
||||||
CursorManager::~CursorManager()
|
CursorManager::~CursorManager()
|
||||||
{
|
{
|
||||||
ServerCursor *temp;
|
for (int32 i = 0; i < fCursorList.CountItems(); i++) {
|
||||||
for(int32 i=0; i<fCursorList.CountItems();i++)
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(i);
|
||||||
{
|
if (cursor)
|
||||||
temp=(ServerCursor*)fCursorList.ItemAt(i);
|
delete cursor;
|
||||||
if(temp)
|
|
||||||
delete temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that it is not necessary to remove and delete the system
|
// Note that it is not necessary to remove and delete the system
|
||||||
// cursors. These cursors are kept in the list with a NULL application
|
// cursors. These cursors are kept in the list with a empty application
|
||||||
// signature so they cannot be removed very easily except via
|
// signature so they cannot be removed very easily except via
|
||||||
// SetCursor(cursor_which). At shutdown, they are removed with the
|
// SetCursor(cursor_which). At shutdown, they are removed with the
|
||||||
// above loop.
|
// above loop.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Registers a cursor with the manager.
|
\brief Registers a cursor with the manager.
|
||||||
\param sc ServerCursor object to register
|
\param sc ServerCursor object to register
|
||||||
\return The token assigned to the cursor or B_ERROR if sc is NULL
|
\return The token assigned to the cursor or B_ERROR if sc is NULL
|
||||||
*/
|
*/
|
||||||
int32 CursorManager::AddCursor(ServerCursor *sc)
|
int32
|
||||||
|
CursorManager::AddCursor(ServerCursor *cursor)
|
||||||
{
|
{
|
||||||
if(!sc)
|
if (!cursor)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fCursorList.AddItem(sc);
|
|
||||||
int32 value=fTokenizer.GetToken();
|
fCursorList.AddItem(cursor);
|
||||||
sc->fToken=value;
|
int32 token = fTokenizer.GetToken();
|
||||||
|
cursor->fToken = token;
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
return token;
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Removes a cursor from the internal list and deletes it
|
\brief Removes a cursor from the internal list and deletes it
|
||||||
\param token ID value of the cursor to be deleted
|
\param token ID value of the cursor to be deleted
|
||||||
|
|
||||||
If the cursor is not found, this call does nothing
|
If the cursor is not found, this call does nothing
|
||||||
*/
|
*/
|
||||||
void CursorManager::DeleteCursor(int32 token)
|
void
|
||||||
|
CursorManager::DeleteCursor(int32 token)
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
ServerCursor *temp;
|
for (int32 i = 0; i < fCursorList.CountItems(); i++) {
|
||||||
for(int32 i=0; i<fCursorList.CountItems();i++)
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(i);
|
||||||
{
|
|
||||||
temp=(ServerCursor*)fCursorList.ItemAt(i);
|
if (cursor && cursor->fToken == token) {
|
||||||
if(temp && temp->fToken==token)
|
|
||||||
{
|
|
||||||
fCursorList.RemoveItem(i);
|
fCursorList.RemoveItem(i);
|
||||||
delete temp;
|
delete cursor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Removes and deletes all of an application's cursors
|
\brief Removes and deletes all of an application's cursors
|
||||||
\param signature Signature to which the cursors belong
|
\param signature Signature to which the cursors belong
|
||||||
@@ -151,10 +139,13 @@ void
|
|||||||
CursorManager::RemoveAppCursors(team_id team)
|
CursorManager::RemoveAppCursors(team_id team)
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
ServerCursor *cursor;
|
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
while ((cursor = (ServerCursor*)fCursorList.ItemAt(index)) != NULL) {
|
while (index < fCursorList.CountItems()) {
|
||||||
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(index);
|
||||||
|
if (!cursor)
|
||||||
|
break;
|
||||||
|
|
||||||
if (cursor->OwningTeam() == team) {
|
if (cursor->OwningTeam() == team) {
|
||||||
fCursorList.RemoveItem(index);
|
fCursorList.RemoveItem(index);
|
||||||
delete cursor;
|
delete cursor;
|
||||||
@@ -165,170 +156,161 @@ CursorManager::RemoveAppCursors(team_id team)
|
|||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets all the cursors from a specified CursorSet
|
\brief Sets all the cursors from a specified CursorSet
|
||||||
\param path Path to the cursor set
|
\param path Path to the cursor set
|
||||||
|
|
||||||
All cursors in the set will be assigned. If the set does not specify a cursor for a
|
All cursors in the set will be assigned. If the set does not specify a
|
||||||
particular cursor specifier, it will remain unchanged. This function will fail if passed
|
cursor for a particular cursor specifier, it will remain unchanged.
|
||||||
a NULL path, an invalid path, or the path to a non-CursorSet file.
|
This function will fail if passed a NULL path, an invalid path, or the
|
||||||
|
path to a non-CursorSet file.
|
||||||
*/
|
*/
|
||||||
void CursorManager::SetCursorSet(const char *path)
|
void
|
||||||
|
CursorManager::SetCursorSet(const char *path)
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
CursorSet cs(NULL);
|
CursorSet cursorSet(NULL);
|
||||||
|
|
||||||
if(!path || cs.Load(path)!=B_OK)
|
if (!path || cursorSet.Load(path) != B_OK)
|
||||||
return;
|
return;
|
||||||
ServerCursor *csr;
|
|
||||||
|
ServerCursor *cursor = NULL;
|
||||||
if(cs.FindCursor(B_CURSOR_DEFAULT,&csr)==B_OK)
|
|
||||||
{
|
if (cursorSet.FindCursor(B_CURSOR_DEFAULT, &cursor) == B_OK) {
|
||||||
if(fDefaultCursor)
|
if (fDefaultCursor)
|
||||||
delete fDefaultCursor;
|
delete fDefaultCursor;
|
||||||
fDefaultCursor=csr;
|
fDefaultCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_TEXT,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_TEXT, &cursor) == B_OK) {
|
||||||
{
|
if (fTextCursor)
|
||||||
if(fTextCursor)
|
|
||||||
delete fTextCursor;
|
delete fTextCursor;
|
||||||
fTextCursor=csr;
|
fTextCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_MOVE,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_MOVE, &cursor) == B_OK) {
|
||||||
{
|
if (fMoveCursor)
|
||||||
if(fMoveCursor)
|
|
||||||
delete fMoveCursor;
|
delete fMoveCursor;
|
||||||
fMoveCursor=csr;
|
fMoveCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_DRAG,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_DRAG, &cursor) == B_OK) {
|
||||||
{
|
if (fDragCursor)
|
||||||
if(fDragCursor)
|
|
||||||
delete fDragCursor;
|
delete fDragCursor;
|
||||||
fDragCursor=csr;
|
fDragCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_RESIZE,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE, &cursor) == B_OK) {
|
||||||
{
|
if (fResizeCursor)
|
||||||
if(fResizeCursor)
|
|
||||||
delete fResizeCursor;
|
delete fResizeCursor;
|
||||||
fResizeCursor=csr;
|
fResizeCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_RESIZE_NWSE,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_NWSE, &cursor) == B_OK) {
|
||||||
{
|
if (fNWSECursor)
|
||||||
if(fNWSECursor)
|
|
||||||
delete fNWSECursor;
|
delete fNWSECursor;
|
||||||
fNWSECursor=csr;
|
fNWSECursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_RESIZE_NESW,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_NESW, &cursor) == B_OK) {
|
||||||
{
|
if (fNESWCursor)
|
||||||
if(fNESWCursor)
|
|
||||||
delete fNESWCursor;
|
delete fNESWCursor;
|
||||||
fNESWCursor=csr;
|
fNESWCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_RESIZE_NS,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_NS, &cursor) == B_OK) {
|
||||||
{
|
if (fNSCursor)
|
||||||
if(fNSCursor)
|
|
||||||
delete fNSCursor;
|
delete fNSCursor;
|
||||||
fNSCursor=csr;
|
fNSCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cs.FindCursor(B_CURSOR_RESIZE_EW,&csr)==B_OK)
|
if (cursorSet.FindCursor(B_CURSOR_RESIZE_EW, &cursor) == B_OK) {
|
||||||
{
|
if (fEWCursor)
|
||||||
if(fEWCursor)
|
|
||||||
delete fEWCursor;
|
delete fEWCursor;
|
||||||
fEWCursor=csr;
|
fEWCursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Acquire the cursor which is used for a particular system cursor
|
\brief Acquire the cursor which is used for a particular system cursor
|
||||||
\param which Which system cursor to get
|
\param which Which system cursor to get
|
||||||
\return Pointer to the particular cursor used or NULL if which is
|
\return Pointer to the particular cursor used or NULL if which is
|
||||||
invalid or the cursor has not been assigned
|
invalid or the cursor has not been assigned
|
||||||
*/
|
*/
|
||||||
ServerCursor *CursorManager::GetCursor(cursor_which which)
|
ServerCursor *
|
||||||
|
CursorManager::GetCursor(cursor_which which)
|
||||||
{
|
{
|
||||||
ServerCursor *temp=NULL;
|
ServerCursor *cursor = NULL;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
switch(which)
|
switch (which) {
|
||||||
{
|
|
||||||
case B_CURSOR_DEFAULT:
|
case B_CURSOR_DEFAULT:
|
||||||
{
|
cursor = fDefaultCursor;
|
||||||
temp=fDefaultCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_TEXT:
|
case B_CURSOR_TEXT:
|
||||||
{
|
cursor = fTextCursor;
|
||||||
temp=fTextCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_MOVE:
|
case B_CURSOR_MOVE:
|
||||||
{
|
cursor = fMoveCursor;
|
||||||
temp=fMoveCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_DRAG:
|
case B_CURSOR_DRAG:
|
||||||
{
|
cursor = fDragCursor;
|
||||||
temp=fDragCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE:
|
case B_CURSOR_RESIZE:
|
||||||
{
|
cursor = fResizeCursor;
|
||||||
temp=fResizeCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_NWSE:
|
case B_CURSOR_RESIZE_NWSE:
|
||||||
{
|
cursor = fNWSECursor;
|
||||||
temp=fNWSECursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_NESW:
|
case B_CURSOR_RESIZE_NESW:
|
||||||
{
|
cursor = fNESWCursor;
|
||||||
temp=fNESWCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_NS:
|
case B_CURSOR_RESIZE_NS:
|
||||||
{
|
cursor = fNSCursor;
|
||||||
temp=fNSCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_EW:
|
case B_CURSOR_RESIZE_EW:
|
||||||
{
|
cursor = fEWCursor;
|
||||||
temp=fEWCursor;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
return temp;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Gets the current system cursor value
|
\brief Gets the current system cursor value
|
||||||
\return The current cursor value or CURSOR_OTHER if some non-system cursor
|
\return The current cursor value or CURSOR_OTHER if some non-system cursor
|
||||||
*/
|
*/
|
||||||
cursor_which CursorManager::GetCursorWhich(void)
|
cursor_which
|
||||||
|
CursorManager::GetCursorWhich()
|
||||||
{
|
{
|
||||||
cursor_which temp;
|
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
temp=fCurrentWhich;
|
|
||||||
|
// ToDo: Where is fCurrentWhich set?
|
||||||
|
cursor_which which;
|
||||||
|
which = fCurrentWhich;
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
return temp;
|
return which;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets the specified system cursor to the a particular cursor
|
\brief Sets the specified system cursor to the a particular cursor
|
||||||
\param which Which system cursor to change
|
\param which Which system cursor to change
|
||||||
@@ -338,34 +320,28 @@ cursor_which CursorManager::GetCursorWhich(void)
|
|||||||
system will take ownership of the cursor and deleting the cursor
|
system will take ownership of the cursor and deleting the cursor
|
||||||
will have no effect on the system.
|
will have no effect on the system.
|
||||||
*/
|
*/
|
||||||
void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
void
|
||||||
|
CursorManager::ChangeCursor(cursor_which which, int32 token)
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
// Find the cursor, based on the token
|
// Find the cursor, based on the token
|
||||||
ServerCursor *cursor=FindCursor(token);
|
ServerCursor *cursor = FindCursor(token);
|
||||||
|
|
||||||
// Did we find a cursor with this token?
|
// Did we find a cursor with this token?
|
||||||
if(!cursor)
|
if (!cursor) {
|
||||||
{
|
|
||||||
Unlock();
|
Unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the assignment
|
// Do the assignment
|
||||||
switch(which)
|
switch (which) {
|
||||||
{
|
|
||||||
case B_CURSOR_DEFAULT:
|
case B_CURSOR_DEFAULT:
|
||||||
{
|
{
|
||||||
if(fDefaultCursor)
|
if (fDefaultCursor)
|
||||||
delete fDefaultCursor;
|
delete fDefaultCursor;
|
||||||
|
|
||||||
fDefaultCursor=cursor;
|
fDefaultCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_TEXT:
|
case B_CURSOR_TEXT:
|
||||||
@@ -373,11 +349,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fTextCursor)
|
if(fTextCursor)
|
||||||
delete fTextCursor;
|
delete fTextCursor;
|
||||||
|
|
||||||
fTextCursor=cursor;
|
fTextCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_MOVE:
|
case B_CURSOR_MOVE:
|
||||||
@@ -385,11 +357,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fMoveCursor)
|
if(fMoveCursor)
|
||||||
delete fMoveCursor;
|
delete fMoveCursor;
|
||||||
|
|
||||||
fMoveCursor=cursor;
|
fMoveCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_DRAG:
|
case B_CURSOR_DRAG:
|
||||||
@@ -397,11 +365,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fDragCursor)
|
if(fDragCursor)
|
||||||
delete fDragCursor;
|
delete fDragCursor;
|
||||||
|
|
||||||
fDragCursor=cursor;
|
fDragCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_RESIZE:
|
case B_CURSOR_RESIZE:
|
||||||
@@ -409,11 +373,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fResizeCursor)
|
if(fResizeCursor)
|
||||||
delete fResizeCursor;
|
delete fResizeCursor;
|
||||||
|
|
||||||
fResizeCursor=cursor;
|
fResizeCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_RESIZE_NWSE:
|
case B_CURSOR_RESIZE_NWSE:
|
||||||
@@ -421,11 +381,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fNWSECursor)
|
if(fNWSECursor)
|
||||||
delete fNWSECursor;
|
delete fNWSECursor;
|
||||||
|
|
||||||
fNWSECursor=cursor;
|
fNWSECursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_RESIZE_NESW:
|
case B_CURSOR_RESIZE_NESW:
|
||||||
@@ -433,11 +389,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fNESWCursor)
|
if(fNESWCursor)
|
||||||
delete fNESWCursor;
|
delete fNESWCursor;
|
||||||
|
|
||||||
fNESWCursor=cursor;
|
fNESWCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_RESIZE_NS:
|
case B_CURSOR_RESIZE_NS:
|
||||||
@@ -445,11 +397,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fNSCursor)
|
if(fNSCursor)
|
||||||
delete fNSCursor;
|
delete fNSCursor;
|
||||||
|
|
||||||
fNSCursor=cursor;
|
fNSCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_CURSOR_RESIZE_EW:
|
case B_CURSOR_RESIZE_EW:
|
||||||
@@ -457,61 +405,64 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
if(fEWCursor)
|
if(fEWCursor)
|
||||||
delete fEWCursor;
|
delete fEWCursor;
|
||||||
|
|
||||||
fEWCursor=cursor;
|
fEWCursor = cursor;
|
||||||
|
|
||||||
if(cursor->GetAppSignature())
|
|
||||||
cursor->SetAppSignature("");
|
|
||||||
fCursorList.RemoveItem(cursor);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
Unlock();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cursor->GetAppSignature())
|
||||||
|
cursor->SetAppSignature("");
|
||||||
|
|
||||||
|
fCursorList.RemoveItem(cursor);
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Internal function which finds the cursor with a particular ID
|
\brief Internal function which finds the cursor with a particular ID
|
||||||
\param token ID of the cursor to find
|
\param token ID of the cursor to find
|
||||||
\return The cursor or NULL if not found
|
\return The cursor or NULL if not found
|
||||||
*/
|
*/
|
||||||
ServerCursor *CursorManager::FindCursor(int32 token)
|
ServerCursor *
|
||||||
|
CursorManager::FindCursor(int32 token)
|
||||||
{
|
{
|
||||||
ServerCursor *temp;
|
for (int32 i = 0; i < fCursorList.CountItems(); i++) {
|
||||||
for(int32 i=0; i<fCursorList.CountItems();i++)
|
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(i);
|
||||||
{
|
if (cursor && cursor->fToken == token)
|
||||||
temp=(ServerCursor*)fCursorList.ItemAt(i);
|
return cursor;
|
||||||
if(temp && temp->fToken==token)
|
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Sets the cursors to the defaults and saves them to CURSOR_SETTINGS_DIR/"d
|
//! Sets the cursors to the defaults and saves them to CURSOR_SETTINGS_DIR/"d
|
||||||
void CursorManager::SetDefaults(void)
|
void
|
||||||
|
CursorManager::SetDefaults()
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
CursorSet cs("Default");
|
CursorSet cursorSet("Default");
|
||||||
cs.AddCursor(B_CURSOR_DEFAULT,default_cursor_data);
|
cursorSet.AddCursor(B_CURSOR_DEFAULT, default_cursor_data);
|
||||||
cs.AddCursor(B_CURSOR_TEXT,default_text_data);
|
cursorSet.AddCursor(B_CURSOR_TEXT, default_text_data);
|
||||||
cs.AddCursor(B_CURSOR_MOVE,default_move_data);
|
cursorSet.AddCursor(B_CURSOR_MOVE, default_move_data);
|
||||||
cs.AddCursor(B_CURSOR_DRAG,default_drag_data);
|
cursorSet.AddCursor(B_CURSOR_DRAG, default_drag_data);
|
||||||
cs.AddCursor(B_CURSOR_RESIZE,default_resize_data);
|
cursorSet.AddCursor(B_CURSOR_RESIZE, default_resize_data);
|
||||||
cs.AddCursor(B_CURSOR_RESIZE_NWSE,default_resize_nwse_data);
|
cursorSet.AddCursor(B_CURSOR_RESIZE_NWSE, default_resize_nwse_data);
|
||||||
cs.AddCursor(B_CURSOR_RESIZE_NESW,default_resize_nesw_data);
|
cursorSet.AddCursor(B_CURSOR_RESIZE_NESW, default_resize_nesw_data);
|
||||||
cs.AddCursor(B_CURSOR_RESIZE_NS,default_resize_ns_data);
|
cursorSet.AddCursor(B_CURSOR_RESIZE_NS, default_resize_ns_data);
|
||||||
cs.AddCursor(B_CURSOR_RESIZE_EW,default_resize_ew_data);
|
cursorSet.AddCursor(B_CURSOR_RESIZE_EW, default_resize_ew_data);
|
||||||
|
|
||||||
BDirectory dir;
|
BDirectory dir;
|
||||||
if(dir.SetTo(CURSOR_SET_DIR)==B_ENTRY_NOT_FOUND)
|
if (dir.SetTo(CURSOR_SET_DIR) == B_ENTRY_NOT_FOUND)
|
||||||
create_directory(CURSOR_SET_DIR,0777);
|
create_directory(CURSOR_SET_DIR, 0777);
|
||||||
|
|
||||||
BString string(CURSOR_SET_DIR);
|
BString string(CURSOR_SET_DIR);
|
||||||
string+="Default";
|
string += "Default";
|
||||||
cs.Save(string.String(),B_CREATE_FILE | B_FAIL_IF_EXISTS);
|
cursorSet.Save(string.String(), B_CREATE_FILE | B_FAIL_IF_EXISTS);
|
||||||
|
|
||||||
SetCursorSet(string.String());
|
SetCursorSet(string.String());
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,8 @@
|
|||||||
#define CURSORMANAGER_H_
|
#define CURSORMANAGER_H_
|
||||||
|
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <OS.h>
|
|
||||||
#include <SysCursor.h>
|
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
#include "SysCursor.h"
|
||||||
#include "TokenHandler.h"
|
#include "TokenHandler.h"
|
||||||
|
|
||||||
class ServerCursor;
|
class ServerCursor;
|
||||||
@@ -52,9 +51,9 @@ public:
|
|||||||
void RemoveAppCursors(team_id team);
|
void RemoveAppCursors(team_id team);
|
||||||
void SetCursorSet(const char *path);
|
void SetCursorSet(const char *path);
|
||||||
ServerCursor *GetCursor(cursor_which which);
|
ServerCursor *GetCursor(cursor_which which);
|
||||||
cursor_which GetCursorWhich(void);
|
cursor_which GetCursorWhich();
|
||||||
void ChangeCursor(cursor_which which, int32 token);
|
void ChangeCursor(cursor_which which, int32 token);
|
||||||
void SetDefaults(void);
|
void SetDefaults();
|
||||||
ServerCursor *FindCursor(int32 token);
|
ServerCursor *FindCursor(int32 token);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -74,6 +73,4 @@ private:
|
|||||||
cursor_which fCurrentWhich;
|
cursor_which fCurrentWhich;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CursorManager *cursormanager;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user