diff --git a/src/add-ons/decorators/BeDecorator/ColorSet.cpp b/src/add-ons/decorators/BeDecorator/ColorSet.cpp deleted file mode 100644 index 16939959d9..0000000000 --- a/src/add-ons/decorators/BeDecorator/ColorSet.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Class for encapsulating GUI system colors -// -// -//------------------------------------------------------------------------------ -#include -#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_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_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; - 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_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_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; - inactive_window_tab=cs.inactive_window_tab; - inactive_window_tab_text=cs.inactive_window_tab_text; -} - -/*! - \brief Prints all color set elements to stdout -*/ -void ColorSet::PrintToStream(void) -{ - printf("panel_background "); panel_background.PrintToStream(); - printf("panel_text "); panel_text.PrintToStream(); - - printf("document_background "); document_background.PrintToStream(); - printf("document_text "); document_text.PrintToStream(); - - printf("control_background "); control_background.PrintToStream(); - printf("control_text "); control_text.PrintToStream(); - printf("control_highlight "); control_highlight.PrintToStream(); - printf("control_border "); control_border.PrintToStream(); - - printf("tooltip_background "); tooltip_background.PrintToStream(); - printf("tooltip_text "); tooltip_text.PrintToStream(); - - printf("menu_background "); menu_background.PrintToStream(); - printf("menu_selected_background "); menu_selected_background.PrintToStream(); - printf("menu_text "); menu_text.PrintToStream(); - printf("menu_selected_text "); menu_selected_text.PrintToStream(); - printf("menu_selected_border "); menu_selected_border.PrintToStream(); - - printf("keyboard_navigation_base "); keyboard_navigation_base.PrintToStream(); - printf("keyboard_navigation_pulse "); keyboard_navigation_pulse.PrintToStream(); - - printf("success "); success.PrintToStream(); - printf("failure "); failure.PrintToStream(); - printf("shine "); shine.PrintToStream(); - printf("shadow "); shadow.PrintToStream(); - - printf("window_tab "); window_tab.PrintToStream(); - printf("window_tab_text "); window_tab_text.PrintToStream(); - - printf("inactive_window_tab "); inactive_window_tab.PrintToStream(); - printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream(); -} diff --git a/src/add-ons/decorators/BeDecorator/ColorSet.h b/src/add-ons/decorators/BeDecorator/ColorSet.h deleted file mode 100644 index ce08a053eb..0000000000 --- a/src/add-ons/decorators/BeDecorator/ColorSet.h +++ /dev/null @@ -1,82 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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: - ColorSet(void); - ColorSet(const ColorSet &cs); - ColorSet & operator=(const ColorSet &cs); - void SetColors(const ColorSet &cs); - void PrintToStream(void); - - RGBColor panel_background, - panel_text, - - document_background, - document_text, - - control_background, - control_text, - control_highlight, - control_border, - - tooltip_background, - tooltip_text, - - menu_background, - menu_selected_background, - menu_text, - menu_selected_text, - 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, - inactive_window_tab, - inactive_window_tab_text; -}; - -#endif diff --git a/src/add-ons/decorators/BeDecorator/Decorator.cpp b/src/add-ons/decorators/BeDecorator/Decorator.cpp deleted file mode 100644 index 2c47579938..0000000000 --- a/src/add-ons/decorators/BeDecorator/Decorator.cpp +++ /dev/null @@ -1,563 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Base class for window decorators -// -//------------------------------------------------------------------------------ -#include -#include "ColorSet.h" -#include "Decorator.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; - _has_focus=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)); - - _look=wlook; - _feel=wfeel; - _flags=wflags; - - _colors=new ColorSet(); -} - -/*! - \brief Destructor - - Frees the color set and the title string -*/ -Decorator::~Decorator(void) -{ - if(_colors!=NULL) - { - delete _colors; - _colors=NULL; - } - if(_title_string) - delete _title_string; -} - -/*! - \brief Updates the decorator's color set - \param cset The color set to update from -*/ -void Decorator::SetColors(const ColorSet &cset) -{ - _colors->SetColors(cset); - _SetColors(); -} - -/*! - \brief Assigns a display driver to the decorator - \param driver A valid DisplayDriver object -*/ -void Decorator::SetDriver(DisplayDriver *driver) -{ - // 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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \brief Returns the value of the close button - \return true if down, false if up -*/ -bool Decorator::GetClose(void) -{ - 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; -} - -/*! - \brief Returns the value of the zoom button - \return true if down, false if up -*/ -bool Decorator::GetZoom(void) -{ - return _zoom_state; -} - -/*! - \brief Returns the decorator's window look - \return the decorator's window look -*/ -int32 Decorator::GetLook(void) -{ - return _look; -} - -/*! - \brief Returns the decorator's window feel - \return the decorator's window feel -*/ -int32 Decorator::GetFeel(void) -{ - return _feel; -} - -/*! - \brief Returns the decorator's window flags - \return the decorator's window flags -*/ -int32 Decorator::GetFlags(void) -{ - return _flags; -} - -/*! - \brief Updates the value of the decorator title - \param string New title value -*/ -void Decorator::SetTitle(const char *string) -{ - _title_string->SetTo(string); - _DoLayout(); -} - -/*! - \brief Returns the decorator's title - \return the decorator's title -*/ -const char *Decorator::GetTitle(void) -{ - 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; - _SetFocus(); -} - -/*! - \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 -*/ -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(pixwidthStringWidth(_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) -{ - 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); -} - -//! Forces a complete decorator update -void Decorator::Draw(void) -{ - _DrawTab(_tabrect); - _DrawFrame(_frame); -} - -//! Draws the close button -void Decorator::DrawClose(void) -{ - _DrawClose(_closerect); -} - -//! draws the frame -void Decorator::DrawFrame(void) -{ - _DrawFrame(_frame); -} - -//! draws the minimize button -void Decorator::DrawMinimize(void) -{ - _DrawTab(_minimizerect); -} - -//! draws the tab, title, and buttons -void Decorator::DrawTab(void) -{ - _DrawTab(_tabrect); - _DrawZoom(_zoomrect); - _DrawMinimize(_minimizerect); - _DrawTitle(_tabrect); - _DrawClose(_closerect); -} - -// draws the title -void Decorator::DrawTitle(void) -{ - _DrawTitle(_tabrect); -} - -//! draws the zoom button -void Decorator::DrawZoom(void) -{ - _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) -{ -} - -/*! - \brief Hook function for when the color set is updated - - This function is called after the decorator's color set is updated. Quite useful - if the decorator uses colors based on those in the system. -*/ -void Decorator::_SetColors(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) -{ - return CLICK_NONE; -} - -//! Hook function called when the decorator changes focus -void Decorator::_SetFocus(void) -{ -} - -//! Function for calculating layout for the decorator -void Decorator::_DoLayout(void) -{ - -} diff --git a/src/add-ons/decorators/BeDecorator/Decorator.h b/src/add-ons/decorators/BeDecorator/Decorator.h deleted file mode 100644 index 82aaf070ad..0000000000 --- a/src/add-ons/decorators/BeDecorator/Decorator.h +++ /dev/null @@ -1,131 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Base class for window decorators -// -//------------------------------------------------------------------------------ -#ifndef _DECORATOR_H_ -#define _DECORATOR_H_ - -#include -#include -#include -#include -#include -#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_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; - -class Decorator -{ -public: - Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); - virtual ~Decorator(void); - - void SetColors(const ColorSet &cset); - void SetDriver(DisplayDriver *driver); - void SetFlags(int32 wflags); - void SetFeel(int32 wfeel); - void SetLook(int32 wlook); - - 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); - const char *GetTitle(void); - - 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); - virtual void DrawFrame(void); - virtual void DrawMinimize(void); - virtual void DrawTab(void); - virtual void DrawTitle(void); - virtual void DrawZoom(void); - -protected: - int32 _ClipTitle(float width); - - /*! - \brief Returns the number of characters in the title - \return The title character count - */ - 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); - virtual void _DrawTab(BRect r); - virtual void _DrawTitle(BRect r); - virtual void _DrawZoom(BRect r); - virtual void _SetFocus(void); - virtual void _DoLayout(void); - virtual void _SetColors(void); - - 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; - BString *_title_string; -}; - -typedef float get_version(void); -typedef Decorator *create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); - -#endif diff --git a/src/add-ons/decorators/BeDecorator/DisplayDriver.cpp b/src/add-ons/decorators/BeDecorator/DisplayDriver.cpp deleted file mode 100644 index 89d2749396..0000000000 --- a/src/add-ons/decorators/BeDecorator/DisplayDriver.cpp +++ /dev/null @@ -1,712 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Mostly abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ -#include "DisplayDriver.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; - - _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); -} - -/*! - \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; -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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; -} - -/*! - \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) -{ - return 0.0; -} - -/*! - \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) -{ - return 0.0; -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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; -} - diff --git a/src/add-ons/decorators/BeDecorator/DisplayDriver.h b/src/add-ons/decorators/BeDecorator/DisplayDriver.h deleted file mode 100644 index 1bb5de2cdf..0000000000 --- a/src/add-ons/decorators/BeDecorator/DisplayDriver.h +++ /dev/null @@ -1,170 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Mostly abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ -#ifndef _DISPLAY_DRIVER_H_ -#define _DISPLAY_DRIVER_H_ - -#include -#include - -#include -#include -#include -#include "RGBColor.h" - -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; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -/*! - \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 -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - virtual bool Initialize(void); - 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: - 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; - bool _is_cursor_hidden; - bool _is_cursor_obscured; - ServerCursor *_cursor; -}; - -#endif diff --git a/src/add-ons/decorators/BeDecorator/Jamfile b/src/add-ons/decorators/BeDecorator/Jamfile index 20541711ab..353fa6fbc7 100644 --- a/src/add-ons/decorators/BeDecorator/Jamfile +++ b/src/add-ons/decorators/BeDecorator/Jamfile @@ -1,14 +1,11 @@ SubDir OBOS_TOP src add-ons decorators BeDecorator ; +UseFreeTypeHeaders ; +UseHeaders [ FDirName $(OBOS_TOP) src servers app server ] ; +UsePrivateHeaders [ FDirName servers app ] ; + Addon BeDecorator : decorators : BeDecorator.cpp - ColorSet.cpp - Decorator.cpp - DisplayDriver.cpp - RGBColor.cpp - ServerBitmap.cpp - ServerCursor.cpp - SystemPalette.cpp + : false + : be libopenbeos.so libappserver.so ; - -LinkSharedOSLibs BeDecorator : be libopenbeos.so ; diff --git a/src/add-ons/decorators/BeDecorator/LayerData.h b/src/add-ons/decorators/BeDecorator/LayerData.h deleted file mode 100644 index 11a67c7fa1..0000000000 --- a/src/add-ons/decorators/BeDecorator/LayerData.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef LAYERDATA_H_ -#define LAYERDATA_H_ - -#include -#include -class ServerBitmap; - -class LayerData -{ -public: -LayerData(void) - { - pensize=1.0; - penlocation.Set(0,0); - draw_mode=B_OP_COPY; - background=NULL; - overlay=NULL; - highcolor.SetColor(0,0,0,255); - lowcolor.SetColor(255,255,255,255); - //SFont font; - //bool antialias_text; - scale=1.0; - }; - - float pensize; - BPoint penlocation; - drawing_mode draw_mode; - source_alpha alpha_mode; - alpha_function blending_mode; - ServerBitmap *background; - ServerBitmap *overlay; - RGBColor highcolor, lowcolor, viewcolor; -// ServerFont *font; - float scale; - escapement_delta edelta; -}; - - -#endif diff --git a/src/add-ons/decorators/BeDecorator/RGBColor.cpp b/src/add-ons/decorators/BeDecorator/RGBColor.cpp deleted file mode 100644 index 7119e4f554..0000000000 --- a/src/add-ons/decorators/BeDecorator/RGBColor.cpp +++ /dev/null @@ -1,316 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Color encapsulation class for the app_server -// -//------------------------------------------------------------------------------ - -// Standard Includes ----------------------------------------------------------- -#include - -// Local Includes -------------------------------------------------------------- -#include "RGBColor.h" -#include "SystemPalette.h" -#include - -/*! - \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); -} - -/*! - \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; - color16=col.color16; - 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; - color32.green=g; - color32.blue=b; - 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) -{ - 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) -{ - color8=col8; - color32=system_palette[col8]; - color16=FindClosestColor16(color32); -} - -/*! - \brief Set the object to specified color - \param color color to copy -*/ -void RGBColor::SetColor(const rgb_color &color) -{ - 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; - color16=col.color16; - color8=col.color8; -} - -/*! - \brief Set the object to specified color - \param col color to copy -*/ -RGBColor & RGBColor::operator=(const RGBColor &col) -{ - color32=col.color32; - color16=col.color16; - color8=col.color8; - return *this; -} - -/*! - \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; - rgb_color col2=color.color32; - - rgb_color newcol={0,0,0,0}; - float mod=0; - int16 delta; - if(position<0 || position>1) - return *this; - - delta=int16(col2.red)-int16(col.red); - mod=col.red + (position * delta); - newcol.red=uint8(mod); - if(mod>255 ) - newcol.red=255; - if(mod<0 ) - newcol.red=0; - - delta=int16(col2.green)-int16(col.green); - mod=col.green + (position * delta); - newcol.green=uint8(mod); - if(mod>255 ) - newcol.green=255; - if(mod<0 ) - newcol.green=0; - - delta=int16(col2.blue)-int16(col.blue); - mod=col.blue + (position * delta); - newcol.blue=uint8(mod); - if(mod>255 ) - newcol.blue=255; - if(mod<0 ) - newcol.blue=0; - - delta=int8(col2.alpha)-int8(col.alpha); - mod=col.alpha + (position * delta); - newcol.alpha=uint8(mod); - if(mod>255 ) - newcol.alpha=255; - if(mod<0 ) - newcol.alpha=0; - - 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; -} diff --git a/src/add-ons/decorators/BeDecorator/RGBColor.h b/src/add-ons/decorators/BeDecorator/RGBColor.h deleted file mode 100644 index e6a2622370..0000000000 --- a/src/add-ons/decorators/BeDecorator/RGBColor.h +++ /dev/null @@ -1,77 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Color encapsulation class for the app_server -// -//------------------------------------------------------------------------------ -#ifndef RGBCOLOR_H_ -#define RGBCOLOR_H_ - -#include - -/*! - \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(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(const rgb_color &color); - void SetColor(const RGBColor &col); - - RGBColor MakeBlendColor(RGBColor color, float position); - - RGBColor & operator=(const RGBColor &col); - RGBColor & operator=(const rgb_color &col); - bool operator==(const rgb_color &col); - bool operator==(const RGBColor &col); -protected: - rgb_color color32; - uint16 color16; - uint8 color8; -}; - -#endif diff --git a/src/add-ons/decorators/BeDecorator/ServerBitmap.cpp b/src/add-ons/decorators/BeDecorator/ServerBitmap.cpp deleted file mode 100644 index 4d00102d28..0000000000 --- a/src/add-ons/decorators/BeDecorator/ServerBitmap.cpp +++ /dev/null @@ -1,225 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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 -// Description: Bitmap class used inside the server -// -//------------------------------------------------------------------------------ -#ifndef _SERVER_BITMAP_H_ -#define _SERVER_BITMAP_H_ - -#include -#include -#include - -/*! - \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 diff --git a/src/add-ons/decorators/BeDecorator/ServerCursor.cpp b/src/add-ons/decorators/BeDecorator/ServerCursor.cpp deleted file mode 100644 index 404dd9e8ce..0000000000 --- a/src/add-ons/decorators/BeDecorator/ServerCursor.cpp +++ /dev/null @@ -1,142 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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()); -} diff --git a/src/add-ons/decorators/BeDecorator/ServerCursor.h b/src/add-ons/decorators/BeDecorator/ServerCursor.h deleted file mode 100644 index 93e9f89d71..0000000000 --- a/src/add-ons/decorators/BeDecorator/ServerCursor.h +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Glorified ServerBitmap used for cursor work. -// -//------------------------------------------------------------------------------ -#ifndef SERVERCURSOR_H_ -#define SERVERCURSOR_H_ - -#include -#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 diff --git a/src/add-ons/decorators/BeDecorator/SystemPalette.cpp b/src/add-ons/decorators/BeDecorator/SystemPalette.cpp deleted file mode 100644 index 5505e075f0..0000000000 --- a/src/add-ons/decorators/BeDecorator/SystemPalette.cpp +++ /dev/null @@ -1,361 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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; - } - -} diff --git a/src/add-ons/decorators/BeDecorator/SystemPalette.h b/src/add-ons/decorators/BeDecorator/SystemPalette.h deleted file mode 100644 index 386a5406e6..0000000000 --- a/src/add-ons/decorators/BeDecorator/SystemPalette.h +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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 - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color system_palette[]; - -#endif diff --git a/src/add-ons/decorators/MacDecorator/ColorSet.cpp b/src/add-ons/decorators/MacDecorator/ColorSet.cpp deleted file mode 100644 index 16939959d9..0000000000 --- a/src/add-ons/decorators/MacDecorator/ColorSet.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Class for encapsulating GUI system colors -// -// -//------------------------------------------------------------------------------ -#include -#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_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_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; - 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_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_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; - inactive_window_tab=cs.inactive_window_tab; - inactive_window_tab_text=cs.inactive_window_tab_text; -} - -/*! - \brief Prints all color set elements to stdout -*/ -void ColorSet::PrintToStream(void) -{ - printf("panel_background "); panel_background.PrintToStream(); - printf("panel_text "); panel_text.PrintToStream(); - - printf("document_background "); document_background.PrintToStream(); - printf("document_text "); document_text.PrintToStream(); - - printf("control_background "); control_background.PrintToStream(); - printf("control_text "); control_text.PrintToStream(); - printf("control_highlight "); control_highlight.PrintToStream(); - printf("control_border "); control_border.PrintToStream(); - - printf("tooltip_background "); tooltip_background.PrintToStream(); - printf("tooltip_text "); tooltip_text.PrintToStream(); - - printf("menu_background "); menu_background.PrintToStream(); - printf("menu_selected_background "); menu_selected_background.PrintToStream(); - printf("menu_text "); menu_text.PrintToStream(); - printf("menu_selected_text "); menu_selected_text.PrintToStream(); - printf("menu_selected_border "); menu_selected_border.PrintToStream(); - - printf("keyboard_navigation_base "); keyboard_navigation_base.PrintToStream(); - printf("keyboard_navigation_pulse "); keyboard_navigation_pulse.PrintToStream(); - - printf("success "); success.PrintToStream(); - printf("failure "); failure.PrintToStream(); - printf("shine "); shine.PrintToStream(); - printf("shadow "); shadow.PrintToStream(); - - printf("window_tab "); window_tab.PrintToStream(); - printf("window_tab_text "); window_tab_text.PrintToStream(); - - printf("inactive_window_tab "); inactive_window_tab.PrintToStream(); - printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream(); -} diff --git a/src/add-ons/decorators/MacDecorator/ColorSet.h b/src/add-ons/decorators/MacDecorator/ColorSet.h deleted file mode 100644 index ce08a053eb..0000000000 --- a/src/add-ons/decorators/MacDecorator/ColorSet.h +++ /dev/null @@ -1,82 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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: - ColorSet(void); - ColorSet(const ColorSet &cs); - ColorSet & operator=(const ColorSet &cs); - void SetColors(const ColorSet &cs); - void PrintToStream(void); - - RGBColor panel_background, - panel_text, - - document_background, - document_text, - - control_background, - control_text, - control_highlight, - control_border, - - tooltip_background, - tooltip_text, - - menu_background, - menu_selected_background, - menu_text, - menu_selected_text, - 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, - inactive_window_tab, - inactive_window_tab_text; -}; - -#endif diff --git a/src/add-ons/decorators/MacDecorator/Decorator.cpp b/src/add-ons/decorators/MacDecorator/Decorator.cpp deleted file mode 100644 index 2c47579938..0000000000 --- a/src/add-ons/decorators/MacDecorator/Decorator.cpp +++ /dev/null @@ -1,563 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Base class for window decorators -// -//------------------------------------------------------------------------------ -#include -#include "ColorSet.h" -#include "Decorator.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; - _has_focus=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)); - - _look=wlook; - _feel=wfeel; - _flags=wflags; - - _colors=new ColorSet(); -} - -/*! - \brief Destructor - - Frees the color set and the title string -*/ -Decorator::~Decorator(void) -{ - if(_colors!=NULL) - { - delete _colors; - _colors=NULL; - } - if(_title_string) - delete _title_string; -} - -/*! - \brief Updates the decorator's color set - \param cset The color set to update from -*/ -void Decorator::SetColors(const ColorSet &cset) -{ - _colors->SetColors(cset); - _SetColors(); -} - -/*! - \brief Assigns a display driver to the decorator - \param driver A valid DisplayDriver object -*/ -void Decorator::SetDriver(DisplayDriver *driver) -{ - // 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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \brief Returns the value of the close button - \return true if down, false if up -*/ -bool Decorator::GetClose(void) -{ - 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; -} - -/*! - \brief Returns the value of the zoom button - \return true if down, false if up -*/ -bool Decorator::GetZoom(void) -{ - return _zoom_state; -} - -/*! - \brief Returns the decorator's window look - \return the decorator's window look -*/ -int32 Decorator::GetLook(void) -{ - return _look; -} - -/*! - \brief Returns the decorator's window feel - \return the decorator's window feel -*/ -int32 Decorator::GetFeel(void) -{ - return _feel; -} - -/*! - \brief Returns the decorator's window flags - \return the decorator's window flags -*/ -int32 Decorator::GetFlags(void) -{ - return _flags; -} - -/*! - \brief Updates the value of the decorator title - \param string New title value -*/ -void Decorator::SetTitle(const char *string) -{ - _title_string->SetTo(string); - _DoLayout(); -} - -/*! - \brief Returns the decorator's title - \return the decorator's title -*/ -const char *Decorator::GetTitle(void) -{ - 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; - _SetFocus(); -} - -/*! - \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 -*/ -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(pixwidthStringWidth(_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) -{ - 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); -} - -//! Forces a complete decorator update -void Decorator::Draw(void) -{ - _DrawTab(_tabrect); - _DrawFrame(_frame); -} - -//! Draws the close button -void Decorator::DrawClose(void) -{ - _DrawClose(_closerect); -} - -//! draws the frame -void Decorator::DrawFrame(void) -{ - _DrawFrame(_frame); -} - -//! draws the minimize button -void Decorator::DrawMinimize(void) -{ - _DrawTab(_minimizerect); -} - -//! draws the tab, title, and buttons -void Decorator::DrawTab(void) -{ - _DrawTab(_tabrect); - _DrawZoom(_zoomrect); - _DrawMinimize(_minimizerect); - _DrawTitle(_tabrect); - _DrawClose(_closerect); -} - -// draws the title -void Decorator::DrawTitle(void) -{ - _DrawTitle(_tabrect); -} - -//! draws the zoom button -void Decorator::DrawZoom(void) -{ - _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) -{ -} - -/*! - \brief Hook function for when the color set is updated - - This function is called after the decorator's color set is updated. Quite useful - if the decorator uses colors based on those in the system. -*/ -void Decorator::_SetColors(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) -{ - return CLICK_NONE; -} - -//! Hook function called when the decorator changes focus -void Decorator::_SetFocus(void) -{ -} - -//! Function for calculating layout for the decorator -void Decorator::_DoLayout(void) -{ - -} diff --git a/src/add-ons/decorators/MacDecorator/Decorator.h b/src/add-ons/decorators/MacDecorator/Decorator.h deleted file mode 100644 index 82aaf070ad..0000000000 --- a/src/add-ons/decorators/MacDecorator/Decorator.h +++ /dev/null @@ -1,131 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Base class for window decorators -// -//------------------------------------------------------------------------------ -#ifndef _DECORATOR_H_ -#define _DECORATOR_H_ - -#include -#include -#include -#include -#include -#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_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; - -class Decorator -{ -public: - Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); - virtual ~Decorator(void); - - void SetColors(const ColorSet &cset); - void SetDriver(DisplayDriver *driver); - void SetFlags(int32 wflags); - void SetFeel(int32 wfeel); - void SetLook(int32 wlook); - - 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); - const char *GetTitle(void); - - 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); - virtual void DrawFrame(void); - virtual void DrawMinimize(void); - virtual void DrawTab(void); - virtual void DrawTitle(void); - virtual void DrawZoom(void); - -protected: - int32 _ClipTitle(float width); - - /*! - \brief Returns the number of characters in the title - \return The title character count - */ - 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); - virtual void _DrawTab(BRect r); - virtual void _DrawTitle(BRect r); - virtual void _DrawZoom(BRect r); - virtual void _SetFocus(void); - virtual void _DoLayout(void); - virtual void _SetColors(void); - - 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; - BString *_title_string; -}; - -typedef float get_version(void); -typedef Decorator *create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); - -#endif diff --git a/src/add-ons/decorators/MacDecorator/DisplayDriver.cpp b/src/add-ons/decorators/MacDecorator/DisplayDriver.cpp deleted file mode 100644 index 89d2749396..0000000000 --- a/src/add-ons/decorators/MacDecorator/DisplayDriver.cpp +++ /dev/null @@ -1,712 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Mostly abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ -#include "DisplayDriver.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; - - _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); -} - -/*! - \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; -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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; -} - -/*! - \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) -{ - return 0.0; -} - -/*! - \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) -{ - return 0.0; -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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; -} - diff --git a/src/add-ons/decorators/MacDecorator/DisplayDriver.h b/src/add-ons/decorators/MacDecorator/DisplayDriver.h deleted file mode 100644 index 1bb5de2cdf..0000000000 --- a/src/add-ons/decorators/MacDecorator/DisplayDriver.h +++ /dev/null @@ -1,170 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Mostly abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ -#ifndef _DISPLAY_DRIVER_H_ -#define _DISPLAY_DRIVER_H_ - -#include -#include - -#include -#include -#include -#include "RGBColor.h" - -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; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -/*! - \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 -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - virtual bool Initialize(void); - 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: - 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; - bool _is_cursor_hidden; - bool _is_cursor_obscured; - ServerCursor *_cursor; -}; - -#endif diff --git a/src/add-ons/decorators/MacDecorator/Jamfile b/src/add-ons/decorators/MacDecorator/Jamfile index da53091009..de41774c6e 100644 --- a/src/add-ons/decorators/MacDecorator/Jamfile +++ b/src/add-ons/decorators/MacDecorator/Jamfile @@ -1,14 +1,11 @@ SubDir OBOS_TOP src add-ons decorators MacDecorator ; +UseFreeTypeHeaders ; +UseHeaders [ FDirName $(OBOS_TOP) src servers app server ] ; +UsePrivateHeaders [ FDirName servers app ] ; + Addon MacDecorator : decorators : MacDecorator.cpp - ColorSet.cpp - Decorator.cpp - DisplayDriver.cpp - RGBColor.cpp - SystemPalette.cpp - ServerBitmap.cpp - ServerCursor.cpp + : false + : be libopenbeos.so libappserver.so ; - -LinkSharedOSLibs MacDecorator : be libopenbeos.so ; diff --git a/src/add-ons/decorators/MacDecorator/LayerData.h b/src/add-ons/decorators/MacDecorator/LayerData.h deleted file mode 100644 index 11a67c7fa1..0000000000 --- a/src/add-ons/decorators/MacDecorator/LayerData.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef LAYERDATA_H_ -#define LAYERDATA_H_ - -#include -#include -class ServerBitmap; - -class LayerData -{ -public: -LayerData(void) - { - pensize=1.0; - penlocation.Set(0,0); - draw_mode=B_OP_COPY; - background=NULL; - overlay=NULL; - highcolor.SetColor(0,0,0,255); - lowcolor.SetColor(255,255,255,255); - //SFont font; - //bool antialias_text; - scale=1.0; - }; - - float pensize; - BPoint penlocation; - drawing_mode draw_mode; - source_alpha alpha_mode; - alpha_function blending_mode; - ServerBitmap *background; - ServerBitmap *overlay; - RGBColor highcolor, lowcolor, viewcolor; -// ServerFont *font; - float scale; - escapement_delta edelta; -}; - - -#endif diff --git a/src/add-ons/decorators/MacDecorator/RGBColor.cpp b/src/add-ons/decorators/MacDecorator/RGBColor.cpp deleted file mode 100644 index 7119e4f554..0000000000 --- a/src/add-ons/decorators/MacDecorator/RGBColor.cpp +++ /dev/null @@ -1,316 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Color encapsulation class for the app_server -// -//------------------------------------------------------------------------------ - -// Standard Includes ----------------------------------------------------------- -#include - -// Local Includes -------------------------------------------------------------- -#include "RGBColor.h" -#include "SystemPalette.h" -#include - -/*! - \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); -} - -/*! - \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; - color16=col.color16; - 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; - color32.green=g; - color32.blue=b; - 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) -{ - 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) -{ - color8=col8; - color32=system_palette[col8]; - color16=FindClosestColor16(color32); -} - -/*! - \brief Set the object to specified color - \param color color to copy -*/ -void RGBColor::SetColor(const rgb_color &color) -{ - 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; - color16=col.color16; - color8=col.color8; -} - -/*! - \brief Set the object to specified color - \param col color to copy -*/ -RGBColor & RGBColor::operator=(const RGBColor &col) -{ - color32=col.color32; - color16=col.color16; - color8=col.color8; - return *this; -} - -/*! - \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; - rgb_color col2=color.color32; - - rgb_color newcol={0,0,0,0}; - float mod=0; - int16 delta; - if(position<0 || position>1) - return *this; - - delta=int16(col2.red)-int16(col.red); - mod=col.red + (position * delta); - newcol.red=uint8(mod); - if(mod>255 ) - newcol.red=255; - if(mod<0 ) - newcol.red=0; - - delta=int16(col2.green)-int16(col.green); - mod=col.green + (position * delta); - newcol.green=uint8(mod); - if(mod>255 ) - newcol.green=255; - if(mod<0 ) - newcol.green=0; - - delta=int16(col2.blue)-int16(col.blue); - mod=col.blue + (position * delta); - newcol.blue=uint8(mod); - if(mod>255 ) - newcol.blue=255; - if(mod<0 ) - newcol.blue=0; - - delta=int8(col2.alpha)-int8(col.alpha); - mod=col.alpha + (position * delta); - newcol.alpha=uint8(mod); - if(mod>255 ) - newcol.alpha=255; - if(mod<0 ) - newcol.alpha=0; - - 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; -} diff --git a/src/add-ons/decorators/MacDecorator/RGBColor.h b/src/add-ons/decorators/MacDecorator/RGBColor.h deleted file mode 100644 index e6a2622370..0000000000 --- a/src/add-ons/decorators/MacDecorator/RGBColor.h +++ /dev/null @@ -1,77 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Color encapsulation class for the app_server -// -//------------------------------------------------------------------------------ -#ifndef RGBCOLOR_H_ -#define RGBCOLOR_H_ - -#include - -/*! - \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(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(const rgb_color &color); - void SetColor(const RGBColor &col); - - RGBColor MakeBlendColor(RGBColor color, float position); - - RGBColor & operator=(const RGBColor &col); - RGBColor & operator=(const rgb_color &col); - bool operator==(const rgb_color &col); - bool operator==(const RGBColor &col); -protected: - rgb_color color32; - uint16 color16; - uint8 color8; -}; - -#endif diff --git a/src/add-ons/decorators/MacDecorator/ServerBitmap.cpp b/src/add-ons/decorators/MacDecorator/ServerBitmap.cpp deleted file mode 100644 index 4d00102d28..0000000000 --- a/src/add-ons/decorators/MacDecorator/ServerBitmap.cpp +++ /dev/null @@ -1,225 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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 -// Description: Bitmap class used inside the server -// -//------------------------------------------------------------------------------ -#ifndef _SERVER_BITMAP_H_ -#define _SERVER_BITMAP_H_ - -#include -#include -#include - -/*! - \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 diff --git a/src/add-ons/decorators/MacDecorator/ServerCursor.cpp b/src/add-ons/decorators/MacDecorator/ServerCursor.cpp deleted file mode 100644 index 404dd9e8ce..0000000000 --- a/src/add-ons/decorators/MacDecorator/ServerCursor.cpp +++ /dev/null @@ -1,142 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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()); -} diff --git a/src/add-ons/decorators/MacDecorator/ServerCursor.h b/src/add-ons/decorators/MacDecorator/ServerCursor.h deleted file mode 100644 index 93e9f89d71..0000000000 --- a/src/add-ons/decorators/MacDecorator/ServerCursor.h +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Glorified ServerBitmap used for cursor work. -// -//------------------------------------------------------------------------------ -#ifndef SERVERCURSOR_H_ -#define SERVERCURSOR_H_ - -#include -#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 diff --git a/src/add-ons/decorators/MacDecorator/SystemPalette.cpp b/src/add-ons/decorators/MacDecorator/SystemPalette.cpp deleted file mode 100644 index 5505e075f0..0000000000 --- a/src/add-ons/decorators/MacDecorator/SystemPalette.cpp +++ /dev/null @@ -1,361 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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; - } - -} diff --git a/src/add-ons/decorators/MacDecorator/SystemPalette.h b/src/add-ons/decorators/MacDecorator/SystemPalette.h deleted file mode 100644 index 386a5406e6..0000000000 --- a/src/add-ons/decorators/MacDecorator/SystemPalette.h +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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 - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color system_palette[]; - -#endif diff --git a/src/add-ons/decorators/WinDecorator/ColorSet.cpp b/src/add-ons/decorators/WinDecorator/ColorSet.cpp deleted file mode 100644 index 16939959d9..0000000000 --- a/src/add-ons/decorators/WinDecorator/ColorSet.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Class for encapsulating GUI system colors -// -// -//------------------------------------------------------------------------------ -#include -#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_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_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; - 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_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_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; - inactive_window_tab=cs.inactive_window_tab; - inactive_window_tab_text=cs.inactive_window_tab_text; -} - -/*! - \brief Prints all color set elements to stdout -*/ -void ColorSet::PrintToStream(void) -{ - printf("panel_background "); panel_background.PrintToStream(); - printf("panel_text "); panel_text.PrintToStream(); - - printf("document_background "); document_background.PrintToStream(); - printf("document_text "); document_text.PrintToStream(); - - printf("control_background "); control_background.PrintToStream(); - printf("control_text "); control_text.PrintToStream(); - printf("control_highlight "); control_highlight.PrintToStream(); - printf("control_border "); control_border.PrintToStream(); - - printf("tooltip_background "); tooltip_background.PrintToStream(); - printf("tooltip_text "); tooltip_text.PrintToStream(); - - printf("menu_background "); menu_background.PrintToStream(); - printf("menu_selected_background "); menu_selected_background.PrintToStream(); - printf("menu_text "); menu_text.PrintToStream(); - printf("menu_selected_text "); menu_selected_text.PrintToStream(); - printf("menu_selected_border "); menu_selected_border.PrintToStream(); - - printf("keyboard_navigation_base "); keyboard_navigation_base.PrintToStream(); - printf("keyboard_navigation_pulse "); keyboard_navigation_pulse.PrintToStream(); - - printf("success "); success.PrintToStream(); - printf("failure "); failure.PrintToStream(); - printf("shine "); shine.PrintToStream(); - printf("shadow "); shadow.PrintToStream(); - - printf("window_tab "); window_tab.PrintToStream(); - printf("window_tab_text "); window_tab_text.PrintToStream(); - - printf("inactive_window_tab "); inactive_window_tab.PrintToStream(); - printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream(); -} diff --git a/src/add-ons/decorators/WinDecorator/ColorSet.h b/src/add-ons/decorators/WinDecorator/ColorSet.h deleted file mode 100644 index ce08a053eb..0000000000 --- a/src/add-ons/decorators/WinDecorator/ColorSet.h +++ /dev/null @@ -1,82 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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: - ColorSet(void); - ColorSet(const ColorSet &cs); - ColorSet & operator=(const ColorSet &cs); - void SetColors(const ColorSet &cs); - void PrintToStream(void); - - RGBColor panel_background, - panel_text, - - document_background, - document_text, - - control_background, - control_text, - control_highlight, - control_border, - - tooltip_background, - tooltip_text, - - menu_background, - menu_selected_background, - menu_text, - menu_selected_text, - 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, - inactive_window_tab, - inactive_window_tab_text; -}; - -#endif diff --git a/src/add-ons/decorators/WinDecorator/Decorator.cpp b/src/add-ons/decorators/WinDecorator/Decorator.cpp deleted file mode 100644 index 2c47579938..0000000000 --- a/src/add-ons/decorators/WinDecorator/Decorator.cpp +++ /dev/null @@ -1,563 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Base class for window decorators -// -//------------------------------------------------------------------------------ -#include -#include "ColorSet.h" -#include "Decorator.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; - _has_focus=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)); - - _look=wlook; - _feel=wfeel; - _flags=wflags; - - _colors=new ColorSet(); -} - -/*! - \brief Destructor - - Frees the color set and the title string -*/ -Decorator::~Decorator(void) -{ - if(_colors!=NULL) - { - delete _colors; - _colors=NULL; - } - if(_title_string) - delete _title_string; -} - -/*! - \brief Updates the decorator's color set - \param cset The color set to update from -*/ -void Decorator::SetColors(const ColorSet &cset) -{ - _colors->SetColors(cset); - _SetColors(); -} - -/*! - \brief Assigns a display driver to the decorator - \param driver A valid DisplayDriver object -*/ -void Decorator::SetDriver(DisplayDriver *driver) -{ - // 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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \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; -} - -/*! - \brief Returns the value of the close button - \return true if down, false if up -*/ -bool Decorator::GetClose(void) -{ - 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; -} - -/*! - \brief Returns the value of the zoom button - \return true if down, false if up -*/ -bool Decorator::GetZoom(void) -{ - return _zoom_state; -} - -/*! - \brief Returns the decorator's window look - \return the decorator's window look -*/ -int32 Decorator::GetLook(void) -{ - return _look; -} - -/*! - \brief Returns the decorator's window feel - \return the decorator's window feel -*/ -int32 Decorator::GetFeel(void) -{ - return _feel; -} - -/*! - \brief Returns the decorator's window flags - \return the decorator's window flags -*/ -int32 Decorator::GetFlags(void) -{ - return _flags; -} - -/*! - \brief Updates the value of the decorator title - \param string New title value -*/ -void Decorator::SetTitle(const char *string) -{ - _title_string->SetTo(string); - _DoLayout(); -} - -/*! - \brief Returns the decorator's title - \return the decorator's title -*/ -const char *Decorator::GetTitle(void) -{ - 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; - _SetFocus(); -} - -/*! - \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 -*/ -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(pixwidthStringWidth(_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) -{ - 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); -} - -//! Forces a complete decorator update -void Decorator::Draw(void) -{ - _DrawTab(_tabrect); - _DrawFrame(_frame); -} - -//! Draws the close button -void Decorator::DrawClose(void) -{ - _DrawClose(_closerect); -} - -//! draws the frame -void Decorator::DrawFrame(void) -{ - _DrawFrame(_frame); -} - -//! draws the minimize button -void Decorator::DrawMinimize(void) -{ - _DrawTab(_minimizerect); -} - -//! draws the tab, title, and buttons -void Decorator::DrawTab(void) -{ - _DrawTab(_tabrect); - _DrawZoom(_zoomrect); - _DrawMinimize(_minimizerect); - _DrawTitle(_tabrect); - _DrawClose(_closerect); -} - -// draws the title -void Decorator::DrawTitle(void) -{ - _DrawTitle(_tabrect); -} - -//! draws the zoom button -void Decorator::DrawZoom(void) -{ - _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) -{ -} - -/*! - \brief Hook function for when the color set is updated - - This function is called after the decorator's color set is updated. Quite useful - if the decorator uses colors based on those in the system. -*/ -void Decorator::_SetColors(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) -{ - return CLICK_NONE; -} - -//! Hook function called when the decorator changes focus -void Decorator::_SetFocus(void) -{ -} - -//! Function for calculating layout for the decorator -void Decorator::_DoLayout(void) -{ - -} diff --git a/src/add-ons/decorators/WinDecorator/Decorator.h b/src/add-ons/decorators/WinDecorator/Decorator.h deleted file mode 100644 index 82aaf070ad..0000000000 --- a/src/add-ons/decorators/WinDecorator/Decorator.h +++ /dev/null @@ -1,131 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Base class for window decorators -// -//------------------------------------------------------------------------------ -#ifndef _DECORATOR_H_ -#define _DECORATOR_H_ - -#include -#include -#include -#include -#include -#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_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; - -class Decorator -{ -public: - Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); - virtual ~Decorator(void); - - void SetColors(const ColorSet &cset); - void SetDriver(DisplayDriver *driver); - void SetFlags(int32 wflags); - void SetFeel(int32 wfeel); - void SetLook(int32 wlook); - - 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); - const char *GetTitle(void); - - 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); - virtual void DrawFrame(void); - virtual void DrawMinimize(void); - virtual void DrawTab(void); - virtual void DrawTitle(void); - virtual void DrawZoom(void); - -protected: - int32 _ClipTitle(float width); - - /*! - \brief Returns the number of characters in the title - \return The title character count - */ - 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); - virtual void _DrawTab(BRect r); - virtual void _DrawTitle(BRect r); - virtual void _DrawZoom(BRect r); - virtual void _SetFocus(void); - virtual void _DoLayout(void); - virtual void _SetColors(void); - - 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; - BString *_title_string; -}; - -typedef float get_version(void); -typedef Decorator *create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); - -#endif diff --git a/src/add-ons/decorators/WinDecorator/DisplayDriver.cpp b/src/add-ons/decorators/WinDecorator/DisplayDriver.cpp deleted file mode 100644 index 89d2749396..0000000000 --- a/src/add-ons/decorators/WinDecorator/DisplayDriver.cpp +++ /dev/null @@ -1,712 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Mostly abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ -#include "DisplayDriver.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; - - _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); -} - -/*! - \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; -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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; -} - -/*! - \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) -{ - return 0.0; -} - -/*! - \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) -{ - return 0.0; -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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) -{ -} - -/*! - \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; -} - diff --git a/src/add-ons/decorators/WinDecorator/DisplayDriver.h b/src/add-ons/decorators/WinDecorator/DisplayDriver.h deleted file mode 100644 index 1bb5de2cdf..0000000000 --- a/src/add-ons/decorators/WinDecorator/DisplayDriver.h +++ /dev/null @@ -1,170 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Mostly abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ -#ifndef _DISPLAY_DRIVER_H_ -#define _DISPLAY_DRIVER_H_ - -#include -#include - -#include -#include -#include -#include "RGBColor.h" - -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; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -/*! - \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 -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - virtual bool Initialize(void); - 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: - 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; - bool _is_cursor_hidden; - bool _is_cursor_obscured; - ServerCursor *_cursor; -}; - -#endif diff --git a/src/add-ons/decorators/WinDecorator/Jamfile b/src/add-ons/decorators/WinDecorator/Jamfile index c19a2e6c75..00e74debc6 100644 --- a/src/add-ons/decorators/WinDecorator/Jamfile +++ b/src/add-ons/decorators/WinDecorator/Jamfile @@ -1,14 +1,11 @@ SubDir OBOS_TOP src add-ons decorators WinDecorator ; +UseFreeTypeHeaders ; +UseHeaders [ FDirName $(OBOS_TOP) src servers app server ] ; +UsePrivateHeaders [ FDirName servers app ] ; + Addon WinDecorator : decorators : WinDecorator.cpp - ColorSet.cpp - Decorator.cpp - DisplayDriver.cpp - RGBColor.cpp - SystemPalette.cpp - ServerBitmap.cpp - ServerCursor.cpp + : false + : be libopenbeos.so libappserver.so ; - -LinkSharedOSLibs WinDecorator : be libopenbeos.so ; diff --git a/src/add-ons/decorators/WinDecorator/LayerData.h b/src/add-ons/decorators/WinDecorator/LayerData.h deleted file mode 100644 index 11a67c7fa1..0000000000 --- a/src/add-ons/decorators/WinDecorator/LayerData.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef LAYERDATA_H_ -#define LAYERDATA_H_ - -#include -#include -class ServerBitmap; - -class LayerData -{ -public: -LayerData(void) - { - pensize=1.0; - penlocation.Set(0,0); - draw_mode=B_OP_COPY; - background=NULL; - overlay=NULL; - highcolor.SetColor(0,0,0,255); - lowcolor.SetColor(255,255,255,255); - //SFont font; - //bool antialias_text; - scale=1.0; - }; - - float pensize; - BPoint penlocation; - drawing_mode draw_mode; - source_alpha alpha_mode; - alpha_function blending_mode; - ServerBitmap *background; - ServerBitmap *overlay; - RGBColor highcolor, lowcolor, viewcolor; -// ServerFont *font; - float scale; - escapement_delta edelta; -}; - - -#endif diff --git a/src/add-ons/decorators/WinDecorator/RGBColor.cpp b/src/add-ons/decorators/WinDecorator/RGBColor.cpp deleted file mode 100644 index 7119e4f554..0000000000 --- a/src/add-ons/decorators/WinDecorator/RGBColor.cpp +++ /dev/null @@ -1,316 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Color encapsulation class for the app_server -// -//------------------------------------------------------------------------------ - -// Standard Includes ----------------------------------------------------------- -#include - -// Local Includes -------------------------------------------------------------- -#include "RGBColor.h" -#include "SystemPalette.h" -#include - -/*! - \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); -} - -/*! - \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; - color16=col.color16; - 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; - color32.green=g; - color32.blue=b; - 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) -{ - 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) -{ - color8=col8; - color32=system_palette[col8]; - color16=FindClosestColor16(color32); -} - -/*! - \brief Set the object to specified color - \param color color to copy -*/ -void RGBColor::SetColor(const rgb_color &color) -{ - 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; - color16=col.color16; - color8=col.color8; -} - -/*! - \brief Set the object to specified color - \param col color to copy -*/ -RGBColor & RGBColor::operator=(const RGBColor &col) -{ - color32=col.color32; - color16=col.color16; - color8=col.color8; - return *this; -} - -/*! - \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; - rgb_color col2=color.color32; - - rgb_color newcol={0,0,0,0}; - float mod=0; - int16 delta; - if(position<0 || position>1) - return *this; - - delta=int16(col2.red)-int16(col.red); - mod=col.red + (position * delta); - newcol.red=uint8(mod); - if(mod>255 ) - newcol.red=255; - if(mod<0 ) - newcol.red=0; - - delta=int16(col2.green)-int16(col.green); - mod=col.green + (position * delta); - newcol.green=uint8(mod); - if(mod>255 ) - newcol.green=255; - if(mod<0 ) - newcol.green=0; - - delta=int16(col2.blue)-int16(col.blue); - mod=col.blue + (position * delta); - newcol.blue=uint8(mod); - if(mod>255 ) - newcol.blue=255; - if(mod<0 ) - newcol.blue=0; - - delta=int8(col2.alpha)-int8(col.alpha); - mod=col.alpha + (position * delta); - newcol.alpha=uint8(mod); - if(mod>255 ) - newcol.alpha=255; - if(mod<0 ) - newcol.alpha=0; - - 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; -} diff --git a/src/add-ons/decorators/WinDecorator/RGBColor.h b/src/add-ons/decorators/WinDecorator/RGBColor.h deleted file mode 100644 index e6a2622370..0000000000 --- a/src/add-ons/decorators/WinDecorator/RGBColor.h +++ /dev/null @@ -1,77 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Color encapsulation class for the app_server -// -//------------------------------------------------------------------------------ -#ifndef RGBCOLOR_H_ -#define RGBCOLOR_H_ - -#include - -/*! - \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(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(const rgb_color &color); - void SetColor(const RGBColor &col); - - RGBColor MakeBlendColor(RGBColor color, float position); - - RGBColor & operator=(const RGBColor &col); - RGBColor & operator=(const rgb_color &col); - bool operator==(const rgb_color &col); - bool operator==(const RGBColor &col); -protected: - rgb_color color32; - uint16 color16; - uint8 color8; -}; - -#endif diff --git a/src/add-ons/decorators/WinDecorator/ServerBitmap.cpp b/src/add-ons/decorators/WinDecorator/ServerBitmap.cpp deleted file mode 100644 index 4d00102d28..0000000000 --- a/src/add-ons/decorators/WinDecorator/ServerBitmap.cpp +++ /dev/null @@ -1,225 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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 -// Description: Bitmap class used inside the server -// -//------------------------------------------------------------------------------ -#ifndef _SERVER_BITMAP_H_ -#define _SERVER_BITMAP_H_ - -#include -#include -#include - -/*! - \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 diff --git a/src/add-ons/decorators/WinDecorator/ServerCursor.cpp b/src/add-ons/decorators/WinDecorator/ServerCursor.cpp deleted file mode 100644 index 404dd9e8ce..0000000000 --- a/src/add-ons/decorators/WinDecorator/ServerCursor.cpp +++ /dev/null @@ -1,142 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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()); -} diff --git a/src/add-ons/decorators/WinDecorator/ServerCursor.h b/src/add-ons/decorators/WinDecorator/ServerCursor.h deleted file mode 100644 index 93e9f89d71..0000000000 --- a/src/add-ons/decorators/WinDecorator/ServerCursor.h +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// Description: Glorified ServerBitmap used for cursor work. -// -//------------------------------------------------------------------------------ -#ifndef SERVERCURSOR_H_ -#define SERVERCURSOR_H_ - -#include -#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 diff --git a/src/add-ons/decorators/WinDecorator/SystemPalette.cpp b/src/add-ons/decorators/WinDecorator/SystemPalette.cpp deleted file mode 100644 index 5505e075f0..0000000000 --- a/src/add-ons/decorators/WinDecorator/SystemPalette.cpp +++ /dev/null @@ -1,361 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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; - } - -} diff --git a/src/add-ons/decorators/WinDecorator/SystemPalette.h b/src/add-ons/decorators/WinDecorator/SystemPalette.h deleted file mode 100644 index 386a5406e6..0000000000 --- a/src/add-ons/decorators/WinDecorator/SystemPalette.h +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 -// 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 - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color system_palette[]; - -#endif