
/***************************************************************************
**
**    $Header:   D:/ECB2S/SRC/LOG/BTNBAR.CPP   1.2.1.5   17 Apr 1997 15:42:16   ZJRD  $
**
**    $Log:   D:/ECB2S/SRC/LOG/BTNBAR.CPP  $
** 
**    Rev 1.2.1.5   17 Apr 1997 15:42:16   ZJRD
** No change.
** 
**    Rev 1.2.1.4   16 Apr 1997 10:16:28   ZJRD
** 2.09F
** 
**    Rev 1.2.1.3   10 Apr 1997 15:28:16   ZJRD
** 2.09F
** 
**    Rev 1.2.1.1   03 Apr 1997 15:09:52   ZJRD
** 2.09E
** 
**    Rev 1.2.1.0   28 Mar 1997 10:14:50   ZJRD
** easy pack sld 2.09d
** 
**    Rev 1.1   19 Mar 1997 11:26:08   ZJRD
** No change.
** 
**    Rev 1.0   12 Mar 1997 14:44:48   ZJRD
** Initial revision.
** 
**    Rev 1.7.1.0.1.2   09 Dec 1996 10:13:52   ZJRD
** EasyPack/SLD Version 2.0P
** 
**    Rev 1.7.1.0.1.0   11 Nov 1996 12:57:08   ZJRD
** EasyPack/SLD Version 2.01
** 
**    Rev 1.7.1.4   09 Sep 1996 13:12:12   ZJRD
** No change.
** 
**    Rev 1.7.1.3   05 Sep 1996 11:24:00   ZJRD
** No change.
** 
**    Rev 1.7.1.2   02 Sep 1996 09:51:18   ZJRD
** EasyPack/SLD Version 1.9d
** 
**    Rev 1.7.1.1   28 Aug 1996 15:43:02   ZJRD
** EasyPack/SLD Version 1.9b
** 
**    Rev 1.7.1.0   12 Aug 1996 10:48:34   ZJRD
** EasyPack/SLD Version 1.98
** 
**    Rev 1.7   11 Jun 1996 10:23:10   ZJRD
** EasyPack/SLD Version 1.97
** 
**    Rev 1.5   05 Jun 1996 14:50:54   ZJRD
** EasyPack/SLD Version 1.96
** 
**    Rev 1.4   29 May 1996 09:27:28   ZJRD
** EasyPack/SLD Version 1.95
** 
**    Rev 1.3   16 May 1996 08:59:10   ZJRD
** No change.
** 
**    Rev 1.2   10 May 1996 09:07:42   ZJRD
** EasyPack/SLD Version 1.93
** 
**    Rev 1.1   02 May 1996 10:22:12   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.31   18 Apr 1996 12:52:32   Shirley
** EasyPack/SLD Version 1.91
** 
**    Rev 1.30   12 Apr 1996 10:33:20   Shirley
** EasyPack/SLD Version 1.90
** 
**    Rev 1.28   15 Feb 1996 08:46:20   Shirley
** No change.
** 
**    Rev 1.27   12 Feb 1996 14:01:24   Shirley
** No change.
** 
**    Rev 1.26   06 Feb 1996 15:26:50   Shirley
** No change.
** 
**    Rev 1.25   06 Feb 1996 13:42:12   Shirley
** No change.
** 
**    Rev 1.24   01 Feb 1996 10:10:48   Shirley
** EasyPack/SLD Version 0.35b
** 
**    Rev 1.23   26 Jan 1996 09:11:38   Shirley
** No change.
** 
**    Rev 1.22   25 Jan 1996 13:11:58   Shirley
** No change.
** 
**    Rev 1.21   24 Jan 1996 10:31:22   Shirley
** EasyPack/SLD Version 0.34d
** 
**    Rev 1.20   23 Jan 1996 11:21:42   Shirley
** No change.
** 
**    Rev 1.19   18 Jan 1996 10:07:08   Shirley
** No change.
** 
**    Rev 1.18   15 Jan 1996 16:09:52   Shirley
** No change.
** 
**    Rev 1.17   04 Jan 1996 11:07:20   Shirley
** No change.
** 
**    Rev 1.16   30 Nov 1995 09:07:42   Shirley
** No change.
** 
**    Rev 1.15   28 Nov 1995 15:28:46   Shirley
** No change.
** 
**    Rev 1.14   21 Nov 1995 11:17:40   Shirley
** EasyPack/SLD Version 0.31
** 
**    Rev 1.13   13 Nov 1995 09:21:18   Shirley
** No change.
** 
**    Rev 1.12   12 Nov 1995 11:27:52   Shirley
** No change.
** 
**    Rev 1.11   08 Nov 1995 16:27:26   Shirley
** No change.
** 
**    Rev 1.10   08 Nov 1995 12:39:20   Shirley
** No change.
** 
**    Rev 1.9   02 Nov 1995 10:02:06   Shirley
** No change.
** 
**    Rev 1.8   27 Oct 1995 16:44:44   Shirley
** No change.
** 
**    Rev 1.7   27 Oct 1995 13:43:02   Shirley
** No change.
** 
**    Rev 1.6   25 Oct 1995 14:25:32   Shirley
** No change.
** 
**    Rev 1.5   18 Oct 1995 14:46:36   Shirley
** EasyPack/SLD Version 0.1e
** 
**    Rev 1.4   13 Oct 1995 13:18:30   Shirley
** EasyPack/SLD Version 0.1d
** 
**    Rev 1.3   29 Sep 1995 09:47:54   Shirley
** No change.
** 
**    Rev 1.2   20 Sep 1995 10:56:22   Shirley
** EasyPack/SLD Version 0.1b
** 
**    Rev 1.1   15 Sep 1995 09:47:26   Shirley
** No change.
** 
**    Rev 1.0   07 Sep 1995 09:54:54   Shirley
** Initial revision.
**
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name:  BTNBAR.CPP
//
//  Description:The implement file for the class: CSuperToolBar
//
//  Author:     Roger Zhang
//
//  Date:       04/14/95
//
//  Modification:
//
//      1. 04/14/95, Initial version 
//
//
//  Copyright (C) 1995 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "hwtip.h"
#include "xview.h"
//#include "control.h"
#include "zqueue.h"                   
#include "uicom.h"                   
#include "srccom.h"
#include "btnbar.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif


extern CStringList* pStkSearchPatternList;  // Defined in VARSRCH.CPP
extern CStringList* pVarSearchPatternList;  // Defined in VARSRCH.CPP

/////////////////////////////////////////////////////////////
//   Tha Array buttons[] is added by jerry to support float 
//   and configrable toolbar in May,1996.
///////////////////////////////////////////////////////////// 
UINT buttons[]= {
ID_FILE_BROWSEMODULE ,
ID_FILE_PREVMODULE        ,
ID_FILE_NEXTMODULE       ,
ID_FILE_LOAD ,
ID_EDIT_SEARCHNEXT        ,
ID_VIEW_SOURCEONLY        ,
ID_VIEW_MIXED             ,
ID_VIEW_BUS                   ,
ID_VIEW_INSTRUCTION           ,
ID_RUN_BREAKPOINT,

ID_RUN_GO                   ,
ID_RUN_HALT               ,
ID_RUN_RESET              ,
ID_RUN_STEPINTO           ,
ID_RUN_STEPOVER           ,
ID_RUN_GOUNTILRETURN ,
//0,//	    BTN_GO_UNTIL,
ID_VIEW_MIXED,
0,//	    BTN_WATCH,
0,//	    BTN_STATEMENT,
0,//	    BTN_INST,
ID_EDIT_SELECTLOCALVARIABLES ,    
ID_EDIT_GOTOSTARTFRAME,
ID_EDIT_GOTOENDFRAME,
ID_EDIT_GOTOFRAME,
ID_VARIABLE_ADD,
ID_VARIABLE_DELETE,
ID_HELP,
0,       //BTN_ABOUT
0,		//BTN_DIAGNOSIS   
ID_RUN_GORUN,
ID_MAP,
ID_GOTO_SHELL,
ID_VIEW_SOURCE,

ID_TOGGLE_TRACE,
ID_GROUP_SPA,
ID_RUN_RESTART,
ID_TRACE_CLEAR,
ID_VIEW_ASSEMBLE,       //37
ID_VIEW_SHORTLINE,
IDC_SRCHCOMBO,
};    
    
/////////////////////////////////////////////////////////////////////////////
// CSuperToolBar

IMPLEMENT_DYNAMIC(CSuperToolBar , CToolBar)

///////////////////////////////////////////////
//                                           //
// This routine is added by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////
             
BOOL CSuperToolBar::AddCombo(int item)
{
     CRect rect;
     GetItemRect(item, &rect);
     rect.top = 1;
     rect.bottom = rect.top + 100;
     if(!m_isCmbSrch)
       if(!m_cmbSrch.Create(CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_VISIBLE, 
            rect, this, IDC_SRCHCOMBO)) {
         TRACE("Failed to create combo-box\n");
         return FALSE;
       }
     else 0;             
     m_isCmbSrch = TRUE;                 
        
     POSITION pos = SrcSrchData.m_StrList.GetTailPosition();
     while(pos) {
          m_cmbSrch.AddString(SrcSrchData.m_StrList.GetPrev(pos));
     }
     m_cmbSrch.SetCurSel(0);
	return 1;
}                                              

///////////////////////////////////////////////
//                                           //
// This routine is added by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

BOOL CSuperToolBar::RemoveButton(int item)
{
    DWORD dwStyle=GetStyle();
    if(m_nCount<=1) return 0;
    CCONTROL::RemoveButton(item);
    if(m_isCmbSrch){
    	Del();
    }
        int* nT;
        int i;
    	switch(nActiveId) {
        case WID_TRACE:
             m_nTraceCount--;
             for(i=item;i<(int)m_nTraceCount;i++)
             	m_nTrace[i]=m_nTrace[i+1];
             nT=(int*)m_nTrace;
             break;
        case WID_SOURCE:
             m_nSourceCount--;
             for(i=item;i<(int)m_nSourceCount;i++)
             	m_nSource[i]=m_nSource[i+1];
            nT=(int*)m_nSource;
            break;
        case WID_VARIABLE:
             m_nVarCount--;
             for(i=item;i<(int)m_nVarCount;i++)
             	m_nVar[i]=m_nVar[i+1];
            nT=(int*)m_nVar;
            break;
        case WID_STACK:
             m_nStackCount--;
             for(i=item;i<(int)m_nStackCount;i++)
             	m_nStack[i]=m_nStack[i+1];
            nT=(int*)m_nStack;
            break;
        case WID_MAIN:
             m_nMainCount--;
             for(i=item;i<(int)m_nMainCount;i++)
             	m_nMain[i]=m_nMain[i+1];
            nT=(int*)m_nMain;
            break;
        case WID_CPU:
             m_nCPUCount--;
             for(i=item;i<(int)m_nCPUCount;i++)
             	m_nCPU[i]=m_nCPU[i+1];
            nT=(int*)m_nCPU;
            break;
        case WID_SHELL:
             m_nShellCount--;
             for(i=item;i<(int)m_nShellCount;i++)
             	m_nShell[i]=m_nShell[i+1];
            nT=(int*)m_nShell;
            break;
        case WID_MEMORY:
             m_nMemCount--;
             for(i=item;i<(int)m_nMemCount;i++)
             	m_nMem[i]=m_nMem[i+1];
            nT=(int*)m_nMem;
            break;
        case WID_BMEM:
             m_nBMemCount--;
             for(i=item;i<(int)m_nBMemCount;i++)
             	m_nBMem[i]=m_nBMem[i+1];
            nT=(int*)m_nBMem;
            break;
        case WID_PERI:
             m_nPeriCount--;
             for(i=item;i<(int)m_nPeriCount;i++)
             	m_nPeri[i]=m_nPeri[i+1];
            nT=(int*)m_nPeri;
            break;           
        case WID_BROWSE:
             m_nBrowseCount--;
             for(i=item;i<(int)m_nBrowseCount;i++)
             	m_nBrowse[i]=m_nBrowse[i+1];
            nT=(int*)m_nBrowse;
            break;                  

    	}
  if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT)))     	
	for(i=0;i<m_nCount;i++)
	    if(nT[i]==BTN_SRCHCOM) 
	 	{
	 		AddCombo(i);
	 		break;      
	 	}	
   
    Invalidate(); 
    UpdateWindow();
    return 1;
}

///////////////////////////////////////////////
//                                           //
// This routine is added by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

BOOL CSuperToolBar::InsertButton(int item,int idleitem,int att)
{
	DWORD dwStyle=GetStyle();
    if(m_nCount>=MAX_BUTTON_NUM) return 0;
    
    if(m_isCmbSrch&&idleitem!=-1&&buttons[idleitem]==IDC_SRCHCOMBO) 
       return 0; 
//modified 8/8/96
    else if( (m_isCmbSrch&&idleitem!=-1&&buttons[idleitem]!=IDC_SRCHCOMBO)
            ||(m_isCmbSrch&&idleitem==-1) )
       Del();
//    else if(!m_isCmbSrch&&idleitem!=-1&&buttons[idleitem]==IDC_SRCHCOMBO) 
//        m_isCmbSrch=1;  
    CCONTROL::InsertButton(item,idleitem,att);
    int *nT;
    int i;
  	switch(nActiveId) {
        case WID_TRACE:
             m_nTraceCount++;
             for(i=(int)m_nTraceCount-1;i>item+1;i--)
             	m_nTrace[i]=m_nTrace[i-1];
             m_nTrace[item+1]=idleitem;
             nT=(int*)m_nTrace;
            break;
        case WID_SHELL:
             m_nShellCount++;
             for(i=(int)m_nShellCount-1;i>item+1;i--)
             	m_nShell[i]=m_nShell[i-1];
             m_nShell[item+1]=idleitem;
             nT=(int*)m_nShell;
            break;
        case WID_MAIN:
             m_nMainCount++;
             for(i=(int)m_nMainCount-1;i>item+1;i--)
             	m_nMain[i]=m_nMain[i-1];
             m_nMain[item+1]=idleitem;
             nT=(int*)m_nMain;
            break;


        case WID_SOURCE:
             m_nSourceCount++;
             for(i=(int)m_nSourceCount-1;i>item+1;i--)
             	m_nSource[i]=m_nSource[i-1];
             m_nSource[item+1]=idleitem;
            nT=(int*)m_nSource;
            break;
        case WID_VARIABLE:
             m_nVarCount++;
             for(i=(int)m_nVarCount-1;i>item+1;i--)
             	m_nVar[i]=m_nVar[i-1];
             m_nVar[item+1]=idleitem;       
            nT=(int*)m_nVar;
            break;
        case WID_STACK:
             m_nStackCount++;
             for(i=(int)m_nStackCount-1;i>item+1;i--)
             	m_nStack[i]=m_nStack[i-1];
             m_nStack[item+1]=idleitem;            
            nT=(int*)m_nStack;
            break;            
        case WID_CPU:
	         m_nCPUCount++;
             for(i=(int)m_nCPUCount-1;i>item+1;i--)
             	m_nCPU[i]=m_nCPU[i-1];
             m_nCPU[item+1]=idleitem;
             nT=(int*)m_nCPU;
            break;          
        case WID_MEMORY:
             m_nMemCount++;
             for(i=(int)m_nMemCount-1;i>item+1;i--)
             	m_nMem[i]=m_nMem[i-1];
             m_nMem[item+1]=idleitem;
             nT=(int*)m_nMem;
            break;
        case WID_BMEM:
             m_nBMemCount++;
             for(i=(int)m_nBMemCount-1;i>item+1;i--)
             	m_nBMem[i]=m_nBMem[i-1];
             m_nBMem[item+1]=idleitem;
             nT=(int*)m_nBMem;
            break;             
        case WID_PERI:
             m_nPeriCount++;
             for(i=(int)m_nPeriCount-1;i>item+1;i--)
             	m_nPeri[i]=m_nPeri[i-1];
             m_nPeri[item+1]=idleitem;
             nT=(int*)m_nPeri;
            break;  
       case WID_BROWSE:
             m_nBrowseCount++;
             for(i=(int)m_nBrowseCount-1;i>item+1;i--)
             	m_nBrowse[i]=m_nBrowse[i-1];
             m_nBrowse[item+1]=idleitem;
             nT=(int*)m_nBrowse;
            break;            
            
     } 
    if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT)))      
	 	for( i=0;i<m_nCount;i++)
	       if(nT[i]==BTN_SRCHCOM) 
	 	   {
	 			AddCombo(i);
	 			break;      
	 	   }	
     Invalidate(); 
     UpdateWindow();
	 return 1;
}

///////////////////////////////////////////////
//                                           //
// This routine is added by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////


BOOL CSuperToolBar::ReplaceButton(int item,int idleitem)
{
    DWORD dwStyle=GetStyle();
    CCONTROL::ReplaceButton(item,idleitem);
    if(m_isCmbSrch){
    	Del();
    }	
        int* nT ;
    	switch(nActiveId) {
        case WID_TRACE:         
             m_nTrace[item]=idleitem;
             nT=(int*)m_nTrace;
            break;
        case WID_SOURCE:
            m_nSource[item]=idleitem;
            nT=(int*)m_nSource;
            break;
        case WID_VARIABLE:
            m_nVar[item]=idleitem;
            nT=(int*)m_nVar;
            break;
        case WID_STACK:
            m_nStack[item]=idleitem;
            nT=(int*)m_nStack;
            break;
        case WID_CPU:
            m_nCPU[item]=idleitem;
            nT=(int*)m_nCPU;
            break; 
		case WID_MAIN:
            m_nMain[item]=idleitem;
            nT=(int*)m_nMain;
            break;                               
        case WID_MEMORY:
            m_nMem[item]=idleitem;
            nT=(int*)m_nMem;
            break;
        case WID_BMEM:
            m_nBMem[item]=idleitem;
            nT=(int*)m_nBMem;
            break;             
        case WID_PERI:
            m_nPeri[item]=idleitem;
            nT=(int*)m_nPeri;
            break;
        case WID_SHELL:
            m_nShell[item]=idleitem;
            nT=(int*)m_nShell;
            break;       
        case WID_BROWSE:
            m_nBrowse[item]=idleitem;
            nT=(int*)m_nBrowse;
            break;            
    	}
	 ASSERT(nT!=NULL);
  if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT)))      	 
	 for(int i=0;i<m_nCount;i++)
	    if(nT[i]==BTN_SRCHCOM) 
	 	{
	 		AddCombo(i);
	 		break;      
	 	}	
     Invalidate(); 
     UpdateWindow(); 
	 return 1;
}
             
             
/////////////////////////////////////////////////////////////////////////////
//
//  Name:   CSuperToolBar::CSuperToolBar
//
//  Description: Constructor of the class CSuperToolBar
//
//  Input:  None
//
//  Output: None
//
//  Return: None
//
/////////////////////////////////////////////////////////////////////////////
CSuperToolBar::CSuperToolBar()
{
	m_isCmbSrch=0;
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   CSuperToolBar::~CSuperToolBar
//          +
//  Description: Destructor of the class CSuperToolBar
//
//  Input:  None
//
//  Output: None
//
//  Return: None
//
/////////////////////////////////////////////////////////////////////////////
CSuperToolBar::~CSuperToolBar()
{                           
//  m_pTip->DestroyWindow();
//  delete m_pTip;
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   CSuperToolBar::CreateBar
//
//  Description: Create the tool bar 
//
//  Input:  
//      pOwner -- the owner of the toolbar
//
//  Output: None
//
//  Return: TRUE -- Success
//          FALSE -- Failed
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::CreateBar(CWnd* pOwner)
{           
    if(!Create(pOwner,TWS_TIPS) || 
       !LoadBitmap(IDR_MAINFRAME) || 
       !NewMain())
    {
        TRACE("Failed to create button bar\n");
        return FALSE;
    }             
    
//    m_pTip->Create("MHTIP.VBX;MhTip;MhTip1", NULL, CRect(0, 0, 50, 20),
//      this, IDC_MHTIP1);
    return TRUE;
}                                        

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   CSuperToolBar::Del
//
//  Description: Delete controls when the toolbar inactive
//
//  Input:  None
//
//  Output: None
//
//  Return: None
//
/////////////////////////////////////////////////////////////////////////////
void CSuperToolBar::Del(void)
{                        
    if(m_isCmbSrch){
    	m_isCmbSrch = FALSE;
        m_cmbSrch.DestroyWindow();
    }
/*    m_isCmbSrch = FALSE;
    switch(nActiveId) {
        case WID_TRACE:
            m_cmbSrch.DestroyWindow();
            break;
        case WID_BROWSE:
            m_cmbSrch.DestroyWindow();
            break;
        case WID_SOURCE:
            m_cmbSrch.DestroyWindow();
            break;
        case WID_VARIABLE:
            m_cmbSrch.DestroyWindow();
            break;
        case WID_STACK:
            m_cmbSrch.DestroyWindow();
            break;
    }
*/
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   CSuperToolBar::NewMain
//
//  Description: Make toolbar of main window active
//
//  Input:  None
//
//  Output: None
//
//  Return: TRUE -- Success
//          FALSE -- Failed
//
/////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////


