本文整理汇总了C++中PolycodeEditor类的典型用法代码示例。如果您正苦于以下问题:C++ PolycodeEditor类的具体用法?C++ PolycodeEditor怎么用?C++ PolycodeEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PolycodeEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
bool PolycodeIDEApp::quitApp() {
quittingApp = true;
while(editorManager->getCurrentEditor()) {
PolycodeEditor *editor = editorManager->getCurrentEditor();
if(editor->hasChanges()) {
OSFileEntry entry(editor->getFilePath(), OSFileEntry::TYPE_FILE);
frame->yesNoCancelPopup->setCaption("The file \""+entry.name+"\" has unsaved changes. Save before quitting?");
frame->yesNoCancelPopup->action = "closeQuitFile";
frame->showModal(frame->yesNoCancelPopup);
return false;
} else {
if(editor->getEditorHolder()) {
editor->getEditorHolder()->setEditor(NULL);
}
editorManager->destroyEditor(editor);
if(editorManager->openEditors.size() > 0) {
editorManager->setCurrentEditor(editorManager->openEditors[0]);
frame->getActiveProjectFrame()->getActiveTab()->showEditor(editorManager->openEditors[0]);
} else{
editorManager->setCurrentEditor(NULL);
}
}
}
return true;
}
示例2: refreshProject
void PolycodeIDEApp::doRemoveFile() {
if(!frame->getActiveProjectFrame()) {
return;
}
if(projectManager->selectedFile != "") {
core->removeDiskItem(projectManager->selectedFile);
if(projectManager->getActiveProject()) {
refreshProject();
}
PolycodeEditor *editor = 0;
for (int i=0; i < editorManager->openEditors.size(); i++) {
if (editorManager->openEditors[i]->getFilePath() == projectManager->selectedFile) {
editor = editorManager->openEditors[i];
break;
}
}
// have to set changes to false to avoid problems with saving and modal dialogs in removeEditor()
// besides, we're removing the file, so saving is not necessary
if (editor) {
editor->setHasChanges(false);
removeEditor(editor);
}
}
}
示例3: switch
void PolycodeIDEApp::handleEvent(Event *event) {
if(event->getDispatcher() == core) {
switch(event->getEventCode()) {
case Core::EVENT_CORE_RESIZE:
frame->Resize(core->getXRes(), core->getYRes());
break;
}
}
if(event->getDispatcher() == frame->getProjectBrowser()) {
if(event->getEventType() == "PolycodeProjectBrowserEvent") {
switch(event->getEventCode()) {
case PolycodeProjectBrowserEvent::SHOW_MENU:
dispatchEvent(new Event(), EVENT_SHOW_MENU);
break;
}
}
if(event->getEventCode() == Event::CHANGE_EVENT) {
BrowserUserData *selectedData = frame->getProjectBrowser()->getSelectedData();
projectManager->setActiveProject(selectedData->parentProject);
if(selectedData->type == 0)
return;
if(selectedData) {
PolycodeEditor *editor;
editor = editorManager->getEditorForPath(selectedData->fileEntry.fullPath);
if(editor) {
frame->showEditor(editor);
} else {
editor = editorManager->createEditorForExtension(selectedData->fileEntry.extension);
if(editor) {
if(editor->openFile(selectedData->fileEntry.fullPath)) {
frame->addEditor(editor);
frame->showEditor(editor);
} else {
delete editor;
editor = NULL;
}
}
}
if(editor) {
editorManager->setCurrentEditor(editor);
}
}
}
}
if(event->getDispatcher() == frame->newProjectWindow) {
if(event->getEventType() == "UIEvent" && event->getEventCode() == UIEvent::OK_EVENT) {
projectManager->createNewProject(frame->newProjectWindow->getTemplateFolder(), frame->newProjectWindow->getProjectName(), frame->newProjectWindow->getProjectLocation());
frame->hideModal();
}
}
}
示例4: hasUnsavedFilesForProject
bool PolycodeEditorManager::hasUnsavedFilesForProject(PolycodeProject *project) {
for(int i=0; i < openEditors.size();i++) {
PolycodeEditor *editor = openEditors[i];
if(editor->hasChanges() && editor->parentProject == project)
return true;
}
return false;
}
示例5:
PolycodeEditor *PolycodeEditorManager::getEditorForPath(String path) {
for(int i=0; i < openEditors.size();i++) {
PolycodeEditor *editor = openEditors[i];
if(editor->getFilePath() == path)
return editor;
}
return NULL;
}
示例6: hasUnsavedFiles
bool PolycodeEditorManager::hasUnsavedFiles() {
for(int i=0; i < openEditors.size();i++) {
PolycodeEditor *editor = openEditors[i];
if(editor->hasChanges())
return true;
}
return false;
}
示例7: closeFile
void PolycodeIDEApp::closeFile() {
// this will save the file if it has changes and/or close it (in closeFiles())
PolycodeEditor *editor = editorManager->getCurrentEditor();
if (editor) {
std::vector<PolycodeEditor*> editorToSave;
editorToSave.push_back(editor);
OSFileEntry entry(editor->getFilePath(), OSFileEntry::TYPE_FILE);
closeFiles(editorToSave, "'"+entry.name+"' has unsaved changes. Save?");
}
}
示例8: getEditorForPath
PolycodeEditor *PolycodeEditorManager::openFile(OSFileEntry file) {
// NOCMAKE_TODO:
/*
if(!Services()->getCore()->fileExists(file.fullPath)) {
return NULL;
}
*/
PolycodeEditor *editor = getEditorForPath(file.fullPath);
if(editor) {
return editor;
} else {
editor = createEditorForExtension(file.extension);
if(editor) {
editor->parentProject = projectManager->getActiveProject();
if(!editor->openFile(file)) {
delete editor;
editor = NULL;
}
}
}
return editor;
}
示例9: closeProject
void PolycodeIDEApp::closeProject() {
if(projectManager->getActiveProject()) {
std::vector<PolycodeEditor*> editors;
PolycodeEditor *editor;
bool hasChanges = false;
for (int i=0; i < editorManager->openEditors.size(); i++) {
editor = editorManager->openEditors[i];
if (editor->hasChanges())
hasChanges = true;
if (editor->parentProject == projectManager->getActiveProject())
editors.push_back(editor);
}
tempEditorStore = editors; // current project files
if (hasChanges) {
String name = projectManager->getActiveProject()->getProjectName();
frame->yesNoCancelPopup->setCaption("Project '" + name + "' has unsaved changes. Save all?");
frame->yesNoCancelPopup->action = "closeProject";
frame->showModal(frame->yesNoCancelPopup);
} else
doCloseProject();
} else
PolycodeConsole::print("There are no active projects to close.\n");
}
示例10: openFile
void PolycodeIDEApp::openFile(OSFileEntry file) {
PolycodeEditorFactory *factory = editorManager->getEditorFactoryForExtension(file.extension);
if(dynamic_cast<PolycodeTextEditorFactory*>(factory)) {
CoreServices *core = CoreServices::getInstance();
Config *config = core->getConfig();
bool useExternalTextEditor = (config->getStringValue("Polycode", "useExternalTextEditor") == "true") && (config->getStringValue("Polycode", "externalTextEditorCommand") != "");
if(useExternalTextEditor) {
PolycodeToolLauncher::openExternalEditor(config->getStringValue("Polycode", "externalTextEditorCommand"), file.fullPath, projectManager->getActiveProject()->getRootFolder());
return;
}
}
PolycodeEditor *editor = editorManager->getEditorForPath(file.fullPath);
if(editor) {
frame->showEditor(editor);
} else {
editor = editorManager->createEditorForExtension(file.extension);
if(editor) {
editor->parentProject = projectManager->getActiveProject();
if(editor->openFile(file)) {
frame->addEditor(editor);
frame->showEditor(editor);
} else {
delete editor;
editor = NULL;
}
}
}
if(editor) {
editorManager->setCurrentEditor(editor);
}
}
示例11: openFile
void PolycodeIDEApp::openFile(OSFileEntry file) {
PolycodeEditor *editor;
editor = editorManager->getEditorForPath(file.fullPath);
if(editor) {
frame->showEditor(editor);
} else {
editor = editorManager->createEditorForExtension(file.extension);
if(editor) {
editor->parentProject = projectManager->getActiveProject();
if(editor->openFile(file)) {
frame->addEditor(editor);
frame->showEditor(editor);
} else {
delete editor;
editor = NULL;
}
}
}
if(editor) {
editorManager->setCurrentEditor(editor);
}
}
示例12: openFileInProject
void PolycodeIDEApp::handleEvent(Event *event) {
if(event->getDispatcher() == frame->console->backtraceWindow) {
if(event->getEventType() == "BackTraceEvent" && event->getEventCode() == BackTraceEvent::EVENT_BACKTRACE_SELECTED) {
BackTraceEvent *btEvent = (BackTraceEvent*) event;
openFileInProject(btEvent->project, btEvent->fileName);
PolycodeEditor *editor = editorManager->getCurrentEditor();
if(editor) {
if(editor->getEditorType() == "PolycodeTextEditor") {
PolycodeTextEditor *textEditor = (PolycodeTextEditor*) editor;
textEditor->highlightLine(btEvent->lineNumber);
}
}
}
}
if(event->getDispatcher() == core) {
switch(event->getEventCode()) {
case Core::EVENT_CORE_RESIZE:
frame->Resize(core->getXRes(), core->getYRes());
break;
}
}
if(event->getDispatcher() == frame->getProjectBrowser()) {
if(event->getEventType() == "PolycodeProjectBrowserEvent") {
switch(event->getEventCode()) {
case PolycodeProjectBrowserEvent::HANDLE_MENU_COMMAND:
PolycodeProjectBrowserEvent *bEvent = (PolycodeProjectBrowserEvent*) event;
/*
contextMenu->addOption("Add New File", "add_new_file");
contextMenu->addOption("Add New Project", "add_new_project");
contextMenu->addOption("Add New Folder", "add_new_folder");
contextMenu->addOption("--------", "");
contextMenu->addOption("Refresh", "refresh");
contextMenu->addOption("Rename", "rename");
contextMenu->addOption("--------", "");
contextMenu->addOption("Remove", "remove");
*/
if(bEvent->command == "add_new_file") {
newFile();
} else if(bEvent->command == "add_new_project") {
newProject();
} else if(bEvent->command == "add_new_folder") {
newGroup();
} else if(bEvent->command == "refresh") {
refreshProject();
} else if(bEvent->command == "rename") {
renameFile();
} else if(bEvent->command == "remove") {
removeFile();
}
break;
}
}
if(event->getEventCode() == Event::CHANGE_EVENT) {
BrowserUserData *selectedData = frame->getProjectBrowser()->getSelectedData();
if(selectedData->type == 3) {
projectManager->activeFolder = selectedData->parentProject->getRootFolder();
projectManager->selectedFile = "";
} else if(selectedData->type == 0) {
projectManager->activeFolder = "";
projectManager->selectedFile = "";
} else {
projectManager->selectedFileEntry = selectedData->fileEntry;
projectManager->selectedFile = selectedData->fileEntry.fullPath;
if(selectedData->fileEntry.type == OSFileEntry::TYPE_FILE) {
projectManager->activeFolder = selectedData->fileEntry.basePath;
} else {
projectManager->activeFolder = selectedData->fileEntry.fullPath;
}
}
projectManager->setActiveProject(selectedData->parentProject);
if(selectedData->type == 0)
return;
if(selectedData) {
openFile(selectedData->fileEntry);
}
}
}
if(event->getDispatcher() == frame->playButton) {
if(event->getEventType() == "UIEvent" && event->getEventCode() == UIEvent::CLICK_EVENT) {
willRunProject = true;
}
}
if(event->getDispatcher() == frame->stopButton) {
if(event->getEventType() == "UIEvent" && event->getEventCode() == UIEvent::CLICK_EVENT) {
stopProject();
}
//.........这里部分代码省略.........
示例13: switch
void PolycodeIDEApp::handleEvent(Event *event) {
if(event->getDispatcher() == core) {
switch(event->getEventCode()) {
case Core::EVENT_CORE_RESIZE:
frame->Resize(core->getXRes(), core->getYRes());
break;
}
}
if(event->getDispatcher() == frame->getProjectBrowser()) {
if(event->getEventType() == "PolycodeProjectBrowserEvent") {
switch(event->getEventCode()) {
case PolycodeProjectBrowserEvent::SHOW_MENU:
dispatchEvent(new Event(), EVENT_SHOW_MENU);
break;
}
}
if(event->getEventCode() == Event::CHANGE_EVENT) {
BrowserUserData *selectedData = frame->getProjectBrowser()->getSelectedData();
if(selectedData->type == 3) {
projectManager->activeFolder = selectedData->parentProject->getRootFolder();
projectManager->selectedFile = "";
} else if(selectedData->type == 0) {
projectManager->activeFolder = "";
projectManager->selectedFile = "";
} else {
projectManager->selectedFileEntry = selectedData->fileEntry;
projectManager->selectedFile = selectedData->fileEntry.fullPath;
if(selectedData->fileEntry.type == OSFileEntry::TYPE_FILE) {
projectManager->activeFolder = selectedData->fileEntry.basePath;
} else {
projectManager->activeFolder = selectedData->fileEntry.fullPath;
}
}
projectManager->setActiveProject(selectedData->parentProject);
if(selectedData->type == 0)
return;
if(selectedData) {
PolycodeEditor *editor;
editor = editorManager->getEditorForPath(selectedData->fileEntry.fullPath);
if(editor) {
frame->showEditor(editor);
} else {
editor = editorManager->createEditorForExtension(selectedData->fileEntry.extension);
if(editor) {
if(editor->openFile(selectedData->fileEntry.fullPath)) {
frame->addEditor(editor);
frame->showEditor(editor);
} else {
delete editor;
editor = NULL;
}
}
}
if(editor) {
editorManager->setCurrentEditor(editor);
}
}
}
}
if(event->getDispatcher() == frame->playButton) {
if(event->getEventType() == "UIEvent" && event->getEventCode() == UIEvent::CLICK_EVENT) {
runProject();
}
}
if(event->getDispatcher() == frame->textInputPopup) {
if(event->getEventType() == "UIEvent" && event->getEventCode() == UIEvent::OK_EVENT) {
core->moveDiskItem(projectManager->selectedFileEntry.fullPath, projectManager->selectedFileEntry.basePath + "/" + frame->textInputPopup->getValue());
if(projectManager->getActiveProject()) {
frame->getProjectBrowser()->refreshProject(projectManager->getActiveProject());
}
PolycodeEditor *editor = editorManager->getEditorForPath(projectManager->selectedFileEntry.fullPath);
if(editor) {
editor->setFilePath(projectManager->selectedFileEntry.basePath + "/" + frame->textInputPopup->getValue());
}
projectManager->selectedFileEntry.fullPath = projectManager->selectedFileEntry.basePath + "/" + frame->textInputPopup->getValue();
projectManager->selectedFileEntry.name = frame->textInputPopup->getValue();
frame->hideModal();
}
}
if(event->getDispatcher() == frame->newProjectWindow) {
if(event->getEventType() == "UIEvent" && event->getEventCode() == UIEvent::OK_EVENT) {
projectManager->createNewProject(frame->newProjectWindow->getTemplateFolder(), frame->newProjectWindow->getProjectName(), frame->newProjectWindow->getProjectLocation());
frame->hideModal();
}
//.........这里部分代码省略.........
示例14: OSFileEntry
void PolycodeIDEApp::handleEvent(Event *event) {
if(event->getDispatcher() == frame->fileDialog) {
if(event->getEventCode() == UIEvent::OK_EVENT && event->getEventType() == "UIEvent") {
String path = frame->fileDialog->getSelection();
if(path != "") {
PolycodeProject *project = projectManager->openProject(path);
if(project) {
projectManager->setActiveProject(project);
OSFileEntry projectEntry = OSFileEntry(project->getProjectFile(), OSFileEntry::TYPE_FILE);
openFile(projectEntry);
}
}
}
}
if(event->getDispatcher() == menuBar) {
String action = menuBar->getSelectedItem();
if(action == "new_file") {
newFile();
} else if(action == "new_project") {
newProject();
} else if(action == "new_folder") {
newGroup();
} else if(action == "open_project") {
openProject();
} else if(action == "close_project") {
closeProject();
} else if(action == "remove_file") {
removeFile();
} else if(action == "refresh_project") {
refreshProject();
} else if(action == "save_file") {
saveFile();
} else if(action == "browse_examples") {
browseExamples();
} else if(action == "quit") {
core->Shutdown();
} else if(action == "run_project") {
runProject();
} else if(action == "export_project") {
exportProject();
} else if(action == "show_api") {
openDocs();
} else if(action == "show_about") {
showAbout();
}
}
if(event->getDispatcher() == frame->console->backtraceWindow) {
if(event->getEventType() == "BackTraceEvent" && event->getEventCode() == BackTraceEvent::EVENT_BACKTRACE_SELECTED) {
BackTraceEvent *btEvent = (BackTraceEvent*) event;
openFileInProject(btEvent->project, btEvent->fileName);
PolycodeEditor *editor = editorManager->getCurrentEditor();
if(editor) {
if(editor->getEditorType() == "PolycodeTextEditor") {
PolycodeTextEditor *textEditor = (PolycodeTextEditor*) editor;
textEditor->highlightLine(btEvent->lineNumber);
}
}
}
}
if(event->getDispatcher() == core) {
switch(event->getEventCode()) {
case Core::EVENT_LOST_FOCUS:
core->setFramerate(3);
break;
case Core::EVENT_GAINED_FOCUS:
core->setFramerate(30);
break;
case Core::EVENT_CORE_RESIZE:
if(menuBar) {
frame->Resize(core->getXRes(), core->getYRes()-25);
menuBar->Resize(core->getXRes(), 25);
} else {
frame->Resize(core->getXRes(), core->getYRes());
}
break;
}
}
if(event->getDispatcher() == frame->getProjectBrowser()) {
if(event->getEventType() == "PolycodeProjectBrowserEvent") {
switch(event->getEventCode()) {
case PolycodeProjectBrowserEvent::HANDLE_MENU_COMMAND:
PolycodeProjectBrowserEvent *bEvent = (PolycodeProjectBrowserEvent*) event;
if(bEvent->command == "add_new_file") {
newFile();
} else if(bEvent->command == "add_files") {
addFiles();
} else if(bEvent->command == "add_new_project") {
newProject();
} else if(bEvent->command == "add_new_folder") {
//.........这里部分代码省略.........
示例15: saveAll
void PolycodeEditorManager::saveAll() {
for(int i=0; i < openEditors.size();i++) {
PolycodeEditor *editor = openEditors[i];
editor->saveFile();
}
}