00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 #include "camtypes.h"
00103
00104 #include "cmxtree.h"
00105
00106
00107
00108 #include "oildbug.h"
00109 #include "nodedoc.h"
00110
00111
00112 #include "nodetext.h"
00113 #include <ios.h>
00114 #include "bubbleid.h"
00115
00116
00117
00118 #include "rifffile.h"
00119 #include "cdrfiltr.h"
00120 #include "cmxform.h"
00121
00122
00123
00124
00125
00126
00127
00128
00129 #include "clipint.h"
00130 #include "keypress.h"
00131 #include "vkextra.h"
00132 #include "insertnd.h"
00133
00134 #if DEBUG_TREE
00135
00136 CC_IMPLEMENT_DYNCREATE(CMXTreeDlg, DialogOp)
00137
00138
00139 CC_IMPLEMENT_MEMDUMP(CMXTreeDlgRecordHandler, CC_CLASS_MEMDUMP)
00140
00141 CC_IMPLEMENT_MEMDUMP( CMXFileRecord, CC_CLASS_MEMDUMP )
00142
00143 CC_IMPLEMENT_MEMDUMP( CMXNodeInfo, CC_CLASS_MEMDUMP )
00144 CC_IMPLEMENT_MEMDUMP( CMXNode, CC_CLASS_MEMDUMP )
00145
00146 CC_IMPLEMENT_MEMDUMP(CMXNodeTypeStatistics,ListItem)
00147 CC_IMPLEMENT_MEMDUMP(CMXNodeTypeStatisticsList,List)
00148
00149
00150
00151 #define new CAM_DEBUG_NEW
00152
00153 CMXTreeDlg* CMXTreeDlg::pCurrentCMXTreeDlg = NULL;
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 CMXTreeDlg::CMXTreeDlg(): DialogOp(CMXTreeDlg::IDD, MODELESS)
00167 {
00168 pRoot = NULL;
00169 pContextNode = NULL;
00170 EndOfFile = FALSE;
00171 AddNextAsChild = FALSE;
00172 Level = 0;
00173 TreeInfo = NULL;
00174 MaxIndex = 0;
00175
00176 EditStr = new StringBase;
00177 if (!EditStr || !EditStr->Alloc(0x100000)) return;
00178
00179 CMXTreeDlg::pCurrentCMXTreeDlg = this;
00180
00181 m_pRIFF = NULL;
00182 m_pHandler = NULL;
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 CMXTreeDlg::~CMXTreeDlg()
00197 {
00198 Delete(pRoot);
00199 DeleteTreeInfo();
00200
00201
00202 delete EditStr;
00203
00204 CMXTreeDlg::pCurrentCMXTreeDlg = NULL;
00205
00206 if (m_pRIFF != NULL)
00207 delete m_pRIFF;
00208
00209 if (m_pHandler != NULL)
00210 delete m_pHandler;
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 void CMXTreeDlg::Do(OpDescriptor*)
00228 {
00229 Create();
00230 Open();
00231 }
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 BOOL CMXTreeDlg::Init()
00248 {
00249
00250 return (RegisterOpDescriptor(
00251 0,
00252 _R(IDS_CMXTREEDLG),
00253 CC_RUNTIME_CLASS(CMXTreeDlg),
00254 OPTOKEN_CMXTREEDLG,
00255 CMXTreeDlg::GetState,
00256 0,
00257 _R(IDBBL_DEBUGTREEDLG),
00258 0 ));
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 BOOL CMXTreeDlg::Create()
00274 {
00275 if (DialogOp::Create())
00276 {
00277 EnableGadget(_R(IDC_DEBUGTREE_EXPAND), TRUE);
00278 EnableGadget(_R(IDC_DEBUGTREE_DUMP), FALSE);
00279 EnableGadget(_R(IDC_DEBUGTREE_HIDDEN), FALSE);
00280 EnableGadget(_R(IDC_DEBUGTREE_SELNONLY),FALSE);
00281 EnableGadget(_R(IDC_DEBUGTREE_REFRESH), FALSE);
00282
00283 InitialiseNewTreeControl();
00284 }
00285
00286 return TRUE;
00287 }
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 OpState CMXTreeDlg::GetState(String_256*, OpDescriptor*)
00302 {
00303 OpState OpSt;
00304 return(OpSt);
00305 }
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 void CMXTreeDlg::ShowFile(char* pFile)
00319 {
00320 String_256 s = pFile;
00321 SetFileName(s);
00322
00323 CreateTree();
00324 DisplayTree(FALSE);
00325 }
00326
00327
00328 void CMXTreeDlg::DeInit()
00329 {
00330 HWND hwndTree = ::GetDlgItem(WindowID, _R(IDC_DEBUGTREE_TREE));
00331 TreeView_DeleteAllItems(hwndTree);
00332
00333 Delete(pRoot);
00334 pRoot = NULL;
00335 }
00336
00337
00338 void CMXTreeDlg::Delete(CMXNode* pNode)
00339 {
00340 if (pNode == NULL)
00341 return;
00342
00343 Delete(pNode->GetChild());
00344 Delete(pNode->GetNext());
00345
00346 delete pNode;
00347 }
00348
00349 void CMXTreeDlg::SetFileName(String_256& ThisFileName)
00350 {
00351 FileName = ThisFileName;
00352 }
00353
00354
00355 void CMXTreeDlg::CreateTree()
00356 {
00357
00358 AddNextAsChild = FALSE;
00359 Level = 0;
00360 Delete(pRoot);
00361 pRoot = NULL;
00362 pContextNode = NULL;
00363
00364 String_256 NameOfType;
00365
00366 ListOfNodeTypeStats.DeleteAll();
00367
00368 PathName* pPath = new PathName(FileName);
00369
00370 if (pPath != NULL && pPath->IsValid())
00371 {
00372 CCDiskFile* pFile = new CCDiskFile(*pPath,ios::in | ios::binary);
00373
00374 if (pFile != NULL)
00375 {
00376 EndOfFile = FALSE;
00377
00378
00379
00380
00381
00382
00383
00384
00385 m_pRIFF = new RIFFFile();
00386
00387 FOURCC FormType = m_pRIFF->Init(pFile);
00388 BOOL FileOk = TRUE;
00389 switch (FormType)
00390 {
00391 case cmxRIFFFORMTYPE_CMX:
00392 NameOfType = "CMX";
00393 break;
00394 case cmxRIFFFORMTYPE_CDR5:
00395 NameOfType = "CDR5";
00396 break;
00397 case cmxRIFFFORMTYPE_CDT5:
00398 NameOfType = "CDRT5";
00399 break;
00400 case cmxRIFFFORMTYPE_CDR6:
00401 NameOfType = "CDR6";
00402 break;
00403 case cmxRIFFFORMTYPE_CDT6:
00404 NameOfType = "CDT6";
00405 break;
00406
00407 default:
00408 FileOk=FALSE;
00409 break;
00410 }
00411
00412 if (FileOk)
00413 {
00414 ParseFile(pFile);
00415 }
00416
00417 delete pFile;
00418 }
00419 }
00420
00421 if (pPath != NULL)
00422 delete pPath;
00423
00424 ListOfNodeTypeStats.Dump(this);
00425 ListOfNodeTypeStats.DeleteAll();
00426
00427 AddOneItem(NULL, (TCHAR *)FileName, TVI_LAST, m_idxPage, NULL);
00428 AddOneItem(NULL, (TCHAR*)NameOfType,TVI_LAST, m_idxPage, NULL);
00429 AddItemsToNewTreeControl(NULL, pRoot);
00430 }
00431
00432
00433 BOOL CMXTreeDlg::ParseFile(CCFile * pFile)
00434 {
00435 ERROR2IF(pFile == NULL || m_pRIFF == NULL,FALSE,"Bad params");
00436
00437 m_pHandler = new CMXTreeDlgRecordHandler(this, pFile);
00438
00439 if (m_pHandler == NULL)
00440 return FALSE;
00441
00442
00443 BOOL finished = FALSE;
00444
00445 UINT32 StartLevel = m_pRIFF->GetObjLevel();
00446
00447
00448 if (!m_pRIFF->NextObject())
00449 finished = TRUE;
00450
00451 RIFFObjectType ObjectType = m_pRIFF->GetObjType();
00452 FOURCC ChunkType = m_pRIFF->GetObjChunkType();
00453 UINT32 Size = m_pRIFF->GetObjSize();
00454 UINT32 Level = m_pRIFF->GetObjLevel();
00455 INT32 RecordNumber = 0;
00456
00457 while (ObjectType != RIFFOBJECTTYPE_FILEEND && !finished)
00458 {
00459 CMXFileRecord* pCMXFileRecord = new CMXFileRecord(ObjectType, ChunkType, Size, Level);
00460
00461 RecordNumber ++;
00462
00463 if (pCMXFileRecord != NULL)
00464 {
00465 pCMXFileRecord->SetRecordNumber(RecordNumber);
00466 m_pHandler->HandleRecord(pCMXFileRecord);
00467 }
00468 else
00469 finished = TRUE;
00470
00471
00472 if (!m_pRIFF->NextObject())
00473 finished = TRUE;
00474
00475 ObjectType = m_pRIFF->GetObjType();
00476 ChunkType = m_pRIFF->GetObjChunkType();
00477 Size = m_pRIFF->GetObjSize();
00478 Level = m_pRIFF->GetObjLevel();
00479 }
00480
00481 return TRUE;
00482 }
00483
00484
00485
00486
00487
00488 void CMXTreeDlg::AddNode(CMXNode* pNode)
00489 {
00490 if (pNode == NULL)
00491 return;
00492
00493 ListOfNodeTypeStats.Update(pNode);
00494
00495 if (pRoot == NULL)
00496 {
00497 pRoot = pNode;
00498 return;
00499 }
00500
00501 if (pContextNode == NULL)
00502 pContextNode = pRoot;
00503
00504 if (pContextNode != NULL)
00505 {
00506 INT32 NewLevel = pNode->GetObjectLevel();
00507 if (NewLevel > Level)
00508 {
00509 AddNextAsChild = TRUE;
00510 Level++;
00511 }
00512 else if (NewLevel < Level)
00513 {
00514 AddNextAsChild = FALSE;
00515 Level--;
00516 }
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533 if (pContextNode != NULL)
00534 {
00535 if (AddNextAsChild)
00536 {
00537 CMXNode* pChildNode = pContextNode->GetChild();
00538 if (pChildNode != NULL)
00539 {
00540 TRACEUSER( "Neville from Markn code", _T("Take cover - context node has already got children"));
00541
00542 while (pChildNode->GetNext() != NULL)
00543 pChildNode = pChildNode->GetNext();
00544
00545 pChildNode->SetNext(pNode);
00546 pNode->SetPrevious(pChildNode);
00547 pNode->SetParent(pChildNode->GetParent());
00548 }
00549 else
00550 {
00551 pContextNode->SetChild(pNode);
00552 pNode->SetParent(pContextNode);
00553 }
00554
00555 AddNextAsChild = FALSE;
00556 pContextNode = pNode;
00557 }
00558 else
00559 {
00560 pContextNode->SetNext(pNode);
00561 pNode->SetPrevious(pContextNode);
00562 pNode->SetParent(pContextNode->GetParent());
00563
00564
00565
00566
00567 pContextNode = pNode;
00568 }
00569 }
00570 }
00571 }
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 CMXTreeDlgRecordHandler* CMXTreeDlg::FindHandler(FOURCC ChunkType)
00588 {
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607 return m_pHandler;
00608 }
00609
00610 void CMXTreeDlg::GetTagText(CMXNode* pNode,String_256& Str)
00611 {
00612 if (pNode != NULL)
00613 GetTagText(pNode->GetChunkType(),Str);
00614 }
00615
00616 void CMXTreeDlg::GetTagText(FOURCC ChunkType, String_256& Str)
00617 {
00618 CMXTreeDlgRecordHandler* pHandler = FindHandler(ChunkType);
00619
00620 if (pHandler != NULL)
00621 pHandler->GetTagText(ChunkType, Str);
00622 }
00623
00624 INT32 CMXTreeDlg::AddDisplayNode(CMXNode* pNode,INT32 Index,INT32 Depth,BOOL ExpandAll)
00625 {
00626 while (pNode != NULL)
00627 {
00628 if (ExpandAll)
00629 pNode->SetShowChildren(TRUE);
00630
00631
00632 CMXNodeInfo* pInfo = new CMXNodeInfo;
00633
00634 if (pInfo != NULL)
00635 pInfo->pNode = pNode;
00636 else
00637 return Index;
00638
00639
00640 char indent[256];
00641 indent[0] = 0;
00642 for (INT32 i=0;i<Depth;i++)
00643 camStrcat(indent," ");
00644
00645 if (pNode->HasChildren())
00646 {
00647 if (pNode->ShowChildren())
00648 camStrcat(indent,"-");
00649 else
00650 camStrcat(indent,"+");
00651 }
00652
00653
00654 String_256 TagText;
00655 GetTagText(pNode,TagText);
00656
00657
00658 String_256 ListBoxText = indent;
00659 ListBoxText += TagText;
00660
00661
00662 SetStringGadgetValue(_R(IDC_DEBUGTREE_LIST), &ListBoxText, FALSE, Index);
00663
00664
00665 if (TreeInfo != NULL)
00666 TreeInfo->AddDebugInfo(Index, pInfo);
00667
00668 MaxIndex = Index;
00669 Index++;
00670
00671 if (pNode->ShowChildren())
00672 Index = AddDisplayNode(pNode->GetChild(),Index,Depth+1,ExpandAll);
00673
00674
00675
00676
00677 pNode = pNode->GetNext();
00678
00679 }
00680
00681 return Index;
00682 }
00683
00684 void CMXTreeDlg::DeleteTreeInfo()
00685 {
00686 if (TreeInfo != NULL)
00687 {
00688 for (INT32 i=0;i<=MaxIndex;i++)
00689 {
00690 CMXNodeInfo *pNodeInfo = GetInfo(i);
00691
00692 TreeInfo->AddDebugInfo(i, NULL);
00693
00694 if (pNodeInfo != NULL)
00695 delete pNodeInfo;
00696 }
00697
00698 delete TreeInfo;
00699 }
00700
00701 TreeInfo = NULL;
00702 MaxIndex = 0;
00703 }
00704
00705
00706 void CMXTreeDlg::DisplayTree(BOOL ExpandAll)
00707 {
00708
00709 HWND hListBox = ::GetDlgItem(WindowID, _R(IDC_DEBUGTREE_LIST));
00710 ENSURE(hListBox != NULL, "Can't find list box in debug tree dialog!");
00711
00712 DeleteTreeInfo();
00713
00714 TreeInfo = new DebugTreeInfo(hListBox);
00715
00716 DeleteAllValues(_R(IDC_DEBUGTREE_LIST));
00717 SetStringGadgetValue(_R(IDC_DEBUGTREE_LIST), &FileName, FALSE, 0);
00718 AddDisplayNode(pRoot,1,0,ExpandAll);
00719 }
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733 void CMXTreeDlg::ShowNodeDebugInfo(INT32 ListIndex)
00734 {
00735 if (ListIndex < 1)
00736 {
00737 String_256 Str = "";
00738 SetStringGadgetValue(_R(IDC_DEBUGTREE_DETAILS), &Str);
00739 return;
00740 }
00741
00742
00743 CMXNode *pNode = GetInfo(ListIndex)->pNode;
00744
00745 if (pNode != NULL)
00746 {
00747 ShowNodeDebugInfoForNode(pNode);
00748 }
00749 }
00750
00751 void CMXTreeDlg::ShowNodeDebugInfoForNode(CMXNode *pNode)
00752 {
00753 if (pNode != NULL)
00754 {
00755 (*EditStr).Empty();
00756
00757 pNode->ResetReadPos();
00758
00759 CMXTreeDlgRecordHandler* pHandler = FindHandler(pNode->GetChunkType());
00760 if (pHandler != NULL)
00761 pHandler->GetRecordDescriptionText(pNode->GetCMXFileRecord(),EditStr);
00762 else
00763 {
00764 TCHAR s[256];
00765 FOURCC ChunkType = pNode->GetChunkType();
00766 canSprintf(s,_T("Default handler (%d)\r\n"), ChunkType);
00767 (*EditStr) += s;
00768 }
00769
00770
00771 SetStringGadgetValue(_R(IDC_DEBUGTREE_DETAILS), EditStr);
00772 }
00773 }
00774
00775 CMXNodeInfo *CMXTreeDlg::GetInfo(INT32 Index)
00776 {
00777 ERROR2IF(TreeInfo==NULL,NULL,"TreeInfo is NULL");
00778 return (CMXNodeInfo *) TreeInfo->GetDebugInfo(Index);
00779 }
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793 MsgResult CMXTreeDlg::Message( Msg* Message)
00794 {
00795
00796 if (IS_OUR_DIALOG_MSG(Message))
00797 {
00798 DialogMsg* Msg = (DialogMsg*) Message;
00799 if ((Msg->DlgMsg == DIM_COMMIT || Msg->DlgMsg == DIM_CANCEL))
00800 {
00801 DeInit();
00802 Close();
00803 End();
00804 }
00805 else if ((Msg->GadgetID == _R(IDC_DEBUGTREE_EXPAND))
00806 && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
00807 {
00808
00809 DisplayTree(TRUE);
00810 ExpandNewTree();
00811 }
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847 else if ((Msg->GadgetID == _R(IDC_DEBUGTREE_LIST)) &&
00848 (Msg->DlgMsg == DIM_SELECTION_CHANGED_COMMIT))
00849 {
00850 WORD Index;
00851 GetValueIndex(_R(IDC_DEBUGTREE_LIST), &Index);
00852 if (Index > 0)
00853 {
00854 CMXNode *pNode = GetInfo(Index)->pNode;
00855 if (pNode != NULL)
00856 {
00857 pNode->SetShowChildren(!pNode->ShowChildren());
00858 DisplayTree(FALSE);
00859 SetSelectedValueIndex(_R(IDC_DEBUGTREE_LIST), Index);
00860 }
00861 }
00862 }
00863 else if ((Msg->GadgetID == _R(IDC_DEBUGTREE_LIST)) && (Msg->DlgMsg == DIM_SELECTION_CHANGED))
00864 {
00865 WORD Index;
00866 GetValueIndex(_R(IDC_DEBUGTREE_LIST), &Index);
00867 ShowNodeDebugInfo(Index);
00868 }
00869 else if ((Msg->GadgetID == _R(IDC_DEBUGTREE_TREE)) && (Msg->DlgMsg == DIM_SELECTION_CHANGED))
00870 {
00871 NM_TREEVIEW *pTV = (NM_TREEVIEW *)Msg->DlgMsgParam;
00872
00873 if(pTV != NULL)
00874 {
00875
00876 TV_ITEM Item = pTV->itemNew;
00877 {
00878
00879 CMXNode *pNode = (CMXNode *)Item.lParam;
00880 ShowNodeDebugInfoForNode(pNode);
00881 }
00882 }
00883 }
00884
00885 return (DLG_EAT_IF_HUNGRY(Msg));
00886 }
00887 return OK;
00888 }
00889
00890
00891
00892
00893
00894 CMXTreeDlgRecordHandler::CMXTreeDlgRecordHandler(CMXTreeDlg * pThisDlg,CCFile* pThisCMXile)
00895 {
00896 ERROR3IF(pThisDlg == NULL,"Null pThisDlg");
00897 ERROR3IF(pThisCMXile == NULL,"Null pThisCMXile");
00898
00899 pCMXDlg = pThisDlg;
00900 pCMXile = pThisCMXile;
00901 }
00902
00903
00904
00905 BOOL CMXTreeDlgRecordHandler::HandleRecord(CMXFileRecord* pRecord)
00906 {
00907 ERROR2IF(pRecord == NULL,FALSE,"NULL record given!");
00908 ERROR2IF(pCMXDlg == NULL,FALSE,"NULL pCMXDlg!");
00909 ERROR2IF(pCMXile == NULL,FALSE,"NULL pCMXile!");
00910
00911 CMXNode* pNode = new CMXNode(pRecord);
00912
00913 pCMXDlg->AddNode(pNode);
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931 return TRUE;
00932 }
00933
00934 void CMXTreeDlgRecordHandler::GetTagText(FOURCC ChunkType, String_256& Str)
00935 {
00936
00937 TCHAR c = ' ';
00938
00939 c = (TCHAR)((ChunkType) & 0xFF);
00940 Str += c;
00941 c = (TCHAR)((ChunkType >> 8) & 0xFF);
00942 Str += c;
00943 c = (TCHAR)((ChunkType >> 16) & 0xFF);
00944 Str += c;
00945 c = (TCHAR)((ChunkType >> 24) & 0xFF);
00946 Str += c;
00947 }
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966 void CMXTreeDlgRecordHandler::GetRecordDescriptionText(CMXFileRecord* pRecord,StringBase* pStr)
00967 {
00968 if (pStr == NULL || pRecord == NULL)
00969 return;
00970
00971 String_256 TagText;
00972 GetTagText(pRecord->GetChunkType(),TagText);
00973 TCHAR* pTagText = TagText;
00974
00975 RIFFObjectType ObjType = pRecord->GetObjectType();
00976 String_256 ObjText;
00977 TCHAR* pObjText = ObjText;
00978 switch (ObjType)
00979 {
00980 case RIFFOBJECTTYPE_NONE:
00981 ObjText = _T("None");
00982 break;
00983 case RIFFOBJECTTYPE_CHUNK:
00984 ObjText = _T("Chunk");
00985 break;
00986 case RIFFOBJECTTYPE_LISTSTART:
00987 ObjText = _T("List start");
00988 break;
00989 case RIFFOBJECTTYPE_LISTEND:
00990 ObjText = _T("List end");
00991 break;
00992 case RIFFOBJECTTYPE_FILEEND:
00993 ObjText = _T("List end");
00994 break;
00995 }
00996
00997 TCHAR s[256];
00998 camSprintf(s,_T("Record Number = %d\r\nRIFF type = %s\r\nTag = %s\r\nSize = %d\r\n\r\n"),pRecord->GetRecordNumber(),pObjText,pTagText,pRecord->GetChunkSize());
00999
01000 (*pStr) += s;
01001 }
01002
01003
01004
01005
01006 CMXNode::CMXNode(CMXFileRecord* pThisRecord)
01007 {
01008 pRecord = NULL;
01009 pNext = NULL;
01010 pPrevious = NULL;
01011 pParent = NULL;
01012 pChild = NULL;
01013
01014 DoShowChildren = FALSE;
01015
01016 if (pThisRecord != NULL)
01017 pRecord = pThisRecord;
01018 }
01019
01020 CMXNode::~CMXNode()
01021 {
01022 if (pRecord != NULL)
01023 delete pRecord;
01024 }
01025
01026 RIFFObjectType CMXNode::GetObjectType()
01027 {
01028 if (pRecord != NULL)
01029 return pRecord->GetObjectType();
01030
01031 return RIFFOBJECTTYPE_NONE;
01032 }
01033
01034 FOURCC CMXNode::GetChunkType()
01035 {
01036 if (pRecord != NULL)
01037 return pRecord->GetChunkType();
01038
01039 return cmxRIFFFORMTYPE_CMX;
01040 }
01041
01042 UINT32 CMXNode::GetChunkSize()
01043 {
01044 if (pRecord != NULL)
01045 return pRecord->GetChunkSize();
01046
01047 return UINT32(-1);
01048 }
01049
01050 UINT32 CMXNode::GetObjectLevel()
01051 {
01052 if (pRecord != NULL)
01053 return pRecord->GetObjectLevel();
01054
01055 return UINT32(-1);
01056 }
01057
01058 void CMXNode::ResetReadPos()
01059 {
01060
01061
01062 }
01063
01064
01065
01066
01067
01068
01069 void CMXNodeTypeStatisticsList::Update(CMXNode* pNode)
01070 {
01071 CMXNodeTypeStatistics* pItem = FindNodeType(pNode->GetObjectType());
01072
01073 if (pItem == NULL)
01074 {
01075 pItem = new CMXNodeTypeStatistics(pNode->GetObjectType());
01076 if (pItem != NULL)
01077 Add(pItem);
01078 }
01079
01080 if (pItem != NULL)
01081 {
01082 pItem->IncNumOccurances();
01083 pItem->AddToTotalSize(pNode->GetChunkSize());
01084 }
01085 }
01086
01087 void CMXNodeTypeStatisticsList::Dump(CMXTreeDlg* pDlg)
01088 {
01089 TRACE( _T("\nRecord stats:\n\n"));
01090
01091 CMXNodeTypeStatistics* pItem = GetHead();
01092
01093 String_256 Str;
01094
01095 while (pItem != NULL)
01096 {
01097 pDlg->GetTagText(pItem->GetChunkType(), Str);
01098
01099 INT32 o = pItem->GetNumOccurances();
01100 INT32 s = pItem->GetTotalSize();
01101
01102 TRACE( _T("%s\t%d\t%d\t%d\n"),(TCHAR*)Str,o,s,(o*8)+s);
01103
01104 pItem = GetNext(pItem);
01105 }
01106 }
01107
01108
01109 CMXNodeTypeStatistics* CMXNodeTypeStatisticsList::FindNodeType(FOURCC ChunkType)
01110 {
01111 CMXNodeTypeStatistics* pItem = GetHead();
01112 while (pItem != NULL)
01113 {
01114 if (pItem->GetChunkType() == ChunkType)
01115 return pItem;
01116
01117 pItem = GetNext(pItem);
01118 }
01119
01120 return NULL;
01121 }
01122
01123
01124 void CMXNodeTypeStatisticsList::Add(CMXNodeTypeStatistics* pNodeType)
01125 {
01126 AddTail(pNodeType);
01127 }
01128
01129 CMXNodeTypeStatistics* CMXNodeTypeStatisticsList::GetHead()
01130 {
01131 return (CMXNodeTypeStatistics*)List::GetHead();
01132 }
01133
01134 CMXNodeTypeStatistics* CMXNodeTypeStatisticsList::GetNext(CMXNodeTypeStatistics* pItem)
01135 {
01136 return (CMXNodeTypeStatistics*)List::GetNext(pItem);
01137 }
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159 HTREEITEM CMXTreeDlg::AddOneItem(HTREEITEM hParent, TCHAR *pText, HTREEITEM hInsAfter, INT32 iImage, CMXNode *pNode)
01160 {
01161 HWND hwndTree = ::GetDlgItem(WindowID, _R(IDC_DEBUGTREE_TREE));
01162
01163 HTREEITEM hItem;
01164 TV_ITEM tvI;
01165 TV_INSERTSTRUCT tvIns;
01166
01167
01168 tvI.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
01169 tvI.pszText = pText;
01170 tvI.cchTextMax = camStrlen(pText);
01171 tvI.iImage = iImage;
01172 tvI.iSelectedImage = iImage;
01173 tvI.lParam = (LPARAM)pNode;
01174
01175 tvIns.item = tvI;
01176 tvIns.hInsertAfter = hInsAfter;
01177 tvIns.hParent = hParent;
01178
01179
01180 hItem = TreeView_InsertItem(hwndTree, &tvIns);
01181
01182 return (hItem);
01183 }
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196 INT32 CMXTreeDlg::GetImageForNode(CMXNode *pNode)
01197 {
01198 INT32 iImage = m_idxGeneralTag;
01199
01200 if (pNode != NULL)
01201 {
01202
01203 RIFFObjectType Type = pNode->GetObjectType();
01204 switch(Type)
01205 {
01206 case RIFFOBJECTTYPE_LISTEND:
01207 iImage = m_idxUp;
01208 break;
01209
01210 case RIFFOBJECTTYPE_LISTSTART:
01211 iImage = m_idxDown;
01212 break;
01213
01214 case RIFFOBJECTTYPE_FILEEND:
01215 iImage = m_idxCompression;
01216 break;
01217
01218 case RIFFOBJECTTYPE_CHUNK:
01219 iImage = m_idxGroup;
01220
01221
01222
01223
01224
01225
01226
01227 break;
01228 }
01229 }
01230
01231 return iImage;
01232 }
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244 HTREEITEM CMXTreeDlg::AddItemsToNewTreeControl(HTREEITEM hParentItem, CMXNode *pNode)
01245 {
01246 if(pNode == NULL)
01247 return 0;
01248
01249 String_256 NodeText;
01250
01251 GetTagText(pNode, NodeText);
01252 INT32 iImage = GetImageForNode(pNode);
01253
01254 HTREEITEM hThisItem = AddOneItem(hParentItem, (TCHAR *)NodeText, hParentItem, iImage, pNode);
01255
01256
01257 CMXNode *pChild = pNode->GetChild();
01258
01259 if(pChild != NULL)
01260 {
01261
01262 AddItemsToNewTreeControl(hThisItem, pChild);
01263 }
01264
01265
01266 CMXNode *pNext = pNode->GetNext();
01267
01268 if(pNext != NULL)
01269 {
01270
01271 AddItemsToNewTreeControl(hParentItem, pNext);
01272 }
01273
01274 return hThisItem;
01275 }
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289 INT32 CMXTreeDlg::AddBitmapResourceToImageList(HIMAGELIST hList, UINT32 ResID)
01290 {
01291 HINSTANCE hMain = AfxGetResourceHandle();
01292 HBITMAP hBmp = ::LoadBitmap(hMain, MAKEINTRESOURCE(ResID));
01293 INT32 index = ImageList_AddMasked(hList, hBmp, RGB(255,0,255));
01294 return index;
01295 }
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307 BOOL CMXTreeDlg::InitialiseNewTreeControl(void)
01308 {
01309 HWND hwndTree = ::GetDlgItem(WindowID, _R(IDC_DEBUGTREE_TREE));
01310
01311 INT32 BitmapWidth = 16;
01312 INT32 BitmapHeight = 16;
01313
01314
01315 hNewTreeControlImageList = ImageList_Create(BitmapWidth, BitmapHeight, ILC_MASK, 0, 0);
01316
01317
01318 m_idxGeneralTag = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_CXFTREE_GENERALTAG));
01319 m_idxDefineBitmap = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_CXFTREE_DEFINEBITMAP));
01320 m_idxDefineColour = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_CXFTREE_DEFINECOLOUR));
01321 m_idxCompression = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_CXFTREE_COMPRESSION));
01322 m_idxDown = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_CXFTREE_DOWN));
01323 m_idxUp = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_CXFTREE_UP));
01324 m_idxGroup = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_CXFTREE_GROUP));
01325 m_idxPage = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_DEBUGTREE_RENDERABLEPAPER));
01326 m_idxAttribute = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_DEBUGTREE_ATTRIBUTE));
01327 m_idxShape = AddBitmapResourceToImageList(hNewTreeControlImageList, _R(IDB_DEBUGTREE_RENDERABLEINK));
01328
01329
01330 TreeView_SetImageList(hwndTree, hNewTreeControlImageList, m_idxGeneralTag);
01331
01332
01333 INT32 Count = ImageList_GetImageCount(hNewTreeControlImageList);
01334
01335 return(Count > 0);
01336 }
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349 BOOL CMXTreeDlg::GetInfoFromHTREEITEM(HTREEITEM hItem, CMXNode **ppNode, INT32 *pChildren)
01350 {
01351 HWND hwndTree = ::GetDlgItem(WindowID, _R(IDC_DEBUGTREE_TREE));
01352
01353 TV_ITEM Item;
01354 Item.hItem = hItem;
01355 Item.mask = TVIF_PARAM | TVIF_CHILDREN | TVIF_STATE;
01356
01357 if(TreeView_GetItem(hwndTree, &Item))
01358 {
01359 *ppNode = (CMXNode *)Item.lParam;
01360 *pChildren = Item.cChildren;
01361 return TRUE;
01362 }
01363
01364 return FALSE;
01365 }
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378 void CMXTreeDlg::ExpandNewTree()
01379 {
01380 HTREEITEM hItem = 0;
01381 HWND hwndTree = ::GetDlgItem(WindowID, _R(IDC_DEBUGTREE_TREE));
01382 hItem = TreeView_GetRoot(hwndTree);
01383
01384 HTREEITEM hSelectedItem = TreeView_GetSelection(hwndTree);
01385
01386
01387 while(hItem != 0)
01388 {
01389 TreeView_Expand(hwndTree, hItem, TVE_EXPAND);
01390
01391
01392 hItem = TreeView_GetNextItem(hwndTree, hItem, TVGN_NEXTVISIBLE);
01393 }
01394
01395 TreeView_SelectItem(hwndTree, hSelectedItem);
01396 }
01397
01398 #endif //DEBUG_TREE
01399
01400
01401