Exemple #1
0
Widget
CreateDragSourceIcon(
        Widget          widget,
        Pixmap          pixmap,
        Pixmap          mask)
{
        Widget          dragIcon;
        Window          rootWindow;
        int             pixmapX, pixmapY;
        unsigned int    pixmapWidth, pixmapHeight, pixmapBorder, pixmapDepth;
        Arg             args[20];
        Cardinal        nn = 0;
 
        XGetGeometry (XtDisplayOfObject(widget), pixmap, &rootWindow,
                &pixmapX, &pixmapY, &pixmapWidth, &pixmapHeight,
                &pixmapBorder, &pixmapDepth);
 
        XtSetArg(args[nn], XmNwidth, pixmapWidth);  nn++;
        XtSetArg(args[nn], XmNheight, pixmapHeight);  nn++;
        XtSetArg(args[nn], XmNmaxWidth, pixmapWidth);  nn++;
        XtSetArg(args[nn], XmNmaxHeight, pixmapHeight);  nn++;
        XtSetArg(args[nn], XmNpixmap, pixmap);  nn++;
        XtSetArg(args[nn], XmNmask, mask);  nn++;
        XtSetArg(args[nn], XmNdepth, pixmapDepth);  nn++;
        dragIcon = XmCreateDragIcon(widget, "sourceIcon", args, nn);

        return(dragIcon);
}
Exemple #2
0
static void
gadget_border_unhighlight(Widget w)
{

    DEBUGOUT(_LtDebug(__FILE__, w, "gadget_border_unhighlight\n"));

    /* with zero width, we don't need this... */
    if (G_HighlightThickness(w) == 0)
    {
	return;
    }

    if (XmIsManager(XtParent(w)))
    {
	_XmDrawHighlight(XtDisplayOfObject(w), XtWindowOfObject(w),
			 XmParentBackgroundGC(w),
			 XtX(w), XtY(w), XtWidth(w), XtHeight(w),
			 G_HighlightThickness(w), LineSolid);
    }
    else
    {
	_XmClearBorder(XtDisplay(w),
		       XtWindow(w),
		       XtX(w), XtY(w),
		       XtWidth(w), XtHeight(w),
		       G_HighlightThickness(w));
    }

    G_Highlighted(w) = False;
    G_HighlightDrawn(w) = False;
}
Exemple #3
0
void XtRemoveAllCallbacks(
    Widget widget,
    _Xconst char* name)
{
    InternalCallbackList *callbacks;
    Widget hookobj;
    XtAppContext app = XtWidgetToApplicationContext(widget);

    LOCK_APP(app);
    callbacks = FetchInternalList(widget, name);
    if (!callbacks) {
	XtAppWarningMsg(app,
	       XtNinvalidCallbackList,XtNxtRemoveAllCallback,XtCXtToolkitError,
              "Cannot find callback list in XtRemoveAllCallbacks",
	      (String *)NULL, (Cardinal *)NULL);
	UNLOCK_APP(app);
	return;
    }
    _XtRemoveAllCallbacks(callbacks);
    hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
	XtChangeHookDataRec call_data;

	call_data.type = XtHremoveAllCallbacks;
	call_data.widget = widget;
	call_data.event_data = (XtPointer) name;
	XtCallCallbackList(hookobj,
		((HookObject)hookobj)->hooks.changehook_callbacks,
		(XtPointer)&call_data);
    }
    UNLOCK_APP(app);
} /* XtRemoveAllCallbacks */
Exemple #4
0
/*ARGSUSED*/
static void
ClearToBackground(Widget w, int x, int y,
		  unsigned int width, unsigned int height)
{
    /* 
     * Don't clear in height or width are zero
     * XClearArea() has special semantic for these values
     */
    TextWidget xaw = (TextWidget)XtParent(w);
    Position x1, y1, x2, y2;

    x1 = XawMax(x, xaw->text.r_margin.left);
    y1 = XawMax(y, xaw->text.r_margin.top);
    x2 = XawMin(x + (int)width, (int)XtWidth(xaw) - xaw->text.r_margin.right);
    y2 = XawMin(y + (int)height, (int)XtHeight(xaw) - xaw->text.r_margin.bottom);

    x = x1;
    y = y1;
    width = XawMax(0, x2 - x1);
    height = XawMax(0, y2 - y1);

    if (height != 0 && width != 0)
	XClearArea(XtDisplayOfObject(w), XtWindowOfObject(w),
		   x, y, width, height, False);
}
Exemple #5
0
static void
to_clipbd(Widget w, XtPointer client_data, XtPointer call_data)
{
    long item_id = 0;
    int status;
    XmString clip_label;
    char buf[32];
    static int cnt;
    Display *dpy = XtDisplayOfObject(w);
    Window window = XtWindowOfObject(w);
    char *data = (char *)client_data;

    sprintf(buf, "%s-%d", data, ++cnt);

    clip_label = XmStringCreateLocalized("to_clipbd");

    do {
	status = XmClipboardStartCopy(dpy, window, clip_label, CurrentTime,
				      NULL, NULL, &item_id);
    } while (status == ClipboardLocked);

    XmStringFree(clip_label);

    do {
	status = XmClipboardCopy(dpy, window, item_id, "STRING",
				buf, (long)strlen(buf)+1, cnt, NULL);
    } while (status == ClipboardLocked);


    do {
	status = XmClipboardEndCopy(dpy, window, item_id);
    } while (status == ClipboardLocked);

    fprintf(stderr, "copied: '%s' to clipboard\n", buf);
}
Exemple #6
0
static void
from_clipbd(Widget w, XtPointer client_data, XtPointer call_data)
{
    int status;
    long private_id;
    char buf[32];
    Display *dpy = XtDisplayOfObject(w);
    Window window = XtWindowOfObject(w);

    do {
	status = XmClipboardRetrieve(dpy, window, "STRING",
				     buf, sizeof(buf), NULL, &private_id);
    } while (status == ClipboardLocked);

    if (status == ClipboardSuccess)
	fprintf(stderr, "Retrieved '%s' (private_id %ld) from clipboard.\n",
	       buf, private_id);
    else
	fprintf(stderr, "Status was %s\n",
		(status == XmClipboardFail) ? "XmClipboardFail" :
		(status == XmClipboardSuccess) ? "XmClipboardSuccess" :
		(status == XmClipboardTruncate) ? "XmClipboardTruncate" :
		(status == XmClipboardLocked) ? "XmClipboardLocked" :
		(status == XmClipboardBadFormat) ? "XmClipboardBadFormat" :
		(status == XmClipboardNoData) ? "XmClipboardNoData" : "???");
}
Exemple #7
0
XtGeometryResult XtMakeGeometryRequest (
    Widget         widget,
    XtWidgetGeometry *request,
    XtWidgetGeometry *reply)
{
    Boolean junk;
    XtGeometryResult r;
    XtGeometryHookDataRec call_data;
    Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) {
        call_data.type = XtHpreGeometry;
        call_data.widget = widget;
        call_data.request = request;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
        call_data.result = r =
                               _XtMakeGeometryRequest(widget, request, reply, &junk);
        call_data.type = XtHpostGeometry;
        call_data.reply = reply;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
    } else {
        r = _XtMakeGeometryRequest(widget, request, reply, &junk);
    }
    UNLOCK_APP(app);

    return ((r == XtGeometryDone) ? XtGeometryYes : r);
}
Exemple #8
0
void XtUnrealizeWidget (
    Widget		widget)
{
    Window window;
    Widget hookobj;
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    window = XtWindow(widget);
    if (! XtIsRealized (widget)) {
        UNLOCK_APP(app);
        return;
    }
    if (widget->core.managed && widget->core.parent != NULL)
        XtUnmanageChild(widget);
    UnrealizeWidget(widget);
    if (window != None)
        XDestroyWindow(XtDisplay(widget), window);
    hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
        XtChangeHookDataRec call_data;

        call_data.type = XtHunrealizeWidget;
        call_data.widget = widget;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.changehook_callbacks,
                           (XtPointer)&call_data);
    }
    UNLOCK_APP(app);
} /* XtUnrealizeWidget */
Exemple #9
0
void XtResizeWindow(
    Widget w)
{
    XtConfigureHookDataRec req;
    Widget hookobj;
    WIDGET_TO_APPCON(w);

    LOCK_APP(app);
    if (XtIsRealized(w)) {
        req.changes.width = w->core.width;
        req.changes.height = w->core.height;
        req.changes.border_width = w->core.border_width;
        req.changeMask = CWWidth | CWHeight | CWBorderWidth;
        XConfigureWindow(XtDisplay(w), XtWindow(w),
                         (unsigned) req.changeMask, &req.changes);
        hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));;
        if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) {
            req.type = XtHconfigure;
            req.widget = w;
            XtCallCallbackList(hookobj,
                               ((HookObject)hookobj)->hooks.confighook_callbacks,
                               (XtPointer)&req);
        }
    }
    UNLOCK_APP(app);
} /* XtResizeWindow */
Exemple #10
0
void
cm_register_drop_site(
	Calendar	*c,
	Widget		w)

{
	XtCallbackRec	transfer_cb_rec[] = { {handle_drop_cb, NULL},
					      {NULL, NULL} };
	static XtCallbackRec animateCBRec[] = { {handle_animate_cb, NULL},
						{NULL, NULL} };
	Display		*display = XtDisplayOfObject(w);

	/*
	 * The above string "CalendarAppointment" is hard coded to match the type
	 * used in dtdnddemo.  In the future we need to use the true
	 * type from the data typing database
	 */

	transfer_cb_rec[0].closure = (XtPointer)c;
	animateCBRec[0].closure = (XtPointer)c;

	DtDndVaDropRegister(w, DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER,
			XmDROP_COPY,
			transfer_cb_rec, 
			DtNdropAnimateCallback, animateCBRec,
			DtNtextIsBuffer, 	True,
			NULL);
	return;
}
Exemple #11
0
void HGU_XmHelpShowUrl(
		       Widget	w,
		       char		*url)
{
  String	str;

  /* check initialisation */
  if( help_resources.help_dir == NULL ){
    HGU_XmHelpMenuInit( get_topl_widget( w ) );
  }

  /* check the url for relative or absolute */
  if( url == NULL )
    url = help_resources.help_default_url;

  if(strncmp(url, "file:",   5) &&
     strncmp(url, "http:",   5) &&
     strncmp(url, "gopher:", 7) &&
     strncmp(url, "WAIS:",   5) &&
     strncmp(url, "news:",   5) &&
     strncmp(url, "telnet:", 7) )
    {
      str = (String) malloc(sizeof(char) *
			    (strlen(url) +
			     strlen(help_resources.help_www_server) +
			     strlen(help_resources.help_dir) +
			     32));
      if( url[0] == '/' )
	sprintf(str, "%s%s", help_resources.help_www_server, url);
      else
	sprintf(str, "%s%s/%s", help_resources.help_www_server,
		help_resources.help_dir, url);
    }
  else
    {
      str = (String) malloc(sizeof(char) * (strlen(url) + 2));
      strcpy( str, url );
    }
  url = str;

  /* check that the viewer is available */
  if( HGU_XmHelpCreateViewer(w, url) ){
    HGU_XmUserError(w,
		    "Can't find or create a Netscape viewer\n"
		    " - please check the  helpViewer resource",
		    XmDIALOG_FULL_APPLICATION_MODAL);
    return;
  }

  /* create the command for Netscape */
  str = (String) malloc(sizeof(char) * (strlen(url) + 32));
  sprintf(str, "openURL(%s)", url);

  /* send the string to Netscape */
  hgu_remote_command(XtDisplayOfObject(w), netscape_window, (const char *) str,
		     True);

  return;
}
/*
 * Function:
 *	SetTabs
 *
 * Arguments:
 *	w	  - MultiSink Object
 *	tab_count - number of tabs in the list
 *	tabs	  - text positions of the tabs
 *
 * Description:
 *	Sets the Tab stops.
 */
