/* callbacks, settings and menus for this window */
SetWindowCallbacks( 1 );
glutIgnoreKeyRepeat(GL_TRUE);
+ glutSetIconTitle("Icon Test - Callback Demo");
subMenuA = glutCreateMenu( MenuCallback );
glutAddMenuEntry( "Sub menu A1 (01)", 11 );
/* Set the default mouse cursor and reset the modifiers value */
window->State.Cursor = GLUT_CURSOR_INHERIT;
-
- window->IsMenu = isMenu;
-
+
window->State.IgnoreKeyRepeat = GL_FALSE;
window->State.KeyRepeating = GL_FALSE;
window->State.IsFullscreen = GL_FALSE;
window->State.VisualizeNormals= GL_FALSE;
+ window->State.pWState.WindowTitle = NULL;
+ window->State.pWState.IconTitle = NULL;
+
+ window->IsMenu = isMenu;
+
/*
* Open the window now. The fgOpenWindow() function is system
* dependant, and resides in freeglut_window.c. Uses fgState.
GLboolean MouseTracking; /* Needed for generating GLUT_ENTERED and GLUT_LEFT entry func callbacks on windows */
GLboolean WindowFuncCalled; /* Indicate whether windowStatus/visibility func was notified that this window was created */
+
+ /* Need to store window titles to emulate
+ * glutSetIconTitle/glutSetWindowTitle as Windows has only
+ * one title associated with a window and we need to swap
+ * them out based on the window's iconic state
+ */
+ char* WindowTitle;
+ char* IconTitle;
};
if (window->State.Visible != visState)
{
window->State.Visible = visState;
+ /* On win32 we only have two states, window displayed and window not displayed (iconified)
+ * We map these to GLUT_FULLY_RETAINED and GLUT_HIDDEN respectively.
+ */
INVOKE_WCB( *window, WindowStatus, ( visState ? GLUT_FULLY_RETAINED:GLUT_HIDDEN ) );
+
+ /* If top level window (not a subwindow/child), and icon title text available, switch titles based on visibility state */
+ if (!window->Parent && window->State.pWState.IconTitle)
+ {
+ if (visState)
+ /* visible, set window title */
+ SetWindowText( window->Window.Handle, window->State.pWState.WindowTitle );
+ else
+ /* not visible, set icon title */
+ SetWindowText( window->Window.Handle, window->State.pWState.IconTitle );
+ }
}
/* Also set visibility state for children */
if( !( window->Window.Handle ) )
fgError( "Failed to create a window (%s)!", title );
+ /* Store title */
+ {
+ window->State.pWState.WindowTitle = malloc (strlen(title) + 1);
+ strcpy(window->State.pWState.WindowTitle, title);
+ }
+
#if !defined(_WIN32_WCE)
/* Need to set requested style again, apparently Windows doesn't listen when requesting windows without title bar or borders */
SetWindowLong(window->Window.Handle, GWL_STYLE, flags);
}
DestroyWindow( window->Window.Handle );
+
+ /* clean up copied title text(s) */
+ if (window->State.pWState.WindowTitle)
+ free(window->State.pWState.WindowTitle);
+ if (window->State.pWState.IconTitle)
+ free(window->State.pWState.IconTitle);
}
#else
SetWindowText( fgStructure.CurrentWindow->Window.Handle, title );
#endif
+
+ /* Make copy of string to refer to later */
+ if (fgStructure.CurrentWindow->State.pWState.WindowTitle)
+ free(fgStructure.CurrentWindow->State.pWState.WindowTitle);
+ fgStructure.CurrentWindow->State.pWState.WindowTitle = malloc (strlen(title) + 1);
+ strcpy(fgStructure.CurrentWindow->State.pWState.WindowTitle, title);
}
/*
* Set the current window's iconified title
- * There really isn't a way to set the icon name separate from the
- * windows name in Win32, so, just set the windows name.
*/
void fgPlatformGlutSetIconTitle( const char* title )
{
-#ifdef _WIN32_WCE
- {
- wchar_t* wstr = fghWstrFromStr(title);
- SetWindowText( fgStructure.CurrentWindow->Window.Handle, wstr );
- free(wstr);
- }
-#else
- SetWindowText( fgStructure.CurrentWindow->Window.Handle, title );
-#endif
+ /* Make copy of string to refer to later */
+ if (fgStructure.CurrentWindow->State.pWState.IconTitle)
+ free(fgStructure.CurrentWindow->State.pWState.IconTitle);
+ fgStructure.CurrentWindow->State.pWState.IconTitle = malloc (strlen(title) + 1);
+ strcpy(fgStructure.CurrentWindow->State.pWState.IconTitle, title);
}
/*