ANIMATE.C

Go to the documentation of this file.
00001 /* file ANIMATE.C The main entry point for the animation module   */
00002 /* This file contains the module's message loop and the code for  */
00003 /* the main windows' window functions and the command dispatcher  */
00004 
00005 #define MODULE_ANIMATE 1
00006 
00007 #include "animate.h"
00008 
00009 #include "callall.h"
00010 
00011 #define NFILESLIST 5
00012 #define LASTFILECMD 31000
00013 
00014 typedef struct tagLASTFILESLIST{
00015   BOOL present;
00016   char file[256];
00017 } LASTFILESLIST;
00018 
00019 static VOID AnimatorMenuCmd(int,HWND,long);
00020 static void ExecuteKeyboardKeyCommand(int key);
00021 static BOOL SetTriViewCursor(BOOL type);
00022 static void UpdateLastFilesList(char *newname);
00023 
00024 extern HINSTANCE __cdecl ResourceX(void);
00025 
00026 HBITMAP hBmBackground=NULL;
00027 UINT AnimationTimer=0;
00028 
00029 static HWND hWndHelp=NULL;
00030 static BOOL bTrackMouse=FALSE,bTrackIcon=FALSE,bToolCaptured=FALSE,
00031             bSpaceDown=FALSE,bTrackPan=FALSE,bCtrlDown=FALSE,
00032             bShiftDown=FALSE,bAltDown=FALSE,bResizing=FALSE;
00033 static int  ScreenXsize,ScreenYsize;
00034 static UINT screen_ready=0;
00035 static int  view_dragging=0,trap_scroll_cursor=0;
00036 static int lmessage_table[2]={IDS_SWAPSVIEW,IDS_SWAP3VIEW};
00037 static int tmessage_table[MAXTOOLS]={
00038     IDS_SELECTTOOL,IDS_NODESELECTOR1,IDS_PANTOOL,IDS_INZOOMTOOL,
00039     IDS_GRABBERTOOL,IDS_ROTATORTOOL,IDS_SIZERTOOL,
00040     IDS_TRACKER,IDS_PATHEDITORTOOL,IDS_SKELETORTOOL
00041                                     };
00042 static char gszSTGsaved[256]={"unnamed.ofx"};
00043 static LASTFILESLIST LastFilesList[NFILESLIST];
00044 static int nLastFiles=0;
00045 
00046 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
00047                      LPSTR lpCmdLine, int nCmdShow){
00048  int i;
00049  MSG msg;
00050  HWND hWndPrev;
00051  HANDLE hAccel,hNewAccel;
00052 #include "..\timeout.c"
00053  hWndPrev = FindWindow(szMainClass, NULL);
00054  if (hWndPrev != NULL){
00055    SetForegroundWindow(hWndPrev);
00056    BringWindowToTop(hWndPrev);
00057    ShowWindow (hWndPrev,SW_SHOW);
00058    return FALSE;
00059  }
00060  // Get the INI file to use and working folder for temporary files
00061  {
00062   FILE *fini=NULL; int ix;
00063   GetModuleFileName(hInstance,IniFilename,256);
00064   *FileInPath(IniFilename) = '\0';
00065   strcpy(TempPath,IniFilename);
00066   strcat(IniFilename,"OPENFX_.CFG");
00067   if((fini=fopen(IniFilename,"r")) != NULL){
00068 //MessageBox(NULL,TempPath,"Read from Config File",MB_OK);
00069     fscanf(fini,"%ld",&ix);
00070     strcpy(TempPath,"X");
00071     fscanf(fini," %[^\n]",TempPath);
00072     if(ix > 1){
00073       fscanf(fini," %[^\n]",IniFilename);
00074     }
00075     else  *FileInPath(IniFilename) = '\0';
00076     fclose(fini);
00077   }
00078   else {
00079     char *pE;
00080     pE=R_GetEnv("TEMP");
00081     if(pE != NULL){
00082       strcpy(TempPath,pE); strcat(TempPath,"\\");
00083       strcpy(IniFilename,TempPath);
00084       *FileInPath(TempPath) = '\0';
00085     }
00086     *FileInPath(IniFilename) = '\0';
00087 //MessageBox(NULL,TempPath,"From envoronment variable",MB_OK);
00088   }
00089   strcat(IniFilename,"OPENFX_.INI");
00090 //MessageBox(NULL,IniFilename,"IniFilename",MB_OK);
00091  }
00092  // 
00093  hInstance=ResourceX();
00094  InitCommonControls();
00095  debug=NULL;
00096  strcpy(ruler_name,"None");
00097  ghdc_triview_Bitmap[0]=ghdc_triview_Bitmap[1]=
00098  ghdc_triview_Bitmap[2]=ghdc_view_Bitmap=NULL;
00099  ghbm_triview[0]=ghbm_triview[1]=ghbm_triview[2]=ghbm_view=NULL;
00100  gCurTool=gCurCommand=gCurSelect= -1;
00101  if(!hPrevInstance){
00102    WNDCLASS wc;
00103    BOOL     rc;
00104    if((ghpaletteScreen=CreateAppPalette(&ScreenXsize,&ScreenYsize)) == NULL)
00105      return FALSE;
00106    wc.lpszClassName = szMainClass;
00107    wc.style = CS_HREDRAW | CS_VREDRAW;
00108    wc.lpfnWndProc = (WNDPROC)MainAnimatorWndProc;
00109    wc.cbClsExtra = 0;
00110    wc.cbWndExtra = 0;
00111    wc.hInstance = hInstance;
00112    wc.hIcon = LoadIcon(hInstance,"ANIMATORICON");
00113    wc.hCursor = LoadCursor(NULL,IDC_ARROW);
00114    wc.hbrBackground = NULL;
00115    wc.lpszMenuName = MAKEINTRESOURCE(ANIMATOR_MENU);
00116    rc = RegisterClass( &wc );
00117    if(!rc)return FALSE;
00118    wc.lpszClassName = szTriViewClass;
00119    wc.style = CS_DBLCLKS;
00120    wc.lpfnWndProc = (WNDPROC)AnimatorTriViewWndProc;
00121    wc.cbClsExtra = 0;
00122    wc.cbWndExtra = 0;
00123    wc.hInstance = hInstance;
00124    wc.hIcon = NULL;
00125    wc.hCursor = LoadCursor(NULL,IDC_ARROW);
00126    wc.hbrBackground = NULL;
00127    wc.lpszMenuName = NULL;
00128    rc = RegisterClass( &wc );
00129    if(!rc)return FALSE;
00130    wc.lpszClassName = szViewClass;
00131    wc.style = 0;
00132    wc.lpfnWndProc = (WNDPROC)AnimatorViewWndProc;
00133    wc.cbClsExtra = 0;
00134    wc.cbWndExtra = 0;
00135    wc.hInstance = hInstance;
00136    wc.hIcon = NULL;
00137    wc.hCursor = LoadCursor(NULL,IDC_ARROW);
00138    wc.hbrBackground = NULL;
00139    wc.lpszMenuName = NULL;
00140    rc = RegisterClass( &wc );
00141    if(!rc)return FALSE;
00142    wc.lpszClassName = szToolboxClass;
00143    wc.style = 0;
00144    wc.lpfnWndProc = (WNDPROC)ToolboxWndProc;
00145    wc.cbClsExtra = 0;
00146    wc.cbWndExtra = 0;
00147    wc.hInstance = hInstance;
00148    wc.hIcon = NULL;
00149    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00150    wc.hbrBackground = NULL; //GetStockObject(LTGRAY_BRUSH);
00151    wc.lpszMenuName = NULL;
00152    if(!RegisterClass(&wc))return FALSE;
00153    wc.lpszClassName = szToolBtnClass;
00154    wc.style = CS_DBLCLKS;
00155    wc.lpfnWndProc = (WNDPROC)ToolBtnWndProc;
00156    wc.cbClsExtra = 0;
00157    wc.cbWndExtra = 0;
00158    wc.hInstance = hInstance;
00159    wc.hIcon = NULL;
00160    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00161    wc.hbrBackground = NULL; //(HBRUSH)(COLOR_WINDOW + 1);
00162    wc.lpszMenuName = NULL;
00163    if(!RegisterClass(&wc))return FALSE;
00164    wc.lpszClassName = szQuicktimeClass;
00165    wc.style = 0;
00166    wc.lpfnWndProc = (WNDPROC)QuicktimeWndProc;
00167    wc.cbClsExtra = 0;
00168    wc.cbWndExtra = 0;
00169    wc.hInstance = hInstance;
00170    wc.hIcon = NULL;
00171    wc.hCursor = LoadCursor(NULL,IDC_ARROW);
00172    wc.hbrBackground = GetStockObject(DKGRAY_BRUSH);
00173    wc.lpszMenuName = NULL;
00174    rc = RegisterClass( &wc );
00175    if(!rc)return FALSE;
00176  }
00177  if((hLibSpin=LoadLibrary("spin.dll")) == NULL){
00178    SendPrgmQuery(IDQ_FAILEDSPIN,3);
00179  }
00180  if(!RegisterNoAlphaWndClass(hInstance)){
00181    SendPrgmQuery(IDQ_FAILEDTIDE,3);
00182  }
00183  ghinst_main=hInstance;
00184  LoadPreferences();
00185  LoadArrowIcons();
00186  /* WARNING no Message Boxes until Window LOOP */
00187  if(!SetupMainWindow(ghinst_main,nCmdShow))return FALSE;
00188  ActivatePreferences();
00189  if(!AnimatorStartup(&screen_ready))return FALSE;
00190  if(setjmp(j_buf) != 0){
00191    SendPrgmQuery(IDQ_FATALERROR,3);
00192    return 0;
00193  }
00194  hAccel=LoadAccelerators(ghinst_main,MAKEINTRESOURCE(ANIMATOR_ACCEL));
00195  if(hAccel == NULL){
00196    SendPrgmQuery(IDQ_FAILEDACCELS,3);
00197    return 0;
00198  }
00199  hNewAccel=hAccel;
00200  ghwndOpenGLview=NULL;
00201  if(EnableGLview() && opengl_visible)StartGLview(TRUE);
00202 
00203  if(StartedInAnimator){
00204    if(GetCommandLine() != NULL){
00205      int X__argc=0;
00206      long l;
00207      char *cp,*cp1,cmdl[256];
00208      strcpy(cmdl,GetCommandLine());
00209      AnsiLower(cmdl);
00210      if((cp=strstr(cmdl,".exe")) != NULL){
00211        if((cp=strchr(cp,' ')) != NULL){
00212          cp++;
00213          if((cp1=strchr(cp,'"')) != NULL)cp=cp1+1;
00214          if((cp1=strchr(cp,'"')) != NULL)*cp1=0;
00215          l=strlen(cp);
00216          X__argc=2;
00217          if(l < 2)X__argc=0;
00218        }
00219        else X__argc=0;
00220      }
00221      else X__argc=0;
00222      if(X__argc > 1){
00223        //MessageBox(NULL,cp,"Loading", MB_OK);
00224        WritePrivateProfileString("CALLBACK","FILE",cp,IniFilename);
00225        PostMessage(ghwnd_main,WM_COMMAND,IDM_FILE_LOAD_DIRECT,0);
00226      }
00227      else  LogOnMessage();
00228    }
00229    else  LogOnMessage();
00230    {
00231      char pref_id[32];
00232      GetPrivateProfileString(IniSection,"KEYVISIBLE","$$$",
00233                              pref_id,sizeof(pref_id),IniFilename);
00234      if(strncmp(pref_id,"YES",3) == 0)PostMessage(ghwnd_main,
00235         WM_COMMAND,(WPARAM)IDM_FILE_KEYFRAMER,(LPARAM)0);
00236    }
00237  }
00238  while (GetMessage(&msg,NULL,0,0)){
00239    if(!IsWindow(ghwndCoord1) || !IsDialogMessage(ghwndCoord1,&msg)){
00240      if(!IsWindow(ghwndDlgTools) || !IsDialogMessage(ghwndDlgTools,&msg)){
00241      if(!IsWindow(hWndHelp) || !IsDialogMessage(hWndHelp,&msg)){
00242        if(!TranslateAccelerator(ghwnd_main,hNewAccel,&msg)){
00243          TranslateMessage(&msg);
00244          DispatchMessage(&msg);
00245        }
00246      }
00247      }
00248    }
00249  }
00250  DisengageTool();
00251  if(debug != NULL)fclose(debug);
00252  if(IsWindow(ghwndTimeline) && IsWindowVisible(ghwndTimeline))
00253    WritePrivateProfileString(IniSection,"KEYVISIBLE","YES",IniFilename);
00254  else
00255    WritePrivateProfileString(IniSection,"KEYVISIBLE","NO",IniFilename);
00256  DestroyWindow(ghwnd_main);
00257  AnimatorShutdown();
00258  if(hLibSpin != NULL)FreeLibrary(hLibSpin);
00259  return (msg.wParam);
00260 }
00261 
00262 //
00263 // The programs main window WINDOWPROC this windows contains the 3 views,
00264 // the camera view window, the toolpannel window and the status display.
00265 //
00266 
00267 LRESULT CALLBACK MainAnimatorWndProc(HWND hwnd, UINT msg, WPARAM wparam,
00268                                     LPARAM lparam ){
00269  static BOOL slider_lock=FALSE,bCaptured=FALSE;
00270  static int  last_x,last_y,type=0;
00271  static RECT rc;
00272  int i,oldi,x,y,ltype;
00273  switch( msg ){
00274    case WM_CALLBACK_RENDER_GL_SWITCH:
00275      /* call to this point to switch from the camera view */
00276      if(View == TRIVIEW){
00277        if(!BigCameraView)PostMessage(ghwnd_main,
00278                WM_COMMAND,(WPARAM)IDM_WINDOW_BIGCAMERA,0);
00279        PostMessage(ghwnd_main,WM_COMMAND,
00280                (WPARAM)IDM_WINDOW_SWITCHWINDOWS,0);
00281      }
00282      else{
00283        PostMessage(ghwnd_main,WM_COMMAND,
00284                (WPARAM)IDM_WINDOW_SWITCHWINDOWS,0);
00285        if(BigCameraView)PostMessage(ghwnd_main,
00286                WM_COMMAND,(WPARAM)IDM_WINDOW_BIGCAMERA,0);
00287      }
00288      break;
00289    case WM_CALLBACK_RENDER_GL: /* OPEN_GL call to update script for DLL */
00290      UpdateGLview(TRUE);
00291      break;
00292    case WM_CREATE:
00293      if(bBackgroundImage){
00294        hBmBackground=LoadImage(ghinst_main,"animator.bmp",IMAGE_BITMAP,
00295                                0,0,LR_LOADFROMFILE);
00296        if(hBmBackground == NULL)
00297          hBmBackground=LoadBitmap(ghinst_main,"screenbitmap");
00298      }
00299      break;
00300    case WM_DESTROY:
00301      if(hBmBackground != NULL)DeleteObject(hBmBackground);
00302      hBmBackground=NULL;
00303      break;
00304    case WM_ACTIVATE:
00305      if(LOWORD(wparam) == WA_INACTIVE && (
00306        (HWND)lparam == ghwndCoord1 ||
00307        (HWND)lparam == ghwndDlgTools))
00308      SendMessage(hwnd,WM_NCACTIVATE,(WPARAM)TRUE,0);
00309      else return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00310      break;
00311    case WM_ACTIVATEAPP:
00312      PostMessage(hwnd,WM_NCACTIVATE,wparam,0);
00313      break;
00314    case WM_SETCURSOR:
00315      if(((HWND)wparam == ghwnd_main ||
00316          (HWND)wparam == ghwnd_xscl) && current_message >= 0){
00317        current_message = -1;
00318        SendPrgmMessage(IDS_ZERO,1);
00319      }
00320      return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00321    case WM_MENUSELECT:{
00322        HMENU hmenu;
00323        UINT fuFlags,uItem,id,i;
00324        if(bSpaceDown){
00325          bSpaceDown=FALSE; bCtrlDown=FALSE; bShiftDown=FALSE; bAltDown=FALSE;
00326        }
00327        hmenu=(HMENU)lparam;
00328        fuFlags=(UINT)HIWORD(wparam);
00329        uItem=(UINT)LOWORD(wparam);
00330        id=0;
00331        if(fuFlags == 0xFFFF)id=0;
00332        else if(fuFlags & MF_POPUP){
00333        }
00334        else{
00335          id=CheckMenuHelpData(uItem);
00336        }
00337        DisplayMenuHelpData(ghwnd_info,id);
00338      }
00339      break;
00340    case WM_LBUTTONDOWN:
00341      x=(short)LOWORD(lparam); y=(short)HIWORD(lparam);
00342      type=0;
00343      if(View == TRIVIEW){
00344        if(x > WindowLeftOrigin+Window0sizeX - 20 &&
00345           x < WindowLeftOrigin+Window0sizeX + 20 &&
00346           y > WindowTopOrigin+Window0sizeY  - 20 &&
00347           y < WindowTopOrigin+Window0sizeY  + 20)type=1;
00348        else if(x > WindowLeftOrigin+Window0sizeX - 10 &&
00349                x < WindowLeftOrigin+Window0sizeX + 10 &&
00350                y > WindowTopOrigin+10 &&
00351                y < WindowTopOrigin+TriviewSpaceY)type=2;
00352        else if(y > WindowTopOrigin+Window0sizeY - 10 &&
00353                y < WindowTopOrigin+Window0sizeY + 10 &&
00354                x > WindowLeftOrigin+10 &&
00355                x < WindowLeftOrigin+TriviewSpaceX-10)type=3;
00356      }
00357      if     (type == 1)SetCursor(LoadCursor(NULL,IDC_SIZEALL));
00358      else if(type == 2)SetCursor(LoadCursor(NULL,IDC_SIZEWE));
00359      else if(type == 3)SetCursor(LoadCursor(NULL,IDC_SIZENS));
00360      if(type > 0){
00361        HDC hdc;
00362        hdc=GetDC(ghwnd_main);
00363        FocusActiveWindow(hdc,FALSE);
00364        ReleaseDC(ghwnd_main,hdc);
00365        SetCapture(hwnd);
00366        DeleteMemoryWindows();
00367        bResizing=TRUE;
00368        bCaptured=TRUE;
00369        GetClientRect(hwnd,&rc);
00370        last_x=x; last_y=y;
00371      }
00372      break;
00373    case WM_LBUTTONUP:
00374      if(bCaptured){
00375        HDC hdc;
00376        hdc=GetDC(ghwnd_main);
00377        FocusActiveWindow(hdc,TRUE);
00378        ReleaseDC(ghwnd_main,hdc);
00379        ReleaseCapture();
00380        bCaptured=FALSE;
00381        bResizing=FALSE;
00382        CreateMemoryWindows();
00383        InvalidateRect(ghwndQuicktime,NULL,TRUE);
00384        UpdateWindow(ghwndQuicktime);
00385        ReDrawStageDisplay(TRUE);
00386        if(ghwndOpenGLview != NULL)UpdateGLview(TRUE);
00387        else PerspectiveView(0,0);
00388        type=0;
00389      }
00390      break;
00391    case WM_MOUSEWHEEL:{
00392        long zDelta;
00393        zDelta = GET_WHEEL_DELTA_WPARAM(wparam);
00394        Zoom2( (double)zDelta/(double)WHEEL_DELTA);
00395      }
00396      return 0;
00397    case WM_MOUSEMOVE:
00398      x=(short)LOWORD(lparam); y=(short)HIWORD(lparam);
00399      if(!bCaptured && View == TRIVIEW){
00400        ltype=0;
00401        if(x > WindowLeftOrigin+Window0sizeX - 20 &&
00402           x < WindowLeftOrigin+Window0sizeX + 20 &&
00403           y > WindowTopOrigin+Window0sizeY  - 20 &&
00404           y < WindowTopOrigin+Window0sizeY  + 20)ltype=1;
00405        else if(x > WindowLeftOrigin+Window0sizeX - 10 &&
00406                x < WindowLeftOrigin+Window0sizeX + 10 &&
00407                y > WindowTopOrigin+10 &&
00408                y < WindowTopOrigin+TriviewSpaceY)ltype=2;
00409        else if(y > WindowTopOrigin+Window0sizeY - 10 &&
00410                y < WindowTopOrigin+Window0sizeY + 10 &&
00411                x > WindowLeftOrigin+10 &&
00412                x < WindowLeftOrigin+TriviewSpaceX-10)ltype=3;
00413        if     (ltype == 1)SetCursor(LoadCursor(NULL,IDC_SIZEALL));
00414        else if(ltype == 2)SetCursor(LoadCursor(NULL,IDC_SIZEWE));
00415        else if(ltype == 3)SetCursor(LoadCursor(NULL,IDC_SIZENS));
00416      }
00417      if(bCaptured){
00418          int dx,dy;
00419          if     (type == 1)SetCursor(LoadCursor(NULL,IDC_SIZEALL));
00420          else if(type == 2)SetCursor(LoadCursor(NULL,IDC_SIZEWE));
00421          else if(type == 3)SetCursor(LoadCursor(NULL,IDC_SIZENS));
00422          dx=x-last_x; dy=y-last_y;
00423          if(dx != 0 || dy != 0){
00424            if     (type == 2)dy=0;
00425            else if(type == 3)dx=0;
00426            Window0sizeX += dx;
00427            Window0sizeX = max(20,Window0sizeX);
00428            Window0sizeX = min(TriviewSpaceX-30,Window0sizeX);
00429            Window0sizeY += dy;
00430            Window0sizeY = max(20,Window0sizeY);
00431            Window0sizeY = min(TriviewSpaceY-30,Window0sizeY);
00432            SetWindowSize(rc.right,rc.bottom,View,FALSE);
00433            GetTriview(FALSE);
00434            for(i=0;i<3;i++)
00435              MoveWindow(ghwnd_triview[i],
00436                       WindowsXmin[i],WindowsYmin[i],
00437                       WindowSizeX[i],WindowSizeY[i],TRUE);
00438            MoveWindow(ghwnd_view,
00439                       WindowViewXmin,WindowViewYmin,
00440                       WindowViewXsize,WindowViewYsize,TRUE);
00441            if(ghwndOpenGLview != NULL)MoveWindow(ghwndOpenGLview,
00442                       WindowViewXmin,WindowViewYmin,
00443                       WindowViewXsize,WindowViewYsize,TRUE);
00444            MoveWindow(ghwndQuicktime,
00445                       WindowViewSliderXpos,WindowViewSliderYpos,
00446                       WindowViewSliderXsize,WindowViewSliderYsize,TRUE);
00447            UpdateWindow(ghwnd_view);
00448            UpdateWindow(ghwnd_triview[1]);
00449 
00450          }
00451          last_x=x; last_y=y;
00452      }
00453      break;
00454    case WM_RBUTTONDOWN:
00455      SendMessage(ghwnd_main,WM_COMMAND,IDM_STOP_TOOL,0);
00456      break;
00457    case WM_ERASEBKGND:{
00458       HDC hDC;
00459       HPALETTE hpalT;
00460       HBRUSH hOldBrush;
00461       RECT rc1;
00462       hDC = (HDC)wparam;
00463       if(hBmBackground == NULL){
00464         hOldBrush = SelectObject (hDC,ghbrushScreen);
00465         GetClientRect(hwnd,(LPRECT)&rc1);
00466         PatBlt(hDC,0,0,rc1.right,rc1.bottom,PATCOPY);
00467         SelectObject (hDC, hOldBrush);
00468       }
00469       else{
00470         HDC hMemDC;
00471         HBITMAP hbmOld;
00472         BITMAP  bm;
00473         GetObject(hBmBackground,sizeof(BITMAP),&bm);
00474         hMemDC = CreateCompatibleDC(hDC);
00475         hbmOld = SelectObject(hMemDC,hBmBackground);
00476         for(x=0;x<(ScreenXsize/bm.bmWidth)+1;x++)
00477         for(y=0;y<(ScreenYsize/bm.bmHeight)+1;y++)
00478           BitBlt(hDC,
00479                   x*bm.bmWidth,y*bm.bmHeight,
00480                   bm.bmWidth,
00481                   bm.bmHeight,
00482                   hMemDC,
00483                   0,0,
00484                   SRCCOPY);
00485         SelectObject(hMemDC,hbmOld);
00486         DeleteDC(hMemDC);
00487       }
00488       return TRUE;
00489     }
00490   case WM_PAINT: {
00491        HDC hdc;
00492        PAINTSTRUCT ps;
00493        HBRUSH hOldBrush;
00494        HPALETTE hpalT;
00495        RECT rc1;
00496        hdc=BeginPaint(hwnd,&ps);
00497        if(hBmBackground == NULL){
00498          hOldBrush = SelectObject (hdc,ghbrushScreen);
00499          GetClientRect(hwnd,(LPRECT)&rc1);
00500          PatBlt(hdc,0,0,rc1.right,rc1.bottom,PATCOPY);
00501          SelectObject (hdc, hOldBrush);
00502        }
00503        if(!bResizing)FocusActiveWindow(hdc,TRUE);  // ????
00504        EndPaint(hwnd,&ps);
00505      }
00506      break;
00507    case WM_SYSCOMMAND:
00508      switch(LOWORD(wparam & 0xfff0)){
00509        case SC_CLOSE:
00510          PostMessage(hwnd,WM_COMMAND,IDM_FILE_EXIT,0);
00511          break;
00512        default:
00513          return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00514          break;
00515      }
00516      break;
00517    case WM_COMMAND:
00518      if(HIWORD(wparam) == 1)lparam=ActiveView; /* acelerator */
00519      if(HIWORD(wparam) == BN_CLICKED){
00520        AnimatorMenuCmd(LOWORD(wparam),hwnd,lparam);
00521      }
00522      else AnimatorMenuCmd(LOWORD(wparam),hwnd,lparam);
00523      break;
00524    case WM_HSCROLL:
00525      if((HWND)lparam != ghwnd_xscl)break;
00526      oldi = -1;
00527      if(!trap_scroll_cursor){
00528        GetWindowRect(ghwnd_xscl,&rc);
00529        ClipCursor(&rc);
00530        trap_scroll_cursor=1;
00531      }
00532      switch (LOWORD(wparam)) {
00533        case SB_ENDSCROLL:
00534         if(trap_scroll_cursor){
00535           ClipCursor(NULL);
00536           trap_scroll_cursor=0;
00537           SetFocus(ghwnd_main);
00538         }
00539         oldi=1; break;
00540        case SB_LINEDOWN:
00541         oldi=0;
00542         CurrentFrame++;
00543         if(GetKeyState(VK_CONTROL) & 0x8000)CurrentFrame=Nframes;
00544         break;
00545        case SB_LINEUP:
00546         oldi=0;
00547         CurrentFrame--;
00548         if(GetKeyState(VK_CONTROL) & 0x8000)CurrentFrame=1;
00549         break;
00550        case SB_PAGEDOWN:
00551          oldi=0;
00552          if(Nframes < 50)CurrentFrame += min(5,Nframes/5);
00553          else            CurrentFrame += min(10,Nframes/10);
00554          break;
00555        case SB_PAGEUP:
00556          oldi=0;
00557          if(Nframes < 50)CurrentFrame -= min(5,Nframes/5);
00558          else            CurrentFrame -= min(10,Nframes/10);
00559          break;
00560        case SB_THUMBTRACK:
00561          CurrentFrame=(long)HIWORD(wparam);  oldi=0; break;
00562        case SB_THUMBPOSITION:
00563          CurrentFrame=(long)HIWORD(wparam);  oldi=0; break;
00564        default: break;
00565      }
00566      if(CurrentFrame < 1)CurrentFrame=1;
00567      if(CurrentFrame > Nframes)CurrentFrame=Nframes;
00568      if(oldi >= 0){
00569 //       SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
00570        SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
00571        if(View == TRIVIEW || View == ONEVIEW){
00572          if(oldi == 1)ghcurSave=SetCursor(ghcurWait);
00573          if(ghwndOpenGLview == NULL)PerspectiveView(0,oldi);
00574          if(oldi == 1){
00575            SetCursor(ghcurSave);
00576            ReDrawStageDisplay(TRUE);
00577            UpdateSelectedActor(FALSE);
00578            UpdateGLview(TRUE);
00579            if(IsWindow(ghwndRobotView))
00580              SendMessage(ghwndRobotView,WM_DRAWROBOT,0,0);
00581          }
00582          else UpdateGLview(FALSE);
00583        }
00584      }
00585      break;
00586    case WM_SIZE:{
00587        int cx,cy;
00588        if(screen_ready){
00589          DeleteMemoryWindows();
00590          cx=LOWORD(lparam); cy=HIWORD(lparam);
00591          SetWindowSize(cx,cy,View,FALSE);
00592          GetTriview(FALSE);
00593          if(View == TRIVIEW){
00594            for(i=0;i<3;i++){
00595              MoveWindow(ghwnd_triview[i],WindowsXmin[i],WindowsYmin[i],
00596                         WindowSizeX[i],WindowSizeY[i],TRUE);
00597            }
00598          }
00599          else{
00600            MoveWindow(ghwnd_current,
00601                       WindowsXmin[ActiveView],WindowsYmin[ActiveView],
00602                       WindowSizeX[ActiveView],WindowSizeY[ActiveView],TRUE);
00603          }
00604          MoveWindow(ghwnd_view,WindowViewXmin,WindowViewYmin,
00605                     WindowViewXsize,WindowViewYsize,TRUE);
00606          if(ghwndOpenGLview != NULL)MoveWindow(ghwndOpenGLview,
00607                     WindowViewXmin,WindowViewYmin,
00608                     WindowViewXsize,WindowViewYsize,TRUE);
00609          MoveWindow(ghwndQuicktime,
00610                     WindowViewSliderXpos,WindowViewSliderYpos,
00611                     WindowViewSliderXsize,WindowViewSliderYsize,TRUE);
00612          if(keyframer_docked_and_visible && IsWindow(ghwndTimeline) &&
00613             IsWindowVisible(ghwndTimeline))
00614            MoveWindow(ghwndTimeline,0,KeyframerYpos,cx,KeyframerSize,TRUE);
00615          InvalidateRect(ghwndQuicktime,NULL,FALSE);
00616          MoveToolsWindow();
00617          SendMessage(ghwnd_info,msg,wparam,lparam);
00618          if(CreateMemoryWindows()){
00619            ReDrawStageDisplay(TRUE);
00620            if(ghwndOpenGLview == NULL)PerspectiveView(0,0);
00621          }
00622          else{
00623            DeleteMemoryWindows();
00624          }
00625        }
00626      }
00627      break;
00628    case WM_KEYDOWN:
00629      ExecuteKeyboardKeyCommand(wparam);
00630    case WM_KEYUP:
00631      if(!bTrackMouse && !bTrackIcon && !bToolCaptured && !bTrackPan){
00632        if(GetKeyState(VK_SPACE) & 0x8000)bSpaceDown=TRUE; else bSpaceDown=FALSE;
00633        if(GetKeyState(VK_CONTROL) & 0x8000)bCtrlDown=TRUE; else bCtrlDown=FALSE;
00634        if(GetKeyState(VK_SHIFT) & 0x8000)bShiftDown=TRUE; else bShiftDown=FALSE;
00635        if(GetKeyState(VK_MENU) & 0x8000)bAltDown=TRUE; else bAltDown=FALSE;
00636        if(CursorInTriview())SetTriViewCursor(FALSE);
00637      }
00638 //     if(bAbortedDrawing){
00639 //       bAbortedDrawing=FALSE;
00640 //       if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
00641 //     }
00642 //     break;
00643 //   case WM_TIMER:
00644 //     if(wparam == 1){
00645 //       KillTimer(hwnd,1);
00646 //       bAbortedDrawing=FALSE;
00647 //       if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
00648 //     }
00649 //     break;
00650    case WM_SETFOCUS:
00651      if(GetKeyState(VK_SPACE) & 0x8000)bSpaceDown=TRUE; else bSpaceDown=FALSE;
00652      if(GetKeyState(VK_SHIFT) & 0x8000)bShiftDown=TRUE; else bShiftDown=FALSE;
00653      if(GetKeyState(VK_CONTROL) & 0x8000)bCtrlDown=TRUE; else bCtrlDown=FALSE;
00654      if(GetKeyState(VK_MENU) & 0x8000)bAltDown=TRUE; else bAltDown=FALSE;
00655      if(CursorInTriview())SetTriViewCursor(FALSE);
00656      break;
00657    case WM_KILLFOCUS:
00658      if(bSpaceDown || bCtrlDown || bShiftDown || bAltDown){
00659        bSpaceDown=FALSE;
00660        bCtrlDown=FALSE;
00661        bShiftDown=FALSE;
00662        bAltDown=FALSE;
00663        if(CursorInTriview())SetTriViewCursor(FALSE);
00664      }
00665      break;
00666    case WM_SYSKEYDOWN:
00667      if(((lparam & 0x40000000) == 0) && wparam == VK_MENU){
00668        bAltDown=TRUE;
00669 //       if(tool == INZOOM && CursorInTriview())SetTriViewCursor(FALSE);
00670        if((bSpaceDown || tool == INZOOM) && CursorInTriview())SetTriViewCursor(FALSE);
00671      }
00672      return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00673    case WM_SYSKEYUP:
00674      bAltDown=FALSE;
00675 //     if(tool == INZOOM && CursorInTriview())SetTriViewCursor(FALSE);
00676      if((bSpaceDown || tool == INZOOM) && CursorInTriview())SetTriViewCursor(FALSE);
00677      break;
00678    default:
00679      return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00680  }
00681  return( 0L );
00682 }
00683 
00684 // window functions for the main screen windows
00685 
00686 LRESULT CALLBACK AnimatorTriViewWndProc(HWND hwnd, UINT msg, WPARAM wparam,
00687                                     LPARAM lparam ){
00688  BOOL flag1,flag2;
00689  HDC hdc;
00690  RECT rc;
00691  int id;
00692  static long evTime;
00693  static int iIconSave = -1,PickedX,PickedY,lastlocaltool;
00694  static BOOL bPickedNode,bPickedDbl=FALSE;
00695  switch( msg ){
00696    case WM_SETCURSOR:
00697      if(!SetTriViewCursor(TRUE))return(DefWindowProc(hwnd,msg,wparam,lparam));
00698      break;
00699    case WM_RBUTTONDOWN:
00700      if(bSpaceDown)break;
00701      if(bToolCaptured)break;
00702      if(!bTrackMouse){
00703        if(PickClosestNode((int)GetWindowLong(hwnd,GWL_ID),
00704                           (int)LOWORD(lparam),(int)HIWORD(lparam),TRUE) &&
00705           SelectedNode != NULL){
00706          {
00707            POINT pt;
00708            HMENU hMenu;
00709            hMenu=NULL;
00710            switch (SelectedNode->type){
00711              case CAMERA:
00712                hMenu=LoadMenu(ghinst_main,"CAMERACONTEXTMENU");
00713                break;
00714              case ROBOT:
00715              case NORMAL:
00716              case ANIMOBJ:
00717                hMenu=LoadMenu(ghinst_main,"ACTORCONTEXTMENU");
00718                break;
00719              case PARTICLE:
00720                hMenu=LoadMenu(ghinst_main,"CSGCONTEXTMENU");
00721                break;
00722              case PATH:
00723                hMenu=LoadMenu(ghinst_main,"PATHCONTEXTMENU");
00724                break;
00725              case LIGHT:
00726                hMenu=LoadMenu(ghinst_main,"LIGHTCONTEXTMENU");
00727                break;
00728              case TARGET:
00729                hMenu=LoadMenu(ghinst_main,"TARGETCONTEXTMENU");
00730                break;
00731              case GROUND:
00732                hMenu=LoadMenu(ghinst_main,"GROUNDCONTEXTMENU");
00733                break;
00734              default: break;
00735            }
00736            if(hMenu != NULL){
00737              pt.x=LOWORD(lparam);
00738              pt.y=HIWORD(lparam);
00739              ClientToScreen(hwnd,&pt);
00740              TrackPopupMenu(GetSubMenu(hMenu,0),
00741                             TPM_LEFTALIGN | TPM_LEFTBUTTON,
00742                             pt.x,pt.y,0,ghwnd_main,NULL);
00743              DestroyMenu(hMenu);
00744            }
00745          }
00746        }
00747        else {
00748         SendMessage(ghwnd_main,WM_COMMAND,IDM_STOP_TOOL,0);
00749        }
00750      }
00751      else if(!bTrackIcon){
00752        if(tool == NOTOOL || tool == NODETOOL){;}
00753        else{
00754          if(tool == GRABBER)StageGrab(1,0);
00755        }
00756      }
00757      break;
00758    case WM_LBUTTONDBLCLK:
00759      if((tool == NOTOOL || tool == NODETOOL) && bPickedDbl){
00760        BOOL draw=FALSE;
00761        object *Op;
00762        bPickedDbl=FALSE;
00763        Op=GetObjectAtFrame(SelectedNode,CurrentFrame);
00764        if(Op != NULL){
00765          switch (Op->type){
00766            case CAMERA:
00767              LensSettings();
00768              draw=TRUE;
00769 //             SelectedInfo();
00770              break;
00771            case NORMAL:
00772            case ANIMOBJ:
00773              Save_UndoA();
00774              DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_COSTUME),
00775                       ghwnd_main,(DLGPROC)EditObjectDlgProc,(LPARAM)Op);
00776              draw=TRUE; break;
00777            case PARTICLE:
00778            case PATH:
00779            case TARGET:
00780            case ROBOT:
00781              Save_UndoA();
00782              EditObject(SelectedNode,(short)Op->lastframe,
00783                                      (short)Op->lastframe,NO,NO);
00784              draw=TRUE;
00785              break;
00786            case LIGHT:
00787              Save_UndoA();
00788              EditLightDialog(Op,NO);
00789              draw=TRUE;
00790              break;
00791            case GROUND:
00792              Save_UndoA();
00793              EditGroundDialog(Op,NO);
00794              draw=TRUE;
00795              break;
00796            default: break;
00797          }
00798          if(draw){
00799            CheckRecursiveFollow(SelectedNode,Op->firstframe,Op->lastframe);
00800            UpdateSelectedActor(FALSE);
00801            ReDrawStageDisplay(TRUE);
00802            if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
00803            else UpdateGLview(TRUE);
00804            UPDATETIMELINES(IDC_TIMEL_UPDATE)
00805          }
00806        }
00807      }
00808      break;
00809    case WM_LBUTTONDOWN:
00810      if(bToolCaptured){
00811        if(tool == TRACKER && subtool == SHIFTER)ShiftKeyFrameDeactivate();
00812        bToolCaptured=FALSE;
00813        bTrackMouse=FALSE;
00814        ClipCursor(NULL);
00815        SetCursor(ghcurSave);
00816        ReleaseCapture();
00817        UpdateWindow(hwnd);
00818        break;
00819      }
00820      if(hwnd != ghwnd_current){
00821        hdc=GetDC(ghwnd_main);
00822        FocusActiveWindow(hdc,FALSE);
00823        ghwnd_current=hwnd;  ActiveView=GetWindowLong(hwnd,GWL_ID);
00824        FocusActiveWindow(hdc,TRUE);
00825        ReleaseDC(ghwnd_main,hdc);
00826      }
00827      SetCapture(hwnd);
00828      if(bSpaceDown){
00829        PanToolDown((int)LOWORD(lparam),(int)HIWORD(lparam),
00830                     bCtrlDown,bAltDown,hwnd);
00831        GetWindowRect(hwnd,&rc);
00832        rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00833        ClipCursor(&rc);
00834        bTrackPan=TRUE;
00835      }
00836      else if((iIconSave=CheckWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam))) >= 0){
00837        InvertWindowIcon(iIconSave,hwnd);
00838        bTrackIcon=TRUE;
00839      }
00840      else if(tool == PAN/* || tool == INZOOM */){
00841        PanToolDown((int)LOWORD(lparam),(int)HIWORD(lparam),
00842                     FALSE,FALSE,hwnd);
00843        GetWindowRect(hwnd,&rc);
00844        rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00845        ClipCursor(&rc);
00846        bTrackPan=TRUE;
00847      }
00848      else if(tool == INZOOM){
00849        Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00850        ZoomView((int)LOWORD(lparam),(int)HIWORD(lparam));
00851      }
00852      else if(tool == ROTATOR ){
00853        StageRotate(GetWindowLong(hwnd,GWL_ID));
00854      }
00855      else if(tool == SIZER   ){
00856        Resize();
00857      }
00858      else if(tool == TRACKER && subtool == SHIFTER ){
00859        do_NOT_abort=YES;
00860        id=ShiftKeyFrameActivate((int)LOWORD(lparam),(int)HIWORD(lparam));
00861        do_NOT_abort=NO;
00862        if(id == 1)bToolCaptured=TRUE;
00863        else if(id < 0)break;
00864 /* under test */
00865 //       if(GetKeyState(VK_CONTROL) & 0x8000){
00866          do_NOT_abort=YES;
00867          if(!bToolCaptured)PickClosestNode((int)GetWindowLong(hwnd,GWL_ID),
00868           (int)LOWORD(lparam),(int)HIWORD(lparam),FALSE);
00869          do_NOT_abort=NO;
00870 //       }
00871 /*************/
00872        GetWindowRect(hwnd,&rc);
00873        rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00874        ghcurSave=SetCursor(ghcurCross);
00875        ClipCursor(&rc);
00876        bTrackMouse=TRUE;
00877        Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00878      }
00879      else if(tool == TRACKER && subtool == ANGLER){
00880        Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00881        do_NOT_abort=YES;
00882        AngleKeyFrame((int)LOWORD(lparam),(int)HIWORD(lparam));
00883        do_NOT_abort=NO;
00884      }
00885      else if(tool == SKELETOR){
00886        if(Skeletor()){
00887 /* under test */
00888          if(GetKeyState(VK_CONTROL) & 0x8000){
00889            do_NOT_abort=YES;
00890            PickClosestNode((int)GetWindowLong(hwnd,GWL_ID),
00891             (int)LOWORD(lparam),(int)HIWORD(lparam),FALSE);
00892            do_NOT_abort=NO;
00893          }
00894 /*************/
00895          GetWindowRect(hwnd,&rc);
00896          rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00897          ghcurSave=SetCursor(ghcurCross);
00898          ClipCursor(&rc);
00899          bTrackMouse=TRUE;
00900          Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00901        }
00902      }
00903      else if(tool == GRABBER){
00904        Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00905        do_NOT_abort=YES;
00906        PickClosestNode((int)GetWindowLong(hwnd,GWL_ID),
00907                        (int)LOWORD(lparam),(int)HIWORD(lparam),FALSE);
00908        do_NOT_abort=NO;
00909        if(StageGrabIdentify()){
00910          ReDrawStageDisplay(TRUE);
00911          PerspectiveView(0,0);
00912          GetWindowRect(hwnd,&rc);
00913          rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00914          ghcurSave=SetCursor(ghcurCross);
00915          ClipCursor(&rc);
00916          bTrackMouse=TRUE;
00917          EnterGrabMode();
00918        }
00919      }
00920      else if(tool == PATHEDITOR){
00921        Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00922        do_NOT_abort=YES;
00923        if(!PickClosestPathPoint((int)GetWindowLong(hwnd,GWL_ID),
00924                        (int)LOWORD(lparam),(int)HIWORD(lparam)) ){
00925 /* under test */
00926          if(GetKeyState(VK_CONTROL) & 0x8000){
00927            PickClosestNode((int)GetWindowLong(hwnd,GWL_ID),
00928                            (int)LOWORD(lparam),(int)HIWORD(lparam),FALSE);
00929          }
00930 /*************/
00931          if(gToolFlags.flagP == 3)AdjustPathTension(GetWindowLong(hwnd,GWL_ID));
00932        }
00933        do_NOT_abort=NO;
00934        GetWindowRect(hwnd,&rc);
00935        rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00936        ghcurSave=SetCursor(ghcurCross);
00937        ClipCursor(&rc);
00938        bTrackMouse=TRUE;
00939      }
00940      else{
00941        GetWindowRect(hwnd,&rc);
00942        rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00943        ghcurSave=SetCursor(ghcurCross);
00944        ClipCursor(&rc);
00945        bTrackMouse=TRUE;
00946        Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00947        bPickedNode=FALSE;
00948        bPickedDbl=FALSE;
00949        if((GetKeyState(VK_CONTROL) & 0x8000) != 0x8000 &&
00950           (tool == NOTOOL || tool == NODETOOL)){
00951 //       if(tool == NOTOOL || tool == NODETOOL){
00952          do_NOT_abort=YES;
00953          if(PickClosestNode((int)GetWindowLong(hwnd,GWL_ID),
00954             (int)LOWORD(lparam),(int)HIWORD(lparam),FALSE)){
00955            bPickedNode=TRUE;
00956            bPickedDbl=TRUE;
00957            PickedX=LOWORD(lparam); PickedY=HIWORD(lparam);
00958            evTime=GetTickCount()+5;
00959          }
00960          do_NOT_abort=NO;
00961        }
00962      }
00963      if(!bTrackPan && !bTrackIcon && !bTrackMouse && GetCapture() == hwnd
00964         && !(GetAsyncKeyState(VK_LBUTTON) & 0x8000)){
00965        ReleaseCapture();
00966      }
00967      break;
00968    case WM_LBUTTONUP:
00969      id=0;
00970      if(bToolCaptured)break;
00971      if(bTrackIcon){
00972        if(iIconSave >= 0){
00973          InvertWindowIcon(iIconSave,hwnd);
00974          if     (iIconSave == 0)iIconSave=IDM_PAN_LEFT;
00975          else if(iIconSave == 1)iIconSave=IDM_PAN_RIGHT;
00976          else if(iIconSave == 2)iIconSave=IDM_PAN_UP;
00977          else if(iIconSave == 3)iIconSave=IDM_PAN_DOWN;
00978          else if(iIconSave == 4)iIconSave=IDM_WINDOW_SWITCHWINDOWS;
00979          else if(iIconSave == 5)iIconSave=IDM_WINDOW_SWITCHWINDOW0;
00980          else if(iIconSave == 6)iIconSave=IDM_WINDOW_SWITCHWINDOW1;
00981          PostMessage(ghwnd_main,WM_COMMAND,(WPARAM)iIconSave,
00982            (LPARAM)GetWindowLong(hwnd,GWL_ID));
00983        }
00984        iIconSave = -1;
00985        bTrackIcon=FALSE;
00986      }
00987      else if(bTrackPan){
00988        if(bSpaceDown){
00989          flag1=bCtrlDown;
00990 //         flag2=bShiftDown;
00991          flag2=bAltDown;
00992        }
00993        else{
00994          if(tool == INZOOM){
00995            if(bAltDown){flag1=FALSE; flag2=TRUE;}  /* zoom out */
00996            else        {flag1=TRUE; flag2=FALSE;}  /* zoom in */
00997          }
00998          else {flag1=FALSE; flag2=FALSE;}
00999        }
01000        PanToolUp((int)LOWORD(lparam),(int)HIWORD(lparam),
01001                  flag1,flag2,hwnd);
01002        bTrackPan=FALSE;
01003        ClipCursor(NULL);
01004        if(!(GetKeyState(VK_SPACE)&0x8000))bSpaceDown=FALSE;
01005        if(!(GetKeyState(VK_CONTROL)&0x8000))bCtrlDown=FALSE;
01006        if(!(GetKeyState(VK_SHIFT)&0x8000))bShiftDown=FALSE;
01007        if(!(GetKeyState(VK_MENU)&0x8000))bAltDown=FALSE;
01008        SetTriViewCursor(FALSE);
01009      }
01010      else if(bTrackMouse){
01011        bTrackMouse=FALSE;   //
01012        ClipCursor(NULL);    // h
01013        SetCursor(ghcurSave);//
01014        if(tool == GRABBER){
01015          if(bPickedNode){
01016            LeaveGrabMode();
01017            StageGrabOff(1);
01018            tool=lastlocaltool;
01019          }
01020          else LeaveGrabMode();
01021        }
01022        else if(tool == PATHEDITOR)id=1;
01023        // h - here?
01024        UpdateWindow(hwnd);
01025      }
01026      bPickedNode=FALSE;
01027      ReleaseCapture();
01028      if(tool == PATHEDITOR && id == 1){
01029        if(gToolFlags.flagP      == 1)CreatePathPoint();
01030        else if(gToolFlags.flagP == 2)DeletePathPoint();
01031      }
01032      break;
01033    case WM_MOUSEMOVE:
01034      if(bTrackMouse){
01035        Move3dCursor(0,(int)LOWORD(lparam),(int)HIWORD(lparam));
01036        do_NOT_abort=YES;
01037        if     (tool == GRABBER)StageGrab(0,0); /* draw to screen */
01038        else if(tool == PATHEDITOR)EditPath();
01039        else if(tool == TRACKER && subtool == SHIFTER && bToolCaptured){
01040          do_NOT_abort=YES;
01041          ShiftKeyFrame((int)LOWORD(lparam),(int)HIWORD(lparam));
01042          do_NOT_abort=NO;
01043        }
01044        else if((tool == NOTOOL || tool == NODETOOL) && bPickedNode){
01045          if(GetTickCount() > evTime){
01046            if(abs((int)LOWORD(lparam) - PickedX) >= 2 ||
01047               abs((int)HIWORD(lparam) - PickedY) >= 2){
01048              if(IsValidPosition() != NULL){
01049                lastlocaltool=tool;
01050                tool=GRABBER;
01051                Save_UndoA();
01052                StageGrabIdentify();
01053                ReDrawStageDisplay(TRUE);
01054                PerspectiveView(0,0);
01055                EnterGrabMode();
01056              }
01057              else{
01058                bPickedNode=FALSE;
01059                ReleaseCapture();
01060                bTrackMouse=FALSE;
01061                ClipCursor(NULL);
01062                Save_UndoA();
01063                StageGrabIdentify();
01064                ReDrawStageDisplay(TRUE);
01065                if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01066                else UpdateGLview(TRUE);
01067              }
01068            }
01069          }
01070        }
01071        do_NOT_abort=NO;
01072      }
01073      else if(bTrackIcon){
01074        int new_icon;
01075        new_icon=CheckWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam));
01076        if(new_icon !=  iIconSave){
01077          if(iIconSave >= 0)InvertWindowIcon(iIconSave,hwnd);
01078          iIconSave=new_icon;
01079          if(iIconSave >= 0)InvertWindowIcon(iIconSave,hwnd);
01080        }
01081      }
01082      else if(bTrackPan){
01083        if(tool == PAN || tool == INZOOM || bSpaceDown){
01084          if(bSpaceDown){
01085            flag1=bCtrlDown;
01086            flag2=bAltDown;
01087          }
01088          else{
01089            if(tool == INZOOM && !bAltDown)flag1=TRUE; else flag1=FALSE;
01090            if(tool == INZOOM &&  bAltDown)flag2=TRUE; else flag2=FALSE;
01091          }
01092          PanToolMove((int)LOWORD(lparam),(int)HIWORD(lparam),
01093                      flag1,flag2,hwnd);
01094        }
01095      }
01096      else { /* get help on in screen icons */
01097        int icon,new_message;
01098        icon=CheckWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam));
01099        if(icon >= 0){
01100          if(icon == 4)new_message=lmessage_table[View];
01101          else         new_message=IDS_SWAPOTHER;
01102          if(new_message != current_message){
01103            current_message=new_message;
01104            SendPrgmMessage(current_message,1);
01105          }
01106        }
01107        else if(current_message != tmessage_table[tool]){
01108          current_message = tmessage_table[tool];
01109          SendPrgmMessage(current_message,1);
01110        }
01111      }
01112      break;
01113    case WM_PAINT:{
01114        PAINTSTRUCT ps;
01115        HPALETTE hpalT;
01116        hdc=BeginPaint(hwnd,&ps);
01117        if(!bResizing){
01118          GetClientRect(hwnd,&rc);
01119          id=(int)GetWindowLong(hwnd,GWL_ID);
01120          if(ghdc_triview_Bitmap[id] != NULL)BitBlt(hdc,0,0,
01121            rc.right,rc.bottom,ghdc_triview_Bitmap[id],0,0,SRCCOPY);
01122          DrawOne3dCursor(hdc,id);
01123        }
01124        EndPaint(hwnd,&ps);
01125      }
01126      break;
01127    default:
01128      return( DefWindowProc( hwnd, msg, wparam, lparam ) );
01129  }
01130  return( 0L );
01131 }
01132 
01133 LRESULT CALLBACK AnimatorViewWndProc(HWND hwnd, UINT msg, WPARAM wparam,
01134                                     LPARAM lparam ){
01135  RECT rc;
01136  static int iIconSave = -1;
01137  switch( msg ){
01138    case WM_ERASEBKGND:{
01139       HDC hDC;
01140       HPALETTE hpalT;
01141       HBRUSH hOldBrush;
01142       if(bResizing)return TRUE;
01143       hDC       = (HDC)wparam;
01144       hOldBrush = SelectObject (hDC,ghbrushWindow);
01145       GetClientRect(hwnd,(LPRECT)&rc);
01146       PatBlt(hDC,0,0,rc.right,rc.bottom,PATCOPY);
01147       SelectObject (hDC, hOldBrush);
01148       return TRUE;
01149    }
01150    case WM_RBUTTONDOWN:{
01151        POINT pt;
01152        HMENU hMenu=LoadMenu(ghinst_main,"CameraViewPopupMenu");
01153        if(hMenu == NULL)break;
01154        pt.x=LOWORD(lparam);
01155        pt.y=HIWORD(lparam);
01156        ClientToScreen(hwnd,&pt);
01157        TrackPopupMenu(GetSubMenu(hMenu,0),TPM_LEFTALIGN | TPM_LEFTBUTTON,
01158                       pt.x,pt.y,0,ghwnd_main,NULL);
01159        DestroyMenu(hMenu);
01160      }
01161      break;
01162    case WM_LBUTTONDOWN:
01163      SetCapture(hwnd);
01164      if((iIconSave=CheckViewWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam))) >= 0){
01165        InvertViewWindowIcon(iIconSave,hwnd);
01166        bTrackIcon=TRUE;
01167        break;
01168      }
01169      GetClientRect(hwnd,&rc);
01170      //ghcurSave=SetCursor(ghcurWait);
01171      PerspectiveView(0,1);
01172      //SetCursor(ghcurSave);
01173      break;
01174    case WM_MOUSEMOVE:{
01175        int new_icon;
01176        new_icon=CheckViewWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam));
01177        if(bTrackIcon){
01178          if(new_icon !=  iIconSave){
01179            if(iIconSave >= 0)InvertViewWindowIcon(iIconSave,hwnd);
01180            iIconSave=new_icon;
01181            if(iIconSave >= 0)InvertViewWindowIcon(iIconSave,hwnd);
01182          }
01183        }
01184        if(new_icon > 0){
01185          current_message=lmessage_table[View];
01186          SendPrgmMessage(current_message,1);
01187        }
01188        else if(current_message != IDS_VIEWUPDATE){
01189          current_message = IDS_VIEWUPDATE;
01190          SendPrgmMessage(IDS_VIEWUPDATE,1);
01191        }
01192      }
01193      break;
01194    case WM_LBUTTONUP:
01195      ReleaseCapture();
01196      if(bTrackIcon){
01197        if(iIconSave >= 0){
01198          InvertViewWindowIcon(iIconSave,hwnd);
01199          if(iIconSave == 1){
01200            if(View == TRIVIEW){
01201              if(!BigCameraView)PostMessage(ghwnd_main,
01202                WM_COMMAND,(WPARAM)IDM_WINDOW_BIGCAMERA,
01203                (LPARAM)GetWindowLong(hwnd,GWL_ID));
01204              PostMessage(ghwnd_main,WM_COMMAND,
01205                (WPARAM)IDM_WINDOW_SWITCHWINDOWS,
01206                (LPARAM)GetWindowLong(hwnd,GWL_ID));
01207            }
01208            else{
01209              PostMessage(ghwnd_main,WM_COMMAND,
01210                (WPARAM)IDM_WINDOW_SWITCHWINDOWS,
01211                (LPARAM)GetWindowLong(hwnd,GWL_ID));
01212              if(BigCameraView)PostMessage(ghwnd_main,
01213                WM_COMMAND,(WPARAM)IDM_WINDOW_BIGCAMERA,
01214                (LPARAM)GetWindowLong(hwnd,GWL_ID));
01215            }
01216          }
01217        }
01218        iIconSave = -1;
01219        bTrackIcon=FALSE;
01220      }
01221      break;
01222    case WM_TIMER:
01223      if(AnimationTimer == 3){
01224        long qsave;
01225        qsave=global_quickdraw;
01226        global_quickdraw=1;
01227        PerspectiveView(1,1);
01228        global_quickdraw=qsave;
01229      }
01230      else{
01231        PerspectiveView(1,AnimationTimer-1);
01232      }
01233      CurrentFrame++;
01234      if(CurrentFrame > Nframes)CurrentFrame=1;
01235 //     SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
01236      SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
01237      break;
01238    case WM_PAINT: {
01239        HDC hdc;
01240        PAINTSTRUCT ps;
01241        HPALETTE hpalT;
01242        hdc=BeginPaint(hwnd,&ps);
01243        if(!bResizing){
01244          GetClientRect(hwnd,&rc);
01245          if(ghdc_view_Bitmap != NULL){
01246            COLORREF oldtextcolour;
01247            int oldbkmode;
01248            char p[8];
01249 //           sprintf(p,"%4.4ld",CurrentFrame);
01250            oldbkmode=SetBkMode(ghdc_view_Bitmap,TRANSPARENT);
01251            oldtextcolour=SetTextColor(ghdc_view_Bitmap,RGB(255,255,255));
01252 //           TextOut(ghdc_view_Bitmap,1,rc.bottom-Textheight,p,strlen(p));
01253            if(AnimationTimer == 0){
01254              HDC hMemDC = CreateCompatibleDC(ghdc_view_Bitmap);
01255              HBITMAP hbmOld=SelectObject(hMemDC,hbmName[5]);
01256              BitBlt(ghdc_view_Bitmap,0,0,
01257                     WINDOW_ID_VSIZE,WINDOW_ID_YSIZE,
01258                     hMemDC,0,0,SRCCOPY);
01259              SelectObject(hMemDC, hbmOld);
01260              DeleteDC(hMemDC);
01261 //
01262 //             TextOut(ghdc_view_Bitmap,
01263 //                     rc.right-8*Textwidth,rc.bottom-Textheight,
01264 //                     "Camera",strlen("Camera"));
01265 //
01266            }
01267            SetBkMode(ghdc_view_Bitmap,oldbkmode);
01268            SetTextColor(ghdc_view_Bitmap,oldtextcolour);
01269            BitBlt(hdc,0,0,rc.right,rc.bottom,ghdc_view_Bitmap,0,0,SRCCOPY);
01270          }
01271        }
01272        EndPaint(hwnd,&ps);
01273      }
01274      break;
01275    default:
01276      return( DefWindowProc( hwnd, msg, wparam, lparam ) );
01277  }
01278  return( 0L );
01279 }
01280 
01281 // Set the mouse cursor to the correct cursor depending on
01282 // the window the cursor is over and the state of the modifier keys
01283 // e.g. the PAN and ZOOM key accelerators.
01284 
01285 static BOOL SetTriViewCursor(BOOL type){
01286  if(bSpaceDown){
01287    if(bCtrlDown)SetCursor(ghcurZin);
01288    else if(bAltDown)SetCursor(ghcurZout);
01289    else SetCursor(ghcurPan);
01290  }
01291 // else if(tool == INZOOM && bAltDown)SetCursor(ghcurZout);
01292  else if(tool == TRACKER && subtool == SHIFTER)SetCursor(ghcurTracker);
01293  else if(tool == TRACKER && subtool == ANGLER)SetCursor(ghcurDirector);
01294  else if(tool < NTOOLS)SetCursor(ghcurTools[tool]);
01295  else if(tool == PATHEDITOR)SetCursor(ghcurPathed);
01296  else if(tool == SKELETOR)SetCursor(ghcurSkeletor);
01297  else if(type)return FALSE;
01298  else SetCursor(ghcurArrow);
01299  return TRUE;
01300 }
01301 
01302 //
01303 // The main windows COMMAND generating function 
01304 //
01305 
01306 #include "glmenu.h"
01307 
01308 #if __HELP_WS__
01309 #include "..\help_ws\include\htmlhelp.h"
01310 #endif
01311 
01312 static VOID AnimatorMenuCmd(int item, HWND hwnd, long lparam){
01313  BOOL play_now=FALSE;
01314  int i;
01315  node *local_node;
01316  char local_nodename[128],lname[255];
01317  static BOOL busy_flag=FALSE;
01318  static object *ObjectInModeler=NULL;
01319  switch (item){
01320    case IDM_FILE_LOAD_DIRECT:{
01321        char load_file[255];
01322        GetPrivateProfileString("CALLBACK","FILE","$$$",
01323            load_file,sizeof(load_file),IniFilename);
01324        if(strncmp(load_file,"$$$",3) == 0)break;
01325        strcpy(gszSTGfile,load_file);
01326        strcpy(gszSTGdir,load_file);
01327        *FileInPath(gszSTGdir) = '\0';
01328        UpdateLastFilesList(gszSTGfile);
01329        goto OPENJUMP;
01330      }
01331    case IDM_FILE_LOAD_STARTUP:
01332      strcpy(gszSTGfile,gszHomeDir); strcat(gszSTGfile,"startup.ofx");
01333      play_now=TRUE;
01334      goto OPENJUMP;
01335    case LASTFILECMD+1:
01336    case LASTFILECMD+2:
01337    case LASTFILECMD+3:
01338    case LASTFILECMD+4:
01339    case LASTFILECMD+5:
01340    case IDM_FILE_LOAD_ANIMATION:
01341      Save_UndoA();
01342      if(EDIT_ACTION){
01343        int fResult;
01344        fResult=SendPrgmQuery(IDQ_CHANGED,2);
01345        if(fResult == IDCANCEL)break;
01346 #if !__DEMO__
01347        if(fResult == IDYES){
01348          if(SelectSfxFileName(1,gszSTGfile,gszSTGdir,IDX_MISC_SAVEANIMATION,
01349                            "(*.OFX)|*.ofx|",ghwnd_main) == TRUE){
01350            AppendFileExtension(gszSTGfile,".ofx");
01351            ghcurSave=SetCursor(ghcurWait);
01352            SaveAnimationFile(gszSTGfile,FALSE);
01353            SetCursor(ghcurSave);
01354          }
01355          else break;
01356        }
01357 #endif
01358      }
01359      play_now=FALSE;
01360      if(item == LASTFILECMD+1 || item == LASTFILECMD+2 ||
01361         item == LASTFILECMD+3 || item == LASTFILECMD+4 ||
01362         item == LASTFILECMD+5){
01363        strcpy(gszSTGfile,LastFilesList[item-LASTFILECMD-1].file);
01364        goto OPENJUMP;
01365      }
01366      if(SelectSfxFileName(0,gszSTGfile,gszSTGdir,
01367       IDX_MISC_OPENANIMATION,"(*.OFX)|*.ofx|",ghwnd_main) == TRUE){
01368        OPENJUMP:
01369        ghcurSave=SetCursor(ghcurWait);
01370        if(LoadAnimationFile(gszSTGfile,FALSE) == OK){
01371          UpdateLastFilesList(gszSTGfile);
01372          SetPrgmMessage(IDS_CURRENT,gszSTGfile);
01373          SendPrgmMessage(IDS_CURRENT,0);
01374 #if !__DEMO__
01375          EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_SAVEOLD,MF_ENABLED);
01376 #endif
01377          strcpy(gszSTGsaved,gszSTGfile);
01378        }
01379        else play_now=FALSE;
01380 //       SetScrollRange(ghwnd_xscl,SB_CTL,1,(int)Nframes,FALSE);
01381 //       SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
01382        SendMessage(ghwnd_xscl,TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(1,Nframes));
01383        SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
01384        ReDrawStageDisplay(TRUE);
01385        if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01386        else UpdateGLview(TRUE);
01387        if(coords_visible)UpdateRuler(0);
01388        UPDATETIMELINES(IDC_TIMEL_UPDATE)
01389        SetCursor(ghcurSave);
01390        if(play_now)PostMessage(hwnd,WM_COMMAND,IDM_FRAME_PLAY_QUICK,0);
01391      }
01392      break;
01393    case IDM_FILE_LOAD_TEMPLATE:
01394    case IDM_FILE_LOAD_NEW: {
01395        int iok=0;
01396        if(EDIT_ACTION){
01397          int fResult;
01398          Save_UndoA();
01399          fResult=SendPrgmQuery(IDQ_CHANGED,2);
01400          if(fResult == IDCANCEL)break;
01401 #if !__DEMO__
01402          if(fResult == IDYES){
01403            if(SelectSfxFileName(1,gszSTGfile,gszSTGdir,
01404              IDX_MISC_SAVEANIMATION,"(*.OFX)|*.ofx|",ghwnd_main) == TRUE){
01405              AppendFileExtension(gszSTGfile,".ofx");
01406              ghcurSave=SetCursor(ghcurWait);
01407              SaveAnimationFile(gszSTGfile,FALSE);
01408              SetCursor(ghcurSave);
01409            }
01410            else break;
01411          }
01412 #endif
01413          iok=1;
01414        }
01415        {
01416          object *Op;
01417          ScrapEverything();
01418          UpdateSelectedActor(FALSE);
01419          SendPrgmMessage(IDS_DEFAULT,0);
01420          EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_SAVEOLD,MF_GRAYED);
01421          gszSTGfile[0]='\0';
01422          strcpy(gszSTGsaved,"unnamed.ofx");
01423          GetTriview(TRUE);
01424          NpointerX=0; NpointerY=0; NpointerZ=0;
01425          if(CreateNode() != NULL){
01426            LoadString(ghinst_main,IDX_MISC_CAMERA,res_str,256);
01427            strcpy(MainNp->actorname,res_str);
01428            MainNp->type=CAMERA;
01429            SelectedCamera=MainNp;
01430            if((Op=CreateCostume(MainNp,1,(short)Nframes)) != NULL){
01431              Op->type=MainNp->type;
01432              MainNp->fobj->morph=NO;
01433              Ncameras=1;
01434              if(item != IDM_FILE_LOAD_TEMPLATE){
01435                CreatePosition(MainNp,1,(short)Nframes);
01436                MainNp->fpos->finish[0]=0;
01437                MainNp->fpos->finish[1]=-TVsizeY/3; //2+TVsizeY/10;
01438                MainNp->fpos->finish[2]=0;
01439                MainNp->fpos->type=SPLINE;
01440                CreateAlign(FirstNp,1,(short)Nframes);
01441                CreateSize(FirstNp,1,(short)Nframes);
01442                CreateNode();
01443                LoadString(ghinst_main,IDX_MISC_TARGET,res_str,256);
01444                strcpy(MainNp->actorname,res_str);
01445                MainNp->type=TARGET;
01446                Op=CreateCostume(MainNp,1,(short)Nframes);
01447                Op->type=MainNp->type;
01448                FirstNp->fali->type=TRACK;
01449                FirstNp->fali->topath=MainNp;
01450                CreatePosition(MainNp,1,Nframes);
01451                MainNp->fpos->type=SPLINE;
01452              }
01453            }
01454            else PostQuitMessage(0L);  /* this should be a 1 in a billion shot */
01455          }
01456          else PostQuitMessage(0L);
01457          EDIT_ACTION=NO;
01458          if(item == IDM_FILE_LOAD_TEMPLATE){
01459            StartDefault(0);
01460            Zoom(CENTREWORLD,0);
01461          }
01462 //         SetScrollRange(ghwnd_xscl,SB_CTL,1,(int)Nframes,FALSE);
01463 //         SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
01464          SendMessage(ghwnd_xscl,TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(1,Nframes));
01465          SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
01466          ReDrawStageDisplay(TRUE);
01467          if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01468          else UpdateGLview(TRUE);
01469          if(coords_visible)UpdateRuler(0);
01470          UPDATETIMELINES(IDC_TIMEL_UPDATE)
01471        }
01472      }
01473      break;
01474 #if !__DEMO__
01475    case IDM_FILE_SAVEOLD:
01476      ghcurSave=SetCursor(ghcurWait);
01477      if(SaveAnimationFile(gszSTGsaved,TRUE) == OK)EDIT_ACTION=NO; // changed FALSE so no question
01478      SetCursor(ghcurSave);
01479      break;
01480    case IDM_FILE_SAVE:
01481      if(SelectSfxFileName(1,gszSTGfile,gszSTGdir,IDX_MISC_SAVEANIMATION,
01482         "(*.OFX)|*.ofx|",ghwnd_main) == TRUE){
01483        AppendFileExtension(gszSTGfile,".ofx");
01484        UpdateLastFilesList(gszSTGfile);
01485        ghcurSave=SetCursor(ghcurWait);
01486        if(SaveAnimationFile(gszSTGfile,FALSE) == OK){
01487          EDIT_ACTION=NO;
01488          EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_SAVEOLD,MF_ENABLED);
01489          strcpy(gszSTGsaved,gszSTGfile);
01490          SetPrgmMessage(IDS_CURRENT,gszSTGfile);
01491          SendPrgmMessage(IDS_CURRENT,0);
01492        }
01493        SetCursor(ghcurSave);
01494      }
01495      break;
01496    case IDM_FILE_PACK:
01497      PackAnimationFile();  
01498      break;
01499    case IDM_FILE_UNPACK:
01500      UnpackAnimationFile();
01501      break;
01502 #endif
01503    case IDM_CALLBACK_FSCRIPT:{   /* only from renderer */
01504        HWND hwndR;
01505        BOOL isOK;
01506        long saved_current;
01507        saved_current=CurrentFrame;
01508        if(lparam != CurrentFrame){
01509          if(lparam > 0 && lparam <= Nframes)CurrentFrame=lparam;
01510        }
01511        isOK=MakeScript(3,1);
01512        CurrentFrame=saved_current;
01513        hwndR=FindWindow("OFX:RenderClass",NULL);
01514        if(IsWindow(hwndR)){
01515          if(isOK)SendMessage(hwndR,WM_COMMAND,IDM_CALLBACK_SETUP,0);
01516          else    SendMessage(hwndR,WM_COMMAND,IDM_CALLBACK_CANCEL,0);
01517        }
01518      }
01519      break;
01520    case IDM_CALLBACK_ASCRIPT:{  /* only from renderer */
01521        BOOL isOK;
01522        HWND hwndR;
01523        isOK=MakeScript(4,1);
01524        hwndR=FindWindow("OFX:RenderClass",NULL);
01525        if(IsWindow(hwndR)){
01526          if(isOK)SendMessage(hwndR,WM_COMMAND,IDM_CALLBACK_SETUP,0);
01527          else    SendMessage(hwndR,WM_COMMAND,IDM_CALLBACK_CANCEL,0);
01528        }
01529      }
01530      break;
01531    case IDM_FILE_EXP_FSCRIPT:
01532      if(!MakeScript(1,1))SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
01533      break;
01534    case IDM_FILE_EXP_ASCRIPT:
01535      if(!MakeScript(0,1))SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
01536      break;
01537    case IDM_FILE_EXP_FMSCRIPT:{
01538        char ttt[64];
01539        LoadString(ghinst_main,IDX_MISC_SCRIPTID,res_str,256);
01540        LoadString(ghinst_main,IDX_MISC_SCRIPTTITLE,ttt,64);
01541        i=RequestNumEntry(5,1,999,res_str,ttt);
01542        if(!MakeScript(1,i))SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
01543      }
01544      break;
01545    case IDM_FILE_EXP_AMSCRIPT:{
01546        char ttt[64];
01547        LoadString(ghinst_main,IDX_MISC_SCRIPTID,res_str,256);
01548        LoadString(ghinst_main,IDX_MISC_SCRIPTTITLE,ttt,64);
01549        i=RequestNumEntry(5,1,999,res_str,ttt);
01550        if(!MakeScript(0,i))SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
01551      }
01552      break;
01553    case IDM_FILE_EXP_VIRTOOLS:
01554      if(!ExportRobotKeyframes())SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
01555      break;
01556    case IDM_FILE_EXP_OPENGL:
01557      StartExternGL();
01558      break;
01559    case IDM_FILE_EXP_VRML:
01560      if(!MakeVRMLScript(0))SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
01561      break;
01562    case IDM_WINDOW_SHOWOPENGL:
01563      StartGLview(FALSE);
01564      break;
01565    case IDM_FILE_MODELER:
01566      ExecuteModeler();
01567      break;
01568    case IDM_FILE_KEYFRAMER:
01569      if(keyframer_docked){
01570        if(IsWindow(ghwndTimeline)){
01571          if(IsWindowVisible(ghwndTimeline)){
01572            TimelineEditor();
01573            keyframer_docked_and_visible=0;
01574            FormatScreen();
01575          }
01576          else{
01577            keyframer_docked_and_visible=1;
01578            FormatScreen();
01579            TimelineEditor();
01580          }
01581        }
01582        else{
01583          keyframer_docked_and_visible=1;
01584          FormatScreen();
01585          TimelineEditor();
01586        }
01587      }
01588      else TimelineEditor();
01589      break;
01590    case IDM_FILE_VIEWER:
01591      LoadUtility("mdiview.exe","OFX:Viewer",1004);
01592      break;
01593    //case IDM_FILE_PLAYER:{  // REMOVED NO FLIC NOW
01594    //    int result;
01595    //    char modulename[255];
01596    //    strcpy(modulename,gszHomeDir);strcat(modulename,"winplay.exe ANIM");
01597    //    result=WinExec(modulename,SW_SHOW);
01598    //    if(result < 32){
01599    //      if(result == ERROR_FILE_NOT_FOUND ||
01600    //         result == ERROR_PATH_NOT_FOUND)SendPrgmQuery(IDQ_NOSTART,3);
01601    //    }
01602    //  }
01603    //  break;
01604    case IDM_FILE_PLAYAVI:
01605      //     LoadUtility("aviplay.exe","OFX:AVIPlayer",1004); // old AVI MDI player 
01606      LoadUtility("ofxmediaplayer.exe","OFX:MediaPlayerClass",-1);
01607      break;
01608    case IDM_FILE_FLI2AVI:
01609      // REMOVED LoadUtility("fli2avi.exe","OFX:AVIConvertClass",-1);
01610      break;
01611    case IDM_FILE_FLI2GIF:
01612      // REMOVED LoadUtility("fli2gif.exe","RFS:GIFConvertClass",-1);
01613      break;
01614    case IDM_FILE_ANIM:
01615      LoadUtility("build.exe","OFX:BuildClass",-1);
01616      break;
01617    case IDM_FILE_AUDIO:
01618      LoadUtility("editsnd.exe","OFX:EditSoundClass",-1);
01619      break;
01620    case IDM_FILE_AVI2MPG:
01621      LoadUtility("avi2mpg.exe",NULL,-1);
01622      break;
01623    case IDM_FILE_GIF2AVI:
01624      LoadUtility("gif2avi.exe",NULL,-1);
01625      break;
01626    case IDM_FILE_PLAYDD:
01627      LoadUtility("ddplay.exe",NULL,-1);
01628      break;
01629    case IDM_FILE_PLAYGG:
01630      LoadUtility("ggplay.exe",NULL,-1);
01631      break;
01632    case IDM_FILE_SHOWSTV:
01633      LoadUtility("stv.exe","OFX:STV",-1);
01634      break;
01635 
01636 
01637    case IDM_FILE_EXIT:
01638      if(EDIT_ACTION){
01639        int fResult;
01640        fResult=SendPrgmQuery(IDQ_CHANGED,2);
01641        if(fResult == IDNO)PostQuitMessage(0L);
01642 #if __DEMO__
01643        PostQuitMessage(0L);
01644 #else
01645        if(fResult == IDYES){
01646          if(SelectSfxFileName(1,gszSTGfile,gszSTGdir,IDX_MISC_SAVEANIMATION,
01647            "(*.OFX)|*.ofx|",ghwnd_main) == TRUE){
01648            AppendFileExtension(gszSTGfile,".ofx");
01649            ghcurSave=SetCursor(ghcurWait);
01650            if(SaveAnimationFile(gszSTGfile,FALSE) == OK)PostQuitMessage(0L);
01651          }
01652          SetCursor(ghcurSave);
01653        }
01654        break;
01655 #endif
01656      }
01657      else PostQuitMessage(0L);
01658      break;
01659    case IDM_CALLBACK_SHUTDOWN:
01660      if(EDIT_ACTION)PostMessage(ghwnd_main,WM_COMMAND,IDM_FILE_EXIT,0);
01661      else PostQuitMessage(0L);
01662      break;
01663    case IDM_FILE_PRINT:
01664      PrintImageFile(ghwnd_main);
01665      break;
01666    case IDM_FILE_PRINTSETUP:
01667      break;
01668    case IDM_CONTEXT_TOOLSLEFT:
01669      bToolpannelLeft ^= 1;
01670      UpdateIconPositions();
01671      break;
01672    case IDM_CONTEXT_TOOLSSMALL:
01673      bToolpannelSmall ^= 1;
01674      ChangeToolboxBitmaps();
01675      UpdateIconPositions();
01676      break;
01677    case IDM_FILE_PREFERENCES:
01678      PreferencesPropertyDlgProc(ghwnd_main);
01679      SendMessage(ghwndTooltip,TTM_ACTIVATE,(WPARAM)Preferences.tooltips,0);
01680      if(Preferences.toolleft  != bToolpannelLeft ||
01681         Preferences.toolsmall != bToolpannelSmall){
01682        if(bToolpannelSmall != Preferences.toolsmall){
01683          bToolpannelSmall=Preferences.toolsmall;
01684          ChangeToolboxBitmaps();
01685        }
01686        bToolpannelLeft=Preferences.toolleft;
01687        UpdateIconPositions();
01688      }
01689      else ReDrawStageDisplay(TRUE);
01690      break;
01691    case IDM_ACTOR_ADD_A:
01692      AddQuickActor(-1);
01693      break;
01694    case IDM_ACTOR_ADD_C:  
01695      Save_UndoA();
01696      local_node=SelectNode(local_nodename,YES,ghwnd_main);
01697      AddCostumeTimeLine(local_node);
01698      UPDATETIMELINES(IDC_TIMEL_UPDATE)
01699      break;
01700    case IDM_ACTOR_ADD_E:{
01701        object *Op1;
01702        if(SelectedNode != NULL){
01703          if(SelectedNode->type == NORMAL){
01704            Save_UndoA();
01705            if((Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
01706              if(Op1->effect != NULL){
01707                int fResult;
01708                fResult=SendPrgmQuery(IDQ_EFFECTEXISTS,2);
01709                if(fResult == IDYES){
01710                  DeleteEffect(Op1);
01711                  AddEffect(Op1,ghwnd_main);
01712                }
01713                else if(fResult == IDNO){
01714                  EditActorEffect(Op1,ghwnd_main);
01715                }
01716              }
01717              else AddEffect(Op1,ghwnd_main);
01718            }
01719            else{
01720              SendPrgmQuery(IDQ_OLD2,0);
01721            }
01722          }
01723          else{
01724            SendPrgmQuery(IDQ_OLD2,0);
01725          }
01726        }
01727        else{
01728          SendPrgmQuery(IDQ_OLD1,0);
01729        }
01730      }
01731      break;
01732    case IDM_ACTOR_DEL_A:
01733    case IDM_ACTOR_DEL_C:
01734      if(SelectedNode != NULL){
01735        Save_UndoA();
01736        if(SelectedNode->type == CAMERA){
01737          if(item == IDM_ACTOR_DEL_C){
01738            SendPrgmQuery(IDQ_CAMERANODELCOSTUME,0);
01739          }
01740          else if(SelectedNode == FirstNp){
01741            SendPrgmQuery(IDQ_CAMERANODELETE,0);
01742          }
01743          else if(SendPrgmQuery(IDQ_DELETECAMERA,1) == IDYES){
01744            if(SelectedNode == SelectedCamera)SelectedCamera=FirstNp;
01745            DeleteNode(SelectedNode);
01746            SelectedNode=NULL;
01747            UpdateSelectedActor(FALSE);
01748            Ncameras--;
01749            ReDrawStageDisplay(TRUE);
01750            if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01751            else UpdateGLview(TRUE);
01752            UPDATETIMELINES(IDC_TIMEL_UPDATE)
01753          }
01754        }
01755        else{
01756          if(SendPrgmQuery(IDQ_DELETEACTOR,1) == IDYES){
01757            if(item == IDM_ACTOR_DEL_A){
01758              if(SelectedNode->type == GROUND)Nground=0;
01759              if(SelectedNode->type == SKY)Nskys=0;
01760              if(SelectedNode->type == DIRECTOR)Ndirectors=0;
01761              if(SelectedNode->type == ROBOT)Nrobots--;
01762              DeleteNode(SelectedNode);
01763              SelectedNode=NULL;
01764              UpdateSelectedActor(FALSE);
01765            }
01766            else if(item == IDM_ACTOR_DEL_C){
01767              if(SelectedNode->type == SKY)DeleteSky(SelectedNode,CurrentFrame);
01768              else DeleteCostume(SelectedNode,CurrentFrame);
01769            }
01770            ReDrawStageDisplay(TRUE);
01771            if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01772            else UpdateGLview(TRUE);
01773            UPDATETIMELINES(IDC_TIMEL_UPDATE)
01774          }
01775        }
01776      }
01777      else SendPrgmQuery(IDQ_OLD1,0);
01778      break;
01779    case IDM_ACTOR_DEL_E:{
01780        object *Op1;
01781        if(SelectedNode != NULL){
01782          Save_UndoA();
01783          if(SelectedNode->type == NORMAL){
01784            if((Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
01785              if(Op1->effect != NULL){
01786                if(SendPrgmQuery(IDQ_DELETEACTOR,1) == IDYES){
01787                   DeleteEffect(Op1);
01788                }
01789              }
01790              else {
01791                SendPrgmQuery(IDQ_NOEFFECT,0);
01792              }
01793            }
01794            else{
01795            }
01796          }
01797          else{
01798            SendPrgmQuery(IDQ_OLD2,0);
01799          }
01800        }
01801        else{
01802          SendPrgmQuery(IDQ_OLD1,0);
01803        }
01804      }
01805      break;
01806    case IDM_ACTOR_SELECT:
01807      if((local_node=SelectNode(local_nodename,YES,ghwnd_main)) != NULL){
01808        if(local_node->type == SKY || local_node->type == IMAGEP){
01809          object *lop;
01810          if((lop=GetObjectAtFrame(local_node,CurrentFrame)) != NULL){
01811            if(local_node->type == SKY)EditSkyDialog((sky *)lop,NO);
01812            else{
01813              if(lop->xip != NULL)
01814                lop->xip=EditObjectImageProcess(ghwnd_main,lop->xip);
01815              else MessageBeep(MB_OK);
01816            }
01817          }
01818          else{
01819            AddCostumeTimeLine(local_node);
01820          }
01821          UPDATETIMELINES(IDC_TIMEL_UPDATE)
01822        }
01823        else {
01824          if(tool != NOTOOL && tool != NODETOOL)DisengageTool();
01825          SelectedNode=local_node;
01826          UpdateSelectedActor(TRUE);
01827          ReDrawStageDisplay(TRUE);
01828          if(SelectedNode->type == GROUND){
01829            object *Op1;
01830            if((Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
01831              EditGroundDialog(Op1,NO);
01832            }
01833          }
01834        }
01835      };
01836      break;
01837    case IDM_ACTOR_INFO:
01838      SelectedInfo();
01839      break;
01840    case IDM_ACTOR_AXIS_SH:
01841      SnapTo(0);
01842      break;
01843    case IDM_ACTOR_AXIS_SNAP:
01844      Save_UndoA();
01845      DisengageTool();
01846      if(StageGrabIdentify()){
01847        SetNewPosition(NpointerX,NpointerY,NpointerZ,1);
01848        ReDrawStageDisplay(TRUE);
01849        if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01850        else UpdateGLview(TRUE);
01851        if(coords_visible)UpdateRuler(0);
01852      }
01853      break;
01854    case IDM_ACTOR_SWAP_ALL:
01855    case IDM_ACTOR_SWAP:{
01856        object *Op1;
01857        if(SelectedNode != NULL){
01858          if(SelectedNode->type == NORMAL || SelectedNode->type == ROBOT){
01859            if((Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
01860              if(SelectSfxFileName(0,gszSCEfile,gszSCEdir,IDX_MISC_REPLACEMENT,
01861                "(*.MFX)|*.mfx|",ghwnd_main) == TRUE){
01862                 Save_UndoA();
01863                 if(item == IDM_ACTOR_SWAP_ALL)ReplaceObjectFile(Op1,gszSCEfile);
01864                 else ReplaceOneObjectFile(SelectedNode,Op1,gszSCEfile);
01865                 ReDrawStageDisplay(TRUE);
01866                 if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01867                 else UpdateGLview(TRUE);
01868                 UPDATETIMELINES(IDC_TIMEL_UPDATE)
01869               }
01870            }
01871            else SendPrgmQuery(IDQ_OLD2,0);
01872          }
01873          else SendPrgmQuery(IDQ_OLD2,0);
01874        }
01875        else SendPrgmQuery(IDQ_OLD1,0);
01876      }
01877      break;
01878    case IDM_ACTOR_RENAME:
01879      if(SelectedNode != NULL){
01880        Save_UndoA();
01881        if(SelectedNode->type == CAMERA &&  SelectedNode == FirstNp){
01882          SendPrgmQuery(IDQ_NOTFIRSTCAMERA,0);
01883          break;
01884        }
01885        LoadString(ghinst_main,IDX_MISC_RENAMEOBJECT,res_str,256);
01886        RequestCharString(64,SelectedNode->actorname,res_str);
01887        UPDATETIMELINES(IDC_TIMEL_UPDATE)
01888      }
01889      break;
01890    case IDM_ACTOR_QADD:
01891      ExecuteActorsMenu(hwnd);
01892      break;
01893    case IDM_ACTOR_QADD_MOD:
01894    case IDM_ACTOR_QADD_MORPH:
01895    case IDM_ACTOR_QADD_CAMERA:
01896    case IDM_ACTOR_QADD_TARGET:
01897    case IDM_ACTOR_QADD_LIGHT:
01898    case IDM_ACTOR_QADD_PATH:
01899    case IDM_ACTOR_QADD_SKY:
01900    case IDM_ACTOR_QADD_GROUND:
01901    case IDM_ACTOR_QADD_XIP:
01902    case IDM_ACTOR_QADD_ROBOT:
01903    case IDM_ACTOR_QADD_CSG:
01904    case IDM_ACTOR_QADD_DIRECTOR:
01905      AddQuickActor(item);
01906      break;
01907    case IDM_ACTOR_TOOL_GRABABS:
01908      if(tool != NOTOOL)DisengageTool();
01909      EDIT_ACTION=YES;
01910      Save_UndoA();
01911      InstantStageGrab();
01912      break;
01913    case IDM_ACTOR_TOOL_ROTATEABS:
01914      if(tool != NOTOOL)DisengageTool();
01915      EDIT_ACTION=YES;
01916      Save_UndoA();
01917      InstantStageRotate();
01918      break;
01919    case IDM_ACTOR_TOOL_SIZEABS:
01920      if(tool != NOTOOL)DisengageTool();
01921      EDIT_ACTION=YES;
01922      Save_UndoA();
01923      InstantStageXpnd();
01924      break;
01925    case IDM_ACTOR_TOOL_GRAB:
01926      if(tool != GRABBER)EngageTool(GRABBER);
01927      break;
01928    case IDM_ACTOR_TOOL_ROTATE:
01929      if(tool != ROTATOR)EngageTool(ROTATOR);
01930      break;
01931    case IDM_ACTOR_TOOL_SIZE:
01932      if(tool != SIZER)EngageTool(SIZER);
01933      break;
01934    case IDM_ACTOR_TOOL_NODE:
01935      if(tool != NODETOOL)EngageTool(NODETOOL);
01936      break;
01937    case IDM_EDIT_SPLINETWEEN:    // same as of tool button
01938    case IDM_ACTOR_TOOL_SHIFTER:
01939      if(tool != TRACKER)EngageTool(TRACKER);
01940      break;
01941    case IDM_ACTOR_TOOL_POSE:
01942      if(tool != SKELETOR)EngageTool(SKELETOR);
01943      break;
01944 
01945    case IDM_ACTOR_TOOL_UNDO:
01946      if(UNDO_TYPE == 1)AnimatorUndo();
01947      else              Restore_UndoA();
01948      break;
01949    case IDM_ACTOR_TOOL_PAN:
01950      if(tool != PAN)EngageTool(PAN);
01951      break;
01952    case IDM_ACTOR_TOOL_ZOOMIN:
01953      if(tool != INZOOM)EngageTool(INZOOM);
01954      break;
01955    case IDM_ACTOR_USEDIRECTOR:
01956      use_director ^= 1;
01957      if(use_director == 1)CheckMenuItem(GetMenu(ghwnd_main),
01958                           IDM_ACTOR_USEDIRECTOR,MF_CHECKED);
01959      else                 CheckMenuItem(GetMenu(ghwnd_main),
01960                           IDM_ACTOR_USEDIRECTOR,MF_UNCHECKED);
01961      if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01962      else UpdateGLview(TRUE);
01963      break;
01964    case IDM_ACTOR_ACTCAMERA:
01965      if(SelectedNode != NULL){
01966        if(SelectedNode->type == CAMERA){
01967          SelectedCamera=SelectedNode;
01968          ReDrawStageDisplay(TRUE);
01969          if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
01970          else UpdateGLview(TRUE);
01971        }
01972      }
01973      else SendPrgmQuery(IDQ_OLD1,0);
01974      break;
01975    case IDM_EDIT_XIMAGE:
01976      DialogBox(ghinst_main,MAKEINTRESOURCE(DLG_XIP),ghwnd_main,
01977         (DLGPROC)EditXipDlgProc);
01978      break;
01979    case IDM_PATH_EDIT:
01980      if(tool != PATHEDITOR)EngageTool(PATHEDITOR);
01981      break;
01982    case IDM_PATH_CURSORTO_START:
01983      SnapTo(1);
01984      break;
01985    case IDM_PATH_CURSORTO_END:
01986      SnapTo(2);
01987      break;
01988    case IDM_PATH_CURSORTO_POINT:
01989      SnapTo(3);
01990      break;
01991    case IDM_PATH_GRAPH_POSITION:
01992      EditPathMovement(1);
01993      break;
01994    case IDM_PATH_REVERSE:{
01995        object *Op1;
01996        if(SelectedNode != NULL){
01997          if(SelectedNode->type == PATH){
01998            if((Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
01999              EDIT_ACTION=YES;
02000              Save_UndoA();
02001              ReversePathDirection(Op1);
02002              ReDrawStageDisplay(TRUE);
02003              if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02004              else UpdateGLview(TRUE);
02005              UpdateGLview(TRUE);
02006            }
02007            else SendPrgmQuery(IDQ_OLD2,0);
02008          }
02009          else SendPrgmQuery(IDQ_NOTAPATH,0);
02010        }
02011        else SendPrgmQuery(IDQ_OLD1,0);
02012      }
02013      break;
02014 
02015    case IDM_FRAME_GO_FIRST:
02016      CurrentFrame=1;
02017      ReDrawStageDisplay(TRUE);
02018      UpdateSelectedActor(FALSE);
02019      if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02020      else UpdateGLview(TRUE);
02021 //     SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
02022      SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02023      break;
02024    case IDM_FRAME_GO_PREVIOUS:
02025      if(CurrentFrame > 1){
02026        if     (GetAsyncKeyState(VK_SHIFT  ) & 0x8000)CurrentFrame -=  5;
02027        else if(GetAsyncKeyState(VK_CONTROL) & 0x8000)CurrentFrame -= 10;
02028        else if(GetAsyncKeyState(VK_MENU   ) & 0x8000)CurrentFrame -= 20;
02029        else            CurrentFrame--;
02030        CurrentFrame=max(CurrentFrame,1);
02031        UpdateSelectedActor(FALSE);
02032        ReDrawStageDisplay(TRUE);
02033        if(ghwndOpenGLview == NULL){
02034          PerspectiveView(0,1);
02035          UpdateWindow(ghwnd_view);
02036        }
02037        else UpdateGLview(TRUE);
02038 //       SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
02039        SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02040      }
02041      break;
02042    case IDM_FRAME_GO_NEXT:
02043      if(CurrentFrame < Nframes){
02044        if     (GetAsyncKeyState(VK_SHIFT  ) & 0x8000)CurrentFrame +=  5;
02045        else if(GetAsyncKeyState(VK_CONTROL) & 0x8000)CurrentFrame += 10;
02046        else if(GetAsyncKeyState(VK_MENU   ) & 0x8000)CurrentFrame += 20;
02047        else            CurrentFrame++;
02048        CurrentFrame=min(CurrentFrame,Nframes);
02049        UpdateSelectedActor(FALSE);
02050        ReDrawStageDisplay(TRUE);
02051        if(ghwndOpenGLview == NULL){
02052          PerspectiveView(0,1);
02053          UpdateWindow(ghwnd_view);
02054        }
02055        else UpdateGLview(TRUE);
02056 //       SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
02057        SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02058      }
02059      break;
02060    case IDM_FRAME_GO_LAST:
02061      CurrentFrame=Nframes;
02062      UpdateSelectedActor(FALSE);
02063      ReDrawStageDisplay(TRUE);
02064      if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02065      else UpdateGLview(TRUE);
02066 //     SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
02067      SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02068      break;
02069    case IDM_FRAME_GO_NEXTKEY:
02070      NextKey('N');
02071      if(IsWindow(ghwndRobotView))SendMessage(ghwndRobotView,WM_DRAWROBOT,0,0);
02072      break;
02073    case IDM_FRAME_GO_LASTKEY:
02074      NextKey('L');
02075      if(IsWindow(ghwndRobotView))SendMessage(ghwndRobotView,WM_DRAWROBOT,0,0);
02076      break;
02077    case IDM_FRAME_GO_FRAME:{
02078        int id;
02079        char ttt[64];
02080        LoadString(ghinst_main,IDX_MISC_GOTOFRAME,res_str,256);
02081        LoadString(ghinst_main,IDX_MISC_FRAMEID,ttt,64);
02082        id=RequestNumEntry(CurrentFrame,1,Nframes,res_str,ttt);
02083        if(id != CurrentFrame && id > 0 && id <= Nframes){
02084          CurrentFrame=(long)id;
02085          ReDrawStageDisplay(TRUE);
02086          UpdateSelectedActor(FALSE);
02087          if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02088          else UpdateGLview(TRUE);
02089 //         SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
02090          SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02091          if(IsWindow(ghwndRobotView))SendMessage(ghwndRobotView,WM_DRAWROBOT,0,0);
02092        }
02093      }
02094      break;
02095    case IDM_FRAME_HIDDENLINE:
02096     if(!MakeScript(3,1))SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
02097     else LoadRenderer(0);
02098     break;
02099    case IDM_FRAME_QUICKRENDER:
02100    case IDM_FRAME_RENDERIN:
02101     if(!MakeScript(3,1))SendPrgmQuery(IDQ_SCRIPTOPENFAIL,0);
02102     else LoadRenderer(3);
02103     break;
02104    case IDM_FRAME_RENDERNOW:
02105      LoadRenderer(2);
02106      break;
02107    case IDM_FRAME_RENDER:
02108      LoadRenderer(1);
02109      break;
02110    case IDM_FRAME_SHOW:{
02111        int result;
02112        char modulename[255],cp[128],cn[128];
02113        GetPrivateProfileString("VIEWER","FILE","$$$",
02114           cn,sizeof(cn),IniFilename);
02115        GetPrivateProfileString("VIEWER","PATH","$$$",
02116           cp,sizeof(cp),IniFilename);
02117        if(strncmp(cn,"$$$",3) == 0 || strncmp(cp,"$$$",3) == 0){
02118          SendPrgmQuery(IDQ_NOLASTIMAGE,0);
02119        }
02120        else LoadUtility("winview.exe","OFX:ViewClass",107);
02121      }
02122      break;
02123    case IDM_FRAME_PLAY_WIRE:
02124      AnimationPlayer(0,hwnd);
02125      break;
02126    case IDM_FRAME_PLAY_QUICK:
02127      if((GetKeyState(VK_CONTROL) & 0x8000) != 0x8000){
02128        AnimationPlayer(2,hwnd);
02129        break;
02130      }
02131    case IDM_FRAME_PLAY_FULL:
02132      AnimationPlayer(1,hwnd);
02133      break;
02134    case IDM_FRAME_SETNUMBER:
02135      if(busy_flag)break;
02136      if(tool == NOTOOL){
02137        int id;
02138        id=Nframes;
02139        Save_UndoA();
02140        busy_flag=TRUE;
02141        SetNumberOfFrames(0);
02142        busy_flag=FALSE;
02143        if(id != Nframes){
02144          if(CurrentFrame > Nframes)CurrentFrame=Nframes;
02145 //         SetScrollRange(ghwnd_xscl,SB_CTL,1,(int)Nframes,FALSE);
02146          SendMessage(ghwnd_xscl,TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(1,Nframes));
02147          UPDATETIMELINES(IDC_TIMEL_UPDATE)
02148          if(ghwndTimeline != NULL && IsZoomed(ghwndTimeline)){
02149 //           SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,FALSE);
02150            SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02151            break;
02152          }
02153          else{
02154 //           SetScrollPos(ghwnd_xscl,SB_CTL,(int)CurrentFrame,TRUE);
02155            SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02156          }
02157          ReDrawStageDisplay(TRUE);
02158          if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02159          else UpdateGLview(TRUE);
02160          if(coords_visible)UpdateRuler(0);
02161        }
02162      }
02163      else SendPrgmQuery(IDQ_NOT_IN_TOOL,0);
02164      break;
02165    case IDM_FRAME_INSERT:
02166      if(busy_flag)break;
02167      if(tool == NOTOOL){
02168        int id;
02169        id=Nframes;
02170        Save_UndoA();
02171        busy_flag=TRUE;
02172        if(InsertFrames(TRUE,0,CurrentFrame,Nframes)){
02173          busy_flag=FALSE;
02174          SendMessage(ghwnd_xscl,TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(1,Nframes));
02175          UPDATETIMELINES(IDC_TIMEL_UPDATE)
02176          if(ghwndTimeline != NULL && IsZoomed(ghwndTimeline)){
02177            SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02178            break;
02179          }
02180          else{
02181            SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02182          }
02183          ReDrawStageDisplay(TRUE);
02184          if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02185          else UpdateGLview(TRUE);
02186          if(coords_visible)UpdateRuler(0);
02187        }
02188        else busy_flag=FALSE;
02189      }
02190      else SendPrgmQuery(IDQ_NOT_IN_TOOL,0);
02191      break;
02192    case IDM_FRAME_DELETE:
02193      if(busy_flag)break;
02194      if(tool == NOTOOL){
02195        int id;
02196        id=Nframes;
02197        Save_UndoA();
02198        busy_flag=TRUE;
02199        if(DeleteRangeOfFrames(TRUE,0,CurrentFrame,Nframes)){
02200          if(CurrentFrame > Nframes)CurrentFrame=Nframes;
02201          busy_flag=FALSE;
02202          SendMessage(ghwnd_xscl,TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(1,Nframes));
02203          UPDATETIMELINES(IDC_TIMEL_UPDATE)
02204          if(ghwndTimeline != NULL && IsZoomed(ghwndTimeline)){
02205            SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02206            break;
02207          }
02208          else{
02209            SendMessage(ghwnd_xscl,TBM_SETPOS,TRUE,(LPARAM)CurrentFrame);
02210          }
02211          ReDrawStageDisplay(TRUE);
02212          if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02213          else UpdateGLview(TRUE);
02214          if(coords_visible)UpdateRuler(0);
02215        }
02216        else busy_flag=FALSE;
02217      }
02218      else SendPrgmQuery(IDQ_NOT_IN_TOOL,0);
02219      break;
02220    case IDM_FRAME_PREVIEW_MAKE:
02221      if(MakePreview() == FAIL)break;
02222      break;
02223    case IDM_STOP_TOOL:
02224      if(tool != NOTOOL){
02225        DisengageTool();
02226      }
02227      break;
02228    case IDM_QUIET_EDITCOSTUME:{
02229        BOOL draw=FALSE;
02230        object *Op;
02231        Op=GetObjectAtFrame(SelectedNode,CurrentFrame);
02232        if(Op != NULL){
02233          switch (Op->type){
02234            case NORMAL:
02235            case ANIMOBJ:
02236              Save_UndoA();
02237              DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_COSTUME),
02238                       ghwnd_main,(DLGPROC)EditObjectDlgProc,(LPARAM)Op);
02239              draw=TRUE; break;
02240            case PARTICLE:
02241            case PATH:
02242            case TARGET:
02243            case ROBOT:
02244              Save_UndoA();
02245              EditObject(SelectedNode,(short)Op->lastframe,
02246                                      (short)Op->lastframe,NO,NO);
02247              draw=TRUE;
02248              break;
02249            case LIGHT:
02250              Save_UndoA();
02251              EditLightDialog(Op,NO);
02252              draw=TRUE;
02253              break;
02254            case GROUND:
02255              Save_UndoA();
02256              EditGroundDialog(Op,NO);
02257              draw=TRUE;
02258              break;
02259            default: break;
02260          }
02261          if(draw){
02262            CheckRecursiveFollow(SelectedNode,Op->firstframe,Op->lastframe);
02263            UpdateSelectedActor(FALSE);
02264            ReDrawStageDisplay(TRUE);
02265            if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02266            else UpdateGLview(TRUE);
02267            UPDATETIMELINES(IDC_TIMEL_UPDATE)
02268          }
02269        }
02270      }
02271      break;
02272    case IDM_QUIET_EDITLIGHT:
02273    case IDM_QUIET_EDITLENS:
02274      LensSettings();
02275      ReDrawStageDisplay(TRUE);
02276      UPDATETIMELINES(IDC_TIMEL_UPDATE)
02277      break;
02278    case IDM_TIMELINE_LINE_ADDP:
02279      if(SelectedNode != NULL){
02280        int id;
02281        Save_UndoA();
02282        if(CheckForControl(SelectedNode,'P') == YES){
02283          id=SendPrgmQuery(IDQ_DELETECHANNEL,1);
02284          if(id == IDYES){
02285            DeletePosition(SelectedNode,CurrentFrame);
02286            UPDATETIMELINES(IDC_TIMEL_UPDATE)
02287          }
02288        }
02289        else MakeControl(SelectedNode,'P',ghwnd_main);
02290        ReDrawStageDisplay(TRUE);
02291        if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02292        else UpdateGLview(TRUE);
02293      }
02294      else SendPrgmQuery(IDQ_NOACTORSELECTED,0);
02295      break;
02296    case IDM_TIMELINE_LINE_ADDR:
02297      if(SelectedNode != NULL){
02298        int id;
02299        Save_UndoA();
02300        if(CheckForControl(SelectedNode,'A') == YES){
02301          id=SendPrgmQuery(IDQ_DELETECHANNELX,1);
02302          if(id == IDYES){
02303            DeleteAlign(SelectedNode,CurrentFrame);
02304            UPDATETIMELINES(IDC_TIMEL_UPDATE)
02305          }
02306        }
02307        else MakeControl(SelectedNode,'A',ghwnd_main);
02308        ReDrawStageDisplay(TRUE);
02309        if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02310        else UpdateGLview(TRUE);
02311      }
02312      else SendPrgmQuery(IDQ_NOACTORSELECTED,0);
02313      break;
02314    case IDM_TIMELINE_LINE_ADDX:
02315      if(SelectedNode != NULL){
02316        int id;
02317        Save_UndoA();
02318        if(CheckForControl(SelectedNode,'Z') == YES){
02319          id=SendPrgmQuery(IDQ_DELETECHANNELX,1);
02320          if(id == IDYES){
02321            DeleteSize(SelectedNode,CurrentFrame);
02322            UPDATETIMELINES(IDC_TIMEL_UPDATE)
02323          }
02324        }
02325        else MakeControl(SelectedNode,'Z',ghwnd_main);
02326        ReDrawStageDisplay(TRUE);
02327        if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02328        else UpdateGLview(TRUE);
02329      }
02330      else SendPrgmQuery(IDQ_NOACTORSELECTED,0);
02331      break;
02332    case IDM_TIMELINE_KEY_ADDP:
02333      Save_UndoA();
02334      MakeKey('P',CurrentFrame,SelectedNode);
02335      break;
02336    case IDM_TIMELINE_KEY_ADDR:
02337      Save_UndoA();
02338      MakeKey('A',CurrentFrame,SelectedNode);
02339      break;
02340    case IDM_TIMELINE_KEY_ADDX:
02341      Save_UndoA();
02342      MakeKey('X',CurrentFrame,SelectedNode);
02343      break;
02344    case IDM_TIMELINE_KEY_RESETR:
02345    case IDM_TIMELINE_KEY_RESETX:
02346    case IDM_TIMELINE_KEY_RESETP:{
02347        object   *Op=NULL;
02348        position *Pp=NULL;
02349        align    *Ap=NULL;
02350        size     *Xp=NULL;
02351        Save_UndoA();
02352        GetTimelinesAtFrame(SelectedNode,CurrentFrame,&Op,&Pp,&Ap,&Xp);
02353        if     (item == IDM_TIMELINE_KEY_RESETP && Pp != NULL){
02354          Pp->finish[0]=Pp->finish[1]=Pp->finish[2]=0;
02355        }
02356        else if(item == IDM_TIMELINE_KEY_RESETR && Ap != NULL){
02357          Ap->theta=0.0; Ap->phi=0.0; Ap->alpha=0.0;
02358        }
02359        else if(item == IDM_TIMELINE_KEY_RESETX && Xp != NULL){
02360          Xp->Sx=1.0; Xp->Sy=1.0; Xp->Sz=1.0;
02361        }
02362        ReDrawStageDisplay(TRUE);
02363        if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02364        else UpdateGLview(TRUE);
02365      }
02366      break;
02367    case IDM_TIMELINE_KEY_SHIFT:
02368      ShiftAllKeys(1);
02369      break;
02370    case IDM_TIMELINE_SHIFT_ACTOR:   // shift all keyframes for selected actor
02371      ShiftAllKeys(0);
02372      break;
02373    case IDM_TIMELINE_MOVE_ALLA:     // move position of actor in all keyframes by DELTA
02374       ShiftSelectedPositionAllKeys();
02375       break;
02376    case IDM_VIEW_DRAW_BOUNDED:
02377      if(DrawStatus == 0){
02378        char tt[128];
02379        DrawStatus=AllDrawStatus;
02380        EnableMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_SELECTED,MF_ENABLED);
02381        EnableMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_DESELECTED,MF_ENABLED);
02382        EnableMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_ALL,MF_ENABLED);
02383        LoadString(ghinst_main,IDX_MISC_DRAWBOUNDED,tt,128);
02384        ModifyMenu(GetMenu(ghwnd_main),IDM_VIEW_DRAW_BOUNDED,
02385            MF_BYCOMMAND|MF_STRING,IDM_VIEW_DRAW_BOUNDED,tt);
02386      }
02387      else{
02388        char tt[128];
02389        DrawStatus=0;
02390        EnableMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_SELECTED,MF_GRAYED);
02391        EnableMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_DESELECTED,MF_GRAYED);
02392        EnableMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_ALL,MF_GRAYED);
02393        LoadString(ghinst_main,IDX_MISC_DRAWFULL,tt,128);
02394        ModifyMenu(GetMenu(ghwnd_main),IDM_VIEW_DRAW_BOUNDED,
02395            MF_BYCOMMAND|MF_STRING,IDM_VIEW_DRAW_BOUNDED,tt);
02396      }
02397      ReDrawStageDisplay(TRUE);
02398      break;
02399    case IDM_VIEW_DRAW_SELECTED:
02400    case IDM_VIEW_DRAW_DESELECTED:
02401    case IDM_VIEW_DRAW_ALL:
02402      switch(item){
02403        case IDM_VIEW_DRAW_SELECTED:   AllDrawStatus=1; break;
02404        case IDM_VIEW_DRAW_DESELECTED: AllDrawStatus=2; break;
02405        case IDM_VIEW_DRAW_ALL:        AllDrawStatus=3; break;
02406      }
02407      CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_ALL       ,MF_UNCHECKED);
02408      CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_SELECTED  ,MF_UNCHECKED);
02409      CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_DESELECTED,MF_UNCHECKED);
02410      if(AllDrawStatus == 1)CheckMenuItem(GetMenu(ghwnd_main),
02411                            IDM_VIEW_DRAW_SELECTED  ,MF_CHECKED);
02412      if(AllDrawStatus == 2)CheckMenuItem(GetMenu(ghwnd_main),
02413                            IDM_VIEW_DRAW_DESELECTED,MF_CHECKED);
02414      if(AllDrawStatus == 3)CheckMenuItem(GetMenu(ghwnd_main),
02415                            IDM_VIEW_DRAW_ALL       ,MF_CHECKED);
02416      if(DrawStatus > 0)DrawStatus=AllDrawStatus;
02417      ReDrawStageDisplay(TRUE);
02418      break;
02419    case IDM_VIEW_LOCKBOUNDED:
02420      local_node=SelectedNode;
02421      if(local_node != NULL){
02422        if(local_node->type == NORMAL){
02423          int id;
02424          object *Op1;
02425          char objname[256];
02426          LoadString(ghinst_main,IDX_MISC_QUICKONLYFOR,res_str,256);
02427          sprintf(objname,res_str,SelectedNode->actorname);
02428          LoadString(ghinst_main,IDX_MISC_QUICKDRAW,res_str,256);
02429          id=MessageBox(NULL,objname,res_str,
02430             MB_YESNOCANCEL|MB_ICONQUESTION|MB_TASKMODAL|MB_DEFBUTTON3);
02431          if(id == IDCANCEL)break;
02432          Op1=local_node->fobj; while (Op1 != NULL){
02433            if(id == IDYES)Op1->quick_only=1;
02434            else           Op1->quick_only=0;
02435            Op1=Op1->next;
02436          }
02437          ReDrawStageDisplay(TRUE);
02438        }
02439        else SendPrgmQuery(IDQ_OLD2,0);
02440      }
02441      else SendPrgmQuery(IDQ_OLD1,0);
02442      break;
02443    case IDM_VIEW_GLOBALQUICKDRAW:
02444      global_quickdraw ^= 1;
02445      if(global_quickdraw)CheckMenuItem(GetMenu(ghwnd_main),
02446                          IDM_VIEW_GLOBALQUICKDRAW,MF_CHECKED);
02447      else                CheckMenuItem(GetMenu(ghwnd_main),
02448                          IDM_VIEW_GLOBALQUICKDRAW,MF_UNCHECKED);
02449      break;
02450    case IDM_VIEW_DRAW_GRID:
02451      draw_grid_on ^= 1;
02452      if(draw_grid_on)
02453        CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_CHECKED);
02454      else
02455        CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_UNCHECKED);
02456      ReDrawStageDisplay(TRUE);
02457      break;
02458    case IDM_VIEW_GRID:
02459      grid_on ^= 1;
02460      if(grid_on)CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_GRID,MF_CHECKED);
02461      else       CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_GRID,MF_UNCHECKED);
02462 //     if(draw_grid_on)ReDrawStageDisplay(TRUE);
02463      break;
02464    case IDM_VIEW_DEFINEGRID:
02465      SetUpGrid();
02466      if(draw_grid_on)
02467        CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_CHECKED);
02468      else
02469        CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_UNCHECKED);
02470      ReDrawStageDisplay(TRUE);
02471      break;
02472    case IDM_ZOOM_IN:
02473      Zoom(ZOOMIN,1);
02474      break;
02475    case IDM_ZOOM_OUT:
02476      Zoom(ZOOMOUT,1);
02477      break;
02478    case IDM_ZOOM_CENTRE:
02479      Zoom(RECENTRE,1);
02480      break;
02481    case IDM_VIEW_RESTORE:
02482      GetTriview(TRUE);
02483      NpointerX=NpointerY=NpointerZ=0;
02484      ReDrawStageDisplay(TRUE);
02485      if(ghwndOpenGLview == NULL)PerspectiveView(0,1);
02486      else UpdateGLview(TRUE);
02487      UpdateRuler(0);
02488      break;
02489    case IDM_VIEW_FULL:
02490      Zoom(CENTREWORLD,1);
02491      break;
02492    case IDM_VIEW_FEEDBACK_CAMERA:
02493      show_camera_fov ^= 1;
02494      if(show_camera_fov)CheckMenuItem(GetMenu(ghwnd_main),
02495                         IDM_VIEW_FEEDBACK_CAMERA,MF_CHECKED);
02496      else               CheckMenuItem(GetMenu(ghwnd_main),
02497                         IDM_VIEW_FEEDBACK_CAMERA,MF_UNCHECKED);
02498      ReDrawStageDisplay(TRUE);
02499      break;
02500    case IDM_VIEW_FEEDBACK_LIGHT:
02501      show_light_cones ^= 1;
02502      if(show_light_cones)CheckMenuItem(GetMenu(ghwnd_main),
02503                          IDM_VIEW_FEEDBACK_LIGHT,MF_CHECKED);
02504      else                CheckMenuItem(GetMenu(ghwnd_main),
02505                          IDM_VIEW_FEEDBACK_LIGHT,MF_UNCHECKED);
02506      ReDrawStageDisplay(TRUE);
02507      break;
02508    case IDM_WINDOW_BIGCAMERA:
02509      BigCameraView ^= 1;
02510      if(BigCameraView)CheckMenuItem(GetMenu(ghwnd_main),
02511                       IDM_WINDOW_BIGCAMERA,MF_CHECKED);
02512      else             CheckMenuItem(GetMenu(ghwnd_main),
02513                       IDM_WINDOW_BIGCAMERA,MF_UNCHECKED);
02514      if(View == ONEVIEW){
02515        RECT rc;
02516        GetClientRect(ghwnd_main,&rc);
02517        SendMessage(ghwnd_main,WM_SIZE,0,MAKELPARAM(rc.right,rc.bottom));
02518        if(BigCameraView)ToolboxSetPosition(2);
02519        else             ToolboxSetPosition(1);
02520      }
02521      break;
02522    case IDM_WINDOW_SWITCHWINDOWS:
02523      SwitchWindow(-1);
02524      break;
02525    case IDM_VIEW_SWAPVIEWPOINT:
02526      WindowBox_view ^= 1;
02527      SetUpWindowBoxView(WindowBox_view);
02528      SwapViewBitmaps();
02529      ReDrawStageDisplay(TRUE);
02530      break;
02531    case IDM_WINDOW_SWITCHWINDOW0:
02532      SwitchWindow(0);
02533      break;
02534    case IDM_WINDOW_SWITCHWINDOW1:
02535      SwitchWindow(1);
02536      break;
02537    case IDM_WINDOW_CLOSE:
02538      CloseUtilities(0);
02539      break;
02540    case IDM_WINDOW_COORDS:{
02541        HMENU hmenu;
02542        int cv[2]={SW_HIDE,SW_SHOWNA};
02543        hmenu=GetMenu(ghwnd_main);
02544        coords_visible ^=1;
02545        if(IsWindow(ghwndCoord1))ShowWindow(ghwndCoord1,cv[coords_visible]);
02546      }
02547      break;
02548    case IDM_WINDOW_TOOLLEFT:
02549      break;
02550    case IDM_WINDOW_RESET:
02551      Window0sizeX=TriviewSpaceX/2;
02552      Window0sizeY=TriviewSpaceY/2;
02553      if(View == TRIVIEW)FormatScreen();
02554      break;
02555    case IDM_FILE_KEYFRAMERDOCK:
02556      i=0;
02557      if(IsWindow(ghwndTimeline)){
02558        if(IsWindowVisible(ghwndTimeline)){
02559          i=1; /* window was visible */
02560          TimelineEditor(); /* Hide It */
02561        }
02562        if(keyframer_docked)FormatScreen();
02563        DestroyTimelineEditor();
02564      }
02565      keyframer_docked ^=1;
02566      if(keyframer_docked)
02567        CheckMenuItem(GetMenu(ghwnd_main),IDM_FILE_KEYFRAMERDOCK,MF_CHECKED);
02568      else
02569        CheckMenuItem(GetMenu(ghwnd_main),IDM_FILE_KEYFRAMERDOCK,MF_UNCHECKED);
02570      if(i == 1){
02571        if(keyframer_docked)keyframer_docked_and_visible=1;
02572        FormatScreen();
02573        TimelineEditor();
02574      }
02575      break;
02576    case IDM_WINDOW_ACTIVATE: {
02577        RECT  r;
02578        POINT p;
02579        HDC hdc;
02580        int i;
02581        if(View == ONEVIEW){
02582          if(ActiveView == TRIFRONT)
02583            PostMessage(hwnd,WM_COMMAND,IDM_WINDOW_SWITCHWINDOW1,0);
02584          else
02585            PostMessage(hwnd,WM_COMMAND,IDM_WINDOW_SWITCHWINDOW0,0);
02586          break;
02587        }
02588        hdc=GetDC(ghwnd_main);
02589        FocusActiveWindow(hdc,FALSE);
02590        ActiveView++; if(ActiveView > 2)ActiveView=0;
02591        ghwnd_current=ghwnd_triview[ActiveView];
02592        FocusActiveWindow(hdc,TRUE);
02593        ReleaseDC(ghwnd_main,hdc);
02594      }
02595      break;
02596    case IDM_COORDS_DEFINE:
02597      UpdateRuler(3);
02598      break;
02599    case IDM_COORDS_ORIGIN:
02600      UpdateRuler(2);
02601      break;
02602    case IDM_COORDS_RELATIVE:
02603      UpdateRuler(1);
02604      break;
02605    case IDM_COORDS_MEASURE:
02606      UpdateRuler(0);
02607      break;
02608    case IDM_PAN_UP:
02609      Nudge(item);
02610      break;
02611    case IDM_PAN_DOWN:
02612      Nudge(item);
02613      break;
02614    case IDM_PAN_LEFT:
02615      Nudge(item);
02616      break;
02617    case IDM_PAN_RIGHT:
02618      Nudge(item);
02619      break;
02620    case IDM_VIEW_FEEDBACK_CURSOR:{
02621        char tt[128];
02622        Draw3dCursor();
02623        CursorToggle ^= 1;
02624        Draw3dCursor();
02625        if(CursorToggle){
02626          LoadString(ghinst_main,IDX_MISC_CROSSHAIR,tt,128);
02627          ModifyMenu(GetMenu(ghwnd_main),IDM_VIEW_FEEDBACK_CURSOR,
02628           MF_BYCOMMAND|MF_STRING,IDM_VIEW_FEEDBACK_CURSOR,tt);
02629        }
02630        else{
02631          LoadString(ghinst_main,IDX_MISC_CROSSWIRE,tt,128);
02632          ModifyMenu(GetMenu(ghwnd_main),IDM_VIEW_FEEDBACK_CURSOR,
02633           MF_BYCOMMAND|MF_STRING,IDM_VIEW_FEEDBACK_CURSOR,tt);
02634        }
02635      }
02636      break;
02637    case IDM_SELECT_ACTOR:
02638      PickNode(NORMAL,99);
02639      break;
02640    case IDM_SELECT_PATH:
02641      PickNode(PATH,99);
02642      break;
02643    case IDM_SELECT_LIGHT:{
02644        object *Op1;
02645        if((GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
02646            SelectedNode != NULL && SelectedNode->type == LIGHT &&
02647              (Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
02648          EditLightDialog(Op1,NO);
02649        }
02650        else PickNode(LIGHT,99);
02651      }
02652      break;
02653    case IDM_SELECT_TARGET:
02654      PickNode(TARGET,99);
02655      break;
02656    case IDM_SELECT_CAMERA:
02657      PickNode(CAMERA,99);
02658      break;
02659    case IDM_SELECT_ROBOT:
02660      PickNode(ANIMOBJ,ROBOT);
02661      break;
02662    case IDM_SELECT_CSG:
02663      PickNode(PARTICLE,99);
02664      break;
02665    case IDM_SELECT_GROUND:{
02666        node *oldnode;
02667        object *Op1;
02668        oldnode=SelectedNode;
02669        PickNode(GROUND,99);
02670        if(SelectedNode != NULL && SelectedNode == oldnode &&
02671           SelectedNode->type == GROUND){
02672          if((Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
02673            EditGroundDialog(Op1,NO);
02674          }
02675        }
02676      }
02677      break;
02678    case IDM_HELP_HOME:
02679 #if __LITE__
02680      LoadString(ghinst_main,IDX_MISC_HOMEPAGEL,res_str,256);
02681 #else
02682      LoadString(ghinst_main,IDX_MISC_HOMEPAGE,res_str,256);
02683 #endif
02684      strcpy(lname,gszHomeDir);
02685      ShellExecute(ghwnd_main,NULL,res_str,NULL,lname,0);
02686      break;
02687    case IDM_HELP_SUPPORT:
02688 #if __LITE__
02689      LoadString(ghinst_main,IDX_MISC_SUPPORTPAGEL,res_str,256);
02690 #else
02691      LoadString(ghinst_main,IDX_MISC_SUPPORTPAGE,res_str,256);
02692 #endif
02693      strcpy(lname,gszHomeDir);
02694      ShellExecute(ghwnd_main,NULL,res_str,NULL,lname,0);
02695      break;
02696    case IDM_HELP:{
02697        char res_str1[256],res_str2[256];
02698        LoadString(ghinst_main,IDX_MISC_HELPFILENAME,res_str,256);
02699        strcpy(lname,gszHomeDir); strcat(lname,"help\\");
02700        strcpy(res_str1,lname);
02701        strcat(res_str1,res_str);
02702 #if !__HELP_WS__
02703        ShellExecute(ghwnd_main,NULL,res_str1,
02704                     NULL,lname,SW_SHOW);
02705 #else
02706        {
02707          HH_WINTYPE hhwin;
02708          char localname[32],localname1[32]=">";
02709          sprintf(localname,"AHelp%ld",rand());
02710          strcat(localname1,localname);
02711          memset(&hhwin,0,sizeof(HH_WINTYPE));
02712          hhwin.cbStruct=sizeof(HH_WINTYPE);
02713          hhwin.fsValidMembers = HHWIN_PARAM_SHOWSTATE |
02714                                 HHWIN_PARAM_PROPERTIES|
02715                                 HHWIN_PARAM_CUR_TAB|
02716                                 HHWIN_PARAM_EXPANSION|
02717                                 HHWIN_PARAM_RECT;
02718          hhwin.rcWindowPos.top=0;
02719          hhwin.rcWindowPos.left=0;
02720          hhwin.rcWindowPos.right=700;
02721          hhwin.rcWindowPos.bottom=500;
02722          hhwin.nShowState=SW_SHOW;
02723          hhwin.pszType=localname;
02724          LoadString(ghinst_main,IDX_MISC_HELPTITLE1,res_str,256);
02725          hhwin.pszCaption=res_str;
02726          hhwin.fNotExpanded = FALSE;
02727          hhwin.fsWinProperties = HHWIN_PROP_TRI_PANE|HHWIN_PROP_TAB_SEARCH;
02728          hhwin.curNavType=HHWIN_NAVTYPE_TOC;
02729          strcpy(res_str2,res_str1);
02730          strcat(res_str2,"::toc.hhc");
02731          hhwin.pszToc=res_str2;
02732          HtmlHelp(ghwnd_main,NULL,HH_SET_WIN_TYPE,(DWORD)&hhwin);
02733          hWndHelp=HtmlHelp(ghwnd_main,localname1,HH_DISPLAY_TOPIC,(DWORD)res_str1);
02734        }
02735 #endif
02736      }
02737      break;
02738    case IDM_HELP_GENERAL:{
02739        char res_str1[256],res_str2[256];
02740        LoadString(ghinst_main,IDX_MISC_HELPFILENAME1,res_str,256);
02741        strcpy(lname,gszHomeDir); strcat(lname,"help\\");
02742        strcpy(res_str1,lname);
02743        strcat(res_str1,res_str);
02744 #if !__HELP_WS__
02745        ShellExecute(ghwnd_main,NULL,res_str1,
02746                     NULL,lname,SW_SHOW);
02747 #else
02748        {
02749          HH_WINTYPE hhwin;
02750          char localname[32],localname1[32]=">";
02751          sprintf(localname,"GHelp%ld",rand());
02752          strcat(localname1,localname);
02753          memset(&hhwin,0,sizeof(HH_WINTYPE));
02754          hhwin.cbStruct=sizeof(HH_WINTYPE);
02755          hhwin.fsValidMembers = HHWIN_PARAM_SHOWSTATE |
02756                                 HHWIN_PARAM_PROPERTIES|
02757                                 HHWIN_PARAM_CUR_TAB|
02758                                 HHWIN_PARAM_EXPANSION|
02759                                 HHWIN_PARAM_RECT;
02760          hhwin.rcWindowPos.top=0;
02761          hhwin.rcWindowPos.left=0;
02762          hhwin.rcWindowPos.right=700;
02763          hhwin.rcWindowPos.bottom=500;
02764          hhwin.nShowState=SW_SHOW;
02765          hhwin.pszType=localname;
02766          LoadString(ghinst_main,IDX_MISC_HELPTITLE2,res_str,256);
02767          hhwin.pszCaption=res_str;
02768          hhwin.fNotExpanded = FALSE;
02769          hhwin.fsWinProperties = HHWIN_PROP_TRI_PANE|HHWIN_PROP_TAB_SEARCH;
02770          hhwin.curNavType=HHWIN_NAVTYPE_TOC;
02771          strcpy(res_str2,res_str1);
02772          strcat(res_str2,"::toc.hhc");
02773          hhwin.pszToc=res_str2;
02774          hhwin.hwndCaller=ghwnd_main;
02775          HtmlHelp(ghwnd_main,NULL,HH_SET_WIN_TYPE,(DWORD)&hhwin);
02776          hWndHelp=HtmlHelp(ghwnd_main,localname1,HH_DISPLAY_TOPIC,(DWORD)res_str1);
02777        }
02778 #endif
02779      }
02780 //     strcpy(lname,gszHomeDir); strcat(lname,"help\\readme.hlp");
02781 //     WinHelp(hwnd,lname,HELP_INDEX,0L);
02782      break;
02783    case IDM_HELP_HELP:
02784 //     WinHelp(hwnd,"WINHELP.HLP",HELP_INDEX,0L);
02785      break;
02786    case IDM_HELP_ABOUT:
02787        DialogBox(ghinst_main,MAKEINTRESOURCE(DLG_ABOUT),ghwnd_main,
02788           (DLGPROC)AboutDlgProc);
02789      break;
02790    case IDM_CALLBACK_RELOAD:{
02791        if(!EditUpdateInUse)break;
02792        EditUpdateInUse=FALSE;
02793        EnableToolPannels(ALL_PANNELS,TRUE);
02794        if(ObjectInModeler != NULL){
02795          ReplaceObjectFile(ObjectInModeler,
02796                            ObjectInModeler->name);
02797          ReDrawStageDisplay(TRUE);
02798        }
02799        ObjectInModeler=NULL;
02800      }
02801      break;
02802    case IDM_CALLBACK_NORELOAD:
02803      EnableToolPannels(ALL_PANNELS,TRUE);
02804      EditUpdateInUse=FALSE;
02805      ObjectInModeler=NULL;
02806      break;
02807    case IDM_EDIT_MODEL:{
02808        HWND hWndModeler;
02809        object *Op1;
02810        if(EditUpdateInUse){
02811          SendPrgmQuery(IDQ_MODELERINUSE,0);
02812          break;
02813        }
02814        if(SelectedNode != NULL){
02815          if(SelectedNode->type == NORMAL || SelectedNode->type == ROBOT){
02816            if((Op1=GetObjectAtFrame(SelectedNode,CurrentFrame)) != NULL){
02817              WritePrivateProfileString("CALLBACK","FILE",Op1->name,
02818                                        IniFilename);
02819              ObjectInModeler=Op1;
02820              ExecuteModeler();
02821              if((hWndModeler=FindWindow("OFX:ModelerClass",NULL)) != NULL){
02822                PostMessage(hWndModeler,WM_COMMAND,IDM_CALLBACK_LOAD_MODELER,0);
02823                EditUpdateInUse=TRUE;
02824                EnableToolPannels(ALL_PANNELS,FALSE);
02825              }
02826              else SendPrgmQuery(IDQ_NOLOADMODELER,0);
02827            }
02828            else{
02829              SendPrgmQuery(IDQ_OLD2,0);
02830            }
02831          }
02832          else{
02833            SendPrgmQuery(IDQ_OLD2,0);
02834          }
02835        }
02836        else{
02837          SendPrgmQuery(IDQ_OLD1,0);
02838        }
02839      }
02840      break;
02841    case IDM_GLCAMERA_PREFERENCES:
02842    case IDM_GLCAMERA_HELP:
02843      if(ghwndOpenGLview != NULL){
02844        SendMessage(ghwndOpenGLview,WM_COMMAND,item,0);
02845      }
02846      break;
02847 
02848    default: break;
02849  }
02850 }
02851 
02852 static void ExecuteKeyboardKeyCommand(int key){
02853   switch(key){
02854     case VK_ESCAPE:{
02855         HWND hWnd;
02856         SendMessage(ghwnd_main,WM_COMMAND,IDM_STOP_TOOL,0);
02857         if((hWnd=FindWindow("OFX:RenderClass",NULL)) != NULL){
02858           PostMessage(hWnd,WM_CALLBACK_ABANDON,0,0);
02859         }
02860       }
02861       break;
02862     case VK_PRIOR:
02863 //      Nudge(IDM_PAN_UP);
02864       break;
02865     case VK_NEXT:
02866 //      Nudge(IDM_PAN_DOWN);
02867       break;
02868     case VK_HOME:
02869 //      Nudge(IDM_PAN_LEFT);
02870       break;
02871     case VK_END:
02872 //      Nudge(IDM_PAN_RIGHT);
02873       break;
02874     case VK_INSERT:      /* bank */
02875 //      Nudge(IDM_ZOOM_IN);
02876       break;
02877     case VK_DELETE:      /* bank */
02878 //      Nudge(IDM_ZOOM_OUT);
02879       break;
02880     default: break;
02881   }
02882 }
02883 
02884 // code to handle the last used files commands on the file menu
02885 
02886 void InitializeLastFilesList(void){
02887  int i,id;
02888  HMENU hmenu;
02889  char iname[32],lname[256];
02890  hmenu=GetSubMenu(GetMenu(ghwnd_main),0);
02891  for(nLastFiles=0,i=0;i<NFILESLIST;i++){
02892    LastFilesList[i].present=FALSE;
02893    sprintf(iname,"STARTFILE%ld",i);
02894    GetPrivateProfileString(IniSection,iname,"$$$",
02895                             LastFilesList[i].file,256,IniFilename);
02896    if(strncmp(LastFilesList[i].file,"$$$",3) == 0)break;
02897    LastFilesList[i].present=TRUE;
02898    nLastFiles++;
02899    id=LASTFILECMD+1+i;
02900    sprintf(lname,"&%ld %s",i+1,FileInPath(LastFilesList[i].file));
02901    InsertMenu(hmenu,IDM_FILE_EXIT,MF_ENABLED | MF_STRING,id,lname);
02902  }
02903  if(nLastFiles > 0)InsertMenu(hmenu,IDM_FILE_EXIT,MF_SEPARATOR,LASTFILECMD,0);
02904 }
02905 
02906 static void UpdateLastFilesList(char *newname){
02907  int i,k,id;
02908  char iname[32],lname[256];
02909  HMENU hmenu;
02910  hmenu=GetSubMenu(GetMenu(ghwnd_main),0);
02911  if(nLastFiles > 0){
02912    for(i=0;i<nLastFiles;i++)
02913      if(strcmp(LastFilesList[i].file,newname) == 0)return;
02914    RemoveMenu(hmenu,LASTFILECMD,MF_BYCOMMAND);
02915    for(i=0;i<nLastFiles;i++)RemoveMenu(hmenu,LASTFILECMD+1+i,MF_BYCOMMAND);
02916    nLastFiles=min(nLastFiles+1,NFILESLIST);
02917    for(i=nLastFiles-1;i>0;i--){
02918      LastFilesList[i].present=LastFilesList[i-1].present;
02919      strcpy(LastFilesList[i].file,LastFilesList[i-1].file);
02920    }
02921  }
02922  else nLastFiles=1;
02923  LastFilesList[0].present=TRUE;
02924  strcpy(LastFilesList[0].file,newname);
02925  for(i=0;i<nLastFiles;i++){
02926    id=LASTFILECMD+1+i;
02927    sprintf(lname,"&%ld %s",i+1,FileInPath(LastFilesList[i].file));
02928    InsertMenu(hmenu,IDM_FILE_EXIT,MF_ENABLED | MF_STRING,id,lname);
02929 //              FileInPath(LastFilesList[i].file));
02930  }
02931  InsertMenu(hmenu,IDM_FILE_EXIT,MF_SEPARATOR,LASTFILECMD,0);
02932  for(i=0;i<nLastFiles;i++){
02933    sprintf(iname,"STARTFILE%ld",i);
02934    WritePrivateProfileString(IniSection,iname,
02935                              LastFilesList[i].file,IniFilename);
02936  }
02937  return;
02938 }
02939 

Generated on Sun Apr 27 14:20:08 2014 for OpenFX by  doxygen 1.5.6