Ejemplo n.º 1
0
int KFuncTable::DefPara(const char * paratype, const char *name)
{
    if ( m_parano > MAX_PARA )
    {
        assert(0);
        return -1;
    }
    
    if ( (m_lastmodule<0) || (m_lastfunc<0) )
        return -1;
    
    m_func[m_lastfunc].f_parano ++;        
    
	int len = strlen(paratype);
	const char * pSpace = strchr(paratype, ' ');
	
	if ( pSpace )
		len = (int) pSpace - (int) paratype;

	char temp[64];

	assert(64>len);
	memcpy(temp, paratype, len);
	temp[len] = 0;

    m_para[m_parano].p_type = AddAtom(temp);
    m_para[m_parano].p_name = AddAtom(name);    
    
    return m_parano ++; 
}
Ejemplo n.º 2
0
long EXPORT EditLBProc(HWND hWnd, WORD wMsg, WORD wParam, long lParam)
{
    switch (wMsg) {
    case WM_GETDLGCODE:
        return DLGC_WANTALLKEYS;

    case WM_KEYDOWN:
        if (wParam == VK_CONTROL)
            control = TRUE;
        break;

    case WM_KEYUP:
        if (wParam == VK_CONTROL)
            control = FALSE;
        break;

    case WM_CHAR:
        if (wParam == VK_TAB)
        {
            ATOM aType = AddAtom("ItemType");
            WORD wType = GetProp(hWnd, (LPSTR) aType);

            SetFocus(GetDlgItem(GetParent(hWnd),
                                wType == SLOT ? IDDMETHODS : IDDSLOTS));
            return TRUE;
        }
        else if (control && handle_edit_keys(hWnd, wParam))
            return TRUE;
        break;

    case WM_VSCROLL:
        if (GetFocus() != hWnd)
            SetFocus(hWnd);
        break;

    case WM_KILLFOCUS:
    {
        ATOM aSel = AddAtom("LastSel");
        int iSel = SendMessage(hWnd, LB_GETCURSEL, 0, 0L);

        SetProp(hWnd, (LPSTR) aSel, iSel);
        SendMessage(hWnd, LB_SETCURSEL, -1, 0L);
        break;
    }

    case WM_SETFOCUS:
    {
        ATOM aSel = AddAtom("LastSel");
        ATOM aFocus = AddAtom("Focus");
        int iSel = GetProp(hWnd, (LPSTR) aSel);

        SendMessage(hWnd, LB_SETCURSEL, iSel != LB_ERR ? iSel : 0, 0L);
        SetProp(GetParent(hWnd), (LPSTR) aFocus, hWnd);
        break;
    }
    }

    return CallWindowProc(lpOrigLBProc, hWnd, wMsg, wParam, lParam);
}
int main (int argc, char **argv)
{
    GenList A, a, b;

    int p;

    Initialize (&A);
    Initialize (&a);
    Initialize (&b);

    AddAtom (2, 0, &a);
    AddAtom (3, 1, &a);
    AddAtom (5, 2, &a);
    
    AddAtom (4, 0, &b);
    AddAtom (6, 1, &b);
    AddAtom (7, 2, &b);
    AddAtom (8, 3, &b);
    
    //Append (&a, &b);

    AddList (&b, 0, &A);
    AddAtom (4, 0, &A);
    AddAtom (6, 1, &A);
    //AddList (&b, 1, &A);
    //AddAtom (10, 2, &A);

    Traverse(&A, print, PrintLength);
}
Ejemplo n.º 4
0
void MP4Track::UpdateSyncSamples(MP4SampleId sampleId, bool isSyncSample)
{
	if (isSyncSample) {
		// if stss atom exists, add entry
		if (m_pStssCountProperty) {
			m_pStssSampleProperty->AddValue(sampleId);
			m_pStssCountProperty->IncrementValue();
		} // else nothing to do (yet)

	} else { // !isSyncSample
		// if stss atom doesn't exist, create one
		if (m_pStssCountProperty == NULL) {

			MP4Atom* pStssAtom = AddAtom("trak.mdia.minf.stbl", "stss");

			pStssAtom->FindProperty(
				"stss.entryCount",
				(MP4Property**)&m_pStssCountProperty);

			pStssAtom->FindProperty(
				"stss.entries.sampleNumber",
				(MP4Property**)&m_pStssSampleProperty);

			// set values for all samples that came before this one
			for (MP4SampleId sid = 1; sid < sampleId; sid++) {
				m_pStssSampleProperty->AddValue(sid);
				m_pStssCountProperty->IncrementValue();
			}
		} // else nothing to do
	}
}
Ejemplo n.º 5
0
TSymbol TSymbolTable::NewRule(string Name)
    {
    auto Rule   = unique_ptr<TSymbolAtom>{make_unique<TSymbolRule>(Name)};
    auto Result = AddAtom(std::move(Rule), Rules);

    return Result;
    }
Ejemplo n.º 6
0
SHOTID CParser::MakeShotID( LPSTR lpString, BOOL bDupCheck )
/***********************************************************************/
{
	ATOM atom;
	 
	if ( !lstrcmpi( lpString, "/prev" ) )
		return( SHOT_PREV );
	if ( !lstrcmpi( lpString, "/prev2" ) )
		return( SHOT_PREV2 );
	if ( !lstrcmpi( lpString, "/next" ) )
		return( SHOT_NEXT );
	if ( !lstrcmpi( lpString, "/test" ) )
		return( SHOT_TEST );
	if ( !lstrcmpi( lpString, "/stop" ) )
		return( SHOT_STOP );
	if ( !lstrcmpi( lpString, "/this" ) )
		return( SHOT_THIS );
	if ( !lstrcmpi( lpString, "/continue" ) )
		return( SHOT_CONT );
		
	if ( atom = FindAtom(lpString) )
	{
		if ( bDupCheck )
			Debug("Duplicate shot id '%s'", lpString);
		return( atom );
	}
	return( (SHOTID)AddAtom(lpString) );
}
Ejemplo n.º 7
0
TSymbol TSymbolTable::NewNonterminal(TTokenIndex Index)
    {
    DUMPVERBOSE("NewNonterminal(TokenIndex=%d)\n", (int)Index);
    auto NonTerminal    = unique_ptr<TSymbolAtom>{make_unique<TSymbolNonTerminal>(Index)};
    auto Result         = AddAtom(std::move(NonTerminal), NonTerminals);

    return Result;
    }
