コード例 #1
0
void CFunctionsView::OnNewClick()
{
	if(!m_context) return;

	TCHAR sNameX[256];
	uint32 nAddress = 0;

	{
		Framework::Win32::CInputBox inputBox(_T("New Function"), _T("New Function Name:"), _T(""));
		const TCHAR* sValue = inputBox.GetValue(m_hWnd);
		if(sValue == NULL) return;
		_tcsncpy(sNameX, sValue, 255);	
	}

	{
		Framework::Win32::CInputBox inputBox(_T("New Function"), _T("New Function Address:"), _T("00000000"));
		const TCHAR* sValue = inputBox.GetValue(m_hWnd);
		if(sValue == NULL) return;
		if(sValue != NULL)
		{
			_stscanf(sValue, _T("%x"), &nAddress);
			if((nAddress & 0x3) != 0x0)
			{
				MessageBox(m_hWnd, _T("Invalid address."), NULL, 16);
				return;
			}
		}
	}

	m_context->m_Functions.InsertTag(nAddress, string_cast<std::string>(sNameX).c_str());

	RefreshList();
	OnFunctionsStateChange();
}
コード例 #2
0
void ItalicAction::actionTriggered(QAction *sender, bool toggled)
{
	auto chatEditBox = qobject_cast<ChatEditBox *>(sender->parent());
	if (!chatEditBox)
		return;

	chatEditBox->inputBox()->setFontItalic(toggled);
}
コード例 #3
0
ファイル: TUI.cpp プロジェクト: bhaggerty/wwiv
    virtual bool Execute()
    {
        UIDesktop *desktop = UIDesktop::GetDesktop();
		UIInputBox inputBox(desktop, 5, 40, 5, 20, "Enter Name:", "Input Demo");
		inputBox.Run();
		std::string result = inputBox.GetText();
		desktop->WriteCentered(desktop->GetHeight() - 3, result);
        return true;
    }
コード例 #4
0
ファイル: inputboxnocancel.cpp プロジェクト: UIKit0/digikam
QString InputBoxNoCancel::AskForString(const QString& title, const QString& label, const QString& initialString, QWidget* const parent)
{
    QString workString = initialString;
    QPointer<InputBoxNoCancel> inputBox(new InputBoxNoCancel(title, label, &workString, parent));
    inputBox->exec();

    delete inputBox;

    return workString;
}
コード例 #5
0
void MenuPanel::createInputBox(const InputBoxInfo& info)
{
    std::unique_ptr<InputBox> inputBox(new InputBox(info.id,
                                                    m_position,
                                                    info.position,
                                                    info.size,
                                                    info.inputLimit,
                                                    info.style));
    inputBox->setVisibleWhenId(info.visibleWhenId);

    m_elements.push_back(std::move(inputBox));
}
コード例 #6
0
ファイル: psp_msg.c プロジェクト: BASLQC/snes9x-euphoria
////////////////////////////////////////////////////////////////////////////////////////
// psp_msg
// -------------- 
//		input : message id, display length
//		output : none
//		comments : show the message in current language.
//							 len allow display length value and special dialog selection
//							 ("yes/no" box or "ok" box).
////////////////////////////////////////////////////////////////////////////////////////
int psp_msg(int num,int len) {	
	int msg_num=0;
	
	while (msg_num<MSG_TOTAL_ENTRIES) {
		if (num==s9xTYL_msg[os9x_language][msg_num].msg_id) break;
		msg_num++;
	}
	if (msg_num==MSG_TOTAL_ENTRIES) return 0;
		
	if (len==MSG_DEFAULT)	len=s9xTYL_msg[os9x_language][msg_num].len;
	if (len>=0)	msgBoxLines(s9xTYL_msg[os9x_language][msg_num].msg,s9xTYL_msg[os9x_language][msg_num].len);
	else if (len==-1) inputBoxOK(s9xTYL_msg[os9x_language][msg_num].msg);
	else if (len==-2) return inputBox(s9xTYL_msg[os9x_language][msg_num].msg);
	return 0;
}
コード例 #7
0
ファイル: test.cpp プロジェクト: idispatch/tvision
void TMyApp::handleEvent(TEvent& event)
 {
  TApplication::handleEvent(event);
  if( event.what == evCommand )
      {
	switch( event.message.command )
	    {
	     case cmInputBox:
	       inputBox();
	      break;

	     default:
	      return;
	    }
	clearEvent( event );
      }
 }
