Пример #1
0
static XmNavigability
WidgetNavigable(
        Widget wid)
{   
  if(    _XmShellIsExclusive( wid)    )
    {
      /* Preserve 1.0 behavior.  (Why?  Don't ask me!)
       */
      return XmNOT_NAVIGABLE ;
    }
  if(    XtIsSensitive(wid)
     &&  ((XmPrimitiveWidget) wid)->primitive.traversal_on    )
    {   
      XmNavigationType nav_type = ((XmPrimitiveWidget) wid)
	                                          ->primitive.navigation_type ;
      if(    (nav_type == XmSTICKY_TAB_GROUP)
	 ||  (nav_type == XmEXCLUSIVE_TAB_GROUP)
	 ||  (    (nav_type == XmTAB_GROUP)
	      &&  !_XmShellIsExclusive( wid))    )
	{
	  return XmTAB_NAVIGABLE ;
	}
    }
  return XmNOT_NAVIGABLE ;
}
static Bool
ChangeSensitive(Widget w)
{
    CommandWidget cbw = (CommandWidget)w;

    if (XtIsRealized(w)) {
	if (XtIsSensitive(w)) {
	    if (w->core.border_pixmap != XtUnspecifiedPixmap)
		XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
				       w->core.border_pixmap);
	    else
		XSetWindowBorder(XtDisplay(w), XtWindow(w),
				 w->core.border_pixel);
	}
	else {
	    if (cbw->simple.insensitive_border == None)
		cbw->simple.insensitive_border =
		    XmuCreateStippledPixmap(XtScreen(w),
					    w->core.border_pixel,
					    cbw->command.set ?
						cbw->label.foreground :
						w->core.background_pixel,
					    w->core.depth);
	    XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
				   cbw->simple.insensitive_border);
	}
    }

    return (False);
}
Пример #3
0
Файл: Simple.c Проект: aosm/X11
static Bool
ChangeSensitive(Widget w)
{
    if (XtIsRealized(w)) {
	if (XtIsSensitive(w))
	    if (w->core.border_pixmap != XtUnspecifiedPixmap)
	    XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
				    w->core.border_pixmap);
	    else
		XSetWindowBorder(XtDisplay(w), XtWindow(w),
				 w->core.border_pixel);
	else {
	    if (((SimpleWidget)w)->simple.insensitive_border == None)
		((SimpleWidget)w)->simple.insensitive_border =
		    XmuCreateStippledPixmap(XtScreen(w),
					    w->core.border_pixel, 
					    w->core.background_pixel,
					    w->core.depth);
	    XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w),
				   ((SimpleWidget)w)->simple.insensitive_border);
	}
    }

    return (False);
}
Пример #4
0
void MotifUI::DumpWidget(Widget w, boolean verbose, int level)
{
   int i;

   for (i = 0; i < level; i++)
      printf("   ");
   printf("%s : %s", XrmQuarkToString(w->core.xrm_name),
	  w->core.widget_class->core_class.class_name);
   if (verbose)
    {
      int n = (level * 3) + strlen(XrmQuarkToString(w->core.xrm_name)) +
	      strlen(w->core.widget_class->core_class.class_name) + 3;
      for ( ; n < G_width; n++)
         printf(" ");
      if (XtIsManaged(w))
	 printf(" Managed  ");
      else
	 printf(" Unmanaged");
      if (XtIsSensitive(w))
	 printf(" Sensitive  ");
      else
	 printf(" Insensitive");
      if (XtIsRealized(w))
	 printf(" Realized  ");
      else
	 printf(" Unrealized");
      if (w->core.visible)
	 printf("  Visible\n");
      else
	 printf("  Invisible\n");
    }
   else
      printf("\n");
}
Пример #5
0
Файл: CWnd.C Проект: dhaley/dcp
BOOL CWnd::IsWindowEnabled(void)
{
    if (_xd_rootwidget == NULL)
	return FALSE;

    return XtIsSensitive(_xd_rootwidget);
}
Пример #6
0
static void
Callback(Widget W)
{
    Widget w;

    w = XtNameToWidget(XtParent(W), "*BubbleButton1");
    XtSetSensitive(w, !XtIsSensitive(w));
}
Пример #7
0
/*ARGSUSED*/
static Boolean 
SetValues(
        Widget cw,
        Widget rw,
        Widget nw,
        ArgList args,		/* unused */
        Cardinal *num_args)	/* unused */
{
  XmArrowButtonWidget current = (XmArrowButtonWidget) cw;
  XmArrowButtonWidget new_w = (XmArrowButtonWidget) nw;
  
  Boolean returnFlag = FALSE;
  
  /*  Check the data put into the new widget.  */
  
  if (!XmRepTypeValidValue(XmRID_ARROW_DIRECTION, 
			   new_w->arrowbutton.direction, (Widget) new_w))
    {
      new_w->arrowbutton.direction = current->arrowbutton.direction;
    }
  
  
  /*  See if the GC's need to be regenerated and widget redrawn.  */
  if (new_w->core.background_pixel != current->core.background_pixel ||
      new_w->primitive.foreground != current->primitive.foreground)
    {
      returnFlag = TRUE;
      XtReleaseGC ((Widget) new_w, new_w->arrowbutton.arrow_GC);
      XtReleaseGC ((Widget) new_w, new_w->arrowbutton.insensitive_GC);
      GetArrowGC (new_w);
    }
  
  if (new_w->arrowbutton.direction != current->arrowbutton.direction ||
      XtIsSensitive(nw) != XtIsSensitive(cw) ||
      new_w->primitive.highlight_thickness !=
      current->primitive.highlight_thickness ||
      new_w->primitive.shadow_thickness != current->primitive.shadow_thickness)
    {
      returnFlag = TRUE;
    }
  
  return (returnFlag);
}
Пример #8
0
static void 
Redisplay(
        Widget wid,
        XEvent *event,
        Region region )
{
  XmArrowButtonWidget aw = (XmArrowButtonWidget) wid;
  int iwidth, iheight;
  XtExposeProc expose;
  
  iwidth = (int) aw->core.width - 2 * aw->primitive.highlight_thickness;
  iheight = (int) aw->core.height - 2 * aw->primitive.highlight_thickness;
  
  /*  Draw the arrow  */
  if ((iwidth > 0) && (iheight > 0))
    {
      if (aw->primitive.shadow_thickness > 0)
	XmeDrawShadows(XtDisplay (aw), XtWindow (aw),
		       aw->primitive.top_shadow_GC,
		       aw->primitive.bottom_shadow_GC,
		       aw->primitive.highlight_thickness,
		       aw->primitive.highlight_thickness,
		       aw->core.width - 2 * aw->primitive.highlight_thickness,
		       aw->core.height - 2 * aw->primitive.highlight_thickness,
		       aw->primitive.shadow_thickness,
		       XmSHADOW_OUT);
      
      if (aw->arrowbutton.selected && XtIsSensitive(wid))
	DrawArrow(aw, aw->primitive.bottom_shadow_GC,
		  aw->primitive.top_shadow_GC, aw->arrowbutton.arrow_GC);
      else
	DrawArrow(aw, aw->primitive.top_shadow_GC,
		  aw->primitive.bottom_shadow_GC,
		  (XtIsSensitive(wid) ?
		   aw->arrowbutton.arrow_GC : aw->arrowbutton.insensitive_GC));
    }
  
  /* Envelop our superclass expose method */
  _XmProcessLock();
  expose = xmPrimitiveClassRec.core_class.expose;
  _XmProcessUnlock(); 
  (*(expose)) ((Widget) aw, event, region);
}
Пример #9
0
Файл: List.c Проект: aosm/X11
void
XawListHighlight(Widget w, int item)
{
    ListWidget lw = (ListWidget)w;
    
    if (XtIsSensitive(w)) {
	lw->list.highlight = item;
	if (lw->list.is_highlighted != NO_HIGHLIGHT)
	PaintItemName(w, lw->list.is_highlighted);
	PaintItemName(w, item);
    }
}
Пример #10
0
    static void _grabbedLabelGadgetExpose(Widget _w, XEvent *_event, 
					  Region _region)
    {
	GC insensitiveGC;

	XmLabelGadget label = (XmLabelGadget)_w;

	unsigned char label_type = XmSTRING;
	XtVaGetValues(_w, XmNlabelType, &label_type, XtPointer(0));

	if (XtIsSensitive(_w) || label_type != XmSTRING)
	    (*oldLabelGadgetExposeProc)(_w, _event, _region);
	else
	{
#if defined(LesstifVersion)
	    // LessTif invokes resize() when exposing the widget,
	    // creating a new insensitive GC.  Inhibit this.
	    XtWidgetProc oldResizeProc = XtClass(_w)->core_class.resize;
	    XtClass(_w)->core_class.resize = noResize;
	    oldResizeProc(_w);
#endif

	    insensitiveGC = LABEL(label).insensitive_GC;

	    LABEL(label).TextRect.x += 1;
	    LABEL(label).TextRect.y += 1;
	    if (LABEL(label)._acc_text != 0)
	    {
		LABEL(label).acc_TextRect.x += 1;
		LABEL(label).acc_TextRect.y += 1;
	    }
	    LABEL(label).insensitive_GC = _gadgetParentTopShadowGC(label);
	    (*oldLabelGadgetExposeProc)(_w, _event, _region);
	    XtReleaseGC(_w, LABEL(label).insensitive_GC);

	    LABEL(label).TextRect.x -= 1;
	    LABEL(label).TextRect.y -= 1;
	    if (LABEL(label)._acc_text != 0)
	    {
		LABEL(label).acc_TextRect.x -= 1;
		LABEL(label).acc_TextRect.y -= 1;
	    }
	    LABEL(label).insensitive_GC = _gadgetParentBottomShadowGC(label);
	    (*oldLabelGadgetExposeProc)(_w, _event, _region);
	    XtReleaseGC(_w, LABEL(label).insensitive_GC);

	    LABEL(label).insensitive_GC = insensitiveGC;

#if defined(LesstifVersion)
	    XtClass(_w)->core_class.resize = oldResizeProc;
#endif
	}
    }
