Fonttool enhancements: preserve cursor positions, be smart about font escape
[grace.git] / src / motifinc.h
blob2803e24db526e33f8c5cbcd4d989fde1a87b47fc
1 /*
2 * Grace - GRaphing, Advanced Computation and Exploration of data
3 *
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
5 *
6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7 * Copyright (c) 1996-2003 Grace Development Team
8 *
9 * Maintained by Evgeny Stambulchik
12 * All Rights Reserved
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 * for Motif specific items
33 #ifndef __MOTIFINC_H_
34 #define __MOTIFINC_H_
36 /* for Widget */
37 #include <X11/Intrinsic.h>
38 /* for XmString; TODO: remove! */
39 #include <Xm/Xm.h>
41 #include "grace.h"
43 /*
44 * Accept/Apply/Close for aac_cb callbacks
46 #define AAC_ACCEPT 0
47 #define AAC_APPLY 1
48 #define AAC_CLOSE 2
50 #define LIST_TYPE_SINGLE 0
51 #define LIST_TYPE_MULTIPLE 1
53 #define SPIN_TYPE_INT 0
54 #define SPIN_TYPE_FLOAT 1
56 #define ALIGN_BEGINNING 0
57 #define ALIGN_CENTER 1
58 #define ALIGN_END 2
60 #define CreateMenuSeparator(w) CreateSeparator(w)
62 extern Widget app_shell; /* defined in xmgrace.c */
64 typedef struct {
65 int value;
66 char *label;
67 } OptionItem;
69 typedef struct {
70 int value;
71 unsigned char *bitmap;
72 } BitmapOptionItem;
74 typedef struct {
75 int value;
76 Widget widget;
77 } OptionWidgetItem;
79 typedef struct {
80 int nchoices;
81 int ncols; /* preferred number of columns */
82 Widget menu;
83 Widget pulldown;
84 OptionWidgetItem *options;
85 } OptionStructure;
87 typedef struct {
88 int nchoices;
89 int *values;
90 void *anydata;
91 Widget rc;
92 Widget list;
93 } ListStructure;
95 /* Storage labeling procedure */
96 typedef char * (*Storage_LabelingProc)(
97 Quark *q,
98 unsigned int *rid
101 typedef struct _StorageStructure StorageStructure;
103 typedef void (*SS_PopupCBProc)(
104 StorageStructure *ss,
105 int nselected /* # of selected list items */
108 struct _StorageStructure {
109 int nchoices;
110 Quark **values;
111 void *anydata;
113 Quark *q;
114 Storage_LabelingProc labeling_proc;
116 Widget rc;
117 Widget list;
118 Widget popup;
119 Widget selpopup;
121 Widget popup_hide_bt;
122 Widget popup_show_bt;
124 Widget popup_delete_bt;
125 Widget popup_duplicate_bt;
127 Widget popup_bring_to_front_bt;
128 Widget popup_send_to_back_bt;
129 Widget popup_move_up_bt;
130 Widget popup_move_down_bt;
132 Widget popup_select_all_bt;
133 Widget popup_unselect_all_bt;
134 Widget popup_invert_selection_bt;
136 SS_PopupCBProc popup_cb;
137 void *data;
140 typedef struct {
141 int type;
142 double min;
143 double max;
144 double incr;
145 Widget rc;
146 Widget text;
147 Widget arrow_up;
148 Widget arrow_down;
149 } SpinStructure;
151 typedef struct {
152 Widget label;
153 Widget form;
154 Widget text;
155 } TextStructure;
157 typedef struct {
158 Widget popup;
159 Widget label_item;
160 Widget shownd_item;
161 Widget showh_item;
162 Widget hide_item;
163 Widget show_item;
164 Widget bringf_item;
165 Widget sendb_item;
166 Widget duplicate_item;
167 Widget kill_item;
168 Widget killd_item;
169 Widget copy12_item;
170 Widget copy21_item;
171 Widget move12_item;
172 Widget move21_item;
173 Widget swap_item;
174 Widget edit_item;
175 } SetPopupMenu;
177 typedef enum {
178 SetMenuHideCB,
179 SetMenuShowCB,
180 SetMenuBringfCB,
181 SetMenuSendbCB,
182 SetMenuDuplicateCB,
183 SetMenuKillCB,
184 SetMenuKillDCB,
185 SetMenuCopy12CB,
186 SetMenuCopy21CB,
187 SetMenuMove12CB,
188 SetMenuMove21CB,
189 SetMenuSwapCB,
190 SetMenuNewFCB,
191 SetMenuNewSCB,
192 SetMenuNewECB,
193 SetMenuNewBCB,
194 SetMenuEditSCB,
195 SetMenuEditECB,
196 SetMenuPackCB
197 } SetMenuCBtype;
199 typedef struct {
200 Widget frame;
201 StorageStructure *graph_sel;
202 StorageStructure *set_sel;
203 } GraphSetStructure;
205 typedef struct {
206 Widget form;
207 GraphSetStructure *src;
208 GraphSetStructure *dest;
209 } SrcDestStructure;
211 typedef struct {
212 Widget dialog;
213 Widget FSB;
214 Widget rc;
215 } FSBStructure;
217 typedef struct {
218 Widget frame;
219 OptionStructure *r_sel;
220 Widget negate;
221 } RestrictionStructure;
223 typedef struct _TransformStructure TransformStructure;
225 typedef void* (*TDBuild_CBProc)(
226 TransformStructure *tdialog
229 typedef void* (*TDGet_CBProc)(
230 void *gui /* specific GUI structure */
233 typedef void (*TDFree_CBProc)(
234 void *tddata /* data */
237 typedef int (*TDRun_CBProc)(
238 Quark *psrc,
239 Quark *pdest,
240 void *tddata /* data */
243 struct _TransformStructure {
244 Widget form;
245 Widget menubar;
246 Widget frame;
247 SrcDestStructure *srcdest;
248 int exclusive;
249 TDBuild_CBProc build_cb;
250 TDGet_CBProc get_cb;
251 TDFree_CBProc free_cb;
252 TDRun_CBProc run_cb;
253 void *gui;
256 typedef struct {
257 TDBuild_CBProc build_cb;
258 TDGet_CBProc get_cb;
259 TDFree_CBProc free_cb;
260 TDRun_CBProc run_cb;
261 } TD_CBProcs;
263 /* OptionChoice CB procedure */
264 typedef void (*OC_CBProc)(
265 OptionStructure *opt,
266 int value, /* value */
267 void * /* data the application registered */
270 /* ToggleButton CB procedure */
271 typedef void (*TB_CBProc)(
272 Widget but,
273 int onoff, /* True/False */
274 void * /* data the application registered */
277 /* FileSelectionBox CB procedure */
278 typedef int (*FSB_CBProc)(
279 FSBStructure *fsbp,
280 char *, /* filename */
281 void * /* data the application registered */
284 /* Button CB procedure */
285 typedef void (*Button_CBProc)(
286 Widget but,
287 void * /* data the application registered */
290 /* List CB procedure */
291 typedef void (*List_CBProc)(
292 ListStructure *listp,
293 int n, /* # of items selected */
294 int *values, /* list of values of the selected items */
295 void * /* data the application registered */
298 /* Storage CB procedure */
299 typedef void (*Storage_CBProc)(
300 StorageStructure *ss,
301 int n, /* # of items selected */
302 Quark **values, /* list of values of the selected items */
303 void *data /* data the application registered */
306 /* Storage double click CB procedure */
307 typedef void (*Storage_DCCBProc)(
308 StorageStructure *ss,
309 Quark *value, /* list of values of the selected items */
310 void *data /* data the application registered */
313 /* Spin Button CB procedure */
314 typedef void (*Spin_CBProc)(
315 SpinStructure *spinp,
316 double, /* value of spinner */
317 void * /* data the application registered */
320 /* Text input CB procedure */
321 typedef void (*Text_CBProc)(
322 TextStructure *cst,
323 char *, /* text string */
324 void * /* data the application registered */
327 /* Text item CB procedure */
328 typedef void (*TItem_CBProc)(
329 Widget ti,
330 char *, /* text string */
331 void * /* data the application registered */
334 /* Scale input CB procedure */
335 typedef void (*Scale_CBProc )(
336 Widget scale,
337 int, /* scale value */
338 void * /* data the application registered */
341 /* AAC Dialog CB procedure */
342 typedef int (*AACDialog_CBProc)(
343 void * /* data the application registered */
346 /* PenChoice input CB procedure */
347 typedef void (*Pen_CBProc )(
348 Widget,
349 const Pen*, /* pen value */
350 void * /* data the application registered */
354 void ManageChild(Widget w);
355 void UnmanageChild(Widget w);
356 int IsManaged(Widget w);
357 void SetSensitive(Widget w, int onoff);
359 Widget GetParent(Widget w);
361 void RegisterEditRes(Widget shell);
363 void SetDimensions(Widget w, unsigned int width, unsigned int height);
364 void GetDimensions(Widget w, unsigned int *width, unsigned int *height);
366 void *GetUserData(Widget w);
367 void SetUserData(Widget w, void *udata);
369 Widget CreateDialogForm(Widget parent, const char *s);
370 void SetDialogFormResizable(Widget form, int onoff);
371 void AddDialogFormChild(Widget form, Widget child);
372 void FixateDialogFormChild(Widget w);
374 Widget CreateFrame(Widget parent, char *s);
376 Widget CreateSeparator(Widget parent);
378 Widget CreateVContainer(Widget parent);
379 Widget CreateHContainer(Widget parent);
381 Widget CreateGrid(Widget parent, int ncols, int nrows);
382 void PlaceGridChild(Widget grid, Widget w, int col, int row);
384 Widget CreateTab(Widget parent);
385 Widget CreateTabPage(Widget parent, char *s);
386 void SelectTabPage(Widget tab, Widget w);
388 Widget CreateScale(Widget parent, char *s, int min, int max, int delta);
389 void SetScaleValue(Widget w, int value);
390 int GetScaleValue(Widget w);
391 void SetScaleWidth(Widget w, int width);
392 void AddScaleCB(Widget w, Scale_CBProc cbproc, void *);
394 SpinStructure *CreateCharSizeChoice(Widget parent, char *s);
396 Widget CreateAngleChoice(Widget parent, char *s);
397 int GetAngleChoice(Widget w);
398 void SetAngleChoice(Widget w, int angle);
400 Widget CreateToggleButton(Widget parent, char *s);
401 int GetToggleButtonState(Widget w);
402 void SetToggleButtonState(Widget w, int value);
403 void AddToggleButtonCB(Widget w, TB_CBProc cbproc, void *anydata);
405 Widget CreateButton(Widget parent, char *label);
406 Widget CreateBitmapButton(Widget parent,
407 int width, int height, const unsigned char *bits);
408 void AddButtonCB(Widget button, Button_CBProc cbproc, void *data);
410 WidgetList CreateAACDialog(Widget form,
411 Widget container, AACDialog_CBProc cbproc, void *data);
413 Widget CreateAACButtons(Widget parent, Widget form, Button_CBProc aac_cb);
415 OptionStructure *CreateOptionChoice(Widget parent, char *labelstr, int ncols,
416 int nchoices, OptionItem *items);
417 OptionStructure *CreateOptionChoiceVA(Widget parent, char *labelstr, ...);
418 OptionStructure *CreateBitmapOptionChoice(Widget parent, char *labelstr, int ncols,
419 int nchoices, int width, int height, BitmapOptionItem *items);
420 void SetOptionChoice(OptionStructure *opt, int value);
421 int GetOptionChoice(OptionStructure *opt);
422 void UpdateOptionChoice(OptionStructure *optp, int nchoices, OptionItem *items);
424 void AddOptionChoiceCB(OptionStructure *opt, OC_CBProc cbproc, void *anydata);
426 ListStructure *CreateListChoice(Widget parent, char *labelstr, int type,
427 int nvisible, int nchoices, OptionItem *items);
428 int SelectListChoice(ListStructure *listp, int choice);
429 void SelectListChoices(ListStructure *listp, int nchoices, int *choices);
430 void UpdateListChoice(ListStructure *listp, int nchoices, OptionItem *items);
431 int GetListChoices(ListStructure *listp, int **values);
432 int GetSingleListChoice(ListStructure *listp, int *value);
433 void AddListChoiceCB(ListStructure *listp, List_CBProc cbproc, void *anydata);
435 void list_selectall_action(Widget w, XEvent *e, String *par, Cardinal *npar);
436 void list_unselectall_action(Widget w, XEvent *e, String *par, Cardinal *npar);
437 void list_invertselection_action(Widget w, XEvent *e, String *par,
438 Cardinal *npar);
440 StorageStructure *CreateStorageChoice(Widget parent,
441 char *labelstr, int type, int nvisible);
442 void SetStorageChoiceLabeling(StorageStructure *ss, Storage_LabelingProc proc);
443 int GetStorageChoices(StorageStructure *ss, Quark ***values);
444 int GetSingleStorageChoice(StorageStructure *ss, Quark **value);
445 int SelectStorageChoice(StorageStructure *ss, Quark *choice);
446 int SelectStorageChoices(StorageStructure *ss, int nchoices, Quark **choices);
447 void UpdateStorageChoice(StorageStructure *ss);
448 void SetStorageChoiceQuark(StorageStructure *ss, Quark *q);
449 void AddStorageChoiceCB(StorageStructure *ss,
450 Storage_CBProc cbproc, void *anydata);
451 void AddStorageChoiceDblClickCB(StorageStructure *ss,
452 Storage_DCCBProc cbproc, void *anydata);
454 SpinStructure *CreateSpinChoice(Widget parent, char *s, int len,
455 int type, double min, double max, double incr);
456 double GetSpinChoice(SpinStructure *spinp);
457 void SetSpinChoice(SpinStructure *spinp, double value);
458 void AddSpinChoiceCB(SpinStructure *spinp, Spin_CBProc cbproc, void *data);
460 TextStructure *CreateTextInput(Widget parent, char *s);
461 TextStructure *CreateCSText(Widget parent, char *s);
462 char *GetTextString(TextStructure *cst);
463 void SetTextString(TextStructure *cst, char *s);
464 void AddTextInputCB(TextStructure *cst, Text_CBProc cbproc, void *data);
465 int GetTextCursorPos(TextStructure *cst);
466 void SetTextCursorPos(TextStructure *cst, int pos);
467 void TextInsert(TextStructure *cst, int pos, char *s);
468 void SetTextEditable(TextStructure *cst, int onoff);
469 void cstext_edit_action(Widget w, XEvent *e, String *par, Cardinal *npar);
471 FSBStructure *CreateFileSelectionBox(Widget parent, char *s);
472 void AddFileSelectionBoxCB(FSBStructure *fsbp, FSB_CBProc cbproc, void *anydata);
473 void SetFileSelectionBoxPattern(FSBStructure *fsb, char *pattern);
475 Widget CreateLabel(Widget parent, char *s);
477 OptionStructure *CreateFontChoice(Widget parent, char *s);
478 OptionStructure *CreatePatternChoice(Widget parent, char *s);
479 OptionStructure *CreateLineStyleChoice(Widget parent, char *s);
480 OptionStructure *CreateSetTypeChoice(Widget parent, char *s);
481 OptionStructure *CreateColorChoice(Widget parent, char *s);
482 OptionStructure *CreateFormatChoice(Widget parent, char *s);
483 OptionStructure *CreateASChoice(Widget parent, char *s);
484 OptionStructure *CreateTextJustChoice(Widget parent, char *s);
485 OptionStructure *CreateJustChoice(Widget parent, char *s);
487 OptionStructure *CreateCharOptionChoice(Widget parent, char *s);
488 void UpdateCharOptionChoice(OptionStructure *opt, int font);
490 Widget CreatePenChoice(Widget parent, char *s);
491 void SetPenChoice(Widget button, Pen *pen);
492 int GetPenChoice(Widget pen_button, Pen *pen);
493 void AddPenChoiceCB(Widget button, Pen_CBProc cbproc, void *anydata);
495 SpinStructure *CreateViewCoordInput(Widget parent, char *s);
497 RestrictionStructure *CreateRestrictionChoice(Widget parent, char *s);
499 StorageStructure *CreateFrameChoice(Widget parent, char *labelstr, int type);
501 StorageStructure *CreateGraphChoice(Widget parent, char *labelstr, int type);
503 StorageStructure *CreateSetChoice(Widget parent, char *labelstr,
504 int type, StorageStructure *graphss);
505 void UpdateSetChoice(StorageStructure *ss);
506 Quark *get_set_choice_gr(StorageStructure *ss);
508 GraphSetStructure *CreateGraphSetSelector(Widget parent, char *s, int sel_type);
509 SrcDestStructure *CreateSrcDestSelector(Widget parent, int sel_type);
510 void UpdateSrcDestSelector(SrcDestStructure *srcdest);
512 void switch_focus_proc(void *data);
513 void hide_graph_proc(void *data);
514 void show_graph_proc(void *data);
515 void duplicate_graph_proc(void *data);
516 void kill_graph_proc(void *data);
517 void copy12_graph_proc(void *data);
518 void copy21_graph_proc(void *data);
519 void move12_graph_proc(void *data);
520 void move21_graph_proc(void *data);
521 void swap_graph_proc(void *data);
522 void create_new_graph_proc(void *data);
524 void hide_set_proc(void *data);
525 void show_set_proc(void *data);
526 void duplicate_set_proc(void *data);
527 void kill_set_proc(void *data);
528 void killd_set_proc(void *data);
529 void copy12_set_proc(void *data);
530 void copy21_set_proc(void *data);
531 void move12_set_proc(void *data);
532 void move21_set_proc(void *data);
533 void swap_set_proc(void *data);
534 void newF_set_proc(void *data);
535 void newS_set_proc(void *data);
536 void newE_set_proc(void *data);
537 void newB_set_proc(void *data);
538 void editS_set_proc(void *data);
539 void editE_set_proc(void *data);
541 SpinStructure *CreateLineWidthChoice(Widget parent, char *s);
543 OptionStructure *CreatePanelChoice(Widget parent, char *labstr, ...);
544 OptionStructure *CreatePrecisionChoice(Widget parent, char *s);
545 OptionStructure *CreatePlacementChoice(Widget parent, char *s);
546 OptionStructure *CreatePaperOrientationChoice(Widget parent, char *s);
547 OptionStructure *CreatePaperFormatChoice(Widget parent, char *s);
549 Widget CreateTextItem2(Widget parent, int len, char *s);
550 Widget CreateTextItem4(Widget parent, int len, char *s);
551 Widget CreateScrollTextItem2(Widget parent, int hgt, char *s);
552 void AddTextItemCB(Widget ti, TItem_CBProc cbproc, void *data);
554 Widget CreateCommandButtons(Widget parent, int n, Widget * buts, char **l);
555 Widget CreateCommandButtonsNoDefault(Widget parent, int n, Widget * buts, char **l);
557 TransformStructure *CreateTransformDialogForm(Widget parent,
558 const char *s, int sel_type, int exclusive, const TD_CBProcs *cbs);
559 int GetTransformDialogSettings(TransformStructure *tdialog,
560 int *nssrc, Quark ***srcsets, Quark ***destsets);
561 void RaiseTransformationDialog(TransformStructure *tdialog);
563 void SetLabel(Widget w, char *s);
564 void AlignLabel(Widget w, int alignment);
565 void SetFixedFont(Widget w);
567 Widget CreateMenuBar(Widget parent);
568 Widget CreateMenu(Widget parent, char *label, char mnemonic, int help);
569 void ManageMenu(Widget menupane);
570 void UnmanageMenu(Widget menupane);
571 Widget CreateMenuButton(Widget parent, char *label, char mnemonic,
572 Button_CBProc cb, void *data);
573 Widget CreateMenuCloseButton(Widget parent, Widget shell);
574 Widget CreateMenuHelpButton(Widget parent, char *label, char mnemonic,
575 Widget form, char *ha);
576 Widget CreateMenuToggle(Widget parent, char *label, char mnemonic,
577 TB_CBProc cb, void *data);
578 Widget CreateMenuLabel(Widget parent, char *name);
580 void AddHelpCB(Widget w, char *ha);
581 void ContextHelpCB(Widget w, void *data);
583 char *GetStringSimple(XmString xms);
585 char *xv_getstr(Widget w);
586 Boolean xv_evalexpr(Widget w, double *);
587 Boolean xv_evalexpri(Widget w, int *);
588 void xv_setstr(Widget w, char *s);
589 void handle_close(Widget w);
590 void RaiseWindow(Widget w);
591 void destroy_dialog(Widget w, XtPointer client_data, XtPointer call_data);
592 void destroy_dialog_cb(Widget but, void *data);
593 void savewidget(Widget w);
594 void deletewidget(Widget w);
596 void DefineDialogCursor(Cursor c);
597 void UndefineDialogCursor(void);
599 #endif /* __MOTIFINC_H_ */