From 7ca3c69091357411aa6caa23132f108958bc3386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 20 Jan 2005 14:10:11 +0000 Subject: [PATCH] added some convinience functions to handle rgb_color additionally to RGBColor git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10898 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/servers/app/PatternHandler.h | 22 ++++++++++++++- src/servers/app/server/PatternHandler.cpp | 29 ++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/headers/private/servers/app/PatternHandler.h b/headers/private/servers/app/PatternHandler.h index 699d475384..d2d3b74f52 100644 --- a/headers/private/servers/app/PatternHandler.h +++ b/headers/private/servers/app/PatternHandler.h @@ -96,16 +96,22 @@ class PatternHandler { PatternHandler(const uint64& p); PatternHandler(const Pattern& p); PatternHandler(const PatternHandler& other); - virtual ~PatternHandler(void); + 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 @@ -114,6 +120,8 @@ class PatternHandler { 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; @@ -138,6 +146,18 @@ 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 diff --git a/src/servers/app/server/PatternHandler.cpp b/src/servers/app/server/PatternHandler.cpp index ceaa1f590e..a520650d6c 100644 --- a/src/servers/app/server/PatternHandler.cpp +++ b/src/servers/app/server/PatternHandler.cpp @@ -179,6 +179,35 @@ void PatternHandler::SetLowColor(const RGBColor& color) fLowColor = color; } +/*! + \brief Set the colors for the pattern to use + \param high High color for the handler + \param low Low color for the handler +*/ +void PatternHandler::SetColors(const rgb_color& high, const rgb_color& low) +{ + fHighColor = high; + fLowColor = low; +} + +/*! + \brief Set the high color for the pattern to use + \param color High color for the handler +*/ +void PatternHandler::SetHighColor(const rgb_color& color) +{ + fHighColor = color; +} + +/*! + \brief Set the low color for the pattern to use + \param color Low color for the handler +*/ +void PatternHandler::SetLowColor(const rgb_color& color) +{ + fLowColor = color; +} + /*! \brief Obtains the color in the pattern at the specified coordinates \param pt Coordinates to get the color for