Пример #11
0
/*ARGSUSED*/
    static void
draw_pixmap(XmEnhancedButtonWidget eb, XEvent *event, Region region)
{
    Pixmap	pix;
    GC		gc = eb->label.normal_GC;
    int		depth;
    Cardinal	width;
    Cardinal	height;
    Cardinal	w;
    Cardinal	h;
    int		x;
    int		y;

    if (!XtIsSensitive((Widget) eb))
	pix = eb->enhancedbutton.insensitive_pixmap;
    else
    {
	if (eb->primitive.highlighted && !eb->pushbutton.armed)
	    pix = eb->enhancedbutton.highlight_pixmap;
	else if (eb->pushbutton.armed)
	    pix = eb->enhancedbutton.armed_pixmap;
	else
	    pix = eb->enhancedbutton.normal_pixmap;
    }

    if (pix == None || !eb->enhancedbutton.pixmap_data)
	return;

    depth = eb->enhancedbutton.pixmap_depth;
    w = eb->enhancedbutton.pixmap_width;
    h = eb->enhancedbutton.pixmap_height;

    gc = eb->label.normal_GC;
    x = eb->primitive.highlight_thickness
	+ eb->primitive.shadow_thickness
	+ eb->label.margin_width;
    y = eb->primitive.highlight_thickness
	+ eb->primitive.shadow_thickness
	+ eb->label.margin_height;
    width = eb->core.width - 2 * x;
    if (w < width)
	width = w;
    height = eb->core.height - 2 * y;
    if (h < height)
	height = h;
    if (depth == eb->core.depth)
	XCopyArea(XtDisplay(eb), pix, XtWindow(eb), gc, 0, 0,
		width, height, x, y);
    else if (depth == 1)
	XCopyPlane(XtDisplay(eb), pix, XtWindow(eb), gc, 0, 0,
		width, height, x, y, (unsigned long)1);
}
Пример #12
0
/******************************************************************************
 *
 *  SelectGC:
 *     Called by DrawVisual. 
 *
 *****************************************************************************/
