summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_mib/mibload.cpp
blob: c71bc031b67e483d7545b4149cde86e88daeab71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
/* $Id$ */
/* Copyright (c) 1994 The Geometry Center; University of Minnesota
   1300 South Second Street;  Minneapolis, MN  55454, USA;

This file is free software; you can redistribute it and/or modify it only
under the the terms of the GNU GENERAL PUBLIC LICENSE which should be
included along with thisw file.  This software may be obtained via anonymous
ftp from geom.umn.edu; email: software@geom.umn.edu. */

/* Author: Daeron Meyer */

#include <stdlib.h>
#include "mibload.h"
#include "mibwidgets.h"

mib_Widget	*mib_root_Widget;
Display		*dpy;
GC		 mib_gc;
static struct _mib_event_handle_funcs {
#ifdef __cplusplus
  void		(*mib_pick_mib_Widget)( Widget, XtPointer,
			XEvent *, Boolean * );
  void		(*mib_move_mib_Widget)( Widget, XtPointer,
			XEvent *, Boolean *);
  void		(*mib_unpick_mib_Widget)( Widget, XtPointer,
			XEvent *, Boolean * );
#else
  void		(*mib_pick_mib_Widget)(/* Widget, XtPointer,
			XButtonPressedEvent *, Boolean * */);
  void		(*mib_move_mib_Widget)(/* Widget, XtPointer,
			XPointerMovedEvent *, Boolean * */);
  void		(*mib_unpick_mib_Widget)(/* Widget, XtPointer,
			XButtonReleasedEvent *, Boolean * */);
#endif
} mib_events;

mib_widget_funcs mwfuncs[] =
{
  { NULL, NULL, NULL, NULL, NULL },
  { "TextBox", mib_create_TextBox, mib_delete_TextBox,
	mib_save_TextBox, mib_load_TextBox},
  { "Button", mib_create_Button, mib_delete_Button,
	mib_save_Button, mib_load_Button},
  { "Toggle", mib_create_Toggle, mib_delete_Toggle,
	mib_save_Toggle, mib_load_Toggle},
  { "RadioBox", mib_create_RadioBox, mib_delete_RadioBox,
	mib_save_RadioBox, mib_load_RadioBox},
  { "DrawingArea", mib_create_DrawingArea, mib_delete_DrawingArea,
	mib_save_DrawingArea, mib_load_DrawingArea},
  { "Label", mib_create_Label, mib_delete_Label,
	mib_save_Label, mib_load_Label},
  { "Frame", mib_create_Frame, mib_delete_Frame,
	mib_save_Frame, mib_load_Frame},
  { "ScrollBar", mib_create_ScrollBar, mib_delete_ScrollBar,
	mib_save_ScrollBar, mib_load_ScrollBar},
  { "TextBig", mib_create_TextBig, mib_delete_TextBig,
	mib_save_TextBig, mib_load_TextBig},
  { "List", mib_create_List, mib_delete_List,
	mib_save_List, mib_load_List},
  { "Scale", mib_create_Scale, mib_delete_Scale,
	mib_save_Scale, mib_load_Scale},
  { "Menu", mib_create_Menu, mib_delete_Menu,
	mib_save_Menu, mib_load_Menu},
  { NULL, NULL, NULL, NULL, NULL },
};

/*****************************************************************************/

void mib_add_mib_Widget(mib_Widget *thisw, mib_Widget *parent)
{
  mib_Widget *tmp;

  if (parent->child == NULL)
  {
    parent->child = thisw;
    thisw->prev = parent;
    thisw->parent = parent;
    thisw->sibling = NULL;
    thisw->child = NULL;
  }
  else
    {
      tmp = parent->child;
      while (tmp->sibling != NULL)
        tmp = tmp->sibling;
      tmp->sibling = thisw;
      thisw->prev = tmp;
      thisw->parent = parent;
      thisw->sibling = NULL;
      thisw->child = NULL;
    }
}

/*****************************************************************************/

