Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!nrc3d.nrc.uab.edu!jpg From: jpg@nrc3d.nrc.uab.edu (Jill Gemmill) Newsgroups: comp.sys.sgi Subject: (none) Message-ID: <9106212128.AA01337@nrc3d.nrc.uab.edu> Date: 21 Jun 91 21:28:47 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 115 Subject: Re: changing window size under PROGRAM control Here are some suggestions I received. Thanks to everyone who responded, including: Brent L. Bates blbates@aero36.larc.nasa.gov Dan Karron, Research Associate karron@nyu.edu A. Chris Long, Jr. acl3k@virginia.edu (1) StraightForward: ----- CUT HERE ----- # include # include void redraw() { reshapeviewport(); color(WHITE); clear(); } void main() { long result; short val; char bigsize = 1; long x,y; prefsize(50, 50); winopen("size test"); redraw(); qdevice(ESCKEY); qdevice(SPACEKEY); do { result = qread(&val); switch (result) { case SPACEKEY: if (!val) break; getorigin(&x,&y); if (bigsize) { winposition(x,x+200,y,y+200); prefsize(200,200); } else { winposition(x,x+50,y,y+50); prefsize(50,50); } winconstraints(); bigsize = !bigsize; break; case REDRAW: redraw(); break; } } while (result != ESCKEY); } ----- TO HERE ----- (2) getorigin(&xorigin,&yorigin); getsize(&xsize,&ysize); aspect=(float)xlen/(float)ylen; if(ysize*aspect>xsize) { ysize=(int)((float)xsize/aspect+0.5); } else { xsize=(int)((float)ysize*aspect+0.5); } keepaspect(xsize,ysize); winconstraints(); viewport(0,xsize-1,0,ysize-1); winposition(xorigin,xorigin+xsize-1,yorigin,yorigin+ysize-1); The program reads in image files that can be different sizes. Xlen & Ylen are the size of the image in pixels. This way the window is automatically adjusted to the new image size. Hope this helps. (3) The documentation is muddy on this point. My memory also is not as crisp as it should be. If you want to programatically resize your window, you have to free the window constraints before you resize the window. Use winconstraints(). You actually have to use it twice for some obscure reason,that perhaps being that there are two levels of values to free up. Then you re-constrain the window to your new size and position. Note that the specifications for a new window should be complete, i.e., you need to re-pin all for corners, not just tell it to get bigger, or move from one corner to another. I have some window manager hacks I like, in that I have macros that replace gl window managers calls with private calls that keep a list of your windows and their sizes. When you exit, it writes files containing the state of your windows. When that program restarts, it checks for the state of its window when it last exited/killed and restarts the windows with that. If you would like a copy, look on my anon ftp at karron.med.nyu.edu. ------------------------------------------------------------------------------- Jill Gemmill Neurobiology Research Center INTERNET: jpg@nrc3d.nrc.uab.edu University of Alabama at Birmingham Volker Hall G82E PHONE: 205-934-7111 Birmingham Alabama 35294-0019 FAX: 205-934-6571 -------------------------------------------------------------------------------