コード例 #1
0
void iupShowError(Ihandle* parent, const char* message)
{
  Ihandle* dlg = IupMessageDlg();
  char* title = NULL, *str_message;

  if (parent)
  {
    IupSetAttributeHandle(dlg, "PARENTDIALOG", parent);
    title = IupGetAttribute(parent, "TITLE");
  }

  if (!title)
    title = "_@IUP_ERROR";

  IupSetStrAttribute(dlg, "TITLE", title);
  IupSetAttribute(dlg, "DIALOGTYPE", "ERROR");
  IupSetAttribute(dlg, "BUTTONS", "OK");

  str_message = IupGetLanguageString(message);
  if (!str_message)
    str_message = (char*)message;
  IupStoreAttribute(dlg, "VALUE", str_message);

  IupPopup(dlg, IUP_CURRENT, IUP_CURRENT);

  IupDestroy(dlg);
}
コード例 #2
0
void show_warning(const char* title, const char* message)
{
	Ihandle* dlg = IupMessageDlg();
	IupSetAttribute(dlg, "DIALOGTYPE", "WARNING");
	IupSetAttribute(dlg, "TITLE", title);
	IupSetAttribute(dlg, "VALUE", message);
	IupPopup(dlg, IUP_CURRENT, IUP_CURRENT);
	IupDestroy(dlg);
}
コード例 #3
0
ファイル: example4_2.c プロジェクト: sanikoyes/iup
void show_error(const char* message, int is_error)
{
  Ihandle* dlg = IupMessageDlg();
  IupSetStrAttribute(dlg, "PARENTDIALOG", IupGetGlobal("PARENTDIALOG"));
  IupSetAttribute(dlg, "DIALOGTYPE", is_error ? "ERROR" : "WARNING");
  IupSetAttribute(dlg, "BUTTONS", "OK");
  IupSetStrAttribute(dlg, "TITLE", is_error ? "Error" : "Warning");
  IupSetStrAttribute(dlg, "VALUE", message);
  IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT);
  IupDestroy(dlg);
}
コード例 #4
0
ファイル: predialogs.c プロジェクト: svn2github/iup-iup
static void new_message(char* type, char* buttons)
{
  Ihandle* dlg = IupMessageDlg();

  if (strcmp(type, "ERROR")!=0)
    IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_");
  IupSetAttribute(dlg, "DIALOGTYPE", type);
  IupSetAttribute(dlg, "TITLE", "IupMessageDlg Test");
  IupSetAttribute(dlg, "BUTTONS", buttons);
  IupSetAttribute(dlg, "VALUE", "Message Text\nSecond Line");
  if (strcmp(type, "WARNING")==0)
    IupSetAttribute(dlg, "BUTTONDEFAULT", "2");
  if (strcmp(type, "INFORMATION")!=0)
    IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb);

  IupPopup(dlg, IUP_CURRENT, IUP_CURRENT);

  printf("BUTTONRESPONSE(%s)\n", IupGetAttribute(dlg, "BUTTONRESPONSE"));

  IupDestroy(dlg);
}
コード例 #5
0
ファイル: iuplua_widgets.c プロジェクト: svn2github/iup-iup
static void CreateMessageDlg(void)
{
  lua_pushusertag(IupMessageDlg(), iuplua_tag);
}
コード例 #6
0
static int cb_btnDecodeToMorse(Ihandle *btn) {

	Ihandle *txtMorse, *txtAscii, *msgDialog;
	char *morseText, *asciiText;
	int morseLen, asciiLen;
	
	Ihandle *errorDialog;
	char *errorText;
	int opReturnCode;

	extern char *error_decode;
	extern BisTree textToMorse;           	/* Might be declared in the driver file */

	txtMorse = IupGetHandle(TXTMORSE_4);
	txtAscii = IupGetHandle(TXTASCII_2);

	asciiText = IupGetAttribute(txtAscii, "VALUE");
	asciiLen = strlen(asciiText);
	morseText = (char *) malloc(8 * asciiLen * sizeof(char));

	if (asciiLen == 0) {
		msgDialog = IupMessageDlg();
		IupSetAttribute(msgDialog, "DIALOGTYPE", "INFORMATION");
		IupSetAttribute(msgDialog, "TITLE", "Decoding Procedure");
		IupSetAttribute(msgDialog, "VALUE", generalInfo);
		IupSetAttribute(msgDialog, "BOTTONS", "OK");
		IupSetAttribute(msgDialog, "PARENTDIALOG", MAINDIALOG);
		IupPopup(msgDialog, IUP_CENTER, IUP_CENTER);
		IupDestroy(msgDialog);
//		IupSetAttribute(txtMorse, "VALUE", 0);
		goto END;
	}

	opReturnCode = morse_convAsciiToMorse(
						&textToMorse, asciiText, asciiLen, morseText, &morseLen);

	/* Check to see if decoding operation is successful or not */
	if (opReturnCode != 0) {
		
		errorText = (char *) malloc(strlen(error_decode) + 10);
		sprintf(errorText, error_decode, opReturnCode);
		
		errorDialog = IupMessageDlg();
		IupSetAttribute(errorDialog, "DIALOGTYPE", "ERROR");
		IupSetAttribute(errorDialog, "BUTTONS", "OK");
		IupSetAttribute(errorDialog, "TITLE", "Error");
		IupSetAttribute(errorDialog, "PARENTDIALOG", MAINDIALOG);
		IupSetAttribute(errorDialog, "VALUE", errorText);
		
		IupPopup(errorDialog, IUP_CENTER, IUP_CENTER);
		IupDestroy(errorDialog);
		free((void *) errorText);
		goto END;
	}
	
	/* Add a nul terminator at the end of the output buffer */
	*(morseText + morseLen) = '\0';

	/*printf("Decoded morse %s, len %d\n", morseText, morseLen);*/
	IupSetStrAttribute(txtMorse, "VALUE", morseText);

	END:
	cb_txtMorseAction(txtMorse);
	free((void *) morseText);

	return IUP_DEFAULT;
}