Exemplo n.º 1
0
void
XFE_AttachmentMenu::update()
{
    Widget *kids;
    int nkids;

    XtVaGetValues (m_submenu, XmNchildren, &kids, XmNnumChildren, &nkids, 0);

    XtUnrealizeWidget(m_submenu);

    if (nkids)
    {
        kids = &(kids[m_firstslot]);
        nkids -= m_firstslot;

        XtUnmanageChildren (kids, nkids);
        fe_DestroyWidgetTree(kids, nkids);
    }

    add_attachment_menu_items(m_submenu);

    XtRealizeWidget(m_submenu);

    XtRemoveCallback(m_cascade, XmNcascadingCallback, update_cb, this);
}
Exemplo n.º 2
0
void
WComposite :: UnmanageChildren (void) const
{
	CompositeWidget cw = (CompositeWidget)widget;

	XtUnmanageChildren(cw->composite.children, cw->composite.num_children);
}
Exemplo n.º 3
0
static void 
UpdateImList(
    I18nEnv *env,
    char *hostname)
{
    Cardinal i;
    XtArgVal n;
    Widget *im_tog = NULL;
    int ret = NoError;

    /* Clean first the existing list */
    
    /* destroy toggle in radio box is any */
    XtVaGetValues(i18n.inputMethodRC, XmNchildren, &im_tog,
		  XmNnumChildren, &n, NULL);
    if (n) {
	XtUnmanageChildren(im_tog, n);
	for (i=0; i<n; i++) XtDestroyWidget(im_tog[i]);
	im_tog = NULL;
    }    

    /* Empty what we used to have here */
    if (env->ims_sel->ims_list_size) {
	XtFree((char *) env->ims_sel->ims_list);
	env->ims_sel->ims_list = NULL;
	env->ims_sel->ims_list_size = 0 ;
    }

    /* then update the env struct with new ims name and status */
    ret = _DtI18nGetImList(env, hostname);
    if (ret != NoError) {
	_DtTurnOffHourGlass(i18n.inputMethodTB);
	_DtI18nErrorDialog(ret);
    }
}
Exemplo n.º 4
0
void NxmColorbarReset ( int type )
/************************************************************************
 * NxmColorBarReset                                                     *
 *                                                                      *
 * This function resets the display of the color bar. Different title   *
 * string will be displayed based on the input parameter.               *
 *                                                                      *
 * void NxmColorBarReset( type )                                        *
 *                                                                      *
 * Input parameters:                                                    *
 *  type            int   0 --- title string = "Active Colors:"         *
 *                        1 --- title string = "Colors:"                *
 *                                                                      *
 * Output parameters:                                                   *
 *                      NULL                                            *
 *                                                                      *
 * Return parameters:                                                   *
 *                      NULL                                            *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * C. Lin/EAI       	05/94                                           *
 * E. Safford/GSC	01/99	clean up				*
 * S. Law/GSC		07/00	added XmStringFree calls		*
 ***********************************************************************/
{
    XmString	xmstr;
/*---------------------------------------------------------------------*/

    if (type == 0) {
	xmstr = XmStringCreateLocalized("Active Colors:");
        XtVaSetValues( _activeColLabel, 
		       XmNlabelString, xmstr,
		       NULL);
	XmStringFree (xmstr);

	if ( NXMcolrCells != NULL ) {
	    XtUnmanageChildren( NXMcolrCells, NXMtotalEditColor );
	    XtManageChild( NXMcolrCells[0]);
	}
    }
    else {
	xmstr = XmStringCreateLocalized("Colors:");
        XtVaSetValues( _activeColLabel, 
		       XmNlabelString, xmstr,
		       NULL);
	XmStringFree (xmstr);

	if ( NXMcolrCells != NULL ) {
	    XtManageChildren( NXMcolrCells, NXMtotalEditColor );
	}
    }
}
Exemplo n.º 5
0
void AttachArea::DisplayAttachmentsInRow(unsigned int X)
{
    int i;
    int managecount, unmanagecount;

    Attachment **list = getList();
    WidgetList manageIconList, unmanageIconList;

    if (getIconCount())
    {
        manageIconList = (WidgetList) XtMalloc(sizeof(Widget)*getIconCount());
        unmanageIconList = (WidgetList) XtMalloc(sizeof(Widget)*getIconCount());
     
        managecount = unmanagecount = 0;
        for(i=0;i<getIconCount();i++) {
 	    if(!list[i]->isDeleted()) {
 	        if(list[i]->getRow() == X) {
		    if(!list[i]->isManaged()) {
		        manageIconList[managecount] = list[i]->baseWidget();
		        managecount++;
		    } 
	        }
	        else { // if deleted
		    if(list[i]->isManaged()) {
		        unmanageIconList[unmanagecount] = list[i]->baseWidget();
		        unmanagecount++;
		    }
	        }
	    }
        }

        XtUnmanageChildren(unmanageIconList, unmanagecount);
        XtManageChildren(manageIconList, managecount);


        XtFree((char *)manageIconList);
        XtFree((char *)unmanageIconList);
    }

    this->attachment_summary(_iconCount - _deleteCount, _deleteCount);
}
Exemplo n.º 6
0
void AttachArea::deleteAttachments( )
{
    int i;
    WidgetList deleteList;
    int count;

    Attachment **list = getList();
 
     // First, unmanaged all the attachment at once so there is no
     // flickering when we delete them

     deleteList = (WidgetList)XtMalloc(sizeof(Widget) * getIconCount());

     for(i=0;i<getIconCount();i++)
 	deleteList[i] = list[i]->baseWidget();
     XtUnmanageChildren(deleteList, i);

     delete deleteList;
     XtFree((char *)deleteList);
 
    // Delete each attachment in the list
    count = getIconCount();
    for(i=count-1;i>=0;i--) {
 	delete list[i];
 	decIconCount();
    }

     _iconCount = 0;
     _iconSelectedCount = 0;
     _deleteCount = 0;
     CalcLastRow();
     AdjustCurrentRow();
     SetScrollBarSize(getLastRow()+1);
     activateDeactivate();
     _attachmentList=NULL;
     _attachmentsSize = 0;
     _selectedAttachmentsSize = 0;
}
Exemplo n.º 7
0
/* virtual */ void
XFE_BookmarkMenu::reallyUpdateRoot()
{
 	WidgetList		children;
 	Cardinal		numChildren;
 	BM_Entry *		root = getMenuFolder();

	// Ignore the root header (ie, "Joe's Bookmarks")
	if (root && BM_IsHeader(root))
	{
		root = BM_GetChildren(root);
	}

 	XfeChildrenGet(_subMenu,&children,&numChildren);	
	
	//  XtUnrealizeWidget(m_subMenu);

 	// Get rid of the previous items we created
 	if (children && numChildren)
	{
 		children += _firstSlot;

 		numChildren -= _firstSlot;

 		if (children && numChildren)
		{
 			XtUnmanageChildren(children,numChildren);
      
 			fe_DestroyWidgetTree(children,numChildren);
		}
	}

 	// Create the entries if any
 	if (root)
 	{
 		createItemTree(_subMenu,root);
 	}
}
Exemplo n.º 8
0
/*
 * Clean up anything left around that won't be removed on
 * switching to another view, such as the hot buttons for
 * navigation to day view.
 */
