示例#1
0
/*
 * This pops up a dialog box.
 */
int popupDialog (CDKSCREEN *screen, CDK_CSTRING2 mesg, int mesgCount, CDK_CSTRING2 buttons, int buttonCount)
{
   /* Declare local variables. */
   CDKDIALOG *popup	= 0;
   int choice;

   /* Create the dialog box. */
   popup = newCDKDialog (screen, CENTER, CENTER,
			 mesg, mesgCount,
			 buttons, buttonCount,
			 A_REVERSE, TRUE,
			 TRUE, FALSE);

   /* Activate the dialog box */
   drawCDKDialog (popup, TRUE);

   /* Get the choice. */
   choice = activateCDKDialog (popup, 0);

   /* Destroy the dialog box. */
   destroyCDKDialog (popup);

   /* Clean the screen. */
   eraseCDKScreen (screen);
   refreshCDKScreen (screen);

   /* Return the choice. */
   return choice;
}
CCDKDialog::CCDKDialog(CDKSCREEN *pScreen, int x, int y, const std::string &message, char **buttons, int bcount,
                       chtype hlight, bool sep, bool box, bool shadow) : CBaseCDKWidget(box)
{
    //std::vector<char *> vec(1, const_cast<char *>(message.c_str()));
    std::vector<char *> vec;
    MakeStringList(message, vec);
    m_pDialog = newCDKDialog(pScreen, x, y, &vec[0], vec.size(), buttons, bcount, hlight, sep, box, shadow);
    if (!m_pDialog) throwerror(false, "Could not create dialog window");
}
示例#3
0
文件: lcdk.c 项目: AitorATuin/lcdk
CDKDIALOG * __newCDKDialog (CDKSCREEN * screen, int xpos, int ypos, char *msg,
    int nmsg, char * buttons, int nbuttons, chtype highlight, 
    boolean separator, boolean box, boolean shadow)
{
    CDKDIALOG  *dialog;
    int i;
    char **dblmsg = toCharDblPtr(msg, nmsg);
    char **dblbtns = toCharDblPtr(buttons, nbuttons);

    dialog = newCDKDialog(screen, xpos, ypos, dblmsg, nmsg, dblbtns, nbuttons,
        highlight, separator, box, shadow);

    return dialog;
}
示例#4
0
int Simpletui::choiceFew(string text, vector<string> choices)
{
	const char **choiceChars=new const char*[choices.size()];
	for(size_t i=0;i<choices.size();i++)
		choiceChars[i]=choices[i].c_str();

	SplitString sText(text);

	CDKDIALOG *dia=newCDKDialog(reinterpret_cast<CDKSCREEN*>(cdk),CENTER,CENTER,sText.getPtr(),sText.getLength(),const_cast<char**>(choiceChars),choices.size(), A_STANDOUT,TRUE,TRUE,FALSE);
	int result=activateCDKDialog(dia,NULL);
	if(dia->exitType!=vNORMAL)
	{
		destroyCDKDialog(dia);
		throw STActionAborted();
	}
	destroyCDKDialog(dia);
	delete[] choiceChars;	// deep-delete unnecessary, references will be destroyed when strings are
	return result;
}
示例#5
0
void displayError( CDKSCREEN* cdkscreen, const std::string & msg )
{
    char* messgs[1] = { const_cast<char*>( msg.c_str() ) };
    char* buttons[1] = { "Ok" };
    CDKDIALOG *dlg = newCDKDialog( cdkscreen, CENTER, CENTER, messgs, 1, buttons, 1, A_REVERSE | A_BOLD, TRUE, TRUE, FALSE );
    setCDKDialogBackgroundColor( dlg, "</2>" );
    refreshCDKScreen( cdkscreen );
    while( dlg->exitType != vESCAPE_HIT )
    {
        const int selection = activateCDKDialog( dlg, NULL );
        switch( selection )
        {
            case 0:
            {
                dlg->exitType = vESCAPE_HIT;
                break;
            }
        }
        refreshCDKScreen( cdkscreen );
    }
    destroyCDKDialog( dlg );
}
示例#6
0
static int
set_config (CmdConfig *cmd_config)
{
	int result, selection;
	char *msg[10];
	char *buttons[] = {N_("</B/24>Continue"), N_("</B16>Cancel")};
	CDKDIALOG *question = NULL;

	result = gp_camera_set_config (cmd_config->camera, cmd_config->window, 
				       cmd_config->context);
	if (result < 0) {
		msg[0] = N_("<C></5>Error");
		msg[1] = "";
		msg[2] = N_("Could not set configuration:");
		msg[3] = (char*) gp_result_as_string (result);
		question = newCDKDialog (cmd_config->screen, CENTER, CENTER,
					 msg, 4, buttons, 2,
					 COLOR_PAIR (2) | A_REVERSE,
					 TRUE, TRUE, FALSE);
		if (!question)
			return (GP_ERROR);
		selection = activateCDKDialog (question, 0);
		if (question->exitType == vNORMAL) {
			switch (selection) {
			case 0: /* Continue */
				destroyCDKDialog (question);
				return (GP_OK);
			default:
				destroyCDKDialog (question);
				return (result);
			}
		} else {
			destroyCDKDialog (question);
			return (result);
		}
	}

	return (GP_OK);
}
示例#7
0
/*
 * This program demonstrates the Cdk dialog widget.
 */
