Fix CursorMove command to correctly honour EdgeScroll settings.
[fvwm.git] / modules / FvwmForm / FvwmForm.h
blobbbb1178e4e2c2e68659708f0def8a5f0ab6e8382
1 /* -*-c-*- */
2 #ifndef FVWMFORM_H
3 #define FVWMFORM_H
5 /* Modification History
7 Created 12/20/98 Dan Espen:
9 - FvwmForm.c got too big for my home machine to deal with.
13 #include "libs/Flocale.h" /* for font definition stuff */
15 * This next stuff should be more specific and customizable.
16 * For example padVText (above) was one of the things TXT_SPC
17 * controlled. (dje)
19 #define TEXT_SPC 3
20 /* This one, box_spc would have to be saved as part of an "item".
21 It's used for input boxes, buttons, and I think, choices.
22 dje */
23 #define BOX_SPC 3
24 /* Item_hspc is only used during the "massage phase"
25 has to be saved in items. */
26 #define ITEM_HSPC 10
27 #define ITEM_VSPC 5
29 /* Control the areas that are realloced in chunks: */
30 #define ITEMS_PER_EXPANSION 32
31 #define CHOICES_PER_SEL_EXPANSION 8
32 #define BUTTON_COMMAND_EXPANSION 8
33 #define TIMEOUT_COMMAND_EXPANSION 8
35 #define I_TEXT 1
36 #define I_INPUT 2
37 #define I_SELECT 3
38 #define I_CHOICE 4
39 #define I_BUTTON 5
40 #define I_TIMEOUT 6
42 #define IS_SINGLE 1
43 #define IS_MULTIPLE 2
45 #define IB_CONTINUE 1
46 #define IB_RESTART 2
47 #define IB_QUIT 3
49 /* There is a "drawtable" for each item drawn in a form */
50 typedef struct _drawtable {
51 struct _drawtable *dt_next; /* link list, circle */
52 char *dt_font_name; /* font name */
53 char *dt_color_names[4];
54 int dt_used; /* 1=used as text, 2 used as item */
55 unsigned long dt_colors[6]; /* text fore/back
56 button/choice/input fore/back
57 hilite and shadow (item only)
58 Note, need all 6 because choices
59 use them all */
60 GC dt_GC; /* graphic ctx used for text */
61 GC dt_item_GC; /* graphic ctx used for graphics */
62 FlocaleFont *dt_Ffont; /* Fvwm font structure */
63 FlocaleWinString *dt_Fstr; /* Fvwm string (handles multibyte) */
64 } DrawTable;
66 /* An "item" is something in a form. Part of the structure is common
67 for all item types, the rest of the structure is a union. */
68 typedef union _item {
69 int type; /* item type, one of I_TEXT .. I_BUTTON */
70 struct _head { /* common header */
71 int type;
72 union _item *next; /* for all items linklist */
73 int win; /* X window id */
74 char *name; /* identifier name */
75 int size_x, size_y; /* size of bounding box */
76 int pos_x, pos_y; /* position of top-left corner */
77 DrawTable *dt_ptr; /* only used for items that need it */
78 } header;
80 struct { /* I_TEXT */
81 struct _head head;
82 int n; /* string length */
83 char *value; /* string to display */
84 unsigned long color; /* color of text */
85 } text;
87 struct { /* I_INPUT */
88 struct _head head;
89 int buf; /* input string buffer */
90 int n; /* string length */
91 char *value; /* input string */
92 char *init_value; /* default string */
93 char *blanks; /* blank string */
94 int size; /* input field size */
95 int left; /* position of the left-most displayed char */
96 union _item *next_input; /* a ring of input fields */
97 union _item *prev_input; /* for tabbing */
98 int value_history_count; /* count of input history */
99 int value_history_yankat; /* yank point between restarts */
100 char **value_history_ptr; /* curr insertion point */
101 } input;
102 struct { /* I_SELECT */
103 struct _head head;
104 int key; /* one of IS_MULTIPLE, IS_SINGLE */
105 int n; /* number of choices */
106 int choices_array_count; /* current choices array size */
107 union _item **choices; /* list of choices */
108 } selection;
109 struct { /* I_CHOICE */
110 struct _head head;
111 int on; /* selected or not */
112 int init_on; /* initially selected or not */
113 char *value; /* value if selected */
114 int n; /* text string length */
115 char *text; /* text string */
116 union _item *sel; /* selection it belongs to */
117 } choice;
118 struct { /* I_BUTTON */
119 struct _head head;
120 int key; /* one of IB_CONTINUE, IB_RESTART, IB_QUIT */
121 int n; /* # of commands */
122 int len; /* text length */
123 char *text; /* text string */
124 int keypress; /* short cut */
125 int button_array_size; /* current size of next array */
126 char **commands; /* Fvwm command to execute */
127 } button;
128 struct { /* I_TIMEOUT */
129 struct _head head;
130 int timeleft; /* seconds left on timer */
131 int len; /* text length */
132 char *text; /* text string */
133 char *command; /* Fvwm command(s) to execute */
134 } timeout;
135 } Item;
137 #define L_LEFT 1
138 #define L_RIGHT 2
139 #define L_CENTER 3
140 #define L_LEFTRIGHT 4
141 #define MICRO_S_FOR_10MS 10000
142 #define VH_SIZE 50 /* size of value history */
144 /* There is one "line" structure for each line in the form.
145 "Lines" point at an array of "items". */
146 typedef struct _line {
147 struct _line *next; /* Pointer to next line */
148 int n; /* number of items on the line */
149 int justify; /* justification */
150 int size_x, size_y; /* size of bounding rectangle */
151 int item_array_size; /* track size */
152 Item **items; /* ptr to array of items */
153 } Line;
155 /* Need a struct for the pointer color.
156 Since colors are unsigned, we need a flag to indicate whether
157 the color was ever set. */
158 typedef struct _ptrc {
159 XColor pointer_color;
160 char used;
161 } Ptr_color;
163 /* There is one "form". Start of attempt to change that. */
164 typedef struct _form {
165 #if 0
166 struct _form *next; /* dje hmm. a linklist of forms? */
167 #endif
168 Item def_button;
169 int grab_server; /* set during parse used on display */
170 int server_grabbed; /* first time switch */
171 int gx, gy, have_geom;
172 int xneg, yneg;
173 int warp_pointer;
174 int max_width, total_height; /* frame size */
175 unsigned long screen_background;
176 Item *cur_input; /* current input during parse and run */
177 Item *first_input; /* forms first input item during parse*/
178 Item *last_error; /* fvwm error message display area */
179 DrawTable *roots_dt; /* root draw tables linklist */
180 int abs_cursor;
181 int rel_cursor;
182 Window frame;
183 int padVText; /* vert space for text item */
184 char *leading; /* part of command to match for data */
185 char *file_to_read; /* file to read for data */
186 char *title; /* form title, NULL, use alias */
187 char *expand_buffer; /* buffer to expand commands in */
188 int expand_buffer_size; /* current size */
189 char have_env_var; /* at least one env var on cmd line */
190 Cursor pointer[3];
191 Ptr_color p_c[6]; /* fg/bg for pointers, used flag */
192 int activate_on_press; /* activate button on press */
193 } Form;
195 enum {input_pointer,button_pointer,button_in_pointer};
196 enum {input_fore,input_back,
197 button_fore,button_back,
198 button_in_fore,button_in_back};
200 extern Form cur_form; /* current form */
201 #define CF cur_form /* I may want to undo this... */
203 /* Globals: */
205 /* Link list roots */
206 extern Item *root_item_ptr; /* pointer to root of item list */
207 extern Line root_line;
208 extern Line *cur_line;
209 extern char preload_yorn;
210 extern Item *item; /* current during parse */
211 extern Item *cur_sel, *cur_button; /* current during parse */
212 extern Display *dpy;
213 extern Atom wm_del_win;
214 extern int fd_x; /* fd for X connection */
215 extern Window root, ref;
216 extern int screen;
218 enum { c_bg, c_fg, c_item_bg, c_item_fg, c_itemlo, c_itemhi };
219 extern char *color_names[4];
220 extern char bg_state;
221 extern char endDefaultsRead;
222 enum { f_text, f_input, f_button, f_timeout };
223 extern char *font_names[4];
224 extern char *screen_background_color;
226 extern int colorset;
227 extern int itemcolorset;
229 /* From FvwmAnimate start */
230 extern char *MyName;
231 extern int MyNameLen;
232 /* here is the old double parens trick. */
233 /* #define DEBUG */
234 #ifdef DEBUG
235 #define myfprintf(X) \
236 fprintf X;\
237 fflush (stderr);
238 #else
239 #define myfprintf(X)
240 #endif
242 #define tempmyfprintf(X) \
243 fprintf X;\
244 fflush (stderr);
246 extern int Channel[2];
248 /* From FvwmAnimate end */
250 /* prototypes */
251 void ReadXServer(void); /* ReadXServer.c */
252 void RedrawText(Item *item); /* FvwmForm.c */
253 void RedrawTimeout(Item *item); /* FvwmForm.c */
254 void RedrawItem (
255 Item *item, int click, XEvent *pev); /* FvwmForm.c */
256 void UpdateRootTransapency(
257 Bool pr_only, Bool do_draw); /* FvwmForm.c */
258 void DoCommand (Item *cmd); /* FvwmForm.c */
259 int FontWidth (XFontStruct *xfs); /* FvwmForm.c */
260 void RedrawFrame (XEvent *pev); /* FvwmForm.c */
261 char * ParseCommand (int, char *, char, int *, char **s); /* ParseCommand.c */
263 RETSIGTYPE DeadPipe(int nonsense); /* FvwmForm.c */
265 #endif