static GC 
SelectGC (
        Widget w
         )
{
 ExmSimpleWidget sw = (ExmSimpleWidget)w;
 GC drawGC;

 /* Select between the normal (sensitive) GC and the insensitive GC. */ 
   drawGC = XtIsSensitive(w)  ? sw->simple.normal_gc 
                              : sw->simple.insensitive_gc;
   return (drawGC);
}
Пример #13
0
static char* get_active(Ihandle *n)
{
   int value = 0;
   Widget w[6];
 
   if (iupmotGetWidgetHandles(n, w) == 0) return NULL;
 
   if (type(n) == FRAME_)
   {
      if (w[4]) value = XtIsSensitive (w[4]);
      else
      {
        char *act = iupGetEnv( n, IUP_ACTIVE );
        if (!act || !iupStrEqual(act, IUP_NO)) value = 1;
      }
   }
   else
   {
      if (w[0]) value = XtIsSensitive (w[0]);
   }

   return value ? IUP_YES : IUP_NO;
}
Пример #14
0
/*ARGSUSED*/
void
NextCallback(Widget w, XtPointer user_data, XtPointer call_data)
{
    XF86SetupInfo *info = (XF86SetupInfo*)user_data;
    int idx = info->lists[info->cur_list].cur_function + 1;

    if (idx < info->lists[info->cur_list].num_functions) {
	info->lists[info->cur_list].cur_function = idx;
	if (idx + 1 == info->lists[info->cur_list].num_functions)
	    XtSetSensitive(next, False);
	if (!XtIsSensitive(back))
	    XtSetSensitive(back, True);
	(info->lists[info->cur_list].functions[idx])(info);
    }
}
Пример #15
0
/*ARGSUSED*/
void
BackCallback(Widget w, XtPointer user_data, XtPointer call_data)
{
    XF86SetupInfo *info = (XF86SetupInfo*)user_data;
    int idx = info->lists[info->cur_list].cur_function - 1;

    if (idx >= 0 && info->lists[info->cur_list].num_functions > 0) {
	info->lists[info->cur_list].cur_function = idx;
	if (idx - 1 == -1)
	    XtSetSensitive(back, False);
	if (!XtIsSensitive(next))
	    XtSetSensitive(next, True);
	(info->lists[info->cur_list].functions[idx])(info);
    }
}
Пример #16
0
static void 
Leave(
        Widget wid,
        XEvent *event,
        String *params,
        Cardinal *num_params )
{
  XmArrowButtonWidget aw = (XmArrowButtonWidget) wid;

  _XmPrimitiveLeave (wid, event, params, num_params);
  
  if (aw->arrowbutton.selected && XtIsSensitive(wid))
    DrawArrow(aw, aw->primitive.top_shadow_GC,
	      aw->primitive.bottom_shadow_GC, NULL);
}
Пример #17
0
Файл: CEdit.C Проект: dhaley/dcp
BOOL CEdit::xd_enable_window(BOOL bEnable)
{
    // Enable or disable a window
    //  Return value:
    //  0 if the widget has not been created (no call to create() yet).
    //  0 if the window was previously enabled
    //  non-zero if the window was previously disabled.

    if (_xd_textwidget == NULL)
	return FALSE ;

    BOOL wasdisabled =! XtIsSensitive(_xd_textwidget);

    XtSetSensitive(_xd_textwidget, bEnable);

    return wasdisabled ;
}
Пример #18
0
/****************************************************************
 ...
*****************************************************************/
static void select_random_race(void)
{
  /* try to find a free nation */
  /* FIXME: this code should be done another way. -ev */
  while (1) {
    unsigned int race_toggle_index = fc_rand(nation_count());

    if (!is_nation_playable(nation_by_number(race_toggle_index))
	|| !nation_by_number(race_toggle_index)->is_available
	|| nation_by_number(race_toggle_index)->player) {
      continue;
    }
    if (XtIsSensitive(races_toggles[race_toggle_index])) {
      x_simulate_button_click(races_toggles[race_toggle_index]);
      break;
    }
  }
}
Пример #19
0
/*******************************************************************
*
* Function: contract_data_changed()
*
*******************************************************************/
int contract_data_changed()
{
CONTRACTS_DATA_TYPE current_data_record;

/* check for View screen (as opposed to Add screen) */
   if(!XtIsSensitive(av_con_save_btn))
      return(False);

   memset (&current_data_record, 0, sizeof(current_data_record));
   get_contracts_data_from_screen(&current_data_record);

   if(memcmp(&current_data_record, &contracts_old_data,
                                         sizeof(current_data_record)) == 0)
      return(False);
   else
      return(True);

} /* end of contract_data_changed */
Пример #20
0
static XmNavigability
WidgetNavigable(
        Widget wid)
{   
  if(    XtIsSensitive(wid)
     &&  ((XmGadget) wid)->gadget.traversal_on    )
    {   
      XmNavigationType nav_type = ((XmGadget) wid)->gadget.navigation_type ;

      if(    (nav_type == XmSTICKY_TAB_GROUP)
	 ||  (nav_type == XmEXCLUSIVE_TAB_GROUP)
	 ||  (    (nav_type == XmTAB_GROUP)
	      &&  !_XmShellIsExclusive( wid))    )
	{
	  return XmTAB_NAVIGABLE ;
	}
      return XmCONTROL_NAVIGABLE ;
    }
  return XmNOT_NAVIGABLE ;
}
Пример #21
0
int iupdrvIsActive(Ihandle* ih)
{
  return XtIsSensitive(ih->handle);
}
Пример #22
0
Файл: Simple.c Проект: aosm/X11
/*ARGSUSED*/
static Boolean
XawSimpleSetValues(Widget current, Widget request, Widget cnew,
		   ArgList args, Cardinal *num_args)
{
    SimpleWidget s_old = (SimpleWidget)current;
    SimpleWidget s_new = (SimpleWidget)cnew;
    Bool new_cursor = False;

    /* this disables user changes after creation */
    s_new->simple.international = s_old->simple.international;

    if (XtIsSensitive(current) != XtIsSensitive(cnew))
	(*((SimpleWidgetClass)XtClass(cnew))->simple_class.change_sensitive)
	   (cnew);

    if (s_old->simple.cursor != s_new->simple.cursor)
	new_cursor = True;
	
    /*
     * We are not handling the string cursor_name correctly here
     */

    if (s_old->simple.pointer_fg != s_new->simple.pointer_fg ||
	s_old->simple.pointer_bg != s_new->simple.pointer_bg ||
	s_old->simple.cursor_name != s_new->simple.cursor_name) {
	ConvertCursor(cnew);
	new_cursor = True;
    }

    if (new_cursor && XtIsRealized(cnew)) {
	if (s_new->simple.cursor != None)
	    XDefineCursor(XtDisplay(cnew), XtWindow(cnew), s_new->simple.cursor);
	else
	    XUndefineCursor(XtDisplay(cnew), XtWindow(cnew));
      }

#ifndef OLDXAW
    if (s_old->core.background_pixmap != s_new->core.background_pixmap) {
	XawPixmap *opix, *npix;

	opix = XawPixmapFromXPixmap(s_old->core.background_pixmap,
				    XtScreen(s_old), s_old->core.colormap,
				    s_old->core.depth);
	npix = XawPixmapFromXPixmap(s_new->core.background_pixmap,
				    XtScreen(s_new), s_new->core.colormap,
				    s_new->core.depth);
	if ((npix && npix->mask) || (opix && opix->mask))
	    XawReshapeWidget(cnew, npix);
    }

    if (s_old->simple.tip != s_new->simple.tip) {
	if (s_old->simple.tip)
	    XtFree((XtPointer)s_old->simple.tip);
	if (s_new->simple.tip)
	    s_new->simple.tip = XtNewString(s_new->simple.tip);
    }

    if (s_old->simple.tip && !s_new->simple.tip)
	XawTipDisable(cnew);
    else if (!s_old->simple.tip && s_new->simple.tip)
	XawTipEnable(cnew);

    if (s_old->simple.display_list != s_new->simple.display_list)
	return (True);
#endif /* OLDXAW */

    return (False);
}
Пример #23
0
/* ARGSUSED */
static void
XawSmeBSBRedisplay(Widget w, XEvent *event, Region region)
{
    GC gc;
    SmeBSBObject entry = (SmeBSBObject)w;
    int	font_ascent, font_descent, y_loc;
    int	fontset_ascent, fontset_descent;
    XFontSetExtents *ext = XExtentsOfFontSet(entry->sme_bsb.fontset);

    font_ascent = font_descent = fontset_ascent = fontset_descent = 0;
    entry->sme_bsb.set_values_area_cleared = False;

    if (entry->sme.international == True) {
	fontset_ascent = XawAbs(ext->max_ink_extent.y);
	fontset_descent = ext->max_ink_extent.height - fontset_ascent;
    }
    else {
	font_ascent = entry->sme_bsb.font->max_bounds.ascent;
	font_descent = entry->sme_bsb.font->max_bounds.descent;
    }
    y_loc = XtY(entry);

    if (XtIsSensitive(w) && XtIsSensitive(XtParent(w))) {
	if (w == XawSimpleMenuGetActiveEntry(XtParent(w))) {
	    XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), 
			   entry->sme_bsb.norm_gc, XtX(w), y_loc,
			   XtWidth(entry), XtHeight(entry));
	    gc = entry->sme_bsb.rev_gc;
	}
	else
	    gc = entry->sme_bsb.norm_gc;
    }
    else
	gc = entry->sme_bsb.norm_gray_gc;
    
    if (entry->sme_bsb.label != NULL) {
	int x_loc = entry->sme_bsb.left_margin;
	int len = strlen(entry->sme_bsb.label);
	char *label = entry->sme_bsb.label;
	 int width, t_width;

	switch(entry->sme_bsb.justify) {
	    case XtJustifyCenter:
		if (entry->sme.international == True) {
		    t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,
						len);
		    width = XtWidth(entry) - (entry->sme_bsb.left_margin +
					      entry->sme_bsb.right_margin);
		}
		else {
		    t_width = XTextWidth(entry->sme_bsb.font, label, len);
		    width = XtWidth(entry) - (entry->sme_bsb.left_margin +
					      entry->sme_bsb.right_margin);
		}
		x_loc += (width - t_width) >> 1;
		break;
	    case XtJustifyRight:
		if (entry->sme.international == True) {
		    t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,
						len);
		    x_loc = XtWidth(entry) - (entry->sme_bsb.right_margin +
					      t_width);
		}
		else {
		    t_width = XTextWidth(entry->sme_bsb.font, label, len);
		    x_loc = XtWidth(entry) - (entry->sme_bsb.right_margin +
					      t_width);
		}
		break;
	    case XtJustifyLeft:
		/*FALLTHROUGH*/
	    default:
		break;
	}

	/* this will center the text in the gadget top-to-bottom */
	if (entry->sme.international == True) {
	    y_loc += ((XtHeight(entry) -
		      (fontset_ascent + fontset_descent)) >> 1) +
		       fontset_ascent;

	    XmbDrawString(XtDisplayOfObject(w), XtWindowOfObject(w),
		          entry->sme_bsb.fontset, gc,
			  XtX(w) + x_loc, y_loc, label, len);
	}
