normalizing line endings..
[freeglut] / progs / demos / Resizer / Resizer.cpp
index 3caf38e..57fce0b 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
@@ -168,10 +196,16 @@ void Position(int x, int y)
 {\r
     int win = glutGetWindow();\r
 \r
-    printf("position %s, %dx%d\n",win==nWindow?"main":"child",\r
+    printf("position, %s: (%d,%d)\n",win==nWindow?"top-left of main":"top-left of child relative to parent",\r
         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
@@ -195,9 +229,9 @@ void Redisplay(void)
     glutPostWindowRedisplay(win);\r
 }\r
 \r
-void Timer(int unused)
-{
-    int win = glutGetWindow();
+void Timer(int unused)\r
+{\r
+    int win = glutGetWindow();\r
     int border, caption;\r
 \r
     nPosX   = glutGet(GLUT_WINDOW_X);\r
@@ -226,10 +260,10 @@ void Timer(int unused)
     else\r
         printf("child window %dx%d, top-left of client at: (%d,%d), relative to parent\n",\r
         nWidth, nHeight,\r
-        nPosX ,nPosY);
-
-    /* (re)set the timer callback and ask glut to call it in 1 second */
-    glutTimerFunc(300, Timer, 0);
+        nPosX ,nPosY);\r
+\r
+    /* (re)set the timer callback and ask glut to call it in 500 ms */\r
+    glutTimerFunc(500, Timer, 0);\r
 }\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