예제 #1
0
static XtPointer*
get_im_info_ptr(Widget  w,
                Boolean create)
{
  Widget p;
  XmVendorShellExtObject ve;
  XmWidgetExtData extData;
  XmImShellInfo im_info;
  XmImDisplayInfo xim_info;

  if (w == NULL)
    return NULL;

  p = w;
  while (!XtIsShell(p))
    p = XtParent(p);

  /* Check extension data since app could be attempting to create
   * a text widget as child of menu shell.  This is illegal, and will
   * be detected later, but check here so we don't core dump.
   */
  if ((extData = _XmGetWidgetExtData((Widget)p, XmSHELL_EXTENSION)) == NULL)
    return NULL;

  ve = (XmVendorShellExtObject) extData->widget;

  return &ve->vendor.im_info;
}
예제 #2
0
/************************************************************************
 * saveKeybd()
 *
 * This routine will write out to the passed file descriptor any state
 * information this dialog needs.  It is called from saveSessionCB with the
 * file already opened.
 * All information is saved in xrm format.  There is no restriction
 * on what can be saved.  It doesn't have to be defined or be part of any
 * widget or Xt definition.  Just name and save it here and recover it in
 * restoreBackdrop.  The suggested minimum is whether you are mapped, and your
 * location.
 ************************************************************************/
void 
saveKeybd(
        int fd )
{
    Position x,y;
    char *bufr = style.tmpBigStr;     /* size=[1024], make bigger if needed */
    XmVendorShellExtObject  vendorExt;
    XmWidgetExtData         extData;

    if (style.kbdDialog != NULL) 
    {
        if (XtIsManaged(style.kbdDialog))
            sprintf(bufr, "*keyboardDlg.ismapped: True\n");
        else
            sprintf(bufr, "*keyboardDlg.ismapped: False\n");

        /* Get and write out the geometry info for our Window */
        x = XtX(XtParent(style.kbdDialog));
        y = XtY(XtParent(style.kbdDialog));

        /* Modify x & y to take into account window mgr frames
         * This is pretty bogus, but I don't know a better way to do it.
         */
        extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
        vendorExt = (XmVendorShellExtObject)extData->widget;
        x -= vendorExt->vendor.xOffset;
        y -= vendorExt->vendor.yOffset;

        sprintf(bufr, "%s*keyboardDlg.x: %d\n", bufr, x);
        sprintf(bufr, "%s*keyboardDlg.y: %d\n", bufr, y);

        write (fd, bufr, strlen(bufr));
    }
}
예제 #3
0
/*ARGSUSED*/
static Boolean 
SetValues(Widget old,
	  Widget ref,
	  Widget new_w,
	  ArgList args,
	  Cardinal *num_args)
{
  XmExtObject	  ne = (XmExtObject) new_w;
  Widget	  resParent = ne->ext.logicalParent;
  XmWidgetExtData ext = _XmGetWidgetExtData(resParent, ne->ext.extensionType);
  Cardinal	  extSize;
  
  if (resParent)
    {
      _XmProcessLock();
      extSize = XtClass(new_w)->core_class.widget_size;
      
      ext->widget = new_w;
      
      ext->oldWidget = (Widget) _XmExtObjAlloc(extSize);
      memcpy((char *)ext->oldWidget, (char *)old, extSize); 
      
      ext->reqWidget = (Widget) _XmExtObjAlloc(extSize);
      memcpy((char *)ext->reqWidget, (char *)ref, extSize); 
      _XmProcessUnlock();

      /* Convert the necessary fields from unit values to pixel values. */
      _XmExtImportArgs(new_w, args, num_args);
    }

  return FALSE;
}
예제 #4
0
static void 
GetValuesHook(Widget new_w,
	      ArgList args,
	      Cardinal *num_args)
{
  XmExtObject     ne = (XmExtObject) new_w;
  Widget          resParent = ne->ext.logicalParent;
  XmWidgetExtData ext;
  
  if (resParent)
    {
      ext = _XmGetWidgetExtData(resParent, ne->ext.extensionType);
      
      ext->widget = new_w;
      
      _XmExtGetValuesHook(new_w, args, num_args);
    }
}
예제 #5
0
파일: I18nMain.c 프로젝트: juddy/edcde
/************************************************************************
 * saveI18n()
 *
 * This routine will write out to the passed file descriptor any state
 * information this dialog needs.  It is called from saveSessionCB with the
 * file already opened.
 * All information is saved in xrm format.  There is no restriction
 * on what can be saved.  It doesn't have to be defined or be part of any
 * widget or Xt definition.  Just name and save it here and recover it in
 * restoreBackdrop.  The suggested minimum is whether you are mapped, and your
 * location.
 ************************************************************************/
