Exemple #1
0
static void 
ClipResize (Widget clip_window, XtPointer client_data, XtPointer call_data) 
{
    Widget work_window = (Widget) client_data ;
    static Dimension prev_clip_width = 0, prev_clip_height = 0 ;
    Dimension clip_width, clip_height, work_width, work_height ;

    /* if we're getting bigger, check the current work_window size
       and if we're bigger than it, resize the work_window so it just
       fits the clipwindow.
       if we're getting smaller, ask the preferred work_window size,
       and if we're still bigger than it, resize the work_window so it just
       fits the clipwindow, else resize it to its preferred size. */

    XtVaGetValues(clip_window, XmNwidth, &clip_width, 
		  XmNheight, &clip_height, NULL);

    if (clip_width > prev_clip_width) {
	XtVaGetValues(work_window, XmNwidth, &work_width, NULL);
	if (clip_width > work_width) {
	    XtVaSetValues(work_window, XmNwidth, clip_width - SB_HT, NULL);
	}
    } else {
	XtWidgetGeometry  preferred;
	XtQueryGeometry(work_window, NULL, &preferred);
	if (clip_width > preferred.width) {
	    XtVaSetValues(work_window, XmNwidth, clip_width - SB_HT, NULL);
	} else {
	    XtVaSetValues(work_window, XmNwidth, preferred.width, NULL);
	}
    }    
    prev_clip_width = clip_width ;

    if (clip_height > prev_clip_height) {
	XtVaGetValues(work_window, XmNheight, &work_height, NULL);
	if (clip_height > work_height) {
	    XtVaSetValues(work_window, XmNheight, clip_height - SB_HT, NULL);
	}
    } else {
	XtWidgetGeometry  preferred;
	XtQueryGeometry(work_window, NULL, &preferred);
	if (clip_height > preferred.height) {
	    XtVaSetValues(work_window, XmNheight, clip_height - SB_HT, NULL);
	} else {
	    XtVaSetValues(work_window, XmNheight, preferred.height, NULL);
	}
    }    
    prev_clip_height = clip_height ;
}
Exemple #2
0
/************************************************************************
 *
 *  QueryGeometry
 *  	return width X height based on the children preferred sizes
 *
 ************************************************************************/
static XtGeometryResult 
QueryGeometry(
        Widget widget,
        XtWidgetGeometry *intended,
        XtWidgetGeometry *desired )
{
    Dimension work_width = 0, work_height = 0, work_bw = 0 ;
    Dimension title_width = 0, title_height = 0, title_bw = 0 ;
    XtWidgetGeometry child_pref ;
    XmFrameWidget fw = (XmFrameWidget) widget ;

    /* first determine what is the desired size, using the
       preferred sizes of the title and the work_area, or the
       current setting if no preference are given */
    if (fw->frame.work_area) {
	XtQueryGeometry (fw->frame.work_area, NULL, &child_pref);    
	if (IsWidth(&child_pref)) work_width = child_pref.width ;
	else work_width = XtWidth(fw->frame.work_area);
	if (IsHeight(&child_pref)) work_height = child_pref.height ;
	else work_height = XtHeight(fw->frame.work_area);
	if (IsBorder(&child_pref)) work_bw = child_pref.border_width ;
	else work_bw = XtBorderWidth(fw->frame.work_area);
    } 
    if (fw->frame.title_area) {
	XtQueryGeometry (fw->frame.title_area, NULL, &child_pref);    
	if (IsWidth(&child_pref)) title_width = child_pref.width ;
	else title_width = XtWidth(fw->frame.title_area);
	if (IsHeight(&child_pref)) title_height = child_pref.height ;
	else title_height = XtHeight(fw->frame.title_area);
	if (IsBorder(&child_pref)) title_bw = child_pref.border_width ;
	else title_bw = XtBorderWidth(fw->frame.title_area);
    }

    CalcFrameSize (fw, 
		   title_width, title_height, title_bw,
		   work_width, work_height, work_bw,
		   &desired->width, &desired->height);

    /* deal with user initial size setting */
    if (!XtIsRealized(widget))  {
	if (XtWidth(widget) != 0) desired->width = XtWidth(widget) ;
	if (XtHeight(widget) != 0) desired->height = XtHeight(widget) ;
    }	    

    return XmeReplyToQueryGeometry(widget, intended, desired) ;
}
Exemple #3
0
static void 
ChangeManaged(Widget wid)
{
  XmGrabShellWidget gs = (XmGrabShellWidget)wid;
  ShellWidget       shell = (ShellWidget)wid;
  Dimension         bw = 0;
  XtWidgetGeometry  pref, mygeom, replygeom;
  XtGeometryResult  result;
  Widget	    child;
  
  mygeom.request_mode = 0;
  if (gs->composite.num_children)
    {
      child = gs->composite.children[0];
      if (XtIsManaged(child))
	{
	  /* Get child's preferred size */
	  result = XtQueryGeometry(child, NULL, &pref);
	  
	  /* Take whatever they want */
	  if (pref.request_mode & CWWidth)
	    {
	      mygeom.width = pref.width; 
	      mygeom.request_mode |=  CWWidth;
	    }

	  if (pref.request_mode & CWHeight)
	    {
	      mygeom.height = pref.height;
	      mygeom.request_mode |=  CWHeight;
	    }

	  if (pref.request_mode & CWBorderWidth)
	    bw = pref.border_width;
	  else
	    bw = child->core.border_width;
	}
    }
  
  mygeom.width += 2*bw + 2*gs->grab_shell.shadow_thickness;
  mygeom.height += 2*bw + 2*gs->grab_shell.shadow_thickness;
  
  result = XtMakeGeometryRequest((Widget)shell, &mygeom, &replygeom);
  switch (result)
    {
    case XtGeometryAlmost:
      XtMakeGeometryRequest((Widget)shell, &replygeom, NULL);
      /* fall through. */
    case XtGeometryYes:
      DoLayout(wid);
      break;
    case XtGeometryNo:
    case XtGeometryDone:
      break;
    }
}
static XtGeometryResult
XawViewportQueryGeometry(Widget w, XtWidgetGeometry *constraints,
			 XtWidgetGeometry *reply)
{
    if (((ViewportWidget)w)->viewport.child != NULL)
	return (XtQueryGeometry(((ViewportWidget)w)->viewport.child,
				constraints, reply));

    return (XtGeometryYes);
}
Exemple #5
0
/************************************************************************
 *
 *  ChangeManaged
 *	Process a changed in managed state of the child.  If its
 *	size is out of sync with the frame, make a resize request
 *	to change the size of the frame.
 *	Note: called before ConstraintDestroy.
 *
 ************************************************************************/
static void 
ChangeManaged(
        Widget wid )
{
   XmFrameWidget fw = (XmFrameWidget) wid ;

   Widget title_area = (fw->frame.title_area &&
			XtIsManaged(fw->frame.title_area)) ?
			fw->frame.title_area : (Widget) NULL;
   Dimension t_w = 0;
   Dimension t_h = 0;
   Dimension t_bw = (title_area) ? title_area->core.border_width : 0;

   Widget work_area = (fw->frame.work_area &&
			XtIsManaged(fw->frame.work_area)) ?
			fw->frame.work_area : (Widget) NULL;

   Dimension w_w = (work_area) ? work_area->core.width : 0;
   Dimension w_h = (work_area) ? work_area->core.height : 0;
   Dimension w_bw = (work_area) ? work_area->core.border_width : 0;
   Dimension fwWidth, fwHeight;

   if (title_area) 
   {                                          
	/* We don't want the current size of the title object -- width/height
	** may have been set on it. Because we'll be forcing it to the size we
	** want (see ConfigureChildren), we must use the "natural" size here,
	** so query its value now. (Use current border_width.)
        */
	XtWidgetGeometry title_reply;                           
	XtQueryGeometry (title_area, NULL, &title_reply);      
	t_w = (title_reply.request_mode & CWWidth) ?          
		title_reply.width : title_area->core.width;   
	t_h = (title_reply.request_mode & CWHeight) ?       
		title_reply.height : title_area->core.height;
   }                             

   /* need to  check on initial sizing (not null) */
   if (XtIsRealized((Widget)fw) || (XtWidth(fw) == 0) || (XtHeight(fw) == 0)) {
       CalcFrameSize (fw, t_w, t_h, t_bw, w_w, w_h, w_bw,
		      &fwWidth, &fwHeight);

       while (XtMakeResizeRequest ((Widget) fw, 
				   fwWidth, fwHeight,
				   &fwWidth, &fwHeight) == XtGeometryAlmost) 
	 /*EMPTY*/;
       ClearShadow(fw);
   }
 
   ConfigureChildren(fw, NULL, NULL);

   DrawShadow(fw);

   XmeNavigChangeManaged((Widget) fw);
}
Exemple #6
0
static XtGeometryResult QueryGeometry(Widget w,
                                      XtWidgetGeometry *intended , XtWidgetGeometry *preferred)
{
    MwRowWidget cw = (MwRowWidget) w;
    XtWidgetGeometry pref_geom , inten_geom;
    Widget *child;
    Dimension width , height;
    Position x,y;
    int lspace , rspace;
    int maxwidth = 0;
    int chnum = 0;

    mwRowClassRec.baseConst_class.get_internal_dimension(w , &x , &y , &width,&height);

    preferred->request_mode = CWWidth | CWHeight;
    preferred->width = cw->core.width - width + 2 * cw->row.spacing;
    preferred->height = cw->core.height - height + 2 * cw->row.spacing;

    inten_geom.request_mode = CWWidth | CWHeight;
    inten_geom.width = width;
    inten_geom.height = height;

    ForAllChildren(cw , child)
    {
        if (!XtIsManaged(*child)) continue;

        XtQueryGeometry(*child , &inten_geom , &pref_geom);
        XtVaGetValues(*child , XtNleft_space , &lspace ,
                      XtNright_space , &rspace , NULL);

        preferred->width += lspace + rspace  + pref_geom.width;
        preferred->height = MW_MAX (preferred->height , pref_geom.height +
                                    2 * cw->row.spacing);

        chnum++;
        maxwidth = MW_MAX(maxwidth , lspace + rspace  + pref_geom.width);
    }

    if (cw->row.homogenous)
        preferred->width = cw->core.width - width + 2 * cw->row.spacing +
                           chnum * maxwidth;


    if (((intended->request_mode & (CWWidth | CWHeight))
            == (CWWidth | CWHeight)) &&
            intended->width == preferred->width &&
            intended->height == preferred->height)
        return XtGeometryYes;

    else if (preferred->width == cw->core.width &&
             preferred->height == cw->core.height)
        return XtGeometryNo;

    else return XtGeometryAlmost;
}
Exemple #7
0
/*----------------------------------------------------------------------*/
/* extern */ void
_XfePreferredGeometry(Widget w,Dimension *width_out,Dimension *height_out)
{
	Dimension width;
	Dimension height;

    assert( _XfeIsAlive(w) );

	if (XfeIsPrimitive(w))
	{
		width  = _XfePreferredWidth(w);
		height = _XfePreferredHeight(w);
	}
	else if (XfeIsManager(w))
	{
		width  = _XfemPreferredWidth(w);
		height = _XfemPreferredHeight(w);
	}
	else
	{
		XtWidgetGeometry reply;

		XtQueryGeometry(w,NULL,&reply);

		if (reply.request_mode & CWWidth)
		{
			width = reply.width;
		}
		else
		{
			width = _XfeWidth(w);
		}


		if (reply.request_mode & CWHeight)
		{
			height = reply.height;
		}
		else
		{
			height = _XfeHeight(w);
		}
	}

	if (width_out)
	{
		*width_out = width;
	}

	if (height_out)
	{
		*height_out = height;
	}
}
Exemple #8
0
void Container::ResizeTimeOut(void *data, XtIntervalId * /*id*/)
{
   Container *obj = (Container *)data;
   int h4 = obj->Parent()->Height();
   Dimension h1, h2, h3;

   if (obj->NumChildren())
    {
      Dimension max_height;
      MotifUI **children = (MotifUI **)obj->Children();
      int i;
      XtWidgetGeometry preferred;

      max_height = 0;
      for (i = 0; i < obj->NumChildren(); i++)
       {
	 if (XtIsManaged(children[i]->BaseWidget()))
	  {
            XtQueryGeometry(children[i]->BaseWidget(), NULL, &preferred);
            if ((h1 = preferred.height) > max_height)
	     {
	       max_height = h1;
	       break;
	     }
	  }
       }
      Position y;
      if (max_height)
         XtVaGetValues(children[0]->BaseWidget(), XmNy, &y, NULL);
      else
	 y = 0;
      h1 = max_height + (2 * y);
    }
   else
      XtVaGetValues(obj->_workArea, XmNheight, &h1, NULL);
   XtVaGetValues(obj->_clipWidget, XmNheight, &h2, NULL);
   XtVaGetValues(obj->_w, XmNheight, &h3, NULL);
   h3 = h3 - h2 + h1;
   if (h2 != h1)
    {
      if (h4 > (int)h3)
         h3 = h4;
      else if (obj->NumChildren() == 0)
         return;
      h4 = h3;
    }
   else if (h4 <= (int)h3)
      return;
   XtVaSetValues(obj->_w, XmNheight, h4, NULL);
   obj->Refresh();
   XtVaGetValues(obj->_w, XmNheight, &h3, NULL);
   if (h3 != h4)
      XtAppAddTimeOut(obj->appContext, 500, ResizeTimeOut, obj);
}
Exemple #9
0
wxSize wxControl::DoGetBestSize() const
{
    Widget w = (Widget)GetTopWidget();

    // Do not return any arbitrary default value...
    wxASSERT_MSG (w, wxT("DoGetBestSize called before creation"));

    XtWidgetGeometry preferred;
    XtQueryGeometry (w, NULL, &preferred);

    return wxSize(preferred.width, preferred.height);
}
Exemple #10
0
/*
 * Usually called from a key press, but there is no reason it can't
 * be called from a button event.
 *
 * Accepts 1 numeric parameter: if nonzero, the menu stays up instead
 * of popping down.
 */
