コード例 #1
0
ファイル: Panner.c プロジェクト: unix-junkie/motif
/* ARGSUSED */
static void 
Initialize (Widget greq, Widget gset, ArgList args, Cardinal *num_args)
{
    XmPannerWidget req = (XmPannerWidget) greq, set = (XmPannerWidget) gset;
    Dimension defwidth, defheight;

#ifdef DEMO
    _XmInitialIzeConverters(greq);
#endif

    XmPanner_private(set) =
	(XmPannerPrivateData *)XtCalloc(1, sizeof(XmPannerPrivateData));
    
    ASSIGN_MAX(XmPanner_canvas_width(req), 1);
    ASSIGN_MAX(XmPanner_canvas_height(req), 1);

    if (XmPanner_default_scale(req) < 1)
      XmPanner_default_scale(set) = XmPannerDefaultScale;

    GetDefaultSize (req, &defwidth, &defheight);

    if (req->core.width < 1) 
	set->core.width = defwidth;

    if (req->core.height < 1) 
	set->core.height = defheight;

    XmPanner_slider_gc(set) = XmPanner_xor_gc(set) = NULL;

    ResetSliderGC (set);		/* foreground */
    ResetXorGC (set);			/* foreground ^ background */

    Rescale(set);			/* does a position check */

    XmPanner_tmp(set).doing = FALSE;
    XmPanner_tmp(set).showing = FALSE;
}
コード例 #2
0
ファイル: IconBox.c プロジェクト: CPFDSoftware-Tony/gmv
/*ARGSUSED*/
static XtGeometryResult
GeometryManager(Widget w, XtWidgetGeometry * request, 
		XtWidgetGeometry * result)
{
    Dimension cwidth, cheight;
    XmIconBoxWidget ibw = (XmIconBoxWidget) XtParent(w);
    IconInfo * info = GetIconInfo(w);
    Boolean w_req = (request->request_mode & CWWidth);
    Boolean h_req = (request->request_mode & CWHeight);
    Boolean x_req = (request->request_mode & CWX);
    Boolean y_req = (request->request_mode & CWY);

    if (!(request->request_mode & (CWWidth | CWHeight | CWX | CWY)))
	return(XtGeometryNo);
    
    result->request_mode = 0;

    if (w_req || h_req) {
	CalcCellSizes((Widget) ibw, w, FALSE, TRUE, &cwidth, &cheight);

	if(w_req)
	    ASSIGN_MAX(cwidth, request->width);
	else
	    ASSIGN_MAX(cwidth, w->core.width);
	
	if(h_req)
	    ASSIGN_MAX(cheight, request->height);
	else
	    ASSIGN_MAX(cheight, w->core.height);

	/*
	 * Do not allow an x, y width and height request at the same time.
	 * since it is unclear what this would mean.  I want to place the
	 * widget in the cell the center of it is over.  With a multiple
	 * request like this is it tough to find out which cell to use
	 * since there are two reasonable values for height and width.
	 */

	result->x = w->core.x;
	result->y = w->core.y;
	result->width  = cwidth;
	result->height = cheight;
	result->request_mode |= CWX | CWY | CWHeight | CWWidth;
    }
    else if ( x_req || y_req ) {
	Position x, y;
	short cell_x, cell_y;

	if (x_req) 
	    x = request->x;
	else
	    x = w->core.x;

	if (y_req)
	    y = request->y;
	else
	    y = w->core.y;

	FindNearestCellLocation((Widget) ibw, &x, &y);

	GetCellFromXY((Widget) ibw, x, y, &cell_x, &cell_y);
	if (XmIconBoxIsCellEmpty((Widget) ibw, cell_x, cell_y, w)) {
	    result->x = x;
	    result->y = y;
	    result->request_mode |= CWX | CWY;
	}
	else			/* Cell is full, return NO. */
	    return(XtGeometryNo);
    }

    if (((request->x == result->x) || !x_req) &&
	((request->y == result->y) || !y_req) &&
	((request->width == result->width) || !w_req) &&
	((request->height == result->height) || !h_req))
    {
	if (request->request_mode & 
	    (CWBorderWidth | CWStackMode | CWSibling)) 
	{
	    return(XtGeometryAlmost);
	}

	if (request->request_mode & XtCWQueryOnly) 
	    return(XtGeometryYes);

	if (w_req || h_req) {
	    if (w_req) 
		info->pref_width = w->core.width = request->width;

	    if (h_req)
		info->pref_height = w->core.height = request->height;
	}
	else {
	    /*
	     * NOTE: We are assuming here that the cell height/width
	     * did not change.  This is valid because this code is
	     * only executed if w_req and h_req are false.
	     */

	    GetCellFromXY((Widget) ibw, result->x, result->y, 
			  &(info->cell_x), &(info->cell_y));
	}
	    
	CalcCellSizes((Widget) ibw, NULL, FALSE, FALSE, 
		      &(XmIconBox_cell_width(ibw)), &(XmIconBox_cell_height(ibw)));

	PlaceChildren((Widget) ibw, w);
	return(XtGeometryYes);
    }

    info->pref_width = info->pref_height = 0; /* invalidate cache. */

    if (((request->x == result->x) || !x_req)         ||
	((request->y == result->y) || !y_req)         ||
	((request->width == result->width) || !w_req) ||
	((request->height == result->height) || !h_req))
    {
	return(XtGeometryAlmost);
    }
    else 
	return(XtGeometryNo);
}