XEmacs 21.2.9
[chise/xemacs-chise.git.1] / src / gui.h
1 /* Generic GUI code. (menubars, scrollbars, toolbars, dialogs)
2    Copyright (C) 1995 Board of Trustees, University of Illinois.
3    Copyright (C) 1995, 1996 Ben Wing.
4    Copyright (C) 1995 Sun Microsystems, Inc.
5
6 This file is part of XEmacs.
7
8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
11 later version.
12
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with XEmacs; see the file COPYING.  If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 /* Synched up with: Not in FSF. */
24
25 /* Written by kkm on 12/24/97 */
26
27 #ifndef _XEMACS_GUI_H_
28 #define _XEMACS_GUI_H_
29
30 int separator_string_p (CONST char *s);
31 void get_gui_callback (Lisp_Object, Lisp_Object *, Lisp_Object *);
32
33 extern int popup_up_p;
34
35 /* This structure describes gui button,
36    menu item or submenu properties */
37 struct gui_item
38 {
39   Lisp_Object name;             /* String */
40   Lisp_Object callback;         /* Symbol or form */
41   Lisp_Object suffix;           /* String */
42   Lisp_Object active;           /* Form */
43   Lisp_Object included;         /* Form */
44   Lisp_Object config;           /* Anything EQable */
45   Lisp_Object filter;           /* Form */
46   Lisp_Object style;            /* Symbol */
47   Lisp_Object selected;         /* Form */
48   Lisp_Object keys;             /* String */
49 };
50 #define GUI_ITEM_LAST_GCPROED keys
51 #define GUI_ITEM_GCPRO_COUNT \
52   (slot_offset(struct gui_item, GUI_ITEM_LAST_GCPROED) / sizeof(Lisp_Object) + 1)
53
54 /*
55  * gui_item is a struct containing a bunch of Lisp_Object
56  * members.  We need to GC-protect all the member slots.
57  * Rather than build a long chain of individual gcpro structs
58  * that protect the slots individually, we protect all the
59  * member slots by pretending the struct is an array.  ANSI C
60  * requires this hack to work, ugly though it is.
61  */
62 #define GCPRO_GUI_ITEM(pgui_item)                                       \
63         do {                                                            \
64           Lisp_Object *gui_item_array = (Lisp_Object *) pgui_item;      \
65           GCPRO1 (gui_item_array[0]);                                   \
66           gcpro1.nvars = GUI_ITEM_GCPRO_COUNT;                          \
67         } while (0);
68
69 extern Lisp_Object Q_accelerator, Q_active, Q_config, Q_filter, Q_included;
70 extern Lisp_Object Q_keys, Q_selected, Q_suffix, Qradio, Qtoggle;
71 extern Lisp_Object Q_key_sequence, Q_label, Q_callback;
72
73 void gui_item_init (struct gui_item *pgui_item);
74 void gui_item_add_keyval_pair (struct gui_item *pgui_item,
75                                Lisp_Object key, Lisp_Object val,
76                                Error_behavior errb);
77 void gui_parse_item_keywords (Lisp_Object item, struct gui_item *pgui_item);
78 void gui_parse_item_keywords_no_errors (Lisp_Object item, struct gui_item *pgui_item);
79 int  gui_item_active_p (CONST struct gui_item *pgui_item);
80 int  gui_item_selected_p (CONST struct gui_item *pgui_item);
81 int  gui_item_included_p (CONST struct gui_item *pgui_item, Lisp_Object into);
82 int  gui_item_hash (Lisp_Object, struct gui_item*, int);
83 Lisp_Object mark_gui_item (struct gui_item* p, void (*markobj) (Lisp_Object));
84 unsigned int gui_item_display_flush_left  (CONST struct gui_item *pgui_item,
85                                            char* buf, Bytecount buf_len);
86 unsigned int gui_item_display_flush_right (CONST struct gui_item *pgui_item,
87                                            char* buf, Bytecount buf_len);
88
89 /* this is mswindows biased but reasonably safe I think */
90 #define GUI_ITEM_ID_SLOTS 8
91 #define GUI_ITEM_ID_MIN(s) (s * 0x2000)
92 #define GUI_ITEM_ID_MAX(s) (0x1FFF + GUI_ITEM_ID_MIN (s))
93 #define GUI_ITEM_ID_BITS(x,s) (((x) & 0x1FFF) + GUI_ITEM_ID_MIN (s))
94
95 #endif /* _XEMACS_GUI_H_ */