Пример #24
0
Файл: List.c Проект: aosm/X11
static void
PaintItemName(Widget w, int item)
{
    char *str;
    GC gc;
    int x, y, str_y;
    ListWidget lw = (ListWidget)w;
    XFontSetExtents *ext  = XExtentsOfFontSet(lw->list.fontset);

    if (!XtIsRealized(w) || item > lw->list.nitems)
      return;

    if (lw->list.vertical_cols) {
	x = lw->list.col_width * (item / lw->list.nrows)
	  + lw->list.internal_width;
	y = lw->list.row_height * (item % lw->list.nrows)
	  + lw->list.internal_height;
    }
    else {
	x = lw->list.col_width * (item % lw->list.ncols)
	  + lw->list.internal_width;
	y = lw->list.row_height * (item / lw->list.ncols)
	  + lw->list.internal_height;
    }

    if ( lw->simple.international == True )
	str_y = y + XawAbs(ext->max_ink_extent.y);
    else
	str_y = y + lw->list.font->max_bounds.ascent;

    if (item == lw->list.is_highlighted) {
	if (item == lw->list.highlight) {
	    gc = lw->list.revgc;
	    HighlightBackground(w, x, y, lw->list.normgc);
	}
	else {
	    if (XtIsSensitive(w)) 
		gc = lw->list.normgc;
	    else
		gc = lw->list.graygc;
	    HighlightBackground(w, x, y, lw->list.revgc);
	    lw->list.is_highlighted = NO_HIGHLIGHT;
	}
    }
    else {
	if (item == lw->list.highlight) {
	    gc = lw->list.revgc;
	    HighlightBackground(w, x, y, lw->list.normgc);
	    lw->list.is_highlighted = item;
	}
	else {
	    if (XtIsSensitive(w)) 
		gc = lw->list.normgc;
	    else
		gc = lw->list.graygc;
	}
    }

    /* List's overall width contains the same number of inter-column
       column_space's as columns.  There should thus be a half
       column_width margin on each side of each column.
       The row case is symmetric */

    x += lw->list.column_space >> 1;
    str_y += lw->list.row_space >> 1;

    str =  lw->list.list[item];	/* draw it */

    ClipToShadowInteriorAndLongest(lw, &gc, x);

    if (lw->simple.international == True)
	XmbDrawString(XtDisplay(w), XtWindow(w), lw->list.fontset,
		      gc, x, str_y, str, strlen(str));
    else
	XDrawString(XtDisplay(w), XtWindow(w), gc, x, str_y, str, strlen(str));

    XSetClipMask(XtDisplay(w), gc, None);
}
Пример #25
0
static void
file_save_write(Widget w, XtPointer closure, XtPointer call)
{
	MGV	*m = (MGV *)closure;
	MGV_APP *r;
	FILE	*fp;
	Boolean	unmark, marked;
	int	i;
	Widget	sm, su;
	char	*p;
	USEUP(w); USEUP(call);
	assert(MgvOK(m));

	assert(m->savefile != NULL);

	wl_find(m->fs_save,
		&sm,	"*saveMarked",
		&su,	"*saveUnmark",
		NULL);

	/*
	 * saveMarked and saveUnmark should always have the same
	 * sensitivity
	 */
	assert(XtIsSensitive(su) == XtIsSensitive(sm));
	marked = unmark = False;
	if(XtIsSensitive(sm)) {
		marked = XmToggleButtonGetState(sm);
		unmark = XmToggleButtonGetState(su);
	}

	fp = NULL;
	r = mgv_appres(m->main);
	if((p = strrchr(m->savefile, '.')) != NULL) {
		if(strcmp(p, ".gz") == 0)
			fp = comp(m, r->gzip, m->savefile);
		else if(strcmp(p, ".Z") == 0)
			fp = comp(m, r->compress, m->savefile);
		else if(strcmp(p, ".bz2") == 0)
			fp = comp(m, r->bzip, m->savefile);
	}
	if(fp == NULL)
		fp = fopen(m->savefile, "w");

	if(fp == NULL) {
		wl_error(w, "%s %s: %s", mgv_s(w, MgvScantOpen),
					m->savefile, strerror(errno));
		XtFree((XtPointer)m->savefile);
		m->savefile = NULL;
		if(m->save_query != NULL)
			XtUnmanageChild(m->save_query);
		return;
	}

	XtFree((XtPointer)m->savefile);
	m->savefile = NULL;

	mgv_write(m, fp, marked);
	fclose(fp);

	if(unmark && m->dsc != NULL) {
		for(i = 0; i < m->dsc->n_pages; ++i)
			mgv_mark(m, i, FALSE, FALSE);
		mgv_list_update(m, -1);
	}

	wl_dlg_popdown(m->fs_save);
}
Пример #26
0
/*ARGSUSED*/
static void
XawLabelRedisplay(Widget gw, XEvent *event, Region region)
{
    LabelWidget w = (LabelWidget)gw;
    GC gc;

    if (*Superclass->core_class.expose != NULL)
	(*Superclass->core_class.expose)(gw, event, region);

    gc = XtIsSensitive(gw) ? w->label.normal_GC : w->label.gray_GC;
#ifdef notdef
    if (region != NULL)
	XSetRegion(XtDisplay(gw), gc, region);
#endif /*notdef*/

    if (w->label.pixmap == None) {
	int len = w->label.label_len;
	char *label = w->label.label;
	Position y = w->label.label_y + w->label.font->max_bounds.ascent;
	Position ksy = w->label.label_y;

	/* display left bitmap */
	if (w->label.left_bitmap && w->label.lbm_width != 0)
	    XCopyPlane (XtDisplay(gw), w->label.left_bitmap, XtWindow(gw), gc,
			0, 0, w->label.lbm_width, w->label.lbm_height,
			w->label.internal_width,
			w->label.internal_height + w->label.lbm_y, 1L);

	if (w->simple.international == True) {
	    XFontSetExtents *ext = XExtentsOfFontSet(w->label.fontset);

	    ksy += XawAbs(ext->max_ink_extent.y);

	    if (len == MULTI_LINE_LABEL) {
		char *nl;

		while ((nl = index(label, '\n')) != NULL) {
		    XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset,
				  gc, w->label.label_x, ksy, label,
				  (int)(nl - label));
		    ksy += ext->max_ink_extent.height;
		    label = nl + 1;
		}
		len = strlen(label);
	    }
	    if (len)
		XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc,
			      w->label.label_x, ksy, label, len);
	}
	else {
	    if (len == MULTI_LINE_LABEL) {
		char *nl;

		while ((nl = index(label, '\n')) != NULL) {
		    if (w->label.encoding)
			XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
				      w->label.label_x, y,
				      (XChar2b *)label, (int)(nl - label) / 2);
		    else
			XDrawString(XtDisplay(gw), XtWindow(gw), gc,
				    w->label.label_x, y, label, (int)(nl - label));
		    y += w->label.font->max_bounds.ascent +
			 w->label.font->max_bounds.descent;
		    label = nl + 1;
		}
		len = strlen(label);
	    }
	    if (len) {
		if (w->label.encoding)
		    XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
				  w->label.label_x, y, (XChar2b *)label, len / 2);
		else
		    XDrawString(XtDisplay(gw), XtWindow(gw), gc,
				w->label.label_x, y, label, len);
	    }
	}
    }
    else if (w->label.label_len == 1)
	XCopyPlane(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
		   0, 0, w->label.label_width, w->label.label_height,
		   w->label.label_x, w->label.label_y, 1L);
    else
	XCopyArea(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
		  0, 0, w->label.label_width, w->label.label_height,
		  w->label.label_x, w->label.label_y);

