[comp.sys.mac.programmer] Resizable windows

CXT105@psuvm.psu.edu (Christopher Tate) (10/15/90)

Problem:  I want a resizable window, with the grow box in the lower right
and all that, but I do not want any scroll bars.  I JUST want the box that
indicates the window is resizable.

How do people usually do this?  The standard DrawGrowIcon() routine draws
lines for the scroll bar borders; I don't want these.  Do I *really* have
to hack up my own WDEF to handle resizable windows without scroll bars?

I suppose I could just draw the grow icon myself, and fake it, but this
sounds pretty ugly.  Is there a "better" way, or better yet, an "approved"
way?

-------
Christopher Tate                       |
cxt105@psuvm.bitnet                    | nobody, not even the rain,
cxt105@psuvm.psu.edu                   |   has such small hands.
 ..!psuvax1!psuvm.bitnet!cxt105        |

mystone@mondo.engin.umich.edu (Dean Yu) (10/15/90)

In article <90287.182643CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
>Problem:  I want a resizable window, with the grow box in the lower right
>and all that, but I do not want any scroll bars.  I JUST want the box that
>indicates the window is resizable.
>
>How do people usually do this?  The standard DrawGrowIcon() routine draws
>lines for the scroll bar borders; I don't want these.  Do I *really* have
>to hack up my own WDEF to handle resizable windows without scroll bars?
>

  If you're going to use the standard WDEF, you can set the clip region of 
your window to a 16 by 16 square that's in the bottom right of your window
before calling _DrawGrowIcon.  The grow icon will be drawn, but the lines
for the scroll bars will be clipped out.
  Note however, that when the user goes to resize the window, the outlines
of the scroll bars will still be drawn while the user is resizing the window.

  -- Dean

_______________________________________________________________________________
Dean Yu                            | E-mail:    mystone@mondo.engin.umich.edu
Patches 'R' Us                     | Real-mail: Dean Yu
A Division of Cyberite Systems     |            909 Church St Apt C
                                   |            Ann Arbor, MI 48104
I'm not the voice of Reason, much  | Phone:	313 662-4073
    less the voice of Cyberite.    |            313 662-4163
-------------------------------------------------------------------------------

ldg@yoda.byu.edu (10/15/90)

In <90287.182643CXT105@psuvm.psu.edu>, Christopher Tate <CXT105@psuvm.psu.edu>
writes:

>Problem:  I want a resizable window, with the grow box in the lower right
>and all that, but I do not want any scroll bars.  I JUST want the box that
>indicates the window is resizable.
>
>How do people usually do this?  The standard DrawGrowIcon() routine draws
>lines for the scroll bar borders; I don't want these.  Do I *really* have
>to hack up my own WDEF to handle resizable windows without scroll bars?
> [...]

I just call DrawGrowIcon() then erase the borders. If you don't want the
borders to even flicker into existance, set the clipRgn to the
appropriately-sized rectangle in the lower-right corner (call ClipRect())
before you call DrawGrowIcon().

Lyle D. Gunderson N6KSZ | "Any technology without       | ldg@yoda.byu.edu
350 CB/BYU              | some attendant risk of misuse | CIS: 73760,2354
Provo UT 84602          | is probably trivial"          | GEnie: L.GUNDERSON
                        |             --Louise Kohl     | AOL: LGunderson

nick@cs.edinburgh.ac.uk (Nick Rothwell) (10/15/90)

In article <90287.182643CXT105@psuvm.psu.edu>, CXT105@psuvm.psu.edu (Christopher Tate) writes:
> How do people usually do this?  The standard DrawGrowIcon() routine draws
> lines for the scroll bar borders; I don't want these.  Do I *really* have
> to hack up my own WDEF to handle resizable windows without scroll bars?

I don't think that would be necessary. As I recall, using the correct
variation code (or whatever it's called) for the standard WDEF will
get one which the Window Manager will resize whenever you click the grow
region, regardless of what you've drawn.

> I suppose I could just draw the grow icon myself, and fake it, but this
> sounds pretty ugly.  Is there a "better" way, or better yet, an "approved"
> way?

I would just fake it, myself. The THINK class library uses a small
icon (SICN) for the grow-box, and paints it itself. Be sure to
highlight/dehighlight it appropriately.

		Nick.

-- 
Nick Rothwell,	Laboratory for Foundations of Computer Science, Edinburgh.
		nick@lfcs.ed.ac.uk    <Atlantic Ocean>!mcsun!ukc!lfcs!nick
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
 "Now remember - and this is most important - you must think in Russian."

llama@eleazar.dartmouth.edu (Joe Francis) (10/15/90)

In article <90287.182643CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
>Problem:  I want a resizable window, with the grow box in the lower right
>and all that, but I do not want any scroll bars.  I JUST want the box that
>indicates the window is resizable.
>
>How do people usually do this?  The standard DrawGrowIcon() routine draws
>lines for the scroll bar borders; I don't want these.  Do I *really* have
>to hack up my own WDEF to handle resizable windows without scroll bars?
>
>I suppose I could just draw the grow icon myself, and fake it, but this
>sounds pretty ugly.  Is there a "better" way, or better yet, an "approved"
>way?

I don't know what the "approved" way is, but I do the following:
1) Save the current clip region.
2) Set the current clip region to where the grom icon appears.
3) Call DrawGrowIcon(wind);
4) Restore clip region.

