X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=progs%2Fdemos%2FResizer%2FResizer.cpp;h=57fce0be9263a30fe4f1a70bb7472af80a3b472a;hb=ddeb18541f3200ccb703af94a2d91e5301b55c3e;hp=3caf38e8d6ba0495d1f4722c1fb67a7644d810c2;hpb=45513505af6c7113e6d85d3ae0732d516d5f89c7;p=freeglut diff --git a/progs/demos/Resizer/Resizer.cpp b/progs/demos/Resizer/Resizer.cpp index 3caf38e..57fce0b 100644 --- a/progs/demos/Resizer/Resizer.cpp +++ b/progs/demos/Resizer/Resizer.cpp @@ -14,6 +14,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ); void Redisplay(); void Reshape(int width, int height); void Position(int x, int y); +void WindowStatus(int state); @@ -31,6 +32,12 @@ void DrawQuad() glEnd(); } +void UnhideTimer(int window) +{ + glutSetWindow(window); + glutShowWindow(); +} + void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) { switch (cChar) @@ -119,6 +126,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) glutDisplayFunc( Redisplay ); glutReshapeFunc( Reshape ); glutPositionFunc( Position ); + glutWindowStatusFunc( WindowStatus ); } else { @@ -133,6 +141,26 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) break; + case 'i': + case 'I': + glutIconifyWindow(); + break; + + + case 'h': + case 'H': + if (nChildWindow!=-1 && cChar=='h') /* Capital H always hides the main window*/ + { + glutSetWindow(nChildWindow); + glutTimerFunc(2000, UnhideTimer, nChildWindow); + } + else + { + glutSetWindow(nWindow); + glutTimerFunc(2000, UnhideTimer, nWindow); + } + glutHideWindow(); + default: break; } @@ -168,10 +196,16 @@ void Position(int x, int y) { int win = glutGetWindow(); - printf("position %s, %dx%d\n",win==nWindow?"main":"child", + printf("position, %s: (%d,%d)\n",win==nWindow?"top-left of main":"top-left of child relative to parent", x, y); } +void WindowStatus(int state) +{ + int win = glutGetWindow(); + printf("windowstatus (win %i): %i\n",win,state); +} + void Redisplay(void) { int win = glutGetWindow(); @@ -195,9 +229,9 @@ void Redisplay(void) glutPostWindowRedisplay(win); } -void Timer(int unused) -{ - int win = glutGetWindow(); +void Timer(int unused) +{ + int win = glutGetWindow(); int border, caption; nPosX = glutGet(GLUT_WINDOW_X); @@ -226,10 +260,10 @@ void Timer(int unused) else printf("child window %dx%d, top-left of client at: (%d,%d), relative to parent\n", nWidth, nHeight, - nPosX ,nPosY); - - /* (re)set the timer callback and ask glut to call it in 1 second */ - glutTimerFunc(300, Timer, 0); + nPosX ,nPosY); + + /* (re)set the timer callback and ask glut to call it in 500 ms */ + glutTimerFunc(500, Timer, 0); } @@ -259,6 +293,7 @@ int main(int argc, char* argv[]) glutDisplayFunc( Redisplay ); glutReshapeFunc( Reshape ); glutPositionFunc( Position ); + glutWindowStatusFunc( WindowStatus ); glutTimerFunc(300, Timer, 0);