BOOL CSuperToolBar::NewMain(void)//modify by carl all SetButtonInfo func
{
//mark by chris, 01/03/97
//  if(m_nMainCount==0){  
	if(1){
    BOOL is = SetButtons(NULL, 21);
    if(is) {    
        SetButtonInfo(0, ID_FILE_BROWSEMODULE, TBBS_BUTTON, BTN_MODULE);
        m_nMain[0]=BTN_MODULE;
        SetButtonInfo(1, ID_FILE_LOAD, TBBS_BUTTON, BTN_LOAD);
        m_nMain[1]=BTN_LOAD;
        SetButtonInfo(2, ID_SEPARATOR, TBBS_SEPARATOR, 6);
        m_nMain[2]=-1;

        SetButtonInfo(3, ID_MAP, TBBS_BUTTON, BTN_MAP);
        m_nMain[3]=BTN_MAP;
        SetButtonInfo(4, ID_SEPARATOR, TBBS_SEPARATOR, 6);
        m_nMain[4]=-1;

        SetButtonInfo(5, ID_RUN_RESET, TBBS_BUTTON, BTN_RESET );
        m_nMain[5]=BTN_RESET;    
        SetButtonInfo(6, ID_RUN_RESTART, TBBS_BUTTON, BTN_RESTART );
        m_nMain[6]=BTN_RESTART;    
        
        SetButtonInfo(7, ID_RUN_BREAKPOINT, TBBS_BUTTON, BTN_BP);
        m_nMain[7]=BTN_BP;
        SetButtonInfo(8, ID_RUN_GO, TBBS_BUTTON, BTN_GO);
        m_nMain[8]=BTN_GO;
        SetButtonInfo(9, ID_RUN_GORUN, TBBS_BUTTON, BTN_GORUN);
        m_nMain[9]=BTN_GORUN;
        SetButtonInfo(10, ID_RUN_HALT, TBBS_BUTTON, BTN_HALT);
        m_nMain[10]=BTN_HALT;
        SetButtonInfo(11, ID_SEPARATOR, TBBS_SEPARATOR, 6);
  		m_nMain[11]=-1;

        SetButtonInfo(12, ID_RUN_STEPINTO, TBBS_BUTTON, BTN_STEPI);
        m_nMain[12]=BTN_STEPI;
        SetButtonInfo(13, ID_RUN_STEPOVER, TBBS_BUTTON, BTN_STEPO);
        m_nMain[13]=BTN_STEPO;
        SetButtonInfo(14, ID_RUN_GOUNTILRETURN, TBBS_BUTTON, BTN_GO_OVER);
        m_nMain[14]=BTN_GO_OVER;
        SetButtonInfo(15, ID_SEPARATOR, TBBS_SEPARATOR, 6);
        m_nMain[15]=-1;
        SetButtonInfo(16, ID_GOTO_SHELL, TBBS_BUTTON, BTN_SHELL);
        m_nMain[16]=BTN_SHELL;
        SetButtonInfo(17, ID_TOGGLE_TRACE, TBBS_BUTTON, BTN_TRACE_TOGGLE);
		m_nMain[17]=BTN_TRACE_TOGGLE;
        SetButtonInfo(18, ID_GROUP_SPA, TBBS_BUTTON, BTN_SPA);
		m_nMain[18]=BTN_SPA;
        SetButtonInfo(19, ID_SEPARATOR, TBBS_SEPARATOR, 6);
        m_nMain[19]=-1;

        SetButtonInfo(20, ID_HELP, TBBS_BUTTON, BTN_HELP);
		m_nMain[20]=BTN_HELP;   
		m_nMainCount=m_nCount;
	   }
	   else return FALSE;
	 }else  SetWinButtons(WID_MAIN);	
        
     nActiveId = WID_MAIN;
     Invalidate();
     return TRUE;
}
///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: modify by chris, 4/15/97, to fix bug(cannot customize forerver
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewSource(void)//modify by carl all SetButtonInfo func
{
DWORD dwStyle=GetStyle();

	if(m_nSourceCount==0)
	{
		BOOL is = SetButtons(NULL, 29);
		if(is) 
		{
			SetButtonInfo(0, ID_FILE_BROWSEMODULE, TBBS_BUTTON, BTN_MODULE);
			m_nSource[0]=BTN_MODULE;
			SetButtonInfo(1, ID_FILE_PREVMODULE, TBBS_BUTTON, BTN_PREV_MODULE); 
			m_nSource[1]=BTN_PREV_MODULE;
			SetButtonInfo(2, ID_FILE_NEXTMODULE, TBBS_BUTTON, BTN_NEXT_MODULE);
			m_nSource[2]=BTN_NEXT_MODULE;
			SetButtonInfo(3, ID_FILE_LOAD, TBBS_BUTTON, BTN_LOAD);
			m_nSource[3]=BTN_LOAD;
			SetButtonInfo(4, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nSource[4]=-1;
			if(dwStyle&(CBRS_LEFT|CBRS_RIGHT))		                  
				SetButtonInfo(5, IDC_SRCHCOMBO, TBBS_SEPARATOR, 6);
			else
				SetButtonInfo(5, IDC_SRCHCOMBO, TBBS_SEPARATOR, 80);
			m_nSource[5]=BTN_SRCHCOM;
			SetButtonInfo(6, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nSource[6]=-1;
			SetButtonInfo(7, ID_EDIT_SEARCHNEXT, TBBS_BUTTON, BTN_SEARCH);
			m_nSource[7]=BTN_SEARCH;
			SetButtonInfo(8, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nSource[8]=-1;
			SetButtonInfo(9, ID_VIEW_SOURCEONLY, TBBS_BUTTON, BTN_SRC_MODE);
			m_nSource[9]=BTN_SRC_MODE;
			SetButtonInfo(10, ID_VIEW_MIXED, TBBS_BUTTON, BTN_MIX_MODE );
			m_nSource[10]=BTN_MIX_MODE;
			SetButtonInfo(11, ID_VIEW_ASSEMBLE, TBBS_BUTTON, BTN_ASSEMBLE_MODE );
			m_nSource[11]=BTN_ASSEMBLE_MODE;
			SetButtonInfo(12, ID_MAP, TBBS_BUTTON, BTN_MAP);
			m_nSource[12]=BTN_MAP;
			SetButtonInfo(13, ID_RUN_RESET, TBBS_BUTTON, BTN_RESET); 
			m_nSource[13]=BTN_RESET;
			SetButtonInfo(14, ID_RUN_RESTART, TBBS_BUTTON, BTN_RESTART );
			m_nSource[14]=BTN_RESTART;
			SetButtonInfo(15, ID_RUN_BREAKPOINT, TBBS_BUTTON, BTN_BP);
			m_nSource[15]=BTN_BP;
			SetButtonInfo(16, ID_RUN_GO, TBBS_BUTTON, BTN_GO);
			m_nSource[16]=BTN_GO;
			        
			SetButtonInfo(17, ID_RUN_GORUN, TBBS_BUTTON, BTN_GORUN);
			m_nSource[17]=BTN_GORUN;
			SetButtonInfo(18, ID_RUN_HALT, TBBS_BUTTON, BTN_HALT);
			m_nSource[18]=BTN_HALT;
			SetButtonInfo(19, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nSource[19]=-1;
			SetButtonInfo(20, ID_RUN_STEPINTO, TBBS_BUTTON, BTN_STEPI);
			m_nSource[20]=BTN_STEPI;
			SetButtonInfo(21, ID_RUN_STEPOVER, TBBS_BUTTON, BTN_STEPO);
			m_nSource[21]=BTN_STEPO;
			SetButtonInfo(22, ID_RUN_GOUNTILRETURN, TBBS_BUTTON, BTN_GO_OVER);
			m_nSource[22]=BTN_GO_OVER;
			SetButtonInfo(23, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nSource[23]=-1;
			SetButtonInfo(24, ID_GOTO_SHELL, TBBS_BUTTON, BTN_SHELL);
			m_nSource[24]=BTN_SHELL;
			SetButtonInfo(25, ID_TOGGLE_TRACE, TBBS_BUTTON, BTN_TRACE_TOGGLE);
			m_nSource[25]=BTN_TRACE_TOGGLE;
			SetButtonInfo(26, ID_GROUP_SPA, TBBS_BUTTON, BTN_SPA);
			m_nSource[26]=BTN_SPA;
			SetButtonInfo(27, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nSource[27]=-1;
			SetButtonInfo(28, ID_HELP, TBBS_BUTTON, BTN_HELP);
			m_nSource[28]=BTN_HELP; 
			m_nSourceCount=m_nCount;
		}
		else
			return 0;
	}
	else
		SetWinButtons(WID_SOURCE);

	if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT)))
		for(int i=0;i<m_nCount;i++)
			if(m_nSource[i]==BTN_SRCHCOM) 
			{
				AddCombo(i);
				break;      
			}	
	nActiveId = WID_SOURCE;
	Invalidate();
	UpdateWindow();
	return TRUE;
}

///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewBrowse(void)//modify by carl all SetButtonInfo func
{                          
DWORD dwStyle=GetStyle();

	if(m_nBrowseCount==0)
	{
		BOOL is = SetButtons(NULL, 29);
		if(is)
		{
			SetButtonInfo(0, ID_FILE_BROWSEMODULE, TBBS_BUTTON, BTN_MODULE);
			m_nBrowse[0]=BTN_MODULE;
			SetButtonInfo(1, ID_FILE_PREVMODULE, TBBS_BUTTON, BTN_PREV_MODULE); 
			m_nBrowse[1]=BTN_PREV_MODULE;
			SetButtonInfo(2, ID_FILE_NEXTMODULE, TBBS_BUTTON, BTN_NEXT_MODULE);
			m_nBrowse[2]=BTN_NEXT_MODULE;
			SetButtonInfo(3, ID_FILE_LOAD, TBBS_BUTTON, BTN_LOAD);
			m_nBrowse[3]=BTN_LOAD;
			SetButtonInfo(4, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nBrowse[4]=-1;   
			if(dwStyle&(CBRS_LEFT|CBRS_RIGHT))		                  
			SetButtonInfo(5, IDC_SRCHCOMBO, TBBS_SEPARATOR, 6);
			else
			SetButtonInfo(5, IDC_SRCHCOMBO, TBBS_SEPARATOR, 80);
			m_nBrowse[5]=BTN_SRCHCOM;
			SetButtonInfo(6, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nBrowse[6]=-1;
			SetButtonInfo(7, ID_EDIT_SEARCHNEXT, TBBS_BUTTON, BTN_SEARCH);
			m_nBrowse[7]=BTN_SEARCH;
			SetButtonInfo(8, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nBrowse[8]=-1;
			SetButtonInfo(9, ID_VIEW_SOURCEONLY, TBBS_BUTTON, BTN_SRC_MODE);
			m_nBrowse[9]=BTN_SRC_MODE;
			SetButtonInfo(10, ID_VIEW_MIXED, TBBS_BUTTON, BTN_MIX_MODE );
			m_nBrowse[10]=BTN_MIX_MODE;
			SetButtonInfo(11, ID_VIEW_ASSEMBLE, TBBS_BUTTON, BTN_ASSEMBLE_MODE );
			m_nBrowse[11]=BTN_ASSEMBLE_MODE;
			SetButtonInfo(12, ID_MAP, TBBS_BUTTON, BTN_MAP);
			m_nBrowse[12]=BTN_MAP;
			SetButtonInfo(13, ID_RUN_RESET, TBBS_BUTTON, BTN_RESET); 
			m_nBrowse[13]=BTN_RESET;
			SetButtonInfo(14, ID_RUN_RESTART, TBBS_BUTTON, BTN_RESTART );
			m_nBrowse[14]=BTN_RESTART;
			SetButtonInfo(15, ID_RUN_BREAKPOINT, TBBS_BUTTON, BTN_BP);
			m_nBrowse[15]=BTN_BP;
			SetButtonInfo(16, ID_RUN_GO, TBBS_BUTTON, BTN_GO);
			m_nBrowse[16]=BTN_GO;
			SetButtonInfo(17, ID_RUN_GORUN, TBBS_BUTTON, BTN_GORUN);
			m_nBrowse[17]=BTN_GORUN;
			SetButtonInfo(18, ID_RUN_HALT, TBBS_BUTTON, BTN_HALT);
			m_nBrowse[18]=BTN_HALT;
			SetButtonInfo(19, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nBrowse[19]=-1;
			SetButtonInfo(20, ID_RUN_STEPINTO, TBBS_BUTTON, BTN_STEPI);
			m_nBrowse[20]=BTN_STEPI;
			SetButtonInfo(21, ID_RUN_STEPOVER, TBBS_BUTTON, BTN_STEPO);
			m_nBrowse[21]=BTN_STEPO;
			SetButtonInfo(22, ID_RUN_GOUNTILRETURN, TBBS_BUTTON, BTN_GO_OVER);
			m_nBrowse[22]=BTN_GO_OVER;
			SetButtonInfo(23, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nBrowse[23]=-1;
			SetButtonInfo(24, ID_GOTO_SHELL, TBBS_BUTTON, BTN_SHELL);
			m_nBrowse[24]=BTN_SHELL;
			SetButtonInfo(25, ID_TOGGLE_TRACE, TBBS_BUTTON, BTN_TRACE_TOGGLE);
			m_nBrowse[25]=BTN_TRACE_TOGGLE;
			SetButtonInfo(26, ID_GROUP_SPA, TBBS_BUTTON, BTN_SPA);
			m_nBrowse[26]=BTN_SPA;
			SetButtonInfo(27, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nBrowse[27]=-1;
			SetButtonInfo(28, ID_HELP, TBBS_BUTTON, BTN_HELP);
			m_nBrowse[28]=BTN_HELP;
			m_nBrowseCount=m_nCount;
		}
		else
			return 0;
	}
	else
	{
		SetWinButtons(WID_BROWSE);
	}
	if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT)))
		for(int i=0;i<m_nCount;i++)
			if(m_nBrowse[i]==BTN_SRCHCOM) 
			{
				AddCombo(i);
				break;      
			}
     Invalidate(); 
     UpdateWindow();
     nActiveId = WID_BROWSE;
     return TRUE;
}

///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewVariable(void)//modify by carl all SetButtonInfo func
{
DWORD dwStyle=GetStyle();

	if(m_nVarCount==0)
	{
		BOOL is = SetButtons(NULL, 26);
		if(is)
		{
			SetButtonInfo(0, ID_FILE_BROWSEMODULE, TBBS_BUTTON, BTN_MODULE);
			m_nVar[0]=BTN_MODULE;
			SetButtonInfo(1, ID_FILE_LOAD, TBBS_BUTTON, BTN_LOAD);
			m_nVar[1]=BTN_LOAD;
			SetButtonInfo(2, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nVar[2]=-1;
			SetButtonInfo(3, ID_RUN_RESET, TBBS_BUTTON, BTN_RESET); 
			m_nVar[3]=BTN_RESET;
			SetButtonInfo(4, ID_RUN_RESTART, TBBS_BUTTON, BTN_RESTART );
			m_nVar[4]=BTN_RESTART;
			SetButtonInfo(5, ID_RUN_BREAKPOINT, TBBS_BUTTON, BTN_BP);
			m_nVar[5]=BTN_BP;
			SetButtonInfo(6, ID_RUN_GO, TBBS_BUTTON, BTN_GO);
			m_nVar[6]=BTN_GO;
			SetButtonInfo(7, ID_RUN_GORUN, TBBS_BUTTON, BTN_GORUN);
			m_nVar[7]=BTN_GORUN;
			SetButtonInfo(8, ID_RUN_HALT, TBBS_BUTTON, BTN_HALT);
			m_nVar[8]=BTN_HALT;
			SetButtonInfo(9, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nVar[9]=-1;
			SetButtonInfo(10, ID_RUN_STEPINTO, TBBS_BUTTON, BTN_STEPI); 
			m_nVar[10]=BTN_STEPI;
			SetButtonInfo(11, ID_RUN_STEPOVER, TBBS_BUTTON, BTN_STEPO);
			m_nVar[11]=BTN_STEPO;
			SetButtonInfo(12, ID_RUN_GOUNTILRETURN, TBBS_BUTTON, BTN_GO_OVER);
			m_nVar[12]=BTN_GO_OVER;
			SetButtonInfo(13, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nVar[13]=-1;
			SetButtonInfo(14, ID_VARIABLE_ADD, TBBS_BUTTON, BTN_ADD_VAR);
			m_nVar[14]=BTN_ADD_VAR;
			SetButtonInfo(15, ID_VARIABLE_DELETE, TBBS_BUTTON, BTN_DEL_VAR); 
			m_nVar[15]=BTN_DEL_VAR;
			SetButtonInfo(16, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nVar[16]=-1;
			if(dwStyle&(CBRS_LEFT|CBRS_RIGHT))		                  
				SetButtonInfo(17, IDC_SRCHCOMBO, TBBS_SEPARATOR, 6);
			else
				SetButtonInfo(17, IDC_SRCHCOMBO, TBBS_SEPARATOR, 80);  
			m_nVar[17]=BTN_SRCHCOM;
			SetButtonInfo(18, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nVar[18]=-1    ;
			SetButtonInfo(19, ID_EDIT_SEARCHNEXT, TBBS_BUTTON, BTN_SEARCH );
			        
			m_nVar[19]=BTN_SEARCH ;
			SetButtonInfo(20, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nVar[20]=-1        ;
			SetButtonInfo(21, ID_GOTO_SHELL, TBBS_BUTTON, BTN_SHELL);
			m_nVar[21]=BTN_SHELL;
			SetButtonInfo(22, ID_TOGGLE_TRACE, TBBS_BUTTON, BTN_TRACE_TOGGLE);
			m_nVar[22]=BTN_TRACE_TOGGLE;
			SetButtonInfo(23, ID_GROUP_SPA, TBBS_BUTTON, BTN_SPA);
			m_nVar[23]=BTN_SPA;
			SetButtonInfo(24, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nVar[24]=-1        ;
			SetButtonInfo(25, ID_HELP, TBBS_BUTTON, BTN_HELP);
			m_nVar[25]=BTN_HELP ;
			m_nVarCount=m_nCount;
		}
		else return 0;
	}
	else
	{
		SetWinButtons(WID_VARIABLE);
	}
	if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT)))		                
		for(int i=0;i<m_nCount;i++)
			if(m_nVar[i]==BTN_SRCHCOM)
			{
				AddCombo(i);
				break;      
			}	
	Invalidate();
	UpdateWindow();     
	nActiveId = WID_VARIABLE;
	return TRUE;
}

///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////

BOOL CSuperToolBar::NewStack(void)
{
DWORD dwStyle=GetStyle();

	if(m_nStackCount==0)
	{
		BOOL is = SetButtons(NULL, 25);
		if(is)
		{
			SetButtonInfo(0, ID_FILE_BROWSEMODULE, TBBS_BUTTON, BTN_MODULE);
			m_nStack[0]=BTN_MODULE;        
			SetButtonInfo(1, ID_FILE_LOAD, TBBS_BUTTON, BTN_LOAD);
			m_nStack[1]=BTN_LOAD;
			SetButtonInfo(2, ID_SEPARATOR, TBBS_SEPARATOR, 6); 
			m_nStack[2]=-1;
			SetButtonInfo(3, ID_RUN_RESET, TBBS_BUTTON, BTN_RESET); 
			m_nStack[3]=BTN_RESET;
			SetButtonInfo(4, ID_RUN_RESTART, TBBS_BUTTON, BTN_RESTART );
			m_nStack[4]=BTN_RESTART;
			SetButtonInfo(5, ID_RUN_BREAKPOINT, TBBS_BUTTON, BTN_BP);
			m_nStack[5]=BTN_BP;
			SetButtonInfo(6, ID_RUN_GO, TBBS_BUTTON, BTN_GO);
			m_nStack[6]=BTN_GO;
			SetButtonInfo(7, ID_RUN_GORUN, TBBS_BUTTON, BTN_GORUN);
			m_nStack[7]=BTN_GORUN;
			SetButtonInfo(8, ID_RUN_HALT, TBBS_BUTTON, BTN_HALT);
			m_nStack[8]=BTN_HALT;
			SetButtonInfo(9, ID_SEPARATOR, TBBS_SEPARATOR, 6); 
			m_nStack[9]=-1;
			SetButtonInfo(10, ID_RUN_STEPINTO, TBBS_BUTTON, BTN_STEPI);
			m_nStack[10]=BTN_STEPI;
			SetButtonInfo(11, ID_RUN_STEPOVER, TBBS_BUTTON, BTN_STEPO);
			m_nStack[11]=BTN_STEPO;
			SetButtonInfo(12, ID_RUN_GOUNTILRETURN, TBBS_BUTTON, BTN_GO_OVER);
			m_nStack[12]=BTN_GO_OVER;
			SetButtonInfo(13, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nStack[13]=-1;
			SetButtonInfo(14, ID_EDIT_SELECTLOCALVARIABLES, TBBS_BUTTON, 
			                    BTN_LOCAL_VAR);
			m_nStack[14]=BTN_LOCAL_VAR;                            
			SetButtonInfo(15, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nStack[15]=-1;
			if(dwStyle&(CBRS_LEFT|CBRS_RIGHT))		               
				SetButtonInfo(16, IDC_SRCHCOMBO, TBBS_SEPARATOR, 6);
			else
				SetButtonInfo(16, IDC_SRCHCOMBO, TBBS_SEPARATOR, 80);
			m_nStack[16]=BTN_SRCHCOM;
			SetButtonInfo(17, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nStack[17]=-1;
			SetButtonInfo(18, ID_EDIT_SEARCHNEXT, TBBS_BUTTON, BTN_SEARCH);
			m_nStack[18]=BTN_SEARCH;
			SetButtonInfo(19, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nStack[19]=-1;
			SetButtonInfo(20, ID_GOTO_SHELL, TBBS_BUTTON, BTN_SHELL);
			m_nStack[20]=BTN_SHELL;
			SetButtonInfo(21, ID_TOGGLE_TRACE, TBBS_BUTTON, BTN_TRACE_TOGGLE);
			m_nStack[21]=BTN_TRACE_TOGGLE;
			SetButtonInfo(22, ID_GROUP_SPA, TBBS_BUTTON, BTN_SPA);
			m_nStack[22]=BTN_SPA;
			SetButtonInfo(23, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nStack[23]=-1;
			SetButtonInfo(24, ID_HELP, TBBS_BUTTON, BTN_HELP);
			m_nStack[24]=BTN_HELP;
			m_nStackCount=m_nCount;
		}
		else return 0;
	}
	else
	{
		SetWinButtons(WID_STACK);
	}
	if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT)))       
		for(int i=0;i<m_nCount;i++)
			if(m_nStack[i]==BTN_SRCHCOM) 
			{
				AddCombo(i);
				break;      
			}
	Invalidate();
	UpdateWindow();
	nActiveId = WID_STACK;
	return TRUE;
}
///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewCpu(void)
{    
	if(m_nCPUCount==0)
	{
		BOOL is = NewMain();
		if(is)
		{
			nActiveId = WID_CPU;
			m_nCPUCount=m_nMainCount;
			for(UINT j=0;j<m_nMainCount;j++)
			m_nCPU[j]=m_nMain[j];
		}
		return  is;
	}
	else
	{
		SetWinButtons(WID_CPU);
		nActiveId = WID_CPU;
		Invalidate();
		UpdateWindow();
		return 1;
	}
}
///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewPeri(void)
{
   if(m_nPeriCount==0){
    	BOOL is = NewMain();
    	if(is)  {
    		nActiveId = WID_PERI;
        	m_nPeriCount=m_nMainCount;
        	for(UINT j=0;j<m_nMainCount;j++)
          	m_nPeri[j]=m_nMain[j];
    	}
    	return  is;
    }
    else
    {
     	SetWinButtons(WID_PERI);
        nActiveId = WID_PERI;
        Invalidate();
        UpdateWindow();
        return 1;
    }
}
///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewMemory(void)
{
    if(m_nMemCount==0){
    	BOOL is = NewMain();
    	if(is)  {
    		nActiveId = WID_MEMORY;
        	m_nMemCount=m_nMainCount;
        	for(UINT j=0;j<m_nMainCount;j++)
          	m_nMem[j]=m_nMain[j];
    	}
    	return  is;
    }
    else
    {
     	SetWinButtons(WID_MEMORY);
        nActiveId = WID_MEMORY;
        Invalidate();
        UpdateWindow();
        return 1;
    }
}
///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewShell(void)
{
    if(m_nShellCount==0){
    	BOOL is = NewMain();
    	if(is)  {
    		nActiveId = WID_SHELL;
        	m_nShellCount=m_nMainCount;
        	for(UINT j=0;j<m_nMainCount;j++)
          	m_nShell[j]=m_nMain[j];
    	}
    	return  is;
    }
    else
    {
     	SetWinButtons(WID_SHELL);
        nActiveId = WID_SHELL;
        Invalidate();
        UpdateWindow();
        return 1;
    }
}
///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewBMem(void)
{
    if(m_nBMemCount==0){
    BOOL is = NewMain();
    if(is){
      nActiveId = WID_BMEM;
      m_nBMemCount=m_nMainCount;
      for(UINT j=0;j<m_nMainCount;j++)
         m_nBMem[j]=m_nMain[j];
    }     
    return  is;    
    }
    else
    {
        SetWinButtons(WID_BMEM);
        nActiveId = WID_BMEM;
        Invalidate();
        UpdateWindow();
        return 1;
        
    }
}
///////////////////////////////////////////////
//                                           //
// This routine is modified by jerry to support //
// configrable toolbar.                      //
///////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSuperToolBar::NewTrace(void)
{
	if(m_nTraceCount==0)
	{
		BOOL is = SetButtons(NULL, 29);
		if(is)
		{
			SetButtonInfo(0, ID_FILE_BROWSEMODULE, TBBS_BUTTON, BTN_MODULE);
			m_nTrace[0]=BTN_MODULE;
			SetButtonInfo(1, ID_FILE_LOAD, TBBS_BUTTON, BTN_LOAD);
			m_nTrace[1]=BTN_LOAD;
			SetButtonInfo(2, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nTrace[2]=-1;
			SetButtonInfo(3, ID_RUN_RESET, TBBS_BUTTON, BTN_RESET);
			m_nTrace[3]=BTN_RESET;
			SetButtonInfo(4, ID_RUN_RESTART, TBBS_BUTTON, BTN_RESTART );
			m_nTrace[4]=BTN_RESTART;
			SetButtonInfo(5, ID_RUN_BREAKPOINT, TBBS_BUTTON, BTN_BP);
			m_nTrace[5]=BTN_BP;
			SetButtonInfo(6, ID_RUN_GO, TBBS_BUTTON, BTN_GO);
			m_nTrace[6]=BTN_GO;
			SetButtonInfo(7, ID_RUN_GORUN, TBBS_BUTTON, BTN_GORUN);
			m_nTrace[7]=BTN_GORUN;
			SetButtonInfo(8, ID_RUN_HALT, TBBS_BUTTON, BTN_HALT);
			m_nTrace[8]=BTN_HALT;
			SetButtonInfo(9, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nTrace[9]=-1;
			SetButtonInfo(10, ID_RUN_STEPINTO, TBBS_BUTTON, BTN_STEPI);
			m_nTrace[10]=BTN_STEPI;
			SetButtonInfo(11, ID_RUN_STEPOVER, TBBS_BUTTON, BTN_STEPO);
			m_nTrace[11]=BTN_STEPO;
			SetButtonInfo(12, ID_RUN_GOUNTILRETURN, TBBS_BUTTON, BTN_GO_OVER);
			m_nTrace[12]=BTN_GO_OVER;
			SetButtonInfo(13, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nTrace[13]=-1;
			SetButtonInfo(14, ID_TRACE_CLEAR, TBBS_BUTTON, BTN_TRACECLEAR);
			m_nTrace[14]=BTN_TRACECLEAR;
			SetButtonInfo(15, ID_EDIT_GOTOSTARTFRAME, TBBS_BUTTON, BTN_FRAME1);
			m_nTrace[15]=BTN_FRAME1;
			SetButtonInfo(16, ID_EDIT_GOTOENDFRAME, TBBS_BUTTON, BTN_FRAMEn);
			m_nTrace[16]=BTN_FRAMEn;
			SetButtonInfo(17, ID_EDIT_GOTOFRAME, TBBS_BUTTON, BTN_FRAME);
			m_nTrace[17]=BTN_FRAME;
			SetButtonInfo(18, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nTrace[18]=-1;
			SetButtonInfo(19, ID_VIEW_BUS, TBBS_BUTTON, BTN_BUS_MODE);
			m_nTrace[19]=BTN_BUS_MODE;
			SetButtonInfo(20, ID_VIEW_INSTRUCTION, TBBS_BUTTON, BTN_INS_MODE);
			m_nTrace[20]=BTN_INS_MODE;
			SetButtonInfo(21, ID_VIEW_MIXED, TBBS_BUTTON, BTN_TRACE_MIXED);
			m_nTrace[21]=BTN_TRACE_MIXED;
			SetButtonInfo(22, ID_VIEW_SOURCE, TBBS_BUTTON, BTN_LISTSRC);
			m_nTrace[22]=BTN_LISTSRC;
			SetButtonInfo(23, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nTrace[23]=-1;
			SetButtonInfo(24, ID_GOTO_SHELL, TBBS_BUTTON, BTN_SHELL);
			m_nTrace[24]=BTN_SHELL;
			SetButtonInfo(25, ID_TOGGLE_TRACE, TBBS_BUTTON, BTN_TRACE_TOGGLE);
			m_nTrace[25]=BTN_TRACE_TOGGLE;
			SetButtonInfo(26, ID_GROUP_SPA, TBBS_BUTTON, BTN_SPA);
			m_nTrace[26]=BTN_SPA;
			SetButtonInfo(27, ID_SEPARATOR, TBBS_SEPARATOR, 6);
			m_nTrace[27]=-1;
			SetButtonInfo(28, ID_HELP, TBBS_BUTTON, BTN_HELP);
			m_nTrace[28]=BTN_HELP;
			m_nTraceCount=m_nCount;
		}
		else
			return 0;
	}
	else
	{
		SetWinButtons(WID_TRACE);
	}
	Invalidate();
	nActiveId = WID_TRACE;
	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   CSuperToolBar::AddSrchText
//
//  Description: Add search text to the search combobox
//
//  Input:  
//      str -- the search text
//
//  Output: None
//
//  Return: None
//
/////////////////////////////////////////////////////////////////////////////
void CSuperToolBar::AddSrchText(const char * str)
{
    if(!m_isCmbSrch)    return;
    CString strTemp;
    if(m_cmbSrch.GetCount()) {
        m_cmbSrch.GetLBText(0, strTemp);
        if(strTemp == str)  return;
    }    
    m_cmbSrch.InsertString(0, str);
    m_cmbSrch.SetCurSel(0);
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
CString CSuperToolBar::GetSrchText(void)
{
    ASSERT(nActiveId == WID_SOURCE || nActiveId == WID_TRACE);
    
    if(!m_isCmbSrch)    return  "";
    int nSel = m_cmbSrch.GetCurSel();
    if(nSel == CB_ERR)  return  "";
    CString str;
    m_cmbSrch.GetLBText(nSel, str);
    return  str;
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
CString CSuperToolBar::GetSrchEditText(void)
{                
    CString str;
    m_cmbSrch.GetWindowText(str);
    return  str;
}

BEGIN_MESSAGE_MAP(CSuperToolBar, CCONTROL)
    //{{AFX_MSG_MAP(CSuperToolBar)
	ON_WM_LBUTTONUP()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//  ON_VBXEVENT(VBN_SETCAPTION, IDC_MHTIP1, OnSetcaptionMhtip1)

/////////////////////////////////////////////////////////////////////////////
// CSuperToolBar message handlers
/*void CSuperToolBar::OnSetcaptionMhtip1(UINT, int, CWnd*, LPVOID lpParams)
{
    
    char StrBuff[256];
    int StrBuffLen;
        
    StrBuffLen = ::GetWindowText((HWND)AFX_NUM_EVENTPARAMINDEX(int, lpParams, 3), StrBuff, 255);
    
    m_pTip->SetStrProperty("Caption", "ifuodiufg"StrBuff);
    m_pTip->ShowWindow(SW_SHOW);    
}
*/

void CSuperToolBar::OnLButtonUp(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
//	BOOL b=m_bCanMove;
	CCONTROL::OnLButtonUp(nFlags, point);
    AdjustCombox();
}                                 	


BOOL CSuperToolBar::AdjustCombox()
{
    DWORD dwStyle=GetStyle();
    if(m_nCount<=1) return 0;
    int* nT;
    int i;
    	switch(nActiveId) {
        case WID_TRACE:
             nT=(int*)m_nTrace;
             break;
        case WID_SOURCE:
            nT=(int*)m_nSource;
            break;
        case WID_VARIABLE:
            nT=(int*)m_nVar;
            break;
        case WID_STACK:
            nT=(int*)m_nStack;
            break;
        case WID_MAIN:
            nT=(int*)m_nMain;
            break;
        case WID_CPU:
            nT=(int*)m_nCPU;
            break;
        case WID_SHELL:
            nT=(int*)m_nShell;
            break;
        case WID_MEMORY:
            nT=(int*)m_nMem;
            break;
        case WID_BMEM:
            nT=(int*)m_nBMem;
            break;
        case WID_PERI:
            nT=(int*)m_nPeri;
            break;           
        case WID_BROWSE:
            nT=(int*)m_nBrowse;
            break;                  

    	}
  if(!(dwStyle&(CBRS_LEFT|CBRS_RIGHT))) 
  { if(!m_isCmbSrch)    	
	for(i=0;i<m_nCount;i++)
	    if(nT[i]==BTN_SRCHCOM) 
	 	{
	 		AddCombo(i);
	 		break;      
	 	}	
  }
  else
  {
  	if(m_isCmbSrch)
		Del();
  }		  	    
  Invalidate(); 
  UpdateWindow();
   return 1;
}
