[comp.sys.mac.programmer] Novice Think C Class Questions

kevinb@wrc.unr.edu (Kevin Brewer) (02/28/91)

I have three quick questions for the Think C Class guru's from a novice
user/programmer.

1) I have an appliction that should have three or four windows. My 
   (mis?)understanding of the Document Class is that the Doc Class should
   control the windows, yet you can only have one window associated with
   each doc instance. How do you create more than one window - say a 
   drawing pane and a text edit pane - for each doc? Obviously, I'm
   confused. I would appreciate any direction on this.

2) I know I need to read more on using the Think C Classes. A while back,
   (unfortunately before I started using Think C and the Classes) there
   was some recommendations for books. Could someone direct me to good
   books? I am moderately familiar with OOP in general (having used Eiffel
   in a class a while back) so I am looking for something that will help
   me better understand Think C Classes and the mac in particular.

3) Where is the least expensive place to find books like the IM series?
   Should I join a developers assoc?

Please excuse my ignorance if these are FAQ. If they are, tell me where
to go to find the answers.

Thanks -
Kevin
e-mail or post - I'm a News junkie (especially since I don't have a TV!)
Kevin Brewer
kevinb@wheeler.wrc.unr.edu
  "When water chokes you, what are you to drink to wash it down?" -Aristotle

Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (03/02/91)

Kevin Brewer writes in a message to All

KB> 1) I have an appliction that should have three or four windows. 
KB> My (mis?)understanding of the Document Class is that the Doc 
KB> Class should  control the windows, yet you can only have one 
KB> window associated with  each doc instance. How do you create 
KB> more than one window - say a drawing pane and a text edit pane 
KB> - for each doc? Obviously, I'm  confused. I would appreciate 
KB> any direction on this.

Normally, one can have drawing in a drawing pane and text in and edit pane on
the same window, have a button or menu item to resize them out of your way or
some other hack.

If you want to go the route of 2 or more windows associated with the same file/document,
you can do as I did: create a subclass of CBeaurocrat called CWindowLiason,
that handles all of the window creation and chain-of-command stuff before it
reaches the document. You have to modify CWIndow to get dispose/free itsWindowLiason
as part of yourWindow.free, and several other things in your document to override
close/openWind, etc.

It's a little complicated to post, but I can E-mail the relevant classes if
you like.


KB> 2) I know I need to read more on using the Think C Classes. A 
KB> while back,  (unfortunately before I started using Think C and 
KB> the Classes) there  was some recommendations for books. Could 
KB> someone direct me to good  books? 

Try the Macintosh C(Pascal) Programming Primer Vol II. Also subscribe to Thinkin'
Cap from SPLAsh (Symantec Programming Languages Assoc.)

SPLAsh Resources
1678 Shattuck Ave #302
Berkeley CA 94709

Greg (TCL's) DOW is the editor/founder.

There is also a disk magazine called Prepare() that sells for $495/year. Heard
good stuff about the source code from it including a TCL View-Editor. The editor
of this tool lurks here.

KB> 3) Where is the least expensive place to find books like the 
KB> IM series?  Should I join a developers assoc

I really have no idea. Used bookstores seems to be the best bet... Maybe someone
has the odd extra set lying around here?


Lawson



 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English
Internet: Lawson.English@p88.f15.n300.z1.fidonet.org

tim@hoptoad.uucp (Tim Maroney) (03/09/91)

Kevin Brewer writes in a message to All
>KB> 1) I have an appliction that should have three or four windows. 
>KB> My (mis?)understanding of the Document Class is that the Doc 
>KB> Class should  control the windows, yet you can only have one 
>KB> window associated with  each doc instance. How do you create 
>KB> more than one window - say a drawing pane and a text edit pane 
>KB> - for each doc? Obviously, I'm  confused. I would appreciate 
>KB> any direction on this.

You do it by using MacApp, which has a list of windows for each document....
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"When errors are found in old research, the relevant theories are
 re-examined.  When facts contradict theory, theory gets dumped.  Is
 that why the NLP people are unwilling to research their facts?"
	-- Jerry Hollombe on sci.psychology

a_dent@fennel.cc.uwa.oz.au (03/16/91)

Kevin Brewer writes in a message to All
KB> 1) I have an appliction that should have three or four windows. 
KB> My (mis?)understanding of the Document Class is that the Doc 
KB> Class should  control the windows, yet you can only have one 
KB> window associated with  each doc instance. How do you create 
KB> more than one window - say a drawing pane and a text edit pane 
KB> - for each doc? Obviously, I'm  confused. I would appreciate 
KB> any direction on this.

I implemented a program which allows multiple windows (a magazine layout
program - a page per window) and so had to be able to change the main
pane - sounds like what you're doing.

I wrote a subclass of CWindow, as shown below, and added a method to the
normal (overridden, from the sample application) Document class:

procedure CREIWAPrintDoc.changeMainPane (newMain: CREIWAPrintPane; 
   newWindow: CWindow);
 begin
  itsMainPane := newMain;
  itsGopher := newMain;
  gGopher := newMain;
  itsWindow := newWindow;
 end;

---------------------------------------------------------------------------

 procedure CREIWAPrintWindow.makeMyPaneMain;
  var
   thePane: CREIWAPrintPane;
   itsScrollPane: CScrollPane;

  function isREIWAPane (theObject: CObject): boolean;
  begin
   isREIWAPane := member(theObject, CREIWAPrintPane);
  end;  { isREIWAPAne}

 begin  { makeMyPaneMain }
  CObject(itsScrollPane) := itsSubviews.FirstItem;
  CObject(thePane) := itsScrollPane.itsSubviews.FirstSuccess(isREIWAPane);
  CREIWAPrintDoc(itsSupervisor).changeMainPane(thePane, SELF);
 end;  { makeMyPaneMain }


 procedure CREIWAPrintWindow.select;
 begin  { select }
  SELF.makeMyPaneMain;
  inherited select;
 end;  { select }

 procedure CREIWAPrintWindow.Activate;
 begin  { Activate }
  SELF.makeMyPaneMain;
  inherited Activate;
 end;  { Activate }

--------------------------------------------------------------------------------
The following fragment of code goes in the Document's DoCommand method and
lets you have a menu of all the windows:

  if (theCommand < 1) & (hiWord(thecommand) = -(PageMenuID + 1)) then begin   
{ selection from Page menu }
    thePageIndex := -loWord(theCommand);  { note the sign change!! }
    CObject(theWindow) := itsWindowList.NthItem(thePageIndex);
    theWindow.Select;
   end;

Hope this helps.

Andy Dent                     A.D. Software phone 09 249 2719
Mac & VAX programmer          94 Bermuda Dve, Ballajura
a_dent@fennel.cc.uwa.oz       Western Australia  6066     
a_dent@fennel.cc.uwa.oz.AU (international)