Visibility functions better implemented now. All goes through
[freeglut] / progs / demos / Resizer / Resizer.cpp
index 0ee64ba..2835022 100644 (file)
@@ -14,6 +14,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY );
 void Redisplay();\r
 void Reshape(int width, int height);\r
 void Position(int x, int y);\r
+void WindowStatus(int state);\r
 \r
 \r
 \r
@@ -31,6 +32,12 @@ void DrawQuad()
     glEnd();\r
 }\r
 \r
+void UnhideTimer(int window)\r
+{\r
+    glutSetWindow(window);\r
+    glutShowWindow();\r
+}\r
+\r
 void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )\r
 {\r
     switch (cChar)\r
@@ -119,6 +126,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
             glutDisplayFunc( Redisplay );\r
             glutReshapeFunc( Reshape );\r
             glutPositionFunc( Position );\r
+            glutWindowStatusFunc( WindowStatus );\r
         }\r
         else\r
         {\r
@@ -133,6 +141,26 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
         break;\r
 \r
 \r
+    case 'i':\r
+    case 'I':\r
+        glutIconifyWindow();\r
+        break;\r
+\r
+\r
+    case 'h':\r
+    case 'H':\r
+        if (nChildWindow!=-1 && cChar=='h') /* Capital H always hides the main window*/\r
+        {\r
+            glutSetWindow(nChildWindow);\r
+            glutTimerFunc(2000, UnhideTimer, nChildWindow);\r
+        }\r
+        else\r
+        {\r
+            glutSetWindow(nWindow);\r
+            glutTimerFunc(2000, UnhideTimer, nWindow);\r
+        }\r
+        glutHideWindow();\r
+\r
     default:\r
         break;\r
     }\r
@@ -172,6 +200,12 @@ void Position(int x, int y)
         x, y);\r
 }\r
 \r
+void WindowStatus(int state)\r
+{\r
+    int win = glutGetWindow();\r
+    printf("windowstatus (win %i): %i\n",win,state);\r
+}\r
+\r
 void Redisplay(void)\r
 {\r
     int win = glutGetWindow();\r
@@ -228,8 +262,8 @@ void Timer(int unused)
         nWidth, nHeight,\r
         nPosX ,nPosY);
 
-    /* (re)set the timer callback and ask glut to call it in 1 second */
-    glutTimerFunc(300, Timer, 0);
+    /* (re)set the timer callback and ask glut to call it in 500 ms */
+    glutTimerFunc(500, Timer, 0);
 }\r
 \r
 \r
@@ -259,6 +293,7 @@ int main(int argc, char* argv[])
     glutDisplayFunc( Redisplay );\r
     glutReshapeFunc( Reshape );\r
     glutPositionFunc( Position );\r
+    glutWindowStatusFunc( WindowStatus );\r
 \r
     glutTimerFunc(300, Timer, 0);\r
 \r