void mib_add_backward(mib_Widget *thisw, mib_Widget *parent)
{
  mib_Widget *tmp;

  if (parent->child == NULL)
  {
    parent->child = thisw;
    thisw->prev = parent;
    thisw->parent = parent;
    thisw->sibling = NULL;
    thisw->child = NULL;
  }
  else
    {
      tmp = parent->child;
      parent->child = thisw;
      thisw->prev = parent;
      thisw->parent = parent;
      thisw->sibling = tmp;
      thisw->child = NULL;
      tmp->prev = thisw;
    }
}

/*****************************************************************************/

void mib_remove_mib_Widget(mib_Widget *thisw)
{
  int		 count;
  mib_Widget	*pnt;

  XtVaSetValues(mib_root_Widget->me, XmNresizePolicy, XmRESIZE_NONE, NULL);
  XtDestroyWidget(thisw->me);

  while (thisw->child != NULL)
    mib_remove_mib_Widget(thisw->child);

  if (thisw->parent == thisw)
  {
    mib_clear_myres(thisw);
    return;
  }

  if (thisw->prev == thisw->parent)
  {
    thisw->parent->child = thisw->sibling;
    if (thisw->sibling != NULL)
      thisw->sibling->prev = thisw->parent;
  }
  else
    {
      thisw->prev->sibling = thisw->sibling;
      if (thisw->sibling != NULL)
	thisw->sibling->prev = thisw->prev;
    }

  mib_clear_myres(thisw);
}

/*****************************************************************************/

void mib_clear_myres(mib_Widget *thisw)
{
  ACE_OS::free(thisw->mib_class);
  ACE_OS::free(thisw->name);

  if ((thisw->mib_class_num < 1) || (thisw->mib_class_num > MI_NUMCLASSES))
    return;

  mwfuncs[thisw->mib_class_num].mib_delete(thisw);
  ACE_OS::free(thisw);
}

/*****************************************************************************/

mib_Widget *mib_new_mib_Widget()
{
  mib_Widget *thisw;
  thisw = (mib_Widget *)ACE_OS::malloc(sizeof(mib_Widget));
  thisw->me = NULL;
  thisw->mib_class_num = MIB_NULL;
  thisw->mib_selected = 0;
  thisw->mib_resizing = 0;
  thisw->myres = NULL;
  thisw->parent = NULL;
  thisw->sibling = NULL;
  thisw->prev = NULL;
  thisw->child = NULL;
  thisw->width = 0;
  thisw->height = 0;
  thisw->topAttachment = 0;
  thisw->bottomAttachment = 0;
  thisw->leftAttachment = 0;
  thisw->rightAttachment = 0;
  thisw->topOffset = 0;
  thisw->bottomOffset = 0;
  thisw->leftOffset = 0;
  thisw->rightOffset = 0;

  return thisw;
}

/*****************************************************************************/

mib_Widget *mib_find_name(mib_Widget *temp, char *name)
{
  mib_Widget *child = temp->child;
  mib_Widget *ret = NULL;

  if (!strcmp(temp->name, name))
    return temp;

  if (child != NULL)
    if (ret = mib_find_name(child, name))
	return ret;

  child = temp->sibling;
  if (child != NULL)
    if (ret = mib_find_name(child, name))
	return ret;

  return NULL;
}

/*****************************************************************************/

