1 /* Copyright (C) 1992-1998 The Geometry Center 2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips 3 * 4 * This file is part of Geomview. 5 * 6 * Geomview is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU Lesser General Public License as published 8 * by the Free Software Foundation; either version 2, or (at your option) 9 * any later version. 10 * 11 * Geomview is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with Geomview; see the file COPYING. If not, write 18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, 19 * USA, or visit http://www.gnu.org. 20 */ 21 #include <stdio.h> 22 #include <stdlib.h> 23 #include <X11/Intrinsic.h> 24 #include <X11/Shell.h> 25 #include <Xm/Xm.h> 26 #include <Xm/Text.h> 27 #include <Xm/TextF.h> 28 #include <Xm/RowColumn.h> 29 #include <Xm/MainW.h> 30 #include <Xm/Label.h> 31 #include <Xm/PushB.h> 32 #include <Xm/PushBG.h> 33 #include <Xm/ToggleB.h> 34 #include <Xm/ToggleBG.h> 35 #include <Xm/DrawingA.h> 36 #include <Xm/CascadeBG.h> 37 #include <Xm/SeparatoG.h> 38 #include <Xm/Frame.h> 39 #include <Xm/BulletinB.h> 40 #include <Xm/Scale.h> 41 #include <Xm/ScrollBar.h> 42 #include <Xm/Form.h> 43 #include <Xm/List.h> 44 #include <Xm/FileSB.h> 45 #include <Xm/AtomMgr.h> 46 #include <Xm/Protocols.h> 47 #include <Xm/MwmUtil.h> 48 49 50 /* Structure of mib_Widget */ 51 /*****************************************************************************/ 52 53 typedef struct _mib_Widget { 54 char *mib_class; /* name of mib class (Button, TextBox, etc..)*/ 55 int mib_class_num; /* class number for ez reference :) */ 56 int mib_mynum; /* numbering for storage format */ 57 Widget me; /* Xt widget */ 58 int mib_selected; /* is selected */ 59 int mib_resizing; /* is resizing 1, or being moved 0 */ 60 int mib_resizetype;/* 1 = upper left, 2 = upper, 3 = ... */ 61 int mib_allowresize; /* can this widget be resized ? */ 62 63 int clkx, clky; /* where user clicked */ 64 65 void *myres; /* my resources (different for each widget) */ 66 67 char *name; /* reference name of this widget */ 68 int width, height; /* width and height */ 69 70 int topAttachment, bottomAttachment, leftAttachment, rightAttachment; 71 /* attachments 1=attached 0=not-attached */ 72 73 int topOffset, bottomOffset, leftOffset, rightOffset; 74 /* offsets if attached */ 75 76 struct _mib_Widget *parent; /* pointer to parent */ 77 struct _mib_Widget *sibling; /* remaining linked list of sibling widgets */ 78 struct _mib_Widget *prev; /* previous sibling or parent */ 79 struct _mib_Widget *child; /* linked list of children widgets */ 80 } mib_Widget; 81 82 /* mib_Buffer structure */ 83 /*****************************************************************************/ 84 85 typedef struct _mib_Buffer { 86 void *buffer; /* pointer to either a file or a char string */ 87 int buf_type; /* type of buffer (defined above) */ 88 int point; /* pointer for string */ 89 int buflen; /* length of string buffer */ 90 } mib_Buffer; 91 92 /* mib_Widget functions */ 93 /*****************************************************************************/ 94 95 void mib_add_mib_Widget(mib_Widget *, mib_Widget *); 96 void mib_add_backward_Widget(mib_Widget *, mib_Widget *); 97 void mib_remove_mib_Widget(mib_Widget *); 98 void mib_clear_myres(mib_Widget *); 99 mib_Widget *mib_new_mib_Widget(); 100 mib_Widget *mib_find_name(mib_Widget *, char *); 101 mib_Widget *mib_load_interface(Widget, char *, int); 102 int mib_count_all(mib_Widget *, int); 103 int mib_load_Root(Widget, mib_Widget **, mib_Buffer *); 104 mib_Widget *mib_load_public(mib_Widget *, mib_Widget *, mib_Buffer *); 105 int mib_load_mib_class(mib_Widget **, mib_Widget *, char *, char *, 106 mib_Buffer *); 107 int mib_load_private(mib_Widget *, mib_Buffer *); 108 void mib_reset_size(mib_Widget *); 109 int mib_read_line(mib_Buffer *, char *, char *); 110 void mib_set_eventhandlers(void (*a)(), void (*b)(), void (*c)()); 111 void mib_apply_eventhandlers(Widget, mib_Widget *); 112 113 void mib_add_backward(mib_Widget *this, mib_Widget *parent); 114 115 /* supporting functions and structures */ 116 /*****************************************************************************/ 117 118 typedef struct _menu_item { 119 char *label; 120 WidgetClass *class; 121 char mnemonic; 122 char *accelerator; 123 char *accel_text; 124 void (*callback)(); 125 XtPointer callback_data; 126 struct _menu_item *subitems; 127 } MenuItem; 128 129 Widget BuildMenu(Widget, int, char *, char, MenuItem *); 130 131 /* mib class numbers */ 132 133 #define MIB_NULL 0 134 #define MIB_TEXTBOX 1 135 #define MIB_BUTTON 2 136 #define MIB_TOGGLE 3 137 #define MIB_RADIOBOX 4 138 #define MIB_DRAWINGAREA 5 139 #define MIB_LABEL 6 140 #define MIB_FRAME 7 141 #define MIB_SCROLLBAR 8 142 #define MIB_TEXTBIG 9 143 #define MIB_LIST 10 144 #define MIB_SCALE 11 145 #define MIB_MENU 12 146 147 /* number of classes */ 148 #define MI_NUMCLASSES 12 149 150 /* for specifying creation of a widget with 151 default private values, no values at all (empty), 152 or no values and editable */ 153 154 #define WDEFAULT 1 155 #define WEMPTY 2 156 #define WEDIT 3 157 158 /* for specifing whether we are loading an 159 interface from a file or from a string and whether it 160 is editable :) */ 161 162 #define MI_FROMFILE 1 163 #define MI_EDITFROMFILE 2 164 #define MI_FROMSTRING 3 165 #define MI_EDITFROMSTRING 4 166 167 #define MI_MAXSTRLEN 200 /* maximum string length */ 168