1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef WebScrollBar_h 27 #define WebScrollBar_h 28 29 #include "WebKit.h" 30 31 #include <wtf/RefPtr.h> 32 #include <wtf/OwnPtr.h> 33 34 #include <WebCore/COMPtr.h> 35 #include <WebCore/Scrollbar.h> 36 #include <WebCore/ScrollableArea.h> 37 38 namespace WebCore { 39 class Scrollbar; 40 } 41 42 class WebScrollBar : public IWebScrollBarPrivate, WebCore::ScrollableArea { 43 public: 44 static WebScrollBar* createInstance(); 45 protected: 46 WebScrollBar(); 47 ~WebScrollBar(); 48 49 public: 50 // IUnknown 51 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); 52 virtual ULONG STDMETHODCALLTYPE AddRef(void); 53 virtual ULONG STDMETHODCALLTYPE Release(void); 54 55 // IWebScrollBarPrivate 56 virtual HRESULT STDMETHODCALLTYPE init( 57 /* [in] */ IWebScrollBarDelegatePrivate* delegate, 58 /* [in] */ OLE_HANDLE containingWindow, 59 /* [in] */ WebScrollBarOrientation orientation, 60 /* [in] */ WebScrollBarControlSize controlSize); 61 62 virtual HRESULT STDMETHODCALLTYPE setEnabled( 63 /* [in] */ BOOL enabled); 64 65 virtual HRESULT STDMETHODCALLTYPE setSteps( 66 /* [in] */ int lineStep, 67 /* [in] */ int pageStep); 68 69 virtual HRESULT STDMETHODCALLTYPE setProportion( 70 /* [in] */ int visibleSize, 71 /* [in] */ int totalSize); 72 73 virtual HRESULT STDMETHODCALLTYPE setRect( 74 /* [in] */ RECT bounds); 75 76 virtual HRESULT STDMETHODCALLTYPE setValue( 77 /* [in] */ int value); 78 79 virtual HRESULT STDMETHODCALLTYPE value( 80 /* [retval][out] */ int* value); 81 82 virtual HRESULT STDMETHODCALLTYPE paint( 83 /* [in] */ HDC dc, 84 /* [in] */ RECT damageRect); 85 86 virtual HRESULT STDMETHODCALLTYPE frameRect( 87 /* [retval][out] */ RECT* bounds); 88 89 virtual HRESULT STDMETHODCALLTYPE width( 90 /* [retval][out] */ int* w); 91 92 virtual HRESULT STDMETHODCALLTYPE height( 93 /* [retval][out] */ int* h); 94 95 virtual HRESULT STDMETHODCALLTYPE requestedWidth( 96 /* [retval][out] */ int* w); 97 98 virtual HRESULT STDMETHODCALLTYPE requestedHeight( 99 /* [retval][out] */ int* h); 100 101 virtual HRESULT STDMETHODCALLTYPE handleMouseEvent( 102 /* [in] */ OLE_HANDLE window, 103 /* [in] */ UINT msg, 104 /* [in] */ WPARAM wParam, 105 /* [in] */ LPARAM lParam); 106 107 virtual HRESULT STDMETHODCALLTYPE scroll( 108 /* [in] */ WebScrollDirection direction, 109 /* [in] */ WebScrollGranularity granularity, 110 /* [in] */ float multiplier); 111 112 protected: 113 // ScrollableArea 114 virtual int scrollSize(WebCore::ScrollbarOrientation) const; 115 virtual int scrollPosition(WebCore::Scrollbar*) const; 116 virtual void setScrollOffset(const WebCore::IntPoint&); 117 virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&); 118 virtual void invalidateScrollCornerRect(const WebCore::IntRect&) { } 119 120 // FIXME: We should provide a way to set this value. 121 virtual bool isActive() const { return true; } 122 123 virtual bool isScrollCornerVisible() const { return false; } 124 virtual WebCore::IntRect scrollCornerRect() const { return WebCore::IntRect(); } 125 126 virtual WebCore::Scrollbar* horizontalScrollbar() const; 127 virtual WebCore::Scrollbar* verticalScrollbar() const; 128 129 ULONG m_refCount; 130 HWND m_containingWindow; 131 int m_currentPosition; 132 RefPtr<WebCore::Scrollbar> m_scrollBar; 133 COMPtr<IWebScrollBarDelegatePrivate> m_delegate; 134 }; 135 136 #endif 137