extern void
cleanup_after_weekview(Calendar *c)
{
    int n;
    Week *w = (Week *)c->view->week_info;

    invalidate_cache(c);
    set_message(c->message_text, "");

    XtUnmanageChildren(w->hot_button, 7);

    XmToggleButtonGadgetSetState(c->week_scope, False, False);

    /*
     * Deallocating everything causes all this view's memory to be
     * freed (at least all we have allocated in this application)
     * at the expense of rebuilding the view next time it is used.
     * Commenting it out improves usability and avoids any risk
     * of memory leakage from Xt and Motif.
     */
    /*
    	deallocator(c);
    */
}
Exemplo n.º 9
0
void
main(int argc, char **argv)
{
    Widget              Container5, *IconGad;   
    int			i, num_obj;
    Cardinal		n;
    Arg			args[MAX_ARGS];
    char		test_char;
    int                 test_num;
    char		ContainerName[NAME_LEN + 1];

    ContainerName[0] = '\0';
    test_char = '\0';
    test_num = 0;

    CommonTestInit(argc, argv);

    num_obj = 10;

    if (UserData != NULL) {
	
	if (strcmp(UserData, "a") == 0) {
	    num_obj = 4;
	    test_num = 1;
	}

	if (strcmp(UserData, "b") == 0) {
	    num_obj = 5;
	    test_num = 2;
	}
	
	if (strcmp(UserData, "c") == 0) {
	    num_obj = 9;
	    test_num = 3;
	}
	
	if (strcmp(UserData, "d") == 0) {
	    num_obj = 20;
	    test_num = 4;
	}
	
	if (strcmp(UserData, "e") == 0) {
	    num_obj = 4;
	    test_num = 5;
	}
	
	test_char = *UserData;
	
	free(UserData);
	
    }
    sprintf(ContainerName, "Container5%c", test_char);

    n = 0;

    Container5 = XmCreateContainer(Shell1, ContainerName, args, n);
    XtManageChild(Container5);

    XtRealizeWidget(Shell1);

    CommonPause();

    /* Add a bunch of Icon Gadgets */

    IconGad = (Widget*) XtMalloc(NUM_OBJ*sizeof(Widget));

    for (i = 0; i < num_obj; i++) {
	char        IconName[20] ;
	XmString   icon_name;

	n = 0 ;
	sprintf(IconName, "IconGad%d", i);
	icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); 
	XtSetArg(args[n], XmNlabelString, icon_name); n++;
	IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n);
        XtManageChild(IconGad[i]);
	XmStringFree(icon_name);
    }


    CommonPause();

    if (test_num == 0 || test_num == 1) {
    
	/* Set the Spatial Style to None */

	n = 0;
	XtSetArg(args[n], XmNspatialStyle, XmNONE); n++;
	XtSetValues(Container5, args, n);

	CommonPause();

	/* Unmanage all the children - Change the ResizeModel - and Remanage */

	XtUnmanageChildren(IconGad, num_obj);
    
	n = 0;
	XtSetArg(args[n], XmNspatialStyle, XmGRID); n++;
	XtSetArg(args[n], XmNspatialResizeModel, XmGROW_BALANCED); n++;
	XtSetValues(Container5, args, n);

	XtManageChildren(IconGad, num_obj);

	CommonPause();
    }

    if (test_num == 2) {
	int new_obj;

	/* Test the different ResizeModel - Start by adding children with
	   grow_balanced, then add with grow_major and then grow_minor. */

	new_obj = 4;
	for (i = num_obj; i < (num_obj+new_obj); i++) {
	    char        IconName[20] ;
	    XmString   icon_name;

	    n = 0 ;
	    sprintf(IconName, "IconGad%d", i);
	    icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL);
	    XtSetArg(args[n], XmNlabelString, icon_name); n++;
	    IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n);
	    XmStringFree(icon_name);
	}

	XtManageChildren(&IconGad[num_obj], new_obj);
	num_obj = num_obj + new_obj;
	
	CommonPause();

	new_obj = 5;
	n = 0;
	XtSetArg(args[n], XmNspatialResizeModel, XmGROW_MAJOR); n++;
	XtSetValues(Container5, args, n);

	for (i = num_obj; i < (num_obj+new_obj); i++) {
	    char        IconName[20] ;
	    XmString   icon_name;

	    n = 0 ;
	    sprintf(IconName, "IconGad%d", i);
	    icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL);
	    XtSetArg(args[n], XmNlabelString, icon_name); n++;
	    IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n);
	    XmStringFree(icon_name);
	}

	XtManageChildren(&IconGad[num_obj], new_obj);
	num_obj = num_obj + new_obj;
	
	CommonPause();

	n = 0;
	XtSetArg(args[n], XmNspatialResizeModel, XmGROW_MINOR); n++;
	XtSetValues(Container5, args, n);

	for (i = num_obj; i < (num_obj+new_obj); i++) {
	    char        IconName[20] ;
	    XmString   icon_name;

	    n = 0 ;
	    sprintf(IconName, "IconGad%d", i);
	    icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL);
	    XtSetArg(args[n], XmNlabelString, icon_name); n++;
	    IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n);
	    XmStringFree(icon_name);
	}

	XtManageChildren(&IconGad[num_obj], new_obj);
	num_obj = num_obj + new_obj;
	
    }

    if (test_num == 3) {
	char        IconName[20];
	XmString   icon_name;

	/* Change the spatialStyle to GRID */

	n = 0;
	XtSetArg(args[n], XmNspatialStyle, XmGRID); n++;
	XtSetValues(Container5, args, n);

	CommonPause();

	/* Test the spatialIncludeModel 
	   Add some children and check where they go */

	i = num_obj;
	n = 0 ;
	sprintf(IconName, "IconGad%d", i);
	icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL);
	XtSetArg(args[n], XmNlabelString, icon_name); n++;
	IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n);
	XmStringFree(icon_name);
	XtManageChild(IconGad[i]);

	CommonPause();

	/* set the spatialIncludeModel to FIRST_FIT */

	n = 0;
	XtSetArg(args[n], XmNspatialIncludeModel, XmFIRST_FIT); n++;
	XtSetValues(Container5, args, n);

	i = num_obj + 1;
	n = 0 ;
	sprintf(IconName, "IconGad%d", i);
	icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL);
	XtSetArg(args[n], XmNlabelString, icon_name); n++;
	IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n);
	XmStringFree(icon_name);
	XtManageChild(IconGad[i]);
	
    }

    CommonPause();

    XtAppMainLoop(app_context);

}
Exemplo n.º 10
0
void ui_create_status_bar(Widget pane, int width, Widget below, video_canvas_t *c, int app_shell)
{
    Widget notification_porthole;
    Widget speed_label, statustext_label;
    Widget notification_box;
    Widget drive_status[NUM_DRIVES];
    Widget drive_track_label[NUM_DRIVES], drive_led[NUM_DRIVES];
    Widget drive_led1[NUM_DRIVES], drive_led2[NUM_DRIVES];
    Widget tape_counter_label[NUM_TAPES];
    Widget tape_button_status[NUM_TAPES];
    Widget pal_ctrl_widget;
    char *button_title;
    int has_tape, notification_width;
    int i;

#define DD      2               /* default distance */
#define BW      1               /* border width */

    Dimension height;
    Dimension led_width = 14, led_height = 5;
    Dimension led_dist = 6;
    Widget fromvert;

    speed_label = XtVaCreateManagedWidget("speedStatus",
                                            labelWidgetClass, pane,
                                            XtNlabel, "",
                                            XtNwidth, width / 3,
                                            XtNborderWidth, 0,
                                            XtNtip, _("Emulation Speed Status"),
#if DEBUG_LAYOUT
                                            XtNbackground, "green",
#endif
                                            /* Constraints: */
                                            XtNfromVert, below,
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNjustify, XtJustifyLeft,
                                            NULL);

    fromvert = speed_label;

    XtVaGetValues(speed_label, XtNheight, &height, NULL);

    if (machine_class != VICE_MACHINE_VSID) {
        Widget drivefromvert, drivefromhoriz;

        Arg args[] = {
            { XtNlabel, (XtArgVal)_("CRT Controls") },
            { XtNwidth, width / 3 - DD },
            { XtNheight, height },
            { XtNfromVert, (XtArgVal)fromvert },
            { XtNvertDistance, DD + 2*BW }, /* DD + missing borders of speed_label */
            { XtNtop, XawChainBottom },
            { XtNbottom, XawChainBottom },
        };
        pal_ctrl_widget = build_pal_ctrl_widget(c, pane,
                                    args, util_arraysize(args));

        fromvert = pal_ctrl_widget;
        drivefromvert = below;
        drivefromhoriz = speed_label;

        for (i = 0; i < NUM_DRIVES; i++) {
            char *name;
            Widget form;
            int status_width = (width / 3) - DD;
            int d = i ^ 1;

            name = lib_msprintf("driveStatus%d", d + 1);
            form =
            drive_status[d] = XtVaCreateManagedWidget(name,
                                formWidgetClass, pane,
                                XtNmappedWhenManaged, False,
                                XtNwidth, status_width,
                                XtNheight, height,
                                XtNborderWidth, 0,
                                /* Constraints: */
#if DEBUG_LAYOUT
                                XtNbackground, "yellow",
#endif
                                XtNdefaultDistance, 0,
                                XtNfromVert, drivefromvert,
                                XtNfromHoriz, drivefromhoriz,
                                XtNhorizDistance, DD,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawRubber,
                                XtNright, XawRubber,
                                NULL);
            lib_free(name);

            /* Position for the next Drive GUI element */
            if (i & 1) {
                drivefromhoriz = speed_label;
                drivefromvert = form;
            } else {
                drivefromhoriz = form;
            }

            name = lib_msprintf("driveTrack%d", d + 1);
            drive_track_label[d] = XtVaCreateManagedWidget(name,
                                commandWidgetClass, form,
                                XtNlabel, "",
                                XtNwidth, status_width - led_width - 2 * led_dist - DD,
                                /* Constraints: */
                                XtNhorizDistance, 0,
                                XtNvertDistance, 0,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainLeft,
                                XtNright, XawChainRight,
                                XtNjustify, XtJustifyRight,
                                NULL);
            lib_free(name);

            /* single LED */

            name = lib_msprintf("driveLed%d", d + 1);
            drive_led[d] = XtVaCreateManagedWidget(name,
                                xfwfcanvasWidgetClass, form,
                                XtNmappedWhenManaged, False,
                                XtNwidth, led_width,
                                XtNheight, led_height,
                                /* Constraints: */
                                XtNfromHoriz, drive_track_label[d],
                                XtNhorizDistance, led_dist,
                                XtNvertDistance, (height-led_height)/2 + BW,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainRight,
                                XtNright, XawChainRight,
                                XtNborderWidth, 0,
                                NULL);
            lib_free(name);

            /* double LEDs */

            name = lib_msprintf("driveLedA%d", d + 1);
            drive_led1[d] = XtVaCreateManagedWidget(name,
                                xfwfcanvasWidgetClass, form,
                                XtNmappedWhenManaged, False,
                                XtNwidth, led_width / 2 - BW,
                                XtNheight, led_height,
                                XtNborderWidth, BW,
                                /* Constraints: */
                                XtNfromHoriz, drive_track_label[d],
                                XtNhorizDistance, led_dist,
                                XtNvertDistance, (height-led_height)/2 + BW,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainRight,
                                XtNright, XawChainRight,
                                NULL);
            lib_free(name);

            name = lib_msprintf("driveLedB%d", d + 1);
            drive_led2[d] = XtVaCreateManagedWidget(name,
                                xfwfcanvasWidgetClass, form,
                                XtNmappedWhenManaged, False,
                                XtNwidth, led_width / 2 - BW,
                                XtNheight, led_height,
                                XtNborderWidth, BW,
                                /* Constraints: */
                                XtNfromHoriz, drive_led1[d],
                                XtNhorizDistance, led_dist,
                                XtNvertDistance, (height-led_height)/2 + BW,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainRight,
                                XtNright, XawChainRight,
                                NULL);
            lib_free(name);

            app_shells[app_shell].drive_widgets[d].track_label = drive_track_label[d];
            app_shells[app_shell].drive_widgets[d].driveled = drive_led[d];
            app_shells[app_shell].drive_widgets[d].driveled1 = drive_led1[d];
            app_shells[app_shell].drive_widgets[d].driveled2 = drive_led2[d];
            app_shells[app_shell].drive_widgets[d].status = drive_status[d];
            strcpy(&(last_attached_images[d][0]), "");
        }
    }

    /*
     * Pack the notification elements, which are sometimes turned on but
     * mostly turned off, into a horizontal Box, and manage/unmanage
     * them as needed. This will automatically re-layout them inside
     * the box.
     * Wrap the box in a Porthole widget to control the size of the
     * space that is used (clipping the stuff that doesn't fit).
     * Too bad there isn't just a single widget doing this. That would
     * make it easier to try to shrink the children when everything
     * doesn't fit, or automatically switch between a one-line and a
     * two-line statusbar, or something like that.
     */
    has_tape = machine_class != VICE_MACHINE_VSID &&
               machine_class != VICE_MACHINE_C64DTV &&
               machine_class != VICE_MACHINE_SCPU64;

    if (has_tape) {
        notification_width = 2 * width / 3 - DD; /* spans 2 columns */
    } else {
        notification_width = width;
    }

    notification_porthole = XtVaCreateManagedWidget("notificationPorthole",
                                            portholeWidgetClass, pane,
                                            XtNwidth, notification_width,
                                            XtNheight, height + 2 * BW,
                                            XtNborderWidth, 0,
                                            XtNorientation, XtorientHorizontal,
#if DEBUG_LAYOUT
                                            XtNbackground, "red1",
#endif
                                            /* Constraints: */
                                            XtNfromVert, drive_status[2],
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNleft, XawChainLeft,
                                            XtNright, XawRubber,
                                            NULL);

    notification_box = XtVaCreateManagedWidget("notificationBox",
                                         boxWidgetClass, notification_porthole,
                                         XtNwidth, notification_width,
                                         XtNorientation, XtorientHorizontal,
                                         XtNborderWidth, 0,
                                         XtNvSpace, 0,
                                         XtNhSpace, DD,
#if DEBUG_LAYOUT
                                         XtNbackground, "pink1",
#endif
                                         NULL);

    statustext_label = XtVaCreateManagedWidget("statustext",
                                            labelWidgetClass, notification_box,
                                            XtNjustify, XtJustifyLeft,
                                            XtNlabel, "",
                                            XtNborderWidth, 0,
                                            NULL);

    button_title = util_concat(_("recording"), "...", NULL);
    rec_button = XtVaCreateManagedWidget("recButton",
                                          commandWidgetClass, notification_box,
                                          XtNtip, _("click to stop recording"),
                                          XtNjustify, XtJustifyLeft,
                                          XtNlabel, button_title,
                                          NULL);
    lib_free(button_title);

    XtAddCallback(rec_button, XtNcallback, rec_button_callback, NULL);

    button_title = util_concat(_("event recording"), "...", NULL);
    event_recording_button = XtVaCreateManagedWidget("eventRecButton",
                                        commandWidgetClass, notification_box,
                                        XtNtip, _("click to stop recording"),
                                        XtNjustify, XtJustifyLeft,
                                        XtNlabel, button_title,
                                        NULL);
    lib_free(button_title);
    XtAddCallback(event_recording_button, XtNcallback, event_recording_button_callback, NULL);

    button_title = util_concat(_("event playback"), "...", NULL);
    event_playback_button = XtVaCreateManagedWidget("eventPlayButton",
                                        commandWidgetClass, notification_box,
                                        XtNtip, _("click to stop playback"),
                                        XtNjustify, XtJustifyLeft,
                                        XtNlabel, button_title,
                                        NULL);
    lib_free(button_title);
    XtAddCallback(event_playback_button, XtNcallback, event_playback_button_callback, NULL);

    {
        Widget list[3];
        list[0] = rec_button;
        list[1] = event_recording_button;
        list[2] = event_playback_button;

#if !DEBUG_LAYOUT
        XtUnmanageChildren(list, util_arraysize(list));
#endif /* DEBUG_LAYOUT */
    }

    /* End of the notification_porthole */
    /* Start of TAPE #1 */

    if (has_tape) {
        Dimension tape_btn_d = 4;
        Dimension tape_btn_w = 24;

        for (i = 0; i < NUM_TAPES; i++) {
            char *name = lib_msprintf("tapeCounter%d", i + 1);
            tape_counter_label[i] = XtVaCreateManagedWidget(name,
                                            commandWidgetClass, pane,
                                            XtNwidth, width / 3 - DD - tape_btn_d - tape_btn_w - 4 * BW - DD, /* 4 borderwidths for 2 widgets */
                                            XtNjustify, XtJustifyRight,
                                            XtNlabel, "Tape #1",
                                            /* Constraints: */
                                            XtNfromVert, drive_status[3],
                                            XtNfromHoriz, drive_status[3],
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNright, XawChainRight,
                                            NULL);
            lib_free(name);

            name = lib_msprintf("tapeButtons%d", i + 1);
            tape_button_status[i] = XtVaCreateManagedWidget(name,
                                            simpleWidgetClass, pane,
                                            XtNwidth, tape_btn_w,
                                            XtNheight, height,
                                            XtNjustify, XtJustifyLeft,
                                            /* Constraints: */
                                            XtNhorizDistance, tape_btn_d,
                                            XtNfromVert, drive_status[3],
                                            XtNfromHoriz, tape_counter_label[i],
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNleft, XawChainRight,
                                            XtNright, XawChainRight,
                                            NULL);
            lib_free(name);

            app_shells[app_shell].tape_widgets[i].counter_value = -1;
            app_shells[app_shell].tape_widgets[i].counter_label = tape_counter_label[i];
            app_shells[app_shell].tape_widgets[i].button_status = tape_button_status[i];

            build_tape_status_widget(&app_shells[app_shell].tape_widgets[i], pane, tape_btn_w, height);
        }
    }

    app_shells[app_shell].speed_label = speed_label;
    app_shells[app_shell].statustext_label = statustext_label;
}
Exemplo n.º 11
0
void XtUnmanageChild(
    Widget child)
{
    XtUnmanageChildren(&child, (Cardinal)1);
} /* XtUnmanageChild */
Exemplo n.º 12
0
static void restore_state_from_file(
Widget	topl,
FILE	*fp)
{
    char		buf[512];
    String		t_name = XtName( topl );
    Boolean		resize_topl=False;

    /* read and set resources */
    while( fgets( buf, 512, fp ) != NULL ){

	char		w_name[128], r_name[64];
	Widget		widget;
	XtResourceList	rsc_list;
	Cardinal	num_rsc;
	int		i;

	/* check for empty string or comment line */
	if( strlen(buf) == 0 || buf[0] == '!' )
	    continue;

	/* extract widget name, resource name and value */
	if( sscanf(buf, " %[^,:,\n]: %[^,\n]", w_name, buf) < 2 )
	    continue;
	if( (int) strlen(w_name) < 1 )
	    continue;
	for(i=(int)strlen(w_name)-1; i > 0 && w_name[i] != '.'
	    && w_name[i] != '*'; i--){}
	w_name[i] = '\0';
	strcpy( &r_name[0], &w_name[i+1] );

	/* get the widget - check for topl widget name */
	switch( w_name[0] ){
	case '\0':
	    widget = topl;
	    break;
	case '.':
	case '*':
	    if( strcmp(&(w_name[1]), t_name) == 0 )
		widget = topl;
	    else if( strncmp(&(w_name[1]), t_name, strlen(t_name)) == 0 ){
		String str = (String) &(w_name[strlen(t_name)+1]);
		if( (widget = XtNameToWidget(topl, str)) == NULL )
		    continue;
	    }
	    else if( (widget = XtNameToWidget(topl, w_name)) == NULL )
		continue;
	    break;
	default:
	    if( strcmp(&w_name[0], t_name) == 0 )
		widget = topl;
	    else if( strncmp(&w_name[0], t_name, strlen(t_name)) == 0 ){
		String str = (String) &(w_name[strlen(t_name)]);
		if( (widget = XtNameToWidget(topl, str)) == NULL )
		    continue;
	    }
	    else if( (widget = XtNameToWidget(topl, w_name)) == NULL )
		continue;
	    break;
	}

	/* convert and set the value */
	XtGetResourceList( XtClass(widget), &rsc_list, &num_rsc );
	for(i=0; i < num_rsc; i++){
	    if( strcmp( r_name, rsc_list[i].resource_name ) == 0 ){
		XrmValue	from, to;

		from.size = (int) strlen( buf );
		from.addr = (caddr_t) buf;

		to.addr = NULL;

		/* some string resources are not copied, eg geometry,
		   therefore allocate space for each string. This is
		   probably a small memory leak */
		if( strcmp(rsc_list[i].resource_type, XtRString) == 0 ){
		    String	str = (String) malloc(strlen(buf) + 4);
		    strcpy(str, buf);
		    XtVaSetValues( widget, r_name, str, NULL );
		}
		else if( XtConvertAndStore( widget, XtRString, &from,
					   rsc_list[i].resource_type, &to) ){

		    /* check for resize of top-level widget */
		    if( widget == topl &&
		       (!strcmp(r_name, XmNheight) ||
			!strcmp(r_name, XmNwidth)) )
		    {
			resize_topl = True;
		    }

		    /* set the resource value */
		    switch( rsc_list[i].resource_size ){
		    case 1:
			XtVaSetValues( widget, r_name,
				      *((unsigned char *) to.addr), NULL );
			break;
		    case 2:
			XtVaSetValues( widget, r_name,
				      *((unsigned short *) to.addr), NULL );
			break;
		    case 4:
			XtVaSetValues( widget, r_name,
				      *((unsigned int *) to.addr), NULL );
			break;
		    }
		}
		break;
	    }
	}
	XtFree( (char *)rsc_list );
    }

    /* check top-level */
    if( resize_topl == True ){
	WidgetList	children;
	Cardinal	numChildren;
	XtVaGetValues( topl, XmNchildren, &children,
		      XmNnumChildren, &numChildren, NULL);
	XtUnmanageChildren(children, numChildren);
	XtManageChildren(children, numChildren);
    }
    return;
}