예제 #1
0
/*  Given the type of object specified, add the object to the
    appropriate chunk.
*/
ITEMID W_EXPORT KppAddItem(WORD wType, LPLPSTR lpItem)
{
    GLOBALHANDLE hChunk;
    WORD wItemSize, wNum;
    ITEMID iRes = 0;

    /* Get the handle of 1st chunk */
    wNum = GetHandle(wType, (GLOBALHANDLE *) &hChunk, 
                     (WORD FAR *) &wItemSize, (BOOL) CREATE_CHUNK);

    /* Add the item given the chunk handle and the type */
    if (hChunk)
    {
        iRes = AddNewItem(wType, hChunk, wNum, wItemSize,
                          NULL, lpItem, NULLID);
        if (!iRes)
            return ERROR;
    }
    
    if (iRes)
        bAppChanged = TRUE;
    
    if (wType == CLASS)
        ADD_CLASS_FLAG(iRes);
    
    return iRes;
}
예제 #2
0
/* Given the handle to the object, make a copy of it in memory, and
    return new handle.
*/
ITEMID W_EXPORT KppCopyItem(WORD wType, ITEMID hdle, LPLPSTR lpItem)
{
    LPSTR lpData = LPNULL;
    GLOBALHANDLE hChunk;
    WORD wItemSize;
    WORD wNum;
    ITEMID newItem = NULLID;

    /* Get the starting chunk */
    wNum = GetHandle(wType, &hChunk, &wItemSize, GET_CHUNK);
    
    if (hChunk)
    {
        /* Get the object */
        if (!FindItem(hChunk, ADTID(hdle), (LPLPSTR) &lpData, 
                      wNum, wItemSize, (BITS) kGETMODE))
            return ERROR;

        /* Add the item, passing in the data */
        newItem = AddNewItem(wType, hChunk, wNum, wItemSize, lpData,
                             lpItem, NULLID);
        if (!newItem)
            return ERROR;
        
        bAppChanged = TRUE;
        
        KppReleaseItem(wType, hdle);
    }

    return newItem;
}
예제 #3
0
BOOL DoMru(HWND hWnd,WORD wId)
{
	char szFileName[128];
	OFSTRUCT of;
	BOOL fExist;

	GetMenuItem(g_qeglobals.d_lpMruMenu, wId, TRUE, szFileName, sizeof(szFileName));

	// Test if the file exists.

	fExist = OpenFile(szFileName ,&of,OF_EXIST) != HFILE_ERROR;

	if (fExist) {

		// Place the file on the top of MRU.
		AddNewItem(g_qeglobals.d_lpMruMenu,(LPSTR)szFileName);

		// Now perform opening this file !!!
		Map_LoadFile (szFileName);	
	}
	else
		// Remove the file on MRU.
		DelMenuItem(g_qeglobals.d_lpMruMenu,wId,TRUE);

	// Refresh the File menu.
	PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(hWnd),0),
			ID_FILE_EXIT);

	return fExist;
}
예제 #4
0
PanoramaViewData* PanoramaViewDataList::CreateNewData()
{
	PanoramaViewData* newData = new PanoramaViewData();
	CString str = GetCreateName();
	newData->SetName(str);
	AddNewItem(newData);
	return newData;
}
void ThreadSearchThread::AddProjectFiles(wxSortedArrayString& sortedArrayString, cbProject& project)
{
    // Adds project file paths to array only if they do not already exist.
    // Same path may exist if we parse both open files and project files
    // for examle.
    for (FilesList::iterator it = project.GetFilesList().begin(); it != project.GetFilesList().end(); ++it)
    {
        AddNewItem(sortedArrayString, (*it)->file.GetFullPath(), m_Masks);
        if ( TestDestroy() == true ) return;
    }
}
void ThreadSearchThread::AddTargetFiles(wxSortedArrayString& sortedArrayString, ProjectBuildTarget& target)
{
    // Adds target file paths to array only if they do not already exist.
    // Same path may exist if we parse both open files and target files
    // for examle.
    for (FilesList::iterator it = target.GetFilesList().begin(); it != target.GetFilesList().end(); it++)
    {
        ProjectFile* pf = *it;
        AddNewItem(sortedArrayString, pf->file.GetFullPath(), m_Masks);
        if ( TestDestroy() == true ) return;
    }
}
예제 #7
0
void OpenDialog( void )
{
	/*
	 * Obtain the system directory name and
	 * store it in szDirName.
	 */
	
	strcpy( szDirName, ValueForKey( g_qeglobals.d_project_entity, "mapspath" ) );
	if ( strlen( szDirName ) == 0 )
	{
		strcpy( szDirName, ValueForKey( g_qeglobals.d_project_entity, "basepath" ) );
		strcat( szDirName, "\\maps" );
	}
	
	/* Place the terminating null character in the szFile. */
	
	szFile[0] = '\0';
	
	/* Set the members of the OPENFILENAME structure. */
	
	ofn.lStructSize = sizeof( OPENFILENAME );
	ofn.hwndOwner = g_qeglobals.d_hwndCamera;
	ofn.lpstrFilter = szFilter;
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = szFile;
	ofn.nMaxFile = sizeof( szFile );
	ofn.lpstrFileTitle = szFileTitle;
	ofn.nMaxFileTitle = sizeof( szFileTitle );
	ofn.lpstrInitialDir = szDirName;
	ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
				OFN_FILEMUSTEXIST;
				
	/* Display the Open dialog box. */
	
	if ( !GetOpenFileName( &ofn ) )
		return; // canceled
		
	// Add the file in MRU.
	//FIXME
	AddNewItem( g_qeglobals.d_lpMruMenu, ofn.lpstrFile );
	
	// Refresh the File menu.
	//FIXME
	PlaceMenuMRUItem( g_qeglobals.d_lpMruMenu, GetSubMenu( GetMenu( g_qeglobals.d_hwndMain ), 0 ),
					  ID_FILE_EXIT );
					  
	/* Open the file. */
	
	Map_LoadFile( ofn.lpstrFile );
}
예제 #8
0
/*
 =======================================================================================================================
 =======================================================================================================================
 */