void 
saveI18n(
        int fd )
{
    Position x,y;
    Dimension width, height;
    char *bufr = style.tmpBigStr;     /* size=[1024], make bigger if needed */
    XmVendorShellExtObject  vendorExt;
    XmWidgetExtData         extData;

    if (style.i18nDialog != NULL) 
    {
        if (XtIsManaged(style.i18nDialog))
            sprintf(bufr, "*i18nDlg.ismapped: True\n");
        else
            sprintf(bufr, "*i18nDlg.ismapped: False\n");

	/* Get and write out the geometry info for our Window */
	x = XtX(XtParent(style.i18nDialog));
	y = XtY(XtParent(style.i18nDialog));

        /* Modify x & y to take into account window mgr frames
         * This is pretty bogus, but I don't know a better way to do it.
         */
        extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
        vendorExt = (XmVendorShellExtObject)extData->widget;
        x -= vendorExt->vendor.xOffset;
        y -= vendorExt->vendor.yOffset;

	width = XtWidth(style.i18nDialog);
	height = XtHeight(style.i18nDialog);

	sprintf(bufr, "%s*i18nDlg.x: %d\n", bufr, x);
	sprintf(bufr, "%s*i18nDlg.y: %d\n", bufr, y);
	sprintf(bufr, "%s*i18nDlg.width: %d\n", bufr, width);
	sprintf(bufr, "%s*i18nDlg.height: %d\n", bufr, height);
	if(-1 == write (fd, bufr, strlen(bufr))) {
		perror(strerror(errno));
	}
    }
}
예제 #6
0
static XmICStruct *
get_iclist(Widget w)
{
    Widget p;
    XmVendorShellExtObject ve;
    XmWidgetExtData extData;
    XmImInfo *im_info;

    p = w;
    while (!XtIsShell(p))
	p = XtParent(p);

    extData = (XmWidgetExtData)_XmGetWidgetExtData((Widget) p, XmSHELL_EXTENSION);
    if (extData == NULL)
	return NULL;

    ve = (XmVendorShellExtObject) extData->widget;
    if ((im_info = (XmImInfo *) ve->vendor.im_info) == NULL)
	return NULL;
    else
	return im_info->iclist;
}
예제 #7
0
XVaNestedList awt_motif_getXICStatusAreaList(Widget w, jobject tc)
{
    Widget p;
    XmVendorShellExtObject ve;
    XmWidgetExtData extData;
    XmImInfo *im_info;
    XmICStruct *icp;

    XVaNestedList list = NULL;
    XRectangle  *ssgeometry = &geometryRect;
    Pixel  bg;
    Pixel  fg;
    Pixmap bpm;
    Dimension height,width;
    Position  x,y;

    p = w;
    while (!XtIsShell(p)){
	p = XtParent(p);
    }

    XtVaGetValues(p,
		  XmNx, &x,
		  XmNy, &y,
		  XmNwidth, &width,
		  XmNheight, &height,
		  NULL);

    extData = (XmWidgetExtData)_XmGetWidgetExtData((Widget) p, XmSHELL_EXTENSION);
    if (extData == NULL) {
	return NULL;
    }

    ve = (XmVendorShellExtObject) extData->widget;
    if ((im_info = (XmImInfo *) ve->vendor.im_info) == NULL) {
	return NULL;         
    } else
	icp = im_info->iclist;


    if (icp) {
	/*
	 * We hava at least a textfield/textarea in the frame, use the
	 * first one.
	 */
	ssgeometry->x = 0;
	ssgeometry->y = height - icp->status_height;
	ssgeometry->width = icp->status_width;
	ssgeometry->height = icp->status_height;

	/*
	 * use motif TextComponent's resource
	 */
	fg = icp->foreground;
	bg = icp->background;
	bpm = icp->background_pixmap;

	list = XVaCreateNestedList(0, 
			XNFontSet, extract_fontset((XmFontList)icp->font_list),
			XNArea, ssgeometry, 
			XNBackground, bg, 
			XNForeground, fg, 
			XNBackgroundPixmap, bpm, 
			NULL);
   }
    return list ;
}
예제 #8
0
int32_t
awt_motif_getIMStatusHeight(Widget vw, jobject tc)
{
    XmICStruct *icp;
    XmVendorShellExtObject ve;
    XmWidgetExtData extData;
    XmImInfo *im_info;
    int32_t width = 0;
    int32_t height = 0;
    XRectangle rect;
    XRectangle *rp;
    int32_t old_height;
    Arg args[1];
    int32_t base_height;
    XFontSet fs;
    XFontSet fss = NULL;
    XFontSet fsp = NULL;

    extData = (XmWidgetExtData)_XmGetWidgetExtData((Widget) vw, XmSHELL_EXTENSION);
    ve = (XmVendorShellExtObject) extData->widget;

    if ((icp = get_iclist(vw)) == NULL) {
	ve->vendor.im_height = 0;
	return 0;
    }
    im_info = (XmImInfo *) ve->vendor.im_info;
    if (im_info->xic == NULL) {
	ve->vendor.im_height = 0;
	return 0;
    }
    status_vlist[0].name = XNFontSet;
    status_vlist[1].name = NULL;
    preedit_vlist[0].name = XNFontSet;
    preedit_vlist[1].name = NULL;

    xic_vlist[0].name = XNAreaNeeded;
    xic_vlist[1].name = NULL;

    im_info->status_width = 0;
    im_info->status_height = 0;
    im_info->preedit_width = 0;
    im_info->preedit_height = 0;
    for (; icp != NULL; icp = icp->next) {
	if (im_info->input_style & XIMStatusArea) {
	    if (icp->status_height == 0) {
		char *ret;

		if (icp->font_list == NO_ARG_VAL ||
		    (fss = extract_fontset((XmFontList) icp->font_list)) == NULL)
		    continue;

		status_vlist[0].value = (XtArgVal) fss;
		XSetICValues(im_info->xic,
			     XNStatusAttributes, &status_vlist[0],
			     NULL);

		xic_vlist[0].value = (XtArgVal) & rp;
		ret = XGetICValues(im_info->xic,
				   XNStatusAttributes, &xic_vlist[0],
				   NULL);

		if (ret) {
		    /* Cannot obtain XIC value. IM server may be gone. */
		    ve->vendor.im_height = 0;
		    return 0;
		} else {
		    icp->status_width = rp->width;
		    icp->status_height = rp->height;
		    XFree(rp);
		}
	    }
	    if (icp->status_width > im_info->status_width)
		im_info->status_width = icp->status_width;
	    if (icp->status_height > im_info->status_height)
		im_info->status_height = icp->status_height;
	}
	if (im_info->input_style & XIMPreeditArea) {
	    if (icp->preedit_height == 0) {
		if (icp->font_list == NO_ARG_VAL ||
		    (fsp = extract_fontset((XmFontList) icp->font_list)) == NULL)
		    continue;

		preedit_vlist[0].value = (XtArgVal) fsp;
		XSetICValues(im_info->xic,
			     XNPreeditAttributes, &preedit_vlist[0],
			     NULL);

		xic_vlist[0].value = (XtArgVal) & rp;
		XGetICValues(im_info->xic,
			     XNPreeditAttributes, &xic_vlist[0],
			     NULL);

		icp->preedit_width = rp->width;
		icp->preedit_height = rp->height;
		XFree(rp);
	    }
	    if (icp->preedit_width > im_info->preedit_width)
		im_info->preedit_width = icp->preedit_width;
	    if (icp->preedit_height > im_info->preedit_height)
		im_info->preedit_height = icp->preedit_height;
	}
    }

    if (im_info->current != NULL && (fss != NULL || fsp != NULL)) {
	if (im_info->current->font_list != NO_ARG_VAL &&
	    (fs = extract_fontset((XmFontList) im_info->current->font_list))
	    != NULL) {
	    if (fss != NULL)
		status_vlist[0].value = (XtArgVal) fs;
	    else
		status_vlist[0].name = NULL;
	    if (fsp != NULL)
		preedit_vlist[0].value = (XtArgVal) fs;
	    else
		preedit_vlist[0].name = NULL;
	    XSetICValues(im_info->xic,
			 XNStatusAttributes, &status_vlist[0],
			 XNPreeditAttributes, &preedit_vlist[0],
			 NULL);
	}
    }
    if (im_info->status_height > im_info->preedit_height)
	height = im_info->status_height;
    else
	height = im_info->preedit_height;
    old_height = ve->vendor.im_height;
    if (height)
	height += SEPARATOR_HEIGHT;

    ve->vendor.im_height = height;

    XtSetArg(args[0], XtNbaseHeight, &base_height);
    XtGetValues(vw, args, 1);
    if (base_height < 0)
	base_height = 0;
    XtSetArg(args[0], XtNbaseHeight, base_height);
    XtSetValues(vw, args, 1);
    return height;
}
예제 #9
0
파일: utils.c 프로젝트: juddy/edcde
void
_DtChildPosition(
    Widget w,
    Widget parent,
    Position *newX,
    Position *newY)
{
    Position pY, pX;
    XmVendorShellExtObject vendorExt;
    XmWidgetExtData        extData;
    int xOffset, yOffset;
    int pHeight, myHeight, sHeight;
    int pWidth, myWidth, sWidth;
    enum { posRight, posBelow, posLeft, posAbove } pos;
    int space;

    /* get x, y offsets for the parent's window frame */
    extData = _XmGetWidgetExtData(parent, XmSHELL_EXTENSION);
    if (extData)
    {
        vendorExt = (XmVendorShellExtObject)extData->widget;
        xOffset = vendorExt->vendor.xOffset;
        yOffset = vendorExt->vendor.yOffset;
    }
    else
        xOffset = yOffset = 0;

    /* get size/position of screen, parent, and widget */
    sHeight = HeightOfScreen(XtScreen(parent));;
    sWidth = WidthOfScreen(XtScreen(parent));
    pX = XtX(parent) - xOffset;
    pY = XtY(parent) - yOffset;
    pHeight = XtHeight(parent) + yOffset + xOffset;
    pWidth = XtWidth(parent) + 2*xOffset;
    myHeight = XtHeight(w) + yOffset + xOffset;
    myWidth = XtWidth(w) + 2*xOffset;

    {
        XWindowAttributes attr;

        XGetWindowAttributes(XtDisplay(parent), XtWindow(parent), &attr);
    }

    /*
     * Determine how much space would be left if the child was positioned
     * to the right, below, left, or above the parent.  Choose the child
     * positioning so that the maximum space is left.
     */
    pos = posRight;
    space = sWidth - (pX + pWidth + myWidth);

    if (sHeight - (pY + pHeight + myHeight) > space)
    {
        pos = posBelow;
        space = sHeight - (pY + pHeight + myHeight);
    }

    if (pX - myWidth > space)
    {
        pos = posLeft;
        space = pX - myWidth;
    }

    if (pY - myHeight > space)
    {
        pos = posAbove;
        space = pY - myHeight;
    }

    /* Given relative positioning, determine x, y coordinates for the child */

    switch (pos)
    {
    case posRight:
        *newX = pX + pWidth + 5;
        *newY = pY + (pHeight - myHeight)/2;
        break;

    case posBelow:
        *newX = pX + (pWidth - myWidth)/2;
        *newY = pY + pHeight + 5;
        break;

    case posLeft:
        *newX = pX - myWidth - 5;
        *newY = pY + (pHeight - myHeight)/2;
        break;

    case posAbove:
        *newX = pX + (pWidth - myWidth)/2;
        *newY = pY - myHeight - 5;
        break;
    }
}
예제 #10
0
XVaNestedList awt_util_getXICStatusAreaList(Widget w)
{
    XIC xic;
    XmImXICInfo icp;
    XmVendorShellExtObject ve;
    XmWidgetExtData extData;
    XmImShellInfo im_info;
    XmFontList fl=NULL;

    XRectangle  *ssgeometry = &geometryRect;
    XRectangle geomRect ;
    XRectangle *im_rect;
    XFontSet   *im_font;

    Pixel bg ;
    Pixel fg ;
    Dimension height, width ;
    Position x,y ;
    Pixmap bpm, *bpmout ;

    XVaNestedList list = NULL;

    char *ret;
    Widget p=w;

    while (!XtIsShell(p)) {
        p = XtParent(p);
    }

    XtVaGetValues(p,
        XmNx, &x,
        XmNy, &y,
        XmNwidth, &width,
        XmNheight, &height,
        XmNbackgroundPixmap, &bpm,
        NULL);

    extData = _XmGetWidgetExtData((Widget) p, XmSHELL_EXTENSION);
    if (extData == NULL) {
        return NULL;
    }
    ve = (XmVendorShellExtObject) extData->widget;
    im_info = get_im_info(w, False);

    if (im_info == NULL) {
        return NULL;
    } else {
        icp = im_info->iclist;
    }

    if (icp) {
        /*
         * We have at least a textfield/textarea in the frame, use the
         * first one.
         */
        ssgeometry->x = 0;
        ssgeometry->y = height - icp->sp_height;
        ssgeometry->width = icp->status_width;
        ssgeometry->height = icp->sp_height;
        XtVaGetValues(w, XmNbackground, &bg, NULL);
        XtVaGetValues(w, XmNforeground, &fg, NULL);
        XtVaGetValues(w, XmNfontList, &fl, NULL);
        /*
         * use motif TextComponent's resource
         */

        list = XVaCreateNestedList(0,
                        XNFontSet, extract_fontset(fl),
                        XNArea, ssgeometry,
                        XNBackground, bg,
                        XNForeground, fg,
                        NULL);
   }
   return list ;
}
예제 #11
0
/************************************************************************
 *
 * SaveMain - saves the parameters associated with a Pad's mainWindow
 *	(called from SaveSessionCB() below).
 *
 ***********************************************************************/