static void
SetTabs(Widget w, int tab_count, short* tabs)
{
    MultiSinkObject sink = (MultiSinkObject)w;
    int i;
    Atom XA_FIGURE_WIDTH;
    unsigned long figure_width = 0;
    XFontStruct *font;

    /*
     * Bug:
     *	 Suppose the first font of fontset stores the unit of column.
     *
     * By Li Yuhong, Mar. 14, 1991
     */
    {
	XFontStruct **f_list;
	char **f_name;

	(void)XFontsOfFontSet(sink->multi_sink.fontset, &f_list, &f_name);
	font = f_list[0];
    }

    /*
     * Find the figure width of the current font
     */
    XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", False);
    if (XA_FIGURE_WIDTH != None
	&& (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)
	    || figure_width == 0)) {
	if (font->per_char && font->min_char_or_byte2 <= '$'
	    && font->max_char_or_byte2 >= '$')
	    figure_width = font->per_char['$' - font->min_char_or_byte2].width;
	else
	    figure_width = font->max_bounds.width;
    }

    if (tab_count > sink->text_sink.tab_count) {
	sink->text_sink.tabs = (Position *)
	    XtRealloc((char *)sink->text_sink.tabs,
		      (Cardinal)(tab_count * sizeof(Position)));
	sink->text_sink.char_tabs = (short *)
	    XtRealloc((char *)sink->text_sink.char_tabs,
		      (Cardinal)(tab_count * sizeof(short)));
      }

    for (i = 0 ; i < tab_count ; i++) {
	sink->text_sink.tabs[i] = tabs[i] * figure_width;
	sink->text_sink.char_tabs[i] = tabs[i];
    }

    sink->text_sink.tab_count = tab_count;

