| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Collabora Ltd. All rights reserved. | 3 * Copyright (C) 2008 Collabora Ltd. All rights reserved. |
| 4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "platform/geometry/IntRect.h" | 33 #include "platform/geometry/IntRect.h" |
| 34 #include "wtf/Forward.h" | 34 #include "wtf/Forward.h" |
| 35 #include "wtf/RefCounted.h" | 35 #include "wtf/RefCounted.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class Event; | 39 class Event; |
| 40 class GraphicsContext; | 40 class GraphicsContext; |
| 41 class HostWindow; | 41 class HostWindow; |
| 42 | 42 |
| 43 // The Widget class serves as a base class for three kinds of objects: | 43 // The Widget class serves as a base class for Scrollbar and FrameView. |
| 44 // (1) Scrollable areas (ScrollView) | |
| 45 // (2) Scrollbars (Scrollbar) | |
| 46 // (3) Plugins (PluginView) | |
| 47 // | |
| 48 // Widgets are connected in a hierarchy, with the restriction that plugins and | |
| 49 // scrollbars are always leaves of the tree. Only ScrollViews can have children | |
| 50 // (and therefore the Widget class has no concept of children). | |
| 51 class PLATFORM_EXPORT Widget : public RefCounted<Widget> { | 44 class PLATFORM_EXPORT Widget : public RefCounted<Widget> { |
| 52 public: | 45 public: |
| 53 Widget(); | 46 Widget(); |
| 54 virtual ~Widget(); | 47 virtual ~Widget(); |
| 55 | 48 |
| 56 int x() const { return frameRect().x(); } | 49 int x() const { return frameRect().x(); } |
| 57 int y() const { return frameRect().y(); } | 50 int y() const { return frameRect().y(); } |
| 58 int width() const { return frameRect().width(); } | 51 int width() const { return frameRect().width(); } |
| 59 int height() const { return frameRect().height(); } | 52 int height() const { return frameRect().height(); } |
| 60 IntSize size() const { return frameRect().size(); } | 53 IntSize size() const { return frameRect().size(); } |
| 61 IntPoint location() const { return frameRect().location(); } | 54 IntPoint location() const { return frameRect().location(); } |
| 62 | 55 |
| 63 virtual void setFrameRect(const IntRect& frame) { m_frame = frame; } | 56 virtual void setFrameRect(const IntRect& frame) { m_frame = frame; } |
| 64 const IntRect& frameRect() const { return m_frame; } | 57 const IntRect& frameRect() const { return m_frame; } |
| 65 IntRect boundsRect() const { return IntRect(0, 0, width(), height()); } | 58 IntRect boundsRect() const { return IntRect(0, 0, width(), height()); } |
| 66 | 59 |
| 67 void resize(int w, int h) { setFrameRect(IntRect(x(), y(), w, h)); } | 60 void resize(int w, int h) { setFrameRect(IntRect(x(), y(), w, h)); } |
| 68 void resize(const IntSize& s) { setFrameRect(IntRect(location(), s)); } | 61 void resize(const IntSize& s) { setFrameRect(IntRect(location(), s)); } |
| 69 void move(int x, int y) { setFrameRect(IntRect(x, y, width(), height())); } | 62 void move(int x, int y) { setFrameRect(IntRect(x, y, width(), height())); } |
| 70 void move(const IntPoint& p) { setFrameRect(IntRect(p, size())); } | 63 void move(const IntPoint& p) { setFrameRect(IntRect(p, size())); } |
| 71 | 64 |
| 72 virtual void paint(GraphicsContext*, const IntRect&) { } | 65 virtual void paint(GraphicsContext*, const IntRect&) { } |
| 73 void invalidate() { invalidateRect(boundsRect()); } | 66 void invalidate() { invalidateRect(boundsRect()); } |
| 74 virtual void invalidateRect(const IntRect&) = 0; | 67 virtual void invalidateRect(const IntRect&) = 0; |
| 75 | 68 |
| 76 bool isSelfVisible() const { return m_selfVisible; } // Whether or not we ha
ve been explicitly marked as visible or not. | |
| 77 bool isParentVisible() const { return m_parentVisible; } // Whether or not o
ur parent is visible. | |
| 78 bool isVisible() const { return m_selfVisible && m_parentVisible; } // Wheth
er or not we are actually visible. | |
| 79 virtual void setParentVisible(bool visible) { m_parentVisible = visible; } | |
| 80 void setSelfVisible(bool v) { m_selfVisible = v; } | |
| 81 | |
| 82 virtual bool isFrameView() const { return false; } | 69 virtual bool isFrameView() const { return false; } |
| 83 virtual bool isScrollbar() const { return false; } | 70 virtual bool isScrollbar() const { return false; } |
| 84 virtual bool isScrollView() const { return false; } | |
| 85 | 71 |
| 86 virtual HostWindow* hostWindow() const { ASSERT_NOT_REACHED(); return 0; } | 72 virtual HostWindow* hostWindow() const { ASSERT_NOT_REACHED(); return 0; } |
| 87 virtual void setParent(Widget*); | 73 void setParent(Widget* parent) { m_parent = parent; } |
| 88 Widget* parent() const { return m_parent; } | 74 Widget* parent() const { return m_parent; } |
| 89 Widget* root() const; | 75 Widget* root() const; |
| 90 | 76 |
| 91 virtual void handleEvent(Event*) { } | |
| 92 | |
| 93 IntRect convertToRootView(const IntRect&) const; | 77 IntRect convertToRootView(const IntRect&) const; |
| 94 IntRect convertFromRootView(const IntRect&) const; | 78 IntRect convertFromRootView(const IntRect&) const; |
| 95 | 79 |
| 96 IntPoint convertToRootView(const IntPoint&) const; | 80 IntPoint convertToRootView(const IntPoint&) const; |
| 97 IntPoint convertFromRootView(const IntPoint&) const; | 81 IntPoint convertFromRootView(const IntPoint&) const; |
| 98 | 82 |
| 99 // It is important for cross-platform code to realize that Mac has flipped c
oordinates. Therefore any code | 83 // It is important for cross-platform code to realize that Mac has flipped c
oordinates. Therefore any code |
| 100 // that tries to convert the location of a rect using the point-based conver
tFromContainingWindow will end | 84 // that tries to convert the location of a rect using the point-based conver
tFromContainingWindow will end |
| 101 // up with an inaccurate rect. Always make sure to use the rect-based conver
tFromContainingWindow method | 85 // up with an inaccurate rect. Always make sure to use the rect-based conver
tFromContainingWindow method |
| 102 // when converting window rects. | 86 // when converting window rects. |
| 103 IntRect convertToContainingWindow(const IntRect&) const; | 87 IntRect convertToContainingWindow(const IntRect&) const; |
| 104 IntRect convertFromContainingWindow(const IntRect&) const; | 88 IntRect convertFromContainingWindow(const IntRect&) const; |
| 105 | 89 |
| 106 IntPoint convertToContainingWindow(const IntPoint&) const; | 90 IntPoint convertToContainingWindow(const IntPoint&) const; |
| 107 IntPoint convertFromContainingWindow(const IntPoint&) const; | 91 IntPoint convertFromContainingWindow(const IntPoint&) const; |
| 108 FloatPoint convertFromContainingWindow(const FloatPoint&) const; | 92 FloatPoint convertFromContainingWindow(const FloatPoint&) const; |
| 109 | 93 |
| 110 // Virtual methods to convert points to/from the containing ScrollView | 94 // Virtual methods to convert points to/from the containing ScrollView |
| 111 virtual IntRect convertToContainingView(const IntRect&) const; | 95 virtual IntRect convertToContainingView(const IntRect&) const; |
| 112 virtual IntRect convertFromContainingView(const IntRect&) const; | 96 virtual IntRect convertFromContainingView(const IntRect&) const; |
| 113 virtual IntPoint convertToContainingView(const IntPoint&) const; | 97 virtual IntPoint convertToContainingView(const IntPoint&) const; |
| 114 virtual IntPoint convertFromContainingView(const IntPoint&) const; | 98 virtual IntPoint convertFromContainingView(const IntPoint&) const; |
| 115 | 99 |
| 116 // Virtual methods to convert points to/from child widgets | |
| 117 virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const; | |
| 118 virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const; | |
| 119 | |
| 120 private: | 100 private: |
| 121 Widget* m_parent; | 101 Widget* m_parent; |
| 122 IntRect m_frame; | 102 IntRect m_frame; |
| 123 bool m_selfVisible; | |
| 124 bool m_parentVisible; | |
| 125 }; | 103 }; |
| 126 | 104 |
| 127 } // namespace blink | 105 } // namespace blink |
| 128 | 106 |
| 129 #endif // Widget_h | 107 #endif // Widget_h |
| OLD | NEW |