static void menu_select_action(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    int keep_menu_up = 0;

    if (*num_params == 1) {
        keep_menu_up = atoi(*params);
    }

    if (event->type == KeyPress || event->type == KeyRelease) {
        XtWidgetGeometry geometry;
        Widget old_active_entry;

        /*
         * Keyboard events bubble up to the top menu, because the top is
         * "spring loaded", So we may get to see them multiple times for
         * different widgets, if the mouse happens to be in a submenu. To
         * put a stop to that: only listen to the top_menu.
         */
        if (w != top_menu) {
#if MENU_DEBUG 
            printf("menu_select_action: ignoring event, not top_menu\n");
#endif
            return;
        }

        /*
         * Apparently, notify() looks at the event coordinates to know
         * which item should be notify()d, instead of just doing the
         * active one. So fake them.
         * It also looks if the event's window matches the widget,
         * presumably also because of spring-loaded menus.  Fake that too.
         * To look at the coordinates, it checks the event type, and it
         * doesn't know about keys. More faking.
         */
        old_active_entry = XawSimpleMenuGetActiveEntry(active_keyboard_menu);
        if (!old_active_entry) {
            return;
        }

        fake_button_action(w, event, NULL, NULL);       /* notify() cares */

        XtQueryGeometry(old_active_entry, NULL, &geometry);
        event->xbutton.x = geometry.x + 1;
        event->xbutton.y = geometry.y + 1;

        w = active_keyboard_menu;
        event->xany.window = XtWindow(w);       /* notify() cares about this */
    }

    do_menu_select(w, event, keep_menu_up);
}
Exemple #11
0
static void
ChangeManaged (Widget w)
{
  if (!XtIsRealized (w))
    {
      XtWidgetGeometry request, reply;

      /* find out how big we'd like to be ... */

      request.request_mode = 0;
      XtQueryGeometry (w, &request, &reply);
      EmacsManagerChangeSize (w, reply.width, reply.height);
    }
}
Exemple #12
0
/***********************************************************************
 Query widget preferred dimensions in its native units
 (XtQueryGeometry always returns geometry in pixels)
***********************************************************************/
void utlQueryDimensions(
Widget w,
Dimension *width,
Dimension *height)
{
    unsigned char unit = XmPIXELS;
    XtWidgetGeometry preferred;

    XtVaGetValues(w,XmNunitType,&unit,NULL);
    XtQueryGeometry(w,NULL,&preferred);

    if (width !=NULL)
    *width = XmConvertUnits(w,XmHORIZONTAL,XmPIXELS,preferred.width,unit);
    if (height !=NULL)
    *height = XmConvertUnits(w,XmVERTICAL,XmPIXELS,preferred.height,unit);
}
Exemple #13
0
static void
compute_height (RestraintWidget w, Widget child)
{
  XtGeometryResult result;
  XtWidgetGeometry reply, intended;
  XtWidgetGeometry my_request, my_reply;

  /* -------- See how big the kid wants to be. -------- */
  /* Let it know we plan to change his width. */
  intended.request_mode = CWWidth;
  intended.width = w->core.width;
  XtQueryGeometry (child, &intended, &reply);
  ON_DEBUG(printf ("In Restraint::compute_height, child wants to be:\n"));
  ON_DEBUG(printf ("  Width: %d,  Height: %d\n", reply.width, reply.height));

  /* -------- Check with my parent for the change. -------- */
  if (reply.height != 0)
    {
      my_request.request_mode = CWHeight;
      my_request.height = reply.height;
      ON_DEBUG(printf ("Restraint: Asking parent for height %d\n", reply.height));
      result = XtMakeGeometryRequest ((Widget) w, &my_request, &my_reply);

      if (result == XtGeometryAlmost)
	{
	  ON_DEBUG(printf ("  Parent said Almost\n"));
	  /* Go with suggestion if we can get taller. */
	  if (my_reply.height > w->core.height)
	    {
	      ON_DEBUG(printf ("  Asking again for %d\n", my_reply.height));
	      my_request.height = my_reply.height;
	      /* Parent must say Yes. */
	      XtMakeGeometryRequest ((Widget) w, &my_request, NULL);
	    }
	}
      else if (result == XtGeometryYes)
	ON_DEBUG(printf ("  Parent said Yes.\n"));
      else if (result == XtGeometryNo)
	ON_DEBUG(printf ("  Parent said No.\n"));
      else
	ON_DEBUG(printf ("  *** Impossible Reply = %d ***\n", result));
    }

  ON_DEBUG(printf ("Restraint: compute_height = %d\n", w->core.height));
}
Exemple #14
0
/*!\reimp
 */
