Updated from proto7 API

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2651 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-02-07 18:56:09 +00:00
parent f6c67f7d6c
commit e0519ecad2
22 changed files with 2623 additions and 800 deletions

View File

@ -16,9 +16,10 @@
#include <stdio.h>
#include "APRView.h"
#include "PortLink.h"
#include <PortLink.h>
#include "defs.h"
#include "ColorWell.h"
#include "ColorUtils.h"
//#define DEBUG_COLORSET
@ -30,9 +31,6 @@
#define LOAD_COLORSET 'ldcs'
#define COLOR_DROPPED 'cldp'
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255);
void PrintRGBColor(rgb_color col);
APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags)
:BView(frame,name,resize,flags), settings(B_SIMPLE_DATA)
{
@ -842,16 +840,3 @@ const char *APRView::SelectionToString(int32 index)
break;
}
}
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;
}
void PrintRGBColor(rgb_color col)
{
printf("RGB Color (%d,%d,%d,%d)\n",col.red,col.green,col.blue,col.alpha);
}

View File

@ -1,87 +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 <bpmagic@columbus.rr.com>
// 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_border "); control_border.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_separator_high "); menu_separator_high.PrintToStream();
printf("menu_separator_low "); menu_separator_low.PrintToStream();
printf("menu_triggers "); menu_triggers.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("keyboard_navigation "); keyboard_navigation.PrintToStream();
printf("desktop "); desktop.PrintToStream();
printf("inactive_window_tab "); inactive_window_tab.PrintToStream();
printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream();
}

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 <bpmagic@columbus.rr.com>
// 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:
@ -14,25 +45,38 @@ public:
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

View File