void SaveAsDialog(bool bRegion) {
	strcpy(szDirName, ValueForKey(g_qeglobals.d_project_entity, "basepath"));

	CString strPath = szDirName;
	AddSlash(strPath);
	strPath += "maps";
	if (g_PrefsDlg.m_strMaps.GetLength() > 0) {
		strPath += va("\\%s", g_PrefsDlg.m_strMaps);
	}

	/* Place the terminating null character in the szFile. */
	szFile[0] = '\0';

	/* Set the members of the OPENFILENAME structure. */
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = g_pParentWnd->GetSafeHwnd();
	ofn.lpstrFilter = szFilter;
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = szFile;
	ofn.nMaxFile = sizeof(szFile);
	ofn.lpstrFileTitle = szFileTitle;
	ofn.nMaxFileTitle = sizeof(szFileTitle);
	ofn.lpstrInitialDir = strPath;
	ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;

	/* Display the Open dialog box. */
	if (!GetSaveFileName(&ofn)) {
		return; // canceled
	}

	if (bRegion) {
		DefaultExtension(ofn.lpstrFile, ".reg");
	}
	else {
		DefaultExtension(ofn.lpstrFile, ".map");
	}

	if (!bRegion) {
		strcpy(currentmap, ofn.lpstrFile);
		AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile);
		PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu, GetSubMenu(GetMenu(g_pParentWnd->GetSafeHwnd()), 0), ID_FILE_EXIT);
	}

	Map_SaveFile(ofn.lpstrFile, bRegion);	// ignore region
}
BOOL COXHistoryCombo::SaveContents(LPCTSTR pszValueName, 
								   LPCTSTR pszCompany /* = NULL */, 
								   LPCTSTR pszApplication /* = NULL*/ , 
								   HKEY hKeyRoot /* = HKEY_CURRENT_USER */, 
								   BOOL bAddNewItem /* = TRUE */)
{
	ASSERT_VALID(this);

	CString sValueName(pszValueName);
	CString sCompany(pszCompany);
	CString sApplication(pszApplication);
	CString sContents;

	if (sValueName.IsEmpty())
	{
		TRACE0("COXHistoryCombo::SaveContents : No value name provided, failing\n");
		return FALSE;
	}

	if (sCompany.IsEmpty())
		sCompany = AfxGetApp()->m_pszRegistryKey;
	if (sCompany.IsEmpty())
	{
		TRACE0("COXHistoryCombo::SaveContents : No valid company name is provided, failing\n");
		return FALSE;
	}

	if (sApplication.IsEmpty())
		sApplication = AfxGetApp()->m_pszProfileName;

	// Add the current contents of the dit control to the list (if not yet one)
	if (bAddNewItem)
		AddNewItem();

	// Get the contents from the list
	sContents = GetContents();

	BOOL bSuccess = SaveContentsToRegistry(hKeyRoot, sCompany, sApplication, sValueName, sContents);

	ASSERT_VALID(this);
	return bSuccess;
}
예제 #10
0
void SaveAsDialog (void)
{ 
	strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "basepath") );
	strcat (szDirName, "\\maps");

	/* Place the terminating null character in the szFile. */ 
 
	szFile[0] = '\0'; 
 
	/* Set the members of the OPENFILENAME structure. */ 
 
	ofn.lStructSize = sizeof(OPENFILENAME); 
	ofn.hwndOwner = g_qeglobals.d_hwndCamera;
	ofn.lpstrFilter = szFilter; 
	ofn.nFilterIndex = 1; 
	ofn.lpstrFile = szFile; 
	ofn.nMaxFile = sizeof(szFile); 
	ofn.lpstrFileTitle = szFileTitle; 
	ofn.nMaxFileTitle = sizeof(szFileTitle); 
	ofn.lpstrInitialDir = szDirName; 
	ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | 
		OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; 

	/* Display the Open dialog box. */ 
 
	if (!GetSaveFileName(&ofn))
		return;	// canceled
  
	DefaultExtension (ofn.lpstrFile, ".map");
	strcpy (currentmap, ofn.lpstrFile);

	// Add the file in MRU.
	AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile);

	// Refresh the File menu.
	PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0),
			ID_FILE_EXIT);

	Map_SaveFile (ofn.lpstrFile, false);	// ignore region
}
void *ThreadSearchThread::Entry()
{
    // Tests if we have a working searcher object.
    // Cancel search if it is not the case
    if ( m_pTextFileSearcher == NULL )
        return 0;

    size_t i = 0;

    // For now, we look for all paths for the different search scopes
    // and store them in a sorted array to avoid pasing several times
    // the same file.
    // This will be changed to avoid consuming a lot of memory (parsing
    // form C:\ and storing all paths...). Aim is to avoid the use of the
    // array for storing items.

    // Search in directory files ?
    if ( m_FindData.MustSearchInDirectory() == true )
    {
        int flags = wxDIR_FILES | wxDIR_DIRS | wxDIR_DOTDOT;
        flags    |= m_FindData.GetHiddenSearch() ? wxDIR_HIDDEN : 0;

        const wxString &path = m_FindData.GetSearchPath(true);
        if (!wxDir::Exists(path))
        {
            ThreadSearchEvent event(wxEVT_THREAD_SEARCH_ERROR, -1);
            event.SetString(_("Cannot open folder ") + path);

            // Using wxPostEvent, we avoid multi-threaded memory violation.
            wxPostEvent(m_pThreadSearchView,event);
            return 0;
        }
        else
        {
            wxDir Dir(path);
            Dir.Traverse(*(static_cast<wxDirTraverser*>(this)), wxEmptyString, flags);
        }

        // Tests thread stop (cancel search, app shutdown)
        if ( TestDestroy() == true ) return 0;
    }

    // Search in workspace files ?
    if ( m_FindData.MustSearchInWorkspace() == true )
    {
        ProjectsArray* pProjectsArray = Manager::Get()->GetProjectManager()->GetProjects();
        for ( size_t j=0; j < pProjectsArray->GetCount(); ++j )
        {
            AddProjectFiles(m_FilePaths, *pProjectsArray->Item(j));
            if ( TestDestroy() == true ) return 0;
        }
    }
    else if ( m_FindData.MustSearchInProject() == true )
    {
        // Search in project files ?
        // Necessary only if not already parsed in worspace part
        cbProject* pProject = Manager::Get()->GetProjectManager()->GetActiveProject();
        if ( pProject != NULL )
        {
            AddProjectFiles(m_FilePaths, *pProject);
            if ( TestDestroy() == true ) return 0;
        }
    }
    else if ( m_FindData.MustSearchInTarget() == true )
    {
        // Search in target files ?
        // Necessary only if not already parsed in project part
        cbProject* pProject = Manager::Get()->GetProjectManager()->GetActiveProject();
        if ( pProject != NULL )
        {
            ProjectBuildTarget *pTarget = pProject->GetBuildTarget(pProject->GetActiveBuildTarget());
            if ( pTarget != 0 )
            {
                AddTargetFiles(m_FilePaths, *pTarget);
                if ( TestDestroy() == true ) return 0;
            }
        }
    }

    // Tests thread stop (cancel search, app shutdown)
    if ( TestDestroy() == true ) return 0;

    // Open files
    if ( m_FindData.MustSearchInOpenFiles() == true )
    {
        EditorManager* pEdManager = Manager::Get()->GetEditorManager();
        for (i = 0; i < (size_t)pEdManager->GetNotebook()->GetPageCount(); ++i)
        {
            cbEditor* pEditor = pEdManager->GetBuiltinEditor(i);
            if ( pEditor != NULL )
            {
                AddNewItem(m_FilePaths, pEditor->GetFilename(), m_Masks);
            }
        }
    }

    // Tests thread stop (cancel search, app shutdown)
    if ( TestDestroy() == true ) return 0;

    // if the list is empty, leave
    if (m_FilePaths.GetCount() == 0)
    {
        //-cbMessageBox(wxT("No files to search in!"), wxT("Error"), wxICON_WARNING);
        ////(pecan 2008/4/26)
        // DO NOT issue graphics calls from this thread !!!!!!
        ThreadSearchEvent event(wxEVT_THREAD_SEARCH_ERROR, -1);
        event.SetString(_("No files to search.\nCheck options "));
        // Using wxPostEvent, we avoid multi-threaded memory violation.
        wxPostEvent(m_pThreadSearchView,event);
        return 0;
    }

    for ( i = 0; i < m_FilePaths.GetCount(); ++i )
    {
        FindInFile(m_FilePaths[i]);

        // Tests thread stop (cancel search, app shutdown)
        if ( TestDestroy() == true ) return 0;
    }

    return 0;
}
void COXHistoryCombo::OnNew() 
{
	// Add the string to the list box and clear the string
	AddNewItem();
}
예제 #13
0
bool FileXML::Load(const wxString& fileName, unsigned int itemsInLine)
{
    // Make sure file exists
    if (fileName.IsEmpty() || !wxFileName::FileExists(fileName))
    {
        mmErrorDialogs::InvalidFile(pParentWindow_);
        return false;
    }

    // Open file
    wxXmlDocument xmlFile;
    if (!xmlFile.Load(fileName, encoding_))
    {
        mmErrorDialogs::MessageError(pParentWindow_
            , _("File is not in Excel XML Spreadsheet 2003 format."), _("Parsing error"));
        return false;
    }

    // Workbook
    wxXmlNode *workbookElement = xmlFile.GetRoot();
    if (workbookElement->GetName().Cmp("Workbook") != 0
        || workbookElement->GetAttribute("xmlns").Cmp("urn:schemas-microsoft-com:office:spreadsheet") != 0)
    {
        mmErrorDialogs::MessageError(pParentWindow_, _("File is not in Excel XML Spreadsheet 2003 format."), _("Parsing error"));
        return false;
    }

    // Worksheet
    // TODO: Allow the user to choose the worksheet. This just uses the first.
    wxXmlNode *worksheetElement = workbookElement->GetChildren();
    for (; worksheetElement && worksheetElement->GetName() != "Worksheet"; worksheetElement = worksheetElement->GetNext())
    {
    };

    if (!worksheetElement)
    {
        mmErrorDialogs::MessageError(pParentWindow_, _("Could not find Worksheet."), _("Parsing error"));
        return false;
    }

    // Table
    wxXmlNode *tableElement = worksheetElement->GetChildren();
    if (tableElement->GetName() != _("Table"))
    {
        mmErrorDialogs::MessageError(pParentWindow_, _("Could not find Table."), _("Parsing error"));
        return false;
    }
    
    // Rows
    for (wxXmlNode *rowElement = tableElement->GetChildren(); rowElement; rowElement = rowElement->GetNext())
    {
        if (rowElement->GetName() != "Row")
            continue;
        AddNewLine();

        // Cells in row
        for (wxXmlNode *cellElement = rowElement->GetChildren(); cellElement; cellElement = cellElement->GetNext())
        {
            if (cellElement->GetName() != "Cell")
                continue;

            if (itemsTable_.back().size() >= itemsInLine)
                break;

            wxXmlNode *dataElement = cellElement->GetChildren();
            wxString content = dataElement? dataElement->GetNodeContent(): "";
            AddNewItem(content);
        }
    }
    return true;
}
예제 #14
0
void MenuEditor::OnEnter(wxCommandEvent& )
{
  AddNewItem();
}
예제 #15
0
void MenuEditor::OnAddMenuItem(wxCommandEvent& )
{
    AddNewItem();
}