Beispiel #1
0
static void
get_icons(
	Widget w)
{
  Arg args[2];
  Pixel background, foreground, top_shadow, bottom_shadow, select;
  Colormap colormap;

  unsigned int width1, width2, height, dummy;

  /* get foreground and background colors */
  XtSetArg (args[0], XmNbackground, &background);
  XtSetArg (args[1], XmNcolormap,  &colormap);
  XtGetValues (w, args, 2);
  XmGetColors ( XtScreen(w) , colormap, background,
	       &foreground, &top_shadow, &bottom_shadow, &select);

  /* get "working" pixmap */
  pxWorking = XmGetPixmapByDepth(XtScreen(w), "xm_working",
                                 foreground, background, w->core.depth);
  if (pxWorking == XmUNSPECIFIED_PIXMAP)
    pxWorking = XmGetPixmapByDepth(XtScreen(w), "default_xm_working",
                                   foreground, background, w->core.depth);

  /* get "stopped/done" pixmap */
  pxStopped = XmGetPixmapByDepth(XtScreen(w), "xm_information",
                                 foreground, background, w->core.depth);
  if (pxStopped == XmUNSPECIFIED_PIXMAP)
    pxStopped = XmGetPixmapByDepth(XtScreen(w), "default_xm_information",
                                   foreground, background, w->core.depth);

  /* get the width of the two pixmaps */
  XGetGeometry(XtDisplay(w), pxWorking,
               (Window *) &dummy,               /* returned root window */
               (int *) &dummy, (int *) &dummy,  /* x, y of pixmap */
               &width1, &height,                /* pixmap width, height */
               &dummy, &dummy);                 /* border width, depth */
  XGetGeometry(XtDisplay(w), pxStopped,
               (Window *) &dummy,               /* returned root window */
               (int *) &dummy, (int *) &dummy,  /* x, y of pixmap */
               &width2, &height,                /* pixmap width, height */
               &dummy, &dummy);                 /* border width, depth */

  /* Compute margins necessary to make the labels the same width */
  if (width1 > width2)
  {
    pxWorkingMargin = 0;
    pxStoppedMargin = width1 - width2;
  }
  else
  {
    pxWorkingMargin = width2 - width1;
    pxStoppedMargin = 0;
  }
}
Beispiel #2
0
/*
 * This one is going to be obsolete in Motif 2.0...
 */
Pixmap
_XmGetPixmap(Screen *screen, char *image_name, int depth,
	     Pixel foreground, Pixel background)
{
    return XmGetPixmapByDepth(screen, image_name,
			      foreground, background, depth);
}
Beispiel #3
0
static Pixmap
ConvertPixmap(char *file_name, int depth)
#endif
{
    XrmValue fg_from,
        fg_to,
        bg_from,
        bg_to;
    Pixel fg,
        bg;

    fg_from.size = strlen(XtDefaultForeground);
    fg_from.addr = XtDefaultForeground;
    fg_to.addr = (XPointer) & fg;
    bg_from.size = strlen(XtDefaultBackground);
    bg_from.addr = XtDefaultBackground;
    bg_to.addr = (XPointer) & bg;
    if (!XtConvertAndStore
	(UxTopLevel, XtRString, &bg_from, XtRPixel, &bg_to)
	|| !XtConvertAndStore
	(UxTopLevel, XtRString, &fg_from, XtRPixel, &fg_to)
	|| (fg == bg)) {
	fg = WhitePixelOfScreen(XtScreen(UxTopLevel));
	bg = BlackPixelOfScreen(XtScreen(UxTopLevel));
    }
    if (depth)
	return (XmGetPixmapByDepth
		(XtScreen(UxTopLevel), file_name, fg, bg, depth));

    else
	return (XmGetPixmap(XtScreen(UxTopLevel), file_name, fg, bg));
}
Beispiel #4
0
/*
 * A pixmap caching function that generates a pixmap, stores it in a pixmap
 * cache and returns the pixmap.
 */
