[comp.sys.mac.programmer] Think class lib - question about CPanorama and CScrollPane

jamesm@sco.COM (James M. Moore) (11/21/89)

I'm having some problems with the CScrollWindow class.  I'm not
getting any response to clicks on the scrollbars.  I've stepped
through CView::DispatchClick, and it looks like I'm just not getting
the scroll bars back from CView::FindSubview.  I've looked at what's
done in the Art example, and the CClipboard, but it looks like I'm
doing basically the same thing.  I'm obviously getting something
wrong, but I just don't see it.

The routine gets called from my document class like so:

	w->IClassWindow(30774, FALSE, gDesktop, this, aClass);


[BClassWindow is a subclass of CWindow.  scrollPane is CScrollPane.
classPicture is BClassWindow, which is a subclass of CPanorama with
only the Draw() method overridden.]

void BClassWindow::IClassWindow(
	short		WINDid,
	Boolean		aFloating,
	CDesktop	*anEnclosure,
	CDirector	*aSupervisor,
	BClass		*theCls
) {
Str255	title;
Rect	bounds;
Point	y;
	inherited::IWindow(WINDid, aFloating, anEnclosure, aSupervisor);
	this->theClass = theCls;
	theCls->ClassName((char *) title);
	CtoPstr(title);
	this->SetTitle(title);
	this->SetActClick(true);
	
	/*
	 * setup scroll pane
	 */
	scrollPane = new(CScrollPane);
	scrollPane->IScrollPane(this, this, 0, 0, 0, 0, sizELASTIC,
		sizELASTIC, true, true, true);
	scrollPane->FitToEnclFrame(true, true);
	scrollPane->DoClick(y, 0, 0);
	
	/*
	 * setup panorama
	 */
	classPicture = new(BClassPanorama);
	classPicture->IPanorama(scrollPane, this, 0, 0, 0, 0,
		sizELASTIC, sizELASTIC);
	classPicture->FitToEnclFrame(true, true);

	/*
	 * install the panorama into the scroll frame
	 */
	scrollPane->InstallPanorama(classPicture);
	
	/*
	 * grow the panorama
	 */
	SetRect(&bounds, 0, 0, 500, 500);
	classPicture->SetBounds(&bounds);
	classPicture->SetScales(1, 1);
	
	/*
	 * Put the window onto the screen
	 */
	this->Select();
};

-- 
James Moore                            | Nil aon .sig maith agam anois -
Santa Cruz Operation UNIX Tech Support |	B'fheidir an tseachtaine seo
jamesm@sco.com                         |		chugainn.

ewing@tramp.Colorado.EDU (EWING DAVID JAMES) (11/23/89)

In article <7532@viscous.sco.COM> jamesm@sco.COM (James M. Moore) writes:
>
>I'm having some problems with the CScrollWindow class.  I'm not
>getting any response to clicks on the scrollbars.  I've stepped
>through CView::DispatchClick, and it looks like I'm just not getting
>the scroll bars back from CView::FindSubview.  I've looked at what's
>done in the Art example, and the CClipboard, but it looks like I'm
>doing basically the same thing.  I'm obviously getting something
>wrong, but I just don't see it.
>
>The routine gets called from my document class like so:
>
>	w->IClassWindow(30774, FALSE, gDesktop, this, aClass);

Hmm.  This seems very confusing.  I'm not sure what you're trying to do in
your initialization class.  Most of it looks like it belongs in your
document's initialization method.  It looks like your trying to have
CScrollWindow act as a window and a director.  For instance, you init the
scrollPane variable with "this" for both its supervisor and its enclosure.
I'm pretty sure that CWindow assumes that its supervisor is a decendent of
CDirector, which may cause your implementation to crash eventually.  I
must admit tha I haven't quite figured out why your clicks haven't been
dispatched properly, but I though that what I've just said might give you
a clue.  Good Luck.

Dave Ewing
ewing@tramp.colorado.edu  (128.138.238.33)
..!hplabs!boulder!onecom!tyvax!iftech!dave (My Mac IIx running uupc & MacOS!)
AppleLink: D2408	  (D2408@applelink.apple.com)

jamesm@sco.COM (James M. Moore) (11/28/89)

My problem with not getting clicks seems to be that I was calling
FitToEnclFrame() rather than FitToEnclosure().  The pane just wasn't
where I thought it was.  Switching the two calls solved the problem.
-- 
James Moore                            | Nil aon .sig maith agam anois -
Santa Cruz Operation UNIX Tech Support |	B'fheidir an tseachtaine seo
jamesm@sco.com                         |		chugainn.