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

424 lines
17 KiB
HTML
Raw Normal View History

<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>