VOID ExitListRoutine( ULONG ExitReason )
{
  SpyDeRegister( SpyInstance );       /* De-Register with our DLL */

  if ( hSwitch != NULLH )
     WinRemoveSwitchEntry(hSwitch);

  if ( hwndFrame != NULLH )
    WinDestroyWindow(hwndFrame);

  if ( hmq != NULLH )
    WinDestroyMsgQueue(hmq);

  /* cleanup STRINGTABLEs loaded for us... */

  FreeStringTable(sizeof(Strings) / sizeof(Strings[0]),  /* max # Strings[] */
                  Strings);                              /* start of string table */

  FreeStringTable(sizeof(Controls) / sizeof(Controls[0]), /* max # Controls[] */
                  Controls);                         /* start of string table */

  if ( hmodNLS != 0 )
    DosFreeModule(hmodNLS);

  if ( hab != 0 )
    WinTerminate(hab);

  DosExitList(EXLST_EXIT, NULL);                /* Indicate "done" */
}
Пример #2
0
static void redisplay1DHistoList()
{
    int i, id, nItems, l, uid, k, nh, jn, *il;
    nTuBrowserInfo *nTuBr;
    XmString *stringTable;
    
    for(jn=0, nh=0; jn< NumOfNTuples; jn++)  {
       nTuBr = NTupleBrowserList[jn];
       for (i=0; i<nTuBr->sizeOfLists; i++) {
         if (nTuBr->hsItemList[i] == NULL) continue;
          id = nTuBr->hsItemList[i]->id;
          if ( (id != -1) && (hs_type(id) == HS_1D_HISTOGRAM)) nh++;
       }    
    }
    OneDHistNumberListed = nh;
    if (nh == 0) {
       stringTable = (XmString *)XtMalloc((1) * sizeof(XmString));
       stringTable[1] = (XmString)0;
       setListItems(OneDHistHistoListW, stringTable, 0);
      /* free the string table */
       FreeStringTable(stringTable);
       return;
    } 
    if (nh > OneDHistSizeOfList) {
       il =  (int *) malloc(sizeof(int) * 2 * nh);
       memcpy((void *) il, (void *) OneDHistListedIDs, (sizeof(int) * nh));
       free(OneDHistListedIDs); OneDHistListedIDs = il;
       OneDHistSizeOfList = 2*nh;
    } 
    stringTable = (XmString *)XtMalloc((nh+1) * sizeof(XmString));
    for(jn=0, nh=0; jn< NumOfNTuples; jn++)  {
       nTuBr = NTupleBrowserList[jn];
       for (i=0; i<nTuBr->sizeOfLists; i++) {
         if (nTuBr->hsItemList[i] == NULL) continue;
         id = nTuBr->hsItemList[i]->id;
         if (nTuBr->hsItemList[i]->type == HS_1D_HISTOGRAM) {
             l = hs_title(id, BrowseUtil2htitle);
             stringTable[nh] = XmStringCreateSimple (BrowseUtil2htitle);
             OneDHistListedIDs[nh] = id;
             nh++; 
          }
        }
    }
    stringTable[nh] =  (XmString ) NULL;
    setListItems(OneDHistHistoListW, stringTable, nh);
    FreeStringTable(stringTable);
    return;
    
}                  
Пример #3
0
/*
** Set the contents of a list and compensate for various motif problems
** associated with this apparently bizarre act.  (It might be worth
** further investigation to better understand why these workarounds
** are necessary).
*/
static void setListItems(Widget w, XmString *strings, int nStrings)
{
    XmString *st1;
    
    /* Motif doesn't reset the selection when items are changed */
    XmListDeselectAllItems(w);

    /* .. and sometimes leaves stray scroll bars if nothing is in the list */
    if (nStrings == 0) {
    	XtVaSetValues(w, XmNitems, st1=StringTable(1, " "),
    		XmNitemCount, 1, XmNsensitive, False, 0);
    	FreeStringTable(st1);
    } else {
    	XtVaSetValues(w, XmNitems, strings, XmNitemCount, nStrings,
    		XmNsensitive, True, 0);
    }
}
Пример #4
0
BOOLEAN
_ReleaseSoundBankData (void *Snd)
{
	STRING_TABLE fxTab = Snd;

	if (fxTab)
	{
		int snd_ct, index;
		TFB_SoundSample **sptr;

		snd_ct = fxTab->size;
		index = 0;
		while (snd_ct--)
		{
			int i;
			
			sptr = (TFB_SoundSample **)(fxTab->strings[index].data);

			for (i = 0; i < NUM_SOUNDSOURCES; ++i)
			{
				if (soundSource[i].sample == (*sptr))
				{
					StopSource (i);
					soundSource[i].sample = NULL;
				}
			}

            if ((*sptr)->decoder)
			    SoundDecoder_Free ((*sptr)->decoder);
			audio_DeleteBuffers ((*sptr)->num_buffers, (*sptr)->buffer);
			HFree ((*sptr)->buffer);
			if ((*sptr)->buffer_tag)
				HFree ((*sptr)->buffer_tag);
			HFree (*sptr);
			*sptr = 0;
			index++;
		}
		FreeStringTable (Snd);

		return (TRUE);
	}

	return (FALSE);
}
Пример #5
0
BOOLEAN
_ReleaseSoundBankData (MEM_HANDLE Snd)
{
	STRING_TABLEPTR fxTab;

	LockStringTable (Snd, &fxTab);
	if (fxTab)
	{
		int snd_ct;
		TFB_SoundSample **sptr;

		snd_ct = fxTab->StringCount;
		sptr = (TFB_SoundSample **)((BYTE *)fxTab + fxTab->StringOffsets[0]);
		while (snd_ct--)
		{
			int i;
			
			for (i = 0; i < NUM_SOUNDSOURCES; ++i)
			{
				if (soundSource[i].sample == (*sptr))
				{
					StopSource (i);
					soundSource[i].sample = NULL;
				}
			}

            if ((*sptr)->decoder)
			    SoundDecoder_Free ((*sptr)->decoder);
			audio_DeleteBuffers ((*sptr)->num_buffers, (*sptr)->buffer);
			HFree ((*sptr)->buffer);
			if ((*sptr)->buffer_tag)
				HFree ((*sptr)->buffer_tag);
			HFree (*sptr);
			*sptr++ = 0;
		}
		UnlockStringTable (Snd);
		FreeStringTable (Snd);

		return (TRUE);
	}

	return (FALSE);
}
Пример #6
0
void mcfioC_OneDHistUpdateNTupleContent()
{
/*
** Update the Data Descriptioon in the 1D Histogram panel
*/
   int i, id, nItems, l, uid, k;
   XmString *stringTable;
   nTuDDL *ddl;
   descrGenNtuple *dNTu;
   varGenNtuple *var;
   Arg args[2];
   XmString s1;
   
   if (OneDHistShellW == NULL) return;
   if (!XtIsManaged(OneDHistFormW)) return;
   ddl = mcf_GetNTuByPtrID(CurrentNTupleBrowserSelected->id);
   if (ddl->descrNtu == NULL) dNTu = ddl->reference->descrNtu;
	    else dNTu = ddl->descrNtu;
   /*
   ** Update the Label fields 
   */
   XtSetArg(args[0], XmNlabelString, s1 = XmStringCreateSimple(ddl->category));
   XtSetValues(OneDHistNtupleCategoryLabelW, args, 1);
   XmStringFree(s1);
   
   XtSetArg(args[0], XmNlabelString, s1 = XmStringCreateSimple(ddl->title));
   XtSetValues(OneDHistNtupleTitleLabelW, args, 1);
   XmStringFree(s1);
   
   nItems = dNTu->numVariables + 1; 
   stringTable = (XmString *)XtMalloc((nItems+1) * sizeof(XmString));
   stringTable[0] = XmStringCreateSimple ("Multiplicity");
   for (k=0; k<dNTu->numVariables; k++) {
      var = dNTu->variables[k];
      stringTable[k+1] = XmStringCreateSimple (var->name);
    }
    stringTable[nItems] = (XmString ) NULL;
    setListItems(OneDHistVariableListW, stringTable, nItems);
    FreeStringTable(stringTable);
    return;
}
Пример #7
0
static void createBrowserOneDHistPanel(nTuBrowserInfo *nTuBr)
{
    Arg args[50];
    int ac;
    XmString s1, *st1;
    Widget dismissBtn, nbinLabel, lowEdgeLabel, highEdgeLabel, multLabel;
    Widget histForm, ntupleForm, titleLabel, histLabel, ntupleLabel;
    Widget ntupleCatLabel, ntupleTitleLabel;

    ac = 0;
    XtSetArg(args[ac], XmNautoUnmanage, False); ac++; 
    XtSetArg(args[ac], XmNresizePolicy, XmRESIZE_NONE); ac++; 
    OneDHistFormW = XmCreateFormDialog(McfioMainPanelW, "form", args, ac);
    OneDHistShellW = XtParent(OneDHistFormW);
    XtVaSetValues(OneDHistShellW, XmNtitle,
                                "One Dimensional Histogram Utility", 0);
    AddMotifCloseCallback(XtParent(OneDHistFormW),
                         (XtCallbackProc)dismissOneDHistCB, NULL);
                         
   OneDHistCreateW = XtVaCreateManagedWidget("create1DBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Create"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 2,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 18, 0);
    XmStringFree(s1);
    XtAddCallback( OneDHistCreateW, XmNactivateCallback,
    	    (XtCallbackProc)createOneDHistCB, (nTuBrowserInfo *) nTuBr );
                         
                         
   OneDHistModifyW = XtVaCreateManagedWidget("modify1DBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Modify"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 20,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 40, 0);
    XmStringFree(s1);
    XtAddCallback( OneDHistModifyW, XmNactivateCallback,
    	    (XtCallbackProc)modifyOneDHistCB, NULL);
    	    
   OneDHistDeleteW = XtVaCreateManagedWidget("delete1DBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Delete"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 42,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 60, 0);
    XmStringFree(s1);
    XtAddCallback( OneDHistDeleteW, XmNactivateCallback,
    	    (XtCallbackProc)deleteOneDHistCB, NULL);
    	    
    dismissBtn = XtVaCreateManagedWidget("dismissBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Dismiss"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 80,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 98, 0);
    XmStringFree(s1);
    XtAddCallback(dismissBtn, XmNactivateCallback,
    	    (XtCallbackProc)dismissOneDHistCB, NULL);

    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Number of bins:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,5); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    nbinLabel = 
       XmCreateLabelGadget(OneDHistFormW, "num1Dbin", args, ac);
    XmStringFree(s1);
    XtManageChild(nbinLabel);
    
    OneDHistNumBinsW = XtVaCreateManagedWidget("numBin1D",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 5,
            XmNmaxLength, 5,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,nbinLabel, 0);
    RemapDeleteKey(OneDHistNumBinsW);
    XmTextSetString(OneDHistNumBinsW, "100");
    
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Low Edge:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,OneDHistNumBinsW); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    lowEdgeLabel = 
       XmCreateLabelGadget(OneDHistFormW, "low1Dbin", args, ac);
    XmStringFree(s1);
    XtManageChild(lowEdgeLabel);
    
    OneDHistLowBinW = XtVaCreateManagedWidget("lowEdge1D",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 10,
            XmNmaxLength, 20,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,lowEdgeLabel, 0);
    RemapDeleteKey(OneDHistLowBinW);
    XmTextSetString(OneDHistLowBinW, "0.");
        	    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("High Edge:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,OneDHistLowBinW); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    highEdgeLabel = 
       XmCreateLabelGadget(OneDHistFormW, "high1Dbin", args, ac);
    XmStringFree(s1);
    XtManageChild(highEdgeLabel);
    
    OneDHistHighBinW = XtVaCreateManagedWidget("highEdge1D",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 10,
            XmNmaxLength, 20,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,highEdgeLabel, 0);
    RemapDeleteKey(OneDHistHighBinW);
    XmTextSetString(OneDHistHighBinW, "1.");
    
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Instance:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,OneDHistHighBinW); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    multLabel = 
       XmCreateLabelGadget(OneDHistFormW, "inst1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(multLabel);
    
    OneDHistMultW = XtVaCreateManagedWidget("inst1DTw",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 10,
            XmNmaxLength, 20,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,multLabel, 0);
    RemapDeleteKey(OneDHistMultW);
    XmTextSetString(OneDHistMultW, "All");
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Title:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistNumBinsW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    titleLabel = 
       XmCreateLabelGadget(OneDHistFormW, "title1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(titleLabel);
    
    OneDHistTitleW = XtVaCreateManagedWidget("title1DTw",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 80,
            XmNmaxLength, 255,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistNumBinsW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,titleLabel, 0);
    RemapDeleteKey(OneDHistTitleW);
    XmTextSetString(OneDHistTitleW, "Please enter a meaningful title here");
    /*
    ** Now the list of 1D histograms.
    */
    /* Create a form to hold the list and the top label */
    ac = 0;
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget, OneDHistTitleW); ac++;
    XtSetArg(args[ac], XmNbottomOffset, 3); ac++;
    XtSetArg(args[ac], XmNleftOffset, 2); ac++;
    XtSetArg(args[ac], XmNtopOffset, 2); ac++;
    histForm = XmCreateForm(OneDHistFormW, "hist1DForm", args, ac);
    XtManageChild(histForm);

    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple(
     "One Dimensional Histogram Listing"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    histLabel = 
       XmCreateLabelGadget(histForm, "HIST1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(histLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNitems, (st1=StringTable(1,
     "No histogram defined                        "))); ac++;
    XtSetArg(args[ac], XmNitemCount, 1); ac++;
    XtSetArg(args[ac], XmNscrollBarDisplayPolicy, XmAS_NEEDED); ac++;
    XtSetArg(args[ac], XmNvisibleItemCount, 10); ac++;
    XtSetArg(args[ac], XmNselectionPolicy, XmBROWSE_SELECT); ac++;
    XtSetArg(args[ac], XmNlistSizePolicy, XmCONSTANT); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopWidget, histLabel); ac++;
    XtSetArg(args[ac], XmNtopOffset, 0); ac++;
    XtSetArg(args[ac], XmNleftOffset, 3); ac++;
    XtSetArg(args[ac], XmNbottomOffset, 4); ac++;
    OneDHistHistoListW = XmCreateScrolledList(histForm, "hist1DList", args,ac);
    FreeStringTable(st1);
    XtAddCallback(OneDHistHistoListW, XmNbrowseSelectionCallback,
                  (XtCallbackProc)  oneDHistListCB, NULL);
    XtManageChild(OneDHistHistoListW);
    OneDHistSizeOfList = 10;
    OneDHistNumberListed = 0;
    OneDHistListedIDs = (int *) malloc(sizeof(int) * OneDHistSizeOfList);
    /*
    ** Now the list of Ntuple Variables. Also a few Label to refer to the 
    ** Ntuple category/title listed on the Main panel.
    ** 
    */
    /* Create a form to hold the list and the top label */
    ac = 0;
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget, histForm); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget, OneDHistTitleW); ac++;
    XtSetArg(args[ac], XmNbottomOffset, 3); ac++;
    XtSetArg(args[ac], XmNleftOffset, 6); ac++;
    XtSetArg(args[ac], XmNtopOffset, 2); ac++;
    ntupleForm = XmCreateForm(OneDHistFormW, "ntu1DForm", args, ac);
    XtManageChild(ntupleForm);

    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Selected NTuple Synopsis"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    ntupleLabel = 
       XmCreateLabelGadget(ntupleForm, "NTU1DDlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(ntupleLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Category:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    XtSetArg(args[ac], XmNtopWidget,ntupleLabel ); ac++;
    ntupleCatLabel = 
       XmCreateLabelGadget(ntupleForm, "NTU1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(ntupleCatLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("None----------------------"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,ntupleCatLabel ); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    XtSetArg(args[ac], XmNtopWidget,ntupleLabel ); ac++;
    OneDHistNtupleCategoryLabelW = 
       XmCreateLabelGadget(ntupleForm, "NTU1DCatlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(OneDHistNtupleCategoryLabelW);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Title:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopWidget, ntupleCatLabel); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    ntupleTitleLabel = 
       XmCreateLabelGadget(ntupleForm, "NTU1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(ntupleTitleLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("None----------------------"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,ntupleCatLabel ); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopWidget,ntupleCatLabel ); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    OneDHistNtupleTitleLabelW = 
       XmCreateLabelGadget(ntupleForm, "NTU1DTitlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(OneDHistNtupleTitleLabelW);
    
    ac = 0;
    XtSetArg(args[ac], XmNitems, (st1=StringTable(1, " "))); ac++;
    XtSetArg(args[ac], XmNitemCount, 1); ac++;
    XtSetArg(args[ac], XmNscrollBarDisplayPolicy, XmAS_NEEDED); ac++;
    XtSetArg(args[ac], XmNvisibleItemCount, 10); ac++;
    XtSetArg(args[ac], XmNselectionPolicy, XmBROWSE_SELECT); ac++;
    XtSetArg(args[ac], XmNlistSizePolicy, XmCONSTANT); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopWidget, OneDHistNtupleTitleLabelW); ac++;
    XtSetArg(args[ac], XmNtopOffset, 2); ac++;
    XtSetArg(args[ac], XmNleftOffset, 3); ac++;
    OneDHistVariableListW = XmCreateScrolledList(ntupleForm, "hist1DList", args,ac);
    FreeStringTable(st1);
    XtManageChild(OneDHistVariableListW);
    FirstOneDHistogram = True;
    XtManageChild(OneDHistFormW);
    
    	    
}
Пример #8
0
MEM_HANDLE
_GetSoundBankData (uio_Stream *fp, DWORD length)
{
	int snd_ct, n;
	DWORD opos;
	char CurrentLine[1024], filename[1024];
#define MAX_FX 256
	TFB_SoundSample *sndfx[MAX_FX];
	STRING_TABLE Snd;

	(void) length;  // ignored
	opos = uio_ftell (fp);

	{
		char *s1, *s2;

		if (_cur_resfile_name == 0
			|| (((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0)
			&& (s2 = strrchr (_cur_resfile_name, '\\')) == 0))
			n = 0;
		else
		{
			if (s2 > s1)
				s1 = s2;
			n = s1 - _cur_resfile_name + 1;
			strncpy (filename, _cur_resfile_name, n);
		}
	}

	snd_ct = 0;
	while (uio_fgets (CurrentLine, sizeof (CurrentLine), fp) &&
			snd_ct < MAX_FX)
	{
		if (sscanf(CurrentLine, "%s", &filename[n]) == 1)
		{
			log_add (log_Info, "_GetSoundBankData(): loading %s", filename);

			sndfx[snd_ct] = (TFB_SoundSample *) HCalloc (sizeof (TFB_SoundSample));

			sndfx[snd_ct]->decoder = SoundDecoder_Load (contentDir,
					filename, 4096, 0, 0);
			if (!sndfx[snd_ct]->decoder)
			{
				log_add (log_Warning, "_GetSoundBankData(): couldn't load %s", filename);
				HFree (sndfx[snd_ct]);
			}
			else
			{
				uint32 decoded_bytes;

				decoded_bytes = SoundDecoder_DecodeAll (sndfx[snd_ct]->decoder);
				log_add (log_Info, "_GetSoundBankData(): decoded_bytes %d", decoded_bytes);
				
				sndfx[snd_ct]->num_buffers = 1;
				sndfx[snd_ct]->buffer = (audio_Object *) HMalloc (
						sizeof (audio_Object) * sndfx[snd_ct]->num_buffers);
				audio_GenBuffers (sndfx[snd_ct]->num_buffers, sndfx[snd_ct]->buffer);
				audio_BufferData (sndfx[snd_ct]->buffer[0], sndfx[snd_ct]->decoder->format,
					sndfx[snd_ct]->decoder->buffer, decoded_bytes,
					sndfx[snd_ct]->decoder->frequency);

				SoundDecoder_Free (sndfx[snd_ct]->decoder);
				sndfx[snd_ct]->decoder = NULL;
				
				++snd_ct;
			}
		}
		else
		{
			log_add (log_Warning, "_GetSoundBankData: Bad file!");
		}

		// pkunk insult fix 2002/11/12 (ftell shouldn't be needed for loop to terminate)
		/*if (uio_ftell (fp) - opos >= length)
			break;*/
	}

	Snd = 0;
	if (snd_ct && (Snd = AllocStringTable (
		sizeof (STRING_TABLE_DESC)
		+ (sizeof (DWORD) * snd_ct)
		+ (sizeof (sndfx[0]) * snd_ct)
		)))
	{
		STRING_TABLEPTR fxTab;

		LockStringTable (Snd, &fxTab);
		if (fxTab == 0)
		{
			while (snd_ct--)
			{
				if (sndfx[snd_ct]->decoder)
					SoundDecoder_Free (sndfx[snd_ct]->decoder);
				HFree (sndfx[snd_ct]);
			}

			FreeStringTable (Snd);
			Snd = 0;
		}
		else
		{
			DWORD *offs, StringOffs;

			fxTab->StringCount = snd_ct;
			fxTab->flags = 0;
			offs = fxTab->StringOffsets;
			StringOffs = sizeof (STRING_TABLE_DESC) + (sizeof (DWORD) * snd_ct);
			memcpy ((BYTE *)fxTab + StringOffs, sndfx, sizeof (sndfx[0]) * snd_ct);
			do
			{
				*offs++ = StringOffs;
				StringOffs += sizeof (sndfx[0]);
			} while (snd_ct--);
			UnlockStringTable (Snd);
		}
	}

	return ((MEM_HANDLE)Snd);
}
Пример #9
0
void *
_GetSoundBankData (uio_Stream *fp, DWORD length)
{
	int snd_ct, n;
	DWORD opos;
	char CurrentLine[1024], filename[1024];
#define MAX_FX 256
	TFB_SoundSample *sndfx[MAX_FX];
	STRING_TABLE Snd;

	(void) length;  // ignored
	opos = uio_ftell (fp);

	{
		char *s1, *s2;

		if (_cur_resfile_name == 0
			|| (((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0)
			&& (s2 = strrchr (_cur_resfile_name, '\\')) == 0))
			n = 0;
		else
		{
			if (s2 > s1)
				s1 = s2;
			n = s1 - _cur_resfile_name + 1;
			strncpy (filename, _cur_resfile_name, n);
		}
	}

	snd_ct = 0;
	while (uio_fgets (CurrentLine, sizeof (CurrentLine), fp) &&
			snd_ct < MAX_FX)
	{
		if (sscanf(CurrentLine, "%s", &filename[n]) == 1)
		{
			log_add (log_Info, "_GetSoundBankData(): loading %s", filename);

			sndfx[snd_ct] = (TFB_SoundSample *) HCalloc (sizeof (TFB_SoundSample));

			sndfx[snd_ct]->decoder = SoundDecoder_Load (contentDir,
					filename, 4096, 0, 0);
			if (!sndfx[snd_ct]->decoder)
			{
				log_add (log_Warning, "_GetSoundBankData(): couldn't load %s", filename);
				HFree (sndfx[snd_ct]);
			}
			else
			{
				uint32 decoded_bytes;

				decoded_bytes = SoundDecoder_DecodeAll (sndfx[snd_ct]->decoder);
				log_add (log_Info, "_GetSoundBankData(): decoded_bytes %d", decoded_bytes);
				
				sndfx[snd_ct]->num_buffers = 1;
				sndfx[snd_ct]->buffer = (audio_Object *) HMalloc (
						sizeof (audio_Object) * sndfx[snd_ct]->num_buffers);
				audio_GenBuffers (sndfx[snd_ct]->num_buffers, sndfx[snd_ct]->buffer);
				audio_BufferData (sndfx[snd_ct]->buffer[0], sndfx[snd_ct]->decoder->format,
					sndfx[snd_ct]->decoder->buffer, decoded_bytes,
					sndfx[snd_ct]->decoder->frequency);

				SoundDecoder_Free (sndfx[snd_ct]->decoder);
				sndfx[snd_ct]->decoder = NULL;
				
				++snd_ct;
			}
		}
		else
		{
			log_add (log_Warning, "_GetSoundBankData: Bad file!");
		}

		// pkunk insult fix 2002/11/12 (ftell shouldn't be needed for loop to terminate)
		/*if (uio_ftell (fp) - opos >= length)
			break;*/
	}

	Snd = NULL;
	if (snd_ct && (Snd = AllocStringTable (snd_ct, 0)))
	{
		STRING_TABLE fxTab = Snd;

		if (fxTab == 0)
		{
			while (snd_ct--)
			{
				if (sndfx[snd_ct]->decoder)
					SoundDecoder_Free (sndfx[snd_ct]->decoder);
				HFree (sndfx[snd_ct]);
			}

			FreeStringTable (Snd);
			Snd = 0;
		}
		else
		{
			STRING str;
			int i;

			str = fxTab->strings;
			for (i = 0; i < snd_ct; i++)
			{
				TFB_SoundSample **target = HMalloc (sizeof (sndfx[0]));
				*target = sndfx[i];
				str->data = (STRINGPTR)target;
				str->length = sizeof (sndfx[0]);
				str++;
			}
		}
	}

	return Snd;
}
Пример #10
0
DIRENTRY_REF
LoadDirEntryTable (uio_DirHandle *dirHandle, const char *path,
		const char *pattern, match_MatchType matchType, PCOUNT pnum_entries)
{
	uio_DirList *dirList;
	COUNT num_entries, length;
	COUNT i;
	COUNT slen;
	uio_DirHandle *dir;
	STRING_TABLE StringTable;
	STRING_TABLEPTR lpST;
	PSTR lpStr;
	PDWORD lpLastOffs;

	dir = uio_openDirRelative (dirHandle, path, 0);
	assert(dir != NULL);
	dirList = uio_getDirList (dir, "", pattern, matchType);
	assert(dirList != NULL);
	num_entries = 0;
	length = 0;

	// First, count the amount of space needed
	for (i = 0; i < dirList->numNames; i++)
	{
		struct stat sb;

		if (dirList->names[i][0] == '.')
		{
			dirList->names[i] = NULL;
			continue;
		}
		if (uio_stat (dir, dirList->names[i], &sb) == -1)
		{
			dirList->names[i] = NULL;
			continue;
		}
		if (!S_ISREG (sb.st_mode))
		{
			dirList->names[i] = NULL;
			continue;
		}
		length += strlen (dirList->names[i]) + 1;
		num_entries++;
	}
	uio_closeDir (dir);

	if (num_entries == 0) {
		uio_DirList_free(dirList);
		*pnum_entries = 0;
		return ((DIRENTRY_REF) 0);
	}

	slen = sizeof (STRING_TABLE_DESC)
			+ (num_entries * sizeof (DWORD));
	StringTable = AllocResourceData (slen + length, 0);
	LockStringTable (StringTable, &lpST);
	if (lpST == 0)
	{
		FreeStringTable (StringTable);
		uio_DirList_free(dirList);
		*pnum_entries = 0;
		return ((DIRENTRY_REF) 0);
	}
	lpST->StringCount = num_entries;
	lpLastOffs = &lpST->StringOffsets[0];
	*lpLastOffs = slen;
	lpStr = (PSTR)lpST + slen;

	for (i = 0; i < dirList->numNames; i++)
	{
		int size;
		if (dirList->names[i] == NULL)
			continue;
		size = strlen (dirList->names[i]) + 1;
		memcpy (lpStr, dirList->names[i], size);
		lpLastOffs[1] = lpLastOffs[0] + size;
		lpLastOffs++;
		lpStr += size;
	}
	
	uio_DirList_free(dirList);
	*pnum_entries = num_entries;
	UnlockStringTable (StringTable);
	return ((DIRENTRY_REF) StringTable);
}