void KXtWidget::resizeEvent( QResizeEvent* )
{
    if ( xtparent )
        return;
    XtWidgetGeometry preferred;
    (void ) XtQueryGeometry( xtw, 0, &preferred );
    XConfigureEvent c;
    c.type = ConfigureNotify;
    c.event = winId();
    c.window = winId();
    c.x = x();
    c.y = y();
    c.width = width();
    c.height = height();
    c.border_width = 0;
    XSendEvent( qt_xdisplay(), c.event, TRUE, NoEventMask, (XEvent*)&c );
    XtResizeWidget( xtw, width(), height(), preferred.border_width );
}
Exemple #15
0
static Boolean QueryGeometry(Widget W, XtWidgetGeometry *request, QueryResult *Expected, XtWidgetGeometry *desired)
{
Boolean status = True;
XtWidgetGeometry OriginalRequest;
XtGeometryResult result;

	if (request)
		OriginalRequest = *request;

	printf("QueryGeometry asked for (%s) ",
		XdbWidgetGeometry2String(request));

	result = XtQueryGeometry(W, request, desired);

	printf("got (%s %s) ",
		XdbWidgetGeometry2String(desired),
		XdbGeometryResult2String(result));
	printf("expected (%s %s %s) ",
		XdbWidgetGeometry2String(&Expected->geo),
		XdbGeometryResult2String(Expected->result),
		XdbWidgetGeometry2String(request));
	/*
	printf("original return (%s) ",
		XdbWidgetGeometry2String(request));
		*/

	if ((desired->request_mode & Expected->geo.request_mode) == Expected->geo.request_mode &&
	    desired->width  == Expected->geo.width  &&
	    desired->height == Expected->geo.height &&
	    result == Expected->result &&
	    (!request ? True : (OriginalRequest.request_mode == request->request_mode &&
	    			OriginalRequest.width == request->width &&
	    			OriginalRequest.height == request->height))
	   )
	{
		printf("Passed\n");
	}
	else
	{
		printf("Failed\n");
		status = False;
	}
	return(status);
}
Exemple #16
0
static void
compute_width (RestraintWidget w, Widget child)
{
  XtGeometryResult result;
  XtWidgetGeometry reply;
  XtWidgetGeometry my_request, my_reply;

  /* Let's see how big the kid wants to be. */
  XtQueryGeometry (child, NULL, &reply);

  ON_DEBUG(printf ("In Restraint::compute_width, child wants to be:\n"));
  ON_DEBUG(printf ("  Width: %d,  Height: %d\n", reply.width, reply.height));
  
  /* Try to grow if the child wants to be wider. */
  if (reply.width > w->core.width)
    {
      my_request.request_mode = CWWidth;
      my_request.width = reply.width;

      ON_DEBUG(printf ("Restraint: Asking parent width = %d\n", reply.width));
      result = XtMakeGeometryRequest ((Widget) w, &my_request, &my_reply);

      /* Go with parent suggestion on almost. */
      if (result == XtGeometryAlmost)
	{
	  ON_DEBUG(printf ("  Parent said Almost.\n"));
	  ON_DEBUG(printf ("  Using suggested width of %d\n", my_reply.width));
	  my_request.width = my_reply.width;

	  /* Parent must say Yes. */
	  XtMakeGeometryRequest ((Widget) w, &my_request, NULL);
	}
      else if (result == XtGeometryYes)
	ON_DEBUG(printf ("  Parent said Yes\n"));
      else if (result == XtGeometryNo)
	ON_DEBUG(printf ("  Parent said No\n"));
      else
	ON_DEBUG(printf ("  *** Impossible Reply = %d ***\n", result));
    }

  ON_DEBUG(printf ("Restraint: compute_width = %d\n", w->core.width));
}
Exemple #17
0
static void menu_exit_submenu_action(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    int i;

    if (w != top_menu) {
#if MENU_DEBUG 
        printf("menu_exit_submenu_action: ignoring event, not top_menu\n");
#endif
        return;
    }

    /*
     * Try to find the parent menu.
     */
    for (i = 0; i < num_submenus; i++) {
        if (submenus[i].widget == active_keyboard_menu) {
            Widget parent_entry;
            XtWidgetGeometry geometry;
            int x, y;

            /*
             * Call this here, instead of in the translation table, since
             * the widget must be adjusted.
             */
            XtCallActionProc(active_keyboard_menu, "unhighlight", event, params, *num_params);

            parent_entry = submenus[i].parent;
            /* get to its SimpleMenu: gleaned from Xaw's SimpleMenu.c */
            active_keyboard_menu = XtParent(parent_entry);
            XtQueryGeometry(parent_entry, NULL, &geometry);
            /* The parent item is probably at this location. */
            x = geometry.x + 1;
            y = geometry.y + 1;

            do_fake_motion(active_keyboard_menu, event, x, y);
            break;
        }
    }
}
Exemple #18
0
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
{
    Dimension shadow, border;

    XtVaGetValues( (Widget) GetMainWidget(),
                   XmNshadowThickness, &shadow,
                   XmNborderWidth, &border,
                   NULL);

    *borderOther = shadow + border;

    if( GetLabelWidget() )
    {
        XtWidgetGeometry preferred;
        XtQueryGeometry( (Widget) GetLabelWidget(), NULL, &preferred );

        *borderTop = preferred.height;
    }
    else
    {
        *borderTop = shadow;
    }
}
Exemple #19
0
static void
ToolTipPost (XtPointer client_data,
             XtIntervalId * id)
{
    Widget w = (Widget) client_data;

    int rx,
        ry,
        x,
        y;
    unsigned int key;
    Window root,
           child;
    XtWidgetGeometry geo;
    Position destX,
             destY;

    XmToolTipConfigTrait ttp; /* ToolTip pointer */

    ttp = ToolTipGetData (w);

    if (ttp == NULL)
    {
        XtWarning ("ToolTipGetData() returned NULL in ToolTipPost()");
        return;
    }

    ttp->timer = (XtIntervalId) NULL;

    XQueryPointer (XtDisplay (w),
                   XtWindow (w), &root, &child, &rx, &ry, &x, &y, &key);

    if (ttp->duration_timer != (XtIntervalId) NULL)
    {
        XtRemoveTimeOut (ttp->duration_timer);
        ttp->duration_timer = (XtIntervalId) NULL;
    }

    if (XmIsPrimitive(w) || XmIsGadget(w))
    {
        XtVaSetValues (ttp->label,
                       XmNlabelString,
                       XmGetToolTipString(w),
                       NULL);
    }
    else
    {
        XmString string;

        string = XmStringCreateLocalized (XtName (w));
        XtVaSetValues (ttp->label, XmNlabelString, string, NULL);
        XmStringFree (string);
    }
    XtQueryGeometry (ttp->label, NULL, &geo);

    /* rws 25 Feb 2001
       Fix for Bug #1153
       Don't let the tip be off the right/bottom of the screen
     */
    destX = rx + (XmIsGadget (w) ? XtX (w) : 0) - x + XtWidth (w) / 2;
    if (destX + geo.width > WidthOfScreen (XtScreen (w)))
    {
        destX = WidthOfScreen (XtScreen (w)) - geo.width;
    }
    destY = ry + (XmIsGadget (w) ? XtY (w) : 0) - y + XtHeight (w);
    if (destY + geo.height > HeightOfScreen (XtScreen (w)))
    {
        destY = ry + (XmIsGadget (w) ? XtY (w) : 0) - y - geo.height;
    }

    XtVaSetValues (XtParent (ttp->label),
                   XmNx, rx + 1,
                   XmNy, ry + 1, XmNwidth, 1, XmNheight, 1, NULL);
    ttp->slider =
        XtVaCreateWidget ("ToolTipSlider", xmSlideContextWidgetClass,
                          XmGetXmDisplay (XtDisplay (w)), XmNslideWidget,
                          XtParent (ttp->label),
                          XmNslideDestX, destX,
                          XmNslideDestY, destY,
                          XmNslideDestWidth, geo.width,
                          XmNslideDestHeight, geo.height, NULL);

    XtAddCallback (ttp->slider, XmNslideFinishCallback,
                   (XtCallbackProc) ToolTipPostFinish, ttp);

    XtPopup (XtParent (ttp->label), XtGrabNone);
}
Exemple #20
0
void
LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
{
    int	i, j;
    Dimension	width, height;	/* size values returned by XtGetValues	   */
    Dimension	shadowThickness;/* size values returned by XtGetValues	   */
    Position	x, y;		/* position values returned by XtGetValues */
    
    int dpwidth, dpheight;	/* JET - display w/h set according to */
    int xorg, yorg;		/* xinerama usage */

    struct {			/* position, size of widgets (pixels)	   */
    int x, y;
    int	width;
    int height;
    }		mw, pw; /* matte, logo, drop shadow, login matte
    				       and greeting widgets		   */

    int		width1, width2; /* general width variable		   */
    int		height1;	/* general height variable		   */
    Position	x1, y1;		/* general position variables		   */
    int		offsety;	/* general offset variable		   */
    int		shadow_offsetx; /* offset for drop shadow (pixels)	   */
    int		shadow_offsety; /* offset for drop shadow (pixels)	   */
    int		spacing;	/* spacing between login & matte bottoms   */
    
    Widget	buttons[4];	/* pushbutton widgets			   */

    XtWidgetGeometry  geometry;	/* geometry of a widget			   */
    
    int		max_width;	/* maximum width  of a set of widgets	   */
    int		origin;		/* horizontal origin for button placement  */
    int		space;		/* total available space left between buttons */
    int         overlap;        /* possible widget overlap                 */

#ifdef VG_TRACE
    vg_TRACE_EXECUTION("main:  entered LayoutCB ...");
#endif /* VG_TRACE */

#ifdef USE_XINERAMA
				/* get info on the prefered screen */
    if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo, 
                              appInfo.xineramaPreferredScreen,
			      &dpwidth, &dpheight, &xorg, &yorg))
      {				/* no joy here either - setup for normal */
	dpwidth = dpyinfo.width;
	dpheight = dpyinfo.height;
	xorg = yorg = 0;
      }
#else  /* no Xinerama */
    dpwidth = dpyinfo.width;
    dpheight = dpyinfo.height;
    xorg = yorg = 0;
#endif    

    /*
     * - squeeze dialog to fit onto screen (if necessary)
     */
    i = 0;
    XtSetArg(argt[i], XmNwidth,                 &width                  ); i++;
    XtGetValues(matte, argt, i);
    mw.width  = ToPixel(matte, XmHORIZONTAL, (int)width  );
#define HMARGIN 4 /* min sum horizontal margin of matte */
    if (mw.width+HMARGIN > dpwidth)
    {
      int delta = mw.width + HMARGIN - dpwidth;
     /*
      * Matte width greater than screen so shrink matteFrame
      * and matte1 width to compensate.
      */
      i=0;
      XtSetArg(argt[i], XmNwidth,       &width          ); i++;
      XtGetValues(matteFrame, argt, i);

      width1 = ToPixel(matteFrame, XmHORIZONTAL, (int)width  );
      width1 -= delta;
      width1 = FromPixel(matteFrame, XmHORIZONTAL, width1 );

      i=0;
      XtSetArg(argt[i], XmNwidth,       width1          ); i++;
      XtSetValues(matteFrame, argt, i);

      width1 = dpwidth - HMARGIN;
      mw.width = FromPixel(matte, XmHORIZONTAL, width1 );

      i=0;
      XtSetArg(argt[i], XmNwidth,       mw.width        ); i++;
      XtSetValues(matte, argt, i);
    }

    /*
     * - Make sure the login widgets don't overlap.
     */
    if (login_form) {
	i = 0;
	XtSetArg(argt[i], XmNy,			&y			); i++;
	XtSetArg(argt[i], XmNheight, 		&height			); i++;
	XtGetValues(greeting, argt, i);

	i = 0;
	XtSetArg(argt[i], XmNy,			&y1			); i++;
	XtGetValues(login_form, argt, i);

	overlap = y + height - y1;

	if (overlap > -10) {
            i = 0;
            XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); 	i++;
            XtSetArg(argt[i], XmNbottomWidget,	   login_form); 	i++;
            XtSetArg(argt[i], XmNbottomOffset,	   10);			i++;
            XtSetValues(greeting, argt, i);
	}
    }
 

    /*
     *  - center the main matte horizontally and vertically...
     */
     
    i = 0;
    XtSetArg(argt[i], XmNx,			&x			); i++;
    XtSetArg(argt[i], XmNy,			&y			); i++;
    XtSetArg(argt[i], XmNwidth,			&width			); i++;
    XtSetArg(argt[i], XmNheight,		&height			); i++;
    XtSetArg(argt[i], XmNshadowThickness,	&shadowThickness	); i++;
    XtGetValues(matte, argt, i);

    mw.width  = ToPixel(matte, XmHORIZONTAL, (int)width  );
    mw.height = ToPixel(matte, XmVERTICAL,   (int)height );

    mw.x = ( x > 0 ? ToPixel(matte, XmHORIZONTAL, (int) x)
	    : (dpwidth - mw.width)/2 );
    
    mw.y = ( y > 0 ? ToPixel(matte, XmVERTICAL, (int) y)
	    : (dpheight - mw.height)/2 );
 
    if ( mw.x < 0 ) mw.x = 0;
    if ( mw.y < 0 ) mw.y = 0;

    x1 = FromPixel(matte, XmHORIZONTAL, mw.x );
    y1 = FromPixel(matte, XmVERTICAL,   mw.y );

    x1 += xorg;			/* JET - adjust for xinerama */
    y1 += yorg;


    i = 0;
    XtSetArg(argt[i], XmNx,			x1			); i++;
    XtSetArg(argt[i], XmNy,			y1			); i++;
    XtSetValues(matte, argt, i);


    /*
     * space the buttons horizontally. Start at the center of the matte
     * and allow them to grow towards the edges...
     */

    i = 0;
    XtSetArg(argt[i], XmNwidth,		&width				); i++;
    XtGetValues(matte1, argt, i);

    max_width = width;

    i = 0;
    XtSetArg(argt[i], XmNwidth,		&width				); i++;
    XtGetValues(clear_button, argt, i);
    
    space = max_width - 4*width;
    spacing = space/4;
    
    if (spacing < 12) spacing = 12;

    i = 0;
    XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
    XtSetArg(argt[i], XmNleftOffset, spacing/2); i++;
    XtSetValues(ok_button,  argt, i);

    i = 0;
    XtSetArg(argt[i], XmNleftAttachment,	XmATTACH_WIDGET		); i++;
    XtSetArg(argt[i], XmNleftWidget, ok_button); i++;
    XtSetArg(argt[i], XmNleftOffset, spacing); i++;
    XtSetValues(clear_button,  argt, i);

    i = 0;
    XtSetArg(argt[i], XmNleftAttachment,	XmATTACH_WIDGET		); i++;
    XtSetArg(argt[i], XmNleftWidget, clear_button); i++;
    XtSetArg(argt[i], XmNleftOffset, spacing); i++;
    XtSetValues(options_button,  argt, i);
    
    i = 0;
    XtSetArg(argt[i], XmNleftAttachment,	XmATTACH_WIDGET		); i++;
    XtSetArg(argt[i], XmNleftWidget, options_button); i++;
    XtSetArg(argt[i], XmNleftOffset, spacing); i++;
    XtSetValues(help_button,  argt, i);
    
    /*
     *  - adjust the copyright vertically to align top with login_matte...
     */

    if (copyright_msg) {
	XtQueryGeometry(copyright_msg, NULL, &geometry);
    
	i = 0;
	XtSetArg(argt[i], XmNshadowThickness,	&width			); i++;
	XtGetValues(copyright_msg, argt, i);

	width1 = ToPixel(copyright_msg, XmHORIZONTAL, width);
	width1 = (dpwidth - (int) geometry.width - 2 * width1)/2;

	x1 = FromPixel(copyright_msg, XmHORIZONTAL, width1);
	y1 = FromPixel(copyright_msg, XmVERTICAL, mw.y);

	i = 0;
	XtSetArg(argt[i], XmNdefaultPosition,	False			); i++;
	XtSetArg(argt[i], XmNx,			x1			); i++;
	XtSetArg(argt[i], XmNy,			y1			); i++;
	XtSetValues(copyright_msg, argt, i);
    }
}
Exemple #21
0
static void menu_nextprev_item(Widget w, XEvent *event, int incr)
{
    Widget old_active_entry;
    Widget new_active_entry = NULL;
    WidgetList children;
    Cardinal numChildren;
    int i = 0, found = 0, wrapped = 0;

    if (w != top_menu) {
#if MENU_DEBUG 
        printf("menu_nextprev_item_action: ignoring event, not top_menu\n");
#endif
        return;
    }

    /*
     * Find which smeBSB object is the active one.
     */
    XtVaGetValues(active_keyboard_menu, XtNchildren, &children,
                                        XtNnumChildren, &numChildren, NULL);

    /*
     * If there are not at least 2 children
     * then there is no point in even trying to go up or down.
     * Besides, might go out of the array's bounds.
     */
    if (numChildren < 2) {
        return;
    }

    old_active_entry = XawSimpleMenuGetActiveEntry(active_keyboard_menu);

    if (old_active_entry) {
        for (i = 0; i < numChildren; i++) {
            if (children[i] == old_active_entry) {
                found = 1;
                break;
            }
        }
    }

    /*
     * If no item was active, start at the top or the bottom.
     */
    if (!found) {
        i = (incr > 0) ? -incr : numChildren;
    }

    /*
     * Find the next sensitive item, going either up or down.
     * Note that we made the separator lines non-sensitive, just for this.
     * Do wrap around, but no more than once, that would be an endless loop.
     */
    while (wrapped < 2) {
        Boolean flag;

        i += incr;

        if (i < 0) {
            i = numChildren - 1;
            wrapped++;
        } else if (i >= numChildren) {
            i = 0;
            wrapped++;
        }

        XtVaGetValues(children[i], XtNsensitive, &flag, NULL);
        if (flag) {
            new_active_entry = children[i];
            break;
        }
    }

    if (new_active_entry && new_active_entry != old_active_entry) {
        XtWidgetGeometry geometry;
        int x, y;

        XtQueryGeometry(new_active_entry, NULL, &geometry);
        x = geometry.x + 1;
        y = geometry.y + 1;

        do_fake_motion(active_keyboard_menu, event, x, y);
    }
}
Exemple #22
0
int
main(int argc, char **argv)
{
    XtAppContext theApp;
    Widget toplevel;
    Widget butt;
    Pixmap Pix;
    Display *theDisplay;
    Window theRootWindow;
    Pixel fg,bg;
    Dimension mt, mb, ml, mr, mw, mh, st, ht;
    XtWidgetGeometry geo;

    toplevel = XtVaAppInitialize(&theApp, "toggle1", NULL, 0,
                                 &argc, argv, NULL, NULL);

    butt= XtVaCreateManagedWidget("Button1", xmToggleButtonWidgetClass, toplevel,
#if 0
                                  XmNindicatorOn, False,
#endif
                                  XmNshadowThickness, 5,
                                  XmNfillOnSelect, True,
                                  NULL);

    XtAddCallback(butt,XmNvalueChangedCallback,HiCB,NULL);

    XtRealizeWidget(toplevel);

    theDisplay = XtDisplay(toplevel);
    theRootWindow = XDefaultRootWindow(theDisplay);

    fg = XBlackPixelOfScreen(DefaultScreenOfDisplay(theDisplay));
    bg = XWhitePixelOfScreen(DefaultScreenOfDisplay(theDisplay));

    Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
                      "xlogo64",
                      fg, bg);
    if (Pix == XmUNSPECIFIED_PIXMAP)
        printf("PIX IS UNSPECIFIED\n");

    XtVaGetValues(butt,
                  XmNmarginTop, &mt, XmNmarginBottom, &mb,
                  XmNmarginLeft, &ml, XmNmarginRight, &mr,
                  XmNmarginWidth, &mw, XmNmarginHeight, &mh,
                  XmNshadowThickness, &st, XmNhighlightThickness, &ht,
                  NULL);
    printf("%d %d %d %d %d %d %d %d\n",
           mt, mb, ml, mr, mw, mh, st, ht);

    XtVaSetValues(butt,
#if 0
                  XmNlabelPixmap,Pix,
#endif
                  XmNlabelType, XmPIXMAP,
                  NULL);

    Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
                      "woman",
                      fg, bg);

    XtVaGetValues(butt,
                  XmNmarginTop, &mt, XmNmarginBottom, &mb,
                  XmNmarginLeft, &ml, XmNmarginRight, &mr,
                  XmNmarginWidth, &mw, XmNmarginHeight, &mh,
                  XmNshadowThickness, &st, XmNhighlightThickness, &ht,
                  NULL);
    printf("%d %d %d %d %d %d %d %d\n",
           mt, mb, ml, mr, mw, mh, st, ht);

    XtVaSetValues(butt,
                  XmNselectPixmap, Pix,
                  NULL);

    XtQueryGeometry(butt, NULL, &geo);
    printf("toggle wants: %d %d has %d %d\n",
           geo.width, geo.height, XtWidth(butt), XtHeight(butt));

    XtVaGetValues(butt,
                  XmNmarginTop, &mt, XmNmarginBottom, &mb,
                  XmNmarginLeft, &ml, XmNmarginRight, &mr,
                  XmNmarginWidth, &mw, XmNmarginHeight, &mh,
                  XmNshadowThickness, &st, XmNhighlightThickness, &ht,
                  NULL);
    printf("%d %d %d %d %d %d %d %d\n",
           mt, mb, ml, mr, mw, mh, st, ht);

    /* Note: the following values are the result of
     * querying the current geometry.
     */
    {
        static XtWidgetGeometry Expected[] = {
            CWWidth | CWHeight            ,  387,  402,   77,   45, 0,0,0, /* Button1 */
        };
        /* toplevel should be replaced with to correct applicationShell */
        PrintDetails(toplevel, Expected);
    }
    LessTifTestMainLoop(toplevel);

    exit(0);
}
Exemple #23
0
/****************************************************************
...
*****************************************************************/
void create_races_dialog(struct player *pplayer)
{
  int per_row = 5;
  int i, j, len, maxracelen, index, nat_count;
  char maxracename[MAX_LEN_NAME];
  char namebuf[64];
  int space;
  XtWidgetGeometry geom;

  races_player = pplayer;
  maxracelen = 0;
  nations_iterate(pnation) {
    if (is_nation_playable(pnation)) {
      len = strlen(nation_adjective_translation(pnation));
      maxracelen = MAX(maxracelen, len);
    }
  } nations_iterate_end;
  maxracelen = MIN(maxracelen, MAX_LEN_NAME-1);
  fc_snprintf(maxracename, sizeof(maxracename), "%*s", maxracelen+2, "W");

  races_dialog_shell = I_T(XtCreatePopupShell("racespopup", 
					  transientShellWidgetClass,
					  toplevel, NULL, 0));

  races_form = XtVaCreateManagedWidget("racesform", 
				       formWidgetClass, 
				       races_dialog_shell, NULL);   

  races_label = I_L(XtVaCreateManagedWidget("raceslabel", 
				       labelWidgetClass, 
				       races_form, NULL));  

  races_toggles_viewport =
    XtVaCreateManagedWidget("racestogglesviewport",
			    viewportWidgetClass,
			    races_form,
			    XtNfromVert, races_label,
			    NULL);

  races_toggles_form =
    XtVaCreateManagedWidget("racestogglesform",
			    formWidgetClass,
			    races_toggles_viewport,
			    NULL);

  free(races_toggles);
  races_toggles = fc_calloc(nation_count(), sizeof(Widget));
  free(races_toggles_to_nations);
  races_toggles_to_nations = fc_calloc(nation_count(),
				       sizeof(struct nation_type *));

  i = 0;
  j = 0;
  index = 0;
  nations_iterate(pnation) {
    if (!is_nation_playable(pnation)) {
      continue;
    }

    if (j == 0) {
      index = i * per_row;
      fc_snprintf(namebuf, sizeof(namebuf), "racestoggle%d", index);
      if (i == 0) {
	races_toggles[index] =
	  XtVaCreateManagedWidget(namebuf,
				  toggleWidgetClass,
				  races_toggles_form,
				  XtNlabel, maxracename,
				  NULL);
      } else {
	races_toggles[index] =
	  XtVaCreateManagedWidget(namebuf,
				  toggleWidgetClass,
				  races_toggles_form,
				  XtNradioGroup,
				  races_toggles[index - 1],
				  XtNfromVert,
				  races_toggles[index - per_row],
				  XtNlabel, maxracename,
				  NULL);
      }
    } else {
      index = i * per_row + j;
      fc_snprintf(namebuf, sizeof(namebuf), "racestoggle%d", index);
      if (i == 0) {
	races_toggles[index] =
	  XtVaCreateManagedWidget(namebuf,
				  toggleWidgetClass,
				  races_toggles_form,
				  XtNradioGroup,
				  races_toggles[index - 1],
				  XtNfromHoriz,
				  races_toggles[index - 1],
				  XtNlabel, maxracename,
				  NULL);
      } else {
	races_toggles[index] =
	  XtVaCreateManagedWidget(namebuf,
				  toggleWidgetClass,
				  races_toggles_form,
				  XtNradioGroup,
				  races_toggles[index - 1],
				  XtNfromVert,
				  races_toggles[index - per_row],
				  XtNfromHoriz,
				  races_toggles[index - 1],
				  XtNlabel, maxracename,
				  NULL);
      }
    }

    races_toggles_to_nations[index] = pnation;

    j++;
    if (j >= per_row) {
      j = 0;
      i++;
    }
  } nations_iterate_end;
  nat_count = index + 1;

  races_leader_form =
    XtVaCreateManagedWidget("racesleaderform",
			    formWidgetClass,
			    races_form,
			    XtNfromVert, races_toggles_viewport,
/*			    XtNfromHoriz, races_toggles_viewport,*/
			    NULL);

  XtVaGetValues(races_leader_form, XtNdefaultDistance, &space, NULL);
  XtQueryGeometry(races_toggles[0], NULL, &geom);
  races_leader =
    XtVaCreateManagedWidget("racesleader",
			    asciiTextWidgetClass,
			    races_leader_form,
			    XtNeditType, XawtextEdit,
			    XtNwidth,
			      space + 2*(geom.width + geom.border_width),
			    XtNstring, "",
			    NULL);

  races_leader_pick_popupmenu = 0;

  races_leader_pick_menubutton =
    I_L(XtVaCreateManagedWidget("racesleaderpickmenubutton",
				menuButtonWidgetClass,
				races_leader_form,
/*				XtNfromVert, races_leader,*/
				XtNfromHoriz, races_leader,
				NULL));

  races_sex_label = I_L(XtVaCreateManagedWidget("racessexlabel",
				            labelWidgetClass,
				            races_form,
					    XtNfromVert, races_leader_form,
					    NULL));

  races_sex_form = XtVaCreateManagedWidget("racessexform",
					   formWidgetClass,
					   races_form,
					   XtNfromVert, races_sex_label,
					   NULL);

  races_sex_toggles[0] =
    I_L(XtVaCreateManagedWidget("racessextoggle0",
				toggleWidgetClass,
				races_sex_form,
				NULL));

  races_sex_toggles[1] =
    I_L(XtVaCreateManagedWidget("racessextoggle1",
				toggleWidgetClass,
				races_sex_form,
				XtNfromHoriz,
				(XtArgVal)races_sex_toggles[0],
				XtNradioGroup,
				races_sex_toggles[0],
				NULL));

  /* find out styles that can be used at the game beginning */
  /* Limit of 64 city_styles should be deleted. -ev */
  for (i = 0, b_s_num = 0; i < game.control.styles_count && i < 64; i++) {
    if (!city_style_has_requirements(&city_styles[i])) {
      city_style_idx[b_s_num] = i;
      city_style_ridx[i] = b_s_num;
      b_s_num++;
    }
  }

  races_style_label =
    I_L(XtVaCreateManagedWidget("racesstylelabel", 
				labelWidgetClass, 
				races_form,
				XtNfromVert, races_sex_form,
/*				XtNfromHoriz, races_toggles_viewport,*/
				NULL));  

  races_style_form =
    XtVaCreateManagedWidget("racesstyleform", 
			    formWidgetClass, 
			    races_form, 
			    XtNfromVert, races_style_label,
/*			    XtNfromHoriz, races_toggles_viewport,*/
			    NULL);   

  free(races_style_toggles);
  races_style_toggles = fc_calloc(b_s_num,sizeof(Widget));

  for( i = 0; i < ((b_s_num-1)/per_row)+1; i++) {
    index = i * per_row;
    fc_snprintf(namebuf, sizeof(namebuf), "racesstyle%d", index);
    if( i == 0 ) {
      races_style_toggles[index] =
	XtVaCreateManagedWidget(namebuf,
				toggleWidgetClass,
				races_style_form,
				XtNlabel, maxracename,
				NULL);
    } else {
      races_style_toggles[index] =
	XtVaCreateManagedWidget(namebuf,
				toggleWidgetClass,
				races_style_form,
				XtNradioGroup,
				races_style_toggles[index-1],
				XtNfromVert,
				races_style_toggles[index-per_row],
				XtNlabel, maxracename,
				NULL);
    }

    for( j = 1; j < per_row; j++) {
      index = i * per_row + j;
      if( index >= b_s_num ) break;
      fc_snprintf(namebuf, sizeof(namebuf), "racesstyle%d", index);
      if( i == 0 ) {
	races_style_toggles[index] =
	  XtVaCreateManagedWidget(namebuf,
				  toggleWidgetClass,
				  races_style_form,
				  XtNradioGroup,
				  races_style_toggles[index-1],
				  XtNfromHoriz,
				  races_style_toggles[index-1],
				  XtNlabel, maxracename,
				  NULL);
      } else {
	races_style_toggles[index] =
	  XtVaCreateManagedWidget(namebuf,
				  toggleWidgetClass,
				  races_style_form,
				  XtNradioGroup,
				  races_style_toggles[index-1],
				  XtNfromVert,
				  races_style_toggles[index-per_row],
				  XtNfromHoriz,
				  races_style_toggles[index-1],
				  XtNlabel, maxracename,
				  NULL);
      }
    }
  }

  races_action_form = XtVaCreateManagedWidget("racesactionform",
					      formWidgetClass,
					      races_form,
					      XtNfromVert, races_style_form,
					      NULL);

  races_ok_command =
    I_L(XtVaCreateManagedWidget("racesokcommand",
				commandWidgetClass,
				races_action_form,
				NULL));

  races_random_command =
    I_L(XtVaCreateManagedWidget("racesdisconnectcommand",
				commandWidgetClass,
				races_action_form,
				XtNfromHoriz, races_ok_command,
				NULL));

  races_quit_command =
    I_L(XtVaCreateManagedWidget("racesquitcommand",
				commandWidgetClass,
				races_action_form,
				XtNfromHoriz, races_random_command,
				NULL));

  XtAddCallback(races_random_command, XtNcallback,
		races_random_command_callback, NULL);
  XtAddCallback(races_quit_command, XtNcallback,
		races_quit_command_callback, NULL);


  for (i = 0; i < nation_count(); i++) {
    if (races_toggles[i]) {
      XtAddCallback(races_toggles[i], XtNcallback,
		    races_toggles_callback, INT_TO_XTPOINTER(i));
    }
  }


  XtAddCallback(races_ok_command, XtNcallback,
		races_ok_command_callback, NULL);


  XtSetKeyboardFocus(races_form, races_leader);

  XtRealizeWidget(races_dialog_shell);

/*  for(i=0; i<game.control.playable_nation_count; i++) {
    races_toggles_to_nations[i] = i;
  }
*/
  qsort(races_toggles_to_nations, nat_count,
	sizeof(struct nation_type *), races_indirect_compare);

  /* Build nation_to_race_toggle */
  free(nation_idx_to_race_toggle);
  nation_idx_to_race_toggle =
      fc_calloc(nation_count(), sizeof(int));
  for (i = 0; i < nation_count(); i++) {
    nation_idx_to_race_toggle[i] = -1;
  }
  for (i = 0; i < nation_count(); i++) {
    if (races_toggles_to_nations[i]) {
      nation_idx_to_race_toggle[nation_index(races_toggles_to_nations[i])] = i;
    }
  }

  for (i = 0; i < nation_count(); i++) {
    if (races_toggles[i]) {
      XtVaSetValues(races_toggles[i],
		    XtNlabel,
		      (XtArgVal)nation_adjective_translation(races_toggles_to_nations[i]),
		    NULL);
    }
  }

  for(i=0; i<b_s_num; i++) {
    XtVaSetValues(races_style_toggles[i], XtNlabel,
		  (XtArgVal)city_style_name_translation(city_style_idx[i]), NULL);
  }

  select_random_race();
}
Exemple #24
0
/************************************************************************
 *
 *  ConfigureChildren
 *	Configure the title and work area if they aren't instigaror
 *      of the request (Yes policy). Compute the shadow location.
 *
 ************************************************************************/
static void 
ConfigureChildren(
	XmFrameWidget fw,
	Widget instigator,
	XtWidgetGeometry * inst_geometry)
{
    Widget child;
    XmFrameConstraint fc;
    Position childX = 0;
    Position childY;
    Dimension childWidth;
    Dimension childHeight;
    Dimension childBW;
    Dimension shadowThickness = fw->manager.shadow_thickness;
    Dimension titleExtent = shadowThickness;
    Dimension shadowHeight = fw->core.height;
    Position shadowY = 0;
    XtWidgetGeometry title_reply;
    Dimension spacing;

    if (fw->frame.title_area && XtIsManaged(fw->frame.title_area)) {
	child = fw->frame.title_area;
	fc = GetFrameConstraint(child);
	spacing = shadowThickness + fc->child_h_spacing;

	/* asking the preferred geometry without constraint */
	XtQueryGeometry (child, NULL, &title_reply);
	childWidth = (title_reply.request_mode & CWWidth) ?
			title_reply.width : child->core.width;
	childHeight = (title_reply.request_mode & CWHeight) ?
			title_reply.height : child->core.height;
	childBW = child->core.border_width;
	if (child == instigator) {
	    childWidth = (inst_geometry->request_mode & CWWidth) ?
			inst_geometry->width : childWidth;
	    childHeight = (inst_geometry->request_mode & CWHeight) ?
			inst_geometry->height : childHeight;
	    childBW = (inst_geometry->request_mode & CWBorderWidth) ?
			inst_geometry->border_width : childBW;
	}
	if (childWidth + 2 * (spacing + childBW) > fw->core.width) {
	    if (fw->core.width > 2 * (spacing + childBW))
		childWidth = fw->core.width - 2 * (spacing + childBW);
	    else
		childWidth = 1;
	}
	switch (fc->child_h_alignment) {
	    case(XmALIGNMENT_BEGINNING):
		if (LayoutIsRtoLM(fw))
		    childX = fw->core.width - spacing -
				childWidth - 2 * childBW;
		else
		    childX = spacing;
		break;
	    case(XmALIGNMENT_CENTER):
		childX = fw->core.width/2 - childWidth/2 - childBW;
	        break;
	    case(XmALIGNMENT_END):
	    default:
		if (LayoutIsRtoLM(fw))
		    childX = spacing;
		else
		    childX = fw->core.width - spacing -
				childWidth - 2 * childBW;
		break;
	}
	CalcTitleExtent (fw, childHeight, childBW,
				&titleExtent, &childY, &shadowHeight, &shadowY);

	if (child != instigator) {
	    XmeConfigureObject (child, childX, childY, childWidth,
				childHeight, childBW);
	}
	else {
	    /* Do not resize the instigator, just return GeometryYes */

	    inst_geometry->request_mode = CWX | CWY | CWWidth | CWHeight |
						CWBorderWidth;
	    child->core.x = childX; 
	    child->core.y = childY; 
	    child->core.width = childWidth; 
	    child->core.height = childHeight; 
	    child->core.border_width = childBW;
	}
    }

    if (fw->frame.work_area  && XtIsManaged(fw->frame.work_area)) {
	child = fw -> frame.work_area;
	if (child != instigator)
	    childBW = child->core.border_width;
	else
	    childBW = (inst_geometry->request_mode & CWBorderWidth) ?
		    inst_geometry->border_width : child->core.border_width;
	    
	CalcWorkAreaSize (fw, &childWidth, &childHeight, childBW,
			      fw->core.width, fw->core.height);
	childX = shadowThickness + fw->frame.margin_width;
	childY = titleExtent + fw->frame.margin_height;
	if (child != instigator) {
	    XmeConfigureObject (child, childX, childY, childWidth, childHeight,
				childBW);
	}
	else {
	    /* Do not resize the instigator, just return GeometryYes */

	    inst_geometry->request_mode = CWX | CWY | CWWidth | CWHeight |
						CWBorderWidth;
	    child->core.x = childX; 
	    child->core.y = childY; 
	    child->core.width = childWidth; 
	    child->core.height = childHeight; 
	    child->core.border_width = childBW;
	}   
    }

    fw->frame.old_shadow_x = 0;
    fw->frame.old_shadow_y = shadowY;
    fw->frame.old_width = fw->core.width;
    fw->frame.old_height = shadowHeight;
    fw->frame.old_shadow_thickness = shadowThickness;

}
static void
ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars)
{
    ViewportWidget w = (ViewportWidget)widget;
    Widget child = w->viewport.child;
    Widget clip = w->viewport.clip;
    ViewportConstraints constraints =
	(ViewportConstraints)clip->core.constraints;
    Bool needshoriz, needsvert;
    int clip_width, clip_height;
    XtWidgetGeometry intended;

    if (child == NULL)
	return;

    clip_width = XtWidth(w);
    clip_height = XtHeight(w);
    intended.request_mode = CWBorderWidth;
    intended.border_width = 0;

    if (w->viewport.forcebars) {
	needsvert = w->viewport.allowvert;
	needshoriz = w->viewport.allowhoriz;
	ComputeWithForceBars(widget, query, &intended,
			     &clip_width, &clip_height);
    }
    else {
	Dimension prev_width, prev_height;
	XtGeometryMask prev_mode;
	XtWidgetGeometry preferred;

	needshoriz = needsvert = False;

	/*
	 * intended.{width,height} caches the eventual child dimensions,
	 * but we don't set the mode bits until after we decide that the
	 * child's preferences are not acceptable
	 */
	if (!w->viewport.allowhoriz)
	    intended.request_mode |= CWWidth;

	if (XtWidth(child) < clip_width)
	    intended.width = clip_width;
	else
	    intended.width = XtWidth(child);

	if (XtHeight(child) < clip_height)
	    intended.height = clip_height;
	else
	    intended.height = XtHeight(child);

	if (!w->viewport.allowvert)
	    intended.request_mode |= CWHeight;

	if (!query) {
	    preferred.width = XtWidth(child);
	    preferred.height = XtHeight(child);
	}
	do { /* while intended != prev  */
	    if (query) {
		(void)XtQueryGeometry(child, &intended, &preferred);
		if (!(preferred.request_mode & CWWidth))
		    preferred.width = intended.width;
		if (!(preferred.request_mode & CWHeight))
		    preferred.height = intended.height;
	    }
	    prev_width = intended.width;
	    prev_height = intended.height;
	    prev_mode = intended.request_mode;
	    /*
	     * note that having once decided to turn on either bar
	     * we'll not change our mind until we're next resized,
	     * thus avoiding potential oscillations
	     */
#define CheckHoriz() \
	    if (w->viewport.allowhoriz &&				\
		preferred.width > clip_width) {				\
		if (!needshoriz) {					\
		    Widget bar;						\
									\
		    needshoriz = True;					\
		    if ((bar = w->viewport.horiz_bar) == NULL)		\
			bar = CreateScrollbar(w, True);			\
		    clip_height -= XtHeight(bar) + XtBorderWidth(bar);	\
		    if (clip_height < 1)				\
			clip_height = 1;				\
		}							\
		intended.width = preferred.width;			\
	    }

	    CheckHoriz();
	    if (w->viewport.allowvert && preferred.height > clip_height) {
		if (!needsvert) {
		    Widget bar;
		    needsvert = True;
		    if ((bar = w->viewport.vert_bar) == NULL)
			bar = CreateScrollbar(w, False);
		    clip_width -= XtWidth(bar) + XtBorderWidth(bar);
		    if (clip_width < 1)
			clip_width = 1;
		    CheckHoriz();
		}
		intended.height = preferred.height;
	    }
	    if (!w->viewport.allowhoriz || preferred.width < clip_width) {
		intended.width = clip_width;
		intended.request_mode |= CWWidth;
	    }
	    if (!w->viewport.allowvert || preferred.height < clip_height) {
		intended.height = clip_height;
		intended.request_mode |= CWHeight;
	    }
	} while (intended.request_mode != prev_mode
		 || (intended.request_mode & CWWidth
		     && intended.width != prev_width)
		 || (intended.request_mode & CWHeight
		     && intended.height != prev_height));
    }

    if (XtIsRealized(clip))
	XRaiseWindow(XtDisplay(clip), XtWindow(clip));

    XtMoveWidget(clip,
		 needsvert ? w->viewport.useright ? 0 :
		 XtWidth(w->viewport.vert_bar)
		 + XtBorderWidth(w->viewport.vert_bar) : 0,
		 needshoriz ? w->viewport.usebottom ? 0 :
		 XtHeight(w->viewport.horiz_bar)
		 + XtBorderWidth(w->viewport.horiz_bar) : 0);
    XtResizeWidget(clip, clip_width, clip_height, 0);

    if (w->viewport.horiz_bar != NULL) {
	Widget bar = w->viewport.horiz_bar;

	if (!needshoriz) {
	    constraints->form.vert_base = NULL;
	    if (destroy_scrollbars) {
		XtDestroyWidget(bar);
		w->viewport.horiz_bar = NULL;
	    }
	}
	else {
	    int bw = XtBorderWidth(bar);

	    XtResizeWidget(bar, clip_width, XtHeight(bar), bw);
	    XtMoveWidget(bar,
			 needsvert && !w->viewport.useright
			 ? XtWidth(w->viewport.vert_bar) : -bw,
			 w->viewport.usebottom
			 ? XtHeight(w) - XtHeight(bar) - bw : -bw);
	    XtSetMappedWhenManaged(bar, True);
	}
    }

    if (w->viewport.vert_bar != NULL) {
	Widget bar = w->viewport.vert_bar;

	if (!needsvert)	{
	    constraints->form.horiz_base = NULL;
	    if (destroy_scrollbars) {
		XtDestroyWidget(bar);
		w->viewport.vert_bar = NULL;
	    }
	}
	else {
	    int bw = bar->core.border_width;

	    XtResizeWidget(bar, XtWidth(bar), clip_height, bw);
	    XtMoveWidget(bar,
			w->viewport.useright
			? XtWidth(w) - XtWidth(bar) - bw : -bw,
			needshoriz && !w->viewport.usebottom
			? XtHeight(w->viewport.horiz_bar) : -bw);
	   XtSetMappedWhenManaged(bar, True);
	}
    }

    if (child != NULL) {
	XtResizeWidget(child, intended.width, intended.height, 0);
	MoveChild(w, needshoriz ? XtX(child) : 0,	needsvert ? XtY(child) : 0);
    }

    SendReport (w, XawPRAll);
}
Exemple #26
0
/************************************************************************
 *									*
 *  GeometryManager							*
 *									*
 ************************************************************************/
static XtGeometryResult 
GeometryManager(
        Widget w,
        XtWidgetGeometry *request,
        XtWidgetGeometry *reply )
{
    CompositeWidgetClass superclass = (CompositeWidgetClass)
	                xmMainWindowClassRec.core_class.superclass ;
    XmMainWindowWidget mw = (XmMainWindowWidget ) w->core.parent;
    XtGeometryResult res;
    Dimension	    newWidth,newHeight, OldHeight;
    Dimension	    bw;
    XtWidgetGeometry  parent_request ;
    XtWidgetGeometry  desired, preferred;
    XtWidgetProc resize;


    CheckKids(mw);

/****************
 *
 * If it's not a mainwindow kid, let the scrolled window deal with it.
 * If it's from the workwindow, and the width changed, resize the menubar
 * and ask for a new height so my layout routine doesn't clip the workwindow.
 *
 ****************/
    if (w != mw->mwindow.MenuBar && 
        w != mw->mwindow.Message &&
        w != mw->mwindow.CommandWindow &&
        w != (Widget )mw->mwindow.Sep1 && 
        w != (Widget) mw->mwindow.Sep2 &&
        w != (Widget) mw->mwindow.Sep3) {

	/* this is the only case of geometry manager enveloping that
	   I know of in Motif */

	XtGeometryHandler geo_mgr;
	_XmProcessLock();
	geo_mgr = superclass->composite_class.geometry_manager;
	_XmProcessUnlock();

        res = (*geo_mgr)(w, request, reply);

        if (res == XtGeometryYes) {

	    Widget mb = mw->mwindow.MenuBar;

	    if ((w == mw->swindow.WorkWindow) && 
                (request->request_mode & CWWidth) && 
                mb && XtIsManaged(mb)) {
                desired.x = mb->core.x;	
	        desired.y = mb->core.y;
	        desired.border_width = mb->core.border_width;
                desired.width = mw->core.width - 
                                (2 * mw->mwindow.margin_width);
                desired.height = mb->core.height;
                desired.request_mode = (CWWidth);
                XtQueryGeometry(mw->mwindow.MenuBar, &desired, &preferred);
                if (preferred.height != mb->core.height) {
                    parent_request.request_mode = CWWidth | CWHeight;
		    if (request->request_mode & XtCWQueryOnly) 
			parent_request.request_mode |= XtCWQueryOnly;
		    parent_request.width = mw->core.width ;
		    parent_request.height = newHeight = mw->core.height - 
			(mb->core.height - (2 * mb->core.border_width)) +
			    preferred.height + (2 *preferred.border_width);
                    if (XtMakeGeometryRequest((Widget) mw, 
					      &parent_request, NULL)
                        == XtGeometryYes) {
			if (!(request->request_mode & XtCWQueryOnly))
			    XmeConfigureObject(mw->mwindow.MenuBar, 
					       mb->core.x, mb->core.y,
					       preferred.width, preferred.height,
					       preferred.border_width);
			else return XtGeometryYes ;
		    }
		}
	    }
	    _XmProcessLock();
	    resize = XtCoreProc(mw, resize);
	    _XmProcessUnlock();
	    (*resize)((Widget)mw) ;
	}
	return(res);
    }
    
    /** Disallow any X or Y changes for MainW children **/
    if ((request -> request_mode & CWX || request -> request_mode & CWY))
	return(XtGeometryNo);


    if(request->request_mode & CWBorderWidth)
	bw = request->border_width;
    else
        bw = w->core.border_width;

    if (request->request_mode & CWWidth) 
	newWidth = request->width + 2 * (bw + mw->mwindow.margin_width);
    else
        newWidth = mw->core.width ;

    /* grow only in width */
    if (newWidth <= mw->core.width) newWidth = mw->core.width;
     
/****************
*
 * Margins are already included in the old width & height
 *
 ****************/
     if(request->request_mode & CWHeight)
         newHeight = mw->core.height - 
	             (w->core.height - (2 * w->core.border_width)) +
	    	     request->height + 2 * bw;
    else 
         newHeight = mw->core.height;

    OldHeight = mw->core.height;
        
    parent_request.request_mode = CWWidth | CWHeight;
    if (request->request_mode & XtCWQueryOnly) 
	parent_request.request_mode |= XtCWQueryOnly;
    parent_request.width = newWidth ;
    parent_request.height = newHeight;

    res = XtMakeGeometryRequest((Widget) mw, &parent_request, NULL) ;

    if (res == XtGeometryYes) {
	if (!(request->request_mode & XtCWQueryOnly)) {
	    if(request->request_mode & CWWidth)
		w->core.width = request->width;
	    if(request->request_mode & CWHeight)
		w->core.height = request->height;

	    mw->swindow.YOffset = mw->swindow.YOffset +
		(newHeight - OldHeight);

	    _XmProcessLock();
	    resize = XtCoreProc(mw, resize);
	    _XmProcessUnlock();
	    (*resize) ((Widget)mw) ;
	}
    }

    return(res);
}
Exemple #27
0
void
AttachArea::initialize()
{

    // We're making the assumption here that this widget's parent`
    // is also a form

    XtWidgetGeometry size;
    Dimension parWid, parHeight;
    Dimension txt_w, txt_h;
    XmFontList fl;
    XmString xms;

    int         colorUse;
    short       act, inact, prim, second, text;
    XmPixelSet  pixels[XmCO_NUM_COLORS];


    _w = XtVaCreateManagedWidget (
			"AttachPane",
			xmFormWidgetClass, _parent, 
			NULL);

    // Get pixel data.
    XmeGetColorObjData(XtScreen(_parent), &colorUse, pixels, XmCO_NUM_COLORS,
		       &act, &inact, &prim, &second, &text);
    _foreground = pixels[text].fg;
    _background = pixels[text].sc;

    parWid = _myOwner->textEditor()->get_text_width();

    fl = _myOwner->textEditor()->get_text_fontList();
    xms = XmStringCreateLocalized("Xyb");
    XmStringExtent(fl, xms, &txt_w, &txt_h);
    parHeight = txt_h + Icon::maxIconHeight() + (2*VSPACE);

    _appBackground = _background;
    _appForeground = _foreground;

    _sw = XtVaCreateManagedWidget ( 
				    "AttachPane_ScrolledWindow", 
				    xmScrolledWindowWidgetClass, _w, 
				    XmNscrollingPolicy,  XmAPPLICATION_DEFINED,
				    XmNrightAttachment,  XmATTACH_FORM,
				    XmNleftAttachment,   XmATTACH_FORM,
				    XmNtopAttachment,    XmATTACH_FORM,
		    		    XmNshadowThickness, (Dimension)1,
				    XmNspacing, 2,
				    XmNwidth,	     parWid,
				    XmNheight,	     parHeight,
				    NULL);

    rowOfAttachmentsStatus = XtCreateManagedWidget("Attachments_Status",
				xmFormWidgetClass,
				_w, NULL, 0);

     XtVaSetValues(rowOfAttachmentsStatus,
  	XmNrightAttachment,	XmATTACH_FORM, 
  	XmNleftAttachment,	XmATTACH_FORM, 
 	XmNtopAttachment,       XmATTACH_WIDGET,
 	XmNtopWidget,	        _sw,
 	XmNtopOffset,		5,
	XmNbottomOffset,	5,
 	NULL );

    this->addToRowOfAttachmentsStatus();

    size.request_mode = CWHeight;
    XtQueryGeometry(rowOfAttachmentsStatus, NULL, &size);

    XtVaSetValues(
	rowOfAttachmentsStatus,
	XmNpaneMaximum, size.height,
	XmNpaneMinimum, size.height,
	NULL
    );

    _vsb = XtVaCreateManagedWidget("vsb", xmScrollBarWidgetClass, _sw,
		    XmNorientation, XmVERTICAL,
		    XmNsliderSize, 1,
		    XmNmaximum, 1,
		    XmNpageIncrement, 1,
		    NULL);

    XtAddCallback(
	_vsb, 
	XmNvalueChangedCallback,&AttachArea::valueChangedCallback,
	(XtPointer) this 
    );

    XtAddCallback(
	_vsb, 
	XmNdragCallback, &AttachArea::dragCallback,
	(XtPointer) this 
    );

    _clipWindow = XtVaCreateManagedWidget("AttachArea_clipWindow", 
		    xmDrawingAreaWidgetClass, _sw,
		    XmNresizePolicy, XmRESIZE_NONE,
		    XmNbackground, _background,
		    XmNwidth,	     parWid,
		    XmNheight,	     parHeight,
		    NULL);
    XmScrolledWindowSetAreas(_sw, NULL, _vsb, _clipWindow);

    XtManageChild(_clipWindow);
    XtManageChild(_vsb);
    XtManageChild(_sw);

    
    // Set RowCol to NULL here.
    // It gets set in the expose_all_attachments.

    _rc = NULL;

    CalcSizeOfAttachPane();

    installDestroyHandler();
}
/*
 * Function:
 *	ComputeWithForceBars
 *
 * Parameters:
 *	widget	    - viewport widget
 *	query	    - whether or not to query the child
 *	intended    - cache of the childs height is stored here
 *		      (used and returned)
 *	clip_width  - size of clip window (used and returned)
 *	clip_height - ""
 *
 * Description:
 *	Computes the layout give forcebars is set.
 */
