Generate developer docs with Sphinx

An effort was started some time ago to consolidate all internal
documentation in the git tree. However, this was just an accumulation of
files in various formats without any strucutre or way to browse it,
which results in no one even knowing that we have docs here.

This converts most of the files to restructuredtext and uses Sphinx to
generate an HTML browsable user manual (with a table of content and a
first attempt to put things in a global hierarchy).

There are almost no changes to the documentation content in this commit
(some obviously obsolete things were removed). The plan is to get the
toolchain up and running to make these docs easily available, and only
then see about improving the content. We can migrate some things off the
wiki and website, and rework the table of contents to have some more
hierarchy levels because currently it's a bit messy.

Change-Id: I924ac9dc6e753887ab56f18a09bdb0a1e1793bfd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4370
Reviewed-by: Niels Sascha Reedijk <[email protected]>
This commit is contained in:
Adrien Destugues
2021-08-27 11:41:17 +00:00
committed by Adrien Destugues
parent 7f8195344a
commit a5061ecec5
146 changed files with 10937 additions and 12069 deletions
@@ -1,705 +0,0 @@
<HTML>
<HEAD>
<TITLE>AppServer.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">AppServer 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 AppServer class sits at the top of the hierarchy, starting and stopping services, monitoring for messages, and so forth.</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=617 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">AppServer(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">~AppServer(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">static int32 Poller(void *data)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">static int32 Picasso(void *data)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">thread_id Run(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void MainLoop(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">bool LoadDecorator(const char *path)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void DispatchMessage(int32 code, int8 *buffer)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void Broadcast(int32 code)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0)">void HandleKeyMessage(int32 code, int8 *buffer)</span></P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
Decorator * instantiate_decorator(Layer *owner, uint32 wflags, uint32 wlook)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">AppServer(void)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
1) Create the message and input ports</P>
<P class="Body" style="margin: 0px">2) Create any necessary semaphores for regulating the 3 main threads</P>
<P class="Body" style="margin: 0px">3) Initialize all member variables</P>
<P class="Body" style="margin: 0px">4) Allocate the application BList</P>
<P class="Body" style="margin: 0px">5) Read in and process all configuration data</P>
<P class="Body" style="margin: 0px">6) Initialize the desktop</P>
<P class="Body" style="margin: 0px">7) Spawn the Picasso and Poller threads</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~AppServer(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Shut down the desktop</P>
<P class="Body" style="margin: 0px">2) Empty and delete the application list</P>
<P class="Body" style="margin: 0px">3) Wait for Picasso and Poller to exit</P>
<P class="Body" style="margin: 0px">4) Free any allocated heap space</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void MainLoop(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
MainLoop is one large loop used to monitor the main message port in the app_server thread. This is a standard port-monitoring loop code:</P>
<P class="Body" style="margin: 0px"><BR>
1) Call port_buffer_size - which will block if the port is empty</P>
<P class="Body" style="margin: 0px">2) Allocate a buffer on the heap if the port buffer size is greater than 0</P>
<P class="Body" style="margin: 0px">3) Read the port</P>
<P class="Body" style="margin: 0px">4) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized</P>
<P class="Body" style="margin: 0px">5) Return from DispatchMessage() and free the message buffer if one was allocated</P>
<P class="Body" style="margin: 0px">6) If the message code matches the B_QUIT_REQUESTED definition and the quit_server flag is true, fall out of the infinite message-monitoring loop</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DispatchMessage(int32 code, int8 *buffer)</span></P>
<P class="Body" style="margin: 0px"><BR>
DispatchMessage implements all the code necessary to respond to a given message sent to the app_server on its main port. This allows for clearer and more manageable code.</P>
<P class="Body" style="margin: 0px"><BR>
CREATE_APP:</P>
<P class="Body" style="margin: 0px"><BR>
Sent by a new BApplication object via synchronous PortLink messaging. Set up the corresponding ServerApp and reply to the BApplication with the new port to which it will send future communications with the App Server.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=110 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=32>
<P class="Body" style="margin: 0px">port_id reply_port</P>
</TD>
<TD WIDTH=318 HEIGHT=32>
<P class="Body" style="margin: 0px">port to which the server is to reply in response to the current message</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">port_id app_port</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">message port for the requesting BApplication</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int16 sig_length</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">length of the following application signature</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *signature</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">Signature of the requesting BApplication</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px"><BR>
1) Get all attached data</P>
<P class="Body" style="margin: 0px">2) Acquire the application list lock</P>
<P class="Body" style="margin: 0px">3) Allocate a ServerApp object and add it to the list</P>
<P class="Body" style="margin: 0px">4) Release application list lock</P>
<P class="Body" style="margin: 0px">5) Acquire active application pointer lock</P>
<P class="Body" style="margin: 0px">6) Update active application pointer</P>
<P class="Body" style="margin: 0px">7) Release active application lock</P>
<P class="Body" style="margin: 0px">8) Send the message SET_SERVER_PORT (with the ServerApp's receiver port attached) to the reply port</P>
<P class="Body" style="margin: 0px">9) Run() the new ServerApp instance</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
DELETE_APP:</P>
<P class="Body" style="margin: 0px"><BR>
Sent by a ServerApp when told to quit either by its BApplication or the Server itself (during shutdown). It is identified by the unique ID assigned to its thread.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=568 HEIGHT=22 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=132 HEIGHT=17>
<P class="Body" style="margin: 0px">thread_id app_thread</P>
</TD>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">Thread id of the ServerApp sending this message</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Get app's thread_id</P>
<P class="Body" style="text-align: left; margin: 0px">2) Acquire application list lock</P>
<P class="Body" style="text-align: left; margin: 0px">3) Iterate through the application list, searching for the ServerApp object with the sent thread_id</P>
<P class="Body" style="text-align: left; margin: 0px">4) Remove the object from the list and delete it</P>
<P class="Body" style="text-align: left; margin: 0px">5) Acquire active application lock</P>
<P class="Body" style="text-align: left; margin: 0px">6) Check to see if the application is active</P>
<P class="Body" style="text-align: left; margin: 0px">7) If application is/was active, set it to the previous application in the list or NULL if there are no other active applications</P>
<P class="Body" style="text-align: left; margin: 0px">8) Release application list lock</P>
<P class="Body" style="text-align: left; margin: 0px">9) Release active application lock</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
GET_SCREEN_MODE:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Received from the OpenBeOS Input Server when requesting the current screen settings via synchronous PortLink messaging. This is a temporary solution which will be deprecated as soon as the BScreen class is complete.</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=42 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=32>
<P class="Body" style="margin: 0px">port_id reply_port</P>
</TD>
<TD WIDTH=318 HEIGHT=32>
<P class="Body" style="margin: 0px">port to which the server is to reply in response to the current message</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Get height, width, and color depth from the global graphics driver object</P>
<P class="Body" style="text-align: left; margin: 0px">2) Attach via PortLink and reply to sender</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
B_QUIT_REQUESTED:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Encountered only under testing situations where the Server is told to quit.</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Attached Data: None</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Set quit_server flag to true</P>
<P class="Body" style="text-align: left; margin: 0px">2) Call Broadcast(QUIT_APP)</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
SET_DECORATOR:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Received from just about anything when a new window decorator is chosen</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=548 HEIGHT=22 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=117 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *path</P>
</TD>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">Path to the proposed new decorator</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Get the path from the buffer</P>
<P class="Body" style="text-align: left; margin: 0px">2) Call LoadDecorator()</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Run(void)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Run() exists mostly for consistency with other regular applications.</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Call MainLoop()</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool LoadDecorator(const char *path)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Allows for a simple way to change the current window decorator systemwide simply by specifying the path to the desired Decorator addon.</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Load the passed string as the path to an addon.</P>
<P class="Body" style="text-align: left; margin: 0px">2) Load all necessary symbols for the decorator</P>
<P class="Body" style="text-align: left; margin: 0px">3) Return false if things didn't go so well</P>
<P class="Body" style="text-align: left; margin: 0px">4) Call Broadcast(UPDATE_DECORATOR)</P>
<P class="Body" style="text-align: left; margin: 0px">5) Return true</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<span class="OBOS-Function-Def">static int32 Picasso(void *data)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Picasso is a function, despite its name, dedicated to ensuring that the server deallocates resources to a dead application. It consists of a while(!quit_server) loop as follows:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Acquire the appliction list lock</P>
<P class="Body" style="text-align: left; margin: 0px">2) Iterate through the list, calling each ServerApp object's PingTarget() method.</P>
<P class="Body" style="text-align: left; margin: 0px">3) If PingTarget returns false, remove the ServerApp from the list and delete it.</P>
<P class="Body" style="text-align: left; margin: 0px">4) Release the appliction list lock</P>
<P class="Body" style="text-align: left; margin: 0px">5) snooze for 3 seconds</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<span class="OBOS-Function-Def">static int32 Poller(void *data)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Poller is the main workhorse of the AppServer class, polling the Server's input port constantly for any messages from the Input Server and calling the appropriate handlers. Like Picasso, it, too, is mostly a while(!quit_server) loop.</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">1) Call port_buffer_size_etc() with a timeout of 3 seconds.</P>
<P class="Body" style="margin: 0px">2) Check to see if the port_buffer_size_etc() timed out and do a continue to next iteration if it did.</P>
<P class="Body" style="margin: 0px">3) Allocate a buffer on the heap if the port buffer size is greater than 0</P>
<P class="Body" style="margin: 0px">4) Read the port</P>
<P class="Body" style="margin: 0px">5) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized</P>
<P class="Body" style="margin: 0px">6) Return from DispatchMessage() and free the message buffer if one was allocated</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">Decorator * instantiate_decorator(Layer *owner, uint32 wflags, uint32 wlook)</span></P>
<P class="Body" style="margin: 0px"><BR>
instantiate_decorator returns a new instance of the decorator currently in use. The caller is responsible for the memory allocated for the returned object.</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire the decorator lock</P>
<P class="Body" style="margin: 0px">2) If create_decorator is NULL, create a new instance of the default decorator</P>
<P class="Body" style="margin: 0px">3) If create_decorator is non-NULL, create a new decorator instance by calling AppServer::create_decorator().</P>
<P class="Body" style="margin: 0px">4) Release the decorator lock</P>
<P class="Body" style="margin: 0px">5) Return the newly allocated instance</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">void Broadcast(int32 code)</span></P>
<P class="Body" style="margin: 0px"><BR>
Broadcast() provides the AppServer class with an easy way to send a quick message to all ServerApps. Primarily, this is called when a font or decorator has changed, or when the server is shutting down. It is not intended to do anything except send a quick message which requires no extra data, such as for some upadate signalling.</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px">1) Acquire application list lock</P>
<P class="Body" style="text-align: left; margin: 0px">2) Create a PortLink instance and set its message code to the passed parameter.</P>
<P class="Body" style="text-align: left; margin: 0px">3) Iterate through the application list, targeting the PortLink instance to each ServerApp's message port and calling Flush().</P>
<P class="Body" style="text-align: left; margin: 0px">4) Release application list lock</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<span class="OBOS-Function-Def">void HandleKeyMessage(int32 code, int8 *buffer)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Called from DispatchMessage to filter out App Server events and otherwise send keystrokes to the active application. </P>
<P class="Body" style="margin: 0px"><BR>
B_KEY_DOWN:</P>
<P class="Body" style="margin: 0px"><BR>
Sent when the user presses (or holds down) a key that's been mapped to a character.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=246 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int64 when</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 rawcode</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">code for the physical key pressed</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 repeat_count</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">number of times a key has been repeated</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 modifiers</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 state_count</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 *states</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 utf8data[3]</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">UTF-8 data generated</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=32>
<P class="Body" style="margin: 0px">int8 charcount</P>
</TD>
<TD WIDTH=318 HEIGHT=32>
<P class="Body" style="margin: 0px">number of bytes to follow containing the string generated (usually 1)</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *string</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">null-terminated string generated by the keystroke</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 raw_char</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">modifier-independent ASCII code for the character</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px"><BR>
1) Get all attached data</P>
<P class="Body" style="margin: 0px">2) If the command modifier is down, check for Left Ctrl+Left Alt+Left Shift+F12 and reset the workspace to 640 x 480 x 256 @ 60Hz and return if true</P>
<P class="Body" style="margin: 0px">3) If the command modifier is down, check for Alt+F1 through Alt+F12 and set workspace and return if true</P>
<P class="Body" style="margin: 0px">4) If the control modifier is true, check for B_CONTROL_KEY+Tab and, if true, find and send to the Deskbar.</P>
<P class="Body" style="margin: 0px">4) Acquire the active application lock</P>
<P class="Body" style="margin: 0px">5) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_KEY_DOWN, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
<P class="Body" style="margin: 0px">6) Release the active application lock</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px">B_KEY_UP:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Sent when the user releases a key that's been mapped to a character.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=224 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int64 when</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 rawcode</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">code for the physical key pressed</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 modifiers</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 state_count</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 *states</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 utf8data[3]</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">UTF-8 data generated</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=32>
<P class="Body" style="margin: 0px">int8 charcount</P>
</TD>
<TD WIDTH=318 HEIGHT=32>
<P class="Body" style="margin: 0px">number of bytes to follow containing the string generated (usually 1)</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *string</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">null-terminated string generated by the keystroke</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 raw_char</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">modifier-independent ASCII code for the character</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px"><BR>
1) Get all attached data</P>
<P class="Body" style="margin: 0px">2) Acquire the active application lock</P>
<P class="Body" style="margin: 0px">3) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_KEY_UP, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
<P class="Body" style="margin: 0px">4) Release the active application lock</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
B_UNMAPPED_KEY_DOWN:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Sent when the user presses a key that has not been mapped to a character.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int64 when</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 rawcode</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">code for the physical key pressed</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 modifiers</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 state_count</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 *states</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire the active application lock</P>
<P class="Body" style="margin: 0px">2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_UNMAPPED_KEY_DOWN, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
<P class="Body" style="margin: 0px">3) Release the active application lock</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
B_UNMAPPED_KEY_UP:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Sent when the user presses a key that has not been mapped to a character.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int64 when</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 rawcode</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">code for the physical key pressed</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 modifiers</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 state_count</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 *states</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire the active application lock</P>
<P class="Body" style="margin: 0px">2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_UNMAPPED_KEY_UP, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
<P class="Body" style="margin: 0px">3) Release the active application lock</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px">B_MODIFIERS_CHANGED:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Sent when the user presses or releases one of the modifier keys</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int64 when</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 modifiers</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 old_modifiers</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">former states of the modifier keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 state_count</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 *states</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire the active application lock</P>
<P class="Body" style="margin: 0px">2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_MODIFIERS_CHANGED, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
<P class="Body" style="margin: 0px">3) Release the active application lock</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,456 @@
AppServer class
###############
The AppServer class sits at the top of the hierarchy, starting and
stopping services, monitoring for messages, and so forth.
Member Functions
================
- AppServer(void)
- ~AppServer(void)
- static int32 Poller(void \*data)
- static int32 Picasso(void \*data)
- thread_id Run(void)
- void MainLoop(void)
- bool LoadDecorator(const char\*path)
- void DispatchMessage(int32 code,int8 \*buffer)
- void Broadcast(int32 code)
- void HandleKeyMessage(int32 code, int8 \*buffer)
Global Functions
================
Decorator \* instantiate_decorator(Layer \*owner, uint32 wflags, uint32 wlook)
AppServer(void)
===============
1. Create the message and input ports
2. Create any necessary semaphores for regulating the 3 main threads
3. Initialize all member variables
4. Allocate the application BList
5. Read in and process all configuration data
6. Initialize the desktop
7. Spawn the Picasso and Poller threads
~AppServer(void)
================
1. Shut down the desktop
2. Empty and delete the application list
3. Wait for Picasso and Poller to exit
4. Free any allocated heap space
void MainLoop(void)
===================
MainLoop is one large loop used to monitor the main message port in
the app_server thread. This is a standard port-monitoring loop code:
1. Call port_buffer_size - which will block if the port is empty
2. Allocate a buffer on the heap if the port buffer size is greater than 0
3. Read the port
4. Pass specified messages to DispatchMessage() for processing, spitting
out an error message to stderr if the message's code is unrecognized
5. Return from DispatchMessage() and free the message buffer if one was
allocated
6. If the message code matches the B_QUIT_REQUESTED definition and the
quit_server flag is true, fall out of the infinite message-monitoring
loop
void DispatchMessage(int32 code, int8 \*buffer)
===============================================
DispatchMessage implements all the code necessary to respond to a
given message sent to the app_server on its main port. This allows for
clearer and more manageable code.
CREATE_APP
----------
Sent by a new BApplication object via synchronous PortLink messaging.
Set up the corresponding ServerApp and reply to the BApplication with
the new port to which it will send future communications with the App
Server.
Attached Data:
+-----------------------------------+-----------------------------------+
| port_id reply_port | port to which the server is to |
| | reply in response to the current |
| | message |
+-----------------------------------+-----------------------------------+
| port_id app_port | message port for the requesting |
| | BApplication |
+-----------------------------------+-----------------------------------+
| int16 sig_length | length of the following |
| | application signature |
+-----------------------------------+-----------------------------------+
| const char \*signature | Signature of the requesting |
| | BApplication |
+-----------------------------------+-----------------------------------+
1. Get all attached data
2. Acquire the application list lock
3. Allocate a ServerApp object and add it to the list
4. Release application list lock
5. Acquire active application pointer lock
6. Update active application pointer
7. Release active application lock
8. Send the message SET_SERVER_PORT (with the ServerApp's receiver port
attached) to the reply port
9. Run() the new ServerApp instance
DELETE_APP
----------
Sent by a ServerApp when told to quit either by its BApplication or
the Server itself (during shutdown). It is identified by the unique ID
assigned to its thread.
Attached Data:
+-----------------------------------+-----------------------------------+
| thread_id app_thread | Thread id of the ServerApp |
| | sending this message |
+-----------------------------------+-----------------------------------+
1. Get app's thread_id
2. Acquire application list lock
3. Iterate through the application list, searching for the ServerApp
object with the sent thread_id
4. Remove the object from the list and delete it
5. Acquire active application lock
6. Check to see if the application is active
7. If application is/was active, set it to the previous application in
the list or NULL if there are no other active applications
8. Release application list lock
9. Release active application lock
GET_SCREEN_MODE
---------------
Received from the OpenBeOS Input Server when requesting the current
screen settings via synchronous PortLink messaging. This is a
temporary solution which will be deprecated as soon as the BScreen
class is complete.
Attached Data:
+-----------------------------------+-----------------------------------+
| port_id reply_port | port to which the server is to |
| | reply in response to the current |
| | message |
+-----------------------------------+-----------------------------------+
1. Get height, width, and color depth from the global graphics driver
object
2. Attach via PortLink and reply to sender
B_QUIT_REQUESTED
----------------
Encountered only under testing situations where the Server is told to
quit.
Attached Data: None
1. Set quit_server flag to true
2. Call Broadcast(QUIT_APP)
SET_DECORATOR
-------------
Received from just about anything when a new window decorator is
chosen
Attached Data:
+-----------------------------------+-----------------------------------+
| const char \*path | Path to the proposed new |
| | decorator |
+-----------------------------------+-----------------------------------+
1. Get the path from the buffer
2. Call LoadDecorator()
void Run(void)
==============
Run() exists mostly for consistency with other regular applications.
1) Call MainLoop()
bool LoadDecorator(const char \*path)
=====================================
Allows for a simple way to change the current window decorator
systemwide simply by specifying the path to the desired Decorator
addon.
1. Load the passed string as the path to an addon.
2. Load all necessary symbols for the decorator
3. Return false if things didn't go so well
4. Call Broadcast(UPDATE_DECORATOR)
5. Return true
static int32 Picasso(void \*data)
=================================
Picasso is a function, despite its name, dedicated to ensuring that
the server deallocates resources to a dead application. It consists of
a while(!quit_server) loop as follows:
1) Acquire the appliction list lock
2) Iterate through the list, calling each ServerApp object's
PingTarget() method.
3) If PingTarget returns false, remove the ServerApp from the list and
delete it.
4) Release the appliction list lock
5) snooze for 3 seconds
static int32 Poller(void \*data)
================================
Poller is the main workhorse of the AppServer class, polling the
Server's input port constantly for any messages from the Input Server
and calling the appropriate handlers. Like Picasso, it, too, is mostly
a while(!quit_server) loop.
1. Call port_buffer_size_etc() with a timeout of 3 seconds.
2. Check to see if the port_buffer_size_etc() timed out and do a
continue to next iteration if it did.
3. Allocate a buffer on the heap if the port buffer size is greater than 0
4. Read the port
5. Pass specified messages to DispatchMessage() for processing, spitting
out an error message to stderr if the message's code is unrecognized
6. Return from DispatchMessage() and free the message buffer if one was
allocated
Decorator \* instantiate_decorator(Layer \*owner, uint32 wflags, uint32 wlook)
==============================================================================
instantiate_decorator returns a new instance of the decorator
currently in use. The caller is responsible for the memory allocated
for the returned object.
1. Acquire the decorator lock
2. If create_decorator is NULL, create a new instance of the default
decorator
3. If create_decorator is non-NULL, create a new decorator instance by
calling AppServer::create_decorator().
4. Release the decorator lock
5. Return the newly allocated instance
void Broadcast(int32 code)
==========================
Broadcast() provides the AppServer class with an easy way to send a
quick message to all ServerApps. Primarily, this is called when a font
or decorator has changed, or when the server is shutting down. It is
not intended to do anything except send a quick message which requires
no extra data, such as for some upadate signalling.
1. Acquire application list lock
2. Create a PortLink instance and set its message code to the passed
parameter.
3. Iterate through the application list, targeting the PortLink instance
to each ServerApp's message port and calling Flush().
4. Release application list lock
void HandleKeyMessage(int32 code, int8 \*buffer)
================================================
Called from DispatchMessage to filter out App Server events and
otherwise send keystrokes to the active application.
B_KEY_DOWN
----------
Sent when the user presses (or holds down) a key that's been mapped to
a character.
Attached Data:
+-----------------------------------+-----------------------------------+
| int64 when | event time in seconds since |
| | 1/1/70 |
+-----------------------------------+-----------------------------------+
| int32 rawcode | code for the physical key pressed |
+-----------------------------------+-----------------------------------+
| int32 repeat_count | number of times a key has been |
| | repeated |
+-----------------------------------+-----------------------------------+
| int32 modifiers | flags signifying the states of |
| | the modifier keys |
+-----------------------------------+-----------------------------------+
| int32 state_count | number of bytes to follow |
| | containing the state of all keys |
+-----------------------------------+-----------------------------------+
| int8 \*states | array of the state of all keys at |
| | the time of the event |
+-----------------------------------+-----------------------------------+
| int8 utf8data[3] | UTF-8 data generated |
+-----------------------------------+-----------------------------------+
| int8 charcount | number of bytes to follow |
| | containing the string generated |
| | (usually 1) |
+-----------------------------------+-----------------------------------+
| const char \*string | null-terminated string generated |
| | by the keystroke |
+-----------------------------------+-----------------------------------+
| int32 raw_char | modifier-independent ASCII code |
| | for the character |
+-----------------------------------+-----------------------------------+
1. Get all attached data
2. If the command modifier is down, check for Left Ctrl+Left Alt+Left
Shift+F12 and reset the workspace to 640 x 480 x 256 @ 60Hz and return
if true
3. If the command modifier is down, check for Alt+F1 through Alt+F12 and
set workspace and return if true
4. If the control modifier is true, check for B_CONTROL_KEY+Tab and, if
true, find and send to the Deskbar.
5. Acquire the active application lock
6. Create a PortLink instance, target the active ServerApp's sender
port, set the opcode to B_KEY_DOWN, attach the buffer en masse, and send
it to the BApplication.
7. Release the active application lock
B_KEY_UP
--------
Sent when the user releases a key that's been mapped to a character.
Attached Data:
+-----------------------------------+-----------------------------------+
| int64 when | event time in seconds since |
| | 1/1/70 |
+-----------------------------------+-----------------------------------+
| int32 rawcode | code for the physical key pressed |
+-----------------------------------+-----------------------------------+
| int32 modifiers | flags signifying the states of |
| | the modifier keys |
+-----------------------------------+-----------------------------------+
| int32 state_count | number of bytes to follow |
| | containing the state of all keys |
+-----------------------------------+-----------------------------------+
| int8 \*states | array of the state of all keys at |
| | the time of the event |
+-----------------------------------+-----------------------------------+
| int8 utf8data[3] | UTF-8 data generated |
+-----------------------------------+-----------------------------------+
| int8 charcount | number of bytes to follow |
| | containing the string generated |
| | (usually 1) |
+-----------------------------------+-----------------------------------+
| const char \*string | null-terminated string generated |
| | by the keystroke |
+-----------------------------------+-----------------------------------+
| int32 raw_char | modifier-independent ASCII code |
| | for the character |
+-----------------------------------+-----------------------------------+
1. Get all attached data
2. Acquire the active application lock
3. Create a PortLink instance, target the active ServerApp's sender
port, set the opcode to B_KEY_UP, attach the buffer en masse, and send
it to the BApplication.
4. Release the active application lock
B_UNMAPPED_KEY_DOWN
-------------------
Sent when the user presses a key that has not been mapped to a
character.
Attached Data:
+-----------------------------------+-----------------------------------+
| int64 when | event time in seconds since |
| | 1/1/70 |
+-----------------------------------+-----------------------------------+
| int32 rawcode | code for the physical key pressed |
+-----------------------------------+-----------------------------------+
| int32 modifiers | flags signifying the states of |
| | the modifier keys |
+-----------------------------------+-----------------------------------+
| int8 state_count | number of bytes to follow |
| | containing the state of all keys |
+-----------------------------------+-----------------------------------+
| int8 \*states | array of the state of all keys at |
| | the time of the event |
+-----------------------------------+-----------------------------------+
1. Acquire the active application lock
2. Create a PortLink instance, target the active ServerApp's sender
port, set the opcode to B_UNMAPPED_KEY_DOWN, attach the buffer en masse,
and send it to the BApplication.
3. Release the active application lock
B_UNMAPPED_KEY_UP
-----------------
Sent when the user presses a key that has not been mapped to a
character.
Attached Data:
+-----------------------------------+-----------------------------------+
| int64 when | event time in seconds since |
| | 1/1/70 |
+-----------------------------------+-----------------------------------+
| int32 rawcode | code for the physical key pressed |
+-----------------------------------+-----------------------------------+
| int32 modifiers | flags signifying the states of |
| | the modifier keys |
+-----------------------------------+-----------------------------------+
| int8 state_count | number of bytes to follow |
| | containing the state of all keys |
+-----------------------------------+-----------------------------------+
| int8 \*states | array of the state of all keys at |
| | the time of the event |
+-----------------------------------+-----------------------------------+
1. Acquire the active application lock
2. Create a PortLink instance, target the active ServerApp's sender
port, set the opcode to B_UNMAPPED_KEY_UP, attach the buffer en masse,
and send it to the BApplication.
3. Release the active application lock
B_MODIFIERS_CHANGED
-------------------
Sent when the user presses or releases one of the modifier keys
Attached Data:
+-----------------------------------+-----------------------------------+
| int64 when | event time in seconds since |
| | 1/1/70 |
+-----------------------------------+-----------------------------------+
| int32 modifiers | flags signifying the states of |
| | the modifier keys |
+-----------------------------------+-----------------------------------+
| int32 old_modifiers | former states of the modifier |
| | keys |
+-----------------------------------+-----------------------------------+
| int8 state_count | number of bytes to follow |
| | containing the state of all keys |
+-----------------------------------+-----------------------------------+
| int8 \*states | array of the state of all keys at |
| | the time of the event |
+-----------------------------------+-----------------------------------+
1. Acquire the active application lock
2. Create a PortLink instance, target the active ServerApp's sender
port, set the opcode to B_MODIFIERS_CHANGED, attach the buffer en masse,
and send it to the BApplication.
3. Release the active application lock
@@ -1,123 +0,0 @@
<HTML>
<HEAD>
<TITLE>BitmapManager.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">BitmapManager 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 BitmapManager object handles all ServerBitmap allocation and deallocation. The rest of the server uses CreateBitmap and DeleteBitmap instead of new and delete. It utilizes the outside pool manager BGET.</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=621 HEIGHT=105 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=238 HEIGHT=17>
<P class="Body" style="margin: 0px">BitmapManager(void)</P>
</TD>
<TD WIDTH=228 HEIGHT=17>
<P class="Body" style="margin: 0px">~BitmapManager(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=238 HEIGHT=62>
<P class="Body" style="margin: 0px">ServerBitmap *CreateBitmap(BRect bounds, color_space space, int32 flags, int32 bytes_per_row=-1, screen_id screen=B_MAIN_SCREEN_ID)</P>
</TD>
<TD WIDTH=228 HEIGHT=62>
<P class="Body" style="margin: 0px">void DeleteBitmap(ServerBitmap *bitmap)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
extern "C" void set_area_buffer_management(void);</P>
<P class="Body" style="margin: 0px">void * expand_area_storage(long size)</P>
<P class="Body" style="margin: 0px">void contract_area_storage(void *buffer)</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BitmapManager(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Create the bitmap list</P>
<P class="Body" style="margin: 0px">2) Create the bitmap area</P>
<P class="Body" style="margin: 0px">3) Allocate the access semaphore</P>
<P class="Body" style="margin: 0px">4) Call set_buffer_area_management</P>
<P class="Body" style="margin: 0px">5) Set up the buffer pool via bpool</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">~BitmapManager(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Iterate over each item in the bitmap list, removing each item, calling brel() on its buffer, and deleting it.</P>
<P class="Body" style="margin: 0px">2) Delete the bitmap list</P>
<P class="Body" style="margin: 0px">3) Delete the bitmap area</P>
<P class="Body" style="margin: 0px">4) Free the access semaphore</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">ServerBitmap *CreateBitmap(BRect bounds, color_space space, int32 flags, int32 bytes_per_row=-1, screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><BR>
CreateBitmap is called by outside objects to allocate a ServerBitmap object. If a problem occurs, it returns NULL.</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire the access semaphore</P>
<P class="Body" style="margin: 0px">2) Verify parameters and if any are invalid, spew an error to stderr and return NULL</P>
<P class="Body" style="margin: 0px">3) Allocate a new ServerBitmap</P>
<P class="Body" style="margin: 0px">4) Allocate a buffer for the bitmap via bget() with the bitmap's theoretical buffer length</P>
<P class="Body" style="margin: 0px">5) If NULL, delete the bitmap and return NULL</P>
<P class="Body" style="margin: 0px">6) Set the bitmap's area and buffer to the appropriate values (area_for buffer and buffer)</P>
<P class="Body" style="margin: 0px">7) Add the bitmap to the bitmap list</P>
<P class="Body" style="margin: 0px">8) Release the access semaphore</P>
<P class="Body" style="margin: 0px">9) Return the bitmap</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">void DeleteBitmap(ServerBitmap *bitmap)</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
Frees a ServerBitmap allocated by CreateBitmap()</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
1) Acquire the access semaphore</span></P>
<P class="Body" style="margin: 0px"><span class="Default">2) Find the bitmap in the list</span></P>
<P class="Body" style="margin: 0px"><span class="Default">3) Remove the bitmap from the list or release the semaphore and return if not found</span></P>
<P class="Body" style="margin: 0px"><span class="Default">4) call brel() on the bitmap's buffer if it is non-NULL</span></P>
<P class="Body" style="margin: 0px"><span class="Default">5) delete the bitmap</span></P>
<P class="Body" style="margin: 0px"><span class="Default">6) Release the access semaphore</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><span class="OBOS-Function-Def">extern "C" void set_area_buffer_management(void)</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
C function defined externally to point the BGET manager to our homegrown area allocation and deallocation functions.</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><span class="OBOS-Function-Def">void * expand_area_storage(long size)</span></P>
<P class="Body" style="margin: 0px"><BR>
"Internal" global function accessed only by set_area_buffer_management and BGET to handle the task of adding more area space to make room for more bitmaps.</P>
<P class="Body" style="margin: 0px"><BR>
1) If size is less than B_PAGE_SIZE, set the area size to B_PAGE_SIZE</P>
<P class="Body" style="margin: 0px">2) If size % B_PAGE_SIZE, set area size to (size/B_PAGE_SIZE)+1)*B_PAGE_SIZE, otherwise setting it to the given size</P>
<P class="Body" style="margin: 0px">3) Call create_area with the area size.</P>
<P class="Body" style="margin: 0px">4) If it couldn't allocate an area, write a panic message to stderr and return NULL, otherwise, return the pointer to the area.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">void contract_area_storage(void *buffer)</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span>"Internal" global function accessed only by set_area_buffer_management and BGET to <span class="Default">remove the area which was previously used for the bitmap pool</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
1) Call area_for on the buffer</span></P>
<P class="Body" style="margin: 0px"><span class="Default">2) If the area_id is not B_ERROR, call delete_area on its area_id.</span></P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,60 @@
BitmapManager class
###################
The BitmapManager object handles all ServerBitmap allocation and
deallocation. The rest of the server uses CreateBitmap and DeleteBitmap
instead of new and delete.
Member Functions
================
BitmapManager(void)
-------------------
1. Create the bitmap list
2. Create the bitmap area
3. Allocate the access semaphore
4. Call set_buffer_area_management
5. Set up the buffer pool via bpool
~BitmapManager(void)
--------------------
1. Iterate over each item in the bitmap list, removing each item,
calling brel() on its buffer, and deleting it.
2. Delete the bitmap list
3. Delete the bitmap area
4. Free the access semaphore
ServerBitmap \*CreateBitmap(BRect bounds, color_space space, int32 flags, int32 bytes_per_row=-1, screen_id screen=B_MAIN_SCREEN_ID)
------------------------------------------------------------------------------------------------------------------------------------
CreateBitmap is called by outside objects to allocate a ServerBitmap
object. If a problem occurs, it returns NULL.
1. Acquire the access semaphore
2. Verify parameters and if any are invalid, spew an error to stderr and
return NULL
3. Allocate a new ServerBitmap
4. Allocate a buffer for the bitmap with the bitmap's
theoretical buffer length
5. If NULL, delete the bitmap and return NULL
6. Set the bitmap's area and buffer to the appropriate values (area_for
buffer and buffer)
7. Add the bitmap to the bitmap list
8. Release the access semaphore
9. Return the bitmap
void DeleteBitmap(ServerBitmap \*bitmap)
----------------------------------------
Frees a ServerBitmap allocated by CreateBitmap()
1. Acquire the access semaphore
2. Find the bitmap in the list
3. Remove the bitmap from the list or release the semaphore and return
if not found
4. call brel() on the bitmap's buffer if it is non-NULL
5. delete the bitmap
6. Release the access semaphore
@@ -1,112 +0,0 @@
<HTML>
<HEAD>
<TITLE>ColorSet.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">ColorSet 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 ColorSet class provides an easy manner to manage system attribute colors, such as window tabs, panel background colors, etc. Each member is an RGBColor. The attributes are list below and are publicly accessible.</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">panel_background</P>
<P class="Body" style="margin: 0px">panel_text</P>
<P class="Body" style="margin: 0px">document_background</P>
<P class="Body" style="margin: 0px">document_text</P>
<P class="Body" style="margin: 0px">control_background</P>
<P class="Body" style="margin: 0px">control_text</P>
<P class="Body" style="margin: 0px">control_border</P>
<P class="Body" style="margin: 0px">control_highlight</P>
<P class="Body" style="margin: 0px">tooltip_background</P>
<P class="Body" style="margin: 0px">tooltip_text</P>
<P class="Body" style="margin: 0px">menu_background</P>
<P class="Body" style="margin: 0px">menu_selected_background</P>
<P class="Body" style="margin: 0px">menu_text</P>
<P class="Body" style="margin: 0px">menu_selected_text</P>
<P class="Body" style="margin: 0px">menu_separator_high</P>
<P class="Body" style="margin: 0px">menu_separator_low</P>
<P class="Body" style="margin: 0px">menu_triggers</P>
<P class="Body" style="margin: 0px">window_tab</P>
<P class="Body" style="margin: 0px">window_tab_text</P>
<P class="Body" style="margin: 0px">inactive_window_tab</P>
<P class="Body" style="margin: 0px">inactive_window_tab_text</P>
<P class="Body" style="margin: 0px">keyboard_navigation</P>
<P class="Body" style="margin: 0px">desktop</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=463 HEIGHT=72 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">ColorSet(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">ColorSet(const ColorSet &amp;cs)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=38>
<P class="Body" style="margin: 0px">ColorSet &amp; operator=(const ColorSet &amp;cs)</P>
</TD>
<TD WIDTH=260 HEIGHT=38>
<P class="Body" style="margin: 0px">void SetColors(const ColorSet &amp;cs)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void PrintToStream(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">ColorSet(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Does nothing.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">ColorSet(const ColorSet &amp;cs)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">ColorSet &amp; operator=(const ColorSet &amp;cs)</span></P>
<P class="Body" style="margin: 0px"><BR>
Calls SetColors on the passed ColorSet object</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetColors(const ColorSet &amp;cs)</span></P>
<P class="Body" style="margin: 0px"><BR>
Copies all data members of the passed color set to those of the current one</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void PrintToStream(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Prints the name of each attribute color and then calls the color's PrintToStream member.</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -1,123 +0,0 @@
<HTML>
<HEAD>
<TITLE>ColorUtils.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">ColorUtils</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">These functions are used for general purpose color-related tasks.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
void SetRGBColor32(rgb_color *col, uint8 r, uint8 g, uint8 b, uint8 a=255)</P>
<P class="Body" style="margin: 0px">void SetRGBAColor32(rgb_color *col, uint16 color16)</P>
<P class="Body" style="margin: 0px">void SetRGBColor16(uint16 *col, uint8 r, uint8 g, uint8 b)</P>
<P class="Body" style="margin: 0px">void SetRGBAColor15(uint16 *col, uint8 r, uint8 g, uint8 b, bool opaque=true)</P>
<P class="Body" style="margin: 0px"><BR>
uint8 FindClosestColor(rgb_color *palette,rgb_color col)</P>
<P class="Body" style="margin: 0px">uint16 FindClosestColor16(rgb_color col)</P>
<P class="Body" style="margin: 0px">uint16 FindClosestColor15(rgb_color col)</P>
<P class="Body" style="margin: 0px"><BR>
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetRGBColor32(rgb_color *col, uint8 r, uint8 g, uint8 b, uint8 a=255)</span></P>
<P class="Body" style="margin: 0px"><BR>
Simply assigns the passed parameters to the internal members of the passed color</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetRGBAColor32(rgb_color *col, uint16 color16)</span></P>
<P class="Body" style="margin: 0px"><BR>
Maps a 16-bit color to a 32-bit one.</P>
<P class="Body" style="margin: 0px"><BR>
gggbbbbb arrrrrgg</P>
<P class="Body" style="margin: 0px">1) Extract component values using the following calculations:</P>
<P class="Body" style="margin: 0px"><BR>
red16 = (uint8[1] &amp; 124) &gt;&gt; 2</P>
<P class="Body" style="margin: 0px"><BR>
green16 = ((uint8[0] &amp; 224) &gt;&gt; 5) | ((uint8[1] &amp; 3) &lt;&lt; 3)</P>
<P class="Body" style="margin: 0px"><BR>
blue16 = uint8[0] &amp; 31</P>
<P class="Body" style="margin: 0px">2) Use cross-multiplication to map each 16-bit color component from 0-31 space to 0-255 space, i.e. red32 = (red16 / 31) * 255</P>
<P class="Body" style="margin: 0px">3) Assign mapped values to the rgb_color passed to the function</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetRGBColor16(uint16 *col, uint8 r, uint8 g, uint8 b)</span></P>
<P class="Body" style="margin: 0px"><BR>
Used for easy assignment of opaque (B_RGB16) 16-bit colors.</P>
<P class="Body" style="margin: 0px"><BR>
1) Clip parameters via a bitwise AND with 31 (var &amp;=31)</P>
<P class="Body" style="margin: 0px">2) Create a uint8 * to the passed color</P>
<P class="Body" style="margin: 0px">3) Assign as follows and return:</P>
<P class="Body" style="margin: 0px"> a) uint8[0] = ( (g &amp; 7) &lt;&lt; 5) | (b &amp; 31)</P>
<P class="Body" style="margin: 0px"> b) uint8[1] = ( (r &amp; 31) &lt;&lt; 3) | ( (g &amp; 56) &gt;&gt; 3)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetRGBAColor15(uint16 *col, uint8 r, uint8 g, uint8 b, bool opaque=true)</span></P>
<P class="Body" style="margin: 0px"><BR>
Used for easy assignment of alpha-aware (B_RGBA16) 16-bit colors.</P>
<P class="Body" style="margin: 0px"><BR>
1) Clip parameters via a bitwise AND with 31 (var &amp;=31)</P>
<P class="Body" style="margin: 0px">2) Create a uint8 * to the passed color</P>
<P class="Body" style="margin: 0px">3) Assign as follows and return:</P>
<P class="Body" style="margin: 0px"> a) uint8[0] = ( (g &amp; 7) &lt;&lt; 5) | (b &amp; 31)</P>
<P class="Body" style="margin: 0px"> b) uint8[1] = ( (r &amp; 31) &lt;&lt; 2) | ( (g &amp; 24) &gt;&gt; 3) | (a) ? 128 : 0</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">uint8 FindClosestColor(rgb_color *palette,rgb_color col)</span></P>
<P class="Body" style="margin: 0px"><BR>
Finds the color which most closely resembles the given one in the given palette.</P>
<P class="Body" style="margin: 0px"><BR>
1) Set the saved delta value to 765 (maximum difference)</P>
<P class="Body" style="margin: 0px">2) Loop through all the colors in the palette. For each color,</P>
<P class="Body" style="margin: 0px"> a) calculate the delta value for each color component and add them together</P>
<P class="Body" style="margin: 0px"> b) compare the new combined delta with the saved one</P>
<P class="Body" style="margin: 0px"> c) if the delta is 0, immediately return the current index</P>
<P class="Body" style="margin: 0px"> d) if the new one is smaller, save it and also the palette index</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">uint16 FindClosestColor16(rgb_color col)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns a 16-bit approximation of the given 32-bit color. Alpha values are ignored.</P>
<P class="Body" style="margin: 0px">1) Create an opaque, 16-bit approximation of col using the following calculations:</P>
<P class="Body" style="margin: 0px"> r16=(31*col.red)/255</P>
<P class="Body" style="margin: 0px"> g16=(31*col.green)/255</P>
<P class="Body" style="margin: 0px"> b16=(31*col.blue)/255</P>
<P class="Body" style="margin: 0px">2) Assign it to a uint16 using the same code as in SetRGBColor16() and return it.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">uint16 FindClosestColor15(rgb_color col)</span></P>
<P class="Body" style="margin: 0px"><BR>
This functions almost exactly like the 16-bit version, but this also takes into account the alpha transparency bit and works in the color space B_RGBA15. Follow the same algorithm as FindClosestColor16(), but assign the return value using SetRGBColor15.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)</span></P>
<P class="Body" style="margin: 0px"><BR>
MakeBlendColor calculates a color that is somewhere between start color col and end color col2, based on position, where 0&lt;= position &lt;= 1. If position is out of these bounds, a color of {0,0,0,0} is returned. If position is 0, the start color is returned. If position is 1, col2 is returned. Otherwise, the color is calculated thus:</P>
<P class="Body" style="margin: 0px"><BR>
1) calculate delta values for each channel, i.e. int16 delta_r=col.red-col2.red</P>
<P class="Body" style="margin: 0px">2) Based on these delta values, calculate the blend values for each channel, i.e. blend_color.red=uint8(col1.red - (delta_r * position) )</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,114 @@
ColorUtils
##########
These functions are used for general purpose color-related tasks.
Global Functions
================
void SetRGBColor32(rgb_color \*col, uint8 r, uint8 g, uint8 b, uint8 a=255)
---------------------------------------------------------------------------
Simply assigns the passed parameters to the internal members of the
passed color
void SetRGBAColor32(rgb_color \*col, uint16 color16)
----------------------------------------------------
Maps a 16-bit color to a 32-bit one.
gggbbbbb arrrrrgg
1. Extract component values using the following calculations:
.. code-block:: cpp
red16 = (uint8[1] & 124) >> 2;
green16 = ((uint8[0] & 224) >> 5) | ((uint8[1] & 3) << 3);
blue16 = uint8[0] & 31;
2. Use cross-multiplication to map each 16-bit color component from 0-31
space to 0-255 space, i.e. red32 = (red16 / 31) \* 255
3. Assign mapped values to the rgb_color passed to the function
void SetRGBColor16(uint16 \*col, uint8 r, uint8 g, uint8 b)
-----------------------------------------------------------
Used for easy assignment of opaque (B_RGB16) 16-bit colors.
1. Clip parameters via a bitwise AND with 31 (var &=31)
2. Create a uint8 * to the passed color
3. Assign as follows and return:
.. code-block:: cpp
uint8[0] = ( (g & 7) << 5) | (b & 31);
uint8[1] = ( (r & 31) << 3) | ( (g & 56) >> 3);
void SetRGBAColor15(uint16 \*col, uint8 r, uint8 g, uint8 b, bool opaque=true)
------------------------------------------------------------------------------
Used for easy assignment of alpha-aware (B_RGBA16) 16-bit colors.
1. Clip parameters via a bitwise AND with 31 (var &=31)
2. Create a uint8 * to the passed color
3. Assign as follows and return:
.. code-block:: cpp
uint8[0] = ( (g & 7) << 5) | (b & 31);
uint8[1] = ( (r & 31) << 2) | ( (g & 24) >> 3) | (a) ? 128 : 0;
uint8 FindClosestColor(rgb_color \*palette,rgb_color col)
---------------------------------------------------------
Finds the color which most closely resembles the given one in the
given palette.
1. Set the saved delta value to 765 (maximum difference)
2. Loop through all the colors in the palette. For each color,
a. calculate the delta value for each color component and add them
together
b. compare the new combined delta with the saved one
c. if the delta is 0, immediately return the current index
d. if the new one is smaller, save it and also the palette index
uint16 FindClosestColor16(rgb_color col)
----------------------------------------
Returns a 16-bit approximation of the given 32-bit color. Alpha values
are ignored.
1. Create an opaque, 16-bit approximation of col using the following
calculations:
.. code-block:: cpp
r16 = (31 * col.red) / 255;
g16 = (31 * col.green) / 255;
b16 = (31 * col.blue) / 255;
2. Assign it to a uint16 using the same code as in SetRGBColor16() and
return it.
uint16 FindClosestColor15(rgb_color col)
----------------------------------------
This functions almost exactly like the 16-bit version, but this also
takes into account the alpha transparency bit and works in the color
space B_RGBA15. Follow the same algorithm as FindClosestColor16(), but
assign the return value using SetRGBColor15.
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)
-----------------------------------------------------------------------
MakeBlendColor calculates a color that is somewhere between start
color col and end color col2, based on position, where 0<= position <=
1. If position is out of these bounds, a color of {0,0,0,0} is
returned. If position is 0, the start color is returned. If position
is 1, col2 is returned. Otherwise, the color is calculated thus:
1. calculate delta values for each channel, i.e. int16 delta_r=col.red-col2.red
2. Based on these delta values, calculate the blend values for each
channel, i.e. blend_color.red=uint8(col1.red - (delta_r \* position) )
@@ -1,215 +0,0 @@
<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=620 HEIGHT=178 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=215 HEIGHT=17>
<P class="Body" style="margin: 0px">CursorManager(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">~CursorManager(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=215 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 AddCursor(ServerCursor *c)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">void DeleteCursor(int32 token)</P>
</TD>
</TR>
<TR>
<TD WIDTH=215 HEIGHT=17>
<P class="Body" style="margin: 0px">void RemoveAppCursors(ServerApp *a)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">void ShowCursor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=215 HEIGHT=17>
<P class="Body" style="margin: 0px">void HideCursor(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">void ObscureCursor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=215 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetCursor(int32 token)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">ServerCursor *GetCursor(cursor_which which)</P>
</TD>
</TR>
<TR>
<TD WIDTH=215 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetCursor(cursor_which which)</P>
</TD>
<TD WIDTH=250 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>
<TR>
<TD WIDTH=215 HEIGHT=17>
<P class="Body" style="margin: 0px">cursor_which GetCursorWhich(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Enumerated Types:</P>
<P class="Body" style="margin: 0px"><BR>
cursor_which {</P>
<P class="Body" style="margin: 0px"> CURSOR_DEFAULT</P>
<P class="Body" style="margin: 0px"> CURSOR_TEXT</P>
<P class="Body" style="margin: 0px"> CURSOR_MOVE</P>
<P class="Body" style="margin: 0px"> CURSOR_DRAG</P>
<P class="Body" style="margin: 0px"> CURSOR_RESIZE</P>
<P class="Body" style="margin: 0px"> CURSOR_RESIZE_NW</P>
<P class="Body" style="margin: 0px"> CURSOR_RESIZE_SE</P>
<P class="Body" style="margin: 0px"> CURSOR_RESIZE_NS</P>
<P class="Body" style="margin: 0px"> CURSOR_RESIZE_EW</P>
<P class="Body" style="margin: 0px"> CURSOR_OTHER</P>
<P class="Body" style="margin: 0px">}</P>
<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">3) Iterate through list of system cursor tokens and see if there's a match. If so, set the internal cursor_which to the match.</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">3) set the internal cursor_which to the one passed to the function</P>
<P class="Body" style="margin: 0px"><BR>
4) 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>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">cursor_which GetCursorWhich(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the current cursor_which attribute which describes the currently active cursor. If the active cursor is not a system cursor, it will return CURSOR_OTHER.</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire cursor lock</P>
<P class="Body" style="margin: 0px">2) Create a local cursor_which and assign it the value of the CursorManager's cursor_which</P>
<P class="Body" style="margin: 0px">3) Release cursor lock</P>
<P class="Body" style="margin: 0px">4) Return the local copy</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,151 @@
CursorManager class
###################
The CursorManager class handles token creation, calling the
cursor-related graphics driver functions, and freeing heap memory for
all ServerCursor instances.
Enumerated Types
================
cursor_which
------------
- CURSOR_DEFAULT
- CURSOR_TEXT
- CURSOR_MOVE
- CURSOR_DRAG
- CURSOR_RESIZE
- CURSOR_RESIZE_NW
- CURSOR_RESIZE_SE
- CURSOR_RESIZE_NS
- CURSOR_RESIZE_EW
- CURSOR_OTHER
Member Functions
================
CursorManager(void)
-------------------
1. Create the cursor list empty
2. Set the token index to 0
3. Allocate the default system cursor and pass it to AddCursor
4. Initialize the member pointer for the graphics driver
5. Create the cursorlock semaphore
6. Call SetDefaultCursor
~CursorManager(void)
--------------------
1. Empty and delete the cursor list
2. Delete the cursorlock semaphore
int32 AddCursor(ServerCursor \*sc)
----------------------------------
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().
1. Acquire cursor lock
2. Add \*sc to the cursor list
3. Set sc->token to the current token index value
4. Increment the token index
5. Assign sc->token to temporary variable
6. Release cursor lock
7. Return the saved token value
void DeleteCursor(int32 ctoken)
-------------------------------
1. Acquire cursor lock
2. Iterate through the cursor list, looking for ctoken
3. If any ServerCursor->token equals ctoken, remove and delete it
4. Release cursor lock
void RemoveAppCursors(ServerApp \*app)
--------------------------------------
1. Acquire cursor lock
2. Iterate through the cursor list, checking each cursor's ServerApp
pointer
3. If any have a ServerApp pointer which matches the passed pointer,
remove and delete them
4. Release cursor lock
void ShowCursor(void), void HideCursor(void), void ObscureCursor(void)
----------------------------------------------------------------------
Simple pass-through functions which call the graphics driver's
functions. Note that acquiring the cursor lock will be necessary for
all three calls.
void SetCursor(int32 token), void SetCursor(cursor_which cursor)
----------------------------------------------------------------
These set the current cursor for the graphics driver to the passed
cursor, either one previously added via AddCursor or a system cursor.
1. Acquire cursor lock
Token version:
2. Find the cursor in the cursor list and call the graphics driver if
non-NULL
3. Iterate through list of system cursor tokens and see if there's a
match. If so, set the internal cursor_which to the match.
cursor_which version:
2. determine which cursor to use via a switch statement and call the
graphics driver with the internal pointer for the appropriate cursor
3. set the internal cursor_which to the one passed to the function
..
4. Release cursor lock
ServerCursor \*GetCursor(cursor_which which)
--------------------------------------------
GetCursor is intended for use in figuring out what cursor is in use
for a particular system cursor.
1. Acquire cursor lock
2. use a switch statement to figure which cursor to return and assign a
temporary pointer its value
3. Release cursor lock
4. Return the temporary pointer
void ChangeCursor(cursor_which which, int32 token)
--------------------------------------------------
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.
1. Acquire cursor lock
2. Call FindCursor and, if NULL, release the cursor lock and return
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.
4. If active flag is true, call SetCursor()
5. Release cursor lock
cursor_which GetCursorWhich(void)
---------------------------------
Returns the current cursor_which attribute which describes the
currently active cursor. If the active cursor is not a system cursor,
it will return CURSOR_OTHER.
1. Acquire cursor lock
2. Create a local cursor_which and assign it the value of the
CursorManager's cursor_which
3. Release cursor lock
4. Return the local copy
@@ -1,50 +0,0 @@
<HTML>
<HEAD>
<TITLE>DebugTools.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">DebugUtils</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">These functions are used to make print-based debugging easier.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
BString TranslateStatusToBString(status_t value)</P>
<P class="Body" style="margin: 0px">BString TranslateColorSpaceToBString(color_space value)</P>
<P class="Body" style="margin: 0px">BString TranslateMessageCodeToBString(int32 value)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BString TranslateStatusToBString(status_t value)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BString TranslateColorSpaceToBString(color_space value)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BString TranslateMessageCodeToBString(int32 value)</span></P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">const char * TranslateStatusToString(status_t value)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">const char * TranslateColorSpaceToString(color_space value)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">const char * TranslateMessageCodeToString(int32 value)</span></P>
<P class="Body" style="margin: 0px"><BR>
All of these functions are essentially big switch() statements which assign an appropriate string for the passed parameter and return the assigned string. This way the string can be printed or otherwise easily used.</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,20 @@
Debug Utility functions
#######################
These functions are used to make print-based debugging easier.
- BString TranslateStatusToBString(status_t value)
- BString TranslateColorSpaceToBString(color_space value)
- BString TranslateMessageCodeToBString(int32 value)
- BString TranslateStatusToBString(status_t value)
- BString TranslateColorSpaceToBString(color_space value)
- BString TranslateMessageCodeToBString(int32 value)
- const char \* TranslateStatusToString(status_t value)
- const char \* TranslateColorSpaceToString(color_space value)
- const char \* TranslateMessageCodeToString(int32 value)
All of these functions are essentially big switch() statements which
assign an appropriate string for the passed parameter and return the
assigned string. This way the string can be printed or otherwise
easily used.
@@ -1,401 +0,0 @@
<HTML>
<HEAD>
<TITLE>Decorator.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">Decorator 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">Decorators provide the actual drawing for a window's looks.</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=617 HEIGHT=270 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">Decorator(BRect int32 wlook, int32 wfeel, int32 wflags)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">~Decorator(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetColors(color_set colors)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetDriver(DisplayDriver *driver)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetClose(bool is_down)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetMinimize(bool is_down)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetZoom(bool is_down)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetFlags(int32 wflags)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetFeel(int32 wfeel)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetLook(int32 wlook)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">bool GetClose(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">bool GetMinimize(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">bool GetZoom(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 GetLook(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=18>
<P class="Body" style="margin: 0px">int32 GetFeel(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=18>
<P class="Body" style="margin: 0px">int32 GetFlags(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetTitle(const char *string)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetFont(SFont *sf)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 _ClipTitle(float width)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetFocus(bool is_active)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">bool GetFocus(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 _TitleWidth(void)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
Virtual Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=617 HEIGHT=269 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(float x, float y)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(BPoint pt)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void ResizeBy(float x, float y)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void ResizeBy(BPoint pt)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void Draw(BRect r)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void Draw(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void DrawClose(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void DrawFrame(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void DrawMinimize(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void DrawTab(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void DrawTitle(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void DrawZoom(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void _DrawClose(BRect r)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void _DrawFrame(BRect r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void _DrawMinimize(BRect r)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void _DrawTab(BRect r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void _DrawTitle(BRect r)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void _DrawZoom(BRect r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">SRegion GetFootprint(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">click_type Clicked(BPoint pt, int32 buttons, int32 modifiers)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void _SetFocus(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">BRect SlideTab(float dx, float dy=0)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
_ Indicates a protected member function</P>
<P class="Body" style="margin: 0px"><BR>
Exported C Functions</P>
<P class="Body" style="margin: 0px"><BR>
Decorator *create_decorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags)</P>
<P class="Body" style="margin: 0px">float get_decorator_version(void)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
Enumerated Types</P>
<P class="Body" style="margin: 0px"><BR>
click_type {</P>
<P class="Body" style="margin: 0px"> CLICK_NONE</P>
<P class="Body" style="margin: 0px"> CLICK_ZOOM</P>
<P class="Body" style="margin: 0px"> CLICK_CLOSE</P>
<P class="Body" style="margin: 0px"> CLICK_MINIMIZE</P>
<P class="Body" style="margin: 0px"> CLICK_TAB</P>
<P class="Body" style="margin: 0px"> CLICK_MOVE</P>
<P class="Body" style="margin: 0px"> CLICK_MOVETOBACK</P>
<P class="Body" style="margin: 0px"> CLICK_MOVETOFRONT</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_L</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_T</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_R</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_B</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_LT</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_RT</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_LB</P>
<P class="Body" style="margin: 0px"> CLICK_RESIZE_RB</P>
<P class="Body" style="margin: 0px">}</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">Decorator(BRect int32 wlook, int32 wfeel, int32 wflags)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets up internal variables common to all decorators.</P>
<P class="Body" style="margin: 0px"><BR>
1) Assign parameters to respective data members</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~Decorator(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Empty.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">void SetColors(color_set colors)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetDriver(DisplayDriver *driver)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetClose(bool is_down)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetMinimize(bool is_down)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetZoom(bool is_down)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetFlags(int32 wflags)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetFeel(int32 wfeel)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetLook(int32 wlook)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool GetClose(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool GetMinimize(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool GetZoom(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">int32 GetLook(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">int32 GetFeel(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">int32 GetFlags(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetTitle(const char *string)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetFont(SFont *sf)</span></P>
<P class="Body" style="margin: 0px"><BR>
These functions work with the internal members common to all Decorators - assigning them and returning them. Additionally, SetTitle() and SetFont() set the clip_font flag to true.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">int32 _ClipTitle(float width)</span></P>
<P class="Body" style="margin: 0px"><BR>
ClipTitle calculates how much of the title, in characters, can be displayed in the given width.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call StringWidth() on the title.</P>
<P class="Body" style="margin: 0px">2) If the string's width is less than<span style="font-style: italic">width</span>, return the string's character count</P>
<P class="Body" style="margin: 0px">3) while the character count to display is &gt; 0</P>
<P class="Body" style="margin: 0px"> a) calculate the string's width</P>
<P class="Body" style="margin: 0px"> b) if the string's width is less than <span style="font-style: italic">width</span>, return the character count</P>
<P class="Body" style="margin: 0px"> c) decrement the character count</P>
<P class="Body" style="margin: 0px">4) If the loop completes itself without returning a value, it can't fit, so return 0.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetFocus(bool is_active)</span></P>
<P class="Body" style="margin: 0px"><BR>
This is for handling color states when a window receives or loses the focus.</P>
<P class="Body" style="margin: 0px"><BR>
1) Set focus flag to whatever is_active is.</P>
<P class="Body" style="margin: 0px">2) call hook function _SetFocus()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool GetFocus(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the focus state held by the decorator</P>
<P class="Body" style="margin: 0px"><BR>
1) Return the focus flag</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 _TitleWidth(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the character count of the title or 0 if it is NULL.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">Virtual Functions</span></P>
<P class="Body" style="margin: 0px"><BR>
Most of these functions have a default behavior which can be overridden, but are implemented to handle the more common implementations.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">void MoveBy(float x, float y)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void MoveBy(BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><BR>
Move all member rectangles of Decorator by the specified amount. </P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ResizeBy(float x, float y)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void ResizeBy(BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><BR>
Resize the client frame, window frame, and the tab frame (width only) by the specified amount. Button rectangles - close, minimize, and zoom - are not modified.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Draw(BRect r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void Draw(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Main drawing call which checks the intersection of the rectangle passed to it and draws all items which intersect it. Draw(void) simply performs drawing calls to draw the entire decorator's footprint area.</P>
<P class="Body" style="margin: 0px"><BR>
1) Check for intersection with BRect which encompasses the decorator's footprint and return if no intersection.</P>
<P class="Body" style="margin: 0px">2) Call _DrawFrame(intersection)</P>
<P class="Body" style="margin: 0px">3) Call _DrawTab(intersection)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DrawClose(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">protected: void _DrawClose(BRect r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void DrawMinimize(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">protected: void _DrawMinimize(BRect r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void DrawZoom(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">protected: void _DrawZoom(BRect r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Each of these is designed to utilize their respective button rectangles. The public (void) versions simply call the internal protected ones with the button rectangle. These protected versions are, by default, empty. The rectangle passed to them is the invalid area to be drawn, which is not necessarily the entire button's rectangle.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DrawFrame(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">protected: void _DrawFrame(BRect r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Draws the frame, if any. The public version amounts to _DrawFrame(framerect). The protected version is expected to not cover up the client frame when drawing. Any drawing within the clientrect member will end up being drawn over by the window's child views.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DrawTab(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">protected: void _DrawTab(BRect r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Draws the window's tab, if any. DrawTab() amounts to _DrawTab(tabrect). If window titles are displayed, the _DrawTitle call is expected to be made here. Button-drawing calls, assuming that a window's buttons are in the tab, should be made here, as well.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DrawTitle(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">protected: void _DrawTitle(BRect r)</span></P>
<P class="Body" style="margin: 0px"><BR>
These cause the window's title to be drawn. DrawTitle() amounts to _DrawTitle(titlerect). </P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void _SetFocus(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
This hook function is primarily used to change colors used when a window changes focus states and is called immediately after the state is changed. If, for example, a decorator does not use OpenBeOS' GUI color set, it would change its drawing colors to reflect the change in focus.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">SRegion GetFootprint(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
This returns the "footprint" of the decorator, i.e. the area which is occupied by the window which is is the border surrounding the main client rectangle. It is possible to have oddly-shaped window borders, like ellipses and circles, but the resulting performance hit would reduce the said decorator to a novelty and not something useable. All versions are to construct an SRegion which the border occupies. This footprint is permitted to include the client rectangle area, but this area must not be actually drawn upon by the decorator itself. The default version returns the frame which encompasses all other rectangles - the "frame" member which belongs to its window border.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">click_type Clicked(BPoint pt, int32 buttons, int32 modifiers)</span></P>
<P class="Body" style="margin: 0px"><BR>
Clicked() performs hit testing for the decorator, given input conditions. This function is required by ALL subclasses expecting to do more than display itself. The return type will cause the server to take the appropriate actions, such as close the window, get ready to move it, etc.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">BRect SlideTab(float dx, dy=0)</span></P>
<P class="Body" style="margin: 0px"><BR>
SlideTab is implemented only for those decorators which allow the user to somehow slide the tab (if there is one) along the window. Currently, only the horizontal direction is supported. It returns the rectangle of the invalid region which needs redrawn as a result of the slide.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">extern "C" Decorator *create_decorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags)</span></P>
<P class="Body" style="margin: 0px"><BR>
Required export function which simply allocates an instance of the decorator and returns it.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">extern "C" float get_decorator_version(void)</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
This should, for now, return 1.00.</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span></P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,289 @@
Decorator class
###############
Decorators provide the actual drawing for a window's looks.
\_ Indicates a protected member function
Member Functions
================
Decorator(BRect int32 wlook, int32 wfeel, int32 wflags)
-------------------------------------------------------
Sets up internal variables common to all decorators.
1) Assign parameters to respective data members
~Decorator(void)
----------------
Empty.
void SetColors(color_set colors)
--------------------------------
void SetDriver(DisplayDriver \*driver)
--------------------------------------
void SetClose(bool is_down)
---------------------------
void SetMinimize(bool is_down)
------------------------------
void SetZoom(bool is_down)
--------------------------
void SetFlags(int32 wflags)
---------------------------
void SetFeel(int32 wfeel)
-------------------------
void SetLook(int32 wlook)
-------------------------
bool GetClose(void)
-------------------
bool GetMinimize(void)
----------------------
bool GetZoom(void)
------------------
int32 GetLook(void)
-------------------
int32 GetFeel(void)
-------------------
int32 GetFlags(void)
--------------------
void SetTitle(const char \*string)
----------------------------------
void SetFont(SFont \*sf)
------------------------
These functions work with the internal members common to all
Decorators - assigning them and returning them. Additionally,
SetTitle() and SetFont() set the clip_font flag to true.
int32 \_ClipTitle(float width)
------------------------------
ClipTitle calculates how much of the title, in characters, can be
displayed in the given width.
1. Call StringWidth() on the title.
2. If the string's width is less thanwidth, return the string's
character count
3. while the character count to display is > 0
a. calculate the string's width
b. if the string's width is less than width, return the character count
c. decrement the character count
4. If the loop completes itself without returning a value, it can't fit,
so return 0.
void SetFocus(bool is_active)
-----------------------------
This is for handling color states when a window receives or loses the
focus.
1. Set focus flag to whatever is_active is.
2. call hook function \_SetFocus()
bool GetFocus(void)
-------------------
Returns the focus state held by the decorator
1) Return the focus flag
int32 \_TitleWidth(void)
------------------------
Returns the character count of the title or 0 if it is NULL.
Virtual Functions
=================
Most of these functions have a default behavior which can be
overridden, but are implemented to handle the more common
implementations.
void MoveBy(float x, float y)
-----------------------------
void MoveBy(BPoint pt)
----------------------
Move all member rectangles of Decorator by the specified amount.
void ResizeBy(float x, float y)
-------------------------------
void ResizeBy(BPoint pt)
------------------------
Resize the client frame, window frame, and the tab frame (width only)
by the specified amount. Button rectangles - close, minimize, and zoom
- are not modified.
void Draw(BRect r)
------------------
void Draw(void)
---------------
Main drawing call which checks the intersection of the rectangle
passed to it and draws all items which intersect it. Draw(void) simply
performs drawing calls to draw the entire decorator's footprint area.
1. Check for intersection with BRect which encompasses the decorator's
footprint and return if no intersection.
2. Call \_DrawFrame(intersection)
3. Call \_DrawTab(intersection)
void DrawClose(void)
--------------------
protected: void \_DrawClose(BRect r)
------------------------------------
void DrawMinimize(void)
-----------------------
protected: void \_DrawMinimize(BRect r)
---------------------------------------
void DrawZoom(void)
-------------------
protected: void \_DrawZoom(BRect r)
-----------------------------------
Each of these is designed to utilize their respective button
rectangles. The public (void) versions simply call the internal
protected ones with the button rectangle. These protected versions
are, by default, empty. The rectangle passed to them is the invalid
area to be drawn, which is not necessarily the entire button's
rectangle.
void DrawFrame(void)
--------------------
protected: void \_DrawFrame(BRect r)
------------------------------------
Draws the frame, if any. The public version amounts to
\_DrawFrame(framerect). The protected version is expected to not cover
up the client frame when drawing. Any drawing within the clientrect
member will end up being drawn over by the window's child views.
void DrawTab(void)
------------------
protected: void \_DrawTab(BRect r)
----------------------------------
Draws the window's tab, if any. DrawTab() amounts to
\_DrawTab(tabrect). If window titles are displayed, the \_DrawTitle
call is expected to be made here. Button-drawing calls, assuming that
a window's buttons are in the tab, should be made here, as well.
void DrawTitle(void)
--------------------
protected: void \_DrawTitle(BRect r)
------------------------------------
These cause the window's title to be drawn. DrawTitle() amounts to
\_DrawTitle(titlerect).
void \_SetFocus(void)
---------------------
This hook function is primarily used to change colors used when a
window changes focus states and is called immediately after the state
is changed. If, for example, a decorator does not use OpenBeOS' GUI
color set, it would change its drawing colors to reflect the change in
focus.
SRegion GetFootprint(void)
--------------------------
This returns the "footprint" of the decorator, i.e. the area which is
occupied by the window which is is the border surrounding the main
client rectangle. It is possible to have oddly-shaped window borders,
like ellipses and circles, but the resulting performance hit would
reduce the said decorator to a novelty and not something useable. All
versions are to construct an SRegion which the border occupies. This
footprint is permitted to include the client rectangle area, but this
area must not be actually drawn upon by the decorator itself. The
default version returns the frame which encompasses all other
rectangles - the "frame" member which belongs to its window border.
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers)
-------------------------------------------------------------
Clicked() performs hit testing for the decorator, given input
conditions. This function is required by ALL subclasses expecting to
do more than display itself. The return type will cause the server to
take the appropriate actions, such as close the window, get ready to
move it, etc.
BRect SlideTab(float dx, dy=0)
------------------------------
SlideTab is implemented only for those decorators which allow the user
to somehow slide the tab (if there is one) along the window.
Currently, only the horizontal direction is supported. It returns the
rectangle of the invalid region which needs redrawn as a result of the
slide.
Exported C Functions
====================
extern "C" Decorator \*create_decorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags)
--------------------------------------------------------------------------------------------
Required export function which simply allocates an instance of the
decorator and returns it.
extern "C" float get_decorator_version(void)
--------------------------------------------
This should, for now, return 1.00.
Enumerated Types
================
click_type
----------
- CLICK_NONE
- CLICK_ZOOM
- CLICK_CLOSE
- CLICK_MINIMIZE
- CLICK_TAB
- CLICK_MOVE
- CLICK_MOVETOBACK
- CLICK_MOVETOFRONT
- CLICK_RESIZE
- CLICK_RESIZE_L
- CLICK_RESIZE_T
- CLICK_RESIZE_R
- CLICK_RESIZE_B
- CLICK_RESIZE_LT
- CLICK_RESIZE_RT
- CLICK_RESIZE_LB
- CLICK_RESIZE_RB
-150
View File
@@ -1,150 +0,0 @@
<HTML>
<HEAD>
<TITLE>Desktop.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">Desktop module</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">There are no globally accessible objects in this section of code, but many function definitions to work with workspaces, screen attributes, and other such things. These functions work with the private desktop classes Screen and Workspace.</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">
<HR>
</P>
<P class="Body" style="margin: 0px">Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
void InitDesktop(void)</P>
<P class="Body" style="margin: 0px">void ShutdownDesktop(void)</P>
<P class="Body" style="margin: 0px"><BR>
void AddWorkspace(int32 index=-1)</P>
<P class="Body" style="margin: 0px">void DeleteWorkspace(int32 index)</P>
<P class="Body" style="margin: 0px">int32 CountWorkspaces(void)</P>
<P class="Body" style="margin: 0px">void SetWorkspaceCount(int32 count)</P>
<P class="Body" style="margin: 0px">int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID)</P>
<P class="Body" style="margin: 0px">void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID)</P>
<P class="Body" style="margin: 0px"><BR>
void SetScreen(screen_id id)</P>
<P class="Body" style="margin: 0px">int32 CountScreens(void)</P>
<P class="Body" style="margin: 0px">screen_id ActiveScreen(void)</P>
<P class="Body" style="margin: 0px">DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)</P>
<P class="Body" style="margin: 0px">status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)</P>
<P class="Body" style="margin: 0px"><BR>
void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)</P>
<P class="Body" style="margin: 0px">void RemoveWindowFromDesktop(ServerWindow *win)</P>
<P class="Body" style="margin: 0px">ServerWindow *GetActiveWindow(void)</P>
<P class="Body" style="margin: 0px">void SetActiveWindow(ServerWindow *win)</P>
<P class="Body" style="margin: 0px">Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id s</P>
<P class="Body" style="margin: 0px">screen=B_MAIN_SCREEN_ID)</P>
<P class="Body" style="margin: 0px"><BR>
void set_drag_message(int32 size, int8 *flattened)</P>
<P class="Body" style="margin: 0px">int8* get_drag_message(int32 *size)</P>
<P class="Body" style="margin: 0px">void empty_drag_ message(void)</P>
<P class="Body" style="margin: 0px"><BR>
Namespaces</P>
<P class="Body" style="margin: 0px"><BR>
desktop_private {</P>
<P class="Body" style="margin: 0px"> int8 *dragmessage</P>
<P class="Body" style="margin: 0px"> int32 dragmessagesize</P>
<P class="Body" style="margin: 0px"> sem_id draglock</P>
<P class="Body" style="margin: 0px">}</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void InitDesktop(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets up all the stuff necessary for the system's desktop.</P>
<P class="Body" style="margin: 0px"><BR>
1) Create a graphics module list by looping through allocation and initialization of display modules until failure is returned. If app_server exists, just create a ViewDriver module</P>
<P class="Body" style="margin: 0px">2) Create and populate Screen list, pointing each Screen instance to its Driver instance</P>
<P class="Body" style="margin: 0px">3) Create layer and workspace locks</P>
<P class="Body" style="margin: 0px">4) Set screen 0 to active</P>
<P class="Body" style="margin: 0px">5) Create the desktop_private::draglock semaphore</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ShutdownDesktop(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Undoes everything done in InitDesktop().</P>
<P class="Body" style="margin: 0px"><BR>
1) Delete all locks</P>
<P class="Body" style="margin: 0px">2) Delete all screens in the list</P>
<P class="Body" style="margin: 0px">3) Delete the desktop_private::draglock semaphore</P>
<P class="Body" style="margin: 0px">4) If desktop_private::dragmessage is non-NULL, delete it.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void AddWorkspace(int32 index=-1)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void DeleteWorkspace(int32 index)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">int32 CountWorkspaces(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetWorkspaceCount(int32 count)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><BR>
Each of these calls the appropriate method in the Screen class. Add and Delete workspace functions operate on all screens.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetScreen(screen_id id)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">int32 CountScreens(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">screen_id ActiveScreen(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><BR>
Each of these calls operate on the objects in the Screen list, calling methods as appropriate.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void RemoveWindowFromDesktop(ServerWindow *win)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">ServerWindow *GetActiveWindow(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetActiveWindow(ServerWindow *win)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><BR>
These operate on the layer structure in the active Screen object, calling methods as appropriate.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void set_drag_message(int32 size, int8 *flattened)</span></P>
<P class="Body" style="margin: 0px"><BR>
This assigns a BMessage in its flattened state to the internal storage. Only one message can be stored at a time. Once an assignment is made, another cannot be made until the current one is emptied. If additional calls are made while there is a drag message assigned, the new assignment will not be made. Note that this merely passes a pointer around. No copies are made and the caller is responsible for freeing any allocated objects from the heap.</P>
<P class="Body" style="margin: 0px"><BR>
1) Acquire the draglock</P>
<P class="Body" style="margin: 0px">2) release the lock and return if winborder_private::dragmessage is non-NULL</P>
<P class="Body" style="margin: 0px">3) Assign parameters to the private variables</P>
<P class="Body" style="margin: 0px">4) Release the draglock</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int8* get_drag_message(int32 *size)</span></P>
<P class="Body" style="margin: 0px"><BR>
Retrieve the current drag message in use. This function will fail if a NULL pointer is passed to it. Note that this does not free the current drag message from use. The size of the flattened message is stored in the size parameter. Note that if there is no message in use, it will return NULL and set size to 0.</P>
<P class="Body" style="margin: 0px"><BR>
1) return NULL if size pointer is NULL</P>
<P class="Body" style="margin: 0px">2) acquire the draglock</P>
<P class="Body" style="margin: 0px">3) set value of size parameter to winborder_private::dragmessagesize</P>
<P class="Body" style="margin: 0px">4) assign a temporary pointer the value of desktop_private::dragmessage</P>
<P class="Body" style="margin: 0px">5) release the draglock</P>
<P class="Body" style="margin: 0px">6) return the temporary pointer</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void empty_drag_ message(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
This empties the current drag message from use and allows for other messages to be assigned.</P>
<P class="Body" style="margin: 0px"><BR>
1) acquire draglock</P>
<P class="Body" style="margin: 0px">2) assign 0 to desktop_private::dragmessagesize and set desktop_private::dragmessage to NULL</P>
<P class="Body" style="margin: 0px">3) release draglock</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
+147
View File
@@ -0,0 +1,147 @@
Desktop module
##############
There are no globally accessible objects in this section of code, but
many function definitions to work with workspaces, screen attributes,
and other such things. These functions work with the private desktop
classes Screen and Workspace.
Global Functions
================
void InitDesktop(void)
----------------------
Sets up all the stuff necessary for the system's desktop.
1. Create a graphics module list by looping through allocation and
initialization of display modules until failure is returned. If
app_server exists, just create a ViewDriver module
2. Create and populate Screen list, pointing each Screen instance to its
Driver instance
3. Create layer and workspace locks
4. Set screen 0 to active
5. Create the desktop_private::draglock semaphore
void ShutdownDesktop(void)
--------------------------
Undoes everything done in InitDesktop().
1. Delete all locks
2. Delete all screens in the list
3. Delete the desktop_private::draglock semaphore
4. If desktop_private::dragmessage is non-NULL, delete it.
void AddWorkspace(int32 index=-1)
---------------------------------
void DeleteWorkspace(int32 index)
---------------------------------
int32 CountWorkspaces(void)
---------------------------
void SetWorkspaceCount(int32 count)
-----------------------------------
int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID)
---------------------------------------------------------
void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID)
---------------------------------------------------------------------
Each of these calls the appropriate method in the Screen class. Add
and Delete workspace functions operate on all screens.
void SetScreen(screen_id id)
----------------------------
int32 CountScreens(void)
------------------------
screen_id ActiveScreen(void)
----------------------------
DisplayDriver \*GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)
---------------------------------------------------------------
status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)
---------------------------------------------------------------------------------------------
Each of these calls operate on the objects in the Screen list, calling
methods as appropriate.
void AddWindowToDesktop(ServerWindow \*win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
-------------------------------------------------------------------------------------------------------------------
void RemoveWindowFromDesktop(ServerWindow \*win)
------------------------------------------------
ServerWindow \*GetActiveWindow(void)
------------------------------------
void SetActiveWindow(ServerWindow \*win)
----------------------------------------
Layer \*GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
--------------------------------------------------------------------------------------------
These operate on the layer structure in the active Screen object,
calling methods as appropriate.
void set_drag_message(int32 size, int8 \*flattened)
---------------------------------------------------
This assigns a BMessage in its flattened state to the internal
storage. Only one message can be stored at a time. Once an assignment
is made, another cannot be made until the current one is emptied. If
additional calls are made while there is a drag message assigned, the
new assignment will not be made. Note that this merely passes a
pointer around. No copies are made and the caller is responsible for
freeing any allocated objects from the heap.
1. Acquire the draglock
2. release the lock and return if winborder_private::dragmessage is
non-NULL
3. Assign parameters to the private variables
4. Release the draglock
int8\* get_drag_message(int32 \*size)
-------------------------------------
Retrieve the current drag message in use. This function will fail if a
NULL pointer is passed to it. Note that this does not free the current
drag message from use. The size of the flattened message is stored in
the size parameter. Note that if there is no message in use, it will
return NULL and set size to 0.
1. return NULL if size pointer is NULL
2. acquire the draglock
3. set value of size parameter to winborder_private::dragmessagesize
4. assign a temporary pointer the value of desktop_private::dragmessage
5. release the draglock
6. return the temporary pointer
void empty_drag\_ message(void)
-------------------------------
This empties the current drag message from use and allows for other
messages to be assigned.
1. acquire draglock
2. assign 0 to desktop_private::dragmessagesize and set
desktop_private::dragmessage to NULL
3. release draglock
Namespaces
==========
desktop_private
---------------
- int8 \*dragmessage
- int32 dragmessagesize
- sem_id draglock
@@ -1,343 +0,0 @@
<HTML>
<HEAD>
<TITLE>DesktopClasses.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">Screen class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Title">Workspace class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Title">RootLayer class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
The Screen class handles all infrastructure needed for each monitor/video card pair. The Workspace class holds data and supplies the infrastructure for drawing the screen.</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><BR>
Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=616 HEIGHT=264 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=227 HEIGHT=32>
<P class="Body" style="margin: 0px">Screen(DisplayDriver *gfxmodule, uint8 workspaces)</P>
</TD>
<TD WIDTH=235 HEIGHT=32>
<P class="Body" style="margin: 0px">~Screen(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=17>
<P class="Body" style="margin: 0px">void AddWorkspace(int32 index=-1)</P>
</TD>
<TD WIDTH=235 HEIGHT=17>
<P class="Body" style="margin: 0px">void DeleteWorkspace(int32 index)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 CountWorkspaces(void)</P>
</TD>
<TD WIDTH=235 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetWorkspaceCount(int32 count)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 CurrentWorkspace(void)</P>
</TD>
<TD WIDTH=235 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetWorkspace(int32 workspace)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=17>
<P class="Body" style="margin: 0px">void Activate(bool active=true)</P>
</TD>
<TD WIDTH=235 HEIGHT=17>
<P class="Body" style="margin: 0px">DisplayDriver *GetDriver(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=32>
<P class="Body" style="margin: 0px">status_t SetSpace(int32 index, int32 res, bool stick=true)</P>
</TD>
<TD WIDTH=235 HEIGHT=32>
<P class="Body" style="margin: 0px">void AddWindow(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=17>
<P class="Body" style="margin: 0px">void RemoveWindow(ServerWindow *win)</P>
</TD>
<TD WIDTH=235 HEIGHT=17>
<P class="Body" style="margin: 0px">ServerWindow *ActiveWindow(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetActiveWindow(ServerWindow *win)</P>
</TD>
<TD WIDTH=235 HEIGHT=32>
<P class="Body" style="margin: 0px">Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE)</P>
</TD>
</TR>
<TR>
<TD WIDTH=227 HEIGHT=17>
<P class="Body" style="margin: 0px">bool IsInitialized(void)</P>
</TD>
<TD WIDTH=235 HEIGHT=17>
<P class="Body" style="margin: 0px">Workspace *GetActiveWorkspace(void)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">Screen(DisplayDriver *gfxmodule, uint8 workspaces)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Set driver pointer to gfxmodule</P>
<P class="Body" style="margin: 0px">2) If driver pointer is non-NULL and driver-&gt;Initialize() is true, set initialized flag to true</P>
<P class="Body" style="margin: 0px">3) If initialized, get the appropriate display driver info and save it internally</P>
<P class="Body" style="margin: 0px">4) Create and populate workspace list</P>
<P class="Body" style="margin: 0px">5) Clear all workspaces</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">~Screen(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Remove all workspaces from the list and delete them</P>
<P class="Body" style="margin: 0px">2) Delete the workspace list</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void AddWorkspace(int32 index=-1)</span></P>
<P class="Body" style="margin: 0px"><BR>
Adds a workspace to the screen object, setting its settings to the default, and adding it to the list in the specified index or the end of the list if the index is -1</P>
<P class="Body" style="margin: 0px"><BR>
1) Create a workspace object</P>
<P class="Body" style="margin: 0px">2) Add it to the workspace list - to the end if the index is -1, and to the particular index if not</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DeleteWorkspace(int32 index)</span></P>
<P class="Body" style="margin: 0px"><BR>
Deletes the workspace at the specified index.</P>
<P class="Body" style="margin: 0px"><BR>
1) Remove the item at the specified index and if non-NULL, delete it.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 CountWorkspaces(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the number of workspaces kept by the particular Screen objects</P>
<P class="Body" style="margin: 0px"><BR>
1) Return the workspace list's CountItems() value</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetWorkspaceCount(int32 count)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets the number of workspaces available to <span style="font-style: italic">count</span>. If <span style="font-style: italic">count</span> is less than the number of current workspaces, the last workspaces are deleted first. Workspaces are added to the end of the list. If a delete workspace should include the active workspace, then the workspace with the index <span style="font-style: italic">count-1</span> is activated. There must be at least one workspace.</P>
<P class="Body" style="margin: 0px"><BR>
1) if count equals the workspace list's CountItems value, return</P>
<P class="Body" style="margin: 0px">2) If count is less than 1, set count to 1. If greater than 32, set to 32.</P>
<P class="Body" style="margin: 0px">3) If active workspace index is greater than count-1, call SetWorkspace(count-1)</P>
<P class="Body" style="margin: 0px">4) If count is greater than the workspace list's CountItems value, call AddWorkspace the appropriate number of times.</P>
<P class="Body" style="margin: 0px">5) If count is less than the workspace list's CountItems, call RemoveWorkspace the appropriate number of times</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 CurrentWorkspace(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the active workspace index</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
void SetWorkspace(int32 workspace)</P>
<P class="Body" style="margin: 0px">void Activate(bool active=true)</P>
<P class="Body" style="margin: 0px">DisplayDriver *GetDriver(void)</P>
<P class="Body" style="margin: 0px">status_t SetSpace(int32 index, int32 res, bool stick=true)</P>
<P class="Body" style="margin: 0px">void AddWindow(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE)</P>
<P class="Body" style="margin: 0px">void RemoveWindow(ServerWindow *win)</P>
<P class="Body" style="margin: 0px">ServerWindow *ActiveWindow(void)</P>
<P class="Body" style="margin: 0px">void SetActiveWindow(ServerWindow *win)</P>
<P class="Body" style="margin: 0px">Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE)</P>
<P class="Body" style="margin: 0px">bool IsInitialized(void)</P>
<P class="Body" style="margin: 0px">Workspace *GetActiveWorkspace(void)</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Workspace class members</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=610 HEIGHT=150 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=225 HEIGHT=32>
<P class="Body" style="margin: 0px">Workspace(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)</P>
</TD>
<TD WIDTH=232 HEIGHT=32>
<P class="Body" style="margin: 0px">~Workspace(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetBGColor(const RGBColor &amp;c)</P>
</TD>
<TD WIDTH=232 HEIGHT=17>
<P class="Body" style="margin: 0px">RGBColor BGColor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=32>
<P class="Body" style="margin: 0px">RootLayer *GetRoot(void)</P>
</TD>
<TD WIDTH=232 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=32>
<P class="Body" style="margin: 0px">void GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)</P>
</TD>
<TD WIDTH=232 HEIGHT=32>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<span class="OBOS-Function-Def">Workspace(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Set background color to RGB(51,102,160)</P>
<P class="Body" style="margin: 0px">2) Copy frame_buffer_info and graphics_card_info structure values</P>
<P class="Body" style="margin: 0px">3) Create a RootLayer object using the values from the two structures</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~Workspace(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Call the RootLayer object's PruneTree method and delete it</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetBGColor(const RGBColor &amp;c)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets the particular color for the workspace. Note that this does not refresh the display.</P>
<P class="Body" style="margin: 0px"><BR>
1) Set the internal background RGBColor object to the color parameter</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">RGBColor BGColor(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the internal background color</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">RootLayer *GetRoot(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the pointer to the RootLayer object</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)</span></P>
<P class="Body" style="margin: 0px"><BR>
Changes the graphics data and resizes the RootLayer accordingly.</P>
<P class="Body" style="margin: 0px"><BR>
1) Copy the two structures to the internal one</P>
<P class="Body" style="margin: 0px">2) Resize the RootLayer</P>
<P class="Body" style="margin: 0px">3) If the RootLayer was resized larger, Invalidate the new areas</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)</span></P>
<P class="Body" style="margin: 0px"><BR>
Copies the two data structures into the parameters passed.</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px">RootLayer class members</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=618 HEIGHT=91 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">RootLayer(BRect frame, const char *name)</P>
</TD>
<TD WIDTH=232 HEIGHT=17>
<P class="Body" style="margin: 0px">~RootLayer(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void RequestDraw(const BRect &amp;r)</P>
</TD>
<TD WIDTH=232 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(float x, float y)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(BPoint pt)</P>
</TD>
<TD WIDTH=232 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetDriver(DisplayDriver *d)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void RebuildRegions(bool recursive=false)</P>
</TD>
<TD WIDTH=232 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">RootLayer(BRect frame, const char *name)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) passes B_FOLLOW_NONE to Layer constructor</P>
<P class="Body" style="margin: 0px">2) set level to 0</P>
<P class="Body" style="margin: 0px">3) set the background color to the color for the workspace set in the system preferences</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~RootLayer(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Does nothing.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RequestDraw(const BRect &amp;r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Requests that the layer be drawn on screen. The rectangle passed is in the layer's own coordinates.</P>
<P class="Body" style="margin: 0px"><BR>
1) call the display driver's FillRect on the rectangle, filling with the layer's background color</P>
<P class="Body" style="margin: 0px">2) recurse through each child and call its RequestDraw() function if it intersects the child's frame</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void MoveBy(BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void MoveBy(float x, float y)</span></P>
<P class="Body" style="margin: 0px"><BR>
Made empty so that the root layer cannot be moved</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetDriver(DisplayDriver *d)</span></P>
<P class="Body" style="margin: 0px"><BR>
Assigns a particular display driver object to the root layer if non-NULL.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RebuildRegions(bool recursive=false)</span></P>
<P class="Body" style="margin: 0px"><BR>
Rebuilds the visible and invalid layers based on the layer hierarchy. Used to update the regions after a call to remove or add a child layer is made or when a layer is hidden or shown.</P>
<P class="Body" style="margin: 0px"><BR>
1) get the frame</P>
<P class="Body" style="margin: 0px">2) set full and visible regions to frame</P>
<P class="Body" style="margin: 0px">3) iterate through each child and exclude its full region from the visible region if the child is visible.</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,216 @@
Screen class
############
The Screen class handles all infrastructure needed for each
monitor/video card pair. The Workspace class holds data and supplies
the infrastructure for drawing the screen.
Member Functions
================
Screen(DisplayDriver \*gfxmodule, uint8 workspaces)
---------------------------------------------------
1. Set driver pointer to gfxmodule
2. If driver pointer is non-NULL and driver->Initialize() is true, set
initialized flag to true
3. If initialized, get the appropriate display driver info and save it
internally
4. Create and populate workspace list
5. Clear all workspaces
~Screen(void)
-------------
1. Remove all workspaces from the list and delete them
2. Delete the workspace list
void AddWorkspace(int32 index=-1)
---------------------------------
Adds a workspace to the screen object, setting its settings to the
default, and adding it to the list in the specified index or the end
of the list if the index is -1
1. Create a workspace object
2. Add it to the workspace list - to the end if the index is -1, and to
the particular index if not
void DeleteWorkspace(int32 index)
---------------------------------
Deletes the workspace at the specified index.
1. Remove the item at the specified index and if non-NULL, delete it.
int32 CountWorkspaces(void)
---------------------------
Returns the number of workspaces kept by the particular Screen objects
1. Return the workspace list's CountItems() value
void SetWorkspaceCount(int32 count)
-----------------------------------
Sets the number of workspaces available to count. If count is less
than the number of current workspaces, the last workspaces are deleted
first. Workspaces are added to the end of the list. If a delete
workspace should include the active workspace, then the workspace with
the index count-1 is activated. There must be at least one workspace.
1. if count equals the workspace list's CountItems value, return
2. If count is less than 1, set count to 1. If greater than 32, set to 32.
3. If active workspace index is greater than count-1, call SetWorkspace(count-1)
4. If count is greater than the workspace list's CountItems value, call
AddWorkspace the appropriate number of times.
5. If count is less than the workspace list's CountItems, call
RemoveWorkspace the appropriate number of times
int32 CurrentWorkspace(void)
----------------------------
Returns the active workspace index
void SetWorkspace(int32 workspace)
----------------------------------
void Activate(bool active=true)
-------------------------------
DisplayDriver \*GetDriver(void)
-------------------------------
status_t SetSpace(int32 index, int32 res, bool stick=true)
----------------------------------------------------------
void AddWindow(ServerWindow \*win, int32 workspace=B_CURRENT_WORKSPACE)
-----------------------------------------------------------------------
void RemoveWindow(ServerWindow \*win)
-------------------------------------
ServerWindow \*ActiveWindow(void)
---------------------------------
void SetActiveWindow(ServerWindow \*win)
----------------------------------------
Layer \*GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE)
---------------------------------------------------------
bool IsInitialized(void)
------------------------
Workspace \*GetActiveWorkspace(void)
------------------------------------
Workspace class members
=======================
Workspace(void)
---------------
1. Set background color to RGB(51,102,160)
2. Copy frame_buffer_info and graphics_card_info structure values
3. Create a RootLayer object using the values from the two structures
~Workspace(void)
----------------
1. Call the RootLayer object's PruneTree method and delete it
void SetBGColor(const RGBColor &c)
----------------------------------
Sets the particular color for the workspace. Note that this does not
refresh the display.
1. Set the internal background RGBColor object to the color parameter
RGBColor BGColor(void)
----------------------
Returns the internal background color
RootLayer \*GetRoot(void)
-------------------------
Returns the pointer to the RootLayer object
void SetData(graphics_card_info \*gcinfo, frame_buffer_info \*fbinfo)
---------------------------------------------------------------------
Changes the graphics data and resizes the RootLayer accordingly.
1. Copy the two structures to the internal one
2. Resize the RootLayer
3. If the RootLayer was resized larger, Invalidate the new areas
void GetData(graphics_card_info \*gcinfo, frame_buffer_info \*fbinfo)
---------------------------------------------------------------------
Copies the two data structures into the parameters passed.
RootLayer class members
=======================
RootLayer(BRect frame, const char \*name)
1. passes B_FOLLOW_NONE to Layer constructor
2. set level to 0
3. set the background color to the color for the workspace set in the
system preferences
~RootLayer(void)
----------------
Does nothing.
void RequestDraw(const BRect &r)
--------------------------------
Requests that the layer be drawn on screen. The rectangle passed is in
the layer's own coordinates.
1. call the display driver's FillRect on the rectangle, filling with
the layer's background color
2. recurse through each child and call its RequestDraw() function if it
intersects the child's frame
void MoveBy(BPoint pt), void MoveBy(float x, float y)
-----------------------------------------------------
Made empty so that the root layer cannot be moved
void SetDriver(DisplayDriver \*d)
---------------------------------
Assigns a particular display driver object to the root layer if
non-NULL.
void RebuildRegions(bool recursive=false)
-----------------------------------------
Rebuilds the visible and invalid layers based on the layer hierarchy.
Used to update the regions after a call to remove or add a child layer
is made or when a layer is hidden or shown.
1. get the frame
2. set full and visible regions to frame
3. iterate through each child and exclude its full region from the
visible region if the child is visible.
@@ -1,290 +0,0 @@
<HTML>
<HEAD>
<TITLE>DisplayDriver.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">DisplayDriver 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 DisplayDriver class is not a useful class unto itself. It is to provide a consistent interface for the rest of the app_server to whatever rendering context it is utilizing, whether it be a remote screen, a ServerBitmap, installed graphics hardware, or whatever. Documentation below will describe the role of each function.</P>
<P class="Body" style="margin: 0px">
<HR>
</P>
<P class="Body" style="margin: 0px">Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=464 HEIGHT=474 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">DisplayDriver(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">~DisplayDriver(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">bool Initialize(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">void Shutdown(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=32>
<P class="Body" style="margin: 0px">void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest)</P>
</TD>
<TD WIDTH=240 HEIGHT=32>
<P class="Body" style="margin: 0px">void DrawChar(char c, BPoint pt)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=47>
<P class="Body" style="margin: 0px">void DrawString(const char *string, int32 length, BPoint pt, escapement_delta *delta=NULL)</P>
</TD>
<TD WIDTH=240 HEIGHT=47>
<P class="Body" style="margin: 0px">void Stroke/FillBezier(BPoint *pts, layerdata *d, int8 *pat)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=32>
<P class="Body" style="margin: 0px">void Stroke/FillEllipse(BRect r, layerdata *d, int8 *pattern)</P>
</TD>
<TD WIDTH=240 HEIGHT=32>
<P class="Body" style="margin: 0px">void Stroke/FillArc(BRect r, float angle, float span, layerdata *d, int8 *pattern)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=47>
<P class="Body" style="margin: 0px">void StrokeLine(BPoint start, BPoint end, layerdata *d, int8 *pattern)</P>
</TD>
<TD WIDTH=240 HEIGHT=47>
<P class="Body" style="margin: 0px">void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, layerdata *d, int8 *pattern, bool is_closed=true)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=47>
<P class="Body" style="margin: 0px">void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, layerdata *d, int8 *pattern)</P>
</TD>
<TD WIDTH=240 HEIGHT=47>
<P class="Body" style="margin: 0px">void Stroke/FillRect(BRect r, layerdata *d, int8 *pattern)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=47>
<P class="Body" style="margin: 0px">void Stroke/FillRoundRect(BRect r, float xrad, float yrad, layerdata *d, int8 *pattern)</P>
</TD>
<TD WIDTH=240 HEIGHT=47>
<P class="Body" style="margin: 0px">void Stroke/FillShape(SShape *sh, layerdata *d, int8 *pattern)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=32>
<P class="Body" style="margin: 0px">void Stroke/FillTriangle(BPoints *pts, BRect r, layerdata *d, int8 *pattern)</P>
</TD>
<TD WIDTH=240 HEIGHT=32>
<P class="Body" style="margin: 0px">void StrokeLineArray(BPoint *pts, int32 numlines, rgb_color *colors, layerdata *d)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=22>
<P class="Body" style="margin: 0px">void DrawPicture(SPicture *pic, BPoint pt)</P>
</TD>
<TD WIDTH=240 HEIGHT=22>
<P class="Body" style="margin: 0px">void CopyBits(BRect src, BRect dest)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">void InvertRect(BRect r)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">uint8 GetDepth(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">uint16 GetHeight(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">uint16 GetWidth(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">screen_mode GetMode(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetMode(screen_mode mode)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">bool DumpToFile(const char *path)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">void ShowCursor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">void HideCursor(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">void ObscureCursor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=17>
<P class="Body" style="margin: 0px">bool IsCursorHidden(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetCursor(ServerCursor *csr)</P>
</TD>
</TR>
<TR>
<TD WIDTH=224 HEIGHT=32>
<P class="Body" style="margin: 0px">virtual float StringWidth(const char *string, int32 length, LayerData *d)</P>
</TD>
<TD WIDTH=240 HEIGHT=32>
<P class="Body" style="margin: 0px">virtual float StringHeight(const char *string, int32 length, LayerData *d)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Protected Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=533 HEIGHT=90 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void Lock(void)</P>
</TD>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void Unlock(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetDepth(void)</P>
</TD>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetHeight(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetWidth(void)</P>
</TD>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetMode(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetCursorHidden(void)</P>
</TD>
<TD WIDTH=200 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetCursorObscured(void)</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">DisplayDriver(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">~DisplayDriver(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool Initialize(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void Shutdown(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
These four are for general start and stop procedures. The constructor and destructor concern themselves with the internal members common to all drivers, such as the current cursor and the access semaphore. Subclasses will probably end up using these to handle memory allocation-related issues, but likely not much else. Initialize() and Shutdown() are for general setup internal to the module. Note that if Initialize() returns false, the server will not use the module, call Shutdown(), and then delete it as accordingly.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">void CopyBits(BRect src, BRect dest)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void InvertRect(BRect r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, render_mode mode)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void DrawPicture(SPicture *pic, BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void DrawChar(char c, BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void DrawString(const char *string, int32 length, BPoint pt, escapement_delta *delta=NULL)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def"><BR>
void StrokeArc(BRect r, float angle, float span, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillArc(BRect r, float angle, float span, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeBezier(BPoint *pts, layerdata *d, int8 *pat)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillBezier(BPoint *pts, layerdata *d, int8 *pat)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeEllipse(BRect r, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillEllipse(BRect r, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeLine(BPoint start, BPoint end, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeLineArray(BPoint *pts, int32 numlines, rgb_color *colors, layerdata *d)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, layerdata *d, int8 *pattern, bool is_closed=true)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeRect(BRect r, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillRect(BRect r, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeRoundRect(BRect r, float xrad, float yrad, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillRoundRect(BRect r, float xrad, float yrad, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeShape(SShape *sh, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillShape(SShape *sh, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void StrokeTriangle(BPoints *pts, BRect r, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void FillTriangle(BPoints *pts, BRect r, layerdata *d, int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><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"><span class="OBOS-Function-Def">bool IsCursorHidden(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetCursor(ServerCursor *csr)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">float StringWidth(const char *string, int32 length, LayerData *d)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">float StringHeight(const char *string, int32 length, LayerData *d)</span></P>
<P class="Body" style="margin: 0px"><BR>
These drawing functions are the meat and potatoes of the graphics module. Defining any or all of them is completely optional. However, the default versions of these functions will do nothing. Thus, implementing them is likely a good idea, even if not required.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">uint8 GetDepth(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">uint16 GetHeight(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">uint16 GetWidth(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">screen_mode GetMode(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetMode(screen_mode mode)</span></P>
<P class="Body" style="margin: 0px"><BR>
These five functions are called internally in order to get information about the current state of the buffer in the module. GetDepth should return 8, 16, or 32, in any event because the server handles RGB color spaces of these depths only.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">bool DumpToFile(const char *path)</span></P>
<P class="Body" style="margin: 0px"><BR>
DumpToFile is completely optional, providing a hook which allows screenshots to be taken. The default version does nothing but return false. If a screenshot is successful, return true.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Lock(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void Unlock(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
These two functions provide a locking scheme for the driver in order to easily make it thread safe. Note that it is not publicly callable.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetDepthInternal(uint8 d)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetHeightInternal(uint16 h)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetWidthInternal(uint16 w)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetModeInternal(int32 m)</span></P>
<P class="Body" style="margin: 0px"><BR>
These four functions set the internal state variables for height, width, etc. If the driver reimplements the public members SetDepth(), etc, be sure to call the respective internal call so that calls to GetDepth(), etc. return the proper values.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetCursorHidden(bool state)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetCursorObscured(bool state)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool IsCursorObscured(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
These calls handle internal state tracking so that subclasses don't have to.</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,210 @@
DisplayDriver class
###################
The DisplayDriver class is not a useful class unto itself. It is to
provide a consistent interface for the rest of the app_server to
whatever rendering context it is utilizing, whether it be a remote
screen, a ServerBitmap, installed graphics hardware, or whatever.
Documentation below will describe the role of each function.
Member Functions
================
DisplayDriver(void)
-------------------
~DisplayDriver(void)
--------------------
bool Initialize(void)
---------------------
void Shutdown(void)
-------------------
These four are for general start and stop procedures. The constructor
and destructor concern themselves with the internal members common to
all drivers, such as the current cursor and the access semaphore.
Subclasses will probably end up using these to handle memory
allocation-related issues, but likely not much else. Initialize() and
Shutdown() are for general setup internal to the module. Note that if
Initialize() returns false, the server will not use the module, call
Shutdown(), and then delete it as accordingly.
void CopyBits(BRect src, BRect dest)
------------------------------------
void InvertRect(BRect r)
------------------------
void DrawBitmap(ServerBitmap \*bmp, BRect src, BRect dest, render_mode mode)
----------------------------------------------------------------------------
void DrawPicture(SPicture \*pic, BPoint pt)
-------------------------------------------
void DrawChar(char c, BPoint pt)
--------------------------------
void DrawString(const char \*string, int32 length, BPoint pt, escapement_delta \*delta=NULL)
--------------------------------------------------------------------------------------------
void StrokeArc(BRect r, float angle, float span, layerdata \*d, int8 \*pattern)
-------------------------------------------------------------------------------
void FillArc(BRect r, float angle, float span, layerdata \*d, int8 \*pattern)
-----------------------------------------------------------------------------
void StrokeBezier(BPoint \*pts, layerdata \*d, int8 \*pat)
----------------------------------------------------------
void FillBezier(BPoint \*pts, layerdata \*d, int8 \*pat)
--------------------------------------------------------
void StrokeEllipse(BRect r, layerdata \*d, int8 \*pattern)
----------------------------------------------------------
void FillEllipse(BRect r, layerdata \*d, int8 \*pattern)
--------------------------------------------------------
void StrokeLine(BPoint start, BPoint end, layerdata \*d, int8 \*pattern)
------------------------------------------------------------------------
void StrokeLineArray(BPoint \*pts, int32 numlines, rgb_color \*colors, layerdata \*d)
-------------------------------------------------------------------------------------
void StrokePolygon(BPoint \*ptlist, int32 numpts, BRect rect, layerdata \*d, int8 \*pattern, bool is_closed=true)
-----------------------------------------------------------------------------------------------------------------
void FillPolygon(BPoint \*ptlist, int32 numpts, BRect rect, layerdata \*d, int8 \*pattern)
------------------------------------------------------------------------------------------
void StrokeRect(BRect r, layerdata \*d, int8 \*pattern)
-------------------------------------------------------
void FillRect(BRect r, layerdata \*d, int8 \*pattern)
-----------------------------------------------------
void StrokeRoundRect(BRect r, float xrad, float yrad, layerdata \*d, int8 \*pattern)
------------------------------------------------------------------------------------
void FillRoundRect(BRect r, float xrad, float yrad, layerdata \*d, int8 \*pattern)
----------------------------------------------------------------------------------
void StrokeShape(SShape \*sh, layerdata \*d, int8 \*pattern)
------------------------------------------------------------
void FillShape(SShape \*sh, layerdata \*d, int8 \*pattern)
----------------------------------------------------------
void StrokeTriangle(BPoints \*pts, BRect r, layerdata \*d, int8 \*pattern)
--------------------------------------------------------------------------
void FillTriangle(BPoints \*pts, BRect r, layerdata \*d, int8 \*pattern)
------------------------------------------------------------------------
void ShowCursor(void)
---------------------
void HideCursor(void)
---------------------
void ObscureCursor(void)
------------------------
bool IsCursorHidden(void)
-------------------------
void SetCursor(ServerCursor \*csr)
----------------------------------
float StringWidth(const char \*string, int32 length, LayerData \*d)
-------------------------------------------------------------------
float StringHeight(const char \*string, int32 length, LayerData \*d)
--------------------------------------------------------------------
These drawing functions are the meat and potatoes of the graphics
module. Defining any or all of them is completely optional. However,
the default versions of these functions will do nothing. Thus,
implementing them is likely a good idea, even if not required.
Protected Functions
===================
uint8 GetDepth(void)
--------------------
uint16 GetHeight(void)
----------------------
uint16 GetWidth(void)
---------------------
screen_mode GetMode(void)
-------------------------
void SetMode(screen_mode mode)
------------------------------
These five functions are called internally in order to get information
about the current state of the buffer in the module. GetDepth should
return 8, 16, or 32, in any event because the server handles RGB color
spaces of these depths only.
bool DumpToFile(const char \*path)
----------------------------------
DumpToFile is completely optional, providing a hook which allows
screenshots to be taken. The default version does nothing but return
false. If a screenshot is successful, return true.
void Lock(void)
---------------
void Unlock(void)
-----------------
These two functions provide a locking scheme for the driver in order
to easily make it thread safe. Note that it is not publicly callable.
void SetDepthInternal(uint8 d)
------------------------------
void SetHeightInternal(uint16 h)
--------------------------------
void SetWidthInternal(uint16 w)
-------------------------------
void SetModeInternal(int32 m)
-----------------------------
These four functions set the internal state variables for height,
width, etc. If the driver reimplements the public members SetDepth(),
etc, be sure to call the respective internal call so that calls to
GetDepth(), etc. return the proper values.
void SetCursorHidden(bool state)
--------------------------------
void SetCursorObscured(bool state)
----------------------------------
bool IsCursorObscured(void)
---------------------------
These calls handle internal state tracking so that subclasses don't
have to.
@@ -1,141 +0,0 @@
<HTML>
<HEAD>
<TITLE>FontFamily.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">FontFamily class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
FontFamily objects are used to tie together all related font styles.</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=463 HEIGHT=90 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">FontFamily(const char *name)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">~FontFamily(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=22>
<P class="Body" style="margin: 0px">const char *GetName(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=22>
<P class="Body" style="margin: 0px">void AddStyle(const char *path, FT_Face face)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void RemoveStyle(const char *style)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">FontStyle *GetStyle(const char *stylename)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *GetStyle(int32 index)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 CountStyles(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">bool HasStyle(const char *style)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">FontFamily(const char *name)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Create and set internal name to the one passed to the constructor</P>
<P class="Body" style="margin: 0px">2) Create the styles list</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~FontFamily(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) delete the internal name</P>
<P class="Body" style="margin: 0px">2) empty and delete the internal style list</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">const char *GetName(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the internal family name</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void AddStyle(const char *path, FT_Face face)</span></P>
<P class="Body" style="margin: 0px"><BR>
Adds the style to the family.</P>
<P class="Body" style="margin: 0px"><BR>
1) Create the FontStyle object and add it to the style list.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RemoveStyle(const char *style)</span></P>
<P class="Body" style="margin: 0px"><BR>
Removes the style from the FontFamily object.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call GetStyle on the given pointer</P>
<P class="Body" style="margin: 0px">2) If non-NULL, delete the object</P>
<P class="Body" style="margin: 0px">3) If the style list is now empty, ask the FontServer to remove it from the family list</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">FontStyle *GetStyle(const char *style)</span></P>
<P class="Body" style="margin: 0px"><BR>
Looks up a FontStyle object based on its style name. Returns NULL if not found.</P>
<P class="Body" style="margin: 0px"><BR>
1) Iterate through the style list</P>
<P class="Body" style="margin: 0px"> a) compare <span style="font-style: italic">style</span> to each FontStyle object's GetName method and return the object if they are the same</P>
<P class="Body" style="margin: 0px">2) If all items have been checked and nothing has been returned, return NULL</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">const char *GetStyle(int32 index)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the name of the style at <span style="font-style: italic">index</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Get the FontStyle item at <span style="font-style: italic">index</span> obtained via the style list's ItemAt call</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 CountStyles(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the number of items in the style list and, thus, the number of styles in the family</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool HasStyle(const char *stylename)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns true if the family has a style with the name <span style="font-style: italic">stylename</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Call GetStyle on the style name and return false if NULL, true if not.</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,86 @@
FontFamily class
################
FontFamily objects are used to tie together all related font styles.
Member Functions
================
FontFamily(const char \*name)
-----------------------------
1. Create and set internal name to the one passed to the constructor
2. Create the styles list
~FontFamily(void)
-----------------
1. delete the internal name
2. empty and delete the internal style list
const char \*GetName(void)
---------------------------
Returns the internal family name
void AddStyle(const char \*path, FT_Face face)
----------------------------------------------
Adds the style to the family.
1. Create the FontStyle object and add it to the style list.
void RemoveStyle(const char \*style)
------------------------------------
Removes the style from the FontFamily object.
1. Call GetStyle on the given pointer
2. If non-NULL, delete the object
3. If the style list is now empty, ask the FontServer to remove it from the family list
FontStyle \*GetStyle(const char \*style)
----------------------------------------
Looks up a FontStyle object based on its style name. Returns NULL if
not found.
1. Iterate through the style list
a. compare style to each FontStyle object's GetName method and return the object if they are the same
2. If all items have been checked and nothing has been returned, return NULL
const char \*GetStyle(int32 index)
----------------------------------
Returns the name of the style at index
1. Get the FontStyle item at index obtained via the style list's
ItemAt call
int32 CountStyles(void)
-----------------------
Returns the number of items in the style list and, thus, the number of
styles in the family
bool HasStyle(const char \*stylename)
-------------------------------------
Returns true if the family has a style with the name stylename
1. Call GetStyle on the style name and return false if NULL, true if
not.
@@ -1,274 +0,0 @@
<HTML>
<HEAD>
<TITLE>FontServer.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">FontServer 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 FontServer provides the base functionality for providing font support for the rest of the system and insulates the rest of the server from having to deal too much with FreeType.</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=621 HEIGHT=306 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">FontServer(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">~FontServer(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">void Lock(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">void Unlock(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">void SaveList(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">status_t ScanDirectory(const char *path)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=47>
<P class="Body" style="margin: 0px">FontStyle *GetFont(font_family family, font_style face)</P>
</TD>
<TD WIDTH=240 HEIGHT=47>
<P class="Body" style="margin: 0px">FontInstance *GetInstance(font_family family, font_style face, int16 size, int16 rotation, int16 shear)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 CountFamiles(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">status_t IsInitialized(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=32>
<P class="Body" style="margin: 0px">int32 CountStyles(font_family family)</P>
</TD>
<TD WIDTH=240 HEIGHT=32>
<P class="Body" style="margin: 0px">FontStyle *GetStyle(font_family family, font_style style)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">void RemoveFamily(const char *family)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">FontFamily *_FindFamily(const char *name)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">ServerFont *GetSystemPlain(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">ServerFont *GetSystemBold(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=32>
<P class="Body" style="margin: 0px">ServerFont *GetSystemFixed(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=32>
<P class="Body" style="margin: 0px">bool SetSystemPlain(const char *family, const char *style, float size)</P>
</TD>
</TR>
<TR>
<TD WIDTH=225 HEIGHT=17>
<P class="Body" style="margin: 0px">void RemoveUnusedFamilies(void)</P>
</TD>
<TD WIDTH=240 HEIGHT=17>
<P class="Body" style="margin: 0px">bool FontsNeedUpdated(void)</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">FontServer(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Create access semaphore</P>
<P class="Body" style="margin: 0px">2) Call FT_Init_FreeType()</P>
<P class="Body" style="margin: 0px">3) If no error initializing the FreeType library, set init flag to true</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~FontServer(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Call FT_Done_FreeType()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Lock(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void Unlock(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
These functions simply acquire and release the internal access semaphore.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SaveList(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Saves the list of all scanned and valid font families and styles to disk</P>
<P class="Body" style="margin: 0px"><BR>
1) create a BMessage for storing font family data (hereafter, the font message)</P>
<P class="Body" style="margin: 0px">2) create a BMessage for storing a list of font family messages (hereafter, the list message)</P>
<P class="Body" style="margin: 0px">3) create a boolean tuned flag and a boolean fixed flag</P>
<P class="Body" style="margin: 0px">4) Iterate through all families</P>
<P class="Body" style="margin: 0px"> A) for each family, get its name and add its name to the font message as "name"</P>
<P class="Body" style="margin: 0px"> B) iterate through the families styles</P>
<P class="Body" style="margin: 0px"> a) get the style's name, and if valid, add it to the font message as "styles"</P>
<P class="Body" style="margin: 0px"> b) if IsTuned and IsScalable, set the tuned flag to true</P>
<P class="Body" style="margin: 0px"> c) if IsFixedWidth, set the fixed flag to true</P>
<P class="Body" style="margin: 0px"> C) if the tuned flag is set, add a boolean true to the font message as "tuned"</P>
<P class="Body" style="margin: 0px"> D) if the fixed flag is set, add a boolean true to the font message as "fixed"</P>
<P class="Body" style="margin: 0px"> E) add the font message to the list message as "family"</P>
<P class="Body" style="margin: 0px"> F) empty the font message</P>
<P class="Body" style="margin: 0px">5) Create a BFile from the path definition SERVER_FONT_LIST for Read/Write, creating the file if nonexistent and erasing any existing one</P>
<P class="Body" style="margin: 0px">6) Flatten the list message to the created BFile object</P>
<P class="Body" style="margin: 0px">7) Set the needs_update flag to false</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">status_t ScanDirectory(const char *path)</span></P>
<P class="Body" style="margin: 0px"><BR>
ScanDirectory is where the brunt of the work of the FontServer is done - scans the directory of all fonts which can be loaded.</P>
<P class="Body" style="margin: 0px"><BR>
1) Make a BDirectory object pointer at the path parameter. If the init code is not B_OK, return it.</P>
<P class="Body" style="margin: 0px">2) Enter a while() loop, iterating through each entry in the given directory, executing as follows:</P>
<P class="Body" style="margin: 0px"> a) Ensure that the entry is not '.' or '..'</P>
<P class="Body" style="margin: 0px"> b) Call FT_New_Face on the entry's full path</P>
<P class="Body" style="margin: 0px"> c) If a valid FT_Face is returned, iterate through to see if there are any supported character mappings in the current entry.</P>
<P class="Body" style="margin: 0px"> d) If there are no supported character mappings, dump the supported mappings to debug output, call FT_Done_Face(), and continue to the next entry</P>
<P class="Body" style="margin: 0px"> e) See if the entry's family has been added to the family list. If it hasn't, create one and add it.</P>
<P class="Body" style="margin: 0px"> f) Check to see if the font's style has been added to its family. If so, call FT_Done_Face, and continue to the next entry</P>
<P class="Body" style="margin: 0px"> g) If the style has not been added, create a new SFont for that family and face, increment the font count, and continue to the next entry.</P>
<P class="Body" style="margin: 0px">3) set the needs_update flag to true</P>
<P class="Body" style="margin: 0px">4) Return B_OK</P>
<P class="Body" style="margin: 0px"><BR>
Supported character mappings are Windows and Apple Unicode, Windows symbol, and Apple Roman character mappings, in order of preference from first to last.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">FontStyle *GetFont(font_family family, font_style face)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns an FontStyle object for the specified family and style or NULL if not found.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call _FindFamily() for the given family</P>
<P class="Body" style="margin: 0px">2) If non-NULL, call its FindStyle() method</P>
<P class="Body" style="margin: 0px">3) Return the result</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">FontInstance *GetInstance(font_family family, font_style face, int16 size, int16 rotation, int16 shear)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns a usable instance of a specified font object with specified properties.</P>
<P class="Body" style="margin: 0px"><BR>
1) Duplicates and performs the code found in GetFont</P>
<P class="Body" style="margin: 0px">2) Assuming that the FontStyle object is non-NULL, it calls its GetInstance method and returns the result.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 CountFamilies(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the number of valid font families available to the system.</P>
<P class="Body" style="margin: 0px"><BR>
1) Return the number of items in the family list</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">status_t IsInitialized(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the initialization status variable</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 CountStyles(font_family family)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the number of styles available for a given font family.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call _FindFamily() to get the appropriate font family</P>
<P class="Body" style="margin: 0px">2) If non-NULL, call its return the result of its CountStyles method</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">FontStyle *GetStyle(font_family family, font_style style)</span></P>
<P class="Body" style="margin: 0px"><BR>
Gets the FontStyle object of the family, style, and flags.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call _FindFamily() to get the appropriate font family</P>
<P class="Body" style="margin: 0px">2) If non-NULL, call the family's GetStyle method on the font_style parameter and return the result</P>
<P class="Body" style="margin: 0px">3) If family is NULL, return NULL</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RemoveFamily(const char *family)</span></P>
<P class="Body" style="margin: 0px"><BR>
Removes a font family from the family list</P>
<P class="Body" style="margin: 0px"><BR>
1) Look up font family in the family list via _FindFamily()</P>
<P class="Body" style="margin: 0px">2) If it exists, delete it</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
protected:</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">FontFamily *_FindFamily(const char *name)</span></P>
<P class="Body" style="margin: 0px"><BR>
Looks up a FontFamily object based on its family name. Returns NULL if not found.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call the family list's find() method.</P>
<P class="Body" style="margin: 0px">2) Return the appropriate FontFamily object or NULL if not found.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">ServerFont *GetSystemPlain(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">ServerFont *GetSystemBold(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">ServerFont *GetSystemFixed(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
These return a copy of a pointer to the system-wide ServerFont objects which represent the appropriate system font settings. It is the responsibility of the caller to delete the object returned. NULL is returned if no setting has been set for a particular system font.</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">bool SetSystemPlain(const char *family, const char *style, float size)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool SetSystemBold(const char *family, const char *style, float size)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool SetSystemFixed(const char *family, const char *style, float size)</span></P>
<P class="Body" style="margin: 0px"><BR>
The system fonts settings may be set via these calls by specifying the family, style, and size. They return true if everything worked out ok and false if not. Settings are not changed if false is returned.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call _FindFamily on the family parameter. if NULL, return false</P>
<P class="Body" style="margin: 0px">2) Call the family's GetStyle member. if NULL, return false</P>
<P class="Body" style="margin: 0px">3) if the appropriate system font pointer is non-NULL, delete it</P>
<P class="Body" style="margin: 0px">4) call the style's Instantiate member with the size parameter</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RemoveUnusedFamilies(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
The purpose of this function is to allow for a complete rescan of the fonts in the appropriate directories.</P>
<P class="Body" style="margin: 0px"><BR>
1) Iterate through the family list</P>
<P class="Body" style="margin: 0px"> A) Get a family</P>
<P class="Body" style="margin: 0px"> B) if it has no dependents, remove it from the list and delete it</P>
<P class="Body" style="margin: 0px">2) Set the needs_update flag to true</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool FontsNeedUpdated(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the value of the needs_update flag</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,228 @@
FontServer class
################
The FontServer provides the base functionality for providing font
support for the rest of the system and insulates the rest of the server
from having to deal too much with FreeType.
Member Functions
================
+-----------------------------------+-----------------------------------+
| FontServer(void) | ~FontServer(void) |
+-----------------------------------+-----------------------------------+
| void Lock(void) | void Unlock(void) |
+-----------------------------------+-----------------------------------+
| void SaveList(void) | status_t ScanDirectory(const char |
| | \*path) |
+-----------------------------------+-----------------------------------+
| FontStyle \*GetFont(font_family | FontInstance |
| family, font_style face) | \*GetInstance(font_family family, |
| | font_style face, int16 size, |
| | int16 rotation, int16 shear) |
+-----------------------------------+-----------------------------------+
| int32 CountFamiles(void) | status_t IsInitialized(void) |
+-----------------------------------+-----------------------------------+
| int32 CountStyles(font_family | FontStyle \*GetStyle(font_family |
| family) | family, font_style style) |
+-----------------------------------+-----------------------------------+
| void RemoveFamily(const char | FontFamily \*_FindFamily(const |
| \*family) | char \*name) |
+-----------------------------------+-----------------------------------+
| ServerFont \*GetSystemPlain(void) | ServerFont \*GetSystemBold(void) |
+-----------------------------------+-----------------------------------+
| ServerFont \*GetSystemFixed(void) | bool SetSystemPlain(const char |
| | \*family, const char \*style, |
| | float size) |
+-----------------------------------+-----------------------------------+
| void RemoveUnusedFamilies(void) | bool FontsNeedUpdated(void) |
+-----------------------------------+-----------------------------------+
FontServer(void)
----------------
1. Create access semaphore
2. Call FT_Init_FreeType()
3. If no error initializing the FreeType library, set init flag to true
~FontServer(void)
-----------------
1. Call FT_Done_FreeType()
void Lock(void), void Unlock(void)
----------------------------------
These functions simply acquire and release the internal access
semaphore.
void SaveList(void)
-------------------
Saves the list of all scanned and valid font families and styles to
disk
1. create a BMessage for storing font family data (hereafter, the font message)
2. create a BMessage for storing a list of font family messages (hereafter, the list message)
3. create a boolean tuned flag and a boolean fixed flag
4. Iterate through all families
A. for each family, get its name and add its name to the font message as "name"
B. iterate through the families styles
a. get the style's name, and if valid, add it to the font message as "styles"
b. if IsTuned and IsScalable, set the tuned flag to true
c. if IsFixedWidth, set the fixed flag to true
C. if the tuned flag is set, add a boolean true to the font message as "tuned"
D. if the fixed flag is set, add a boolean true to the font message as "fixed"
E. add the font message to the list message as "family"
F. empty the font message
5. Create a BFile from the path definition SERVER_FONT_LIST for Read/Write, creating the file if nonexistent and erasing any existing one
6. Flatten the list message to the created BFile object
7. Set the needs_update flag to false
status_t ScanDirectory(const char \*path)
-----------------------------------------
ScanDirectory is where the brunt of the work of the FontServer is done: scan the directory of all fonts which can be loaded.
1. Make a BDirectory object pointer at the path parameter. If the init code is not B_OK, return it.
2. Enter a while() loop, iterating through each entry in the given directory, executing as follows:
a. Ensure that the entry is not '.' or '..'
b. Call FT_New_Face on the entry's full path
c. If a valid FT_Face is returned, iterate through to see if there are any supported character mappings in the current entry.
d. If there are no supported character mappings, dump the supported mappings to debug output, call FT_Done_Face(), and continue to the next entry
e. See if the entry's family has been added to the family list. If it hasn't, create one and add it.
f. Check to see if the font's style has been added to its family. If so, call FT_Done_Face, and continue to the next entry
g. If the style has not been added, create a new SFont for that family and face, increment the font count, and continue to the next entry.
3. set the needs_update flag to true
4. Return B_OK
Supported character mappings are Windows and Apple Unicode, Windows
symbol, and Apple Roman character mappings, in order of preference
from first to last.
FontStyle \*GetFont(font_family family, font_style face)
--------------------------------------------------------
Returns an FontStyle object for the specified family and style or NULL
if not found.
1. Call \_FindFamily() for the given family
2. If non-NULL, call its FindStyle() method
3. Return the result
FontInstance \*GetInstance(font_family family, font_style face, int16 size, int16 rotation, int16 shear)
--------------------------------------------------------------------------------------------------------
Returns a usable instance of a specified font object with specified
properties.
1. Duplicates and performs the code found in GetFont
2. Assuming that the FontStyle object is non-NULL, it calls its GetInstance method and returns the result.
int32 CountFamilies(void)
-------------------------
Returns the number of valid font families available to the system.
1. Return the number of items in the family list
status_t IsInitialized(void)
----------------------------
Returns the initialization status variable
int32 CountStyles(font_family family)
-------------------------------------
Returns the number of styles available for a given font family.
1. Call \_FindFamily() to get the appropriate font family
2. If non-NULL, call its return the result of its CountStyles method
FontStyle \*GetStyle(font_family family, font_style style)
----------------------------------------------------------
Gets the FontStyle object of the family, style, and flags.
1. Call \_FindFamily() to get the appropriate font family
2. If non-NULL, call the family's GetStyle method on the font_style parameter and return the result
3. If family is NULL, return NULL
void RemoveFamily(const char \*family)
--------------------------------------
Removes a font family from the family list
1. Look up font family in the family list via \_FindFamily()
2. If it exists, delete it
FontFamily \*_FindFamily(const char \*name)
-------------------------------------------
Looks up a FontFamily object based on its family name. Returns NULL if not found.
1. Call the family list's find() method.
2. Return the appropriate FontFamily object or NULL if not found.
ServerFont \*GetSystemPlain(void), ServerFont \*GetSystemBold(void), ServerFont \*GetSystemFixed(void)
------------------------------------------------------------------------------------------------------
These return a copy of a pointer to the system-wide ServerFont objects
which represent the appropriate system font settings. It is the
responsibility of the caller to delete the object returned. NULL is
returned if no setting has been set for a particular system font.
bool SetSystemPlain(const char \*family, const char \*style, float size)
------------------------------------------------------------------------
bool SetSystemBold(const char \*family, const char \*style, float size)
-----------------------------------------------------------------------
bool SetSystemFixed(const char \*family, const char \*style, float size)
------------------------------------------------------------------------
The system fonts settings may be set via these calls by specifying the
family, style, and size. They return true if everything worked out ok
and false if not. Settings are not changed if false is returned.
1. Call \_FindFamily on the family parameter. if NULL, return false
2. Call the family's GetStyle member. if NULL, return false
3. if the appropriate system font pointer is non-NULL, delete it
4. call the style's Instantiate member with the size parameter
void RemoveUnusedFamilies(void)
-------------------------------
The purpose of this function is to allow for a complete rescan of the
fonts in the appropriate directories.
1. Iterate through the family list
A. Get a family
B. if it has no dependents, remove it from the list and delete it
2. Set the needs_update flag to true
bool FontsNeedUpdated(void)
---------------------------
Returns the value of the needs_update flag
@@ -1,164 +0,0 @@
<HTML>
<HEAD>
<TITLE>FontStyle.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">FontStyle class : public SharedObject</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">FontStyle objects represent a font's look, such as bold, italics, etc.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Type Definitions</P>
<P class="Body" style="margin: 0px"><BR>
typedef struct CachedFaceRec_</P>
<P class="Body" style="margin: 0px">{</P>
<P class="Body" style="margin: 0px"> BString file_path; </P>
<P class="Body" style="margin: 0px"> uint32 face_index; </P>
<P class="Body" style="margin: 0px">} CachedFaceRec, *CachedFace;</P>
<P class="Body" style="margin: 0px"><BR>
A record used in FreeType caching.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=618 HEIGHT=198 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=213 HEIGHT=32>
<P class="Body" style="margin: 0px">FontStyle(const char *filepath, FT_Face face)</P>
</TD>
<TD WIDTH=250 HEIGHT=32>
<P class="Body" style="margin: 0px">~FontStyle(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=213 HEIGHT=32>
<P class="Body" style="margin: 0px">ServerFont *Instantiate(float size, float rotation=0.0, float shear=90.0)</P>
</TD>
<TD WIDTH=250 HEIGHT=32>
<P class="Body" style="margin: 0px">bool IsFixedWidth(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=213 HEIGHT=17>
<P class="Body" style="margin: 0px">bool IsScalable(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">bool HasKerning(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=213 HEIGHT=17>
<P class="Body" style="margin: 0px">bool HasTuned(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">uint16 GlyphCount(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=213 HEIGHT=17>
<P class="Body" style="margin: 0px">uint16 CharMapCount(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *Style(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=213 HEIGHT=17>
<P class="Body" style="margin: 0px">FontFamily *Family(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">FT_Face GetFace(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=213 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *GetPath(void)</P>
</TD>
<TD WIDTH=250 HEIGHT=17>
<P class="Body" style="margin: 0px">int16 ConvertToUni code(uint16 c)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">FontStyle(const char *filepath, FT_Face face)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) set name from face</P>
<P class="Body" style="margin: 0px">2) create a CachedFaceRec object and generate the handle as being the memory address converted to an integer. Assign the path from the parameter.</P>
<P class="Body" style="margin: 0px">3) set the path from the parameter</P>
<P class="Body" style="margin: 0px">4) set family to NULL</P>
<P class="Body" style="margin: 0px">5) create the instance list</P>
<P class="Body" style="margin: 0px">6) check to see if face object has ready-made strikes and set IsTuned flags as appropriate</P>
<P class="Body" style="margin: 0px">7) set fixed-width, kerning, and scalable flags as appropriate, based on face data</P>
<P class="Body" style="margin: 0px">8) get and assign glyph and charmap count</P>
<P class="Body" style="margin: 0px">9) set bounds to an invalid rectangle</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~FontStyle(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) delete all pointer objects</P>
<P class="Body" style="margin: 0px">2) empty instance list, delete all attached instances, and delete the list</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">ServerFont *Instantiate(float size, float rotation=0.0, float shear=90.0)</span></P>
<P class="Body" style="margin: 0px"><BR>
Retrieves a specific instance of the font style, based on the size, rotation, and shear values</P>
<P class="Body" style="margin: 0px"><BR>
1) create a new ServerFont object</P>
<P class="Body" style="margin: 0px">2) add the new object to the instance list and return it</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool IsFixedWidth(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool IsScalable(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool HasKerning(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">bool HasTuned(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">uint16 GlyphCount(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">uint16 CharMapCount(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">const char *GetPath(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">FT_Face GetFace(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
These merely return the appropriate flags/values which are assigned values in the constructor.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">const char *Style(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the string value for the particular style.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">FontFamily *Family(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the pointer to the FontStyle object's family. Do NOT delete this pointer.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int16 ConvertToUnicode(uint16 c)</span></P>
<P class="Body" style="margin: 0px"><BR>
Converts a character code to a UTF-8 string</P>
<P class="Body" style="margin: 0px"><BR>
1) Look up the face from the cache manager</P>
<P class="Body" style="margin: 0px">2) Call FT_Get_Char_Index for the particular character code and return the value</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
-389
View File
@@ -1,389 +0,0 @@
<HTML>
<HEAD>
<TITLE>Layer.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">Layer 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 Layer class is responsible for working with invalid regions and serves as the shadow class for BViews.</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=620 HEIGHT=480 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=231 HEIGHT=32>
<P class="Body" style="margin: 0px">Layer(BRect frame, const char *name, int32 resize, int32 flags, ServerWindow *win)</P>
</TD>
<TD WIDTH=234 HEIGHT=32>
<P class="Body" style="margin: 0px">~Layer(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=32>
<P class="Body" style="margin: 0px">void AddChild(Layer *child, Layer *before=NULL, bool rebuild=true)</P>
</TD>
<TD WIDTH=234 HEIGHT=32>
<P class="Body" style="margin: 0px">RemoveChild(Layer *child, bool rebuild=true)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void RemoveSelf(bool rebuild=true)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">void Invalidate(BRect r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void Invalidate(BRegion *region)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">BRect Frame(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">BRect Bounds(void)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(BPoint pt)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(float x, float y)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">void ResizeBy(BPoint pt)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void ResizeBy(float x, float y)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 CountChildren(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">bool IsDirty(void)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">BRect ConvertToTop(const BRect &amp;r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=32>
<P class="Body" style="margin: 0px">BRegion ConvertToTop(const BRegion &amp;r)</P>
</TD>
<TD WIDTH=234 HEIGHT=32>
<P class="Body" style="margin: 0px">BRect ConvertFromTop(const BRect &amp;r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=32>
<P class="Body" style="margin: 0px">BRegion ConvertFromTop(const BRegion &amp;r)</P>
</TD>
<TD WIDTH=234 HEIGHT=32>
<P class="Body" style="margin: 0px">BRect ConvertToParent(const BRect &amp;r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=32>
<P class="Body" style="margin: 0px">BRegion ConvertToParent(const BRegion &amp;r)</P>
</TD>
<TD WIDTH=234 HEIGHT=32>
<P class="Body" style="margin: 0px">BRect ConvertFromParent(const BRect &amp;r)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=32>
<P class="Body" style="margin: 0px">BRegion ConvertFromParent(const BRegion &amp;r)</P>
</TD>
<TD WIDTH=234 HEIGHT=32>
<P class="Body" style="margin: 0px">void RebuildRegions(bool recursive=false)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void MakeTopChild(void)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">void MakeBottomChild(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=17>
<P class="Body" style="margin: 0px">void RequestDraw(const BRect &amp;r)</P>
</TD>
<TD WIDTH=234 HEIGHT=17>
<P class="Body" style="margin: 0px">Layer *FindLayer(int32 token)</P>
</TD>
</TR>
<TR>
<TD WIDTH=231 HEIGHT=32>
<P class="Body" style="margin: 0px">Layer *GetChildAt(BPoint pt, bool recursive=false)</P>
</TD>
<TD WIDTH=234 HEIGHT=32>
<P class="Body" style="margin: 0px">PortLink *GetLink(void)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
If there are any global functions associated with the class, they are listed here.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">Layer(BRect frame, const char *name, int32 resize, int32 flags, ServerWindow *win)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) acquire a new layer token</P>
<P class="Body" style="margin: 0px">2) validate (and fix, if necessary) parameters and assign to member objects</P>
<P class="Body" style="margin: 0px">3) initalize relation pointers to NULL</P>
<P class="Body" style="margin: 0px">4) set level to -1</P>
<P class="Body" style="margin: 0px">5) set invalid region to NULL</P>
<P class="Body" style="margin: 0px">6) set full and visible regions to bounds</P>
<P class="Body" style="margin: 0px">7) set child count to 0</P>
<P class="Body" style="margin: 0px">8) get ServerWindow's window port and create a PortLink pointed at it</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~Layer(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) if parent is non-NULL, call RemoveSelf()</P>
<P class="Body" style="margin: 0px">2) if topchild is non-NULL, iterate through children and delete them.</P>
<P class="Body" style="margin: 0px">3) delete invalid, full, and visible regions if non-NULL</P>
<P class="Body" style="margin: 0px">4) delete the internal PortLink</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void AddChild(Layer *child, Layer *before=NULL, bool rebuild=true)</span></P>
<P class="Body" style="margin: 0px"><BR>
Function which corresponds to BView::AddChild</P>
<P class="Body" style="margin: 0px"><BR>
1) if child-&gt;parent is non-NULL, spew an error to stderr and return</P>
<P class="Body" style="margin: 0px">2) set child-&gt;parent to this</P>
<P class="Body" style="margin: 0px"><BR>
if before == NULL:</P>
<P class="Body" style="margin: 0px"> A) if topchild is non-NULL, set child-&gt;uppersibling to child</P>
<P class="Body" style="margin: 0px"> B) set child-&gt;lowersibling to topchild</P>
<P class="Body" style="margin: 0px"> C) if topchild is NULL, set bottomchild to child</P>
<P class="Body" style="margin: 0px"> D) set topchild to child</P>
<P class="Body" style="margin: 0px"><BR>
if before != NULL:</P>
<P class="Body" style="margin: 0px"> A) if before-&gt;upper is non-NULL, set child-&gt;upper to before-&gt;upper</P>
<P class="Body" style="margin: 0px"> B) set before-&gt;upper to child</P>
<P class="Body" style="margin: 0px"> C) set child-&gt;lower to before</P>
<P class="Body" style="margin: 0px"> D) if child-&gt;upper is non-NULL, set child-&gt;upper-&gt;lower to child</P>
<P class="Body" style="margin: 0px"> E) increment child's level</P>
<P class="Body" style="margin: 0px">3) increment the child count</P>
<P class="Body" style="margin: 0px">4) if rebuild flag is true, call RebuildRegions</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">RemoveChild(Layer *child, bool rebuild=true)</span></P>
<P class="Body" style="margin: 0px"><BR>
Function which corresponds to BView::RemoveChild</P>
<P class="Body" style="margin: 0px"><BR>
1) if child's parent != this, spew an error to stderr and return</P>
<P class="Body" style="margin: 0px">2) set child's parent to NULL</P>
<P class="Body" style="margin: 0px">3) set child's level to -1</P>
<P class="Body" style="margin: 0px">4) if top child matches child, set top child to child's lower sibling</P>
<P class="Body" style="margin: 0px">5) if bottom child matches child, set bottom child to child's upper sibilng</P>
<P class="Body" style="margin: 0px">6) if child-&gt;uppersibling is non-NULL, set its lowersibling to the child's lowersibling</P>
<P class="Body" style="margin: 0px">7) if child-&gt;lowersibling is non-NULL, set its uppersibling to the child's uppersibling</P>
<P class="Body" style="margin: 0px">8) decrement child count</P>
<P class="Body" style="margin: 0px">9) call RebuildRegions</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RemoveSelf(bool rebuild=true)</span></P>
<P class="Body" style="margin: 0px"><BR>
Function which corresponds to BView::RemoveSelf</P>
<P class="Body" style="margin: 0px"><BR>
1) if parent is NULL, spew an error to stderr and return</P>
<P class="Body" style="margin: 0px">2) call parent-&gt;RemoveChild(this)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Invalidate(BRect r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void Invalidate(BRegion *region)</span></P>
<P class="Body" style="margin: 0px"><BR>
Marks the area passed to the function as needing to be redrawn</P>
<P class="Body" style="margin: 0px"><BR>
1) if parent is NULL, return</P>
<P class="Body" style="margin: 0px">2) if the passed area intersects the layer's frame, add it to the invalid region, creating a new invalid object if necessary.</P>
<P class="Body" style="margin: 0px">3) Iterate through all child layers, calling child-&gt;Invalidate() on the area converted from the parent</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">BRect Frame(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BRect Bounds(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Frame() returns the layer's frame in its parent coordinates. Bounds() returns the frame offset to (0,0).</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void MoveBy(BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void MoveBy(float x, float y)</span></P>
<P class="Body" style="margin: 0px"><BR>
Moves the layer in its parent's coordinate space by the specified amount</P>
<P class="Body" style="margin: 0px"><BR>
1) offset the frame by the specified amount</P>
<P class="Body" style="margin: 0px">2) if parent is non-NULL, call parent-&gt;RebuildRegions()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ResizeBy(BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void ResizeBy(float x, float y)</span></P>
<P class="Body" style="margin: 0px"><BR>
Resizes the layer by the specified amount and all children as appropriate.</P>
<P class="Body" style="margin: 0px"><BR>
1) resize the frame by the specified amount</P>
<P class="Body" style="margin: 0px">2) iterate through all children, checking the resize flags to see whether each should be resized and calling child-&gt;ResizeBy() by the appropriate amount if it is necessary.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 CountChildren(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the number of children owned directly by the layer - grandchildren not included and some assembly required. Instructions are written in Yiddish.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool IsDirty(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns true if the layer needs redrawn (if invalid region is non-NULL).</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">BRect ConvertToTop(const BRect &amp;r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BRegion ConvertToTop(const BRegion &amp;r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Converts the given data to the coordinates of the root layer in the layer tree.</P>
<P class="Body" style="margin: 0px"><BR>
1) if parent is non-NULL, return the data.</P>
<P class="Body" style="margin: 0px">2) if parent is NULL, call this: return (parent-&gt;ConvertToTop( data_offset_by_frame.left_top ) )</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">BRect ConvertFromTop(const BRect &amp;r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BRegion ConvertFromTop(const BRegion &amp;r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Converts the given data from the coordinates of the root layer in the layer tree.</P>
<P class="Body" style="margin: 0px"><BR>
1) if parent is non-NULL, return the layer's frame</P>
<P class="Body" style="margin: 0px">2) if parent is NULL, call this: return (parent-&gt;ConvertFromTop( data_offset_by_frame.left_and_top * -1 ) )</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">BRect ConvertToParent(const BRect &amp;r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BRegion ConvertToParent(const BRegion &amp;r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Converts the given data to the coordinates of the parent layer</P>
<P class="Body" style="margin: 0px"><BR>
1) return the data offset by the layer's frame's top left point, i.e. frame.LeftTop()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">BRect ConvertFromParent(const BRect &amp;r)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">BRegion ConvertFromParent(const BRegion &amp;r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Converts the given data from the coordinates of the parent layer</P>
<P class="Body" style="margin: 0px"><BR>
1) operates exactly like ConvertToParent, except that the offset values are multiplied by -1</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RebuildRegions(bool recursive=false)</span></P>
<P class="Body" style="margin: 0px"><BR>
Rebuilds the visible and invalid layers based on the layer hierarchy. Used to update the regions after a call to remove or add a child layer is made or when a layer is hidden or shown.</P>
<P class="Body" style="margin: 0px"><BR>
1) get the frame</P>
<P class="Body" style="margin: 0px">2) set full and visible regions to frame</P>
<P class="Body" style="margin: 0px">3) iterate through each child and exclude its full region from the visible region if the child is visible.</P>
<P class="Body" style="margin: 0px">4) iterate through each lowersibling and exclude its full region from the visible region if the it is visible and it intersects the layer's frame.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void MakeTopChild(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Makes the layer the top child owned by its parent. Note that the top child is "behind" other children on the screen.</P>
<P class="Body" style="margin: 0px"><BR>
1) if parent is NULL, spew an error to stderr and return</P>
<P class="Body" style="margin: 0px">2) if parent's top child equals this, return without doing anything</P>
<P class="Body" style="margin: 0px">3) if lowersibling and uppersibling are both NULL, return without doing anything</P>
<P class="Body" style="margin: 0px">4) save pointer to parent layer to a temporary variable</P>
<P class="Body" style="margin: 0px">5) call RemoveSelf and then the former parent's AddChild</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void MakeBottomChild(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Makes the layer the bottom child owned by its parent. Note that the top child is "in front of" other children on the screen.</P>
<P class="Body" style="margin: 0px"><BR>
1) if parent is NULL, spew an error to stderr and return</P>
<P class="Body" style="margin: 0px">2) if parent's bottom child equals this, return without doing anything</P>
<P class="Body" style="margin: 0px">3) if lowersibling and uppersibling are both NULL, return without doing anything</P>
<P class="Body" style="margin: 0px">4) save pointer to parent layer to a temporary variable</P>
<P class="Body" style="margin: 0px">5) call RemoveSelf() with rebuild set to false</P>
<P class="Body" style="margin: 0px">6) call former parent's AddChild (rebuild is false), setting the before parameter to the former parent's bottomchild</P>
<P class="Body" style="margin: 0px">7) save lowersibling to a temporary variable</P>
<P class="Body" style="margin: 0px">8) call lowersibling-&gt;RemoveSelf() with no rebuild</P>
<P class="Body" style="margin: 0px">9) call the parent's AddChild() with the before set to this and rebuild set to true</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RequestDraw(const BRect &amp;r)</span></P>
<P class="Body" style="margin: 0px"><BR>
Requests that the layer be drawn on screen. The rectangle passed is in the layer's own coordinates.</P>
<P class="Body" style="margin: 0px"><BR>
1) if invalid is NULL, return</P>
<P class="Body" style="margin: 0px">2) set the PortLink opcode to B_DRAW</P>
<P class="Body" style="margin: 0px">3) create a BMessage(B_DRAW) and attach all invalid rectangles to it</P>
<P class="Body" style="margin: 0px">4) attach the view token to the message</P>
<P class="Body" style="margin: 0px">4) flatten the message to a buffer, attach it to the PortLink, and Flush() it.</P>
<P class="Body" style="margin: 0px">5) recurse through each child and call its RequestDraw() function if it intersects the child's frame</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">Layer *FindLayer(int32 token)</span></P>
<P class="Body" style="margin: 0px"><BR>
Finds a child layer given an identifying token</P>
<P class="Body" style="margin: 0px"><BR>
1) iterate through children and check tokens. Return a match if found.</P>
<P class="Body" style="margin: 0px">2) iterate through children, calling its FindLayer function, return any non-NULL results</P>
<P class="Body" style="margin: 0px">3) return NULL - we got this far, so there is no match</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">Layer *GetChildAt(BPoint pt, bool recursive=false)</span></P>
<P class="Body" style="margin: 0px"><BR>
Gets the child at a given point. if recursive is true, all layers under the current one in the tree are searched. if the point is contained by the current layer's frame and no child is found, this function returns the current layer. if the point is outside the current layer's frame, it returns NULL</P>
<P class="Body" style="margin: 0px"><BR>
1) if frame does not contain the point, return NULL
</P>
<P class="Body" style="margin: 0px">if recursive is true:</P>
<P class="Body" style="margin: 0px"> A) start at the *bottom* child and iterate upward.</P>
<P class="Body" style="margin: 0px"> B) if the child has children, call the child's GetChildAt with the point converted to the child's coordinate space, returning any non-NULL results</P>
<P class="Body" style="margin: 0px"> C) if the child is hidden, continue to the next iteration</P>
<P class="Body" style="margin: 0px"> D) if the child's frame contains the point, return the child</P>
<P class="Body" style="margin: 0px"> E) if none of the children contain the point, return this</P>
<P class="Body" style="margin: 0px"><BR>
if recursive is false:</P>
<P class="Body" style="margin: 0px"> A) start at the *bottom* child and iterate upward.</P>
<P class="Body" style="margin: 0px"> B) if the child is hidden, continue to the next iteration</P>
<P class="Body" style="margin: 0px"> C) if the child's frame contains the point, return the child</P>
<P class="Body" style="margin: 0px"> D) if none of the children contain the point, return this</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">PortLink *GetLink(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the layer's internal PortLink object so a message can be sent to the Layer's window.</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
+283
View File
@@ -0,0 +1,283 @@
Layer class
###########
The Layer class is responsible for working with invalid regions and
serves as the shadow class for BViews.
Member Functions
================
Layer(BRect frame, const char \*name, int32 resize, int32 flags, ServerWindow \*win)
------------------------------------------------------------------------------------
1. acquire a new layer token
2. validate (and fix, if necessary) parameters and assign to member objects
3. initalize relation pointers to NULL
4. set level to -1
5. set invalid region to NULL
6. set full and visible regions to bounds
7. set child count to 0
8. get ServerWindow's window port and create a PortLink pointed at it
~Layer(void)
------------
1. if parent is non-NULL, call RemoveSelf()
2. if topchild is non-NULL, iterate through children and delete them.
3. delete invalid, full, and visible regions if non-NULL
4. delete the internal PortLink
void AddChild(Layer \*child, Layer \*before=NULL, bool rebuild=true)
--------------------------------------------------------------------
Function which corresponds to BView::AddChild
1) if child->parent is non-NULL, spew an error to stderr and return
2) set child->parent to this
a) if before == NULL:
A) if topchild is non-NULL, set child->uppersibling to child
B) set child->lowersibling to topchild
C) if topchild is NULL, set bottomchild to child
D) set topchild to child
b) if before != NULL:
A) if before->upper is non-NULL, set child->upper to before->upper
B) set before->upper to child
C) set child->lower to before
D) if child->upper is non-NULL, set child->upper->lower to child
E) increment child's level
3) increment the child count
4) if rebuild flag is true, call RebuildRegions
RemoveChild(Layer \*child, bool rebuild=true)
---------------------------------------------
Function which corresponds to BView::RemoveChild
1. if child's parent != this, spew an error to stderr and return
2. set child's parent to NULL
3. set child's level to -1
4. if top child matches child, set top child to child's lower sibling
5. if bottom child matches child, set bottom child to child's upper sibilng
6. if child->uppersibling is non-NULL, set its lowersibling to the child's lowersibling
7. if child->lowersibling is non-NULL, set its uppersibling to the child's uppersibling
8. decrement child count
9. call RebuildRegions
void RemoveSelf(bool rebuild=true)
----------------------------------
Function which corresponds to BView::RemoveSelf
1. if parent is NULL, spew an error to stderr and return
2. call parent->RemoveChild(this)
void Invalidate(BRect r)
------------------------
void Invalidate(BRegion \*region)
---------------------------------
Marks the area passed to the function as needing to be redrawn
1) if parent is NULL, return
2) if the passed area intersects the layer's frame, add it to the
invalid region, creating a new invalid object if necessary.
3) Iterate through all child layers, calling child->Invalidate() on the
area converted from the parent
BRect Frame(void), BRect Bounds(void)
-------------------------------------
Frame() returns the layer's frame in its parent coordinates. Bounds()
returns the frame offset to (0,0).
void MoveBy(BPoint pt), void MoveBy(float x, float y)
-----------------------------------------------------
Moves the layer in its parent's coordinate space by the specified
amount
1. offset the frame by the specified amount
2. if parent is non-NULL, call parent->RebuildRegions()
void ResizeBy(BPoint pt), void ResizeBy(float x, float y)
---------------------------------------------------------
Resizes the layer by the specified amount and all children as
appropriate.
1) resize the frame by the specified amount
2) iterate through all children, checking the resize flags to see
whether each should be resized and calling child->ResizeBy() by the
appropriate amount if it is necessary.
int32 CountChildren(void)
-------------------------
Returns the number of children owned directly by the layer -
grandchildren not included and some assembly required. Instructions
are written in Yiddish.
bool IsDirty(void)
------------------
Returns true if the layer needs redrawn (if invalid region is
non-NULL).
BRect ConvertToTop(const BRect &r), BRegion ConvertToTop(const BRegion &r)
--------------------------------------------------------------------------
Converts the given data to the coordinates of the root layer in the
layer tree.
1) if parent is non-NULL, return the data.
2) if parent is NULL, call this: return (parent->ConvertToTop(
data_offset_by_frame.left_top ) )
BRect ConvertFromTop(const BRect &r), BRegion ConvertFromTop(const BRegion &r)
------------------------------------------------------------------------------
Converts the given data from the coordinates of the root layer in the
layer tree.
1. if parent is non-NULL, return the layer's frame
2. if parent is NULL, call this: return (parent->ConvertFromTop(
data_offset_by_frame.left_and_top \* -1 ) )
BRect ConvertToParent(const BRect &r), BRegion ConvertToParent(const BRegion &r)
Converts the given data to the coordinates of the parent layer
1. return the data offset by the layer's frame's top left point, i.e.
frame.LeftTop()
BRect ConvertFromParent(const BRect &r), BRegion ConvertFromParent(const BRegion &r)
------------------------------------------------------------------------------------
Converts the given data from the coordinates of the parent layer
1. operates exactly like ConvertToParent, except that the offset
values are multiplied by -1
void RebuildRegions(bool recursive=false)
-----------------------------------------
Rebuilds the visible and invalid layers based on the layer hierarchy.
Used to update the regions after a call to remove or add a child layer
is made or when a layer is hidden or shown.
1. get the frame
2. set full and visible regions to frame
3. iterate through each child and exclude its full region from the
visible region if the child is visible.
4. iterate through each lowersibling and exclude its full region from
the visible region if the it is visible and it intersects the layer's
frame.
void MakeTopChild(void)
-----------------------
Makes the layer the top child owned by its parent. Note that the top
child is "behind" other children on the screen.
1. if parent is NULL, spew an error to stderr and return
2. if parent's top child equals this, return without doing anything
3. if lowersibling and uppersibling are both NULL, return without doing anything
4. save pointer to parent layer to a temporary variable
5. call RemoveSelf and then the former parent's AddChild
void MakeBottomChild(void)
--------------------------
Makes the layer the bottom child owned by its parent. Note that the
top child is "in front of" other children on the screen.
1. if parent is NULL, spew an error to stderr and return
2. if parent's bottom child equals this, return without doing anything
3. if lowersibling and uppersibling are both NULL, return without doing anything
4. save pointer to parent layer to a temporary variable
5. call RemoveSelf() with rebuild set to false
6. call former parent's AddChild (rebuild is false), setting the before
parameter to the former parent's bottomchild
7. save lowersibling to a temporary variable
8. call lowersibling->RemoveSelf() with no rebuild
9. call the parent's AddChild() with the before set to this and rebuild set to true
void RequestDraw(const BRect &r)
--------------------------------
Requests that the layer be drawn on screen. The rectangle passed is in
the layer's own coordinates.
1. if invalid is NULL, return
2. set the PortLink opcode to B_DRAW
3. create a BMessage(B_DRAW) and attach all invalid rectangles to it
4. attach the view token to the message
5. flatten the message to a buffer, attach it to the PortLink, and Flush() it.
6. recurse through each child and call its RequestDraw() function if it
intersects the child's frame
Layer \*FindLayer(int32 token)
------------------------------
Finds a child layer given an identifying token
1. iterate through children and check tokens. Return a match if found.
2. iterate through children, calling its FindLayer function, return any non-NULL results
3. return NULL - we got this far, so there is no match
Layer \*GetChildAt(BPoint pt, bool recursive=false)
---------------------------------------------------
Gets the child at a given point. if recursive is true, all layers
under the current one in the tree are searched. if the point is
contained by the current layer's frame and no child is found, this
function returns the current layer. if the point is outside the
current layer's frame, it returns NULL
1. if frame does not contain the point, return NULL
if recursive is true:
A. start at the \*bottom\* child and iterate upward.
B. if the child has children, call the child's GetChildAt with the point
converted to the child's coordinate space, returning any non-NULL
results
C. if the child is hidden, continue to the next iteration
D. if the child's frame contains the point, return the child
E. if none of the children contain the point, return this
if recursive is false:
A. start at the \*bottom\* child and iterate upward.
B. if the child is hidden, continue to the next iteration
C. if the child's frame contains the point, return the child
D. if none of the children contain the point, return this
PortLink \*GetLink(void)
------------------------
Returns the layer's internal PortLink object so a message can be sent
to the Layer's window.
@@ -1,118 +0,0 @@
<HTML>
<HEAD>
<TITLE>PatternHandler.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">PatternHandler 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">PatternHandler provides an easy way to integrate pattern support into classes which require it, such as the DisplayDriver class.</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=618 HEIGHT=90 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=219 HEIGHT=17>
<P class="Body" style="margin: 0px">PatternHandler(void)</P>
</TD>
<TD WIDTH=245 HEIGHT=17>
<P class="Body" style="margin: 0px">~PatternHandler(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=219 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetTarget(int8 *pattern)</P>
</TD>
<TD WIDTH=245 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetColors(RGBColor c1, RGBColor c2)</P>
</TD>
</TR>
<TR>
<TD WIDTH=219 HEIGHT=17>
<P class="Body" style="margin: 0px">RGBColor GetColor(BPoint pt)</P>
</TD>
<TD WIDTH=245 HEIGHT=17>
<P class="Body" style="margin: 0px">RGBColor GetColor(float x, float y)</P>
</TD>
</TR>
<TR>
<TD WIDTH=219 HEIGHT=17>
<P class="Body" style="margin: 0px">bool GetValue(float x, float y)</P>
</TD>
<TD WIDTH=245 HEIGHT=17>
<P class="Body" style="margin: 0px">bool GetValue(BPoint pt)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Enumerated Types</P>
<P class="Body" style="margin: 0px"><BR>
pattern_enum</P>
<P class="Body" style="margin: 0px">{</P>
<P class="Body" style="margin: 0px"> uint64 type64</P>
<P class="Body" style="margin: 0px"> uint8 type8 [8]</P>
<P class="Body" style="margin: 0px">}</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">PatternHandler()</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
1) Initialize internal RGBColor variables to black and white, respectively.</P>
<P class="Body" style="margin: 0px">2) Set internal pattern to B_SOLID_HIGH (all 1's)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~PatternHandler()</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
Empty</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetTarget(int8 *pattern)</span></P>
<P class="Body" style="margin: 0px"><BR>
Updates the pattern handler's pattern. It copies the pattern passed to it, so it does NOT take responsibility for freeing any memory.</P>
<P class="Body" style="margin: 0px"><BR>
1) cast the passed pointer in such a way to copy it as a uint64 to the pattern_enum.type64 member</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">void SetColors(RGBColor c1, RGBColor c2)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets the internal high and low colors for the pattern handler. These will be the colors returned when GetColor() is called.</P>
<P class="Body" style="margin: 0px"><BR>
1) Assign c1 to high color and c2 to low color</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">RGBColor GetColor(BPoint pt)
RGBColor GetColor (float x, float y)</span></P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">bool GetValue(BPoint pt)
bool GetValue (float x, float y)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def"><BR>
</span><span class="Default">GetColor returns the color in the pattern at the specified location. GetValue returns true for the high color and false for the low color.</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
1) xpos = x % 8, ypos = y % 8
2) value = pointer [ ypos ] &amp; ( 1 &lt;&lt; (7 - xpos) )</span></P>
<P class="Body" style="margin: 0px"><span class="Default">3) GetValue: return (value==0)?false:true</span></P>
<P class="Body" style="margin: 0px"><span class="Default">GetColor: return (value==0)?lowcolor:highcolor</span></P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,65 @@
PatternHandler class
####################
PatternHandler provides an easy way to integrate pattern support into
classes which require it, such as the DisplayDriver class.
Enumerated Types
================
pattern_enum
------------
- uint64 type64
- uint8 type8 [8]
Member Functions
================
PatternHandler()
----------------
1. Initialize internal RGBColor variables to black and white, respectively.
2. Set internal pattern to B_SOLID_HIGH (all 1's)
~PatternHandler()
-----------------
Empty
void SetTarget(int8 \*pattern)
------------------------------
Updates the pattern handler's pattern. It copies the pattern passed to
it, so it does NOT take responsibility for freeing any memory.
1. cast the passed pointer in such a way to copy it as a uint64 to the
pattern_enum.type64 member
void SetColors(RGBColor c1, RGBColor c2)
----------------------------------------
Sets the internal high and low colors for the pattern handler. These
will be the colors returned when GetColor() is called.
1. Assign c1 to high color and c2 to low color
RGBColor GetColor(BPoint pt) RGBColor GetColor (float x, float y)
-----------------------------------------------------------------
bool GetValue(BPoint pt) bool GetValue (float x, float y)
---------------------------------------------------------
GetColor returns the color in the pattern at the specified location.
GetValue returns true for the high color and false for the low color.
1. xpos = x % 8, ypos = y % 8 2) value = pointer [ ypos ] & ( 1 << (7 - xpos) )
2. GetValue: return (value==0)?false:true
3. GetColor: return (value==0)?lowcolor:highcolor
@@ -1,189 +0,0 @@
<HTML>
<HEAD>
<TITLE>RGBColor.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">RGBColor 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">RGBColor objects provide a simplified interface to colors for the app_server, especially the DisplayDriver class</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=617 HEIGHT=264 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">RGBColor(rgb_color col)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">RGBColor(uint16 color16)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">RGBColor(uint8 color8)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">RGBColor(const RGBColor &amp;color)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">RGBColor(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void PrintToStream(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">uint8 GetColor8(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">uint16 GetColor16(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">rgb_color GetColor32(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetColor(uint16 color16)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetColor(uint8 color 8)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetColor(rgb_color color)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetColor(const RGBColor &amp;col)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">Operators: =,==,!=</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">RGBColor MakeBlendColor( RGBColor c, float position)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(rgb_color col)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(uint16 color16)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(uint8 color8)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(const RGBColor &amp;color)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(void)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
1) In all cases, extract the color data by calling SetColor. Void version sets to (0,0,0,0)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void PrintToStream(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Prints the color values of the color32 member via printf()</P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">uint8 GetColor8(void)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">uint16 GetColor16(void)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">rgb_color GetColor32(void)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
These are for obtaining space-specific versions of the color assigned to the object.</P>
<P class="Body" style="margin: 0px"><BR>
1) In all cases, return the internal color storage members </P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetColor(const RGBColor &amp;color)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
Copy all internal members to the current object.</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
<BR>
</span><span class="OBOS-Function-Def">void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetColor(rgb_color col)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><span class="Default">1) Assign parameters to internal rgb_color</span></P>
<P class="Body" style="margin: 0px"><span class="Default">2) call SetRGBAColor15()</span></P>
<P class="Body" style="margin: 0px"><span class="Default">3) call SystemPalette::FindClosestColor()</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><span class="Default"><BR>
</span><span class="OBOS-Function-Def">void SetColor(uint16 color16)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
1) Assign parameter to internal uint16</span></P>
<P class="Body" style="margin: 0px"><span class="Default">2) call SetRGBAColor32()</span></P>
<P class="Body" style="margin: 0px"><span class="Default">3) call SystemPalette::FindClosestColor()</span></P>
<P class="Body" style="margin: 0px"><span style="font-size: 16pt"><BR>
<BR>
</span><span class="OBOS-Function-Def">void SetColor(uint8 color8)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span style="font-size: 16pt"><BR>
</span><span class="Default">1) Assign parameter to internal uint8</span></P>
<P class="Body" style="margin: 0px"><span class="Default">2) Get the 32-bit value from the palette and assign it to the internal rgb_color</span></P>
<P class="Body" style="margin: 0px"><span class="Default">3) call SetRGBAColor16()</span></P>
<P class="Body" style="margin: 0px"><span style="font-size: 16pt"><BR>
<BR>
</span><span class="OBOS-Function-Def">RGBColor &amp; operator=(const RGBColor &amp;from)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
Copy all data members over and return the value of this (return *this;)</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><span class="OBOS-Function-Def">bool operator==(const RGBColor &amp;from)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><span class="Default">Compare rgb_colors and if all members are equal, return true. Otherwise, return false.</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><span class="OBOS-Function-Def">bool operator!=(const RGBColor &amp;from)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
Compare rgb_colors and if all are equal, return false. <span class="Default">Otherwise, return true.</span></P>
<P class="Body" style="margin: 0px"><BR>
<span class="OBOS-Function-Def">RGBColor MakeBlendColor(RGBColor c, float position)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns a color which is (position * 100) of the way from the current color to the one passed to it. This would be an easy way to generate color gradients, for example, but with more control.</P>
<P class="Body" style="margin: 0px"><BR>
1) Clip position to the range 0&lt;=position&lt;=1</P>
<P class="Body" style="margin: 0px">2) For each color component,</P>
<P class="Body" style="margin: 0px"> a) calculate the delta (delta=int16(c.component-thiscolor.component))</P>
<P class="Body" style="margin: 0px"> b) calculate the modifier (mod=thiscolor.component+(delta * position))</P>
<P class="Body" style="margin: 0px"> c) clip modifier to the range 0 &lt;= modifier &lt;= 255</P>
<P class="Body" style="margin: 0px"> d) assign modifier to the component (thiscolor.component=int8(mod))</P>
<P class="Body" style="margin: 0px">3) return a new RGBColor constructed around the new color</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,117 @@
RGBColor class
##############
RGBColor objects provide a simplified interface to colors for the
app_server, especially the DisplayDriver class
Member Functions
================
RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
------------------------------------------------
RGBColor(rgb_color col)
-----------------------
RGBColor(uint16 color16)
------------------------
RGBColor(uint8 color8)
----------------------
RGBColor(const RGBColor &color)
-------------------------------
RGBColor(void)
--------------
In all cases, extract the color data by calling SetColor. Void version sets to (0,0,0,0)
void PrintToStream(void)
------------------------
Prints the color values of the color32 member via printf()
uint8 GetColor8(void)
---------------------
uint16 GetColor16(void)
-----------------------
rgb_color GetColor32(void)
--------------------------
These are for obtaining space-specific versions of the color assigned
to the object.
1) In all cases, return the internal color storage members
void SetColor(const RGBColor &color)
------------------------------------
Copy all internal members to the current object.
void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
-----------------------------------------------------
void SetColor(rgb_color col)
----------------------------
1. Assign parameters to internal rgb_color
2. call SetRGBAColor15()
3. call SystemPalette::FindClosestColor()
void SetColor(uint16 color16)
-----------------------------
1. Assign parameter to internal uint16
2. call SetRGBAColor32()
3. call SystemPalette::FindClosestColor()
void SetColor(uint8 color8)
---------------------------
1. Assign parameter to internal uint8
2. Get the 32-bit value from the palette and assign it to the internal rgb_color
3. call SetRGBAColor16()
RGBColor & operator=(const RGBColor &from)
------------------------------------------
Copy all data members over and return the value of this (return \*this;)
bool operator==(const RGBColor &from)
-------------------------------------
Compare rgb_colors and if all members are equal, return true. Otherwise,
return false.
bool operator!=(const RGBColor &from)
-------------------------------------
Compare rgb_colors and if all are equal, return false. Otherwise,
return true.
RGBColor MakeBlendColor(RGBColor c, float position)
---------------------------------------------------
Returns a color which is (position \* 100) of the way from the current
color to the one passed to it. This would be an easy way to generate
color gradients, for example, but with more control.
1) Clip position to the range 0<=position<=1
2) For each color component,
a) calculate the delta (delta=int16(c.component-thiscolor.component))
b) calculate the modifier (mod=thiscolor.component+(delta \* position))
c) clip modifier to the range 0 <= modifier <= 255
d) assign modifier to the component (thiscolor.component=int8(mod))
3) return a new RGBColor constructed around the new color
@@ -1,330 +0,0 @@
<HTML>
<HEAD>
<TITLE>ServerApp.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">ServerApp 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">ServerApps are the server-side counterpart to BApplications. They monitor for messages for the BApplication, create BWindows and BBitmaps, and provide a channel for the app_server to send messages to a user application without having a window.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=681 HEIGHT=156 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=251 HEIGHT=32>
<P class="Body" style="margin: 0px">ServerApp(port_id sendport, port_id rcvport, const char *signature, thread_id thread_bapp)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">~ServerApp(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=251 HEIGHT=17>
<P class="Body" style="margin: 0px">bool Run(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">static int32 MonitorApp(void *data)</P>
</TD>
</TR>
<TR>
<TD WIDTH=251 HEIGHT=17>
<P class="Body" style="margin: 0px">void Lock(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void Unlock(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=251 HEIGHT=17>
<P class="Body" style="margin: 0px">bool IsLocked(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void WindowBroadcast(int32 code)</P>
</TD>
</TR>
<TR>
<TD WIDTH=251 HEIGHT=17>
<P class="Body" style="margin: 0px">bool IsActive(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">bool PingTarget(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=251 HEIGHT=17>
<P class="Body" style="margin: 0px">void DispatchMessage(int32 code, int8 *buffer)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">ServerApp(port_id sendport, port_id rcvport, const char *sig, thread_id thread_bapp)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Create the window list as empty</P>
<P class="Body" style="margin: 0px">2) Save sendport, rcvport, sig, and thread_bapp to the respective ServerApp members</P>
<P class="Body" style="margin: 0px">3) Set quit_app flag to false</P>
<P class="Body" style="margin: 0px">4) Create the window list lock</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~ServerApp(void)</span><span style="font-size: 16pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
1) Empty and delete window list and accompanying windows</P>
<P class="Body" style="margin: 0px">2) Wait for the monitoring thread to exit</P>
<P class="Body" style="margin: 0px">3) Call CursorManager::RemoveAppCursors(this)</P>
<P class="Body" style="margin: 0px">4) Delete the window list lock</P>
<P class="Body" style="margin: 0px">5) If monitoring thread still active, kill it (in case app is deleted without a quit message)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool Run(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Run() simply makes a ServerApp start monitoring for messages from its BApplication, telling it to quit if there is a problem.</P>
<P class="Body" style="margin: 0px"><BR>
1) Spawn the monitoring thread (which utilizes MonitorApp())
2) If any error, tell the BApplication to quit, spit an error to stderr, and return false</P>
<P class="Body" style="margin: 0px">3) Resume the monitoring thread</P>
<P class="Body" style="margin: 0px">4) Return true</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">static int32 MonitorApp(void *data)</span></P>
<P class="Body" style="margin: 0px"><BR>
Thread function for monitoring for messages from the ServerApp's BApplication.</P>
<P class="Body" style="margin: 0px"><BR>
1) Call port_buffer_size - which will block if the port is empty</P>
<P class="Body" style="margin: 0px">2) Allocate a buffer on the heap if the port buffer size is greater than 0</P>
<P class="Body" style="margin: 0px">3) Read the port</P>
<P class="Body" style="margin: 0px">4) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized</P>
<P class="Body" style="margin: 0px">5) Return from DispatchMessage() and free the message buffer if one was allocated</P>
<P class="Body" style="margin: 0px">6) If the message code matches the B_QUIT_REQUESTED definition and the quit_app flag is true, fall out of the infinite message-monitoring loop. Otherwise continue to next iteration</P>
<P class="Body" style="text-align: left; margin: 0px">7) Send a DELETE_APP message to the server's main message to force deleting of the ServerApp instance and exit</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<span class="OBOS-Function-Def">bool IsActive(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Used for determining whether the application is the active one. Simply returns the isactive flag.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void PingTarget(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
PingTarget() is called only from the Picasso thread of the app_server in order to determine whether its respective BApplication still exists. BApplications have been known to crash from time to time without the common courtesy of notifying the server of its intentions. ;D</P>
<P class="Body" style="margin: 0px"><BR>
1) Call get_thread_info() with the app's thread_id</P>
<P class="Body" style="margin: 0px">2) if it returns anything but B_OK, return false. Otherwise, return true.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void DispatchMessage(int32 code, int8 *buffer)</span></P>
<P class="Body" style="margin: 0px"><BR>
DispatchMessage implements all the code necessary to respond to a given message sent to the ServerApp on its receiving message port. This allows for clearer and more manageable code.</P>
<P class="Body" style="margin: 0px"><BR>
CREATE_WINDOW:</P>
<P class="Body" style="margin: 0px"><BR>
Sent by a new BWindow object via synchronous PortLink messaging. Set up the corresponding ServerWindow and reply to the BWindow with the new port to which it will send future communications with the App Server.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=156 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=32>
<P class="Body" style="margin: 0px">port_id reply_port</P>
</TD>
<TD WIDTH=318 HEIGHT=32>
<P class="Body" style="margin: 0px">port to which the server is to reply in response to the current message</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">BRect wframe</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">frame of the requesting BWindow</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">uint32 wflags</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">flag data of the requesting BWindow</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">port_id win_port</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">receiver port of the requesting BWindow</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">uint32 workspaces</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">workspaces on which the BWindow is to appear</P>
</TD>
</TR>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">const char *title</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">title of the requesting BWindow</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px"><BR>
1) Get all attached data</P>
<P class="Body" style="margin: 0px">2) Acquire the window list lock</P>
<P class="Body" style="margin: 0px">3) Allocate a ServerWindow object and add it to the list</P>
<P class="Body" style="margin: 0px">4) Release window list lock</P>
<P class="Body" style="margin: 0px">5) Send the message SET_SERVER_PORT (with the ServerWindow's receiver port attached to the reply port</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
DELETE_APP:</P>
<P class="Body" style="margin: 0px"><BR>
Sent by a ServerWindow when told to quit. It is identified by the unique ID assigned to its thread.</P>
<P class="Body" style="margin: 0px"><BR>
Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=568 HEIGHT=22 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=132 HEIGHT=17>
<P class="Body" style="margin: 0px">thread_id win_thread</P>
</TD>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">Thread id of the ServerWindow sending this message</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Get window's thread_id</P>
<P class="Body" style="text-align: left; margin: 0px">2) Acquire window list lock</P>
<P class="Body" style="text-align: left; margin: 0px">3) Iterate through the window list, searching for the ServerWindow object with the sent thread_id</P>
<P class="Body" style="text-align: left; margin: 0px">4) Remove the object from the list and delete it</P>
<P class="Body" style="text-align: left; margin: 0px">5) Release window list lock</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
SET_CURSOR_DATA:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Received from the ServerApp's BApplication when SetCursor(const void *) is called. </P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=22 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int8 cursor[68]</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">Cursor data in the format as defined in the BeBook</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Create a ServerCursor from the attached cursor data</P>
<P class="Body" style="text-align: left; margin: 0px">2) Add the new ServerCursor to the CursorManager and then call CursorManager::SetCursor</P>
<P class="Body" style="text-align: left; margin: 0px">
</P>
<P class="Body" style="text-align: left; margin: 0px">SET_CURSOR_BCURSOR:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Received from the ServerApp's BApplication when SetCursor(BCursor *, bool) is called. </P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
</P>
<P class="Body" style="margin: 0px">Attached Data:</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<P class="Body" style="text-align: center; margin: 0px"></P>
<TABLE WIDTH=573 HEIGHT=22 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=112 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 token</P>
</TD>
<TD WIDTH=318 HEIGHT=17>
<P class="Body" style="margin: 0px">Token identifier of cursor in the BCursor class</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="text-align: center; margin: 0px"><BR>
</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Get the attached token and call CursorManager::SetCursor(token)</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
B_QUIT_REQUESTED:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Received from the BApplication when quits, so set the quit flag and ask the server to delete the object</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Attached Data: None</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Set quit_app flag to true</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
UPDATE_DECORATOR:</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Received from the poller thread when the window decorator for the system has changed. </P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Attached Data: None</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Call WindowBroadcast(UPDATE_DECORATOR)</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void WindowBroadcast(int32 code)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
Similar to AppServer::Broadcast(), this sends a message to all ServerWindows which belong to the ServerApp.</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
1) Acquire window list lock</P>
<P class="Body" style="text-align: left; margin: 0px">2) Create a PortLink instance and set its message code to the passed parameter.</P>
<P class="Body" style="text-align: left; margin: 0px">3) Iterate through the window list, targeting the PortLink instance to each ServerWindow's message port and calling Flush().</P>
<P class="Body" style="text-align: left; margin: 0px">4) Release window list lock</P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Lock(void)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><span class="OBOS-Function-Def">void Unlock(void)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><span class="OBOS-Function-Def">bool IsLocked(void)</span></P>
<P class="Body" style="text-align: left; margin: 0px"><BR>
These functions are used to regulate access to the ServerApp's data members. Lock() acquires the internal semaphore, Unlock() releases it, and IsLocked returns true only if the semaphore's value is positive.</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,226 @@
ServerApp class
###############
ServerApps are the server-side counterpart to BApplications. They
monitor for messages for the BApplication, create BWindows and BBitmaps,
and provide a channel for the app_server to send messages to a user
application without having a window.
Member Functions
================
- ServerApp(port_id sendport, port_id rcvport, const char\*signature, thread_id thread_bapp)
- ~ServerApp(void)
- bool Run(void)
- static int32 MonitorApp(void \*data)
- void Lock(void)
- void Unlock(void)
- bool IsLocked(void)
- void WindowBroadcast(int32 code)
- bool IsActive(void)
- bool PingTarget(void)
- void DispatchMessage(int32 code, int8 \*buffer)
ServerApp(port_id sendport, port_id rcvport, const char \*sig, thread_id thread_bapp)
-------------------------------------------------------------------------------------
1. Create the window list as empty
2. Save sendport, rcvport, sig, and thread_bapp to the respective
ServerApp members
3. Set quit_app flag to false
4. Create the window list lock
~ServerApp(void)
----------------
1. Empty and delete window list and accompanying windows
2. Wait for the monitoring thread to exit
3. Call CursorManager::RemoveAppCursors(this)
4. Delete the window list lock
5. If monitoring thread still active, kill it (in case app is deleted
without a quit message)
bool Run(void)
--------------
Run() simply makes a ServerApp start monitoring for messages from its
BApplication, telling it to quit if there is a problem.
1. Spawn the monitoring thread (which utilizes MonitorApp()) 2) If any
error, tell the BApplication to quit, spit an error to stderr, and
return false
2. Resume the monitoring thread
3. Return true
static int32 MonitorApp(void \*data)
------------------------------------
Thread function for monitoring for messages from the ServerApp's
BApplication.
1. Call port_buffer_size - which will block if the port is empty
2. Allocate a buffer on the heap if the port buffer size is greater than 0
3. Read the port
4. Pass specified messages to DispatchMessage() for processing, spitting
out an error message to stderr if the message's code is unrecognized
5. Return from DispatchMessage() and free the message buffer if one was
allocated
6. If the message code matches the B_QUIT_REQUESTED definition and the
quit_app flag is true, fall out of the infinite message-monitoring loop.
Otherwise continue to next iteration
7. Send a DELETE_APP message to the server's main message to force
deleting of the ServerApp instance and exit
bool IsActive(void)
-------------------
Used for determining whether the application is the active one. Simply
returns the isactive flag.
void PingTarget(void)
---------------------
PingTarget() is called only from the Picasso thread of the app_server
in order to determine whether its respective BApplication still
exists. BApplications have been known to crash from time to time
without the common courtesy of notifying the server of its intentions.
;D
1. Call get_thread_info() with the app's thread_id
2. if it returns anything but B_OK, return false. Otherwise, return
true.
void DispatchMessage(int32 code, int8 \*buffer)
-----------------------------------------------
DispatchMessage implements all the code necessary to respond to a
given message sent to the ServerApp on its receiving message port.
This allows for clearer and more manageable code.
CREATE_WINDOW
.............
Sent by a new BWindow object via synchronous PortLink messaging. Set
up the corresponding ServerWindow and reply to the BWindow with the
new port to which it will send future communications with the App
Server.
Attached Data:
+-----------------------------------+-----------------------------------+
| port_id reply_port | port to which the server is to |
| | reply in response to the current |
| | message |
+-----------------------------------+-----------------------------------+
| BRect wframe | frame of the requesting BWindow |
+-----------------------------------+-----------------------------------+
| uint32 wflags | flag data of the requesting |
| | BWindow |
+-----------------------------------+-----------------------------------+
| port_id win_port | receiver port of the requesting |
| | BWindow |
+-----------------------------------+-----------------------------------+
| uint32 workspaces | workspaces on which the BWindow |
| | is to appear |
+-----------------------------------+-----------------------------------+
| const char \*title | title of the requesting BWindow |
+-----------------------------------+-----------------------------------+
1. Get all attached data
2. Acquire the window list lock
3. Allocate a ServerWindow object and add it to the list
4. Release window list lock
5. Send the message SET_SERVER_PORT (with the ServerWindow's receiver
port attached to the reply port
DELETE_APP
..........
Sent by a ServerWindow when told to quit. It is identified by the
unique ID assigned to its thread.
Attached Data:
+-----------------------------------+-----------------------------------+
| thread_id win_thread | Thread id of the ServerWindow |
| | sending this message |
+-----------------------------------+-----------------------------------+
1. Get window's thread_id
2. Acquire window list lock
3. Iterate through the window list, searching for the ServerWindow
object with the sent thread_id
4. Remove the object from the list and delete it
5. Release window list lock
SET_CURSOR_DATA
...............
Received from the ServerApp's BApplication when SetCursor(const void\*) is called.
Attached Data:
+-----------------------------------+-----------------------------------+
| int8 cursor[68] | Cursor data in the format as |
| | defined in the BeBook |
+-----------------------------------+-----------------------------------+
1. Create a ServerCursor from the attached cursor data
2. Add the new ServerCursor to the CursorManager and then call
CursorManager::SetCursor
SET_CURSOR_BCURSOR
..................
Received from the ServerApp's BApplication when SetCursor(BCursor \*,
bool) is called.
Attached Data:
+-----------------------------------+-----------------------------------+
| int32 token | Token identifier of cursor in the |
| | BCursor class |
+-----------------------------------+-----------------------------------+
1) Get the attached token and call CursorManager::SetCursor(token)
B_QUIT_REQUESTED
................
Received from the BApplication when quits, so set the quit flag and
ask the server to delete the object
Attached Data: None
1) Set quit_app flag to true
UPDATE_DECORATOR
................
Received from the poller thread when the window decorator for the
system has changed.
Attached Data: None
1) Call WindowBroadcast(UPDATE_DECORATOR)
void WindowBroadcast(int32 code)
--------------------------------
Similar to AppServer::Broadcast(), this sends a message to all
ServerWindows which belong to the ServerApp.
1) Acquire window list lock
2) Create a PortLink instance and set its message code to the passed
parameter.
3) Iterate through the window list, targeting the PortLink instance to
each ServerWindow's message port and calling Flush().
4) Release window list lock
void Lock(void), void Unlock(void), bool IsLocked(void)
-------------------------------------------------------
These functions are used to regulate access to the ServerApp's data
members. Lock() acquires the internal semaphore, Unlock() releases it,
and IsLocked returns true only if the semaphore's value is positive.
@@ -1,119 +0,0 @@
<HTML>
<HEAD>
<TITLE>ServerBitmap.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">ServerBitmap 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">ServerBitmaps are the server side counterpart to BBitmap. Note that they are not allocated like other objects - the BitmapManager handles all allocation and deletion tasks.</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=466 HEIGHT=103 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=253 HEIGHT=47>
<P class="Body" style="margin: 0px">ServerBitmap(BRect r, color_space cspace, int32 flags, int32 bytesperrow=-1, screen_id screen=B_MAIN_SCREEN_ID)</P>
</TD>
<TD WIDTH=213 HEIGHT=47>
<P class="Body" style="margin: 0px">void _HandleSpace(color_space cs, int32 bytesperline=-1)</P>
</TD>
</TR>
<TR>
<TD WIDTH=253 HEIGHT=22>
<P class="Body" style="margin: 0px">~ServerBitmap(void)</P>
</TD>
<TD WIDTH=213 HEIGHT=22>
<P class="Body" style="margin: 0px">int32 BytesPerRow(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=253 HEIGHT=17>
<P class="Body" style="margin: 0px">uint8 *Bits(void)</P>
</TD>
<TD WIDTH=213 HEIGHT=17>
<P class="Body" style="margin: 0px">area_id Area(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=253 HEIGHT=17>
<P class="Body" style="margin: 0px">uint32 BitsLength(void)</P>
</TD>
<TD WIDTH=213 HEIGHT=17>
<P class="Body" style="margin: 0px">BRect Bounds(void)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
If there are any global functions associated with the class, they are listed here.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">ServerBitmap(BRect r, color_space cspace, int32 flags, int32 bytesperrow=-1, screen_id screen=B_MAIN_SCREEN_ID)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Call _HandleSpace()</P>
<P class="Body" style="margin: 0px">2) Call _HandleFlags()</P>
<P class="Body" style="margin: 0px">3) Initialize remaining data members to parameters or safe values</P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
</span><BR>
<span style="font-size: 16pt">~ServerBitmap(void)</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
Empty</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
<BR>
</span><span class="OBOS-Function-Def">uint8 *Bits(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the bitmap's buffer member</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">area_id Area(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the bitmap's buffer member.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">uint32 BitsLength(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns bytes_per_row * height</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">BRect Bounds(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
returns BRect(width-1,height-1)</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 BytesPerRow(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
returns the bitmap's bytes_per_row member</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void _HandleSpace(color_space cs, int32 bytesperline=-1)</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
Large function which essentially consists of a switch() of the available color spaces and assigns the bits per pixel and bytes per line values based on the color space. If bytesperline is -1, the default is used, otherwise it uses the specified value.</span></P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,55 @@
ServerBitmap class
##################
ServerBitmaps are the server side counterpart to BBitmap. Note that they
are not allocated like other objects - the BitmapManager handles all
allocation and deletion tasks.
Member Functions
================
ServerBitmap(BRect r, color_space cspace, int32 flags, int32 bytesperrow=-1, screen_id screen=B_MAIN_SCREEN_ID)
---------------------------------------------------------------------------------------------------------------
1. Call \_HandleSpace()
2. Call \_HandleFlags()
3. Initialize remaining data members to parameters or safe values
~ServerBitmap(void)
-------------------
Empty
uint8 \*Bits(void)
------------------
Returns the bitmap's buffer member
area_id Area(void)
------------------
Returns the bitmap's buffer member.
uint32 BitsLength(void)
-----------------------
Returns bytes_per_row \* height
BRect Bounds(void)
------------------
returns BRect(width-1,height-1)
int32 BytesPerRow(void)
-----------------------
returns the bitmap's bytes_per_row member
void _HandleSpace(color_space cs, int32 bytesperline=-1)
---------------------------------------------------------
Large function which essentially consists of a switch() of the available
color spaces and assigns the bits per pixel and bytes per line values
based on the color space. If bytesperline is -1, the default is used,
otherwise it uses the specified value.
@@ -1,86 +0,0 @@
<HTML>
<HEAD>
<TITLE>SharedObject.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">SharedObjectf class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
The FontStyle class represents the particular style in a font family, such as Bold, Roman, etc. and provides information on an individual font, such as whether it has a fixed width, whether it is scalable etc. It also houses all instances of the individual style.</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px">Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=617 HEIGHT=68 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">SharedObject(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">virtual SharedObject(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">virtual void AddDependent(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">virtual void RemoveDependent(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">virtual bool HasDependents(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">SharedObject(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Sets dependent count to 0</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">virtual ~SharedObject(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Does nothing</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">virtual void AddDependent(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Increments dependent count</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">virtual void RemoveDependent(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Decrements dependent count if greater than 0</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">virtual bool HasDependents(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) if dependent count &gt; 0, return true. Otherwise, return false.</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,26 @@
SharedObject class
###################
Member Functions
----------------
SharedObject(void)
1) Sets dependent count to 0
virtual ~SharedObject(void)
1) Does nothing
virtual void AddDependent(void)
1) Increments dependent count
virtual void RemoveDependent(void)
1) Decrements dependent count if greater than 0
virtual bool HasDependents(void)
1) if dependent count > 0, return true. Otherwise, return false.
@@ -1,249 +0,0 @@
<HTML>
<HEAD>
<TITLE>SystemPalette.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">SystemPalette 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">This object does all the handling for system attribute colors and system palette management.</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=617 HEIGHT=196 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">SystemPalette(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">~SystemPalette(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetPalette(uint8 index, RGBColor col)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetPalette(uint8 index, rgb_color col)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">RGBColor GetPalette(uint8 index)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">void SetGUIColor(color_which which, RGBColor col)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=32>
<P class="Body" style="margin: 0px">RGBColor GetGUIColor(color_which which)</P>
</TD>
<TD WIDTH=260 HEIGHT=32>
<P class="Body" style="margin: 0px">color_set GetGUIColors(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void SetGUIColors(color_set cset)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void _GenerateSystemPalette(rgb_color *palette)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void _SetDefaultGUIColors(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
_ Denotes a protected function</P>
<P class="Body" style="margin: 0px"><BR>
Structures</P>
<P class="Body" style="margin: 0px"><BR>
color_set {</P>
<P class="Body" style="margin: 0px"> rgb_color panel_background</P>
<P class="Body" style="margin: 0px"> rgb_color panel_text</P>
<P class="Body" style="margin: 0px"> rgb_color document_background</P>
<P class="Body" style="margin: 0px"> rgb_color document_text</P>
<P class="Body" style="margin: 0px"> rgb_color control_background</P>
<P class="Body" style="margin: 0px"> rgb_color control_text</P>
<P class="Body" style="margin: 0px"> rgb_color control_border</P>
<P class="Body" style="margin: 0px"> rgb_color control_highlight</P>
<P class="Body" style="margin: 0px"> rgb_color tooltip_background</P>
<P class="Body" style="margin: 0px"> rgb_color tooltip_text</P>
<P class="Body" style="margin: 0px"> rgb_color menu_background</P>
<P class="Body" style="margin: 0px"> rgb_color menu_selected_background</P>
<P class="Body" style="margin: 0px"> rgb_color menu_text</P>
<P class="Body" style="margin: 0px"> rgb_color menu_selected_text</P>
<P class="Body" style="margin: 0px"> rgb_color menu_separator</P>
<P class="Body" style="margin: 0px"> rgb_color menu_triggers</P>
<P class="Body" style="margin: 0px">}</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">SystemPalette(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Allocate the rgb_color[256] palette on the heap and call _GenerateSystemPalette()</P>
<P class="Body" style="margin: 0px">2) Initialize attribute variables to the defaults</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~SystemPalette(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Free the palette array</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetPalette(uint8 index, RGBColor col)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetPalette(uint8 index, rgb_color col)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets the said index to the passed color value.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">RGBColor GetPalette(uint8 index)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns the color at said index in the palette.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void SetGUIColor(color_which which, RGBColor col)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor GetGUIColor(color_which which)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">color_set GetGUIColors(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetGUIColors(color_set cset)</span></P>
<P class="Body" style="margin: 0px"><BR>
These tweak or return the system attribute colors, one at a time or all at once.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">protected: void _GenerateSystemPalette(rgb_color *palette)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets the passed palette to the BeOS R5 system colors, which follows.</P>
<P class="Body" style="margin: 0px"><span class="Default">Grays:</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,0 -&gt; 248,248,248 by increments of 8</span></P>
<P class="Body" style="margin: 0px"><span class="Default">Blues:</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,255</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,229</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,204</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,179</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,154</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,129</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,105</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,80</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,55</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,0,30</span></P>
<P class="Body" style="margin: 0px"><span class="Default">Reds: as per blues, but red values are 1 less</span></P>
<P class="Body" style="margin: 0px"><span class="Default">Greens: as per blues, but green values are 1 less</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,152,51</span></P>
<P class="Body" style="margin: 0px"><span class="Default">255,255,255</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
The following sets use [255, 203, 152, 102, 51, 0] for the blue values, keeping the other colors the same:</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
203,255, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">152,255, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">102,255, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">51,255, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">255,152, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
0,102,255</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,102,203</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
203,203, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">152,255, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">102,255, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">51,255, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">255,102, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
0,102,152</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,102,102</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
203,152, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">152,152, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">102,152, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">51,152, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
230,134,0</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
255,51, [value excepting 255]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
0,102,51</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,102,0</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
203,102, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">152,102, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">102,102, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">51,102, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">255,0, [value excepting 0]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
255,175,19</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,51,255</span></P>
<P class="Body" style="margin: 0px"><span class="Default">0,51,203</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
203,51, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">152,51, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">102,51, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">51,51, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
255,203,102 -&gt; 255,203,255, stepping in the [value] increments</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
0,51, [value, starting at 152]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">203,0, [value, excepting 0]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
255,227,70</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
152,0, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">102,0, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default">51,0, [value]</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
255,203,51 </span></P>
<P class="Body" style="margin: 0px"><span class="Default">255,203,0</span></P>
<P class="Body" style="margin: 0px"><span class="Default"><BR>
255,255, [values in reverse]</span></P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">protected: void _SetDefaultGUIColors(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Sets the internal color_set to the defaults, which is the following:</P>
<P class="Body" style="margin: 0px"><BR>
panel_background: 216,216, 216</P>
<P class="Body" style="margin: 0px">panel_text: 0,0,0</P>
<P class="Body" style="margin: 0px">document_background: 255,255,255</P>
<P class="Body" style="margin: 0px">document_text: 0,0,0</P>
<P class="Body" style="margin: 0px">control_background: 216,216,216</P>
<P class="Body" style="margin: 0px">control_text: 0,0,0</P>
<P class="Body" style="margin: 0px">control_border: 0,0,0</P>
<P class="Body" style="margin: 0px">control_highlight: 0,0,255</P>
<P class="Body" style="margin: 0px">tooltip_background: </P>
<P class="Body" style="margin: 0px">tooltip_text: 0,0,0</P>
<P class="Body" style="margin: 0px">menu_background: 216,216,216</P>
<P class="Body" style="margin: 0px">menu_selected_background: 160,160,160</P>
<P class="Body" style="margin: 0px">menu_text: 0,0,0</P>
<P class="Body" style="margin: 0px">menu_selected_text: 0,0,0</P>
<P class="Body" style="margin: 0px">menu_separator_high: 241,241,241</P>
<P class="Body" style="margin: 0px">menu_separator_low: 186,186,186</P>
<P class="Body" style="margin: 0px">menu_triggers: 0,0,0</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,231 @@
SystemPalette class
###################
This object does all the handling for system attribute colors and system
palette management.
Member Functions
================
_ Denotes a protected function
SystemPalette(void)
-------------------
1. Allocate the rgb_color[256] palette on the heap and call _GenerateSystemPalette()
2. Initialize attribute variables to the defaults
~SystemPalette(void)
--------------------
1) Free the palette array
void SetPalette(uint8 index, RGBColor col), void SetPalette(uint8 index, rgb_color col)
---------------------------------------------------------------------------------------
Sets the said index to the passed color value.
RGBColor GetPalette(uint8 index)
--------------------------------
Returns the color at said index in the palette.
void SetGUIColor(color_which which, RGBColor col)
-------------------------------------------------
RGBColor GetGUIColor(color_which which)
---------------------------------------
color_set GetGUIColors(void)
----------------------------
void SetGUIColors(color_set cset)
---------------------------------
These tweak or return the system attribute colors, one at a time or all at once.
protected: void \_GenerateSystemPalette(rgb_color \*palette)
------------------------------------------------------------
Sets the passed palette to the BeOS R5 system colors, which follows.
Grays:
......
0,0,0 -> 248,248,248 by increments of 8
Blues:
......
0,0,255
0,0,229
0,0,204
0,0,179
0,0,154
0,0,129
0,0,105
0,0,80
0,0,55
0,0,30
Reds:
.....
as per blues, but red values are 1 less
Greens:
.......
as per blues, but green values are 1 less
0,152,51
255,255,255
The following sets use [255, 203, 152, 102, 51, 0] for the blue values,
keeping the other colors the same:
203,255, [value]
152,255, [value]
102,255, [value]
51,255, [value]
255,152, [value]
0,102,255
0,102,203
203,203, [value]
152,255, [value]
102,255, [value]
51,255, [value]
255,102, [value]
0,102,152
0,102,102
203,152, [value]
152,152, [value]
102,152, [value]
51,152, [value]
230,134,0
255,51, [value excepting 255]
0,102,51
0,102,0
203,102, [value]
152,102, [value]
102,102, [value]
51,102, [value]
255,0, [value excepting 0]
255,175,19
0,51,255
0,51,203
203,51, [value]
152,51, [value]
102,51, [value]
51,51, [value]
255,203,102 -> 255,203,255, stepping in the [value] increments
0,51, [value, starting at 152]
203,0, [value, excepting 0]
255,227,70
152,0, [value]
102,0, [value]
51,0, [value]
255,203,51
255,203,0
255,255, [values in reverse]
protected: void _SetDefaultGUIColors(void)
-------------------------------------------
Sets the internal color_set to the defaults, which is the following:
- panel_background: 216,216, 216
- panel_text: 0,0,0
- document_background: 255,255,255
- document_text: 0,0,0
- control_background: 216,216,216
- control_text: 0,0,0
- control_border: 0,0,0
- control_highlight: 0,0,255
- tooltip_background:
- tooltip_text: 0,0,0
- menu_background: 216,216,216
- menu_selected_background: 160,160,160
- menu_text: 0,0,0
- menu_selected_text: 0,0,0
- menu_separator_high: 241,241,241
- menu_separator_low: 186,186,186
- menu_triggers: 0,0,0
Structures
==========
.. code-block:: cpp
color_set {
rgb_color panel_background
rgb_color panel_text
rgb_color document_background
rgb_color document_text
rgb_color control_background
rgb_color control_text
rgb_color control_border
rgb_color control_highlight
rgb_color tooltip_background
rgb_color tooltip_text
rgb_color menu_background
rgb_color menu_selected_background
rgb_color menu_text
rgb_color menu_selected_text
rgb_color menu_separator
rgb_color menu_triggers
}
@@ -1,135 +0,0 @@
<HTML>
<HEAD>
<TITLE>TokenHandler.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">TokenHandler class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
<P class="Body" style="margin: 0px"><BR>
This is a simple way to provide tokens for various reasons. </P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><BR>
Member Functions</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=617 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">TokenHandler(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">~TokenHandler(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">int32 GetToken(void)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void Reset(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">void ExcludeValue(int32 value)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
<P class="Body" style="margin: 0px">void ResetExcludes(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
<P class="Body" style="margin: 0px">bool IsExclude(int32 value)</P>
</TD>
<TD WIDTH=260 HEIGHT=17>
&nbsp;
</TD>
</TR>
<TR>
<TD WIDTH=203 HEIGHT=17>
&nbsp;
</TD>
<TD WIDTH=260 HEIGHT=17>
&nbsp;
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">TokenHandler(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Initialize the index to -1</P>
<P class="Body" style="margin: 0px">2) create the access semaphore</P>
<P class="Body" style="margin: 0px">3) create the exclude list with no items</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~TokenHandler(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) delete the access lock</P>
<P class="Body" style="margin: 0px">2) call ResetExcludes and delete the exclude list</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">int32 GetToken(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Returns a unique token which is not equal to any excluded values</P>
<P class="Body" style="margin: 0px"><BR>
1) create a local variable to return the new token</P>
<P class="Body" style="margin: 0px">2) acquire the access semaphore</P>
<P class="Body" style="margin: 0px">3) Increment the internal index</P>
<P class="Body" style="margin: 0px">4) while IsExclude(index) is true, increment the index</P>
<P class="Body" style="margin: 0px">5) assign it to the local variable</P>
<P class="Body" style="margin: 0px">6) release the access semaphore</P>
<P class="Body" style="margin: 0px">7) return the local variable</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Reset(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) acquire the access semaphore</P>
<P class="Body" style="margin: 0px">2) set the internal index to -1</P>
<P class="Body" style="margin: 0px">3) release the access semaphore</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ExcludeValue(int32 value)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) acquire the access semaphore</P>
<P class="Body" style="margin: 0px">2) if IsExclude(value) is false, add it to the exclude list</P>
<P class="Body" style="margin: 0px">3) release the access semaphore</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ResetExcludes(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) acquire the access semaphore</P>
<P class="Body" style="margin: 0px">2) Iterate through the exclude list, removing and deleting each item</P>
<P class="Body" style="margin: 0px">3) release the access semaphore</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool IsExclude(int32 value)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) create a boolean match flag and set it to false</P>
<P class="Body" style="margin: 0px">2) acquire the access semaphore</P>
<P class="Body" style="margin: 0px">3) iterate through the exclude list and see if the value matches any in the list</P>
<P class="Body" style="margin: 0px">4) If there is a match, set the match flag to true and exit the loop</P>
<P class="Body" style="margin: 0px">5) release the access semaphore</P>
<P class="Body" style="margin: 0px">6) return the match flag</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,66 @@
TokenHandler class
##################
This is a simple way to provide tokens for various reasons.
Member Functions
================
TokenHandler(void)
------------------
1. Initialize the index to -1
2. create the access semaphore
3. create the exclude list with no items
~TokenHandler(void)
-------------------
1. delete the access lock
2. call ResetExcludes and delete the exclude list
int32 GetToken(void)
--------------------
Returns a unique token which is not equal to any excluded values
1. create a local variable to return the new token
2. acquire the access semaphore
3. Increment the internal index
4. while IsExclude(index) is true, increment the index
5. assign it to the local variable
6. release the access semaphore
7. return the local variable
void Reset(void)
----------------
1. acquire the access semaphore
2. set the internal index to -1
3. release the access semaphore
void ExcludeValue(int32 value)
------------------------------
1. acquire the access semaphore
2. if IsExclude(value) is false, add it to the exclude list
3. release the access semaphore
void ResetExcludes(void)
------------------------
1. acquire the access semaphore
2. Iterate through the exclude list, removing and deleting each item
3. release the access semaphore
bool IsExclude(int32 value)
---------------------------
1. create a boolean match flag and set it to false
2. acquire the access semaphore
3. iterate through the exclude list and see if the value matches any in
the list
4. If there is a match, set the match flag to true and exit the loop
5. release the access semaphore
6. return the match flag
@@ -1,423 +0,0 @@
<HTML>
<HEAD>
<TITLE>WinBorder.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">WinBorder class : public Layer</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">WinBorder objects provide window management functionality and ensure that the border for each window is drawn.</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=621 HEIGHT=201 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=294 HEIGHT=32>
<P class="Body" style="margin: 0px">WinBorder(BRect r, const char *name, int32 resize, int32 flags, ServerWindow *win)</P>
</TD>
<TD WIDTH=172 HEIGHT=32>
<P class="Body" style="margin: 0px">~WinBorder(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">void RequestDraw(void)</P>
</TD>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(BPoint pt)</P>
</TD>
</TR>
<TR>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">void MoveBy(float x, float y)</P>
</TD>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">void ResizeBy(BPoint pt)</P>
</TD>
</TR>
<TR>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">void ResizeBy(float x, float y)</P>
</TD>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">void MouseDown(int8 *buffer)</P>
</TD>
</TR>
<TR>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">void MouseUp(int8 *buffer)</P>
</TD>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">void MouseMoved(int8 *buffer)</P>
</TD>
</TR>
<TR>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">void UpdateDecorator(void)</P>
</TD>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">void UpdateColors(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">void UpdateFont(void)</P>
</TD>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">void UpdateScreen(void)</P>
</TD>
</TR>
<TR>
<TD WIDTH=294 HEIGHT=17>
<P class="Body" style="margin: 0px">void RebuildRegions(bool recursive=true)</P>
</TD>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">void Activate(bool state)</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
Global Functions</P>
<P class="Body" style="margin: 0px"><BR>
bool is_moving_window(void)</P>
<P class="Body" style="margin: 0px">void set_is_moving_window(bool state)</P>
<P class="Body" style="margin: 0px">bool is_resizing_window(void)</P>
<P class="Body" style="margin: 0px">void set_is_resizing_window(bool state)</P>
<P class="Body" style="margin: 0px">void set_active_winborder(WinBorder *win)</P>
<P class="Body" style="margin: 0px">WinBorder * get_active_winborder(void)</P>
<P class="Body" style="margin: 0px"><BR>
Namespaces</P>
<P class="Body" style="margin: 0px"><BR>
winborder_private {</P>
<P class="Body" style="margin: 0px"> bool is_moving_a_window</P>
<P class="Body" style="margin: 0px"> bool is_resizing_a_window</P>
<P class="Body" style="margin: 0px"> WinBorder *active_winborder</P>
<P class="Body" style="margin: 0px">}</P>
<P class="Body" style="margin: 0px"><BR>
<HR>
</P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">WinBorder(BRect r, const char *name, int32 resize, int32 flags, ServerWindow *win)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Pass parameters to Layer constructor</P>
<P class="Body" style="margin: 0px">2) Instantiate a decorator</P>
<P class="Body" style="margin: 0px">3) Initialize visible and full regions via Decorator::GetFootprint()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">~WinBorder(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
1) Delete decorator instance</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RequestDraw(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Reimplements Layer::RequestDraw() because it has no corresponding BView</P>
<P class="Body" style="margin: 0px"><BR>
1) if IsDirty()==false, return</P>
<P class="Body" style="margin: 0px">2) Iterate through each BRect in the invalid region and call Decorator::Draw(BRect) for each invalid rectangle</P>
<P class="Body" style="margin: 0px">3) Perform recursive child calls as in Layer::RequestDraw()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void MoveBy(BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void MoveBy(float x, float y)</span></P>
<P class="Body" style="margin: 0px"><BR>
Moves the WinBorder's position on screen - reimplements Layer::MoveBy()</P>
<P class="Body" style="margin: 0px"><BR>
1) Call the decorator's MoveBy()</P>
<P class="Body" style="margin: 0px">2) Call Layer::MoveBy()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void ResizeBy(BPoint pt)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void ResizeBy(float x, float y)</span></P>
<P class="Body" style="margin: 0px"><BR>
Resizes the WinBorder - reimplements Layer::MoveBy()</P>
<P class="Body" style="margin: 0px"><BR>
1) Call the decorator's ResizeBy()</P>
<P class="Body" style="margin: 0px">2) Call Layer::ResizeBy()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void MouseDown(int8 *buffer)</span></P>
<P class="Body" style="margin: 0px"><BR>
Figures out what to do with B_MOUSE_DOWN messages sent to the window's border.</P>
<P class="Body" style="margin: 0px"><BR>
1) Extract data from the buffer</P>
<P class="Body" style="margin: 0px">2) Call the decorator's Clicked() function</P>
<P class="Body" style="margin: 0px">3) Feed return value to a switch() function (table below)</P>
<P class="Body" style="margin: 0px">4) Call the ServerWindow's Activate() function</P>
<P class="Body" style="margin: 0px"><BR>
</P>
<TABLE WIDTH=561 HEIGHT=324 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=158 HEIGHT=17>
<P class="Body" style="margin: 0px">CLICK_MOVETOBACK</P>
</TD>
<TD WIDTH=263 HEIGHT=17>
<P class="Body" style="margin: 0px">call MoveToBack()</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=17>
<P class="Body" style="margin: 0px">CLICK_MOVETOFRONT</P>
</TD>
<TD WIDTH=263 HEIGHT=17>
<P class="Body" style="margin: 0px">call MoveToFront()</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=32>
<P class="Body" style="margin: 0px">CLICK_CLOSE</P>
</TD>
<TD WIDTH=263 HEIGHT=32>
<P class="Body" style="margin: 0px">1) call SetCloseButton(true)</P>
<P class="Body" style="margin: 0px">2) call decorator-&gt;DrawClose</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=32>
<P class="Body" style="margin: 0px">CLICK_ZOOM</P>
</TD>
<TD WIDTH=263 HEIGHT=32>
<P class="Body" style="margin: 0px">1) call SetZoomButton(true)</P>
<P class="Body" style="margin: 0px">2) call decorator-&gt;DrawZoom</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=32>
<P class="Body" style="margin: 0px">CLICK_MINIMIZE</P>
</TD>
<TD WIDTH=263 HEIGHT=32>
<P class="Body" style="margin: 0px">1) call SetMinimizeButton(true)</P>
<P class="Body" style="margin: 0px">2) call decorator-&gt;DrawMinimize</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=47>
<P class="Body" style="margin: 0px">CLICK_DRAG</P>
</TD>
<TD WIDTH=263 HEIGHT=47>
<P class="Body" style="margin: 0px">1) call MoveToFront()</P>
<P class="Body" style="margin: 0px">2) call set_is_win_moving(true)</P>
<P class="Body" style="margin: 0px">3) Save the mouse position</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=32>
<P class="Body" style="margin: 0px">CLICK_RESIZE</P>
</TD>
<TD WIDTH=263 HEIGHT=32>
<P class="Body" style="margin: 0px">1) call MoveToFront()</P>
<P class="Body" style="margin: 0px">2) call set_is_win_resizing(true)</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=17>
<P class="Body" style="margin: 0px">CLICK_NONE</P>
</TD>
<TD WIDTH=263 HEIGHT=17>
<P class="Body" style="margin: 0px">do nothing</P>
</TD>
</TR>
<TR>
<TD WIDTH=158 HEIGHT=17>
<P class="Body" style="margin: 0px">default:</P>
</TD>
<TD WIDTH=263 HEIGHT=17>
<P class="Body" style="margin: 0px">Spew an error to stderr and return</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<span class="OBOS-Function-Def">void MouseUp(int8 *buffer)</span></P>
<P class="Body" style="margin: 0px"><BR>
Figures out what to do with B_MOUSE_UP messages sent to the window's border.</P>
<P class="Body" style="margin: 0px"><BR>
1) Extract data from the buffer</P>
<P class="Body" style="margin: 0px">2) Call the decorator's Clicked() function</P>
<P class="Body" style="margin: 0px">3) Feed return value to a switch() function (table below)</P>
<P class="Body" style="margin: 0px">4) if is_resizing_window, call set_is_resizing_window(false)</P>
<P class="Body" style="margin: 0px">5) if is_moving_window, call set_is_moving_window(false)</P>
<P class="Body" style="margin: 0px"></P>
<TABLE WIDTH=612 HEIGHT=371 BORDER=1 CELLPADDING=1 CELLSPACING=2>
<TR>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">CLICK_MOVETOBACK</P>
</TD>
<TD WIDTH=286 HEIGHT=17>
<P class="Body" style="margin: 0px">call MoveToBack()</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">CLICK_MOVETOFRONT</P>
</TD>
<TD WIDTH=286 HEIGHT=17>
<P class="Body" style="margin: 0px">call MoveToFront()</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=63>
<P class="Body" style="margin: 0px">CLICK_CLOSE</P>
</TD>
<TD WIDTH=286 HEIGHT=63>
<P class="Body" style="margin: 0px">1) call SetCloseButton(false)</P>
<P class="Body" style="margin: 0px">2) call decorator-&gt;DrawClose</P>
<P class="Body" style="margin: 0px">3) send B_QUIT_REQUESTED to the target BWindow</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=48>
<P class="Body" style="margin: 0px">CLICK_ZOOM</P>
</TD>
<TD WIDTH=286 HEIGHT=48>
<P class="Body" style="margin: 0px">1) call SetZoomButton(false)</P>
<P class="Body" style="margin: 0px">2) call decorator-&gt;DrawZoom</P>
<P class="Body" style="margin: 0px">3) send B_ZOOM to the target BWindow</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=48>
<P class="Body" style="margin: 0px">CLICK_MINIMIZE</P>
</TD>
<TD WIDTH=286 HEIGHT=48>
<P class="Body" style="margin: 0px">1) call SetMinimizeButton(false)</P>
<P class="Body" style="margin: 0px">2) call decorator-&gt;DrawMinimize</P>
<P class="Body" style="margin: 0px">3) send B_MINIMIZE to the target BWindow</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=24>
<P class="Body" style="margin: 0px">CLICK_DRAG</P>
</TD>
<TD WIDTH=286 HEIGHT=24>
<P class="Body" style="margin: 0px">call set_is_win_moving(false)</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=24>
<P class="Body" style="margin: 0px">CLICK_RESIZE</P>
</TD>
<TD WIDTH=286 HEIGHT=24>
<P class="Body" style="margin: 0px">call set_is_win_resizing(false)</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">CLICK_NONE</P>
</TD>
<TD WIDTH=286 HEIGHT=17>
<P class="Body" style="margin: 0px">do nothing</P>
</TD>
</TR>
<TR>
<TD WIDTH=172 HEIGHT=17>
<P class="Body" style="margin: 0px">default:</P>
</TD>
<TD WIDTH=286 HEIGHT=17>
<P class="Body" style="margin: 0px">Spew an error to stderr</P>
</TD>
</TR>
</TABLE>
<P class="Body" style="margin: 0px"><BR>
<BR>
<BR>
<span class="OBOS-Function-Def">void MouseMoved(int8 *buffer)</span></P>
<P class="Body" style="margin: 0px"><BR>
Figures out what to do with B_MOUSE_MOVED messages sent to the window's border.</P>
<P class="Body" style="margin: 0px"><BR>
1) Extract data from the buffer</P>
<P class="Body" style="margin: 0px">2) Call the decorator's Clicked() function</P>
<P class="Body" style="margin: 0px">3) If not CLICK_CLOSE and decorator-&gt;GetClose is true, call SetClose(false) and DrawClose()</P>
<P class="Body" style="margin: 0px">4) If not CLICK_ZOOM and decorator-&gt;GetZoom is true, call SetZoom(false) and DrawZoom()</P>
<P class="Body" style="margin: 0px">5) If not CLICK_MINIMIZE and decorator-&gt;GetMinimize is true, call SetMinimize(false) and DrawMinimize()</P>
<P class="Body" style="margin: 0px">6) if CLICK_RESIZE or its variants, call CursorManager::SetCursor() with the appropriate system cursor.</P>
<P class="Body" style="margin: 0px">7) if is_moving_window() is true, calculate the amount the mouse has moved and call decorator-&gt;MoveBy() followed by Layer::MoveBy()</P>
<P class="Body" style="margin: 0px">8) if is_resizing_window() is true, calculate the amount the mouse has moved and call decorator-&gt;ResizeBy() followed by Layer::ResizeBy()</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void UpdateDecorator(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Hook function called by the WinBorder's ServerWindow when the decorator used is changed.</P>
<P class="Body" style="margin: 0px"><BR>
1) Delete the current decorator</P>
<P class="Body" style="margin: 0px">2) Call instantiate_decorator</P>
<P class="Body" style="margin: 0px">3) Get the new decorator's footprint region and assign it to the full and visible regions</P>
<P class="Body" style="margin: 0px">4) Call RebuildRegions and then RequestDraw</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void UpdateColors(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Hook function called by the WinBorder's ServerWindow when system colors change</P>
<P class="Body" style="margin: 0px"><BR>
1) Call the decorator's SetColors(), passing the SystemPalette's GetGUIColors() value</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void UpdateFont(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Hook function called by the WinBorder's ServerWindow when system fonts change</P>
<P class="Body" style="margin: 0px"><BR>
TODO: implementation details</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void UpdateScreen(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
Hook function called by the WinBorder's ServerWindow when screen attributes change</P>
<P class="Body" style="margin: 0px"><BR>
1) Call the decorator's UpdateScreen and then RequestDraw</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void RebuildRegions(bool recursive=true)</span></P>
<P class="Body" style="margin: 0px"><BR>
Reimplementation of Layer::RebuildRegions which changes it such that lower siblings are clipped to the footprint instead of the frame.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void Activate(bool state)</span></P>
<P class="Body" style="margin: 0px"><BR>
This function is never directly called except from within set_active_winborder. It exists to force redraw and set the internal state information to the proper values for when a window receives or loses focus.</P>
<P class="Body" style="margin: 0px"><BR>
1) call the decorator's SetFocus(state)</P>
<P class="Body" style="margin: 0px">2) set the internal is_active flag to state</P>
<P class="Body" style="margin: 0px">3) iterate through each rectangle in the visible region and call the decorator's Draw on it.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool is_moving_window(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void set_is_moving_window(bool state)</span></P>
<P class="Body" style="margin: 0px"><BR>
These two functions set and return the variable winborder_private::is_moving_a_window.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">bool is_resizing_window(void)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void set_is_resizing_window(bool state)</span></P>
<P class="Body" style="margin: 0px"><BR>
These two functions set and return the variable winborder_private::is_resizing_a_window.</P>
<P class="Body" style="margin: 0px"><BR>
<BR>
<span class="OBOS-Function-Def">void set_active_winborder(WinBorder *win)</span></P>
<P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">WinBorder * get_active_winborder(void)</span></P>
<P class="Body" style="margin: 0px"><BR>
These two functions set and return the variable winborder_private::active_winborder</P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
@@ -0,0 +1,236 @@
WinBorder class : public Layer
##############################
WinBorder objects provide window management functionality and ensure
that the border for each window is drawn.
Member Functions
================
WinBorder(BRect r, const char \*name, int32 resize, int32 flags, ServerWindow \*win)
------------------------------------------------------------------------------------
1. Pass parameters to Layer constructor
2. Instantiate a decorator
3. Initialize visible and full regions via Decorator::GetFootprint()
~WinBorder(void)
----------------
1. Delete decorator instance
void RequestDraw(void)
----------------------
Reimplements Layer::RequestDraw() because it has no corresponding BView
1. if IsDirty()==false, return
2. Iterate through each BRect in the invalid region and call Decorator::Draw(BRect) for each invalid rectangle
3. Perform recursive child calls as in Layer::RequestDraw()
void MoveBy(BPoint pt), void MoveBy(float x, float y)
-----------------------------------------------------
Moves the WinBorder's position on screen - reimplements Layer::MoveBy()
1. Call the decorator's MoveBy()
2. Call Layer::MoveBy()
void ResizeBy(BPoint pt), void ResizeBy(float x, float y)
---------------------------------------------------------
Resizes the WinBorder - reimplements Layer::MoveBy()
1. Call the decorator's ResizeBy()
2. Call Layer::ResizeBy()
void MouseDown(int8 \*buffer)
-----------------------------
Figures out what to do with B_MOUSE_DOWN messages sent to the window's border.
1. Extract data from the buffer
2. Call the decorator's Clicked() function
3. Feed return value to a switch() function (table below)
4. Call the ServerWindow's Activate() function
+-----------------------------------+-----------------------------------+
| CLICK_MOVETOBACK | call MoveToBack() |
+-----------------------------------+-----------------------------------+
| CLICK_MOVETOFRONT | call MoveToFront() |
+-----------------------------------+-----------------------------------+
| CLICK_CLOSE | 1) call SetCloseButton(true) |
| | |
| | 2) call decorator->DrawClose |
+-----------------------------------+-----------------------------------+
| CLICK_ZOOM | 1) call SetZoomButton(true) |
| | |
| | 2) call decorator->DrawZoom |
+-----------------------------------+-----------------------------------+
| CLICK_MINIMIZE | 1) call SetMinimizeButton(true) |
| | |
| | 2) call decorator->DrawMinimize |
+-----------------------------------+-----------------------------------+
| CLICK_DRAG | 1) call MoveToFront() |
| | |
| | 2) call set_is_win_moving(true) |
| | |
| | 3) Save the mouse position |
+-----------------------------------+-----------------------------------+
| CLICK_RESIZE | 1) call MoveToFront() |
| | |
| | 2) call set_is_win_resizing(true) |
+-----------------------------------+-----------------------------------+
| CLICK_NONE | do nothing |
+-----------------------------------+-----------------------------------+
| default: | Spew an error to stderr and |
| | return |
+-----------------------------------+-----------------------------------+
void MouseUp(int8 \*buffer)
---------------------------
Figures out what to do with B_MOUSE_UP messages sent to the window's border.
1. Extract data from the buffer
2. Call the decorator's Clicked() function
3. Feed return value to a switch() function (table below)
4. if is_resizing_window, call set_is_resizing_window(false)
5. if is_moving_window, call set_is_moving_window(false)
+-----------------------------------+-----------------------------------+
| CLICK_MOVETOBACK | call MoveToBack() |
+-----------------------------------+-----------------------------------+
| CLICK_MOVETOFRONT | call MoveToFront() |
+-----------------------------------+-----------------------------------+
| CLICK_CLOSE | 1) call SetCloseButton(false) |
| | |
| | 2) call decorator->DrawClose |
| | |
| | 3) send B_QUIT_REQUESTED to the |
| | target BWindow |
+-----------------------------------+-----------------------------------+
| CLICK_ZOOM | 1) call SetZoomButton(false) |
| | |
| | 2) call decorator->DrawZoom |
| | |
| | 3) send B_ZOOM to the target |
| | BWindow |
+-----------------------------------+-----------------------------------+
| CLICK_MINIMIZE | 1) call SetMinimizeButton(false) |
| | |
| | 2) call decorator->DrawMinimize |
| | |
| | 3) send B_MINIMIZE to the target |
| | BWindow |
+-----------------------------------+-----------------------------------+
| CLICK_DRAG | call set_is_win_moving(false) |
+-----------------------------------+-----------------------------------+
| CLICK_RESIZE | call set_is_win_resizing(false) |
+-----------------------------------+-----------------------------------+
| CLICK_NONE | do nothing |
+-----------------------------------+-----------------------------------+
| default: | Spew an error to stderr |
+-----------------------------------+-----------------------------------+
void MouseMoved(int8 \*buffer)
------------------------------
Figures out what to do with B_MOUSE_MOVED messages sent to the window's border.
1. Extract data from the buffer
2. Call the decorator's Clicked() function
3. If not CLICK_CLOSE and decorator->GetClose is true, call SetClose(false) and DrawClose()
4. If not CLICK_ZOOM and decorator->GetZoom is true, call SetZoom(false) and DrawZoom()
5. If not CLICK_MINIMIZE and decorator->GetMinimize is true, call SetMinimize(false) and DrawMinimize()
6. if CLICK_RESIZE or its variants, call CursorManager::SetCursor() with the appropriate system cursor.
7. if is_moving_window() is true, calculate the amount the mouse has moved and call decorator->MoveBy() followed by Layer::MoveBy()
8. if is_resizing_window() is true, calculate the amount the mouse has moved and call decorator->ResizeBy() followed by Layer::ResizeBy()
void UpdateDecorator(void)
--------------------------
Hook function called by the WinBorder's ServerWindow when the decorator used is changed.
1. Delete the current decorator
2. Call instantiate_decorator
3. Get the new decorator's footprint region and assign it to the full and visible regions
4. Call RebuildRegions and then RequestDraw
void UpdateColors(void)
-----------------------
Hook function called by the WinBorder's ServerWindow when system colors change
1. Call the decorator's SetColors(), passing the SystemPalette's GetGUIColors() value
void UpdateFont(void)
---------------------
Hook function called by the WinBorder's ServerWindow when system fonts change
| TODO: implementation details
void UpdateScreen(void)
-----------------------
Hook function called by the WinBorder's ServerWindow when screen
attributes change
1. Call the decorator's UpdateScreen and then RequestDraw
void RebuildRegions(bool recursive=true)
----------------------------------------
Reimplementation of Layer::RebuildRegions which changes it such that
lower siblings are clipped to the footprint instead of the frame.
void Activate(bool state)
-------------------------
This function is never directly called except from within
set_active_winborder. It exists to force redraw and set the internal
state information to the proper values for when a window receives or
loses focus.
1. call the decorator's SetFocus(state)
2. set the internal is_active flag to state
3. iterate through each rectangle in the visible region and call the decorator's Draw on it.
Global Functions
================
bool is_moving_window(void), void set_is_moving_window(bool state)
------------------------------------------------------------------
These two functions set and return the variable
winborder_private::is_moving_a_window.
bool is_resizing_window(void), void set_is_resizing_window(bool state)
----------------------------------------------------------------------
These two functions set and return the variable
winborder_private::is_resizing_a_window.
void set_active_winborder(WinBorder \*win), WinBorder \* get_active_winborder(void)
-----------------------------------------------------------------------------------
These two functions set and return the variable winborder_private::active_winborder
Namespaces
==========
.. code-block:: cpp
winborder_private {
bool is_moving_a_window
bool is_resizing_a_window
WinBorder *active_winborder
}
-271
View File
@@ -1,271 +0,0 @@
<HTML>
<HEAD>
<TITLE>App Server Interface Spec.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}
.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 style="color: rgb(0,0,128); font-family: 'Swis721 BT'; font-size: 18pt">App Server Interface Specification v0.3</span><span style="color: rgb(0,0,128); font-family: 'Swis721 BT'; font-size: 12pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt">Purpose:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">The app_server provides services to the OpenBeOS by managing processes, filtering and dispatching input from the Input Server to the appropriate applications, and managing all graphics-related tasks.</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Tasks:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">The tasks performed by the app_server are grouped in relation to its purpose.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Receives and redirects (dispatches) messages from the input server</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt"><BR>
Responds to messages from apps</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Receives and consolidates requests from BView, BWindow, BBitmap, and others to draw stuff (draw bitmap, etc)</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Utilizes ports to communicate with child processes</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Handles drag &amp; drop messaging</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Manages the system clipboard</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt"><BR>
Loads and Kills processes</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Detects absence of Input Server and restarts when not running</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Aids in system shutdown</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt"><BR>
Dynamically loads accelerant portion of graphics driver</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Creates a connection with BBitmaps requiring a child view</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Draws the blue desktop screen</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Provides workspace support</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Provides functionality to the BeAPI for drawing primitives, such as rectangles, ellipses, and beziers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Provides a means for BViews to draw on BBitmaps</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Manages window behavior with respect to redraw (move to front, minimize, etc)</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Returns a frame buffer to direct-access classes</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Caches fonts for screen and printer use</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt">Draws text and provides other font API support for the BeAPI classes</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 16pt">Table of Contents</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt"><BR>
</span><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 14pt">Graphics:</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 14pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. Desktop Initialization</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Window management</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> A. ServerApp</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> B. ServerWindow</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> C. Layer</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> D. WindowBorder</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> E. Decorator</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Screen updates</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> IV. Cursor management</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> V. Display Drivers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 13pt">Process Management:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. BApplication execution</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Non-BApplication execution</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Killing/Exiting applications</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> IV. System Shutdown</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 13pt">Input Processing:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. Input Server messages</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Mouse</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Keyboard</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 14pt">Messaging:</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 14pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. Inter-Application messaging</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Drag-and-drop</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Methods</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 11pt"><BR>
<BR>
<BR>
<BR>
</span><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 14pt">Graphics:</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 14pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. Desktop Initialization</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Window management</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Screen updates</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 13pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> IV. Cursor management</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 13pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 13pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">I. Desktop Initialization</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
The graphics hardware is abstracted from the rest of the app_server. When started, the server creates the desktop, which is little more than a collection of workspaces. The desktop actually creates a DisplayDriver and then calls the driver's method Inititialize() before calling a few high-level routines for setup. Below is the process by which the HWDriver class, which is used to access the primary graphics card in the system, followed by the steps taken to set up the desktop.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">Load Accelerant</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> The app_server looks in three paths when scanning for an accelerant:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">/fd/beos/system/add-ons/app_server</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">/boot/home/config/add-ons/app_server</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">/boot/beos/system/add-ons/app_server</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
When the app_server searches a path, it simply prints to the debug stream on the serial port a message akin "Attempting to load accelerant so-and-so" when loading the accelerant. Following this, it is loads the accelerant via load_add_on(), obtains the hook function control_graphics_card is via get_image_symbol, and control_graphics_card(OPEN_GRAPHICS_CARD) is called. If this returns an error, the image is unloaded after a control_graphics_card(CLOSE_GRAPHICS_CARD) is called and the server spits out a message like "So-and-so is not an acceptable driver" to the serial port. Assuming that the OPEN call succeeds, the app_server serial prints "Using so-and-so as accelerant." Hook functions are then acquired through control_graphics_card(B_GET_GRAPHICS_CARD_HOOKS). At this point, it is a good idea to have a palette generated for 8-bit mode (just in case we're going to use it), so the server generates the system palette. The palette on the graphics card is then set through many calls to control_graphics_card(B_SET_INDEXED_COLOR). </span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Set up workspaces</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> Workspace preferences are read in from disk. If they exist, they are used; otherwise the default of 3 workspace, each with the settings [email protected], is used. Each workspace is initialized to the proper information (preferences or default). Additionally, all settings are checked and possibly "clipped" by information gained through the driver class. With the desktop having been given the proper settings, the default workspace, 0, is activated.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">Display</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> Provided that everything has gone well so far, the screen is filled to the user-set workspace color or RGB(51,102,160) Also, the global clipboard is created, which is nothing more than a BClipboard object. The Input Server will notify the app_server of its existence, at which point the cursor will be set to B_HAND_CURSOR and shown on the screen.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
II. Window management</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Window management is a complicated issue, requiring the cooperation of a number of different types of elements. Each BApplication, BWindow, and BView has a counterpart in the app_server which has a role to play. These objects are Decorators, ServerApps, ServerWindows, Layers, and WindowBorders.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">A. ServerApps</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
ServerApp objects are created when a BApplication notifies the app_server of its presence. In acknowledging the BApplication's existence, the server creates a ServerApp which will handle future server-app communications and notifies the BApplication of the port to which it must send future messages.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
ServerApps are each an independent thread which has a function similar to that of a BLooper, but with additional tasks. When a BWindow is created, it spawns a ServerWindow object to handle the new window. The same applies to when a window is destroyed. Cursor commands and all other BApplication functions which require server interaction are also handled. B_QUIT_REQUESTED messages are received and passed along to the main thread in order for the ServerApp object to be destroyed. The server's Picasso thread also utilizes ServerApp::PingTarget in order to determine whether the counterpart BApplication is still alive and running.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B. ServerWindows</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
ServerWindow objects' purpose is to take care of the needs of BWindows. This includes all calls which require a trip to the server, such as BView graphics calls and sending messages to invoke hook functions within a window.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">C. Layers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Layers are shadowed BViews and are used to handle much BView functionality and also determine invalid screen regions. Hierarchal functions, such as AddChild, are mirrored. Invalid regions are tracked and generate Draw requests which are sent to the application for a specific BView to update its part of the screen.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">D. WindowBorders</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
WindowBorders are a special kind of Layer with no BView counterpart, designed to handle window management issues, such as click tests, resize and move events, and ensuring that its decorator updates the screen appropriately.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">F. Decorators</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Decorators are addons which are intended to do one thing: draw the window frame. The Decorator API and development information is described in the Decorator Development Reference. They are essentially the means by which WindowBorders draw to the screen.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">G. How It All Works</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">The app_server is one large, complex beast because of all the tasks it performs. It also utilizes the various objects to accomplish them. Input messages are received from the Input Server and all messages not specific to the server (such as Ctrl-Alt-Shift-Backspace) are passed to the active application, if any. Mouse clicks are passed to the ServerWindow class for hit testing. These hit tests can result in window tabs and buttons being clicked, or mouse click messages being passed to a specific view in a window.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
These input messages which are passed to a running application will sometimes cause things to happen inside it, such as button presses, window closings/openings, etc. which will cause messages to be sent to the server. These messages are sent either from a BWindow to a ServerWindow or a BApplication to a ServerApp. When such messages are sent, then the corresponding app_server object performs an appropriate action.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">III. Screen Updates</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Screen updates are done entirely through the BView class or some subclass thereof, hereafter referred to as a view. A view's drawing commands will cause its window to store draw command messages in a message packet. At some point Flush() will be called and the command packet will be sent to the window's ServerWindow object inside the server.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
The ServerWindow will receive the packet, check to ensure that its size is correct, and begin retrieving each command from the packet and dispatching it, taking the appropriate actions. Actual drawing commands, such as StrokeRect, will involve the ServerWindow object calling the appropriate command in the graphics module for the Layer corresponding to the view which sent the command.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">IV. Cursor Management</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
The app_server handles all messiness to do with the cursor. The cursor commands which are members of the BApplication class will send a message to its ServerApp, which will then call the DisplayDriver's appropriate function. The DisplayDriver used will actually handle the drawing of the cursor and whether or not to do so at any given time.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
OpenBeOS R1 will also include the advent of an extension of the API: SetCursor(BBitmap *), which will accept a BBitmap of color space RGB(A)32, RGBA16, CMAP8, GRAY8, or GRAY1. Thus, color cursors and cursors which are not 16x16 are now supported.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
V. Display Drivers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Unlike the BeOS R5 app_server, OpenBeOS' server will have a special feature: a modular graphics driver access class. The class is not actually the graphics driver, but, rather, a generalized interface which is implemented to interact with various destinations for graphics output. This allows the server to draw to a BWindow/BView combination, a BDirectWindow, or the actual frame buffer of a particular graphics card. All that the rest of the server needs to do is call whichever graphics function that is needed.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 13pt">Process Management:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. BApplication execution</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Non-BApplication execution</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Killing/Exiting applications</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> IV. System Shutdown</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">I. BApplication execution</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">Applications will come in two types: those which communicate with the app_server and take advantage of its services, and those which do not. To access the app_server, an application must be derived from BApplication.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
When a BApplication (referred to hereafter as a BApp) is executed, the app constructor creates its BLooper message port with the name AppLooperPort. This port's id, by means of BLooper, registers its port_id with the app_server so that the two can communicate with each other most easily.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
When the app_server receives notification that an app has been created, the server creates an AppMonitor (with accompanying thread) in its own team to handle messages sent to it and sends a reply with the port_id of the AppMonitor, to which all future messages are sent. These AppMonitor objects are stored in a global BList created for the storage of such things.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">II. non-BApplication execution</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">Other applications do not communicate with the app_server. These applications have no access to app services and do not generally pass BMessages. This includes, but is not limited to, UNIX apps. The app_server ignores such applications except when asked to kill them.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
While, technically, these are not limited to being non-GUI applications, in practice these applications are command-line-only, for the application would be required to (1) render the app_server unable to access video hardware and (2) reinvent existing graphics code to load and use accelerants and draw onto the video buffer. This is extremely bad style and programming practice, not to mention more work than it is worth except in one case: the OpenBeOS app_server can coexist with the BeOS R5 app_server with some degree of peace because it can utilize extra video cards which the BeOS app_server does not use.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">III. Killing/Exiting Applications</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">While the input server handles the Team Monitor window, the app_server actually takes care of shutting down teams, peacefully or not. Exiting an app is done simply by sending a B_QUIT_REQUESTED message to particular app. Killing an app is done via kill_team, but all the messy details are handled by the kernel itself through this call. When the user requests a team die via the Team Monitor, the Input Server sends a message to the app_server to kill the team, attaching the team_id. The app_server responds by happily nuking the respective team and notifies the registrar of its forcible removal from the roster.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
IV. System Shutdown</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">Although the server maintains an internal list of running GUI applications, when a request to shut down the system is received by the app_server, it will pass the request on to the registrar, which will, in turn, increment its way through the app roster and request each app quit. When each quit request is sent, a timer is started and after timeout, the registrar will ask the server to kill the particular team and continue iterating through the application list.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 13pt">Input Processing:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. Input Server messages</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Mouse</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Keyboard</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 12pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
I. Input Server messages</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">The Input Server collects information about keyboard and mouse events and forwards them to the app_server via messages. They are sent to port specifically for such messages, and the port is monitored by a thread whose task is to monitor, process, and dispatch them to the appropriate recipients. The Input Server is a regular BApplication, and unlike other applications, it requests a port to which it can send input messages.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">II. Mouse</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">Mouse events consist of button changes, mouse movements, and the mouse wheel. The message will consist of the time of the event and attachments appropriate for each message listed below:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
B_MOUSE_DOWN</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> when</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> location of the cursor</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> button number</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifiers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> clicks</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B_MOUSE_UP</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> buttons' status // not implemented for R5 but included for future expansion</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> location of the cursor</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifiers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B_MOUSE_MOVED</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> location of the cursor</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> buttons' status</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B_MOUSE_WHEEL_CHANGED</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> location of the cursor</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> transit - in or out</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> x delta</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> y delta</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">III. Keyboard</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Keyboard events consist of notification when a key is pressed or released. Any keypress or release will evoke a message, regardless of whether or not the key is mapped. The message will consist of the appropriate code and attachments listed below:</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
B_KEY_DOWN</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> key code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> repeat count</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifiers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> states</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> UTF-8 code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> string generated</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifier-independent ASCII code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B_KEY_UP</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> key code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifiers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> states</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> UTF-8 code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> string generated</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifier-independent ASCII code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B_UNMAPPED_KEY_DOWN</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> key code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifiers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> states</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B_UNMAPPED_KEY_UP</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> key code</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifiers</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> states</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">B_MODIFIERS_CHANGED // sent when a modifier key changes</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> time</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> modifier states</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> previous modifier states</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"> states</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
Nearly all keypresses received by the app_server are passed onto the appropriate application. Control-Tab, when held, is sent to the Deskbar for app switching. Command+F?? is intercepted and a workspace is switched. Left Control + Alt + Delete is not even intercepted by the app_server. The Input Server receives it and shows the Team Monitor window.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,128,128); font-weight: bold; font-family: 'Swis721 BT'; font-size: 14pt">Messaging:</span><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 14pt"></span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> I. Inter-Application messaging</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> II. Drag-and-drop</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,128,128); font-family: 'Swis721 BT'; font-size: 13pt"> III. Methods</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 13pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">I. Inter-Application Messaging</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">The details of messaging are depicted under Process Management::BApplication.</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt">II. Drag-and-drop</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
III. Methods</span></P>
<P class="Body" style="margin: 0px"><span style="color: rgb(128,0,0); font-family: 'Swis721 BT'; font-size: 12pt"><BR>
</span><span style="color: rgb(0,0,0); font-family: 'Swis721 BT'; font-size: 12pt">Messaging with the app_server is not done using BMessages because of the overhead required to send them costs time and speed. Instead, ports are utilized indirectly by means of the PortLink class, which simply makes attaching data to a port message easier, but requires very little overhead. </span></P>
<DIV class="layer" id="Layer 1">
</DIV>
</DIV>
</BODY>
</HTML>
+425
View File
@@ -0,0 +1,425 @@
App Server Interface Specification v0.3
#######################################
Purpose:
========
The app_server provides services to the OpenBeOS by managing processes,
filtering and dispatching input from the Input Server to the appropriate
applications, and managing all graphics-related tasks.
Tasks:
======
The tasks performed by the app_server are grouped in relation to its
purpose.
- Receives and redirects (dispatches) messages from the input server
- Responds to messages from apps
- Receives and consolidates requests from BView, BWindow, BBitmap, and others to draw stuff (draw bitmap, etc)
- Utilizes ports to communicate with child processes
- Handles drag & drop messaging
- Manages the system clipboard
- Loads and Kills processes
- Detects absence of Input Server and restarts when not running
- Aids in system shutdown
- Dynamically loads accelerant portion of graphics driver
- Creates a connection with BBitmaps requiring a child view
- Draws the blue desktop screen
- Provides workspace support
- Provides functionality to the BeAPI for drawing primitives, such as rectangles, ellipses, and beziers
- Provides a means for BViews to draw on BBitmaps
- Manages window behavior with respect to redraw (move to front, minimize, etc)
- Returns a frame buffer to direct-access classes
- Caches fonts for screen and printer use
- Draws text and provides other font API support for the BeAPI classes
Graphics:
=========
Desktop Initialization
-----------------------
The graphics hardware is abstracted from the rest of the app_server.
When started, the server creates the desktop, which is little more than
a collection of workspaces. The desktop actually creates a DisplayDriver
and then calls the driver's method Inititialize() before calling a few
high-level routines for setup. Below is the process by which the
HWDriver class, which is used to access the primary graphics card in the
system, followed by the steps taken to set up the desktop.
Load Accelerant
...............
The app_server looks in three paths when scanning for an accelerant:
- /fd/beos/system/add-ons/app_server
- /boot/home/config/add-ons/app_server
- /boot/beos/system/add-ons/app_server
When the app_server searches a path, it simply prints to the debug
stream on the serial port a message akin "Attempting to load accelerant
so-and-so" when loading the accelerant. Following this, it is loads the
accelerant via load_add_on(), obtains the hook function
control_graphics_card is via get_image_symbol, and
control_graphics_card(OPEN_GRAPHICS_CARD) is called. If this returns an
error, the image is unloaded after a
control_graphics_card(CLOSE_GRAPHICS_CARD) is called and the server
spits out a message like "So-and-so is not an acceptable driver" to the
serial port. Assuming that the OPEN call succeeds, the app_server serial
prints "Using so-and-so as accelerant." Hook functions are then acquired
through control_graphics_card(B_GET_GRAPHICS_CARD_HOOKS). At this point,
it is a good idea to have a palette generated for 8-bit mode (just in
case we're going to use it), so the server generates the system palette.
The palette on the graphics card is then set through many calls to
control_graphics_card(B_SET_INDEXED_COLOR).
Set up workspaces
.................
Workspace preferences are read in from disk. If they exist, they are
used; otherwise the default of 3 workspace, each with the settings
[email protected], is used. Each workspace is initialized to the proper
information (preferences or default). Additionally, all settings are
checked and possibly "clipped" by information gained through the driver
class. With the desktop having been given the proper settings, the
default workspace, 0, is activated.
Display
.......
Provided that everything has gone well so far, the screen is filled to
the user-set workspace color or RGB(51,102,160) Also, the global
clipboard is created, which is nothing more than a BClipboard object.
The Input Server will notify the app_server of its existence, at which
point the cursor will be set to B_HAND_CURSOR and shown on the screen.
Window management
-----------------
Window management is a complicated issue, requiring the cooperation of a
number of different types of elements. Each BApplication, BWindow, and
BView has a counterpart in the app_server which has a role to play.
These objects are Decorators, ServerApps, ServerWindows, Layers, and
WindowBorders.
ServerApps
..........
ServerApp objects are created when a BApplication notifies the
app_server of its presence. In acknowledging the BApplication's
existence, the server creates a ServerApp which will handle future
server-app communications and notifies the BApplication of the port to
which it must send future messages.
ServerApps are each an independent thread which has a function similar
to that of a BLooper, but with additional tasks. When a BWindow is
created, it spawns a ServerWindow object to handle the new window. The
same applies to when a window is destroyed. Cursor commands and all
other BApplication functions which require server interaction are also
handled. B_QUIT_REQUESTED messages are received and passed along to the
main thread in order for the ServerApp object to be destroyed. The
server's Picasso thread also utilizes ServerApp::PingTarget in order to
determine whether the counterpart BApplication is still alive and
running.
ServerWindows
.............
ServerWindow objects' purpose is to take care of the needs of BWindows.
This includes all calls which require a trip to the server, such as
BView graphics calls and sending messages to invoke hook functions
within a window.
Layers
......
Layers are shadowed BViews and are used to handle much BView
functionality and also determine invalid screen regions. Hierarchal
functions, such as AddChild, are mirrored. Invalid regions are tracked
and generate Draw requests which are sent to the application for a
specific BView to update its part of the screen.
WindowBorders
.............
WindowBorders are a special kind of Layer with no BView counterpart,
designed to handle window management issues, such as click tests, resize
and move events, and ensuring that its decorator updates the screen
appropriately.
Decorators
..........
Decorators are addons which are intended to do one thing: draw the
window frame. The Decorator API and development information is described
in the Decorator Development Reference. They are essentially the means
by which WindowBorders draw to the screen.
How It All Works
................
The app_server is one large, complex beast because of all the tasks it
performs. It also utilizes the various objects to accomplish them. Input
messages are received from the Input Server and all messages not
specific to the server (such as Ctrl-Alt-Shift-Backspace) are passed to
the active application, if any. Mouse clicks are passed to the
ServerWindow class for hit testing. These hit tests can result in window
tabs and buttons being clicked, or mouse click messages being passed to
a specific view in a window.
These input messages which are passed to a running application will
sometimes cause things to happen inside it, such as button presses,
window closings/openings, etc. which will cause messages to be sent to
the server. These messages are sent either from a BWindow to a
ServerWindow or a BApplication to a ServerApp. When such messages are
sent, then the corresponding app_server object performs an appropriate
action.
Screen Updates
--------------
Screen updates are done entirely through the BView class or some
subclass thereof, hereafter referred to as a view. A view's drawing
commands will cause its window to store draw command messages in a
message packet. At some point Flush() will be called and the command
packet will be sent to the window's ServerWindow object inside the
server.
The ServerWindow will receive the packet, check to ensure that its size
is correct, and begin retrieving each command from the packet and
dispatching it, taking the appropriate actions. Actual drawing commands,
such as StrokeRect, will involve the ServerWindow object calling the
appropriate command in the graphics module for the Layer corresponding
to the view which sent the command.
Cursor Management
-----------------
The app_server handles all messiness to do with the cursor. The cursor
commands which are members of the BApplication class will send a message
to its ServerApp, which will then call the DisplayDriver's appropriate
function. The DisplayDriver used will actually handle the drawing of the
cursor and whether or not to do so at any given time.
OpenBeOS R1 will also include the advent of an extension of the API:
SetCursor(BBitmap \*), which will accept a BBitmap of color space
RGB(A)32, RGBA16, CMAP8, GRAY8, or GRAY1. Thus, color cursors and
cursors which are not 16x16 are now supported.
Display Drivers
---------------
Unlike the BeOS R5 app_server, OpenBeOS' server will have a special
feature: a modular graphics driver access class. The class is not
actually the graphics driver, but, rather, a generalized interface which
is implemented to interact with various destinations for graphics
output. This allows the server to draw to a BWindow/BView combination, a
BDirectWindow, or the actual frame buffer of a particular graphics card.
All that the rest of the server needs to do is call whichever graphics
function that is needed.
Process Management
==================
BApplication execution
-----------------------
Applications will come in two types: those which communicate with the
app_server and take advantage of its services, and those which do not.
To access the app_server, an application must be derived from
BApplication.
When a BApplication (referred to hereafter as a BApp) is executed, the
app constructor creates its BLooper message port with the name
AppLooperPort. This port's id, by means of BLooper, registers its
port_id with the app_server so that the two can communicate with each
other most easily.
When the app_server receives notification that an app has been created,
the server creates an AppMonitor (with accompanying thread) in its own
team to handle messages sent to it and sends a reply with the port_id of
the AppMonitor, to which all future messages are sent. These AppMonitor
objects are stored in a global BList created for the storage of such
things.
non-BApplication execution
--------------------------
Other applications do not communicate with the app_server. These
applications have no access to app services and do not generally pass
BMessages. This includes, but is not limited to, UNIX apps. The
app_server ignores such applications except when asked to kill them.
While, technically, these are not limited to being non-GUI applications,
in practice these applications are command-line-only, for the
application would be required to (1) render the app_server unable to
access video hardware and (2) reinvent existing graphics code to load
and use accelerants and draw onto the video buffer. This is extremely
bad style and programming practice, not to mention more work than it is
worth except in one case: the OpenBeOS app_server can coexist with the
BeOS R5 app_server with some degree of peace because it can utilize
extra video cards which the BeOS app_server does not use.
Killing/Exiting Applications
----------------------------
While the input server handles the Team Monitor window, the app_server
actually takes care of shutting down teams, peacefully or not. Exiting
an app is done simply by sending a B_QUIT_REQUESTED message to
particular app. Killing an app is done via kill_team, but all the messy
details are handled by the kernel itself through this call. When the
user requests a team die via the Team Monitor, the Input Server sends a
message to the app_server to kill the team, attaching the team_id. The
app_server responds by happily nuking the respective team and notifies
the registrar of its forcible removal from the roster.
System Shutdown
---------------
Although the server maintains an internal list of running GUI
applications, when a request to shut down the system is received by the
app_server, it will pass the request on to the registrar, which will, in
turn, increment its way through the app roster and request each app
quit. When each quit request is sent, a timer is started and after
timeout, the registrar will ask the server to kill the particular team
and continue iterating through the application list.
Input Processing
================
Input Server messages
---------------------
The Input Server collects information about keyboard and mouse events
and forwards them to the app_server via messages. They are sent to port
specifically for such messages, and the port is monitored by a thread
whose task is to monitor, process, and dispatch them to the appropriate
recipients. The Input Server is a regular BApplication, and unlike other
applications, it requests a port to which it can send input messages.
Mouse
-----
Mouse events consist of button changes, mouse movements, and the mouse
wheel. The message will consist of the time of the event and attachments
appropriate for each message listed below:
B_MOUSE_DOWN
............
- when
- location of the cursor
- button number
- modifiers
- clicks
B_MOUSE_UP
..........
- time
- buttons' status // not implemented for R5 but included for future expansion
- location of the cursor
- modifiers
B_MOUSE_MOVED
.............
- time
- location of the cursor
- buttons' status
B_MOUSE_WHEEL_CHANGED
.....................
- time
- location of the cursor
- transit - in or out
- x delta
- y delta
Keyboard
--------
Keyboard events consist of notification when a key is pressed or
released. Any keypress or release will evoke a message, regardless of
whether or not the key is mapped. The message will consist of the
appropriate code and attachments listed below:
B_KEY_DOWN
..........
- time
- key code
- repeat count
- modifiers
- states
- UTF-8 code
- string generated
- modifier-independent ASCII code
B_KEY_UP
........
- time
- key code
- modifiers
- states
- UTF-8 code
- string generated
- modifier-independent ASCII code
B_UNMAPPED_KEY_DOWN
...................
- time
- key code
- modifiers
- states
B_UNMAPPED_KEY_UP
.................
- time
- key code
- modifiers
- states
B_MODIFIERS_CHANGED
...................
sent when a modifier key changes
- time
- modifier states
- previous modifier states
- states
Nearly all keypresses received by the app_server are passed onto the
appropriate application. Control-Tab, when held, is sent to the Deskbar
for app switching. Command+F?? is intercepted and a workspace is
switched. Left Control + Alt + Delete is not even intercepted by the
app_server. The Input Server receives it and shows the Team Monitor
window.
Messaging
=========
Inter-Application Messaging
---------------------------
The details of messaging are depicted under Process
Management::BApplication.
Drag-and-drop
-------------
Methods
-------
Messaging with the app_server is not done using BMessages because of the
overhead required to send them costs time and speed. Instead, ports are
utilized indirectly by means of the PortLink class, which simply makes
attaching data to a port message easier, but requires very little
overhead.
-339
View File
@@ -1,339 +0,0 @@
BGET -- Memory Allocator
==========================
by John Walker
[email protected]
http://www.fourmilab.ch/
BGET is a comprehensive memory allocation package which is easily
configured to the needs of an application. BGET is efficient in both
the time needed to allocate and release buffers and in the memory
overhead required for buffer pool management. It automatically
consolidates contiguous space to minimise fragmentation. BGET is
configured by compile-time definitions, Major options include:
* A built-in test program to exercise BGET and
demonstrate how the various functions are used.
* Allocation by either the "first fit" or "best fit"
method.
* Wiping buffers at release time to catch code which
references previously released storage.
* Built-in routines to dump individual buffers or the
entire buffer pool.
* Retrieval of allocation and pool size statistics.
* Quantisation of buffer sizes to a power of two to
satisfy hardware alignment constraints.
* Automatic pool compaction, growth, and shrinkage by
means of call-backs to user defined functions.
Applications of BGET can range from storage management in ROM-based
embedded programs to providing the framework upon which a multitasking
system incorporating garbage collection is constructed. BGET
incorporates extensive internal consistency checking using the
<assert.h> mechanism; all these checks can be turned off by compiling
with NDEBUG defined, yielding a version of BGET with minimal size and
maximum speed.
The basic algorithm underlying BGET has withstood the test of time; more
than 25 years have passed since the first implementation of this code.
And yet, it is substantially more efficient than the native allocation
schemes of many operating systems: the Macintosh and Microsoft Windows
to name two, on which programs have obtained substantial speed-ups by
layering BGET as an application level memory manager atop the underlying
system's.
BGET has been implemented on the largest mainframes and the lowest of
microprocessors. It has served as the core for multitasking operating
systems, multi-thread applications, embedded software in data network
switching processors, and a host of C programs. And while it has
accreted flexibility and additional options over the years, it remains
fast, memory efficient, portable, and easy to integrate into your
program.
BGET IMPLEMENTATION ASSUMPTIONS
===============================
BGET is written in as portable a dialect of C as possible. The only
fundamental assumption about the underlying hardware architecture is
that memory is allocated is a linear array which can be addressed as a
vector of C "char" objects. On segmented address space architectures,
this generally means that BGET should be used to allocate storage within
a single segment (although some compilers simulate linear address spaces
on segmented architectures). On segmented architectures, then, BGET
buffer pools may not be larger than a segment, but since BGET allows any
number of separate buffer pools, there is no limit on the total storage
which can be managed, only on the largest individual object which can be
allocated. Machines with a linear address architecture, such as the
VAX, 680x0, Sparc, MIPS, or the Intel 80386 and above in native mode,
may use BGET without restriction.
GETTING STARTED WITH BGET
=========================
Although BGET can be configured in a multitude of fashions, there are
three basic ways of working with BGET. The functions mentioned below
are documented in the following section. Please excuse the forward
references which are made in the interest of providing a roadmap to
guide you to the BGET functions you're likely to need.
Embedded Applications
---------------------
Embedded applications typically have a fixed area of memory dedicated to
buffer allocation (often in a separate RAM address space distinct from
the ROM that contains the executable code). To use BGET in such an
environment, simply call bpool() with the start address and length of
the buffer pool area in RAM, then allocate buffers with bget() and
release them with brel(). Embedded applications with very limited RAM
but abundant CPU speed may benefit by configuring BGET for BestFit
allocation (which is usually not worth it in other environments).
Malloc() Emulation
------------------
If the C library malloc() function is too slow, not present in your
development environment (for example, an a native Windows or Macintosh
program), or otherwise unsuitable, you can replace it with BGET.
Initially define a buffer pool of an appropriate size with
bpool()--usually obtained by making a call to the operating system's
low-level memory allocator. Then allocate buffers with bget(), bgetz(),
and bgetr() (the last two permit the allocation of buffers initialised
to zero and [inefficient] re-allocation of existing buffers for
compatibility with C library functions). Release buffers by calling
brel(). If a buffer allocation request fails, obtain more storage from
the underlying operating system, add it to the buffer pool by another
call to bpool(), and continue execution.
Automatic Storage Management
----------------------------
You can use BGET as your application's native memory manager and
implement automatic storage pool expansion, contraction, and optionally
application-specific memory compaction by compiling BGET with the BECtl
variable defined, then calling bectl() and supplying functions for
storage compaction, acquisition, and release, as well as a standard pool
expansion increment. All of these functions are optional (although it
doesn't make much sense to provide a release function without an
acquisition function, does it?). Once the call-back functions have been
defined with bectl(), you simply use bget() and brel() to allocate and
release storage as before. You can supply an initial buffer pool with
bpool() or rely on automatic allocation to acquire the entire pool.
When a call on bget() cannot be satisfied, BGET first checks if a
compaction function has been supplied. If so, it is called (with the
space required to satisfy the allocation request and a sequence number
to allow the compaction routine to be called successively without
looping). If the compaction function is able to free any storage (it
needn't know whether the storage it freed was adequate) it should return
a nonzero value, whereupon BGET will retry the allocation request and,
if it fails again, call the compaction function again with the
next-higher sequence number.
If the compaction function returns zero, indicating failure to free
space, or no compaction function is defined, BGET next tests whether a
non-NULL allocation function was supplied to bectl(). If so, that
function is called with an argument indicating how many bytes of
additional space are required. This will be the standard pool expansion
increment supplied in the call to bectl() unless the original bget()
call requested a buffer larger than this; buffers larger than the
standard pool block can be managed "off the books" by BGET in this mode.
If the allocation function succeeds in obtaining the storage, it returns
a pointer to the new block and BGET expands the buffer pool; if it
fails, the allocation request fails and returns NULL to the caller. If
a non-NULL release function is supplied, expansion blocks which become
totally empty are released to the global free pool by passing their
addresses to the release function.
Equipped with appropriate allocation, release, and compaction functions,
BGET can be used as part of very sophisticated memory management
strategies, including garbage collection. (Note, however, that BGET is
*not* a garbage collector by itself, and that developing such a system
requires much additional logic and careful design of the application's
memory allocation strategy.)
BGET FUNCTION DESCRIPTIONS
==========================
Functions implemented by BGET (some are enabled by certain of the
optional settings below):
void bpool(void *buffer, bufsize len);
Create a buffer pool of <len> bytes, using the storage starting at
<buffer>. You can call bpool() subsequently to contribute additional
storage to the overall buffer pool.
void *bget(bufsize size);
Allocate a buffer of <size> bytes. The address of the buffer is
returned, or NULL if insufficient memory was available to allocate the
buffer.
void *bgetz(bufsize size);
Allocate a buffer of <size> bytes and clear it to all zeroes. The
address of the buffer is returned, or NULL if insufficient memory was
available to allocate the buffer.
void *bgetr(void *buffer, bufsize newsize);
Reallocate a buffer previously allocated by bget(), changing its size to
<newsize> and preserving all existing data. NULL is returned if
insufficient memory is available to reallocate the buffer, in which case
the original buffer remains intact.
void brel(void *buf);
Return the buffer <buf>, previously allocated by bget(), to the free
space pool.
void bectl(int (*compact)(bufsize sizereq, int sequence),
void *(*acquire)(bufsize size),
void (*release)(void *buf),
bufsize pool_incr);
Expansion control: specify functions through which the package may
compact storage (or take other appropriate action) when an allocation
request fails, and optionally automatically acquire storage for
expansion blocks when necessary, and release such blocks when they
become empty. If <compact> is non-NULL, whenever a buffer allocation
request fails, the <compact> function will be called with arguments
specifying the number of bytes (total buffer size, including header
overhead) required to satisfy the allocation request, and a sequence
number indicating the number of consecutive calls on <compact>
attempting to satisfy this allocation request. The sequence number is 1
for the first call on <compact> for a given allocation request, and
increments on subsequent calls, permitting the <compact> function to
take increasingly dire measures in an attempt to free up storage. If
the <compact> function returns a nonzero value, the allocation attempt
is re-tried. If <compact> returns 0 (as it must if it isn't able to
release any space or add storage to the buffer pool), the allocation
request fails, which can trigger automatic pool expansion if the
<acquire> argument is non-NULL. At the time the <compact> function is
called, the state of the buffer allocator is identical to that at the
moment the allocation request was made; consequently, the <compact>
function may call brel(), bpool(), bstats(), and/or directly manipulate
the buffer pool in any manner which would be valid were the application
in control. This does not, however, relieve the <compact> function of
the need to ensure that whatever actions it takes do not change things
underneath the application that made the allocation request. For
example, a <compact> function that released a buffer in the process of
being reallocated with bgetr() would lead to disaster. Implementing a
safe and effective <compact> mechanism requires careful design of an
application's memory architecture, and cannot generally be easily
retrofitted into existing code.
If <acquire> is non-NULL, that function will be called whenever an
allocation request fails. If the <acquire> function succeeds in
allocating the requested space and returns a pointer to the new area,
allocation will proceed using the expanded buffer pool. If <acquire>
cannot obtain the requested space, it should return NULL and the entire
allocation process will fail. <pool_incr> specifies the normal
expansion block size. Providing an <acquire> function will cause
subsequent bget() requests for buffers too large to be managed in the
linked-block scheme (in other words, larger than <pool_incr> minus the
buffer overhead) to be satisfied directly by calls to the <acquire>
function. Automatic release of empty pool blocks will occur only if all
pool blocks in the system are the size given by <pool_incr>.
void bstats(bufsize *curalloc, bufsize *totfree,
bufsize *maxfree, long *nget, long *nrel);
The amount of space currently allocated is stored into the variable
pointed to by <curalloc>. The total free space (sum of all free blocks
in the pool) is stored into the variable pointed to by <totfree>, and
the size of the largest single block in the free space pool is stored
into the variable pointed to by <maxfree>. The variables pointed to by
<nget> and <nrel> are filled, respectively, with the number of
successful (non-NULL return) bget() calls and the number of brel()
calls.
void bstatse(bufsize *pool_incr, long *npool,
long *npget, long *nprel,
long *ndget, long *ndrel);
Extended statistics: The expansion block size will be stored into the
variable pointed to by <pool_incr>, or the negative thereof if automatic
expansion block releases are disabled. The number of currently active
pool blocks will be stored into the variable pointed to by <npool>. The
variables pointed to by <npget> and <nprel> will be filled with,
respectively, the number of expansion block acquisitions and releases
which have occurred. The variables pointed to by <ndget> and <ndrel>
will be filled with the number of bget() and brel() calls, respectively,
managed through blocks directly allocated by the acquisition and release
functions.
void bufdump(void *buf);
The buffer pointed to by <buf> is dumped on standard output.
void bpoold(void *pool, int dumpalloc, int dumpfree);
All buffers in the buffer pool <pool>, previously initialised by a call
on bpool(), are listed in ascending memory address order. If
<dumpalloc> is nonzero, the contents of allocated buffers are dumped; if
<dumpfree> is nonzero, the contents of free blocks are dumped.
int bpoolv(void *pool);
The named buffer pool, previously initialised by a call on bpool(), is
validated for bad pointers, overwritten data, etc. If compiled with
NDEBUG not defined, any error generates an assertion failure. Otherwise 1
is returned if the pool is valid, 0 if an error is found.
BGET CONFIGURATION
==================
#define TestProg 20000 /* Generate built-in test program
if defined. The value specifies
how many buffer allocation attempts
the test program should make. */
#define SizeQuant 4 /* Buffer allocation size quantum:
all buffers allocated are a
multiple of this size. This
MUST be a power of two. */
#define BufDump 1 /* Define this symbol to enable the
bpoold() function which dumps the
buffers in a buffer pool. */
#define BufValid 1 /* Define this symbol to enable the
bpoolv() function for validating
a buffer pool. */
#define DumpData 1 /* Define this symbol to enable the
bufdump() function which allows
dumping the contents of an allocated
or free buffer. */
#define BufStats 1 /* Define this symbol to enable the
bstats() function which calculates
the total free space in the buffer
pool, the largest available
buffer, and the total space
currently allocated. */
#define FreeWipe 1 /* Wipe free buffers to a guaranteed
pattern of garbage to trip up
miscreants who attempt to use
pointers into released buffers. */
#define BestFit 1 /* Use a best fit algorithm when
searching for space for an
allocation request. This uses
memory more efficiently, but
allocation will be much slower. */
#define BECtl 1 /* Define this symbol to enable the
bectl() function for automatic
pool space control. */
-52
View File
@@ -1,52 +0,0 @@
<html>
<body bgcolor="#ffffff" text="#000000">
<center><h1><font color="#008000">OpenBeOS R1 Application Server Specification</font></h1>
<h2><font color="#800000">Table of Contents</font></h2></center>
<h3>Class Descriptions</h3>
<dd>Application Management</dd>
<ul>
<li><a href="AppServer.htm">AppServer</a></li>
<li><a href="DebugTools.htm">DebugTools</a></li>
<li><a href="ServerApp.htm">ServerApp</a></li>
<li><a href="SharedObject.htm">SharedObject</a></li>
<li><a href="TokenHandler.htm">TokenHandler</a></li>
</ul>
<dd>Graphics Management</dd>
<P>
<ul>
<li><a href="BitmapManager.htm">BitmapManager</a></li>
<li><a href="ColorUtils.htm">ColorUtils</a></li>
<li><a href="CursorManager.htm">CursorManager</a></li>
<li><a href="Decorator.htm">Decorator</a></li>
<li><a href="Desktop.htm">Desktop</a></li>
<li><a href="DesktopClasses.htm">Desktop Classes</a></li>
<li><a href="DisplayDriver.htm">DisplayDriver</a></li>
<li><a href="Layer.htm">Layer</a></li>
<li><a href="PatternHandler.htm">PatternHandler</a></li>
<li><a href="RGBColor.htm">RGBColor</a></li>
<li><a href="ServerBitmap.htm">ServerBitmap</a></li>
<li><a href="SystemPalette.htm">SystemPalette</a></li>
<li><a href="WinBorder.htm">WinBorder</a></li>
</ul>
<dd>Font Infrastructure</dd>
<P>
<ul>
<li><a href="FontServer.htm">FontServer</a></li>
<li><a href="FontFamily.htm">FontFamily</a></li>
</ul>
<h3>Other Documents</h3>
<ul>
<li><a href="asis.htm">App Server Interface Specification</a></li>
<li><a href="MultiMonitor.htm">Multiple Monitor Support Spec</a></li>
</ul>
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
Application Server
============================================
Class Descriptions
~~~~~~~~~~~~~~~~~~
Application Management
.. toctree::
/servers/app_server/AppServer
/servers/app_server/ServerApp
/servers/app_server/SharedObject
/servers/app_server/TokenHandler
/servers/app_server/DebugTools
Graphics Management
.. toctree::
/servers/app_server/BitmapManager
/servers/app_server/ColorUtils
/servers/app_server/CursorManager
/servers/app_server/Decorator
/servers/app_server/Desktop
/servers/app_server/DesktopClasses
/servers/app_server/DisplayDriver
/servers/app_server/Layer
/servers/app_server/PatternHandler
/servers/app_server/RGBColor
/servers/app_server/ServerBitmap
/servers/app_server/SystemPalette
/servers/app_server/WinBorder
Font Infrastructure
.. toctree::
/servers/app_server/FontServer
/servers/app_server/FontFamily
Other Documents
~~~~~~~~~~~~~~~
.. toctree::
/servers/app_server/asis
- `Multiple Monitor Support Spec <MultiMonitor.htm>`__