Пример #1
0
void OSD::DialogShow(const QString &window, const QString &text, int updatefor)
{
    if (m_Dialog)
    {
        QString current = m_Dialog->objectName();
        if (current != window)
        {
            DialogQuit();
        }
        else
        {
            MythDialogBox *dialog = dynamic_cast<MythDialogBox*>(m_Dialog);
            if (dialog)
                dialog->Reset();

            DialogSetText(text);
        }
    }

    if (!m_Dialog)
    {
        OverrideUIScale();
        MythScreenType *dialog;

        if (window == OSD_DLG_EDITOR)
            dialog = new ChannelEditor(m_ParentObject, window.toLatin1());
        else if (window == OSD_DLG_CONFIRM)
            dialog = new MythConfirmationDialog(NULL, text, false);
        else
            dialog = new MythDialogBox(text, NULL, window.toLatin1(), false, true);

        dialog->SetPainter(m_CurrentPainter);
        if (dialog->Create())
        {
            PositionWindow(dialog);
            m_Dialog = dialog;
            MythDialogBox *dbox = dynamic_cast<MythDialogBox*>(m_Dialog);
            if (dbox)
                dbox->SetReturnEvent(m_ParentObject, window);
            MythConfirmationDialog *cbox = dynamic_cast<MythConfirmationDialog*>(m_Dialog);
            if (cbox)
            {
                cbox->SetReturnEvent(m_ParentObject, window);
                cbox->SetData("DIALOG_CONFIRM_X_X");
            }
            m_Children.insert(window, m_Dialog);
        }
        else
        {
            RevertUIScale();
            delete dialog;
            return;
        }

        RevertUIScale();
    }

    if (updatefor)
    {
        m_NextPulseUpdate  = MythDate::current();
        m_PulsedDialogText = text;
        SetExpiry(window, kOSDTimeout_None, updatefor);
    }

    DialogBack();
    HideAll(true, m_Dialog);
    m_Dialog->SetVisible(true);
}
Пример #2
0
do_menu(int item) {
	int  xitem;
	char text[1000];

	if (SAMP_MENU_1 <= item && item <= SAMP_MENU_N) {
		CheckMenuItem(MainMenu, SAMP_MENU_0+Sample,
			      MF_BYCOMMAND|MF_UNCHECKED);

		CheckMenuItem(MainMenu, item,
			      MF_BYCOMMAND|MF_CHECKED);

		Sample = item-SAMP_MENU_0;
		Redraw = 1;
		return(1);
	}

	switch (item) {
	  case FILE_MENU_OPEN:
		open_file();
		return(1);

	  case CHAN_MENU_NCHAN:
		sprintf(text, "%d", Nchan);
		DialogSetText(text, CHAN_MENU_TEXTBOX);
		DialogBegin("ChanDlg");
		return(1);

	  case CHAN_MENU_TEXTBOX:
		return(0);

	  case CHAN_MENU_SET:
		DialogGetText(text, CHAN_MENU_TEXTBOX);
		DialogEnd();
		printf("Set channels to %s\n", text);
		Nchan = atoi(text);
		Redraw = 1;
		return(1);

	  case CHAN_MENU_CANCEL:
		DialogEnd();
		printf("cancelled channel dialog\n");
		return(1);

	  case PLOT_MENU_SETUP: /* used for setting menu items */
		break;

	  case PLOT_MENU_LINE:
		PlotType &= ~0xff;
		PlotType |= T_LINE;
		Redraw   = 1;
		break;

	  case PLOT_MENU_SCATTER:
		PlotType &= ~0xff;
		PlotType |= T_SCATTER;
		Redraw   = 1;
		break;

	  case PLOT_MENU_COLMAP:
		PlotType &= ~0xff;
		PlotType |= T_COLORMAP;
		Redraw   = 1;
		break;

	  case PLOT_MENU_STACKED:
		if (PlotType & T_STACKED) PlotType &= ~T_STACKED;
		else                      PlotType |=  T_STACKED;
		Redraw   = 1;
		break;

	  default:
	      printf("Didn't recognize menu pick %d\n", item);
	}

	CheckMenuItem(MainMenu, PLOT_MENU_LINE,
		      MF_BYCOMMAND|(PlotType&T_LINE?MF_CHECKED:MF_UNCHECKED));
	CheckMenuItem(MainMenu, PLOT_MENU_SCATTER,
		      MF_BYCOMMAND|(PlotType&T_SCATTER?MF_CHECKED:MF_UNCHECKED));
	CheckMenuItem(MainMenu, PLOT_MENU_COLMAP,
		      MF_BYCOMMAND|(PlotType&T_COLORMAP?MF_CHECKED:MF_UNCHECKED));

	CheckMenuItem(MainMenu, PLOT_MENU_STACKED,
		      MF_BYCOMMAND|(PlotType&T_STACKED?MF_CHECKED:MF_UNCHECKED));

	if (PlotType & T_COLORMAP)
	 EnableMenuItem(MainMenu, PLOT_MENU_STACKED, MF_GRAYED);
	else
	 EnableMenuItem(MainMenu, PLOT_MENU_STACKED, MF_ENABLED);

	return(1);
}