/// Function name  : onDocumentsControl_ContextMenu
// Description     : Displays the tab context menu and implements it's commands
// 
// DOCUMENTS_DATA*  pWindowData  : [in] Documents data
// CONST POINT*     ptClick      : [in] Cursor position (in screen co-ordinates)
// 
BOOL  onDocumentsControl_ContextMenu(DOCUMENTS_DATA*  pWindowData, CONST POINT*  ptClick)
{
   TCHITTESTINFO  oHitTest;            // Document tab HitTest
   CUSTOM_MENU*   pCustomMenu;         // Custom menu
   DOCUMENT*      pDocument;           // Document that was clicked, if any
   INT            iDocumentIndex;      // Index of the document that was clicked

   // Prepare
   oHitTest.pt    = *ptClick;
   oHitTest.flags = TCHT_ONITEM;

   /// [CHECK] Has the user clicked a tab heading?
   ScreenToClient(pWindowData->hTabCtrl, &oHitTest.pt);
   iDocumentIndex = TabCtrl_HitTest(pWindowData->hTabCtrl, &oHitTest);

   // Lookup document (Will fails if user did not click a tab heading)
   if (findDocumentByIndex(pWindowData->hTabCtrl, iDocumentIndex, pDocument))
   {
      CONSOLE_ACTION();

      // Generate custom menu
      pCustomMenu = createCustomMenu(TEXT("DIALOG_MENU"), TRUE, IDM_DOCUMENT_POPUP);

      /// Enable/Disable menu items
      EnableMenuItem(pCustomMenu->hPopup, IDM_FILE_SAVE,                    isModified(pDocument) ? MF_ENABLED : MF_DISABLED);
      EnableMenuItem(pCustomMenu->hPopup, IDM_WINDOW_CLOSE_OTHER_DOCUMENTS, getDocumentCount() > 1 ? MF_ENABLED : MF_DISABLED);

      // Enable/Disable project items
      EnableMenuItem(pCustomMenu->hPopup, IDM_DOCUMENT_ADD_PROJECT,    getActiveProject() AND !isDocumentInProject(pDocument) ? MF_ENABLED : MF_DISABLED);
      EnableMenuItem(pCustomMenu->hPopup, IDM_DOCUMENT_REMOVE_PROJECT, getActiveProject() AND isDocumentInProject(pDocument)  ? MF_ENABLED : MF_DISABLED);

      /// Display context menu and return choice immediately
      switch (TrackPopupMenu(pCustomMenu->hPopup, TPM_RETURNCMD WITH TPM_TOPALIGN WITH TPM_LEFTALIGN, ptClick->x, ptClick->y, NULL, pWindowData->hTabCtrl, NULL))
      {
      // [SAVE/CLOSE/CLOSE-OTHER] Perform relevant command
      case IDM_FILE_SAVE:                     commandSaveDocument(getMainWindowData(), pDocument, FALSE, NULL);  break;
      case IDM_FILE_CLOSE:                    closeDocumentByIndex(pWindowData->hTabCtrl, iDocumentIndex);       break;
      case IDM_WINDOW_CLOSE_OTHER_DOCUMENTS:  closeAllDocuments(pWindowData->hTabCtrl, TRUE);                    break;

      // [ADD/REMOVE PROJECT] TODO
      case IDM_DOCUMENT_ADD_PROJECT:          addDocumentToProject(pDocument);         break;
      case IDM_DOCUMENT_REMOVE_PROJECT:       removeDocumentFromProject(pDocument);    break;
         break;
      }

      // Cleanup
      deleteCustomMenu(pCustomMenu);
   }
   
   // Return TRUE if handled, otherwise FALSE
   return (iDocumentIndex != -1);
}
Esempio n. 2
0
bool ProjucerApplication::perform (const InvocationInfo& info)
{
    switch (info.commandID)
    {
        case CommandIDs::newProject:                createNewProject(); break;
        case CommandIDs::open:                      askUserToOpenFile(); break;
        case CommandIDs::saveAll:                   openDocumentManager.saveAll(); break;
        case CommandIDs::closeAllDocuments:         closeAllDocuments (true); break;
        case CommandIDs::showUTF8Tool:              showUTF8ToolWindow(); break;
        case CommandIDs::showSVGPathTool:           showSVGPathDataToolWindow(); break;
        case CommandIDs::showGlobalPreferences:     AppearanceSettings::showGlobalPreferences (globalPreferencesWindow); break;
        case CommandIDs::loginLogout:               loginOrLogout(); break;
        default:                                    return JUCEApplication::perform (info);
    }

    return true;
}
Esempio n. 3
0
void BOpenSaveEditorModule::editorUnset(BCodeEditor *edr)
{
    B_D(BOpenSaveEditorModule);
    if (edr) {
        if (!d->actNewFile.isNull())
            disconnect(d->actNewFile, SIGNAL(triggered()), edr, SLOT(addDocument()));
        if (!d->actOpenFiles.isNull())
            disconnect(d->actOpenFiles, SIGNAL(triggered()), edr, SLOT(openDocuments()));
        if (!d->actReopenFile.isNull())
            disconnect(d->actReopenFile, SIGNAL(triggered()), edr, SLOT(reopenCurrentDocument()));
        if (!d->actSaveFile.isNull())
            disconnect(d->actSaveFile, SIGNAL(triggered()), edr, SLOT(saveCurrentDocument()));
        if (!d->actSaveFileAs.isNull())
            disconnect(d->actSaveFileAs, SIGNAL(triggered()), edr, SLOT(saveCurrentDocumentAs()));
        if (!d->actSaveAllFiles.isNull())
            disconnect(d->actSaveAllFiles, SIGNAL(triggered()), edr, SLOT(saveAllDocuments()));
        if (!d->actCloseFile.isNull())
            disconnect(d->actCloseFile, SIGNAL(triggered()), edr, SLOT(closeCurrentDocument()));
        if (!d->actCloseAllFiles.isNull())
            disconnect(d->actCloseAllFiles, SIGNAL(triggered()), edr, SLOT(closeAllDocuments()));
    }
    d->checkActions();
    d->resetFileHistory();
}
MultiDocumentPanel::~MultiDocumentPanel()
{
    closeAllDocuments (false);
}
Esempio n. 5
0
 ~DemoMultiDocumentPanel()
 {
     closeAllDocuments (true);
 }
void EditorTabWidget::terminate()
{
  m_terminating = true;
  closeAllDocuments();
}