コード例 #1
0
ファイル: system.cpp プロジェクト: smallbasic/SmallBASIC
void System::showMenu() {
  logEntered();

  if (!_menuActive) {
    _menuActive = true;
    char buffer[64];
    if (_systemMenu != NULL) {
      delete [] _systemMenu;
    }

    StringList *items = new StringList();
    int completions = 0;

    if (get_focus_edit() && isEditing()) {
      completions = get_focus_edit()->getCompletions(items, MAX_COMPLETIONS);
    }

    _systemMenu = new int[MENU_SIZE + completions];

    int index = 0;
    if (get_focus_edit() != NULL) {
      if (isEditing()) {
        items->add(new String("Undo"));
        items->add(new String("Redo"));
        items->add(new String("Cut"));
        items->add(new String("Copy"));
        items->add(new String("Paste"));
        items->add(new String("Select All"));
        items->add(new String("Save"));
        items->add(new String("Run"));
#if defined(_SDL)
        items->add(new String("Debug"));
        items->add(new String("Show Output"));
#endif
        items->add(new String("Help"));
        for (int i = 0; i < completions; i++) {
          _systemMenu[index++] = MENU_COMPLETION_0 + i;
        }
        _systemMenu[index++] = MENU_UNDO;
        _systemMenu[index++] = MENU_REDO;
        _systemMenu[index++] = MENU_CUT;
        _systemMenu[index++] = MENU_COPY;
        _systemMenu[index++] = MENU_PASTE;
        _systemMenu[index++] = MENU_SELECT_ALL;
        _systemMenu[index++] = MENU_SAVE;
        _systemMenu[index++] = MENU_RUN;
#if defined(_SDL)
        _systemMenu[index++] = MENU_DEBUG;
        _systemMenu[index++] = MENU_OUTPUT;
#endif
        _systemMenu[index++] = MENU_HELP;
      } else if (isRunning()) {
        items->add(new String("Cut"));
        items->add(new String("Copy"));
        items->add(new String("Paste"));
        items->add(new String("Select All"));
        _systemMenu[index++] = MENU_CUT;
        _systemMenu[index++] = MENU_COPY;
        _systemMenu[index++] = MENU_PASTE;
        _systemMenu[index++] = MENU_SELECT_ALL;
      }
#if defined(_SDL)
      items->add(new String("Back"));
      _systemMenu[index++] = MENU_BACK;
#else
      items->add(new String("Show keypad"));
      _systemMenu[index++] = MENU_KEYPAD;
      if (!isEditing()) {
        bool controlMode = get_focus_edit()->getControlMode();
        sprintf(buffer, "Control Mode [%s]", (controlMode ? "ON" : "OFF"));
        items->add(new String(buffer));
        _systemMenu[index++] = MENU_CTRL_MODE;
      }
#endif
    } else {
      items->add(new String("Console"));
      items->add(new String("View source"));
      _systemMenu[index++] = MENU_CONSOLE;
      _systemMenu[index++] = MENU_SOURCE;
      if (!isEditing()) {
        items->add(new String("Restart"));
        _systemMenu[index++] = MENU_RESTART;
      }
#if !defined(_SDL)
      items->add(new String("Show keypad"));
      _systemMenu[index++] = MENU_KEYPAD;
#endif
      items->add(new String("Screenshot"));
      _systemMenu[index++] = MENU_SCREENSHOT;
      if (_mainBas) {
        sprintf(buffer, "Font Size %d%%", _fontScale - FONT_SCALE_INTERVAL);
        items->add(new String(buffer));
        sprintf(buffer, "Font Size %d%%", _fontScale + FONT_SCALE_INTERVAL);
        items->add(new String(buffer));
        _systemMenu[index++] = MENU_ZOOM_UP;
        _systemMenu[index++] = MENU_ZOOM_DN;
        sprintf(buffer, "Editor [%s]", opt_ide == IDE_NONE ? "OFF" : "ON");
        items->add(new String(buffer));
        _systemMenu[index++] = MENU_EDITMODE;
      }
#if !defined(_SDL)
      if (!_mainBas && !_activeFile.empty()) {
        items->add(new String("Desktop Shortcut"));
        items->add(new String("Share"));
        _systemMenu[index++] = MENU_SHORTCUT;
        _systemMenu[index++] = MENU_SHARE;
      }
#endif
      sprintf(buffer, "Audio [%s]", (opt_mute_audio ? "OFF" : "ON"));
      items->add(new String(buffer));
      _systemMenu[index++] = MENU_AUDIO;
#if defined(_SDL)
      items->add(new String("Back"));
      _systemMenu[index++] = MENU_BACK;
#endif
    }
    optionsBox(items);
    delete items;
    _menuActive = false;
  }
}
コード例 #2
0
ファイル: InfoPad.cpp プロジェクト: NoSuchProcess/OrangeC
void InfoPad::handleEvent(TEvent& event)
{
    if (event.what == evCommand && event.message.command == cmQuit)
    {
        while (editWindows)
            editWindows->WinMessage(WM_COMMAND, IDM_CLOSE, 0);
    }
    TApplication::handleEvent(event);
    if (event.what == evCommand)
    {
        switch (event.message.command)
        {
            case ID_OPTIONS:
                optionsBox();
                break;
            case ID_MOREWINDOWS:
                if (WindowMRU.Get(0))
                    WindowMenuBox();
                else
                    messageBox("No windows available", mfInformation);
                break;
            case ID_UNDO:
                if (current)
                {
                    current->child->WinMessage(WM_UNDO, 0, 0);
                }
                break;
            case IDM_REDO:
                if (current)
                {
                    current->child->WinMessage(WM_REDO, 0, 0);
                }
                break;
            case ID_CUT:
                if (current)
                {
                    current->child->WinMessage(WM_CUT, 0, 0);
                }
                break;
            case ID_COPY:
                if (current)
                {
                    current->child->WinMessage(WM_COPY, 0, 0);
                }
                break;
            case ID_PASTE:
                if (current)
                {
                    current->child->WinMessage(WM_PASTE, 0, 0);
                }
                break;
            case ID_NEW:
                openfile((DWINFO *)-1, True, True);
                break;
            case ID_OPEN:
                CreateDrawWindow((DWINFO *)0, True);
                break;
            case ID_SAVE:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_SAVE, 0);
                }
                break;
            case ID_SAVEAS:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_SAVEAS, 0);
                }
                break;
            case ID_CLOSE:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_CLOSE, 0);
                    current->close();
                    current = NULL;
                }
                break;
            case ID_SEARCH:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_FIND, 0);
                }
                break;
            case ID_REPLACE:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_REPLACE, 0);
                }
                break;
            case ID_SEARCHNEXT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_FINDNEXT, 0);
                }
                break;
            case ID_GOTO:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_GOTO, 0);
                }
                break;
            case ID_TOUPPER:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_TOUPPER, 0);
                }
                break;
            case ID_TOLOWER:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_TOLOWER, 0);
                }
                break;
            case ID_INDENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_INDENT, 0);
                }
                break;
            case ID_OUTDENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_UNINDENT, 0);
                }
                break;
            case ID_COMMENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_COMMENT, 0);
                }
                break;
            case ID_UNCOMMENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_UNCOMMENT, 0);
                }
                break;
            case ID_CLOSEALL:
                CloseAll();
                break;
            case ID_ABOUT:
                AboutBox();
                break;
            default:
                if (event.message.command >= FILE_MRU_BASE && event.message.command < FILE_MRU_BASE + MRU::MAX_MRU)
                {
                    static DWINFO temp;
                    MRUItem *p = cfg.FileMRU().Get(event.message.command - FILE_MRU_BASE);
                    if (p)
                    {
                        newInfo = &temp;
                        newInfo->dwLineNo =  - 1;
                        newInfo->logMRU = TRUE;
                        strcpy(newInfo->dwTitle, p->title);
                        strcpy(newInfo->dwName, p->name);
                        openfile(newInfo, FALSE, TRUE);
                    }
                }
                else if (event.message.command >= WINDOW_MRU_BASE && event.message.command < WINDOW_MRU_BASE + MRU::MAX_WINDOW_MRU)
                {
                    static DWINFO temp;
                    MRUItem *p = WindowMRU.Get(event.message.command - WINDOW_MRU_BASE);
                    if (p)
                    {
                        newInfo = &temp;
                        newInfo->dwLineNo =  - 1;
                        newInfo->logMRU = TRUE;
                        strcpy(newInfo->dwTitle, p->title);
                        strcpy(newInfo->dwName, p->name);
                        openfile(newInfo, FALSE, TRUE);
                    }
                }
                break;
        }
    }

}