コード例 #1
0
ファイル: status.C プロジェクト: fooeybartoni/CSI702
Widget status_history(Widget parent)
{
    Widget history_shell = create_status_history(parent);

    MString history_msg;

    if (history == 0 || status_history_size == 0)
    {
	history_msg = rm("No history.");
    }
    else
    {
	history_msg = MString("Recent messages");
	history_msg += rm(" (oldest first)");
	history_msg += cr();

	int i = current_history;
	do {
	    if (!history[i].isEmpty())
	    {
		if (!history_msg.isEmpty())
		    history_msg += cr();
		history_msg += history[i];
	    }
	    i = (i + 1) % status_history_size;
	} while (i != current_history);
    }

    if (lesstif_version <= 87)
    {
	// LessTif 0.87 and earlier fails to resize the shell properly
	// - the border width is zero.  Use this hack instead.
	XmFontList font_list;
	XtVaGetValues(history_label, XmNfontList, &font_list, XtPointer(0));
    
	Dimension history_width  = history_msg.width(font_list)  + 6;
	Dimension history_height = history_msg.height(font_list) + 6;

	XtResizeWidget(history_label, history_width, history_height, 0);
	XtResizeWidget(history_row,   history_width, history_height, 0);

	XtResizeWidget(history_shell, history_width, history_height, 1);
    }

    XtVaSetValues(history_label, XmNlabelString, history_msg.xmstring(), 
		  XtPointer(0));

    return history_shell;
}
コード例 #2
0
ファイル: Porthole.c プロジェクト: dimkr/tinyxlib
static void
XawPortholeChangeManaged(Widget gw)
{
    PortholeWidget pw = (PortholeWidget)gw;
    Widget child = find_child (pw);	/* ignore extra children */

    if (child) {
	if (!XtIsRealized (gw)) {
	    XtWidgetGeometry geom, retgeom;

	    geom.request_mode = 0;
	    if (XtWidth(pw) == 0) {
		geom.width = XtWidth(child);
		geom.request_mode |= CWWidth;
	    }
	    if (XtHeight(pw) == 0) {
		geom.height = XtHeight(child);
		geom.request_mode |= CWHeight;
	    }
	    if (geom.request_mode &&
		XtMakeGeometryRequest (gw, &geom, &retgeom)
		== XtGeometryAlmost)
		(void)XtMakeGeometryRequest(gw, &retgeom, NULL);
	}
	
	XtResizeWidget(child, Max(XtWidth(child), XtWidth(pw)),
		       Max(XtHeight(child), XtHeight(pw)), 0);

	SendReport(pw, XawPRAll);
    }
}
コード例 #3
0
ファイル: Balloon.c プロジェクト: Gilles86/afni
/*****
* Name:			drawBalloonSquared
* Return Type:	void
* Description:	pops up the balloon widget as a simple square
* In:
*	w:			XmBalloon Widget id;
*	x:			absolute x popup position;
*	y:			absolute y popup position;
*	width:		desired widget width;
* Returns:
*	nothing
*****/
static void
drawBalloonSquared(Widget w, Position x, Position y, int width)
{
	XmBalloonWidget balloon = (XmBalloonWidget)w;
	Display *dpy = XtDisplay(w);

	/* resize to fit */
	XtResizeWidget((Widget)balloon, 2*ATTR(margin_width) + width, 
		2*ATTR(margin_height) + ATTR(font_height),
		balloon->core.border_width);

	/* move to correct location */
	XtMoveWidget(w, x + ATTR(left_offset), y + ATTR(top_offset));

	/*****
	* pop it up.
	* Note that the label can change when the widget is already popped.
	*****/
	if(!ATTR(popped))
		XtPopup((Widget)balloon, XtGrabNone);
	ATTR(popped) = True;

	/* do a FillRect to clear current label */
	XSetForeground(dpy, ATTR(gc), balloon->core.background_pixel);
	XFillRectangle(dpy, XtWindow((Widget)balloon), ATTR(gc), 0, 0,
		balloon->core.width, balloon->core.height);
	XSetForeground(dpy, ATTR(gc), ATTR(foreground));

	/* draw the text in the window */
	drawText(dpy, balloon, XtWindow((Widget)balloon), ATTR(gc), 0, 0);
}
コード例 #4
0
static void
XawViewportChangeManaged(Widget widget)
{
    ViewportWidget w = (ViewportWidget)widget;
    int num_children = w->composite.num_children;
    Widget child, *childP;
    int i;

    child = NULL;
    for (childP = w->composite.children,
	 i = 0; i < num_children;
	 childP++, i++) {
	if (XtIsManaged(*childP)
	    && *childP != w->viewport.clip
	    && *childP != w->viewport.horiz_bar
	    && *childP != w->viewport.vert_bar)	{
	    child = *childP;
	    break;
	}
    }

    if (child != w->viewport.child) {
	w->viewport.child = child;
	if (child != NULL) {
	    XtResizeWidget(child, XtWidth(child), XtHeight(child), 0);
	    if (XtIsRealized(widget)) {
		ViewportConstraints constraints =
		    (ViewportConstraints)child->core.constraints;
		if (!XtIsRealized(child)) {
		    Window window = XtWindow(w);

		    XtMoveWidget(child, 0, 0);
		    w->core.window = XtWindow(w->viewport.clip);
		    XtRealizeWidget(child);
		    w->core.window = window;
		    constraints->viewport.reparented = True;
		}
		else if (!constraints->viewport.reparented) {
		    XReparentWindow(XtDisplay(w), XtWindow(child),
				    XtWindow(w->viewport.clip), 0, 0);
		    constraints->viewport.reparented = True;
		    if (child->core.mapped_when_managed)
		    XtMapWidget(child);
		}
	    }
	    GetGeometry(widget, XtWidth(child), XtHeight(child));
	    (*((ViewportWidgetClass)w->core.widget_class)->form_class.layout)
	    ((FormWidget)w, XtWidth(w), XtHeight(w), True /* True? */);
	}
    }

#ifdef notdef
    (*Superclass->composite_class.change_managed)(widget);
#endif
}
コード例 #5
0
ファイル: plugin.c プロジェクト: UlricE/SiagOffice
int plugin_size_set(int ph, int width, int height)
{
	if (width < 10 || width > 1000 ||
		height < 10 || height > 1000) return -1;
	plugin[ph].width = width;
	plugin[ph].height = height;
	if (plugin[ph].visible && plugin[ph].core != None) {
		XtResizeWidget(plugin[ph].core, width+6, height+6, 1);
		XResizeWindow(XtDisplay(plugin[ph].core),
			plugin[ph].victim, width, height);
	}
	return 0;
}
コード例 #6
0
ファイル: SoXtGLWidget.cpp プロジェクト: ALLPix/SoXt
// doc in super
void    // virtual, protected
SoXtGLWidget::sizeChanged(const SbVec2s & size)
{
  // SoDebugError::postInfo("SoXtGLWidget::sizeChanged", "[invoked (%d, %d)]",
  //   size[0], size[1]);
  if (this->isBorder()) {
    PRIVATE(this)->glsize[0] = size[0] - 2 * PRIVATE(this)->borderwidth;
    PRIVATE(this)->glsize[1] = size[1] - 2 * PRIVATE(this)->borderwidth;
  } else {
    PRIVATE(this)->glsize = size;
  }
  XtResizeWidget(PRIVATE(this)->glxwidget, PRIVATE(this)->glsize[0], PRIVATE(this)->glsize[1], 0);
}
コード例 #7
0
void KXtWidget::init(const char* name, WidgetClass widget_class,
                    Widget parent, QWidget* qparent,
                    ArgList args, Cardinal num_args,
                    bool managed)
{
    need_reroot=FALSE;
    xtparent = 0;
    if (parent ) {
        Q_ASSERT(!qparent);
        xtw = XtCreateWidget(name, widget_class, parent, args, num_args);
        if ( widget_class == qWidgetClass )
            ((QWidgetRec*)xtw)->qwidget.qxtwidget = this;
        xtparent = parent;
        if (managed)
            XtManageChild(xtw);
    } else {
        Q_ASSERT(!managed);

        String n, c;
        XtGetApplicationNameAndClass(qt_xdisplay(), &n, &c);
        xtw = XtAppCreateShell(n, c, widget_class, qt_xdisplay(),
                               args, num_args);
        if ( widget_class == qWidgetClass )
            ((QWidgetRec*)xtw)->qwidget.qxtwidget = this;
    }

    if ( qparent ) {
        XtResizeWidget( xtw, 100, 100, 0 );
        XtSetMappedWhenManaged(xtw, False);
        XtRealizeWidget(xtw);
        XSync(qt_xdisplay(), False);    // I want all windows to be created now
        XReparentWindow(qt_xdisplay(), XtWindow(xtw), qparent->winId(), x(), y());
        XtSetMappedWhenManaged(xtw, True);
        need_reroot=TRUE;
    }

    Arg reqargs[20];
    Cardinal nargs=0;
    XtSetArg(reqargs[nargs], XtNx, x());        nargs++;
    XtSetArg(reqargs[nargs], XtNy, y());        nargs++;
    XtSetArg(reqargs[nargs], XtNwidth, width());        nargs++;
    XtSetArg(reqargs[nargs], XtNheight, height());      nargs++;
    //XtSetArg(reqargs[nargs], "mappedWhenManaged", False);     nargs++;
    XtSetValues(xtw, reqargs, nargs);

    //#### destroy();   MLK

    if (!parent || XtIsRealized(parent))
        XtRealizeWidget(xtw);
}
コード例 #8
0
ファイル: PrintS.c プロジェクト: unix-junkie/motif
static void 
AttributesNotifyHandler(
		    Widget w,
		    XtPointer client_data,
		    XEvent *event,
		    Boolean *continue_to_dispatch)
{
    XPAttributeEvent * xatrev = (XPAttributeEvent *) event ;
    XmPrintShellWidget print_shell = (XmPrintShellWidget) w ;
    Dimension width = w->core.width, height = w->core.height;

    /* For now, blindly update resolution and sizes */
    ResourcesUpdate(w, xatrev->context, &width, &height);

    XtResizeWidget(w, width, height, w->core.border_width);
}
コード例 #9
0
static void
ChangeManaged (RestraintWidget w)
{
  Widget child = NULL;
  int i;
  /* Find the child, if any. */
  for (i = 0; i < w->composite.num_children; i++)
    if (XtIsManaged (w->composite.children[i]))
      {
	child = w->composite.children[i];
	/* There can only be one! */
	break;
      }

  ON_DEBUG(printf ("Restraint::ChangeManaged: my size = %d x %d\n",
		   w->core.width, w->core.height));
  ON_DEBUG(printf ("  Num children = %d, child = 0x%p\n",
		   w->composite.num_children, child));

  /* If this is our first child, compute initial sizing. */
  /* Tried using !XtIsRealized (w) to do this stuff when were
     are being realized, but this doesn't handle the case of this
     widget being realized before it has a child.  This code will
     handle both cases correctly. */
  ON_DEBUG(printf ("  Checking for width calc\n    child = 0x%p, first = %d\n",
		   child, w->restraint.had_child));
  if (child != NULL && w->restraint.had_child == False)
    {
      compute_width (w, child);
      /* Q: Should this be reset when last child is deleted, so next new
	 child causes another width computation? 14:54 02/03/93 DJB */
      w->restraint.had_child = True;
    }

  /* Force child to take on my width. */
  if (child != NULL)
    {
      compute_height (w, child);
      ON_DEBUG(printf ("Restraint::ChangeManaged: sizing child to %d x %d\n",
		       w->core.width, w->core.height));
      XtResizeWidget (child, w->core.width, w->core.height, 0);
    }

  ON_DEBUG(printf ("----\n"));
  /* Do Motif bookkeeping. */
  _XmNavigChangeManaged ((Widget) w);
}
コード例 #10
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 );
}
コード例 #11
0
ファイル: Vendor.c プロジェクト: idunham/tinyxlib
void
XawVendorShellExtResize(Widget w)
{
	ShellWidget sw = (ShellWidget) w;
	Widget childwid;
	Cardinal i;
	int core_height;

	_XawImResizeVendorShell( w );
	core_height = _XawImGetShellHeight( w );
	for( i = 0; i < sw->composite.num_children; i++ ) {
	    if( XtIsManaged( sw->composite.children[ i ] ) ) {
		childwid = sw->composite.children[ i ];
		XtResizeWidget( childwid, sw->core.width, core_height,
			       childwid->core.border_width );
	    }
	}
}
コード例 #12
0
static void
Resize (RestraintWidget w)
{
  Widget child;

  /* This widget should only have one child. */
  if (w->composite.num_children == 0)
    return;

  child = w->composite.children[0];

  ON_DEBUG(printf ("Restraint::Resize resizing child to %d x %d\n",
		   w->core.width, w->core.height));

  XtResizeWidget(child,
		 w->core.width - child->core.border_width,
		 w->core.height - child->core.border_width,
		 child->core.border_width);
}
コード例 #13
0
ファイル: ScrollByL.c プロジェクト: aosm/X11apps
static void
Layout(Widget w)
{    
  ScrollByLineWidget sblw = (ScrollByLineWidget) w;
  Dimension width, height;
  Widget bar;
  Position bar_bw;

  CreateScrollbar(w);

/* 
 * For now always show the bar.
 */

  bar = sblw->scroll.bar;
  height = sblw->core.height;
  width = sblw->core.width;
  bar_bw = bar->core.border_width;

  /* Move child and v_bar to correct location. */

  if (sblw->scroll.use_right) {
    XtMoveWidget(bar, width - (bar->core.width + bar_bw), - bar_bw);
    sblw->scroll.offset = 0;
  }
  else {
    XtMoveWidget(bar, - bar_bw, - bar_bw);
    sblw->scroll.offset = bar->core.width + bar_bw;
  }

  /* resize the scrollbar to be the correct height or width. */

  XtResizeWidget(bar, bar->core.width, height, bar->core.border_width);

  SetThumbHeight(w);
  
  sblw->scroll.num_visible_lines = height / sblw->scroll.font_height + 1;
}
コード例 #14
0
void SetDisplay (ImageDisplay* IDdata) 
/*  sets size and position of the Image display window */
{
     int iXHalf, iYHalf, inXZoom, inYZoom, iScrWid, iScrHei;
     int iZoom, ch1;
     Dimension cwid, chei;
     char *ZP;
     Display     *dpy = XtDisplay (IDdata->display);
     unsigned int unx, uny;
     unsigned long pasize, ilong;
     int value, slider_size, increment, page_increment;
     int sbar_width = SBAR_WIDTH; 

/* update info in control pixel info area*/
     UpdateInfo(IDdata);  

/* don't bother if there's no valid image yet */
     if (!IDdata) return; /* shouldn't happen */
     if (!image[CurImag].valid) { /* set display for no image */
      /* no scroll bars */
      if (XtIsRealized (IDdata->hscroll)) XtUnmapWidget (IDdata->hscroll);
      IDdata->hscr_vis = 0;
      if (XtIsRealized (IDdata->vscroll)) XtUnmapWidget (IDdata->vscroll);
      IDdata->vscr_vis = 0;
      /* no image - give default label */
      XtVaSetValues(IDdata->shell, XmNtitle, "XFITSview", NULL);
/* hide display */
      if (XtIsRealized (IDdata->canvas)) XtUnmapWidget (IDdata->canvas);
      return;}

/*                    maximum display size */
     XtVaGetValues (IDdata->display,
		    XmNwidth, &cwid,
		    XmNheight, &chei,
		    NULL);
/*     cwid = cwid - CONTROLWIDTH;  leave room for control panel */
     IDdata->disp_wid = cwid;
     IDdata->disp_hei = chei;

     iZoom = IDdata->zoom; /* for convinence */

/*         display should be an integral multiple of image pixels */
     if (iZoom>1)
        {IDdata->disp_wid =
            ((IDdata->disp_wid/iZoom)*iZoom);
         IDdata->disp_hei =
            ((IDdata->disp_hei/iZoom)*iZoom);}
/*                    zoomed image size */
     inXZoom = image[CurImag].iImageNx;
     if (iZoom>1) inXZoom =  inXZoom * iZoom;
     if (iZoom<0) inXZoom = -inXZoom / iZoom;
     inYZoom = image[CurImag].iImageNy;
     if (iZoom>1) inYZoom =  inYZoom * iZoom;
     if (iZoom<0) inYZoom = -inYZoom / iZoom;
/*                     scroll bar size */
     iScrWid = sbar_width;
     iScrHei = sbar_width;
/*                      scroll bars needed? (iterate to get it right) */
     if ((IDdata->disp_wid-iScrWid)>=inXZoom) iScrHei = 0;
     if ((IDdata->disp_hei-iScrHei)>=inYZoom) iScrWid = 0;
     if ((IDdata->disp_wid-iScrWid)>=inXZoom) iScrHei = 0;
     if ((IDdata->disp_hei-iScrHei)>=inYZoom) iScrWid = 0;
     if (image[CurImag].valid) /* something in display? */
              /* Display needn't be larger than display+scrollbars */
              /* This sets the image size for no & negative zooms */
       {IDdata->disp_wid=min(IDdata->disp_wid, inXZoom+iScrWid);
        IDdata->disp_hei=min(IDdata->disp_hei,inYZoom+iScrHei);}
/*                      correct for size of scroll bars */
     IDdata->disp_wid -= iScrWid; 
     if (IDdata->disp_wid<0) IDdata->disp_wid = iScrWid;
     IDdata->disp_hei -= iScrHei; 
     if (IDdata->disp_hei<0) IDdata->disp_hei = iScrHei;
/*   Display may still be too big */
     if (image[CurImag].valid) /* something in display? */
       {IDdata->disp_wid = min (IDdata->disp_wid, inXZoom);
        IDdata->disp_hei = min (IDdata->disp_hei, inYZoom);}
     else
       {IDdata->disp_wid += iScrWid;  /* no scroll bars if no image */
        IDdata->disp_hei += iScrHei;} 
/* leave at least the width of the scroll bars (SBAR_WIDTH) around the edge */
     IDdata->disp_wid = min (IDdata->disp_wid, (int)cwid-sbar_width);
     IDdata->disp_hei = min (IDdata->disp_hei, (int)chei-sbar_width);
/*                    display should have an even number  of rows */
/*     IDdata->disp_hei = 2 * ((IDdata->disp_hei+1)/2); */

/* resize window */
     if (XtIsRealized (IDdata->canvas)) XtMapWidget (IDdata->canvas);
     XtResizeWidget(IDdata->canvas, 
		    (Dimension)IDdata->disp_wid,
		    (Dimension)IDdata->disp_hei, 
		    (Dimension)0);

/*                      Half Size of display in image pixels */
     iXHalf = IDdata->disp_wid/2;
     if (iZoom>1) iXHalf =  iXHalf / iZoom;
     if (iZoom<0) iXHalf = -iXHalf * iZoom;
     iYHalf = IDdata->disp_hei/2;
     if (iZoom>1) iYHalf =  iYHalf / iZoom;
     if (iZoom<0) iYHalf = -iYHalf * iZoom;
     iXHalf = min (iXHalf, image[CurImag].iImageNx/2);
     iYHalf = min (iYHalf, image[CurImag].iImageNy/2);

/* setup and center scroll */
/*     IDdata->scrollx = image[CurImag].iImageNx / 2; */
/*     IDdata->scrolly = image[CurImag].iImageNy / 2; */
     IDdata->hscr_max = image[CurImag].iImageNx-2*iXHalf;
     IDdata->hscr_min = 1;
     if (IDdata->hscr_max<=IDdata->hscr_min) 
       IDdata->hscr_max = IDdata->hscr_min + 1;
     IDdata->hscr_half = iXHalf;
     value = IDdata->scrollx - iXHalf;
     slider_size = 2 * iXHalf;
     increment = iXHalf / 5; if (increment<1) increment = 1;
     page_increment = 3 * iXHalf / 2; if (page_increment<1) page_increment = 1;
     if (value>IDdata->hscr_max) value = IDdata->hscr_max;
     if (value<IDdata->hscr_min) value = IDdata->hscr_min;
     if (iScrHei)
       {
         /* keep X-Windows from blowing it's tiny mind */
         XmScrollBarSetValues (IDdata->hscroll, 1, 1, 1, 1, False);
	 XtVaSetValues(IDdata->hscroll, 
		     XmNheight,    iScrHei,
		     XmNvalue,     value,
		     XmNmaximum,   (Dimension)(IDdata->hscr_max+2*iXHalf),
		     XmNminimum,   (Dimension)(IDdata->hscr_min),
		     NULL);
	XmScrollBarSetValues (IDdata->hscroll, value, slider_size, increment, 
			      page_increment, False);}
     IDdata->vscr_max = image[CurImag].iImageNy-2*iYHalf;
     IDdata->vscr_min = 1;
     if (IDdata->vscr_max<=IDdata->vscr_min) 
       IDdata->vscr_max = IDdata->vscr_min + 1;
     IDdata->vscr_half = iYHalf;
     value = IDdata->scrolly - iYHalf;
     slider_size = 2 * iYHalf;
     increment = iYHalf / 5; if (increment<1) increment = 1;
     page_increment = 3 * iYHalf / 2; if (page_increment<1) page_increment = 1;
     if (value>IDdata->vscr_max) value = IDdata->vscr_max;
     if (value<IDdata->vscr_min) value = IDdata->vscr_min;
     if (iScrWid)
       {
         /* keep X-Windows from blowing it's tiny mind */
         XmScrollBarSetValues (IDdata->vscroll, 1, 1, 1, 1, False);
	 XtVaSetValues(IDdata->vscroll, 
		     XmNwidth,     iScrWid,
		     XmNvalue,     value,
		     XmNmaximum,   (Dimension)(IDdata->vscr_max+2*iYHalf),
		     XmNminimum,   (Dimension)(IDdata->vscr_min),
		     NULL);
	XmScrollBarSetValues (IDdata->vscroll, value, slider_size, increment, 
			      page_increment, False);}

/*     make horizonal scroll bar visible or invisible as necessary */
/*  iScrHei = 0 => no horizontal scroll */
     if (iScrHei) /* visible */
       {XtMapWidget (IDdata->hscroll);
	IDdata->hscr_vis = 1;}
     else /* invisible */
       {XtUnmapWidget (IDdata->hscroll);
	IDdata->hscr_vis = 0;}

/*     make vertical scroll bar visible or invisible as necessary */
/*  iScrWid = 0 => no vertical scroll */
     if (iScrWid) /* visible */
       {XtMapWidget (IDdata->vscroll);
	IDdata->vscr_vis = 1;}
     else /* invisible */
       {XtUnmapWidget (IDdata->vscroll);
	IDdata->vscr_vis = 0;}

/* make work ZPixmap for zooming display */
     if (iZoom!=1) 
       {
/* delete old if necessary*/
	 unx = IDdata->disp_wid;
	 uny = IDdata->disp_hei;
	 if ( !IDdata->work || 
	     (unx>IDdata->work->width) || (uny>IDdata->work->height)) 
	   {
	     if (IDdata->work) 
	       {if (IDdata->work->data) XtFree(IDdata->work->data);
		XtFree((XtPointer)IDdata->work);}

/* create new pix map */
	     pasize = unx * uny * ((IDdata->depth+1)/8);
	     ZP = (char*) XtMalloc (pasize);
	     IDdata->work = 
	       XCreateImage (dpy, 
			     DefaultVisual(dpy, DefaultScreen(dpy)), 
			     IDdata->depth, ZPixmap, 0, 
			     ZP, unx, uny, 8, 0); 
/* blank it out */
	     for (ilong=0; ilong<pasize; ilong++) 
	       IDdata->work->data[ilong] = 0;
  
	   }} /* end of create new ZPixmap */

} /* end SetDisplay */
コード例 #15
0
ファイル: Balloon.c プロジェクト: Gilles86/afni
/*****
* Name:			drawBalloonShaped
* Return Type:	void
* Description:	pops up the balloon widget as a shaped window
* In:
*	w:			XmBalloon Widget id;
*	x:			absolute x popup position;
*	y:			absolute y popup position;
*	width:		desired widget width;
* Returns:
*	nothing
* Note:
*	This routine composes a *clipmask* for the widget to use when
*	it is displayed. The clipmask is initially empty and gets filled
*	according to the selected options. Once it is filled, the text
*	is rendered in the selected color.
*****/
static void
drawBalloonShaped(Widget w, Position x, Position y, int width)
{
	BALLOON = (XmBalloonWidget)w;
	XGCValues xgc;
	int face_width, face_height, x_offset, y_offset;
	Dimension bwidth, bheight;
	Pixmap shape_mask;
	Display *dpy = XtDisplay(w);
	Window win = XtWindow(w);

	/* horizontal offset for text rendering */
	x_offset = ATTR(margin_width) + ATTR(font_width);
	y_offset = 0.25 * ATTR(font_height);

	bwidth = 2*ATTR(margin_width) + width + 2*x_offset;
	bheight = 2*ATTR(margin_height) + ATTR(font_height) + 2*y_offset;

	/* resize to fit */
	XtResizeWidget(w, bwidth, bheight, balloon->core.border_width);

	/* compute desired border size */
	setTransform(&ATTR(maskt), 0, bwidth, bheight, 0, -1.0, 1.0, -1.0, 1.0);

	face_width = abs(Xwidth(BORDER_SIZE(balloon), BORDER_SIZE(balloon),
		&(ATTR(maskt))));
	face_height = abs(Xheight(BORDER_SIZE(balloon), BORDER_SIZE(balloon),
		&(ATTR(maskt))));

	setTransform(&ATTR(t), face_width, bwidth - face_width,
		bheight - face_height, face_height, 
		-WINDOW_WIDTH(balloon)/2, WINDOW_WIDTH(balloon)/2,
		-WINDOW_HEIGHT(balloon)/2, WINDOW_HEIGHT(balloon)/2);

	/* Free up previous clipmask if the size differs */
	if(ATTR(shape_mask) &&
		ATTR(shape_width) != w->core.width &&
		ATTR(shape_height) != w->core.height)
	{
		XFreePixmap(dpy, ATTR(shape_mask));
		ATTR(shape_mask) = None;
	}

	/* allocate a clipmask (bitmap of depth one) */
	if(!(ATTR(shape_mask)))
	{
		ATTR(shape_mask) = XCreatePixmap(dpy, win, bwidth, bheight, 1);
		ATTR(shape_width) = bwidth;
		ATTR(shape_height) = bheight;
	}
	shape_mask = ATTR(shape_mask);

	/* simple gc */
	if(!(ATTR(shape_gc)))
		ATTR(shape_gc) = XCreateGC(dpy, shape_mask, 0, &xgc);

	/* make it fully transparent */
	XSetForeground(dpy, ATTR(shape_gc), 0);
	XFillRectangle(dpy, shape_mask, ATTR(shape_gc), 0, 0, bwidth, bheight);
	XSetForeground(dpy, ATTR(shape_gc), 1);

	/*****
	* Fill in the border bits if we have a border. If we aren't transparent
	* a filled arc is created.
	*****/
	if(ATTR(border_size) > 0.0 || !ATTR(transparent))
	{
		FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(maskt)),
			-1.0, -1.0, 2.0, 2.0, 0, 360*64);
	}

	/*****
	* if we are being transparent, erase the inner part of the disk
	* and fill the bits for the text. If we aren't transparent we don't
	* have to do this 'cause the bits set for the disk already cover the
	* bits that cover the text.
	*****/
	if(ATTR(transparent))
	{
		if(ATTR(border_size) > 0.0)
		{
			XSetForeground(dpy, ATTR(shape_gc), 0);
			FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(maskt)),
				-WINDOW_WIDTH(balloon)/2, -WINDOW_HEIGHT(balloon)/2,
				WINDOW_WIDTH(balloon), WINDOW_HEIGHT(balloon),
				0, 360*64);
			XSetForeground(dpy, ATTR(shape_gc), 1);
		}
		drawText(dpy, balloon, shape_mask, ATTR(shape_gc), x_offset, y_offset);
	}
	/* the highest enclosing widget is the widget itself */
	XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, shape_mask, ShapeSet);

	/* erase clipmask */
	XSetForeground(dpy, ATTR(shape_gc), 0); 
	XFillRectangle(dpy, shape_mask, ATTR(shape_gc), 0, 0, bwidth, bheight);
	XSetForeground(dpy, ATTR(shape_gc), 1);

	/* draw clip shape */
	if(ATTR(transparent))
	{
		drawText(dpy, balloon, shape_mask, ATTR(shape_gc), x_offset, y_offset);
	}
	else
	{
		FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(t)),
			-WINDOW_WIDTH(balloon)/2, -WINDOW_HEIGHT(balloon)/2,
			WINDOW_WIDTH(balloon), WINDOW_HEIGHT(balloon),
			0, 360*64);
	}

	/* compose final clipmask */
	XShapeCombineMask(dpy, win, ShapeClip, 0, 0, shape_mask, ShapeSet);

	/* move to correct location */
	XtMoveWidget((Widget)balloon, x + 4, y + 4);

	/*****
	* pop it up.
	* Note that the label can change when the widget is already popped.
	*****/
	if(!ATTR(popped))
		XtPopup((Widget)balloon, XtGrabNone);
	ATTR(popped) = True;

	/* draw the text */
	drawText(dpy, balloon, win, ATTR(gc), x_offset, y_offset);

	/* if we have got a popdown timeout, add it */
	if(ATTR(popdown_delay))
	{
		ATTR(popdown_id) = XtAppAddTimeOut(ATTR(context),
			ATTR(popdown_delay), popdownBalloon, (XtPointer)balloon);
	}

}
コード例 #16
0
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);
}
コード例 #17
0
ファイル: lockscreen.c プロジェクト: mariodebian/tcos
int main (int argc, char **argv) {

	XtResource desktopBackingStoreResources[] = { { XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof(int), 0, XtRImmediate, (XtPointer) Always, }, };

	Display * display;
	Visual * vis;

	XSetWindowAttributes attr;
	unsigned long valuemask;

	Pixmap src, msk;
	XColor fg, bg;
	int blackColor;
	GC gc;

	Widget toplevel;
	Dimension displayWidth, displayHeight;

	Cursor blankcursor;

	Widget form, viewport, desktop;
	Window desktop_win;

	char srcBits[] = { 0,0,0,0,0 };
	char mskBits[] = { 0,0,0,0,0 };


	/* Call the main Xt initialisation function.  It parses command-line options, generating appropriate resource specs, and makes a
	 * connection to the X display. */
	toplevel = XtVaAppInitialize(NULL, "ScreenLocker", NULL, 0, &argc, argv, NULL, XtNborderWidth, 0, NULL);

	display = XtDisplay(toplevel);

	vis = DefaultVisual(display, DefaultScreen(display));

	displayWidth = WidthOfScreen(DefaultScreenOfDisplay(display));
	displayHeight = HeightOfScreen(DefaultScreenOfDisplay(display));
	

	/* full screen - set position to 0,0, but defer size calculation until widgets are realized */
	XtVaSetValues(toplevel, XtNoverrideRedirect, True, XtNgeometry, "+0+0", NULL);


	form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, XtNborderWidth, 0, XtNdefaultDistance, 0, NULL);
	viewport = XtVaCreateManagedWidget("viewport", viewportWidgetClass, form, XtNborderWidth, 0, NULL);
	desktop = XtVaCreateManagedWidget("desktop", coreWidgetClass, viewport, XtNborderWidth, 0, NULL);

	XtVaSetValues(desktop, XtNwidth, displayWidth, XtNheight, displayHeight, NULL);

	/* "Realize" all the widgets, i.e. actually create and map their X windows */
	XtRealizeWidget(toplevel);



	/* We want to stop the window manager from managing our toplevel window. This is not really a nice thing to do, so may not work
	 * properly with every window manager.  We do this simply by setting overrideRedirect and reparenting our window to the root. 
	 * The window manager will get a ReparentNotify and hopefully clean up its frame window. */
	XtVaSetValues(toplevel, XtNoverrideRedirect, True, NULL);
	XReparentWindow(display, XtWindow(toplevel), DefaultRootWindow(display), 0, 0);

	/* Now we want to fix the size of "viewport".  We shouldn't just change it directly.
	 * Instead we set "toplevel" to the required size (which should propagate through "form" to "viewport").
	 * Then we remove "viewport" from being managed by "form", change its resources to position it and make sure that "form" won't
	 * attempt to resize it, then ask "form" to manage it again. */
	XtResizeWidget(toplevel, displayWidth, displayHeight, 0);
	XtUnmanageChild(viewport);
	XtVaSetValues(viewport, XtNhorizDistance, 0, XtNvertDistance, 0, XtNleft, XtChainLeft, XtNright, XtChainLeft, XtNtop, XtChainTop, XtNbottom, XtChainTop, NULL);
	XtManageChild(viewport);

	/* Now we can set "toplevel" to its proper size. */
	XtResizeWidget(toplevel, displayWidth, displayHeight, 0);


	/*image = XCreateImage(display, vis, 32, ZPixmap, 0, NULL, 2000, 2000, BitmapPad(display), 0);*/
	blackColor = BlackPixel(display, DefaultScreen(display));
	desktop_win = XtWindow(desktop);
	gc = XCreateGC(display, desktop_win, 0, NULL);

	/* Tell the GC we draw using the black color*/
	XSetForeground(display, gc, blackColor);
	XFillRectangle(display, desktop_win, gc, 0, 0, displayWidth, displayHeight);



	src = XCreateBitmapFromData(display, DefaultRootWindow(display), srcBits, 5, 5);
	msk = XCreateBitmapFromData(display, DefaultRootWindow(display), mskBits, 5, 5);
	XAllocNamedColor(display, DefaultColormap(display,DefaultScreen(display)), "black", &fg, &fg);
	XAllocNamedColor(display, DefaultColormap(display,DefaultScreen(display)), "white", &bg, &bg);
	blankcursor = XCreatePixmapCursor(display, src, msk, &fg, &bg, 2, 2);
	XFreePixmap(display, src);
	XFreePixmap(display, msk);

	XtVaGetApplicationResources(desktop, (XtPointer)&attr.backing_store, desktopBackingStoreResources, 1, NULL);
	valuemask = CWBackingStore;

	attr.cursor = blankcursor;
	valuemask |= CWCursor;

	XChangeWindowAttributes(display, desktop_win, valuemask, &attr);
  
	/* Try to get the input focus. */
	XSetInputFocus(display, DefaultRootWindow(display), RevertToPointerRoot, CurrentTime);

	/* now grab keyboard and mouse */
	if (XtGrabKeyboard(desktop, True, GrabModeAsync, GrabModeAsync, CurrentTime) != GrabSuccess ||
	    XtGrabPointer(desktop, True, (unsigned int) AllPointerEventMask, GrabModeAsync, GrabModeAsync, None, blankcursor, CurrentTime) != GrabSuccess) {
		printf ("Could not grab keyboard and mouse.\n");
	}

	while (1) {
		/* sleep a little bit - only for better task-scheduling... */
		sleep (5);
	}

	return (0);

}
コード例 #18
0
ファイル: ScrollBox.c プロジェクト: Acularius/Pixel-Brother
static void DoLayout(Widget w, Boolean doit)
{
    ScrollBoxWidget sbw = (ScrollBoxWidget)w;
    Widget wmain, vscroll, hscroll, child;
    Dimension mw, mh;   /* main window */
    Dimension vh;   /* vertical scrollbar length (height) */
    Dimension hw;   /* horizontal scrollbar length (width) */
    Position vx;
    Position hy;
    Cardinal i;

    if (sbw->composite.num_children != 3)
        XtAppError(XtWidgetToApplicationContext(w),
            "ScrollBox: must manage exactly three widgets.");

    for (i = 0; i < sbw->composite.num_children; i++) 
    {
        child = sbw->composite.children[i];

        if (!XtIsManaged(child)) 
            XtAppError(XtWidgetToApplicationContext(w),
                "ScrollBox: all three widgets must be managed.");
    }

    /* Child one is the main window, two is the vertical scrollbar, 
       and three is the horizontal scrollbar. */

    wmain = sbw->composite.children[0];
    vscroll = sbw->composite.children[1];
    hscroll = sbw->composite.children[2];

    /* Size all three widgets so that space is fully utilized. */

    mw = sbw->core.width - (2 * sbw->scrollBox.h_space) -
        vscroll->core.width - (2 * vscroll->core.border_width) -
        (2 * wmain->core.border_width);

    mh = sbw->core.height - (2 * sbw->scrollBox.v_space) -
        hscroll->core.height - (2 * hscroll->core.border_width) -
        (2 * wmain->core.border_width);

    /* Force the main window to be sized to the appropriate increment. */

    mw = (mw / sbw->scrollBox.increment_width) *
        sbw->scrollBox.increment_width;

    mh = ((mh / sbw->scrollBox.increment_height) *
        sbw->scrollBox.increment_height) +
        sbw->scrollBox.increment_height;

    vx = wmain->core.x + mw + sbw->scrollBox.h_space + 
        wmain->core.border_width + vscroll->core.border_width; 

    hy = wmain->core.y + mh + sbw->scrollBox.v_space + 
        wmain->core.border_width + hscroll->core.border_width; 

    vh = mh;   /* scrollbars are always same length as main window */
    hw = mw;

    if (doit)
    {
        XtResizeWidget(wmain, mw, mh, 1);

        XtResizeWidget(vscroll, vscroll->core.width, vh, 1);
        XtMoveWidget(vscroll, vx, vscroll->core.y);

        XtResizeWidget(hscroll, hw, hscroll->core.height, 1);
        XtMoveWidget(hscroll, hscroll->core.x, hy);
    }
}
コード例 #19
0
ファイル: resize_window.c プロジェクト: gokulkarthick/afd
/*############################ resize_window() #########################*/
signed char
resize_window(void)
{
   static int old_long_window_height = -1,
              old_short_window_height = -1;
   int        long_window_height,
              ret,
              short_window_height;
   Arg        args[2];
   Cardinal   argcount;

   if (window_size(&window_width, &window_height) == YES)
   {
#ifdef _AUTO_REPOSITION
      XWindowAttributes window_attrib;
      int               display_width,
                        display_height,
                        new_x,
                        new_y;
      Position          root_x,
                        root_y;
#endif
      static int        old_line_height = 0;

#ifdef _AUTO_REPOSITION
      /* Get new window position. */
      display_width = DisplayWidth(display, DefaultScreen(display));
      display_height = DisplayHeight(display, DefaultScreen(display));
      XGetWindowAttributes(display, XtWindow(appshell), &window_attrib);

      /* Translate coordinates relative to root window. */
      XtTranslateCoords(appshell, window_attrib.x, window_attrib.y,
                        &root_x, &root_y);

      /* Change x coordinate. */
      if ((root_x + window_width) > display_width)
      {
         new_x = display_width - window_width;

         /* Is window wider then display? */
         if (new_x < 0)
         {
            new_x = 0;
         }
      }
      else
      {
         new_x = root_x;
      }

      /* Change y coordinate. */
      if ((root_y + window_height + 23) > display_height)
      {
         new_y = display_height - window_height;

         /* Is window wider then display? */
         if (new_y < 23)
         {
            new_y = 23;
         }
      }
      else
      {
         new_y = root_y;
      }

      /* Resize window. */
      XtVaSetValues(appshell,
                    XmNminWidth, window_width,
                    XmNmaxWidth, window_width,
                    XmNminHeight, window_height + line_height + line_height + glyph_height + magic_value,
                    XmNmaxHeight, window_height + line_height + line_height + glyph_height + magic_value,
                    NULL);
      XMoveResizeWindow(display, XtWindow(appshell),
                        new_x, new_y,
                        window_width,
                        window_height + line_height + line_height + glyph_height + magic_value);
#else
      XtVaSetValues(appshell,
                    XmNminWidth, window_width,
                    XmNmaxWidth, window_width,
                    XmNminHeight, window_height + line_height + line_height + glyph_height + magic_value,
                    XmNmaxHeight, window_height + line_height + line_height + glyph_height + magic_value,
                    NULL);
      XResizeWindow(display, XtWindow(appshell), window_width,
                    window_height + line_height + line_height + glyph_height + magic_value);
#endif

      /* If the line_height changed, don't forget to change the */
      /* height of the label and button window!                 */
      argcount = 0;
      XtSetArg(args[argcount], XmNwidth, (Dimension)window_width);
      argcount++;
      long_window_height = no_of_rows * line_height;
      if (long_window_height != old_long_window_height)
      {
         XtSetArg(args[argcount], XmNheight, (Dimension)long_window_height);
         argcount++;
         old_long_window_height = long_window_height;
      }
      XtSetValues(line_window_w, args, argcount);
      argcount = 0;
      XtSetArg(args[argcount], XmNwidth, (Dimension)window_width);
      argcount++;
      short_window_height = no_of_short_rows * line_height;
      if (short_window_height != old_short_window_height)
      {
         XtSetArg(args[argcount], XmNheight, (Dimension)(short_window_height));
         argcount++;
         old_short_window_height = short_window_height;
      }
      XtSetValues(short_line_window_w, args, argcount);
      argcount = 0;
      XtSetArg(args[argcount], XmNwidth, (Dimension)window_width);
      argcount++;
      if (line_height != old_line_height)
      {
         XtSetArg(args[argcount], XmNheight, (Dimension)line_height);
         argcount++;
         old_line_height = line_height;
      }
      XtSetValues(label_window_w, args, argcount);
      XtSetValues(button_window_w, args, argcount);
      ret = YES;
   }
   else
   {
      long_window_height = no_of_rows * line_height;
      if (long_window_height != old_long_window_height)
      {
         argcount = 0;
         XtSetArg(args[argcount], XmNheight, (Dimension)long_window_height);
         argcount++;
         XtSetValues(line_window_w, args, argcount);
         XtResizeWidget(line_window_w, window_width, long_window_height, 0);
      }
      short_window_height = (no_of_short_rows * line_height) + 1;
      if (short_window_height != old_short_window_height)
      {
         argcount = 0;
         XtSetArg(args[argcount], XmNheight, (Dimension)(short_window_height));
         argcount++;
         XtSetValues(short_line_window_w, args, argcount);
         XtResizeWidget(short_line_window_w, window_width,
                        short_window_height, 0);
      }
      if ((old_long_window_height != -1) && (old_short_window_height != -1))
      {
         if (short_line_window_w->core.y != (line_window_w->core.y + long_window_height))
         {
            XtMoveWidget(short_line_window_w,
                         short_line_window_w->core.x,
                         line_window_w->core.y + long_window_height);
         }
      }
      old_long_window_height = long_window_height;
      old_short_window_height = short_window_height;
      ret = NO;
   }
   return(ret);
}
コード例 #20
0
/*****************************************************************************
  FUNCTION : ui_map_geometry

  PURPOSE  : compute the geometry of the displays and the size of the squares
  NOTES    :
  RETURNS  : 
  UPDATE   : 22.09.1994
******************************************************************************/
static void ui_map_geometry(int zoom_fact)
{
    int  maxstepsX,maxstepsY;
    int  n;
    XtWidgetGeometry geo_info, geo_data;
    XtWidgetGeometry disp_info, disp_data;
    XtWidgetGeometry view_info, view_data;
    XtGeometryResult geo_result;


    /* do nothing, if no network defined */

    if( krui_getNoOfUnits() == 0)
	return;
    maxstepsX = (int) (MAP_xMax-MAP_xMin)/MAP_scaleX;
    maxstepsY = (int) (MAP_yMax-MAP_yMin)/MAP_scaleY;


    /* set the necessary xlib environment variables */

    if(ui_col_monochromeMode){ 
	/* this is a  B&W terminal */
	MAP_GRAPH_gc[0]  = XCreateGC(ui_display,MAP_GRAPH_win,0,0); 
    } else { 
	/* this is a color terminal */
	for(n=0;n<=20;n++)
	    MAP_GRAPH_gc[n] = XCreateGC(ui_display,MAP_GRAPH_win,0,0); 
    
	/* set the foreground and background colors */
	for(n=0; n<10;n++){
	    XSetForeground(ui_display,MAP_GRAPH_gc[n],
			   (uint) ui_col_rangePixels[(int)(n*1.7)]); 
	    XSetBackground(ui_display,MAP_GRAPH_gc[n], 
			   WhitePixel(ui_display,MAP_GRAPH_screen));
	    XSetForeground(ui_display,MAP_GRAPH_gc[10+n],
			   (uint)  ui_col_rangePixels[(int)(15+n*1.7)]); 
	    XSetBackground(ui_display,MAP_GRAPH_gc[10+n],
			   WhitePixel(ui_display,MAP_GRAPH_screen));
	}
    }


    /* get widget geometry */

    geo_result = XtQueryGeometry(MAP_GRAPH_mainwidget,&geo_data,&geo_info);
  
    if(geo_result != XtGeometryYes){
	geo_info.height = 400;
	geo_info.width  = 400;
    }
    if(zoom_fact != 0){
	XtResizeWidget(MAP_GRAPH_mainwidget,geo_info.width,
		       geo_info.height,geo_info.border_width);
    }


    /* adjust squaresize */

    if(ui_col_monochromeMode){	/* this is a  B&W terminal */
	MAP_BW_squaresizeX = MAP_BW_squaresizeX + zoom_fact;
	MAP_BW_squaresizeY = MAP_BW_squaresizeY + zoom_fact;
	if(MAP_BW_squaresizeX == 0)MAP_BW_squaresizeX = 1;
	if(MAP_BW_squaresizeY == 0)MAP_BW_squaresizeY = 1;
	MAP_windowsizeX = MAP_BW_squaresizeX*maxstepsX+40;
	MAP_windowsizeY = MAP_BW_squaresizeY*maxstepsY+40;
    }else{			/* this is a color terminal */
	MAP_squaresizeX = MAP_squaresizeX + zoom_fact;
	MAP_squaresizeY = MAP_squaresizeY + zoom_fact;
	if(MAP_squaresizeX == 0)MAP_squaresizeX = 1;
	if(MAP_squaresizeY == 0)MAP_squaresizeY = 1;
	MAP_windowsizeX = MAP_squaresizeX*maxstepsX+62;
	MAP_windowsizeY = MAP_squaresizeY*maxstepsY+62;
    }
  

    /* Resize all involved windows so that they fit the data and the screen */

    XtResizeWidget(MAP_GRAPH_displaywidget,MAP_windowsizeX+62,
		   MAP_windowsizeY+62,0);
    MAP_viewsizeX = MAP_squaresizeX * maxstepsX;
    MAP_viewsizeY = MAP_squaresizeY * maxstepsY;
    geo_result = XtQueryGeometry(MAP_GRAPH_displaywidget,
				 &disp_data,&disp_info);
    geo_result = XtQueryGeometry(view,&view_data,&view_info);
    if(view_info.width > disp_info.width)
	XtResizeWidget(view,disp_info.width,
		       disp_info.height,view_info.border_width);
    else
	if(disp_info.width < geo_info.width)
	    XtResizeWidget(view,disp_info.width,
			   disp_info.height,view_info.border_width);
	else
	    XtResizeWidget(view,geo_info.width,
			   geo_info.height,view_info.border_width);

}