1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2005, Haiku 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: Cursor.cpp 23 // Author: Frans van Nispen (xlr8@tref.nl) 24 // Gabe Yoder (gyoder@stny.rr.com) 25 // Description: BCursor describes a view-wide or application-wide cursor. 26 //------------------------------------------------------------------------------ 27 /** 28 @note: As BeOS only supports 16x16 monochrome cursors, and I would like 29 to see a nice shadowes one, we will need to extend this one. 30 */ 31 32 // Standard Includes ----------------------------------------------------------- 33 34 // System Includes ------------------------------------------------------------- 35 #include <AppDefs.h> 36 #include <Cursor.h> 37 #include <PortLink.h> 38 #include <AppServerLink.h> 39 40 // Project Includes ------------------------------------------------------------ 41 #include <ServerProtocol.h> 42 43 44 const BCursor *B_CURSOR_SYSTEM_DEFAULT; 45 const BCursor *B_CURSOR_I_BEAM; 46 // these are initialized in BApplication::InitData() 47 48 49 BCursor::BCursor(const void *cursorData) 50 { 51 int8 *data = (int8 *)cursorData; 52 m_serverToken = 0; 53 54 if (data == NULL 55 || data[0] != 16 // size 56 || data[1] != 1 // depth 57 || data[2] >= 16 || data[3] >= 16) // hot-spot 58 return; 59 60 // Send data directly to server 61 BPrivate::AppServerLink serverlink; 62 int32 code = SERVER_FALSE; 63 64 serverlink.StartMessage(AS_CREATE_BCURSOR); 65 serverlink.Attach(cursorData, 68); 66 serverlink.FlushWithReply(code); 67 if (code == SERVER_TRUE) 68 serverlink.Read<int32>(&m_serverToken); 69 } 70 71 72 // undefined on BeOS 73 74 BCursor::BCursor(BMessage *data) 75 { 76 m_serverToken = 0; 77 } 78 79 80 BCursor::~BCursor() 81 { 82 // Notify server to deallocate server-side objects for this cursor 83 BPrivate::AppServerLink serverlink; 84 serverlink.StartMessage(AS_DELETE_BCURSOR); 85 serverlink.Attach<int32>(m_serverToken); 86 serverlink.Flush(); 87 } 88 89 90 // not implemented on BeOS 91 92 status_t BCursor::Archive(BMessage *into, bool deep) const 93 { 94 return B_OK; 95 } 96 97 98 // not implemented on BeOS 99 100 BArchivable *BCursor::Instantiate(BMessage *data) 101 { 102 return NULL; 103 } 104 105 106 status_t 107 BCursor::Perform(perform_code d, void *arg) 108 { 109 /* 110 printf("perform %d\n", (int)d); 111 */ 112 return B_OK; 113 } 114 115 116 void BCursor::_ReservedCursor1() {} 117 void BCursor::_ReservedCursor2() {} 118 void BCursor::_ReservedCursor3() {} 119 void BCursor::_ReservedCursor4() {} 120