Exemplo n.º 1
0
void LoadGoodiesFont(void)
{
	if ((FStatusFont =
	     FlocaleLoadFont(dpy, statusfont_string, module->name)) == NULL)
	{
		fprintf(stderr, "%s: Couldn't load font. Exiting!\n",
                       module->name);
		exit(1);
	}
	goodies_fontheight = FStatusFont->height;
}
Exemplo n.º 2
0
void InitPopupMenu(struct XObj *xobj)
{
  unsigned long mask;
  XSetWindowAttributes Attr;
  int i;
  char *str;

  /* Enregistrement des couleurs et de la police / set the colors and the font
   */
  if (xobj->colorset >= 0) {
    xobj->TabColor[fore] = Colorset[xobj->colorset].fg;
    xobj->TabColor[back] = Colorset[xobj->colorset].bg;
    xobj->TabColor[hili] = Colorset[xobj->colorset].hilite;
    xobj->TabColor[shad] = Colorset[xobj->colorset].shadow;
  } else {
    xobj->TabColor[fore] = GetColor(xobj->forecolor);
    xobj->TabColor[back] = GetColor(xobj->backcolor);
    xobj->TabColor[hili] = GetColor(xobj->hilicolor);
    xobj->TabColor[shad] = GetColor(xobj->shadcolor);
  }

  mask = 0;
  Attr.background_pixel = xobj->TabColor[back];
  mask |= CWBackPixel;
  Attr.cursor = XCreateFontCursor(dpy, XC_hand2);
  mask |= CWCursor;             /* Curseur pour la fenetre / window cursor */

  xobj->win = XCreateWindow(dpy, *xobj->ParentWin,
		xobj->x, xobj->y, xobj->width, xobj->height, 0,
		CopyFromParent, InputOutput, CopyFromParent,
		mask, &Attr);
  xobj->gc = fvwmlib_XCreateGC(dpy, xobj->win, 0, NULL);
  XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);

  if ((xobj->Ffont = FlocaleLoadFont(dpy, xobj->font, ScriptName)) == NULL)
  {
    fprintf(stderr, "%s: Couldn't load font. Exiting!\n", ScriptName);
    exit(1);
  }
  if (xobj->Ffont->font != NULL)
    XSetFont(dpy, xobj->gc, xobj->Ffont->font->fid);

  XSetLineAttributes(dpy, xobj->gc, 1, LineSolid, CapRound, JoinMiter);
  xobj->value3 = CountOption(xobj->title);
  if (xobj->value > xobj->value3)
    xobj->value = xobj->value3;
  if (xobj->value < 1)
    xobj->value = 1;

  /* Redimensionnement du widget / Widget resizing */
  xobj->height = xobj->Ffont->height  +12;
  xobj->width = 30;
  for (i = 1; i <= xobj->value3; i++)
  {
    str = (char*)GetMenuTitle(xobj->title, i);
    if (xobj->width < FlocaleTextWidth(xobj->Ffont, str, strlen(str))+34)
      xobj->width = FlocaleTextWidth(xobj->Ffont, str, strlen(str))+34;
    free(str);
  }
  XResizeWindow(dpy, xobj->win, xobj->width, xobj->height);
  if (xobj->colorset >= 0)
    SetWindowBackground(dpy, xobj->win, xobj->width, xobj->height,
			&Colorset[xobj->colorset], Pdepth,
			xobj->gc, True);
  XSelectInput(dpy, xobj->win, ExposureMask);
}
Exemplo n.º 3
0
/*
 * Fonction pour PushButton
 */