Widget
BuildMenu(Widget parent, int menu_type, char *menu_title, char menu_mnemonic,
		 MenuItem *items)
{
    Widget menu, cascade, widget;
    int i;
    XmString str;

    if (menu_type == XmMENU_PULLDOWN || menu_type == XmMENU_OPTION)
        menu = XmCreatePulldownMenu(parent, "_pulldown", NULL, 0);
    else if (menu_type == XmMENU_POPUP)
        menu = XmCreatePopupMenu(parent, "_popup", NULL, 0);
    else {
        XtWarning("Invalid menu type passed to BuildMenu()");
        return NULL;
    }

    /* Pulldown menus require a cascade button to be made */
    if (menu_type == XmMENU_PULLDOWN) {
        str = XmStringCreateSimple(menu_title);
        cascade = XtVaCreateManagedWidget(menu_title,
            xmCascadeButtonGadgetClass, parent,
            XmNsubMenuId,   menu,
            XmNlabelString, str,
            XmNmnemonic,    menu_mnemonic,
            NULL);
        XmStringFree(str);
    } else if (menu_type == XmMENU_OPTION) {
        /* Option menus are a special case, but not hard to handle */
        Arg args[2];
        str = XmStringCreateSimple(menu_title);
        XtSetArg(args[0], XmNsubMenuId, menu);
        XtSetArg(args[1], XmNlabelString, str);
        /* This really isn't a cascade, but thisw is the widget handle
         * we're going to return at the end of the function.
         */
        cascade = XmCreateOptionMenu(parent, menu_title, args, 2);
        XmStringFree(str);
    }

    /* Now add the menu items */
    for (i = 0; items[i].label != NULL; i++) {
        /* If subitems exist, create the pull-right menu by calling thisw
         * function recursively.  Since the function returns a cascade
         * button, the widget returned is used..
         */
        if (items[i].subitems)
            if (menu_type == XmMENU_OPTION) {
            widget = XtVaCreateManagedWidget(items[i].label,
                *items[i].wclass, menu, NULL);
		items[i].subitems = (struct _menu_item *) widget;
	     /* daeron mod (tm) :-) ... we now use thisw to pass back each
		widget we create to the mibMenu functions so that it can
		be stored as part of the mibMenu structure */

             /* XtWarning("You can't have submenus from option menu items.");
                continue;*/
            } else
                widget = BuildMenu(menu, XmMENU_PULLDOWN,
                    items[i].label, items[i].mnemonic, items[i].subitems);
        else
	  {
            widget = XtVaCreateManagedWidget(items[i].label,
                *items[i].wclass, menu,
                NULL);
	    /* ditto here from above ... - Daeron mod (tm) */
	    items[i].subitems = (struct _menu_item *) widget;
	  }

        /* Whether the item is a real item or a cascade button with a
         * menu, it can still have a mnemonic.
         */
        if (items[i].mnemonic)
            XtVaSetValues(widget, XmNmnemonic, items[i].mnemonic, NULL);

        /* any item can have an accelerator, except cascade menus. But,
         * we don't worry about that; we know better in our declarations.
         */
        if (items[i].accelerator) {
            str = XmStringCreateSimple(items[i].accel_text);
            XtVaSetValues(widget,
                XmNaccelerator, items[i].accelerator,
                XmNacceleratorText, str,
                NULL);
            XmStringFree(str);
        }

        if (items[i].callback)
            XtAddCallback(widget,
                (items[i].wclass == &xmToggleButtonWidgetClass ||
                 items[i].wclass == &xmToggleButtonGadgetClass)?
                    XmNvalueChangedCallback : /* ToggleButton class */
                    XmNactivateCallback,      /* PushButton class */
                items[i].callback, items[i].callback_data);
    }

    /* for popup menus, just return the menu; pulldown menus, return
     * the cascade button; option menus, return the thing returned
     * from XmCreateOptionMenu().  This isn't a menu, or a cascade button!
     */
    return menu_type == XmMENU_POPUP? menu : cascade;
}

/*****************************************************************************/

mib_Widget *mib_load_interface(Widget parent, char *from, int file_type)
{
  mib_Buffer  thiswfile;
  mib_Widget *thisw;
  FILE	     *infile;
  char	     *instring;
  char	      ch;

  thiswfile.buf_type = file_type;

  dpy = XtDisplay(parent);

  if ((file_type == MI_FROMFILE) || (file_type == MI_EDITFROMFILE))
  {
    if (!(infile = fopen(from,"r")))
      return NULL;

    ch = '\0';
    while ((ch != '\n')&&(!feof(infile)))  /* throw away first line */
      ch = (char)fgetc(infile);

    thiswfile.buffer = (void *)infile;
    thiswfile.point = 0;

    if (!mib_load_Root(parent, &thisw, &thiswfile))
    {
      /* delete thisw */
      return NULL;
    }
    else
    {
      fclose(infile);
      return thisw;
    }
  }
  else
  if ((file_type == MI_FROMSTRING) || (file_type == MI_EDITFROMSTRING))
  {
    instring = from;
    if (instring == NULL)
      return NULL;

    thiswfile.buffer = (void *)instring;
    thiswfile.buflen = strlen(instring);
    thiswfile.point = 0;

    if (!mib_load_Root(parent, &thisw, &thiswfile))
    {
      /* delete thisw */
      return NULL;
    }
    else
      return thisw;
  }
  else
    return NULL;

}

