Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 00037 static char *source_file = __FILE__; 00038 /* #include "defs.h" */ 00039 00040 #include <Xm/Xm.h> 00041 #include <Xm/CascadeBG.h> 00042 #include <Xm/Form.h> 00043 #include <Xm/Label.h> 00044 #include <Xm/RowColumn.h> 00045 #include <Xm/ToggleBG.h> 00046 #include "motifutil.h" 00047 00048 /* ==================================================================== 00049 * 00050 * Quit_Callback 00051 * 00052 * Callback for quitting the program. 00053 * 00054 * ==================================================================== 00055 */ 00056 00057 void 00058 Quit_Callback ( 00059 Widget w, /* Invoking widget */ 00060 XtPointer client_data, /* Client's data */ 00061 XtPointer call_data ) /* Callback data */ 00062 { 00063 XtCloseDisplay ( XtDisplay(w) ); 00064 exit (0); 00065 } 00066 00067 00068 /* ==================================================================== 00069 * 00070 * Unmanage_Callback 00071 * 00072 * Callback for unmanaging a popup form. 00073 * 00074 * ==================================================================== 00075 */ 00076 00077 void 00078 Unmanage_Callback ( 00079 Widget w, /* Invoking widget */ 00080 XtPointer form, /* Client's data -- form to unmanage*/ 00081 XtPointer call_data ) /* Callback data */ 00082 { 00083 XtUnmanageChild ( (Widget) form ); 00084 } 00085 00086 /* ==================================================================== 00087 * 00088 * Build_Radio_Box 00089 * 00090 * Create a radio box widget, with the given parent and Args, and with 00091 * children which are toggle button gadgets with labels given. 00092 * 00093 * If title is non-NULL, the radio box is put in a form with the title 00094 * above it. 00095 * 00096 * ==================================================================== 00097 */ 00098 00099 Widget 00100 Build_Radio_Box ( 00101 Widget parent, /* Parent widget */ 00102 char *title, /* Title or NULL */ 00103 char *name, /* Name of radio box */ 00104 Arg wargs[], /* Argument array, with some extra space */ 00105 int nargs, /* Current size of wargs array */ 00106 char *labels[], /* Button label array */ 00107 int nlabels ) /* Number of buttons */ 00108 { 00109 Widget form = NULL; 00110 Widget title_lab, radio_box, radio_button; 00111 char namebuf[512]; 00112 int i; 00113 00114 if ( title != NULL ) { 00115 /* We need a form to attach a title: */ 00116 (void) strcpy ( namebuf, name ); 00117 (void) strcat ( namebuf, ".form" ); 00118 form = XtCreateManagedWidget ( 00119 namebuf, xmFormWidgetClass, parent, wargs, nargs ); 00120 title_lab = XtCreateManagedWidget ( 00121 title, xmLabelGadgetClass, form, NULL, 0 ); 00122 nargs = 0; 00123 XtSetArg ( wargs[nargs], XmNtopAttachment, XmATTACH_WIDGET ); 00124 nargs++; 00125 XtSetArg ( wargs[nargs], XmNtopWidget, title_lab ); 00126 nargs++; 00127 parent = form; 00128 } 00129 00130 XtSetArg ( wargs[nargs], XmNentryClass, 00131 xmToggleButtonGadgetClass ); nargs++; 00132 radio_box = XmCreateRadioBox ( parent, name, wargs, nargs ); 00133 XtManageChild ( radio_box ); 00134 for (i=0; i < nlabels; i++) { 00135 radio_button = XtCreateManagedWidget ( 00136 labels[i], 00137 xmToggleButtonGadgetClass, 00138 radio_box, 00139 NULL, 00140 0); 00141 } 00142 00143 return form ? form : radio_box; 00144 } 00145 00146 /* ==================================================================== 00147 * 00148 * Build_Pulldown_Menu 00149 * 00150 * Construct a pulldown menu. Pulldown menus are built from cascade 00151 * buttons, so this function creates the cascade button which owns the 00152 * menu, the menu, and any submenu specified. It uses the recursive 00153 * MENU_ITEM data structure for describing the menu(s) to be created. 00154 * 00155 * This is based on an article in The X Journal, Jan/Feb 1992, by Dan 00156 * Heller. 00157 * 00158 * ==================================================================== 00159 */ 00160 00161 Widget 00162 Build_Pulldown_Menu ( 00163 Widget parent, 00164 char *menu_title, 00165 char menu_mnemonic, 00166 MENU_ITEM *items ) 00167 { 00168 Widget PullDown, cascade, widget; 00169 int i; 00170 XmString str; 00171 00172 /* Create the menu shell: */ 00173 PullDown = XmCreatePulldownMenu ( parent, "_pulldown", NULL, 0 ); 00174 00175 /* Create the cascade button: */ 00176 str = XmStringCreateSimple ( menu_title ); 00177 cascade = XtVaCreateManagedWidget ( 00178 menu_title, xmCascadeButtonGadgetClass, parent, 00179 XmNsubMenuId, PullDown, 00180 XmNlabelString, str, 00181 XmNmnemonic, menu_mnemonic, 00182 NULL ); 00183 XmStringFree ( str ); 00184 00185 /* Now add the menu items: */ 00186 for ( i = 0; MITEM_label(items,i) != NULL; i++ ) { 00187 00188 /* If a subitem menu is specified, make a recursive call for the 00189 * pull-right menu, and use the cascade button returned: 00190 */ 00191 if ( MITEM_subitems(items,i) != NULL ) { 00192 widget = Build_Pulldown_Menu ( PullDown, 00193 MITEM_label(items,i), 00194 MITEM_mnemonic(items,i), 00195 MITEM_subitems(items,i) ); 00196 } else { 00197 widget = XtVaCreateManagedWidget ( 00198 MITEM_label(items,i), 00199 *MITEM_class(items,i), 00200 PullDown, NULL ); 00201 } 00202 00203 /* In either case, this item can have a mnemonic: */ 00204 if ( MITEM_mnemonic(items,i) != NULL ) { 00205 XtVaSetValues ( widget, 00206 XmNmnemonic, MITEM_mnemonic(items,i), 00207 NULL ); 00208 } 00209 00210 /* Any item can have an accelerator except cascade menus. But we 00211 * don't worry about the exception, assuming that the menu item 00212 * structures were built correctly: 00213 */ 00214 if ( MITEM_accelerator(items,i) != NULL ) { 00215 str = XmStringCreateSimple ( MITEM_accel_text(items,i) ); 00216 XtVaSetValues ( widget, 00217 XmNaccelerator, MITEM_accelerator(items,i), 00218 XmNacceleratorText, str, 00219 NULL ); 00220 XmStringFree ( str ); 00221 } 00222 00223 /* Finally, anyone can have a callback: */ 00224 if ( MITEM_callback(items,i) != NULL ) { 00225 XtAddCallback ( widget, XmNactivateCallback, 00226 MITEM_callback(items,i), 00227 MITEM_callback_data(items,i) ); 00228 } 00229 } 00230 00231 /* Return the cascade button: */ 00232 return cascade; 00233 }