void InitPushButton(struct XObj *xobj)
{
	unsigned long mask;
	XSetWindowAttributes Attr;
	int i;
	char *str;

	/* Enregistrement des couleurs et de la police */
	if (xobj->colorset >= 0) {
		xobj->TabColor[fore] = Colorset[xobj->colorset].fg;
		xobj->TabColor[back] = Colorset[xobj->colorset].bg;
		xobj->TabColor[hili] = Colorset[xobj->colorset].hilite;
		xobj->TabColor[shad] = Colorset[xobj->colorset].shadow;
	} else {
		xobj->TabColor[fore] = GetColor(xobj->forecolor);
		xobj->TabColor[back] = GetColor(xobj->backcolor);
		xobj->TabColor[hili] = GetColor(xobj->hilicolor);
		xobj->TabColor[shad] = GetColor(xobj->shadcolor);
	}

	mask = 0;
	Attr.cursor = XCreateFontCursor(dpy, XC_hand2);
	mask |= CWCursor;
	Attr.background_pixel = xobj->TabColor[back];
	mask |= CWBackPixel;


	/* Epaisseur de la fenetre = 0 */
	xobj->win = XCreateWindow(
		dpy, *xobj->ParentWin, xobj->x, xobj->y, xobj->width,
		xobj->height, 0, CopyFromParent, InputOutput, CopyFromParent,
		mask, &Attr);
	xobj->gc = fvwmlib_XCreateGC(dpy, xobj->win, 0, NULL);
	XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);

	if ((xobj->Ffont = FlocaleLoadFont(
		     dpy, xobj->font, ScriptName)) == NULL)
	{
		fprintf(
			stderr, "%s: Couldn't load font. Exiting!\n",
			ScriptName);
		exit(1);
	}
	if (xobj->Ffont->font != NULL)
		XSetFont(dpy, xobj->gc, xobj->Ffont->font->fid);

	XSetLineAttributes(dpy, xobj->gc, 1, LineSolid, CapRound, JoinMiter);

	/* Redimensionnement du widget */
	str = (char*)GetMenuTitle(xobj->title, 1);
	if (xobj->icon == NULL)
	{
		i = xobj->Ffont->height + 12;
		if (xobj->height < i)
			xobj->height = i;
		i = FlocaleTextWidth(xobj->Ffont, str, strlen(str)) + 16;
		if (xobj->width < i)
			xobj->width = i;
	}
	else if (strlen(str) == 0)
	{
		if (xobj->height < xobj->icon_h + 10)
			xobj->height = xobj->icon_h + 10;
		if (xobj->width < xobj->icon_w + 10)
			xobj->width = xobj->icon_w + 10;
	}
	else
	{
		if (xobj->icon_w + 10 > FlocaleTextWidth(
			    xobj->Ffont, str, strlen(str)) + 16)
			i = xobj->icon_w + 10;
		else
			i = FlocaleTextWidth(
				xobj->Ffont, str, strlen(str)) + 16;
		if (xobj->width < i)
			xobj->width = i;
		i = xobj->icon_h+ 2 * (xobj->Ffont->height + 10);
		if (xobj->height < i)
			xobj->height = i;
	}
	XResizeWindow(dpy, xobj->win, xobj->width, xobj->height);
	if (xobj->colorset >= 0)
		SetWindowBackground(dpy, xobj->win, xobj->width, xobj->height,
				    &Colorset[xobj->colorset], Pdepth,
				    xobj->gc, True);
	xobj->value3 = CountOption(xobj->title);
	XSelectInput(dpy, xobj->win, ExposureMask);
}
Exemplo n.º 4
0
void InitTextField(struct XObj *xobj)
{
	unsigned long mask;
	XSetWindowAttributes Attr;
	int i;
	int num_chars;

	/* Enregistrement des couleurs et de la police */
	/* colors and fonts */
	if (xobj->colorset >= 0) {
		xobj->TabColor[fore] = Colorset[xobj->colorset].fg;
		xobj->TabColor[back] = Colorset[xobj->colorset].bg;
		xobj->TabColor[hili] = Colorset[xobj->colorset].hilite;
		xobj->TabColor[shad] = Colorset[xobj->colorset].shadow;
	} else {
		xobj->TabColor[fore] = GetColor(xobj->forecolor);
		xobj->TabColor[back] = GetColor(xobj->backcolor);
		xobj->TabColor[hili] = GetColor(xobj->hilicolor);
		xobj->TabColor[shad] = GetColor(xobj->shadcolor);
	}

	mask=0;
	Attr.cursor=XCreateFontCursor(dpy,XC_xterm);
	mask|=CWCursor; /* Curseur pour la fenetre / window cursor */
	Attr.background_pixel=xobj->TabColor[back];
	mask|=CWBackPixel;

	xobj->win=XCreateWindow(dpy,*xobj->ParentWin,
				xobj->x,xobj->y,xobj->width,xobj->height,0,
				CopyFromParent,InputOutput,CopyFromParent,
				mask,&Attr);
	xobj->gc=fvwmlib_XCreateGC(dpy,xobj->win,0,NULL);
	XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]);

	if ((xobj->Ffont = FlocaleLoadFont(
		     dpy, xobj->font, ScriptName)) == NULL)
	{
		fprintf(
			stderr, "%s: Couldn't load font. Exiting!\n",
			ScriptName);
		exit(1);
	}
	if (xobj->Ffont->font != NULL)
		XSetFont(dpy, xobj->gc, xobj->Ffont->font->fid);

	XSetLineAttributes(dpy,xobj->gc,1,LineSolid,CapRound,JoinMiter);
	/* value2 représente la fin de la zone selectionnee */
	/* value2 gives the end of the selected zone */
	/* calculate number of characters in title */
	num_chars = FlocaleStringCharLength(xobj->Ffont, xobj->title);
	if (xobj->value > num_chars)
		xobj->value = num_chars;
	xobj->value2=xobj->value;
	/* left position of the visible title */
	xobj->value3=0;

	/* Redimensionnement du widget */
	/* widget resizing */
	xobj->height= xobj->Ffont->height + 10;
	i = FlocaleTextWidth(xobj->Ffont,xobj->title,strlen(xobj->title))+40;
	if (xobj->width<i)
		xobj->width=i;
	XResizeWindow(dpy,xobj->win,xobj->width,xobj->height);
	if (xobj->colorset >= 0)
		SetWindowBackground(dpy, xobj->win, xobj->width, xobj->height,
				    &Colorset[xobj->colorset], Pdepth,
				    xobj->gc, True);
	XSelectInput(dpy, xobj->win, ExposureMask);
}
Exemplo n.º 5
0
void InitVScrollBar(struct XObj *xobj)
{
	unsigned long mask;
	XSetWindowAttributes Attr;
	int i,j;
	char str[20];

	/* Enregistrement des couleurs et de la police */
	if (xobj->colorset >= 0) {
		xobj->TabColor[fore] = Colorset[xobj->colorset].fg;
		xobj->TabColor[back] = Colorset[xobj->colorset].bg;
		xobj->TabColor[hili] = Colorset[xobj->colorset].hilite;
		xobj->TabColor[shad] = Colorset[xobj->colorset].shadow;
	} else {
		xobj->TabColor[fore] = GetColor(xobj->forecolor);
		xobj->TabColor[back] = GetColor(xobj->backcolor);
		xobj->TabColor[hili] = GetColor(xobj->hilicolor);
		xobj->TabColor[shad] = GetColor(xobj->shadcolor);
	}

	mask = 0;
	Attr.background_pixel = xobj->TabColor[back];
	mask |= CWBackPixel;
	Attr.cursor = XCreateFontCursor(dpy,XC_hand2);
	mask |= CWCursor;             /* Curseur pour la fenetre */

	xobj->win = XCreateWindow(
		dpy, *xobj->ParentWin, xobj->x, xobj->y, xobj->width,
		xobj->height, 0, CopyFromParent, InputOutput, CopyFromParent,
		mask, &Attr);
	xobj->gc = fvwmlib_XCreateGC(dpy, xobj->win, 0, NULL);
	XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);


	if ((xobj->Ffont = FlocaleLoadFont(dpy, xobj->font, ScriptName)) ==
	    NULL)
	{
		fprintf(
			stderr, "%s: Couldn't load font. Exiting!\n",
			ScriptName);
		exit(1);
	}
	if (xobj->Ffont->font != NULL)
		XSetFont(dpy, xobj->gc, xobj->Ffont->font->fid);

	XSetLineAttributes(dpy, xobj->gc, 1, LineSolid, CapRound, JoinMiter);

	if ((xobj->value3 - xobj->value2) <= 0)
		xobj->value3 = xobj->value2 + 10;
	if (!((xobj->value >= xobj->value2) && (xobj->value <= xobj->value3)))
		xobj->value = xobj->value2;

	i = (xobj->Ffont->height)*2+30;
	if (xobj->height < i)
		xobj->height = i;
	sprintf(str, "%d", xobj->value2);
	i = FlocaleTextWidth(xobj->Ffont, str, strlen(str));
	sprintf(str, "%d", xobj->value3);
	j = FlocaleTextWidth(xobj->Ffont, str, strlen(str));
	if (i<j)
		i = j*2+30;
	else
		i = i*2+30;
	xobj->width = i;
	XResizeWindow(dpy, xobj->win, xobj->width, xobj->height);
	if (xobj->colorset >= 0)
		SetWindowBackground(dpy, xobj->win, xobj->width, xobj->height,
				    &Colorset[xobj->colorset], Pdepth,
				    xobj->gc, True);
	XSelectInput(dpy, xobj->win, ExposureMask);
}