Updated WinDecorator from proto7 API

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2650 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-02-07 18:37:12 +00:00
parent bbceccae40
commit f6c67f7d6c
21 changed files with 2677 additions and 503 deletions
+117 -12
View File
@@ -1,61 +1,166 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ColorSet.cpp
// Author: DarkWyrm <[email protected]>
// Description: Class for encapsulating GUI system colors
//
//
//------------------------------------------------------------------------------
#include <stdio.h>
#include "ColorSet.h"
//! Constructor which does nothing
ColorSet::ColorSet(void)
{
}
/*!
\brief Copy constructor which does a massive number of assignments
\param cs Color set to copy from
*/
ColorSet::ColorSet(const ColorSet &cs)
{
panel_background=cs.panel_background;
panel_text=cs.panel_text;
document_background=cs.document_background;
document_text=cs.document_text;
control_background=cs.control_background;
control_text=cs.control_text;
control_border=cs.control_border;
control_highlight=cs.control_highlight;
control_border=cs.control_border;
tooltip_background=cs.tooltip_background;
tooltip_text=cs.tooltip_text;
menu_background=cs.menu_background;
menu_selected_background=cs.menu_selected_background;
menu_text=cs.menu_text;
menu_selected_text=cs.menu_selected_text;
menu_separator_high=cs.menu_separator_high;
menu_separator_low=cs.menu_separator_low;
menu_triggers=cs.menu_triggers;
menu_selected_border=cs.menu_selected_border;
keyboard_navigation_base=cs.keyboard_navigation_base;
keyboard_navigation_pulse=cs.keyboard_navigation_pulse;
success=cs.success;
failure=cs.failure;
shine=cs.shine;
shadow=cs.shadow;
window_tab=cs.window_tab;
window_tab_text=cs.window_tab_text;
keyboard_navigation=cs.keyboard_navigation;
desktop=cs.desktop;
inactive_window_tab=cs.inactive_window_tab;
inactive_window_tab_text=cs.inactive_window_tab_text;
}
/*!
\brief Overloaded assignment operator which does a massive number of assignments
\param cs Color set to copy from
\return The new values assigned to the color set
*/
ColorSet & ColorSet::operator=(const ColorSet &cs)
{
SetColors(cs);
return *this;
}
/*!
\brief Copy function which handles assignments,
and, yes, *IT EVEN MAKES french fries!!*
\param cs Color set to copy from
*/
void ColorSet::SetColors(const ColorSet &cs)
{
panel_background=cs.panel_background;
panel_text=cs.panel_text;
document_background=cs.document_background;
document_text=cs.document_text;
control_background=cs.control_background;
control_text=cs.control_text;
control_border=cs.control_border;
control_highlight=cs.control_highlight;
control_border=cs.control_border;
tooltip_background=cs.tooltip_background;
tooltip_text=cs.tooltip_text;
menu_background=cs.menu_background;
menu_selected_background=cs.menu_selected_background;
menu_text=cs.menu_text;
menu_selected_text=cs.menu_selected_text;
menu_separator_high=cs.menu_separator_high;
menu_separator_low=cs.menu_separator_low;
menu_triggers=cs.menu_triggers;
menu_selected_border=cs.menu_selected_border;
keyboard_navigation_base=cs.keyboard_navigation_base;
keyboard_navigation_pulse=cs.keyboard_navigation_pulse;
success=cs.success;
failure=cs.failure;
shine=cs.shine;
shadow=cs.shadow;
window_tab=cs.window_tab;
window_tab_text=cs.window_tab_text;
keyboard_navigation=cs.keyboard_navigation;
desktop=cs.desktop;
inactive_window_tab=cs.inactive_window_tab;
inactive_window_tab_text=cs.inactive_window_tab_text;
}
/*!
\brief Prints all color set elements to stdout
*/
void ColorSet::PrintToStream(void)
{
printf("panel_background "); panel_background.PrintToStream();
printf("panel_text "); panel_text.PrintToStream();
printf("document_background "); document_background.PrintToStream();
printf("document_text "); document_text.PrintToStream();
printf("control_background "); control_background.PrintToStream();
printf("control_text "); control_text.PrintToStream();
printf("control_highlight "); control_highlight.PrintToStream();
printf("control_border "); control_border.PrintToStream();
printf("tooltip_background "); tooltip_background.PrintToStream();
printf("tooltip_text "); tooltip_text.PrintToStream();
printf("menu_background "); menu_background.PrintToStream();
printf("menu_selected_background "); menu_selected_background.PrintToStream();
printf("menu_text "); menu_text.PrintToStream();
printf("menu_selected_text "); menu_selected_text.PrintToStream();
printf("menu_selected_border "); menu_selected_border.PrintToStream();
printf("keyboard_navigation_base "); keyboard_navigation_base.PrintToStream();
printf("keyboard_navigation_pulse "); keyboard_navigation_pulse.PrintToStream();
printf("success "); success.PrintToStream();
printf("failure "); failure.PrintToStream();
printf("shine "); shine.PrintToStream();
printf("shadow "); shadow.PrintToStream();
printf("window_tab "); window_tab.PrintToStream();
printf("window_tab_text "); window_tab_text.PrintToStream();
printf("inactive_window_tab "); inactive_window_tab.PrintToStream();
printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream();
}
+51 -6
View File
@@ -1,8 +1,39 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ColorSet.h
// Author: DarkWyrm <[email protected]>
// Description: Class for encapsulating GUI system colors
//
//
//------------------------------------------------------------------------------
#ifndef COLORSET_H_
#define COLORSET_H_
#include "RGBColor.h"
/*!
\class ColorSet ColorSet.h
\brief Encapsulates GUI system colors
*/
class ColorSet
{
public:
@@ -10,28 +41,42 @@ public:
ColorSet(const ColorSet &cs);
ColorSet & operator=(const ColorSet &cs);
void SetColors(const ColorSet &cs);
void PrintToStream(void);
RGBColor panel_background,
panel_text,
document_background,
document_text,
control_background,
control_text,
control_border,
control_highlight,
control_border,
tooltip_background,
tooltip_text,
menu_background,
menu_selected_background,
menu_text,
menu_selected_text,
menu_separator_high,
menu_separator_low,
menu_triggers,
menu_selected_border,
keyboard_navigation_base,
keyboard_navigation_pulse,
success,
failure,
shine,
shadow,
// Not all of these guys don't exist in InterfaceDefs.h, but we keep
// them as part of the color set anyway - they're important nonetheless
window_tab,
window_tab_text,
keyboard_navigation,
desktop;
inactive_window_tab,
inactive_window_tab_text;
};
#endif
@@ -1,101 +0,0 @@
#include "ColorUtils.h"
#include <stdio.h>
#include <stdlib.h>
//#define DEBUG_COLOR_UTILS
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255)
{
col->red=r;
col->green=g;
col->blue=b;
col->alpha=a;
}
uint8 FindClosestColor(rgb_color *palette, rgb_color color)
{
// We will be passed a 256-color palette and a 24-bit color
uint16 cindex=0,cdelta=765,delta=765;
rgb_color *c;
for(uint16 i=0;i<256;i++)
{
c=&(palette[i]);
delta=abs(c->red-color.red)+abs(c->green-color.green)+
abs(c->blue-color.blue);
if(delta==0)
{
cindex=i;
break;
}
if(delta<cdelta)
{
cindex=i;
cdelta=delta;
}
}
#ifdef DEBUG_COLOR_UTILS
printf("FindClosestColor( {%u,%u,%u,%u} ) : {%u,%u,%u,%u}\n",
color.red,color.green,color.blue,color.alpha,
palette[cindex].red,palette[cindex].green,palette[cindex].blue,palette[cindex].alpha);
#endif
return (uint8)cindex;
}
uint16 FindClosestColor16(rgb_color color)
{
printf("FindClosestColor16 unimplemented\n");
return 0;
}
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)
{
rgb_color newcol={0,0,0,0};
float mod=0;
int16 delta;
if(position<0 || position>1)
return newcol;
delta=int16(col2.red)-int16(col.red);
mod=col.red + (position * delta);
newcol.red=uint8(mod);
if(mod>255 )
newcol.red=255;
if(mod<0 )
newcol.red=0;
delta=int16(col2.green)-int16(col.green);
mod=col.green + (position * delta);
newcol.green=uint8(mod);
if(mod>255 )
newcol.green=255;
if(mod<0 )
newcol.green=0;
delta=int16(col2.blue)-int16(col.blue);
mod=col.blue + (position * delta);
newcol.blue=uint8(mod);
if(mod>255 )
newcol.blue=255;
if(mod<0 )
newcol.blue=0;
delta=int8(col2.alpha)-int8(col.alpha);
mod=col.alpha + (position * delta);
newcol.alpha=uint8(mod);
if(mod>255 )
newcol.alpha=255;
if(mod<0 )
newcol.alpha=0;
#ifdef DEBUG_COLOR_UTILS
printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n",
col.red,col.green,col.blue,col.alpha,
col2.red,col2.green,col2.blue,col2.alpha,
position,
newcol.red,newcol.green,newcol.blue,newcol.alpha);
#endif
return newcol;
}
@@ -1,20 +0,0 @@
#ifndef COLORUTILS_H_
#define COLORUTILS_H_
#include <GraphicsDefs.h>
// Quick assignment for rgb_color structs
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255);
// Given a color palette, returns the index of the closest match to
// the color passed to it. Alpha values are not considered
uint8 FindClosestColor(rgb_color *palette, rgb_color color);
uint16 FindClosestColor16(rgb_color color);
// Function which could be used to calculate gradient colors. Position is
// a floating point number such that 0.0 <= position <= 1.0. Any number outside
// this range will cause the function to fail and return the color (0,0,0,0)
// Alpha components are included in the calculations. 0 yields color #1
// and 1 yields color #2.
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position);
#endif
+373 -74
View File
@@ -1,239 +1,538 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Decorator.cpp
// Author: DarkWyrm <[email protected]>
// Description: Base class for window decorators
//
//------------------------------------------------------------------------------
#include <Region.h>
#include "ColorSet.h"
#include "Decorator.h"
#include <string.h>
#include "DisplayDriver.h"
/*!
\brief Constructor
\param rect Size of client area
\param wlook style of window look. See Window.h
\param wfeel style of window feel. See Window.h
\param wflags various window flags. See Window.h
Does general initialization of internal data members and creates a colorset
object.
*/
Decorator::Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
{
close_state=false;
minimize_state=false;
zoom_state=false;
title_string=NULL;
driver=NULL;
_close_state=false;
_minimize_state=false;
_zoom_state=false;
_title_string=new BString;
_driver=NULL;
closerect.Set(0,0,1,1);
zoomrect.Set(0,0,1,1);
minimizerect.Set(0,0,1,1);
resizerect.Set(0,0,1,1);
frame=rect;
tabrect.Set(rect.left,rect.top,rect.right, rect.top+((rect.bottom-rect.top)/4));
_closerect.Set(0,0,1,1);
_zoomrect.Set(0,0,1,1);
_minimizerect.Set(0,0,1,1);
_resizerect.Set(0,0,1,1);
_frame=rect;
_tabrect.Set(rect.left,rect.top,rect.right, rect.top+((rect.bottom-rect.top)/4));
look=wlook;
feel=wfeel;
flags=wflags;
_look=wlook;
_feel=wfeel;
_flags=wflags;
colors=new ColorSet();
_colors=new ColorSet();
}
/*!
\brief Destructor
Frees the color set and the title string
*/
Decorator::~Decorator(void)
{
if(colors!=NULL)
if(_colors!=NULL)
{
delete colors;
colors=NULL;
delete _colors;
_colors=NULL;
}
if(title_string)
delete title_string;
if(_title_string)
delete _title_string;
}
void Decorator::SetColors(ColorSet cset)
/*!
\brief Updates the decorator's color set
\param cset The color set to update from
*/
void Decorator::SetColors(const ColorSet &cset)
{
colors->SetColors(cset);
if(_colors)
_colors->SetColors(cset);
}
void Decorator::SetDriver(DisplayDriver *d)
/*!
\brief Assigns a display driver to the decorator
\param driver A valid DisplayDriver object
*/
void Decorator::SetDriver(DisplayDriver *driver)
{
driver=d;
// lots of subclasses will depend on the driver for text support, so call
// _DoLayout() after this
_driver=driver;
_DoLayout();
}
/*!
\brief Sets the close button's value.
\param is_down Whether the button is down or not
Note that this does not update the button's look - it just updates the
internal button value
*/
void Decorator::SetClose(bool is_down)
{
close_state=is_down;
_close_state=is_down;
}
/*!
\brief Sets the minimize button's value.
\param is_down Whether the button is down or not
Note that this does not update the button's look - it just updates the
internal button value
*/
void Decorator::SetMinimize(bool is_down)
{
zoom_state=is_down;
_zoom_state=is_down;
}
/*!
\brief Sets the zoom button's value.
\param is_down Whether the button is down or not
Note that this does not update the button's look - it just updates the
internal button value
*/
void Decorator::SetZoom(bool is_down)
{
minimize_state=is_down;
_minimize_state=is_down;
}
/*!
\brief Sets the decorator's window flags
\param wflags New value for the flags
While this call will not update the screen, it will affect how future
updates work and immediately affects input handling.
*/
void Decorator::SetFlags(int32 wflags)
{
flags=wflags;
_flags=wflags;
}
/*!
\brief Sets the decorator's window feel
\param wflags New value for the feel
While this call will not update the screen, it will affect how future
updates work and immediately affects input handling.
*/
void Decorator::SetFeel(int32 wfeel)
{
feel=wfeel;
_feel=wfeel;
}
/*!
\brief Sets the decorator's window look
\param wflags New value for the look
While this call will not update the screen, it will affect how future
updates work and immediately affects input handling.
*/
void Decorator::SetLook(int32 wlook)
{
look=wlook;
_look=wlook;
}
/*!
\brief Returns the value of the close button
\return true if down, false if up
*/
bool Decorator::GetClose(void)
{
return close_state;
return _close_state;
}
/*!
\brief Returns the value of the minimize button
\return true if down, false if up
*/
bool Decorator::GetMinimize(void)
{
return minimize_state;
return _minimize_state;
}
/*!
\brief Returns the value of the zoom button
\return true if down, false if up
*/
bool Decorator::GetZoom(void)
{
return zoom_state;
return _zoom_state;
}
/*!
\brief Returns the decorator's window look
\return the decorator's window look
*/
int32 Decorator::GetLook(void)
{
return look;
return _look;
}
/*!
\brief Returns the decorator's window feel
\return the decorator's window feel
*/
int32 Decorator::GetFeel(void)
{
return feel;
return _feel;
}
/*!
\brief Returns the decorator's window flags
\return the decorator's window flags
*/
int32 Decorator::GetFlags(void)
{
return flags;
return _flags;
}
/*!
\brief Updates the value of the decorator title
\param string New title value
*/
void Decorator::SetTitle(const char *string)
{
if(string)
{
size_t size=strlen(string);
if(!(size>0))
return;
delete title_string;
title_string=new char[size];
strcpy(title_string,string);
}
else
{
delete title_string;
title_string=NULL;
}
_title_string->SetTo(string);
}
/*!
\brief Returns the decorator's title
\return the decorator's title
*/
const char *Decorator::GetTitle(void)
{
return title_string;
return _title_string->String();
}
/*!
\brief Changes the focus value of the decorator
\param is_active True if active, false if not
While this call will not update the screen, it will affect how future
updates work.
*/
void Decorator::SetFocus(bool is_active)
{
has_focus=is_active;
_has_focus=is_active;
_SetFocus();
}
/*
void Decorator::SetFont(SFont *sf)
{
}
/*!
\brief Provides the number of characters that will fit in the given width
\param width Maximum number of pixels the title can be
\return the number of characters that will fit in the given width
*/
void Decorator::_ClipTitle(void)
int32 Decorator::_ClipTitle(float width)
{
if(_driver)
{
int32 strlength=_title_string->CountChars();
float pixwidth=_driver->StringWidth(_title_string->String(),strlength,&_layerdata);
while(strlength>=0)
{
if(pixwidth<width)
break;
strlength--;
pixwidth=_driver->StringWidth(_title_string->String(),strlength,&_layerdata);
}
return strlength;
}
return 0;
}
//-------------------------------------------------------------------------
// Virtual Methods
//-------------------------------------------------------------------------
/*!
\brief Moves the decorator frame and all default rectangles
\param x X Offset
\param y y Offset
If a subclass implements this method, be sure to call Decorator::MoveBy
to ensure that internal members are also updated. All members of the Decorator
class are automatically moved in this method
*/
void Decorator::MoveBy(float x, float y)
{
_zoomrect.OffsetBy(x,y);
_closerect.OffsetBy(x,y);
_minimizerect.OffsetBy(x,y);
_minimizerect.OffsetBy(x,y);
_tabrect.OffsetBy(x,y);
_frame.OffsetBy(x,y);
_resizerect.OffsetBy(x,y);
_borderrect.OffsetBy(x,y);
}
/*!
\brief Moves the decorator frame and all default rectangles
\param pt Point containing the offsets
If a subclass implements this method, be sure to call Decorator::MoveBy
to ensure that internal members are also updated. All members of the Decorator
class are automatically moved in this method
*/
void Decorator::MoveBy(BPoint pt)
{
MoveBy(pt.x,pt.y);
}
/*!
\brief Moves the tab by the specified amount
\param dx x offset
\param dy y offset
\return The new tab rectangle.
Slides the tab by the x or y value. This function is not required to be
implemented by subclasses. Note that the tab rectangle returned does not
necessarily reflect _tabrect offset by the amount given - few people want to
slide a tab right off the window - that would be a Bad Thing (TM).
*/
BRect Decorator::SlideTab(float dx, float dy=0)
{
return BRect(0,0,0,0);
}
/*!
\brief Resizes the decorator frame
\param dx x offset
\param dy y offset
This is a required function for subclasses to implement - the default does nothing.
Note that window resize flags should be followed and _frame should be resized
accordingly. It would also be a wise idea to ensure that the window's rectangles
are not inverted.
*/
void Decorator::ResizeBy(float x, float y)
{
}
/*!
\brief Resizes the decorator frame
\param pt Point containing the offsets
This is a required function for subclasses to implement - the default does nothing.
Note that window resize flags should be followed and _frame should be resized
accordingly. It would also be a wise idea to ensure that the window's rectangles
are not inverted.
*/
void Decorator::ResizeBy(BPoint pt)
{
}
/*!
\brief Updates the decorator's look in the area r
\param r The area to update.
The default version updates all areas which intersect the frame and tab.
*/
void Decorator::Draw(BRect r)
{
_DrawTab(r & tabrect);
_DrawFrame(r & frame);
_DrawTab(r & _tabrect);
_DrawFrame(r & _frame);
}
//! Forces a complete decorator update
void Decorator::Draw(void)
{
_DrawTab(tabrect);
_DrawFrame(frame);
_DrawTab(_tabrect);
_DrawFrame(_frame);
}
//! Draws the close button
void Decorator::DrawClose(void)
{
_DrawClose(closerect);
_DrawClose(_closerect);
}
//! draws the frame
void Decorator::DrawFrame(void)
{
_DrawFrame(frame);
_DrawFrame(_frame);
}
//! draws the minimize button
void Decorator::DrawMinimize(void)
{
_DrawTab(minimizerect);
_DrawTab(_minimizerect);
}
//! draws the tab, title, and buttons
void Decorator::DrawTab(void)
{
_DrawTab(tabrect);
_DrawZoom(zoomrect);
_DrawMinimize(minimizerect);
_DrawTitle(tabrect);
_DrawClose(closerect);
_DrawTab(_tabrect);
_DrawZoom(_zoomrect);
_DrawMinimize(_minimizerect);
_DrawTitle(_tabrect);
_DrawClose(_closerect);
}
// draws the title
void Decorator::DrawTitle(void)
{
_DrawTitle(tabrect);
_DrawTitle(_tabrect);
}
//! draws the zoom button
void Decorator::DrawZoom(void)
{
_DrawZoom(zoomrect);
_DrawZoom(_zoomrect);
}
/*!
\brief Actually draws the close button
\param r Area of the button to update
Unless a subclass has a particularly large button, it is probably unnecessary
to check the update rectangle.
*/
void Decorator::_DrawClose(BRect r)
{
}
/*!
\brief Actually draws the frame
\param r Area of the frame to update
*/
void Decorator::_DrawFrame(BRect r)
{
}
/*!
\brief Actually draws the minimize button
\param r Area of the button to update
Unless a subclass has a particularly large button, it is probably unnecessary
to check the update rectangle.
*/
void Decorator::_DrawMinimize(BRect r)
{
}
/*!
\brief Actually draws the tab
\param r Area of the tab to update
This function is called when the tab itself needs drawn. Other items, like the
window title or buttons, should not be drawn here.
*/
void Decorator::_DrawTab(BRect r)
{
}
/*!
\brief Actually draws the title
\param r area of the title to update
The main tasks for this function are to ensure that the decorator draws the title
only in its own area and drawing the title itself. Using B_OP_COPY for drawing
the title is recommended because of the marked performance hit of the other
drawing modes, but it is not a requirement.
*/
void Decorator::_DrawTitle(BRect r)
{
}
/*!
\brief Actually draws the zoom button
\param r Area of the button to update
Unless a subclass has a particularly large button, it is probably unnecessary
to check the update rectangle.
*/
void Decorator::_DrawZoom(BRect r)
{
}
/*
SRegion Decorator::GetFootprint(void)
/*!
\brief Returns the "footprint" of the entire window, including decorator
\return Region representing the window's screen footprint
This function should generate a new BRegion allocated on the heap which represents
the entire area occupied by the window decorator on the screen. For example, a BeOS
decorator would return _tabrect + _borderrect.
This function is required by all subclasses.
*/
BRegion *Decorator::GetFootprint(void)
{
return NULL;
}
/*!
\brief Performs hit-testing for the decorator
\return The type of area clicked
Clicked is called whenever it has been determined that the window has received a
mouse click. The default version returns CLICK_NONE. A subclass may use any or all
of them.
Click type : Action taken by the server
- \c CLICK_NONE : Do nothing
- \c CLICK_ZOOM : Handles the zoom button (setting states, etc)
- \c CLICK_CLOSE : Handles the close button (setting states, etc)
- \c CLICK_MINIMIZE : Handles the minimize button (setting states, etc)
- \c CLICK_TAB : Currently unused
- \c CLICK_DRAG : Moves the window to the front and prepares to move the window
- \c CLICK_MOVETOBACK : Moves the window to the back of the stack
- \c CLICK_MOVETOFRONT : Moves the window to the front of the stack
- \c CLICK_SLIDETAB : Initiates tab-sliding, including calling SlideTab()
- \c CLICK_RESIZE : Handle window resizing as appropriate
- \c CLICK_RESIZE_L
- \c CLICK_RESIZE_T
- \c CLICK_RESIZE_R
- \c CLICK_RESIZE_B
- \c CLICK_RESIZE_LT
- \c CLICK_RESIZE_RT
- \c CLICK_RESIZE_LB
- \c CLICK_RESIZE_RB
This function is required by all subclasses.
*/
click_type Decorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
+72 -64
View File
@@ -1,87 +1,89 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Decorator.h
// Author: DarkWyrm <[email protected]>
// Description: Base class for window decorators
//
//------------------------------------------------------------------------------
#ifndef _DECORATOR_H_
#define _DECORATOR_H_
#include <SupportDefs.h>
#include <Rect.h>
#include "ColorSet.h"
#include <Region.h>
#include <String.h>
#include <Window.h>
#include "LayerData.h"
#include "ColorSet.h"
class DisplayDriver;
typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE,
CLICK_TAB, CLICK_DRAG, CLICK_MOVETOBACK, CLICK_MOVETOFRONT,
CLICK_TAB, CLICK_DRAG, CLICK_MOVETOBACK, CLICK_MOVETOFRONT, CLICK_SLIDETAB,
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 } click_type;
// Definitions which are used in place of including Window.h
// window_look and window_feel are enumerated types, so we convert them
// to uint32's in order to ensure a constant size when sending via PortLink
// instead of depending on magic numbers in the header file.
#define WLOOK_NO_BORDER 0
#define WLOOK_BORDERED 1
#define WLOOK_TITLED 2
#define WLOOK_DOCUMENT 3
#define WLOOK_MODAL 4
#define WLOOK_FLOATING 5
#define WFEEL_NORMAL 0
#define WFEEL_MODAL_SUBSET 1
#define WFEEL_MODAL_APP 2
#define WFEEL_MODAL_WINDOW 3
#define WFEEL_FLOATING_SUBSET 4
#define WFEEL_FLOATING_APP 5
#define WFEEL_FLOATING_WINDOW 6
#define NOT_MOVABLE 0x00000001
#define NOT_CLOSABLE 0x00000020
#define NOT_ZOOMABLE 0x00000040
#define NOT_MINIMIZABLE 0x00004000
#define NOT_RESIZABLE 0x00000002
#define NOT_H_RESIZABLE 0x00000004
#define NOT_V_RESIZABLE 0x00000008
#define AVOID_FRONT 0x00000080
#define AVOID_FOCUS 0x00002000
#define WILL_ACCEPT_FIRST_CLICK 0x00000010
#define OUTLINE_RESIZE 0x00001000
#define NO_WORKSPACE_ACTIVATION 0x00000100
#define NOT_ANCHORED_ON_ACTIVATE 0x00020000
#define ASYNCHRONOUS_CONTROLS 0x00080000
#define QUIT_ON_WINDOW_CLOSE 0x00100000
class Decorator
{
public:
Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags);
virtual ~Decorator(void);
void SetColors(ColorSet cset);
void SetDriver(DisplayDriver *d);
void SetClose(bool is_down);
void SetMinimize(bool is_down);
void SetZoom(bool is_down);
void SetColors(const ColorSet &cset);
void SetDriver(DisplayDriver *driver);
void SetFlags(int32 wflags);
void SetFeel(int32 wfeel);
void SetLook(int32 wlook);
bool GetClose(void);
bool GetMinimize(void);
bool GetZoom(void);
void SetClose(bool is_down);
void SetMinimize(bool is_down);
void SetZoom(bool is_down);
virtual void SetTitle(const char *string);
int32 GetLook(void);
int32 GetFeel(void);
int32 GetFlags(void);
void SetTitle(const char *string);
void SetFocus(bool is_active);
bool GetFocus(void) { return has_focus; };
const char *GetTitle(void);
// void SetFont(SFont *sf);
void _ClipTitle(void);
ColorSet GetColors(void) { if(colors) return *colors; else return ColorSet(); }
bool GetClose(void);
bool GetMinimize(void);
bool GetZoom(void);
void SetFocus(bool is_active);
bool GetFocus(void) { return _has_focus; };
ColorSet GetColors(void) { return (_colors)?*_colors:ColorSet(); }
virtual BRect SlideTab(float dx, float dy=0);
virtual BRegion *GetFootprint(void);
virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
virtual void MoveBy(float x, float y);
virtual void MoveBy(BPoint pt);
virtual void ResizeBy(float x, float y);
virtual void ResizeBy(BPoint pt);
virtual void Draw(BRect r);
virtual void Draw(void);
virtual void DrawClose(void);
@@ -90,10 +92,11 @@ public:
virtual void DrawTab(void);
virtual void DrawTitle(void);
virtual void DrawZoom(void);
//virtual SRegion GetFootprint(void);
virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected:
int32 _ClipTitle(float width);
int32 _TitleWidth(void) { return (_title_string)?_title_string->CountChars():0; }
virtual void _DrawClose(BRect r);
virtual void _DrawFrame(BRect r);
virtual void _DrawMinimize(BRect r);
@@ -102,16 +105,21 @@ protected:
virtual void _DrawZoom(BRect r);
virtual void _SetFocus(void)=0;
virtual void _DoLayout(void)=0;
ColorSet *colors;
int32 look, feel, flags;
DisplayDriver *driver;
LayerData layerdata;
BRect zoomrect,closerect,minimizerect,tabrect,frame,
resizerect,borderrect;
ColorSet *_colors;
DisplayDriver *_driver;
LayerData _layerdata;
int32 _look, _feel, _flags;
BRect _zoomrect,_closerect,_minimizerect,_tabrect,_frame,
_resizerect,_borderrect;
private:
bool close_state, zoom_state, minimize_state;
bool has_focus;
char *title_string;
bool _close_state, _zoom_state, _minimize_state;
bool _has_focus;
BString *_title_string;
};
typedef float get_version(void);
typedef Decorator *create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags);
#endif
@@ -1,85 +1,712 @@
/*
DisplayDriver.cpp
Modular class to allow the server to not care what the ultimate output is
for graphics calls.
*/
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: DisplayDriver.cpp
// Author: DarkWyrm <[email protected]>
// Description: Mostly abstract class which handles all graphics output
// for the server
//
//------------------------------------------------------------------------------
#include "DisplayDriver.h"
#include "LayerData.h"
#include "ServerCursor.h"
/*!
\brief Sets up internal variables needed by all DisplayDriver subclasses
Subclasses should follow DisplayDriver's lead and use this function mostly
for initializing data members.
*/
DisplayDriver::DisplayDriver(void)
{
lock_sem=create_sem(1,"displaydriver_lock");
buffer_depth=0;
buffer_width=0;
buffer_height=0;
buffer_mode=-1;
_lock_sem=create_sem(1,"DisplayDriver Lock");
_buffer_depth=0;
_buffer_width=0;
_buffer_height=0;
_buffer_mode=-1;
_is_cursor_hidden=false;
_is_cursor_obscured=false;
_cursor=NULL;
}
/*!
\brief Deletes the locking semaphore
Subclasses should use the destructor mostly for freeing allocated heap space.
*/
DisplayDriver::~DisplayDriver(void)
{
delete_sem(lock_sem);
delete_sem(_lock_sem);
}
/*!
\brief Initializes the driver object.
\return true if successful, false if not
Initialize sets up the driver for display, including the initial clearing
of the screen. If things do not go as they should, false should be returned.
*/
bool DisplayDriver::Initialize(void)
{
return false;
}
uint8 DisplayDriver::GetDepth(void)
/*!
\brief Shuts down the driver's video subsystem
Any work done by Initialize() should be undone here. Note that Shutdown() is
called even if Initialize() was unsuccessful.
*/
void DisplayDriver::Shutdown(void)
{
return buffer_depth;
}
uint16 DisplayDriver::GetHeight(void)
/*!
\brief Called for all BView::CopyBits calls
\param src Source rectangle.
\param dest Destination rectangle.
Bounds checking must be done in this call. If the destination is not the same size
as the source, the source should be scaled to fit.
*/
void DisplayDriver::CopyBits(BRect src, BRect dest)
{
return buffer_height;
}
uint16 DisplayDriver::GetWidth(void)
/*!
\brief Called for all BView::DrawBitmap calls
\param bmp Bitmap to be drawn. It will always be non-NULL and valid. The color
space is not guaranteed to match.
\param src Source rectangle
\param dest Destination rectangle. Source will be scaled to fit if not the same size.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
Bounds checking must be done in this call.
*/
void DisplayDriver::DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d)
{
return buffer_width;
}
int32 DisplayDriver::GetMode(void)
/*!
\brief Utilizes the font engine to draw a string to the frame buffer
\param string String to be drawn. Always non-NULL.
\param length Number of characters in the string to draw. Always greater than 0. If greater
than the number of characters in the string, draw the entire string.
\param pt Point at which the baseline starts. Characters are to be drawn 1 pixel above
this for backwards compatibility. While the point itself is guaranteed to be inside
the frame buffers coordinate range, the clipping of each individual glyph must be
performed by the driver itself.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
*/
void DisplayDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL)
{
return buffer_mode;
}
/*!
\brief Called for all BView::FillArc calls
\param r Rectangle enclosing the entire arc
\param angle Starting angle for the arc in degrees
\param span Span of the arc in degrees. Ending angle = angle+span.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the arc may end up
being clipped.
*/
void DisplayDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::FillBezier calls.
\param pts 4-element array of BPoints in the order of start, end, and then the two control
points.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call.
*/
void DisplayDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::FillEllipse calls
\param r BRect enclosing the ellipse to be drawn.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the ellipse may end up
being clipped.
*/
void DisplayDriver::FillEllipse(BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::FillPolygon calls
\param ptlist Array of BPoints defining the polygon.
\param numpts Number of points in the BPoint array.
\param rect Rectangle which contains the polygon
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
The points in the array are not guaranteed to be within the framebuffer's
coordinate range.
*/
void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::FillRect calls
\param r BRect to be filled. Guaranteed to be in the frame buffer's coordinate space
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
*/
void DisplayDriver::FillRect(BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::FillRoundRect calls
\param r The rectangle itself
\param xrad X radius of the corner arcs
\param yrad Y radius of the corner arcs
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the roundrect may end
up being clipped.
*/
void DisplayDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)
{
}
//void DisplayDriver::FillShape(SShape *sh, LayerData *d, int8 *pat)
//{
//}
/*!
\brief Called for all BView::FillTriangle calls
\param pts Array of 3 BPoints. Always non-NULL.
\param r BRect enclosing the triangle. While it will definitely enclose the triangle,
it may not be within the frame buffer's bounds.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the triangle may end
up being clipped.
*/
void DisplayDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Hides the cursor.
Hide calls are not nestable, unlike that of the BApplication class. Subclasses should
call _SetCursorHidden(true) somewhere within this function to ensure that data is
maintained accurately. Subclasses must include a call to DisplayDriver::HideCursor
for proper state tracking.
*/
void DisplayDriver::HideCursor(void)
{
_is_cursor_hidden=true;
}
/*!
\brief Returns whether the cursor is visible or not.
\return true if hidden or obscured, false if not.
*/
bool DisplayDriver::IsCursorHidden(void)
{
_Lock();
bool value=(_is_cursor_hidden || _is_cursor_obscured);
_Unlock();
return value;
}
/*!
\brief Moves the cursor to the given point.
The coordinates passed to MoveCursorTo are guaranteed to be within the frame buffer's
range, but the cursor data itself will need to be clipped. A check to see if the
cursor is obscured should be made and if so, a call to _SetCursorObscured(false)
should be made the cursor in addition to displaying at the passed coordinates.
*/
void DisplayDriver::MoveCursorTo(float x, float y)
{
}
/*!
\brief Inverts the colors in the rectangle.
\param r Rectangle of the area to be inverted. Guaranteed to be within bounds.
*/
void DisplayDriver::InvertRect(BRect r)
{
}
/*!
\brief Shows the cursor.
Show calls are not nestable, unlike that of the BApplication class. Subclasses should
call _SetCursorHidden(false) somewhere within this function to ensure that data is
maintained accurately. Subclasses must call DisplayDriver::ShowCursor at some point
to ensure proper state tracking.
*/
void DisplayDriver::ShowCursor(void)
{
_is_cursor_hidden=false;
_is_cursor_obscured=false;
}
/*!
\brief Obscures the cursor.
Obscure calls are not nestable. Subclasses should call DisplayDriver::ObscureCursor
somewhere within this function to ensure that data is maintained accurately. A check
will be made by the system before the next MoveCursorTo call to show the cursor if
it is obscured.
*/
void DisplayDriver::ObscureCursor(void)
{
_is_cursor_obscured=true;
}
/*!
\brief Changes the cursor.
\param cursor The new cursor. Guaranteed to be non-NULL.
The driver does not take ownership of the given cursor. Subclasses should make
a copy of the cursor passed to it. The default version of this function hides the
cursory, replaces it, and shows the cursor if previously visible.
*/
void DisplayDriver::SetCursor(ServerCursor *cursor)
{
_Lock();
bool hidden=_is_cursor_hidden;
bool obscured=_is_cursor_obscured;
if(_cursor)
delete _cursor;
_cursor=new ServerCursor(cursor);
if(!hidden && !obscured)
ShowCursor();
_Unlock();
}
/*!
\brief Called for all BView::StrokeArc calls
\param r Rectangle enclosing the entire arc
\param angle Starting angle for the arc in degrees
\param span Span of the arc in degrees. Ending angle = angle+span.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the arc may end up
being clipped.
*/void DisplayDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::StrokeBezier calls.
\param pts 4-element array of BPoints in the order of start, end, and then the two control
points.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call.
*/
void DisplayDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::StrokeEllipse calls
\param r BRect enclosing the ellipse to be drawn.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the ellipse may end up
being clipped.
*/
void DisplayDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Draws a line. Really.
\param start Starting point
\param end Ending point
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
The endpoints themselves are guaranteed to be in bounds, but clipping for lines with
a thickness greater than 1 will need to be done.
*/
void DisplayDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::StrokePolygon calls
\param ptlist Array of BPoints defining the polygon.
\param numpts Number of points in the BPoint array.
\param rect Rectangle which contains the polygon
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
The points in the array are not guaranteed to be within the framebuffer's
coordinate range.
*/
void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true)
{
}
/*!
\brief Called for all BView::StrokeRect calls
\param r BRect to be filled. Guaranteed to be in the frame buffer's coordinate space
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
*/
void DisplayDriver::StrokeRect(BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Called for all BView::StrokeRoundRect calls
\param r The rect itself
\param xrad X radius of the corner arcs
\param yrad Y radius of the corner arcs
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the roundrect may end
up being clipped.
*/
void DisplayDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)
{
}
//void DisplayDriver::StrokeShape(SShape *sh, LayerData *d, int8 *pat)
//{
//}
/*!
\brief Called for all BView::StrokeTriangle calls
\param pts Array of 3 BPoints. Always non-NULL.
\param r BRect enclosing the triangle. While it will definitely enclose the triangle,
it may not be within the frame buffer's bounds.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
Bounds checking must be done in this call because only part of the triangle may end
up being clipped.
*/
void DisplayDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Draws a series of lines - optimized for speed
\param pts Array of BPoints pairs
\param numlines Number of lines to be drawn
\param colors Array of colors for each respective line
\param d Data structure containing any other data necessary for the call. Always non-NULL.
Data for this call is passed directly from userland - this call is responsible for all
checking. All lines are to be processed in the call using the same LayerData settings
for each line.
*/
void DisplayDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)
{
}
/*!
\brief Sets the screen mode to specified resolution and color depth.
\param mode constant as defined in GraphicsDefs.h
Subclasses must include calls to _SetDepth, _SetHeight, _SetWidth, and _SetMode
to update the state variables kept internally by the DisplayDriver class.
*/
void DisplayDriver::SetMode(int32 mode)
{
}
/*!
\brief Dumps the contents of the frame buffer to a file.
\param path Path and leaf of the file to be created without an extension
\return False if unimplemented or unsuccessful. True if otherwise.
Subclasses should add an extension based on what kind of file is saved
*/
bool DisplayDriver::DumpToFile(const char *path)
{
return false;
}
//---------------------------------------------------------
// Private Methods
//---------------------------------------------------------
void DisplayDriver::Lock(void)
/*!
\brief Gets the width of a string in pixels
\param string Source null-terminated string
\param length Number of characters in the string
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\return Width of the string in pixels
This corresponds to BView::StringWidth.
*/
float DisplayDriver::StringWidth(const char *string, int32 length, LayerData *d)
{
acquire_sem(lock_sem);
return 0.0;
}
void DisplayDriver::Unlock(void)
/*!
\brief Gets the height of a string in pixels
\param string Source null-terminated string
\param length Number of characters in the string
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\return Height of the string in pixels
The height calculated in this function does not include any padding - just the
precise maximum height of the characters within and does not necessarily equate
with a font's height, i.e. the strings 'case' and 'alps' will have different values
even when called with all other values equal.
*/
float DisplayDriver::StringHeight(const char *string, int32 length, LayerData *d)
{
release_sem(lock_sem);
return 0.0;
}
void DisplayDriver::SetDepthInternal(uint8 d)
/*!
\brief Retrieves the bounding box each character in the string
\param string Source null-terminated string
\param count Number of characters in the string
\param mode Metrics mode for either screen or printing
\param delta Optional glyph padding. This value may be NULL.
\param rectarray Array of BRect objects which will have at least count elements
\param d Data structure containing any other data necessary for the call. Always non-NULL.
See BFont::GetBoundingBoxes for more details on this function.
*/
void DisplayDriver::GetBoundingBoxes(const char *string, int32 count,
font_metric_mode mode, escapement_delta *delta, BRect *rectarray, LayerData *d)
{
buffer_depth=d;
}
void DisplayDriver::SetHeightInternal(uint16 h)
/*!
\brief Retrieves the escapements for each character in the string
\param string Source null-terminated string
\param charcount Number of characters in the string
\param delta Optional glyph padding. This value may be NULL.
\param escapements Array of escapement_delta objects which will have at least charcount elements
\param offsets Actual offset values when iterating over the string. This array will also
have at least charcount elements and the values placed therein will reflect
the current kerning/spacing mode.
\param d Data structure containing any other data necessary for the call. Always non-NULL.
See BFont::GetEscapements for more details on this function.
*/
void DisplayDriver::GetEscapements(const char *string, int32 charcount,
escapement_delta *delta, escapement_delta *escapements, escapement_delta *offsets, LayerData *d)
{
buffer_height=h;
}
void DisplayDriver::SetWidthInternal(uint16 w)
/*!
\brief Retrieves the inset values of each glyph from its escapement values
\param string Source null-terminated string
\param charcount Number of characters in the string
\param edgearray Array of edge_info objects which will have at least charcount elements
\param d Data structure containing any other data necessary for the call. Always non-NULL.
See BFont::GetEdges for more details on this function.
*/
void DisplayDriver::GetEdges(const char *string, int32 charcount, edge_info *edgearray, LayerData *d)
{
buffer_width=w;
}
void DisplayDriver::SetModeInternal(int32 m)
/*!
\brief Determines whether a font contains a certain string of characters
\param string Source null-terminated string
\param charcount Number of characters in the string
\param hasarray Array of booleans which will have at least charcount elements
See BFont::GetHasGlyphs for more details on this function.
*/
void DisplayDriver::GetHasGlyphs(const char *string, int32 charcount, bool *hasarray)
{
buffer_mode=m;
}
/*!
\brief Truncates an array of strings to a certain width
\param instrings Array of null-terminated strings
\param stringcount Number of strings passed to the function
\param mode Truncation mode
\param maxwidth Maximum width for all strings
\param outstrings String array provided by the caller into which the truncated strings are
to be placed.
See BFont::GetTruncatedStrings for more details on this function.
*/
void DisplayDriver::GetTruncatedStrings( const char **instrings, int32 stringcount,
uint32 mode, float maxwidth, char **outstrings)
{
}
/*!
\brief Returns the bit depth for the current screen mode
\return Current number of bits per pixel
*/
uint8 DisplayDriver::GetDepth(void)
{
return _buffer_depth;
}
/*!
\brief Returns the height for the current screen mode
\return Height of the screen
*/
uint16 DisplayDriver::GetHeight(void)
{
return _buffer_height;
}
/*!
\brief Returns the width for the current screen mode
\return Width of the screen
*/
uint16 DisplayDriver::GetWidth(void)
{
return _buffer_width;
}
/*!
\brief Returns the screen mode constant in use by the driver
\return Current screen mode
*/
int32 DisplayDriver::GetMode(void)
{
return _buffer_mode;
}
/*!
\brief Returns whether or not the cursor is currently obscured
\return True if obscured, false if not.
*/
bool DisplayDriver::IsCursorObscured(bool state)
{
return _is_cursor_obscured;
}
// Protected Internal Functions
/*!
\brief Locks the driver
\param timeout Optional timeout specifier
\return True if the lock was successful, false if not.
The return value need only be checked if a timeout was specified. Each public
member function should lock the driver before doing anything else. Functions
internal to the driver (protected/private) need not do this.
*/
bool DisplayDriver::_Lock(bigtime_t timeout)
{
if(acquire_sem_etc(_lock_sem,1,B_RELATIVE_TIMEOUT,timeout)!=B_NO_ERROR)
return false;
return true;
}
/*!
\brief Unlocks the driver
*/
void DisplayDriver::_Unlock(void)
{
release_sem(_lock_sem);
}
/*!
\brief Internal depth-setting function
\param d Number of bits per pixel in use
_SetDepth must be called from within any implementation of SetMode
*/
void DisplayDriver::_SetDepth(uint8 d)
{
_buffer_depth=d;
}
/*!
\brief Internal height-setting function
\param h Height of the frame buffer
_SetHeight must be called from within any implementation of SetMode
*/
void DisplayDriver::_SetHeight(uint16 h)
{
_buffer_height=h;
}
/*!
\brief Internal width-setting function
\param w Width of the frame buffer
_SetWidth must be called from within any implementation of SetMode
*/
void DisplayDriver::_SetWidth(uint16 w)
{
_buffer_width=w;
}
/*!
\brief Internal mode-setting function.
\param m Screen mode in use as defined in GraphicsDefs.h
_SetMode must be called from within any implementation of SetMode. Note that this
does not actually change the screen mode; it just updates the state variable used
to talk with the outside world.
*/
void DisplayDriver::_SetMode(int32 m)
{
_buffer_mode=m;
}
/*!
\brief Obtains the current cursor for the driver.
\return Pointer to the current cursor object.
Do NOT delete this pointer - change pointers via SetCursor. This call will be
necessary for blitting the cursor to the screen and other such tasks.
*/
ServerCursor *DisplayDriver::_GetCursor(void)
{
return _cursor;
}
@@ -1,21 +1,52 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: DisplayDriver.h
// Author: DarkWyrm <[email protected]>
// Description: Mostly abstract class which handles all graphics output
// for the server
//
//------------------------------------------------------------------------------
#ifndef _DISPLAY_DRIVER_H_
#define _DISPLAY_DRIVER_H_
#include <GraphicsCard.h>
#include <SupportDefs.h>
#include <OS.h>
#include <View.h>
#include <Font.h>
#include <Rect.h>
#include "RGBColor.h"
class ServerBitmap;
class ServerCursor;
class ServerBitmap;
class LayerData;
#ifndef ROUND
#define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a))
#endif
/*!
\brief Data structure for passing cursor information to hardware drivers.
*/
typedef struct
{
uchar *xormask, *andmask;
@@ -44,17 +75,18 @@ typedef struct
#endif
#define DRAW_COPY 0
#define DRAW_OVER 1
#define DRAW_ERASE 2
#define DRAW_INVERT 3
#define DRAW_ADD 4
#define DRAW_SUBTRACT 5
#define DRAW_BLEND 6
#define DRAW_MIN 7
#define DRAW_MAX 8
#define DRAW_SELECT 9
#define DRAW_ALPHA 10
/*!
\class DisplayDriver DisplayDriver.h
\brief Mostly abstract class which handles all graphics output for the server.
The DisplayDriver is called in order to handle all messiness associated with
a particular rendering context, such as the screen, and the methods to
handle organizing information related to it along with writing to the context
itself.
While all virtual functions are technically optional, the default versions
do very little, so implementing them all more or less required.
*/
class DisplayDriver
{
@@ -62,53 +94,77 @@ public:
DisplayDriver(void);
virtual ~DisplayDriver(void);
virtual bool Initialize(void);
virtual void Shutdown(void)=0;
virtual void CopyBits(BRect src, BRect dest)=0;
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest)=0;
virtual void DrawChar(char c, BPoint pt)=0;
// virtual void DrawPicture(SPicture *pic, BPoint pt)=0;
// virtual void DrawString(const char *string, int32 length, BPoint pt, escapement_delta *delta=NULL)=0;
virtual void InvertRect(BRect r)=0;
virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat)=0;
virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat)=0;
virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat)=0;
virtual void FillEllipse(BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat)=0;
virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true)=0;
virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat)=0;
virtual void StrokeRect(BRect r, LayerData *d, int8 *pat)=0;
virtual void FillRect(BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat)=0;
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat)=0;
virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)=0;
virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)=0;
virtual void SetMode(int32 mode)=0;
virtual bool DumpToFile(const char *path)=0;
virtual void Shutdown(void);
virtual void CopyBits(BRect src, BRect dest);
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d);
virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL);
virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat);
virtual void FillEllipse(BRect r, LayerData *d, int8 *pat);
virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat);
virtual void FillRect(BRect r, LayerData *d, int8 *pat);
virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat);
virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
virtual void HideCursor(void);
virtual bool IsCursorHidden(void);
virtual void MoveCursorTo(float x, float y);
virtual void InvertRect(BRect r);
virtual void ShowCursor(void);
virtual void ObscureCursor(void);
virtual void SetCursor(ServerCursor *cursor);
virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat);
virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat);
virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat);
virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true);
virtual void StrokeRect(BRect r, LayerData *d, int8 *pat);
virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat);
virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d);
virtual void SetMode(int32 mode);
virtual bool DumpToFile(const char *path);
virtual float StringWidth(const char *string, int32 length, LayerData *d);
virtual float StringHeight(const char *string, int32 length, LayerData *d);
virtual void GetBoundingBoxes(const char *string, int32 count, font_metric_mode mode,
escapement_delta *delta, BRect *rectarray, LayerData *d);
virtual void GetEscapements(const char *string, int32 charcount, escapement_delta *delta,
escapement_delta *escapements, escapement_delta *offsets, LayerData *d);
virtual void GetEdges(const char *string, int32 charcount, edge_info *edgearray, LayerData *d);
virtual void GetHasGlyphs(const char *string, int32 charcount, bool *hasarray);
virtual void GetTruncatedStrings( const char **instrings, int32 stringcount, uint32 mode,
float maxwidth, char **outstrings);
uint8 GetDepth(void);
uint16 GetHeight(void);
uint16 GetWidth(void);
int32 GetMode(void);
bool IsCursorObscured(bool state);
protected:
void Lock(void);
void Unlock(void);
void SetDepthInternal(uint8 d);
void SetHeightInternal(uint16 h);
void SetWidthInternal(uint16 w);
void SetModeInternal(int32 m);
bool _Lock(bigtime_t timeout=B_INFINITE_TIMEOUT);
void _Unlock(void);
void _SetDepth(uint8 d);
void _SetHeight(uint16 h);
void _SetWidth(uint16 w);
void _SetMode(int32 m);
ServerCursor *_GetCursor(void);
private:
sem_id lock_sem;
uint8 buffer_depth;
uint16 buffer_width;
uint16 buffer_height;
int32 buffer_mode;
sem_id _lock_sem;
uint8 _buffer_depth;
uint16 _buffer_width;
uint16 _buffer_height;
int32 _buffer_mode;
bool _is_cursor_hidden;
bool _is_cursor_obscured;
ServerCursor *_cursor;
};
#endif
+4 -2
View File
@@ -3,10 +3,12 @@ SubDir OBOS_TOP src add-ons decorators WinDecorator ;
Addon WinDecorator : decorators :
WinDecorator.cpp
ColorSet.cpp
ColorUtils.cc
Decorator.cpp
DisplayDriver.cpp
RGBColor.cpp
SystemPalette.cpp
ServerBitmap.cpp
ServerCursor.cpp
;
LinkSharedOSLibs WinDecorator : be ;
LinkSharedOSLibs WinDecorator : be libopenbeos.so ;
@@ -33,4 +33,4 @@ float scale;
};
#endif
#endif
+182 -23
View File
@@ -1,30 +1,93 @@
/*
RGBColor.cpp
Color encapsulation class for app_server.
*/
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: RGBColor.cpp
// Author: DarkWyrm <[email protected]>
// Description: Color encapsulation class for the app_server
//
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
#include <stdio.h>
// Local Includes --------------------------------------------------------------
#include "RGBColor.h"
#include "SystemPalette.h"
#include <ColorUtils.h>
RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
/*!
\brief Create an RGBColor from specified values
\param red red
\param green green
\param blue blue
\param alpha alpha, defaults to 255
*/
RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a)
{
SetColor(r,g,b,a);
}
RGBColor::RGBColor(rgb_color col)
/*!
\brief Create an RGBColor from specified values
\param red red
\param green green
\param blue blue
\param alpha alpha, defaults to 255
*/
RGBColor::RGBColor(int r, int g, int b, int a=255)
{
SetColor(r,g,b,a);
}
/*!
\brief Create an RGBColor from an rgb_color
\param col color to initialize from
*/
RGBColor::RGBColor(const rgb_color &col)
{
SetColor(col);
}
/*!
\brief Create an RGBColor from a 16-bit RGBA color
\param col color to initialize from
*/
RGBColor::RGBColor(uint16 col)
{
SetColor(col);
}
/*!
\brief Create an RGBColor from an index color
\param col color to initialize from
*/
RGBColor::RGBColor(uint8 col)
{
SetColor(col);
}
/*!
\brief Copy Contructor
\param col color to initialize from
*/
RGBColor::RGBColor(const RGBColor &col)
{
color32=col.color32;
@@ -32,26 +95,48 @@ RGBColor::RGBColor(const RGBColor &col)
color8=col.color8;
}
/*!
\brief Create an RGBColor with the values(0,0,0,0)
*/
RGBColor::RGBColor(void)
{
SetColor(0,0,0,0);
}
/*!
\brief Returns the color as the closest 8-bit color in the palette
\return The palette index for the current color
*/
uint8 RGBColor::GetColor8(void)
{
return color8;
}
/*!
\brief Returns the color as the closest 16-bit color
\return 16-bit value of the current color, including alpha
*/
uint16 RGBColor::GetColor16(void)
{
return color16;
}
/*!
\brief Returns the color as a 32-bit color
\return current color, including alpha
*/
rgb_color RGBColor::GetColor32(void)
{
return color32;
}
/*!
\brief Set the object to specified values
\param red red
\param green green
\param blue blue
\param alpha alpha, defaults to 255
*/
void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
{
color32.red=r;
@@ -60,27 +145,58 @@ void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
color32.alpha=a;
}
/*!
\brief Set the object to specified values
\param red red
\param green green
\param blue blue
\param alpha alpha, defaults to 255
*/
void RGBColor::SetColor(int r, int g, int b, int a=255)
{
color32.red=(uint8)r;
color32.green=(uint8)g;
color32.blue=(uint8)b;
color32.alpha=(uint8)a;
}
/*!
\brief Set the object to specified value
\param col16 color to copy
*/
void RGBColor::SetColor(uint16 col16)
{
// Pared-down version from what is used in the app_server to
// eliminate some dependencies
color16=col16;
SetRGBColor(&color32,col16);
color8=FindClosestColor(system_palette,color32);
}
/*!
\brief Set the object to specified index in the palette
\param col8 color to copy
*/
void RGBColor::SetColor(uint8 col8)
{
// Pared-down version from what is used in the app_server to
// eliminate some dependencies
color8=col8;
color32=system_palette[col8];
color16=FindClosestColor16(color32);
}
void RGBColor::SetColor(rgb_color color)
/*!
\brief Set the object to specified color
\param color color to copy
*/
void RGBColor::SetColor(const rgb_color &color)
{
// Pared-down version from what is used in the app_server to
// eliminate some dependencies
color32=color;
color16=FindClosestColor16(color32);
color8=FindClosestColor(system_palette,color32);
}
/*!
\brief Set the object to specified color
\param col color to copy
*/
void RGBColor::SetColor(const RGBColor &col)
{
color32=col.color32;
@@ -88,7 +204,10 @@ void RGBColor::SetColor(const RGBColor &col)
color8=col.color8;
}
/*!
\brief Set the object to specified color
\param col color to copy
*/
RGBColor & RGBColor::operator=(const RGBColor &col)
{
color32=col.color32;
@@ -97,12 +216,30 @@ RGBColor & RGBColor::operator=(const RGBColor &col)
return *this;
}
RGBColor & RGBColor::operator=(rgb_color col)
/*!
\brief Set the object to specified color
\param col color to copy
*/
RGBColor & RGBColor::operator=(const rgb_color &col)
{
color32=col;
color16=FindClosestColor16(color32);
color8=FindClosestColor(system_palette,color32);
return *this;
}
/*!
\brief Returns a color blended between the object's value and
another color.
\param color The other color to be blended with.
\param position A weighted percentage of the second color to use. 0 <= value <= 1.0
\return The blended color
If the position passed to this function is invalid, the starting
color will be returned.
*/
RGBColor RGBColor::MakeBlendColor(RGBColor color, float position)
{
rgb_color col=color32;
@@ -112,7 +249,7 @@ RGBColor RGBColor::MakeBlendColor(RGBColor color, float position)
float mod=0;
int16 delta;
if(position<0 || position>1)
return newcol;
return *this;
delta=int16(col2.red)-int16(col.red);
mod=col.red + (position * delta);
@@ -145,13 +282,35 @@ RGBColor RGBColor::MakeBlendColor(RGBColor color, float position)
newcol.alpha=255;
if(mod<0 )
newcol.alpha=0;
#ifdef DEBUG_COLOR_UTILS
printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n",
col.red,col.green,col.blue,col.alpha,
col2.red,col2.green,col2.blue,col2.alpha,
position,
newcol.red,newcol.green,newcol.blue,newcol.alpha);
#endif
return RGBColor(newcol);
}
/*!
\brief Prints the 32-bit values of the color to standard out
*/
void RGBColor::PrintToStream(void)
{
printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha);
}
/*!
\brief Overloaded comaparison
\return true if all color elements are exactly equal
*/
bool RGBColor::operator==(const rgb_color &col)
{
return (color32.red==col.red && color32.green==col.green
&& color32.blue==col.blue && color32.alpha==col.alpha)?true:false;
}
/*!
\brief Overloaded comaparison
\return true if all color elements are exactly equal
*/
bool RGBColor::operator==(const RGBColor &col)
{
return (color32.red==col.color32.red && color32.green==col.color32.green
&& color32.blue==col.color32.blue
&& color32.alpha==col.color32.alpha)?true:false;
}
+48 -3
View File
@@ -1,28 +1,73 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: RGBColor.h
// Author: DarkWyrm <[email protected]>
// Description: Color encapsulation class for the app_server
//
//------------------------------------------------------------------------------
#ifndef RGBCOLOR_H_
#define RGBCOLOR_H_
#include <GraphicsDefs.h>
/*!
\class RGBColor RGBColor.h
\brief A color class to encapsulate color space ugliness in the app_server
RGBColors can be used to perform tasks much more difficult using rgb_colors. This
class is limited to the app_server because of the access to the system palette for
looking up the 32-bit value to each color index.
*/
class RGBColor
{
public:
RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
RGBColor(rgb_color col);
RGBColor(int r, int g, int b, int a=255);
RGBColor(const rgb_color &col);
RGBColor(uint16 col);
RGBColor(uint8 col);
RGBColor(const RGBColor &col);
RGBColor(void);
void PrintToStream(void);
uint8 GetColor8(void);
uint16 GetColor16(void);
rgb_color GetColor32(void);
void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
void SetColor(int r, int g, int b, int a=255);
void SetColor(uint16 color16);
void SetColor(uint8 color8);
void SetColor(rgb_color color);
void SetColor(const rgb_color &color);
void SetColor(const RGBColor &col);
RGBColor MakeBlendColor(RGBColor color, float position);
RGBColor & operator=(const RGBColor &col);
RGBColor & operator=(rgb_color col);
RGBColor & operator=(const rgb_color &col);
bool operator==(const rgb_color &col);
bool operator==(const RGBColor &col);
protected:
rgb_color color32;
uint16 color16;
@@ -0,0 +1,225 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ServerBitmap.cpp
// Author: DarkWyrm <[email protected]>
// Description: Bitmap class used by the server
//
//------------------------------------------------------------------------------
#include "ServerBitmap.h"
/*!
\brief Constructor called by the BitmapManager (only).
\param rect Size of the bitmap.
\param space Color space of the bitmap
\param flags Various bitmap flags to tweak the bitmap as defined in Bitmap.h
\param bytesperline Number of bytes in each row. -1 implies the default value. Any
value less than the the default will less than the default will be overridden, but any value
greater than the default will result in the number of bytes specified.
\param screen Screen assigned to the bitmap.
*/
ServerBitmap::ServerBitmap(BRect rect,color_space space, int32 flags,
int32 bytesperline=-1, screen_id screen=B_MAIN_SCREEN_ID)
{
_initialized=false;
_area=B_ERROR;
_width=rect.IntegerWidth()+1;
_height=rect.IntegerHeight()+1;
_space=space;
_area=B_ERROR;
_buffer=NULL;
_HandleSpace(space, bytesperline);
}
//! Copy constructor does not copy the buffer.
ServerBitmap::ServerBitmap(const ServerBitmap *bmp)
{
_initialized=false;
_area=B_ERROR;
_buffer=NULL;
if(bmp)
{
_width=bmp->_width;
_height=bmp->_height;
_bytesperrow=bmp->_bytesperrow;
_space=bmp->_space;
_flags=bmp->_flags;
_bpp=bmp->_bpp;
}
else
{
_width=0;
_height=0;
_bytesperrow=0;
_space=B_NO_COLOR_SPACE;
_flags=0;
_bpp=0;
}
}
/*!
\brief Empty. Defined for subclasses.
*/
ServerBitmap::~ServerBitmap(void)
{
}
/*!
\brief Gets the number of bytes occupied by the bitmap, including padding bytes.
\return The number of bytes occupied by the bitmap, including padding.
*/
uint32 ServerBitmap::BitsLength(void)
{
return (uint32)(_bytesperrow*_height);
}
/*!
\brief Internal function used to translate color space values to appropriate internal
values.
\param space Color space for the bitmap.
\param bytesperline Number of bytes per row.
*/
void ServerBitmap::_HandleSpace(color_space space, int32 bytesperline=-1)
{
// Big convoluted mess just to handle every color space and dword align
// the buffer
switch(space)
{
// Buffer is dword-aligned, so nothing need be done
// aside from allocate the memory
case B_RGB32:
case B_RGBA32:
case B_RGB32_BIG:
case B_RGBA32_BIG:
case B_UVL32:
case B_UVLA32:
case B_LAB32:
case B_LABA32:
case B_HSI32:
case B_HSIA32:
case B_HSV32:
case B_HSVA32:
case B_HLS32:
case B_HLSA32:
case B_CMY32:
case B_CMYA32:
case B_CMYK32:
// 24-bit = 32-bit with extra 8 bits ignored
case B_RGB24_BIG:
case B_RGB24:
case B_LAB24:
case B_UVL24:
case B_HSI24:
case B_HSV24:
case B_HLS24:
case B_CMY24:
{
if(bytesperline<(_width*4))
_bytesperrow=_width*4;
else
_bytesperrow=bytesperline;
_bpp=32;
break;
}
// Calculate size and dword-align
// 1-bit
case B_GRAY1:
{
int32 numbytes=_width>>3;
if((_width % 8) != 0)
numbytes++;
if(bytesperline<numbytes)
{
for(int8 i=0;i<4;i++)
{
if( (numbytes+i)%4==0)
{
_bytesperrow=numbytes+i;
break;
}
}
}
else
_bytesperrow=bytesperline;
_bpp=1;
}
// 8-bit
case B_CMAP8:
case B_GRAY8:
case B_YUV411:
case B_YUV420:
case B_YCbCr422:
case B_YCbCr411:
case B_YCbCr420:
case B_YUV422:
{
if(bytesperline<_width)
{
for(int8 i=0;i<4;i++)
{
if( (_width+i)%4==0)
{
_bytesperrow=_width+i;
break;
}
}
}
else
_bytesperrow=bytesperline;
_bpp=8;
break;
}
// 16-bit
case B_YUV9:
case B_YUV12:
case B_RGB15:
case B_RGBA15:
case B_RGB16:
case B_RGB16_BIG:
case B_RGB15_BIG:
case B_RGBA15_BIG:
case B_YCbCr444:
case B_YUV444:
{
if(bytesperline<_width*2)
{
if( (_width*2) % 4 !=0)
_bytesperrow=(_width+1)*2;
else
_bytesperrow=_width*2;
}
else
_bytesperrow=bytesperline;
_bpp=16;
break;
}
case B_NO_COLOR_SPACE:
_bpp=0;
break;
}
}
@@ -0,0 +1,119 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ServerBitmap.h
// Author: DarkWyrm <[email protected]>
// Description: Bitmap class used inside the server
//
//------------------------------------------------------------------------------
#ifndef _SERVER_BITMAP_H_
#define _SERVER_BITMAP_H_
#include <GraphicsDefs.h>
#include <Rect.h>
#include <OS.h>
/*!
\class ServerBitmap ServerBitmap.h
\brief Bitmap class used inside the server.
This class is not directly allocated or freed. Instead, it is
managed by the BitmapManager class. It is also the base class for
all cursors. Every BBitmap has a shadow ServerBitmap object.
*/
class ServerBitmap
{
public:
ServerBitmap(BRect rect,color_space space, int32 flags,
int32 bytesperline=-1, screen_id screen=B_MAIN_SCREEN_ID);
ServerBitmap(const ServerBitmap *bmp);
~ServerBitmap(void);
/*!
\brief Returns the area in which the buffer resides
\return
- \c B_ERROR if the buffer is not allocated in an area
- area_id for the buffer
*/
area_id Area(void) { return _area; }
//! Returns the bitmap's buffer
uint8 *Bits(void) { return _buffer; }
uint32 BitsLength(void);
//! Returns the size of the bitmap
BRect Bounds() { return BRect(0,0,_width-1,_height-1); };
//! Returns the number of bytes in each row, including padding
int32 BytesPerRow(void) { return _bytesperrow; };
//! Returns the pixel color depth
uint8 BitsPerPixel(void) { return _bpp; }
//! Returns the color space of the bitmap
color_space ColorSpace(void) { return _space; }
//! Returns the width of the bitmap
int32 Width(void) const { return _width; }
//! Returns the height of the bitmap
int32 Height(void) const { return _height; }
//! Returns whether the bitmap is valid
bool InitCheck(void) { return _initialized; }
protected:
//! Internal function used by the BitmapManager.
void _SetArea(area_id ID) { _area=ID; }
//! Internal function used by the BitmapManager.
void _SetBuffer(void *ptr) { _buffer=(uint8*)ptr; }
/*!
\brief Internal function used by subclasses
Subclasses should call this so the buffer can automagically
be allocated on the heap.
*/
void _AllocateBuffer(void) { if(_buffer!=NULL) delete _buffer; _buffer=new uint8[BitsLength()]; }
/*!
\brief Internal function used by subclasses
Subclasses should call this to free the internal buffer.
*/
void _FreeBuffer(void) { if(_buffer!=NULL) { delete _buffer; _buffer=NULL; } }
void _HandleSpace(color_space space, int32 bytesperline=-1);
bool _initialized;
area_id _area;
uint8 *_buffer;
int32 _width,_height;
int32 _bytesperrow;
color_space _space;
int32 _flags;
int _bpp;
};
#endif
@@ -0,0 +1,142 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ServerCursor.cpp
// Author: DarkWyrm <[email protected]>
// Description: Glorified ServerBitmap used for cursor work.
//
//------------------------------------------------------------------------------
#include "ServerCursor.h"
/*!
\brief Constructor
\param r Size of the cursor
\param cspace Color space of the cursor
\param flags ServerBitmap flags. See Bitmap.h.
\param hotspot Hotspot of the cursor
\param bytesperline Bytes per row for the cursor. See ServerBitmap::ServerBitmap()
*/
ServerCursor::ServerCursor(BRect r, color_space cspace, int32 flags, BPoint hotspot, int32 bytesperrow=-1, screen_id screen=B_MAIN_SCREEN_ID)
: ServerBitmap(r,cspace,flags,bytesperrow,screen)
{
_hotspot=hotspot;
_hotspot.ConstrainTo(Bounds());
_app_signature=NULL;
_AllocateBuffer();
}
/*!
\brief Constructor
\param data pointer to 68-byte cursor data array. See BeBook entry for BCursor for details
*/
ServerCursor::ServerCursor(int8 *data)
: ServerBitmap(BRect(0,0,15,15),B_RGBA32,0,64)
{
// 68-byte array used in R5 for holding cursors.
// This API has serious problems and should be deprecated(but supported) in R2
// Now that we have all the setup, we're going to map (for now) the cursor
// to RGBA32. Eventually, there will be support for 16 and 8-bit depths
if(data)
{
_initialized=true;
uint32 black=0xFF000000,
white=0xFFFFFFFF,
*bmppos;
uint16 *cursorpos, *maskpos,cursorflip, maskflip,
cursorval, maskval,powval;
uint8 i,j;
cursorpos=(uint16*)(data+4);
maskpos=(uint16*)(data+36);
_AllocateBuffer();
// for each row in the cursor data
for(j=0;j<16;j++)
{
bmppos=(uint32*)(_buffer+ (j*64) );
// On intel, our bytes end up swapped, so we must swap them back
cursorflip=(cursorpos[j] & 0xFF) << 8;
cursorflip |= (cursorpos[j] & 0xFF00) >> 8;
maskflip=(maskpos[j] & 0xFF) << 8;
maskflip |= (maskpos[j] & 0xFF00) >> 8;
// for each column in each row of cursor data
for(i=0;i<16;i++)
{
// Get the values and dump them to the bitmap
powval=((15-i) * (15-i));
cursorval=cursorflip & powval;
maskval=maskflip & powval;
bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF);
}
}
}
else
{
_width=0;
_height=0;
_bytesperrow=0;
_space=B_NO_COLOR_SPACE;
}
_app_signature=NULL;
}
/*!
\brief Copy constructor
\param cursor cursor to copy
*/
ServerCursor::ServerCursor(const ServerCursor *cursor)
: ServerBitmap(cursor)
{
_AllocateBuffer();
_initialized=true;
_app_signature=NULL;
if(cursor)
{
if(cursor->_buffer)
memcpy(_buffer, cursor->_buffer, BitsLength());
_hotspot=cursor->_hotspot;
}
}
//! Frees the heap space allocated for the cursor's image data
ServerCursor::~ServerCursor(void)
{
_FreeBuffer();
if(_app_signature)
delete _app_signature;
}
/*!
\brief Sets the cursor's hotspot
\param pt New location of hotspot, constrained to the cursor's boundaries.
*/
void ServerCursor::SetHotSpot(BPoint pt)
{
_hotspot=pt;
_hotspot.ConstrainTo(Bounds());
}
@@ -0,0 +1,66 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ServerCursor.h
// Author: DarkWyrm <[email protected]>
// Description: Glorified ServerBitmap used for cursor work.
//
//------------------------------------------------------------------------------
#ifndef SERVERCURSOR_H_
#define SERVERCURSOR_H_
#include <Point.h>
#include "ServerBitmap.h"
class ServerApp;
class CursorManager;
/*!
\class ServerCursor ServerCursor.h
\brief Class to handle all cursor capabilities for the system
Although descended from ServerBitmaps, ServerCursors are not handled by
the BitmapManager - they are allocated like any other object. Unlike BeOS
R5, cursors can be any size or color space, and this class accomodates and
expands the R5 API.
*/
class ServerCursor : public ServerBitmap
{
public:
ServerCursor(BRect r, color_space cspace, int32 flags, BPoint hotspot, int32 bytesperrow=-1, screen_id screen=B_MAIN_SCREEN_ID);
ServerCursor(int8 *data);
ServerCursor(const ServerCursor *cursor);
~ServerCursor(void);
//! Returns the cursor's hot spot
BPoint GetHotSpot(void);
void SetHotSpot(BPoint pt);
const char *GetAppSignature(void) { return _app_signature; }
private:
friend ServerApp;
friend CursorManager;
BPoint _hotspot;
char *_app_signature;
int32 _token;
};
#endif
@@ -0,0 +1,361 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: SystemPalette.cpp
// Author: DarkWyrm <[email protected]>
// Description: One global function to generate the palette which is
// the default BeOS System palette and the variable to go with it
//
//------------------------------------------------------------------------------
// Local Includes --------------------------------------------------------------
#include "SystemPalette.h"
/*!
\var rgb_color system_palette[256]
\brief The global array of colors for the system palette.
Whenever the system's color palette is referenced, this is the variable used.
*/
rgb_color system_palette[256];
/*!
\brief Takes a palette array and places the BeOS System palette in it.
\param palette 256-element rgb_color array
*/
void GenerateSystemPalette(rgb_color *palette)
{
int i,j,index=0;
int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 },
indexvals2[]={ 255,203,152,102,51,0 };
// ff, cb, 98, 66, 33
rgb_color *currentcol;
// Grays 0,0,0 -> 248,248,248 by 8's
for(i=0; i<=248; i+=8,index++)
{
currentcol=&(palette[index]);
currentcol->red=i;
currentcol->green=i;
currentcol->blue=i;
currentcol->alpha=255;
}
// Blues, following indexvals1
for(i=0; i<10; i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=0;
currentcol->green=0;
currentcol->blue=indexvals1[i];
currentcol->alpha=255;
}
// Reds, following indexvals1 - 1
for(i=0; i<10; i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=indexvals1[i] - 1;
currentcol->green=0;
currentcol->blue=0;
currentcol->alpha=255;
}
// Greens, following indexvals1 - 1
for(i=0; i<10; i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=0;
currentcol->green=indexvals1[i] - 1;
currentcol->blue=0;
currentcol->alpha=255;
}
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=152;
currentcol->blue=51;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=255;
currentcol->green=255;
currentcol->blue=255;
index++;
for(j=1;j<5;j++)
{
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=indexvals2[j];
currentcol->green=255;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
}
for(i=0;i<4;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=255;
currentcol->green=152;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
currentcol+=sizeof(rgb_color);
currentcol->red=255;
currentcol->green=102;
currentcol->blue=51;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=255;
currentcol->green=102;
currentcol->blue=0;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=102;
currentcol->blue=255;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=102;
currentcol->blue=203;
index++;
// Mostly array runs from here on out
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=203;
currentcol->green=203;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=152;
currentcol->green=255;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=102;
currentcol->green=255;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=51;
currentcol->green=255;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=255;
currentcol->green=102;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=102;
currentcol->blue=152;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=102;
currentcol->blue=102;
index++;
// knocks out 4 assignment loops at once :)
for(j=1;j<5;j++)
{
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=indexvals2[j];
currentcol->green=152;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
}
currentcol+=sizeof(rgb_color);
currentcol->red=230;
currentcol->green=134;
currentcol->blue=0;
index++;
for(i=1;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=255;
currentcol->green=51;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=102;
currentcol->blue=51;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=102;
currentcol->blue=0;
index++;
for(j=1;j<5;j++)
{
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=indexvals2[j];
currentcol->green=102;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
}
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=255;
currentcol->green=0;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
currentcol+=sizeof(rgb_color);
currentcol->red=255;
currentcol->green=175;
currentcol->blue=19;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=51;
currentcol->blue=255;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=0;
currentcol->green=51;
currentcol->blue=203;
index++;
for(j=1;j<5;j++)
{
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=indexvals2[j];
currentcol->green=51;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
}
for(i=3;i>=0;i--,index++)
{
currentcol=&(palette[index]);
currentcol->red=255;
currentcol->green=203;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
for(i=2;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=0;
currentcol->green=51;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
for(i=0;i<5;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=203;
currentcol->green=0;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
currentcol+=sizeof(rgb_color);
currentcol->red=255;
currentcol->green=227;
currentcol->blue=70;
index++;
for(j=2;j<6;j++)
{
for(i=0;i<6;i++,index++)
{
currentcol=&(palette[index]);
currentcol->red=indexvals2[j];
currentcol->green=0;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
}
currentcol+=sizeof(rgb_color);
currentcol->red=255;
currentcol->green=203;
currentcol->blue=51;
index++;
currentcol+=sizeof(rgb_color);
currentcol->red=255;
currentcol->green=203;
currentcol->blue=0;
index++;
for(i=5;i<=0;i--,index++)
{
currentcol=&(palette[index]);
currentcol->red=255;
currentcol->green=255;
currentcol->blue=indexvals2[i];
currentcol->alpha=255;
}
}
@@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: SystemPalette.h
// Author: DarkWyrm <[email protected]>
// Description: One global function to generate the palette which is
// the default BeOS System palette and the variable to go with it
//
//------------------------------------------------------------------------------
#ifndef _SYSTEM_PALETTE_H_
#define _SYSTEM_PALETTE_H_
#include <GraphicsDefs.h>
void GenerateSystemPalette(rgb_color *palette);
extern rgb_color system_palette[];
#endif
@@ -56,7 +56,7 @@ printf("~WinDecorator()\n");
click_type WinDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
if(closerect.Contains(pt))
if(_closerect.Contains(pt))
{
#ifdef DEBUG_DECOR
@@ -66,7 +66,7 @@ printf("WinDecorator():Clicked() - Close\n");
return CLICK_CLOSE;
}
if(zoomrect.Contains(pt))
if(_zoomrect.Contains(pt))
{
#ifdef DEBUG_DECOR
@@ -77,7 +77,7 @@ printf("WinDecorator():Clicked() - Zoom\n");
}
// Clicking in the tab?
if(tabrect.Contains(pt))
if(_tabrect.Contains(pt))
{
// Here's part of our window management stuff
if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus())
@@ -86,7 +86,7 @@ printf("WinDecorator():Clicked() - Zoom\n");
}
// We got this far, so user is clicking on the border?
BRect srect(frame);
BRect srect(_frame);
srect.top+=19;
BRect clientrect(srect.InsetByCopy(3,3));
if(srect.Contains(pt) && !clientrect.Contains(pt))
@@ -109,25 +109,25 @@ void WinDecorator::_DoLayout(void)
#ifdef DEBUG_DECOR
printf("WinDecorator()::_DoLayout()\n");
#endif
tabrect=frame;
borderrect=frame;
_tabrect=_frame;
_borderrect=_frame;
borderrect.top+=19;
_borderrect.top+=19;
tabrect.bottom=tabrect.top+18;
_tabrect.bottom=_tabrect.top+18;
zoomrect=tabrect;
zoomrect.top+=4;
zoomrect.right-=4;
zoomrect.bottom-=4;
zoomrect.left=zoomrect.right-10;
zoomrect.bottom=zoomrect.top+10;
_zoomrect=_tabrect;
_zoomrect.top+=4;
_zoomrect.right-=4;
_zoomrect.bottom-=4;
_zoomrect.left=_zoomrect.right-10;
_zoomrect.bottom=_zoomrect.top+10;
closerect=zoomrect;
zoomrect.OffsetBy(0-zoomrect.Width()-4,0);
_closerect=_zoomrect;
_zoomrect.OffsetBy(0-_zoomrect.Width()-4,0);
minimizerect=zoomrect;
minimizerect.OffsetBy(0-zoomrect.Width()-2,0);
_minimizerect=_zoomrect;
_minimizerect.OffsetBy(0-_zoomrect.Width()-2,0);
}
void WinDecorator::MoveBy(float x, float y)
@@ -138,12 +138,12 @@ void WinDecorator::MoveBy(float x, float y)
void WinDecorator::MoveBy(BPoint pt)
{
// Move all internal rectangles the appropriate amount
frame.OffsetBy(pt);
closerect.OffsetBy(pt);
tabrect.OffsetBy(pt);
borderrect.OffsetBy(pt);
zoomrect.OffsetBy(pt);
minimizerect.OffsetBy(pt);
_frame.OffsetBy(pt);
_closerect.OffsetBy(pt);
_tabrect.OffsetBy(pt);
_borderrect.OffsetBy(pt);
_zoomrect.OffsetBy(pt);
_minimizerect.OffsetBy(pt);
}
/*
SRegion * WinDecorator::GetFootprint(void)
@@ -152,8 +152,8 @@ SRegion * WinDecorator::GetFootprint(void)
// relative to the layer. This is most often used to set a WindowBorder
// object's visible region.
SRegion *reg=new SRegion(borderrect);
reg->Include(tabrect);
SRegion *reg=new SRegion(_borderrect);
reg->Include(_tabrect);
return reg;
}
*/
@@ -164,13 +164,13 @@ void WinDecorator::_DrawTitle(BRect r)
// the client side.
/* if(title)
{
driver->SetDrawingMode(B_OP_OVER);
rgb_color tmpcol=driver->HighColor();
driver->SetHighColor(textcol.red,textcol.green,textcol.blue);
driver->DrawString((char *)string,strlen(string),
BPoint(frame.left+textoffset,closerect.bottom-1));
driver->SetHighColor(tmpcol.red,tmpcol.green,tmpcol.blue);
driver->SetDrawingMode(B_OP_COPY);
_driver->SetDrawingMode(B_OP_OVER);
rgb_color tmpcol=_driver->HighColor();
_driver->SetHighColor(textcol.red,textcol.green,textcol.blue);
_driver->DrawString((char *)string,strlen(string),
BPoint(_frame.left+textoffset,_closerect.bottom-1));
_driver->SetHighColor(tmpcol.red,tmpcol.green,tmpcol.blue);
_driver->SetDrawingMode(B_OP_COPY);
}
*/
}
@@ -200,10 +200,10 @@ printf("WinDecorator::Draw(): "); update.PrintToStream();
// Draw the top view's client area - just a hack :)
RGBColor blue(100,100,255);
layerdata.highcolor=blue;
_layerdata.highcolor=blue;
if(borderrect.Intersects(update))
driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh);
if(_borderrect.Intersects(update))
_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
_DrawFrame(update);
_DrawTab(update);
@@ -218,9 +218,9 @@ printf("WinDecorator::Draw()\n");
// Draw the top view's client area - just a hack :)
RGBColor blue(100,100,255);
layerdata.highcolor=blue;
_layerdata.highcolor=blue;
driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh);
_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
DrawFrame();
DrawTab();
@@ -231,8 +231,8 @@ void WinDecorator::_DrawZoom(BRect r)
DrawBlendedRect(r,GetZoom());
// Draw the Zoom box
layerdata.highcolor=textcol;
driver->StrokeRect(r.InsetByCopy(2,2),&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=textcol;
_driver->StrokeRect(r.InsetByCopy(2,2),&_layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawClose(BRect r)
@@ -241,11 +241,11 @@ void WinDecorator::_DrawClose(BRect r)
DrawBlendedRect(r,GetClose());
// Draw the X
layerdata.highcolor=textcol;
driver->StrokeLine(BPoint(closerect.left+2,closerect.top+2),BPoint(closerect.right-2,
closerect.bottom-2),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(BPoint(closerect.right-2,closerect.top+2),BPoint(closerect.left+2,
closerect.bottom-2),&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=textcol;
_driver->StrokeLine(BPoint(_closerect.left+2,_closerect.top+2),BPoint(_closerect.right-2,
_closerect.bottom-2),&_layerdata,(int8*)&solidhigh);
_driver->StrokeLine(BPoint(_closerect.right-2,_closerect.top+2),BPoint(_closerect.left+2,
_closerect.bottom-2),&_layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawMinimize(BRect r)
@@ -253,31 +253,31 @@ void WinDecorator::_DrawMinimize(BRect r)
// Just like DrawZoom, but for a Minimize button
DrawBlendedRect(r,GetMinimize());
layerdata.highcolor=textcol;
driver->StrokeLine(BPoint(minimizerect.left+2,minimizerect.bottom-2),BPoint(minimizerect.right-2,
minimizerect.bottom-2),&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=textcol;
_driver->StrokeLine(BPoint(_minimizerect.left+2,_minimizerect.bottom-2),BPoint(_minimizerect.right-2,
_minimizerect.bottom-2),&_layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawTab(BRect r)
{
// If a window has a tab, this will draw it and any buttons which are
// in it.
if(look==WLOOK_NO_BORDER)
if(_look==B_NO_BORDER_WINDOW_LOOK)
return;
layerdata.highcolor=frame_lowcol;
driver->StrokeRect(tabrect,&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowcol;
_driver->StrokeRect(_tabrect,&_layerdata,(int8*)&solidhigh);
// UpdateTitle(layer->name->String());
layerdata.highcolor=tab_lowcol;
driver->FillRect(tabrect.InsetByCopy(1,1),&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=tab_lowcol;
_driver->FillRect(_tabrect.InsetByCopy(1,1),&_layerdata,(int8*)&solidhigh);
// Draw the buttons if we're supposed to
if(!(flags & NOT_CLOSABLE))
_DrawClose(closerect);
if(!(flags & NOT_ZOOMABLE))
_DrawZoom(zoomrect);
if(!(_flags & B_NOT_CLOSABLE))
_DrawClose(_closerect);
if(!(_flags & B_NOT_ZOOMABLE))
_DrawZoom(_zoomrect);
}
void WinDecorator::DrawBlendedRect(BRect r, bool down)
@@ -316,77 +316,77 @@ void WinDecorator::DrawBlendedRect(BRect r, bool down)
SetRGBColor(&tmpcol, uint8(startcol.red-(i*rstep)),
uint8(startcol.green-(i*gstep)),
uint8(startcol.blue-(i*bstep)));
layerdata.highcolor=tmpcol;
driver->StrokeLine(BPoint(r.left,r.top+i),
BPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=tmpcol;
_driver->StrokeLine(BPoint(r.left,r.top+i),
BPoint(r.left+i,r.top),&_layerdata,(int8*)&solidhigh);
SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)),
uint8(halfcol.green-(i*gstep)),
uint8(halfcol.blue-(i*bstep)));
layerdata.highcolor=tmpcol;
driver->StrokeLine(BPoint(r.left+steps,r.top+i),
BPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=tmpcol;
_driver->StrokeLine(BPoint(r.left+steps,r.top+i),
BPoint(r.left+i,r.top+steps),&_layerdata,(int8*)&solidhigh);
}
// layerdata.highcolor=startcol;
// driver->FillRect(r,&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowcol;
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
// _layerdata.highcolor=startcol;
// _driver->FillRect(r,&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowcol;
_driver->StrokeRect(r,&_layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawFrame(BRect rect)
{
if(look==WLOOK_NO_BORDER)
if(_look==B_NO_BORDER_WINDOW_LOOK)
return;
BRect r=borderrect;
BRect r=_borderrect;
layerdata.highcolor=frame_midcol;
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowcol;
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_midcol;
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowcol;
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowercol;
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowercol;
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_midcol;
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_midcol;
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highercol;
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highercol;
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_midcol;
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_midcol;
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
layerdata.highcolor=frame_highcol;
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highcol;
_driver->StrokeRect(r,&_layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowercol;
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowercol;
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highercol;
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highercol;
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
}
extern "C" float get_decorator_version(void)
@@ -397,4 +397,4 @@ extern "C" float get_decorator_version(void)
extern "C" Decorator *instantiate_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
{
return new WinDecorator(rect,wlook,wfeel,wflags);
}
}
@@ -42,4 +42,4 @@ protected:
int textoffset;
};
#endif
#endif
+1 -1
View File
@@ -17,4 +17,4 @@
#define GET_DECORATOR 'gdec'
#define SET_UI_COLORS 'suic'
#endif
#endif