4 * Some standard Straylight dboxes.
6 * © 1993-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Steel library.
13 * Steel is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Steel is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Steel. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 #define stddbox__WARNING_TITLE 0
43 #define stddbox__WARNING_MESSAGE 5
44 #define stddbox__WARNING_OK 4
45 #define stddbox__WARNING_CANCEL 3
47 #define stddbox__NOTE_TITLE 2
48 #define stddbox__NOTE_MESSAGE 0
49 #define stddbox__NOTE_OK 1
51 #define stddbox__WRITE_OK 0
52 #define stddbox__WRITE_WRITE 1
54 #define stddbox__SAVEWARN_TITLE 0
55 #define stddbox__SAVEWARN_MESSAGE 5
56 #define stddbox__SAVEWARN_CANCEL 3
57 #define stddbox__SAVEWARN_SAVE 4
58 #define stddbox__SAVEWARN_REMOVE 7
60 #define stddbox__PROGINFO_TITLE 0
61 #define stddbox__PROGINFO_NAME 7
62 #define stddbox__PROGINFO_PURPOSE 5
63 #define stddbox__PROGINFO_AUTHOR 3
64 #define stddbox__PROGINFO_VERSION 1
66 static xfersend_saveproc stddbox__save;
67 static BOOL stddbox__saved;
70 * BOOL warning(char *okMsg,char *warn,...)
73 * Pops up a warning box, with a Cancel button and a default action button
74 * with your own text in it.
77 * char *okMsg == what to put in the default action button
78 * char *warn == the warning message (printf()-style format string)
81 * TRUE if the user chose the OK button.
84 BOOL warning(char *okMsg,char *warn,...)
86 dbox warndb=dbox_create("warning");
91 vsprintf(msg,warn,ap);
97 dbox_syshandle(warndb),
98 msgs_lookup("stddbWARN:Warning from %s"),
101 dbox_setfield(warndb,stddbox__WARNING_MESSAGE,msg);
102 dbox_setfield(warndb,stddbox__WARNING_OK,okMsg);
103 if (!dbox_hasTitle(warndb))
104 dbox_setEmbeddedTitle(warndb,stddbox__WARNING_TITLE,FALSE);
106 clicked=nopoll_doDbox
111 stddbox__WARNING_CANCEL,
115 return (clicked==nopoll_OK);
119 * void note(char *notemsg,...)
122 * Displays a small note on the screen, so you can tell the user that he
123 * has done something silly, etc. A lot nicer than old werr().
126 * char *notemsg == the note (printf()-style format string)
129 void note(char *notemsg,...)
131 dbox notedb=dbox_create("note");
134 va_start(ap,notemsg);
135 vsprintf(msg,notemsg,ap);
141 dbox_syshandle(notedb),
142 msgs_lookup("stddbNOTE:Note from %s"),
145 dbox_setfield(notedb,stddbox__NOTE_MESSAGE,msg);
146 if (!dbox_hasTitle(notedb))
147 dbox_setEmbeddedTitle(notedb,stddbox__NOTE_TITLE,FALSE);
148 nopoll_doDbox(notedb,nopoll_ONPTR,stddbox__NOTE_OK,-1,-1);
158 * stddbox_writableHandler proc,
163 * Opens a dialogue box for the user to input a string. Needs the
164 * 'writable' template.
167 * char *title == the title for the dialogue box.
168 * char *default == the default string to put in the writable area.
169 * char *result == a buffer to contain the result string. May be 0.
170 * stddbox_writableHandler proc == proc to call when OK is clicked. May
171 * be 0. Return TRUE if successful (i.e. we may close the dbox).
172 * void *handle == passed to proc.
175 * TRUE if the string has been updated.
183 stddbox_writableHandler proc,
187 dbox w=dbox_create("writable");
196 dbox_setfield(w,1,"%s",deflt);
197 win_settitle(dbox_syshandle(w),"%s",title);
198 dbox_display(w,FALSE);
201 switch (dbox_fillin(w))
208 dbox_getfield(w,1,result,256);
210 mayClose=proc(result,handle);
214 if (dbox_wasAdjustClick() || mayClose==FALSE)
230 * BOOL stddbox__saver(char *filename,void *handle)
233 * Passes on the save request to the caller's own save routine, and erases
234 * the data if the file is now safe.
237 * char *filename == where to save the file
238 * void *handle == the caller's handle to the data
241 static BOOL stddbox__saver(char *filename,void *handle)
243 if (stddbox__save(filename,handle)==FALSE)
245 if (saveas_file_is_safe())
254 * void (*dispose)(void *handle),
259 * xfersend_saveproc saveproc,
260 * xfersend_sendproc sendproc,
261 * xfersend_printproc printproc,
266 * Pops up a save warning box allowing the use the luxury of saving his
267 * data before closing the file. The file is only removed if the data is
271 * BOOL useName == whether to use the given name in the warning message
272 * void (*dispose)(void *handle) == function to dispose the user's data
273 * the others == as for saveas()
279 void (*dispose)(void *handle),
284 xfersend_saveproc saveproc,
285 xfersend_sendproc sendproc,
286 xfersend_printproc printproc,
291 if (win_anyWindows())
293 d=dbox_create("saveWarn");
299 msgs_lookup("stddbWARN:Warning from %s"),
306 stddbox__SAVEWARN_MESSAGE,
307 msgs_lookup("stddbREFN:File '%s' has been modified, but not saved. "
308 "Do you want to discard these changes, save and then "
309 "close the file, or cancel?"),
316 stddbox__SAVEWARN_MESSAGE,
317 msgs_lookup("stddbREF:This file has been modified, but not saved. "
318 "Do you want to discard these changes, save and then "
319 "close the file, or cancel?")
321 if (!dbox_hasTitle(d))
322 dbox_setEmbeddedTitle(d,stddbox__SAVEWARN_TITLE,FALSE);
323 stddbox__save=saveproc;
325 switch (nopoll_doDbox
329 stddbox__SAVEWARN_SAVE,
330 stddbox__SAVEWARN_CANCEL,
331 stddbox__SAVEWARN_REMOVE
335 stddbox__saved=FALSE;
365 msgs_lookup("stddbREFN:Are you sure you want to "
366 "remove edited file '%s'?"),
373 msgs_lookup("stddbREF:Are you sure you want to "
374 "remove your edited file?")
392 * Presents a standard progInfo window giving information about an
396 * char *name == the name of the program
397 * char *purpose == what it does
398 * char *author == author/copyright string (usually something like
399 * '© 1993-1998 Straylight')
400 * int version == the version number*100 (e.g. 374 for 3.74 etc.)
401 * char *date == the date of compilation (use _TIME_NOW)
404 void progInfo(char *name,char *purpose,char *author,int version,char *date)
406 dbox d=dbox_create("progInfo");
410 if (!dbox_hasTitle(d))
411 dbox_setEmbeddedTitle(d,stddbox__PROGINFO_TITLE,TRUE);
412 dbox_setfield(d,stddbox__PROGINFO_NAME,"%s",name);
413 dbox_setfield(d,stddbox__PROGINFO_PURPOSE,"%s",purpose);
414 dbox_setfield(d,stddbox__PROGINFO_AUTHOR,"%s",author);
418 stddbox__PROGINFO_VERSION,
425 msgs_lookup("stddbPIH:This window gives you "
426 "information about this version of %s."),
427 wimpt_programname());
435 * Handles a monologue box (like info windows) where no input is required.
436 * You should create the dbox, fill in any fields required. This routine
437 * then handles the rest. It deletes the dbox when it's finished - it's of
438 * no use to the caller anyway - who wants a used dialogue box with no
441 * You can specify a help message tag to be displayed before any messages
442 * embedded in the icons. This is passed through msgs_lookup before
443 * sending to help_addLine. Specify zero for this to send no message.
446 * dbox d == the box to handle
447 * char *help == the help message tag to stick on the top
450 void mbox(dbox d,char *help)
453 dbox_display(d,dbox_MENU_OVERPTR);
456 switch (dbox_fillin(d))
464 help_addLine(msgs_lookup(help));