[Dda-cvs] ntdda/src/win32gui winmain.c,1.44,1.45
Status: Beta
Brought to you by:
doolin
From: Roozbeh <rgr...@us...> - 2007-11-27 02:44:15
|
Update of /cvsroot/dda/ntdda/src/win32gui In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv3781 Modified Files: winmain.c Log Message: new subroutine added by Roozbeh in which zoomin and zoomout will be handled Index: winmain.c =================================================================== RCS file: /cvsroot/dda/ntdda/src/win32gui/winmain.c,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** winmain.c 1 Jul 2006 15:20:58 -0000 1.44 --- winmain.c 27 Nov 2007 02:44:10 -0000 1.45 *************** *** 39,43 **** #include "toolbar.h" #include "statusbar.h" ! #include "runstates.h" #include "dxf.h" --- 39,44 ---- #include "toolbar.h" #include "statusbar.h" ! #include "runstates.h" ! #include "dxf.h" *************** *** 59,64 **** char szAppName[] = "DDA for Windows"; char mess[80]; /* mess appears to be a temporary variable. Might be able to get rid of it. */ ! ! // Get rid of this as well. --- 60,67 ---- char szAppName[] = "DDA for Windows"; char mess[80]; /* mess appears to be a temporary variable. Might be able to get rid of it. */ ! ! ! ! // Get rid of this as well. *************** *** 142,154 **** ! void ! set_mainwindow_titlebar(HWND hwMain, char * filetype, char * filename) { ! ! char mainWinTitle[120]; ! ! sprintf(mainWinTitle, "%s --- %s: %s",szAppName,filetype,filepath.gfile); ! SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! } ! void --- 145,166 ---- ! void ! ! set_mainwindow_titlebar(HWND hwMain, char * filetype, char * filename) { ! ! ! ! char mainWinTitle[120]; ! ! ! ! sprintf(mainWinTitle, "%s --- %s: %s",szAppName,filetype,filepath.gfile); ! ! SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! } ! ! ! void *************** *** 403,412 **** static int handleKeydown(HWND hwMain, WPARAM wParam, LPARAM lParam) { ! // Added By Roozbeh int wparamlo, wparamhi; ! short delta = 100; ! ! if (whatToDraw == LINES || whatToDraw == BLOCKS) { /* Get the value of LOWORD and HIWORD. --- 415,428 ---- static int handleKeydown(HWND hwMain, WPARAM wParam, LPARAM lParam) { ! ! // Added By Roozbeh int wparamlo, wparamhi; ! short delta = 100; ! ! ! ! if (whatToDraw == LINES || whatToDraw == BLOCKS) { ! /* Get the value of LOWORD and HIWORD. *************** *** 414,422 **** wparamlo = LOWORD(wParam); wparamhi = HIWORD(wParam); - - switch (wparamlo) { ! /* Moving the model using the Left, Right ! * Up and Dwon button. */ case (VK_LEFT): --- 430,442 ---- wparamlo = LOWORD(wParam); wparamhi = HIWORD(wParam); ! ! switch (wparamlo) { ! ! ! /* Moving the model using the Left, Right ! ! * Up and Dwon button. ! */ case (VK_LEFT): *************** *** 428,432 **** break; ! case (VK_UP): yoff = yoff + delta; break; --- 448,453 ---- break; ! case (VK_UP): ! yoff = yoff + delta; break; *************** *** 434,438 **** case (VK_DOWN): yoff = yoff - delta; ! break; /* Zoom in By pressing the Add button. --- 455,460 ---- case (VK_DOWN): yoff = yoff - delta; ! break; ! /* Zoom in By pressing the Add button. *************** *** 440,464 **** */ case (VK_ADD): ! zoom = (long)floor(zoom*1.2); break; ! case (VK_SUBTRACT): zoom = (long)floor(zoom/1.2); ! break; default: break; ! } ! ! InvalidateRect(hwMain, NULL, TRUE); UpdateWindow(hwMain); ! } // Added By Roozbeh ! #if 0 { char mess[128]; sprintf(mess, "nVirtKey: %d",wParam); ! MessageBox(NULL,mess,"keydown",MB_OK); } #endif --- 462,495 ---- */ case (VK_ADD): ! zoom = (long)floor(zoom*1.2); ! break; ! ! case (VK_SUBTRACT): zoom = (long)floor(zoom/1.2); ! break; ! default: break; ! } ! ! ! ! InvalidateRect(hwMain, NULL, TRUE); ! UpdateWindow(hwMain); ! } ! // Added By Roozbeh ! #if 0 ! { char mess[128]; sprintf(mess, "nVirtKey: %d",wParam); ! MessageBox(NULL,mess,"keydown",MB_OK); ! } #endif *************** *** 467,471 **** --- 498,535 ---- } + // Added By Roozbeh + static int + handleZoominoutdown(HWND hwMain, int z) { + + + // Added By Roozbeh + short delta = 100; + + if (whatToDraw == LINES || whatToDraw == BLOCKS) { + + /* Zoom in By pressing the Add button. + * zoom out By pressing the Subtract button. + */ + switch (z) + { + + case (0): + zoom = (long)floor(zoom*1.2); + break; + + case (1): + zoom = (long)floor(zoom/1.2); + break; + } + + + } + InvalidateRect(hwMain, NULL, TRUE); + UpdateWindow(hwMain); + + return 0; + } + //Added By Roozbeh *************** *** 633,638 **** filepath.gfile[0] = '\0'; //sprintf(mainWinTitle, "%s for Windows 95/NT", (LPSTR) szAppName); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain,NULL,NULL); dda_set_menu_state(dda,GEOM_STATE | ABORTED); --- 697,704 ---- filepath.gfile[0] = '\0'; //sprintf(mainWinTitle, "%s for Windows 95/NT", (LPSTR) szAppName); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! set_mainwindow_titlebar(hwMain,NULL,NULL); ! dda_set_menu_state(dda,GEOM_STATE | ABORTED); *************** *** 656,660 **** //sprintf(mainWinTitle, "%s for Windows 95/NT", (LPSTR) szAppName); //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain,NULL,NULL); hInst = (HINSTANCE) GetWindowLong(hwMain, GWL_HINSTANCE); --- 722,727 ---- //sprintf(mainWinTitle, "%s for Windows 95/NT", (LPSTR) szAppName); //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain,NULL,NULL); ! hInst = (HINSTANCE) GetWindowLong(hwMain, GWL_HINSTANCE); *************** *** 666,671 **** { //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", (LPSTR) szAppName, filepath.gfile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); } --- 733,740 ---- { //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", (LPSTR) szAppName, filepath.gfile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); ! } *************** *** 693,698 **** { //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", (LPSTR) szAppName, filepath.gfile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); if (strcmp(filepath.gfile, filepath.oldfile) != 0 && MessageBox(hwMain, "Apply geometry?", "GEOMETRY", MB_YESNO) == IDYES) --- 762,769 ---- { //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", (LPSTR) szAppName, filepath.gfile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); ! if (strcmp(filepath.gfile, filepath.oldfile) != 0 && MessageBox(hwMain, "Apply geometry?", "GEOMETRY", MB_YESNO) == IDYES) *************** *** 723,727 **** //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", (LPSTR) szAppName, (LPSTR) filepath.gfile); //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); dda_set_menu_state(dda,GEOM_STATE); --- 794,799 ---- //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", (LPSTR) szAppName, (LPSTR) filepath.gfile); //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); ! dda_set_menu_state(dda,GEOM_STATE); *************** *** 819,829 **** else { ! ! // TODO: Find a way to handle both Geometry and Analysis files ! // with a titlebar call. //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s, Analysis File = %s", (LPSTR) szAppName, (LPSTR) filepath.gfile, (LPSTR) filepath.afile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! set_mainwindow_titlebar(hwMain, "Analysis",filepath.afile); //updateMainMenu(hwMain, anastate*readystate); --- 891,907 ---- else { ! ! ! // TODO: Find a way to handle both Geometry and Analysis files ! ! // with a titlebar call. ! //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s, Analysis File = %s", (LPSTR) szAppName, (LPSTR) filepath.gfile, (LPSTR) filepath.afile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! ! ! set_mainwindow_titlebar(hwMain, "Analysis",filepath.afile); ! //updateMainMenu(hwMain, anastate*readystate); *************** *** 943,952 **** Geometrydata * geomdata = dda_get_geometrydata(dda); strcpy(filepath.oldfile, filepath.afile); ! filepath.afile[0] = '\0'; ! hInst = (HINSTANCE) GetWindowLong(hwMain, GWL_HINSTANCE); //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", LPSTR) szAppName, filepath.gfile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); if (!DialogBoxParam(hInst, "ANALDLG2", hwMain, (DLGPROC)AnalDlgProc,(LPARAM)geomdata )) --- 1021,1034 ---- Geometrydata * geomdata = dda_get_geometrydata(dda); strcpy(filepath.oldfile, filepath.afile); ! filepath.afile[0] = '\0'; ! ! hInst = (HINSTANCE) GetWindowLong(hwMain, GWL_HINSTANCE); ! //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s", LPSTR) szAppName, filepath.gfile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! set_mainwindow_titlebar(hwMain, "Geometry",filepath.gfile); ! if (!DialogBoxParam(hInst, "ANALDLG2", hwMain, (DLGPROC)AnalDlgProc,(LPARAM)geomdata )) *************** *** 955,962 **** } ! if(filepath.afile[0] != '\0') { //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s, Analysis File = %s", (LPSTR) szAppName, filepath.gfile, filepath.afile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); set_mainwindow_titlebar(hwMain, "Analysis",filepath.afile); --- 1037,1046 ---- } ! if(filepath.afile[0] != '\0') { ! //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s, Analysis File = %s", (LPSTR) szAppName, filepath.gfile, filepath.afile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain, "Analysis",filepath.afile); *************** *** 988,996 **** //iface->setdisplay((unsigned int)hwMain); ! if(filepath.afile[0] != '\0') { //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s, Analysis File = %s", LPSTR) szAppName, filepath.gfile, filepath.afile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! set_mainwindow_titlebar(hwMain, "Analysis",filepath.afile); if (MessageBox(hwMain, "Run analysis?", "ANALYSIS", MB_YESNO) == IDYES) --- 1072,1083 ---- //iface->setdisplay((unsigned int)hwMain); ! if(filepath.afile[0] != '\0') { ! //sprintf(mainWinTitle, "%s for Windows 95/NT --- Geometry = %s, Analysis File = %s", LPSTR) szAppName, filepath.gfile, filepath.afile); ! //SetWindowText(hwMain, (LPCTSTR) mainWinTitle); ! ! set_mainwindow_titlebar(hwMain, "Analysis",filepath.afile); ! if (MessageBox(hwMain, "Run analysis?", "ANALYSIS", MB_YESNO) == IDYES) *************** *** 1738,1743 **** DDA * dda = (DDA *)GetWindowLong(hwMain,GWL_USERDATA); ! LPCTSTR szFilter[] = {"Autocad Dxf files (*.dxf)\0*.dxf\0All files (*.*)\0*.*\0\0"}; ! // TODO: Add a dxf file type for this, instead of shoving into the geometry file. // That way, the dxf file can be modified independently at a future date. fileBrowse(hwMain, &ofn, szFilter, filepath.gpath, filepath.gfile, "dxf"); --- 1825,1832 ---- DDA * dda = (DDA *)GetWindowLong(hwMain,GWL_USERDATA); ! LPCTSTR szFilter[] = {"Autocad Dxf files (*.dxf)\0*.dxf\0All files (*.*)\0*.*\0\0"}; ! ! // TODO: Add a dxf file type for this, instead of shoving into the geometry file. ! // That way, the dxf file can be modified independently at a future date. fileBrowse(hwMain, &ofn, szFilter, filepath.gpath, filepath.gfile, "dxf"); *************** *** 1746,1751 **** strcpy(filepath.gpath, filepath.oldpath); return 0; /* user pressed cancel */ ! } ! set_mainwindow_titlebar(hwMain,"DXF",filepath.gfile); --- 1835,1842 ---- strcpy(filepath.gpath, filepath.oldpath); return 0; /* user pressed cancel */ ! } ! ! ! set_mainwindow_titlebar(hwMain,"DXF",filepath.gfile); *************** *** 1761,1771 **** // The dxf file will be read from this line and lines, polylines // and arcs will be recognized from dxf file ! fp1 = fopen(filepath.gfile,"r"); // WARNING: This overwrites the name of the currently open file fp1! strcpy (filepath.gfile, strcat (filepath.rootname, ".geo")); dxf_read_file(fp1,filepath.gfile); ! ! // Send message to GeomApply to have geometry automatically loaded. ! SendMessage(hwMain, WM_COMMAND, GEOM_APPLY, lParam); return 1; --- 1852,1866 ---- // The dxf file will be read from this line and lines, polylines // and arcs will be recognized from dxf file ! fp1 = fopen(filepath.gfile,"r"); ! // WARNING: This overwrites the name of the currently open file fp1! strcpy (filepath.gfile, strcat (filepath.rootname, ".geo")); dxf_read_file(fp1,filepath.gfile); ! ! ! // Send message to GeomApply to have geometry automatically loaded. ! ! SendMessage(hwMain, WM_COMMAND, GEOM_APPLY, lParam); ! return 1; *************** *** 1938,1943 **** handleAPWEDGE(hwMain); break; ! case DDAHELP_OVERVIEW: case DDAHELP_INDEX: case DDAHELP_GEOMETRY: --- 2033,2046 ---- handleAPWEDGE(hwMain); break; + // Added By Roozbeh + case TOOLBAR_ZOOMOUT: + handleZoominoutdown(hwMain,0); + break; + case TOOLBAR_ZOOMIN: + handleZoominoutdown(hwMain,1); + break; + // Added By Roozbeh ! case DDAHELP_OVERVIEW: case DDAHELP_INDEX: case DDAHELP_GEOMETRY: *************** *** 2127,2131 **** hddawin = CreateWindowEx(WS_EX_ACCEPTFILES, ! szAppName, szAppName, WS_OVERLAPPEDWINDOW | --- 2230,2235 ---- hddawin = CreateWindowEx(WS_EX_ACCEPTFILES, ! szAppName, ! szAppName, WS_OVERLAPPEDWINDOW | |