#ifndef NO_TAB_FIX
    ((TextWidget)XtParent(w))->text.redisplay_needed = True;
#endif
}
Exemple #13
0
/*============================================================ DndInitialize
 * Must be called anywhere before the top level widget creation and the
 * main loop. Initialize global variables and bind the DndDispatch function
 * to the top level widget. Creates the cursors to be used in drag actions.
 *=========================================================================*/
void
MwDndInitialize(Widget shell)
{
    int	 screen,i;
    Colormap colormap;
    Window	 root;

    dpy	= XtDisplayOfObject(shell);
    screen	= DefaultScreen(dpy);
    colormap= DefaultColormap(dpy,screen);
    root	= DefaultRootWindow(dpy);
		

    Black.pixel=BlackPixel(dpy,screen);
    White.pixel=WhitePixel(dpy,screen);
    XQueryColor(dpy,colormap,&Black);
    XQueryColor(dpy,colormap,&White);
	
    for(i=1;i!=MW_DndEND;i++)
    {
	DndCursor[i].ImagePixmap=
	    XCreateBitmapFromData(dpy,root,
				  DndCursor[i].ImageData,
				  DndCursor[i].Width,
				  DndCursor[i].Height);
	DndCursor[i].MaskPixmap=
	    XCreateBitmapFromData(dpy,root,
				  DndCursor[i].MaskData,
				  DndCursor[i].Width,
				  DndCursor[i].Height);
	DndCursor[i].CursorID=
	    XCreatePixmapCursor(dpy,DndCursor[i].ImagePixmap,
				DndCursor[i].MaskPixmap,
				&Black,&White,
				DndCursor[i].HotSpotX,
				DndCursor[i].HotSpotY);
    }
	
    DndCursor[0].CursorID=XCreateFontCursor(dpy,XC_question_arrow);
	
    /* These two are for older versions */
    OldDndProtocol=XInternAtom(dpy,"DndProtocol",FALSE);
    OldDndSelection=XInternAtom(dpy,"DndSelection",FALSE);
    /* Now the correct stuff */
    MwDndProtocol=XInternAtom(dpy,"_DND_PROTOCOL",FALSE);
    MwDndSelection=XInternAtom(dpy,"_DND_SELECTION",FALSE);
    
    WM_STATE=XInternAtom(dpy,"WM_STATE",True);
    Dragging=0;
    DragPrecision=10;
    XtAddEventHandler(shell,NoEventMask,True,MwDndDispatchEvent,NULL);
    OtherDrop=RootDrop=IconDrop=NULL;
    RootFlag=0;
    MainWidget=shell;
}
Exemple #14
0
/*
 * Syntesize a mouse-1 down event for the Widget w passed as second argument.
 * This can be, e.g. a dialog button, or some other window.
 */
