From: <dc...@us...> - 2012-11-23 07:41:50
|
Revision: 1477 http://freeglut.svn.sourceforge.net/freeglut/?rev=1477&view=rev Author: dcnieho Date: 2012-11-23 07:41:39 +0000 (Fri, 23 Nov 2012) Log Message: ----------- implemented position callback on windows and some other minor edits Modified Paths: -------------- trunk/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c trunk/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp trunk/freeglut/freeglut/src/fg_ext.c trunk/freeglut/freeglut/src/mswin/fg_main_mswin.c trunk/freeglut/freeglut/src/mswin/fg_state_mswin.c Modified: trunk/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c =================================================================== --- trunk/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c 2012-11-23 07:06:57 UTC (rev 1476) +++ trunk/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c 2012-11-23 07:41:39 UTC (rev 1477) @@ -207,7 +207,7 @@ { int winIdx; int window = getWindowAndIdx(&winIdx); - printf ( "%6d Window %d Reshape Callback: %d %d\n", + printf ( "%6d Window %d Position Callback: %d %d\n", ++sequence_number, window, left, top ) ; position_called[winIdx] = 1 ; position_left[winIdx] = left ; Modified: trunk/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp =================================================================== --- trunk/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp 2012-11-23 07:06:57 UTC (rev 1476) +++ trunk/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp 2012-11-23 07:41:39 UTC (rev 1477) @@ -141,29 +141,35 @@ glutPostRedisplay(); } -void Reshape(int x, int y) +void Reshape(int width, int height) { int win = glutGetWindow(); - nWidth = glutGet(GLUT_WINDOW_WIDTH); - nHeight = glutGet(GLUT_WINDOW_HEIGHT); printf("reshape %s, %dx%d\n",win==nWindow?"main":"child", - nWidth, nHeight); + width, height); - glViewport(0,0,nWidth,nHeight); + glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluOrtho2D(0,nWidth,0,nHeight); + gluOrtho2D(0,width,0,height); if (win==nWindow && nChildWindow!=-1) { glutSetWindow(nChildWindow); - glutPositionWindow((int)(nWidth*.35),(int)(nHeight*.35)); - glutReshapeWindow((int)(nWidth*.3),(int)(nHeight*.3)); + glutPositionWindow((int)(width*.35),(int)(height*.35)); + glutReshapeWindow((int)(width*.3),(int)(height*.3)); glutSetWindow(nWindow); } } +void Position(int x, int y) +{ + int win = glutGetWindow(); + + printf("position %s, %dx%d\n",win==nWindow?"main":"child", + x, y); +} + void Redisplay(void) { int win = glutGetWindow(); @@ -246,6 +252,7 @@ glutKeyboardFunc( SampleKeyboard ); glutDisplayFunc( Redisplay ); glutReshapeFunc( Reshape ); + glutPositionFunc( Position ); glutMainLoop(); printf("glutMainLoop returned\n"); Modified: trunk/freeglut/freeglut/src/fg_ext.c =================================================================== --- trunk/freeglut/freeglut/src/fg_ext.c 2012-11-23 07:06:57 UTC (rev 1476) +++ trunk/freeglut/freeglut/src/fg_ext.c 2012-11-23 07:41:39 UTC (rev 1477) @@ -86,6 +86,7 @@ CHECK_NAME(glutDetachMenu); CHECK_NAME(glutDisplayFunc); CHECK_NAME(glutReshapeFunc); + CHECK_NAME(glutPositionFunc); CHECK_NAME(glutKeyboardFunc); CHECK_NAME(glutMouseFunc); CHECK_NAME(glutMultiEntryFunc); Modified: trunk/freeglut/freeglut/src/mswin/fg_main_mswin.c =================================================================== --- trunk/freeglut/freeglut/src/mswin/fg_main_mswin.c 2012-11-23 07:06:57 UTC (rev 1476) +++ trunk/freeglut/freeglut/src/mswin/fg_main_mswin.c 2012-11-23 07:41:39 UTC (rev 1477) @@ -427,6 +427,17 @@ break; + case WM_MOVE: + { + SFG_Window* saved_window = fgStructure.CurrentWindow; + RECT windowRect; + GetWindowRect( window->Window.Handle, &windowRect ); + + INVOKE_WCB( *window, Position, ( windowRect.left, windowRect.top ) ); + fgSetWindow(saved_window); + } + break; + case WM_SETFOCUS: /* printf("WM_SETFOCUS: %p\n", window ); */ Modified: trunk/freeglut/freeglut/src/mswin/fg_state_mswin.c =================================================================== --- trunk/freeglut/freeglut/src/mswin/fg_state_mswin.c 2012-11-23 07:06:57 UTC (rev 1476) +++ trunk/freeglut/freeglut/src/mswin/fg_state_mswin.c 2012-11-23 07:41:39 UTC (rev 1477) @@ -187,11 +187,9 @@ if (fgStructure.CurrentWindow->Parent && (eWhat==GLUT_WINDOW_X || eWhat==GLUT_WINDOW_Y)) { /* For child window, we should return relative to upper-left - * of parent's client area. + * of parent's client area. */ - POINT topleft; - topleft.x = winRect.left; - topleft.y = winRect.top; + POINT topleft = {winRect.left,winRect.top}; ScreenToClient(fgStructure.CurrentWindow->Parent->Window.Handle,&topleft); winRect.left = topleft.x; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |