RenderThemeGdk.cpp [plain text]
#include "config.h"
#include "RenderThemeGdk.h"
#include "GraphicsContext.h"
#include <cairo.h>
#define THEME_COLOR 204
#define THEME_FONT 210
#define TS_NORMAL 1
#define TS_HOVER 2
#define TS_ACTIVE 3
#define TS_DISABLED 4
#define TS_FOCUSED 5
#define BP_BUTTON 1
#define BP_RADIO 2
#define BP_CHECKBOX 3
#define TFP_TEXTFIELD 1
#define TFS_READONLY 6
namespace WebCore {
RenderTheme* theme()
{
static RenderThemeGdk gdkTheme;
return &gdkTheme;
}
RenderThemeGdk::RenderThemeGdk()
{
}
RenderThemeGdk::~RenderThemeGdk()
{
}
void RenderThemeGdk::close()
{
}
void RenderThemeGdk::addIntrinsicMargins(RenderStyle* style) const
{
if (style->fontSize() < 11)
return;
const int m = 2;
if (style->width().isIntrinsicOrAuto()) {
if (style->marginLeft().quirk())
style->setMarginLeft(Length(m, Fixed));
if (style->marginRight().quirk())
style->setMarginRight(Length(m, Fixed));
}
if (style->height().isAuto()) {
if (style->marginTop().quirk())
style->setMarginTop(Length(m, Fixed));
if (style->marginBottom().quirk())
style->setMarginBottom(Length(m, Fixed));
}
}
bool RenderThemeGdk::supportsFocus(EAppearance appearance)
{
switch (appearance) {
case PushButtonAppearance:
case ButtonAppearance:
case TextFieldAppearance:
return true;
default:
return false;
}
return false;
}
unsigned RenderThemeGdk::determineState(RenderObject* o)
{
unsigned result = TS_NORMAL;
if (!isEnabled(o))
result = TS_DISABLED;
else if (isReadOnlyControl(o))
result = TFS_READONLY; else if (supportsFocus(o->style()->appearance()) && isFocused(o))
result = TS_FOCUSED;
else if (isHovered(o))
result = TS_HOVER;
else if (isPressed(o))
result = TS_ACTIVE;
if (isChecked(o))
result += 4; return result;
}
ThemeData RenderThemeGdk::getThemeData(RenderObject* o)
{
ThemeData result;
switch (o->style()->appearance()) {
case PushButtonAppearance:
case ButtonAppearance:
result.m_part = BP_BUTTON;
result.m_state = determineState(o);
break;
case CheckboxAppearance:
result.m_part = BP_CHECKBOX;
result.m_state = determineState(o);
break;
case RadioAppearance:
result.m_part = BP_RADIO;
result.m_state = determineState(o);
break;
case TextFieldAppearance:
result.m_part = TFP_TEXTFIELD;
result.m_state = determineState(o);
break;
}
return result;
}
void RenderThemeGdk::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
{
addIntrinsicMargins(style);
}
}