@ -1,18 +1,39 @@
/*
DecView.cpp: The Appearance app's decorator handler
Utilizes app_server graphics module emulation to allows decorators to display
a preview. Saves the chosen decorator's path in a settings file in the app_server
settings directory.
*/
//------------------------------------------------------------------------------
// 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: DecView.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: decorator handler for the app
//
// Utilizes app_server graphics module emulation to allows decorators to display
// a preview. Saves the chosen decorator's path in a settings file in the app_server
// settings directory.
//------------------------------------------------------------------------------
#include <OS.h>
#include <String.h>
#include <Directory.h>
#include <Entry.h>
#include <Path.h>
#include "DecView.h"
#include "PortLink.h"
#include <PortLink.h>
#include <Directory.h>
#include <File.h>
#include <stdio.h>
@ -117,7 +138,7 @@ printf("MSG: Decorator NOT Chosen - couldn't load decorator\n");
break;
}
ldata.highcolor.SetColor(colorset.desktop);
// ldata.highcolor.SetColor(colorset.desktop);
driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high);
if(decorator)
{
@ -278,13 +299,13 @@ bool DecView::LoadDecorator(const char *path)
if(!path)
return false;
create_decorator *pcreatefunc=NULL;
get_decorator_version *pversionfunc=NULL;
// get_decorator_version *pversionfunc=NULL;
status_t stat;
image_id addon;
addon=load_add_on(path);
stat=get_image_symbol(addon, "get_decorator_version", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc);
/* stat=get_image_symbol(addon, "get_decorator_version", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc);
if(stat!=B_OK)
{
unload_add_on(addon);
@ -293,7 +314,7 @@ printf("LoadDecorator(%s): Couldn't get version symbol\n",path);
#endif
return false;
}
*/
// As of now, we do nothing with decorator versions, but the possibility exists
// that the API will change even though I cannot forsee any reason to do so. If
// we *did* do anything with decorator versions, the assignment to a global would
@ -323,7 +344,8 @@ printf("LoadDecorator(): Deleting old decorator\n");
// unload_add_on(decorator_id);
}
decorator_id=addon;
decorator=pcreatefunc(BRect(50,50,150,150),WLOOK_TITLED,WFEEL_NORMAL,0);
decorator=pcreatefunc(BRect(50,50,150,150),B_TITLED_WINDOW_LOOK,
B_NORMAL_WINDOW_FEEL,0);
decorator->SetDriver(driver);
decorator->SetFocus(true);
// decorator->Draw();
@ -357,7 +379,7 @@ printf("DecView::SetColors\n");
{
if(decorator)
{
ldata.highcolor.SetColor(colorset.desktop);
// ldata.highcolor.SetColor(colorset.desktop);
driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high);
decorator->SetColors(colorset);
decorator->Draw();
@ -404,9 +426,9 @@ printf("UnpackSettings(): NULL parameter\n");
set->menu_selected_text.SetColor(*col);
if(msg->FindData("WINDOW_TAB",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
set->window_tab.SetColor(*col);
if(msg->FindData("KEYBOARD_NAVIGATION",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
set->keyboard_navigation.SetColor(*col);
if(msg->FindData("DESKTOP",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
set->desktop.SetColor(*col);
if(msg->FindData("KEYBOARD_NAVIGATION_BASE",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
set->keyboard_navigation_base.SetColor(*col);
if(msg->FindData("KEYBOARD_NAVIGATION_PULSE",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
set->keyboard_navigation_pulse.SetColor(*col);
return true;
}

View File

@ -1,3 +1,29 @@
//------------------------------------------------------------------------------
// 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: DecView.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: decorator handler for the app
//
//------------------------------------------------------------------------------
#ifndef DEC_VIEW_H_
#define DEC_VIEW_H_

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 <bpmagic@columbus.rr.com>
// 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)
{

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 <bpmagic@columbus.rr.com>
// 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,19 +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 uint16 get_decorator_version(void);
typedef float get_version(void);
typedef Decorator *create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags);
#endif

View File

@ -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 <bpmagic@columbus.rr.com>
// 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;
}

View File

@ -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 <bpmagic@columbus.rr.com>
// 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

View File

@ -2,6 +2,20 @@ SubDir OBOS_TOP src prefs appearance ;
AddResources Appearance : Appearance.rsrc ;
Preference Appearance : APRMain.cpp APRView.cpp APRWindow.cpp Decorator.cpp DecView.cpp DisplayDriver.cpp PortLink.cpp PreviewDriver.cpp RGBColor.cpp ColorWell.cpp ColorSet.cpp ;
Preference Appearance :
APRMain.cpp
APRView.cpp
APRWindow.cpp
Decorator.cpp
DecView.cpp
DisplayDriver.cpp
PreviewDriver.cpp
RGBColor.cpp
ColorWell.cpp
ColorSet.cpp
ServerCursor.cpp
ServerBitmap.cpp
SystemPalette.cpp
;
LinkSharedOSLibs Appearance : be tracker ;
LinkSharedOSLibs Appearance : be tracker libopenbeos.so ;

View File

@ -1,438 +0,0 @@
/*
PortLink.cpp:
A helper class for port-based messaging
------------------------------------------------------------------------
How it works:
The class utilizes a fixed-size array of PortLinkData object pointers. When
data is attached, a new PortLinkData object is allocated and a copy of the
passed data is created inside it. When the time comes for the message to be sent,
the data is pieced together into a flattened array and written to the port.
------------------------------------------------------------------------
Data members:
*attachments[] - fixed-size array of pointers used to hold the attached data
opcode - message value which is sent along with any data
target - port to which the message is sent when Flush() is called
replyport - port used with synchronous messaging - FlushWithReply()
bufferlength - total bytes taken up by attachments
num_attachments - internal variable which is used to track which "slot"
will be the next one to receive an attachment object
*/
#include "PortLink.h"
#include <string.h>
#include <stdio.h>
#include <malloc.h>
//#define PLDEBUG
// Internal data storage class for holding attached data whilst it is waiting
// to be Flattened() and then Flushed(). There is no need for this to be called outside
// the PortLink class.
class PortLinkData
{
public:
PortLinkData(void);
~PortLinkData(void);
bool Set(void *data, size_t size);
char *buffer;
size_t buffersize;
};
PortLink::PortLink(port_id port)
{
// For this class to be useful (and to prevent a lot of init problems)
// we require a port in the constructor
target=port;
// We start out without any data attached to the port message
num_attachments=0;
opcode=0;
bufferlength=0;
replyport=create_port(30,"PortLink reply port");
}
PortLink::~PortLink(void)
{
// If, for some odd reason, this is deleted with something attached,
// free the memory used by the attachments. We do not flush the queue
// because the port may no longer be valid in cases such as the app
// is in the process of quitting
MakeEmpty();
}
void PortLink::SetOpCode(int32 code)
{
// Sets the message code. This does not change once the message is sent.
// Another call to SetOpCode() is required for such things.
opcode=code;
}
void PortLink::SetPort(port_id port)
{
// Sets the target port. While not necessary in most uses, this exists
// mostly to prevent flexibility problems
target=port;
}
port_id PortLink::GetPort(void)
{
// Simply returns the port at which the object is pointed.
return target;
}
void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT)
{
// Fires a message off to the target, complete with attachments. NOTE:
// the recipient must delete all attachments, being the PortLink object assumes
// no responsiblity for the attachments once the message is sent.
int8 *msgbuffer;
int32 size;
if(num_attachments>0)
{
FlattenData(&msgbuffer,&size);
// Dump message to port, reset attachments, and clean up
if(timeout!=B_INFINITE_TIMEOUT)
write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout);
else
write_port(target,opcode,msgbuffer,size);
MakeEmpty();
}
else
{
if(timeout!=B_INFINITE_TIMEOUT)
write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout);
else
write_port(target,opcode,NULL,0);
}
}
int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT)
{
// Fires a message to the target and then waits for a reply. The target will
// receive a message with the first item being the port_id to reply to.
// NOTE: like Flush(), any attached data must be deleted.
// Effectively, an Attach() call inlined for changes
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
{
*status=B_ERROR;
return NULL;
}
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&replyport,sizeof(port_id)))
{
bufferlength+=sizeof(port_id);
}
else
{
delete pld;
*status=B_ERROR;
return NULL;
}
// Flatten() inlined to make some necessary changes
int8 *buffer=new int8[bufferlength];
int8 *bufferindex=buffer;
size_t size=0;
// attach our port_id first
memcpy(bufferindex, pld->buffer, pld->buffersize);
bufferindex += pld->buffersize;
size+=pld->buffersize;
// attach everything else
for(int i=0;i<num_attachments;i++)
{
pld=attachments[i];
memcpy(bufferindex, pld->buffer, pld->buffersize);
bufferindex += pld->buffersize;
size+=pld->buffersize;
}
// Flush the thing....FOOSH! :P
write_port(target,opcode,buffer,size);
MakeEmpty();
delete buffer;
// Now we wait for the reply
if(timeout==B_INFINITE_TIMEOUT)
{
*buffersize=port_buffer_size(replyport);
if(*buffersize>0)
buffer=(int8*)new int8[*buffersize];
read_port(replyport,code, buffer, *buffersize);
}
else
{
*buffersize=port_buffer_size_etc(replyport,0,timeout);
if(*buffersize==B_TIMED_OUT)
{
*status=*buffersize;
return NULL;
}
if(*buffersize>0)
buffer=(int8*)new int8[*buffersize];
read_port(replyport,code, buffer, *buffersize);
}
// We got this far, so we apparently have some data
*status=B_OK;
return buffer;
}
void PortLink::Attach(void *data, size_t size)
{
// This is the member called to attach data to a message. Attachments are
// treated to be in 'Append' mode, tacking on each attached piece of data
// to the end of the list.
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
if(size==0)
return;
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
// These functions were added for a major convenience in passing common types
// Eventually, I'd like to templatize these, but for now, this'll do
void PortLink::Attach(int32 data)
{
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
int32 size=sizeof(int32);
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
void PortLink::Attach(int16 data)
{
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
int32 size=sizeof(int16);
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
void PortLink::Attach(int8 data)
{
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
int32 size=sizeof(int8);
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
void PortLink::Attach(float data)
{
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
int32 size=sizeof(float);
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
void PortLink::Attach(bool data)
{
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
int32 size=sizeof(bool);
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
void PortLink::Attach(BRect data)
{
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
int32 size=sizeof(BRect);
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
void PortLink::Attach(BPoint data)
{
// Prevent parameter problems
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
return;
int32 size=sizeof(BPoint);
// create a new storage object and stash the data
PortLinkData *pld=new PortLinkData;
if(pld->Set(&data,size))
{
num_attachments++;
attachments[num_attachments-1]=pld;
bufferlength+=size;
}
else
{
delete pld;
}
}
void PortLink::FlattenData(int8 **buffer,int32 *size)
{
// This function is where all the magic happens, but it is strictly internal.
// It iterates through each PortLinkData object and copies it to the main buffer
// which ends up, ultimately, being written to the PortLink's target port.
// skip if there aree no attachments
if(bufferlength<1)
return;
*buffer=new int8[bufferlength];
int8 *bufferindex=*buffer;
PortLinkData *pld;
*size=0;
for(int i=0;i<num_attachments;i++)
{
pld=attachments[i];
memcpy(bufferindex, pld->buffer, pld->buffersize);
bufferindex += pld->buffersize;
*size+=pld->buffersize;
}
}
void PortLink::MakeEmpty(void)
{
// Nukes all the attachments currently held by the PortLink class
if(num_attachments!=0)
{
for(int i=0; i<num_attachments; i++)
{
delete attachments[i];
}
}
num_attachments=0;
bufferlength=0;
}
PortLinkData::PortLinkData(void)
{
// Initialize object to empty
buffersize=0;
}
PortLinkData::~PortLinkData(void)
{
// Frees the buffer if we actually used the class to store data
if(buffersize>0)
free(buffer);
}
bool PortLinkData::Set(void *data, size_t size)
{
// Function copies the passed to the internal buffers for storage
if(size>0 && buffersize==0 && data!=NULL)
{
buffer=(char *)malloc(size);
if(buffer==NULL)
return false;
memcpy(buffer, data, size);
buffersize=size;
return true;
}
return false;
}

View File

@ -1,43 +0,0 @@
#ifndef _PORTLINK_H_
#define _PORTLINK_H_
#include <Errors.h>
#include <OS.h>
#include <SupportDefs.h>
#include <Rect.h>
#ifndef _PORTLINK_BUFFERSIZE
#define _PORTLINK_MAX_ATTACHMENTS 50
#endif
class PortLinkData;
class PortLink
{
public:
PortLink(port_id port);
~PortLink(void);
void SetOpCode(int32 code);
void SetPort(port_id port);
port_id GetPort(void);
void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT);
int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize,
bigtime_t timeout=B_INFINITE_TIMEOUT);
void Attach(void *data, size_t size);
void Attach(int32 data);
void Attach(int16 data);
void Attach(int8 data);
void Attach(float data);
void Attach(bool data);
void Attach(BRect data);
void Attach(BPoint data);
void MakeEmpty(void);
protected:
void FlattenData(int8 **buffer,int32 *size);
port_id target, replyport;
int32 opcode, bufferlength;
int num_attachments;
PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS];
};
#endif

View File

@ -28,6 +28,7 @@
#include "PortLink.h"
#include "PreviewDriver.h"
#include "LayerData.h"
#include "ColorSet.h"
BRect preview_bounds(0,0,200,200);;
@ -97,7 +98,7 @@ void PreviewDriver::CopyBits(BRect src, BRect dest)
view->viewbmp->Unlock();
}
void PreviewDriver::DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest)
void PreviewDriver::DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d)
{
}

View File

@ -11,10 +11,10 @@
#include <Region.h>
#include "DisplayDriver.h"
class BBitmap;
class PortLink;
class ServerCursor;
class ColorSet;
class PVView : public BView
{
@ -38,7 +38,7 @@ public:
virtual bool Initialize(void);
virtual void Shutdown(void);
virtual void CopyBits(BRect src, BRect dest);
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest);
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d);
virtual void DrawChar(char c, BPoint pt);
// virtual void DrawPicture(SPicture *pic, BPoint pt);
// virtual void DrawString(const char *string, int32 length, BPoint pt, escapement_delta *delta=NULL);
@ -76,4 +76,4 @@ protected:
extern BRect preview_bounds;
#endif
#endif

View File

@ -1,31 +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 <bpmagic@columbus.rr.com>
// Description: Color encapsulation class for the app_server
//
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
#include <stdio.h>
#include "RGBColor.h"
RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
// Local Includes --------------------------------------------------------------
#include "RGBColor.h"
#include "SystemPalette.h"
#include <ColorUtils.h>
/*!
\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;
@ -33,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;
@ -61,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;
@ -89,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;
@ -98,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;
@ -113,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);
@ -146,18 +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;
}

View File

@ -1,29 +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 <bpmagic@columbus.rr.com>
// 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;

View File

@ -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 <bpmagic@columbus.rr.com>
// 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;
}
}

View File

@ -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 <bpmagic@columbus.rr.com>
// 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

View File

@ -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 <bpmagic@columbus.rr.com>
// 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());
}

View File

@ -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 <bpmagic@columbus.rr.com>
// 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

View File

@ -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 <bpmagic@columbus.rr.com>
// 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;
}
}

View File

@ -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 <bpmagic@columbus.rr.com>
// 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