Ejemplo n.º 8
0
void MP4Track::UpdateRenderingOffsets(MP4SampleId sampleId, 
	MP4Duration renderingOffset)
{
	// if ctts atom doesn't exist
	if (m_pCttsCountProperty == NULL) {

		// no rendering offset, so nothing to do
		if (renderingOffset == 0) {
			return;
		}

		// else create a ctts atom
		MP4Atom* pCttsAtom = AddAtom("trak.mdia.minf.stbl", "ctts");

		// and get handles on the properties
		pCttsAtom->FindProperty(
			"ctts.entryCount",
			(MP4Property**)&m_pCttsCountProperty);

		pCttsAtom->FindProperty(
			"ctts.entries.sampleCount",
			(MP4Property**)&m_pCttsSampleCountProperty);

		pCttsAtom->FindProperty(
			"ctts.entries.sampleOffset",
			(MP4Property**)&m_pCttsSampleOffsetProperty);

		// if this is not the first sample
		if (sampleId > 1) {
			// add a ctts entry for all previous samples
			// with rendering offset equal to zero
			m_pCttsSampleCountProperty->AddValue(sampleId - 1);
			m_pCttsSampleOffsetProperty->AddValue(0);
			m_pCttsCountProperty->IncrementValue();;
		}
	}

	// ctts atom exists (now)

	u_int32_t numCtts = m_pCttsCountProperty->GetValue();

	// if renderingOffset == renderingOffset of last entry
	if (numCtts && renderingOffset
	   == m_pCttsSampleOffsetProperty->GetValue(numCtts-1)) {

		// increment last entry sampleCount
		m_pCttsSampleCountProperty->IncrementValue(1, numCtts-1);

	} else {
		// add ctts entry, sampleCount = 1, sampleOffset = renderingOffset
		m_pCttsSampleCountProperty->AddValue(1);
		m_pCttsSampleOffsetProperty->AddValue(renderingOffset);
		m_pCttsCountProperty->IncrementValue();
	}
}
Ejemplo n.º 9
0
static void SubClassListBoxes(HWND hWnd, WORD wL1, WORD wL2)
{
    HWND hCtl1 = GetDlgItem(hWnd, wL1);
    HWND hCtl2 = GetDlgItem(hWnd, wL2);
    ATOM aType = AddAtom("ItemType");
    ATOM aSel = AddAtom("LastSel");
    ATOM aFocus = AddAtom("Focus");

    if (!lpOrigLBProc)
        lpOrigLBProc = (FARPROC) GetWindowLong(hCtl1, GWL_WNDPROC);

    control = FALSE;
    SetProp(hCtl1, (LPSTR) aType, SLOT);
    SetProp(hCtl2, (LPSTR) aType, METHOD);
    SetProp(hCtl1, (LPSTR) aSel, LB_ERR);
    SetProp(hCtl2, (LPSTR) aSel, LB_ERR);
    SetProp(hWnd, (LPSTR) aFocus, hCtl1);
    SetWindowLong(hCtl1, GWL_WNDPROC, (long) EditLBProc);
    SetWindowLong(hCtl2, GWL_WNDPROC, (long) EditLBProc);
}
Ejemplo n.º 10
0
Symbol *UniqueSymbol(Scope *fScope, Type *fType, symbolkind kind)
{
    static int nextTmp = 0;
    static SourceLoc tmpLoc = { 0, 0 };
    char buf[256];
    int atom;
  
    sprintf(buf, "@TMP%d", nextTmp++);
    atom = AddAtom(atable, buf);
    return AddSymbol(&tmpLoc, fScope, atom, fType, kind);
} // UniqueSymbol
Ejemplo n.º 11
0
int KFuncTable::AddFunc(unsigned ord, const char *name, unsigned opt,
                        int     parano,
                        const char * paratype,
						int     kind,
						const void *  oldaddr)
{
    if ( (m_funcno > MAX_FUNC) || (m_lastmodule<0) )
    {
        assert(0);
        m_lastfunc = -1;

        return -1;
    }

	m_lastfunc = m_funcno ++;

    m_func[m_lastfunc].f_kind       = kind;
    m_func[m_lastfunc].f_module     = m_lastmodule;
    m_func[m_lastfunc].InitStub(m_lastfunc, (FARPROC) ProxyProlog);
	m_func[m_lastfunc].f_methodid   = ord;
    m_func[m_lastfunc].f_name       = AddAtom(name);
    m_func[m_lastfunc].f_parano     = 0;
    m_func[m_lastfunc].f_firstpara  = m_parano;
    m_func[m_lastfunc].f_class      = opt;
    m_func[m_lastfunc].f_hooked     = FALSE;

    m_func[m_lastfunc].f_totaltime  = 0;
    m_func[m_lastfunc].f_callno     = 0;

    for (int i=0; i<parano; i++)
	{
        DefPara(paratype);

		if ( i < (parano-1) )
		{
			paratype = strchr(paratype, ' ') + 1;

			if ( paratype==(const char *) 1 )
			{
				assert(false);

				paratype = NULL;
			}
		}
	}
    
	if ( oldaddr )
		m_func[m_lastfunc].f_oldaddress = (FARPROC) oldaddr;
	else
		m_func[m_lastfunc].f_oldaddress = GetProcAddr(m_lastfunc);
	
    return m_lastfunc;
}
Ejemplo n.º 12
0
static BOOL handle_edit_keys(HWND hWnd, WORD wKey)
{
    WORD wMsg = NULL;
    ATOM aType = AddAtom("ItemType");
    WORD wType = GetProp(hWnd, (LPSTR) aType);
    char c = wKey + 0x40;

    switch (c) {
    case 'D':
        wMsg = wType == SLOT ? IDM_DELETESLOT : IDM_DELETEMETHOD;
        break;
    case 'E':
        wMsg = wType == SLOT ? IDM_EDITSLOT : IDM_EDITMETHOD;
        break;
    case 'G':
    case 'L':
    {
        int iSel = SendMessage(hWnd, LB_GETCURSEL, 0, 0L);

        if (iSel != LB_ERR)
        {
            SendMessage(hWnd, LB_GETTEXT, iSel,
                        (LONG) (LPSTR) return_buffer);

            if (return_buffer[0] == INHERIT_MARK)
            {
                if (c == 'L')
                    wMsg = wType == SLOT ? IDM_MAKELOCALSLOT
                           : IDM_MAKELOCALMETHOD;
                else
                    wMsg = wType == SLOT ? IDM_EDITSLOTOWNER
                           : IDM_EDITMETHODOWNER;
            }
        }
    }
    break;
    case 'N':
        wMsg = wType == SLOT ? IDM_NEWSLOT : IDM_NEWMETHOD;
        break;
    case 'R':
        wMsg = wType == SLOT ? IDM_RENAMESLOT : IDM_RENAMEMETHOD;
        break;
    }

    if (wMsg)
    {
        SendMessage(GetParent(hWnd), WM_COMMAND, wMsg,
                    (long) (LPSTR) return_buffer);
        return TRUE;
    }

    return FALSE;
}
Ejemplo n.º 13
0
/***************************************************************************\
* IncGlobalAtomCount
*
* Description:
* Duplicates an atom.
*
*
* History:
* 1-22-91 sanfords Created.
\***************************************************************************/
LATOM IncLocalAtomCount(
LATOM la)
{
    WCHAR sz[256];

    if (la == 0) {
        return (0);
    }
    if (GetAtomName(la, sz, 256) == 0) {
        RIPMSG0(RIP_WARNING, "IncLocalAtomCount out of memory");
        return (0);
    }
    return ((LATOM)AddAtom(sz));
}
Ejemplo n.º 14
0
/***************************************************************************\
* GlobalToLocalAtom
*
* Description:
* Converts a Global Atom to a Local Atom
*
* History:
* 12-1-91 sanfords Created.
\***************************************************************************/
LATOM GlobalToLocalAtom(
GATOM ga)
{
    WCHAR sz[256];

    if (ga == 0) {
        return (0);
    }
    if (GlobalGetAtomName((ATOM)ga, sz, 256) == 0) {
        RIPMSG0(RIP_WARNING, "GlobalToLocalAtom out of memory");
        return (0);
    }
    return ((LATOM)AddAtom(sz));
}
Ejemplo n.º 15
0
/***************************************************************************\
* MakeInstSpecificAtom
*
* Description:
* Creates a new atom that has hwnd imbeded into it.
*
* History:
* 11-1-91 sanfords Created.
\***************************************************************************/
LATOM MakeInstSpecificAtom(
LATOM la,
HWND hwnd)
{
    WCHAR sz[256];
    LPWSTR psz;

    if (GetAtomName(la, sz, 256) == 0) {
        return (0);
    }
#ifdef UNICODE
    psz = sz + wcslen(sz);
#else
    psz = sz + strlen(sz);
#endif
    wsprintf(psz, TEXT("(%#p)"), hwnd);
    la = AddAtom(sz);
    return (la);
}
Ejemplo n.º 16
0
void MoleculeGroup::AddMolecule(const int molecule_id, const Molecule& molecule,
                            const arma::rowvec& position,
                            const arma::rowvec& velocity)
{
    // TODO(Zak): Allow for polyatomic molecules by randomly
    // orienting around center of mass position.
    // This assert is a placeholder until then.
    assert (molecule.num_atoms() == 1);
    molecule_names_.push_back(molecule.name());
    molecular_index_to_mass_.push_back(molecule.mass());
    molecular_index_to_molecule_.push_back(molecule_id);
    for (std::vector<Atom>::const_iterator i_atom = molecule.begin();
         i_atom != molecule.end(); ++i_atom) {
      AddAtom(*i_atom, molecule_id, position, velocity);
    }
    num_molecules_++;
    com_positions_.insert_rows(com_positions_.n_rows, position);
    com_velocities_.insert_rows(com_velocities_.n_rows, velocity);
}
Ejemplo n.º 17
0
HMODULE
CreateModuleInstance(LPSTR lpszModuleName)
{
    LPMODULEINFO lpModuleTemp;
    HMODULE hModule;

    if (!(lpModuleTemp = CREATEHMODULE(hModule))) {
	return (HMODULE)0;
    }

    lpModuleTemp->lpModuleName = WinMalloc(strlen(lpszModuleName)+1);
    strcpy(lpModuleTemp->lpModuleName, lpszModuleName);

    lpModuleTemp->atmModuleName = AddAtom(lpszModuleName);
    lpModuleTable[++bModIndex] = lpModuleTemp;
    lpModuleTemp->bModIndex = bModIndex;

    lpModuleTemp->ObjHead.lpObjNext = (LPOBJHEAD)lpModuleHead;
    lpModuleHead = (LPOBJHEAD)lpModuleTemp;
    RELEASEMODULEINFO(lpModuleTemp);
    return hModule;
}
Ejemplo n.º 18
0
bool CModelManager::LoadModel(const char *file )
{
	Renderer::IRender *render = GameSystem::SystemGetter::GetRender();
	Scene::ISceneManager * pSceneMgr = GameSystem::SystemGetter::GetSceneManager();

	if( file == NULL )
	{
		return false;
	}
	ATOM atom = AddAtom(file);
	if( m_relation[atom] != NULL )
	{
		return true;
	}

	m_pFileManager->SetCurrentPath( "Model" );
	Renderer::Object::IModel *model;
	model = render->CreateModelFromFile( file );
	m_pFileManager->SetCurrentPath( "Texture" );
	if( model == NULL )
	{
		return false;
	}
	Scene::IModelActor *actor = pSceneMgr->CreateActor( model );
	if( actor == NULL )
	{
		model->Release();
		delete model;
		return false;
	}

	m_relation_to_model[atom] = model;
	m_relation[atom] = actor;

	m_added_models.push_back(atom);

	return true;
}
Ejemplo n.º 19
0
void WinMainCRTStartup(void)
{
	InitAtomTable(0x3001);
	HINSTANCE hModule = GetModuleHandle(0);
	HRSRC hResource = FindResource(hModule, "Files.rc2", RT_RCDATA);
	char *q = (char *)LoadResource(hModule, hResource);
	DWORD n = SizeofResource(hModule, hResource);
	char directive[MAX_PATH];
	char arguments[MAX_PATH];
	char *p = 0;
	char c = '\n';
	while (n)
	{
		switch (c)
		{
		case '(':
			p = arguments;
			break;
		case ')':
			if (*directive == '\n')
				AddAtom(arguments);
			//fall through
		case '\n':
		case '#':
			p = directive;
			//fall through
		default:
			*p++ = c;
			*p = '\0';
			break;
		}
		c = *q++;
		--n;
	}
	DialogBoxParam(hModule, MAKEINTRESOURCE(100), 0, DlgMain, 0);
	ExitProcess(0);
}
Ejemplo n.º 20
0
TValPair::TValPair(const char *p, const char *v)
{
	sName = p;
    Atom = AddAtom(v);
}	//TValPair::TValPair
Ejemplo n.º 21
0
/*********************************************************************
**
**  Adds a new popup menu to the list and to the menu bar. 
**
**  Position is the position of the new menu.  If position is -1,
**  the menu is inserted as the last item.
**
**********************************************************************/
BOOL __far __pascal MyCreatePopup
( 
  HWND hDataWnd, 
  LPSTR lpMenuID,
  LPSTR lpMenuText,
  short int Position
)
{
  HMENUSYS hMenuSys;
  FPMENUSYS MenuSysPtr;

  /* Menu info. to store in menu info. list. */
  MENUINFO MenuInfo;
  
  BOOL bReturn;
  
  BOOL bCreatedBar;
  
  
  /* Get the menu sys. data */
  hMenuSys = (HMENUSYS) WndData( hDataWnd, WDM_GETMENUSYS, 0, NULL );
  
  /* Lock menu sys. data. */
  MenuSysPtr = ( FPMENUSYS ) GlobalLock( hMenuSys );
    
  /* Verify that the new menu's ID string is unique. */
  if( GetMenuInfo( MenuSysPtr->hMenuList, lpMenuID, &MenuInfo ) )
  {
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, MENUALREADYEXISTS, MB_ICONHAND | MB_OK );

    /* Success. */
    return( FALSE );
  }


  /* If there is no menu bar the create one and set it. */
  if( MenuSysPtr->hMenuBar == NULL ) 
  {
    /* Create the menu bar. */
    MenuSysPtr->hMenuBar = CreateMenu();
    bCreatedBar = TRUE;

    /* Error. */
    if( MenuSysPtr->hMenuBar == NULL ) 
    {
      /* Unlock menu sys. data. */
      GlobalUnlock( hMenuSys );
      
      /* Error. */ 
      MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, CANTCREATEMENU, MB_ICONHAND | MB_OK );
  
      /* Success. */
      return( FALSE );
    }

    SetMenu( hDataWnd, MenuSysPtr->hMenuBar );
  }
  else bCreatedBar = FALSE;


  /* Create the popup menu. */
  MenuInfo.hMenu = CreatePopupMenu();
  if( MenuInfo.hMenu == NULL ) 
  {
    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, CANTCREATEMENU, MB_ICONHAND | MB_OK );

    /* If just created the bar. */
    if( bCreatedBar == TRUE )
    {
      /* Remove the bar. */
      SetMenu( hDataWnd, NULL );
      DestroyMenu( MenuSysPtr->hMenuBar );
      MenuSysPtr->hMenuBar = NULL;
    }
    
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Success. */
    return( FALSE );
  }


  /* Add the menu to the menu bar. */
  if( ! InsertMenu( MenuSysPtr->hMenuBar, Position, MF_BYPOSITION | MF_ENABLED | MF_STRING | MF_POPUP, (UINT) MenuInfo.hMenu, lpMenuText) )
  {
    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, CANTCREATEMENU, MB_ICONHAND | MB_OK );

    /* If just created the bar. */
    if( bCreatedBar == TRUE )
    {
      /* Remove the bar. */
      SetMenu( hDataWnd, NULL );
      DestroyMenu( MenuSysPtr->hMenuBar );
      MenuSysPtr->hMenuBar = NULL;
    }
    
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Success. */
    return( FALSE );
  }
  
  /* Init. the other menu info. */
  MenuInfo.MenuID       = AddAtom( lpMenuID );   
  MenuInfo.hParentMenu  = MenuSysPtr->hMenuBar;   
  MenuInfo.hMacroString = NULL;   

  /* Save the menu info. */
  bReturn = SaveMenuInfo( hDataWnd, &(MenuSysPtr)->hMenuList, (FPMENUINFO) &MenuInfo );
  if( bReturn == FALSE )
  {
    /* Remove the new menu from the menu bar. */
    RemoveMenu( MenuSysPtr->hMenuBar, Position, MF_BYPOSITION );
    DestroyMenu( MenuInfo.hMenu );
    
    /* If just created the bar. */
    if( bCreatedBar == TRUE )
    {
      /* Remove the bar. */
      SetMenu( hDataWnd, NULL );
      DestroyMenu( MenuSysPtr->hMenuBar );
      MenuSysPtr->hMenuBar = NULL;
    }
    
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Failure. */
    return FALSE;
  }
      
  /* Show changes. */
  DrawMenuBar( MenuSysPtr->hMenuBar );

  /* Unlock menu sys. data. */
  GlobalUnlock( hMenuSys );
    
  /* Success. */
  return( TRUE );
}
Ejemplo n.º 22
0
int CModelManager::CreateNewModel( LPCTSTR pFileName )
{
	return CreateNewModel( AddAtom(pFileName) );
}
Ejemplo n.º 23
0
Scene::IModelActor *CModelManager::GetCopyModel( char *file_name )
{
	return GetCopyModel( AddAtom(file_name) );
}
Ejemplo n.º 24
0
DWORD
main(
    int argc,
    char *argv[],
    char *envp[]
    )
{
    ATOM Atom1, Atom2, Atom3;
    BOOL Atom1Found, Atom2Found, Atom3Found;
    DWORD Atom1Length, Atom2Length, Atom3Length;
    TCHAR NameBuffer[ 128 ];

    printf( "TATOM: Entering Test Program\n" );

    Atom1 = AddAtom( TEXT("Atom1") );
    Atom2 = AddAtom( TEXT("#4095") );
    Atom3 = AddAtom( (LPTSTR)0x1234 );

    printf( "AddAtom( ""Atom1"" ) == %X\n", Atom1 );
    printf( "AddAtom( ""#4095"" ) == %X\n", Atom2 );
    printf( "AddAtom( 0x1234 ) == %X\n", Atom3 );

    Atom1 = AddAtom( TEXT("Atom1") );
    Atom2 = AddAtom( TEXT("#4095") );
    Atom3 = AddAtom( (LPTSTR)0x1234 );

    printf( "AddAtom( ""Atom1"" ) == %X\n", Atom1 );
    printf( "AddAtom( ""#4095"" ) == %X\n", Atom2 );
    printf( "AddAtom( 0x1234 ) == %X\n", Atom3 );

    assert( Atom1Found = (Atom1 == FindAtom( TEXT("Atom1") )) );
    assert( Atom2Found = (Atom2 == FindAtom( TEXT("#4095") )) );
    assert( Atom3Found = (Atom3 == FindAtom( (LPTSTR)0x1234 )) );

    printf( "FindAtom( ""Atom1"" ) == %X\n", Atom1 );
    printf( "FindAtom( ""#4095"" ) == %X\n", Atom2 );
    printf( "FindAtom( 0x1234 ) == %X\n", Atom3 );

    Atom1Length = GetAtomName( Atom1, NameBuffer, sizeof( NameBuffer ));
#ifdef UNICODE
    printf( "GetAtomName( %X ) == %ws\n", Atom1, NameBuffer );
#else
    printf( "GetAtomName( %X ) == %s\n", Atom1, NameBuffer );
#endif
    Atom2Length = GetAtomName( Atom2, NameBuffer, sizeof( NameBuffer ));
#ifdef UNICODE
    printf( "GetAtomName( %X ) == %ws\n", Atom2, NameBuffer );
#else
    printf( "GetAtomName( %X ) == %s\n", Atom2, NameBuffer );
#endif
    Atom3Length = GetAtomName( Atom3, NameBuffer, sizeof( NameBuffer ));
#ifdef UNICODE
    printf( "GetAtomName( %X ) == %ws\n", Atom3, NameBuffer );
#else
    printf( "GetAtomName( %X ) == %s\n", Atom3, NameBuffer );
#endif

    printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
    printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
    printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
    printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
    printf( "DeleteAtom( %X ) == %X\n", Atom2, DeleteAtom( Atom2 ) );
    printf( "DeleteAtom( %X ) == %X\n", Atom3, DeleteAtom( Atom3 ) );

    Atom1 = GlobalAddAtom( TEXT("Atom1") );
    Atom2 = GlobalAddAtom( TEXT("#4095") );
    Atom3 = GlobalAddAtom( (LPTSTR)0x1234 );

    printf( "GlobalAddAtom( ""Atom1"" ) == %X\n", Atom1 );
    printf( "GlobalAddAtom( ""#4095"" ) == %X\n", Atom2 );
    printf( "GlobalAddAtom( 0x1234 ) == %X\n", Atom3 );

    Atom1 = GlobalAddAtom( TEXT("Atom1") );
    Atom2 = GlobalAddAtom( TEXT("#4095") );
    Atom3 = GlobalAddAtom( (LPTSTR)0x1234 );

    printf( "GlobalAddAtom( ""Atom1"" ) == %X\n", Atom1 );
    printf( "GlobalAddAtom( ""#4095"" ) == %X\n", Atom2 );
    printf( "GlobalAddAtom( 0x1234 ) == %X\n", Atom3 );

    assert( Atom1Found = (Atom1 == GlobalFindAtom( TEXT("Atom1") )) );
    assert( Atom2Found = (Atom2 == GlobalFindAtom( TEXT("#4095") )) );
    assert( Atom3Found = (Atom3 == GlobalFindAtom( (LPTSTR)0x1234 )) );

    printf( "GlobalFindAtom( ""Atom1"" ) == %X\n", Atom1 );
    printf( "GlobalFindAtom( ""#4095"" ) == %X\n", Atom2 );
    printf( "GlobalFindAtom( 0x1234 ) == %X\n", Atom3 );

    Atom1Length = GlobalGetAtomName( Atom1, NameBuffer, sizeof( NameBuffer ));
#ifdef UNICODE
    printf( "GlobalGetAtomName( %X ) == %ws\n", Atom1, NameBuffer );
#else
    printf( "GlobalGetAtomName( %X ) == %s\n", Atom1, NameBuffer );
#endif
    Atom2Length = GlobalGetAtomName( Atom2, NameBuffer, sizeof( NameBuffer ));
#ifdef UNICODE
    printf( "GlobalGetAtomName( %X ) == %ws\n", Atom2, NameBuffer );
#else
    printf( "GlobalGetAtomName( %X ) == %s\n", Atom2, NameBuffer );
#endif
    Atom3Length = GlobalGetAtomName( Atom3, NameBuffer, sizeof( NameBuffer ));
#ifdef UNICODE
    printf( "GlobalGetAtomName( %X ) == %ws\n", Atom3, NameBuffer );
#else
    printf( "GlobalGetAtomName( %X ) == %s\n", Atom3, NameBuffer );
#endif

    printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
    printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
    printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
    printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
    printf( "GlobalDeleteAtom( %X ) == %X\n", Atom2, GlobalDeleteAtom( Atom2 ) );
    printf( "GlobalDeleteAtom( %X ) == %X\n", Atom3, GlobalDeleteAtom( Atom3 ) );

    printf( "TATOM: Exiting Test Program\n" );

    return 0;
}
Ejemplo n.º 25
0
BOOL W_CALLBACK KappaEditObjectDlg(HWND hWndDlg, UINT message,
                                   WPARAM wParam, LPARAM lParam)
{
    short sRes, bRet;
    GLOBALHANDLE hObj = NULL;

    switch (message) {
    case WM_INITDIALOG:
        KppInitDialogFont(hWndDlg, TRUE);
#ifdef CTL3D
        if (Kpp3dCtrls())
            Ctl3dSubclassDlg(hWndDlg, CTL3D_ALL);
#endif
        InitEditDlg(hWndDlg, OBJECT);
        break;

    case WM_CTLCOLOR:
#ifdef CTL3D
        if (Kpp3dCtrls())
            return Ctl3dCtlColorEx(hWndDlg, wParam, lParam);
#endif
        SetBkColor(wParam, GetSysColor(COLOR_WINDOW));
        return KppGetBrush(FALSE);

    case WM_ACTIVATE:
        if (!wParam || wParam == 2)
            hEditActive = NULL;
        else
            hEditActive = hWndDlg;
        break;

    case WM_LBUTTONDOWN:
        if (hEditActive == hWndDlg)
            EditParent(hWndDlg, lParam);
        else
            hEditActive = hWndDlg;
        break;

    case WM_SETFOCUS:
    {
        ATOM aFocus = AddAtom("Focus");
        HWND hFocus = GetProp(hWndDlg, (LPSTR) aFocus);

        if (hFocus)
        {
            SetFocus(hFocus);
            return TRUE;
        }
    }
    break;

    case WM_INITMENUPOPUP:
#ifdef OS2_COMP
        MenuOptions(hWndDlg, (HMENU) wParam, GetDlgItem(hWndDlg, IDDINFO));
        PrepareDlgSelection(hWndDlg, (HMENU) wParam);
#else
        if (LOWORD(lParam) == 1)
            EditMenuOptions(hWndDlg, GetDlgItem(hWndDlg, IDDINFO));
        else if ((LOWORD(lParam) == 2) || (LOWORD(lParam) == 3))
            PrepareDlgSelection(hWndDlg);
#endif

        break;

    case WM_SIZE:
        if (wParam != SIZEICONIC)
            SetProp(hWndDlg, pIconized, FALSE);
        else
        {
            SetProp(hWndDlg, pIconized, TRUE);
            SendMessage(hWndDlg, WM_PAINT, 0, 0L);
        }
        break;

    case WM_PAINT:
#if WINVER < 0x030a
    case WM_PAINTICON:
#endif
        if (GetProp(hWndDlg, pIconized))
        {
            PAINTSTRUCT ps;
            HDC hDC = BeginPaint(hWndDlg, &ps);
            HBRUSH hBrush =
                CreateSolidBrush(GetSysColor(COLOR_BACKGROUND));
            RECT rect;

            GetClientRect(hWndDlg, &rect);
            SelectObject(hDC, hBrush);
            PatBlt(hDC, 0, 0,
                   rect.right - rect.left, rect.bottom - rect.top,
                   PATCOPY);
            DrawIcon(hDC, 2, 2, objectIcon);
            EndPaint(hWndDlg, &ps);
            DeleteObject(hBrush);
            return TRUE;
        }
        return FALSE;

    case WM_QUERYDRAGICON:
        return objectIcon;

    case WM_COMMAND:
        hObj = GetProp(hWndDlg, (LPSTR) "hObj");
        switch (wParam) {
        /* OPEN EXISTING OBJECT (USER SELECTED) */
        case IDM_OPEN:
        /* OPEN EXISTING OBJECT (FROM ANOTHER FUNCTION) */
        case IDG_AUTOOPEN:
        /* START A NEW OBJECT */
        case IDM_NEW:
            return OpenObjectClassEditor(hWndDlg, OBJECT,
                                         hObj, wParam, lParam);

#ifndef RUNTIME
        case IDM_HELP:
            KppDoWindowHelp(hWndDlg, "e_instance");
            break;
#endif

        case IDG_IMAGE_AUTOOPEN:
        {
            HMENU hMenu;

            /* OPEN EXISTING OBJECT (FROM ANOTHER FUNCTION) */
            bRet = OpenObjectClassEditor(hWndDlg, OBJECT, hObj,
                                         wParam, lParam);
            hMenu = GetMenu(hWndDlg);
            EnableMenuItem(hMenu, IDM_SAVEAS, MF_GRAYED);
            EnableMenuItem(hMenu, IDM_NEW, MF_GRAYED);
            EnableMenuItem(hMenu, IDM_OPEN, MF_GRAYED);

            return bRet;
        }

        case IDM_CUT:
        case IDM_COPY:
        case IDM_PASTE:
        case IDM_CLEAR:
            KpeHandleEditMenu(GetFocus(), wParam);
            if (wParam != IDM_COPY)
                MARK_AS_MODIFIED(hWndDlg);
            break;

        /* SAVE OBJECT */
        case IDM_SAVE:
            EditorSaveItem(hWndDlg, OBJECT, hObj, SAVE);
            break;

        /* SAVE AS */
        case IDM_SAVEAS:
            EditorSaveAs(hWndDlg, OBJECT, hObj, wParam);
            break;

        /* Rename the object or class */
        case IDM_RENAME:
            return RenameObjectClassItem(hWndDlg, OBJECT, hObj);

        /* EXIT IS SELECTED FROM MENU (save and proceed with ABORT) */
        case IDM_EXIT:
        case IDCANCEL:
            sRes = ExitObjectClassEditor(hWndDlg, OBJECT, hObj);
            if (sRes == TRUE)
                DestroyWindow(hWndDlg);
            return TRUE;

        case IDDSLOTS:
            if (HIWORD(lParam) != LBN_DBLCLK)
                break;
            return ModifyMethSlot(hWndDlg, SLOT, hObj, IDM_EDIT, OBJECT);

        case IDM_IMAGE_EDIT:        /* from ^E accelerator */
            SendMessage(GetFocus(), WM_CHAR, 'E' - 0x40, 0L);
            return TRUE;

        case IDM_OPTIONSLAYOUTMODE: /* from ^L accelerator */
            SendMessage(GetFocus(), WM_CHAR, 'L' - 0x40, 0L);
            return TRUE;

        case IDM_WIDGETCUSTOM:      /* from ^G accelerator */
            SendMessage(GetFocus(), WM_CHAR, 'G' - 0x40, 0L);
            return TRUE;

        case IDM_EDITSLOT:
            return ModifyMethSlot(hWndDlg, SLOT, hObj,
                                  IDM_EDIT, OBJECT);

        case IDM_DELETESLOT:
            return ModifyMethSlot(hWndDlg, SLOT, hObj,
                                  IDM_DELETE, OBJECT);

        case IDM_RENAMESLOT:
            return ModifyMethSlot(hWndDlg, SLOT, hObj,
                                  IDM_RENAME, OBJECT);

        case IDM_MAKELOCALSLOT:
            return ModifyMethSlot(hWndDlg, SLOT, hObj,
                                  IDM_MAKELOCAL, OBJECT);

        case IDM_EDITMETHODOWNER:
            return ModifyMethSlot(hWndDlg, METHOD, hObj,
                                  IDM_EDITOWNER, OBJECT);

        case IDM_EDITSLOTOWNER:
            return ModifyMethSlot(hWndDlg, SLOT, hObj,
                                  IDM_EDITOWNER, OBJECT);

        case IDM_NEWSLOT:
            if (AddNewSlotMethod(hWndDlg, OBJECT, hObj, SLOT) == TRUE)
                MARK_AS_MODIFIED(hWndDlg);
            break;

        case IDG_CLOSESLOT:
            return CloseMethSlot(hWndDlg, SLOT, lParam);

        case IDDMETHODS:
            if (HIWORD(lParam) != LBN_DBLCLK)
                break;
            return ModifyMethSlot(hWndDlg, METHOD, hObj,
                                  IDM_EDIT, OBJECT);

        case IDM_EDITMETHOD:
            return ModifyMethSlot(hWndDlg, METHOD, hObj,
                                  IDM_EDIT, OBJECT);

        case IDM_DELETEMETHOD:
            return ModifyMethSlot(hWndDlg, METHOD, hObj,
                                  IDM_DELETE, OBJECT);

        case IDM_RENAMEMETHOD:
            return ModifyMethSlot(hWndDlg, METHOD, hObj,
                                  IDM_RENAME, OBJECT);

        case IDM_MAKELOCALMETHOD:
            return ModifyMethSlot(hWndDlg, METHOD, hObj, IDM_MAKELOCAL, OBJECT);

        case IDM_NEWMETHOD:
            if (AddNewSlotMethod(hWndDlg, OBJECT, hObj, METHOD) == TRUE)
                MARK_AS_MODIFIED(hWndDlg);        /* SK */
            break;

        /* A METHOD EDITOR IS CLOSING */
        case IDG_CLOSEMETHOD:
            return CloseMethSlot(hWndDlg, METHOD, lParam);

        case IDDINFO:
            if (HIWORD(lParam) == EN_CHANGE)
                MARK_AS_MODIFIED(hWndDlg);
            break;

        default:
            return FALSE;
        }
        break;

    default:
        return FALSE;
    }

    return TRUE;
}
Ejemplo n.º 26
0
int InitSymbolTable(CgStruct *Cg)
{
    SourceLoc dummyLoc = { 0, 0 };
    int ii, name;

    // Create the super-global scope and add predefined types and symbols:

    PushScope(NewScopeInPool(mem_CreatePool(0, 0)));
    UndefinedType = NewType(TYPE_BASE_UNDEFINED_TYPE | TYPE_CATEGORY_SCALAR, 0);
    CFloatType = NewType(TYPE_BASE_CFLOAT | TYPE_CATEGORY_SCALAR | TYPE_QUALIFIER_CONST, 1);
    CIntType = NewType(TYPE_BASE_CINT | TYPE_CATEGORY_SCALAR | TYPE_QUALIFIER_CONST, 1);
    VoidType = NewType(TYPE_BASE_VOID | TYPE_CATEGORY_SCALAR | TYPE_MISC_VOID, 0);
    FloatType = NewType(TYPE_BASE_FLOAT | TYPE_CATEGORY_SCALAR, 1);
    IntType = NewType(TYPE_BASE_INT | TYPE_CATEGORY_SCALAR, 1);
    BooleanType = NewType(TYPE_BASE_BOOLEAN | TYPE_CATEGORY_SCALAR, 1);

    CFloat1Type = NewPackedArrayType(CFloatType, 1, TYPE_QUALIFIER_CONST);
    CFloat2Type = NewPackedArrayType(CFloatType, 2, TYPE_QUALIFIER_CONST);
    CFloat3Type = NewPackedArrayType(CFloatType, 3, TYPE_QUALIFIER_CONST);
    CFloat4Type = NewPackedArrayType(CFloatType, 4, TYPE_QUALIFIER_CONST);
    CInt1Type = NewPackedArrayType(CIntType, 1, TYPE_QUALIFIER_CONST);
    CInt2Type = NewPackedArrayType(CIntType, 2, TYPE_QUALIFIER_CONST);
    CInt3Type = NewPackedArrayType(CIntType, 3, TYPE_QUALIFIER_CONST);
    CInt4Type = NewPackedArrayType(CIntType, 4, TYPE_QUALIFIER_CONST);
    Float1Type = NewPackedArrayType(FloatType, 1, 0);
    Float2Type = NewPackedArrayType(FloatType, 2, 0);
    Float3Type = NewPackedArrayType(FloatType, 3, 0);
    Float4Type = NewPackedArrayType(FloatType, 4, 0);
    Int1Type = NewPackedArrayType(IntType, 1, 0);
    Int2Type = NewPackedArrayType(IntType, 2, 0);
    Int3Type = NewPackedArrayType(IntType, 3, 0);
    Int4Type = NewPackedArrayType(IntType, 4, 0);
    Boolean1Type = NewPackedArrayType(BooleanType, 1, 0);
    Boolean2Type = NewPackedArrayType(BooleanType, 2, 0);
    Boolean3Type = NewPackedArrayType(BooleanType, 3, 0);
    Boolean4Type = NewPackedArrayType(BooleanType, 4, 0);

    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat"), CFloatType, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint"), CIntType, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, VOID_SY, VoidType, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, FLOAT_SY, FloatType, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, INT_SY, IntType, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, BOOLEAN_SY, BooleanType, TYPEDEF_S);

    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat1"), CFloat1Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat2"), CFloat2Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat3"), CFloat3Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat4"), CFloat4Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint1"), CInt1Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint2"), CInt2Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint3"), CInt3Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint4"), CInt4Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float1"), Float1Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float2"), Float2Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float3"), Float3Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float4"), Float4Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int1"), Int1Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int2"), Int2Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int3"), Int3Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int4"), Int4Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool1"), Boolean1Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool2"), Boolean2Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool3"), Boolean3Type, TYPEDEF_S);
    AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool4"), Boolean4Type, TYPEDEF_S);

    FalseSymb = AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "false"), BooleanType, CONSTANT_S);
    TrueSymb = AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "true"), BooleanType, CONSTANT_S);
    FalseSymb->details.con.value = 0;
    TrueSymb->details.con.value = 1;

    SetScalarTypeName(TYPE_BASE_NO_TYPE, LookUpAddString(atable, "***no-base-type***"), UndefinedType);
    SetScalarTypeName(TYPE_BASE_UNDEFINED_TYPE, LookUpAddString(atable, "***undefined-base-type***"), UndefinedType);
    SetScalarTypeName(TYPE_BASE_CFLOAT, LookUpAddString(atable, "cfloat"), CFloatType);
    SetScalarTypeName(TYPE_BASE_CINT, LookUpAddString(atable, "cint"), CIntType);
    SetScalarTypeName(TYPE_BASE_VOID, LookUpAddString(atable, "void"), VoidType);
    SetScalarTypeName(TYPE_BASE_FLOAT, LookUpAddString(atable, "float"), FloatType);
    SetScalarTypeName(TYPE_BASE_INT, LookUpAddString(atable, "int"), IntType);
    SetScalarTypeName(TYPE_BASE_BOOLEAN, LookUpAddString(atable, "bool"), BooleanType);

    name = LookUpAddString(atable, "***unknown-profile-base-type***");
    for (ii = TYPE_BASE_FIRST_USER; ii <= TYPE_BASE_LAST_USER; ii++)
        SetScalarTypeName(ii, name, UndefinedType);

    // Add profile specific symbols and types:

    Cg->theHAL->RegisterNames(Cg->theHAL);
    AddAtom(atable, "<*** end hal specific atoms ***>");

    // Initialize misc. other globals:

    CurrentDeclTypeSpecs.basetype = UndefinedType;
    CurrentDeclTypeSpecs.IsDerived = 0;
    CurrentDeclTypeSpecs.type = *UndefinedType;

    return 1;
} // InitSymbolTable
Ejemplo n.º 27
0
/*********************************************************************
**
**  Adds a new menu item to a menu. 
**
**  Position is the position of the new menu item.  If position is -1,
**  the menu item is inserted as the last item.
**
**********************************************************************/
BOOL __far __pascal MyInsertMenu
( 
  HWND hDataWnd, 
  LPSTR lpMenuID,
  LPSTR lpItemID,
  LPSTR lpItemText,
  LPSTR lpMacro,
  short int Position
)
{
  HMENUSYS hMenuSys;
  FPMENUSYS MenuSysPtr;

  /* Menu info. to store in menu info. list. */
  MENUINFO MenuInfo, MenuItemInfo;
  
  BOOL bReturn;
  
  /* Pointer to macro string. */
  char __far * MacroStringPtr;

  
  /* Get the menu sys. data */
  hMenuSys = (HMENUSYS) WndData( hDataWnd, WDM_GETMENUSYS, 0, NULL );
  
  /* Lock menu sys. data. */
  MenuSysPtr = ( FPMENUSYS ) GlobalLock( hMenuSys );
    
  /* Menubar does not even exist. */
  if( MenuSysPtr->hMenuBar == NULL ) 
  {
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, MENUDOESNOTEXIST, MB_ICONHAND | MB_OK );

    /* Success. */
    return( FALSE );
  }

  /* Find the menu that the item will be added to. */
  if( GetMenuInfo( MenuSysPtr->hMenuList, lpMenuID, &MenuInfo ) )
  {
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, MENUDOESNOTEXIST, MB_ICONHAND | MB_OK );

    /* Success. */
    return( FALSE );
  }


  /* Verify that the new menu's ID string is unique. */
  if( GetMenuInfo( MenuSysPtr->hMenuList, lpItemID, &MenuItemInfo ) )
  {
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, MENUALREADYEXISTS, MB_ICONHAND | MB_OK );

    /* Success. */
    return( FALSE );
  }


  /* Allocate memory for storage of macro string. */
  if( !GlobalAllocMem( hDataWnd, &(MenuItemInfo).hMacroString, _fstrlen( lpMacro ) + sizeof(char) ) )
  {
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, CANTCREATEMENU, MB_ICONHAND | MB_OK );

    /* Failure. */
    return( FALSE );
  }
  
  /* Copy macro string storage area. */
  MacroStringPtr = (char __far *) GlobalLock( MenuItemInfo.hMacroString );
  _fstrcpy( MacroStringPtr, lpMacro );
  GlobalUnlock( MenuItemInfo.hMacroString );

  /* Init. the other menu item info. */
  MenuItemInfo.MenuID       = AddAtom( lpItemID );   
  MenuItemInfo.hMenu        = NULL;   
  MenuItemInfo.hParentMenu  = MenuInfo->hMenu;   
  MenuItemInfo.hMacroString = NULL;   

  /* Add the menu item to the menu. */
  if( ! InsertMenu( MenuInfo->hMenu, Position, MF_BYPOSITION | MF_ENABLED | MF_STRING, MenuItemInfo.MenuID, lpItemText) )
  {
    /* Delete allocated info. */
    DeleteAtom( MenuItemInfo.ButtonID );
    GlobalFree( MenuItemInfo.hMacroString ); 

    /* Error. */ 
    MsgBox( GetLibInst(), hDataWnd, IDS_ERRORTITLE, CANTCREATEMENU, MB_ICONHAND | MB_OK );

    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Success. */
    return( FALSE );
  }
  
  /* Save the menu info. */
  bReturn = SaveMenuInfo( hDataWnd, &(MenuSysPtr)->hMenuList, (FPMENUINFO) &MenuInfo );
  if( bReturn == FALSE )
  {
    /* Delete allocated info. */
    DeleteAtom( MenuItemInfo.ButtonID );
    GlobalFree( MenuItemInfo.hMacroString ); 

    /* Remove the new menu item. */
    RemoveMenu( MenuInfo->hMenu, Position, MF_BYPOSITION );
    
    /* Unlock menu sys. data. */
    GlobalUnlock( hMenuSys );
    
    /* Failure. */
    return FALSE;
  }
      
  /* Show changes. */
  DrawMenuBar( MenuSysPtr->hMenuBar );

  /* Unlock menu sys. data. */
  GlobalUnlock( hMenuSys );
    
  /* Success. */
  return( TRUE );
}
Ejemplo n.º 28
0
 void OBResidue::InsertAtom(OBAtom *atom)
 {
   AddAtom(atom);
 }