コード例 #8
0
ファイル: trilobite.cpp プロジェクト: kirbyUK/trilobite
int main(int argc, char* argv[])
{
    //The current working directory:
    Directory* dir = NULL;

    //Checks if too many arguments have been given:
    if(argc > 2)
    {
        std::cerr << "Please pass a single, valid directory\n";
        return -1;
    }
    //Otherwise, sees if a directory has been given,
    //and if so, attempt to open it:
    else if(argc == 2)
    {
        //Attempt to open
        try
        {
            dir = new Directory(argv[1]);
        }
        //Give an error message and quit if it fails:
        catch(int e)
        {
            std::cerr << "Cannot open '" << argv[1] << "': ";
            switch(e)
            {
            case EACCES:
                std::cerr << "Permission denied.";
                break;
            case ENOENT:
                std::cerr << "No such directory.";
                break;
            case ENOTDIR:
                std::cerr << "Not a directory.";
                break;
            }
            std::cerr << std::endl;
            return -1;
        }
    }
    //Otherwise, there are no arguments given, so use
    //the user's current working directory:
    else
    {
        //Get the current working directory:
        char* cwd = getcwd(NULL, 0);

        //Attempt to open it:
        try
        {
            dir = new Directory(cwd);
        }
        //Give an error message and quit if it fails:
        catch(int e)
        {
            std::cerr << "Cannot open '" << cwd << "': ";
            switch(e)
            {
            case EACCES:
                std::cerr << "Permission denied.";
                break;
            case ENOENT:
                std::cerr << "No such directory.";
                break;
            case ENOTDIR:
                std::cerr << "Not a directory.";
                break;
            }
            std::cerr << std::endl;
            return -1;
        }
    }
    //Attempt to read the directory's contents:
    try
    {
        dir->read();
    }
    //Give an error message and quit if it fails:
    catch(int e)
    {
        std::cerr << "Cannot open '" << dir->getPath() << "': ";
        switch(errno)
        {
        case EACCES:
            std::cerr << "Permission denied.";
            break;
        case ENOENT:
            std::cerr << "No such directory.";
            break;
        case ENOTDIR:
            std::cerr << "Not a directory.";
            break;
        }
        std::cerr << std::endl;
        return -1;
    }

    if(dir->getName() == "../")
        dir->cleanPath();

    //Initialise ncurses:
    initscr();

    //The colour pairs:
    init_pair(2, COLOR_WHITE, COLOR_RED);
    //Enable keypad mode (allows use of the up and down arrows):
    keypad(stdscr, true);

    //Start using colour:
    start_color();

    //Update the screen:
    refresh();

    //Hides the cursor, set 'noecho()':
    curs_set(0);
    noecho();

    int input = 0;
    std::string path = "";
    unsigned int selection = 0;
    DiskItem* clipboard = NULL;

    //While the user has not quit:
    while((char(input) != 'q') && (char(input) != 'Q'))
    {
        //Redraw the windows and help:
        updateWindows();
        drawHelp();

        //If necessary, resizes the directory path:
        path = "";
        if(dir->getPath().length() >= screenX)
            path = fitToSize(dir->getPath(), (screenX - 2));
        else
            path = dir->getPath();

        //The X position needed to print the path in the centre:
        int pos = ((screenX - path.length()) / 2);
        //Write the user's current directory:
        mvprintw(0, pos, "%s", path.c_str());

        //Get the files and sort the contents:
        std::vector <DiskItem*> items = dir->getFiles();

        //Checks if the contents of the directory will fit in the window:
        if((fileview.height - 2) > (items.size() - dir->getDotfiles()))
        {
            //Print the contents, except the dotfiles, to the window:
            for(unsigned int i = dir->getDotfiles(); i < items.size(); i++)
            {
                //If we're printing the current selection, highlight it:
                if(selection == (i - dir->getDotfiles()))
                {
                    //Print the name:
                    mvwprintw(fileview.window,((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());

                    //Move to the beginning of the line, and highlight the line up to but excluding the window border:
                    mvwchgat(fileview.window, ((i - dir->getDotfiles()) + 1), 1, (fileview.width - 2), A_NORMAL, 1, NULL);
                }
                else
                    //Print the name:
                    mvwprintw(fileview.window, ((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());
            }
        }
        //Otherwise, we can only print part of the directory's contents:
        else
        {
            //If the selection is less than the height, display the first few items:
            if(selection < (fileview.height - 2))
            {
                for(unsigned int i = dir->getDotfiles(); i < ((fileview.height - 2) + dir->getDotfiles()); i++)
                {
                    //If we're printing the current selection, highlight it:
                    if(selection == (i - dir->getDotfiles()))
                    {
                        //Print the name:
                        mvwprintw(fileview.window,((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());

                        //Move to the beginning of the line, and highlight the line up to but excluding the window border:
                        mvwchgat(fileview.window, ((i - dir->getDotfiles()) + 1), 1, (fileview.width - 2), A_NORMAL, 1, NULL);
                    }
                    else
                        //Print the name:
                        mvwprintw(fileview.window, ((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());
                }
            }
            //Otherwise, display the selection as the last item:
            else
            {
                for(unsigned int i = (dir->getDotfiles() + ((selection + 1) - (fileview.height - 2))); i < ((selection + 1) + dir->getDotfiles()); i++)
                {
                    unsigned int y = i - ((selection - (fileview.height - 2)) + dir->getDotfiles());

                    //If we're printing the current selection, highlight it:
                    if(selection == (i - dir->getDotfiles()))
                    {
                        //Print the name:
                        mvwprintw(fileview.window, y, 1, "%s", items[i]->getName().c_str());

                        //Move to the beginning of the line, and highlight the line up to but excluding the window border:
                        mvwchgat(fileview.window, y, 1, (fileview.width - 2), A_NORMAL, 1, NULL);
                    }
                    else
                        //Print the name:
                        mvwprintw(fileview.window, y, 1, "%s", items[i]->getName().c_str());
                }
            }
        }

        //Print the selected file's metadata to the 'fileinfo' window:
        printMetaData(items[selection + dir->getDotfiles()]);

        //Print the contents of the clipboard to the 'extrainfo' window:
        printClipboard(clipboard);

        //Refresh the screen and windows:
        refresh();
        wrefresh(fileview.window);
        wrefresh(fileinfo.window);
        wrefresh(extrainfo.window);

        //Gets the input:
        input = getch();

        //Moves the selection up or down if those keys were pressed:
        if((input == KEY_UP) || (char(input) == 'k') || (char(input) == 'K'))
            if(selection > 0) selection--;
        if((input == KEY_DOWN) || (char(input) == 'j') || (char(input) == 'J'))
            if(selection < ((items.size() - dir->getDotfiles()) - 1)) selection++;

        //If the user has pressed Enter:
        if(char(input) == '\n')
        {
            //Attempts to cast the current selection to a Directory*:
            Directory* selected = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]);

            //If the user has selected a directory:
            if(selected != NULL)
            {
                //Keep the old directory so we can delete it:
                Directory* oldDir = dir;

                //Makes a copy of the directory we want to move to:
                try
                {
                    dir = new Directory(selected);
                    dir->read();

                    delete oldDir;
                    selection = 0;

                    clear();
                }
                //If an error occurs, inform the user with a message box:
                catch(int e)
                {
                    std::string error = "Cannot open '" + dir->getPath() + "' ";
                    switch(errno)
                    {
                    case EACCES:
                        error += "Permission denied.";
                        break;
                    case ENOENT:
                        error += "No such directory.";
                        break;
                    case ENOTDIR:
                        error += "Not a directory.";
                        break;
                    }
                    messageBox(error);
                }
            }
        }
        //Otherwise, if the user has pressed 'd' for delete:
        else if((char(input) == 'd') || (char(input) == 'D'))
        {
            DiskItem* selected = items[selection + dir->getDotfiles()];
            //Attempt to delete the selected item:
            if(selected->deletef())
            {
                delete selected;
                dir->getFiles().erase(dir->getFiles().begin() + (selection + dir->getDotfiles()));

                //If we deleted the last item, then 'selection + dir->getDotfiles()' will
                //go out of bounds on the 'item' array, so decrement selection:
                if((selection + dir->getDotfiles()) == dir->getFiles().size())
                    selection--;
            }
            //If an error occurs, inform the user with a message box:
            else
            {
                std::string error = "Could not delete '" + selected->getPath() + "'";
                messageBox(error);
            }
        }
        //Otherwise, if the user has pressed 'c' for copy:
        else if((char(input) == 'C') || (char(input) == 'c'))
        {
            if(items[selection + dir->getDotfiles()]->getName() != "../")
            {
                //Checks if we are trying to copy a directory or a file:
                clipboard = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]);

                if(clipboard == NULL)
                {
                    //We are copying a file:
                    clipboard = new File(dynamic_cast <File*>(items[selection + dir->getDotfiles()]));
                }
                else
                {
                    //We are copying a directory:
                    clipboard = new Directory(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]));
                }
            }
        }
        //Otherwise, if the user has pressed 'x' for cut:
        else if((char(input) == 'X') || (char(input) == 'x'))
        {
            if(items[selection + dir->getDotfiles()]->getName() != "../")
            {
                //Checks if we are trying to cut a directory or a file:
                clipboard = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]);

                if(clipboard == NULL)
                {
                    //We are cutting a file:
                    clipboard = new File(dynamic_cast <File*>(items[selection + dir->getDotfiles()]));
                }
                else
                {
                    //We are cutting a directory:
                    clipboard = new Directory(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]));
                }
                clipboard->cut();
            }
        }
        //Otherwise, if the user has pressed 'p' for paste:
        else if((char(input) == 'P') || (char(input) == 'p'))
        {
            if(clipboard != NULL)
            {
                //Attempt to paste the item in the clipboard:
                if(! clipboard->paste(dir->getPath()))
                {
                    //If an error occurs, inform the user with a message box:
                    std::string error = "Could not paste '" + clipboard->getName() + "'";
                    messageBox(error);
                }
                else
                {
                    //If it works fine, add the new item to the directory's list of items:
                    DiskItem* item = clipboard;
                    dir->getFiles().push_back(item);
                    std::sort(dir->getFiles().begin(), dir->getFiles().end(), byName);

                    //Empty the clipboard:
                    clipboard = NULL;
                }
            }
        }
        //Otherwise, if the user presses 'r' for rename:
        else if((char(input) == 'R') || (char(input) == 'r'))
        {
            //Get the new name, and attempt to rename the selected item:
            std::string newName = inputBox();
            if(newName != "")
            {
                //Check if we are renaming a directory:
                if(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]) != NULL)
                    newName += '/';

                if(! items[selection + dir->getDotfiles()]->rename(newName.c_str()))
                {
                    //If an error occurs, inform the user with a message box:
                    std::string error = "Cannot rename '" + items[selection + dir->getDotfiles()]->getName() + "'";
                    messageBox(error);
                }
            }
        }
    }

    //Delete the directory object:
    delete dir;

    //Close ncurses:
    endwin();
    return 0;
}
コード例 #9
0
int
main (void)
{
  bowl_init ();
#if 0
  twoButtonBox ("some sample text", "confirmation", "yes", "no");
#elif 0
  problemBox (MSG_SILO_PROBLEM, MSG_PROBLEM);
#elif 0
  for (;;)
    {
      pleaseWaitBox (MSG_RUNNING_LILO);
      sleep (2);
    }
#elif 0
  inputBox (MSG_LINUX_AND_SWAP, MSG_NO_SWAP_PARTITION, "/dev/sda1");
#elif 1
  {
      char buf[128];
      enterDirBox ("Enter a directory", "Here you must type the directory name", "/debian", buf, 128);
  }
#elif 1
  {
    struct d_choices opt[30];
    int i;

    for (i = 0; i < 30; i++)
      {
	opt[i].tag = malloc (16);
	sprintf (opt[i].tag, "таг %d", i);
	opt[i].string = malloc (128);
	sprintf (opt[i].string, "item %d", i);
	opt[i].state = i;
      }

    menuBox ("This is a little text", "I'm the title", opt, 30, 1);
  }
#elif 1
  {
    char *choices[30];
    char values[30];
    char *valuesp;
    int i;

    for (i = 0; i < 30; i++)
      {
	choices[i] = malloc (128);
	sprintf (choices[i], "item %d", i);
	values[i] = i % 2 ? '*' : ' ';
      }

    valuesp = values;
    checkBox ("This is a little text", "I'm the title", 10, 50,
	      choices, &valuesp, 30);
  }
#elif 0
  {
    int i;

    scaleBox ("Installing rescue floppy...", "Please wait",
	      10, SCALE_CREATE);
    for (i = 0; i <= 10; i++)
      {
	scaleBox (NULL, NULL, i, SCALE_REFRESH);
	sleep (1);
      }
  }
#elif 1
  bowl_new_text (MSG_BAD_FLOPPY MSG_LINUX_AND_SWAP);
  bowl_title (MSG_NO_SWAP_PARTITION);
  bowl_new_button (MSG_YES, 0);
  bowl_new_button (MSG_NO, 0);
  bowl_new_button (_("Cancel"), 0);
  bowl_new_button ("Quit", 0);
  bowl_new_button ("Help", 0);
  bowl_layout ();
  bowl_run ();
#endif

  return 0;
}
コード例 #10
0
ファイル: cmd_copymove.c プロジェクト: VWarlock/C8080
char cmd_copymove1(uchar copymode, uchar shiftPressed) {
  char *name;
  char e;
  FileInfo* f;
  char sourceFile[256];
  char mask[11];
  char forMask[11];
  char type;
  uint i;

  if(shiftPressed) {
    // Копируем имя c первой панели (без пути)
    f = getSelNoBack();
    if(!f) return 0; // Файл не выбран, выходим без ошибки
    unpackName(cmdLine, f->fname);
  } else {
    // Копируем путь со второй панели
    i = strlen(panelB.path1);
    if(i >= 254) return ERR_RECV_STRING; // Так как прибавим 2 символа
    cmdLine[0] = '/';
    strcpy(cmdline+1, panelB.path1);
    if(i != 0) strcpy(cmdline+i+1, "/");
  }

  // Позволяем пользователю изменить путь или имя
  if(!inputBox(copymode ? " kopirowatx " : " pereimenowatx/peremestitx ") && cmdline[0]!=0) return 0;

  // Преобразование относительного пути в абсолютный
  if(!absolutePath(cmdline)) return ERR_RECV_STRING;

  // Используется ли маска?
  mask[0] = 0;  
  name = getname(cmdline);
  if(name[0] != 0) {
    // Сохраняем маску
    packName(mask, name);
    // Убираем из пути маску
    dropPathInt(cmdLine, 0);
  } else {
    // Если в ком строке что то есть, а имя не выделено, значит ком строка оканчивается на /.
    // Этот символ надо удалить
    if(cmdline[0] != 0 && name[0] == 0) name[-1] = 0;
  }

  // Ищем первый файл
  type = getFirstSelected(sourceFile);
  if(type == 0) return 0; // Нет выбранных файлов

  for(;;) {
    // Преобразование относительного пути в абсолютный
    if(!absolutePath(sourceFile)) { e = ERR_RECV_STRING; break; }

    // Добавляем имя
    packName(forMask, getname(sourceFile));
    if(mask[0]) applyMask(forMask, mask);
    if(catPathAndUnpack(cmdline, forMask)) return ERR_RECV_STRING;

    // Самого в мебя не копируем и не переименовываем
    if(0!=strcmp(sourceFile, cmdline)) {
      // Выполнение операции
      if(copymode) {
        if(type==2) {
          e = cmd_copyFolder(sourceFile, cmdline);
        } else {
          e = cmd_copyFile(sourceFile, cmdline);
        }
      } else {
        // Простое окно
        drawWindow(" pereimenowanie/pereme}enie ");
        drawWindowText(0, 1, "iz:");
        drawWindowText(4, 1, sourceFile);
        drawWindowText(0, 2, "w:");
        drawWindowText(4, 2, cmdline);
        drawAnyKeyButton();

        // Прерывание
        if(fs_bioskey(1) == KEY_ESC) { e = ERR_USER; break; }

        e = fs_move(sourceFile, cmdline);    
      }

      if(e) break;
    }

    // Убираем из пути имя файла
    dropPathInt(cmdLine, 0);

    // Следующий выбранный файл
    type = getNextSelected(sourceFile);
    if(type == 0) { e=0; break; }
  } // конец цикла

  // При переносе файла надо обновить обе панели
  // А при копировании список файов используется под буфер
  getFiles();
  dupFiles(1);

  return e;
}
コード例 #11
0
ファイル: whiptcl.c プロジェクト: cyberbeat/mysql-gui-tools
static int wtCmd(ClientData clientData, Tcl_Interp * interp, int argc,
                  char ** argv) {
    enum mode mode = MODE_NONE;
    poptContext optCon;
    int arg;
    const char * optArg;
    const char * text;
    const char * nextArg;
    char * end;
    int height;
    int width;
    int noCancel = 0;
    int noItem = 0;
    int scrollText = 0;
    int rc = 0;
    int flags = 0;
    int defaultNo = 0;
    char * result;
    char ** selections, ** next;
    char * title = NULL;
    struct poptOption optionsTable[] = {
	    { "checklist", '\0', 0, 0, OPT_CHECKLIST },
	    { "defaultno", '\0', 0, &defaultNo, 0 },
	    { "inputbox", '\0', 0, 0, OPT_INPUTBOX },
	    { "menu", '\0', 0, 0, OPT_MENU },
	    { "msgbox", '\0', 0, 0, OPT_MSGBOX },
	    { "nocancel", '\0', 0, &noCancel, 0 },
	    { "noitem", '\0', 0, &noItem, 0 },
	    { "radiolist", '\0', 0, 0, OPT_RADIOLIST },
	    { "scrolltext", '\0', 0, &scrollText, 0 },
	    { "title", '\0', POPT_ARG_STRING, &title, 0 },
	    { "yesno", '\0', 0, 0, OPT_YESNO },
	    { 0, 0, 0, 0, 0 } 
    };
    
    optCon = poptGetContext("whiptcl", argc, argv, optionsTable, 0);

    while ((arg = poptGetNextOpt(optCon)) > 0) {
	optArg = poptGetOptArg(optCon);

	switch (arg) {
	  case OPT_MENU:
	    if (mode != MODE_NONE) rc = -1;
	    mode = MODE_MENU;
	    break;

	  case OPT_MSGBOX:
	    if (mode != MODE_NONE) rc = -1;
	    mode = MODE_MSGBOX;
	    break;

	  case OPT_RADIOLIST:
	    if (mode != MODE_NONE) rc = -1;
	    mode = MODE_RADIOLIST;
	    break;

	  case OPT_CHECKLIST:
	    if (mode != MODE_NONE) rc = -1;
	    mode = MODE_CHECKLIST;
	    break;

	  case OPT_YESNO:
	    if (mode != MODE_NONE) rc = -1;
	    mode = MODE_YESNO;
	    break;

	  case OPT_INPUTBOX:
	    if (mode != MODE_NONE) rc = -1;
	    mode = MODE_INPUTBOX;
	    break;
	}
    }
    
    if (arg < -1) {
	/* this could buffer oveflow, bug we're not setuid so I don't care */
	interp->result = malloc(200);
	interp->freeProc = TCL_DYNAMIC;
	sprintf(interp->result, "%s: %s\n", 
		poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
		poptStrerror(arg));

	return TCL_ERROR;
    }

    if (mode == MODE_NONE) {
	interp->result = "no dialog mode was specified";
	return TCL_ERROR;
    } else if (rc) {
	interp->result = "multiple modes were specified";
	return TCL_ERROR;
    }

    if (!(text = poptGetArg(optCon))) {
	interp->result = "missing text parameter";
	return TCL_ERROR;
    }

    if (!(nextArg = poptGetArg(optCon))) {
	interp->result = "height missing";
	return TCL_ERROR;
    }
    height = strtoul(nextArg, &end, 10);
    if (*end) {
	interp->result = "height is not a number";
	return TCL_ERROR;
    }

    if (!(nextArg = poptGetArg(optCon))) {
	interp->result = "width missing";
	return TCL_ERROR;
    }
    width = strtoul(nextArg, &end, 10);
    if (*end) {
	interp->result = "width is not a number";
	return TCL_ERROR;
    }

    width -= 2;
    height -= 2;
    newtOpenWindow((80 - width) / 2, (24 - height) / 2, width, height, title);

    if (noCancel) flags |= FLAG_NOCANCEL;
    if (noItem) flags |= FLAG_NOITEM;
    if (scrollText) flags |= FLAG_SCROLL_TEXT;
    if (defaultNo) flags |= FLAG_DEFAULT_NO;

    switch (mode) {
      case MODE_MSGBOX:
	rc = messageBox(text, height, width, MSGBOX_MSG, flags);
	break;

      case MODE_YESNO:
	rc = messageBox(text, height, width, MSGBOX_YESNO, flags);
	if (rc == DLG_OKAY)
	    interp->result = "yes";
	else 
	    interp->result = "no";
	if (rc == DLG_ERROR) rc = 0;
	break;

      case MODE_INPUTBOX:
	rc = inputBox(text, height, width, optCon, flags, &result);
	if (!rc) {
	    interp->result = strdup(result);
	    interp->freeProc = TCL_DYNAMIC;
	}
	break;

      case MODE_MENU:
	rc = listBox(text, height, width, optCon, flags, &result);
	if (!rc) {
	    interp->result = strdup(result);
	    interp->freeProc = TCL_DYNAMIC;
	}
	break;

      case MODE_RADIOLIST:
	rc = checkList(text, height, width, optCon, 1, flags, &selections);
	if (!rc) {
	    interp->result = strdup(selections[0]);
	    interp->freeProc = TCL_DYNAMIC;
	}
	break;

      case MODE_CHECKLIST:
	rc = checkList(text, height, width, optCon, 0, flags, &selections);

	if (!rc) {
	    for (next = selections; *next; next++) 
		Tcl_AppendElement(interp, *next);

	    free(selections);
	}
	break;

      case MODE_NONE:
	/* this can't happen */
    }

    newtPopWindow();

    if (rc == DLG_ERROR) {
	interp->result = "bad paramter for whiptcl dialog box";
	return TCL_ERROR;
    } 

    Tcl_SetVar(interp, "whiptcl_canceled", (rc == DLG_CANCEL) ? "1" : "0",
		0);

    return TCL_OK;
}

static char * setBacktext(ClientData data, Tcl_Interp * interp, 
			  char * name1, char * name2, int flags) {
    static char blankLine[81] = "                                        "
                         "                                        ";

    newtDrawRootText(0, 0, blankLine);
    newtDrawRootText(0, 0, Tcl_GetVar(interp, "whiptcl_backtext",
		                      TCL_GLOBAL_ONLY));

    return NULL;
}

static char * setHelptext(ClientData data, Tcl_Interp * interp, 
			  char * name1, char * name2, int flags) {
    char * text = Tcl_GetVar(interp, "whiptcl_helpline", TCL_GLOBAL_ONLY);

    if (!text)
	text = "";
    else if (!strlen(text))
	text = NULL;

    newtPopHelpLine();
    newtPushHelpLine(text);

    return NULL;
}