[comp.sys.next] HELP! Yet more problems with making new windows...

adam@mit-amt.MEDIA.MIT.EDU (Adam Glass) (08/16/89)

Sigh... just when I thought it was all over, and I had finally gotten these
darn windows working, I turn out to be wrong. Groan...

This is basically what I've got:

Pre-read notes: variables windowid and scrollid are defined as 'id'. Window.h
and lots of other nice things are #included -- I don't think that's the
problem. "Without further ado", here's the code:

      windowid = [Window newContent:myRect:style:type:mask:YES]; // line 574
      [windowid makeKeyAndOrderFront];                           // line 575
      scrollid = [ScrollView newFrame:&myRect];                  // line 576

Post-read notes: cc complains (at compile time) that it can't find the method
"newContent", the method on the first line of code. It also complains that it
can't find "newFrame", but it crashes before it gets to that point on a run.
Sigh...

This is what cc says when I make the application:

ButtonFnctns.m:574: warning: cannot find factory method.
ButtonFnctns.m:574: warning: return type for `newContent:::::' defaults to id.

But if it can't find the method, how does it know that it takes 5 arguments?
And aren't I assigning it to a variable of type id (windowid) ??

What am I doing wrong?

Adam

--
"Offer me anything I ask for..."
"Anything you want."
"I want my father back, you son of a bitch." - The Princess Bride

adam@mit-amt.MEDIA.MIT.EDU (Adam Glass) (08/17/89)

combs@sumex-aim.stanford.edu (Dave Combs) writes:
> Concerning the newContent::::: call, the compiler error is correct.
> Since you are not supplying values to the various arguments to the call
> (even if NULL), it assumes that the tokens "style", "type" and "mask"
> are actual values, instead of parameter names.  Also, is "myRect" a pointer
> to an NXRect, or an NXRect itself?  Final note: the argument name is
> "buttonMask", not "mask."
> 
> The call probably should be:
>   [Window newContent:&myRect 
>            style:(some_integer_style)
>          backing:(some_integer_buffering_type)
>       buttonMask:(some_integer_buttonMask)
>            defer:(some_BOOL_flag)]

For the sake of brevity and netload, I didn't include the stuff above, where
I define those variables, but I'll do it here to show you that I am doing the
right thing (so far as I can tell). Code:

- MakeWindowAndDrawText:(int) storynum:(int) priority
{
    int fd, style, type, mask;
    NXRect myRect;
    id windowid, scrollid;

      /* set style, mask, myRect and type to the desired settings */
      windowid = [Window newContent:myRect:style:type:mask:YES];
      [windowid makeKeyAndOrderFront];
      scrollid = [ScrollView newFrame:&myRect];
      [[windowid contentView] setAutoresizeSubviews:YES];
      [[windowid contentView] addSubview:scrollid];
      /* etc... */
}

Sigh... any more suggestions?

Adam

--
"Offer me anything I ask for..."      (mail address in message header)
"Anything you want."
"I want my father back, you son of a bitch." - The Princess Bride

dayglow@ibmpa.UUCP (Eric Ly) (08/21/89)

<From: adam@mit-amt.MEDIA.MIT.EDU (Adam Glass)> writes:
 
> Sigh... just when I thought it was all over, and I had finally gotten these
> darn windows working, I turn out to be wrong. Groan...
> 
> This is basically what I've got:
> 
> Pre-read notes: variables windowid and scrollid are defined as 'id'. Window.h
> and lots of other nice things are #included -- I don't think that's the
> problem. "Without further ado", here's the code:
> 
>       windowid = [Window newContent:myRect:style:type:mask:YES]; // line 574
>       [windowid makeKeyAndOrderFront];                           // line 575
>       scrollid = [ScrollView newFrame:&myRect];                  // line 576
> 
> Post-read notes: cc complains (at compile time) that it can't find the method
> "newContent", the method on the first line of code. It also complains that it
> can't find "newFrame", but it crashes before it gets to that point on a run.
> Sigh...

The problem is that you're using one too many colons.  For line 574, try
something like:

    windowid = [Window newContent:&myRect style:myStyle backing:NX_BUFFERED
	buttonMask:NX_ALLBUTTONS defer:YES];

For line 575, it's:

    [windowid makeKeyAndOrderFront:self];

If you look at the specs for the Window class, this method requires an
unused but required argument to conform to the target/action paradigm.

Line 576 is fine syntactically.  The compiler complains because you haven't
declared the prototype method by including <appkit/ScrollView.h>.  For each
class that you use, make sure you include the header file for that class.
Hope this helps.

						Eric Ly
						IBM Palo Alto

dz@kiwi.ucsb.edu (Daniel James Zerkle) (08/22/89)

In article <1796@ibmpa.UUCP> dayglow@ibmpa.UUCP (Eric Ly) writes:

>For each
>class that you use, make sure you include the header file for that class.

You can also put a line like:

#import <appkit/appkit.h>

This will include everything in sight, so you won't have to worry
about getting your particular include file.  Of course, this means
that the compiles will be a little slower, but that's the price you
have to pay.

| Dan Zerkle home:(805) 968-4683 morning:961-2434 afternoon:687-0110  |
| dz@cornu.ucsb.edu dz%cornu@ucsbuxa.bitnet ...ucbvax!hub!cornu!dz    |
| Snailmail: 6681 Berkshire Terrace #5, Isla Vista, CA  93117         |
| Disclaimer: If it's wrong or stupid, pretend I didn't do it.        |