TOOLBOX.C

Go to the documentation of this file.
00001 /* file TOOLBOX .C */
00002 
00003 #define MODULE_TOOLBOX 1
00004 
00005 #include "animate.h"
00006 
00007 typedef struct tagQUICKTIME{
00008   HWND hwnd;
00009   WNDPROC fpSclass;
00010   HBITMAP hbm;
00011   int idBitmap;
00012   int idCommand,idHelp,iTip;
00013 } QUICKTIME;
00014 
00015 typedef struct tagTOOL_STRUCT{
00016  long  Message,Help,Tip;
00017 } TOOL_STRUCT;
00018 
00019 extern HBITMAP hBmBackground;
00020 
00021 #define LARGE_TOOL_X 50
00022 #define LARGE_TOOL_Y 40
00023 #define SMALL_TOOL_X 32
00024 #define SMALL_TOOL_Y 32
00025 #define N_ICONS       9
00026 static HBITMAP hBitmapB=NULL,
00027                hBitmapH=NULL,
00028                hBitmapD=NULL,
00029                hBitmapI=NULL,
00030                hBitmapM=NULL;
00031 static BOOL    tools_enable=TRUE;
00032 static long    cxToolBtn,cyToolBtn;
00033 static char    szToolsClass[]="OFX:AnimatorToolsClass";
00034 static LRESULT CALLBACK ToolsWndProc(HWND,UINT,WPARAM,LPARAM);
00035 static TOOL_STRUCT aTools[N_ICONS]={
00036   IDM_STOP_TOOL,        IDI_TOOL1,           IDI_TIP_T_1,
00037   IDM_ACTOR_TOOL_NODE,  IDI_TOOL2,           IDI_TIP_T_2,
00038   IDM_ACTOR_TOOL_PAN,   IDI_TOOL3,           IDI_TIP_T_3,
00039   IDM_ACTOR_TOOL_ZOOMIN,IDI_TOOL4,           IDI_TIP_T_4,
00040   IDM_ACTOR_TOOL_GRAB,  IDI_TOOL5,           IDI_TIP_T_5,
00041   IDM_ACTOR_TOOL_ROTATE,IDI_TOOL6,           IDI_TIP_T_6,
00042   IDM_ACTOR_TOOL_SIZE,  IDI_TOOL7,           IDI_TIP_T_7,
00043   IDM_ACTOR_QADD,       IDI_TOOL8,           IDI_TIP_T_8,
00044   IDM_FRAME_RENDER,     IDI_COMMAND_RENDER,  IDI_TIP_A_1
00045 };
00046 
00047 static void ToolboxCreate(void);
00048 static void PannelSelectTool(HWND hwnd, int *oldtool, int newtool);
00049 static void DoAddTooltip(HWND hwndOwner, HWND tipon, int resid);
00050 static HWND DoCreateTooltip(HWND hwndOwner);
00051 
00052 #define NO_MESSAGE -1
00053 #define NO_HELP    -1
00054 
00055 static QUICKTIME QtWin[6]={
00056  NULL,NULL,NULL,0,       -1,                  NO_HELP,           IDI_TIP_Q_2,
00057  NULL,NULL,NULL,IDBM_QT1,IDM_FRAME_GO_LASTKEY,IDI_TIME_LASTKEY,  IDI_TIP_Q_1,
00058  NULL,NULL,NULL,IDBM_QT4,IDM_FRAME_GO_NEXTKEY,IDI_TIME_NEXTKEY,  IDI_TIP_Q_5,
00059  NULL,NULL,NULL,IDBM_QT2,IDM_FRAME_PLAY_QUICK,IDI_TIME_PLAYQUICK,IDI_TIP_Q_3,
00060  NULL,NULL,NULL,IDBM_QT3,IDM_FRAME_PLAY_WIRE, IDI_TIME_PLAYWIRE, IDI_TIP_Q_4,
00061 // NULL,NULL,NULL,0,       -1,                  NO_HELP,           IDI_TIP_Q_2
00062  NULL,NULL,NULL,0,       IDM_FRAME_GO_FRAME,  IDI_GOFRAME,       IDI_TIP_Q_2
00063 };
00064 
00065 void ToolboxShow(BOOL fShow){
00066  if(!ghwndQuicktime)ToolboxCreate();
00067 }
00068 
00069 void ToolboxDestroy(void){
00070  if(ghwndQuicktime)DestroyWindow(ghwndQuicktime);
00071  if(ghwndCoord1)DestroyWindow(ghwndCoord1);
00072  if(ghwndTools)DestroyWindow(ghwndTools);
00073  ghwndQuicktime=NULL;
00074  ghwndCoord1=NULL;
00075  ghwndTools=NULL;
00076 }
00077 
00078 void AugmentToolPannel(BOOL state){
00079  if(state)UNDO_TYPE=1;
00080  else     UNDO_TYPE=0;
00081 }
00082 
00083 void EnableTools(BOOL status){
00084   tools_enable=status;
00085   InvalidateRect(ghwndTools,NULL,FALSE);
00086 }
00087 
00088 void MoveToolsWindow(void){
00089  int i,x,y;
00090  RECT rc1;
00091  POINT pt;
00092  if(ghwndTools == NULL)return;
00093  if(BigCameraView)GetWindowRect(ghwnd_triview[ActiveView],&rc1);
00094  else             GetWindowRect(ghwnd_view,&rc1);
00095  if(bToolpannelLeft)x=WindowGap;
00096  else x=rc1.right+3;
00097  y=rc1.top;
00098  pt.x=x; pt.y=y;
00099  ScreenToClient(ghwnd_main,&pt);
00100  x=pt.x; y=pt.y;
00101  for(i=0;i<N_ICONS;i++){
00102    MoveWindow(GetDlgItem(ghwndTools,i),
00103               0,cyToolBtn*i,cxToolBtn,cyToolBtn,FALSE);
00104  }
00105  MoveWindow(ghwndTools,x,y,cxToolBtn,cyToolBtn*N_ICONS,TRUE);
00106 }
00107 
00108 void ChangeToolboxBitmaps(void){
00109  if(hBitmapB != NULL)DeleteObject(hBitmapB);  hBitmapB=NULL;
00110  if(hBitmapH != NULL)DeleteObject(hBitmapH);  hBitmapH=NULL;
00111  if(hBitmapD != NULL)DeleteObject(hBitmapD);  hBitmapD=NULL;
00112  if(hBitmapI != NULL)DeleteObject(hBitmapI);  hBitmapI=NULL;
00113  if(hBitmapM != NULL)DeleteObject(hBitmapM);  hBitmapM=NULL;
00114  if(bToolpannelSmall){
00115    cxToolBtn=SMALL_TOOL_X;
00116    cyToolBtn=SMALL_TOOL_Y;
00117    hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_B));
00118    hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_H));
00119    hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_D));
00120    hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_I));
00121    hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_M));
00122  }
00123  else{
00124    cxToolBtn=LARGE_TOOL_X;
00125    cyToolBtn=LARGE_TOOL_Y;
00126    hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_B));
00127    hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_H));
00128    hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_D));
00129    hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_I));
00130    hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_M));
00131  }
00132 }
00133 
00134 static long GetWhichButton(void){
00135   long  i,button_index = -1;
00136   POINT pt;
00137   RECT  rc;
00138   GetCursorPos(&pt);
00139   for(i=0;i<N_ICONS;i++){
00140     GetWindowRect(GetDlgItem(ghwndTools,i),&rc);
00141     if(PtInRect(&rc,pt))button_index=i;
00142   }
00143   return button_index;
00144 }
00145 
00146 static void ToolboxCreate(void){
00147  char title[256];
00148  int x,y;
00149  RECT rc,rc1;
00150  POINT pt;
00151 // if(Preferences.tooltips){
00152  if((ghwndTooltip=DoCreateTooltip(ghwnd_main)) == NULL)return;
00153  SetWindowPos(ghwndTooltip,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
00154  SendMessage(ghwndTooltip,TTM_ACTIVATE,(WPARAM)Preferences.tooltips,0);
00155 // }
00156  if((ghwndQuicktime = CreateWindow(szQuicktimeClass,NULL,
00157     WS_CHILD | WS_VISIBLE | !WS_BORDER,
00158     WindowViewSliderXpos,WindowViewSliderYpos,
00159     WindowViewSliderXsize,WindowViewSliderYsize,
00160     ghwnd_main,NULL,ghinst_main,NULL)) == NULL)return;
00161  GetWindowRect(ghwnd_view,&rc1);
00162  if(bToolpannelLeft)x=WindowGap;
00163  else x=rc1.right+3;
00164  y=rc1.top;
00165  pt.x=x; pt.y=y;
00166  ScreenToClient(ghwnd_main,&pt);
00167  x=pt.x; y=pt.y;
00168  if(bToolpannelSmall){
00169    cxToolBtn=SMALL_TOOL_X;
00170    cyToolBtn=SMALL_TOOL_Y;
00171  }
00172  else{
00173    cxToolBtn=LARGE_TOOL_X;
00174    cyToolBtn=LARGE_TOOL_Y;
00175  }
00176  ghwndTools=CreateWindowEx(
00177                          WS_EX_TRANSPARENT,
00178                          szToolboxClass,NULL,
00179                          WS_CHILD | !WS_BORDER | WS_VISIBLE,
00180                          x,y,
00181                          cxToolBtn,cyToolBtn*N_ICONS,
00182                          ghwnd_main,
00183                          (HMENU)101,
00184                          ghinst_main,NULL);
00185  ghwndCoord1=CreateDialog(ghinst_main,MAKEINTRESOURCE(DLG_COORDS),
00186                           ghwnd_main,(DLGPROC)CoordinatesDlgProc);
00187  return;
00188 }
00189 
00190 LRESULT CALLBACK ToolboxWndProc(HWND hwnd,UINT msg,
00191                                 WPARAM wParam,LPARAM lParam){
00192  long i;
00193  HWND hWndChild;
00194  switch (msg) {
00195    case WM_CREATE:
00196      if(bToolpannelSmall){
00197        hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_B));
00198        hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_H));
00199        hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_D));
00200        hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_I));
00201        hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_M));
00202      }
00203      else{
00204        hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_B));
00205        hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_H));
00206        hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_D));
00207        hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_I));
00208        hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_M));
00209      }
00210      for(i=0;i<N_ICONS;i++){
00211        hWndChild=CreateWindowEx(
00212                               WS_EX_TRANSPARENT,
00213                               szToolBtnClass,NULL,
00214                               WS_CHILD | WS_VISIBLE,
00215                               0,cyToolBtn*i,
00216                               cxToolBtn,cyToolBtn,
00217                               hwnd,(HMENU)i,
00218                               ghinst_main,NULL);
00219        DoAddTooltip(ghwnd_main,hWndChild,aTools[i].Tip);
00220      }
00221      break;
00222    case WM_DESTROY:
00223      if(hBitmapB != NULL)DeleteObject(hBitmapB);  hBitmapB=NULL;
00224      if(hBitmapH != NULL)DeleteObject(hBitmapH);  hBitmapH=NULL;
00225      if(hBitmapD != NULL)DeleteObject(hBitmapD);  hBitmapD=NULL;
00226      if(hBitmapI != NULL)DeleteObject(hBitmapI);  hBitmapI=NULL;
00227      if(hBitmapM != NULL)DeleteObject(hBitmapM);  hBitmapM=NULL;
00228      break;
00229    default:
00230      return DefWindowProc(hwnd, msg, wParam, lParam);
00231  }
00232  return 0;
00233 }
00234 
00235 LRESULT CALLBACK ToolBtnWndProc(HWND hwnd,UINT msg,
00236                                 WPARAM wParam,LPARAM lParam){
00237  static int  toolTimer = -1, down_tool;
00238  static BOOL bCaptured=FALSE,bCancel=FALSE,bLastCancel=FALSE,bBusy=FALSE;
00239  long w,wold,hid;
00240  MSG mmsg;
00241  mmsg.hwnd=hwnd;
00242  mmsg.message=msg;
00243  mmsg.wParam=wParam;
00244  mmsg.lParam=lParam;
00245  hid=(int)GetWindowLong(hwnd,GWL_ID);
00246  switch (msg) {
00247    case WM_TIMER:
00248      if(bBusy || toolTimer < 0)break;
00249      bBusy=TRUE;
00250      w=GetWhichButton();
00251      if(w < 0 && toolTimer >= 0){
00252        KillTimer(hwnd,toolTimer);
00253        toolTimer = -1;
00254      }
00255      if( w < 0 && gCurTool >= 0){
00256        wold=gCurTool;
00257        gCurTool= -1;
00258        InvalidateRect(GetDlgItem(ghwndTools,wold),NULL,FALSE);
00259      }
00260      bBusy=FALSE;
00261      break;
00262    case WM_SETCURSOR:{
00263        hid=aTools[hid].Help;
00264        if(current_message != hid){
00265          if(hid == NO_HELP)SendPrgmMessage(IDS_ZERO,1);
00266          else SendIconHelpMessage(hid);
00267        }
00268        current_message=hid;
00269      }
00270      return DefWindowProc(hwnd,msg,wParam,lParam);
00271    case WM_MOUSEMOVE:
00272      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00273      w=GetWhichButton();
00274      if(bCaptured){
00275        if(w == hid)bCancel=FALSE;
00276        else        bCancel=TRUE;
00277        if(bCancel != bLastCancel)InvalidateRect(hwnd,NULL,FALSE);
00278        bLastCancel=bCancel;
00279      }
00280      else{
00281        wold=gCurTool;
00282        gCurTool=w;
00283        if(wold != w){
00284          if(wold >= 0 && wold  < N_ICONS)
00285            InvalidateRect(GetDlgItem(ghwndTools,wold),NULL,FALSE);
00286          if(gCurTool >= 0 && gCurTool < N_ICONS)
00287            InvalidateRect(GetDlgItem(ghwndTools,gCurTool),NULL,FALSE);
00288        }
00289        if(toolTimer < 0)toolTimer=SetTimer(hwnd,100,500,NULL);
00290      }
00291      break;
00292    case WM_LBUTTONDBLCLK:
00293      w=GetWhichButton();
00294      if(w == 2)PostMessage(ghwnd_main,WM_COMMAND,IDM_ZOOM_CENTRE,0);
00295      if(w == 3)PostMessage(ghwnd_main,WM_COMMAND,IDM_VIEW_FULL,0);
00296      if(w == 4)PostMessage(ghwnd_main,WM_COMMAND,IDM_ACTOR_TOOL_GRABABS,0);
00297      if(w == 5)PostMessage(ghwnd_main,WM_COMMAND,IDM_ACTOR_TOOL_ROTATEABS,0);
00298      if(w == 6)PostMessage(ghwnd_main,WM_COMMAND,IDM_ACTOR_TOOL_SIZEABS,0);
00299      break;
00300    case WM_LBUTTONDOWN:
00301      if(toolTimer >= 0)KillTimer(hwnd,toolTimer); toolTimer = -1;
00302      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00303      bCaptured=TRUE;
00304      bCancel=bLastCancel=FALSE;
00305      down_tool=hid;
00306      SetCapture(hwnd);
00307      InvalidateRect(hwnd,NULL,FALSE);
00308      break;
00309    case WM_LBUTTONUP:
00310      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00311      ReleaseCapture();
00312      w=GetWhichButton();
00313      bCaptured=FALSE;
00314      if(w < 0 && gCurTool >= 0){
00315        wold=gCurTool;
00316        gCurTool = -1;
00317        InvalidateRect(GetDlgItem(ghwndTools,wold),NULL,FALSE);
00318      }
00319      InvalidateRect(hwnd,NULL,FALSE);
00320      if(down_tool == w && aTools[down_tool].Message != NO_MESSAGE)
00321        PostMessage(ghwnd_main,WM_COMMAND,aTools[w].Message,0);
00322      gCurTool= -1;
00323      break;
00324    case WM_RBUTTONDOWN:{
00325        POINT pt;
00326        HMENU hMenu=LoadMenu(ghinst_main,"ToolbarPopupMenu");
00327        if(hMenu == NULL)break;
00328        pt.x=LOWORD(lParam);
00329        pt.y=HIWORD(lParam);
00330        ClientToScreen(hwnd,&pt);
00331        if(bToolpannelLeft)
00332          CheckMenuItem(hMenu,IDM_CONTEXT_TOOLSLEFT,MF_CHECKED);
00333        if(bToolpannelSmall)
00334          CheckMenuItem(hMenu,IDM_CONTEXT_TOOLSSMALL,MF_CHECKED);
00335        TrackPopupMenu(GetSubMenu(hMenu,0),TPM_LEFTALIGN | TPM_LEFTBUTTON,
00336                       pt.x,pt.y,0,ghwnd_main,NULL);
00337        DestroyMenu(hMenu);
00338      }
00339      break;
00340    case WM_PAINT:{
00341        HDC hDC;
00342        PAINTSTRUCT ps;
00343        hDC=BeginPaint(hwnd,&ps);
00344        if(hBitmapB != NULL && hBitmapD != NULL  && hBitmapH != NULL){
00345          HDC hMemDC;
00346          HBITMAP hbmOld;
00347          BOOL blit=FALSE;
00348          hMemDC = CreateCompatibleDC(hDC);
00349          if(!tools_enable){
00350            hbmOld = SelectObject(hMemDC,hBitmapI);
00351            blit=TRUE;
00352          }
00353          else if( (tool == NOTOOL     && hid == 0)      ||
00354                   (tool == NODETOOL   && hid == 1)      ||
00355                   (tool == TRACKER    && hid == 1)      ||
00356                   (tool == SKELETOR   && hid == 1)      ||
00357                   (tool == PATHEDITOR && hid == 1)      ||
00358                   (tool == PAN        && hid == 2)      ||
00359                   (tool == INZOOM     && hid == 3)      ||
00360                   (tool == GRABBER    && hid == 4)      ||
00361                   (tool == ROTATOR    && hid == 5)      ||
00362                   (tool == SIZER      && hid == 6)      ||
00363                   (hwnd == GetCapture() && !bCancel)  ||
00364                   FALSE)
00365            hbmOld = SelectObject(hMemDC,hBitmapD);
00366          else if(hid == gCurTool)
00367            hbmOld = SelectObject(hMemDC,hBitmapH);
00368          else{
00369            hbmOld = SelectObject(hMemDC,hBitmapB);
00370            blit=TRUE;
00371          }
00372          if(hBmBackground == NULL)blit=FALSE;
00373          if(blit){
00374            HDC hdc_view;
00375            RECT rc;
00376            POINT pp;
00377            BITMAP bm;
00378            HBITMAP hbm_view,hbmoldv;
00379            hbm_view=CreateCompatibleBitmap(hMemDC,cxToolBtn,cyToolBtn);
00380            hdc_view=CreateCompatibleDC(hMemDC);
00381            hbmoldv=SelectObject(hdc_view,hbm_view);
00382            GetWindowRect(hwnd,&rc);
00383            pp.x=rc.left; pp.y=rc.top;
00384            ScreenToClient(ghwnd_main,&pp);
00385            GetObject(hBmBackground,sizeof(BITMAP),&bm);
00386            pp.x = pp.x % bm.bmWidth;
00387            pp.y = pp.y % bm.bmHeight;
00388            SelectObject(hMemDC,hBmBackground);
00389            if(pp.y + cyToolBtn > bm.bmHeight){
00390              if(pp.x + cxToolBtn > bm.bmWidth){
00391                BitBlt(hDC,
00392                   0,0,
00393                   bm.bmWidth -pp.x,
00394                   bm.bmHeight-pp.y,
00395                   hMemDC,
00396                   pp.x,pp.y,
00397                   SRCCOPY);
00398                BitBlt(hDC,
00399                   bm.bmWidth-pp.x,bm.bmHeight-pp.y,
00400                   cxToolBtn - (bm.bmWidth -pp.x),
00401                   cyToolBtn - (bm.bmHeight-pp.y),
00402                   hMemDC,
00403                   (pp.x + (bm.bmWidth -pp.x)) % bm.bmWidth,
00404                   (pp.y + (bm.bmHeight-pp.y)) % bm.bmHeight,
00405                   SRCCOPY);
00406              }
00407              else{
00408                BitBlt(hDC,
00409                   0,0,
00410                   cxToolBtn,
00411                   bm.bmHeight-pp.y,
00412                   hMemDC,
00413                   pp.x,pp.y,
00414                   SRCCOPY);
00415                BitBlt(hDC,
00416                   0,bm.bmHeight-pp.y,
00417                   cxToolBtn,
00418                   cyToolBtn - (bm.bmHeight-pp.y),
00419                   hMemDC,
00420                   pp.x,(pp.y + (bm.bmHeight-pp.y)) % bm.bmHeight,
00421                   SRCCOPY);
00422              }
00423            }
00424            else if(pp.x + cxToolBtn > bm.bmWidth){
00425              BitBlt(hDC,
00426                   0,0,
00427                   bm.bmWidth -pp.x,
00428                   cyToolBtn,
00429                   hMemDC,
00430                   pp.x,pp.y,
00431                   SRCCOPY);
00432              BitBlt(hDC,
00433                   bm.bmWidth-pp.x,0,
00434                   cxToolBtn - (bm.bmWidth -pp.x),
00435                   cyToolBtn,
00436                   hMemDC,
00437                   (pp.x + (bm.bmWidth -pp.x)) % bm.bmWidth,pp.y,
00438                   SRCCOPY);
00439            }
00440            else BitBlt(hDC,
00441                   0,0,
00442                   cxToolBtn,
00443                   cyToolBtn,
00444                   hMemDC,
00445                   pp.x,pp.y,
00446                   SRCCOPY);
00447            SelectObject(hMemDC,hBitmapM);
00448            BitBlt(hDC,
00449                   0,0,
00450                   cxToolBtn,
00451                   cyToolBtn,
00452                   hMemDC,
00453                   0,hid*cyToolBtn,
00454                   0x00220326); // DSna
00455            if(tools_enable)SelectObject(hMemDC,hBitmapB);
00456            else            SelectObject(hMemDC,hBitmapI);
00457            BitBlt(hdc_view,
00458                   0,0,
00459                   cxToolBtn,
00460                   cyToolBtn,
00461                   hMemDC,
00462                   0,hid*cyToolBtn,
00463                   SRCCOPY);
00464            SelectObject(hMemDC,hBitmapM);
00465            BitBlt(hdc_view,
00466                   0,0,
00467                   cxToolBtn,
00468                   cyToolBtn,
00469                   hMemDC,
00470                   0,hid*cyToolBtn,
00471                   SRCAND);
00472            BitBlt(hDC,
00473                   0,0,
00474                   cxToolBtn,
00475                   cyToolBtn,
00476                   hdc_view,
00477                   0,0,
00478                   SRCPAINT);
00479            SelectObject(hdc_view,hbmoldv);
00480            DeleteObject(hbm_view);
00481            DeleteDC(hdc_view);
00482          }
00483          else BitBlt(hDC,
00484                   0,0,
00485                   cxToolBtn,
00486                   cyToolBtn,
00487                   hMemDC,
00488                   0,hid*cyToolBtn,
00489                   SRCCOPY);
00490          SelectObject(hMemDC,hbmOld);
00491          DeleteDC(hMemDC);
00492        }
00493        EndPaint(hwnd,&ps);
00494      }
00495      break;
00496    default:
00497      return DefWindowProc(hwnd,msg,wParam,lParam);
00498  }
00499  return 0;
00500 }
00501 
00502 void ToolboxSetPosition(int w){
00503 }
00504 
00505 static void DrawQtBtn(BOOL selected,HDC hDC, LPRECT lprc, HBITMAP hbm){
00506  HDC hMemDC;
00507  BITMAP  bmp;
00508  HBITMAP hbmOld;
00509  HBRUSH holdbrush,hbrushFace;
00510  HPEN   holdpen,hpenShadow,hpenHighlight;
00511  int x,y,cx,cy;
00512  hbrushFace=CreateSolidBrush(RGB(192,192,192));
00513  holdbrush=SelectObject(hDC,hbrushFace);
00514  hpenShadow=CreatePen(PS_SOLID,0,RGB(128,128,128));
00515  hpenHighlight=CreatePen(PS_SOLID,0,RGB(255,255,255));
00516  holdpen=SelectObject(hDC,GetStockObject(BLACK_PEN));
00517  Rectangle(hDC,0,0,lprc->right+1,lprc->bottom);
00518  SelectObject(hDC,hpenShadow);
00519  if(selected){
00520    MoveToEx(hDC,1,lprc->bottom-2,NULL);
00521    LineTo(hDC,1,1);
00522    LineTo(hDC,lprc->right-1,1);
00523  }
00524  else{
00525    MoveToEx(hDC,1,lprc->bottom-2,NULL);
00526    LineTo(hDC,lprc->right-1,lprc->bottom-2);
00527    LineTo(hDC,lprc->right-1,1);
00528    MoveToEx(hDC,2,lprc->bottom-3,NULL);
00529    LineTo(hDC,lprc->right-2,lprc->bottom-3);
00530    LineTo(hDC,lprc->right-2,3);
00531    SelectObject(hDC,hpenHighlight);
00532    MoveToEx(hDC,1,lprc->bottom-3,NULL);
00533    LineTo(hDC,1,1);
00534    LineTo(hDC,lprc->right-1,1);
00535    MoveToEx(hDC,2,lprc->bottom-4,NULL);
00536    LineTo(hDC,2,2);
00537    LineTo(hDC,lprc->right-2,2);
00538  }
00539  SelectObject(hDC,holdpen);
00540  DeleteObject(hpenShadow);
00541  DeleteObject(hpenHighlight);
00542  SelectObject(hDC,holdbrush);
00543  DeleteObject(hbrushFace);
00544  if(hbm == NULL)return;
00545  GetObject(hbm,sizeof(BITMAP),&bmp);
00546  cx = bmp.bmWidth;
00547  cy = bmp.bmHeight;
00548  x=max(0,(lprc->right-cx)/2); y=max(0,(lprc->bottom-cy)/2)+1;
00549  if(selected){x++; y++;}
00550  hMemDC = CreateCompatibleDC(hDC);
00551  hbmOld = SelectObject(hMemDC, hbm);
00552  BitBlt(hDC,x,y,cx,cy,hMemDC,0,0,SRCAND);
00553  SelectObject(hMemDC, hbmOld);
00554  DeleteDC(hMemDC);
00555 }
00556 
00557 static LRESULT CALLBACK QuicktimeSubclassProc(HWND hwnd,UINT msg,
00558                                        WPARAM wParam,LPARAM lParam){
00559  int hid;
00560  MSG mmsg;
00561  LRESULT lRet;
00562  mmsg.hwnd=hwnd;
00563  mmsg.message=msg;
00564  mmsg.wParam=wParam;
00565  mmsg.lParam=lParam;
00566  switch (msg) {
00567    case WM_KEYDOWN:
00568     SetFocus(ghwnd_main);
00569     return 0;
00570    case WM_LBUTTONDOWN:
00571    case WM_LBUTTONUP:
00572      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00573      break;
00574    case WM_MOUSEMOVE:
00575      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00576      hid=QtWin[GetWindowLong(hwnd,GWL_ID)].idHelp;
00577      if(hid == NO_HELP)SendPrgmMessage(IDS_ZERO,1);
00578          else {
00579            if(current_message != hid){
00580               SendIconHelpMessage(hid);
00581               current_message=hid;
00582            }
00583          }
00584      break;
00585    default: break;
00586  }
00587  lRet=CallWindowProc(QtWin[GetWindowLong(hwnd,GWL_ID)].fpSclass,
00588                      hwnd,msg,wParam,lParam);
00589  switch (msg) {
00590    case WM_LBUTTONUP:
00591      SetFocus(ghwnd_main);
00592      break;
00593    default: break;
00594  }
00595  return lRet;
00596 }
00597 
00598 #define STATICSIZE 40
00599 
00600 LRESULT CALLBACK QuicktimeWndProc(HWND hwnd,UINT msg,WPARAM wParam,
00601                                   LPARAM lParam){
00602  static BOOL bCaptured=FALSE;
00603  static RECT wrc;
00604  HDC  hDC;
00605  HWND hdesk;
00606  BITMAP bmp;
00607  static int  xc,yc;
00608  int i,xp,sxsize,scsize,btnsize,btnxsize;
00609  switch (msg) {
00610    case WM_CREATE:
00611      for(i=0;i<6;i++){
00612        if(i == 0){
00613 //
00614 //         QtWin[i].hwnd=CreateWindow("SCROLLBAR",NULL,
00615 //           WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_TOPALIGN,
00616 //           0,0,0,0,hwnd,(HMENU)i,ghinst_main,NULL);
00617 // for reference
00618          QtWin[i].hwnd=CreateWindowEx(0,TRACKBAR_CLASS,"",
00619            WS_CHILD | WS_BORDER | WS_VISIBLE | TBS_BOTTOM,// | TBS_AUTOTICKS,
00620            0,0,0,0,
00621            hwnd,(HMENU)i,ghinst_main,NULL);
00622 //         DoAddTooltip(ghwnd_main,QtWin[i].hwnd,QtWin[i].iTip);
00623 //
00624          QtWin[i].fpSclass=NULL;
00625          ghwnd_xscl=QtWin[i].hwnd;
00626        }
00627        else if(i == 5){ /* static text */
00628          QtWin[i].hwnd=CreateWindow("button",NULL,
00629            WS_CHILD | WS_VISIBLE | !WS_BORDER | BS_PUSHBUTTON,
00630            0,0,0,0,hwnd,(HMENU)i,ghinst_main,NULL);
00631          QtWin[i].fpSclass=(WNDPROC)SetWindowLong(QtWin[i].hwnd,GWL_WNDPROC,
00632            (LONG)QuicktimeSubclassProc);
00633          DoAddTooltip(ghwnd_main,QtWin[i].hwnd,QtWin[i].iTip);
00634 //         QtWin[i].hwnd=CreateWindow("static",NULL,
00635 //           WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER,
00636 //           0,0,0,0,hwnd,(HMENU)i,ghinst_main,NULL);
00637          SendMessage(QtWin[i].hwnd,WM_SETFONT,
00638                     (WPARAM)GetStockObject(ANSI_VAR_FONT),0);
00639          SendMessage(QtWin[i].hwnd,WM_SETTEXT,0,(LPARAM)"0001");
00640        }
00641        else{
00642          QtWin[i].hwnd=CreateWindow("button",NULL,
00643            WS_CHILD | WS_VISIBLE | !WS_BORDER | BS_OWNERDRAW | BS_PUSHBUTTON,
00644            0,0,0,0,hwnd,(HMENU)i,ghinst_main,NULL);
00645          QtWin[i].fpSclass=(WNDPROC)SetWindowLong(QtWin[i].hwnd,GWL_WNDPROC,
00646            (LONG)QuicktimeSubclassProc);
00647          QtWin[i].hbm=LoadBitmap(ghinst_main,
00648            MAKEINTRESOURCE(QtWin[i].idBitmap));
00649          DoAddTooltip(ghwnd_main,QtWin[i].hwnd,QtWin[i].iTip);
00650        }
00651      }
00652      return 0;
00653    case WM_SIZE:
00654      xp=0;btnsize=HIWORD(lParam); sxsize=LOWORD(lParam);
00655 //     if(Xres > 800)btnxsize=2*btnsize;
00656 //     else          btnxsize=(3*btnsize/2);
00657      if(Xres <= 800)btnxsize=(2*btnsize/3); // New resolution for bigger buttons
00658      else           btnxsize=btnsize;       // RSF
00659      for(i=0;i<6;i++){
00660        if(i == 0)scsize=sxsize-4*btnxsize-STATICSIZE;
00661        else scsize=btnxsize;
00662        if(i == 0){ /* for Windows95 */
00663          BOOL v4;
00664          DWORD version;
00665          version=GetVersion();
00666          if((version & 0x80000000) == 0x80000000){
00667           if(LOBYTE(LOWORD(version)) < 4)v4=FALSE;
00668            else                           v4=TRUE;
00669          }
00670          else{
00671           if(LOBYTE(LOWORD(version)) < 4)v4=FALSE;
00672            else                           v4=TRUE;
00673          }
00674          if(v4)MoveWindow(QtWin[i].hwnd,xp,0,scsize+1,btnsize,TRUE);
00675          else  MoveWindow(QtWin[i].hwnd,xp,0,scsize+1,btnsize,TRUE);
00676        }
00677        else if(i == 5){
00678 //         MoveWindow(QtWin[i].hwnd,xp,0,STATICSIZE,btnsize,TRUE);   // text
00679          MoveWindow(QtWin[i].hwnd,xp,1,STATICSIZE,btnsize-1,TRUE); // Button
00680        }
00681        else MoveWindow(QtWin[i].hwnd,xp,0,scsize,btnsize,TRUE);
00682        xp += scsize;
00683      }
00684      break;
00685    case WM_SETCURSOR:
00686      if(current_message >= 0){
00687        current_message = -1;
00688        SendPrgmMessage(IDS_ZERO,1);
00689      }
00690      return( DefWindowProc(hwnd,msg,wParam,lParam));
00691    case WM_DRAWITEM:{
00692        UINT idCtl;
00693        LPDRAWITEMSTRUCT lpdis;
00694        idCtl=(UINT)wParam;
00695        lpdis=(LPDRAWITEMSTRUCT)lParam;
00696        if(idCtl < 5){
00697          if(lpdis->itemState & ODS_SELECTED){
00698            DrawQtBtn(TRUE,lpdis->hDC,&(lpdis->rcItem),QtWin[idCtl].hbm);
00699          }
00700          else{
00701            DrawQtBtn(FALSE,lpdis->hDC,&(lpdis->rcItem),QtWin[idCtl].hbm);
00702          }
00703        }
00704      }
00705      return TRUE;
00706    case WM_LBUTTONDOWN:
00707      if(0){ /* comment out drag facility */
00708        bCaptured=TRUE;
00709        SetCapture(hwnd);
00710        hdesk=GetDesktopWindow();
00711        hDC=GetWindowDC(hdesk);
00712        GetWindowRect(hwnd,&wrc);
00713        DrawFocusRect(hDC,&wrc);
00714        ReleaseDC(hdesk,hDC);
00715        xc=(int)((short)LOWORD(lParam)); yc=(int)((short)HIWORD(lParam));
00716      }
00717      break;
00718    case WM_MOUSEMOVE:
00719      if(bCaptured){
00720        hdesk=GetDesktopWindow();
00721        hDC=GetWindowDC(hdesk);
00722        DrawFocusRect(hDC,&wrc);
00723        OffsetRect(&wrc,(int)((short)LOWORD(lParam)-(short)xc),
00724                        (int)((short)HIWORD(lParam)-(short)yc));
00725        DrawFocusRect(hDC,&wrc);
00726        ReleaseDC(hdesk,hDC);
00727        xc=LOWORD(lParam); yc=HIWORD(lParam);
00728      }
00729      break;
00730    case WM_LBUTTONUP:
00731      if(bCaptured){
00732        POINT pt;
00733        ReleaseCapture();
00734        hdesk=GetDesktopWindow();
00735        hDC=GetWindowDC(hdesk);
00736        DrawFocusRect(hDC,&wrc);
00737        ReleaseDC(hdesk,hDC);
00738        bCaptured=FALSE;
00739        pt.x=wrc.left; pt.y=wrc.top;
00740        ScreenToClient(ghwnd_main,&pt); /* for Child Window */
00741        SetWindowPos(hwnd,NULL,pt.x,pt.y,0,0,SWP_NOSIZE);
00742        InvalidateRect(hwnd,NULL,TRUE); /* for Child Window */
00743      }
00744      break;
00745    case WM_COMMAND:
00746      if(HIWORD(wParam) == BN_CLICKED){
00747        i = -1;
00748        if((HWND)lParam == QtWin[1].hwnd)i=1;
00749        if((HWND)lParam == QtWin[2].hwnd)i=2;
00750        if((HWND)lParam == QtWin[3].hwnd)i=3;
00751        if((HWND)lParam == QtWin[4].hwnd)i=4;
00752        if((HWND)lParam == QtWin[5].hwnd)i=5;
00753        if(i >= 0)SendMessage(ghwnd_main,WM_COMMAND,QtWin[i].idCommand,0);
00754      }
00755      SetFocus(ghwnd_main);
00756      break;
00757    case WM_HSCROLL:
00758      PostMessage(ghwnd_main,WM_HSCROLL,wParam,lParam);
00759      break;
00760    case WM_DESTROY:
00761      for(i=0;i<6;i++){
00762        if(QtWin[i].fpSclass != NULL)SetWindowLong(QtWin[i].hwnd,GWL_WNDPROC,
00763             (LONG)QtWin[i].fpSclass);
00764        if(QtWin[i].hbm != NULL)DeleteObject(QtWin[i].hbm);
00765        QtWin[i].hbm = NULL;
00766      }
00767      break;
00768    default:
00769      return DefWindowProc(hwnd, msg, wParam, lParam);
00770  }
00771  return 0;
00772 }
00773 
00774 void UpdateFrameBox(void){
00775  char str[32];
00776  sprintf(str,"%4.4ld",CurrentFrame);
00777  SendMessage(QtWin[5].hwnd,WM_SETTEXT,0,(LPARAM)str);
00778  return;
00779 }
00780 
00781 static void GetFormatString(char *format, double x, double y, double z,
00782  double dx, double dy, double dz){
00783  if(fabs(x)  > 9999999.0 || fabs(y)  > 9999999.0 ||
00784     fabs(z)  > 9999999.0 || fabs(dx) > 9999999.0 ||
00785     fabs(dy) > 9999999.0 || fabs(dz) > 9999999.0)
00786    sprintf(format,"%s","%9.1le");
00787  else if(fabs(x)  > 99999.0 || fabs(y)  > 99999.0 ||
00788          fabs(z)  > 99999.0 || fabs(dx) > 99999.0 ||
00789          fabs(dy) > 99999.0 || fabs(dz) > 99999.0)
00790    sprintf(format,"%s","%9.0lf");
00791  else  sprintf(format,"%s","%9.2lf");
00792 }
00793 
00794 static void GetDoubleCoordinates(int ix, int iy, int iz,
00795                      double *x,  double *y,  double *z,
00796                      double *dx, double *dy, double *dz){
00797  *x = (double)(ix-lrulerx);
00798  *y = (double)(iy-lrulery);
00799  *z = (double)(iz-lrulerz);
00800  *dx = (double)(ix-rulerx);
00801  *dy = (double)(iy-rulery);
00802  *dz = (double)(iz-rulerz);
00803  *x  /= ruler; *y   /=ruler; *z   /=ruler;
00804  *dx /= ruler; *dy /= ruler; *dz /= ruler;
00805 }
00806 
00807 #define NC_BUTTONS 5
00808 
00809 static struct QC {int idBitmap; int dlgID; int idHelp; int iTip;
00810        HWND hwnd;WNDPROC fpSclass; HBITMAP hbm;} QtCoord[NC_BUTTONS]={
00811   IDBM_CO1,DLG_COORDS_GOTO,     IDI_COORD_MEASURE, IDI_TIP_C_1,NULL,NULL,NULL,
00812   IDBM_CO2,DLG_COORDS_CANCEL,   IDI_COORD_RELATIVE,IDI_TIP_C_2,NULL,NULL,NULL,
00813   IDBM_CO3,DLG_COORDS_SETCENTRE,IDI_COORD_ORIGIN,  IDI_TIP_C_3,NULL,NULL,NULL,
00814   IDBM_CO4,DLG_COORDS_DEFINE,   IDI_COORD_DEFINE,  IDI_TIP_C_4,NULL,NULL,NULL,
00815   IDBM_CO5,DLG_COORDS_MEASURE,  IDI_COORD_NEAREST, IDI_TIP_C_5,NULL,NULL,NULL
00816 };
00817 
00818 static LRESULT CALLBACK CoordinatesSubclassProc(HWND hwnd,UINT msg,
00819                                        WPARAM wParam,LPARAM lParam){
00820  MSG mmsg;
00821  int i,hid;
00822  for(i=0;i<NC_BUTTONS;i++){
00823    if(QtCoord[i].hwnd == hwnd)goto XXIT;
00824  }
00825  MessageBeep(MB_OK);
00826  XXIT:
00827  mmsg.hwnd=hwnd;
00828  mmsg.message=msg;
00829  mmsg.wParam=wParam;
00830  mmsg.lParam=lParam;
00831  switch (msg) {
00832    case WM_LBUTTONDOWN:
00833    case WM_LBUTTONUP:
00834      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,
00835                                          0,(LPARAM)(LPMSG)&mmsg);
00836      break;
00837    case WM_MOUSEMOVE:
00838      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,
00839                                          0,(LPARAM)(LPMSG)&mmsg);
00840      hid=QtCoord[i].idHelp;
00841      if(hid == NO_HELP)SendPrgmMessage(IDS_ZERO,1);
00842          else SendIconHelpMessage(hid);
00843      break;
00844    default: break;
00845  }
00846  return CallWindowProc(QtCoord[i].fpSclass,hwnd,msg,wParam,lParam);
00847 }
00848 
00849 LRESULT CALLBACK CoordinatesDlgProc(HWND hdlg,UINT msg,
00850                             WPARAM wparam,LPARAM lparam){
00851  BOOL err;
00852  RECT rc;
00853  int i,ix,iy,iz;
00854  double x,y,z,dx,dy,dz;
00855  char string[32],format[10];
00856  static int xpos=-1,ypos=-1,infocus=0,lastid=-1,udflag=1;
00857  switch( msg ) {
00858    case WM_PAINT:
00859      PaintDialogBackground(hdlg,ghinst_main);
00860      break;
00861    case WM_INITDIALOG:
00862      for(i=0;i<NC_BUTTONS;i++){
00863        QtCoord[i].hbm=LoadBitmap(ghinst_main,
00864                                  MAKEINTRESOURCE(QtCoord[i].idBitmap));
00865        QtCoord[i].hwnd=GetDlgItem(hdlg,QtCoord[i].dlgID);
00866        if(QtCoord[i].hwnd != NULL){
00867          QtCoord[i].fpSclass=(WNDPROC)SetWindowLong(QtCoord[i].hwnd,
00868                               GWL_WNDPROC,(LONG)CoordinatesSubclassProc);
00869          DoAddTooltip(ghwnd_main,QtCoord[i].hwnd,QtCoord[i].iTip);
00870        }
00871      }
00872      if(xpos == -1 && ypos == -1){
00873        xpos=GetPrivateProfileInt(IniSection,"XCOORDPOS",-1,
00874                                  IniFilename);
00875        if(xpos < 0)xpos=52;
00876        ypos=GetPrivateProfileInt(IniSection,"YCOORDPOS",-1,
00877                                  IniFilename);
00878        if(ypos < 0)ypos=50;
00879      }
00880      SetWindowPos(hdlg,HWND_TOP,xpos,ypos,0,0,SWP_NOSIZE);
00881      udflag=1;
00882      PostMessage(hdlg,WM_COMMAND,IDC_COORD_UPDATE,0);
00883      return (TRUE);
00884    case WM_CTLCOLORSTATIC:
00885    case WM_CTLCOLORDLG:
00886      SetBkColor((HDC)wparam,RGB(192,192,192));
00887      return (LRESULT)GetStockObject(LTGRAY_BRUSH);
00888    case WM_DRAWITEM:{
00889        BOOL status;
00890        HBITMAP hbm;
00891        LPDRAWITEMSTRUCT lpdis;
00892        lpdis=(LPDRAWITEMSTRUCT)lparam;
00893        if(lpdis->itemState & ODS_SELECTED)status=TRUE; else status=FALSE;
00894        if     (lpdis->CtlID == DLG_COORDS_GOTO)hbm=QtCoord[0].hbm;
00895        else if(lpdis->CtlID == DLG_COORDS_CANCEL)hbm=QtCoord[1].hbm;
00896        else if(lpdis->CtlID == DLG_COORDS_SETCENTRE)hbm=QtCoord[2].hbm;
00897        else if(lpdis->CtlID == DLG_COORDS_DEFINE)hbm=QtCoord[3].hbm;
00898        else if(lpdis->CtlID == DLG_COORDS_MEASURE)hbm=QtCoord[4].hbm;
00899        DrawQtBtn(status,lpdis->hDC,&(lpdis->rcItem),hbm);
00900      }
00901      return TRUE;
00902    case WM_DESTROY:
00903      for(i=0;i<NC_BUTTONS;i++){
00904        if(QtCoord[i].hbm != NULL)DeleteObject(QtCoord[i].hbm);
00905        if(QtCoord[i].fpSclass != NULL)SetWindowLong(QtCoord[i].hwnd,
00906          GWL_WNDPROC,(LONG)QtCoord[i].fpSclass);
00907      }
00908      GetWindowRect(hdlg,&rc);
00909      xpos=rc.left; ypos=rc.top;
00910      sprintf(string,"%ld",xpos);
00911      WritePrivateProfileString(IniSection,"XCOORDPOS",string,IniFilename);
00912      sprintf(string,"%ld",ypos);
00913      WritePrivateProfileString(IniSection,"YCOORDPOS",string,IniFilename);
00914      break;
00915    case WM_NCHITTEST:
00916      if(current_message >= 0){
00917        current_message = -1;
00918        SendPrgmMessage(IDS_ZERO,1);
00919      }
00920      break;
00921    case WM_COMMAND:
00922      switch(HIWORD(wparam)){
00923        case EN_SETFOCUS:
00924          infocus=1;
00925          break;
00926        case EN_KILLFOCUS:
00927          infocus=0;
00928          break;
00929        case EN_CHANGE:
00930          if(!infocus)break;
00931          udflag=1;
00932          i=(int)LOWORD(wparam);
00933          if(GetDlgItemText(hdlg,i,string,30) != 0){
00934            if(i == DLG_COORDS_X){
00935              if(lastid == DLG_COORDS_DX)break;
00936              ix=(int)(atof(string)*ruler)+lrulerx;
00937              GetDoubleCoordinates(ix,NpointerY,NpointerZ,
00938                               &x,&y,&z,&dx,&dy,&dz);
00939              GetFormatString(format,x,y,z,dx,dy,dz);
00940              sprintf(string,format,dx);
00941              lastid=i;
00942              SetDlgItemText(hdlg,DLG_COORDS_DX,string);
00943              lastid=-1;
00944            }
00945            else if(i == DLG_COORDS_Y){
00946              if(lastid == DLG_COORDS_DY)break;
00947              iy=(int)(atof(string)*ruler)+lrulery;
00948              GetDoubleCoordinates(NpointerX,iy,NpointerZ,
00949                               &x,&y,&z,&dx,&dy,&dz);
00950              GetFormatString(format,x,y,z,dx,dy,dz);
00951              sprintf(string,format,dy);
00952              lastid=i;
00953              SetDlgItemText(hdlg,DLG_COORDS_DY,string);
00954              lastid= -1;
00955            }
00956            else if(i == DLG_COORDS_Z){
00957              if(lastid == DLG_COORDS_DZ)break;
00958              iz=(int)(atof(string)*ruler)+lrulerz;
00959              GetDoubleCoordinates(NpointerX,NpointerY,iz,
00960                               &x,&y,&z,&dx,&dy,&dz);
00961              GetFormatString(format,x,y,z,dx,dy,dz);
00962              sprintf(string,format,dz);
00963              lastid=i;
00964              SetDlgItemText(hdlg,DLG_COORDS_DZ,string);
00965              lastid= -1;
00966            }
00967            else if(i == DLG_COORDS_DX){
00968              if(lastid == DLG_COORDS_X)break;
00969              ix=(int)(atof(string)*ruler)+rulerx;
00970              GetDoubleCoordinates(ix,NpointerY,NpointerZ,
00971                               &x,&y,&z,&dx,&dy,&dz);
00972              GetFormatString(format,x,y,z,dx,dy,dz);
00973              sprintf(string,format,x);
00974              lastid=i;
00975              SetDlgItemText(hdlg,DLG_COORDS_X,string);
00976              lastid= -1;
00977            }
00978            else if(i == DLG_COORDS_DY){
00979              if(lastid == DLG_COORDS_Y)break;
00980              iy=(int)(atof(string)*ruler)+rulery;
00981              GetDoubleCoordinates(NpointerX,iy,NpointerZ,
00982                               &x,&y,&z,&dx,&dy,&dz);
00983              GetFormatString(format,x,y,z,dx,dy,dz);
00984              sprintf(string,format,y);
00985              lastid=i;
00986              SetDlgItemText(hdlg,DLG_COORDS_Y,string);
00987              lastid= -1;
00988            }
00989            else if(i == DLG_COORDS_DZ){
00990              if(lastid == DLG_COORDS_Z)break;
00991              iz=(int)(atof(string)*ruler)+rulerz;
00992              GetDoubleCoordinates(NpointerX,NpointerY,iz,
00993                               &x,&y,&z,&dx,&dy,&dz);
00994              GetFormatString(format,x,y,z,dx,dy,dz);
00995              sprintf(string,format,z);
00996              lastid=i;
00997              SetDlgItemText(hdlg,DLG_COORDS_Z,string);
00998              lastid= -1;
00999            }
01000          }
01001          break;
01002        default:   break;
01003      }
01004      switch(LOWORD(wparam)){
01005        case IDCANCEL:
01006          PostMessage(ghwnd_main,WM_COMMAND,IDM_WINDOW_COORDS,0);
01007          break;
01008        case IDOK:
01009        case DLG_COORDS_GOTO:{
01010            point TVC;
01011            if(GetDlgItemText(hdlg,DLG_COORDS_X,string,30) == 0)break;
01012            TVC[0]=(long)(atof(string)*ruler)+lrulerx;
01013            if(GetDlgItemText(hdlg,DLG_COORDS_Y,string,30) == 0)break;
01014            TVC[1]=(long)(atof(string)*ruler)+lrulery;
01015            if(GetDlgItemText(hdlg,DLG_COORDS_Z,string,30) == 0)break;
01016            TVC[2]=(long)(atof(string)*ruler)+lrulerz;
01017            if(in_stage_triview(TVC)){
01018              Draw3dCursor();
01019              NpointerX=TVC[0]; NpointerY=TVC[1]; NpointerZ=TVC[2];
01020              Draw3dCursor();
01021            }
01022            else{
01023              NpointerX=TVC[0]; NpointerY=TVC[1]; NpointerZ=TVC[2];
01024              TVpointX=NpointerX - TVsizeX/2;
01025              TVpointY=NpointerY - TVsizeY/2;
01026              TVpointZ=NpointerZ - TVsizeZ/2;
01027              ReDrawStageDisplay(TRUE);
01028              PerspectiveView(0,0);
01029            }
01030            PostMessage(hdlg,WM_COMMAND,IDC_COORD_UPDATE,0);
01031          }
01032          break;
01033        case DLG_COORDS_CANCEL:
01034          if(HIWORD(wparam) != BN_CLICKED)break;
01035          udflag=1;
01036          PostMessage(hdlg,WM_COMMAND,IDC_COORD_UPDATE,0);
01037          break;
01038        case DLG_COORDS_SETCENTRE:
01039          if(HIWORD(wparam) != BN_CLICKED)break;
01040          SendMessage(ghwnd_main,WM_COMMAND,IDM_COORDS_ORIGIN,0);
01041          break;
01042        case DLG_COORDS_MEASURE:
01043          if(HIWORD(wparam) != BN_CLICKED)break;
01044          if(SelectedNode != NULL){
01045            point p,tp;
01046            short im;
01047            double phi,theta,alpha,mratio,sx,sy,sz,ima;
01048            GetTransform(0,CurrentFrame,1.0,
01049                         SelectedNode,SelectedNode->fobj,p,tp,
01050                         &phi,&theta,&alpha,&sx,&sy,&sz,&im,&ima);
01051            dx=(double)(p[0]-NpointerX)/ruler;
01052            dy=(double)(p[1]-NpointerY)/ruler;
01053            dz=(double)(p[2]-NpointerZ)/ruler;
01054            ima=sqrt(dx*dx+dy*dy+dz*dz);
01055            sprintf(string,"D %17.3lf",ima);
01056          }
01057          else sprintf(string,"N/A");
01058          SetDlgItemText(hdlg,DLG_COORDS_DIST,string);
01059          break;
01060        case DLG_COORDS_DEFINE:
01061          if(HIWORD(wparam) != BN_CLICKED)break;
01062          SendMessage(ghwnd_main,WM_COMMAND,IDM_COORDS_DEFINE,0);
01063          break;
01064        case IDC_COORD_UPDATE:
01065          GetDoubleCoordinates(NpointerX,NpointerY,NpointerZ,
01066                               &x,&y,&z,&dx,&dy,&dz);
01067          GetFormatString(format,x,y,z,dx,dy,dz);
01068          sprintf(string,format,x);  SetDlgItemText(hdlg,DLG_COORDS_X,string);
01069          sprintf(string,format,y);  SetDlgItemText(hdlg,DLG_COORDS_Y,string);
01070          sprintf(string,format,z);  SetDlgItemText(hdlg,DLG_COORDS_Z,string);
01071          rulerx=NpointerX; rulery=NpointerY; rulerz=NpointerZ;
01072          if(udflag){
01073            sprintf(string,format,0.0);SetDlgItemText(hdlg,DLG_COORDS_DX,string);
01074            sprintf(string,format,0.0);SetDlgItemText(hdlg,DLG_COORDS_DY,string);
01075            sprintf(string,format,0.0);SetDlgItemText(hdlg,DLG_COORDS_DZ,string);
01076            udflag=0;
01077          }
01078          break;
01079        default:   break;
01080      }
01081      break;
01082    default: break;
01083  }
01084  return(FALSE);
01085 }
01086 
01087 static void DoAddTooltip(HWND hwndOwner, HWND tipon, int resid){
01088  TOOLINFO ti;
01089  if(ghwndTooltip == NULL || tipon == NULL)return;
01090  memset(&ti,0,sizeof(TOOLINFO));
01091  ti.cbSize = sizeof(TOOLINFO);
01092  ti.uFlags = TTF_IDISHWND;
01093  ti.hwnd = hwndOwner;
01094  ti.hinst = ghinst_main;
01095  ti.uId = (UINT)tipon;
01096  ti.lpszText = (LPSTR)resid;
01097  SendMessage(ghwndTooltip,TTM_ADDTOOL,0,(LPARAM) (LPTOOLINFO) &ti);
01098  return;
01099 }
01100 
01101 static HWND DoCreateTooltip(HWND hwndOwner){
01102  HWND hwndTT;
01103  hwndTT = CreateWindow(TOOLTIPS_CLASS, (LPSTR) NULL, TTS_ALWAYSTIP,
01104      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
01105      hwndOwner, (HMENU) NULL, ghinst_main, NULL);
01106  return hwndTT;
01107 }
01108 

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