diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index fab62566fc..141fd18602 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -318,6 +318,22 @@ enum { AS_LAST_CODE }; +// Cursor types, currently they are all private besides the first two +enum cursor_which { + B_CURSOR_DEFAULT = 1, + B_CURSOR_TEXT, + B_CURSOR_MOVE, + B_CURSOR_DRAG, + B_CURSOR_RESIZE, + B_CURSOR_RESIZE_NWSE, + B_CURSOR_RESIZE_NESW, + B_CURSOR_RESIZE_NS, + B_CURSOR_RESIZE_EW, + B_CURSOR_OTHER, + B_CURSOR_APP, + B_CURSOR_INVALID +}; + // bitmap allocation types enum { kAllocator, diff --git a/src/kits/app/Cursor.cpp b/src/kits/app/Cursor.cpp index 4155e70162..320664ed1c 100644 --- a/src/kits/app/Cursor.cpp +++ b/src/kits/app/Cursor.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/src/kits/app/Jamfile b/src/kits/app/Jamfile index 0cf3a2a200..940e5cc2f2 100644 --- a/src/kits/app/Jamfile +++ b/src/kits/app/Jamfile @@ -18,7 +18,6 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 { } UsePrivateHeaders shared app interface kernel ; -UsePrivateHeaders [ FDirName servers app ] ; UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ; SetSubDirSupportedPlatforms haiku libbe_test ; diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 53061000ec..2ade46cbff 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku, Inc. + * Copyright 2001-2006, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -17,11 +17,10 @@ #include #include #include +#include #include #include -// TODO: remove this header -#include #include #include @@ -30,7 +29,6 @@ #include #include #include -#include // for private system colors stuff #include #include "moreUTF8.h" @@ -862,7 +860,7 @@ count_decorators(void) int32 code; int32 count = -1; - if (link.FlushWithReply(code) == B_OK) + if (link.FlushWithReply(code) == B_OK && code == B_OK) link.Read(&count); return count; @@ -882,9 +880,9 @@ get_decorator(void) int32 code; int32 index = -1; - if (link.FlushWithReply(code) == B_OK) + if (link.FlushWithReply(code) == B_OK && code == B_OK) link.Read(&index); - + return index; } @@ -899,22 +897,19 @@ status_t get_decorator_name(const int32 &index, BString &name) { BPrivate::AppServerLink link; - int32 code; - link.StartMessage(AS_GET_DECORATOR_NAME); link.Attach(index); - - if (link.FlushWithReply(code) == B_OK) - { + + int32 code; + if (link.FlushWithReply(code) == B_OK && code == B_OK) { char *string; - if(link.ReadString(&string)==B_OK) - { - name=string; - delete [] string; + if (link.ReadString(&string) == B_OK) { + name = string; + free(string); return B_OK; } } - + return B_ERROR; } @@ -943,50 +938,18 @@ get_decorator_preview(const int32 &index, BBitmap *bitmap) status_t set_decorator(const int32 &index) { - if(index < 0) + if (index < 0) return B_BAD_VALUE; - + BPrivate::AppServerLink link; - + link.StartMessage(AS_SET_DECORATOR); link.Attach(index); link.Flush(); - + return B_OK; } -/*! - \brief Private function to get the system's GUI colors as a set - \param colors The recipient color set -*/ -void -get_system_colors(ColorSet *colors) -{ - if (!colors) - return; - - BPrivate::AppServerLink link; - link.StartMessage(AS_GET_UI_COLORS); - - int32 code; - if (link.FlushWithReply(code) == B_OK && code == B_OK) - link.Read(colors); -} - -/*! - \brief Private function to set the system's GUI colors all at once - \param colors The color set to use -*/ -void -set_system_colors(const ColorSet &colors) -{ - BPrivate::AppServerLink link; - - link.StartMessage(AS_SET_UI_COLORS); - link.Attach(colors); - link.Flush(); -} - } // namespace BPrivate // These methods were marked with "Danger, will Robinson!" in diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile index dd730f0624..25c70d83e2 100644 --- a/src/kits/interface/Jamfile +++ b/src/kits/interface/Jamfile @@ -25,7 +25,7 @@ if ! $(HAIKU_COMPATIBLE) { SetSubDirSupportedPlatforms haiku libbe_test ; -UsePrivateHeaders shared app interface input [ FDirName servers app ] ; +UsePrivateHeaders shared app interface input ; SEARCH_SOURCE += [ FDirName $(SUBDIR) BTextView ] ; diff --git a/src/servers/app/BitmapManager.h b/src/servers/app/BitmapManager.h new file mode 100644 index 0000000000..74ed2ba983 --- /dev/null +++ b/src/servers/app/BitmapManager.h @@ -0,0 +1,39 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + */ +#ifndef BITMAP_MANAGER_H +#define BITMAP_MANAGER_H + + +#include +#include +#include +#include +#include + +class ClientMemoryAllocator; +class ServerBitmap; + +class BitmapManager { + public: + BitmapManager(); + virtual ~BitmapManager(); + + ServerBitmap* CreateBitmap(ClientMemoryAllocator* allocator, BRect bounds, + color_space space, int32 flags, int32 bytesPerRow = -1, + screen_id screen = B_MAIN_SCREEN_ID, + int8* _allocationType = NULL); + void DeleteBitmap(ServerBitmap* bitmap); + + protected: + BList fBitmapList; + BLocker fLock; +}; + +extern BitmapManager *gBitmapManager; + +#endif /* BITMAP_MANAGER_H */ diff --git a/src/servers/app/ColorSet.h b/src/servers/app/ColorSet.h new file mode 100644 index 0000000000..8fe8a72fdd --- /dev/null +++ b/src/servers/app/ColorSet.h @@ -0,0 +1,85 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + */ +#ifndef COLOR_SET_H +#define COLOR_SET_H + + +#include +#include +#include +#include + + +/*! + \class ColorSet ColorSet.h + \brief Encapsulates GUI system colors +*/ +class ColorSet : public BLocker { + public: + ColorSet(); + ColorSet(const ColorSet &cs); + ColorSet & operator=(const ColorSet &cs); + + void SetColors(const ColorSet &cs); + void PrintToStream(void) const; + + bool ConvertToMessage(BMessage *msg) const; + bool ConvertFromMessage(const BMessage *msg); + + void SetToDefaults(void); + + rgb_color StringToColor(const char *string); + rgb_color AttributeToColor(int32 which); + + status_t SetColor(const char *string, rgb_color value); + + static status_t LoadColorSet(const char *path, ColorSet *set); + static status_t SaveColorSet(const char *path, const ColorSet &set); + + rgb_color 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, + window_tab, + + // Not all of these guys do exist in InterfaceDefs.h, + // but we keep them as part of the color set anyway - + // they're important nonetheless + window_tab_text, + inactive_window_tab, + inactive_window_tab_text; + + private: + rgb_color *StringToMember(const char *string); + void PrintMember(const rgb_color &color) const; +}; + +#endif // COLOR_SET_H diff --git a/src/servers/app/CursorSet.cpp b/src/servers/app/CursorSet.cpp index e5771f9a38..29c5201890 100644 --- a/src/servers/app/CursorSet.cpp +++ b/src/servers/app/CursorSet.cpp @@ -7,10 +7,11 @@ */ +#include "CursorSet.h" +#include "ServerCursor.h" + #include -#include #include -#include #include #include diff --git a/src/servers/app/CursorSet.h b/src/servers/app/CursorSet.h new file mode 100644 index 0000000000..5c86a3b330 --- /dev/null +++ b/src/servers/app/CursorSet.h @@ -0,0 +1,43 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + */ +#ifndef CURSOR_SET_H +#define CURSOR_SET_H + + +#include +#include +#include + +#include + +class ServerCursor; + + +/*! + \brief Class to manage system cursor sets +*/ +class CursorSet : public BMessage { + public: + CursorSet(const char *name); + + status_t Save(const char *path,int32 saveflags=0); + status_t Load(const char *path); + status_t AddCursor(cursor_which which,const BBitmap *cursor, const BPoint &hotspot); + status_t AddCursor(cursor_which which, uint8 *data); + void RemoveCursor(cursor_which which); + status_t FindCursor(cursor_which which, BBitmap **cursor, BPoint *hotspot); + status_t FindCursor(cursor_which which, ServerCursor **cursor); + void SetName(const char *name); + const char *GetName(void); + + private: + const char *_CursorWhichToString(cursor_which which); + BBitmap *_CursorDataToBitmap(uint8 *data); +}; + +#endif // CURSOR_SET_H diff --git a/src/servers/app/Decorator.h b/src/servers/app/Decorator.h new file mode 100644 index 0000000000..0f8c0c3ec3 --- /dev/null +++ b/src/servers/app/Decorator.h @@ -0,0 +1,168 @@ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Stephan Aßmus + */ +#ifndef _DECORATOR_H_ +#define _DECORATOR_H_ + + +#include +#include +#include +#include + +#include "ColorSet.h" +#include "DrawState.h" + +class DesktopSettings; +class DrawingEngine; +class ServerFont; +class BRegion; + + +typedef enum { + DEC_NONE = 0, + DEC_ZOOM, + DEC_CLOSE, + DEC_MINIMIZE, + DEC_TAB, + DEC_DRAG, + DEC_MOVETOBACK, + DEC_SLIDETAB, + + DEC_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(DesktopSettings& settings, BRect rect, + window_look look, uint32 flags); + virtual ~Decorator(); + + void SetColors(const ColorSet &cset); + void SetDriver(DrawingEngine *driver); + void SetFont(ServerFont *font); + + virtual void SetLook(DesktopSettings& settings, + window_look look, BRegion* updateRegion = NULL); + virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL); + + void SetClose(bool pressed); + void SetMinimize(bool pressed); + void SetZoom(bool pressed); + + virtual void SetTitle(const char* string, BRegion* updateRegion = NULL); + + window_look Look() const; + uint32 Flags() const; + + const char* Title() const; + + // we need to know its border(frame). WinBorder's _frame rect + // must expand to include Decorator borders. Otherwise we can't + // draw the border. We also add TabRect because I feel we'll need it + BRect BorderRect() const; + BRect TabRect() const; + + bool GetClose(); + bool GetMinimize(); + bool GetZoom(); + + virtual void GetSizeLimits(int32* minWidth, int32* minHeight, + int32* maxWidth, int32* maxHeight) const; + + void SetFocus(bool focussed); + bool IsFocus() + { return fIsFocused; }; + ColorSet Colors() + { return (_colors) ? *_colors : ColorSet(); } + + virtual void GetFootprint(BRegion *region); + + virtual click_type Clicked(BPoint pt, int32 buttons, + int32 modifiers); + + void MoveBy(float x, float y); + virtual void MoveBy(BPoint pt); + void ResizeBy(float x, float y, BRegion* dirty); + virtual void ResizeBy(BPoint pt, BRegion* dirty) = 0; + + virtual void SetTabLocation(float location) {} + virtual float TabLocation() const + { return 0.0; } + + virtual void Draw(BRect r); + virtual void Draw(); + virtual void DrawClose(); + virtual void DrawFrame(); + virtual void DrawMinimize(); + virtual void DrawTab(); + virtual void DrawTitle(); + virtual void DrawZoom(); + + protected: + int32 _ClipTitle(float width); + + /*! + \brief Returns the number of characters in the title + \return The title character count + */ + int32 _TitleWidth() const + { return fTitle.CountChars(); } + + virtual void _DoLayout(); + + virtual void _DrawFrame(BRect r); + virtual void _DrawTab(BRect r); + + virtual void _DrawClose(BRect r); + virtual void _DrawTitle(BRect r); + virtual void _DrawZoom(BRect r); + virtual void _DrawMinimize(BRect r); + + virtual void _SetFocus(); + virtual void _SetColors(); + + ColorSet* _colors; + DrawingEngine* _driver; + DrawState fDrawState; + + window_look fLook; + uint32 fFlags; + + BRect _zoomrect; + BRect _closerect; + BRect _minimizerect; + BRect _tabrect; + BRect _frame; + BRect _resizerect; + BRect _borderrect; + + private: + bool fClosePressed; + bool fZoomPressed; + bool fMinimizePressed; + + bool fIsFocused; + + BString fTitle; +}; + +// add-on stuff +typedef float get_version(void); +typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect rect, + window_look look, uint32 flags); + +#endif /* _DECORATOR_H_ */ diff --git a/src/servers/app/DrawState.h b/src/servers/app/DrawState.h new file mode 100644 index 0000000000..ad81ba0936 --- /dev/null +++ b/src/servers/app/DrawState.h @@ -0,0 +1,200 @@ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Adi Oanca + * Stephan Aßmus + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef _DRAW_STATE_H_ +#define _DRAW_STATE_H_ + + +#include +#include +#include +#include // for B_FONT_ALL + +#include "RGBColor.h" +#include "FontManager.h" +#include "ServerFont.h" +#include "PatternHandler.h" + +class BRegion; + +namespace BPrivate { + class LinkReceiver; + class LinkSender; +}; + + +class DrawState { + public: + DrawState(); + DrawState(const DrawState& from); + virtual ~DrawState(); + + DrawState& operator=(const DrawState& from); + + DrawState* PushState(); + DrawState* PopState(); + DrawState* PreviousState() const { return fPreviousState; } + + void ReadFontFromLink(BPrivate::LinkReceiver& link); + // NOTE: ReadFromLink() does not read Font state!! + // It was separate in ServerWindow, and I didn't + // want to change it without knowing implications. + void ReadFromLink(BPrivate::LinkReceiver& link); + void WriteToLink(BPrivate::LinkSender& link) const; + + // coordinate transformation + void SetOrigin(const BPoint& origin); + void OffsetOrigin(const BPoint& offset); + const BPoint& Origin() const + { return fOrigin; } + + void SetScale(float scale); + float Scale() const + { return fScale; } + + // coordinate transformations + void Transform(float* x, float* y) const; + void InverseTransform(float* x, float* y) const; + + void Transform(BPoint* point) const; + void Transform(BRect* rect) const; + void Transform(BRegion* region) const; + + void InverseTransform(BPoint* point) const; + + // additional clipping as requested by client + void SetClippingRegion(const BRegion* region); + const BRegion* ClippingRegion() const + { return fClippingRegion; } +/* inline int32 CountClippingRects() const + { return fClippingRegion ? fClippingRegion.CountRects() : 0; } + inline BRect ClippingRectAt(int32 index) const;*/ + + // color + void SetHighColor(const RGBColor& color); + const RGBColor& HighColor() const + { return fHighColor; } + + void SetLowColor(const RGBColor& color); + const RGBColor& LowColor() const + { return fLowColor; } + + void SetPattern(const Pattern& pattern); + const Pattern& GetPattern() const + { return fPattern; } + + // drawing/blending mode + void SetDrawingMode(drawing_mode mode); + drawing_mode GetDrawingMode() const + { return fDrawingMode; } + + void SetBlendingMode(source_alpha srcMode, + alpha_function fncMode); + source_alpha AlphaSrcMode() const + { return fAlphaSrcMode; } + alpha_function AlphaFncMode() const + { return fAlphaFncMode; } + + // pen + void SetPenLocation(const BPoint& location); + const BPoint& PenLocation() const; + + void SetPenSize(float size); + float PenSize() const; + + // font + void SetFont(const ServerFont& font, + uint32 flags = B_FONT_ALL); + const ServerFont& Font() const + { return fFont; } + + // overrides aliasing flag contained in SeverFont::Flags()) + void SetForceFontAliasing(bool aliasing); + bool ForceFontAliasing() const + { return fFontAliasing; } + + // postscript style settings + void SetLineCapMode(cap_mode mode); + cap_mode LineCapMode() const + { return fLineCapMode; } + + void SetLineJoinMode(join_mode mode); + join_mode LineJoinMode() const + { return fLineJoinMode; } + + void SetMiterLimit(float limit); + float MiterLimit() const + { return fMiterLimit; } + + // convenience functions + void PrintToStream() const; + + void SetSubPixelPrecise(bool precise); + bool SubPixelPrecise() const + { return fSubPixelPrecise; } + + protected: + BPoint fOrigin; + float fScale; + + BRegion* fClippingRegion; + + RGBColor fHighColor; + RGBColor fLowColor; + Pattern fPattern; + + drawing_mode fDrawingMode; + source_alpha fAlphaSrcMode; + alpha_function fAlphaFncMode; + + BPoint fPenLocation; + float fPenSize; + + ServerFont fFont; + // overrides font aliasing flag + bool fFontAliasing; + + // This is not part of the normal state stack. + // Layer will update it in PushState/PopState. + // A BView can have a flag "B_SUBPIXEL_PRECISE", + // I never knew what it does on R5, but I can use + // it in Painter to actually draw stuff with + // sub-pixel coordinates. It means + // StrokeLine(BPoint(10, 5), BPoint(20, 9)); + // will look different from + // StrokeLine(BPoint(10.3, 5.8), BPoint(20.6, 9.5)); + bool fSubPixelPrecise; + + cap_mode fLineCapMode; + join_mode fLineJoinMode; + float fMiterLimit; + // "internal", used to calculate the size + // of the font (again) when the scale changes + float fUnscaledFontSize; + + DrawState* fPreviousState; +}; + + +// inline implementations + +/* +// ClippingRectAt +BRect +DrawState::ClippingRectAt(int32 index) const +{ + BRect r; + if (fClippingRegion) { + r = fClippingRegion.RectAt(index); + } + return r; +}*/ + +#endif /* _DRAW_STATE_H_ */ diff --git a/src/servers/app/DrawingEngine.h b/src/servers/app/DrawingEngine.h new file mode 100644 index 0000000000..48dc29b814 --- /dev/null +++ b/src/servers/app/DrawingEngine.h @@ -0,0 +1,169 @@ +/* + * Copyright 2001-2005, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Gabe Yoder + * Stephan Aßmus + */ +#ifndef DRAWING_ENGINE_H_ +#define DRAWING_ENGINE_H_ + + +#include +#include +#include +#include + +class BPoint; +class BRect; +class BRegion; + +class DrawState; +class HWInterface; +class Painter; +class RGBColor; +class ServerBitmap; +class ServerCursor; +class ServerFont; + +typedef struct { + BPoint pt1; + BPoint pt2; + rgb_color color; + +} LineArrayData; + +class DrawingEngine { +public: + DrawingEngine(HWInterface* interface = NULL); + virtual ~DrawingEngine(); + + // when implementing, be sure to call the inherited version + status_t Initialize(); + void Shutdown(); + + // locking + bool Lock(); + void Unlock(); + + bool WriteLock(); + void WriteUnlock(); + + // for "changing" hardware + void Update(); + + void SetHWInterface(HWInterface* interface); + + // for screen shots + bool DumpToFile(const char *path); + ServerBitmap* DumpToBitmap(); + status_t ReadBitmap(ServerBitmap *bitmap, bool drawCursor, + BRect bounds); + + // clipping for all drawing functions, passing a NULL region + // will remove any clipping (drawing allowed everywhere) + void ConstrainClippingRegion(const BRegion* region); + + // drawing functions + void CopyRegion(/*const*/ BRegion* region, + int32 xOffset, int32 yOffset); + + void InvertRect(BRect r); + + void DrawBitmap(ServerBitmap *bitmap, + const BRect &source, const BRect &dest, + const DrawState *d); + // drawing primitives + + void DrawArc(BRect r, const float &angle, + const float &span, + const DrawState *d, + bool filled); + + void DrawBezier(BPoint *pts, const DrawState *d, + bool filled); + + void DrawEllipse(BRect r, const DrawState *d, + bool filled); + + void DrawPolygon(BPoint *ptlist, int32 numpts, + BRect bounds, const DrawState *d, + bool filled, bool closed); + + // this version used by Decorator + void StrokeRect(BRect r, const RGBColor &color); + void FillRect(BRect r, const RGBColor &color); + + void StrokeRect(BRect r, const DrawState *d); + void FillRect(BRect r, const DrawState *d); + + // for debugging purposes? +// void StrokeRegion(BRegion &r, const DrawState *d); + + void FillRegion(BRegion &r, const DrawState *d); + void FillRegion(BRegion &r, const RGBColor& color); + + void DrawRoundRect(BRect r, float xrad, + float yrad, const DrawState *d, + bool filled); + + void DrawShape(const BRect &bounds, + int32 opcount, const uint32 *oplist, + int32 ptcount, const BPoint *ptlist, + const DrawState *d, bool filled); + + void DrawTriangle(BPoint *pts, const BRect &bounds, + const DrawState *d, bool filled); + + // this version used by Decorator + void StrokeLine(const BPoint &start, + const BPoint &end, const RGBColor &color); + + void StrokeLine(const BPoint &start, + const BPoint &end, DrawState *d); + + void StrokeLineArray(int32 numlines, + const LineArrayData *data, + const DrawState *d); + + // this version used by Decorator + void StrokePoint(const BPoint &pt, + const RGBColor &color); + + void StrokePoint(const BPoint &pt, + DrawState *d); + + // -------- text related calls + + // DrawState is NOT const because this call updates the pen position in the passed DrawState + BPoint DrawString(const char* string, int32 length, + const BPoint& pt, DrawState* d, + escapement_delta* delta = NULL); + + float StringWidth(const char* string, int32 length, + const DrawState* d, + escapement_delta* delta = NULL); + + float StringWidth(const char* string, + int32 length, const ServerFont& font, + escapement_delta* delta = NULL); + + float StringHeight(const char* string, + int32 length, const DrawState* d); + + private: + BRect _CopyRect(BRect r, int32 xOffset, + int32 yOffset) const; + + void _CopyRect(uint8* bits, uint32 width, + uint32 height, uint32 bytesPerRow, + int32 xOffset, int32 yOffset) const; + + Painter* fPainter; + HWInterface* fGraphicsCard; + uint32 fAvailableHWAccleration; +}; + +#endif // DRAWING_ENGINE_H_ diff --git a/src/servers/app/FontFamily.h b/src/servers/app/FontFamily.h new file mode 100644 index 0000000000..b513a9c73f --- /dev/null +++ b/src/servers/app/FontFamily.h @@ -0,0 +1,217 @@ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef FONT_FAMILY_H_ +#define FONT_FAMILY_H_ + + +#include +#include +#include +#include +#include +#include + +#include +#include FT_FREETYPE_H +#include "ReferenceCounting.h" +#include "HashTable.h" + + +struct node_ref; +class FontFamily; +class ServerFont; + +enum font_format { + FONT_TRUETYPE = 0, + FONT_TYPE_1, + FONT_OPENTYPE, + FONT_BDF, + FONT_CFF, + FONT_CID, + FONT_PCF, + FONT_PFR, + FONT_SFNT, + FONT_TYPE_42, + FONT_WINFONT, +}; + + +class FontKey : public Hashable { + public: + FontKey(uint16 familyID, uint16 styleID) + : fHash(familyID | (styleID << 16UL)) + { + } + + virtual uint32 Hash() const + { return fHash; } + virtual bool CompareTo(Hashable& other) const + { return fHash == other.Hash(); } + + private: + uint32 fHash; +}; + + +/*! + \class FontStyle FontFamily.h + \brief Object used to represent a font style + + FontStyle objects help abstract a lot of the font engine details while + still offering plenty of information the style in question. +*/ +class FontStyle : public ReferenceCounting, public Hashable/*, public BLocker*/ { + public: + FontStyle(node_ref& nodeRef, const char* path, FT_Face face); + virtual ~FontStyle(); + + virtual uint32 Hash() const; + virtual bool CompareTo(Hashable& other) const; + + const node_ref& NodeRef() const { return fNodeRef; } + + bool Lock(); + void Unlock(); + +/*! + \fn bool FontStyle::IsFixedWidth(void) + \brief Determines whether the font's character width is fixed + \return true if fixed, false if not +*/ + bool IsFixedWidth() const + { return fFreeTypeFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH; } +/*! + \fn bool FontStyle::IsScalable(void) + \brief Determines whether the font can be scaled to any size + \return true if scalable, false if not +*/ + bool IsScalable() const + { return fFreeTypeFace->face_flags & FT_FACE_FLAG_SCALABLE; } +/*! + \fn bool FontStyle::HasKerning(void) + \brief Determines whether the font has kerning information + \return true if kerning info is available, false if not +*/ + bool HasKerning() const + { return fFreeTypeFace->face_flags & FT_FACE_FLAG_KERNING; } +/*! + \fn bool FontStyle::HasTuned(void) + \brief Determines whether the font contains strikes + \return true if it has strikes included, false if not +*/ + bool HasTuned() const + { return fFreeTypeFace->num_fixed_sizes > 0; } +/*! + \fn bool FontStyle::TunedCount(void) + \brief Returns the number of strikes the style contains + \return The number of strikes the style contains +*/ + int32 TunedCount() const + { return fFreeTypeFace->num_fixed_sizes; } +/*! + \fn bool FontStyle::GlyphCount(void) + \brief Returns the number of glyphs in the style + \return The number of glyphs the style contains +*/ + uint16 GlyphCount() const + { return fFreeTypeFace->num_glyphs; } +/*! + \fn bool FontStyle::CharMapCount(void) + \brief Returns the number of character maps the style contains + \return The number of character maps the style contains +*/ + uint16 CharMapCount() const + { return fFreeTypeFace->num_charmaps; } + + const char* Name() const + { return fName.String(); } + FontFamily* Family() const + { return fFamily; } + uint16 ID() const + { return fID; } + uint32 Flags() const; + + uint16 Face() const + { return fFace; } + uint16 PreservedFace(uint16) const; + + const char* Path() const; + void GetHeight(float size, font_height &heigth) const; + font_direction Direction() const + { return B_FONT_LEFT_TO_RIGHT; } + font_file_format FileFormat() const + { return B_TRUETYPE_WINDOWS; } + + FT_Face FreeTypeFace() const + { return fFreeTypeFace; } + + status_t UpdateFace(FT_Face face); + +// TODO: Re-enable when I understand how the FT2 Cache system changed from +// 2.1.4 to 2.1.8 +// int16 ConvertToUnicode(uint16 c); + + private: + friend class FontFamily; + uint16 _TranslateStyleToFace(const char *name) const; + void _SetFontFamily(FontFamily* family, uint16 id); + + private: + FT_Face fFreeTypeFace; + BString fName; + BString fPath; + node_ref fNodeRef; + + FontFamily* fFamily; + uint16 fID; + + BRect fBounds; + + font_height fHeight; + uint16 fFace; +}; + +/*! + \class FontFamily FontFamily.h + \brief Class representing a collection of similar styles + + FontFamily objects bring together many styles of the same face, such as + Arial Roman, Arial Italic, Arial Bold, etc. +*/ +class FontFamily { + public: + FontFamily(const char* name, uint16 id); + virtual ~FontFamily(); + + const char* Name() const; + + bool AddStyle(FontStyle* style); + bool RemoveStyle(FontStyle* style); + + FontStyle* GetStyle(const char* style) const; + FontStyle* GetStyleMatchingFace(uint16 face) const; + FontStyle* GetStyleByID(uint16 face) const; + + uint16 ID() const + { return fID; } + uint32 Flags(); + + bool HasStyle(const char* style) const; + int32 CountStyles() const; + FontStyle* StyleAt(int32 index) const; + + private: + BString fName; + BObjectList fStyles; + uint16 fID; + uint16 fNextID; + uint32 fFlags; +}; + +#endif /* FONT_FAMILY_H_ */ diff --git a/src/servers/app/FontManager.cpp b/src/servers/app/FontManager.cpp index 098be9a606..454c20c195 100644 --- a/src/servers/app/FontManager.cpp +++ b/src/servers/app/FontManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2006, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -10,10 +10,10 @@ /** Manages font families and styles */ -#include -#include -#include -#include +#include "FontFamily.h" +#include "FontManager.h" +#include "ServerConfig.h" +#include "ServerFont.h" #include #include diff --git a/src/servers/app/FontManager.h b/src/servers/app/FontManager.h new file mode 100644 index 0000000000..1cd34d7487 --- /dev/null +++ b/src/servers/app/FontManager.h @@ -0,0 +1,113 @@ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef FONT_MANAGER_H +#define FONT_MANAGER_H + + +#include "HashTable.h" + +#include +#include + +#include +#include FT_FREETYPE_H + +class BPath; + +class FontFamily; +class FontStyle; +class ServerFont; + + +/*! + \class FontManager FontManager.h + \brief Manager for the largest part of the font subsystem +*/ +class FontManager : public BLooper { + public: + FontManager(); + virtual ~FontManager(); + + status_t InitCheck() { return fInitStatus; } + void SaveRecentFontMappings(); + + virtual void MessageReceived(BMessage* message); + + int32 CheckRevision(uid_t user); + int32 CountFamilies(); + + int32 CountStyles(const char *family); + FontFamily* FamilyAt(int32 index) const; + + FontFamily *GetFamily(uint16 familyID) const; + FontFamily *GetFamily(const char *name); + + FontStyle *GetStyleByIndex(const char *family, int32 index); + FontStyle *GetStyle(const char *family, const char *style, uint16 familyID = 0xffff, + uint16 styleID = 0xffff, uint16 face = 0); + FontStyle *GetStyle(const char *family, uint16 styleID); + FontStyle *GetStyle(uint16 familyID, uint16 styleID) const; + FontStyle* FindStyleMatchingFace(uint16 face) const; + + void RemoveStyle(FontStyle* style); + // this call must not be used by anything else than class FontStyle + + const ServerFont* DefaultPlainFont() const; + const ServerFont* DefaultBoldFont() const; + const ServerFont* DefaultFixedFont() const; + + void AttachUser(uid_t userID); + void DetachUser(uid_t userID); + + private: + struct font_directory; + struct font_mapping; + + void _AddDefaultMapping(const char* family, const char* style, const char* path); + bool _LoadRecentFontMappings(); + status_t _AddMappedFont(const char* family, const char* style = NULL); + FontStyle* _GetDefaultStyle(const char* familyName, const char* styleName, + const char* fallbackFamily, const char* fallbackStyle, + uint16 fallbackFace); + status_t _SetDefaultFonts(); + void _AddSystemPaths(); + font_directory* _FindDirectory(node_ref& nodeRef); + void _RemoveDirectory(font_directory* directory); + status_t _CreateDirectories(const char* path); + status_t _AddPath(const char* path); + status_t _AddPath(BEntry& entry, font_directory** _newDirectory = NULL); + + void _RemoveStyle(font_directory& directory, FontStyle* style); + void _RemoveStyle(dev_t device, uint64 directory, uint64 node); + FontFamily* _FindFamily(const char* family) const; + + void _ScanFontsIfNecessary(); + void _ScanFonts(); + status_t _ScanFontDirectory(font_directory& directory); + status_t _AddFont(font_directory& directory, BEntry& entry); + + FT_CharMap _GetSupportedCharmap(const FT_Face &face); + + private: + status_t fInitStatus; + BObjectList fDirectories; + BObjectList fMappings; + BObjectList fFamilies; + HashTable fStyleHashTable; + ServerFont* fDefaultPlainFont; + ServerFont* fDefaultBoldFont; + ServerFont* fDefaultFixedFont; + bool fScanned; + int32 fNextID; +}; + +extern FT_Library gFreeTypeLibrary; +extern FontManager *gFontManager; + +#endif /* FONT_MANAGER_H */ diff --git a/src/servers/app/HashTable.h b/src/servers/app/HashTable.h new file mode 100644 index 0000000000..6c50f77699 --- /dev/null +++ b/src/servers/app/HashTable.h @@ -0,0 +1,48 @@ +/* + * Copyright 2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef _HASH_TABLE_H_ +#define _HASH_TABLE_H_ + + +#include + + +class Hashable { + public: + virtual uint32 Hash() const = 0; + virtual bool CompareTo(Hashable& hashable) const = 0; +}; + +class HashTable { + public: + HashTable(bool owning = false, int32 capacity = 100, float loadFactor = 0.75); + ~HashTable(); + + void MakeEmpty(bool deleteValues = true); + bool IsEmpty() const { return fCount == 0; } + bool ContainsKey(Hashable& key) const { return _GetHashEntry(key) != NULL; } + int32 CountItems() const { return fCount; } + + Hashable *GetValue(Hashable& key) const; + + bool AddItem(Hashable* value); + Hashable *RemoveItem(Hashable& key); + + protected: + struct entry; + + bool _Rehash(); + entry *_GetHashEntry(Hashable& key) const; + + entry** fTable; + int32 fCapacity, fCount, fThreshold; + float fLoadFactor; + bool fOwning; +}; + +#endif /* HASHTABLE_H */ diff --git a/src/servers/app/Jamfile b/src/servers/app/Jamfile index 2bff083904..86b8d82f19 100644 --- a/src/servers/app/Jamfile +++ b/src/servers/app/Jamfile @@ -3,7 +3,7 @@ SubDir HAIKU_TOP src servers app ; AddResources app_server : app_server.rdef ; UseLibraryHeaders png zlib ; -UsePrivateHeaders app graphics input interface kernel shared [ FDirName servers app ] ; +UsePrivateHeaders app graphics input interface kernel shared ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ; UseFreeTypeHeaders ; diff --git a/src/servers/app/PatternHandler.h b/src/servers/app/PatternHandler.h new file mode 100644 index 0000000000..3167d78668 --- /dev/null +++ b/src/servers/app/PatternHandler.h @@ -0,0 +1,196 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2005, Haiku, Inc. +// +// 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: PatternHandler.h +// Author: DarkWyrm +// Stephan Aßmus +// Description: Class for easy calculation and use of patterns +// +//------------------------------------------------------------------------------ +#ifndef PATTERNHANDLER_H +#define PATTERNHANDLER_H + +#include +#include +#include "RGBColor.h" + +class Pattern { + public: + + Pattern(void) {} + + Pattern(const uint64& p) + { fPattern.type64 = p; } + + Pattern(const int8* p) + { fPattern.type64 = *((const uint64*)p); } + + Pattern(const Pattern& src) + { fPattern.type64 = src.fPattern.type64; } + + Pattern(const pattern& src) + { fPattern.type64 = *(uint64*)src.data; } + + inline const int8* GetInt8(void) const + { return fPattern.type8; } + + inline uint64 GetInt64(void) const + { return fPattern.type64; } + + inline void Set(const int8* p) + { fPattern.type64 = *((const uint64*)p); } + + inline void Set(const uint64& p) + { fPattern.type64 = p; } + + Pattern& operator=(const Pattern& from) + { fPattern.type64 = from.fPattern.type64; return *this; } + + Pattern& operator=(const int64 &from) + { fPattern.type64 = from; return *this; } + + Pattern& operator=(const pattern &from) + { memcpy(&fPattern.type64, &from, sizeof(pattern)); return *this; } + + bool operator==(const Pattern& other) const + { return fPattern.type64 == other.fPattern.type64; } + + bool operator==(const pattern& other) const + { return fPattern.type64 == *(uint64*)other.data; } + + private: + + typedef union + { + uint64 type64; + int8 type8[8]; + } pattern_union; + + pattern_union fPattern; +}; + +extern const Pattern kSolidHigh; +extern const Pattern kSolidLow; +extern const Pattern kMixedColors; + +/*! + \brief Class for easy calculation and use of patterns + + PatternHandlers are designed specifically for DisplayDriver subclasses. + Pattern support can be easily added by setting the pattern to use via + SetTarget, and then merely retrieving the value for the coordinates + specified. +*/ +class PatternHandler { + public: + PatternHandler(void); + PatternHandler(const int8* p); + PatternHandler(const uint64& p); + PatternHandler(const Pattern& p); + PatternHandler(const PatternHandler& other); + virtual ~PatternHandler(void); + + void SetPattern(const int8* p); + void SetPattern(const uint64& p); + void SetPattern(const Pattern& p); + void SetPattern(const pattern& p); + + void SetColors(const RGBColor& high, const RGBColor& low); + void SetHighColor(const RGBColor& color); + void SetLowColor(const RGBColor& color); + + void SetColors(const rgb_color& high, const rgb_color& low); + void SetHighColor(const rgb_color& color); + void SetLowColor(const rgb_color& color); + + + RGBColor HighColor() const + { return fHighColor; } + RGBColor LowColor() const + { return fLowColor; } + + RGBColor ColorAt(const BPoint& pt) const; + RGBColor ColorAt(float x, float y) const; + inline RGBColor ColorAt(int x, int y) const; + // TODO: any ideas for a better name of the rgb_color version of this function? + inline rgb_color R5ColorAt(int x, int y) const; + + bool IsHighColor(const BPoint& pt) const; + inline bool IsHighColor(int x, int y) const; + inline bool IsSolidHigh() const + { return fPattern == B_SOLID_HIGH; } + inline bool IsSolidLow() const + { return fPattern == B_SOLID_LOW; } + inline bool IsSolid() const + { return IsSolidHigh() || IsSolidLow(); } + + const pattern* GetR5Pattern(void) const + { return (const pattern*)fPattern.GetInt8(); } + const Pattern& GetPattern(void) const + { return fPattern; } + private: + Pattern fPattern; + RGBColor fHighColor; + RGBColor fLowColor; +}; + +/*! + \brief Obtains the color in the pattern at the specified coordinates + \param x X coordinate to get the color for + \param y Y coordinate to get the color for + \return Color for the coordinates +*/ +inline RGBColor +PatternHandler::ColorAt(int x, int y) const +{ + return IsHighColor(x, y) ? fHighColor : fLowColor; +} + +/*! + \brief Obtains the color in the pattern at the specified coordinates + \param x X coordinate to get the color for + \param y Y coordinate to get the color for + \return Color for the coordinates +*/ +inline rgb_color +PatternHandler::R5ColorAt(int x, int y) const +{ + return IsHighColor(x, y) ? fHighColor.GetColor32() : fLowColor.GetColor32(); +} + +/*! + \brief Obtains the value of the pattern at the specified coordinates + \param pt Coordinates to get the value for + \return Value for the coordinates - true if high, false if low. +*/ +inline bool +PatternHandler::IsHighColor(int x, int y) const +{ + // TODO: Does this work correctly for + // negative coordinates?!? + const int8* ptr = fPattern.GetInt8(); + int32 value = ptr[y % 8] & (1 << (7 - (x % 8)) ); + + return (value == 0) ? false : true; + +} + +#endif diff --git a/src/servers/app/RGBColor.h b/src/servers/app/RGBColor.h new file mode 100644 index 0000000000..240757e2ae --- /dev/null +++ b/src/servers/app/RGBColor.h @@ -0,0 +1,58 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + */ +#ifndef RGB_COLOR_H +#define RGB_COLOR_H + + +#include + + +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(); + + uint8 GetColor8() const; + uint16 GetColor15() const; + uint16 GetColor16() const; + rgb_color GetColor32() const; + + 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); + + const RGBColor & operator=(const RGBColor &col); + const RGBColor & operator=(const rgb_color &col); + bool operator==(const rgb_color &col) const; + bool operator==(const RGBColor &col) const; + + bool IsTransparentMagic() const; + + void PrintToStream() const; + + protected: + rgb_color fColor32; + + // caching + mutable uint16 fColor16; + mutable uint16 fColor15; + mutable uint8 fColor8; + mutable bool fUpdate8; + mutable bool fUpdate15; + mutable bool fUpdate16; +}; + +#endif // RGB_COLOR_H diff --git a/src/servers/app/ReferenceCounting.h b/src/servers/app/ReferenceCounting.h new file mode 100644 index 0000000000..2b8f5435cc --- /dev/null +++ b/src/servers/app/ReferenceCounting.h @@ -0,0 +1,55 @@ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef REFERENCE_COUNTING_H +#define REFERENCE_COUNTING_H + + +#include + + +/*! + \class ReferenceCounting ReferenceCounting.h + \brief Base class for reference counting objects + + ReferenceCounting objects track dependencies upon a particular object. In this way, + it is possible to ensure that a shared resource is not deleted if something else + needs it. How the dependency tracking is done largely depends on the child class. +*/ +class ReferenceCounting { + public: + ReferenceCounting() + : fReferenceCount(1) {} + virtual ~ReferenceCounting() {} + + inline void Acquire(); + inline bool Release(); + + private: + int32 fReferenceCount; +}; + + +inline void +ReferenceCounting::Acquire() +{ + atomic_add(&fReferenceCount, 1); +} + +inline bool +ReferenceCounting::Release() +{ + if (atomic_add(&fReferenceCount, -1) == 1) { + delete this; + return true; + } + + return false; +} + +#endif /* REFERENCE_COUNTING_H */ diff --git a/src/servers/app/RenderingBuffer.h b/src/servers/app/RenderingBuffer.h new file mode 100644 index 0000000000..c1c706fe4f --- /dev/null +++ b/src/servers/app/RenderingBuffer.h @@ -0,0 +1,33 @@ +// RenderingBuffer.h + +#ifndef RENDERING_BUFFER_H +#define RENDERING_BUFFER_H + +#include +#include + +class RenderingBuffer { + public: + RenderingBuffer() {} + virtual ~RenderingBuffer() {} + + virtual status_t InitCheck() const = 0; + + virtual color_space ColorSpace() const = 0; + virtual void* Bits() const = 0; + virtual uint32 BytesPerRow() const = 0; + // the *count* of the pixels per line + virtual uint32 Width() const = 0; + // the *count* of lines + virtual uint32 Height() const = 0; + + inline uint32 BitsLength() const + { return Height() * BytesPerRow(); } + + inline BRect Bounds() const + { return BRect(0.0, 0.0, + Width() - 1, + Height() - 1); } +}; + +#endif // RENDERING_BUFFER_H diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 4766aeda53..d4db8125eb 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -16,24 +16,9 @@ \brief Counterpart to BApplication within the app_server */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - #include "AppServer.h" #include "BitmapManager.h" +#include "ColorSet.h" #include "CursorManager.h" #include "CursorSet.h" #include "Desktop.h" @@ -57,8 +42,23 @@ #include "SystemPalette.h" #include "WindowLayer.h" -//#define DEBUG_SERVERAPP +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +//#define DEBUG_SERVERAPP #ifdef DEBUG_SERVERAPP # define STRACE(x) printf x #else diff --git a/src/servers/app/ServerBitmap.h b/src/servers/app/ServerBitmap.h new file mode 100644 index 0000000000..51606a42f8 --- /dev/null +++ b/src/servers/app/ServerBitmap.h @@ -0,0 +1,150 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + */ +#ifndef SERVER_BITMAP_H +#define SERVER_BITMAP_H + + +#include +#include +#include + + +class BitmapManager; +class ClientMemoryAllocator; + +/*! + \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: + inline bool IsValid() const + { return fInitialized; } + + void Acquire(); + + inline uint8* Bits() const + { return fBuffer; } + inline uint32 BitsLength() const + { return (uint32)(fBytesPerRow * fHeight); } + + inline BRect Bounds() const + { return BRect(0, 0, fWidth - 1, fHeight - 1); } + inline int32 Width() const + { return fWidth; } + inline int32 Height() const + { return fHeight; } + + inline int32 BytesPerRow() const + { return fBytesPerRow; } + inline uint8 BitsPerPixel() const + { return fBitsPerPixel; } + inline color_space ColorSpace() const + { return fSpace; } + + //! Returns the identifier token for the bitmap + inline int32 Token() const + { return fToken; } + + inline void* AllocationCookie() const + { return fAllocationCookie; } + + area_id Area() const; + uint32 AreaOffset() const; + + //! Does a shallow copy of the bitmap passed to it + inline void ShallowCopy(const ServerBitmap *from); + + status_t ImportBits(const void *bits, int32 bitsLength, + int32 bytesPerRow, color_space colorSpace); + status_t ImportBits(const void *bits, int32 bitsLength, + int32 bytesPerRow, color_space colorSpace, + BPoint from, BPoint to, int32 width, + int32 height); + + void PrintToStream(); + +protected: + friend class BitmapManager; + friend class PicturePlayer; + + ServerBitmap(BRect rect, + color_space space, + int32 flags, + int32 bytesPerRow = -1, + screen_id screen = B_MAIN_SCREEN_ID); + ServerBitmap(const ServerBitmap* bmp); + virtual ~ServerBitmap(); + + //! used by the BitmapManager +// inline void _SetBuffer(void *ptr) +// { fBuffer = (uint8*)ptr; } + + bool _Release(); + + void _AllocateBuffer(); + + void _HandleSpace(color_space space, + int32 bytesperline = -1); + + bool fInitialized; + ClientMemoryAllocator* fAllocator; + void* fAllocationCookie; + uint8* fBuffer; + int32 fReferenceCount; + + int32 fWidth; + int32 fHeight; + int32 fBytesPerRow; + color_space fSpace; + int32 fFlags; + int fBitsPerPixel; + int32 fToken; +}; + +class UtilityBitmap : public ServerBitmap { + public: + UtilityBitmap(BRect rect, + color_space space, + int32 flags, + int32 bytesperline = -1, + screen_id screen = B_MAIN_SCREEN_ID); + UtilityBitmap(const ServerBitmap* bmp); + + UtilityBitmap(const uint8* alreadyPaddedData, + uint32 width, + uint32 height, + color_space format); + + + virtual ~UtilityBitmap(); +}; + +// ShallowCopy +void +ServerBitmap::ShallowCopy(const ServerBitmap* from) +{ + if (!from) + return; + + fInitialized = from->fInitialized; + fBuffer = from->fBuffer; + fWidth = from->fWidth; + fHeight = from->fHeight; + fBytesPerRow = from->fBytesPerRow; + fSpace = from->fSpace; + fFlags = from->fFlags; + fBitsPerPixel = from->fBitsPerPixel; + fToken = from->fToken; +} + +#endif // SERVER_BITMAP_H diff --git a/src/servers/app/ServerConfig.h b/src/servers/app/ServerConfig.h new file mode 100644 index 0000000000..99da638dbe --- /dev/null +++ b/src/servers/app/ServerConfig.h @@ -0,0 +1,76 @@ +#ifndef _APPSERVER_CONFIG_H +#define _APPSERVER_CONFIG_H + +// This is defined to place the server in test mode, which modifies certain things like +// system keyboard shortcuts. Note that it is possible, though senseless, to place it in +// regular mode and still use a display driver which depends on the R5 app_server +#ifndef TEST_MODE + #define TEST_MODE 0 +#endif + +// Uncomment this if the DisplayDriver should only rely on drawing functions implemented +// in software even though hardware-accelerated functions are available +// NOTE: everything is software right now (since DisplayDriverPainter) +//#define DISABLE_HARDWARE_ACCELERATION + +// Define this for a quick hack to test some of the drawing functions +//#define DISPLAYDRIVER_TEST_HACK + +// Define this if you want the display driver to emulate the input server. +#if TEST_MODE +# define ENABLE_INPUT_SERVER_EMULATION +#endif + +// This is the application signature of our app_server when running as a +// regular application. When running as the app_server, this is not used. +#define SERVER_SIGNATURE "application/x-vnd.haiku-app-server" + +// ToDo: use find_directory() instead of absolute path names! +// Directory for all app_server-related settings. Must include ending slash. +#define SERVER_SETTINGS_DIR "/boot/home/config/settings/app_server/" + +// Flattened list of usable fonts maintained by the server. The file is a +// flattened BMessage which is used for caching the names when obtained +// by the various font functions. +#define SERVER_FONT_LIST "/boot/home/config/settings/app_server/fontlist" + +// Flattened list of BMessages containing data for each workspace +#define WORKSPACE_DATA_LIST "/boot/home/config/settings/app_server/workspace_settings" + +// folder used to keep saved color sets for the UI - tab color, etc. +#define COLOR_SET_DIR "/boot/home/config/settings/color_sets/" + +// folder used to keep saved cursor sets for the system +#define CURSOR_SET_DIR "/boot/home/config/settings/cursor_sets/" + +// name of the file containing the current UI color settings +#define COLOR_SETTINGS_NAME "system_colors" + +// name of the file containing the current system cursor settings +#define CURSOR_SETTINGS_NAME "system_cursors" + +// name of the file containing the config data for the desktop +#define WORKSPACE_SETTINGS_NAME "workspace_data" + +// Folder for additional window decorators +#define DECORATORS_DIR "/boot/home/config/add-ons/decorators/" + +// These definitions provide the server something to use for default +// system fonts. +# define DEFAULT_PLAIN_FONT_FAMILY "Bitstream Vera Sans" +# define FALLBACK_PLAIN_FONT_FAMILY "Swis721 BT" +# define DEFAULT_PLAIN_FONT_STYLE "Roman" +# define DEFAULT_PLAIN_FONT_SIZE 12.0f +# define DEFAULT_BOLD_FONT_FAMILY "Bitstream Vera Sans" +# define FALLBACK_BOLD_FONT_FAMILY "Swis721 BT" +# define DEFAULT_BOLD_FONT_STYLE "Bold" +# define DEFAULT_BOLD_FONT_SIZE 12.0f +# define DEFAULT_FIXED_FONT_FAMILY "Bitstream Vera Sans Mono" +# define FALLBACK_FIXED_FONT_FAMILY "Courier10 BT" +# define DEFAULT_FIXED_FONT_STYLE "Roman" +# define DEFAULT_FIXED_FONT_SIZE 12.0f +// This is the port capacity for all monitoring objects - ServerApps +// and ServerWindows +#define DEFAULT_MONITOR_PORT_SIZE 30 + +#endif /* _APPSERVER_CONFIG_H */ diff --git a/src/servers/app/ServerCursor.h b/src/servers/app/ServerCursor.h new file mode 100644 index 0000000000..3977321a82 --- /dev/null +++ b/src/servers/app/ServerCursor.h @@ -0,0 +1,72 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Stephan Aßmus + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef SERVER_CURSOR_H +#define SERVER_CURSOR_H + + +#include "ServerBitmap.h" + +#include +#include + +class ServerApp; +class CursorManager; + + +class ServerCursor : public ServerBitmap { + public: + ServerCursor(BRect r, color_space space, + int32 flags, BPoint hotspot, + int32 bytesperrow = -1, + screen_id screen = B_MAIN_SCREEN_ID); + ServerCursor(const uint8* cursorDataFromR5); + ServerCursor(const uint8* alreadyPaddedData, + uint32 width, uint32 height, + color_space format); + ServerCursor(const ServerCursor* cursor); + + virtual ~ServerCursor(); + + //! Returns the cursor's hot spot + void SetHotSpot(BPoint pt); + BPoint GetHotSpot() const + { return fHotSpot; } + + void SetOwningTeam(team_id tid) + { fOwningTeam = tid; } + team_id OwningTeam() const + { return fOwningTeam; } + + int32 Token() const + { return fToken; } + + void Acquire() + { atomic_add(&fReferenceCount, 1); } + bool Release(); + + void SetPendingViewCursor(bool pending); + + void AttachedToManager(CursorManager* manager); + + const uint8* CursorData() const + { return fCursorData; } + + private: + friend class CursorManager; + + BPoint fHotSpot; + team_id fOwningTeam; + int32 fReferenceCount; + uint8* fCursorData; + CursorManager* fManager; + vint32 fPendingViewCursor; +}; + +#endif // SERVER_CURSOR_H diff --git a/src/servers/app/ServerFont.h b/src/servers/app/ServerFont.h new file mode 100644 index 0000000000..55bf13bb01 --- /dev/null +++ b/src/servers/app/ServerFont.h @@ -0,0 +1,173 @@ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Jérôme Duval, jerome.duval@free.fr + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef SERVER_FONT_H +#define SERVER_FONT_H + + +#include +#include + +#include "FontFamily.h" + +class BShape; +class BString; + + +class ServerFont { + public: + ServerFont(); + ServerFont(FontStyle& style, + float size = 12.0, + float fRotation = 0.0, + float fShear = 90.0, + uint16 flags = 0, + uint8 spacing = B_CHAR_SPACING); + ServerFont(const ServerFont& font); + virtual ~ServerFont(); + + ServerFont &operator=(const ServerFont& font); + + font_direction Direction() const + { return fDirection; } + uint32 Encoding() const + { return fEncoding; } + edge_info Edges() const + { return fEdges; } + uint32 Flags() const + { return fFlags; } + uint32 Spacing() const + { return fSpacing; } + float Shear() const + { return fShear; } + float Rotation() const + { return fRotation; } + float Size() const + { return fSize; } + uint16 Face() const + { return fFace; } + uint32 CountGlyphs() + { return fStyle->GlyphCount(); } + int32 CountTuned(); + + font_file_format FileFormat(); + + const char* Style() const; + const char* Family() const; + const char* Path() const + { return fStyle->Path(); } + + void SetStyle(FontStyle* style); + status_t SetFamilyAndStyle(uint16 familyID, + uint16 styleID); + status_t SetFamilyAndStyle(uint32 fontID); + + uint16 StyleID() const + { return fStyle->ID(); } + uint16 FamilyID() const + { return fStyle->Family()->ID(); } + uint32 GetFamilyAndStyle() const; + + void SetDirection(font_direction dir) + { fDirection = dir; } + void SetEdges(edge_info info) + { fEdges = info; } + void SetEncoding(uint32 encoding) + { fEncoding = encoding; } + void SetFlags(uint32 value) + { fFlags = value; } + void SetSpacing(uint32 value) + { fSpacing = value; } + void SetShear(float value) + { fShear = value; } + void SetSize(float value) + { fSize = value; } + void SetRotation(float value) + { fRotation = value; } + void SetFace(uint32 face); + + bool IsFixedWidth() const + { return fStyle->IsFixedWidth(); } + bool IsScalable() const + { return fStyle->IsScalable(); } + bool HasKerning() const + { return fStyle->HasKerning(); } + bool HasTuned() const + { return fStyle->HasTuned(); } + int32 TunedCount() const + { return fStyle->TunedCount(); } + uint16 GlyphCount() const + { return fStyle->GlyphCount(); } + uint16 CharMapCount() const + { return fStyle->CharMapCount(); } + + + FT_Face GetTransformedFace(bool rotate, bool shear) const; + void PutTransformedFace(FT_Face face) const; + + status_t GetGlyphShapes(const char charArray[], + int32 numChars, BShape *shapeArray[]) const; + + status_t GetHasGlyphs(const char charArray[], + int32 numChars, bool hasArray[]) const; + + status_t GetEdges(const char charArray[], + int32 numChars, edge_info edgeArray[]) const; + + status_t GetEscapements(const char charArray[], + int32 numChars, escapement_delta delta, + BPoint escapementArray[], + BPoint offsetArray[]) const; + + status_t GetEscapements(const char charArray[], + int32 numChars, escapement_delta delta, + float widthArray[]) const; + + status_t GetBoundingBoxesAsString(const char charArray[], + int32 numChars, BRect rectArray[], + bool stringEscapement, font_metric_mode mode, + escapement_delta delta); + + status_t GetBoundingBoxesForStrings(char *charArray[], + int32 lengthArray[], int32 numStrings, + BRect rectArray[], font_metric_mode mode, + escapement_delta deltaArray[]); + + float StringWidth(const char *string, int32 numChars) const; + + bool Lock() const { return fStyle->Lock(); } + void Unlock() const { fStyle->Unlock(); } + + FT_Face GetFTFace() const + { return fStyle->FreeTypeFace(); }; + + BRect BoundingBox(); + void GetHeight(font_height& height) const; + + void TruncateString(BString* inOut, + uint32 mode, + float width) const; + +protected: + friend class FontStyle; + + FontStyle* fStyle; + edge_info fEdges; + float fSize; + float fRotation; + float fShear; + BRect fBounds; + uint32 fFlags; + uint32 fSpacing; + font_direction fDirection; + uint16 fFace; + uint32 fEncoding; +}; + +#endif /* SERVER_FONT_H */ diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index 1fb900175c..5016378c97 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -1,3 +1,13 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marc Flerackers (mflerackers@androme.be) + * Stefano Ceccherini (burton666@libero.it) + */ + + #include "DrawingEngine.h" #include "ServerBitmap.h" #include "ServerPicture.h" @@ -5,7 +15,6 @@ #include "ViewLayer.h" #include "WindowLayer.h" -#include #include #include diff --git a/src/servers/app/SystemPalette.cpp b/src/servers/app/SystemPalette.cpp index 8886c9fac3..de532890d8 100644 --- a/src/servers/app/SystemPalette.cpp +++ b/src/servers/app/SystemPalette.cpp @@ -1,122 +1,108 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. -// -// 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 -// Authors: DarkWyrm -// Stefano Ceccherini -// Description: Methods to initialize and get the system color_map. -// -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Stefano Ceccherini (burton666@libero.it) + */ + +//! Methods to initialize and get the system color_map. + + +#include "SystemPalette.h" + #include #include -#include const static rgb_color kSystemPalette[] = { - { 0, 0, 0, 255 }, { 8, 8, 8, 255 }, { 16, 16, 16, 255 }, - { 24, 24, 24, 255 }, { 32, 32, 32, 255 }, { 40, 40, 40, 255 }, - { 48, 48, 48, 255 }, { 56, 56, 56, 255 }, { 64, 64, 64, 255 }, - { 72, 72, 72, 255 }, { 80, 80, 80, 255 }, { 88, 88, 88, 255 }, - { 96, 96, 96, 255 }, { 104, 104, 104, 255 }, { 112, 112, 112, 255 }, - { 120, 120, 120, 255 }, { 128, 128, 128, 255 }, { 136, 136, 136, 255 }, - { 144, 144, 144, 255 }, { 152, 152, 152, 255 }, { 160, 160, 160, 255 }, - { 168, 168, 168, 255 }, { 176, 176, 176, 255 }, { 184, 184, 184, 255 }, - { 192, 192, 192, 255 }, { 200, 200, 200, 255 }, { 208, 208, 208, 255 }, - { 216, 216, 216, 255 }, { 224, 224, 224, 255 }, { 232, 232, 232, 255 }, - { 240, 240, 240, 255 }, { 248, 248, 248, 255 }, { 0, 0, 255, 255 }, - { 0, 0, 229, 255 }, { 0, 0, 204, 255 }, { 0, 0, 179, 255 }, - { 0, 0, 154, 255 }, { 0, 0, 129, 255 }, { 0, 0, 105, 255 }, - { 0, 0, 80, 255 }, { 0, 0, 55, 255 }, { 0, 0, 30, 255 }, - { 255, 0, 0, 255 }, { 228, 0, 0, 255 }, { 203, 0, 0, 255 }, - { 178, 0, 0, 255 }, { 153, 0, 0, 255 }, { 128, 0, 0, 255 }, - { 105, 0, 0, 255 }, { 80, 0, 0, 255 }, { 55, 0, 0, 255 }, - { 30, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 228, 0, 255 }, - { 0, 203, 0, 255 }, { 0, 178, 0, 255 }, { 0, 153, 0, 255 }, - { 0, 128, 0, 255 }, { 0, 105, 0, 255 }, { 0, 80, 0, 255 }, - { 0, 55, 0, 255 }, { 0, 30, 0, 255 }, { 0, 152, 51, 255 }, - { 255, 255, 255, 255 }, { 203, 255, 255, 255 }, { 203, 255, 203, 255 }, - { 203, 255, 152, 255 }, { 203, 255, 102, 255 }, { 203, 255, 51, 255 }, - { 203, 255, 0, 255 }, { 152, 255, 255, 255 }, { 152, 255, 203, 255 }, - { 152, 255, 152, 255 }, { 152, 255, 102, 255 }, { 152, 255, 51, 255 }, - { 152, 255, 0, 255 }, { 102, 255, 255, 255 }, { 102, 255, 203, 255 }, - { 102, 255, 152, 255 }, { 102, 255, 102, 255 }, { 102, 255, 51, 255 }, - { 102, 255, 0, 255 }, { 51, 255, 255, 255 }, { 51, 255, 203, 255 }, - { 51, 255, 152, 255 }, { 51, 255, 102, 255 }, { 51, 255, 51, 255 }, - { 51, 255, 0, 255 }, { 255, 152, 255, 255 }, { 255, 152, 203, 255 }, - { 255, 152, 152, 255 }, { 255, 152, 102, 255 }, { 255, 152, 51, 255 }, - { 255, 152, 0, 255 }, { 0, 102, 255, 255 }, { 0, 102, 203, 255 }, - { 203, 203, 255, 255 }, { 203, 203, 203, 255 }, { 203, 203, 152, 255 }, - { 203, 203, 102, 255 }, { 203, 203, 51, 255 }, { 203, 203, 0, 255 }, - { 152, 203, 255, 255 }, { 152, 203, 203, 255 }, { 152, 203, 152, 255 }, - { 152, 203, 102, 255 }, { 152, 203, 51, 255 }, { 152, 203, 0, 255 }, - { 102, 203, 255, 255 }, { 102, 203, 203, 255 }, { 102, 203, 152, 255 }, - { 102, 203, 102, 255 }, { 102, 203, 51, 255 }, { 102, 203, 0, 255 }, - { 51, 203, 255, 255 }, { 51, 203, 203, 255 }, { 51, 203, 152, 255 }, - { 51, 203, 102, 255 }, { 51, 203, 51, 255 }, { 51, 203, 0, 255 }, - { 255, 102, 255, 255 }, { 255, 102, 203, 255 }, { 255, 102, 152, 255 }, - { 255, 102, 102, 255 }, { 255, 102, 51, 255 }, { 255, 102, 0, 255 }, - { 0, 102, 152, 255 }, { 0, 102, 102, 255 }, { 203, 152, 255, 255 }, - { 203, 152, 203, 255 }, { 203, 152, 152, 255 }, { 203, 152, 102, 255 }, - { 203, 152, 51, 255 }, { 203, 152, 0, 255 }, { 152, 152, 255, 255 }, - { 152, 152, 203, 255 }, { 152, 152, 152, 255 }, { 152, 152, 102, 255 }, - { 152, 152, 51, 255 }, { 152, 152, 0, 255 }, { 102, 152, 255, 255 }, - { 102, 152, 203, 255 }, { 102, 152, 152, 255 }, { 102, 152, 102, 255 }, - { 102, 152, 51, 255 }, { 102, 152, 0, 255 }, { 51, 152, 255, 255 }, - { 51, 152, 203, 255 }, { 51, 152, 152, 255 }, { 51, 152, 102, 255 }, - { 51, 152, 51, 255 }, { 51, 152, 0, 255 }, { 230, 134, 0, 255 }, - { 255, 51, 203, 255 }, { 255, 51, 152, 255 }, { 255, 51, 102, 255 }, - { 255, 51, 51, 255 }, { 255, 51, 0, 255 }, { 0, 102, 51, 255 }, - { 0, 102, 0, 255 }, { 203, 102, 255, 255 }, { 203, 102, 203, 255 }, - { 203, 102, 152, 255 }, { 203, 102, 102, 255 }, { 203, 102, 51, 255 }, - { 203, 102, 0, 255 }, { 152, 102, 255, 255 }, { 152, 102, 203, 255 }, - { 152, 102, 152, 255 }, { 152, 102, 102, 255 }, { 152, 102, 51, 255 }, - { 152, 102, 0, 255 }, { 102, 102, 255, 255 }, { 102, 102, 203, 255 }, - { 102, 102, 152, 255 }, { 102, 102, 102, 255 }, { 102, 102, 51, 255 }, - { 102, 102, 0, 255 }, { 51, 102, 255, 255 }, { 51, 102, 203, 255 }, - { 51, 102, 152, 255 }, { 51, 102, 102, 255 }, { 51, 102, 51, 255 }, - { 51, 102, 0, 255 }, { 255, 0, 255, 255 }, { 255, 0, 203, 255 }, - { 255, 0, 152, 255 }, { 255, 0, 102, 255 }, { 255, 0, 51, 255 }, - { 255, 175, 19, 255 }, { 0, 51, 255, 255 }, { 0, 51, 203, 255 }, - { 203, 51, 255, 255 }, { 203, 51, 203, 255 }, { 203, 51, 152, 255 }, - { 203, 51, 102, 255 }, { 203, 51, 51, 255 }, { 203, 51, 0, 255 }, - { 152, 51, 255, 255 }, { 152, 51, 203, 255 }, { 152, 51, 152, 255 }, - { 152, 51, 102, 255 }, { 152, 51, 51, 255 }, { 152, 51, 0, 255 }, - { 102, 51, 255, 255 }, { 102, 51, 203, 255 }, { 102, 51, 152, 255 }, - { 102, 51, 102, 255 }, { 102, 51, 51, 255 }, { 102, 51, 0, 255 }, - { 51, 51, 255, 255 }, { 51, 51, 203, 255 }, { 51, 51, 152, 255 }, - { 51, 51, 102, 255 }, { 51, 51, 51, 255 }, { 51, 51, 0, 255 }, - { 255, 203, 102, 255 }, { 255, 203, 152, 255 }, { 255, 203, 203, 255 }, - { 255, 203, 255, 255 }, { 0, 51, 152, 255 }, { 0, 51, 102, 255 }, - { 0, 51, 51, 255 }, { 0, 51, 0, 255 }, { 203, 0, 255, 255 }, - { 203, 0, 203, 255 }, { 203, 0, 152, 255 }, { 203, 0, 102, 255 }, - { 203, 0, 51, 255 }, { 255, 227, 70, 255 }, { 152, 0, 255, 255 }, - { 152, 0, 203, 255 }, { 152, 0, 152, 255 }, { 152, 0, 102, 255 }, - { 152, 0, 51, 255 }, { 152, 0, 0, 255 }, { 102, 0, 255, 255 }, - { 102, 0, 203, 255 }, { 102, 0, 152, 255 }, { 102, 0, 102, 255 }, - { 102, 0, 51, 255 }, { 102, 0, 0, 255 }, { 51, 0, 255, 255 }, - { 51, 0, 203, 255 }, { 51, 0, 152, 255 }, { 51, 0, 102, 255 }, - { 51, 0, 51, 255 }, { 51, 0, 0, 255 }, { 255, 203, 51, 255 }, - { 255, 203, 0, 255 }, { 255, 255, 0, 255 }, { 255, 255, 51, 255 }, - { 255, 255, 102, 255 }, { 255, 255, 152, 255 }, { 255, 255, 203, 255 }, - { 255, 255, 255, 0 } // B_TRANSPARENT_MAGIC_CMAP8 + { 0, 0, 0, 255 }, { 8, 8, 8, 255 }, { 16, 16, 16, 255 }, + { 24, 24, 24, 255 }, { 32, 32, 32, 255 }, { 40, 40, 40, 255 }, + { 48, 48, 48, 255 }, { 56, 56, 56, 255 }, { 64, 64, 64, 255 }, + { 72, 72, 72, 255 }, { 80, 80, 80, 255 }, { 88, 88, 88, 255 }, + { 96, 96, 96, 255 }, { 104, 104, 104, 255 }, { 112, 112, 112, 255 }, + { 120, 120, 120, 255 }, { 128, 128, 128, 255 }, { 136, 136, 136, 255 }, + { 144, 144, 144, 255 }, { 152, 152, 152, 255 }, { 160, 160, 160, 255 }, + { 168, 168, 168, 255 }, { 176, 176, 176, 255 }, { 184, 184, 184, 255 }, + { 192, 192, 192, 255 }, { 200, 200, 200, 255 }, { 208, 208, 208, 255 }, + { 216, 216, 216, 255 }, { 224, 224, 224, 255 }, { 232, 232, 232, 255 }, + { 240, 240, 240, 255 }, { 248, 248, 248, 255 }, { 0, 0, 255, 255 }, + { 0, 0, 229, 255 }, { 0, 0, 204, 255 }, { 0, 0, 179, 255 }, + { 0, 0, 154, 255 }, { 0, 0, 129, 255 }, { 0, 0, 105, 255 }, + { 0, 0, 80, 255 }, { 0, 0, 55, 255 }, { 0, 0, 30, 255 }, + { 255, 0, 0, 255 }, { 228, 0, 0, 255 }, { 203, 0, 0, 255 }, + { 178, 0, 0, 255 }, { 153, 0, 0, 255 }, { 128, 0, 0, 255 }, + { 105, 0, 0, 255 }, { 80, 0, 0, 255 }, { 55, 0, 0, 255 }, + { 30, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 228, 0, 255 }, + { 0, 203, 0, 255 }, { 0, 178, 0, 255 }, { 0, 153, 0, 255 }, + { 0, 128, 0, 255 }, { 0, 105, 0, 255 }, { 0, 80, 0, 255 }, + { 0, 55, 0, 255 }, { 0, 30, 0, 255 }, { 0, 152, 51, 255 }, + { 255, 255, 255, 255 }, { 203, 255, 255, 255 }, { 203, 255, 203, 255 }, + { 203, 255, 152, 255 }, { 203, 255, 102, 255 }, { 203, 255, 51, 255 }, + { 203, 255, 0, 255 }, { 152, 255, 255, 255 }, { 152, 255, 203, 255 }, + { 152, 255, 152, 255 }, { 152, 255, 102, 255 }, { 152, 255, 51, 255 }, + { 152, 255, 0, 255 }, { 102, 255, 255, 255 }, { 102, 255, 203, 255 }, + { 102, 255, 152, 255 }, { 102, 255, 102, 255 }, { 102, 255, 51, 255 }, + { 102, 255, 0, 255 }, { 51, 255, 255, 255 }, { 51, 255, 203, 255 }, + { 51, 255, 152, 255 }, { 51, 255, 102, 255 }, { 51, 255, 51, 255 }, + { 51, 255, 0, 255 }, { 255, 152, 255, 255 }, { 255, 152, 203, 255 }, + { 255, 152, 152, 255 }, { 255, 152, 102, 255 }, { 255, 152, 51, 255 }, + { 255, 152, 0, 255 }, { 0, 102, 255, 255 }, { 0, 102, 203, 255 }, + { 203, 203, 255, 255 }, { 203, 203, 203, 255 }, { 203, 203, 152, 255 }, + { 203, 203, 102, 255 }, { 203, 203, 51, 255 }, { 203, 203, 0, 255 }, + { 152, 203, 255, 255 }, { 152, 203, 203, 255 }, { 152, 203, 152, 255 }, + { 152, 203, 102, 255 }, { 152, 203, 51, 255 }, { 152, 203, 0, 255 }, + { 102, 203, 255, 255 }, { 102, 203, 203, 255 }, { 102, 203, 152, 255 }, + { 102, 203, 102, 255 }, { 102, 203, 51, 255 }, { 102, 203, 0, 255 }, + { 51, 203, 255, 255 }, { 51, 203, 203, 255 }, { 51, 203, 152, 255 }, + { 51, 203, 102, 255 }, { 51, 203, 51, 255 }, { 51, 203, 0, 255 }, + { 255, 102, 255, 255 }, { 255, 102, 203, 255 }, { 255, 102, 152, 255 }, + { 255, 102, 102, 255 }, { 255, 102, 51, 255 }, { 255, 102, 0, 255 }, + { 0, 102, 152, 255 }, { 0, 102, 102, 255 }, { 203, 152, 255, 255 }, + { 203, 152, 203, 255 }, { 203, 152, 152, 255 }, { 203, 152, 102, 255 }, + { 203, 152, 51, 255 }, { 203, 152, 0, 255 }, { 152, 152, 255, 255 }, + { 152, 152, 203, 255 }, { 152, 152, 152, 255 }, { 152, 152, 102, 255 }, + { 152, 152, 51, 255 }, { 152, 152, 0, 255 }, { 102, 152, 255, 255 }, + { 102, 152, 203, 255 }, { 102, 152, 152, 255 }, { 102, 152, 102, 255 }, + { 102, 152, 51, 255 }, { 102, 152, 0, 255 }, { 51, 152, 255, 255 }, + { 51, 152, 203, 255 }, { 51, 152, 152, 255 }, { 51, 152, 102, 255 }, + { 51, 152, 51, 255 }, { 51, 152, 0, 255 }, { 230, 134, 0, 255 }, + { 255, 51, 203, 255 }, { 255, 51, 152, 255 }, { 255, 51, 102, 255 }, + { 255, 51, 51, 255 }, { 255, 51, 0, 255 }, { 0, 102, 51, 255 }, + { 0, 102, 0, 255 }, { 203, 102, 255, 255 }, { 203, 102, 203, 255 }, + { 203, 102, 152, 255 }, { 203, 102, 102, 255 }, { 203, 102, 51, 255 }, + { 203, 102, 0, 255 }, { 152, 102, 255, 255 }, { 152, 102, 203, 255 }, + { 152, 102, 152, 255 }, { 152, 102, 102, 255 }, { 152, 102, 51, 255 }, + { 152, 102, 0, 255 }, { 102, 102, 255, 255 }, { 102, 102, 203, 255 }, + { 102, 102, 152, 255 }, { 102, 102, 102, 255 }, { 102, 102, 51, 255 }, + { 102, 102, 0, 255 }, { 51, 102, 255, 255 }, { 51, 102, 203, 255 }, + { 51, 102, 152, 255 }, { 51, 102, 102, 255 }, { 51, 102, 51, 255 }, + { 51, 102, 0, 255 }, { 255, 0, 255, 255 }, { 255, 0, 203, 255 }, + { 255, 0, 152, 255 }, { 255, 0, 102, 255 }, { 255, 0, 51, 255 }, + { 255, 175, 19, 255 }, { 0, 51, 255, 255 }, { 0, 51, 203, 255 }, + { 203, 51, 255, 255 }, { 203, 51, 203, 255 }, { 203, 51, 152, 255 }, + { 203, 51, 102, 255 }, { 203, 51, 51, 255 }, { 203, 51, 0, 255 }, + { 152, 51, 255, 255 }, { 152, 51, 203, 255 }, { 152, 51, 152, 255 }, + { 152, 51, 102, 255 }, { 152, 51, 51, 255 }, { 152, 51, 0, 255 }, + { 102, 51, 255, 255 }, { 102, 51, 203, 255 }, { 102, 51, 152, 255 }, + { 102, 51, 102, 255 }, { 102, 51, 51, 255 }, { 102, 51, 0, 255 }, + { 51, 51, 255, 255 }, { 51, 51, 203, 255 }, { 51, 51, 152, 255 }, + { 51, 51, 102, 255 }, { 51, 51, 51, 255 }, { 51, 51, 0, 255 }, + { 255, 203, 102, 255 }, { 255, 203, 152, 255 }, { 255, 203, 203, 255 }, + { 255, 203, 255, 255 }, { 0, 51, 152, 255 }, { 0, 51, 102, 255 }, + { 0, 51, 51, 255 }, { 0, 51, 0, 255 }, { 203, 0, 255, 255 }, + { 203, 0, 203, 255 }, { 203, 0, 152, 255 }, { 203, 0, 102, 255 }, + { 203, 0, 51, 255 }, { 255, 227, 70, 255 }, { 152, 0, 255, 255 }, + { 152, 0, 203, 255 }, { 152, 0, 152, 255 }, { 152, 0, 102, 255 }, + { 152, 0, 51, 255 }, { 152, 0, 0, 255 }, { 102, 0, 255, 255 }, + { 102, 0, 203, 255 }, { 102, 0, 152, 255 }, { 102, 0, 102, 255 }, + { 102, 0, 51, 255 }, { 102, 0, 0, 255 }, { 51, 0, 255, 255 }, + { 51, 0, 203, 255 }, { 51, 0, 152, 255 }, { 51, 0, 102, 255 }, + { 51, 0, 51, 255 }, { 51, 0, 0, 255 }, { 255, 203, 51, 255 }, + { 255, 203, 0, 255 }, { 255, 255, 0, 255 }, { 255, 255, 51, 255 }, + { 255, 255, 102, 255 }, { 255, 255, 152, 255 }, { 255, 255, 203, 255 }, + { 255, 255, 255, 0 } // B_TRANSPARENT_MAGIC_CMAP8 }; @@ -139,8 +125,7 @@ static color_map sColorMap; \param blue2 Blue component of the second color. \return The distance between the given colors. */ -static inline -unsigned +static inline uint32 color_distance(uint8 red1, uint8 green1, uint8 blue1, uint8 red2, uint8 green2, uint8 blue2) { diff --git a/src/servers/app/SystemPalette.h b/src/servers/app/SystemPalette.h new file mode 100644 index 0000000000..967d8b1376 --- /dev/null +++ b/src/servers/app/SystemPalette.h @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, Haiku, Inc. +// +// 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 + +extern void InitializeColorMap(); +extern const rgb_color *SystemPalette(); +extern const color_map *SystemColorMap(); + +#endif diff --git a/src/servers/app/WorkspacesLayer.cpp b/src/servers/app/WorkspacesLayer.cpp index de78adcb41..ea6100df41 100644 --- a/src/servers/app/WorkspacesLayer.cpp +++ b/src/servers/app/WorkspacesLayer.cpp @@ -16,7 +16,6 @@ #include "WindowLayer.h" #include "Workspace.h" -#include #include diff --git a/src/servers/app/drawing/Jamfile b/src/servers/app/drawing/Jamfile index 4fd6638424..f1053e5d3b 100644 --- a/src/servers/app/drawing/Jamfile +++ b/src/servers/app/drawing/Jamfile @@ -1,7 +1,7 @@ SubDir HAIKU_TOP src servers app drawing ; UseLibraryHeaders agg ; -UsePrivateHeaders app graphics interface shared [ FDirName servers app ] ; +UsePrivateHeaders app graphics interface shared ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ; diff --git a/src/servers/app/drawing/Painter/Jamfile b/src/servers/app/drawing/Painter/Jamfile index 481b0c081f..4c5886aee6 100644 --- a/src/servers/app/drawing/Painter/Jamfile +++ b/src/servers/app/drawing/Painter/Jamfile @@ -4,7 +4,8 @@ SetSubDirSupportedPlatformsBeOSCompatible ; AddSubDirSupportedPlatforms libbe_test ; UseLibraryHeaders agg ; -UsePrivateHeaders app interface shared [ FDirName servers app ] ; +UsePrivateHeaders app interface shared ; +UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter drawing_modes ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter font_support ] ; diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index f1a1cfd76b..05b39964dc 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -1,12 +1,12 @@ /* - * Copyright 2005, Stephan Aßmus . All rights reserved. + * Copyright 2005-2006, Stephan Aßmus . All rights reserved. * Distributed under the terms of the MIT License. * * API to the Anti-Grain Geometry based "Painter" drawing backend. Manages * rendering pipe-lines for stroke, fills, bitmap and text rendering. - * */ + #include #include diff --git a/src/servers/app/drawing/Painter/Painter.h b/src/servers/app/drawing/Painter/Painter.h index e22ddd1dc6..3b8a740856 100644 --- a/src/servers/app/drawing/Painter/Painter.h +++ b/src/servers/app/drawing/Painter/Painter.h @@ -1,23 +1,23 @@ /* - * Copyright 2005, Stephan Aßmus . All rights reserved. + * Copyright 2005-2006, Stephan Aßmus . All rights reserved. * Distributed under the terms of the MIT License. * * API to the Anti-Grain Geometry based "Painter" drawing backend. Manages * rendering pipe-lines for stroke, fills, bitmap and text rendering. * */ - #ifndef PAINTER_H #define PAINTER_H -#include -#include -#include -#include +#include "FontManager.h" +#include "RGBColor.h" +#include "ServerFont.h" #include "defines.h" -#include "RGBColor.h" +#include +#include + class AGGTextRenderer; class BBitmap; diff --git a/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp b/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp index d2a002eece..4178070a10 100644 --- a/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp +++ b/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp @@ -1,17 +1,14 @@ -// AGGTextRenderer.cpp +/* + * Copyright 2005-2006, Stephan Aßmus . All rights reserved. + * Distributed under the terms of the MIT License. + */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "AGGTextRenderer.h" + +#include "FontManager.h" +#include "moreUTF8.h" +#include "ServerFont.h" #include #include @@ -19,8 +16,16 @@ #include #include -#include "AGGTextRenderer.h" -#include "moreUTF8.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define FLIP_Y false diff --git a/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.h b/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.h index db85c5ac56..9e5a581994 100644 --- a/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.h +++ b/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.h @@ -1,18 +1,20 @@ -// AGGTextRenderer.h - +/* + * Copyright 2005-2006, Stephan Aßmus . All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef AGG_TEXT_RENDERER_H #define AGG_TEXT_RENDERER_H +#include "agg_font_freetype.h" +#include "defines.h" + +#include "ServerFont.h" +#include "Transformable.h" + #include #include #include -#include "agg_font_freetype.h" -#include "defines.h" - -#include "Transformable.h" - -class ServerFont; class AGGTextRenderer { public: diff --git a/src/servers/app/drawing/Painter/font_support/agg_font_freetype.cpp b/src/servers/app/drawing/Painter/font_support/agg_font_freetype.cpp index 44adf8bf21..f03253ad4d 100644 --- a/src/servers/app/drawing/Painter/font_support/agg_font_freetype.cpp +++ b/src/servers/app/drawing/Painter/font_support/agg_font_freetype.cpp @@ -16,17 +16,18 @@ //---------------------------------------------------------------------------- // modified to use family and style id as glyph cache lookup -#include + #include "agg_font_freetype.h" #include "agg_bitset_iterator.h" #include "agg_renderer_scanline.h" -#include -#include +#include "ServerFont.h" +#include "FontFamily.h" -namespace agg -{ +#include + +namespace agg { //------------------------------------------------------------------------------ // // This code implements the AUTODIN II polynomial diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index c32222e8a3..a1e68d9497 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -6,7 +6,7 @@ SetSubDirSupportedPlatforms libbe_test ; if $(TARGET_PLATFORM) = libbe_test { UseLibraryHeaders agg png zlib ; -UsePrivateHeaders app graphics input interface kernel shared [ FDirName servers app ] ; +UsePrivateHeaders app graphics input interface kernel shared ; local appServerDir = [ FDirName $(HAIKU_TOP) src servers app ] ;