void 
SaveMain(
        Editor *pPad,
        int padNum,
        int fd)
{
    char bufr[1024];
    Position x,y;
    Dimension width, height;
    Atom *pWsPresence;
    unsigned long numInfo;
    Atom actual_type;
    int  actual_format;
    unsigned long nitems;
    unsigned long leftover;
    WM_STATE * wm_state;

    if(pPad->mainWindow != (Widget)NULL) 
    {
        XmVendorShellExtObject vendorExt;
        XmWidgetExtData        extData;

        if(XtIsRealized(pPad->mainWindow))
	    sprintf(bufr,"*mainWindow%d.ismapped: True\n", padNum);

        /* Get and write out the geometry info for our Window */
        x = XtX(XtParent(pPad->mainWindow));
        y = XtY(XtParent(pPad->mainWindow));

	/*
         * Modify x & y to take into account window mgr frames
	 * This is pretty bogus, but I don't know a better way to do it.
	 */
        extData = _XmGetWidgetExtData(pPad->app_shell, XmSHELL_EXTENSION);
        vendorExt = (XmVendorShellExtObject)extData->widget;
        x -= vendorExt->vendor.xOffset;
        y -= vendorExt->vendor.yOffset;

	width = XtWidth(XtParent(pPad->mainWindow));
	height = XtHeight(XtParent(pPad->mainWindow));

        sprintf(bufr, "%s*mainWindow%d.x: %d\n", bufr, padNum, x);
        sprintf(bufr, "%s*mainWindow%d.y: %d\n", bufr, padNum, y);
        sprintf(bufr, "%s*mainWindow%d.width: %d\n", bufr, padNum, width);
        sprintf(bufr, "%s*mainWindow%d.height: %d\n", bufr, padNum, height);

        wm_state_atom = XmInternAtom (XtDisplay(pPad->app_shell), "WM_STATE", 
                                      False);
        /*  Getting the WM_STATE property to see if iconified or not */
        XGetWindowProperty (XtDisplay(pPad->app_shell), 
                            XtWindow (pPad->app_shell),
                            wm_state_atom, 0L, (long) BUFSIZ, False,
                            wm_state_atom, &actual_type, &actual_format,
                            &nitems, &leftover, (unsigned char **) &wm_state);

        /* Write out if iconified our not */
        sprintf(bufr, "%s*mainWindow%d.iconify: ", bufr, padNum);

        if (wm_state->state == IconicState)
          sprintf (bufr, "%sTrue\n", bufr);
        else
          sprintf (bufr, "%sFalse\n", bufr);

	if(DtWsmGetWorkspacesOccupied(XtDisplay(pPad->app_shell), 
				  XtWindow(pPad->app_shell), &pWsPresence,
				  &numInfo) == Success)
	{
	    int i;
	    sprintf(bufr, "%s*mainWindow%d.workspaceList: ", bufr, padNum);
	    for(i = 0; i < numInfo; i++)
	    {
	        char *name =  XGetAtomName(XtDisplay(pPad->app_shell),
					   pWsPresence[i]);
		sprintf(bufr, "%s %s", bufr, name);
		XtFree(name);
	    }
	    sprintf(bufr, "%s\n", bufr);
	    XtFree((char *)pWsPresence);
	}

        write (fd, bufr, strlen(bufr));
    }
    if(pPad->fileStuff.fileName != (char *)NULL)
    {
	sprintf(bufr, "*mainWindow%d.fileName: %s\n", padNum, 
		pPad->fileStuff.fileName);
        write (fd, bufr, strlen(bufr));
    }
}
예제 #12
0
/*ARGSUSED*/
static XtGeometryResult 
GeometryManager(
        Widget wid,
        XtWidgetGeometry *request,
        XtWidgetGeometry *reply ) /* unused */
{
    ShellWidget 	shell = (ShellWidget)(wid->core.parent);
    XtWidgetGeometry 	my_request;
    XmVendorShellExtObject ve;
    XmWidgetExtData   extData;

    extData = _XmGetWidgetExtData((Widget)shell, XmSHELL_EXTENSION);
    ve = (XmVendorShellExtObject) extData->widget;

    if(!(shell->shell.allow_shell_resize) && XtIsRealized(wid) &&
       (request->request_mode & (CWWidth | CWHeight | CWBorderWidth)))
      return(XtGeometryNo);

    
    /*
     * Because of our klutzy API we mimic position requests on the
     * dialog to ourselves. 
     * We cannot check for the trait here since it isn't done only for 
     * BB. DialogShell GM behavior is to always follow position requests
     * even if the child is not dialogShellSavvy.
     */

    my_request.request_mode = 0;

    /* %%% worry about XtCWQueryOnly */
    if (request->request_mode & XtCWQueryOnly)
      my_request.request_mode |= XtCWQueryOnly;

    /* Here we have a tricky bit of code.
       If the SetValues on the bb child position was 0,
       which is always the current position of the bb, Xt will
       not see a change and therefore not trigerred a geometry request.
       So BB (or any dialogShellSavvy child) has to catch this case
       and change the position request to use a special value,
       XmDIALOG_SAVVY_FORCE_ORIGIN, to notify the Dialog that it wants
       to move in 0 */

    if (request->request_mode & CWX) {
	if (request->x == XmDIALOG_SAVVY_FORCE_ORIGIN)
	  my_request.x = 0;
	else
	  my_request.x = request->x;
	my_request.request_mode |= CWX;
    }
    if (request->request_mode & CWY) {
	if (request->y == XmDIALOG_SAVVY_FORCE_ORIGIN)
	  my_request.y = 0;
	else
	  my_request.y = request->y;
	my_request.request_mode |= CWY;
    }

    if (request->request_mode & CWWidth) {
	my_request.width = request->width;
	my_request.request_mode |= CWWidth;
    }
    if (request->request_mode & CWHeight) {
        if (!ve->vendor.im_height)
          _XmImResize((Widget)shell); /* updates im_height */
	my_request.height = request->height + ve->vendor.im_height;
	my_request.request_mode |= CWHeight;
    }
    if (request->request_mode & CWBorderWidth) {
	my_request.border_width = request->border_width;
	my_request.request_mode |= CWBorderWidth;
    }

    if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
	== XtGeometryYes) {
          if (!(request->request_mode & XtCWQueryOnly)) {
	      /* just report the size changes to the kid, not
		 the dialog position itself, but reply yes
		 anyway */
	      if (my_request.request_mode & CWWidth)
		  wid->core.width = my_request.width ;
	      _XmImResize((Widget)shell);
	      if (my_request.request_mode & CWHeight)
		  wid->core.height = my_request.height - ve->vendor.im_height;
	  }
	  return XtGeometryYes;
      } else 
	  return XtGeometryNo;
}
예제 #13
0
/*
 * border width and size and location are ty...
 *
 * 1. We allow the border width of a XmDialogShell child to change
 *    size arbitrarily.
 *
 * 2. The border width of the shell widget tracks the child's
 *    at all times, exactly.
 *
 * 3. The width of the shell is kept exactly the same as the
 *    width of the child at all times.
 *
 * 4. The child is always positioned at the location
 *    (- child_border, - child_border).
 *
 * the net result is the child has a border width which is always
 * what the user asked for;  but none of it is ever seen, it's all
 * clipped by the shell (parent).  The user sees the border
 * of the shell which is the size he set the child's border to.
 *
 * In the DEC window manager world the window manager does
 * exactly the same thing with the window it puts around the shell.
 * Hence the shell and child have a border width just as the user
 * set but the window manager overrides that and only a single
 * pixel border is displayed.  In a non-wm environment the child 
 * appears to have a border width, in reality this is the shell
 * widget border.  You wanted to know...
 */