extern Pixmap
XmGetPixmap(Screen *screen, char *image_name,
	    Pixel foreground, Pixel background)
{
    Pixmap p;

    p = XmGetPixmapByDepth(screen, image_name, foreground, background,
			   DefaultDepthOfScreen(screen));

    DEBUGOUT(_LtDebug(__FILE__, NULL,
		      "XmGetPixmap(%s, %d, %d) => 0x%x (depth %d)\n",
		      image_name, foreground, background, p,
		      DefaultDepthOfScreen(screen)));

    return p;
}
Beispiel #5
0
// Pixmap caching utility
void MotifUI::GetPixmaps(Widget w,
                         char *name,
                         Pixmap *pixmap,
                         Pixmap *mask)
{
   // Try to find pixmap in cache
   PixmapLookupList pixmaps = pixmap_table;
   int i;
   for (i = 0; i < n_pixmaps; i++, pixmaps++)
      if (!strcmp((**pixmaps).name, name))
       {
	 *pixmap = (**pixmaps).pixmap;
	 if (mask)
	    *mask = (**pixmaps).mask;
	 return;
       }

   Pixmap _mask;
   char *s;
   SubstitutionRec subs[1];
   char *bmPath;
   char *PIXMAP_DIR = "/usr/dt/appconfig/icons/%L/%B:"
                      "/usr/dt/appconfig/icons/C/%B:"
                      "/usr/include/X11/bitmaps/%B";

   if (*name == '/')
     s = name;
   else
    {
#ifdef NO_CDE
      if ((s = getenv("XBMLANGPATH")) && *s)
#else
      if ((s = getenv("XMICONSEARCHPATH")) && *s)
#endif
       {
         bmPath = new char [strlen(s) + strlen(PIXMAP_DIR) + 2];
         sprintf(bmPath, "%s:%s", PIXMAP_DIR, s);
       }
      else
         bmPath = PIXMAP_DIR;
      subs[0].match = 'B';
      subs[0].substitution = name;
      s = XtFindFile(bmPath, subs, XtNumber(subs), NULL);
      if (bmPath != PIXMAP_DIR)
         delete [] bmPath;
    }

   struct stat statbuf;
   if (!s || stat(s, &statbuf) < 0)
    {
      *pixmap = XmUNSPECIFIED_PIXMAP;
      if (mask)
         *mask = XmUNSPECIFIED_PIXMAP;
      return;
    }

   int len = strlen(s);
   if (!strcmp(s + len - 3, ".pm"))
    {
      XpmAttributes attributes;
      memset((char *)&attributes, 0, sizeof(XpmAttributes));
#ifdef NO_CDE
      XpmReadFileToPixmap(display, root, s, pixmap, &_mask, &attributes);
#else
      _DtXpmReadFileToPixmap(display, root, s, pixmap, &_mask, &attributes);
#endif

      if (_mask)
         FillBackground(w, *pixmap, _mask);
#ifdef NO_CDE
      XpmFreeAttributes(&attributes);
#else
      _DtXpmFreeAttributes(&attributes);
#endif
    }
   else
    {
      if (UIClass() == MAIN_WINDOW)
         *pixmap = XmGetPixmapByDepth(XtScreen(w), s, white, black, depth);
      else
         *pixmap = XmGetPixmapByDepth(XtScreen(w), s, black, white, depth);
      char *s1 = new char [len + 3];
      strcpy(s1, s);
      strcpy(s1 + len - 3, "_m.bm");
      if (stat(s1, &statbuf) < 0)
         _mask = XmUNSPECIFIED_PIXMAP;
      else
       {
         _mask = XmGetPixmapByDepth(XtScreen(w), s1, white, black, 1);
         FillBackground(w, *pixmap, _mask);
       }
      delete [] s1;
    }
   if (mask)
      *mask = _mask;
   if (s != name)
      XtFree(s);

   // Add pixmap to table
   if (!(n_pixmaps % 8))
    {
      pixmaps = new PixmapLookup [n_pixmaps + 8];
      for (i = 0; i < n_pixmaps; i++)
	 pixmaps[i] = pixmap_table[i];
      for (i = n_pixmaps; i < n_pixmaps + 8; i++)
	 pixmaps[i] = new PixmapLookupStruct;
      delete []pixmap_table;
      pixmap_table = pixmaps;
    }
   pixmap_table[n_pixmaps]->name = strdup(name);
   pixmap_table[n_pixmaps]->pixmap = *pixmap;
   pixmap_table[n_pixmaps]->mask = _mask;
   n_pixmaps++;
}
Beispiel #6
0
void
create_overwrite_dialog(
	Widget parent_widget,
	char *sname,
	char *tname,
	Boolean isdir)
{
  char  buf[2048];
  char  tfolder[MAX_PATH], tobject[MAX_PATH];                      /* t for target */
  char  gname[MAX_PATH], gfolder[MAX_PATH], gobject[MAX_PATH]; /* g for generated */

  Arg args[10];
  int n =0;
  int i;
  XmString msg;
  XmString xm_string[N_OVERWRITE_RADIO_BUTTONS];
  Widget radiobtn[N_OVERWRITE_RADIO_BUTTONS];
  Widget form, outerFrame;
  Widget action_label, icon, action_area, separator, msg_label;
  Pixel background, foreground;
  Pixmap px;
  Position x, y;

  static ActionAreaItem action_items[] = {
    {"Ok",          6, 1, ok_callback,               NULL},
    {"Cancel Copy", 6, 7, overwrite_cancel_callback, NULL},  /* possibly changed below to "Cancel Move" */
    {"Help",        6, 4, help_callback,             (XtPointer) HELP_OVERWRITE},
  };

  ActionAreaDefn overwriteActions = {
     XtNumber(action_items),
     0,                      /* Ok is default action */
     action_items
  };


  /* save the target name for possible rename in ok_callback */
  strcpy(G_rename_oldname,tname);


  if (G_move)
  {
     action_items[2].label   = "Cancel Move";
     action_items[2].msg_num = 8;
  }

  /* Create the dialog shell for the dialog */
  n = 0;
  XtSetArg (args[n], XmNallowShellResize,  True);   n++;
  XtSetArg (args[n], XmNmappedWhenManaged, FALSE); n++;
  if (G_move)
  {
     XtSetArg (args[n], XmNtitle, GETMESSAGE(5, 2, "Folder Move - File Overwrite"));
     n++;
  }
  else
  {
     XtSetArg (args[n], XmNtitle, GETMESSAGE(5, 9, "Folder Copy - File Overwrite"));
     n++;
  }
  G_over_dialog = XmCreateDialogShell (parent_widget, "dialog_shell", args, n);

   /* create a frame around the dialog for better separation from window border */
  outerFrame = XtVaCreateWidget("outerFrame",
                             xmFrameWidgetClass,
                             G_over_dialog,
                             XmNshadowThickness, 3,
                             XmNshadowType, XmSHADOW_ETCHED_IN,
                             NULL);

  /* Create the Manager Widget, form, for the copy dialog */
  form  = XtVaCreateWidget ("dialog_form",
  			     xmFormWidgetClass,
                             outerFrame,
                             XmNverticalSpacing,   VERTICAL_SPACING,
                             XmNhorizontalSpacing, HORIZONTAL_SPACING,
                             NULL);

  /* Create a question dialog icon */
  n = 0;
  XtSetArg (args[n], XmNbackground, &background); n++;
  XtSetArg (args[n], XmNforeground, &foreground); n++;
  XtGetValues (form, args, n);

  px = XmGetPixmapByDepth(XtScreen(form), "xm_question",
                          foreground, background, form->core.depth);
  if (px == XmUNSPECIFIED_PIXMAP)
    px = XmGetPixmapByDepth(XtScreen(form), "default_xm_question",
                     foreground, background, form->core.depth);

  icon = XtVaCreateManagedWidget("question_icon",
                             xmLabelWidgetClass,
                             form,
                             XmNlabelType,        XmPIXMAP,
                             XmNlabelPixmap,      px,
                             XmNtopAttachment,    XmATTACH_FORM,
                             XmNleftAttachment,   XmATTACH_FORM,
                             NULL);

  /* Create the message label */
  split_path(tname,tfolder,tobject);
  sprintf(buf,
          GETMESSAGE(5, 1, "A file named\n%s\nalready exists inside the folder\n%s"),
          tobject, tfolder);
  msg = XmStringCreateLocalized(buf);
  msg_label = XtVaCreateManagedWidget("msg_header",
                             xmLabelWidgetClass,
                             form,
                             XmNlabelString,      msg,
                             XmNalignment,        XmALIGNMENT_BEGINNING,
                             XmNtopAttachment,    XmATTACH_FORM,
                             XmNleftAttachment,   XmATTACH_WIDGET,
                             XmNleftWidget,       icon,
                             XmNleftOffset,       HORIZONTAL_SPACING,
                             XmNrightAttachment,  XmATTACH_FORM,
                             NULL);
  XmStringFree(msg);


  /* create the action-question */
  msg = XmStringCreateLocalized(GETMESSAGE(5, 8, "Action to take:"));
  action_label = XtVaCreateManagedWidget("action-question",
                             xmLabelWidgetClass,
                             form,
                             XmNlabelString,      msg,
                             XmNalignment,        XmALIGNMENT_BEGINNING,
                             XmNtopAttachment,    XmATTACH_WIDGET,
                             XmNtopWidget,        msg_label,
                             XmNtopOffset,        2*VERTICAL_SPACING,
                             XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET,
                             XmNleftWidget,       msg_label,
                             NULL);
  XmStringFree(msg);


  /* create radio box */

  n = 0;
  XtSetArg (args[n], XmNorientation,      XmVERTICAL);               n++;
  XtSetArg (args[n], XmNtopAttachment,    XmATTACH_WIDGET);          n++;
  XtSetArg (args[n], XmNtopWidget,        action_label);             n++;
  XtSetArg (args[n], XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET); n++;
  XtSetArg (args[n], XmNleftWidget,       action_label);             n++;
  XtSetArg (args[n], XmNleftOffset,       2*HORIZONTAL_SPACING);     n++;
  G_overwrite_radio = (Widget) XmCreateRadioBox(form, "radio_box", args, n);

  /* create the radio buttons */
  xm_string[G_OVERWRITE_EXISTING] = XmStringCreateLocalized(
                        GETMESSAGE(5, 3, "Replace existing file"));
  xm_string[G_RENAME_EXISTING] = XmStringCreateLocalized(
                        GETMESSAGE(5, 4, "Rename existing file to:"));
  xm_string[G_SKIP] = XmStringCreateLocalized(
                        GETMESSAGE(5, 6, "Skip this file"));


  for (i=0; i < N_OVERWRITE_RADIO_BUTTONS ;i++ )
     {

       radiobtn[i] = XtVaCreateManagedWidget("radio_toggle",
                                            xmToggleButtonWidgetClass, G_overwrite_radio,
                                            XmNalignment,   XmALIGNMENT_BEGINNING,
                                            XmNlabelString, xm_string[i],
                                            NULL);
       XtAddCallback(radiobtn[i], XmNvalueChangedCallback, radio_callback, (XtPointer)(XtArgVal) i);
       XmStringFree(xm_string[i]);
     }

  /* initially set replace-file radio button to TRUE */
  G_overwrite_selection = G_OVERWRITE_EXISTING;
  n=0;
  XtSetArg (args[n], XmNset, TRUE); n++;
  XtSetValues(radiobtn[G_overwrite_selection], args, n);

  /* create text field for entering a new file name */
  generate_NewPath(gname,tname);
  split_path(gname,gfolder,gobject);
  G_rename_text = XtVaCreateManagedWidget("rename_text",
                              xmTextFieldWidgetClass,
                              form,
                              XmNleftAttachment,        XmATTACH_WIDGET,
                              XmNleftWidget,            G_overwrite_radio,
                              XmNleftOffset,       	HORIZONTAL_SPACING,
                              XmNbottomAttachment,      XmATTACH_OPPOSITE_WIDGET,
                              XmNbottomWidget,          G_overwrite_radio,
                              XmNrightAttachment,      XmATTACH_FORM,
                              XmNrightOffset,          5,
                 	      XmNvalue, 		gobject,
                 	      XmNsensitive, 		FALSE,
                 	      XmNcursorPosition,        strlen(gobject),
                              NULL);


  /* create the toggle button */
  msg = XmStringCreateLocalized(GETMESSAGE(5, 7, "Apply this action to subsequent name conflicts"));
  G_over_confirm = XtVaCreateManagedWidget("over_confirm",
  			     xmToggleButtonWidgetClass,
  			     form,
                             XmNlabelString,      msg,
                             XmNset,              !G_overwrite_confirm,
                             XmNtopAttachment,    XmATTACH_WIDGET,
                             XmNtopWidget,        G_overwrite_radio,
                             XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET,
                             XmNleftWidget,       action_label,
                             XmNleftOffset,       0,
                             XmNrightAttachment,  XmATTACH_FORM,
                             XmNalignment,        XmALIGNMENT_BEGINNING,
                             NULL);
  XtAddCallback(G_over_confirm, XmNvalueChangedCallback, confirmtoggle_callback, NULL);
  XmStringFree(msg);

  /* create the action area of the Copy Directory Dialog */
  action_area = Create_Action_Area(form, overwriteActions, NULL);
  separator  =  XtVaCreateManagedWidget("separator",
                             xmSeparatorWidgetClass,
                             form,
                             XmNtopAttachment,     XmATTACH_WIDGET,
                             XmNtopWidget,         G_over_confirm,
                             XmNbottomAttachment,  XmATTACH_WIDGET,
                             XmNbottomWidget,      action_area,
                             XmNleftAttachment,    XmATTACH_FORM,
                             XmNrightAttachment,   XmATTACH_FORM,
                             NULL);


  /* set initial keyborad focus to the action button area */
  XtSetArg (args[0], XmNinitialFocus, action_area);
  XtSetValues(form, args, 1);

  /* Manage the overwrite Directory Dialog */
  XtManageChild(G_overwrite_radio);
  XtManageChild(form);
  XtManageChild(outerFrame);

  /* Choose a window position */
  _DtChildPosition(G_over_dialog, parent_widget, &x, &y);
  n=0;
  XtSetArg (args[n], XmNx, x); n++;
  XtSetArg (args[n], XmNy, y); n++;
  XtSetValues(G_over_dialog, args, n);

  /* Now that we have a window postion, map the dialog shell */
  XtMapWidget(G_over_dialog);

  return;
}
Beispiel #7
0
int
main(int argc, char **argv)
{
  Widget toplevel, rc, one;
  XtAppContext app;

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "BubbleButtonTest", NULL, 0, &argc, argv, NULL, NULL);

  rc = XmCreateRowColumn(toplevel, "RC", NULL, 0);

  one = XltCreateBubbleButton(rc, "BubbleButton1", NULL, 0);
  XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL);
  {
  XmString string;

  string = XmStringCreateSimple("MouseOver");
  XtVaSetValues(one,
  	XmNalignment, XmALIGNMENT_CENTER,
  	XltNmouseOverString, string,
  	NULL);
  XmStringFree(string);
  }
  XtManageChild(one);
  one = XltCreateBubbleButton(rc, "BubbleButton2", NULL, 0);
  {
    Pixmap pixmap;
    Pixmap pixmap_insens;
    XpmAttributes attrib;
    GC gc;

    {
	XpmColorSymbol colors[1];

	XtVaGetValues(one,
		      XmNbackground, &colors[0].pixel,
		      NULL);
	colors[0].name = NULL;
	colors[0].value = "None";
	attrib.valuemask = XpmCloseness | XpmColorSymbols;
	attrib.closeness = 40000;
	attrib.colorsymbols = colors;
	attrib.numsymbols = 1;
	XpmCreatePixmapFromData(XtDisplay(one),
				XRootWindowOfScreen(XtScreen(one)),
				dates,
				&pixmap,
				NULL,
				&attrib);

	pixmap_insens = XCreatePixmap(XtDisplay(one),
				      pixmap,
				      attrib.width,
				      attrib.height,
				      DefaultDepthOfScreen(XtScreen(one)));
	gc = XDefaultGCOfScreen(XtScreen(one));
	XSetFunction(XtDisplay(one),gc,GXcopy);
	XCopyArea(XtDisplay(one),
		  pixmap,
		  pixmap_insens,
		  gc,
		  0, 0,
		  attrib.width, attrib.height,
		  0, 0);
	XSetFillStyle(XtDisplay(one), gc, FillStippled);
	XSetStipple(XtDisplay(one), gc,
		    XmGetPixmapByDepth(XtScreen(one),
				       "25_foreground",
				       1 /*WhitePixelOfScreen(XtScreen(ToolBar))*/,
				       0 /*BlackPixelOfScreen(XtScreen(ToolBar))*/,
				       1));
	XFillRectangle(XtDisplay(one),
		       pixmap_insens,
		       gc,
		       0, 0,
		       attrib.width + 1, attrib.height + 1);

	XpmFreeAttributes(&attrib);

	XtVaSetValues(one,
		      XmNalignment, XmALIGNMENT_CENTER,
		      XmNlabelType, XmPIXMAP,
		      XmNlabelPixmap, pixmap,
		      XltNmouseOverPixmap, pixmap_insens,
		      NULL);
    }
  }
  XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL);
  XtManageChild(one);

  XtManageChild(rc);

  XtRealizeWidget(toplevel);
  XtAppMainLoop(app);

  exit(0);
}