// -------------------------------------------------------------- -*- C++ -*-
// File: Uimx/IlvWidget/include/scrollhook.h
// --------------------------------------------------------------------------
//  Copyright (C) 1990-1994 by ILOG.
//  All Rights Reserved.
//
//  N O T I C E
//
//  THIS MATERIAL IS CONSIDERED A TRADE SECRET BY ILOG.
//  UNAUTHORIZED ACCESS, USE, REPRODUCTION OR DISTRIBUTION IS PROHIBITED.
// --------------------------------------------------------------------------
// Declaration of the IlvManager Widget scroll hook class
// --------------------------------------------------------------------------
#if !defined(_scrollhook_h)
#define _scrollhook_h

#include <ilviews/mgrio.h>

// --------------------------------------------------------------------------
// IlvScrollViewHook to attach automatic Motif scrollbars to an IlvView
// --------------------------------------------------------------------------
class IlvScrollViewHook
:  public IlvManagerViewHook {
protected:
    IlvPos _previousx;
    IlvPos _previousy;
    IlvSystemView _verticalSB;
    IlvSystemView _horizontalSB;
    IlvRect _bbox;
public:
    IlvScrollViewHook(IlvManager* mgr,IlvView* view,
		      IlvSystemView vscroll,IlvSystemView hscroll)
	:IlvManagerViewHook(mgr,view),_previousx(0),_previousy(0),
    _verticalSB(vscroll),_horizontalSB(hscroll)
	{ mgr->computeBBox(_bbox); initScrollBars(); }
    // Slots accessors_____________________________________
    IlvSystemView getHsb() const { return _horizontalSB;}
    IlvSystemView getVsb() const { return _verticalSB;}
    void setHsb(IlvSystemView hsb) { _horizontalSB=hsb; }
    void setVsb(IlvSystemView vsb) { _verticalSB=vsb; }
#if defined(IlvVersion) && (IlvVersion >= 200)
    virtual void transformerChanged(const IlvTransformer*,
				    const IlvTransformer*)
#else  /* VIEWS < 2.0 */
    virtual void transformerChanged(IlvTransformer*,
				    IlvTransformer*)
#endif /* VIEWS < 2.0 */
	{ adjustScrollBars(); }
    virtual void viewResized()
	{ adjustScrollBars(); }
    virtual void contentsChanged()
	{
	  getManager()->computeBBox(_bbox);
	  adjustScrollBars();
	}
    void initScrollBars();
    void adjustView();
    void adjustScrollBars();
};


#endif /* _scrollhook_h */