void
synthesize_event(XEvent *ev, Widget w)
{
    memset(ev, 0, sizeof(XButtonPressedEvent));
    ev->type = ButtonPress;
    ev->xbutton.serial = 1;
    ev->xbutton.send_event = True;
    ev->xbutton.button = 1;
    ev->xbutton.display = XtDisplayOfObject(w);
    ev->xbutton.window = XtWindowOfObject(w);
}
Exemple #15
0
void draw(Widget w, Window win, Dimension width, Dimension height, Pixel color)
{
       GC drawGC;

       drawGC = XtAllocateGC(w,
                             0,0,
                             NULL,
                             0,0);

       XSetForeground(XtDisplayOfObject(w),
                      drawGC,
                      color);

       /* NOTE: the skip is per Motif -- no effort is made to avoid the
          shadows */
       XDrawRectangle(XtDisplayOfObject(w), win, drawGC,
                      10, 10, width - 20, height - 20);

       XtReleaseGC(w, drawGC);
}
Exemple #16
0
XtGeometryResult
XtMakeResizeRequest(
    Widget	widget,
    _XtDimension width,
    _XtDimension height,
    Dimension	*replyWidth,
    Dimension	*replyHeight)
{
    XtWidgetGeometry request, reply;
    XtGeometryResult r;
    XtGeometryHookDataRec call_data;
    Boolean junk;
    Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    request.request_mode = CWWidth | CWHeight;
    request.width = width;
    request.height = height;

    if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) {
        call_data.type = XtHpreGeometry;
        call_data.widget = widget;
        call_data.request = &request;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
        call_data.result = r =
                               _XtMakeGeometryRequest(widget, &request, &reply, &junk);
        call_data.type = XtHpostGeometry;
        call_data.reply = &reply;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
    } else {
        r = _XtMakeGeometryRequest(widget, &request, &reply, &junk);
    }
    if (replyWidth != NULL) {
        if (r == XtGeometryAlmost && reply.request_mode & CWWidth)
            *replyWidth = reply.width;
        else
            *replyWidth = width;
    }
    if (replyHeight != NULL) {
        if (r == XtGeometryAlmost && reply.request_mode & CWHeight)
            *replyHeight = reply.height;
        else
            *replyHeight = height;
    }
    UNLOCK_APP(app);
    return ((r == XtGeometryDone) ? XtGeometryYes : r);
} /* XtMakeResizeRequest */
Exemple #17
0
int HGU_XmHelpCreateViewer(
			   Widget	w,
			   char		*url)
{
  int	wait_time, time_out_period = 30;

  /* check initialisation */
  if( help_resources.help_dir == NULL ){
    HGU_XmHelpMenuInit( get_topl_widget( w ) );
  }

  /* get the viewer window */
  if( (netscape_window = hgu_remote_find_window(XtDisplayOfObject(w))) == (Window) 0 ){
    
    /* start up a netscape viewer */
    if( fork() == 0 ){

      execl(help_resources.help_viewer, "netscape", "-display", 
	    DisplayString(XtDisplayOfObject(w)), url, NULL);
      fprintf(stderr, 
	      "HGU_XmHelpUtilities: failed to start netscape viewer\n");
      exit( 1 ); 	/* if it returns the viewer can't execute */
    }

    /* wait for the netscape window */
    wait_time = 0;
    while( (netscape_window = hgu_remote_find_window(XtDisplayOfObject(w)))
	   == (Window) 0 ){
      sleep( 5 );
      wait_time += 5;
      if( wait_time >= time_out_period ){
	return( 1 );
      }
    }
  }

  return( 0 );
}
Exemple #18
0
void HGU_XmHelpOnContextCb(Widget	w,
			   XtPointer	client_data,
			   XtPointer	call_data)
{
  Widget		help_widget, topl;
  Cursor		cursor;
  XmAnyCallbackStruct	*cbs = (XmAnyCallbackStruct *) call_data;

  /* check initialisation */
  if( help_resources.help_dir == NULL ){
    HGU_XmHelpMenuInit( get_topl_widget( w ) );
  }

  cursor = XCreateFontCursor(XtDisplayOfObject(w), XC_hand2);
  topl = get_topl_widget( w );
  if( (help_widget = XmTrackingEvent(topl, cursor, False, cbs->event)) ){
    cbs->reason = XmCR_HELP;
    XtCallCallbacks(help_widget, XmNhelpCallback, &cbs);
  }
  XFreeCursor(XtDisplayOfObject(w), cursor);

  return;
}
Exemple #19
0
static void Redisplay(Widget w , XEvent *event , Region region)
{
	MwLineMEObject cw = (MwLineMEObject) w;
	Display * dpy = XtDisplayOfObject(w);
	Window win = XtWindowOfObject(w);

	XSetForeground(dpy , cw->lineME.gc , cw->baseME.dark);
	XFillRectangle(dpy , win , cw->lineME.gc , cw->rectangle.x , cw->rectangle.y ,
		cw->rectangle.width , cw->rectangle.height / 2);

	XSetForeground(dpy , cw->lineME.gc , cw->baseME.light);
	XFillRectangle(dpy , win , cw->lineME.gc , cw->rectangle.x , cw->rectangle.y +
		cw->rectangle.height / 2  , cw->rectangle.width , cw->rectangle.height);

}
Exemple #20
0
static void Initialize(Widget req_widget, Widget new_widget,
		ArgList args, Cardinal *num_args)
{
	MwLineMEObject nw = (MwLineMEObject) new_widget;
	Display * dpy = XtDisplayOfObject(new_widget);
	XGCValues gc_res;
	XtGCMask  gc_mask;

	gc_res.foreground = nw->baseME.foreground;
	gc_mask = GCForeground ;

	nw->lineME.gc = XCreateGC(dpy,DefaultRootWindow(dpy),
		gc_mask, &gc_res);

}
Exemple #21
0
/*
 * iconMergeBitmaps
 *
 * Create new bitmap consisting of the offset composition of the given bitmaps.
 */