static void 
ChangeManaged(
        Widget wid )
{
    XmDialogShellWidget shell = (XmDialogShellWidget) wid ;
    /*
     *  If the child went to unmanaged, call XtPopdown.
     *  If the child went to managed, call XtPopup.
     */
    
    Widget	 child;
    XmWidgetExtData		extData = 
	_XmGetWidgetExtData((Widget) shell, XmSHELL_EXTENSION);
    XmVendorShellExtObject ve = (XmVendorShellExtObject)extData->widget;
    XmDialogSavvyTrait trait ;


    if (((child = GetRectObjKid((CompositeWidget) shell)) == NULL) ||
	(child->core.being_destroyed))
	return;



    trait = (XmDialogSavvyTrait) 
      XmeTraitGet((XtPointer) XtClass(child), XmQTdialogShellSavvy) ;
    
    /* MANAGED Case first ********/
    if (child->core.managed)  {
	XtWidgetGeometry	request;
	Position		kidX, kidY;
	Dimension		kidBW;
	Boolean		defaultPosition = True;

	/*
	 * temporary workaround for setkeyboard focus |||
	 */
	if (child != ve->vendor.old_managed)
	    {
		XtSetKeyboardFocus((Widget)shell, (Widget)child);
		ve->vendor.old_managed = (Widget)child;
	    }

	/* 
	 * if the child isn't realized, then we need to realize it
	 * so we have a valid size. It will get created as a result
	 * so we  zero out it's position info so it'll
	 * be okay and then restore it.
	 */
	if (!XtIsRealized(child)) {
	    kidX = XtX(child);
	    kidY = XtY(child);
	    kidBW = XtBorderWidth(child);
		
	    XtX(child) = 0;
	    XtY(child) = 0;
	    XtBorderWidth(child) = 0;
		
	    /* Bug 4102306, This is an additional difference brought forward from motif 1.2 */
	    if (XtHeight(shell) != XtHeight(child))
	    {
		_XmImChangeManaged((Widget)shell);
	    }
	    /* End fix for Bug 4012306 */

	    XtRealizeWidget(child);
		
	    XtX(child) = kidX;
	    XtY(child) = kidY;
	    XtBorderWidth(child) = kidBW;
	}
	  
	else if (trait) {
	    /*  
	     *  Move the window to 0,0
	     *  but don't tell the widget.  It thinks it's where
	     *  the shell is...
	     */
	    if ((XtX(child) != 0) || (XtY(child) != 0))
		XMoveWindow (XtDisplay(child), XtWindow(child), 0, 0);
	}

	/*
	 * map callback should occur BEFORE child default positioning
	 * otherwise, widgets such as fileselection using map callback for
	 * correct sizing have default positioning done before the widget 
	 * grows to its correct dimensions
	 */

	if(shell->core.mapped_when_managed && trait ) { 
	    trait->callMapUnmapCB(child, True);	 /* call Map callback */
	}	

	/* 
	 * Make sure that the shell has the same common parameters as 
	 * its child.  Then move the child so that the shell will 
	 * correctly surround it.
	 */
	request.request_mode = 0;
	
	if (trait) {
	    XtVaGetValues(child, XmNdefaultPosition, &defaultPosition, NULL);

	    if (defaultPosition && (ve->vendor.externalReposition)) {
		defaultPosition = False;
		XtVaSetValues(child, XmNdefaultPosition, False, NULL);
	    }
	}

	if (XtX(child) && trait) {
	    kidX = XtX(child);
	    XtX(child) = 0;
	} else
	    kidX = XtX(shell);
	
	if (XtY(child) && trait) {
	    kidY = XtY(child);
	    XtY(child) = 0;
	} else
	    kidY = XtY(shell);

	if (XtBorderWidth(child) && trait) {
	    kidBW = XtBorderWidth(child);
	    XtBorderWidth(child) = 0;
	} else
	    kidBW = XtBorderWidth(shell);
	

	if (XtWidth (child) != XtWidth (shell)) {
	    request.request_mode |= CWWidth;
	    request.width = XtWidth(child);
	}

	if (XtHeight (child) + ve->vendor.im_height != XtHeight (shell)) {
	    request.request_mode |= CWHeight;
	    request.height = XtHeight(child) + ve->vendor.im_height;
	}
	
	if (trait) {
	    if (defaultPosition)  {
		GetDefaultPosition(child,
				   XtParent(shell),
				   &request.x,
				   &request.y);
		if (request.x != kidX) request.request_mode |= CWX;
		if (request.y != kidY) request.request_mode |= CWY;
	    } else {
		if (kidX != XtX(shell)) {
		    request.request_mode |= CWX;
		    if (kidX == XmDIALOG_SAVVY_FORCE_ORIGIN)
			request.x = 0;
		    else
			request.x = kidX;
		}
		if (kidY != XtY(shell)) {
		    request.request_mode |= CWY;
		    if (kidY == XmDIALOG_SAVVY_FORCE_ORIGIN)
			request.y = 0;
		    else
			request.y = kidY;
		}
	    }
	} else {
	    if (kidX != XtX(shell)) {
		request.request_mode |= CWX;
		request.x = kidX;
	    }
	    if (kidY != XtY(shell)) {
		request.request_mode |= CWY;
		request.y = kidY;
	    }
	    if (kidBW != XtBorderWidth(shell)) {
		request.request_mode |= CWBorderWidth;
		request.border_width = kidBW;
	    }
	}

	if (request.request_mode) {
	    unsigned int old_height = ve->vendor.im_height;
	    XtMakeGeometryRequest((Widget) shell, &request, &request);
	    _XmImResize((Widget)shell);
            if (ve->vendor.im_height != old_height)
            {
               request.request_mode = CWHeight;
               request.height = XtHeight(child) + ve->vendor.im_height;
               XtMakeGeometryRequest((Widget) shell, &request, &request);
               _XmImResize((Widget)shell);
            }
	}
	
	/*
	 * the grab_kind is handled in the popup_callback
	 */
	if(shell->core.mapped_when_managed    ) {   
	    XtPopup  ((Widget) shell, XtGrabNone);
	} 
    }


    /*
     * CHILD BEING UNMANAGED
     */
    else {
        int i, j;
	/*
	 * Fix for CR5043, CR5758 and CR8825 -
	 * For nested Dialog Shells, it is necessary to unmanage
	 * dialog shell popups of the child of this dialog shell.
	 */
	for (i = 0; i < child->core.num_popups; i++) {
	  if (XmIsDialogShell(child->core.popup_list[i])) {
	    XmDialogShellWidget next_shell = 
	      (XmDialogShellWidget)(child->core.popup_list[i]);

	    for (j = 0; j < next_shell->composite.num_children; j++) {
	      XtUnmanageChild(next_shell->composite.children[j]);
	    }
	  }
	}
	/* End Fix CR5043, CR5758 and CR8825 */
	    
	/*
	 * take it down and then tell user
	 */
	    
	XtPopdown((Widget) shell);
	    
	if(trait ) { 
	    trait->callMapUnmapCB(child, False); /* call UnMap callback */
	}	
    }

    XmeNavigChangeManaged((Widget) shell);
}