X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2FResizer%2FResizer.cpp;h=57fce0be9263a30fe4f1a70bb7472af80a3b472a;hb=fade9e761e4438d60759f9a9b6cf679ff7e9c1d7;hp=c2ca76d78aa15771ffa585e6771e6328f6aa647a;hpb=43d5ba94e11af91a1b574ccd7bc8a57c9901fa16;p=freeglut diff --git a/progs/demos/Resizer/Resizer.cpp b/progs/demos/Resizer/Resizer.cpp index c2ca76d..57fce0b 100644 --- a/progs/demos/Resizer/Resizer.cpp +++ b/progs/demos/Resizer/Resizer.cpp @@ -12,7 +12,9 @@ GLboolean bChildPosDone = GL_FALSE, bChildSizeDone = GL_FALSE; void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ); void Redisplay(); -void Reshape(int x, int y); +void Reshape(int width, int height); +void Position(int x, int y); +void WindowStatus(int state); @@ -30,6 +32,12 @@ void DrawQuad() glEnd(); } +void UnhideTimer(int window) +{ + glutSetWindow(window); + glutShowWindow(); +} + void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) { switch (cChar) @@ -117,6 +125,8 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) glutKeyboardFunc( SampleKeyboard ); glutDisplayFunc( Redisplay ); glutReshapeFunc( Reshape ); + glutPositionFunc( Position ); + glutWindowStatusFunc( WindowStatus ); } else { @@ -131,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; } @@ -166,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(); @@ -193,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); @@ -224,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); } @@ -257,6 +293,7 @@ int main(int argc, char* argv[]) glutDisplayFunc( Redisplay ); glutReshapeFunc( Reshape ); glutPositionFunc( Position ); + glutWindowStatusFunc( WindowStatus ); glutTimerFunc(300, Timer, 0);