haiku/docs/develop/servers/app_server/CursorManager.htm

180 lines
8.6 KiB
HTML
Raw Normal View History

<HTML>
<HEAD>
<TITLE>CursorManager.htm</TITLE>
<style type="text/css">
<!--
.Default {background-color: rgb(255,255,255); color: rgb(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 12pt}
.OBOS-Function-Def {background-color: rgb(255,255,255); color: rgb(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 16pt}
.OBOS-Title {background-color: rgb(255,255,255); color: rgb(0,128,0); font-family: 'Dutch801 Rm BT'; font-size: 24pt}
.Text-Background {background-color: rgb(255,255,255)}
.GR-Default {}
.Body {margin: 0px}
.Footer {margin: 0px}
.Header {margin: 0px}
.WP-Default {text-align: left; text-indent: 0px; margin-left: 0px; margin-right: 0px}
-->
</style>
</HEAD>
<BODY BGCOLOR="#ffffff">
<DIV class="sheet" id="Sheet 1">
<P class="Body" style="margin: 0px"><span class="OBOS-Title">CursorManager class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">The CursorManager class handles token creation, calling the cursor-related graphics driver functions, and freeing heap memory for all ServerCursor instances.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><BR>
Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=634 HEIGHT=156 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=216 HEIGHT=17>
<P class="Body" style="margin: 0px">CursorManager(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">~CursorManager(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=216 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 AddCursor(ServerCursor *c)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void DeleteCursor(int32 token)</P>
</TD>
</TR>
<TR>
<TD WIDTH=216 HEIGHT=17>
<P class="Body" style="margin: 0px">void RemoveAppCursors(ServerApp *a)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void ShowCursor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=216 HEIGHT=17>
<P class="Body" style="margin: 0px">void HideCursor(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void ObscureCursor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=216 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetCursor(int32 token)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">ServerCursor *GetCursor(cursor_which which)</P>
</TD>
</TR>
<TR>
<TD WIDTH=216 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetCursor(cursor_which which)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">void ChangeCursor(cursor_which which,</P>
<P class="Body" style="margin: 0px">int32 token)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">CursorManager(void)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
<BR>
1) Create the cursor list empty</P>
<P class="Body" style="margin: 0px">2) Set the token index to 0</P>
<P class="Body" style="margin: 0px">3) Allocate the default system cursor and pass it to AddCursor</P>
<P class="Body" style="margin: 0px">4) Initialize the member pointer for the graphics driver</P>
<P class="Body" style="margin: 0px">5) Create the cursorlock semaphore</P>
<P class="Body" style="margin: 0px">6) Call SetDefaultCursor</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~CursorManager(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Empty and delete the cursor list</P>
<P class="Body" style="margin: 0px">2) Delete the cursorlock semaphore</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 AddCursor(ServerCursor *sc)</span></P>
<P class="Body" style="margin: 0px"><BR>
AddCursor() is used to register the cursor in question with the manager, allowing for the user application to have the identifying token, if necessary. The cursor becomes the property of the manager. If a user application deletes a BCursor, its ServerApp will call DeleteCursor().</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire cursor lock</P>
<P class="Body" style="margin: 0px">2) Add *sc to the cursor list</P>
<P class="Body" style="margin: 0px">3) Set sc-&gt;token to the current token index value</P>
<P class="Body" style="margin: 0px">4) Increment the token index</P>
<P class="Body" style="margin: 0px">5) Assign sc-&gt;token to temporary variable</P>
<P class="Body" style="margin: 0px">6) Release cursor lock</P>
<P class="Body" style="margin: 0px">7) Return the saved token value</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DeleteCursor(int32 ctoken)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire cursor lock</P>
<P class="Body" style="margin: 0px">2) Iterate through the cursor list, looking for ctoken</P>
<P class="Body" style="margin: 0px">3) If any ServerCursor-&gt;token equals ctoken, remove and delete it</P>
<P class="Body" style="margin: 0px">4) Release cursor lock</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RemoveAppCursors(ServerApp *app)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire cursor lock</P>
<P class="Body" style="margin: 0px">2) Iterate through the cursor list, checking each cursor's ServerApp pointer</P>
<P class="Body" style="margin: 0px">3) If any have a ServerApp pointer which matches the passed pointer, remove and delete them</P>
<P class="Body" style="margin: 0px">4) Release cursor lock</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ShowCursor(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void HideCursor(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void ObscureCursor(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Simple pass-through functions which call the graphics driver's functions. Note that acquiring the cursor lock will be necessary for all three calls.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetCursor(int32 token)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetCursor(cursor_which cursor)</span></P>
<P class="Body" style="margin: 0px"><BR>
These set the current cursor for the graphics driver to the passed cursor, either one previously added via AddCursor or a system cursor.</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire cursor lock</P>
<P class="Body" style="margin: 0px"><BR>
Token version:</P>
<P class="Body" style="margin: 0px">2) Find the cursor in the cursor list and call the graphics driver if non-NULL</P>
<P class="Body" style="margin: 0px"><BR>
cursor_which version:</P>
<P class="Body" style="margin: 0px">2) determine which cursor to use via a switch statement and call the graphics driver with the internal pointer for the appropriate cursor</P>
<P class="Body" style="margin: 0px"><BR>
3) Release cursor lock</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">ServerCursor *GetCursor(cursor_which which)</span></P>
<P class="Body" style="margin: 0px"><BR>
GetCursor is intended for use in figuring out what cursor is in use for a particular system cursor.</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire cursor lock</P>
<P class="Body" style="margin: 0px">2) use a switch statement to figure which cursor to return and assign a temporary pointer its value</P>
<P class="Body" style="margin: 0px">3) Release cursor lock</P>
<P class="Body" style="margin: 0px">4) Return the temporary pointer</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ChangeCursor(cursor_which which, int32 token)</span></P>
<P class="Body" style="margin: 0px"><BR>
Calling ChangeCursor will allow a user to change a system cursor's appearance. Note that in calling this, the cursor changes ownership and belongs to the system. Thus, the BCursor destructor will not ultimately cause the cursor to be deleted.</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire cursor lock</P>
<P class="Body" style="margin: 0px">2) Call FindCursor and, if NULL, release the cursor lock and return</P>
<P class="Body" style="margin: 0px">3) Look up the pointer for the system cursor in question and check to see if it is active. If active, then set the local active flag to true. Set the system cursor pointer to the one looked up.</P>
<P class="Body" style="margin: 0px">4) If active flag is true, call SetCursor()</P>
<P class="Body" style="margin: 0px">5) Release cursor lock</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>