implemented glutSetIconTitle that works on win32, when a window is
minimized, its title is now changed, and changed back when it is restored git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1543 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
736f745cc1
commit
78707f3e63
@ -650,6 +650,7 @@ main(int argc, char *argv[])
|
||||
/* 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 );
|
||||
|
@ -92,14 +92,17 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
|
||||
|
||||
/* 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.
|
||||
|
@ -98,6 +98,14 @@ struct tagSFG_PlatformWindowState
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -135,7 +135,21 @@ static void fghUpdateWindowStatus(SFG_Window *window, GLboolean visState)
|
||||
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 */
|
||||
|
@ -702,6 +702,12 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
||||
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);
|
||||
@ -859,6 +865,12 @@ void fgPlatformCloseWindow( SFG_Window* window )
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -908,24 +920,24 @@ void fgPlatformGlutSetWindowTitle( const char* title )
|
||||
#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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user