]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - dialog.h
first pass
[PuTTY.git] / dialog.h
index 8daa3320c843533f1eb33160ec78bbe7774a7ff6..9ac355c64afcab78279aa88db966d25969b15184 100644 (file)
--- a/dialog.h
+++ b/dialog.h
@@ -162,7 +162,7 @@ union control {
         * 
         * The `data' parameter points to the writable data being
         * modified as a result of the configuration activity; for
-        * example, the PuTTY `Config' structure, although not
+        * example, the PuTTY `Conf' structure, although not
         * necessarily.
         * 
         * The `dlg' parameter is passed back to the platform-
@@ -209,6 +209,10 @@ union control {
         * has a drop-down list built in. (Note that a _non_-
         * editable drop-down list is done as a special case of a
         * list box.)
+        * 
+        * Don't try setting has_list and password on the same
+        * control; front ends are not required to support that
+        * combination.
         */
        int has_list;
        /*
@@ -333,9 +337,20 @@ union control {
         * the respective widths of `ncols' columns, which together
         * will exactly fit the width of the list box. Otherwise
         * `percentages' must be NULL.
+        * 
+        * There should never be more than one column in a
+        * drop-down list (one with height==0), because front ends
+        * may have to implement it as a special case of an
+        * editable combo box.
         */
        int ncols;                     /* number of columns */
        int *percentages;              /* % width of each column */
+        /*
+         * Flag which can be set to FALSE to suppress the horizontal
+         * scroll bar if a list box entry goes off the right-hand
+         * side.
+         */
+        int hscroll;
     } listbox;
     struct {
        STANDARD_PREFIX;
@@ -418,6 +433,8 @@ struct controlset {
     union control **ctrls;            /* actual array */
 };
 
+typedef void (*ctrl_freefn_t)(void *);    /* used by ctrl_alloc_with_free */
+
 /*
  * This is the container structure which holds a complete set of
  * controls.
@@ -429,6 +446,7 @@ struct controlbox {
     int nfrees;
     int freesize;
     void **frees;                     /* array of aux data areas to free */
+    ctrl_freefn_t *freefuncs;          /* parallel array of free functions */
 };
 
 struct controlbox *ctrl_new_box(void);
@@ -440,10 +458,10 @@ void ctrl_free_box(struct controlbox *);
 
 /* Set up a panel title. */
 struct controlset *ctrl_settitle(struct controlbox *,
-                                char *path, char *title);
+                                const char *path, const char *title);
 /* Retrieve a pointer to a controlset, creating it if absent. */
-struct controlset *ctrl_getset(struct controlbox *,
-                              char *path, char *name, char *boxtitle);
+struct controlset *ctrl_getset(struct controlbox *, const char *path,
+                               const char *name, const char *boxtitle);
 void ctrl_free_set(struct controlset *);
 
 void ctrl_free(union control *);
@@ -455,8 +473,14 @@ void ctrl_free(union control *);
  * and so data allocated through this function is better not used
  * to hold modifiable per-instance things. It's mostly here for
  * allocating structures to be passed as control handler params.
+ *
+ * ctrl_alloc_with_free also allows you to provide a function to free
+ * the structure, in case there are other dynamically allocated bits
+ * and pieces dangling off it.
  */
 void *ctrl_alloc(struct controlbox *b, size_t size);
+void *ctrl_alloc_with_free(struct controlbox *b, size_t size,
+                           ctrl_freefn_t freefunc);
 
 /*
  * Individual routines to create `union control' structures in a controlset.
@@ -469,12 +493,12 @@ void *ctrl_alloc(struct controlbox *b, size_t size);
 
 /* `ncolumns' is followed by that many percentages, as integers. */
 union control *ctrl_columns(struct controlset *, int ncolumns, ...);
