#ifndef lint static char rcsId[]="$Header: /usr/local/rcs/Newt/XmHTML/RCS/debug_menu.c,v 1.1 1997/08/31 17:45:23 newt Exp newt $"; #endif /***** * debug_menu.c : put_a_description_here * * This file Version $Revision: 1.1 $ * * Creation date: Sun Aug 31 14:23:40 GMT+0100 1997 * Last modification: $Date: 1997/08/31 17:45:23 $ * By: $Author: newt $ * Current State: $State: Exp $ * * Author: newt * * Copyright (C) 1994-1997 by Ripley Software Development * All Rights Reserved * * This file is part of insert_program_name_here * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU [Library] General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU [Library] General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *****/ /***** * ChangeLog * $Log: debug_menu.c,v $ * Revision 1.1 1997/08/31 17:45:23 newt * Initial Revision * *****/ #include #include #include #ifdef DEBUG #include #include #include #include #include /* XmIsHTML() macro & resource definitions */ #include "debug.h" /* debug arrays */ #include "debug_menu.h" /* proto's */ /*** External Function Prototype Declarations ***/ /*** Public Variable Declarations ***/ /*** Private Datatype Declarations ****/ typedef struct{ String file; int file_id; }debugRec; /*** Private Function Prototype Declarations ****/ static void debugCB(Widget w, XtPointer client_data, XmToggleButtonCallbackStruct *cbs); static void debugResCB(Widget w, XtPointer client_data, XmToggleButtonCallbackStruct *cbs); /*** Private Variable Declarations ***/ #define MAX_ENTRIES 15 static debugRec debugLevels[MAX_ENTRIES] = { { "XmHTML.c", 1}, { "format.c", 2}, { "callbacks.c", 3}, { "parse.c", 4}, { "paint.c", 5}, { "images.c/XmImage.c", 6}, { "colors.c", 7}, { "fonts.c", 8}, { "XCC.c", 9}, { "map.c", 10}, { "frames.c", 11}, { "forms.c", 12}, { "quantize.c", 13}, { "plc.c", 14}, { "Image readers", 15} }; /***** * Name: debugCB * Return Type: void * Description: debug level callback. Sets/Unsets the selected debug level. * In: * w: widget id of toggleButton triggering this callback; * client_..: selected debug level; * cbs: toggleButton callback data; * Returns: * nothing. *****/ static void debugCB(Widget w, XtPointer client_data, XmToggleButtonCallbackStruct *cbs) { xmhtml_debug_levels_defined[(int)client_data] = cbs->set; } /***** * Name: debugResCB * Return Type: void * Description: callback for XmHTML debug resources. * In: * w: widget id of toggleButton triggering this callback; * client_..: id of selected button; * cbs: toggleButton callback data; * Returns: * nothing. *****/ static void debugResCB(Widget w, XtPointer client_data, XmToggleButtonCallbackStruct *cbs) { Widget html = NULL; XtVaGetValues(w, XmNuserData, &html, NULL); if(html == NULL) return; switch((int)client_data) { case MAX_ENTRIES+1: XtVaSetValues(html, XmNdebugDisableWarnings, (Boolean)cbs->set, NULL); break; case MAX_ENTRIES+2: XtVaSetValues(html, XmNdebugEnableFullOutput, (Boolean)cbs->set, NULL); break; case MAX_ENTRIES+3: XtVaSetValues(html, XmNdebugSaveClipmasks, (Boolean)cbs->set, NULL); break; case MAX_ENTRIES+4: XtVaSetValues(html, XmNdebugNoAnimationLoopCount, (Boolean)cbs->set, NULL); break; default: fprintf(stderr, "debugResCB: impossible selection (id = %i)\n", (int)client_data); break; } } /***** * Name: AddDebugMenu * Return Type: void * Description: adds a "Debug" menu to the menubar of an application. * Allows one to select debug output when an application is * running. * In: * html: XmHTMLWidget id; * menubar: menubar Widget id to which a debug menu should be added; * label: the label to use for this menu. When NULL, "Debug" is used; * Returns: * nothing. *****/ void DebugAddMenu(Widget html, Widget menubar, String label) { Widget tb, debug_menu; int i; XmString xms; char accel; Boolean full = False, nowarn = False, savemasks = False, noloop = False; /* sanity */ if(html == NULL || !XmIsHTML(html) || menubar == NULL) return; XtVaGetValues(html, XmNdebugDisableWarnings, &nowarn, XmNdebugEnableFullOutput, &full, XmNdebugSaveClipmasks, &savemasks, XmNdebugNoAnimationLoopCount, &noloop, NULL); if(label == NULL) label = "Debug"; accel = label[0]; /* create debug menu */ debug_menu = XmCreatePulldownMenu(menubar, "debugPulldown", NULL, 0); /* create options button */ xms = XmStringCreateLocalized(label); tb = XtVaCreateManagedWidget(label, xmCascadeButtonWidgetClass, menubar, XmNlabelString, xms, XmNmnemonic, accel, XmNsubMenuId, debug_menu, NULL); XmStringFree(xms); /* don't need it anymore */ for(i = 0; i < MAX_ENTRIES; i++) { tb = XtVaCreateManagedWidget(debugLevels[i].file, xmToggleButtonGadgetClass, debug_menu, XmNset, xmhtml_debug_levels_defined[debugLevels[i].file_id], NULL); XtAddCallback(tb, XmNvalueChangedCallback, (XtCallbackProc)debugCB, (XtPointer)debugLevels[i].file_id); } XtVaCreateManagedWidget("separator", xmSeparatorGadgetClass, debug_menu, NULL); tb = XtVaCreateManagedWidget("Disable Warnings", xmToggleButtonGadgetClass, debug_menu, XmNset, nowarn, XmNuserData, html, /* need to have this */ NULL); XtAddCallback(tb, XmNvalueChangedCallback, (XtCallbackProc)debugResCB, (XtPointer)(MAX_ENTRIES+1)); tb = XtVaCreateManagedWidget("Save Clipmasks", xmToggleButtonGadgetClass, debug_menu, XmNset, savemasks, XmNuserData, html, /* need to have this */ NULL); XtAddCallback(tb, XmNvalueChangedCallback, (XtCallbackProc)debugResCB, (XtPointer)(MAX_ENTRIES+2)); tb = XtVaCreateManagedWidget("No Animation loopcount", xmToggleButtonGadgetClass, debug_menu, XmNset, noloop, XmNuserData, html, /* need to have this */ NULL); XtAddCallback(tb, XmNvalueChangedCallback, (XtCallbackProc)debugResCB, (XtPointer)(MAX_ENTRIES+3)); tb = XtVaCreateManagedWidget("Full Output", xmToggleButtonGadgetClass, debug_menu, XmNset, full, XmNuserData, html, /* need to have this */ NULL); XtAddCallback(tb, XmNvalueChangedCallback, (XtCallbackProc)debugResCB, (XtPointer)(MAX_ENTRIES+4)); /* show it */ XtManageChild(debug_menu); } #else /* DEBUG */ /*ARGSUSED*/ void DebugAddMenu(Widget html, Widget menubar, String label) { ; /* do nothing */ } #endif