#ifdef notdef
    if (region != NULL)
	XSetClipMask(XtDisplay(gw), gc, (Pixmap)None);
#endif /* notdef */
}
Пример #27
0
static Boolean
XawLabelSetValues(Widget current, Widget request, Widget cnew,
		  ArgList args, Cardinal *num_args)
{
    LabelWidget curlw = (LabelWidget)current;
    LabelWidget reqlw = (LabelWidget)request;
    LabelWidget newlw = (LabelWidget)cnew;
    unsigned int i;
    Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS];

    for (i = 0; i < NUM_CHECKS; i++)
	checks[i] = False;

    for (i = 0; i < *num_args; i++) {
	if (streq(XtNbitmap, args[i].name))
	    checks[PIXMAP] = True;
	else if (streq(XtNwidth, args[i].name))
	    checks[WIDTH] = True;
	else if (streq(XtNheight, args[i].name))
	    checks[HEIGHT] = True;
    }

    if (newlw->label.label == NULL)
	newlw->label.label = newlw->core.name;

    /*
     * resize on bitmap change
     */
    if (curlw->label.left_bitmap != newlw->label.left_bitmap)
	was_resized = True;

    if (curlw->label.encoding != newlw->label.encoding)
	was_resized = True;

    if (curlw->simple.international
	&& curlw->label.fontset != newlw->label.fontset)
	was_resized = True;

    if (curlw->label.label != newlw->label.label) {
	if (curlw->label.label != curlw->core.name)
	    XtFree((char *)curlw->label.label);

	if (newlw->label.label != newlw->core.name)
	    newlw->label.label = XtNewString(newlw->label.label);

	was_resized = True;
    }

    if (was_resized || (curlw->label.font != newlw->label.font) ||
        curlw->label.justify != newlw->label.justify || checks[PIXMAP]) {
	SetTextWidthAndHeight(newlw);
	was_resized = True;
    }

    /* recalculate the window size if something has changed */
    if (newlw->label.resize && was_resized) {
	if (XtHeight(curlw) == XtHeight(reqlw) && !checks[HEIGHT])
	    XtHeight(newlw) = newlw->label.label_height +
			      (newlw->label.internal_height << 1);

	set_bitmap_info(newlw);

	if (XtWidth(curlw) == XtWidth(reqlw) && !checks[WIDTH])
	    XtWidth(newlw) = newlw->label.label_width + LEFT_OFFSET(newlw) +
			     (newlw->label.internal_width << 1);
    }

    if (curlw->label.foreground		!= newlw->label.foreground
	|| curlw->core.background_pixel != newlw->core.background_pixel
	|| curlw->label.font->fid	!= newlw->label.font->fid) {
	/* The Fontset is not in the GC - don't make a new GC if FS changes! */
	XtReleaseGC(cnew, curlw->label.normal_GC);
	XtReleaseGC(cnew, curlw->label.gray_GC);
	XmuReleaseStippledPixmap(XtScreen(current), curlw->label.stipple);
	GetNormalGC(newlw);
	GetGrayGC(newlw);
	redisplay = True;
    }

    if (curlw->label.label_x != newlw->label.label_x ||
        curlw->label.label_y != newlw->label.label_y)
	redisplay = True;

    if (curlw->label.internal_width != newlw->label.internal_width
	|| curlw->label.internal_height != newlw->label.internal_height
	|| was_resized) {
	/* Resize() will be called if geometry changes succeed */
	Position dx, dy;

	_Reposition(newlw, XtWidth(curlw), XtHeight(curlw), &dx, &dy);
    }

      return (was_resized || redisplay ||
	      XtIsSensitive(current) != XtIsSensitive(cnew));
}
Пример #28
0
/******************************************************************************
 *
 *  SetValues:
 *     Called by the Intrinsics when an application attempts to
 *     change the value of a resource.  
 *
 *****************************************************************************/