static void
ComputeWithForceBars(Widget widget, Bool query, XtWidgetGeometry *intended,
		     int *clip_width, int *clip_height)
{
    ViewportWidget w = (ViewportWidget)widget;
    Widget child = w->viewport.child;
    XtWidgetGeometry preferred;

    /*
     * If forcebars then needs = allows = has
     * Thus if needsvert is set it MUST have a scrollbar
     */
    if (w->viewport.allowvert) {
	if (w->viewport.vert_bar == NULL)
	    w->viewport.vert_bar = CreateScrollbar(w, False);

	*clip_width -= XtWidth(w->viewport.vert_bar) +
		       XtBorderWidth(w->viewport.vert_bar);
    }

    if (w->viewport.allowhoriz) {
	if (w->viewport.horiz_bar == NULL)
	    w->viewport.horiz_bar = CreateScrollbar(w, True);

	*clip_height -= XtHeight(w->viewport.horiz_bar) +
			XtBorderWidth(w->viewport.horiz_bar);
    }

    AssignMax(*clip_width, 1);
    AssignMax(*clip_height, 1);

    if (!w->viewport.allowvert) {
	intended->height = *clip_height;
	intended->request_mode = CWHeight;
    }
    if (!w->viewport.allowhoriz) {
	intended->width = *clip_width;
	intended->request_mode = CWWidth;
    }

    if (query) {
	if (w->viewport.allowvert || w->viewport.allowhoriz) {
	    XtQueryGeometry(child, intended, &preferred);

	    if (!(intended->request_mode & CWWidth)) {
		if (preferred.request_mode & CWWidth)
		    intended->width = preferred.width;
		else
		    intended->width = XtWidth(child);
	    }

	    if (!(intended->request_mode & CWHeight)) {
		if (preferred.request_mode & CWHeight)
		    intended->height = preferred.height;
		else
		    intended->height = XtHeight(child);
	    }
	}
    }
    else {
	if (w->viewport.allowvert)
	    intended->height = XtHeight(child);
	if (w->viewport.allowhoriz)
	    intended->width = XtWidth(child);
    }

    if (*clip_width > (int)intended->width)
	intended->width = *clip_width;
    if (*clip_height > (int)intended->height)
	intended->height = *clip_height;
}
Exemple #29
0
//
// Create the guts of the dialog
//
Widget
FindDialog::createWorkArea(Widget dialog)
{
  // TODO - CHECK ERROR!!!
  Widget *label = new Widget[_num_text_fields]; 


  register unsigned int		offset;

  _name = GETMSG(DT_catd, 1, 192, "Mailer - Find");

  title(_name);

	// make this a modal dialog
	/*
	XtVaSetValues (dialog,
			XmNdialogStyle,	XmDIALOG_FULL_APPLICATION_MODAL,
			NULL);
	*/

  	printHelpId("dialog", dialog);

  /* add help callback */
  // XtAddCallback(dialog, XmNhelpCallback, HelpCB, helpId);

	Widget fd_pane = XtVaCreateWidget ("fd_pane",
				xmPanedWindowWidgetClass,
				dialog,
				XmNsashWidth,	1,
				XmNsashHeight,	1,
				NULL);

	printHelpId ("fd_pane", fd_pane);
	// add help callback
	// XtAddCallback (fd_pane, XmNhelpCallback, HelpCB, helpId);

	Widget	fd_form = XtVaCreateWidget ("fd_form",
				xmFormWidgetClass,
				fd_pane,
				XmNfractionBase,	100,
				NULL);

	printHelpId ("fd_form", fd_form);
	// add help callback
	// XtAddCallback (fd_form, XmNhelpCallback, HelpCB, helpId);


	Widget _fd_labelbox = XtVaCreateManagedWidget ("_fd_labelbox",
				xmRowColumnWidgetClass,
				fd_form,
				XmNtopAttachment,	XmATTACH_FORM,
				XmNleftAttachment,	XmATTACH_POSITION,
				XmNrightAttachment,	XmATTACH_POSITION,
				XmNleftPosition,	5,
				XmNrightPosition,	95,
				XmNpacking,		XmPACK_COLUMN,
				XmNnumColumns,		2,
				XmNorientation,		XmVERTICAL,
				XmNisAligned,		True,
				XmNentryAlignment,	XmALIGNMENT_END,
				XmNentryVerticalAlignment,	XmALIGNMENT_CENTER,
				NULL); 
	printHelpId ("_fd_labelbox", _fd_labelbox);
	// add help callback
	// XtAddCallback (_fd_labelbox, XmNhelpCallback, HelpCB, helpId);


	Widget	*_fd_labels = new Widget [_num_text_fields];

	int	_fd_i = 0;
	for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
	{
		_fd_labels [_fd_i] = XtVaCreateManagedWidget (
					_text_labels [_fd_i],
					xmLabelGadgetClass,
					_fd_labelbox,
					NULL);

		printHelpId ("_fd_labels [%s]", _fd_labels [_fd_i]);
		// naturally, this is bogus --must be fixed to return proper label
		// add help callback
		// XtAddCallback(_fd_labels [_fd_i], XmNhelpCallback, HelpCB, helpId);
	}

	for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
	{
		_text_fields [_fd_i] = XtVaCreateManagedWidget (
					_text_names [_fd_i],
					xmTextFieldWidgetClass,
					_fd_labelbox,
					NULL);
		printHelpId ("_text_fields [%s]", _text_fields [_fd_i]);
		// naturally, this is bogus --must be fixed to return proper label
		// add help callback
		// XtAddCallback(_text_fields [_fd_i], XmNhelpCallback, HelpCB, helpId);

		XtAddCallback(_text_fields [_fd_i], XmNactivateCallback,
			(XtCallbackProc)textFieldCallback, (XtPointer)this);
	}


  XmString	strForward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 193, "Forward"));
  XmString	strBackward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 194, "Backward"));

  Widget fd_direction
	= XmVaCreateSimpleRadioBox(fd_form,
				"Direction",
			       0,		// Initial selection
			       directionCallback,
				//NULL,
			       XmVaRADIOBUTTON, strForward, NULL, NULL, NULL,
			       XmVaRADIOBUTTON, strBackward, NULL, NULL, NULL,
			       XmNuserData,	this,
				XmNsensitive,	True,
				XmNtopAttachment,	XmATTACH_WIDGET,
				XmNtopWidget,		_fd_labelbox,
				XmNorientation,	XmHORIZONTAL,
				XmNleftAttachment,	XmATTACH_POSITION,
				XmNleftPosition,	33,
			       NULL);
	 printHelpId ("fd_direction", fd_direction);
	// add help callback
	//XtAddCallback (fd_direction, XmNhelpCallback, HelpCB, helpId);

  XmStringFree(strForward);
  XmStringFree(strBackward);

  //
  // Now create the Action Area.
  //
