[comp.sys.mac.programmer] Drawing windows

stas@brahms.udel.edu (Stanislaus Pietrucha) (05/23/91)

I know I can find this information in the 6(?) volumes Inside the Mac, or
whatever the title is, but I'll ask here:

I am VERY new at programming on the Mac.  I am in the process of trying to
learn my way around (via articles in mac User and other printed materials,
such as this newsgroup).  I will soon by the Macintosh reference books, but two
quick questions:

1. Which volume(s) should I get first, with basic information in them.  Info
I'll need to write a Mac application with Mac-type interface?

2. How can I create a window on the screen.  Basically I ask because when
I run an application created with Think C I get this stupid window that
says "console" and I want to open my own window(s) within the application.

If the answer to the second question is too long and hard to understand for
new Mac programmers, I'll just have to get my hands on those reference books,
so which ones should I get? (I know I'll need all of them, but just to get me
started, what ones do I need?)

Thanks again,

Stas

dorner@pequod.cso.uiuc.edu (Steve Dorner) (05/23/91)

In article <21620@brahms.udel.edu> stas@brahms.udel.edu (Stanislaus Pietrucha) writes:
>1. Which volume(s) should I get first, with basic information in them.  Info
>I'll need to write a Mac application with Mac-type interface?

85% of what you need is in IM vol I.  The Memory Manager chapter of IM II
is crucial, though.

Beyond that, it all depends on what your app does.  If it uses color, you'll
want IM V.  If it messes with folders and such, you'll want IM IV.

I suspect we'll all have to have IM VI if we want to be System 7 friendly.
--
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: uunet!uiucuxc!uiuc.edu!s-dorner

vrm@babcock.cerc.wvu.wvnet.edu (Vasile R. Montan) (05/24/91)

From article <21620@brahms.udel.edu>, by stas@brahms.udel.edu (Stanislaus Pietrucha):

> 1. Which volume(s) should I get first, with basic information in them.  Info
> I'll need to write a Mac application with Mac-type interface?

In spite of what many people say, I *don't* recommend IM as a set of books
for learning how to program the Mac.  This is not to say that they are not
worthy publications; they are indeed remarkable for their thoroughness.
Unfortunately, this same thoroughness necessarily comes at the expense of
clarity.  I recommend starting with a more introductory book; once you
master the basics and want to move into more esoteric techniques, then
IM is just the thing.

My preference is Macintosh Revealed by Stephen Chernicoff.  Volumes I
and II are essential; volumes II and IV are nice but not necessary.
Each is around $26.  These books will cover 80% of all the things you
will ever need to do.  In understand there is also another good 
introductory text, whose name escapes me, although it might be 'MacPrimer.'

If you want the ISBN numbers for the Chernicoff books, email me at
un020070@vaxa.wvnet.edu

> 2. How can I create a window on the screen.  Basically I ask because when
> I run an application created with Think C I get this stupid window that
> says "console" and I want to open my own window(s) within the application.

There's two basic ways.  The first way is to totally create the window
from scratch within your program.  The second way is to load in the
window as a resource.  The second way is far more common, and in many
ways is both easier and more flexible.

To do this second way, do the following:
1.  Create a resource file using Reit and associate it with your
program, however you do that in Think C.  In this resource file,
create a WIND resource to represent the window you want.  (If this
makes no sense whatsoever, email me.)  In the following code,
I'll assume that this WIND has an ID of 1000.
2.  In your program, declare a variable of type WindowPtr, however
you do that in C.  (I don't know C, so I can't say.)
3.  Get the window using the following line:

     MyWindowPtr := GetNewWindow (1000, nil, nil);

Of course, you'll have to figure out how to say this in C.  MyWindowPtr
is the WindowPtr variable you declared; 1000 is the resource ID of the WIND.
4.  To draw in the window, set the current drawing port to this window
by saying:

     SetPort(MyWindowPtr);


Good luck!

--Kurisuto
un020070@vaxa.wvnet.edu

jboser@cs.fau.edu (Jeff Boser) (05/28/91)