Perhaps kludgy, but it has the advantage that the grow icon is still drawn
by DrawGrowIcon, so it will be drawn in the correct color on color systems,
will still "do the right thing" if someone patches DrawGrowIcon for some
bizarre region.

-----------------------------------------------------------------------------
"Read My Lips: No Nude Texans!" - George Bush clearing up a misunderstanding

hawley@adobe.COM (Steve Hawley) (10/15/90)

In article <90287.182643CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
>Problem:  I want a resizable window, with the grow box in the lower right
>and all that, but I do not want any scroll bars.  I JUST want the box that
>indicates the window is resizable.
>
>I suppose I could just draw the grow icon myself, and fake it, but this
>sounds pretty ugly.  Is there a "better" way, or better yet, an "approved"
>way?

I can't say what the approved way is, but I'll tell you what I did:
I wrote a routine that was a little for flexible:

MyDrawGrowIcon(theWindow, hscroll, vscroll)
WindowPtr theWindow;
Boolean hscroll, vscroll;

Which drew the standard grow icon (which I snarfed from a screen snapshot
and converted to a static bitmap local to MyDrawGrowIcon), and provided the
marked off areas for scroll bars only on demand.  I consider this to be a
good solution: it requires no new WDEFs or CDEFs, no patching of traps, and
is easy to code (don't forget to pay attention to color!).

For complete slickness you may want to rewrite the routine that tracks the
window outline for reshaping in a similar way.

To Rich Siegel -- what does Think C do for the project window?

Steve Hawley
hawley@adobe.com
-- 
"I'm sick and tired of being told that ordinary decent people are fed up with
being sick and tired.  I know I'm certainly not, and I'm sick and tired of
begin told that I am." -Monty Python

leonardr@svc.portal.com (Leonard Rosenthol) (10/16/90)

In article <1990Oct15.020733.16435@engin.umich.edu>,
mystone@mondo.engin.umich.edu (Dean Yu) writes:
> In article <90287.182643CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
> >Problem:  I want a resizable window, with the grow box in the lower right
> >and all that, but I do not want any scroll bars.  I JUST want the box that
> >indicates the window is resizable.
> >
>   If you're going to use the standard WDEF, you can set the clip region of 
> your window to a 16 by 16 square that's in the bottom right of your window
> before calling _DrawGrowIcon.  The grow icon will be drawn, but the lines
> for the scroll bars will be clipped out.
>
	There is, however, one problem with this...What if Apple ever changes
the size of the 'GrowIcon', then you either end up with extra stuff, or not
enough?  This will also effect utilities like Personality and ClickChange
which allow the user to change the WDEF in use.  
	The PROPER solution is to write a WDEF, and second, I think would
be to at least stub the standard WDEF and handle the wGrowMsg message 
yourself.  Admittedly, writing a WDEF is not entirely trivial, but Apple
supplies source to theirs, and you can just mod the appropriate parts.

Leonard Rosenthol
Software Ventures
--
Leonard Rosenthol
Software Ventures Corp.
MicroPhone II Development Team

russotto@eng.umd.edu (Matthew T. Russotto) (10/16/90)

In article <90287.182643CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
>Problem:  I want a resizable window, with the grow box in the lower right
>and all that, but I do not want any scroll bars.  I JUST want the box that
>indicates the window is resizable.

I always set the ClipRgn to the grow box region, call DrawGrowIcon, and fix
the ClipRgn.

(thus, the lines don't get drawn)


--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
      .sig under construction, like the rest of this campus.

keith@Apple.COM (Keith Rollin) (10/16/90)

In article <1990Oct15.190508.8408@svc.portal.com> leonardr@svc.portal.com (Leonard Rosenthol) writes:
>In article <1990Oct15.020733.16435@engin.umich.edu>,
>mystone@mondo.engin.umich.edu (Dean Yu) writes:
>> In article <90287.182643CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
>> >Problem:  I want a resizable window, with the grow box in the lower right
>> >and all that, but I do not want any scroll bars.  I JUST want the box that
>> >indicates the window is resizable.
>> >
>>   If you're going to use the standard WDEF, you can set the clip region of 
>> your window to a 16 by 16 square that's in the bottom right of your window
>> before calling _DrawGrowIcon.  The grow icon will be drawn, but the lines
>> for the scroll bars will be clipped out.
>>
>	There is, however, one problem with this...What if Apple ever changes
>the size of the 'GrowIcon', then you either end up with extra stuff, or not
>enough?  This will also effect utilities like Personality and ClickChange
>which allow the user to change the WDEF in use.  

I don't think that we'll ever change the size of the grow icon. If we 
did, every scrollbar in the world would fail to line up with it.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

d88-jwa@dront.nada.kth.se (Jon W{tte) (10/16/90)

> Problem:  I want a resizable window, with the grow box in the lower right
> and all that, but I do not want any scroll bars.  I JUST want the box that
> indicates the window is resizable.

To graw a resize icon without the scrollbar borders:

1) you could use FrameRect to draw the rect border
    and the small rects (or your own SICN or ICON)

2) You can do this:

void
DrawMyGrow(WindowPtr myWindow)
{
        PenState theState;
        RgnHandle foo = NewRgn();
        Rect r;
        GrafPtr aPort;
 
        GetPort(&aPort);
        SetPort(myWindow);
        GetClip(foo);
        GetPenState(&theState);
        PenNormal();
 
        SetRect(&r, myWindow->portRect.right - 15, myWindow->portRect.bottom -
                15, myWindow->portRect.right, myWindow->portRect.bottom);
        ClipRect(&r);
        DrawGrowIcon(myWindow);
 
        SetClip(foo);
        SetPenState(&theState);
        DisposHandle(foo);
        SetPort(aPort);
}

3) You can just erase the lines after a simple call to DrawGrowIcon.