-union control *ctrl_editbox(struct controlset *, char *label, char shortcut,
-                           int percentage, intorptr helpctx,
+union control *ctrl_editbox(struct controlset *, const char *label,
+                            char shortcut, int percentage, intorptr helpctx,
                            handler_fn handler,
                            intorptr context, intorptr context2);
-union control *ctrl_combobox(struct controlset *, char *label, char shortcut,
-                            int percentage, intorptr helpctx,
+union control *ctrl_combobox(struct controlset *, const char *label,
+                             char shortcut, int percentage, intorptr helpctx,
                             handler_fn handler,
                             intorptr context, intorptr context2);
 /*
@@ -483,89 +507,35 @@ union control *ctrl_combobox(struct controlset *, char *label, char shortcut,
  * title is expected to be followed by a shortcut _iff_ `shortcut'
  * is NO_SHORTCUT.
  */
-union control *ctrl_radiobuttons(struct controlset *, char *label,
-                                char shortcut, int ncolumns,
-                                intorptr helpctx,
+union control *ctrl_radiobuttons(struct controlset *, const char *label,
+                                char shortcut, int ncolumns, intorptr helpctx,
                                 handler_fn handler, intorptr context, ...);
-union control *ctrl_pushbutton(struct controlset *,char *label,char shortcut,
-                              intorptr helpctx,
+union control *ctrl_pushbutton(struct controlset *, const char *label,
+                               char shortcut, intorptr helpctx,
                               handler_fn handler, intorptr context);
-union control *ctrl_listbox(struct controlset *,char *label,char shortcut,
-                           intorptr helpctx,
+union control *ctrl_listbox(struct controlset *, const char *label,
+                            char shortcut, intorptr helpctx,
                            handler_fn handler, intorptr context);
-union control *ctrl_droplist(struct controlset *, char *label, char shortcut,
-                            int percentage, intorptr helpctx,
+union control *ctrl_droplist(struct controlset *, const char *label,
+                             char shortcut, int percentage, intorptr helpctx,
                             handler_fn handler, intorptr context);
-union control *ctrl_draglist(struct controlset *,char *label,char shortcut,
-                            intorptr helpctx,
+union control *ctrl_draglist(struct controlset *, const char *label,
+                             char shortcut, intorptr helpctx,
                             handler_fn handler, intorptr context);
-union control *ctrl_filesel(struct controlset *,char *label,char shortcut,
-                           char const *filter, int write, char *title,
-                           intorptr helpctx,
+union control *ctrl_filesel(struct controlset *, const char *label,
+                            char shortcut, const char *filter, int write,
+                            const char *title, intorptr helpctx,
                            handler_fn handler, intorptr context);
-union control *ctrl_fontsel(struct controlset *,char *label,char shortcut,
-                           intorptr helpctx,
+union control *ctrl_fontsel(struct controlset *, const char *label,
+                            char shortcut, intorptr helpctx,
                            handler_fn handler, intorptr context);
-union control *ctrl_text(struct controlset *, char *text, intorptr helpctx);
-union control *ctrl_checkbox(struct controlset *, char *label, char shortcut,
-                            intorptr helpctx,
+union control *ctrl_text(struct controlset *, const char *text,
+                         intorptr helpctx);
+union control *ctrl_checkbox(struct controlset *, const char *label,
+                             char shortcut, intorptr helpctx,
                             handler_fn handler, intorptr context);
 union control *ctrl_tabdelay(struct controlset *, union control *);
 
-/*
- * Standard handler routines to cover most of the common cases in
- * the config box.
- */
-/*
- * The standard radio-button handler expects the main `context'
- * field to contain the `offsetof' of an int field in the structure
- * pointed to by `data', and expects each of the individual button
- * data to give a value for that int field.
- */
-void dlg_stdradiobutton_handler(union control *ctrl, void *dlg,
-                               void *data, int event);
-/*
- * The standard checkbox handler expects the main `context' field
- * to contain the `offsetof' an int field in the structure pointed
- * to by `data', optionally ORed with CHECKBOX_INVERT to indicate
- * that the sense of the datum is opposite to the sense of the
- * checkbox.
- */
-#define CHECKBOX_INVERT (1<<30)
-void dlg_stdcheckbox_handler(union control *ctrl, void *dlg,
-                            void *data, int event);
-/*
- * The standard edit-box handler expects the main `context' field
- * to contain the `offsetof' a field in the structure pointed to by
- * `data'. The secondary `context2' field indicates the type of
- * this field:
- * 
- *  - if context2 > 0, the field is a char array and context2 gives
- *    its size.
- *  - if context2 == -1, the field is an int and the edit box is
- *    numeric.
- *  - if context2 < -1, the field is an int and the edit box is
- *    _floating_, and (-context2) gives the scale. (E.g. if
- *    context2 == -1000, then typing 1.2 into the box will set the
- *    field to 1200.)
- */
-void dlg_stdeditbox_handler(union control *ctrl, void *dlg,
-                           void *data, int event);
-/*
- * The standard file-selector handler expects the main `context'
- * field to contain the `offsetof' a Filename field in the
- * structure pointed to by `data'.
- */
-void dlg_stdfilesel_handler(union control *ctrl, void *dlg,
-                           void *data, int event);
-/*
- * The standard font-selector handler expects the main `context'
- * field to contain the `offsetof' a Font field in the structure
- * pointed to by `data'.
- */
-void dlg_stdfontsel_handler(union control *ctrl, void *dlg,
-                           void *data, int event);
-
 /*
  * Routines the platform-independent dialog code can call to read
  * and write the values of controls.
@@ -575,7 +545,7 @@ int dlg_radiobutton_get(union control *ctrl, void *dlg);
 void dlg_checkbox_set(union control *ctrl, void *dlg, int checked);
 int dlg_checkbox_get(union control *ctrl, void *dlg);
 void dlg_editbox_set(union control *ctrl, void *dlg, char const *text);
-void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length);
+char *dlg_editbox_get(union control *ctrl, void *dlg);   /* result must be freed by caller */
 /* The `listbox' functions can also apply to combo boxes. */
 void dlg_listbox_clear(union control *ctrl, void *dlg);
 void dlg_listbox_del(union control *ctrl, void *dlg, int index);
@@ -595,10 +565,10 @@ int dlg_listbox_index(union control *ctrl, void *dlg);
 int dlg_listbox_issel(union control *ctrl, void *dlg, int index);
 void dlg_listbox_select(union control *ctrl, void *dlg, int index);
 void dlg_text_set(union control *ctrl, void *dlg, char const *text);
-void dlg_filesel_set(union control *ctrl, void *dlg, Filename fn);
-void dlg_filesel_get(union control *ctrl, void *dlg, Filename *fn);
-void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec fn);
-void dlg_fontsel_get(union control *ctrl, void *dlg, FontSpec *fn);
+void dlg_filesel_set(union control *ctrl, void *dlg, Filename *fn);
+Filename *dlg_filesel_get(union control *ctrl, void *dlg);
+void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fn);
+FontSpec *dlg_fontsel_get(union control *ctrl, void *dlg);
 /*
  * Bracketing a large set of updates in these two functions will
  * cause the front end (if possible) to delay updating the screen
@@ -610,6 +580,10 @@ void dlg_update_done(union control *ctrl, void *dlg);
  * Set input focus into a particular control.
  */
 void dlg_set_focus(union control *ctrl, void *dlg);
+/*
+ * Change the label text on a control.
+ */
+void dlg_label_change(union control *ctrl, void *dlg, char const *text);
 /*
  * Return the `ctrl' structure for the most recent control that had
  * the input focus apart from the one mentioned. This is NOT
@@ -623,7 +597,7 @@ union control *dlg_last_focused(union control *ctrl, void *dlg);
  * error; dlg_error() puts up a message-box or equivalent.
  */
 void dlg_beep(void *dlg);
-void dlg_error_msg(void *dlg, char *msg);
+void dlg_error_msg(void *dlg, const char *msg);
 /*
  * This function signals to the front end that the dialog's
  * processing is completed, and passes an integer value (typically
@@ -660,21 +634,6 @@ 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.
  */
@@ -688,8 +647,8 @@ void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size);
  *          ... process this controlset ...
  *      }
  */
-int ctrl_find_path(struct controlbox *b, char *path, int index);
-int ctrl_path_elements(char *path);
+int ctrl_find_path(struct controlbox *b, const char *path, int index);
+int ctrl_path_elements(const char *path);
 /* Return the number of matching path elements at the starts of p1 and p2,
  * or INT_MAX if the paths are identical. */
-int ctrl_path_compare(char *p1, char *p2);
+int ctrl_path_compare(const char *p1, const char *p2);