static Pixmap
iconMergeBitmaps(
	Widget		widget,
	Pixmap		bitmap1,
	int		width1,
	int		height1,
	Pixmap		bitmap2,
	int		width2,
	int		height2,
	int		xOffset,
	int		yOffset,
	Boolean		clear)
{
	Display		*display = XtDisplayOfObject(widget);
	Window		window = DefaultRootWindow(display);
	int		screen = DefaultScreen(display);
	Pixmap		mergedBitmap, blankBitmap;
	int		extraX, extraY, width, height;
	static GC	graphicsContext = NULL;
	XGCValues	gcValues;

	extraX = width2 - width1 + xOffset + 1;
	if (extraX < 0) extraX = 0;
	width = width1 + extraX;

	extraY = height2 - height1 + yOffset + 1;
	if (extraY < 0) extraY = 0;
	height = height1 + extraY;

	mergedBitmap = XCreatePixmap(display, window, width, height, 1);

	if (graphicsContext == NULL) {
                graphicsContext = XCreateGC(display, mergedBitmap, 0L, NULL);
	}

	if (clear) {
		iconClearBitmap(display, window, graphicsContext, mergedBitmap,
			width, height);
	}

	XCopyArea(display, bitmap2, mergedBitmap, graphicsContext, 0, 0,
		width2, height2, xOffset, yOffset);

	XCopyArea(display, bitmap1, mergedBitmap, graphicsContext, 0, 0,
		width1, height1, 0, 0);

	return mergedBitmap;
}
Exemple #22
0
/* help_menu initialisation procedure */
void HGU_XmHelpMenuInit(Widget	topl)
{
  /* initialise the help resources */
  XtGetApplicationResources(topl, &help_resources, help_res,
			    XtNumber(help_res), NULL, 0);

  /* setup a temporary filename */
  help_str_file = (char *) malloc(sizeof(char) * 64);
  help_str_url = (char *) malloc(sizeof(char) * 72);
  sprintf(help_str_file, "/tmp/HGU_XmHelpMenu_%d.html", getpid());
  sprintf(help_str_url, "file:%s", help_str_file);

  /* setup the required atoms */
  mozilla_remote_init_atoms(XtDisplayOfObject(topl));

  return;
}
Exemple #23
0
void HGU_XmCreatePrivateColormap(Widget w)
{
  Display	*dpy;
  Window	win;
  Visual	*visual;
  Colormap	cmap, def_cmap;
  XColor	colorcell;
  unsigned long	plane_masks[1], pixels[256];
  unsigned int	n_pixels;
  int			i;

  /* create a private colormap */
  if( (dpy = XtDisplayOfObject( w )) == NULL )
    return;
  win = RootWindow( dpy, DefaultScreen( dpy ) );
  visual = HGU_XGetVisual(dpy, DefaultScreen( dpy ), PseudoColor, 8);
  if( visual == NULL ){
    visual = DefaultVisual( dpy, DefaultScreen( dpy ) );
  }
  cmap = XCreateColormap( dpy, win, visual, AllocNone );
  def_cmap = DefaultColormap( dpy, DefaultScreen( dpy ) );
    
  /* copy all existing colours */
  n_pixels = 0;
  colorcell.flags = DoRed|DoGreen|DoBlue;
  for(i=0; i < 256; i++){

    if( XAllocColorCells(dpy, cmap, False, plane_masks,
			 0, &(pixels[n_pixels]), 1) == 0 )
      continue;
    if( i >= 32 )	/* only free colours over pixel value 32 */
      n_pixels++;

    colorcell.pixel = i;
    XQueryColor(dpy, def_cmap, &colorcell);
    XStoreColor(dpy, cmap, &colorcell);
  }

  XFreeColors(dpy, cmap, pixels, n_pixels, 0);
    
  /* set the colormap as the widget resource */
  XtVaSetValues(w, XmNcolormap, cmap, NULL);
  globals.cmap = cmap;

  return;
}
Exemple #24
0
void sgnlResetSgnlDomain(
  Widget	w,
  WlzIVertex2	*selVtx)
{

  /* set the signal domain */
  if( warpGlobals.sgnlObj ){
    warpCanvasExposeCb(w, (XtPointer) &(warpGlobals.sgnl), NULL);
  }
  warpSetSignalDomain(selVtx);
  if( warpGlobals.sgnlObj ){
    warpDisplayDomain(&(warpGlobals.sgnl), warpGlobals.sgnlObj, 1);
  }
  XFlush(XtDisplayOfObject(w));

  return;
}
Exemple #25
0
/*
 * iconFree
 *
 * Deallocate the icon and associated resources.
 */
