Big sprawling dialog-box commit covering all sorts of things.
[u/mdw/putty] / dialog.h
index 6b9f5e3..fb3906c 100644 (file)
--- a/dialog.h
+++ b/dialog.h
@@ -51,6 +51,11 @@ enum {
  */
 typedef union { void *p; int i; } intorptr;
 
+#ifndef INLINE
+intorptr I(int i);
+intorptr P(void *p);
+#endif
+
 #if defined DEFINE_INTORPTR_FNS || defined INLINE
 #ifdef INLINE
 #define PREFIX INLINE
@@ -60,9 +65,6 @@ typedef union { void *p; int i; } intorptr;
 PREFIX intorptr I(int i) { intorptr ret; ret.i = i; return ret; }
 PREFIX intorptr P(void *p) { intorptr ret; ret.p = p; return ret; }
 #undef PREFIX
-#else
-intorptr I(int i);
-intorptr P(void *p);
 #endif
 
 /*
@@ -280,6 +282,11 @@ union control {
         * Return even if it doesn't have the input focus.
         */
        int isdefault;
+       /*
+        * Also, the reverse of this: a default cancel-type button,
+        * which is implicitly pressed when you hit Escape.
+        */
+       int iscancel;
     } button;
     struct {
        STANDARD_PREFIX;
@@ -597,11 +604,12 @@ void dlg_update_done(union control *ctrl, void *dlg);
  */
 void dlg_set_focus(union control *ctrl, void *dlg);
 /*
- * Return the `ctrl' structure for the control that had the input
- * focus before this one. This is NOT GUARANTEED to work on all
- * platforms, so don't base any critical functionality on it!
+ * Return the `ctrl' structure for the most recent control that had
+ * the input focus apart from the one mentioned. This is NOT
+ * GUARANTEED to work on all platforms, so don't base any critical
+ * functionality on it!
  */
-union control *dlg_last_focused(void *dlg);
+union control *dlg_last_focused(union control *ctrl, void *dlg);
 /*
  * During event processing, you might well want to give an error
  * indication to the user. dlg_beep() is a quick and easy generic
@@ -646,6 +654,21 @@ int dlg_coloursel_results(union control *ctrl, void *dlg,
 void dlg_refresh(union control *ctrl, void *dlg);
 
 /*
+ * It's perfectly possible that individual controls might need to
+ * allocate or store per-dialog-instance data, so here's a
+ * mechanism.
+ * 
+ * `dlg_get_privdata' and `dlg_set_privdata' allow the user to get
+ * and set a void * pointer associated with the control in
+ * question. `dlg_alloc_privdata' will allocate memory, store a
+ * pointer to that memory in the private data field, and arrange
+ * for it to be automatically deallocated on dialog cleanup.
+ */
+void *dlg_get_privdata(union control *ctrl, void *dlg);
+void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr);
+void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size);
+
+/*
  * Standard helper functions for reading a controlbox structure.
  */