From: izydorst Date: Sun, 17 Aug 2003 14:34:05 +0000 (+0000) Subject: new MessageBox function X-Git-Tag: V2.12.0~1392 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1390fe6edd7ee9b71a67d9390856efda0e24031a;p=cc65 new MessageBox function git-svn-id: svn://svn.cc65.org/cc65/trunk@2347 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/include/geos/gdlgbox.h b/include/geos/gdlgbox.h index 8f54f5d96..5bbfa7322 100644 --- a/include/geos/gdlgbox.h +++ b/include/geos/gdlgbox.h @@ -1,9 +1,8 @@ /* GEOS dialog box functions - ported to small C on 26.12.1999 - by Maciej 'YTM/Alliance' Witkowiak - 10.03.2000 - update + by Maciej 'YTM/Elysium' Witkowiak + 26.12.1999, 10.03.2000, 17.8.2003 */ #ifndef _GDLGBOX_H @@ -23,6 +22,17 @@ char __fastcall__ DlgBoxGetString(char *myString, char strLength, char __fastcall__ DlgBoxFileSelect(const char *classtxt, char ftype, char *fname); +/* This is a more general dialog box, works like printf in a window */ +char MessageBox(char mode, const char *format, ...); + +/* mode argument for MessageBox() */ +enum { + MB_EMPTY=0, + MB_OK, + MB_OKCANCEL, + MB_YESNO, + MB_LAST }; + /* Now the command string type */ typedef void dlgBoxStr; diff --git a/libsrc/geos/dlgbox/Makefile b/libsrc/geos/dlgbox/Makefile index 29a83c33e..1c69d7d52 100644 --- a/libsrc/geos/dlgbox/Makefile +++ b/libsrc/geos/dlgbox/Makefile @@ -4,15 +4,21 @@ # # +%.o: %.c + @$(CC) $(CFLAGS) $< + @$(AS) -g -o $@ $(AFLAGS) $(*).s + %.o: %.s @$(AS) -o $@ $(AFLAGS) $< - +C_OBJS = messagebox.o S_OBJS = dodlgbox.o rstrfrmdialogue.o\ dbget2lines.o dlgboxyesno.o dlgboxokcancel.o dlgboxok.o dlgboxgetstring.o\ dlgboxfileselect.o -all: $(S_OBJS) +all: $(C_OBJS) $(S_OBJS) clean: @rm -f *.~ $(S_OBJS) core + @rm -f $(C_OBJS:.o=.s) + @rm -f $(C_OBJS) diff --git a/libsrc/geos/dlgbox/messagebox.c b/libsrc/geos/dlgbox/messagebox.c new file mode 100644 index 000000000..196512334 --- /dev/null +++ b/libsrc/geos/dlgbox/messagebox.c @@ -0,0 +1,88 @@ + +/* + * char MessageBox (char mode, const char *format, ...) + * + * Maciej 'YTM/Elysium' Witkowiak, 17.08.2003 + * + */ + +#include +#include + +void _mbprintout(void); + +static dlgBoxStr _mbdlg_EMPTY = { + DB_DEFPOS(1), + DB_OPVEC(&RstrFrmDialogue), + DB_USRROUT(&_mbprintout), + DB_END, +}; + +static dlgBoxStr _mbdlg_OK = { + DB_DEFPOS(1), + DB_OPVEC(&RstrFrmDialogue), + DB_USRROUT(&_mbprintout), + DB_ICON(OK, DBI_X_1, DBI_Y_2), + DB_END, +}; + +static dlgBoxStr _mbdlg_OKCANCEL = { + DB_DEFPOS(1), + DB_OPVEC(&RstrFrmDialogue), + DB_USRROUT(&_mbprintout), + DB_ICON(OK, DBI_X_0, DBI_Y_2), + DB_ICON(CANCEL, DBI_X_2, DBI_Y_2), + DB_END, +}; + +static dlgBoxStr _mbdlg_YESNO = { + DB_DEFPOS(1), + DB_OPVEC(&RstrFrmDialogue), + DB_USRROUT(&_mbprintout), + DB_ICON(YES, DBI_X_0, DBI_Y_2), + DB_ICON(NO, DBI_X_2, DBI_Y_2), + DB_END, +}; + +static dlgBoxStr *_mbboxes[] = { + &_mbdlg_EMPTY, + &_mbdlg_OK, + &_mbdlg_OKCANCEL, + &_mbdlg_YESNO +}; + +static char _mbbuffer[256]; + +char MessageBox(char mode, const char *format, ...) +{ + register char *buf; + va_list ap; + + /* first format out things */ + va_start(ap, format); + vsprintf(_mbbuffer, format, ap); + va_end(ap); + + /* replace LFs by CRs */ + buf = &_mbbuffer[0]; + while (*buf) { + if (*buf==LF) *buf=CR; + ++buf; + } + + /* validate mode */ + if (mode>=MB_LAST) + mode = MB_EMPTY; + + return DoDlgBox(_mbboxes[mode]); +} + +void _mbprintout(void) +{ + UseSystemFont(); + curWindow.top = DEF_DB_TOP; + curWindow.left = DEF_DB_LEFT+10; + curWindow.right = DEF_DB_RIGHT-10; + curWindow.bot = DEF_DB_BOT; + PutString(_mbbuffer, DEF_DB_TOP+10+curFontDesc.height, DEF_DB_LEFT+10 ); +}