ewk_color_picker.cpp [plain text]
#include "config.h"
#include "ewk_color_picker.h"
#include "WKColorPickerResultListener.h"
#include "WKString.h"
#include "ewk_color_picker_private.h"
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
#if ENABLE(INPUT_TYPE_COLOR)
using namespace WebCore;
EwkColorPicker::EwkColorPicker(WKColorPickerResultListenerRef colorPickerListener, const Color& initialColor)
: m_colorPickerListener(colorPickerListener)
, m_color(initialColor)
{
}
void EwkColorPicker::setColor(const Color& color)
{
WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
WKColorPickerResultListenerSetColor(m_colorPickerListener.get(), colorString.get());
}
const Color& EwkColorPicker::color() const
{
return m_color;
}
#endif
Eina_Bool ewk_color_picker_color_set(Ewk_Color_Picker* colorPicker, int r, int g, int b, int a)
{
#if ENABLE(INPUT_TYPE_COLOR)
EINA_SAFETY_ON_NULL_RETURN_VAL(colorPicker, false);
colorPicker->setColor(Color(r, g, b, a));
return true;
#else
UNUSED_PARAM(colorPicker);
UNUSED_PARAM(r);
UNUSED_PARAM(g);
UNUSED_PARAM(b);
UNUSED_PARAM(a);
return false;
#endif
}
Eina_Bool ewk_color_picker_color_get(const Ewk_Color_Picker* colorPicker, int* r, int* g, int* b, int* a)
{
#if ENABLE(INPUT_TYPE_COLOR)
EINA_SAFETY_ON_NULL_RETURN_VAL(colorPicker, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(r, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(g, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(b, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(a, false);
const Color& color = colorPicker->color();
*r = color.red();
*g = color.green();
*b = color.blue();
*a = color.alpha();
return true;
#else
UNUSED_PARAM(colorPicker);
UNUSED_PARAM(r);
UNUSED_PARAM(g);
UNUSED_PARAM(b);
UNUSED_PARAM(a);
return false;
#endif
}