#define TIGHTNESS	20

  register Widget		widget;

  Widget fd_action = XtVaCreateWidget("actionArea",
				 xmFormWidgetClass,
				 fd_pane,
				 XmNleftAttachment,	XmATTACH_FORM,
				 XmNrightAttachment,	XmATTACH_FORM,
				 XmNfractionBase, TIGHTNESS * _num_buttons-1,
				 NULL);
	 printHelpId ("actionArea", fd_action);
	// add help callback
	//XtAddCallback (fd_action, XmNhelpCallback, HelpCB, helpId);

  for (offset = 0; offset < _num_buttons; offset++) 
  {  widget = XtVaCreateManagedWidget(_buttonData[offset].label,
				     xmPushButtonWidgetClass,	fd_action,

				     XmNleftAttachment,
				     offset ? XmATTACH_POSITION:XmATTACH_FORM,

				     XmNleftPosition,	TIGHTNESS * offset,
				     XmNtopAttachment,	XmATTACH_FORM,

				     XmNrightAttachment,
				     offset != _num_buttons - 1 ? XmATTACH_POSITION : XmATTACH_FORM,

				     XmNrightPosition,
				     TIGHTNESS * offset + (TIGHTNESS - 1),

				     XmNshowAsDefault,	offset == 0,
				     NULL);

	// again, bogus -- doesn't each one need a unique tag?
	 printHelpId ("widget", widget);
	// add help callback
	//XtAddCallback (widget, XmNhelpCallback, HelpCB, helpId);

    if (_buttonData[offset].callback != NULL) {
      XtAddCallback(widget, XmNactivateCallback,
		    _buttonData[offset].callback,
		    _buttonData[offset].data);
    }


    if (offset == 0) {
      Dimension		height;
      Dimension		margin;

      XtVaGetValues(fd_action, XmNmarginHeight, &margin, NULL);
      XtVaGetValues(widget, XmNheight, &height, NULL);
      height +=2 * margin;
      XtVaSetValues(fd_action,
		    XmNdefaultButton,	widget,
		    XmNpaneMaximum,	height,
		    XmNpaneMinimum,	height,
		    NULL);

    }
  }

  _status_text = XtVaCreateManagedWidget("StatusLabel",
					   xmLabelWidgetClass, fd_pane,
                                           XmNrightAttachment, XmATTACH_FORM,
                                           XmNleftAttachment, XmATTACH_FORM,
                                           XmNalignment, XmALIGNMENT_BEGINNING,
                                           NULL);
	    
  Dimension height;
  XtWidgetGeometry size;

  size.request_mode = CWHeight;
  XtQueryGeometry(_status_text, NULL, &size);
  XtVaSetValues(_status_text,
		XmNpaneMaximum, size.height,
		XmNpaneMinimum, size.height,
		NULL);
 
  clearStatus();

  XtManageChild (fd_form);
  XtManageChild (fd_direction);
  XtManageChild(fd_action);
  XtManageChild(fd_pane);

  XtManageChild(dialog);

  // Make sure get the height of the dialog after it has been
  // managed.
  XtVaGetValues(dialog, XmNheight, &height, NULL);
  XtVaSetValues(dialog, 
		XmNmappedWhenManaged, True,
		XmNminHeight, height,
		NULL);
  XtRealizeWidget(dialog);

  return (fd_pane);
}
Exemple #30
0
static void
initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args)
{
    Dimension h;

#ifdef DEBUG
    printf("NumEntry - initialize(%s) - %i args\n", XtName(new_w), *num_args);
#endif
    XtHeight(new_w) = 0;
    XtWidth(new_w) = 0;
    NumEntry_Value(new_w) = XtNewString(NumEntry_Value(new_w));
    NumEntry_Label(new_w) = XmCreateLabel(new_w, "Label", NULL, 0);
    if (NumEntry_LabelString(new_w) == NULL)
    {
	NumEntry_LabelString(new_w) = XmStringCreateSimple(XtName(new_w));
    }
    XtVaSetValues(NumEntry_Label(new_w),
		  XmNlabelString, NumEntry_LabelString(new_w),
		  NULL);
    XtOverrideTranslations(NumEntry_Label(new_w), XtParseTranslationTable(tm_table));
    XtManageChild(NumEntry_Label(new_w));
    XtHeight(new_w) = XtHeight(new_w) > XtHeight(NumEntry_Label(new_w)) ? XtHeight(new_w) : XtHeight(NumEntry_Label(new_w));
    XtWidth(new_w) += XtWidth(NumEntry_Label(new_w));

    NumEntry_TextField(new_w) = XmCreateTextField(new_w, "Text", NULL, 0);
    XtAddCallback(NumEntry_TextField(new_w), XmNvalueChangedCallback, (XtCallbackProc)ValueChange, (XtPointer)NULL);
    XtAddCallback(NumEntry_TextField(new_w), XmNactivateCallback, (XtCallbackProc)Activate, (XtPointer)NULL);
    XtAddCallback(NumEntry_TextField(new_w), XmNlosingFocusCallback, (XtCallbackProc)LosingFocus, (XtPointer)NULL);
    XtVaSetValues(NumEntry_TextField(new_w),
		  XmNvalue, NumEntry_Value(new_w),
		  XmNcolumns, NumEntry_Columns(new_w),
		  NULL);
    XtOverrideTranslations(NumEntry_TextField(new_w), XtParseTranslationTable(tm_table));
    XtOverrideTranslations(NumEntry_TextField(new_w), XtParseTranslationTable(text_tm_table));
    XtManageChild(NumEntry_TextField(new_w));
    XtHeight(new_w) = XtHeight(new_w) > XtHeight(NumEntry_TextField(new_w)) ? XtHeight(new_w) : XtHeight(NumEntry_TextField(new_w));
    XtWidth(new_w) += XtWidth(NumEntry_TextField(new_w));
    h = XtHeight(new_w);
    h = (h * 2) / 3;
    NumEntry_RowColumn(new_w) = XmCreateRowColumn(new_w, "RowCol", NULL, 0);
    XtVaSetValues(NumEntry_RowColumn(new_w),
		  XmNtraversalOn, False,
		  XmNpacking, XmPACK_COLUMN,
		  XmNorientation, XmHORIZONTAL,
		  XmNnumColumns, 1,
		  NULL);
    XtOverrideTranslations(NumEntry_RowColumn(new_w), XtParseTranslationTable(tm_table));
    NumEntry_UpArrow(new_w) = XmCreateArrowButton(NumEntry_RowColumn(new_w), "UpArrow", NULL, 0);
    XtAddCallback(NumEntry_UpArrow(new_w), XmNactivateCallback, (XtCallbackProc)StepValue, (XtPointer)1);
    XtAddCallback(NumEntry_UpArrow(new_w), XmNarmCallback, (XtCallbackProc)AutoRepeat, (XtPointer)True);
    XtAddCallback(NumEntry_UpArrow(new_w), XmNdisarmCallback, (XtCallbackProc)AutoRepeat, (XtPointer)False);
    XtVaSetValues(NumEntry_UpArrow(new_w),
		  XmNwidth, h,
		  XmNarrowDirection, XmARROW_UP,
		  NULL);
    XtOverrideTranslations(NumEntry_UpArrow(new_w), XtParseTranslationTable(tm_table));
    XtManageChild(NumEntry_UpArrow(new_w));
    NumEntry_DnArrow(new_w) = XmCreateArrowButton(NumEntry_RowColumn(new_w), "DnArrow", NULL, 0);
    XtAddCallback(NumEntry_DnArrow(new_w), XmNactivateCallback, (XtCallbackProc)StepValue, (XtPointer)-1);
    XtAddCallback(NumEntry_DnArrow(new_w), XmNarmCallback, (XtCallbackProc)AutoRepeat, (XtPointer)True);
    XtAddCallback(NumEntry_DnArrow(new_w), XmNdisarmCallback, (XtCallbackProc)AutoRepeat, (XtPointer)False);
    XtVaSetValues(NumEntry_DnArrow(new_w),
		  XmNwidth, h,
		  XmNarrowDirection, XmARROW_DOWN,
		  NULL);
    XtOverrideTranslations(NumEntry_DnArrow(new_w), XtParseTranslationTable(tm_table));
    XtManageChild(NumEntry_DnArrow(new_w));
    XtVaSetValues(NumEntry_RowColumn(new_w),
		  XmNtopAttachment, XmATTACH_FORM,
		  XmNbottomAttachment, XmATTACH_FORM,
		  XmNleftAttachment, XmATTACH_NONE,
		  XmNrightAttachment, XmATTACH_FORM,
		  NULL);
    XtVaSetValues(NumEntry_TextField(new_w),
		  XmNtopAttachment, XmATTACH_FORM,
		  XmNbottomAttachment, XmATTACH_FORM,
		  XmNleftAttachment, XmATTACH_NONE,
		  XmNrightAttachment, XmATTACH_WIDGET,
		  XmNrightWidget, NumEntry_RowColumn(new_w),
		  NULL);
    XtVaSetValues(NumEntry_Label(new_w),
		  XmNalignment, XmALIGNMENT_BEGINNING,
		  XmNtopAttachment, XmATTACH_FORM,
		  XmNbottomAttachment, XmATTACH_FORM,
		  XmNleftAttachment, XmATTACH_FORM,
		  XmNrightAttachment, XmATTACH_WIDGET,
		  XmNrightWidget, NumEntry_TextField(new_w),
		  NULL);
    {
    XtWidgetGeometry pref;

	XtQueryGeometry(NumEntry_RowColumn(new_w), NULL, &pref);
	XtWidth(new_w) += pref.width;
    }
    XtManageChild(NumEntry_RowColumn(new_w));
    XtAddCallback(new_w, XmNhelpCallback, (XtCallbackProc)Help, NULL);
    NumEntry_TimerId(new_w) = (XtIntervalId)NULL;
    NumEntry_Result(new_w) = XltCalc(NumEntry_Value(new_w));
}