/*****************************************************************************/

int mib_load_mib_class(mib_Widget **thisw, mib_Widget *parent, char *name,
		char *iname, mib_Buffer *fin )
{
  int namelen, editstate, count, set;

  if ((fin->buf_type == MI_EDITFROMFILE) ||
	(fin->buf_type == MI_EDITFROMSTRING))
    editstate = WEDIT;
  else
    editstate = WEMPTY;

  namelen = strlen(name);
  if (namelen < 2)
    return 0;

  name[namelen-1] = '\0';
  name[0] = ' ';

  count = 1;

  while (mwfuncs[count].name)
  {
    if (!strcmp(&(name[1]), mwfuncs[count].name))
    {
      *thisw = mwfuncs[count].mib_create(parent, iname, NULL, 0, 0, 0, 0,
		editstate);
      return 1;
    }
    count++;
  }

  (*thisw)->parent = (*thisw);
  return 1;
}

/*****************************************************************************/

mib_Widget *mib_load_public(mib_Widget *root, mib_Widget *thisw, mib_Buffer *fin)
{
  int	got_line, done;
  char	res[MI_MAXSTRLEN];
  char	val[MI_MAXSTRLEN];
  char	valcp[MI_MAXSTRLEN];
  Arg	args[20];
  int	mynum, n;
 
  got_line = 1;
  done = 0;

  /* thisw loop reads basic info about Widget */
  while (got_line && (!done))
  {
    got_line = mib_read_line(fin, res, val);
    if (!strcmp(res,"Ref"))
      sscanf(val, "%d", &mynum);
    else
    if (!strcmp(res,"Widget"))
    {
      strcpy(valcp,val);
      done = 1;
    }
  }

  done = 0;

  while (got_line && (!done))
  {
    got_line = mib_read_line(fin, res, val);
    if (!strcmp(res, "Children"))
      n = 0;
    else
    if (!strcmp(res, "Parent")) /* don't support complete widget tree yet */
      n = 0;
    else
    if (!strcmp(res,"Public-"))
      n = 0;
    else
    if (!strcmp(res,"Name"))
    {
      val[strlen(val)-1] = '\0';
      mib_load_mib_class(&thisw, root, valcp, &(val[1]), fin);
      thisw->name = (char *)ACE_OS::malloc(strlen(val));
      sprintf(thisw->name,"%s",&(val[1]));
      thisw->mib_mynum = mynum;
      done = 1;
    }
    else
       return 0;
  }

  if (!got_line)
    return NULL;

  done = 0;

  /* second loop reads public info */
  while (got_line && (!done))
  {
    got_line = mib_read_line(fin, res, val);
    if (!strcmp(res,"Xmwidth"))
      sscanf(val,"%d",&(thisw->width));
    else
    if (!strcmp(res,"Xmheight"))
      sscanf(val,"%d",&(thisw->height));
    else
    if (!strcmp(res,"XmtopAttachment"))
      sscanf(val,"%d",&(thisw->topAttachment));
    else
    if (!strcmp(res,"XmbottomAttachment"))
      sscanf(val,"%d",&(thisw->bottomAttachment));
    else
    if (!strcmp(res,"XmleftAttachment"))
      sscanf(val,"%d",&(thisw->leftAttachment));
    else
    if (!strcmp(res,"XmrightAttachment"))
      sscanf(val,"%d",&(thisw->rightAttachment));
    else
    if (!strcmp(res,"XmtopOffset"))
      sscanf(val,"%d",&(thisw->topOffset));
    else
    if (!strcmp(res,"XmbottomOffset"))
      sscanf(val,"%d",&(thisw->bottomOffset));
    else
    if (!strcmp(res,"XmleftOffset"))
      sscanf(val,"%d",&(thisw->leftOffset));
    else
    if (!strcmp(res,"XmrightOffset"))
      sscanf(val,"%d",&(thisw->rightOffset));
    else
    if (!strcmp(res,"Private-"))
      done = 1;
  }

  n = 0;
  if ((fin->buf_type == MI_EDITFROMFILE) ||
	(fin->buf_type == MI_EDITFROMSTRING))
  {
    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg (args[n], XmNleftOffset, thisw->leftOffset); n++;
    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg (args[n], XmNtopOffset, thisw->topOffset); n++;
    if (thisw == root)
    {
      XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
      XtSetArg (args[n], XmNrightOffset, thisw->rightOffset); n++;
      XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
      XtSetArg (args[n], XmNbottomOffset, thisw->bottomOffset); n++;
    }
  }
  else
  {
    if (thisw->leftAttachment)
    {
      XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
      XtSetArg (args[n], XmNleftOffset, thisw->leftOffset);n++;
    }
    if (thisw->topAttachment)
    {
      XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
      XtSetArg (args[n], XmNtopOffset, thisw->topOffset);n++;
    }
    if (thisw->bottomAttachment)
    {
      XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
      XtSetArg (args[n], XmNbottomOffset, thisw->bottomOffset);n++;
    }
    if (thisw->rightAttachment)
    {
      XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
      XtSetArg (args[n], XmNrightOffset, thisw->rightOffset);n++;
    }
  }

  XtSetArg (args[n], XmNwidth, thisw->width); n++;
  XtSetArg (args[n], XmNheight, thisw->height); n++;

  XtSetValues(thisw->me, args, n);

  return thisw;
}

