dialog.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * Exports and types from dialog.c.
  3. */
  4. /*
  5. * This will come in handy for generic control handlers. Anyone
  6. * knows how to make this more portable, let me know :-)
  7. */
  8. #define ATOFFSET(data, offset) ( (void *) ( (char *)(data) + (offset) ) )
  9. /*
  10. * This is the big union which defines a single control, of any
  11. * type.
  12. *
  13. * General principles:
  14. * - _All_ pointers in this structure are expected to point to
  15. * dynamically allocated things, unless otherwise indicated.
  16. * - `char' fields giving keyboard shortcuts are expected to be
  17. * NO_SHORTCUT if no shortcut is desired for a particular control.
  18. * - The `label' field can often be NULL, which will cause the
  19. * control to not have a label at all. This doesn't apply to
  20. * checkboxes and push buttons, in which the label is not
  21. * separate from the control.
  22. */
  23. #define NO_SHORTCUT '\0'
  24. enum {
  25. CTRL_TEXT, /* just a static line of text */
  26. CTRL_EDITBOX, /* label plus edit box */
  27. CTRL_RADIO, /* label plus radio buttons */
  28. CTRL_CHECKBOX, /* checkbox (contains own label) */
  29. CTRL_BUTTON, /* simple push button (no label) */
  30. CTRL_LISTBOX, /* label plus list box */
  31. CTRL_COLUMNS, /* divide window into columns */
  32. CTRL_FILESELECT, /* label plus filename selector */
  33. CTRL_FONTSELECT, /* label plus font selector */
  34. CTRL_TABDELAY /* see `tabdelay' below */
  35. };
  36. /*
  37. * Many controls have `intorptr' unions for storing user data,
  38. * since the user might reasonably want to store either an integer
  39. * or a void * pointer. Here I define a union, and two convenience
  40. * functions to create that union from actual integers or pointers.
  41. *
  42. * The convenience functions are declared as inline if possible.
  43. * Otherwise, they're declared here and defined when this header is
  44. * included with DEFINE_INTORPTR_FNS defined. This is a total pain,
  45. * but such is life.
  46. */
  47. typedef union { void *p; int i; } intorptr;
  48. #ifndef INLINE
  49. intorptr I(int i);
  50. intorptr P(void *p);
  51. #endif
  52. #if defined DEFINE_INTORPTR_FNS || defined INLINE
  53. #ifdef INLINE
  54. #define PREFIX INLINE
  55. #else
  56. #define PREFIX
  57. #endif
  58. PREFIX intorptr I(int i) { intorptr ret; ret.i = i; return ret; }
  59. PREFIX intorptr P(void *p) { intorptr ret; ret.p = p; return ret; }
  60. #undef PREFIX
  61. #endif
  62. /*
  63. * Each control has an `int' field specifying which columns it
  64. * occupies in a multi-column part of the dialog box. These macros
  65. * pack and unpack that field.
  66. *
  67. * If a control belongs in exactly one column, just specifying the
  68. * column number is perfectly adequate.
  69. */
  70. #define COLUMN_FIELD(start, span) ( (((span)-1) << 16) + (start) )
  71. #define COLUMN_START(field) ( (field) & 0xFFFF )
  72. #define COLUMN_SPAN(field) ( (((field) >> 16) & 0xFFFF) + 1 )
  73. union control;
  74. /*
  75. * The number of event types is being deliberately kept small, on
  76. * the grounds that not all platforms might be able to report a
  77. * large number of subtle events. We have:
  78. * - the special REFRESH event, called when a control's value
  79. * needs setting
  80. * - the ACTION event, called when the user does something that
  81. * positively requests action (double-clicking a list box item,
  82. * or pushing a push-button)
  83. * - the VALCHANGE event, called when the user alters the setting
  84. * of the control in a way that is usually considered to alter
  85. * the underlying data (toggling a checkbox or radio button,
  86. * moving the items around in a drag-list, editing an edit
  87. * control)
  88. * - the SELCHANGE event, called when the user alters the setting
  89. * of the control in a more minor way (changing the selected
  90. * item in a list box).
  91. * - the CALLBACK event, which happens after the handler routine
  92. * has requested a subdialog (file selector, font selector,
  93. * colour selector) and it has come back with information.
  94. */
  95. enum {
  96. EVENT_REFRESH,
  97. EVENT_ACTION,
  98. EVENT_VALCHANGE,
  99. EVENT_SELCHANGE,
  100. EVENT_CALLBACK
  101. };
  102. typedef void (*handler_fn)(union control *ctrl, void *dlg,
  103. void *data, int event);
  104. #define STANDARD_PREFIX \
  105. int type; \
  106. char *label; \
  107. int tabdelay; \
  108. int column; \
  109. handler_fn handler; \
  110. intorptr context; \
  111. intorptr helpctx
  112. union control {
  113. /*
  114. * The first possibility in this union is the generic header
  115. * shared by all the structures, which we are therefore allowed
  116. * to access through any one of them.
  117. */
  118. struct {
  119. int type;
  120. /*
  121. * Every control except CTRL_COLUMNS has _some_ sort of
  122. * label. By putting it in the `generic' union as well as
  123. * everywhere else, we avoid having to have an irritating
  124. * switch statement when we go through and deallocate all
  125. * the memory in a config-box structure.
  126. *
  127. * Yes, this does mean that any non-NULL value in this
  128. * field is expected to be dynamically allocated and
  129. * freeable.
  130. *
  131. * For CTRL_COLUMNS, this field MUST be NULL.
  132. */
  133. char *label;
  134. /*
  135. * If `tabdelay' is non-zero, it indicates that this
  136. * particular control should not yet appear in the tab
  137. * order. A subsequent CTRL_TABDELAY entry will place it.
  138. */
  139. int tabdelay;
  140. /*
  141. * Indicate which column(s) this control occupies. This can
  142. * be unpacked into starting column and column span by the
  143. * COLUMN macros above.
  144. */
  145. int column;
  146. /*
  147. * Most controls need to provide a function which gets
  148. * called when that control's setting is changed, or when
  149. * the control's setting needs initialising.
  150. *
  151. * The `data' parameter points to the writable data being
  152. * modified as a result of the configuration activity; for
  153. * example, the PuTTY `Conf' structure, although not
  154. * necessarily.
  155. *
  156. * The `dlg' parameter is passed back to the platform-
  157. * specific routines to read and write the actual control
  158. * state.
  159. */
  160. handler_fn handler;
  161. /*
  162. * Almost all of the above functions will find it useful to
  163. * be able to store a piece of `void *' or `int' data.
  164. */
  165. intorptr context;
  166. /*
  167. * For any control, we also allow the storage of a piece of
  168. * data for use by context-sensitive help. For example, on
  169. * Windows you can click the magic question mark and then
  170. * click a control, and help for that control should spring
  171. * up. Hence, here is a slot in which to store per-control
  172. * data that a particular platform-specific driver can use
  173. * to ensure it brings up the right piece of help text.
  174. */
  175. intorptr helpctx;
  176. } generic;
  177. struct {
  178. STANDARD_PREFIX;
  179. union control *ctrl;
  180. } tabdelay;
  181. struct {
  182. STANDARD_PREFIX;
  183. } text;
  184. struct {
  185. STANDARD_PREFIX;
  186. char shortcut; /* keyboard shortcut */
  187. /*
  188. * Percentage of the dialog-box width used by the edit box.
  189. * If this is set to 100, the label is on its own line;
  190. * otherwise the label is on the same line as the box
  191. * itself.
  192. */
  193. int percentwidth;
  194. int password; /* details of input are hidden */
  195. /*
  196. * A special case of the edit box is the combo box, which
  197. * has a drop-down list built in. (Note that a _non_-
  198. * editable drop-down list is done as a special case of a
  199. * list box.)
  200. *
  201. * Don't try setting has_list and password on the same
  202. * control; front ends are not required to support that
  203. * combination.
  204. */
  205. int has_list;
  206. /*
  207. * Edit boxes tend to need two items of context, so here's
  208. * a spare.
  209. */
  210. intorptr context2;
  211. } editbox;
  212. struct {
  213. STANDARD_PREFIX;
  214. /*
  215. * `shortcut' here is a single keyboard shortcut which is
  216. * expected to select the whole group of radio buttons. It
  217. * can be NO_SHORTCUT if required, and there is also a way
  218. * to place individual shortcuts on each button; see below.
  219. */
  220. char shortcut;
  221. /*
  222. * There are separate fields for `ncolumns' and `nbuttons'
  223. * for several reasons.
  224. *
  225. * Firstly, we sometimes want the last of a set of buttons
  226. * to have a longer label than the rest; we achieve this by
  227. * setting `ncolumns' higher than `nbuttons', and the
  228. * layout code is expected to understand that the final
  229. * button should be given all the remaining space on the
  230. * line. This sounds like a ludicrously specific special
  231. * case (if we're doing this sort of thing, why not have
  232. * the general ability to have a particular button span
  233. * more than one column whether it's the last one or not?)
  234. * but actually it's reasonably common for the sort of
  235. * three-way control you get a lot of in PuTTY: `yes'
  236. * versus `no' versus `some more complex way to decide'.
  237. *
  238. * Secondly, setting `nbuttons' higher than `ncolumns' lets
  239. * us have more than one line of radio buttons for a single
  240. * setting. A very important special case of this is
  241. * setting `ncolumns' to 1, so that each button is on its
  242. * own line.
  243. */
  244. int ncolumns;
  245. int nbuttons;
  246. /*
  247. * This points to a dynamically allocated array of `char *'
  248. * pointers, each of which points to a dynamically
  249. * allocated string.
  250. */
  251. char **buttons; /* `nbuttons' button labels */
  252. /*
  253. * This points to a dynamically allocated array of `char'
  254. * giving the individual keyboard shortcuts for each radio
  255. * button. The array may be NULL if none are required.
  256. */
  257. char *shortcuts; /* `nbuttons' shortcuts; may be NULL */
  258. /*
  259. * This points to a dynamically allocated array of
  260. * intorptr, giving helpful data for each button.
  261. */
  262. intorptr *buttondata; /* `nbuttons' entries; may be NULL */
  263. } radio;
  264. struct {
  265. STANDARD_PREFIX;
  266. char shortcut;
  267. } checkbox;
  268. struct {
  269. STANDARD_PREFIX;
  270. char shortcut;
  271. /*
  272. * At least Windows has the concept of a `default push
  273. * button', which gets implicitly pressed when you hit
  274. * Return even if it doesn't have the input focus.
  275. */
  276. int isdefault;
  277. /*
  278. * Also, the reverse of this: a default cancel-type button,
  279. * which is implicitly pressed when you hit Escape.
  280. */
  281. int iscancel;
  282. } button;
  283. struct {
  284. STANDARD_PREFIX;
  285. char shortcut; /* keyboard shortcut */
  286. /*
  287. * Height of the list box, in approximate number of lines.
  288. * If this is zero, the list is a drop-down list.
  289. */
  290. int height; /* height in lines */
  291. /*
  292. * If this is set, the list elements can be reordered by
  293. * the user (by drag-and-drop or by Up and Down buttons,
  294. * whatever the per-platform implementation feels
  295. * comfortable with). This is not guaranteed to work on a
  296. * drop-down list, so don't try it!
  297. */
  298. int draglist;
  299. /*
  300. * If this is non-zero, the list can have more than one
  301. * element selected at a time. This is not guaranteed to
  302. * work on a drop-down list, so don't try it!
  303. *
  304. * Different non-zero values request slightly different
  305. * types of multi-selection (this may well be meaningful
  306. * only in GTK, so everyone else can ignore it if they
  307. * want). 1 means the list box expects to have individual
  308. * items selected, whereas 2 means it expects the user to
  309. * want to select a large contiguous range at a time.
  310. */
  311. int multisel;
  312. /*
  313. * Percentage of the dialog-box width used by the list box.
  314. * If this is set to 100, the label is on its own line;
  315. * otherwise the label is on the same line as the box
  316. * itself. Setting this to anything other than 100 is not
  317. * guaranteed to work on a _non_-drop-down list, so don't
  318. * try it!
  319. */
  320. int percentwidth;
  321. /*
  322. * Some list boxes contain strings that contain tab
  323. * characters. If `ncols' is greater than 0, then
  324. * `percentages' is expected to be non-zero and to contain
  325. * the respective widths of `ncols' columns, which together
  326. * will exactly fit the width of the list box. Otherwise
  327. * `percentages' must be NULL.
  328. *
  329. * There should never be more than one column in a
  330. * drop-down list (one with height==0), because front ends
  331. * may have to implement it as a special case of an
  332. * editable combo box.
  333. */
  334. int ncols; /* number of columns */
  335. int *percentages; /* % width of each column */
  336. /*
  337. * Flag which can be set to FALSE to suppress the horizontal
  338. * scroll bar if a list box entry goes off the right-hand
  339. * side.
  340. */
  341. int hscroll;
  342. } listbox;
  343. struct {
  344. STANDARD_PREFIX;
  345. char shortcut;
  346. /*
  347. * `filter' dictates what type of files will be selected by
  348. * default; for example, when selecting private key files
  349. * the file selector would do well to only show .PPK files
  350. * (on those systems where this is the chosen extension).
  351. *
  352. * The precise contents of `filter' are platform-defined,
  353. * unfortunately. The special value NULL means `all files'
  354. * and is always a valid fallback.
  355. *
  356. * Unlike almost all strings in this structure, this value
  357. * is NOT expected to require freeing (although of course
  358. * you can always use ctrl_alloc if you do need to create
  359. * one on the fly). This is because the likely mode of use
  360. * is to define string constants in a platform-specific
  361. * header file, and directly reference those. Or worse, a
  362. * particular platform might choose to cast integers into
  363. * this pointer type...
  364. */
  365. char const *filter;
  366. /*
  367. * Some systems like to know whether a file selector is
  368. * choosing a file to read or one to write (and possibly
  369. * create).
  370. */
  371. int for_writing;
  372. /*
  373. * On at least some platforms, the file selector is a
  374. * separate dialog box, and contains a user-settable title.
  375. *
  376. * This value _is_ expected to require freeing.
  377. */
  378. char *title;
  379. } fileselect;
  380. struct {
  381. /* In this variant, `label' MUST be NULL. */
  382. STANDARD_PREFIX;
  383. int ncols; /* number of columns */
  384. int *percentages; /* % width of each column */
  385. /*
  386. * Every time this control type appears, exactly one of
  387. * `ncols' and the previous number of columns MUST be one.
  388. * Attempting to allow a seamless transition from a four-
  389. * to a five-column layout, for example, would be way more
  390. * trouble than it was worth. If you must lay things out
  391. * like that, define eight unevenly sized columns and use
  392. * column-spanning a lot. But better still, just don't.
  393. *
  394. * `percentages' may be NULL if ncols==1, to save space.
  395. */
  396. } columns;
  397. struct {
  398. STANDARD_PREFIX;
  399. char shortcut;
  400. } fontselect;
  401. };
  402. #undef STANDARD_PREFIX
  403. /*
  404. * `controlset' is a container holding an array of `union control'
  405. * structures, together with a panel name and a title for the whole
  406. * set. In Windows and any similar-looking GUI, each `controlset'
  407. * in the config will be a container box within a panel.
  408. *
  409. * Special case: if `boxname' is NULL, the control set gives an
  410. * overall title for an entire panel of controls.
  411. */
  412. struct controlset {
  413. char *pathname; /* panel path, e.g. "SSH/Tunnels" */
  414. char *boxname; /* internal short name of controlset */
  415. char *boxtitle; /* title of container box */
  416. int ncolumns; /* current no. of columns at bottom */
  417. int ncontrols; /* number of `union control' in array */
  418. int ctrlsize; /* allocated size of array */
  419. union control **ctrls; /* actual array */
  420. };
  421. typedef void (*ctrl_freefn_t)(void *); /* used by ctrl_alloc_with_free */
  422. /*
  423. * This is the container structure which holds a complete set of
  424. * controls.
  425. */
  426. struct controlbox {
  427. int nctrlsets; /* number of ctrlsets */
  428. int ctrlsetsize; /* ctrlset size */
  429. struct controlset **ctrlsets; /* actual array of ctrlsets */
  430. int nfrees;
  431. int freesize;
  432. void **frees; /* array of aux data areas to free */
  433. ctrl_freefn_t *freefuncs; /* parallel array of free functions */
  434. };
  435. struct controlbox *ctrl_new_box(void);
  436. void ctrl_free_box(struct controlbox *);
  437. /*
  438. * Standard functions used for populating a controlbox structure.
  439. */
  440. /* Set up a panel title. */
  441. struct controlset *ctrl_settitle(struct controlbox *,
  442. const char *path, const char *title);
  443. /* Retrieve a pointer to a controlset, creating it if absent. */
  444. struct controlset *ctrl_getset(struct controlbox *, const char *path,
  445. const char *name, const char *boxtitle);
  446. void ctrl_free_set(struct controlset *);
  447. void ctrl_free(union control *);
  448. /*
  449. * This function works like `malloc', but the memory it returns
  450. * will be automatically freed when the controlbox is freed. Note
  451. * that a controlbox is a dialog-box _template_, not an instance,
  452. * and so data allocated through this function is better not used
  453. * to hold modifiable per-instance things. It's mostly here for
  454. * allocating structures to be passed as control handler params.
  455. *
  456. * ctrl_alloc_with_free also allows you to provide a function to free
  457. * the structure, in case there are other dynamically allocated bits
  458. * and pieces dangling off it.
  459. */
  460. void *ctrl_alloc(struct controlbox *b, size_t size);
  461. void *ctrl_alloc_with_free(struct controlbox *b, size_t size,
  462. ctrl_freefn_t freefunc);
  463. /*
  464. * Individual routines to create `union control' structures in a controlset.
  465. *
  466. * Most of these routines allow the most common fields to be set
  467. * directly, and put default values in the rest. Each one returns a
  468. * pointer to the `union control' it created, so that final tweaks
  469. * can be made.
  470. */
  471. /* `ncolumns' is followed by that many percentages, as integers. */
  472. union control *ctrl_columns(struct controlset *, int ncolumns, ...);
  473. union control *ctrl_editbox(struct controlset *, const char *label,
  474. char shortcut, int percentage, intorptr helpctx,
  475. handler_fn handler,
  476. intorptr context, intorptr context2);
  477. union control *ctrl_combobox(struct controlset *, const char *label,
  478. char shortcut, int percentage, intorptr helpctx,
  479. handler_fn handler,
  480. intorptr context, intorptr context2);
  481. /*
  482. * `ncolumns' is followed by (alternately) radio button titles and
  483. * intorptrs, until a NULL in place of a title string is seen. Each
  484. * title is expected to be followed by a shortcut _iff_ `shortcut'
  485. * is NO_SHORTCUT.
  486. */
  487. union control *ctrl_radiobuttons(struct controlset *, const char *label,
  488. char shortcut, int ncolumns, intorptr helpctx,
  489. handler_fn handler, intorptr context, ...);
  490. union control *ctrl_pushbutton(struct controlset *, const char *label,
  491. char shortcut, intorptr helpctx,
  492. handler_fn handler, intorptr context);
  493. union control *ctrl_listbox(struct controlset *, const char *label,
  494. char shortcut, intorptr helpctx,
  495. handler_fn handler, intorptr context);
  496. union control *ctrl_droplist(struct controlset *, const char *label,
  497. char shortcut, int percentage, intorptr helpctx,
  498. handler_fn handler, intorptr context);
  499. union control *ctrl_draglist(struct controlset *, const char *label,
  500. char shortcut, intorptr helpctx,
  501. handler_fn handler, intorptr context);
  502. union control *ctrl_filesel(struct controlset *, const char *label,
  503. char shortcut, const char *filter, int write,
  504. const char *title, intorptr helpctx,
  505. handler_fn handler, intorptr context);
  506. union control *ctrl_fontsel(struct controlset *, const char *label,
  507. char shortcut, intorptr helpctx,
  508. handler_fn handler, intorptr context);
  509. union control *ctrl_text(struct controlset *, const char *text,
  510. intorptr helpctx);
  511. union control *ctrl_checkbox(struct controlset *, const char *label,
  512. char shortcut, intorptr helpctx,
  513. handler_fn handler, intorptr context);
  514. union control *ctrl_tabdelay(struct controlset *, union control *);
  515. /*
  516. * Routines the platform-independent dialog code can call to read
  517. * and write the values of controls.
  518. */
  519. void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton);
  520. int dlg_radiobutton_get(union control *ctrl, void *dlg);
  521. void dlg_checkbox_set(union control *ctrl, void *dlg, int checked);
  522. int dlg_checkbox_get(union control *ctrl, void *dlg);
  523. void dlg_editbox_set(union control *ctrl, void *dlg, char const *text);
  524. char *dlg_editbox_get(union control *ctrl, void *dlg); /* result must be freed by caller */
  525. /* The `listbox' functions can also apply to combo boxes. */
  526. void dlg_listbox_clear(union control *ctrl, void *dlg);
  527. void dlg_listbox_del(union control *ctrl, void *dlg, int index);
  528. void dlg_listbox_add(union control *ctrl, void *dlg, char const *text);
  529. /*
  530. * Each listbox entry may have a numeric id associated with it.
  531. * Note that some front ends only permit a string to be stored at
  532. * each position, which means that _if_ you put two identical
  533. * strings in any listbox then you MUST not assign them different
  534. * IDs and expect to get meaningful results back.
  535. */
  536. void dlg_listbox_addwithid(union control *ctrl, void *dlg,
  537. char const *text, int id);
  538. int dlg_listbox_getid(union control *ctrl, void *dlg, int index);
  539. /* dlg_listbox_index returns <0 if no single element is selected. */
  540. int dlg_listbox_index(union control *ctrl, void *dlg);
  541. int dlg_listbox_issel(union control *ctrl, void *dlg, int index);
  542. void dlg_listbox_select(union control *ctrl, void *dlg, int index);
  543. void dlg_text_set(union control *ctrl, void *dlg, char const *text);
  544. void dlg_filesel_set(union control *ctrl, void *dlg, Filename *fn);
  545. Filename *dlg_filesel_get(union control *ctrl, void *dlg);
  546. void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fn);
  547. FontSpec *dlg_fontsel_get(union control *ctrl, void *dlg);
  548. /*
  549. * Bracketing a large set of updates in these two functions will
  550. * cause the front end (if possible) to delay updating the screen
  551. * until it's all complete, thus avoiding flicker.
  552. */
  553. void dlg_update_start(union control *ctrl, void *dlg);
  554. void dlg_update_done(union control *ctrl, void *dlg);
  555. /*
  556. * Set input focus into a particular control.
  557. */
  558. void dlg_set_focus(union control *ctrl, void *dlg);
  559. /*
  560. * Change the label text on a control.
  561. */
  562. void dlg_label_change(union control *ctrl, void *dlg, char const *text);
  563. /*
  564. * Return the `ctrl' structure for the most recent control that had
  565. * the input focus apart from the one mentioned. This is NOT
  566. * GUARANTEED to work on all platforms, so don't base any critical
  567. * functionality on it!
  568. */
  569. union control *dlg_last_focused(union control *ctrl, void *dlg);
  570. /*
  571. * During event processing, you might well want to give an error
  572. * indication to the user. dlg_beep() is a quick and easy generic
  573. * error; dlg_error() puts up a message-box or equivalent.
  574. */
  575. void dlg_beep(void *dlg);
  576. void dlg_error_msg(void *dlg, const char *msg);
  577. /*
  578. * This function signals to the front end that the dialog's
  579. * processing is completed, and passes an integer value (typically
  580. * a success status).
  581. */
  582. void dlg_end(void *dlg, int value);
  583. /*
  584. * Routines to manage a (per-platform) colour selector.
  585. * dlg_coloursel_start() is called in an event handler, and
  586. * schedules the running of a colour selector after the event
  587. * handler returns. The colour selector will send EVENT_CALLBACK to
  588. * the control that spawned it, when it's finished;
  589. * dlg_coloursel_results() fetches the results, as integers from 0
  590. * to 255; it returns nonzero on success, or zero if the colour
  591. * selector was dismissed by hitting Cancel or similar.
  592. *
  593. * dlg_coloursel_start() accepts an RGB triple which is used to
  594. * initialise the colour selector to its starting value.
  595. */
  596. void dlg_coloursel_start(union control *ctrl, void *dlg,
  597. int r, int g, int b);
  598. int dlg_coloursel_results(union control *ctrl, void *dlg,
  599. int *r, int *g, int *b);
  600. /*
  601. * This routine is used by the platform-independent code to
  602. * indicate that the value of a particular control is likely to
  603. * have changed. It triggers a call of the handler for that control
  604. * with `event' set to EVENT_REFRESH.
  605. *
  606. * If `ctrl' is NULL, _all_ controls in the dialog get refreshed
  607. * (for loading or saving entire sets of settings).
  608. */
  609. void dlg_refresh(union control *ctrl, void *dlg);
  610. /*
  611. * Standard helper functions for reading a controlbox structure.
  612. */
  613. /*
  614. * Find the index of next controlset in a controlbox for a given
  615. * path, or -1 if no such controlset exists. If -1 is passed as
  616. * input, finds the first. Intended usage is something like
  617. *
  618. * for (index=-1; (index=ctrl_find_path(ctrlbox, index, path)) >= 0 ;) {
  619. * ... process this controlset ...
  620. * }
  621. */
  622. int ctrl_find_path(struct controlbox *b, const char *path, int index);
  623. int ctrl_path_elements(const char *path);
  624. /* Return the number of matching path elements at the starts of p1 and p2,
  625. * or INT_MAX if the paths are identical. */
  626. int ctrl_path_compare(const char *p1, const char *p2);