static Boolean 
SetValues (
        Widget old_w,
        Widget request_w,
        Widget new_w,
        ArgList args,
        Cardinal *num_args
          )
{
 ExmSimpleWidgetClass wc = (ExmSimpleWidgetClass)XtClass(new_w);
 ExmSimpleWidget cw = (ExmSimpleWidget)old_w;
 ExmSimpleWidget rw = (ExmSimpleWidget)request_w;
 ExmSimpleWidget nw = (ExmSimpleWidget)new_w;
 Boolean redisplayFlag = False;

 /* Validate the value of ExmNsimpleShape by calling XmRepTypeValidValue. */
   if (nw->simple.simple_shape != cw->simple.simple_shape) {
     if (!XmRepTypeValidValue (simpleShapeId, nw->simple.simple_shape, 
                               (Widget)nw))
       nw->simple.simple_shape = cw->simple.simple_shape;
     else
       redisplayFlag = True;
   }

 /* Redisplay on change in sensitivity */
 if (XtIsSensitive(new_w) != XtIsSensitive(old_w))
   redisplayFlag = True;

 /* If the widget's foreground or background color changes, 
    then we must update the GC. */ 
   if (nw->primitive.foreground != cw->primitive.foreground ||
       nw->core.background_pixel != cw->core.background_pixel) {
     if (wc->simple_class.destroy_gc)
       (*(wc->simple_class.destroy_gc))((Widget)cw);
     if (wc->simple_class.create_gc)
       (*(wc->simple_class.create_gc))((Widget)nw);
     redisplayFlag = True;
   }

 /* Check for application geometry settings. '0' means 'ideal size' */
   if (rw->core.width == FIND_NATURAL_SIZE) {
     nw->core.width = FIND_NATURAL_SIZE;
     nw->simple.need_to_compute_width = True;
   }
   else if (rw->core.width != cw->core.width) {
     nw->core.width = rw->core.width;
     nw->simple.pref_width = rw->core.width;
     nw->simple.need_to_compute_width = False;
   }

   if (rw->core.height == FIND_NATURAL_SIZE) {
     nw->core.height = FIND_NATURAL_SIZE;
     nw->simple.need_to_compute_height = True;
   }
   else if (rw->core.height != cw->core.height) {
     nw->core.height = rw->core.height;
     nw->simple.pref_height = rw->core.height;
     nw->simple.need_to_compute_height = False;
   }

 /* Check for any changes in total widget set, margin size, or 
    window decoration size.  If any are found, call Reconfigure. */ 
   nw->simple.need_to_reconfigure = False;
   if (nw->core.width != cw->core.width ||
       nw->core.height != cw->core.height ||
       nw->simple.margin_width != cw->simple.margin_width ||
       nw->simple.margin_height != cw->simple.margin_height ||
       nw->primitive.shadow_thickness != cw->primitive.shadow_thickness ||
       nw->primitive.highlight_thickness != cw->primitive.highlight_thickness
      ) 
   Reconfigure (exmSimpleWidgetClass, new_w, old_w);

   return (redisplayFlag);
}
void SelectorRadioInteractor::reloadMenuOptions()
{
    SelectorInstance *si = (SelectorInstance*) this->interactorInstance;
    SelectorNode     *snode = (SelectorNode*)si->getNode();
    int endi, n, i;
    Arg wargs[10];
    Pixel bg, fg;
    Widget button, w;
    int newOptionCnt = si->getOptionCount();
    int oldOptionCnt = this->toggleWidgets.getSize();
    Boolean setting, oldSetting;
    XmString xmstr, oldstr;
    char *cp;

    // reuse existing buttons
    for (i=1; i<=oldOptionCnt; i++) {
        if (i>newOptionCnt) break;
        w = (Widget)this->toggleWidgets.getElement(i);
        char *optname = (char *)si->getOptionNameString(i);
        ASSERT(optname);
        if (snode->isOptionSelected(i))  setting = True;
        else setting = False;
        XtVaGetValues (w, XmNlabelString, &oldstr, XmNset, &oldSetting, NULL);
        if (oldSetting!=setting) XtVaSetValues (w, XmNset, setting, NULL);
        XmStringGetLtoR (oldstr, XmSTRING_DEFAULT_CHARSET, &cp);
        XmStringFree (oldstr);
        if (!XtIsSensitive (w)) XtSetSensitive(w, True);
        if ((!cp)||(strcmp(cp, optname))) {
            xmstr = XmStringCreateLtoR(optname, "canvas");
            XtVaSetValues (w, XmNuserData, i, XmNlabelString, xmstr, NULL);
            XmStringFree (xmstr);
        } else XtVaSetValues (w, XmNuserData, i, NULL);
        if (cp) XtFree(cp);
        delete optname;
    }

    // deal with existing, unneeded buttons
    endi = i;
    for (i=i; i<=oldOptionCnt; i++) {
        w = (Widget)this->toggleWidgets.getElement(endi);
        if ((i==oldOptionCnt) && (newOptionCnt == 0)) {
            xmstr = XmStringCreateLtoR("(empty)", "canvas");
            XtSetSensitive(w, False);
            XtVaSetValues (w, XmNlabelString, xmstr, NULL);
            XmStringFree(xmstr);
            break;
        }
        XtUnmanageChild (w);
        XtDestroyWidget (w);
        this->toggleWidgets.deleteElement(endi);
    }


    // get new buttons if more are needed
    XtVaGetValues (this->toggleRadio, XmNforeground, &fg, XmNbackground, &bg, NULL);
    for (i=i; i<=newOptionCnt; i++) {
        char *optname = (char*)si->getOptionNameString(i);
        Boolean setting;
        ASSERT(optname);
        xmstr = XmStringCreateLtoR(optname, "canvas");
        n = 0;
        XtSetArg(wargs[n], XmNuserData, i); n++;
        XtSetArg(wargs[n], XmNlabelString, xmstr ); n++;
        if (snode->isOptionSelected(i))  setting = True;
        else setting = False;
        XtSetArg(wargs[n], XmNset, setting); n++;
        XtSetArg(wargs[n], XmNbackground, bg); n++;
        XtSetArg(wargs[n], XmNforeground, fg); n++;
        button = XtCreateManagedWidget(optname,
                xmToggleButtonWidgetClass, this->toggleRadio, wargs,n);

        XtAddCallback(button, XmNvalueChangedCallback,
		 (XtCallbackProc)SelectorRadioInteractor_SelectorToggleCB,
		 (XtPointer)this);

        this->appendOptionWidget(button);
        delete optname;
        XmStringFree(xmstr);
    }
    this->resetUserDimensions();
    XtVaSetValues (XtParent(this->toggleRadio), XmNheight, 0, NULL);
}
Пример #30
0
/************************************************************************
 *
 *  SetValues
 *     Perform and updating necessary for a set values call.
 *
 ************************************************************************/