int main (int argc, char **argv)
{
   /* *INDENT-EQLS* */
   CDKSCREEN *cdkscreen = 0;
   CDKDIALOG *question  = 0;
   const char *buttons[] =
   {"</B/24>Ok", "</B16>Cancel"};
   const char *message[10];
   const char *mesg[3];
   char temp[100];
   int selection;

   CDK_PARAMS params;

   CDKparseParams (argc, argv, &params, CDK_MIN_PARAMS);

   cdkscreen = initCDKScreen (NULL);

   /* Start color. */
   initCDKColor ();

   /* Create the message within the dialog box. */
   message[0] = "<C></U>Dialog Widget Demo";
   message[1] = " ";
   message[2] = "<C>The dialog widget allows the programmer to create";
   message[3] = "<C>a popup dialog box with buttons. The dialog box";
   message[4] = "<C>can contain </B/32>colours<!B!32>, </R>character attributes<!R>";
   message[5] = "<R>and even be right justified.";
   message[6] = "<L>and left.";

   /* Create the dialog box. */
   question = newCDKDialog (cdkscreen,
			    CDKparamValue (&params, 'X', CENTER),
			    CDKparamValue (&params, 'Y', CENTER),
			    (CDK_CSTRING2) message, 7,
			    (CDK_CSTRING2) buttons, 2,
			    COLOR_PAIR (2) | A_REVERSE,
			    TRUE,
			    CDKparamValue (&params, 'N', TRUE),
			    CDKparamValue (&params, 'S', FALSE));

   /* Check if we got a null value back. */
   if (question == 0)
   {
      /* Shut down Cdk. */
      destroyCDKScreen (cdkscreen);
      endCDK ();

      printf ("Cannot create the dialog box. Is the window too small?\n");
      ExitProgram (EXIT_FAILURE);
   }

   /* Activate the dialog box. */
   selection = activateCDKDialog (question, 0);

   /* Tell them what was selected. */
   if (question->exitType == vESCAPE_HIT)
   {
      mesg[0] = "<C>You hit escape. No button selected.";
      mesg[1] = "";
      mesg[2] = "<C>Press any key to continue.";
      popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
   }
   else if (question->exitType == vNORMAL)
   {
      sprintf (temp, "<C>You selected button #%d", selection);
      mesg[0] = temp;
      mesg[1] = "";
      mesg[2] = "<C>Press any key to continue.";
      popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
   }

   /* Clean up. */
   destroyCDKDialog (question);
   destroyCDKScreen (cdkscreen);
   endCDK ();
   ExitProgram (EXIT_SUCCESS);
}
CCDKDialog::CCDKDialog(CDKSCREEN *pScreen, int x, int y, char **message, int mcount, char **buttons, int bcount,
                       chtype hlight, bool sep, bool box, bool shadow) : CBaseCDKWidget(box)
{
    m_pDialog = newCDKDialog(pScreen, x, y, message, mcount, buttons, bcount, hlight, sep, box, shadow);
    if (!m_pDialog) throwerror(false, "Could not create dialog window");
}