2 * Copyright 2001-2006, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Frans van Nispen (xlr8@tref.nl)
7 * Gabe Yoder (gyoder@stny.rr.com)
8 * Axel Dörfler, axeld@pinc-software.de
11 /** BCursor describes a view-wide or application-wide cursor. */
14 @note: As BeOS only supports 16x16 monochrome cursors, and I would like
15 to see a nice shadowes one, we will need to extend this one.
21 #include <AppServerLink.h>
22 #include <ServerProtocol.h>
25 const BCursor
*B_CURSOR_SYSTEM_DEFAULT
;
26 const BCursor
*B_CURSOR_I_BEAM
;
27 // these are initialized in BApplication::InitData()
29 BCursor::BCursor(const void *cursorData
)
34 const uint8
*data
= (const uint8
*)cursorData
;
36 if (data
== B_HAND_CURSOR
|| data
== B_I_BEAM_CURSOR
) {
37 // just use the default cursors from the app_server
38 fServerToken
= data
== B_HAND_CURSOR
?
39 B_CURSOR_ID_SYSTEM_DEFAULT
: B_CURSOR_ID_I_BEAM
;
43 // Create a new cursor in the app_server
46 || data
[0] != 16 // size
47 || data
[1] != 1 // depth
48 || data
[2] >= 16 || data
[3] >= 16) // hot-spot
51 // Send data directly to server
52 BPrivate::AppServerLink link
;
53 link
.StartMessage(AS_CREATE_CURSOR
);
54 link
.Attach(cursorData
, 68);
57 if (link
.FlushWithReply(status
) == B_OK
&& status
== B_OK
) {
58 link
.Read
<int32
>(&fServerToken
);
64 BCursor::BCursor(BCursorID id
)
72 BCursor::BCursor(const BCursor
& other
)
81 BCursor::BCursor(BMessage
*data
)
96 BCursor::Archive(BMessage
*into
, bool deep
) const
98 // not implemented on BeOS
104 BCursor::Instantiate(BMessage
*data
)
106 // not implemented on BeOS
112 BCursor::operator=(const BCursor
& other
)
114 if (&other
!= this && other
!= *this) {
117 fServerToken
= other
.fServerToken
;
118 fNeedToFree
= other
.fNeedToFree
;
121 // Tell app_server that there is another reference for this
123 BPrivate::AppServerLink link
;
124 link
.StartMessage(AS_REFERENCE_CURSOR
);
125 link
.Attach
<int32
>(fServerToken
);
133 BCursor::operator==(const BCursor
& other
) const
135 return fServerToken
== other
.fServerToken
;
140 BCursor::operator!=(const BCursor
& other
) const
142 return fServerToken
!= other
.fServerToken
;
147 BCursor::Perform(perform_code d
, void *arg
)
153 void BCursor::_ReservedCursor1() {}
154 void BCursor::_ReservedCursor2() {}
155 void BCursor::_ReservedCursor3() {}
156 void BCursor::_ReservedCursor4() {}
160 BCursor::_FreeCursorData()
162 // Notify server to deallocate server-side objects for this cursor
164 BPrivate::AppServerLink link
;
165 link
.StartMessage(AS_DELETE_CURSOR
);
166 link
.Attach
<int32
>(fServerToken
);