static void
iconFree(
	IconInfo	*iconPtr)
{
	Display		*display = XtDisplayOfObject(iconPtr->dragIcon);

	if (iconPtr == NULL) {
		return;
	}

	XtFree(iconPtr->name);
	/*
	 * REMIND: This needs to free other things too...
	 * XFreePixmap(display, iconPtr->bitmap);
	 * XFreePixmap(display, iconPtr->mask);
	 * Free(iconPtr->dragIcon);
	 */
	XtFree((char *)iconPtr);
}
Exemple #26
0
void XtUnmanageChildren (
    WidgetList children,
    Cardinal num_children)
{
    Widget parent, hookobj;
    Cardinal ii;
#ifdef XTHREADS
    XtAppContext app;
#endif

    if (num_children == 0) return;
    if (children[0] == NULL) {
	XtWarningMsg(XtNinvalidChild,XtNxtUnmanageChildren,XtCXtToolkitError,
		     "Null child found in argument list to unmanage",
		     (String *)NULL, (Cardinal *)NULL);
	return;
    }
#ifdef XTHREADS
    app = XtWidgetToApplicationContext(children[0]);
#endif
    LOCK_APP(app);
    parent = children[0]->core.parent;
    if (parent->core.being_destroyed) {
	UNLOCK_APP(app);
	return;
    }
    UnmanageChildren(children, num_children, parent, &ii,
		     (Boolean)True, XtNxtUnmanageChildren);
    hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0]));
    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
	XtChangeHookDataRec call_data;

	call_data.type = XtHunmanageChildren;
	call_data.widget = parent;
	call_data.event_data = (XtPointer) children;
	call_data.num_event_data = num_children;
	XtCallCallbackList(hookobj,
		((HookObject)hookobj)->hooks.changehook_callbacks,
		(XtPointer)&call_data);
    }
    UNLOCK_APP(app);
} /* XtUnmanageChildren */
Exemple #27
0
static void
gadget_border_highlight(Widget w)
{

    DEBUGOUT(_LtDebug(__FILE__, w, "gadget_border_highlight\n"));

    /* with zero width, we don't need this... */
    if (G_HighlightThickness(w) == 0)
    {
	return;
    }

    _XmDrawHighlight(XtDisplayOfObject(w), XtWindowOfObject(w),
		     XmParentHighlightGC(w),
		     XtX(w), XtY(w), XtWidth(w), XtHeight(w),
		     G_HighlightThickness(w), LineSolid);

    G_Highlighted(w) = True;
    G_HighlightDrawn(w) = True;
}
Exemple #28
0
void DumpGrabList(Widget w)
{
    XmDisplay    wd;
    XmModalData  modal;
    int          i;

    wd = (XmDisplay) XmGetXmDisplay(XtDisplayOfObject(w));
    printf("\n*** Grab List Dump ***\n");
    modal = wd->display.modals;
    printf("%i entries in grab list\n", wd->display.numModals);
    for ( i = 0; i < wd->display.numModals; i++ ) {
        printf("Entry #%i ----------\n", (int)(i + 1));
	DumpW((Widget) modal->wid,     "  wid     = ", "            ", "  ");
	DumpW((Widget) modal->ve,      "  ve      = ", "            ", "  ");
	DumpW((Widget) modal->grabber, "  grabber = ", "            ", "  ");
	printf("  exclusive = %s, spring loaded = %s\n",
	       modal->exclusive ? "Yes" : "No",
	       modal->springLoaded ? "Yes" : "No");
	modal++;
    }
} /* DumpGrabList */
void postProcRedoCb(
  Widget	w,
  XtPointer	client_data,
  XtPointer	call_data)
{
  WlzObject	*tmpObj;
  /* push current to undo stack and pop redo object */

  if((tmpObj = WlzObjListObj(sgnlPostProcRedoList))){
    warpCanvasExposeCb(w, (XtPointer) &(warpGlobals.sgnl), NULL);
    if( warpGlobals.sgnlObj ){
      WlzObjListPush(sgnlPostProcUndoList, warpGlobals.sgnlObj);
      WlzFreeObj(warpGlobals.sgnlObj);
    }
    warpGlobals.sgnlObj  = WlzAssignObject(tmpObj, NULL);
    WlzObjListPop(sgnlPostProcRedoList);
    warpDisplayDomain(&(warpGlobals.sgnl), warpGlobals.sgnlObj, 1);
    XFlush(XtDisplayOfObject(w));
  }
  
  return;
}
Exemple #30
0
/*
 * iconGetBitmap
 *
 * Get a bitmap for the icon based on the path and name of the icon. 
 * If no bitmap file is found use a built-in default.
 */
static Pixmap
iconGetBitmap(
	Widget		widget,
	char		*iconPath,
	IconBitmapPart	iconPart,
	unsigned short	*returnWidth,
	unsigned short	*returnHeight)
{
	Display		*display = XtDisplayOfObject(widget);
	Window		window = DefaultRootWindow(display);
	int		status;
	int		xHot, yHot;
	Pixmap		bitmap;
	unsigned int	width, height;
	
	*returnWidth = *returnHeight = 0;

	if (iconPath != NULL) {

		status = XReadBitmapFile(display, window, iconPath,
			&width, &height, &bitmap, &xHot, &yHot);

		if (status == BitmapSuccess) {
			*returnWidth = (unsigned short) width;
			*returnHeight = (unsigned short) height;
		} else {
			printf(
			    "Unable to read icon from bitmap file \"%s\".\n"
			    "Using default icon bitmap.\n",
			    iconPath, NULL);
			bitmap = iconDefaultBitmap(display, window, iconPart,
				returnWidth, returnHeight);
		}
	} else {
		bitmap = iconDefaultBitmap(display, window, iconPart,
			returnWidth, returnHeight);
	}
	return bitmap;
}