X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=lwlib%2Flwlib-Xm.c;h=254691dc6a496b575a67578fa281eac2049f48f4;hp=87008b5017be3da866952e72214b775384999a51;hb=d81014e89b5102527e5b50aac62edeed2955671d;hpb=3e447015251ce6dcde843cbed10d9033d5538622 diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c index 87008b5..254691d 100644 --- a/lwlib/lwlib-Xm.c +++ b/lwlib/lwlib-Xm.c @@ -219,6 +219,10 @@ xm_update_label (widget_instance* instance, Widget widget, widget_value* val) if (val->value) { + /* #### Temporary fix. I though Motif was supposed to grok %_ + type things. */ + lw_remove_accelerator_spec (val->value); + #ifdef LWLIB_DIALOGS_MOTIF /* * Sigh. The main text of a label is the name field for menubar @@ -255,18 +259,18 @@ xm_update_label (widget_instance* instance, Widget widget, widget_value* val) { name_string = XmStringCreateLtoR (res_name, XmSTRING_DEFAULT_CHARSET); - + value_name = XtMalloc (strlen (val->value) + 2); *value_name = 0; strcat (value_name, " "); strcat (value_name, val->value); - + val_string = XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET); - + built_string = XmStringConcat (name_string, val_string); - + XtFree (value_name); } } @@ -297,6 +301,14 @@ xm_update_label (widget_instance* instance, Widget widget, widget_value* val) XmStringFree (val_string); } +static void +xm_safe_update_label (widget_instance* instance, Widget widget, widget_value* val) +{ + /* Don't clobber non-labels. */ + if (XtIsSubclass (widget, xmLabelWidgetClass)) + xm_update_label (instance, widget, val); +} + #endif /* defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) */ /* update of list */ @@ -332,6 +344,38 @@ xm_update_pushbutton (widget_instance* instance, Widget widget, XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance); } +#ifdef LWLIB_WIDGETS_MOTIF +static void +xm_update_progress (widget_instance* instance, Widget scale, + widget_value* val) +{ + Arg al[20]; + int ac = 0; + Dimension height = 0; + Dimension width = 0; + if (!val->call_data) + { + XtSetArg (al [ac], XmNeditable, False); ac++; + } + else + { + XtSetArg (al [ac], XmNeditable, val->enabled); ac++; + } + height = (Dimension)lw_get_value_arg (val, XtNheight); + width = (Dimension)lw_get_value_arg (val, XtNwidth); + if (height > 0) + { + XtSetArg (al [ac], XmNscaleHeight, height); ac++; + } + if (width > 0) + { + XtSetArg (al [ac], XmNscaleWidth, width); ac++; + } + + XtSetValues (scale, al, 1); +} +#endif /* LWLIB_WIDGETS_MOTIF */ + #ifdef LWLIB_MENUBARS_MOTIF static void @@ -506,7 +550,7 @@ make_menu_in_widget (widget_instance* instance, Widget widget, XtSetArg (al [ac], XmNsubMenuId, menu); ac++; button = XmCreateCascadeButton (widget, cur->name, al, ac); - xm_update_label (instance, button, cur); + xm_safe_update_label (instance, button, cur); XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback, (XtPointer)instance); @@ -527,7 +571,7 @@ make_menu_in_widget (widget_instance* instance, Widget widget, else button = XmCreatePushButtonGadget (widget, cur->name, al, ac); - xm_update_label (instance, button, cur); + xm_safe_update_label (instance, button, cur); /* don't add a callback to a simple label */ if (cur->type == TOGGLE_TYPE || cur->type == RADIO_TYPE) @@ -581,7 +625,8 @@ update_one_menu_entry (widget_instance* instance, Widget widget, /* update the menu button as a label. */ if (val->change >= VISIBLE_CHANGE) { - xm_update_label (instance, widget, val); + xm_safe_update_label (instance, widget, val); + if (XtClass (widget) == xmToggleButtonWidgetClass || XtClass (widget) == xmToggleButtonGadgetClass) { @@ -791,14 +836,11 @@ xm_update_one_widget (widget_instance* instance, Widget widget, /* Common to all widget types */ XtSetArg (al [ac], XmNsensitive, val->enabled); ac++; XtSetArg (al [ac], XmNuserData, val->call_data); ac++; - lw_add_value_args_to_args (val, al, &ac); - XtSetValues (widget, al, ac); #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF) /* Common to all label like widgets */ - if (XtIsSubclass (widget, xmLabelWidgetClass)) - xm_update_label (instance, widget, val); + xm_safe_update_label (instance, widget, val); #endif class = XtClass (widget); /* Class specific things */ @@ -856,6 +898,15 @@ xm_update_one_widget (widget_instance* instance, Widget widget, xm_update_scrollbar (instance, widget, val); } #endif +#ifdef LWLIB_WIDGETS_MOTIF + else if (class == xmScaleWidgetClass) + { + xm_update_progress (instance, widget, val); + } +#endif + /* Lastly update our global arg values. */ + if (val->args && val->args->nargs) + XtSetValues (widget, val->args->args, val->args->nargs); } /* getting the value back */ @@ -884,14 +935,14 @@ xm_update_one_value (widget_instance* instance, Widget widget, else if (class == xmTextWidgetClass) { if (val->value) - free (val->value); + XtFree (val->value); val->value = XmTextGetString (widget); val->edited = True; } else if (class == xmTextFieldWidgetClass) { if (val->value) - free (val->value); + XtFree (val->value); val->value = XmTextFieldGetString (widget); val->edited = True; } @@ -907,7 +958,7 @@ xm_update_one_value (widget_instance* instance, Widget widget, if (radiobox) { CompositeWidget radio = (CompositeWidget)widget; - int i; + unsigned int i; for (i = 0; i < radio->composite.num_children; i++) { int set = False; @@ -926,7 +977,7 @@ xm_update_one_value (widget_instance* instance, Widget widget, val->edited = True; } } - else if (class == xmListWidgetClass + else if (class == xmListWidgetClass #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1 || class == xmComboBoxWidgetClass #endif @@ -1139,7 +1190,7 @@ make_dialog (char* name, Widget parent, Boolean pop_up_p, n_children++; } - /* invisible seperator button */ + /* invisible separator button */ ac = 0; XtSetArg (al[ac], XmNmappedWhenManaged, FALSE); ac++; children [n_children] = XmCreateLabel (row, "separator_button", @@ -1255,10 +1306,11 @@ make_dialog (char* name, Widget parent, Boolean pop_up_p, XtSetArg(al[ac], XmNrightOffset, 13); ac++; value = XmCreateScrolledList (form, "list", al, ac); - /* this is the easiest way I found to have the dble click in the + /* this is the easiest way I found to have the double click in the list activate the default button */ XtAddCallback (value, XmNdefaultActionCallback, activate_button, button); } + /* else add nothing; it's a separator */ ac = 0; XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; @@ -1296,11 +1348,12 @@ make_dialog (char* name, Widget parent, Boolean pop_up_p, XtInstallAccelerators (value, button); XmProcessTraversal(value, XmTRAVERSE_CURRENT); } - else + else if (radio_box) { XtInstallAccelerators (form, button); XmProcessTraversal(value, XmTRAVERSE_CURRENT); } + /* else we don' need no STEENKIN' assellerators. */ #ifdef DND_KLUDGE XtFree ((char *) dnd_override); @@ -1644,16 +1697,17 @@ xm_create_progress (widget_instance *instance) { Arg al[20]; int ac = 0; + Dimension height = 0; + Dimension width = 0; Widget scale = 0; widget_value* val = instance->info->val; - if (!val->call_data) { - XtSetArg (al [ac], XmNsensitive, False); ac++; + XtSetArg (al [ac], XmNeditable, False); ac++; } else { - XtSetArg (al [ac], XmNsensitive, val->enabled); ac++; + XtSetArg (al [ac], XmNeditable, val->enabled); ac++; } XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; XtSetArg (al [ac], XmNuserData, val->call_data); ac++; @@ -1663,6 +1717,18 @@ xm_create_progress (widget_instance *instance) look ugly. I think this may be a LessTif bug but for now we just get rid of it. */ XtSetArg (al [ac], XmNhighlightThickness, (Dimension)0);ac++; + + height = (Dimension)lw_get_value_arg (val, XtNheight); + width = (Dimension)lw_get_value_arg (val, XtNwidth); + if (height > 0) + { + XtSetArg (al [ac], XmNscaleHeight, height); ac++; + } + if (width > 0) + { + XtSetArg (al [ac], XmNscaleWidth, width); ac++; + } + /* add any args the user supplied for creation time */ lw_add_value_args_to_args (val, al, &ac); @@ -1684,7 +1750,7 @@ xm_create_text_field (widget_instance *instance) Widget text = 0; widget_value* val = instance->info->val; - XtSetArg (al [ac], XmNsensitive, val->enabled && val->call_data); ac++; + XtSetArg (al [ac], XmNsensitive, val->enabled); ac++; XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; XtSetArg (al [ac], XmNuserData, val->call_data); ac++; XtSetArg (al [ac], XmNmappedWhenManaged, FALSE); ac++; @@ -1778,7 +1844,7 @@ xm_create_combo_box (widget_instance *instance) /* Table of functions to create widgets */ -widget_creation_entry +const widget_creation_entry xm_creation_table [] = { #ifdef LWLIB_MENUBARS_MOTIF