From 6d58bc1d0db1428b24d419c2f8bf74e48e94c1b9 Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Mon, 21 Apr 2003 23:01:36 +0000 Subject: [PATCH] Remove now-unused nsScrollingView and nsIScrollbar implementations. Removed unused widget/public/nsWidgetSupport.h. Bug 201624, r+sr=roc. git-svn-id: svn://10.0.0.236/trunk@141538 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 1 - mozilla/layout/build/nsLayoutModule.cpp | 4 - mozilla/layout/html/base/src/nsPresShell.cpp | 1 - .../TableContentTest/TableContentTest.cpp | 2 +- mozilla/modules/libpref/src/init/all.js | 1 - mozilla/view/public/nsViewsCID.h | 4 - mozilla/view/src/Makefile.in | 1 - mozilla/view/src/nsScrollPortView.cpp | 1 - mozilla/view/src/nsScrollingView.cpp | 1800 ----------------- mozilla/view/src/nsScrollingView.h | 158 -- mozilla/view/src/nsView.cpp | 1 - mozilla/view/src/nsViewManager.cpp | 7 - .../webshell/tests/viewer/nsWidgetSupport.cpp | 29 - .../webshell/tests/viewer/nsWidgetSupport.h | 8 - mozilla/widget/public/MANIFEST | 2 - mozilla/widget/public/Makefile.in | 1 - mozilla/widget/public/nsIScrollbar.h | 139 -- mozilla/widget/public/nsWidgetSupport.h | 121 -- mozilla/widget/src/beos/Makefile.in | 1 - mozilla/widget/src/beos/nsScrollbar.cpp | 362 ---- mozilla/widget/src/beos/nsScrollbar.h | 107 - mozilla/widget/src/beos/nsWidgetFactory.cpp | 61 - mozilla/widget/src/build/nsWidgetSupport.cpp | 29 - .../widget/src/build/nsWinWidgetFactory.cpp | 69 - mozilla/widget/src/cocoa/Makefile.in | 1 - mozilla/widget/src/cocoa/nsScrollbar.h | 157 -- mozilla/widget/src/cocoa/nsScrollbar.mm | 458 ----- mozilla/widget/src/cocoa/nsWidgetFactory.mm | 11 - mozilla/widget/src/gtk/Makefile.in | 1 - mozilla/widget/src/gtk/nsGtkEventHandler.cpp | 64 - mozilla/widget/src/gtk/nsGtkEventHandler.h | 2 - mozilla/widget/src/gtk/nsScrollbar.cpp | 470 ----- mozilla/widget/src/gtk/nsScrollbar.h | 81 - mozilla/widget/src/gtk/nsWidgetFactory.cpp | 67 - mozilla/widget/src/gtk/nsWindow.cpp | 5 - mozilla/widget/src/gtk/nsWindow.h | 1 - mozilla/widget/src/gtk2/Makefile.in | 1 - mozilla/widget/src/gtk2/nsCommonWidget.cpp | 11 - mozilla/widget/src/gtk2/nsCommonWidget.h | 1 - mozilla/widget/src/gtk2/nsScrollbar.cpp | 575 ------ mozilla/widget/src/gtk2/nsScrollbar.h | 144 -- mozilla/widget/src/gtk2/nsWidgetFactory.cpp | 67 - mozilla/widget/src/mac/Makefile.in | 1 - mozilla/widget/src/mac/nsScrollbar.cpp | 442 ---- mozilla/widget/src/mac/nsScrollbar.h | 110 - mozilla/widget/src/mac/nsWidgetFactory.cpp | 10 - mozilla/widget/src/mac/nsWidgetSupport.cpp | 28 - mozilla/widget/src/os2/Makefile.in | 1 - mozilla/widget/src/os2/nsScrollbar.cpp | 362 ---- mozilla/widget/src/os2/nsScrollbar.h | 77 - mozilla/widget/src/os2/nsWidgetFactory.cpp | 68 - mozilla/widget/src/photon/Makefile.in | 3 +- mozilla/widget/src/photon/nsScrollbar.cpp | 365 ---- mozilla/widget/src/photon/nsScrollbar.h | 83 - mozilla/widget/src/photon/nsWidgetFactory.cpp | 67 - .../widget/src/support/nsWidgetSupport.cpp | 29 - mozilla/widget/src/support/nsWidgetSupport.h | 8 - mozilla/widget/src/windows/Makefile.in | 1 - mozilla/widget/src/windows/nsScrollbar.cpp | 563 ------ mozilla/widget/src/windows/nsScrollbar.h | 102 - mozilla/widget/src/xlib/Makefile.in | 1 - mozilla/widget/src/xlib/nsScrollBar.cpp | 444 ---- mozilla/widget/src/xlib/nsScrollBar.h | 102 - mozilla/widget/src/xlib/nsWidgetFactory.cpp | 63 - 64 files changed, 2 insertions(+), 7955 deletions(-) delete mode 100644 mozilla/view/src/nsScrollingView.cpp delete mode 100644 mozilla/view/src/nsScrollingView.h delete mode 100644 mozilla/widget/public/nsIScrollbar.h delete mode 100644 mozilla/widget/public/nsWidgetSupport.h delete mode 100644 mozilla/widget/src/beos/nsScrollbar.cpp delete mode 100644 mozilla/widget/src/beos/nsScrollbar.h delete mode 100644 mozilla/widget/src/cocoa/nsScrollbar.h delete mode 100644 mozilla/widget/src/cocoa/nsScrollbar.mm delete mode 100644 mozilla/widget/src/gtk/nsScrollbar.cpp delete mode 100644 mozilla/widget/src/gtk/nsScrollbar.h delete mode 100644 mozilla/widget/src/gtk2/nsScrollbar.cpp delete mode 100644 mozilla/widget/src/gtk2/nsScrollbar.h delete mode 100644 mozilla/widget/src/mac/nsScrollbar.cpp delete mode 100644 mozilla/widget/src/mac/nsScrollbar.h delete mode 100644 mozilla/widget/src/os2/nsScrollbar.cpp delete mode 100644 mozilla/widget/src/os2/nsScrollbar.h delete mode 100644 mozilla/widget/src/photon/nsScrollbar.cpp delete mode 100644 mozilla/widget/src/photon/nsScrollbar.h delete mode 100644 mozilla/widget/src/windows/nsScrollbar.cpp delete mode 100644 mozilla/widget/src/windows/nsScrollbar.h delete mode 100644 mozilla/widget/src/xlib/nsScrollBar.cpp delete mode 100644 mozilla/widget/src/xlib/nsScrollBar.h diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index ffc91bccd77..ae33ff3022b 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -6876,7 +6876,6 @@ PresShell::RemoveDummyLayoutRequest(void) #include "nsILinkHandler.h" static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); -static NS_DEFINE_CID(kScrollingViewCID, NS_SCROLLING_VIEW_CID); static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); static void diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index 6cf1a41d4d4..cae8acfcca7 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -135,7 +135,6 @@ // view stuff #include "nsViewsCID.h" #include "nsView.h" -#include "nsScrollingView.h" #include "nsScrollPortView.h" #include "nsViewManager.h" @@ -529,7 +528,6 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewManager) NS_GENERIC_FACTORY_CONSTRUCTOR_NOREFS(nsView) -NS_GENERIC_FACTORY_CONSTRUCTOR_NOREFS(nsScrollingView) NS_GENERIC_FACTORY_CONSTRUCTOR_NOREFS(nsScrollPortView) static NS_IMETHODIMP @@ -1169,8 +1167,6 @@ static const nsModuleComponentInfo gComponents[] = { { "View Manager", NS_VIEW_MANAGER_CID, "@mozilla.org/view-manager;1", nsViewManagerConstructor }, { "View", NS_VIEW_CID, "@mozilla.org/view;1", nsViewConstructor }, - { "Scrolling View", NS_SCROLLING_VIEW_CID, "@mozilla.org/scrolling-view;1", - nsScrollingViewConstructor }, { "Scroll Port View", NS_SCROLL_PORT_VIEW_CID, "@mozilla.org/scroll-port-view;1", nsScrollPortViewConstructor }, diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index ffc91bccd77..ae33ff3022b 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -6876,7 +6876,6 @@ PresShell::RemoveDummyLayoutRequest(void) #include "nsILinkHandler.h" static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); -static NS_DEFINE_CID(kScrollingViewCID, NS_SCROLLING_VIEW_CID); static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); static void diff --git a/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp b/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp index 751204b2ab1..ae0eae3fe00 100644 --- a/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp +++ b/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp @@ -483,7 +483,7 @@ GeometryTest::GeometryTest(BasicTest *aDoc) nsIView * rootView = nsnull; // Create a view - static NS_DEFINE_IID(kScrollingViewCID, NS_SCROLLING_VIEW_CID); + static NS_DEFINE_IID(kScrollingViewCID, NS_SCROLL_PORT_VIEW_CID); status = nsComponentManager::CreateInstance(kScrollingViewCID, nsnull, diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index ecc948ebece..f97913a640c 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -212,7 +212,6 @@ pref("view_source.wrap_long_lines", false); // gfx widgets pref("nglayout.widget.mode", 2); -pref("nglayout.widget.gfxscrollbars", true); // css2 hover pref pref("nglayout.events.showHierarchicalHover", false); diff --git a/mozilla/view/public/nsViewsCID.h b/mozilla/view/public/nsViewsCID.h index 0d70bffe5bf..3ebd22360bd 100644 --- a/mozilla/view/public/nsViewsCID.h +++ b/mozilla/view/public/nsViewsCID.h @@ -50,10 +50,6 @@ { 0xc95f1832, 0xc376, 0x11d1, \ {0xb7, 0x21, 0x0, 0x60, 0x8, 0x91, 0xd8, 0xc9}} -#define NS_SCROLLING_VIEW_CID \ -{ 0xc95f1833, 0xc376, 0x11d1, \ - {0xb7, 0x21, 0x0, 0x60, 0x8, 0x91, 0xd8, 0xc9}} - #define NS_SCROLL_PORT_VIEW_CID \ { 0x3b733c91, 0x7223, 0x11d3, \ { 0xb3, 0x61, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde }} diff --git a/mozilla/view/src/Makefile.in b/mozilla/view/src/Makefile.in index e9d08ae24c5..64354b353ab 100644 --- a/mozilla/view/src/Makefile.in +++ b/mozilla/view/src/Makefile.in @@ -48,7 +48,6 @@ EXTRA_DSO_LIBS = gkgfx CPPSRCS = \ nsView.cpp \ - nsScrollingView.cpp \ nsScrollPortView.cpp \ nsViewManager.cpp \ $(NULL) diff --git a/mozilla/view/src/nsScrollPortView.cpp b/mozilla/view/src/nsScrollPortView.cpp index 45131ea12f8..e8f93ad6073 100644 --- a/mozilla/view/src/nsScrollPortView.cpp +++ b/mozilla/view/src/nsScrollPortView.cpp @@ -39,7 +39,6 @@ #include "nsIWidget.h" #include "nsUnitConversion.h" #include "nsIPresContext.h" -#include "nsIScrollbar.h" #include "nsIDeviceContext.h" #include "nsGUIEvent.h" #include "nsWidgetsCID.h" diff --git a/mozilla/view/src/nsScrollingView.cpp b/mozilla/view/src/nsScrollingView.cpp deleted file mode 100644 index 20ec44e1b94..00000000000 --- a/mozilla/view/src/nsScrollingView.cpp +++ /dev/null @@ -1,1800 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsScrollingView.h" -#include "nsIServiceManager.h" -#include "nsIWidget.h" -#include "nsUnitConversion.h" -#include "nsIPresContext.h" -#include "nsIScrollbar.h" -#include "nsIDeviceContext.h" -#include "nsGUIEvent.h" -#include "nsWidgetsCID.h" -#include "nsViewsCID.h" -#include "nsIScrollableView.h" -#include "nsIFrame.h" -#include "nsILookAndFeel.h" -#include "nsISupportsArray.h" -#include "nsIScrollPositionListener.h" -#include "nsIRegion.h" -#include "nsViewManager.h" - -static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID); -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); -static NS_DEFINE_IID(kIClipViewIID, NS_ICLIPVIEW_IID); - -class ScrollBarView : public nsView -{ -public: - ScrollBarView(nsScrollingView *aScrollingView); - ~ScrollBarView(); - - nsEventStatus HandleEvent(nsViewManager* aVM, nsGUIEvent *aEvent, PRBool aCaptured); - - // Do not set the visibility of the ScrollbarView using SetVisibility. Instead it - // must be marked as visible or hidden using SetEnabled. - // The nsScrollingView::UpdateComponentVisibility looks at both the enabled flag and the - // scrolling views visibility to determine if the ScrollBarView is visible or hidden and calls - // SetVisibility. KMM - - void SetEnabled(PRBool aEnabled); - PRBool GetEnabled(); - -public: - nsScrollingView *mScrollingView; - -protected: - PRBool mEnabled; - -}; - -static inline PRBool -ViewIsShowing(ScrollBarView *aView) -{ - return(aView->GetEnabled()); -} - -ScrollBarView::ScrollBarView(nsScrollingView *aScrollingView) -{ - mScrollingView = aScrollingView; - mEnabled = PR_FALSE; -} - -ScrollBarView::~ScrollBarView() -{ -} - -nsEventStatus ScrollBarView::HandleEvent(nsViewManager* aVM, nsGUIEvent *aEvent, PRBool aCaptured) -{ - switch (aEvent->message) - { - case NS_SCROLLBAR_POS: - case NS_SCROLLBAR_PAGE_NEXT: - case NS_SCROLLBAR_PAGE_PREV: - case NS_SCROLLBAR_LINE_NEXT: - case NS_SCROLLBAR_LINE_PREV: - NS_ASSERTION((nsnull != mScrollingView), "HandleEvent() called after the ScrollingView has been destroyed."); - if (nsnull != mScrollingView) - mScrollingView->HandleScrollEvent(aEvent, 0); - return nsEventStatus_eConsumeNoDefault; - - default: - break; - } - - return nsEventStatus_eIgnore; -} - -void ScrollBarView::SetEnabled(PRBool aEnabled) -{ - mEnabled = aEnabled; -} - -PRBool ScrollBarView::GetEnabled() -{ - return(mEnabled); -} - -class CornerView : public nsView -{ -public: - CornerView(); - ~CornerView(); - - NS_IMETHOD ShowQuality(PRBool aShow); - NS_IMETHOD SetQuality(nsContentQuality aQuality); - NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect, - PRUint32 aPaintFlags, PRBool &Result); - NS_IMETHOD Paint(nsIRenderingContext& rc, const nsIRegion& region, - PRUint32 aPaintFlags, PRBool &aResult); - - void Show(PRBool aShow, PRBool aRethink); - - PRBool mShowQuality; - nsContentQuality mQuality; - PRBool mShow; - nsCOMPtr mLookAndFeelService; -}; - -CornerView::CornerView() -{ - mShowQuality = PR_FALSE; - mQuality = nsContentQuality_kGood; - mShow = PR_FALSE; -} - -CornerView::~CornerView() -{ -} - -NS_IMETHODIMP CornerView::ShowQuality(PRBool aShow) -{ - if (mShowQuality != aShow) - { - mShowQuality = aShow; - - if (mShow == PR_FALSE) - { - if (mShowQuality == PR_FALSE) - mViewManager->SetViewVisibility(this, nsViewVisibility_kHide); - else - mViewManager->SetViewVisibility(this, nsViewVisibility_kShow); - - nsIScrollableView *par; - if (NS_SUCCEEDED (mParent->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&par))) { - par->ComputeScrollOffsets(PR_TRUE); - } - } - - mViewManager->UpdateView(this, NS_VMREFRESH_IMMEDIATE); - } - return NS_OK; -} - -NS_IMETHODIMP CornerView::SetQuality(nsContentQuality aQuality) -{ - if (mQuality != aQuality) - { - mQuality = aQuality; - - if (mVis == nsViewVisibility_kShow) - mViewManager->UpdateView(this, NS_VMREFRESH_IMMEDIATE); - } - return NS_OK; -} - -void CornerView::Show(PRBool aShow, PRBool aRethink) -{ - if (mShow != aShow) - { - mShow = aShow; - - if (mShow == PR_TRUE) - mViewManager->SetViewVisibility(this, nsViewVisibility_kShow); - else if (mShowQuality == PR_FALSE) - mViewManager->SetViewVisibility(this, nsViewVisibility_kHide); - - if (PR_TRUE == aRethink) - { - nsIScrollableView *par; - if (NS_SUCCEEDED (mParent->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&par))) { - par->ComputeScrollOffsets(PR_TRUE); - } - } - } -} - -NS_IMETHODIMP CornerView::Paint(nsIRenderingContext& rc, const nsRect& rect, - PRUint32 aPaintFlags, PRBool &aResult) -{ - if (mVis == nsViewVisibility_kShow) - { - nsRect brect; - nscolor bgcolor; - - GetBounds(brect); - - brect.x = brect.y = 0; - - if (!mLookAndFeelService) - mLookAndFeelService = do_GetService(kLookAndFeelCID); - - if (mLookAndFeelService) - mLookAndFeelService->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgcolor); - else - bgcolor = NS_RGB(192, 192, 192); - - rc.SetColor(bgcolor); - rc.FillRect(brect); - - if (mShowQuality) - { - nscolor tcolor, bcolor; - - //display quality indicator - - rc.Translate(brect.x, brect.y); - - rc.SetColor(NS_RGB(0, 0, 0)); - - rc.FillEllipse(NSToCoordFloor(brect.width * 0.15f), - NSToCoordFloor(brect.height * 0.15f), - NSToCoordRound(brect.width * 0.7f), // XXX should use NSToCoordCeil ?? - NSToCoordRound(brect.height * 0.7f)); // XXX should use NSToCoordCeil ?? - - if (mQuality == nsContentQuality_kGood) - rc.SetColor(NS_RGB(0, 255, 0)); - else if (mQuality == nsContentQuality_kFair) - rc.SetColor(NS_RGB(255, 176, 0)); - else if (mQuality == nsContentQuality_kPoor) - rc.SetColor(NS_RGB(255, 0, 0)); - else - rc.SetColor(NS_RGB(0, 0, 255)); - - //hey, notice that these numbers don't add up... that's because - //something funny happens on windows when the *right* numbers are - //used. MMP - - rc.FillEllipse(NSToCoordRound(brect.width * 0.23f), // XXX should use NSToCoordCeil ?? - NSToCoordRound(brect.height * 0.23f), // XXX should use NSToCoordCeil ?? - nscoord(brect.width * 0.46f), - nscoord(brect.height * 0.46f)); - - rc.GetColor(bcolor); - tcolor = bcolor; - - //this is inefficient, but compact... - - tcolor = NS_RGB((int)PR_MIN(NS_GET_R(bcolor) + 40, 255), - (int)PR_MIN(NS_GET_G(bcolor) + 40, 255), - (int)PR_MIN(NS_GET_B(bcolor) + 40, 255)); - - rc.SetColor(tcolor); - - rc.FillEllipse(NSToCoordRound(brect.width * 0.34f), // XXX should use NSToCoordCeil ?? - NSToCoordRound(brect.height * 0.34f), // XXX should use NSToCoordCeil ?? - nscoord(brect.width * 0.28f), - nscoord(brect.height * 0.28f)); - - tcolor = NS_RGB((int)PR_MIN(NS_GET_R(bcolor) + 120, 255), - (int)PR_MIN(NS_GET_G(bcolor) + 120, 255), - (int)PR_MIN(NS_GET_B(bcolor) + 120, 255)); - - rc.SetColor(tcolor); - - rc.FillEllipse(NSToCoordRound(brect.width * 0.32f), // XXX should use NSToCoordCeil ?? - NSToCoordRound(brect.height * 0.32f), // XXX should use NSToCoordCeil ?? - nscoord(brect.width * 0.17f), - nscoord(brect.height * 0.17f)); - } - } - - aResult = PR_TRUE; - - return NS_OK; -} - -NS_IMETHODIMP -CornerView::Paint(nsIRenderingContext& rc, const nsIRegion& region, - PRUint32 aPaintFlags, PRBool &aResult) -{ - // Corner View Paint is overridden to get rid of compiler warnings caused - // by overloading Paint then overriding Paint. - return nsView::Paint(rc, region, aPaintFlags, aResult); -} - - -class ClipView : public nsView, public nsIClipView -{ -public: - ClipView(); - ~ClipView(); - - NS_IMETHOD QueryInterface(REFNSIID aIID, - void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); -}; - -ClipView::ClipView() -{ -} - -ClipView::~ClipView() -{ -} - -nsresult ClipView::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (nsnull == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - if (aIID.Equals(NS_GET_IID(nsIClipView))) { - *aInstancePtr = (void*)(nsIClipView*)this; - return NS_OK; - } - - return nsView::QueryInterface(aIID, aInstancePtr); -} - -nsrefcnt ClipView::AddRef() -{ - NS_WARNING("not supported for views"); - return 1; -} - -nsrefcnt ClipView::Release() -{ - NS_WARNING("not supported for views"); - return 1; -} - -nsScrollingView::nsScrollingView() - : mInsets(0, 0, 0, 0) -{ - mSizeX = mSizeY = 0; - mOffsetX = mOffsetY = 0; - mClipView = nsnull; - mVScrollBarView = nsnull; - mHScrollBarView = nsnull; - mCornerView = nsnull; - mScrollPref = nsScrollPreference_kAuto; - mLineHeight = 240; - mListeners = nsnull; -} - -nsScrollingView::~nsScrollingView() -{ - if (nsnull != mVScrollBarView) - { - // Clear the back-pointer from the scrollbar... - ((ScrollBarView*)mVScrollBarView)->mScrollingView = nsnull; - } - - if (nsnull != mHScrollBarView) - { - // Clear the back-pointer from the scrollbar... - ((ScrollBarView*)mHScrollBarView)->mScrollingView = nsnull; - } - - mClipView = nsnull; - mCornerView = nsnull; - - if (mScrollingTimer) - { - mScrollingTimer->Cancel(); - } - - if (nsnull != mListeners) { - mListeners->Clear(); - NS_RELEASE(mListeners); - } - - if (nsnull != mViewManager) { - nsIScrollableView* scrollingView; - mViewManager->GetRootScrollableView(&scrollingView); - if ((nsnull != scrollingView) && (this == scrollingView)) { - mViewManager->SetRootScrollableView(nsnull); - } - } -} - -nsresult nsScrollingView::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (nsnull == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - *aInstancePtr = nsnull; - if (aIID.Equals(NS_GET_IID(nsIScrollableView))) { - *aInstancePtr = (void*)(nsIScrollableView*)this; - return NS_OK; - } - - return nsView::QueryInterface(aIID, aInstancePtr); -} - -nsrefcnt nsScrollingView::AddRef() -{ - NS_WARNING("not supported for views"); - return 1; -} - -nsrefcnt nsScrollingView::Release() -{ - NS_WARNING("not supported for views"); - return 1; -} - - -NS_IMETHODIMP nsScrollingView::Init(nsIViewManager* aManager, - const nsRect &aBounds, - const nsIView *aParent, - nsViewVisibility aVisibilityFlag) -{ - nsIDeviceContext *dx = nsnull; - - aManager->GetDeviceContext(dx); - - if (dx) - { - float t2d, d2a; - - dx->GetTwipsToDevUnits(t2d); - dx->GetDevUnitsToAppUnits(d2a); - - mLineHeight = NSToCoordRound(240.0f * t2d * d2a); - - NS_RELEASE(dx); - } - - return nsView::Init(aManager, aBounds, aParent, aVisibilityFlag); -} - -void nsScrollingView::SetDimensions(const nsRect& aRect, PRBool aPaint) -{ - nsIDeviceContext *dx; - mViewManager->GetDeviceContext(dx); - float scrollWidth, scrollHeight; - dx->GetScrollBarDimensions(scrollWidth, scrollHeight); - nscoord showHorz = 0, showVert = 0; - nsRect clipRect; - - // Set our bounds and size our widget if we have one - nsView::SetDimensions(aRect, aPaint); - -#if 0 - //this will fix the size of the thumb when we resize the root window, - //but unfortunately it will also cause scrollbar flashing. so long as - //all resize operations happen through the viewmanager, this is not - //an issue. we'll see. MMP - - ComputeScrollOffsets(); -#endif - - NS_ASSERTION(aRect.x == 0 && aRect.y == 0, "ScrollingView has contents sticking above or to left"); - - // Determine how much space is actually taken up by the scrollbars - if (mHScrollBarView && ViewIsShowing((ScrollBarView *)mHScrollBarView)) - showHorz = NSToCoordRound(scrollHeight); - - if (mVScrollBarView && ViewIsShowing((ScrollBarView *)mVScrollBarView)) - showVert = NSToCoordRound(scrollWidth); - - // Compute the clip view rect - clipRect.SetRect(0, 0, PR_MAX((aRect.width - showVert), mInsets.left+mInsets.right), PR_MAX((aRect.height - showHorz), mInsets.top+mInsets.bottom)); - clipRect.Deflate(mInsets); - - // Size and position the clip view - if (nsnull != mClipView) { - mClipView->SetPosition(clipRect.x, clipRect.y); - clipRect.x = clipRect.y = 0; - mClipView->SetDimensions(clipRect, aPaint); - UpdateScrollControls(aPaint); - } - - NS_RELEASE(dx); -} - -void nsScrollingView::SetPosition(nscoord aX, nscoord aY) -{ - // If we have a widget then there's no need to adjust child widgets, - // because they're relative to our window - if (nsnull != mWindow) - { - nsView::SetPosition(aX, aY); - } - else - { - nsIDeviceContext *dx; - nsIWidget *thiswin; - GetWidget(thiswin); - float t2p; - - if (nsnull == thiswin) - GetOffsetFromWidget(nsnull, nsnull, thiswin); - - if (nsnull != thiswin) - thiswin->BeginResizingChildren(); - - nsView::SetPosition(aX, aY); - - mViewManager->GetDeviceContext(dx); - dx->GetAppUnitsToDevUnits(t2p); - - nsView* scrolledView = GetScrolledView(); - if (scrolledView) - { - // Adjust the positions of the scrollbars and clip view's widget - AdjustChildWidgets(this, this, 0, 0, t2p); - } - - if (nsnull != thiswin) - { - thiswin->EndResizingChildren(); - NS_RELEASE(thiswin); - } - - NS_RELEASE(dx); - } -} - -nsresult -nsScrollingView::SetComponentVisibility(nsView* aView, nsViewVisibility aViewVisibility) -{ - nsresult rv = NS_OK; - if (nsnull != aView) { - // Only set visibility if it's not currently set. - nsViewVisibility componentVisibility; - aView->GetVisibility(componentVisibility); - if (aViewVisibility != componentVisibility) { - rv = aView->SetVisibility(aViewVisibility); - } - } - - return rv; -} - -// Set the visibility of the scrolling view's components (ClipView, CornerView, ScrollBarView's) - -nsresult -nsScrollingView::UpdateComponentVisibility(nsViewVisibility aScrollingViewVisibility) -{ - nsresult rv = NS_OK; - if (nsViewVisibility_kHide == aScrollingViewVisibility) { - - // Hide Clip View - rv = SetComponentVisibility(mClipView, nsViewVisibility_kHide); - - // Hide horizontal scrollbar - if (NS_SUCCEEDED(rv)) { - rv = SetComponentVisibility(mHScrollBarView, nsViewVisibility_kHide); - } - - // Hide vertical scrollbar - if (NS_SUCCEEDED(rv)) { - rv = SetComponentVisibility(mVScrollBarView, nsViewVisibility_kHide); - } - - // Hide the corner view - if (NS_SUCCEEDED(rv)) { - rv = SetComponentVisibility(mCornerView, nsViewVisibility_kHide); - } - - } else if (nsViewVisibility_kShow == aScrollingViewVisibility) { - // Show clip view if if the scrolling view is visible - rv = SetComponentVisibility(mClipView, nsViewVisibility_kShow); - - PRBool horizEnabled = PR_FALSE; - PRBool vertEnabled = PR_FALSE; - - // Show horizontal scrollbar if it is enabled otherwise hide it - if ((NS_SUCCEEDED(rv)) && (nsnull != mHScrollBarView)) { - horizEnabled = ((ScrollBarView *)mHScrollBarView)->GetEnabled(); - rv = SetComponentVisibility(mHScrollBarView, horizEnabled ? nsViewVisibility_kShow : nsViewVisibility_kHide); - } - - // Show vertical scrollbar view if it is enabled otherwise hide it - if ((NS_SUCCEEDED(rv)) && (nsnull != mVScrollBarView)) { - vertEnabled = ((ScrollBarView *)mVScrollBarView)->GetEnabled(); - rv = SetComponentVisibility(mVScrollBarView, vertEnabled ? nsViewVisibility_kShow : nsViewVisibility_kHide); - } - - // Show the corner view if both the horizontal and vertical scrollbars are enabled otherwise hide it - if (NS_SUCCEEDED(rv)) { - rv = SetComponentVisibility(mCornerView, (horizEnabled && vertEnabled) ? nsViewVisibility_kShow : nsViewVisibility_kHide); - } - } - - return rv; -} - - -NS_IMETHODIMP nsScrollingView::SetVisibility(nsViewVisibility aVisibility) -{ - nsresult rv = UpdateComponentVisibility(aVisibility); - if (NS_SUCCEEDED(rv)) { - rv = nsView::SetVisibility(aVisibility); - } - return rv; -} - -NS_IMETHODIMP nsScrollingView::GetClipView(const nsIView** aClipView) const -{ - NS_PRECONDITION(aClipView, "null pointer"); - *aClipView = mClipView; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::AddScrollPositionListener(nsIScrollPositionListener* aListener) -{ - if (nsnull == mListeners) { - nsresult rv = NS_NewISupportsArray(&mListeners); - if (NS_FAILED(rv)) - return rv; - } - return mListeners->AppendElement(aListener); -} - -NS_IMETHODIMP nsScrollingView::RemoveScrollPositionListener(nsIScrollPositionListener* aListener) -{ - if (nsnull != mListeners) { - return mListeners->RemoveElement(aListener); - } - return NS_ERROR_FAILURE; -} - -void nsScrollingView::HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags) -{ - nsIView *scview = nsView::GetViewFor(aEvent->widget); - nsIDeviceContext *px; - float t2p, p2t; - nscoord dx = 0, dy = 0; // in device units - nsSize clipSize; - - mViewManager->GetDeviceContext(px); - px->GetAppUnitsToDevUnits(t2p); - px->GetDevUnitsToAppUnits(p2t); - NS_RELEASE(px); - - // Get the size of the clip view - mClipView->GetDimensions(clipSize); - - nscoord offsetX = mOffsetX; - nscoord offsetY = mOffsetY; - - // Is it a vertical scroll event or a horizontal scroll event? - if ((nsnull != mVScrollBarView) && (scview == mVScrollBarView)) - { - nscoord oldOffsetY = offsetY; - nscoord newPos; - - // The new scrollbar position is in app units - newPos = ((nsScrollbarEvent *)aEvent)->position; - - // Don't allow a scroll below the bottom of the scrolled view - if ((newPos + clipSize.height) > mSizeY) - newPos = mSizeY - clipSize.height; - - // Snap the new scrollbar position to the nearest pixel. This ensures that - // as we scroll the view a pixel at a time the scrollbar position - // is at the same pixel as the top edge of the scrolled view - offsetY = NSIntPixelsToTwips(NSTwipsToIntPixels(newPos, t2p), p2t); - - // Compute the delta in device units. We need device units when scrolling - // the window - dy = NSTwipsToIntPixels((oldOffsetY - offsetY), t2p); - if (dy != 0) - { - // Update the scrollbar position passed in with the scrollbar event. - // This value will be used to update the scrollbar thumb, and we want - // to make sure the scrollbar thumb is in sync with the offset we came - // up with here. - ((nsScrollbarEvent *)aEvent)->position = offsetY; - } - } - else if ((nsnull != mHScrollBarView) && (scview == mHScrollBarView)) - { - nscoord oldOffsetX = offsetX; - nscoord newPos; - - // The new scrollbar position is in app units - newPos = ((nsScrollbarEvent *)aEvent)->position; - - // Don't allow a scroll beyond the width of the scrolled view - if ((newPos + clipSize.width) > mSizeX) - newPos = mSizeX - clipSize.width; - - // Snap the new scrollbar position to the nearest pixel. This ensures that - // as we scroll the view a pixel at a time the scrollbar position - // is at the same pixel as the left edge of the scrolled view - offsetX = NSIntPixelsToTwips(NSTwipsToIntPixels(newPos, t2p), p2t); - - // Compute the delta in device units. We need device units when scrolling - // the window - dx = NSTwipsToIntPixels((oldOffsetX - offsetX), t2p); - if (dx != 0) - { - // Update the scrollbar position passed in with the scrollbar event. - // This value will be used to update the scrollbar thumb, and we want - // to make sure the scrollbar thumb is in sync with the offset we came - // up with here. - ((nsScrollbarEvent *)aEvent)->position = offsetX; - } - } - - NotifyScrollPositionWillChange(offsetX, offsetY); - - mOffsetX = offsetX; - mOffsetY = offsetY; - - // Position the scrolled view - nsView *scrolledView = GetScrolledView(); - if(scrolledView) { - scrolledView->SetPosition(-mOffsetX, -mOffsetY); - Scroll(scrolledView, dx, dy, t2p, 0); - NotifyScrollPositionDidChange(offsetX, offsetY); - } -} - -NS_IMETHODIMP nsScrollingView::Notify(nsITimer * aTimer) -{ - nscoord xoff, yoff; - - // First do the scrolling of the view - xoff = mOffsetX; - yoff = mOffsetY; - - nscoord newPos = yoff + mScrollingDelta; - - if (newPos < 0) - newPos = 0; - - ScrollTo(0, newPos, 0); - - // Now fake a mouse event so the frames can process the selection event - - nsRect rect; - nsGUIEvent event; - nsEventStatus retval; - - event.message = NS_MOUSE_MOVE; - - GetBounds(rect); - - event.point.x = rect.x; - event.point.y = (mScrollingDelta > 0) ? (rect.height - rect.y - 1) : 135; - - //printf("timer %d %d\n", event.point.x, event.point.y); - - nsIViewObserver *obs; - - if (NS_SUCCEEDED (mViewManager->GetViewObserver(obs))) - { - PRBool handled; - obs->HandleEvent((nsIView *)this, &event, &retval, PR_TRUE, handled); - NS_RELEASE(obs); - } - - nsresult rv; - mScrollingTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); - if (NS_SUCCEEDED(rv)) - mScrollingTimer->InitWithCallback(this, 25, nsITimer::TYPE_ONE_SHOT); - - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative) -{ - nsIDeviceContext *dx; - mViewManager->GetDeviceContext(dx); - nsresult rv = NS_ERROR_FAILURE; - - // XXX Have the all widgets siblings. For the time being this is needed - // for 'fixed' elements... - nsWidgetInitData initData; - initData.clipChildren = PR_TRUE; - initData.clipSiblings = PR_TRUE; - - // Create a clip view - mClipView = new ClipView; - - if (nsnull != mClipView) - { - // The clip view needs a widget to clip any of the scrolled view's - // child views with widgets. Note that the clip view has an opacity - // of 0.0f (completely transparent) - // XXX The clip widget should be created on demand only... - rv = mClipView->Init(mViewManager, mDimBounds, this); - rv = mViewManager->InsertChild(this, mClipView, mZIndex); - rv = mViewManager->SetViewOpacity(mClipView, 0.0f); - rv = mClipView->CreateWidget(kWidgetCID, &initData, - mWindow ? nsnull : aNative); - } - - // Create a view for a corner cover - mCornerView = new CornerView; - - if (nsnull != mCornerView) - { - nsRect trect; - float sbWidth, sbHeight; - - dx->GetScrollBarDimensions(sbWidth, sbHeight); - trect.width = NSToCoordRound(sbWidth); - trect.x = mDimBounds.width - trect.width; - trect.height = NSToCoordRound(sbHeight); - trect.y = mDimBounds.height - trect.height; - - rv = mCornerView->Init(mViewManager, trect, this, nsViewVisibility_kHide); - mViewManager->InsertChild(this, mCornerView, mZIndex); - mCornerView->CreateWidget(kWidgetCID, &initData, - mWindow ? nsnull : aNative); - } - - // Create a view for a vertical scrollbar - mVScrollBarView = new ScrollBarView(this); - - if (nsnull != mVScrollBarView) - { - nsRect trect; - float sbWidth, sbHeight; - - dx->GetScrollBarDimensions(sbWidth, sbHeight); - trect.width = NSToCoordRound(sbWidth); - trect.x = mDimBounds.width - trect.width; - trect.height -= NSToCoordRound(sbHeight); - trect.y = 0; - - static NS_DEFINE_IID(kCScrollbarIID, NS_VERTSCROLLBAR_CID); - - rv = mVScrollBarView->Init(mViewManager, trect, this); - rv = mViewManager->InsertChild(this, mVScrollBarView, mZIndex); - rv = mVScrollBarView->CreateWidget(kCScrollbarIID, &initData, - mWindow ? nsnull : aNative, - PR_FALSE); - - nsIView *scrolledView; - GetScrolledView(scrolledView); - -#ifdef LOSER // MOUSE WHEEL TRACKER CODE - - // XXX This code is to be reviewed by michealp - // It gets the Window for the view and the gets the widget - // for the vertical ScrollbarView and sets it into the window - // this is need for platforms where the window receives - // scrollbar message that need to be sent to the vertical scrollbar - // For example, the Mouse Wheel Tracker on MS-Windows - - // Find Parent view with window and remember the window - nsIWidget * win = nsnull; - nsView * view = this; - view->GetWidget(win); - while (win == nsnull) { - nsView * parent = view->GetParent(); - if (nsnull == parent) { - break; - } - parent->GetWidget(win); - view = parent; - } - - // Set scrollbar widget into window - if (nsnull != win) { - nsIWidget * scrollbar; - mVScrollBarView->GetWidget(scrollbar); - if (nsnull != scrollbar) { - win->SetVerticalScrollbar(scrollbar); - NS_RELEASE(scrollbar); - } - NS_RELEASE(win); - } - // XXX done with the code that needs to be reviewed -#endif - } - - // Create a view for a horizontal scrollbar - mHScrollBarView = new ScrollBarView(this); - - if (nsnull != mHScrollBarView) - { - nsRect trect; - float sbWidth, sbHeight; - - dx->GetScrollBarDimensions(sbWidth, sbHeight); - trect.height = NSToCoordRound(sbHeight); - trect.y = mDimBounds.height - trect.height; - trect.width -= NSToCoordRound(sbWidth); - trect.x = 0; - - static NS_DEFINE_IID(kCHScrollbarIID, NS_HORZSCROLLBAR_CID); - - rv = mHScrollBarView->Init(mViewManager, trect, this); - rv = mViewManager->InsertChild(this, mHScrollBarView, mZIndex); - rv = mHScrollBarView->CreateWidget(kCHScrollbarIID, &initData, - mWindow ? nsnull : aNative, - PR_FALSE); - } - - NS_RELEASE(dx); - - return rv; -} - -NS_IMETHODIMP nsScrollingView::SetWidget(nsIWidget *aWidget) -{ - if (nsnull != aWidget) { - NS_ASSERTION(PR_FALSE, "please don't try and set a widget here"); - return NS_ERROR_FAILURE; - } - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost) -{ - nsView::SetZIndex(aAuto, aZIndex, aTopMost); - - // inform all views that the z-index has changed. - // XXX why are we doing this? they're all a child of this view, so they - // shouldn't need to be re-z-indexed. - if (mClipView) mViewManager->SetViewZIndex(mClipView, aAuto, aZIndex, aTopMost); - if (mCornerView) mViewManager->SetViewZIndex(mCornerView, aAuto, aZIndex, aTopMost); - if (mVScrollBarView) mViewManager->SetViewZIndex(mVScrollBarView, aAuto, aZIndex, aTopMost); - if (mHScrollBarView) mViewManager->SetViewZIndex(mHScrollBarView, aAuto, aZIndex, aTopMost); - - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets) -{ - nsView *scrolledView = GetScrolledView(); - nsIScrollbar *scrollv = nsnull, *scrollh = nsnull; - PRBool hasVertical = PR_TRUE, hasHorizontal = PR_FALSE; - nsIWidget *win; - - if (nsnull != scrolledView) - { - nscoord dx = 0, dy = 0; - nsIDeviceContext *px; - nsSize hSize; - nsSize vSize; - PRUint32 oldsizey = mSizeY, oldsizex = mSizeX; - nscoord offx, offy; - float scale; - nsRect controlRect(0, 0, mDimBounds.width, mDimBounds.height); - - controlRect.Deflate(mInsets); - - mViewManager->GetDeviceContext(px); - px->GetAppUnitsToDevUnits(scale); - - nsSize sz; - scrolledView->GetDimensions(sz); - mSizeX = sz.width; - mSizeY = sz.height; - - if (nsnull != mHScrollBarView) { - mHScrollBarView->GetDimensions(hSize); - mHScrollBarView->GetWidget(win); - - if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) { - if (((mSizeX > controlRect.width) && - (mScrollPref != nsScrollPreference_kNeverScroll)) || - (mScrollPref == nsScrollPreference_kAlwaysScroll) || - (mScrollPref == nsScrollPreference_kAlwaysScrollHorizontal)) - { - hasHorizontal = PR_TRUE; - } - NS_RELEASE(scrollh); - } - - NS_RELEASE(win); - } - - if (nsnull != mVScrollBarView) { - mVScrollBarView->GetDimensions(vSize); - offy = mOffsetY; - - mVScrollBarView->GetWidget(win); - - if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv))) { - if ((mSizeY > (controlRect.height - (hasHorizontal ? hSize.height : 0)))) { - // if we are scrollable - if (mScrollPref != nsScrollPreference_kNeverScroll) { - //we need to be able to scroll - - ((ScrollBarView *)mVScrollBarView)->SetEnabled(PR_TRUE); - win->Enable(PR_TRUE); - - //now update the scroller position for the new size - - PRUint32 oldpos = 0; - float p2t; - PRInt32 availheight; - - scrollv->GetPosition(oldpos); - px->GetDevUnitsToAppUnits(p2t); - - availheight = controlRect.height - (hasHorizontal ? hSize.height : 0); - - // XXX Check for 0 initial size. This is really indicative - // of a problem. - if (0 == oldsizey) - mOffsetY = 0; - else - { - mOffsetY = NSIntPixelsToTwips(NSTwipsToIntPixels(nscoord(oldpos), scale), p2t); - - if ((mSizeY - mOffsetY) < availheight) - { - mOffsetY = mSizeY - availheight; - - if (mOffsetY < 0) - mOffsetY = 0; - } - } - - dy = NSTwipsToIntPixels((offy - mOffsetY), scale); - - scrollv->SetParameters(mSizeY, availheight, - mOffsetY, mLineHeight); - } - } else { - // The scrolled view is entirely visible vertically. Either hide the - // vertical scrollbar or disable it - mOffsetY = 0; - dy = NSTwipsToIntPixels(offy, scale); - - scrollv->SetPosition(0); // make sure thumb is at the top - scrollv->SetParameters(0, 0, 0, 0); // make thumb full-size - - if (mScrollPref == nsScrollPreference_kAlwaysScroll || mScrollPref == nsScrollPreference_kAlwaysScrollVertical) - { - ((ScrollBarView *)mVScrollBarView)->SetEnabled(PR_TRUE); - win->Enable(PR_FALSE); - } - else - { - ((ScrollBarView *)mVScrollBarView)->SetEnabled(PR_FALSE); - win->Enable(PR_TRUE); - hasVertical = PR_FALSE; - } - } - - NS_RELEASE(scrollv); - } - - NS_RELEASE(win); - } - - if (nsnull != mHScrollBarView) { - offx = mOffsetX; - mHScrollBarView->GetWidget(win); - - if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) { - if ((mSizeX > (controlRect.width - (hasVertical ? vSize.width : 0)))) { - if (mScrollPref != nsScrollPreference_kNeverScroll) { - //we need to be able to scroll - - ((ScrollBarView *)mHScrollBarView)->SetEnabled(PR_TRUE); - win->Enable(PR_TRUE); - - //now update the scroller position for the new size - - PRUint32 oldpos = 0; - float p2t; - PRInt32 availwidth; - - scrollh->GetPosition(oldpos); - px->GetDevUnitsToAppUnits(p2t); - - availwidth = controlRect.width - (hasVertical ? vSize.width : 0); - - // XXX Check for 0 initial size. This is really indicative - // of a problem. - if (0 == oldsizex) - mOffsetX = 0; - else - { - mOffsetX = NSIntPixelsToTwips(NSTwipsToIntPixels(nscoord(oldpos), scale), p2t); - - if ((mSizeX - mOffsetX) < availwidth) - { - mOffsetX = mSizeX - availwidth; - - if (mOffsetX < 0) - mOffsetX = 0; - } - } - - dx = NSTwipsToIntPixels((offx - mOffsetX), scale); - - scrollh->SetParameters(mSizeX, availwidth, - mOffsetX, mLineHeight); - } - } else { - // The scrolled view is entirely visible horizontally. Either hide the - // horizontal scrollbar or disable it - mOffsetX = 0; - dx = NSTwipsToIntPixels(offx, scale); - - scrollh->SetPosition(0); // make sure thumb is all the way to the left - - if (mScrollPref == nsScrollPreference_kAlwaysScroll || mScrollPref == nsScrollPreference_kAlwaysScrollHorizontal) - { - ((ScrollBarView *)mHScrollBarView)->SetEnabled(PR_TRUE); - win->Enable(PR_FALSE); - } - else - { - ((ScrollBarView *)mHScrollBarView)->SetEnabled(PR_FALSE); - win->Enable(PR_TRUE); - } - } - - NS_RELEASE(scrollh); - } - - NS_RELEASE(win); - } - - // Adjust the size of the clip view to account for scrollbars that are - // showing - if (mHScrollBarView && ViewIsShowing((ScrollBarView *)mHScrollBarView)) { - controlRect.height -= hSize.height; - controlRect.height = PR_MAX(controlRect.height, 0); - } - - if (mVScrollBarView && ViewIsShowing((ScrollBarView *)mVScrollBarView)) { - controlRect.width -= vSize.width; - controlRect.width = PR_MAX(controlRect.width, 0); - } - - nsRect r(0, 0, controlRect.width, controlRect.height); - mClipView->SetDimensions(r, PR_FALSE); - - // Position the scrolled view - scrolledView->SetPosition(-mOffsetX, -mOffsetY); - - if (mCornerView) - { - if (mHScrollBarView && ViewIsShowing((ScrollBarView *)mHScrollBarView) && - mVScrollBarView && ViewIsShowing((ScrollBarView *)mVScrollBarView)) - ((CornerView *)mCornerView)->Show(PR_TRUE, PR_FALSE); - else - ((CornerView *)mCornerView)->Show(PR_FALSE, PR_FALSE); - } - - if ((dx != 0) || (dy != 0) && aAdjustWidgets) - AdjustChildWidgets(this, scrolledView, 0, 0, scale); - - NS_RELEASE(px); - } - else - { - // There's no scrolled view so hide the scrollbars and corner view - if (nsnull != mHScrollBarView) - { - ((ScrollBarView *)mHScrollBarView)->SetEnabled(PR_FALSE); - - mHScrollBarView->GetWidget(win); - if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) { - scrollh->SetParameters(0, 0, 0, 0); - NS_RELEASE(scrollh); - } - NS_RELEASE(win); - } - - if (nsnull != mVScrollBarView) - { - ((ScrollBarView *)mVScrollBarView)->SetEnabled(PR_FALSE); - - mVScrollBarView->GetWidget(win); - if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv))) - { - scrollv->SetParameters(0, 0, 0, 0); - NS_RELEASE(scrollv); - } - NS_RELEASE(win); - } - - if (nsnull != mCornerView) - ((CornerView *)mCornerView)->Show(PR_FALSE, PR_FALSE); - - mOffsetX = mOffsetY = 0; - mSizeX = mSizeY = 0; - } - - UpdateScrollControls(PR_TRUE); - - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetContainerSize(nscoord *aWidth, nscoord *aHeight) const -{ - *aWidth = mSizeX; - *aHeight = mSizeY; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::ShowQuality(PRBool aShow) -{ - ((CornerView *)mCornerView)->ShowQuality(aShow); - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetShowQuality(PRBool &aShow) const -{ - aShow = ((CornerView *)mCornerView)->mShowQuality; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::SetQuality(nsContentQuality aQuality) -{ - ((CornerView *)mCornerView)->SetQuality(aQuality); - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::SetScrollPreference(nsScrollPreference aPref) -{ - mScrollPref = aPref; - ComputeScrollOffsets(PR_TRUE); - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetScrollPreference(nsScrollPreference &aScrollPreference) const -{ - aScrollPreference = mScrollPref; - return NS_OK; -} - -// XXX doesn't smooth scroll - -NS_IMETHODIMP nsScrollingView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags) -{ - nsIDeviceContext *dev; - float t2p; - float p2t; - nsSize clipSize; - nsIWidget *widget; - PRInt32 dx = 0, dy = 0; - - mViewManager->GetDeviceContext(dev); - dev->GetAppUnitsToDevUnits(t2p); - dev->GetDevUnitsToAppUnits(p2t); - - NS_RELEASE(dev); - - mClipView->GetDimensions(clipSize); - - // Clamp aX - - if ((aX + clipSize.width) > mSizeX) - aX = mSizeX - clipSize.width; - - if (aX < 0) - aX = 0; - - // Clamp aY - - if ((aY + clipSize.height) > mSizeY) - aY = mSizeY - clipSize.height; - - if (aY < 0) - aY = 0; - - aX = NSIntPixelsToTwips(NSTwipsToIntPixels(aX, t2p), p2t); - aY = NSIntPixelsToTwips(NSTwipsToIntPixels(aY, t2p), p2t); - - // do nothing if the we aren't scrolling. - if (aX == mOffsetX && aY == mOffsetY) - return NS_OK; - - mVScrollBarView->GetWidget(widget); - - if (nsnull != widget) { - nsIScrollbar* scrollv = nsnull; - if (NS_SUCCEEDED (widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv))) { - // Move the scrollbar's thumb - - PRUint32 oldpos = mOffsetY; - - scrollv->SetPosition(aY); - - dy = NSTwipsToIntPixels((oldpos - aY), t2p); - - NS_RELEASE(scrollv); - } - - NS_RELEASE(widget); - } - - mHScrollBarView->GetWidget(widget); - - if (nsnull != widget) { - nsIScrollbar* scrollh = nsnull; - if (NS_SUCCEEDED (widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) { - // Move the scrollbar's thumb - - PRUint32 oldpos = mOffsetX; - - scrollh->SetPosition(aX); - - dx = NSTwipsToIntPixels((oldpos - aX), t2p); - - NS_RELEASE(scrollh); - } - - NS_RELEASE(widget); - } - - // Update the scrolled view's position - - nsView* scrolledView = GetScrolledView(); - - NotifyScrollPositionWillChange(aX, aY); - - if (nsnull != scrolledView) - { - scrolledView->SetPosition(-aX, -aY); - - mOffsetX = aX; - mOffsetY = aY; - } - - Scroll(scrolledView, dx, dy, t2p, 0); - - NotifyScrollPositionDidChange(aX, aY); - - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::SetControlInsets(const nsMargin &aInsets) -{ - mInsets = aInsets; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetControlInsets(nsMargin &aInsets) const -{ - aInsets = mInsets; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetScrollbarVisibility(PRBool *aVerticalVisible, - PRBool *aHorizontalVisible) const -{ - *aVerticalVisible = mVScrollBarView && ViewIsShowing((ScrollBarView *)mVScrollBarView); - *aHorizontalVisible = mHScrollBarView && ViewIsShowing((ScrollBarView *)mHScrollBarView); - return NS_OK; -} - -void nsScrollingView::AdjustChildWidgets(nsScrollingView *aScrolling, nsView *aView, - nscoord aDx, nscoord aDy, float scale) -{ - nscoord offx, offy; - PRBool isscroll = PR_FALSE; - - if (aScrolling == aView) - { - nsIWidget *widget; - aScrolling->GetOffsetFromWidget(&aDx, &aDy, widget); - NS_IF_RELEASE(widget); - } - - aView->GetPosition(&offx, &offy); - - aDx += offx; - aDy += offy; - - nsView* kid; - for (kid = aView->GetFirstChild(); kid != nsnull; kid = kid->GetNextSibling()) - { - nsIWidget *win; - kid->GetWidget(win); - - if (nsnull != win) - { - nsRect bounds; - -#if 0 - win->BeginResizingChildren(); -#endif - kid->GetBounds(bounds); - - if (!isscroll || - (isscroll && - (kid != ((nsScrollingView *)aView)->mVScrollBarView) && - (kid != ((nsScrollingView *)aView)->mHScrollBarView))) - win->Move(NSTwipsToIntPixels((bounds.x + aDx), scale), NSTwipsToIntPixels((bounds.y + aDy), scale)); - else - win->Move(NSTwipsToIntPixels((bounds.x + aDx + offx), scale), NSTwipsToIntPixels((bounds.y + aDy + offy), scale)); - } - - // Don't recurse if the view has a widget, because we adjusted the view's - // widget position, and its child widgets are relative to its positon - if (nsnull == win) - AdjustChildWidgets(aScrolling, kid, aDx, aDy, scale); - - if (nsnull != win) - { -#if 0 - win->EndResizingChildren(); -#endif - NS_RELEASE(win); - } - } -} - -void nsScrollingView::UpdateScrollControls(PRBool aPaint) -{ - nsRect clipRect; - nsSize cornerSize = nsSize(0, 0); - nsSize visCornerSize = nsSize(0, 0); - nsPoint cornerPos = nsPoint(0, 0); - PRBool vertVis = PR_FALSE; - PRBool horzVis = PR_FALSE; - - if (nsnull != mClipView) - { - mClipView->GetBounds(clipRect); - - if (nsnull != mVScrollBarView) - vertVis = ((ScrollBarView *)mVScrollBarView)->GetEnabled(); - - if (nsnull != mHScrollBarView) - horzVis = ((ScrollBarView *)mHScrollBarView)->GetEnabled(); - - if (nsnull != mCornerView) - { - mCornerView->GetDimensions(cornerSize); - - // If both the vertical and horizontal scrollbars are enabled, so is the corner view. - if (vertVis && horzVis) - visCornerSize = cornerSize; - - if (PR_TRUE == vertVis) - visCornerSize.width = 0; - - if (PR_TRUE == horzVis) - visCornerSize.height = 0; - } - - // Size and position the vertical scrollbar - if (nsnull != mVScrollBarView) - { - nsSize vertSize; - - mVScrollBarView->GetDimensions(vertSize); - mVScrollBarView->SetPosition(clipRect.XMost(), clipRect.y); - nsRect r(0, 0, vertSize.width, clipRect.height - visCornerSize.height); - mVScrollBarView->SetDimensions(r, aPaint); - - if (vertVis == nsViewVisibility_kShow) - cornerPos.x = clipRect.XMost(); - else - cornerPos.x = clipRect.XMost() - cornerSize.width; - } - - // Size and position the horizontal scrollbar - if (nsnull != mHScrollBarView) - { - nsSize horzSize; - - mHScrollBarView->GetDimensions(horzSize); - mHScrollBarView->SetPosition(clipRect.x, clipRect.YMost()); - nsRect r(0, 0, clipRect.width - visCornerSize.width, horzSize.height); - mHScrollBarView->SetDimensions(r, aPaint); - - if (horzVis == nsViewVisibility_kShow) - cornerPos.y = clipRect.YMost(); - else - cornerPos.y = clipRect.YMost() - cornerSize.height; - } - - // Position the corner view - if (nsnull != mCornerView) - mCornerView->SetPosition(cornerPos.x, cornerPos.y); - } - - // Update the visibility of all of the ScrollingView's components - nsViewVisibility scrollingViewVisibility; - GetVisibility(scrollingViewVisibility); - UpdateComponentVisibility(scrollingViewVisibility); -} - -NS_IMETHODIMP nsScrollingView::SetScrolledView(nsIView *aScrolledView) -{ - return mViewManager->InsertChild(mClipView, aScrolledView, 0); -} - -nsView* nsScrollingView::GetScrolledView() const -{ - if (nsnull != mClipView) { - return mClipView->GetFirstChild(); - } else { - return nsnull; - } -} - -NS_IMETHODIMP nsScrollingView::GetScrolledView(nsIView *&aScrolledView) const -{ - aScrolledView = GetScrolledView(); - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetScrollPosition(nscoord &aX, nscoord &aY) const -{ - aX = mOffsetX; - aY = mOffsetY; - - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::SetScrollProperties(PRUint32 aProperties) -{ - mScrollProperties = aProperties; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetScrollProperties(PRUint32 *aProperties) -{ - *aProperties = mScrollProperties; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::SetLineHeight(nscoord aHeight) -{ - mLineHeight = aHeight; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::GetLineHeight(nscoord *aHeight) -{ - *aHeight = mLineHeight; - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLinesY) -{ - nsCOMPtr widget; - nscoord newPosX = 0, newPosY = 0; - - if (aNumLinesX != 0) { - if (NS_SUCCEEDED (mHScrollBarView->GetWidget(*getter_AddRefs(widget)))) { - nsCOMPtr scrollh( do_QueryInterface(widget) ); - if (scrollh) { - PRUint32 oldPos = 0; - PRUint32 lineInc; - - scrollh->GetPosition(oldPos); - scrollh->GetLineIncrement(lineInc); - - newPosX = oldPos + lineInc * aNumLinesX; - } - } - } - if (aNumLinesY != 0) { - if (NS_SUCCEEDED (mVScrollBarView->GetWidget(*getter_AddRefs(widget)))) { - nsCOMPtr scrollv( do_QueryInterface(widget) ); - if (scrollv) { - PRUint32 oldPos = 0; - PRUint32 lineInc; - - scrollv->GetPosition(oldPos); - scrollv->GetLineIncrement(lineInc); - - newPosY = oldPos + lineInc * aNumLinesY; - } - } - } - - nsSize clipSize; - mClipView->GetDimensions(clipSize); - - //sanity check values - if (newPosX > (mSizeX - clipSize.width)) - newPosX = mSizeX - clipSize.width; - else if (newPosX < 0) - newPosX = 0; - - if (newPosY > (mSizeY - clipSize.height)) - newPosY = mSizeY - clipSize.height; - else if (newPosY < 0) - newPosY = 0; - - ScrollTo(newPosX, newPosY, 0); - - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY) -{ - nsCOMPtr widget; - nscoord newPosX = 0, newPosY = 0; - - nsSize clipSize; - mClipView->GetDimensions(clipSize); - - if (aNumPagesX != 0) { - if (NS_SUCCEEDED (mHScrollBarView->GetWidget(*getter_AddRefs(widget)))) { - nsCOMPtr scrollh( do_QueryInterface(widget) ); - if (scrollh) { - PRUint32 oldPos = 0; - - scrollh->GetPosition(oldPos); - - newPosX = oldPos + clipSize.width * aNumPagesX; - } - } - } - if (aNumPagesY != 0) { - if (NS_SUCCEEDED (mVScrollBarView->GetWidget(*getter_AddRefs(widget)))) { - nsCOMPtr scrollv( do_QueryInterface(widget) ); - if (scrollv) { - PRUint32 oldPos = 0; - - scrollv->GetPosition(oldPos); - - newPosY = oldPos + clipSize.height * aNumPagesY; - } - } - } - - //sanity check values - if (newPosX > (mSizeX - clipSize.width)) - newPosX = mSizeX - clipSize.width; - else if (newPosX < 0) - newPosX = 0; - - if (newPosY > (mSizeY - clipSize.height)) - newPosY = mSizeY - clipSize.height; - else if (newPosY < 0) - newPosY = 0; - - ScrollTo(newPosX, newPosY, 0); - - return NS_OK; -} - -NS_IMETHODIMP nsScrollingView::ScrollByWhole(PRBool aTop) -{ - nscoord newPos = 0; - - if (aTop) { - newPos = 0; - } - else { - nsSize clipSize; - mClipView->GetDimensions(clipSize); - newPos = mSizeY - clipSize.height; - } - - ScrollTo(0, newPos, 0); - - return NS_OK; -} - -PRBool nsScrollingView::CannotBitBlt(nsView* aScrolledView) -{ - PRUint32 scrolledViewFlags = aScrolledView->GetViewFlags(); - - return (mScrollProperties & NS_SCROLL_PROPERTY_NEVER_BLIT) || - (scrolledViewFlags & NS_VIEW_FLAG_DONT_BITBLT) || - (!(mScrollProperties & NS_SCROLL_PROPERTY_ALWAYS_BLIT) - && !mViewManager->CanScrollWithBitBlt(aScrolledView)); -} - -void nsScrollingView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, - float scale, PRUint32 aUpdateFlags) -{ - if ((aDx != 0) || (aDy != 0)) - { - // Since we keep track of the dirty region as absolute screen coordintes, - // we need to offset it by the amount we scrolled. - nsCOMPtr dirtyRegion; - GetDirtyRegion(*getter_AddRefs(dirtyRegion)); - dirtyRegion->Offset(aDx, aDy); - - nsIWidget *clipWidget; - - mClipView->GetWidget(clipWidget); - - if ((nsnull == clipWidget) || CannotBitBlt(aScrolledView)) - { - // XXX Repainting is really slow. The widget's Scroll() member function - // needs an argument that specifies whether child widgets are scrolled, - // and we need to be able to specify the rect to be scrolled... - mViewManager->UpdateView(mClipView, 0); - AdjustChildWidgets(this, aScrolledView, 0, 0, scale); - } - else - { - // Scroll the contents of the widget by the specfied amount, and scroll - // the child widgets - clipWidget->Scroll(aDx, aDy, nsnull); - mViewManager->UpdateViewAfterScroll(this, aDx, aDy); - } - - NS_IF_RELEASE(clipWidget); - } -} - -nsresult nsScrollingView::NotifyScrollPositionWillChange(nscoord aX, nscoord aY) -{ - nsresult result; - - if (!mListeners) - return NS_OK; - - PRUint32 listenerCount; - - result = mListeners->Count(&listenerCount); - - if (NS_FAILED(result) || listenerCount < 1) - return result; - - const nsIID& kScrollPositionListenerIID = NS_GET_IID(nsIScrollPositionListener); - nsIScrollPositionListener* listener; - - for (PRUint32 i = 0; i < listenerCount; i++) { - result = mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener); - if (NS_FAILED(result)) - return result; - - if (!listener) - return NS_ERROR_NULL_POINTER; - - listener->ScrollPositionWillChange(this, aX, aY); - NS_RELEASE(listener); - } - - return result; -} - -nsresult nsScrollingView::NotifyScrollPositionDidChange(nscoord aX, nscoord aY) -{ - nsresult result; - - if (!mListeners) - return NS_OK; - - PRUint32 listenerCount; - - result = mListeners->Count(&listenerCount); - - if (NS_FAILED(result) || listenerCount < 1) - return result; - - const nsIID& kScrollPositionListenerIID = NS_GET_IID(nsIScrollPositionListener); - nsIScrollPositionListener* listener; - - for (PRUint32 i = 0; i < listenerCount; i++) { - result = mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener); - if (NS_FAILED(result)) - return result; - - if (!listener) - return NS_ERROR_NULL_POINTER; - - listener->ScrollPositionDidChange(this, aX, aY); - NS_RELEASE(listener); - } - - return result; -} - diff --git a/mozilla/view/src/nsScrollingView.h b/mozilla/view/src/nsScrollingView.h deleted file mode 100644 index 487f34b8b3c..00000000000 --- a/mozilla/view/src/nsScrollingView.h +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollingView_h___ -#define nsScrollingView_h___ - -#include "nsView.h" -#include "nsIScrollableView.h" -#include "nsCOMPtr.h" -#include "nsITimer.h" - -class nsISupportsArray; - -//this is a class that acts as a container for other views and provides -//automatic management of scrolling of the views it contains. - -class nsScrollingView : public nsView, public nsIScrollableView, public nsITimerCallback -{ -public: - nsScrollingView(); - - NS_IMETHOD QueryInterface(REFNSIID aIID, - void** aInstancePtr); - - //overrides - NS_IMETHOD Init(nsIViewManager* aManager, - const nsRect &aBounds, - const nsIView *aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); - virtual void SetDimensions(const nsRect& aRect, PRBool aPaint = PR_TRUE); - virtual void SetPosition(nscoord aX, nscoord aY); - // SetVisibility is overriden so that it will set it's components visibility (ClipView, - // CornerView, ScrollBarView's),as well as it's own visibility. - NS_IMETHOD SetVisibility(nsViewVisibility visibility); - NS_IMETHOD SetWidget(nsIWidget *aWidget); - - NS_IMETHOD SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost); - - //nsIScrollableView interface - NS_IMETHOD CreateScrollControls(nsNativeWidget aNative = nsnull); - NS_IMETHOD ComputeScrollOffsets(PRBool aAdjustWidgets = PR_TRUE); - NS_IMETHOD GetContainerSize(nscoord *aWidth, nscoord *aHeight) const; - NS_IMETHOD SetScrolledView(nsIView *aScrolledView); - NS_IMETHOD GetScrolledView(nsIView *&aScrolledView) const; - - NS_IMETHOD ShowQuality(PRBool aShow); - NS_IMETHOD GetShowQuality(PRBool &aShow) const; - NS_IMETHOD SetQuality(nsContentQuality aQuality); - - NS_IMETHOD SetScrollPreference(nsScrollPreference aPref); - NS_IMETHOD GetScrollPreference(nsScrollPreference &aScrollPreference) const; - NS_IMETHOD GetScrollPosition(nscoord &aX, nscoord &aY) const; - NS_IMETHOD ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags); - NS_IMETHOD SetControlInsets(const nsMargin &aInsets); - NS_IMETHOD GetControlInsets(nsMargin &aInsets) const; - NS_IMETHOD GetScrollbarVisibility(PRBool *aVerticalVisible, - PRBool *aHorizontalVisible) const; - NS_IMETHOD SetScrollProperties(PRUint32 aProperties); - NS_IMETHOD GetScrollProperties(PRUint32 *aProperties); - NS_IMETHOD SetLineHeight(nscoord aHeight); - NS_IMETHOD GetLineHeight(nscoord *aHeight); - NS_IMETHOD ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLinesY); - NS_IMETHOD ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY); - NS_IMETHOD ScrollByWhole(PRBool aTop); - - NS_IMETHOD GetClipView(const nsIView** aClipView) const; - nsView* GetClipView() const { return mClipView; } - - NS_IMETHOD AddScrollPositionListener(nsIScrollPositionListener* aListener); - NS_IMETHOD RemoveScrollPositionListener(nsIScrollPositionListener* aListener); - - // local to view module - void HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags); - - // Set the visibility of a nsScrollingView's component - // @param aView nsScrollingView component to set visibility for or nsnull. - // @param aViewVisibility new setting for the component view If not the same as the current setting - // @returns the result of calling the SetVisibility on the component. - nsresult SetComponentVisibility(nsView* aView, nsViewVisibility aViewVisibility); - - // Update the visibility of the nsScrollingView's components (ClipView, CornerView, ScrollBarView's) - // @param aScrollingViewVisibility Visibility setting of the ScrollingView to consider when - // setting the visibility of the components. - // @returns the result of calling SetComponentVisibility for each component. - nsresult UpdateComponentVisibility(nsViewVisibility aScrollingViewVisibility); - - nsresult NotifyScrollPositionWillChange(nscoord aX, nscoord aY); - nsresult NotifyScrollPositionDidChange(nscoord aX, nscoord aY); - - nsView* GetScrolledView() const; - -private: - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - -protected: - virtual ~nsScrollingView(); - - // nsITimerCallback Interface - NS_DECL_NSITIMERCALLBACK - - //private - void AdjustChildWidgets(nsScrollingView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float aScale); - void UpdateScrollControls(PRBool aPaint); - void Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags); - PRBool CannotBitBlt(nsView* aScrolledView); - -protected: - nscoord mSizeX, mSizeY; - nscoord mOffsetX, mOffsetY; - nsView *mClipView; - nsView *mVScrollBarView; - nsView *mHScrollBarView; - nsView *mCornerView; - nsScrollPreference mScrollPref; - nsMargin mInsets; - nsCOMPtr mScrollingTimer; - nscoord mScrollingDelta; - PRUint32 mScrollProperties; - nscoord mLineHeight; - nsISupportsArray *mListeners; -}; - -#endif diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index 2abddc5ffce..e99941b4aa0 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -42,7 +42,6 @@ #include "nsIPresContext.h" #include "nsIWidget.h" #include "nsIButton.h" -#include "nsIScrollbar.h" #include "nsGUIEvent.h" #include "nsIDeviceContext.h" #include "nsIComponentManager.h" diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index a357cf988a5..ddf90e3850a 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -46,7 +46,6 @@ #include "nsGfxCIID.h" #include "nsIScrollableView.h" #include "nsView.h" -#include "nsIScrollbar.h" #include "nsISupportsArray.h" #include "nsICompositeListener.h" #include "nsCOMPtr.h" @@ -1953,7 +1952,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS nsView* baseView; nsView* view; nsPoint offset; - nsIScrollbar* sb; PRBool capturedEvent = PR_FALSE; if (NS_IS_MOUSE_EVENT(aEvent) || NS_IS_KEY_EVENT(aEvent) || @@ -1974,11 +1972,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS view = mKeyGrabber; capturedEvent = PR_TRUE; } - else if (NS_OK == aEvent->widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void**)&sb)) { - view = baseView; - capturedEvent = PR_TRUE; - NS_RELEASE(sb); - } else { view = baseView; } diff --git a/mozilla/webshell/tests/viewer/nsWidgetSupport.cpp b/mozilla/webshell/tests/viewer/nsWidgetSupport.cpp index 8311c50b144..e5a84d605e0 100644 --- a/mozilla/webshell/tests/viewer/nsWidgetSupport.cpp +++ b/mozilla/webshell/tests/viewer/nsWidgetSupport.cpp @@ -43,7 +43,6 @@ #include "nsIWidget.h" #include "nsICheckButton.h" #include "nsITextWidget.h" -#include "nsIScrollbar.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -52,7 +51,6 @@ static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID); static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); -static NS_DEFINE_IID(kIScrollBarIID, NS_ISCROLLBAR_IID); #ifdef XP_MAC #define WIDGET_SUPPORT_EXPORT(returnType) PR_PUBLIC_API(returnType) @@ -168,33 +166,6 @@ NS_CreateTextWidget(nsISupports* aParent, -WIDGET_SUPPORT_EXPORT(nsresult) -NS_CreateScrollBar(nsISupports* aParent, - nsIScrollbar* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) - aParent->QueryInterface(kIWidgetIID,(void**)&parent); - - nsIWidget* widget = nsnull; - if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Create(parent, aRect, aHandleEventFunction, NULL); - widget->Show(PR_TRUE); - NS_IF_RELEASE(widget); - } - else - { - NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object"); - } - - if (aParent) - NS_IF_RELEASE(parent); - - return NS_OK; -} - WIDGET_SUPPORT_EXPORT(nsresult) NS_ShowWidget(nsISupports* aWidget, PRBool aShow) { diff --git a/mozilla/webshell/tests/viewer/nsWidgetSupport.h b/mozilla/webshell/tests/viewer/nsWidgetSupport.h index a44e02564e9..b14f73e3849 100644 --- a/mozilla/webshell/tests/viewer/nsWidgetSupport.h +++ b/mozilla/webshell/tests/viewer/nsWidgetSupport.h @@ -53,7 +53,6 @@ class nsIMouseListener; class nsIToolkit; class nsIWidget; class nsICheckButton; -class nsIScrollbar; class nsITooltipWidget; class nsITextWidget; @@ -97,13 +96,6 @@ NS_CreateTooltipWidget(nsISupports* aParent, const nsFont* aFont = nsnull); -extern nsresult -NS_CreateScrollBar(nsISupports* aParent, - nsIScrollbar* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction); - - extern nsresult NS_ShowWidget(nsISupports* aWidget, PRBool aShow); diff --git a/mozilla/widget/public/MANIFEST b/mozilla/widget/public/MANIFEST index 71734e2e9db..4c4d0f858b3 100644 --- a/mozilla/widget/public/MANIFEST +++ b/mozilla/widget/public/MANIFEST @@ -8,7 +8,6 @@ nsIKBStateControl.h nsIButton.h nsICheckButton.h nsITextWidget.h -nsIScrollbar.h nsGUIEvent.h nsEvent.h nsIMouseListener.h @@ -17,7 +16,6 @@ nsIMenuListener.h nsWidgetsCID.h nsILabel.h nsILookAndFeel.h -nsWidgetSupport.h nsIMenu.h nsIMenuBar.h nsIMenuItem.h diff --git a/mozilla/widget/public/Makefile.in b/mozilla/widget/public/Makefile.in index 6f921ddd79b..2e5ce1dfa52 100644 --- a/mozilla/widget/public/Makefile.in +++ b/mozilla/widget/public/Makefile.in @@ -41,7 +41,6 @@ EXPORTS = \ nsIButton.h \ nsICheckButton.h \ nsITextWidget.h \ - nsIScrollbar.h \ nsGUIEvent.h \ nsEvent.h \ nsIMouseListener.h \ diff --git a/mozilla/widget/public/nsIScrollbar.h b/mozilla/widget/public/nsIScrollbar.h deleted file mode 100644 index 89fa1adf4a8..00000000000 --- a/mozilla/widget/public/nsIScrollbar.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIScrollbar_h__ -#define nsIScrollbar_h__ - -#include "nsIWidget.h" - -// {18032AD2-B265-11d1-AA2A-000000000000} -#define NS_ISCROLLBAR_IID \ -{ 0x18032ad2, 0xb265, 0x11d1, \ -{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } - - -/** - * - * Scrollbar, converts mouse input into values that can be used - * to shift the contents of a window. - * - */ - - -class nsIScrollbar : public nsISupports -{ -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCROLLBAR_IID) - - /** - * Set the scrollbar range - * @param aEndRange set range for scrollbar from 0 to aEndRange - * @result NS_Ok if no errors - * - */ - NS_IMETHOD SetMaxRange(PRUint32 aEndRange) = 0; - - /** - * Get the scrollbar range - * @return the upper end of the scrollbar range - * @result NS_Ok if no errors - */ - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange) = 0; - - /** - * Set the thumb position. - * @param aPos a value between (startRange) and (endRange - thumbSize) - * @result NS_Ok if no errors - * - */ - NS_IMETHOD SetPosition(PRUint32 aPos) = 0; - - /** - * Get the thumb position. - * @return a value between (startRange) and (endRange - thumbSize) - * @result NS_Ok if no errors - * - */ - NS_IMETHOD GetPosition(PRUint32& aPos) = 0; - - /** - * Set the thumb size. - * @param aSize size of the thumb. Must be a value between - * startRange and endRange - * @result NS_Ok if no errors - */ - NS_IMETHOD SetThumbSize(PRUint32 aSize) = 0; - - /** - * Get the thumb size. - * @return size of the thumb. The value is between - * startRange and endRange - * @result NS_Ok if no errors - */ - NS_IMETHOD GetThumbSize(PRUint32& aSize) = 0; - - /** - * Set the line increment. - * @param aSize size of the line increment. The value must - * be between startRange and endRange - * @result NS_Ok if no errors - */ - NS_IMETHOD SetLineIncrement(PRUint32 aSize) = 0; - - /** - * Get the line increment. - * @return size of the line increment. The value is - * between startRange and endRange - * @result NS_Ok if no errors - */ - NS_IMETHOD GetLineIncrement(PRUint32& aSize) = 0; - - /** - * Set all scrollbar parameters at once - * @param aMaxRange set range for scrollbar from 0 to aMaxRange - * @param aThumbSize size of the thumb. Must be a value between - * startRange and endRange - * @param aPosition a value between (startRange) and (endRange - thumbSize) - * @param aLineIncrement size of the line increment. The value must - * be between startRange and endRange - * @result NS_Ok if no errors - */ - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) = 0; -}; - -#endif // nsIScrollbar_h__ diff --git a/mozilla/widget/public/nsWidgetSupport.h b/mozilla/widget/public/nsWidgetSupport.h deleted file mode 100644 index 099bf3d392a..00000000000 --- a/mozilla/widget/public/nsWidgetSupport.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsWidgetSupport_h__ -#define nsWidgetSupport_h__ - -#include "nscore.h" -#include "nsComObsolete.h" -#include "nsISupports.h" -#include "nsIWidget.h" - - -struct nsRect; -class nsIAppShell; -class nsIButton; -class nsIEventListener; -class nsILabel; -class nsILookAndFeel; -class nsIMouseListener; -class nsIToolkit; -class nsIWidget; -class nsICheckButton; -class nsIScrollbar; -class nsITextWidget; - -// These are a series of support methods which help in the creation -// of widgets. They are not needed, but are provided as a convenience -// mechanism when creating widgets - - -extern NS_WIDGET nsresult -NS_CreateButton( nsISupports* aParent, - nsIButton* aButton, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont* aFont = nsnull); - -extern NS_WIDGET nsresult -NS_CreateCheckButton( nsISupports* aParent, - nsICheckButton* aCheckButton, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont* aFont = nsnull); - -extern NS_WIDGET nsresult -NS_CreateLabel( nsISupports* aParent, - nsILabel* aLabel, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont* aFont = nsnull); - -extern NS_WIDGET nsresult -NS_CreateTextWidget(nsISupports* aParent, - nsITextWidget* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont* aFont = nsnull); - - - -extern NS_WIDGET nsresult -NS_CreateScrollBar(nsISupports* aParent, - nsIScrollbar* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction); - - -extern NS_WIDGET nsresult -NS_ShowWidget(nsISupports* aWidget, PRBool aShow); - -extern NS_WIDGET nsresult -NS_MoveWidget(nsISupports* aWidget, PRUint32 aX, PRUint32 aY); - -extern NS_WIDGET nsresult -NS_EnableWidget(nsISupports* aWidget, PRBool aEnable); - -extern NS_WIDGET nsresult -NS_SetFocusToWidget(nsISupports* aWidget); - -extern NS_WIDGET nsresult -NS_GetWidgetNativeData(nsISupports* aWidget, void** aNativeData); - - - - - -#endif diff --git a/mozilla/widget/src/beos/Makefile.in b/mozilla/widget/src/beos/Makefile.in index 6f447d44f42..70fee2eb7e1 100644 --- a/mozilla/widget/src/beos/Makefile.in +++ b/mozilla/widget/src/beos/Makefile.in @@ -57,7 +57,6 @@ CPPSRCS = \ nsFilePicker.cpp \ nsLookAndFeel.cpp \ nsObject.cpp \ - nsScrollbar.cpp \ nsSound.cpp \ nsToolkit.cpp \ nsWidgetFactory.cpp \ diff --git a/mozilla/widget/src/beos/nsScrollbar.cpp b/mozilla/widget/src/beos/nsScrollbar.cpp deleted file mode 100644 index 8e73f654920..00000000000 --- a/mozilla/widget/src/beos/nsScrollbar.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsISupportsUtils.h" -#include "nsWidgetsCID.h" -#include "nsScrollbar.h" -#include "nsToolkit.h" -#include "nsGUIEvent.h" -#include "nsUnitConversion.h" - - -//------------------------------------------------------------------------- -// -// nsISupports -// -//------------------------------------------------------------------------- -NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWindow) -NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWindow) -NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsWindow) - -//------------------------------------------------------------------------- -// -// nsScrollbar constructor -// -//------------------------------------------------------------------------- -nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWindow(), nsIScrollbar() -{ - mOrientation = (aIsVertical) ? B_VERTICAL : B_HORIZONTAL; - mLineIncrement = 0; - mScrollbar = 0; - thumb = 0; -} - - -//------------------------------------------------------------------------- -// -// nsScrollbar destructor -// -//------------------------------------------------------------------------- -nsScrollbar::~nsScrollbar() -{ -} - - -//------------------------------------------------------------------------- -// Handle Destroy() here so that we properly Release() the instance -// and mScrollbar is destroyed by nsWindow::Destroy even though -// mScrollbar is non-zero after the call -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::Destroy() { - nsWindow::Destroy(); - NS_RELEASE_THIS(); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Define the range settings -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - float min, max; - if(mScrollbar && mScrollbar->LockLooper()) - { - mScrollbar->GetRange(&min, &max); - mScrollbar->SetRange(min, float(aEndRange - thumb)); - mScrollbar->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Return the range settings -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetMaxRange(PRUint32& aRange) -{ - float startRange, endRange; - if(mScrollbar && mScrollbar->LockLooper()) - { - mScrollbar->GetRange(&startRange, &endRange); - aRange = endRange + thumb; - mScrollbar->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb position -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - if(mScrollbar && mScrollbar->LockLooper()) - { - mScrollbar->SetValue(aPos); - mScrollbar->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the current thumb position. -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetPosition(PRUint32& aPosition) -{ - if(mScrollbar && mScrollbar->LockLooper()) - { - aPosition = mScrollbar->Value(); - mScrollbar->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - float min, max, smallStep, bigStep; - if(mScrollbar && mScrollbar->LockLooper()) - { - mScrollbar->GetRange(&min, &max); - max = max + thumb - aSize; -// thumb = aSize; - mScrollbar->SetRange(min, max); - mScrollbar->SetProportion(max == min ? 1 : (aSize / (max > min ? max - min : min - max))); - mScrollbar->GetSteps(&smallStep, &bigStep); - mScrollbar->SetSteps(smallStep, aSize); - mScrollbar->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - aSize = thumb; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aSize) -{ - float smallStep, bigStep; - if(mScrollbar && mScrollbar->LockLooper()) - { - mScrollbar->GetSteps(&smallStep, &bigStep); - mScrollbar->SetSteps(aSize, bigStep); - mScrollbar->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aSize) -{ - float smallStep, bigStep; - aSize = 0; - if(mScrollbar && mScrollbar->LockLooper()) - { - mScrollbar->GetSteps(&smallStep, &bigStep); - aSize = uint32(smallStep); - mScrollbar->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set all scrolling parameters -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - mScrollbar->LockLooper(); - mScrollbar->SetResizingMode(B_FOLLOW_NONE); - mScrollbar->UnlockLooper(); - SetMaxRange(aMaxRange); - SetThumbSize(aThumbSize); - SetPosition(aPosition); - SetLineIncrement(aLineIncrement); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// paint message. Don't send the paint out -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnPaint(nsRect &r) -{ - return PR_FALSE; -} - - -PRBool nsScrollbar::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - - -//------------------------------------------------------------------------- -// -// Deal with scrollbar messages (actually implemented only in nsScrollbar) -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnScroll() -{ - PRBool result = PR_TRUE; - int32 newpos; - if(mEventCallback) - { - if(mScrollbar->LockLooper()) - { - if(mScrollbar->GetPosition(newpos)) - { - nsScrollbarEvent event; - InitEvent(event, NS_SCROLLBAR_POS); - event.widget = (nsWindow *)this; - event.position = newpos; - result = ConvertStatus((*mEventCallback)(&event)); - -// if(newpos != event.position) -// SetPosition(newpos = event.position); - } - mScrollbar->UnlockLooper(); - } - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// get position/dimensions -// -//------------------------------------------------------------------------- - -NS_METHOD nsScrollbar::GetBounds(nsRect &aRect) -{ - return nsWindow::GetBounds(aRect); -} - -BView *nsScrollbar::CreateBeOSView() -{ - BRect temp; - - // work around stupit BeOS bug - if(mOrientation == B_VERTICAL) - temp.Set(0, 0, B_V_SCROLL_BAR_WIDTH, B_H_SCROLL_BAR_HEIGHT * 2); - else - temp.Set(0, 0, B_V_SCROLL_BAR_WIDTH * 2, B_H_SCROLL_BAR_HEIGHT); - - mScrollbar = new nsScrollbarBeOS(this, temp, "", NULL, 0, 0, mOrientation); - - return mScrollbar; -} - -//------------------------------------------------------------------------- -// Sub-class of BeOS Scrollbar -//------------------------------------------------------------------------- -nsScrollbarBeOS::nsScrollbarBeOS( nsIWidget *aWidgetWindow, BRect aFrame, - const char *aName, BView *aTarget, float aMin, float aMax, - orientation aOrientation ) - : BScrollBar( aFrame, aName, aTarget, aMin, aMax, aOrientation ), - nsIWidgetStore( aWidgetWindow ), first(true), sbposchanged(false) -{ -} - -void nsScrollbarBeOS::ValueChanged(float newValue) -{ - if(first) - { - first = false; - return; - } - - sbpos = newValue; - sbposchanged = true; - - nsWindow *w = (nsWindow *)GetMozillaWidget(); - nsToolkit *t; - if(w && (t = w->GetToolkit()) != 0) - { - MethodInfo *info = new MethodInfo(w, w, nsWindow::ONSCROLL); - t->CallMethodAsync(info); - NS_RELEASE(t); - } -} - -bool nsScrollbarBeOS::GetPosition(int32 &p) -{ - if(! sbposchanged) - return false; - p = (int32)sbpos; - sbposchanged = false; - return true; -} diff --git a/mozilla/widget/src/beos/nsScrollbar.h b/mozilla/widget/src/beos/nsScrollbar.h deleted file mode 100644 index 2380fcb44f2..00000000000 --- a/mozilla/widget/src/beos/nsScrollbar.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsISupportsUtils.h" -#include "nsdefs.h" -#include "nsWindow.h" -#include "nsSwitchToUIThread.h" - -#include "nsIScrollbar.h" - -#include - -class nsScrollbarBeOS; - -/** - * Native BeOS scrollbar wrapper. - */ - -class nsScrollbar : public nsWindow, - public nsIScrollbar -{ - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - NS_IMETHOD Destroy(void); - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - virtual PRBool OnPaint(nsRect &r); - virtual PRBool OnScroll(); - virtual PRBool OnResize(nsRect &aWindowRect); - NS_IMETHOD GetBounds(nsRect &aRect); - -protected: - nsScrollbarBeOS *mScrollbar; - BView *CreateBeOSView(); - int mLineIncrement; - float mScaleFactor; - int32 thumb; - orientation mOrientation; -}; - -class nsScrollbarBeOS : public BScrollBar, public nsIWidgetStore -{ - bool first; - float sbpos; - bool sbposchanged; - - public: - nsScrollbarBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName, - BView *aTarget, float aMin, float aMax, orientation aOrientation ); - void ValueChanged(float newValue); - bool GetPosition(int32 &p); -}; - -#endif // nsButton_h__ diff --git a/mozilla/widget/src/beos/nsWidgetFactory.cpp b/mozilla/widget/src/beos/nsWidgetFactory.cpp index a5f424a4473..165cd4b0a47 100644 --- a/mozilla/widget/src/beos/nsWidgetFactory.cpp +++ b/mozilla/widget/src/beos/nsWidgetFactory.cpp @@ -49,7 +49,6 @@ #include "nsToolkit.h" #include "nsLookAndFeel.h" #include "nsFilePicker.h" -#include "nsScrollbar.h" #include "nsBidiKeyboard.h" // Drag & Drop, Clipboard @@ -74,58 +73,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -static nsresult nsHorizScrollbarConstructor(nsISupports *aOuter,REFNSIID aIID, - void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if (NULL == aResult) { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_FALSE); - if (inst == NULL) { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID,aResult); - NS_RELEASE(inst); - - return rv; -} - -static nsresult nsVertScrollbarConstructor(nsISupports *aOuter,REFNSIID aIID, - void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if (NULL == aResult) { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_TRUE); - if (inst == NULL) { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - static const nsModuleComponentInfo components[] = { { "BeOS nsWindow", @@ -136,14 +83,6 @@ static const nsModuleComponentInfo components[] = NS_CHILD_CID, "@mozilla.org/widgets/child_window/beos;1", ChildWindowConstructor }, - { "BeOS Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/horizscroll/beos;1", - nsHorizScrollbarConstructor }, - { "BeOS Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/beos;1", - nsVertScrollbarConstructor }, { "BeOS AppShell", NS_APPSHELL_CID, "@mozilla.org/widget/appshell/beos;1", diff --git a/mozilla/widget/src/build/nsWidgetSupport.cpp b/mozilla/widget/src/build/nsWidgetSupport.cpp index 8a55c696d3f..c7ab7b4c5f7 100644 --- a/mozilla/widget/src/build/nsWidgetSupport.cpp +++ b/mozilla/widget/src/build/nsWidgetSupport.cpp @@ -47,7 +47,6 @@ #include "nsIToolkit.h" #include "nsIWidget.h" #include "nsICheckButton.h" -#include "nsIScrollbar.h" #include "nsITextWidget.h" @@ -59,7 +58,6 @@ static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID); static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID); static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); -static NS_DEFINE_IID(kIScrollBarIID, NS_ISCROLLBAR_IID); NS_WIDGET nsresult @@ -171,33 +169,6 @@ NS_CreateTextWidget(nsISupports* aParent, -NS_WIDGET nsresult -NS_CreateScrollBar(nsISupports* aParent, - nsIScrollbar* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) - aParent->QueryInterface(kIWidgetIID,(void**)&parent); - - nsIWidget* widget = nsnull; - if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Create(parent, aRect, aHandleEventFunction, NULL); - widget->Show(PR_TRUE); - NS_IF_RELEASE(widget); - } - else - { - NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object"); - } - - if (aParent) - NS_IF_RELEASE(parent); - - return NS_OK; -} - extern NS_WIDGET nsresult NS_ShowWidget(nsISupports* aWidget, PRBool aShow) { diff --git a/mozilla/widget/src/build/nsWinWidgetFactory.cpp b/mozilla/widget/src/build/nsWinWidgetFactory.cpp index dd357f81b81..606b51c718a 100644 --- a/mozilla/widget/src/build/nsWinWidgetFactory.cpp +++ b/mozilla/widget/src/build/nsWinWidgetFactory.cpp @@ -44,7 +44,6 @@ #include "nsFilePicker.h" #include "nsLookAndFeel.h" -#include "nsScrollbar.h" #include "nsToolkit.h" #include "nsWindow.h" #include "nsAppShell.h" @@ -79,66 +78,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFullScreen) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -static NS_IMETHODIMP -nsHorizScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWindow *)new nsScrollbar(PR_FALSE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - -static NS_IMETHODIMP -nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWindow *)new nsScrollbar(PR_TRUE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - static const nsModuleComponentInfo components[] = { { "nsWindow", @@ -153,14 +92,6 @@ static const nsModuleComponentInfo components[] = NS_FILEPICKER_CID, "@mozilla.org/filepicker;1", nsFilePickerConstructor }, - { "Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/horizscroll/win;1", - nsHorizScrollbarConstructor }, - { "Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/win;1", - nsVertScrollbarConstructor }, { "AppShell", NS_APPSHELL_CID, "@mozilla.org/widget/appshell/win;1", diff --git a/mozilla/widget/src/cocoa/Makefile.in b/mozilla/widget/src/cocoa/Makefile.in index 107916e6639..63f95d9be0a 100644 --- a/mozilla/widget/src/cocoa/Makefile.in +++ b/mozilla/widget/src/cocoa/Makefile.in @@ -85,7 +85,6 @@ CPPSRCS = \ CMMSRCS = \ nsFilePicker.mm \ - nsScrollbar.mm \ nsToolkit.mm \ nsAppShellCocoa.mm \ nsCocoaWindow.mm \ diff --git a/mozilla/widget/src/cocoa/nsScrollbar.h b/mozilla/widget/src/cocoa/nsScrollbar.h deleted file mode 100644 index 42d8aae4c94..00000000000 --- a/mozilla/widget/src/cocoa/nsScrollbar.h +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsChildView.h" -#include "nsIScrollbar.h" -#import "mozView.h" - - -/** - * Mac Scrollbar. - */ - -class nsScrollbar : public nsChildView, public nsIScrollbar -{ -private: - typedef nsChildView Inherited; - -public: - - nsScrollbar(); - virtual ~nsScrollbar(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsWindow Interface - virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent); - NS_IMETHOD Show(PRBool bState); - NS_IMETHOD Enable(PRBool bState); - NS_IMETHOD IsEnabled(PRBool* outState); - - // nsIScrollbar part - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - - - /**------------------------------------------------------------------------------- - * Set all the scrollbar parameters - * @update dc 09/16/98 - * @param aMaxRange -- max range of the scrollbar in relative units - * @param aThumbSize -- thumb size, in relative units - * @param aPosition -- the thumb position in relative units - * @param aLineIncrement -- the increment levelof the scrollbar - * @return NS_OK if the position is valid - */ - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - // called from the ScrollbarView when someone hits a part - // of the scrollbar. - void DoScroll(NSScrollerPart inPart); - -protected: - - virtual PRBool IsVertical ( ) const = 0; - - NSScroller* GetControl() { return mView; } - - virtual NSView* CreateCocoaView() ; - virtual GrafPtr GetQuickDrawPort() ; - -// DATA -private: - PRInt32 mValue; - PRUint32 mMaxValue; - PRUint32 mVisibleImageSize; - PRUint32 mLineIncrement; - ControlPartCode mClickedPartCode; - static ControlActionUPP sControlActionProc; // we only need one of these -}; - - -class nsVertScrollbar : public nsScrollbar -{ -public: - nsVertScrollbar() { }; - virtual ~nsVertScrollbar() { }; - -protected: - virtual PRBool IsVertical ( ) const { return PR_TRUE; } ; -}; - -class nsHorizScrollbar : public nsScrollbar -{ -public: - nsHorizScrollbar() { }; - virtual ~nsHorizScrollbar() { }; - -protected: - virtual PRBool IsVertical ( ) const { return PR_FALSE; } ; -}; - - - -@interface ScrollbarView : NSScroller -{ - // Our window [WEAK] - NSWindow* mWindow; - - // the nsScrollbar that created this view. It retains this NSView, so - // the link back to it must be weak. [WEAK] - nsScrollbar* mGeckoChild; -} - - // default initializer -- (id)initWithFrame:(NSRect)frameRect geckoChild:(nsScrollbar*)inChild; - // overridden parent class initializer -- (id)initWithFrame:(NSRect)frameRect; - -- (IBAction)scroll:(NSScroller*)sender; - -@end - -#endif // nsScrollbar_ diff --git a/mozilla/widget/src/cocoa/nsScrollbar.mm b/mozilla/widget/src/cocoa/nsScrollbar.mm deleted file mode 100644 index cee7f048360..00000000000 --- a/mozilla/widget/src/cocoa/nsScrollbar.mm +++ /dev/null @@ -1,458 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsScrollbar.h" -#include "nsIDeviceContext.h" -#if TARGET_CARBON || (UNIVERSAL_INTERFACES_VERSION >= 0x0330) -#include -#endif - -NS_IMPL_ISUPPORTS_INHERITED1(nsScrollbar, nsChildView, nsIScrollbar); - - -ControlActionUPP nsScrollbar::sControlActionProc = nsnull; - - -nsScrollbar::nsScrollbar() - : Inherited() - , mValue(0) - , mMaxValue(0) - , mVisibleImageSize(0) - , mLineIncrement(0) - , mClickedPartCode(0) -{ - WIDGET_SET_CLASSNAME("nsScrollbar"); -} - - -nsScrollbar::~nsScrollbar() -{ -} - - - -NSView* -nsScrollbar::CreateCocoaView ( ) -{ - // Cocoa sets the orientation of a scrollbar at creation time by looking - // at its frame and taking the longer side to be the orientation. Since - // chances are good at this point gecko just wants us to be 1x1, use - // the flag at creation to force the desired orientation. - NSRect orientation; - orientation.origin.x = orientation.origin.y = 0; - if ( IsVertical() ) { - orientation.size.width = 20; - orientation.size.height = 100; - } - else { - orientation.size.width = 100; - orientation.size.height = 20; - } - return [[[ScrollbarView alloc] initWithFrame:orientation geckoChild:this] autorelease]; -} - - -GrafPtr -nsScrollbar::GetQuickDrawPort ( ) -{ - // pray we're always a child of a NSQuickDrawView - NSQuickDrawView* parent = (NSQuickDrawView*)[mView superview]; - return [parent qdPort]; -} - -// -// DoScroll -// -// Called from the action proc of the scrollbar, adjust the control's -// value as well as the value in the content node which communicates -// to gecko that the document is scrolling. -// -void -nsScrollbar::DoScroll(NSScrollerPart inPart) -{ - PRInt32 scrollBarMessage = 0; - PRUint32 oldPos, newPos; - PRUint32 incr; - GetPosition(oldPos); - GetLineIncrement(incr); - switch ( inPart ) { - - // - // For the up/down buttons, scroll up or down by the line height and - // update the attributes on the content node (the scroll frame listens - // for these attributes and will scroll accordingly). However, - // if we have a mediator, we're in an outliner and we have to scroll by - // lines. Outliner ignores the params to ScrollbarButtonPressed() except - // to check if one is greater than the other to indicate direction. - // - - case NSScrollerDecrementLine: // scroll up/left - scrollBarMessage = NS_SCROLLBAR_LINE_PREV; - newPos = oldPos - incr; - SetPosition(newPos); - break; - - case NSScrollerIncrementLine: // scroll down/right - scrollBarMessage = NS_SCROLLBAR_LINE_NEXT; - newPos = oldPos + incr; - SetPosition(newPos); - break; - - case NSScrollerDecrementPage: // scroll up a page - scrollBarMessage = NS_SCROLLBAR_PAGE_PREV; - newPos = oldPos - mVisibleImageSize; - SetPosition(newPos); - break; - - case NSScrollerIncrementPage: // scroll down a page - scrollBarMessage = NS_SCROLLBAR_PAGE_NEXT; - newPos = oldPos + mVisibleImageSize; - SetPosition(newPos); - break; - - // - // The scroller handles changing the value on the thumb for - // us, so read it, convert it back to the range gecko is expecting, - // and tell the content. - // - case NSScrollerKnob: - case NSScrollerKnobSlot: - scrollBarMessage = NS_SCROLLBAR_POS; - newPos = (int) ([mView floatValue] * (mMaxValue-mVisibleImageSize)); - SetPosition(newPos); - break; - - default: - newPos = oldPos; // do nothing - } - - // send event to scroll the parent - nsScrollbarEvent scrollBarEvent; - scrollBarEvent.eventStructType = NS_GUI_EVENT; - scrollBarEvent.widget = this; - scrollBarEvent.message = scrollBarMessage; - GetPosition(newPos); - scrollBarEvent.position = newPos; - Inherited::DispatchWindowEvent(scrollBarEvent); - -} - - -/**------------------------------------------------------------------------------- - * DispatchMouseEvent handle an event for this scrollbar - * @update dc 08/31/98 - * @Param aEvent -- The mouse event to respond to for this button - * @return -- True if the event was handled, PR_FALSE if we did not handle it. - */ -PRBool nsScrollbar::DispatchMouseEvent(nsMouseEvent &aEvent) -{ - return PR_TRUE; -} - - -// -// SetMaxRange -// -// Set the maximum range of a scroll bar. This should be set to the -// full scrollable area minus the visible area. -// -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - mMaxValue = ((int)aEndRange) > 0 ? aEndRange : 10; - if ( GetControl() ) - [mView setFloatValue:[mView floatValue] knobProportion:(mVisibleImageSize / (float)mMaxValue)]; - return NS_OK; -} - - -// -// GetMaxRange -// -// Get the maximum range of a scroll bar -// -NS_METHOD nsScrollbar::GetMaxRange(PRUint32& aMaxRange) -{ - aMaxRange = mMaxValue; - return NS_OK; -} - - -// -// SetPosition -// -// Set the current position of the slider and redraw the scrollbar -// -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - if ((PRInt32)aPos < 0) - aPos = 0; - - mValue = aPos > mMaxValue ? mMaxValue : aPos; - [mView setFloatValue:(mValue / (float)(mMaxValue-mVisibleImageSize))]; - - return NS_OK; -} - - -// -// GetPosition -// -// Get the current position of the slider -// -NS_METHOD nsScrollbar::GetPosition(PRUint32& aPos) -{ - aPos = mValue; - return NS_OK; -} - - -// -// SetThumbSize -// -// Change the knob proportion to be the ratio of the size of the visible image (given in |aSize|) -// to the total area (visible + max). Recall that the max size is the total minus the -// visible area. -// -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - mVisibleImageSize = ((int)aSize) > 0 ? aSize : 1; - - [mView setFloatValue:(mValue / (float)(mMaxValue-mVisibleImageSize)) - knobProportion:(mVisibleImageSize / (float)mMaxValue)]; - - return NS_OK; -} - - -// -// GetThumbSize -// -// Get the height of the visible view area. -// -NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - aSize = mVisibleImageSize; - return NS_OK; -} - - -// -// SetLineIncrement -// -// Set the line increment of the scroll bar -// -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement) -{ - mLineIncrement = (((int)aLineIncrement) > 0 ? aLineIncrement : 1); - return NS_OK; -} - - -// -// GetLineIncrement -// -// Get the line increment of the scroll bar -// -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aLineIncrement) -{ - aLineIncrement = mLineIncrement; - return NS_OK; -} - -/**------------------------------------------------------------------------------- - * See documentation in nsScrollbar.h - * @update dc 012/10/98 - */ -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - SetLineIncrement(aLineIncrement); - - mVisibleImageSize = ((PRInt32)aThumbSize) > 0 ? aThumbSize : 1; - mMaxValue = ((PRInt32)aMaxRange) > 0 ? aMaxRange : 10; - mValue = aPosition > mMaxValue ? mMaxValue : aPosition; - - [mView setFloatValue:(mValue / (float)(mMaxValue-mVisibleImageSize)) - knobProportion:(mVisibleImageSize / (float)mMaxValue )]; - - return NS_OK; -} - - -// -// Show -// -// Hide or show the scrollbar -// -NS_IMETHODIMP -nsScrollbar::Show(PRBool bState) -{ - // the only way to get the scrollbar view to not draw is to remove it - // from the view hierarchy. cache the parent view so that we can - // hook it up later if we're told to show. - if ( mVisible && !bState ) { - mParentView = [mView superview]; - [mView removeFromSuperview]; - } - else if ( !mVisible && bState ) { - if ( mParentView ) - [mParentView addSubview:mView]; - } - - mVisible = bState; - return NS_OK; -} - - -// -// Enable -// -// Enable/disable this scrollbar -// -NS_IMETHODIMP -nsScrollbar::Enable(PRBool bState) -{ - [mView setEnabled:(bState ? YES : NO)]; - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::IsEnabled(PRBool *aState) -{ - if (aState) - *aState = [mView isEnabled] ? PR_TRUE : PR_FALSE; - return NS_OK; -} - - -#pragma mark - - -@implementation ScrollbarView - -// -// -initWithFrame:geckoChild -// Designated Initializer -// -// Init our superclass and make the connection to the gecko nsIWidget we're -// mirroring -// -- (id)initWithFrame:(NSRect)frameRect geckoChild:(nsScrollbar*)inChild -{ - [super initWithFrame:frameRect]; - - NS_ASSERTION(inChild, "Need to provide a tether between this and a nsChildView class"); - mGeckoChild = inChild; - - // make ourselves the target of the scroll and set the action message - [self setTarget:self]; - [self setAction:@selector(scroll:)]; - - return self; -} - - -// -// -initWithFrame -// -// overridden parent class initializer -// -- (id)initWithFrame:(NSRect)frameRect -{ - NS_WARNING("You're calling the wrong initializer. You really want -initWithFrame:geckoChild"); - return [self initWithFrame:frameRect geckoChild:nsnull]; -} - -- (NSWindow*) getNativeWindow -{ - NSWindow* currWin = [self window]; - if (currWin) - return currWin; - else - return mWindow; -} - -- (void) setNativeWindow: (NSWindow*)aWindow -{ - mWindow = aWindow; -} - -// -// -widget -// -// return our gecko child view widget. Note this does not AddRef. -// -- (nsIWidget*) widget -{ - return NS_STATIC_CAST(nsIWidget*, mGeckoChild); -} - -- (BOOL)isFlipped -{ - return YES; -} - - -// -// -mouseMoved -// -// our parent view will try to forward this message down to us. The -// default behavior for NSResponder is to forward it up the chain. Can you -// say "infinite recursion"? I thought so. Just stub out the action to -// break the cycle of madness. -// -- (void)mouseMoved:(NSEvent*)theEvent -{ - // do nothing -} - -// -// -scroll -// -// the action message we've set up to be called when the scrollbar needs -// to adjust its value. Feed back into the owning widget to process -// how much to scroll and adjust the correct attributes. -// -- (IBAction)scroll:(NSScroller*)sender -{ - if ( mGeckoChild ) - mGeckoChild->DoScroll([sender hitPart]); -} - - -@end - diff --git a/mozilla/widget/src/cocoa/nsWidgetFactory.mm b/mozilla/widget/src/cocoa/nsWidgetFactory.mm index bef26a495e1..2745ce49920 100644 --- a/mozilla/widget/src/cocoa/nsWidgetFactory.mm +++ b/mozilla/widget/src/cocoa/nsWidgetFactory.mm @@ -69,7 +69,6 @@ #include "nsIComponentManager.h" #include "nsSound.h" -#include "nsScrollbar.h" #include "nsNativeScrollbar.h" #include "nsBidiKeyboard.h" @@ -86,8 +85,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenuBar) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenu) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenuItem) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsVertScrollbar) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHorizScrollbar) NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeScrollbar) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) //NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) @@ -173,14 +170,6 @@ static nsModuleComponentInfo components[] = NS_BIDIKEYBOARD_CID, "@mozilla.org/widget/bidikeyboard;1", nsBidiKeyboardConstructor }, - { "Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/horizscroll/mac;1", - nsHorizScrollbarConstructor }, - { "Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/mac;1", - nsVertScrollbarConstructor }, { "Native Scrollbar", NS_NATIVESCROLLBAR_CID, "@mozilla.org/widget/nativescrollbar;1", diff --git a/mozilla/widget/src/gtk/Makefile.in b/mozilla/widget/src/gtk/Makefile.in index 0da92983c3f..926bb55a3e2 100644 --- a/mozilla/widget/src/gtk/Makefile.in +++ b/mozilla/widget/src/gtk/Makefile.in @@ -61,7 +61,6 @@ CPPSRCS = \ nsKeyboardUtils.cpp \ nsLabel.cpp \ nsLookAndFeel.cpp \ - nsScrollbar.cpp \ nsSound.cpp \ nsTextHelper.cpp \ nsTextWidget.cpp \ diff --git a/mozilla/widget/src/gtk/nsGtkEventHandler.cpp b/mozilla/widget/src/gtk/nsGtkEventHandler.cpp index 42fa807056f..60cd7b167f9 100644 --- a/mozilla/widget/src/gtk/nsGtkEventHandler.cpp +++ b/mozilla/widget/src/gtk/nsGtkEventHandler.cpp @@ -41,7 +41,6 @@ #include "nsWindow.h" #include "nsAppShell.h" -#include "nsScrollbar.h" #include "nsGUIEvent.h" #include "nsTextWidget.h" @@ -484,69 +483,6 @@ void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p) delete event.windowSize; } -//============================================================== -void handle_scrollbar_value_changed(GtkAdjustment *adj, gpointer p) -{ - nsScrollbar *widget = (nsScrollbar*) p; - nsScrollbarEvent sevent; - - sevent.message = NS_SCROLLBAR_POS; - sevent.widget = (nsWidget *) p; - sevent.eventStructType = NS_SCROLLBAR_EVENT; - - GdkWindow *win = (GdkWindow *)widget->GetNativeData(NS_NATIVE_WINDOW); - gdk_window_get_pointer(win, &sevent.point.x, &sevent.point.y, nsnull); - - NS_ADDREF(widget); - widget->OnScroll(sevent, adj->value); - NS_RELEASE(widget); - -/* FIXME we need to set point.* from the event stuff. */ -#if 0 - nsWindow * widgetWindow = (nsWindow *) p ; - XmScrollBarCallbackStruct * cbs = (XmScrollBarCallbackStruct*) call_data; - sevent.widget = (nsWindow *) p; - if (cbs->event != nsnull) { - sevent.point.x = cbs->event->xbutton.x; - sevent.point.y = cbs->event->xbutton.y; - } else { - sevent.point.x = 0; - sevent.point.y = 0; - } - sevent.time = 0; //XXX Implement this - - switch (cbs->reason) { - - case XmCR_INCREMENT: - sevent.message = NS_SCROLLBAR_LINE_NEXT; - break; - - case XmCR_DECREMENT: - sevent.message = NS_SCROLLBAR_LINE_PREV; - break; - - case XmCR_PAGE_INCREMENT: - sevent.message = NS_SCROLLBAR_PAGE_NEXT; - break; - - case XmCR_PAGE_DECREMENT: - sevent.message = NS_SCROLLBAR_PAGE_PREV; - break; - - case XmCR_DRAG: - sevent.message = NS_SCROLLBAR_POS; - break; - - case XmCR_VALUE_CHANGED: - sevent.message = NS_SCROLLBAR_POS; - break; - - default: - break; - } -#endif -} - // GTK's text widget already does XIM, so we don't want to do this again gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event, gpointer p) diff --git a/mozilla/widget/src/gtk/nsGtkEventHandler.h b/mozilla/widget/src/gtk/nsGtkEventHandler.h index 5478e633e54..c75d9e42874 100644 --- a/mozilla/widget/src/gtk/nsGtkEventHandler.h +++ b/mozilla/widget/src/gtk/nsGtkEventHandler.h @@ -50,8 +50,6 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event, gpointer gint handle_key_release_event(GtkObject *w, GdkEventKey* event, gpointer p); gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p); -void handle_scrollbar_value_changed(GtkAdjustment *adjustment, gpointer p); - //---------------------------------------------------- void handle_xlib_shell_event(GdkSuperWin *superwin, XEvent *event, gpointer p); diff --git a/mozilla/widget/src/gtk/nsScrollbar.cpp b/mozilla/widget/src/gtk/nsScrollbar.cpp deleted file mode 100644 index 2ff23092267..00000000000 --- a/mozilla/widget/src/gtk/nsScrollbar.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include - -#include "nsScrollbar.h" -#include "nsGUIEvent.h" - -#include "nsGtkEventHandler.h" - -NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWidget) -NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWidget) -NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget) - -//------------------------------------------------------------------------- -// -// nsScrollbar constructor -// -//------------------------------------------------------------------------- -nsScrollbar::nsScrollbar (PRBool aIsVertical):nsWidget (), nsIScrollbar () -{ - mOrientation = (aIsVertical) ? - GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL; - mAdjustment = nsnull; -} - -//------------------------------------------------------------------------- -// -// nsScrollbar destructor -// -//------------------------------------------------------------------------- -nsScrollbar::~nsScrollbar () -{ -} - -//------------------------------------------------------------------------- -// -// Create the native scrollbar widget -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::CreateNative (GtkObject * parentWindow) -{ - // Create scrollbar, random default values - mAdjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 100, 1, 25, 25)); - - if (!GDK_IS_SUPERWIN(parentWindow)) { -#ifdef DEBUG - g_print("Damn, brother. That's not a superwin.\n"); -#endif - return NS_ERROR_FAILURE; - } - - GdkSuperWin *superwin = GDK_SUPERWIN(parentWindow); - - mMozBox = gtk_mozbox_new(superwin->bin_window); - - switch (mOrientation) - { - case GTK_ORIENTATION_HORIZONTAL: - mWidget = gtk_hscrollbar_new (mAdjustment); - break; - case GTK_ORIENTATION_VERTICAL: - mWidget = gtk_vscrollbar_new (mAdjustment); - break; - } - - // make sure that we put the scrollbar into the mozbox - - gtk_container_add(GTK_CONTAINER(mMozBox), mWidget); - - gtk_widget_set_name (mWidget, "nsScrollbar"); - - gtk_signal_connect (GTK_OBJECT (mAdjustment), - "value_changed", - GTK_SIGNAL_FUNC (handle_scrollbar_value_changed), - this); - gtk_signal_connect (GTK_OBJECT (mAdjustment), - "destroy", - GTK_SIGNAL_FUNC (DestroySignal), - this); - - return NS_OK; -} - -void -nsScrollbar::OnDestroySignal(GtkWidget* aGtkWidget) -{ - if ((void*)aGtkWidget == (void*)mAdjustment) { - mAdjustment = nsnull; - } - else { - nsWidget::OnDestroySignal(aGtkWidget); - } -} - -//------------------------------------------------------------------------- -// -// Define the range settings -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::SetMaxRange (PRUint32 aEndRange) -{ - if (mAdjustment) { - GTK_ADJUSTMENT (mAdjustment)->upper = (float) aEndRange; - gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed"); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Return the range settings -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::GetMaxRange (PRUint32 & aMaxRange) -{ - if (mAdjustment) - aMaxRange = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->upper; - else - aMaxRange = 0; - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb position -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::SetPosition (PRUint32 aPos) -{ - // if (mAdjustment) - // gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), (float) aPos); - - if (mAdjustment && mWidget) - { - - // XXX - pav - // this should be working fine, but for some reason we still get the additional value_changed - // i'm not sure why, but since we are using GFX scrollbars, this problem doesn't happen. - // see bug http://bugzilla.mozilla.org/show_bug.cgi?id=13407 for more details. - - // - // The following bit of code borrowed from gtkrange.c, - // gtk_range_adjustment_value_changed(): - // - // Ok, so, like, the problem is that the view manager expects - // SetPosition() to simply do that - set the position of the - // scroll bar. Nothing else! - // - // Unfortunately, calling gtk_adjustment_set_value() causes - // the adjustment object (mAdjustment) to emit a - // "value_changed" signal which in turn causes the - // scrollbar widget (mWidget) to scroll to the given position. - // - // The net result of this is that the content is scrolled - // twice, once by the view manager and once by the - // scrollbar - and things get messed up from then onwards. - // - // The following bit of code does the equivalent of - // gtk_adjustment_set_value(), except no signal is emitted. - // - GtkRange * range = GTK_RANGE(mWidget); - GtkAdjustment * adjustment = GTK_ADJUSTMENT(mAdjustment); - - adjustment->value = (float) aPos; - - if (range->old_value != adjustment->value) - { - gtk_range_slider_update (range); - gtk_range_clear_background (range); - - range->old_value = adjustment->value; - } - } - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the current thumb position. -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::GetPosition (PRUint32 & aPos) -{ - if (mAdjustment) - aPos = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->value; - else - aPos = 0; - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb size -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::SetThumbSize (PRUint32 aSize) -{ - if (aSize > 0) - { - if (mAdjustment) { - GTK_ADJUSTMENT (mAdjustment)->page_increment = (float) aSize; - GTK_ADJUSTMENT (mAdjustment)->page_size = (float) aSize; - gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed"); - } - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the thumb size -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::GetThumbSize (PRUint32 & aThumbSize) -{ - if (mAdjustment) - aThumbSize = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->page_size; - else - aThumbSize = 0; - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement) -{ - if (aLineIncrement > 0) - { - if (mAdjustment) { - GTK_ADJUSTMENT (mAdjustment)->step_increment = (float) aLineIncrement; - gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed"); - } - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::GetLineIncrement (PRUint32 & aLineInc) -{ - if (mAdjustment) { - aLineInc = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->step_increment; - } - else - aLineInc = 0; - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set all scrolling parameters -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - if (mAdjustment) { - int thumbSize = (((int) aThumbSize) > 0 ? aThumbSize : 1); - int maxRange = (((int) aMaxRange) > 0 ? aMaxRange : 1); - int mLineIncrement = (((int) aLineIncrement) > 0 ? aLineIncrement : 1); - - int maxPos = maxRange - thumbSize; - int pos = ((int) aPosition) > maxPos ? maxPos - 1 : ((int) aPosition); - - GTK_ADJUSTMENT (mAdjustment)->lower = 0; - GTK_ADJUSTMENT (mAdjustment)->upper = maxRange; - GTK_ADJUSTMENT (mAdjustment)->page_size = thumbSize; - GTK_ADJUSTMENT (mAdjustment)->page_increment = thumbSize; - GTK_ADJUSTMENT (mAdjustment)->step_increment = mLineIncrement; - - gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), pos); - gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed"); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -int nsScrollbar::AdjustScrollBarPosition (int aPosition) -{ - return 0; /* XXX */ -} - -//------------------------------------------------------------------------- -// -// Deal with scrollbar messages (actually implemented only in nsScrollbar) -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnScroll (nsScrollbarEvent & aEvent, PRUint32 cPos) -{ - PRBool result = PR_TRUE; - float newPosition; - - switch (aEvent.message) - { - - // scroll one line right or down - case NS_SCROLLBAR_LINE_NEXT: - { - newPosition = GTK_ADJUSTMENT (mAdjustment)->value; - // newPosition += mLineIncrement; - newPosition += 10; - PRUint32 thumbSize; - PRUint32 maxRange; - GetThumbSize (thumbSize); - GetMaxRange (maxRange); - PRUint32 max = maxRange - thumbSize; - if (newPosition > (int) max) - newPosition = (int) max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) - { - aEvent.position = (PRUint32) newPosition; - result = ConvertStatus ((*mEventCallback) (&aEvent)); - newPosition = aEvent.position; - } - break; - } - - - // scroll one line left or up - case NS_SCROLLBAR_LINE_PREV: - { - newPosition = GTK_ADJUSTMENT (mAdjustment)->value; - - // newPosition -= mLineIncrement; - newPosition -= 10; - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the decrement - if (mEventCallback) - { - aEvent.position = (PRUint32) newPosition; - aEvent.widget = (nsWidget *) this; - result = ConvertStatus ((*mEventCallback) (&aEvent)); - newPosition = aEvent.position; - } - break; - } - - // Scrolls one page right or down - case NS_SCROLLBAR_PAGE_NEXT: - { - newPosition = GTK_ADJUSTMENT (mAdjustment)->value; - PRUint32 thumbSize; - GetThumbSize (thumbSize); - PRUint32 maxRange; - GetThumbSize (thumbSize); - GetMaxRange (maxRange); - PRUint32 max = maxRange - thumbSize; - if (newPosition > (int) max) - newPosition = (int) max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) - { - aEvent.position = (PRUint32) newPosition; - result = ConvertStatus ((*mEventCallback) (&aEvent)); - newPosition = aEvent.position; - } - break; - } - - // Scrolls one page left or up. - case NS_SCROLLBAR_PAGE_PREV: - { - newPosition = GTK_ADJUSTMENT (mAdjustment)->value; - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) - { - aEvent.position = (PRUint32) newPosition; - result = ConvertStatus ((*mEventCallback) (&aEvent)); - newPosition = aEvent.position; - } - break; - } - - - // Scrolls to the absolute position. The current position is specified by - // the cPos parameter. - case NS_SCROLLBAR_POS: - { - newPosition = cPos; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) - { - aEvent.position = (PRUint32) newPosition; - result = ConvertStatus ((*mEventCallback) (&aEvent)); - newPosition = aEvent.position; - } - break; - } - } - /* - GTK_ADJUSTMENT(mAdjustment)->value = newPosition; - gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "value_changed"); - */ - /* - if (mEventCallback) { - aEvent.position = cPos; - result = ConvertStatus((*mEventCallback)(&aEvent)); - newPosition = aEvent.position; - } - */ - return result; -} diff --git a/mozilla/widget/src/gtk/nsScrollbar.h b/mozilla/widget/src/gtk/nsScrollbar.h deleted file mode 100644 index 1a7cd759135..00000000000 --- a/mozilla/widget/src/gtk/nsScrollbar.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsWidget.h" -#include "nsIScrollbar.h" - -/** - * Native GTK+ scrollbar wrapper. - */ -class nsScrollbar : public nsWidget, - public nsIScrollbar -{ - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - NS_DECL_ISUPPORTS_INHERITED - - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - virtual PRBool OnScroll (nsScrollbarEvent & aEvent, PRUint32 cPos); - -protected: - NS_IMETHOD CreateNative(GtkObject *parentWindow); - virtual void OnDestroySignal(GtkWidget* aGtkWidget); - -private: - int mOrientation; - GtkAdjustment *mAdjustment; - - int AdjustScrollBarPosition(int aPosition); -}; - -#endif /* nsScrollbar_h__ */ diff --git a/mozilla/widget/src/gtk/nsWidgetFactory.cpp b/mozilla/widget/src/gtk/nsWidgetFactory.cpp index 9ce1c39a19f..c67b1fe4932 100644 --- a/mozilla/widget/src/gtk/nsWidgetFactory.cpp +++ b/mozilla/widget/src/gtk/nsWidgetFactory.cpp @@ -56,7 +56,6 @@ #include "nsClipboardHelper.h" #include "nsHTMLFormatConverter.h" #include "nsDragService.h" -#include "nsScrollbar.h" #include "nsSound.h" #include "nsGtkMozRemoteHelper.h" #include "nsBidiKeyboard.h" @@ -81,64 +80,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) NS_GENERIC_FACTORY_CONSTRUCTOR(nsGtkXRemoteWidgetHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -static nsresult nsHorizScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_FALSE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - -static nsresult nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_TRUE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - static const nsModuleComponentInfo components[] = { { "Gtk nsWindow", @@ -157,14 +98,6 @@ static const nsModuleComponentInfo components[] = NS_CHECKBUTTON_CID, "@mozilla.org/widgets/checkbutton/gtk;1", nsCheckButtonConstructor }, - { "Gtk Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/horizscroll/gtk;1", - nsHorizScrollbarConstructor }, - { "Gtk Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/gtk;1", - nsVertScrollbarConstructor }, { "Gtk Text Widget", NS_TEXTFIELD_CID, "@mozilla.org/widgets/textwidget/gtk;1", diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index 947fb508c95..ad531e8b15c 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -2526,11 +2526,6 @@ NS_IMETHODIMP nsWindow::GetScreenBounds(nsRect &aRect) } -PRBool nsWindow::OnScroll(nsScrollbarEvent &aEvent, PRUint32 cPos) -{ - return PR_FALSE; -} - //------------------------------------------------------------------------- // // Hide or show this component diff --git a/mozilla/widget/src/gtk/nsWindow.h b/mozilla/widget/src/gtk/nsWindow.h index 8b166483438..c31de1f8ad0 100644 --- a/mozilla/widget/src/gtk/nsWindow.h +++ b/mozilla/widget/src/gtk/nsWindow.h @@ -154,7 +154,6 @@ public: void InvalidateWindowPos(void); - virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); // in nsWidget now // virtual PRBool OnResize(nsSizeEvent &aEvent); diff --git a/mozilla/widget/src/gtk2/Makefile.in b/mozilla/widget/src/gtk2/Makefile.in index a4413d5a146..89ecf13a740 100644 --- a/mozilla/widget/src/gtk2/Makefile.in +++ b/mozilla/widget/src/gtk2/Makefile.in @@ -49,7 +49,6 @@ CSRCS = \ CPPSRCS = \ nsWindow.cpp \ - nsScrollbar.cpp \ nsAppShell.cpp \ nsWidgetFactory.cpp \ nsToolkit.cpp \ diff --git a/mozilla/widget/src/gtk2/nsCommonWidget.cpp b/mozilla/widget/src/gtk2/nsCommonWidget.cpp index dc750adce36..33f9483ff87 100644 --- a/mozilla/widget/src/gtk2/nsCommonWidget.cpp +++ b/mozilla/widget/src/gtk2/nsCommonWidget.cpp @@ -206,17 +206,6 @@ nsCommonWidget::InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent, aEvent.time = aGdkEvent->time; } -void -nsCommonWidget::InitScrollbarEvent(nsScrollbarEvent &aEvent, PRUint32 aMsg) -{ - memset(&aEvent, 0, sizeof(nsScrollbarEvent)); - aEvent.eventStructType = NS_SCROLLBAR_EVENT; - aEvent.message = NS_SCROLLBAR_POS; - aEvent.widget = NS_STATIC_CAST(nsIWidget *, this); - // XXX do we need to get the pointer position relative to the widget - // or not? -} - #ifdef ACCESSIBILITY void diff --git a/mozilla/widget/src/gtk2/nsCommonWidget.h b/mozilla/widget/src/gtk2/nsCommonWidget.h index 8164f409e1e..d63b28a2818 100644 --- a/mozilla/widget/src/gtk2/nsCommonWidget.h +++ b/mozilla/widget/src/gtk2/nsCommonWidget.h @@ -77,7 +77,6 @@ public: void InitMouseScrollEvent(nsMouseScrollEvent &aEvent, GdkEventScroll *aGdkEvent, PRUint32 aMsg); void InitKeyEvent(nsKeyEvent &aEvent, GdkEventKey *aGdkEvent, PRUint32 aMsg); - void InitScrollbarEvent(nsScrollbarEvent &aEvent, PRUint32 aMsg); void InitSizeModeEvent(nsSizeModeEvent &aEvent); #ifdef ACCESSIBILITY diff --git a/mozilla/widget/src/gtk2/nsScrollbar.cpp b/mozilla/widget/src/gtk2/nsScrollbar.cpp deleted file mode 100644 index e917d49b574..00000000000 --- a/mozilla/widget/src/gtk2/nsScrollbar.cpp +++ /dev/null @@ -1,575 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code mozilla.org code. - * - * The Initial Developer of the Original Code Christopher Blizzard - * . Portions created by the Initial Developer - * are Copyright (C) 2001 the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsScrollbar.h" -#include "mozcontainer.h" -#include -#include -#include - -/* callbacks from widgets */ -static void value_changed_cb (GtkAdjustment *adjustment, gpointer data); - -nsScrollbar::nsScrollbar(PRBool aIsVertical) -{ - if (aIsVertical) - mOrientation = GTK_ORIENTATION_VERTICAL; - else - mOrientation = GTK_ORIENTATION_HORIZONTAL; - - mWidget = nsnull; - mAdjustment = nsnull; - mMaxRange = 0; - mThumbSize = 0; -} - -nsScrollbar::~nsScrollbar() -{ -} - -NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsCommonWidget) -NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsCommonWidget) -NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget) - -// nsIWidget - -NS_IMETHODIMP -nsScrollbar::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NativeCreate(aParent, nsnull, aRect, aHandleEventFunction, - aContext, aAppShell, aToolkit, aInitData); -} - -NS_IMETHODIMP -nsScrollbar::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NativeCreate(nsnull, aParent, aRect, aHandleEventFunction, - aContext, aAppShell, aToolkit, aInitData); -} - -NS_IMETHODIMP -nsScrollbar::Destroy(void) -{ - if (mIsDestroyed || !mCreated) - return NS_OK; - - LOG(("nsScrollbar::Destroy [%p]\n", (void *)this)); - mIsDestroyed = PR_TRUE; - mCreated = PR_FALSE; - - NativeShow(PR_FALSE); - - if (mWidget) { - gtk_widget_destroy(mWidget); - mWidget = NULL; - // this is just a ref into the widget above - mAdjustment = NULL; - } - - OnDestroy(); - - return NS_OK; -} - -NS_IMETHODIMP -nsScrollbar::IsVisible(PRBool & aState) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX, PRInt32 *aY) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::Move(PRInt32 aX, PRInt32 aY) -{ - LOG(("nsScrollbar::Move [%p] %d %d\n", (void *)this, - aX, aY)); - - if (aX == mBounds.x && aY == mBounds.y) - return NS_OK; - - mBounds.x = aX; - mBounds.y = aY; - - // If the bounds aren't sane then don't actually move the window. - // It will be moved to the proper position when the bounds become - // sane. - if (AreBoundsSane() && mCreated) - moz_container_move(MOZ_CONTAINER(gtk_widget_get_parent(mWidget)), - mWidget, aX, aY, mBounds.width, mBounds.height); - - return NS_OK; -} - -NS_IMETHODIMP -nsScrollbar::Enable(PRBool aState) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::SetFocus(PRBool aRaise) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsIFontMetrics* -nsScrollbar::GetFont(void) -{ - return nsnull; -} - -NS_IMETHODIMP -nsScrollbar::SetFont(const nsFont &aFont) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::Invalidate(PRBool aIsSynchronous) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::Update() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::SetColorMap(nsColorMap *aColorMap) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void* -nsScrollbar::GetNativeData(PRUint32 aDataType) -{ - return nsnull; -} - -NS_IMETHODIMP -nsScrollbar::SetTitle(const nsString& aTitle) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::SetMenuBar(nsIMenuBar * aMenuBar) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::ShowMenuBar(PRBool aShow) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::BeginResizingChildren(void) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::EndResizingChildren(void) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsScrollbar::CaptureRollupEvents(nsIRollupListener * aListener, - PRBool aDoCapture, - PRBool aConsumeRollupEvent) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - - -// nsIScrollbar - -NS_IMETHODIMP -nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - mMaxRange = aEndRange; - - UpdateAdjustment(); - - return NS_OK; -} - -NS_IMETHODIMP -nsScrollbar::GetMaxRange(PRUint32& aMaxRange) -{ - aMaxRange = mMaxRange; - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::SetPosition(PRUint32 aPos) -{ - if (mAdjustment && (PRUint32)mAdjustment->value != aPos) { - mAdjustment->value = (gdouble)aPos; - UpdateAdjustment(); - } - - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::GetPosition(PRUint32& aPos) -{ - if (mAdjustment) - aPos = (PRUint32)mAdjustment->value; - else - aPos = 0; - - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - mThumbSize = aSize; - - if (mAdjustment) { - mAdjustment->page_increment = aSize; - UpdateAdjustment(); - } - - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - aSize = mThumbSize; - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::SetLineIncrement(PRUint32 aSize) -{ - if (mAdjustment) { - mAdjustment->step_increment = aSize; - UpdateAdjustment(); - } - - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::GetLineIncrement(PRUint32& aSize) -{ - if (mAdjustment) - aSize = (PRUint32)mAdjustment->step_increment; - else - aSize = 0; - - return NS_OK; -} - - -NS_IMETHODIMP -nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - mMaxRange = aMaxRange; - mThumbSize = aThumbSize; - - if (mAdjustment) { - mAdjustment->lower = 0; - mAdjustment->page_increment = aThumbSize; - mAdjustment->step_increment = aLineIncrement; - - UpdateAdjustment(); - } - - return NS_OK; -} - - -// we assume that this will ONLY be called when updating from scrolling -NS_IMETHODIMP -nsScrollbar::SetBounds (const nsRect &aRect) -{ - LOG(("nsScrollbar::SetBounds [%p] %d %d %d %d\n", - (void *)this, aRect.x, aRect.y, - aRect.width, aRect.height)); - - if (mWidget) { - LOG(("widget allocation %d %d %d %d\n", - mWidget->allocation.x, - mWidget->allocation.y, - mWidget->allocation.width, - mWidget->allocation.height)); - nsCommonWidget::SetBounds(aRect); - - // update the x/y with our new sizes - mWidget->allocation.x = aRect.x; - mWidget->allocation.y = aRect.y; - - moz_container_scroll_update (MOZ_CONTAINER(gtk_widget_get_parent(mWidget)), - mWidget, aRect.x, aRect.y); - } - return NS_OK; -} - -nsresult -nsScrollbar::NativeCreate(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - // initialize all the common bits of this class - BaseCreate(aParent, aRect, aHandleEventFunction, aContext, - aAppShell, aToolkit, aInitData); - - // Do we need to listen for resizes? - PRBool listenForResizes = PR_FALSE; - if (aNativeParent || (aInitData && aInitData->mListenForResizes)) - listenForResizes = PR_TRUE; - - // and do our common creation - CommonCreate(aParent, listenForResizes); - - // save our bounds - mBounds = aRect; - - // find our parent window - GdkWindow *parentWindow; - if (aParent) - parentWindow = GDK_WINDOW(aParent->GetNativeData(NS_NATIVE_WINDOW)); - else - parentWindow = GDK_WINDOW(aNativeParent); - - if (!parentWindow) - return NS_ERROR_FAILURE; - - // use the parent window to find the parent widget - gpointer user_data; - gdk_window_get_user_data(parentWindow, &user_data); - - if (!user_data) - return NS_ERROR_FAILURE; - - // our parent widget - GtkWidget *parentWidget = GTK_WIDGET(user_data); - - // create the right widget - if (mOrientation == GTK_ORIENTATION_VERTICAL) - mWidget = gtk_vscrollbar_new(NULL); - else - mWidget = gtk_hscrollbar_new(NULL); - - // set the parent of the scrollbar to be the gdk window of the - // parent window. - gtk_widget_set_parent_window(mWidget, parentWindow); - - // add this widget to the parent window, assuming it's a container - // of course. - moz_container_put(MOZ_CONTAINER(parentWidget), mWidget, - mBounds.x, mBounds.y); - - // and realize the widget - gtk_widget_realize(mWidget); - - // resize so that everything is set to the right dimensions - Resize(mBounds.width, mBounds.height, PR_FALSE); - - // get a handle to the adjustment for later use - this doesn't - // addref - mAdjustment = gtk_range_get_adjustment(GTK_RANGE(mWidget)); - - // add a label so we can get back here if we need to - g_object_set_data(G_OBJECT(mAdjustment), "nsScrollbar", - this); - - // add a callback so we will get value changes - g_signal_connect(G_OBJECT(mAdjustment), "value_changed", - G_CALLBACK(value_changed_cb), this); - - LOG(("nsScrollbar [%p] %s %p %lx\n", (void *)this, - (mOrientation == GTK_ORIENTATION_VERTICAL) - ? "vertical" : "horizontal", - (void *)mWidget, GDK_WINDOW_XWINDOW(mWidget->window))); - LOG(("\tparent was %p %lx\n", (void *)parentWindow, - GDK_WINDOW_XWINDOW(parentWindow))); - - return NS_OK; -} - -void -nsScrollbar::NativeResize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) -{ - LOG(("nsScrollbar::NativeResize [%p] %d %d\n", (void *)this, - aWidth, aHeight)); - // clear our resize flag - mNeedsResize = PR_FALSE; - - moz_container_move(MOZ_CONTAINER(gtk_widget_get_parent(mWidget)), - mWidget, mBounds.x, mBounds.y, aWidth, aHeight); -} - -void -nsScrollbar::NativeResize(PRInt32 aX, PRInt32 aY, - PRInt32 aWidth, PRInt32 aHeight, - PRBool aRepaint) -{ - LOG(("nsScrollbar::NativeResize [%p] %d %d %d %d\n", (void *)this, - aX, aY, aWidth, aHeight)); - // clear our resize flag - mNeedsResize = PR_FALSE; - - moz_container_move(MOZ_CONTAINER(gtk_widget_get_parent(mWidget)), - mWidget, aX, aY, aWidth, aHeight); -} - -void -nsScrollbar::NativeShow (PRBool aAction) -{ - LOG(("nsScrollbar::NativeShow [%p] %d\n", (void *)this, aAction)); - - if (aAction) { - // unset our flag now that our window has been shown - mNeedsShow = PR_FALSE; - gtk_widget_show(mWidget); - } - else { - gtk_widget_hide(mWidget); - } -} - -void -nsScrollbar::OnValueChanged(void) -{ - LOG(("nsScrollbar::OnValueChanged [%p]\n", (void *)this)); - nsScrollbarEvent event; - InitScrollbarEvent(event, NS_SCROLLBAR_POS); - event.position = (PRUint32)mAdjustment->value; - - nsEventStatus status; - DispatchEvent(&event, status); -} - -void -nsScrollbar::UpdateAdjustment(void) -{ - if (!mAdjustment) - return; - - // Infinity in Mozilla is measured by setting the max range and - // the thumb size to zero. In the adjustment, this doesn't work. - // Just set the upper bounds and the page size to one to get an - // infinite scrollbar. - if (mMaxRange == 0 && mThumbSize == 0) { - mAdjustment->upper = 1; - mAdjustment->page_size = 1; - } - else { - mAdjustment->upper = mMaxRange; - mAdjustment->page_size = mThumbSize; - } - - LOG(("nsScrollbar::UpdateAdjustment [%p] upper: %d page_size %d\n", - (void *)this, mAdjustment->upper, mAdjustment->page_size)); - - gtk_adjustment_changed(mAdjustment); -} - -/* static */ -void -value_changed_cb (GtkAdjustment *adjustment, gpointer data) -{ - nsScrollbar *scrollbar = NS_STATIC_CAST(nsScrollbar *, data); - - scrollbar->OnValueChanged(); -} - diff --git a/mozilla/widget/src/gtk2/nsScrollbar.h b/mozilla/widget/src/gtk2/nsScrollbar.h deleted file mode 100644 index 7a93c308fb6..00000000000 --- a/mozilla/widget/src/gtk2/nsScrollbar.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code mozilla.org code. - * - * The Initial Developer of the Original Code Christopher Blizzard - * . Portions created by the Initial Developer - * are Copyright (C) 2001 the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsBaseWidget.h" -#include "nsIScrollbar.h" - -#include - -#include "nsCommonWidget.h" - -class nsScrollbar : public nsCommonWidget, - public nsIScrollbar { -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - NS_DECL_ISUPPORTS_INHERITED - - // nsIWidget - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD Destroy(void); - NS_IMETHOD IsVisible(PRBool & aState); - NS_IMETHOD ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX, PRInt32 *aY); - NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); - NS_IMETHOD Enable(PRBool aState); - NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE); - virtual nsIFontMetrics* GetFont(void); - NS_IMETHOD SetFont(const nsFont &aFont); - NS_IMETHOD Invalidate(PRBool aIsSynchronous); - NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous); - NS_IMETHOD Update(); - NS_IMETHOD SetColorMap(nsColorMap *aColorMap); - NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect); - virtual void* GetNativeData(PRUint32 aDataType); - NS_IMETHOD SetTitle(const nsString& aTitle); - NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar); - NS_IMETHOD ShowMenuBar(PRBool aShow); - NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect); - NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect); - NS_IMETHOD BeginResizingChildren(void); - NS_IMETHOD EndResizingChildren(void); - NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, - PRBool aDoCapture, - PRBool aConsumeRollupEvent); - - // nsIScrollbar - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - // from nsBaseWidget - NS_IMETHOD SetBounds (const nsRect &aRect); - - nsresult NativeCreate(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData); - - // common widget - void NativeResize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint); - - void NativeResize(PRInt32 aX, PRInt32 aY, - PRInt32 aWidth, PRInt32 aHeight, - PRBool aRepaint); - - void NativeShow (PRBool aAction); - - // Callbacks - void OnValueChanged(void); - -private: - GtkWidget *mWidget; - GtkOrientation mOrientation; - GtkAdjustment *mAdjustment; - - // We track these separately because sometimes their values might - // be different than the values stored in the adjustment. - PRUint32 mMaxRange; - PRUint32 mThumbSize; - - // Update the adjustment taking into account differences between - // the adjustment's method and mozilla's method for measuing - // infinity. - void UpdateAdjustment(void); -}; diff --git a/mozilla/widget/src/gtk2/nsWidgetFactory.cpp b/mozilla/widget/src/gtk2/nsWidgetFactory.cpp index 3ac3bb86865..8d0cd64aa8f 100644 --- a/mozilla/widget/src/gtk2/nsWidgetFactory.cpp +++ b/mozilla/widget/src/gtk2/nsWidgetFactory.cpp @@ -42,7 +42,6 @@ #include "nsBaseWidget.h" #include "nsLookAndFeel.h" #include "nsWindow.h" -#include "nsScrollbar.h" #include "nsGtkMozRemoteHelper.h" #include "nsTransferable.h" #include "nsClipboardHelper.h" @@ -69,64 +68,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsClipboard, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) -static -nsresult nsHorizScrollbarConstructor (nsISupports *aOuter, - REFNSIID aIID, - void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if (!aResult) - return NS_ERROR_NULL_POINTER; - - *aResult = nsnull; - - if (aOuter) - return NS_ERROR_NO_AGGREGATION; - - inst = (nsISupports *)(nsBaseWidget *)(nsCommonWidget *) - new nsScrollbar(PR_FALSE); - - if (!inst) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - -static -nsresult nsVertScrollbarConstructor (nsISupports *aOuter, - REFNSIID aIID, - void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if (!aResult) - return NS_ERROR_NULL_POINTER; - - *aResult = nsnull; - - if (aOuter) - return NS_ERROR_NO_AGGREGATION; - - inst = (nsISupports *)(nsBaseWidget *)(nsCommonWidget *) - new nsScrollbar(PR_TRUE); - - if (!inst) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - static const nsModuleComponentInfo components[] = { { "Gtk2 Window", @@ -145,14 +86,6 @@ static const nsModuleComponentInfo components[] = NS_LOOKANDFEEL_CID, "@mozilla.org/widget/lookandfeel/gtk;1", nsLookAndFeelConstructor }, - { "Gtk2 Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/hoizscroll/gtk;1", - nsHorizScrollbarConstructor }, - { "Gtk2 Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/gtk;1", - nsVertScrollbarConstructor }, { "Gtk2 Sound", NS_SOUND_CID, "@mozilla.org/sound;1", diff --git a/mozilla/widget/src/mac/Makefile.in b/mozilla/widget/src/mac/Makefile.in index 60f413c9cdb..7414e26c1f5 100644 --- a/mozilla/widget/src/mac/Makefile.in +++ b/mozilla/widget/src/mac/Makefile.in @@ -84,7 +84,6 @@ CPPSRCS = nsAppShell.cpp \ nsMenuBarX.cpp \ nsMenuItemX.cpp \ nsMimeMapper.cpp \ - nsScrollbar.cpp \ nsNativeScrollbar.cpp \ nsSound.cpp \ nsTextWidget.cpp \ diff --git a/mozilla/widget/src/mac/nsScrollbar.cpp b/mozilla/widget/src/mac/nsScrollbar.cpp deleted file mode 100644 index 96b79aadf0d..00000000000 --- a/mozilla/widget/src/mac/nsScrollbar.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsScrollbar.h" -#include "nsIDeviceContext.h" -#if TARGET_CARBON || (UNIVERSAL_INTERFACES_VERSION >= 0x0330) -#include -#endif - -#include "nsWatchTask.h" - - -// -// StControlActionProcOwner -// -// A class that wraps a control action proc so that it is disposed of -// correctly when the shared library shuts down -// -class StControlActionProcOwner { -public: - - StControlActionProcOwner ( ) - { - sControlActionProc = NewControlActionUPP(nsScrollbar::ScrollActionProc); - NS_ASSERTION(sControlActionProc, "Couldn't create live scrolling action proc"); - } - ~StControlActionProcOwner ( ) - { - if ( sControlActionProc ) - DisposeControlActionUPP(sControlActionProc); - } - - ControlActionUPP ActionProc() { return sControlActionProc; } - -private: - ControlActionUPP sControlActionProc; -}; - - -static ControlActionUPP ScrollbarActionProc(); - -static ControlActionUPP ScrollbarActionProc() -{ - static StControlActionProcOwner sActionProcOwner; - return sActionProcOwner.ActionProc(); -} - - -NS_IMPL_ADDREF(nsScrollbar); -NS_IMPL_RELEASE(nsScrollbar); - -NS_INTERFACE_MAP_BEGIN(nsScrollbar) - NS_INTERFACE_MAP_ENTRY(nsIScrollbar) -NS_INTERFACE_MAP_END_INHERITING(nsWindow) - - -/**------------------------------------------------------------------------------- - * nsScrollbar Constructor - * @update dc 10/31/98 - * @param aIsVertical -- Tells if the scrollbar had a vertical or horizontal orientation - */ -nsScrollbar::nsScrollbar() - : nsMacControl() - , mLineIncrement(0) - , mFullImageSize(0) - , mVisibleImageSize(0) - , mMouseDownInScroll(PR_FALSE) - , mClickedPartCode(0) -{ - WIDGET_SET_CLASSNAME("nsScrollbar"); - SetControlType(kControlScrollBarLiveProc); -} - -/**------------------------------------------------------------------------------- - * Destuctor for the nsScrollbar - * @update dc 10/31/98 - */ -nsScrollbar::~nsScrollbar() -{ -} - - -/**------------------------------------------------------------------------------- - * ScrollActionProc Callback for TrackControl - * @update jrm 99/01/11 - * @param ctrl - The Control being tracked - * @param part - Part of the control (arrow, thumb, gutter) being hit - */ -pascal void nsScrollbar::ScrollActionProc(ControlHandle ctrl, ControlPartCode part) -{ - nsScrollbar* me = (nsScrollbar*)(::GetControlReference(ctrl)); - NS_ASSERTION(nsnull != me, "NULL nsScrollbar"); - if (nsnull != me) - me->DoScrollAction(part); -} - -/**------------------------------------------------------------------------------- - * ScrollActionProc Callback for TrackControl - * @update jrm 99/01/11 - * @param part - Part of the control (arrow, thumb, gutter) being hit - */ -void nsScrollbar::DoScrollAction(ControlPartCode part) -{ - PRUint32 pos; - PRUint32 incr; - PRUint32 visibleImageSize; - PRInt32 scrollBarMessage = 0; - GetPosition(pos); - GetLineIncrement(incr); - GetThumbSize(visibleImageSize); - switch(part) - { - case kControlUpButtonPart: - { - scrollBarMessage = NS_SCROLLBAR_LINE_PREV; - SetPosition(pos - incr); - break; - } - case kControlDownButtonPart: - scrollBarMessage = NS_SCROLLBAR_LINE_NEXT; - SetPosition(pos + incr); - break; - case kControlPageUpPart: - scrollBarMessage = NS_SCROLLBAR_PAGE_PREV; - SetPosition(pos - visibleImageSize); - break; - case kControlPageDownPart: - scrollBarMessage = NS_SCROLLBAR_PAGE_NEXT; - SetPosition(pos + visibleImageSize); - break; - case kControlIndicatorPart: - scrollBarMessage = NS_SCROLLBAR_POS; - SetPosition(::GetControl32BitValue(GetControl())); - break; - } - EndDraw(); - - // send event to scroll the parent - nsScrollbarEvent scrollBarEvent; - scrollBarEvent.eventStructType = NS_GUI_EVENT; - scrollBarEvent.widget = this; - scrollBarEvent.message = scrollBarMessage; - GetPosition(pos); - scrollBarEvent.position = pos; - Inherited::DispatchWindowEvent(scrollBarEvent); - - // update the area of the parent uncovered by the scrolling - nsIWidget* parent = GetParent(); - parent->Update(); - NS_RELEASE(parent); - - // update this scrollbar - Invalidate(PR_FALSE); - Update(); - - StartDraw(); -} - -/**------------------------------------------------------------------------------- - * DispatchMouseEvent handle an event for this scrollbar - * @update dc 08/31/98 - * @Param aEvent -- The mouse event to respond to for this button - * @return -- True if the event was handled, PR_FALSE if we did not handle it. - */ -PRBool nsScrollbar::DispatchMouseEvent(nsMouseEvent &aEvent) -{ - PRBool eatEvent = PR_FALSE; - switch (aEvent.message) - { - case NS_MOUSE_LEFT_DOUBLECLICK: - case NS_MOUSE_LEFT_BUTTON_DOWN: - NS_ASSERTION(this != 0, "NULL nsScrollbar2"); - ::SetControlReference(mControl, (UInt32) this); - StartDraw(); - { - Point thePoint; - thePoint.h = aEvent.point.x; - thePoint.v = aEvent.point.y; - mClickedPartCode = ::TestControl(mControl, thePoint); - if (mClickedPartCode > 0) - ::HiliteControl(mControl, mClickedPartCode); - - switch (mClickedPartCode) - { - case kControlUpButtonPart: - case kControlDownButtonPart: - case kControlPageUpPart: - case kControlPageDownPart: - case kControlIndicatorPart: - // We are assuming Appearance 1.1 or later, so we - // have the "live scroll" variant of the scrollbar, - // which lets you pass the action proc to TrackControl - // for the thumb (this was illegal in previous - // versions of the defproc). - nsWatchTask::GetTask().Suspend(); - ::TrackControl(mControl, thePoint, ScrollbarActionProc()); - nsWatchTask::GetTask().Resume(); - ::HiliteControl(mControl, 0); - // We don't dispatch the mouseDown event because mouseUp is eaten - // by TrackControl anyway and the only messages the app really - // cares about are the NS_SCROLLBAR_xxx messages. - eatEvent = PR_TRUE; - break; - } - SetPosition(mValue); - } - EndDraw(); - break; - - - case NS_MOUSE_LEFT_BUTTON_UP: - mClickedPartCode = 0; - break; - - case NS_MOUSE_EXIT: - if (mWidgetArmed) - { - StartDraw(); - ::HiliteControl(mControl, 0); - EndDraw(); - } - break; - - case NS_MOUSE_ENTER: - if (mWidgetArmed) - { - StartDraw(); - ::HiliteControl(mControl, mClickedPartCode); - EndDraw(); - } - break; - } - - if (eatEvent) - return PR_TRUE; - return (Inherited::DispatchMouseEvent(aEvent)); - -} - -/**------------------------------------------------------------------------------- - * set the maximum range of a scroll bar - * @update dc 09/16/98 - * @param aMaxRange -- the maximum to set this to - * @return -- If a good size was returned - */ -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) // really means set full image size. -{ - mFullImageSize = ((int)aEndRange) > 0 ? aEndRange : 10; - if (mControl) - { - StartDraw(); - ::SetControl32BitMaximum( - mControl, - mFullImageSize > mVisibleImageSize ? mFullImageSize - mVisibleImageSize : 0); - EndDraw(); - } - return NS_OK; -} - -/**------------------------------------------------------------------------------- - * get the maximum range of a scroll bar - * @update dc 09/16/98 - * @param aMaxRange -- The current maximum this slider can be - * @return -- If a good size was returned - */ -NS_METHOD nsScrollbar::GetMaxRange(PRUint32& aMaxRange) // really means get full image size -{ - aMaxRange = mFullImageSize; - return NS_OK; -} - -/**------------------------------------------------------------------------------- - * Set the current position of the slider - * @update dc 09/16/98 - * @param aMaxRange -- The current value to set the slider position to. - * @return -- NS_OK if the position is valid - */ -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - if ((PRInt32)aPos < 0) - aPos = 0; - PRUint32 aMax = mFullImageSize - mVisibleImageSize; - - PRInt32 oldValue = mValue; - mValue = ((PRInt32)aPos) > aMax ? aMax : ((int)aPos); - - // redraw the scrollbar. should update be done now, or later? - if (mValue != oldValue) - { - Invalidate(PR_FALSE); - Update(); - } - - return NS_OK; -} - - -/**------------------------------------------------------------------------------- - * Get the current position of the slider - * @update dc 09/16/98 - * @param aMaxRange -- The current slider position. - * @return -- NS_OK if the position is valid - */ -NS_METHOD nsScrollbar::GetPosition(PRUint32& aPos) -{ - aPos = mValue; - return NS_OK; -} - -/**------------------------------------------------------------------------------- - * Set the height of a vertical, or width of a horizontal scroll bar thumb control - * @update dc 09/16/98 - * @param aSize -- the size to set the thumb control to - * @return -- NS_OK if the position is valid - */ -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - mVisibleImageSize = ((int)aSize) > 0 ? aSize : 1; - - if (mVisibleImageSize > mFullImageSize) - mVisibleImageSize = mFullImageSize; - if (mControl) - { - StartDraw(); - SetControlViewSize(mControl, mVisibleImageSize); - EndDraw(); - } - return NS_OK; -} - -/**------------------------------------------------------------------------------- - * get the height of a vertical, or width of a horizontal scroll bar thumb control - * @update dc 09/16/98 - * @param aSize -- the size to set the thumb control to - * @return -- NS_OK if the position is valid - */ -NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - aSize = mVisibleImageSize; - return NS_OK; -} - -/**------------------------------------------------------------------------------- - * Set the increment of the scroll bar - * @update dc 09/16/98 - * @param aLineIncrement -- the control increment - * @return -- NS_OK if the position is valid - */ -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement) -{ - mLineIncrement = (((int)aLineIncrement) > 0 ? aLineIncrement : 1); - return NS_OK; -} - - -/**------------------------------------------------------------------------------- - * Get the increment of the scroll bar - * @update dc 09/16/98 - * @param aLineIncrement -- the control increment - * @return NS_OK if the position is valid - */ -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aLineIncrement) -{ - aLineIncrement = mLineIncrement; - return NS_OK; -} - -/**------------------------------------------------------------------------------- - * See documentation in nsScrollbar.h - * @update dc 012/10/98 - */ -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - SetLineIncrement(aLineIncrement); - SetPosition(aPosition); - mVisibleImageSize = aThumbSize; // needed by SetMaxRange - SetMaxRange(aMaxRange); - SetThumbSize(aThumbSize); // Needs to know the maximum value when calling Mac toolbox. - - return NS_OK; -} - -#pragma mark - - -//------------------------------------------------------------------------- -// -// Get the rect which the Mac control uses. This may be different for -// different controls, so this method allows overriding -// -//------------------------------------------------------------------------- -void nsScrollbar::GetRectForMacControl(nsRect &outRect) -{ - outRect = mBounds; - outRect.x = outRect.y = 0; - - if (mBounds.height > mBounds.width) - { - // vertical scroll bar - outRect.Inflate(0, 1); - } - else - { - // horizontal scroll bar - outRect.Inflate(1, 0); - } -} - diff --git a/mozilla/widget/src/mac/nsScrollbar.h b/mozilla/widget/src/mac/nsScrollbar.h deleted file mode 100644 index 2e485296e18..00000000000 --- a/mozilla/widget/src/mac/nsScrollbar.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsMacControl.h" -#include "nsIScrollbar.h" -#include - -/** - * Mac Scrollbar. - */ - -class nsScrollbar : public nsMacControl, public nsIScrollbar -{ -private: - typedef nsMacControl Inherited; - -public: - nsScrollbar(); - virtual ~nsScrollbar(); - - NS_DECL_ISUPPORTS_INHERITED - - // nsWindow Interface - virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent); - - // nsIScrollbar part - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - - - /**------------------------------------------------------------------------------- - * Set all the scrollbar parameters - * @update dc 09/16/98 - * @param aMaxRange -- max range of the scrollbar in relative units - * @param aThumbSize -- thumb size, in relative units - * @param aPosition -- the thumb position in relative units - * @param aLineIncrement -- the increment levelof the scrollbar - * @return NS_OK if the position is valid - */ - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - ControlHandle GetControl() { return mControl; } - -protected: - - virtual void GetRectForMacControl(nsRect &outRect); - -private: - - friend class StControlActionProcOwner; - - static pascal void ScrollActionProc(ControlHandle, ControlPartCode); - void DoScrollAction(ControlPartCode); - -// DATA -private: - - PRUint32 mFullImageSize; - PRUint32 mVisibleImageSize; - PRUint32 mLineIncrement; - PRBool mMouseDownInScroll; - ControlPartCode mClickedPartCode; -}; - - - -#endif // nsScrollbar_ diff --git a/mozilla/widget/src/mac/nsWidgetFactory.cpp b/mozilla/widget/src/mac/nsWidgetFactory.cpp index 598115ac37f..fd2a122e5c7 100644 --- a/mozilla/widget/src/mac/nsWidgetFactory.cpp +++ b/mozilla/widget/src/mac/nsWidgetFactory.cpp @@ -50,7 +50,6 @@ #include "nsTextWidget.h" #include "nsLabel.h" #include "nsFilePicker.h" -#include "nsScrollbar.h" #include "nsNativeScrollbar.h" #if TARGET_CARBON @@ -100,7 +99,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsRadioButton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsListBox) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextAreaWidget) #endif -NS_GENERIC_FACTORY_CONSTRUCTOR(nsScrollbar) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) // used by Viewer? NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell) NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) @@ -141,14 +139,6 @@ static const nsModuleComponentInfo components[] = NS_FILEPICKER_CID, "@mozilla.org/filepicker;1", nsFilePickerConstructor }, - { "Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/horizscroll/mac;1", - nsScrollbarConstructor }, - { "Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/mac;1", - nsScrollbarConstructor }, { "Text Field", NS_TEXTFIELD_CID, "@mozilla.org/widgets/textwidget/mac;1", diff --git a/mozilla/widget/src/mac/nsWidgetSupport.cpp b/mozilla/widget/src/mac/nsWidgetSupport.cpp index 7050686db4d..5d3ff623f00 100644 --- a/mozilla/widget/src/mac/nsWidgetSupport.cpp +++ b/mozilla/widget/src/mac/nsWidgetSupport.cpp @@ -47,7 +47,6 @@ #include "nsIToolkit.h" #include "nsIWidget.h" #include "nsICheckButton.h" -#include "nsIScrollbar.h" #include "nsITextWidget.h" @@ -162,33 +161,6 @@ NS_CreateTextWidget(nsISupports* aParent, -NS_WIDGET nsresult -NS_CreateScrollBar(nsISupports* aParent, - nsIScrollbar* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) - aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent); - - nsIWidget* widget = nsnull; - if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) { - widget->Create(parent, aRect, aHandleEventFunction, NULL); - widget->Show(PR_TRUE); - NS_IF_RELEASE(widget); - } - else - { - NS_ERROR("Called QueryInterface on a non nsIWidget supported object"); - } - - if (aParent) - NS_IF_RELEASE(parent); - - return NS_OK; -} - extern NS_WIDGET nsresult NS_ShowWidget(nsISupports* aWidget, PRBool aShow) { diff --git a/mozilla/widget/src/os2/Makefile.in b/mozilla/widget/src/os2/Makefile.in index 2ff4019c5d8..6011e7c00b3 100644 --- a/mozilla/widget/src/os2/Makefile.in +++ b/mozilla/widget/src/os2/Makefile.in @@ -55,7 +55,6 @@ CPPSRCS = \ nsFilePicker.cpp \ nsFrameWindow.cpp \ nsLookAndFeel.cpp \ - nsScrollbar.cpp \ nsSound.cpp \ nsToolkit.cpp \ nsWidgetFactory.cpp \ diff --git a/mozilla/widget/src/os2/nsScrollbar.cpp b/mozilla/widget/src/os2/nsScrollbar.cpp deleted file mode 100644 index c4784e91b81..00000000000 --- a/mozilla/widget/src/os2/nsScrollbar.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is the Mozilla OS/2 libraries. - * - * The Initial Developer of the Original Code is John Fairhurst, - * . Portions created by John Fairhurst are - * Copyright (C) 1999 John Fairhurst. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsScrollbar.h" -#include "nsToolkit.h" -#include "nsGUIEvent.h" -#include "nsUnitConversion.h" - - -NS_IMPL_ADDREF(nsScrollbar) -NS_IMPL_RELEASE(nsScrollbar) - -//------------------------------------------------------------------------- -// -// nsScrollbar constructor -// -//------------------------------------------------------------------------- -nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWindow(), nsIScrollbar() -{ - mPositionFlag = aIsVertical ? SBS_VERT : SBS_HORZ; - mScaleFactor = 1.0f; - mLineIncrement = 0; - mThumbSize = 0; - mMaxRange = 0; -} - - -//------------------------------------------------------------------------- -// -// nsScrollbar destructor -// -//------------------------------------------------------------------------- -nsScrollbar::~nsScrollbar() -{ -} - - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kInsScrollbarIID, NS_ISCROLLBAR_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsScrollbarIID)) { - *aInstancePtr = (void*) ((nsIScrollbar*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// Define the range settings -// -//------------------------------------------------------------------------- -#define ROUND_D(u) NSToIntRound( (u) / mScaleFactor) -#define ROUND_U(u) (PRUint32) NSToIntRound( (u) * mScaleFactor) - -void nsScrollbar::SetThumbRange( PRUint32 aEndRange, PRUint32 aSize) -{ - // get current position - - PRUint32 pos; - GetPosition( pos); - - // set scale factor dependent on max range - if( aEndRange > 32000) - mScaleFactor = aEndRange / 32000.0f; - - // set new sizes - mMaxRange = aEndRange; - mThumbSize = aSize; - - // set range & pos - mOS2Toolkit->SendMsg( mWnd, SBM_SETSCROLLBAR, - MPFROMSHORT( ROUND_D(pos)), - MPFROM2SHORT( 0, ROUND_D(mMaxRange-mThumbSize))); - - // set thumb - mOS2Toolkit->SendMsg( mWnd, SBM_SETTHUMBSIZE, - MPFROM2SHORT( ROUND_D(mThumbSize), - ROUND_D(mMaxRange))); -} - -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - SetThumbRange( aEndRange, mThumbSize); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Return the range settings -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetMaxRange(PRUint32& aRange) -{ - aRange = ROUND_U(mMaxRange); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb position -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - mOS2Toolkit->SendMsg( mWnd, SBM_SETPOS, MPFROMSHORT(ROUND_D( aPos))); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the current thumb position. -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetPosition(PRUint32& aPosition) -{ - MRESULT rc = mOS2Toolkit->SendMsg( mWnd, SBM_QUERYPOS); - aPosition = ROUND_U( SHORT1FROMMR(rc)); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - SetThumbRange( mMaxRange, aSize); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - aSize = ROUND_U(mThumbSize); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aSize) -{ - mLineIncrement = NSToIntRound(aSize / mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aSize) -{ - aSize = (PRUint32)NSToIntRound(mLineIncrement * mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set all scrolling parameters -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - SetThumbRange( aMaxRange, aThumbSize); - SetPosition( aPosition); - SetLineIncrement( aLineIncrement); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Deal with scrollbar messages (actually implemented only in nsScrollbar) -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnScroll( ULONG msgid, MPARAM mp1, MPARAM mp2) -{ - PRBool result = PR_TRUE; - - USHORT scrollCode = SHORT2FROMMP(mp2); - int msg = 0; - - BOOL hasEvent = mEventListener != nsnull || mEventCallback != nsnull; - - PRUint32 newpos, li, ts; - - GetPosition( newpos); - GetLineIncrement( li); - GetThumbSize( ts); - - switch (scrollCode) { - - // scroll one line right or down - // SB_LINERIGHT and SB_LINEDOWN are actually the same value - //case SB_LINERIGHT: - case SB_LINEDOWN: - { - newpos += li; - msg = NS_SCROLLBAR_LINE_NEXT; - break; - } - - - // scroll one line left or up - //case SB_LINELEFT: - case SB_LINEUP: - { - if( newpos > li) newpos -= li; - else newpos = 0; - msg = NS_SCROLLBAR_LINE_PREV; - break; - } - - // Scrolls one page right or down - // case SB_PAGERIGHT: - case SB_PAGEDOWN: - { - newpos += (ts - li); - msg = NS_SCROLLBAR_PAGE_NEXT; - break; - } - - // Scrolls one page left or up. - //case SB_PAGELEFT: - case SB_PAGEUP: - { - PRUint32 delta; - delta = ts - li; - if( newpos > delta) newpos -= delta; - else newpos = 0; - msg = NS_SCROLLBAR_PAGE_PREV; - break; - } - - case SB_SLIDERTRACK: - { - newpos = ROUND_U( SHORT1FROMMP(mp2)); - msg = NS_SCROLLBAR_POS; - break; - } - } - - if( msg != 0) - { - // Ensure newpos is sensible - if( newpos > (mMaxRange - mThumbSize)) - newpos = mMaxRange - mThumbSize; - - // if there are listeners, give them a chance to alter newpos - if( mEventListener != nsnull || mEventCallback != nsnull) - { - nsScrollbarEvent event; - InitEvent( event, msg); - event.eventStructType = NS_SCROLLBAR_EVENT; - event.position = newpos; - DispatchWindowEvent( &event); - NS_RELEASE( event.widget); - - // Ensure position is still sensible - newpos = event.position; - if( newpos > (mMaxRange - mThumbSize)) - newpos = mMaxRange - mThumbSize; - } - - // Now move the scrollbar - SetPosition( newpos); - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// return the window class name and initialize the class if needed -// -//------------------------------------------------------------------------- -PCSZ nsScrollbar::WindowClass() -{ - /* Can't return (PSZ)WC_SCROLLBAR since we need to return a real string - * as some string manipulation might be done on the returned value. - * The return from WinQueryClassName for a WC_SCROLLBAR is "#8", so that is - * what we'll return. Value makes since since WC_SCROLLBAR is 0xFFFF0008. - */ - return WC_SCROLLBAR_STRING; -} - - -//------------------------------------------------------------------------- -// -// return window styles -// -//------------------------------------------------------------------------- -ULONG nsScrollbar::WindowStyle() -{ - return mPositionFlag | SBS_THUMBSIZE | SBS_AUTOTRACK | (BASE_CONTROL_STYLE & (~WS_TABSTOP)); -} - - -//------------------------------------------------------------------------- -// -// get position/dimensions -// -//------------------------------------------------------------------------- - -NS_METHOD nsScrollbar::GetBounds(nsRect &aRect) -{ - return nsWindow::GetBounds(aRect); -} - -PRBool nsScrollbar::OnPaint() -{ - return PR_FALSE; -} diff --git a/mozilla/widget/src/os2/nsScrollbar.h b/mozilla/widget/src/os2/nsScrollbar.h deleted file mode 100644 index ab4996ebc62..00000000000 --- a/mozilla/widget/src/os2/nsScrollbar.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is the Mozilla OS/2 libraries. - * - * The Initial Developer of the Original Code is John Fairhurst, - * . Portions created by John Fairhurst are - * Copyright (C) 1999 John Fairhurst. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsWindow.h" - -#include "nsIScrollbar.h" - -/** - * WC_SCROLLBAR wrapper, for NS_HORZSCROLLBAR_CID & NS_VERTSCROLLBAR_CID - */ - -class nsScrollbar : public nsWindow, - public nsIScrollbar -{ - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - virtual PRBool OnScroll( ULONG msgid, MPARAM mp1, MPARAM mp2); - NS_IMETHOD GetBounds(nsRect &aRect); - - protected: - // Creation hooks - virtual PCSZ WindowClass(); - virtual ULONG WindowStyle(); - virtual PRBool OnPaint(); - - private: - void SetThumbRange( PRUint32 aEndRange, PRUint32 aSize); - ULONG mPositionFlag; - int mLineIncrement; - float mScaleFactor; - PRUint32 mThumbSize; // cache XP thumbsize - PRUint32 mMaxRange; // cache XP maxrange -}; - -#endif diff --git a/mozilla/widget/src/os2/nsWidgetFactory.cpp b/mozilla/widget/src/os2/nsWidgetFactory.cpp index 2d3c2a4fdf2..5e90b654763 100644 --- a/mozilla/widget/src/os2/nsWidgetFactory.cpp +++ b/mozilla/widget/src/os2/nsWidgetFactory.cpp @@ -53,7 +53,6 @@ #include "nsILocalFile.h" #include "nsFilePicker.h" #include "nsLookAndFeel.h" -#include "nsScrollbar.h" #include "nsSound.h" #include "nsToolkit.h" @@ -116,65 +115,6 @@ static NS_IMETHODIMP nsAppShellConstructor (nsISupports *aOuter, REFNSIID aIID, return rv; } -static NS_IMETHODIMP nsHorizScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_FALSE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - -static NS_IMETHODIMP nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_TRUE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - - // component definition, will be exported using XPCOM static const nsModuleComponentInfo components[] = { @@ -210,14 +150,6 @@ static const nsModuleComponentInfo components[] = NS_LOOKANDFEEL_CID, "@mozilla.org/widget/lookandfeel/os2;1", nsLookAndFeelConstructor }, - { "OS/2 Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widget/horizscroll/os2;1", - nsHorizScrollbarConstructor }, - { "OS/2 Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widget/vertscroll/os2;1", - nsVertScrollbarConstructor }, { "OS/2 Sound", NS_SOUND_CID, "@mozilla.org/sound;1", diff --git a/mozilla/widget/src/photon/Makefile.in b/mozilla/widget/src/photon/Makefile.in index 93526439502..33e8261fe5c 100644 --- a/mozilla/widget/src/photon/Makefile.in +++ b/mozilla/widget/src/photon/Makefile.in @@ -32,7 +32,7 @@ EXPORT_LIBRARY = 1 IS_COMPONENT = 1 MODULE_NAME = nsWidgetPhModule REQUIRES = xpcom \ - string \ + string \ appshell \ gfx \ pref \ @@ -53,7 +53,6 @@ CPPSRCS = \ nsAppShell.cpp \ nsClipboard.cpp \ nsLookAndFeel.cpp \ - nsScrollbar.cpp \ nsToolkit.cpp \ nsWidget.cpp \ nsWidgetFactory.cpp \ diff --git a/mozilla/widget/src/photon/nsScrollbar.cpp b/mozilla/widget/src/photon/nsScrollbar.cpp deleted file mode 100644 index 8ed527c4ff0..00000000000 --- a/mozilla/widget/src/photon/nsScrollbar.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include "nsPhWidgetLog.h" - -#include "nsScrollbar.h" -#include "nsToolkit.h" -#include "nsGUIEvent.h" -#include "nsUnitConversion.h" - - -NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWidget) -NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWidget) -NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget) - -//------------------------------------------------------------------------- -// -// nsScrollbar constructor -// -//------------------------------------------------------------------------- -nsScrollbar::nsScrollbar (PRBool aIsVertical):nsWidget (), nsIScrollbar () -{ - NS_INIT_ISUPPORTS(); - - mOrientation = (aIsVertical) ? Pt_VERTICAL : Pt_HORIZONTAL; -} - -//------------------------------------------------------------------------- -// -// nsScrollbar destructor -// -//------------------------------------------------------------------------- -nsScrollbar::~nsScrollbar () -{ -} - -//------------------------------------------------------------------------- -// -// Create the native scrollbar widget -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::CreateNative (PtWidget_t * parentWindow) -{ - nsresult res = NS_ERROR_FAILURE; - PhPoint_t pos; - PhDim_t dim; - PtArg_t arg[5]; - - pos.x = mBounds.x; - pos.y = mBounds.y; - dim.w = mBounds.width; - dim.h = mBounds.height; - - PtSetArg( &arg[0], Pt_ARG_ORIENTATION, mOrientation, 0 ); - PtSetArg( &arg[1], Pt_ARG_POS, &pos, 0 ); - PtSetArg( &arg[2], Pt_ARG_DIM, &dim, 0 ); - PtSetArg( &arg[3], Pt_ARG_FLAGS, 0, Pt_GETS_FOCUS); - PtSetArg( &arg[4], Pt_ARG_BASIC_FLAGS, Pt_ALL_INLINES, ~0 ); - mWidget = PtCreateWidget( PtScrollbar, parentWindow, 5, arg ); - if( mWidget ) - { - res = NS_OK; - - /* Add an Activate Callback */ - PtAddCallback(mWidget, Pt_CB_SCROLL_MOVE, handle_scroll_move_event, this); - } - - return res; -} - - - -//------------------------------------------------------------------------- -// -// Define the range settings -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetMaxRange (PRUint32 aEndRange) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) { - PtArg_t arg; - PtSetArg( &arg, Pt_ARG_MAXIMUM, aEndRange, 0 ); - if( PtSetResources( mWidget, 1, &arg ) == 0 ) - res = NS_OK; - } - return res; -} - -//------------------------------------------------------------------------- -// -// Return the range settings -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetMaxRange (PRUint32 & aMaxRange) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) { - PtArg_t arg; - int *max; - - PtSetArg( &arg, Pt_ARG_MAXIMUM, &max, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - aMaxRange = *max; - res = NS_OK; - } - } - return res; -} - -//------------------------------------------------------------------------- -// -// Set the thumb position -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetPosition (PRUint32 aPos) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) { - PtArg_t arg; - - PtSetArg( &arg, Pt_ARG_GAUGE_VALUE, aPos, 0); - if (PtSetResources(mWidget, 1, &arg) == 0) - res = NS_OK; - } - return res; -} - -//------------------------------------------------------------------------- -// -// Get the current thumb position. -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetPosition (PRUint32 & aPos) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) - { - PtArg_t arg; - int *pos; - PtSetArg(&arg, Pt_ARG_GAUGE_VALUE, &pos, 0); - if (PtGetResources(mWidget, 1, &arg) == 0) { - aPos = (PRUint32)*pos; - res = NS_OK; - } - } - return res; -} - -//------------------------------------------------------------------------- -// -// Set the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetThumbSize (PRUint32 aSize) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) - { - PtArg_t arg; - - PtSetArg( &arg, Pt_ARG_SLIDER_SIZE, aSize, 0 ); - if( PtSetResources( mWidget, 1, &arg ) == 0 ) - { - res = NS_OK; - } - } - - return res; -} - -//------------------------------------------------------------------------- -// -// Get the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetThumbSize (PRUint32 & aThumbSize) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) - { - PtArg_t arg; - int *size; - - PtSetArg( &arg, Pt_ARG_SLIDER_SIZE, &size, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - aThumbSize = *size; - res = NS_OK; - } - } - - return res; -} - -//------------------------------------------------------------------------- -// -// Set the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) - { - PtArg_t arg; - - PtSetArg( &arg, Pt_ARG_INCREMENT, aLineIncrement, 0 ); - if( PtSetResources( mWidget, 1, &arg ) == 0 ) - { - res = NS_OK; - } - } - - return res; -} - - -//------------------------------------------------------------------------- -// -// Get the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetLineIncrement (PRUint32 & aLineInc) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) - { - PtArg_t arg; - int *incr; - - PtSetArg( &arg, Pt_ARG_INCREMENT, &incr, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - aLineInc = *incr; - res = NS_OK; - } - } - - return res; -} - - -//------------------------------------------------------------------------- -// -// Set all scrolling parameters -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - nsresult res = NS_ERROR_FAILURE; - - if( mWidget ) { - PtArg_t arg[4]; - - PtSetArg( &arg[0], Pt_ARG_MAXIMUM , aMaxRange, 0 ); - PtSetArg( &arg[1], Pt_ARG_SLIDER_SIZE , aThumbSize, 0 ); - PtSetArg( &arg[2], Pt_ARG_INCREMENT, aLineIncrement, 0 ); - PtSetArg( &arg[3], Pt_ARG_GAUGE_VALUE, aPosition, 0); - if( PtSetResources( mWidget, 4, arg ) == 0 ) - res = NS_OK; - } - return res; -} - -//------------------------------------------------------------------------- -// -// Deal with scrollbar messages (actually implemented only in nsScrollbar) -// --- This funciton is not necessary ---- -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnScroll (nsScrollbarEvent & aEvent, PRUint32 cPos) -{ - PRBool result = PR_TRUE; - - if (mEventCallback) { - aEvent.position = cPos; - result = ConvertStatus((*mEventCallback)(&aEvent)); - } - return result; -} - -//------------------------------------------------------------------------- -// -// -// -//------------------------------------------------------------------------- -int nsScrollbar::handle_scroll_move_event (PtWidget_t *aWidget, void *aData, PtCallbackInfo_t *aCbinfo ) -{ - nsScrollbar *me = (nsScrollbar *) aData; - nsScrollbarEvent scroll_event; - PRUint32 thePos = 0; - PtScrollbarCallback_t *theScrollbarCallback = (PtScrollbarCallback_t *) aCbinfo->cbdata; - - scroll_event.message = NS_SCROLLBAR_POS; - scroll_event.widget = (nsWidget *) me; - scroll_event.eventStructType = NS_SCROLLBAR_EVENT; - thePos = theScrollbarCallback->position; - - switch (theScrollbarCallback->action) { - case Pt_SCROLL_DECREMENT: - scroll_event.message = NS_SCROLLBAR_LINE_PREV; - break; - case Pt_SCROLL_INCREMENT: - scroll_event.message = NS_SCROLLBAR_LINE_NEXT; - break; - case Pt_SCROLL_PAGE_INCREMENT: - scroll_event.message = NS_SCROLLBAR_PAGE_NEXT; - break; - case Pt_SCROLL_PAGE_DECREMENT: - scroll_event.message = NS_SCROLLBAR_PAGE_PREV; - break; - case NS_SCROLLBAR_POS: - scroll_event.message = NS_SCROLLBAR_POS; - break; - default: - break; - } - me->OnScroll(scroll_event, thePos); - return (Pt_CONTINUE); -} diff --git a/mozilla/widget/src/photon/nsScrollbar.h b/mozilla/widget/src/photon/nsScrollbar.h deleted file mode 100644 index ba4d69f9dc2..00000000000 --- a/mozilla/widget/src/photon/nsScrollbar.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsWidget.h" -#include "nsIScrollbar.h" - -/** - * Native Photon scrollbar wrapper. - */ - -class nsScrollbar : public nsWidget, - public nsIScrollbar -{ - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - - virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); - -protected: - NS_IMETHOD CreateNative(PtWidget_t *parentWindow); - static int handle_scroll_move_event (PtWidget_t *aWidget, void *aData, PtCallbackInfo_t *aCbinfo ); - -private: - int mOrientation; - -}; - -#endif // nsScrollbar_ diff --git a/mozilla/widget/src/photon/nsWidgetFactory.cpp b/mozilla/widget/src/photon/nsWidgetFactory.cpp index 01c5c72e419..52ca216aeb5 100644 --- a/mozilla/widget/src/photon/nsWidgetFactory.cpp +++ b/mozilla/widget/src/photon/nsWidgetFactory.cpp @@ -50,7 +50,6 @@ #include "nsClipboard.h" #include "nsHTMLFormatConverter.h" #include "nsDragService.h" -#include "nsScrollbar.h" #include "nsSound.h" #ifdef IBMBIDI #include "nsBidiKeyboard.h" @@ -76,64 +75,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) #endif -static nsresult nsHorizScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_FALSE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - -static nsresult nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( NULL == aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; - } - *aResult = NULL; - if (NULL != aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_TRUE); - if (inst == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - static nsModuleComponentInfo components[] = { { "Ph nsWindow", @@ -144,14 +85,6 @@ static nsModuleComponentInfo components[] = NS_CHILD_CID, "@mozilla.org/widgets/child_window/ph;1", ChildWindowConstructor }, - { "Ph Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/horizscroll/ph;1", - nsHorizScrollbarConstructor }, - { "Ph Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/ph;1", - nsVertScrollbarConstructor }, { "Ph AppShell", NS_APPSHELL_CID, "@mozilla.org/widget/appshell/ph;1", diff --git a/mozilla/widget/src/support/nsWidgetSupport.cpp b/mozilla/widget/src/support/nsWidgetSupport.cpp index 02928c3ac4e..efba7ea3b66 100644 --- a/mozilla/widget/src/support/nsWidgetSupport.cpp +++ b/mozilla/widget/src/support/nsWidgetSupport.cpp @@ -48,7 +48,6 @@ #include "nsIToolkit.h" #include "nsIWidget.h" #include "nsICheckButton.h" -#include "nsIScrollbar.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -58,7 +57,6 @@ static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID); static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); -static NS_DEFINE_IID(kIScrollBarIID, NS_ISCROLLBAR_IID); #ifdef XP_MAC #define WIDGET_SUPPORT_EXPORT(returnType) PR_PUBLIC_API(returnType) @@ -174,33 +172,6 @@ NS_CreateTextWidget(nsISupports* aParent, -WIDGET_SUPPORT_EXPORT(nsresult) -NS_CreateScrollBar(nsISupports* aParent, - nsIScrollbar* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) - aParent->QueryInterface(kIWidgetIID,(void**)&parent); - - nsIWidget* widget = nsnull; - if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Create(parent, aRect, aHandleEventFunction, NULL); - widget->Show(PR_TRUE); - NS_IF_RELEASE(widget); - } - else - { - NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object"); - } - - if (aParent) - NS_IF_RELEASE(parent); - - return NS_OK; -} - WIDGET_SUPPORT_EXPORT(nsresult) NS_ShowWidget(nsISupports* aWidget, PRBool aShow) { diff --git a/mozilla/widget/src/support/nsWidgetSupport.h b/mozilla/widget/src/support/nsWidgetSupport.h index a44e02564e9..b14f73e3849 100644 --- a/mozilla/widget/src/support/nsWidgetSupport.h +++ b/mozilla/widget/src/support/nsWidgetSupport.h @@ -53,7 +53,6 @@ class nsIMouseListener; class nsIToolkit; class nsIWidget; class nsICheckButton; -class nsIScrollbar; class nsITooltipWidget; class nsITextWidget; @@ -97,13 +96,6 @@ NS_CreateTooltipWidget(nsISupports* aParent, const nsFont* aFont = nsnull); -extern nsresult -NS_CreateScrollBar(nsISupports* aParent, - nsIScrollbar* aWidget, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction); - - extern nsresult NS_ShowWidget(nsISupports* aWidget, PRBool aShow); diff --git a/mozilla/widget/src/windows/Makefile.in b/mozilla/widget/src/windows/Makefile.in index 4567cd03572..9a083c79cf2 100644 --- a/mozilla/widget/src/windows/Makefile.in +++ b/mozilla/widget/src/windows/Makefile.in @@ -61,7 +61,6 @@ CPPSRCS = \ nsClipboard.cpp \ nsWindow.cpp \ nsFilePicker.cpp \ - nsScrollbar.cpp \ nsAppShell.cpp \ nsLookAndFeel.cpp \ nsToolkit.cpp \ diff --git a/mozilla/widget/src/windows/nsScrollbar.cpp b/mozilla/widget/src/windows/nsScrollbar.cpp deleted file mode 100644 index e007fd07114..00000000000 --- a/mozilla/widget/src/windows/nsScrollbar.cpp +++ /dev/null @@ -1,563 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsScrollbar.h" -#include "nsToolkit.h" -#include "nsGUIEvent.h" -#include -#include "nsUnitConversion.h" - - -NS_IMPL_ADDREF(nsScrollbar) -NS_IMPL_RELEASE(nsScrollbar) - -nsScrollbar::InitializationState nsScrollbar::sScrollbarInited = nsScrollbar::eNotInitialized; - -//------------------------------------------------------------------------- -// -// nsScrollbar constructor -// -//------------------------------------------------------------------------- -nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWindow(), nsIScrollbar() -{ - mPositionFlag = (aIsVertical) ? SBS_VERT : SBS_HORZ; - mScaleFactor = 1.0f; - mLineIncrement = 0; - mBackground = ::GetSysColor(COLOR_SCROLLBAR); - - //prevent resource leaks.. - if (mBrush) - ::DeleteObject(mBrush); - - mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground)); -} - - -//------------------------------------------------------------------------- -// -// nsScrollbar destructor -// -//------------------------------------------------------------------------- -nsScrollbar::~nsScrollbar() -{ -} - - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kInsScrollbarIID, NS_ISCROLLBAR_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsScrollbarIID)) { - *aInstancePtr = (void*) ((nsIScrollbar*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// Define the range settings -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - if (aEndRange > 32767) - mScaleFactor = aEndRange / 32767.0f; - if (mWnd) { - VERIFY(::SetScrollRange(mWnd, SB_CTL, 0, NSToIntRound(aEndRange / mScaleFactor), TRUE)); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Return the range settings -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetMaxRange(PRUint32& aRange) -{ - int startRange, endRange; - if (mWnd) { - VERIFY(::GetScrollRange(mWnd, SB_CTL, &startRange, &endRange)); - } - aRange = (PRUint32)NSToIntRound(endRange * mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb position -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - ::SetScrollPos(mWnd, SB_CTL, NSToIntRound(aPos / mScaleFactor), TRUE); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the current thumb position. -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetPosition(PRUint32& aPosition) -{ - aPosition = (PRUint32)NSToIntRound(::GetScrollPos(mWnd, SB_CTL) * mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - if (mWnd) { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - si.nPage = NSToIntRound(aSize / mScaleFactor); - ::SetScrollInfo(mWnd, SB_CTL, &si, TRUE); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - if (mWnd) { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si)); - aSize = (PRUint32)NSToIntRound(si.nPage * mScaleFactor); - } - else - { - aSize = 0; - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aSize) -{ - mLineIncrement = NSToIntRound(aSize / mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aSize) -{ - aSize = (PRUint32)NSToIntRound(mLineIncrement * mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set all scrolling parameters -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - if (aMaxRange > 32767) - mScaleFactor = aMaxRange / 32767.0f; - - if (mWnd) { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; - si.nPage = NSToIntRound(aThumbSize / mScaleFactor); - si.nPos = NSToIntRound(aPosition / mScaleFactor); - si.nMin = 0; - si.nMax = NSToIntRound(aMaxRange / mScaleFactor); - ::SetScrollInfo(mWnd, SB_CTL, &si, TRUE); - } - - mLineIncrement = NSToIntRound(aLineIncrement / mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// paint message. Don't send the paint out -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnPaint() -{ - return PR_FALSE; -} - - -PRBool nsScrollbar::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - - -//------------------------------------------------------------------------- -// -// Deal with scrollbar messages (actually implemented only in nsScrollbar) -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnScroll(UINT scrollCode, int cPos) -{ - PRBool result = PR_TRUE; - int newPosition; - - switch (scrollCode) { - - // scroll one line right or down - // SB_LINERIGHT and SB_LINEDOWN are actually the same value - //case SB_LINERIGHT: - case SB_LINEDOWN: - { - newPosition = ::GetScrollPos(mWnd, SB_CTL) + mLineIncrement; - - PRUint32 range; - PRUint32 size; - GetMaxRange(range); - GetThumbSize(size); - PRUint32 max = range - size; - - if (newPosition > (int)max) - newPosition = (int)max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_LINE_NEXT; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - - - // scroll one line left or up - //case SB_LINELEFT: - case SB_LINEUP: - { - newPosition = ::GetScrollPos(mWnd, SB_CTL) - mLineIncrement; - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the decrement - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_LINE_PREV; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - - // Scrolls one page right or down - // case SB_PAGERIGHT: - case SB_PAGEDOWN: - { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si)); - - newPosition = ::GetScrollPos(mWnd, SB_CTL) + si.nPage; - - PRUint32 range; - PRUint32 size; - GetMaxRange(range); - GetThumbSize(size); - PRUint32 max = range - size; - - - if (newPosition > (int)max) - newPosition = (int)max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_PAGE_NEXT; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor);; - - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - - // Scrolls one page left or up. - //case SB_PAGELEFT: - case SB_PAGEUP: - { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si)); - - newPosition = ::GetScrollPos(mWnd, SB_CTL) - si.nPage; - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_PAGE_PREV; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition - 10, TRUE); - - break; - } - - // Scrolls to the absolute position. The current position is specified by - // the cPos parameter. - case SB_THUMBPOSITION: - case SB_THUMBTRACK: - { - newPosition = cPos; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_POS; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// return the window class name and initialize the class if needed -// -//------------------------------------------------------------------------- -LPCTSTR nsScrollbar::WindowClass() -{ - static const LPCTSTR subclassedScrollBar = "MozillaScrollBar"; - static const LPCTSTR classicScrollBarClass = "SCROLLBAR"; - - if (eNotInitialized == sScrollbarInited) { - sScrollbarInited = eInitFailed; - // get the class info for scroll bars - WNDCLASS scrollBarClass; - if (GetClassInfo(nsToolkit::mDllInstance, - classicScrollBarClass, &scrollBarClass)) { - // modify the class name, leave everything else as it is - scrollBarClass.lpszClassName = subclassedScrollBar; - if (::RegisterClassA(&scrollBarClass)) - sScrollbarInited = eInitSucceeded; - } - } - - if (eInitSucceeded == sScrollbarInited) - return subclassedScrollBar; - return classicScrollBarClass; -} - - -//------------------------------------------------------------------------- -// -// return window styles -// -//------------------------------------------------------------------------- -DWORD nsScrollbar::WindowStyle() -{ - return mPositionFlag | WS_CHILD | WS_CLIPSIBLINGS; -} - - -//------------------------------------------------------------------------- -// -// return window extended styles -// -//------------------------------------------------------------------------- -DWORD nsScrollbar::WindowExStyle() -{ - return 0; -} - - -//------------------------------------------------------------------------- -// -// get position/dimensions -// -//------------------------------------------------------------------------- - -NS_METHOD nsScrollbar::GetBounds(nsRect &aRect) -{ - return nsWindow::GetBounds(aRect); -} - - -//------------------------------------------------------------------------- -// -// return the window class name and initialize the class if needed -// -//------------------------------------------------------------------------- -LPCWSTR nsScrollbar::WindowClassW() -{ - static const LPCWSTR subclassedScrollBar = L"MozillaScrollBar"; - static const LPCWSTR classicScrollBarClass = L"SCROLLBAR"; - - if (eNotInitialized == sScrollbarInited) { - sScrollbarInited = eInitFailed; - // get the class info for scroll bars - WNDCLASSW scrollBarClass; - if (GetClassInfoW(nsToolkit::mDllInstance, - classicScrollBarClass, &scrollBarClass)) { - // modify the class name, leave everything else as it is - scrollBarClass.lpszClassName = subclassedScrollBar; - if (::RegisterClassW(&scrollBarClass)) - sScrollbarInited = eInitSucceeded; - } - } - - if (eInitSucceeded == sScrollbarInited) - return subclassedScrollBar; - return classicScrollBarClass; -} - diff --git a/mozilla/widget/src/windows/nsScrollbar.h b/mozilla/widget/src/windows/nsScrollbar.h deleted file mode 100644 index 653e7274b4d..00000000000 --- a/mozilla/widget/src/windows/nsScrollbar.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsdefs.h" -#include "nsWindow.h" -#include "nsSwitchToUIThread.h" - -#include "nsIScrollbar.h" - -/** - * Native WIN32 scrollbar wrapper. - */ - -class nsScrollbar : public nsWindow, - public nsIScrollbar -{ - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - virtual PRBool OnPaint(); - virtual PRBool OnScroll(UINT scrollCode, int cPos); - virtual PRBool OnResize(nsRect &aWindowRect); - NS_IMETHOD GetBounds(nsRect &aRect); - -protected: - - virtual LPCTSTR WindowClass(); - virtual LPCWSTR WindowClassW(); - virtual DWORD WindowStyle(); - virtual DWORD WindowExStyle(); - -private: - DWORD mPositionFlag; - int mLineIncrement; - float mScaleFactor; - - enum InitializationState - { - eNotInitialized, - eInitFailed, - eInitSucceeded - }; - static InitializationState sScrollbarInited; -}; - -#endif // nsButton_h__ diff --git a/mozilla/widget/src/xlib/Makefile.in b/mozilla/widget/src/xlib/Makefile.in index 47560785d15..bc7f72c3e9e 100644 --- a/mozilla/widget/src/xlib/Makefile.in +++ b/mozilla/widget/src/xlib/Makefile.in @@ -61,7 +61,6 @@ CPPSRCS = \ nsKeyCode.cpp \ nsLabel.cpp \ nsLookAndFeel.cpp \ - nsScrollBar.cpp \ nsSound.cpp \ nsTextHelper.cpp \ nsTextWidget.cpp \ diff --git a/mozilla/widget/src/xlib/nsScrollBar.cpp b/mozilla/widget/src/xlib/nsScrollBar.cpp deleted file mode 100644 index 8900e269b5d..00000000000 --- a/mozilla/widget/src/xlib/nsScrollBar.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Tim Copperfield - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsScrollBar.h" -#include "nsGfxCIID.h" -#include "xlibrgb.h" - -#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) -#define NS_SCROLLBAR_MIN 8 - -NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWidget) -NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWidget) - // XXX not INHERITED? -NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget) - -PRLogModuleInfo *XlibScrollbarLM = PR_NewLogModule("XlibScrollbar"); - -nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget() -{ - mMaxRange = 0; - mPosition = 0; - mThumbSize = 0; - mXScale = 0.0; - mYScale = 0.0; - mLineIncrement = 1; - mIsVertical = aIsVertical; - mBackground = NS_RGB(100,100,100); - mBackgroundPixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, mBackground); - mBorderPixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, mBackground); - mBar = 0; - mBarBounds.x = mBarBounds.y = mBarBounds.width = mBarBounds.height = 0; -}; - -nsScrollbar::~nsScrollbar() -{ -} - -/* Create scrollbar widget */ -void nsScrollbar::CreateNative(Window aParent, nsRect aRect) -{ - XSetWindowAttributes attr; - unsigned long attr_mask; - - // on a window resize, we don't want to window contents to - // be discarded... - attr.bit_gravity = NorthWestGravity; - // make sure that we listen for events - attr.event_mask = StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | FocusChangeMask | VisibilityChangeMask; - // set the default background color and border to that awful gray - attr.background_pixel = mBackgroundPixel; - attr.border_pixel = mBorderPixel; - // set the colormap - attr.colormap = xxlib_rgb_get_cmap(mXlibRgbHandle); - // here's what's in the struct - attr_mask = CWBitGravity | CWEventMask | CWBackPixel | CWBorderPixel; - // check to see if there was actually a colormap. - if (attr.colormap) - attr_mask |= CWColormap; - - CreateNativeWindow(aParent, mBounds, attr, attr_mask); - // set up the scrolling bar. - attr.event_mask = Button1MotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | FocusChangeMask | VisibilityChangeMask; - attr.background_pixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, NS_RGB(192,192,192)); - attr.border_pixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, NS_RGB(100,100,100)); - // set up the size - CalcBarBounds(); - mBar = XCreateWindow(mDisplay, - mBaseWindow, - mBarBounds.x, mBarBounds.y, - mBarBounds.width, mBarBounds.height, - 2, // border width - mDepth, - InputOutput, - mVisual, - attr_mask, - &attr); - XSetWindowBackgroundPixmap(mDisplay, mBar, None); - AddWindowCallback(mBar, this); - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::CreateNative created window 0x%lx with bar 0x%lx\n", - mBaseWindow, mBar)); -} - -void nsScrollbar::DestroyNative(void) -{ - // override since we have two native widgets - if (mBar) { - DestroyNativeChildren(mDisplay, mBar); - - XDestroyWindow(mDisplay, mBar); - DeleteWindowCallback(mBar); - mBar = 0; - } - if (mBaseWindow) { - nsWidget::DestroyNative(); - mBaseWindow = 0; - } -} - -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::SetMaxRange()\n")); - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("Max Range set to %d\n", aEndRange)); - mMaxRange = aEndRange; - CalcBarBounds(); - LayoutBar(); - return NS_OK; -} - -PRUint32 nsScrollbar::GetMaxRange(PRUint32& aRange) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::GetMaxRange()\n")); - aRange = mMaxRange; - return NS_OK; -} - -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::SetPosition()\n")); - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("Scroll to %d\n", aPos)); - mPosition = CLAMP(aPos, 0, mMaxRange); - CalcBarBounds(); - LayoutBar(); - return NS_OK; -} - -PRUint32 nsScrollbar::GetPosition(PRUint32& aPosition) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::GetPosition()\n")); - aPosition = mPosition; - return NS_OK; -} - -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::SetThumbSize()\n")); - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("Thumb size set to %d\n", aSize)); - - mThumbSize = aSize; - CalcBarBounds(); - LayoutBar(); - return NS_OK; -} - -NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::GetThumbSize()\n")); - - aSize = mThumbSize; - return NS_OK; -} - -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aSize) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::SetLineIncrement()\n")); - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("Set Line Increment to %d\n", aSize)); - - mLineIncrement = aSize; - CalcBarBounds(); - LayoutBar(); - return NS_OK; -} - -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aSize) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::GetLineIncrement()\n")); - - aSize = mLineIncrement; - return NS_OK; -} - -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::SetParameters()\n")); - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("MaxRange = %d ThumbSize = %d aPosition = %d LineIncrement = %d\n", - aMaxRange, aThumbSize, aPosition, aLineIncrement)); - - SetMaxRange(aMaxRange); - SetThumbSize(aThumbSize); - SetPosition(aPosition); - SetLineIncrement(aLineIncrement); - CalcBarBounds(); - LayoutBar(); - return NS_OK; -} - -PRBool nsScrollbar::OnScroll(PRUint32 scrollCode, int cPos) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::OnScroll\n")); - - PRBool result = PR_FALSE; - switch (scrollCode) { - case NS_SCROLLBAR_PAGE_NEXT: - result = NextPage(); - break; - case NS_SCROLLBAR_PAGE_PREV: - result = PrevPage(); - break; - case NS_SCROLLBAR_POS: - if (mIsVertical == PR_TRUE) - result = SetPosition(cPos); - else - result = SetPosition(cPos); - break; - default: - break; - } - return result; -} - -PRBool nsScrollbar::OnResize(nsSizeEvent &event) -{ - PRBool result; - - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::OnResize\n")); - - nsWidget::OnResize(event); - CalcBarBounds(); - LayoutBar(); - result = PR_FALSE; - return result; -} - -PRBool nsScrollbar::DispatchMouseEvent(nsMouseEvent &aEvent) -{ - PRInt32 real; - - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::DispatchMouseEvent\n")); - - /* that calculation is kind of screwed, but better than the original */ - switch (aEvent.message) { - case NS_MOUSE_MIDDLE_BUTTON_DOWN: - if (mIsVertical == PR_TRUE) { - real = (PRInt32)((float)(PR_MAX(0, aEvent.point.y - ((PRInt32)PR_MAX((mThumbSize * mYScale), NS_SCROLLBAR_MIN) / 2))) / mYScale); - OnScroll(NS_SCROLLBAR_POS, real); - } else { - real = (PRInt32)((float)(PR_MAX(0, aEvent.point.x - ((PRInt32)PR_MAX((mThumbSize * mXScale), NS_SCROLLBAR_MIN) / 2))) / mXScale); - OnScroll(NS_SCROLLBAR_POS, real); - } - break; - - case NS_MOUSE_LEFT_BUTTON_DOWN: - if (mIsVertical == PR_TRUE) { - if (aEvent.point.y < mBarBounds.y) - OnScroll(NS_SCROLLBAR_PAGE_PREV, 0); - else if (aEvent.point.y > (mBarBounds.y + mBarBounds.height)) - OnScroll(NS_SCROLLBAR_PAGE_NEXT, 0); - } else { /* !vertical */ - if (aEvent.point.x < mBarBounds.x) - OnScroll(NS_SCROLLBAR_PAGE_PREV, 0); - else if (aEvent.point.x > (mBarBounds.x + mBarBounds.width)) - OnScroll(NS_SCROLLBAR_PAGE_NEXT, 0); - } - break; - default: - break; -} - return SendEvent(NS_SCROLLBAR_POS); - } - -NS_IMETHODIMP nsScrollbar::Show(PRBool bState) -{ - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::Show(): %s\n", - (bState == PR_TRUE) ? "true" : "false")); - nsWidget::Show(bState); - if (bState) { - if (mBar) { - XMapWindow(mDisplay, mBar); - } - CalcBarBounds(); - LayoutBar(); - } - return NS_OK; -} - -NS_IMETHODIMP nsScrollbar::Resize(PRInt32 aWidth, - PRInt32 aHeight, - PRBool aRepaint) -{ - nsWidget::Resize(aWidth, aHeight, aRepaint); - CalcBarBounds(); - LayoutBar(); - return NS_OK; -} - -NS_IMETHODIMP nsScrollbar::Resize(PRInt32 aX, - PRInt32 aY, - PRInt32 aWidth, - PRInt32 aHeight, - PRBool aRepaint) -{ - nsWidget::Resize(aX, aY, aWidth, aHeight, aRepaint); - CalcBarBounds(); - LayoutBar(); - return NS_OK; -} - -nsresult nsScrollbar::NextPage(void) -{ - PRUint32 max; - nsresult result = PR_FALSE; - - // change it locally. - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::NextPage(): maxrange is %d thumb is %d position is %d\n", mMaxRange, mThumbSize, mPosition)); - max = mMaxRange - mThumbSize; - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::NextPage(): max is %d\n", max)); - mPosition += mThumbSize; - if (mPosition > max) - mPosition = max; - PR_LOG(XlibScrollbarLM, PR_LOG_DEBUG, ("nsScrollbar::NextPage(): new position is %d\n", mPosition)); - - result = SendEvent(NS_SCROLLBAR_POS); - CalcBarBounds(); - LayoutBar(); - return result; -} - -nsresult nsScrollbar::PrevPage(void) -{ - nsresult result = PR_FALSE; - - // check to make sure we don't go backwards - if (mThumbSize > mPosition) { - mPosition = 0; - } else { - mPosition -= mThumbSize; - } - result = SendEvent(NS_SCROLLBAR_POS); - CalcBarBounds(); - LayoutBar(); - return result; -} - -void nsScrollbar::CalcBarBounds(void) -{ - PRUint32 bar_start; - PRUint32 bar_end; - - if (mMaxRange == 0) { - bar_start = 0; - bar_end = 0; - mXScale = 0.0; - mYScale = 0.0; - } else { - if (mIsVertical == PR_TRUE) { - mYScale = (float)mRequestedSize.height / (float)mMaxRange; - bar_start = (PRUint32)((float)mPosition * mYScale); - bar_end = (PRUint32)((float)mThumbSize * mYScale); - bar_start = CLAMP(bar_start, 0, (PRUint32)(mRequestedSize.height)); - } else { - mXScale = (float)mRequestedSize.width / (float)mMaxRange; - bar_start = (PRUint32)((float)mPosition * mXScale); - bar_end = (PRUint32)((float)mThumbSize * mXScale); - bar_start = CLAMP(bar_start, 0, (PRUint32)(mRequestedSize.width)); - } - } - bar_end = PR_MAX(bar_end, NS_SCROLLBAR_MIN); - - if (mIsVertical == PR_TRUE) { - mBarBounds.x = 0; - mBarBounds.y = bar_start; - mBarBounds.width = mRequestedSize.width - 4; - mBarBounds.height = bar_end; - } else { - mBarBounds.x = bar_start; - mBarBounds.y = 0; - mBarBounds.width = bar_end; - mBarBounds.height = mRequestedSize.height - 4; - } - - if (mBarBounds.height == 0) - mBarBounds.height = 1; - - if (mBarBounds.width == 0) - mBarBounds.width = 1; -} - -void nsScrollbar::LayoutBar(void) -{ - /* Workaround for bug 77344. I am not sure whether this is mandatory or not. */ - if (mDisplay) - XMoveResizeWindow(mDisplay, mBar, - mBarBounds.x, mBarBounds.y, - mBarBounds.width, mBarBounds.height); -} - -NS_IMETHODIMP nsScrollbar::Move(PRInt32 aX, PRInt32 aY) -{ - return nsWidget::Move(aX, aY); -} - -PRBool nsScrollbar::SendEvent(PRUint32 message) -{ - PRBool result = PR_FALSE; - // send the event - if (mEventCallback) { - nsScrollbarEvent sevent; - sevent.message = message; - sevent.widget = (nsWidget *)this; - sevent.eventStructType = NS_SCROLLBAR_EVENT; - sevent.position = (mPosition); - // send the event - result = ConvertStatus((*mEventCallback) (&sevent)); - // the gtk code indicates that the callback can - // modify the position. how odd. - mPosition = sevent.position; - } - return result; -} diff --git a/mozilla/widget/src/xlib/nsScrollBar.h b/mozilla/widget/src/xlib/nsScrollBar.h deleted file mode 100644 index 75b4537e772..00000000000 --- a/mozilla/widget/src/xlib/nsScrollBar.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsWidget.h" -#include "nsIScrollbar.h" - -class nsScrollbar : public nsWidget, - public nsIScrollbar -{ - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - NS_DECL_ISUPPORTS_INHERITED - - // Override some of the native widget methods for scrollbars - PRBool OnResize (nsSizeEvent &event); - PRBool DispatchMouseEvent (nsMouseEvent &aEvent); - NS_IMETHOD Show (PRBool bState); - NS_IMETHOD Move (PRInt32 aX, PRInt32 aY); - NS_IMETHOD Resize (PRInt32 aWidth, - PRInt32 aHeight, - PRBool aRepaint); - NS_IMETHOD Resize (PRInt32 aX, - PRInt32 aY, - PRInt32 aWidth, - PRInt32 aHeight, - PRBool aRepaint); - virtual void DestroyNative(); // override since we have 2 native widgets - - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - PRBool OnScroll(PRUint32 scrollCode, int cPos); - void CreateNative(Window aParent, nsRect aRect); - PRBool SendEvent(PRUint32 message); - -private: - void CalcBarBounds(void); - void LayoutBar(void); - nsresult NextPage(void); - nsresult PrevPage(void); - PRUint32 mMaxRange; - PRUint32 mPosition; - PRUint32 mThumbSize; - float mXScale; - float mYScale; - PRUint32 mLineIncrement; - PRBool mIsVertical; - nsIRenderingContext *mRenderingContext; - Window mBar; - nsRect mBarBounds; -}; - -#endif // nsButton_h__ diff --git a/mozilla/widget/src/xlib/nsWidgetFactory.cpp b/mozilla/widget/src/xlib/nsWidgetFactory.cpp index cae1c2b2f44..d324ba665f7 100644 --- a/mozilla/widget/src/xlib/nsWidgetFactory.cpp +++ b/mozilla/widget/src/xlib/nsWidgetFactory.cpp @@ -56,7 +56,6 @@ #include "nsClipboardHelper.h" #include "nsHTMLFormatConverter.h" #include "nsDragService.h" -#include "nsScrollBar.h" #include "nsSound.h" #include "nsBidiKeyboard.h" @@ -78,60 +77,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -static nsresult nsHorizScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( nsnull == aResult ) - { - return NS_ERROR_NULL_POINTER; - } - *aResult = nsnull; - if (nsnull != aOuter) - { - return NS_ERROR_NO_AGGREGATION; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_FALSE); - if (inst == nsnull) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - -static nsresult nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - nsISupports *inst = nsnull; - - if ( nsnull == aResult ) - { - return NS_ERROR_NULL_POINTER; - } - *aResult = nsnull; - if (nsnull != aOuter) - { - return NS_ERROR_NO_AGGREGATION; - } - - inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_TRUE); - if (inst == nsnull) - { - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; -} - static const nsModuleComponentInfo components[] = { { "Xlib nsWindow", @@ -150,14 +95,6 @@ static const nsModuleComponentInfo components[] = NS_CHECKBUTTON_CID, "@mozilla.org/widgets/checkbutton/xlib;1", nsCheckButtonConstructor }, - { "Xlib Horiz Scrollbar", - NS_HORZSCROLLBAR_CID, - "@mozilla.org/widgets/horizscroll/xlib;1", - nsHorizScrollbarConstructor }, - { "Xlib Vert Scrollbar", - NS_VERTSCROLLBAR_CID, - "@mozilla.org/widgets/vertscroll/xlib;1", - nsVertScrollbarConstructor }, { "Xlib Text Widget", NS_TEXTFIELD_CID, "@mozilla.org/widgets/textwidget/xlib;1",