/*****************************************************************************/

int mib_load_private(mib_Widget *thisw, mib_Buffer *fin)
{

  if (thisw->mib_class_num == MIB_NULL)
    return 1;

  if ((thisw->mib_class_num < 1) || (thisw->mib_class_num > MI_NUMCLASSES))
    return 0;

  mwfuncs[thisw->mib_class_num].mib_load(thisw, fin);

  return 1;
}

/*****************************************************************************/

int mib_load_Root(Widget parent, mib_Widget **thisw, mib_Buffer *fin)
{

  char		res[MI_MAXSTRLEN];
  char		val[MI_MAXSTRLEN];
  char		name[MI_MAXSTRLEN];
  int		num_widgets, count, n, got_line;
  Arg		args[20];
  XGCValues     gcvals;
  XtGCMask      val_mask;
  mib_Widget   *temp;

  got_line = mib_read_line(fin, res, val);
  if (!strcmp(res,"TotalWidgets"))
    sscanf(val, "%d", &num_widgets);
  else
    return 0;

  (*thisw) = mib_new_mib_Widget();
  (*thisw)->mib_class = (char*)ACE_OS::malloc(9);
  sprintf((*thisw)->mib_class,"RootForm");

/*  (*thisw)->me = XmCreateForm(parent, "MainForm", args, 0); */
  
  (*thisw)->me = parent;

  if (!mib_load_public((*thisw), (*thisw), fin))
    return 0;

  /* we don't expect any private resources for the root widget */

  got_line = mib_read_line(fin, res, val);
  if (strcmp(res,"EndWidget."))
    return 0;

/*   XtManageChild((*thisw)->me);
*/
  XtVaSetValues((*thisw)->me, XmNresizePolicy, XmRESIZE_NONE, NULL);

  count = num_widgets - 1;
  while (count > 0)
  {

    if (!(temp = mib_load_public((*thisw), temp, fin)))
    {
      /* delete temp */
      return 0;
    }

    if (!mib_load_private(temp,fin))
    {
      /* delete temp */
      return 0;
    }
    count--;

  }

  mib_reset_size((*thisw));

  XtVaSetValues((*thisw)->me, XmNresizePolicy, XmRESIZE_ANY, NULL);

  val_mask = (long)0;
  mib_gc = XtGetGC((*thisw)->me, val_mask, &gcvals);

  return 1;
}