In article <1791@babcock.cerc.wvu.wvnet.edu> vrm@babcock.cerc.wvu.wvnet.edu (Vasile R. Montan) writes:
>From article <21620@brahms.udel.edu>, by stas@brahms.udel.edu (Stanislaus Pietrucha):
>
>> 1. Which volume(s) should I get first, with basic information in them.  Info
>> I'll need to write a Mac application with Mac-type interface?
>In spite of what many people say, I *don't* recommend IM as a set of books
>for learning how to program the Mac.  This is not to say that they are not
>worthy publications; they are indeed remarkable for their thoroughness.
>Unfortunately, this same thoroughness necessarily comes at the expense of
>clarity.  I recommend starting with a more introductory book; once you
>master the basics and want to move into more esoteric techniques, then
>IM is just the thing.

I must have missed a club meeting.  I have YET to hear of someone recommending
that someone learn to program the mac solely from IM (I have, and I dont).
The fact is, if you plan on writing anything beyond HelloWorld, IM is
absolutely necessary.  Just as there are books teaching languages, the
tech docs are the truth, the whole truth, and nothing but the truth.

So, if you are learning to program on the mac, I tell you three times:
1) learn C or Pascal, and do not worry about mac stuff.
2) Buy IM, as many of the volumes as you can carry.
3) THEN get a intro book, and start playing with sample code.

Macintosh Revealed (I have all 4) is a good INTRODUCTION, but does nothing
for a programmer who wants to do his own thing.  The same goes for Mac
Programming Primer.  I own about 8 other introduction books, and have
learned something from each and every one, but they all pale before the
information contained in IM.  In fact, the intro books are unnecessary
for experienced and capable (both, not either) programmers.  IM describes
all the Toolbox routines, how to use them, and when to use them.  And it
is written incredibly well, to boot.  And YOU CANNOT DO WITHOUT IT!

>My preference is Macintosh Revealed by Stephen Chernicoff.  Volumes I
>and II are essential; volumes II and IV are nice but not necessary.
>Each is around $26.  These books will cover 80% of all the things you
>will ever need to do.

I have all 4 volumes, and they are no where near as complete as you claim.
The chapter summaries and references are cryptic to say the least, and the
routine descriptions and their uses are separate.  If you, as a professional,
take any pride at all in your resources, skimping on literature is not
going to save you anything, least of all money and time, in the short and
long run.  Even though it will mean eight movies I will have to give up,
I am going to get IM 6, when it becomes available here.  I am sick and
tired (or is that tired and sick?) of people whimping out, trying to just
get by, and generally trying to take shortcuts.

>> 2. How can I create a window on the screen.  Basically I ask because when
>> I run an application created with Think C I get this stupid window that
>> says "console" and I want to open my own window(s) within the application.
>There's two basic ways.  The first way is to totally create the window
>from scratch within your program.  The second way is to load in the
>window as a resource.

whoh.. what a concept:  IM1-Table of contents: The Window Manager,
Using the Window Manager: page 280:
"When appropriate in your program, use NewWindow or GetNewWindow to
create any windows you need; these functions return a window pointer, which
you can then use to refer to the Window.  NewWindow takes descriptive
information about the window from its parameters, whereas GetNewWindow gets
the information from a window template in a resource file."

Two pages away are detailed descriptions of exactly what NewWindow and
GetNewWindow do and what to pass as parameters.

If you read your Think C docs (another big concept!), you will find out
what a console window is, and what it is used for.

So... to sum up, If you are daunted by the size of IM, or the learning
curve of mac programming, GET OUT OF THE PROFESSION!  You are only lowering
the state-of-the-art.


.....jeff
jboser@tuna.cs.fau.edu
-- 
"Make something an idiot can use, and only an idiot will use it." - RAH
Like a bible, maybe? - me

sdd@oceania.UUCP (Steve Dakin) (05/29/91)

> 2. How can I create a window on the screen.  Basically I ask because when
> I run an application created with Think C I get this stupid window that
> says "console" and I want to open my own window(s) within the application.
> 
If you got THINK C, just take that BullsEye sample app and start adding your  
own stuff to it, and removing what you don't want (just the stuff that draws  
the bullseye).  That's how I got my first Mac C program to work the way I  
wanted it to.

--
+-----------------------------------+
|            Steve Dakin            |
|     oceania!sdd@uunet.uu.net      |
|            (NeXT mail)            |
| tread lighty so others may follow |
+-----------------------------------+

-- 
+-----------------------------------+
|            Steve Dakin            |
|     oceania!sdd@uunet.uu.net      |
|            (NeXT mail)            |