Happy hacking !

							h+

h+@nada.kth.se
"Moof!(tm)"

djvelleman@amherst.bitnet (10/17/90)

In article <1990Oct15.190508.8408@svc.portal.com>, leonardr@svc.portal.com (Leonard Rosenthol) writes:
> In article <1990Oct15.020733.16435@engin.umich.edu>,
> mystone@mondo.engin.umich.edu (Dean Yu) writes:
>> In article <90287.182643CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
>> >Problem:  I want a resizable window, with the grow box in the lower right
>> >and all that, but I do not want any scroll bars.  I JUST want the box that
>> >indicates the window is resizable.
>> >
>>   If you're going to use the standard WDEF, you can set the clip region of 
>> your window to a 16 by 16 square that's in the bottom right of your window
>> before calling _DrawGrowIcon.  The grow icon will be drawn, but the lines
>> for the scroll bars will be clipped out.
>>
> 	There is, however, one problem with this...What if Apple ever changes
> the size of the 'GrowIcon', then you either end up with extra stuff, or not
> enough?  This will also effect utilities like Personality and ClickChange
> which allow the user to change the WDEF in use.  
> 	The PROPER solution is to write a WDEF, and second, I think would
> be to at least stub the standard WDEF and handle the wGrowMsg message 
> yourself.  Admittedly, writing a WDEF is not entirely trivial, but Apple
> supplies source to theirs, and you can just mod the appropriate parts.

  If Apple ever changes the size of the growicon, they might also
change the width of the scrollbar region.  What do you suggest we do about
setting the size of our scrollbars?  Should every program that has a scrollbar
have its own window def, rather than relying on the width of the scrollbar
region of the standard WDEF not to change?
  I agree that it's a good idea not to rely too much on specific features of
the current standard window, control, and menu definition functions, to be
compatible with future changes, but there are limits to how far one can
reasonably take this.  It seems to me it is much more likely that Apple will
change the APPEARANCE, but not the size, of the standard growicon (adding
color, or shading, or little animated green men who grab the corners of your
window and move them for you :-)  If you use your own WDEF then your program
will look out of date when these improvements appear.
  I vote for the clipping solution to this problem.  BTW, I think the proper
size of the rectangle to clip to is 15 by 15, not 16 by 16.  I have found
clipping to be useful in other situations when the toolbox wants to draw
something but I don't want it to be drawn.  (For example, the control manager
always likes to redraw controls immediately whenever you do anything to them.)

  Dan Velleman
  Math Dept.
  Amherst College