/*****************************************************************************/

int mib_read_line(mib_Buffer *bufin, char *res, char *val)
{
  FILE *fin;
  char *strin;
  char  ch;
  int   count, mark;
  char  inbuf[MI_MAXSTRLEN];

  if ((bufin->buf_type == MI_FROMFILE) || (bufin->buf_type == MI_EDITFROMFILE))
  {
    fin = (FILE *)bufin->buffer;
    ch = '\0';
    count = 0;
    mark = 0;
    while ((ch != '\n')&&(!feof(fin))&&(count<MI_MAXSTRLEN))
    {
      ch = (char)fgetc(fin);
      if ((mark == 0) && (ch == ':'))
	mark = count;
      if ((ch != '\\')&&(ch != '\n'))
      {
	inbuf[count] = ch;
	count++;
      }
    }
    if (feof(fin))
      return 0;
    inbuf[count] = '\0';
    if (count > 0)
    {
      if (inbuf[count-1] == 'n')
        inbuf[count-1] = '\0';
    }
    else
      return 0;

  }
  else
  if ((bufin->buf_type == MI_FROMSTRING) ||
	(bufin->buf_type == MI_EDITFROMSTRING))
  {
    strin = (char *)bufin->buffer;
    count = bufin->point;
    mark = 0;

    if (count >= bufin->buflen)
      return 0;

    while ((strin[count] != '\n') && (count < bufin->buflen))
    {
      if ((mark == 0) && (strin[count] == ':'))
	mark = count;
      count++;
    }

    strin[count] = '\0';
    if (count >= bufin->buflen)
      return 0;
    sprintf(inbuf,"%s",&(strin[bufin->point]));
    strin[count] = '\n';
    if (mark != 0)
      mark -= bufin->point;
    bufin->point = count+1;
  }
  else
    return 0;

  if (mark == 0)
  {
    sprintf(res,"%s",inbuf);
    sprintf(val,"\0");
  }
  else
  {
    inbuf[mark] = '\0';
    sprintf(res,"%s",inbuf);
    inbuf[mark] = ' ';
    if ((int)(strlen(inbuf)-mark) > 1)
      sprintf(val,"%s",&(inbuf[mark+2]));
    else
      sprintf(val,"\0");
  }

  return 1;
}

/*****************************************************************************/

void mib_reset_size(mib_Widget *temp)
{
  Arg	args[5];
  int	n;

  mib_Widget *child = temp->child;

  if (temp->mib_class_num != MIB_NULL)
  {
    n = 0;
    XtSetArg (args[n], XmNwidth, temp->width); n++;
    XtSetArg (args[n], XmNheight, temp->height); n++;

    XtSetValues(temp->me, args, n);
  }

  if (child != NULL)
    mib_reset_size(child);

  child = temp->sibling;
  if (child != NULL)
    mib_reset_size(child);
}

/*****************************************************************************/

#ifdef __cplusplus
void mib_set_eventhandlers(void a(Widget, XtPointer,
			XEvent *, Boolean * ),
                           void b( Widget, XtPointer,
			XEvent *, Boolean* ),
                           void c(Widget, XtPointer,
			XEvent *, Boolean *)
                           )
#else
void mib_set_eventhandlers(void * a, void * b, void * c)
#endif
{
  mib_events.mib_pick_mib_Widget =  a;
  mib_events.mib_move_mib_Widget =  b;
  mib_events.mib_unpick_mib_Widget = c;
}

/*****************************************************************************/

void mib_apply_eventhandlers(Widget thisw, mib_Widget *actual)
{
  XtAddEventHandler(thisw, ButtonPressMask, FALSE,
	mib_events.mib_pick_mib_Widget, (XtPointer)actual);
  XtAddEventHandler(thisw, Button3MotionMask, FALSE,
	mib_events.mib_move_mib_Widget, (XtPointer)actual);
  XtAddEventHandler(thisw, ButtonReleaseMask, FALSE,
	mib_events.mib_unpick_mib_Widget, (XtPointer)actual);

}

/*****************************************************************************/