/* * 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; }
int CCDKDialog::Activate(chtype *actions) { SetButtonBar(); int ret = activateCDKDialog(m_pDialog, actions); ButtonBar.Pop(); return ret; }
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; }
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 ); }
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); }
/* * 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, ¶ms, 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 (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', CENTER), (CDK_CSTRING2) message, 7, (CDK_CSTRING2) buttons, 2, COLOR_PAIR (2) | A_REVERSE, TRUE, CDKparamValue (¶ms, 'N', TRUE), CDKparamValue (¶ms, '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); }