static Boolean 
SetValues(
        Widget cw,
        Widget rw,
        Widget nw,
        ArgList args,
        Cardinal *num_args )
{
        XmGadget cur = (XmGadget) cw ;
        XmGadget req = (XmGadget) rw ;
        XmGadget new_w = (XmGadget) nw ;
   Boolean returnFlag;

    if (XtIsSensitive(cw) != XtIsSensitive(nw))
    {
    	if (!XtIsSensitive(nw))
    	{
	    _XmToolTipLeave(nw, NULL, NULL, NULL);
    	}
    }

    if (XmGetToolTipString(nw) != XmGetToolTipString(cw))
    {
        XmSetToolTipString(cw, XmGetToolTipString(nw));
    }

   /* CR 7124: XmNlayoutDirection is a CG resource. */
   if (cur->gadget.layout_direction != new_w->gadget.layout_direction)
     {
       XmeWarning((Widget) new_w, MESSAGE1);
       new_w->gadget.layout_direction = cur->gadget.layout_direction;
     }

   if(    cur->gadget.navigation_type != new_w->gadget.navigation_type    )
     {
       if(    !XmRepTypeValidValue( XmRID_NAVIGATION_TYPE, 
			        new_w->gadget.navigation_type, (Widget) new_w)    )
	 {
	   new_w->gadget.navigation_type = cur->gadget.navigation_type ;
	 } 
     }
   returnFlag = _XmNavigSetValues ((Widget) cur, (Widget) req, (Widget) new_w,
				                               args, num_args);
   /*  Validate changed data.  */

   if(    !XmRepTypeValidValue( XmRID_UNIT_TYPE, new_w->gadget.unit_type,
                                                             (Widget) new_w)    )
   {
      new_w->gadget.unit_type = cur->gadget.unit_type;
   }


   /*  Convert the necessary fields from unit values to pixel values  */

   _XmGadgetImportArgs((Widget) new_w, args, num_args);

   /*  Check for resize conditions  */

   if (cur->gadget.shadow_thickness != new_w->gadget.shadow_thickness ||
       cur->gadget.highlight_thickness != new_w->gadget.highlight_thickness)
      returnFlag = True;
   

   /*  Force the border width to 0  */

   new_w->rectangle.border_width = 0;

   if(    new_w->gadget.highlight_drawn
      &&  (    !XtIsSensitive( (Widget) new_w)
	   ||  (    cur->gadget.highlight_on_enter
		&&  !(new_w->gadget.highlight_on_enter)
		&&  (_XmGetFocusPolicy( (Widget) new_w) == XmPOINTER)))    )
     {
       if(    ((XmGadgetClass) XtClass( new_w))
	                                 ->gadget_class.border_unhighlight    )
	 {
	   (*(((XmGadgetClass) XtClass( new_w))
	                   ->gadget_class.border_unhighlight))( (Widget) new_w) ;
	 }
     }

   /*  Return a flag which may indicate that a redraw needs to occur.  */
   
   return (returnFlag);
}