diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
commit | 1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch) | |
tree | 4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/platform/wx/RenderThemeWx.cpp | |
parent | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff) | |
download | external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/platform/wx/RenderThemeWx.cpp')
-rw-r--r-- | WebCore/platform/wx/RenderThemeWx.cpp | 165 |
1 files changed, 142 insertions, 23 deletions
diff --git a/WebCore/platform/wx/RenderThemeWx.cpp b/WebCore/platform/wx/RenderThemeWx.cpp index bfe2a77..05ebeb9 100644 --- a/WebCore/platform/wx/RenderThemeWx.cpp +++ b/WebCore/platform/wx/RenderThemeWx.cpp @@ -29,8 +29,11 @@ #include "Document.h" #include "FrameView.h" #include "GraphicsContext.h" +#include "NotImplemented.h" #include "RenderView.h" +#include "WebKit/wx/WebView.h" + #include <wx/defs.h> #include <wx/renderer.h> #include <wx/dcclient.h> @@ -60,14 +63,24 @@ public: virtual void setRadioSize(RenderStyle*) const; + virtual void adjustRepaintRect(const RenderObject*, IntRect&); + virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual int minimumMenuListSize(RenderStyle*) const; + + virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + + virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool isControlStyled(const RenderStyle*, const BorderData&, - const BackgroundLayer&, const Color&) const; + const FillLayer&, const Color&) const; virtual bool controlSupportsTints(const RenderObject*) const; @@ -78,14 +91,33 @@ public: virtual Color platformActiveSelectionForegroundColor() const; virtual Color platformInactiveSelectionForegroundColor() const; + + virtual int popupInternalPaddingLeft(RenderStyle*) const; + virtual int popupInternalPaddingRight(RenderStyle*) const; + virtual int popupInternalPaddingTop(RenderStyle*) const; + virtual int popupInternalPaddingBottom(RenderStyle*) const; private: void addIntrinsicMargins(RenderStyle*) const; void close(); - bool supportsFocus(EAppearance) const; + bool supportsFocus(ControlPart) const; }; + +// Constants + +#define MINIMUM_MENU_LIST_SIZE 21 +#define POPUP_INTERNAL_PADDING_LEFT 6 +#define POPUP_INTERNAL_PADDING_TOP 2 +#define POPUP_INTERNAL_PADDING_BOTTOM 2 + +#ifdef __WXMAC__ +#define POPUP_INTERNAL_PADDING_RIGHT 22 +#else +#define POPUP_INTERNAL_PADDING_RIGHT 20 +#endif + RenderTheme* theme() { static RenderThemeWx rt; @@ -93,21 +125,33 @@ RenderTheme* theme() } bool RenderThemeWx::isControlStyled(const RenderStyle* style, const BorderData& border, - const BackgroundLayer& background, const Color& backgroundColor) const + const FillLayer& background, const Color& backgroundColor) const { - if (style->appearance() == TextFieldAppearance || style->appearance() == TextAreaAppearance) + if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart) return style->border() != border; return RenderTheme::isControlStyled(style, border, background, backgroundColor); } +void RenderThemeWx::adjustRepaintRect(const RenderObject* o, IntRect& r) +{ + switch (o->style()->appearance()) { + case MenulistPart: { + r.setWidth(r.width() + 100); + break; + } + default: + break; + } +} + bool RenderThemeWx::controlSupportsTints(const RenderObject* o) const { if (!isEnabled(o)) return false; // Checkboxes only have tint when checked. - if (o->style()->appearance() == CheckboxAppearance) + if (o->style()->appearance() == CheckboxPart) return isChecked(o); // For now assume other controls have tint if enabled. @@ -169,12 +213,12 @@ void RenderThemeWx::setRadioSize(RenderStyle* style) const setCheckboxSize(style); } -bool RenderThemeWx::supportsFocus(EAppearance appearance) const +bool RenderThemeWx::supportsFocus(ControlPart part) const { - switch (appearance) { - case PushButtonAppearance: - case ButtonAppearance: - case TextFieldAppearance: + switch (part) { + case PushButtonPart: + case ButtonPart: + case TextFieldPart: return true; default: // No for all others... return false; @@ -188,32 +232,32 @@ void RenderThemeWx::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* s bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { - wxWindow* window = o->view()->frameView()->nativeWindow(); + wxWindow* window = o->view()->frameView()->platformWidget(); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); - wxASSERT(dc->IsOk()); - int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; - EAppearance appearance = o->style()->appearance(); - if (supportsFocus(o->style()->appearance()) && isFocused(o)) + ControlPart part = o->style()->appearance(); + if (supportsFocus(part) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; - if (appearance == PushButtonAppearance || appearance == ButtonAppearance) + if (part == PushButtonPart || part == ButtonPart) wxRendererNative::Get().DrawPushButton(window, *dc, r, flags); - // TODO: add a radio button rendering API to wx - //else if(appearance == RadioAppearance) - else if(appearance == CheckboxAppearance) { + else if(part == RadioPart) { + if (isChecked(o)) + flags |= wxCONTROL_CHECKED; + wxRenderer_DrawRadioButton(window, *dc, r, flags); + } + else if(part == CheckboxPart) { if (isChecked(o)) flags |= wxCONTROL_CHECKED; wxRendererNative::Get().DrawCheckBox(window, *dc, r, flags); } - return false; } @@ -224,12 +268,67 @@ void RenderThemeWx::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, bool RenderThemeWx::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { - i.context->setStrokeThickness(1); - i.context->setStrokeColor(Color(0, 0, 0)); - i.context->drawRect(r); + wxWindow* window = o->view()->frameView()->platformWidget(); + wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); + wxRenderer_DrawTextCtrl(window, *dc, r, 0); + return false; +} + +int RenderThemeWx::minimumMenuListSize(RenderStyle*) const +{ + return MINIMUM_MENU_LIST_SIZE; +} + +void RenderThemeWx::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const +{ +} + +bool RenderThemeWx::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +{ + wxWindow* window = o->view()->frameView()->platformWidget(); + wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); + + int flags = 0; + if (!isEnabled(o)) + flags |= wxCONTROL_DISABLED; + + if (supportsFocus(o->style()->appearance()) && isFocused(o)) + flags |= wxCONTROL_FOCUSED; + + if (isPressed(o)) + flags |= wxCONTROL_PRESSED; + + wxRenderer_DrawChoice(window, *dc, r, flags); + + return false; +} + +void RenderThemeWx::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const +{ + notImplemented(); +} + +bool RenderThemeWx::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +{ + wxWindow* window = o->view()->frameView()->platformWidget(); + wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); + + int flags = 0; + if (!isEnabled(o)) + flags |= wxCONTROL_DISABLED; + + if (supportsFocus(o->style()->appearance()) && isFocused(o)) + flags |= wxCONTROL_FOCUSED; + + if (isPressed(o)) + flags |= wxCONTROL_PRESSED; + + wxRendererNative::Get().DrawComboBoxDropButton(window, *dc, r, flags); + return false; } + Color RenderThemeWx::platformActiveSelectionBackgroundColor() const { return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); @@ -259,5 +358,25 @@ Color RenderThemeWx::platformInactiveSelectionForegroundColor() const #endif } +int RenderThemeWx::popupInternalPaddingLeft(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_LEFT; +} + +int RenderThemeWx::popupInternalPaddingRight(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_RIGHT; +} + +int RenderThemeWx::popupInternalPaddingTop(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_TOP; +} + +int RenderThemeWx::popupInternalPaddingBottom(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_BOTTOM; +} + } |