• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the WebKit project.
3  *
4  * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
5  *               2006 Nikolas Zimmermann <zimmermann@kde.org>
6  * Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com>
7  * Copyright (C) 2009 Maxime Simon <simon.maxime@gmail.com>
8  *
9  * All rights reserved.
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public License
22  * along with this library; see the file COPYING.LIB.  If not, write to
23  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  *
26  */
27 
28 #include "config.h"
29 #include "RenderThemeHaiku.h"
30 
31 #include "GraphicsContext.h"
32 #include "NotImplemented.h"
33 #include <ControlLook.h>
34 #include <View.h>
35 
36 
37 namespace WebCore {
38 
create()39 PassRefPtr<RenderTheme> RenderThemeHaiku::create()
40 {
41     return adoptRef(new RenderThemeHaiku());
42 }
43 
themeForPage(Page *)44 PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page*)
45 {
46     static RenderTheme* renderTheme = RenderThemeHaiku::create().releaseRef();
47     return renderTheme;
48 }
49 
RenderThemeHaiku()50 RenderThemeHaiku::RenderThemeHaiku()
51 {
52 }
53 
~RenderThemeHaiku()54 RenderThemeHaiku::~RenderThemeHaiku()
55 {
56 }
57 
supportsFocus(ControlPart appearance)58 static bool supportsFocus(ControlPart appearance)
59 {
60     switch (appearance) {
61     case PushButtonPart:
62     case ButtonPart:
63     case TextFieldPart:
64     case TextAreaPart:
65     case SearchFieldPart:
66     case MenulistPart:
67     case RadioPart:
68     case CheckboxPart:
69         return true;
70     default:
71         return false;
72     }
73 }
74 
supportsFocusRing(const RenderStyle * style) const75 bool RenderThemeHaiku::supportsFocusRing(const RenderStyle* style) const
76 {
77     return supportsFocus(style->appearance());
78 }
79 
platformActiveSelectionBackgroundColor() const80 Color RenderThemeHaiku::platformActiveSelectionBackgroundColor() const
81 {
82     return Color(ui_color(B_CONTROL_HIGHLIGHT_COLOR));
83 }
84 
platformInactiveSelectionBackgroundColor() const85 Color RenderThemeHaiku::platformInactiveSelectionBackgroundColor() const
86 {
87     return Color(ui_color(B_CONTROL_HIGHLIGHT_COLOR));
88 }
89 
platformActiveSelectionForegroundColor() const90 Color RenderThemeHaiku::platformActiveSelectionForegroundColor() const
91 {
92     return Color(ui_color(B_CONTROL_TEXT_COLOR));
93 }
94 
platformInactiveSelectionForegroundColor() const95 Color RenderThemeHaiku::platformInactiveSelectionForegroundColor() const
96 {
97     return Color(ui_color(B_CONTROL_TEXT_COLOR));
98 }
99 
platformTextSearchHighlightColor() const100 Color RenderThemeHaiku::platformTextSearchHighlightColor() const
101 {
102     return Color(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
103 }
104 
systemFont(int propId,FontDescription &) const105 void RenderThemeHaiku::systemFont(int propId, FontDescription&) const
106 {
107     notImplemented();
108 }
109 
paintCheckbox(RenderObject *,const PaintInfo & info,const IntRect & intRect)110 bool RenderThemeHaiku::paintCheckbox(RenderObject*, const PaintInfo& info, const IntRect& intRect)
111 {
112     if (info.context->paintingDisabled())
113         return false;
114 
115     rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
116     BRect rect = intRect;
117     BView* view = info.context->platformContext();
118 
119     if (!be_control_look)
120         return false;
121 
122     be_control_look->DrawCheckBox(view, rect, rect, base);
123     return true;
124 }
125 
setCheckboxSize(RenderStyle * style) const126 void RenderThemeHaiku::setCheckboxSize(RenderStyle* style) const
127 {
128     int size = 10;
129 
130     // If the width and height are both specified, then we have nothing to do.
131     if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
132         return;
133 
134     // FIXME: A hard-coded size of 'size' is used. This is wrong but necessary for now.
135     if (style->width().isIntrinsicOrAuto())
136         style->setWidth(Length(size, Fixed));
137 
138     if (style->height().isAuto())
139         style->setHeight(Length(size, Fixed));
140 }
141 
paintRadio(RenderObject *,const PaintInfo & info,const IntRect & intRect)142 bool RenderThemeHaiku::paintRadio(RenderObject*, const PaintInfo& info, const IntRect& intRect)
143 {
144     if (info.context->paintingDisabled())
145         return false;
146 
147     rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
148     BRect rect = intRect;
149     BView* view = info.context->platformContext();
150 
151     if (!be_control_look)
152         return false;
153 
154     be_control_look->DrawRadioButton(view, rect, rect, base);
155     return true;
156 }
157 
setRadioSize(RenderStyle * style) const158 void RenderThemeHaiku::setRadioSize(RenderStyle* style) const
159 {
160     // This is the same as checkboxes.
161     setCheckboxSize(style);
162 }
163 
adjustMenuListStyle(CSSStyleSelector *,RenderStyle * style,Element *) const164 void RenderThemeHaiku::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
165 {
166     // Leave some space for the arrow.
167     style->setPaddingRight(Length(22, Fixed));
168     const int minHeight = 20;
169     style->setMinHeight(Length(minHeight, Fixed));
170 }
171 
paintMenuList(RenderObject *,const PaintInfo &,const IntRect &)172 bool RenderThemeHaiku::paintMenuList(RenderObject*, const PaintInfo&, const IntRect&)
173 {
174     notImplemented();
175     return false;
176 }
177 
178 } // namespace WebCore
179