Exemple #1
0
void DrawHDipstick(struct XObj *xobj, XEvent *evp)
{
 int  i;

 i=(xobj->width-4)*(xobj->value-xobj->value2)/(xobj->value3-xobj->value2);

 DrawReliefRect(0,0,xobj->width,xobj->height,xobj,shad,hili);
 if (i!=0)
 {
  DrawReliefRect(2,2,i,xobj->height-4,xobj,hili,shad);
  XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]);
  XFillRectangle(dpy,xobj->win,xobj->gc,4,4,i-4,xobj->height-8);
 }

}
Exemple #2
0
void DrawHScrollBar(struct XObj *xobj)
{
 int x,y,w,h;
 char str[20];
 int asc,desc,dir;
 XCharStruct struc;

 /* Calcul de la taille de l'ascenseur */
 x=0;
 y=xobj->height/2-12;
 w=xobj->width;
 h=24;
 DrawReliefRect(x,y,w,h,xobj,xobj->TabColor[shad].pixel,xobj->TabColor[li].pixel,
 		xobj->TabColor[black].pixel,1);
 DrawThumbH(xobj);
 
 /* Ecriture des valeurs */
 sprintf(str,"%d",xobj->value2);
 x=4;
 XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&asc,&desc,&struc);
 y=y+asc+h;
 DrawString(xobj->display,xobj->gc,xobj->win,x,y,str,
	strlen(str),xobj->TabColor[fore].pixel,
	xobj->TabColor[li].pixel,xobj->TabColor[back].pixel,
	!xobj->flags[1]);
 sprintf(str,"%d",xobj->value3);
 x=w-XTextWidth(xobj->xfont,str,strlen(str))-4;
 DrawString(xobj->display,xobj->gc,xobj->win,x,y,str,
	strlen(str),xobj->TabColor[fore].pixel,
	xobj->TabColor[li].pixel,xobj->TabColor[back].pixel,
	!xobj->flags[1]);
}
Exemple #3
0
void DrawVScrollBar(struct XObj *xobj)
{
  int x,y,w,h;
  char str[20];
  int asc,desc,dir;
  XCharStruct struc;

  /* Calcul de la taille de l'ascenseur */
  x = xobj->width/2 - 12;
  y = 0;
  w = 24;
  h = xobj->height;
  DrawReliefRect(x, y, w, h, xobj, shad, hili);
  DrawThumbV(xobj);

  /* Ecriture des valeurs */
  XTextExtents(xobj->xfont, "lp", strlen("lp"), &dir, &asc, &desc, &struc);
  x = x + 26;
  y = asc + 2;
  sprintf(str, "%d", xobj->value3);
  DrawString(dpy, xobj, xobj->win, x, y, str, strlen(str), fore, hili, back,
	     !xobj->flags[1]);
  sprintf(str, "%d", xobj->value2);
  y = h - desc - 2;
  DrawString(dpy, xobj, xobj->win, x, y, str, strlen(str), fore, hili, back,
	     !xobj->flags[1]);
}
Exemple #4
0
/*
 * Fonction pour VScrollBar
 */
void DrawThumbV(struct XObj *xobj, XEvent *evp)
{
	int x,y,w,h;
	XSegment segm;
	char str[20];

	x = xobj->width/2 - 10;
	y = 2 +
		(xobj->height - 36)*(xobj->value - xobj->value3) /
		(xobj->value2 - xobj->value3);
	w = 20;
	h = 32;
	DrawReliefRect(x, y, w, h, xobj, hili, shad);
	segm.x1 = x + 3;
	segm.y1 = y + 15;
	segm.x2 = x + w - 3;
	segm.y2 = y + 15;
	XSetForeground(dpy, xobj->gc, xobj->TabColor[shad]);
	XDrawSegments(dpy, xobj->win, xobj->gc, &segm, 1);
	segm.x1 = x + 3;
	segm.y1 = y + 16;
	segm.x2 = x + w - 3;
	segm.y2 = y + 16;
	XSetForeground(dpy, xobj->gc, xobj->TabColor[hili]);
	XDrawSegments(dpy, xobj->win, xobj->gc, &segm, 1);
	XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);

	sprintf(str, "%d", xobj->value);
	x = x-FlocaleTextWidth(xobj->Ffont, str, strlen(str))-6;
	y = y + 13 + xobj->Ffont->ascent/2;
	MyDrawString(dpy, xobj, xobj->win, x, y, str, fore, hili, back,
		     !xobj->flags[1], NULL, evp);
}
Exemple #5
0
void DrawCheckBox(struct XObj *xobj)
{
  XSegment segm[2];
  int asc,desc,dir;
  XCharStruct struc;
 
  /* Dessin du rectangle arrondi / drawing of the round rectangle */
  XTextExtents(xobj->xfont, "lp", strlen("lp"), &dir, &asc, &desc, &struc);
  DrawReliefRect(0, asc-11, xobj->height, xobj->height, xobj, hili, shad);

  /* Calcul de la position de la chaine de charactere */
  /* Compute the position of string */
  DrawString(dpy, xobj, xobj->win, 23, asc,xobj->title, strlen(xobj->title),
	     fore, hili, back, !xobj->flags[1]);
  /* Dessin de la croix / draw the cross */
  if (xobj->value)
  {
    XSetLineAttributes(dpy, xobj->gc, 2, LineSolid, CapProjecting, JoinMiter);
    segm[0].x1 = 5;
    segm[0].y1 = 5;
    segm[0].x2 = xobj->height - 6;
    segm[0].y2 = xobj->height - 6;
    segm[1].x1 = 5;
    segm[1].y1 = xobj->height - 6;
    segm[1].x2 = xobj->height - 6;
    segm[1].y2 = 5;
    XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);
    XDrawSegments(dpy, xobj->win, xobj->gc, segm, 2);
    XSetLineAttributes(dpy, xobj->gc, 1, LineSolid, CapRound, JoinMiter);
  }
}
Exemple #6
0
void DrawList(struct XObj *xobj)
{
 int asc,desc,dir,HeightCell;
 XCharStruct struc;
 int NbVisCell,NbCell;
 XRectangle r;

 /* Dessin du contour */
 DrawReliefRect(0,0,xobj->width,xobj->height,xobj,
	xobj->TabColor[li].pixel,xobj->TabColor[shad].pixel,xobj->TabColor[fore].pixel,-1);

 /* Dessin du contour de la liste */
 r.x=2+BdWidth;
 r.y=r.x;
 r.width=xobj->width-r.x-4-2*BdWidth-SbWidth;
 r.height=xobj->height-r.y-2*BdWidth;
 DrawReliefRect(r.x,r.y,r.width,r.height,xobj,xobj->TabColor[shad].pixel,
	xobj->TabColor[li].pixel,xobj->TabColor[fore].pixel,-1);

 /* Calcul du nombre de cellules visibles */
 XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&asc,&desc,&struc);
 HeightCell=asc+desc+3;
 NbVisCell=r.height/HeightCell;
 NbCell=CountOption(xobj->title);
 if (NbCell>NbVisCell)
 {
  if (xobj->value2>(NbCell-NbVisCell+1))
   xobj->value2=NbCell-NbVisCell+1;
 if ((xobj->value2<1)||(xobj->value2<0))
  xobj->value2=1;
 }
 else
  xobj->value2=1;
 

 /* Dessin des cellules */
 DrawCellule(xobj,NbCell,NbVisCell,HeightCell,asc);

 /* Dessin de l'ascenseur vertical */
 DrawVSbList(xobj,NbCell,NbVisCell,0);

}
Exemple #7
0
void DrawVSbList(struct XObj *xobj,int NbCell,int NbVisCell,int press)
{
 XRectangle r;
 int PosTh,SizeTh;

 r.y=2+BdWidth;
 r.x=xobj->width-(6+BdWidth)-SbWidth;
 r.height=xobj->height-r.y-2*BdWidth;
 r.width=SbWidth+4;
 DrawReliefRect(r.x,r.y,r.width,r.height,xobj,xobj->TabColor[shad].pixel,
		xobj->TabColor[li].pixel,xobj->TabColor[fore].pixel,-1);

 /* Calcul du rectangle pour les fleches*/
 r.x=r.x+2;
 r.y=r.y+2;
 r.width=r.width-4;
 r.height=r.height-4;

 /* Dessin de la fleche haute */
 DrawArrowN(xobj,r.x+1,r.y+1,press==1);
 DrawArrowS(xobj,r.x+1,r.y+r.height-14,press==2);

 /* Calcul du rectangle pour le pouce*/
 r.y=r.y+13;
 r.height=r.height-26;

 /* Effacement */
 XSetForeground(xobj->display,xobj->gc,xobj->TabColor[back].pixel);
 XFillRectangle(xobj->display,xobj->win,xobj->gc,r.x+1,r.y+1,r.width-2,r.height-2);

 /* Dessin du pouce */
 if (NbVisCell<NbCell)
  SizeTh=(NbVisCell*(r.height-8)/NbCell)+8;
 else
  SizeTh=r.height;
 PosTh=(xobj->value2-1)*(r.height-8)/NbCell;
 DrawReliefRect(r.x,r.y+PosTh,r.width,SizeTh,xobj,xobj->TabColor[li].pixel,
		xobj->TabColor[shad].pixel,xobj->TabColor[fore].pixel,-1);
}
Exemple #8
0
void DrawPopupMenu(struct XObj *xobj, XEvent *evp)
{
  XSegment segm[4];
  char* str;
  int x,y;
  int asc = xobj->Ffont->ascent;

  DrawReliefRect(0, 0, xobj->width, xobj->height, xobj, hili, shad);

  /* Dessin de la fleche / arrow drawing */
  segm[0].x1 = 7;
  segm[0].y1 = asc;
  segm[0].x2 = 19;
  segm[0].y2 = asc;
  segm[1].x1 = 8;
  segm[1].y1 = asc;
  segm[1].x2 = 13;
  segm[1].y2 = 5 + asc;
  segm[2].x1 = 6;
  segm[2].y1 = asc - 1;
  segm[2].x2 = 19;
  segm[2].y2 = 0 + asc -1;
  segm[3].x1 = 7;
  segm[3].y1 = asc;
  segm[3].x2 = 12;
  segm[3].y2 = 5 +asc;
  XSetForeground(dpy, xobj->gc, xobj->TabColor[shad]);
  XDrawSegments(dpy, xobj->win, xobj->gc, segm, 4);
  segm[0].x1 = 17;
  segm[0].y1 = asc + 1;
  segm[0].x2 = 13;
  segm[0].y2 = 5 + asc;
  segm[1].x1 = 19;
  segm[1].y1 = asc;
  segm[1].x2 = 14;
  segm[1].y2 = 5 + asc;
  XSetForeground(dpy, xobj->gc, xobj->TabColor[hili]);
  XDrawSegments(dpy, xobj->win, xobj->gc, segm, 2);

  /* Dessin du titre du popup menu */
  str = (char*)GetMenuTitle(xobj->title, xobj->value);
  y = asc + 5;
  x = GetXTextPosition(xobj,xobj->width,
		       FlocaleTextWidth(xobj->Ffont,str,strlen(str)),
		       25,8,8);
  MyDrawString(dpy, xobj, xobj->win, x, y, str, fore, hili, back,
	     !xobj->flags[1], NULL, evp);

  free(str);
}
Exemple #9
0
void DrawThumbH(struct XObj *xobj)
{
 int x,y,w,h;
 XSegment segm;
 char str[20];
 int asc,desc,dir;
 XCharStruct struc;

 x=3+(xobj->width-36)*(xobj->value-xobj->value2)/(xobj->value3-xobj->value2);
 y=xobj->height/2-9;
 w=30;
 h=18;
 DrawReliefRect(x,y,w,h,xobj,xobj->TabColor[li].pixel,xobj->TabColor[shad].pixel,
 		xobj->TabColor[black].pixel,-1);
 segm.x1=x+15;
 segm.y1=y+3;
 segm.x2=x+15;
 segm.y2=y+h-3;
 XSetForeground(xobj->display,xobj->gc,xobj->TabColor[shad].pixel);
 XDrawSegments(xobj->display,xobj->win,xobj->gc,&segm,1);
 segm.x1=x+16;
 segm.y1=y+3;
 segm.x2=x+16;
 segm.y2=y+h-3;
 XSetForeground(xobj->display,xobj->gc,xobj->TabColor[li].pixel);
 XDrawSegments(xobj->display,xobj->win,xobj->gc,&segm,1);
 XSetForeground(xobj->display,xobj->gc,xobj->TabColor[fore].pixel);
 
 sprintf(str,"%d",xobj->value);
 x=x+15-(XTextWidth(xobj->xfont,str,strlen(str))/2);
 XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&asc,&desc,&struc);
 y=y-desc-4;
 DrawString(xobj->display,xobj->gc,xobj->win,x,y,str,
	strlen(str),xobj->TabColor[fore].pixel,
	xobj->TabColor[li].pixel,xobj->TabColor[back].pixel,
	!xobj->flags[1]);

}
Exemple #10
0
void DrawVScrollBar(struct XObj *xobj, XEvent *evp)
{
	int x,y,w,h;
	char str[20];

	/* Calcul de la taille de l'ascenseur */
	x = xobj->width/2 - 12;
	y = 0;
	w = 24;
	h = xobj->height;
	DrawThumbV(xobj, evp);
	DrawReliefRect(x, y, w, h, xobj, shad, hili);
	/* Ecriture des valeurs */
	x = x + 26;
	y = xobj->Ffont->ascent + 2;
	sprintf(str, "%d", xobj->value3);
	MyDrawString(dpy, xobj, xobj->win, x, y, str, fore, hili, back,
		     !xobj->flags[1], NULL, evp);
	sprintf(str, "%d", xobj->value2);
	y = h - xobj->Ffont->descent - 2;
	MyDrawString(dpy, xobj, xobj->win, x, y, str, fore, hili, back,
		     !xobj->flags[1], NULL, evp);
}
Exemple #11
0
void DrawThumbV(struct XObj *xobj)
{
  int x,y,w,h;
  XSegment segm;
  char str[20];
  int asc,desc,dir;
  XCharStruct struc;

  x = xobj->width/2 - 10;
  y = 2 +
    (xobj->height - 36)*(xobj->value - xobj->value3) / 
    (xobj->value2 - xobj->value3);
  w = 20;
  h = 32;
  DrawReliefRect(x, y, w, h, xobj, hili, shad);
  segm.x1 = x + 3;
  segm.y1 = y + 15;
  segm.x2 = x + w - 3;
  segm.y2 = y + 15;
  XSetForeground(dpy, xobj->gc, xobj->TabColor[shad]);
  XDrawSegments(dpy, xobj->win, xobj->gc, &segm, 1);
  segm.x1 = x + 3;
  segm.y1 = y + 16;
  segm.x2 = x + w - 3;
  segm.y2 = y + 16;
  XSetForeground(dpy, xobj->gc, xobj->TabColor[hili]);
  XDrawSegments(dpy, xobj->win, xobj->gc, &segm, 1);
  XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);
  
  sprintf(str, "%d", xobj->value);
  x = x-XTextWidth(xobj->xfont, str, strlen(str))-6;
  XTextExtents(xobj->xfont, "lp", strlen("lp"), &dir, &asc, &desc, &struc);
  y = y + 13 + asc/2;
  DrawString(dpy, xobj, xobj->win, x, y, str, strlen(str), fore, hili, back,
	     !xobj->flags[1]);
}
Exemple #12
0
void EvtKeyCheckBox(struct XObj *xobj, XKeyEvent *EvtKey)
{
  KeySym ks;
  unsigned char buf[10];
  XSegment segm[2];
  int asc,desc,dir;
  XCharStruct struc;

  XLookupString(EvtKey, (char *)buf, sizeof(buf), &ks, NULL);
  if (ks == XK_Return) {
    XTextExtents(xobj->xfont, "lp", strlen("lp"), &dir, &asc, &desc, &struc);
    xobj->value = !xobj->value;
    DrawReliefRect(0, asc-11, xobj->height, xobj->height, xobj, hili, shad);
    SendMsg(xobj,SingleClic);
    if (xobj->value)
    {
      XSetLineAttributes(dpy, xobj->gc, 2,
			 LineSolid, CapProjecting, JoinMiter);
      segm[0].x1 = 5;
      segm[0].y1 = 5;
      segm[0].x2 = xobj->height - 6;
      segm[0].y2 = xobj->height - 6;
      segm[1].x1 = 5;
      segm[1].y1 = xobj->height - 6;
      segm[1].x2 = xobj->height - 6;
      segm[1].y2 = 5;
      XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);
      XDrawSegments(dpy, xobj->win, xobj->gc, segm, 2);
      XSetLineAttributes(dpy, xobj->gc, 1, LineSolid, CapRound, JoinMiter);
    }
    else
    {
      XClearArea(dpy, xobj->win, 4, 4, xobj->height-8, xobj->height-8, False);
    }
  }
}
Exemple #13
0
void DrawPushButton(struct XObj *xobj, XEvent *evp)
{
	DrawReliefRect(0, 0, xobj->width, xobj->height, xobj, hili, shad);
	DrawIconStr(0, xobj, True, PUSH_BUTTON_LCR_OFFSETS, NULL, NULL, evp);
}
Exemple #14
0
void EvtMouseCheckBox(struct XObj *xobj, XButtonEvent *EvtButton)
{
  static XEvent event;
  int End = 1;
  unsigned int modif;
  int x1,x2,y1,y2;
  Window Win1,Win2;
  Window WinBut = 0;
  int In = 0;
  XSegment segm[2];
  int asc,desc,dir;
  XCharStruct struc;
  
  while (End)
  {
    XNextEvent(dpy, &event);
    switch (event.type)
    {
    case EnterNotify:
      XQueryPointer(dpy, *xobj->ParentWin,
		    &Win1, &Win2, &x1, &y1, &x2, &y2, &modif);
      if (WinBut == 0)
      {
	WinBut = Win2;
	/* Mouse on button */
	XTextExtents(xobj->xfont, "lp", strlen("lp"), &dir, &asc, &desc, &struc);
	DrawReliefRect(0, asc-11, xobj->height, xobj->height, xobj, shad, hili);
	In = 1;
      }
      else
      {
	if (Win2 == WinBut)
	{
	  /* Mouse on button */
	  DrawReliefRect(0, asc-11, xobj->height, xobj->height,
			 xobj, shad, hili);
	  In = 1;
	}
	else if (In)
	{
	  In = 0;
	  /* Mouse not on button */
	  DrawReliefRect(0, asc-11, xobj->height, xobj->height,
			 xobj, hili, shad);
	}
      }
      break;
    case LeaveNotify:
      XQueryPointer(dpy, *xobj->ParentWin,
		    &Win1, &Win2, &x1, &y1, &x2, &y2, &modif);
      if (Win2 == WinBut)
      {
	In = 1;
	/* Mouse on button */
	DrawReliefRect(0, asc-11, xobj->height, xobj->height, xobj, shad, hili);
      }
      else if (In)
      {
	/* Mouse not on button */
	DrawReliefRect(0, asc-11, xobj->height, xobj->height, xobj, hili, shad);
	In = 0;
      }
      break;
    case ButtonRelease:
      End = 0;
      /* Mouse not on button */
      if (In)
      {
	/* Envoie d'un message vide de type SingleClic pour un clique souris */
	xobj->value = !xobj->value;
	DrawReliefRect(0, asc-11, xobj->height, xobj->height, xobj, hili, shad);
	SendMsg(xobj,SingleClic);
      }
      if (xobj->value)
      {
	XSetLineAttributes(dpy, xobj->gc, 2,
			   LineSolid, CapProjecting, JoinMiter);
	segm[0].x1 = 5;
	segm[0].y1 = 5;
	segm[0].x2 = xobj->height - 6;
	segm[0].y2 = xobj->height - 6;
	segm[1].x1 = 5;
	segm[1].y1 = xobj->height - 6;
	segm[1].x2 = xobj->height - 6;
	segm[1].y2 = 5;
	XSetForeground(dpy, xobj->gc, xobj->TabColor[fore]);
	XDrawSegments(dpy, xobj->win, xobj->gc, segm, 2);
	XSetLineAttributes(dpy, xobj->gc, 1, LineSolid, CapRound, JoinMiter);
      }
      else
      {
	XClearArea(dpy, xobj->win, 4, 4, xobj->height-8, xobj->height-8, False);
      }
      break;
    }
  }
}
Exemple #15
0
/* text field drawing */
void DrawTextField(struct XObj *xobj)
{
 int x1,y1;
 int x2,l;
 int desc,dir,asc;
 XCharStruct struc;
 int nl=0;
 int right=0;

 l=strlen(xobj->title);
 if (xobj->value>l)
  xobj->value=l;
 if (xobj->value2>l)
  xobj->value2=l;
 DrawReliefRect(0,0,xobj->width,xobj->height,xobj,shad,hili);
 XClearArea(dpy,xobj->win,2,2,xobj->width-4,xobj->height-4,False);
 XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]);
 XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&y1,&desc,&struc);
 /* calcul du premier caractere visible */
 /* computation of the first visible character */
 while (l-nl >= 1 &&
	 XTextWidth(xobj->xfont,xobj->title + nl,
		    xobj->value - nl) > (xobj->width-10))
   { nl++; }
 if (nl>xobj->value3) { xobj->value3 = nl; }
 else if (xobj->value3>xobj->value) { xobj->value3--; }
 /* calcul de la longueur du titre visible */
 /* computation of the length of the visible title */
 while ( l-xobj->value3-right >= 1 && 
	 XTextWidth(xobj->xfont,xobj->title + xobj->value3,
		    l - xobj->value3 - right) > (xobj->width-10))
 { right++; }
#ifdef I18N_MB
 XmbDrawString(dpy,xobj->win,xobj->xfontset,xobj->gc,5,y1+5,
	       xobj->title + xobj->value3,
	       strlen(xobj->title) - xobj->value3-right);
#else
 XDrawString(dpy,xobj->win,xobj->gc,5,y1+5,xobj->title+xobj->value3,
	     strlen(xobj->title) - xobj->value3-right);
#endif

 /* Dessin de la zone selectionnee */
 /* selected zone drawing */
 XSetFunction(dpy,xobj->gc,GXinvert);
 if (xobj->value2>xobj->value)		/* Curseur avant la souris */
 {
  x1=XTextWidth(xobj->xfont,&xobj->title[xobj->value3],
		xobj->value - xobj->value3);
  x2=XTextWidth(xobj->xfont,&xobj->title[xobj->value],
		xobj->value2 - xobj->value);
 }
 else		/* Curseur apres la souris / cursor after the mouse */
 {
  x1=XTextWidth(xobj->xfont,&xobj->title[xobj->value3],
		xobj->value2 - xobj->value3);
  x2=XTextWidth(xobj->xfont,&xobj->title[xobj->value2],
		xobj->value - xobj->value2);
 }
 XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&asc,&desc,&struc);
 XFillRectangle(dpy,xobj->win,xobj->gc,x1+5,7,x2,y1+desc-2);
 XSetFunction(dpy,xobj->gc,GXcopy);

 /* Dessin du point d'insertion */
 /* insertion point drawing */
 DrawPointTxt(xobj,xobj->TabColor[fore]);
}
Exemple #16
0
void DrawTextField(struct XObj *xobj, XEvent *evp)
{
	int x1,y1;
	int x2,l;
	int nl=0;
	int right=0;
	int offset,offset2,offset3;
	int end_value;

	fprintf(stderr,"DrawTextField: value %d value2 %d value3 %d\n",
		xobj->value, xobj->value2, xobj->value3);

	y1 = xobj->Ffont->ascent;
	l=strlen(xobj->title);
	/* calculate byte offsets corresponding to value,value2,value3 */
	offset = getByteOffsetBoundsCheck(xobj->Ffont,xobj->title,xobj->value);
	offset2 = getByteOffsetBoundsCheck(xobj->Ffont,xobj->title,
					   xobj->value2);
	offset3 = getByteOffsetBoundsCheck(xobj->Ffont,xobj->title,
					   xobj->value3);
	/* value corresponding to behind last character */
	end_value = FlocaleStringCharLength(xobj->Ffont, xobj->title );
	if(offset == l)
		xobj->value = end_value;
	if(offset2 == l)
		xobj->value2 = end_value;
	if(offset3 == l)
		xobj->value3 = end_value;

	fprintf(stderr, "DrawTextField: offset: %d offset2 %d, offset3: %d\n",
		offset, offset2, offset3);

	/*if (offset > l)
		xobj->value = FlocaleStringByteToCharOffset(xobj->Ffont,
							    xobj->title,
							    l-1) + 1;
	if (offset2 > l)
		xobj->value2 = FlocaleStringByteToCharOffset(xobj->Ffont,
							     xobj->title,
							     l-1) + 1; */
	DrawReliefRect(0,0,xobj->width,xobj->height,xobj,shad,hili);
	XClearArea(dpy,xobj->win,2,2,xobj->width-4,xobj->height-4,False);
	XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]);
	/* calcul du premier caractere visible */
	/* computation of the first visible character */
	while (l-nl >= 1 &&
	       FlocaleTextWidth(xobj->Ffont,xobj->title + nl,
				offset - nl) > (xobj->width-10))
	{
		nl += FlocaleStringNumberOfBytes(xobj->Ffont,xobj->title + nl);
		fprintf(stderr,"nl: %d\n", nl);
	}
	/* now nl is the byte offset of the first the first visible
	   character */
	if (nl > offset3) /* the first visible character needs to be updated */
	{
		xobj->value3 = getCharOffsetBoundsCheck(xobj->Ffont,
							xobj->title, nl);
		/*FlocaleStringByteToCharOffset(xobj->Ffont,
		  xobj->title, nl);*/
		offset3 = nl;
	}
	else if (xobj->value3 > xobj->value)
	{
		xobj->value3--;
		offset3 = FlocaleStringCharToByteOffset(xobj->Ffont,
							xobj->title,
							xobj->value3);
	}
	fprintf(stderr, "Got visible offset; %d char %d\n", offset3,
		xobj->value3);
	/* calcul de la longueur du titre visible */
	/* computation of the length of the visible title */
	/* increase string until it won't fit anymore into into the textbox */
	right = offset3;
	while(right < l && FlocaleTextWidth(xobj->Ffont, xobj->title + offset3,
					    right - offset3) <=
	      xobj->width - 10)
	{
		right += FlocaleStringNumberOfBytes(xobj->Ffont,
						    xobj->title + right);
	}
	/* the string didn't fit? */
	if(FlocaleTextWidth(xobj->Ffont, xobj->title + offset3,
			    right - offset3) >
	   xobj->width - 10)
	{
		right -= FlocaleStringNumberOfBytes(
				xobj->Ffont,
				xobj->title +
				FlocaleStringCharToByteOffset(
				       xobj->Ffont, xobj->title,
				       FlocaleStringByteToCharOffset(
					      xobj->Ffont, xobj->title,
					      right) - 1));
	}
	/* unless we had an empty string, we would have already been at the
	   beginning */
	if(right < offset3)
		right = offset3;

	/*while ( l - offset3 - right >= 1 &&
		FlocaleTextWidth(xobj->Ffont,xobj->title + offset3,
				 l - offset3 - right) > (xobj->width-10))
	{
	right += FlocaleStringNumberOfBytes(xobj->Ffont,
	xobj->title + right);
		fprintf(stderr, "sl: %d\n", l - offset3 - right);
		} */
	fprintf(stderr,"computed length of visible string\n");
	FwinString->win = xobj->win;
	FwinString->gc = xobj->gc;
	FwinString->x = 5;
	FwinString->y = y1+5;
	FwinString->str = xobj->title + offset3;
	FwinString->len = right - offset3;
	  /*strlen(xobj->title) - offset3 - right;*/
	FlocaleDrawString(dpy, xobj->Ffont, FwinString, FWS_HAVE_LENGTH);
#if 0
	XmbDrawString(dpy,xobj->win,xobj->xfontset,xobj->gc,5,y1+5,
		      xobj->title + xobj->value3,
		      strlen(xobj->title) - xobj->value3-right);
#endif

	/* Dessin de la zone selectionnee */
	/* selected zone drawing */
	XSetFunction(dpy,xobj->gc,GXinvert);
	if (xobj->value2>xobj->value)          /* Curseur avant la souris */
	{
		x1=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset3],
				    offset - offset3);
		x2=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset],
				    offset2 - offset);
	}
	else           /* Curseur apres la souris / cursor after the mouse */
	{
		x1=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset3],
				    offset2 - offset3);
		x2=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset2],
				    offset - offset2);
	}
	XFillRectangle(
		dpy,xobj->win,xobj->gc,x1+5,7,x2,y1+xobj->Ffont->descent-2);
	XSetFunction(dpy,xobj->gc,GXcopy);

	/* Dessin du point d'insertion */
	/* insertion point drawing */
	DrawPointTxt(xobj,xobj->TabColor[fore]);
}
Exemple #17
0
void EvtMousePushButton(struct XObj *xobj, XButtonEvent *EvtButton)
{
	static XEvent event;
	int End = 1;
	unsigned int modif;
	int x1,x2,y1,y2,i;
	Window Win1,Win2,WinPop;
	Window WinBut = 0;
	int In = 0;
	char *str;
	int x,y,hOpt,yMenu,hMenu,wMenu;
	int oldvalue = 0,newvalue;
	unsigned long mask;
	XSetWindowAttributes Attr;

	if (EvtButton->button == Button1)
	{
		i = (xobj->width -
		     FlocaleTextWidth(
			     xobj->Ffont, xobj->title, strlen(xobj->title)))/2;

		while (End)
		{
			FNextEvent(dpy, &event);
			switch (event.type)
			{
			case EnterNotify:
				FQueryPointer(
					dpy, *xobj->ParentWin,
					&Win1, &Win2, &x1, &y1, &x2, &y2,
					&modif);
				if (WinBut == 0)
				{
					WinBut = Win2;
					DrawReliefRect(
						0, 0, xobj->width,
						xobj->height, xobj, shad,
						hili);
					DrawIconStr(
						0,xobj, True,
						PUSH_BUTTON_LCR_OFFSETS, NULL,
						NULL, NULL);
					In = 1;
				}
				else
				{
					if (Win2 == WinBut)
					{
						DrawReliefRect(
							0, 0, xobj->width,
							xobj->height, xobj,
							shad, hili);
						DrawIconStr(
							1, xobj, True,
							PUSH_BUTTON_LCR_OFFSETS,
							NULL, NULL, NULL);
						In = 1;
					}
					else if (In)
					{
						In = 0;
						DrawReliefRect(
							0, 0, xobj->width,
							xobj->height, xobj,
							hili, shad);
						DrawIconStr(
							0, xobj, True,
							PUSH_BUTTON_LCR_OFFSETS,
							NULL, NULL, NULL);
					}
				}
				break;
			case LeaveNotify:
				FQueryPointer(
					dpy, *xobj->ParentWin,
					&Win1, &Win2, &x1, &y1, &x2, &y2,
					&modif);
				if (Win2 == WinBut)
				{
					In = 1;
					DrawReliefRect(
						0, 0, xobj->width,
						xobj->height, xobj, shad,
						hili);
					DrawIconStr(
						1, xobj, True,
						PUSH_BUTTON_LCR_OFFSETS, NULL,
						NULL, NULL);
				}
				else if (In)
				{
					DrawReliefRect(
						0, 0, xobj->width,
						xobj->height, xobj, hili,
						shad);
					DrawIconStr(
						0, xobj, True,
						PUSH_BUTTON_LCR_OFFSETS, NULL,
						NULL, NULL);
					In = 0;
				}
				break;
			case ButtonRelease:
				End = 0;
				DrawReliefRect(
					0, 0, xobj->width, xobj->height, xobj,
					hili, shad);
				DrawIconStr(
					0, xobj, True,
					PUSH_BUTTON_LCR_OFFSETS, NULL, NULL,
					NULL);
				if (In)
				{
					/* Envoie d'un message vide de type
					 * SingleClic pour un clique souris */
					xobj->value = 1;
					SendMsg(xobj, SingleClic);
					xobj->value = 0;
				}
				break;
			}
		}
	}
	/* affichage du popup menu / Drawing the popup menu */
	else if (EvtButton->button == Button3)
	{
		if (xobj->value3 > 1)
		{
			hOpt = xobj->Ffont->height + 10;
			/* Hauteur totale du menu / Total height of the menu */
			hMenu = (xobj->value3 - 1) * hOpt;
			yMenu = xobj->y + xobj->height;
			wMenu = 0;
			for (i = 2 ; i <= xobj->value3; i++)
			{
				str = (char*)GetMenuTitle(xobj->title, i);
				if (wMenu < FlocaleTextWidth(
					    xobj->Ffont, str, strlen(str))+34)
					wMenu = FlocaleTextWidth(
						xobj->Ffont, str,
						strlen(str))+34;
				free(str);
			}

			/* Creation de la fenetre menu / create the menu
			 * window */
			XTranslateCoordinates(dpy, *xobj->ParentWin, Root,
					      xobj->x, yMenu, &x, &y, &Win1);
			if (x<0) x = 0;
			if (y<0) y = 0;
			if (x + wMenu > XDisplayWidth(dpy, screen))
			{
				x = XDisplayWidth(dpy, screen) - wMenu;
			}
			if (y + hMenu > XDisplayHeight(dpy, screen))
			{
				y = y-hMenu-xobj->height;
			}

			mask = 0;
			Attr.background_pixel = xobj->TabColor[back];
			mask |= CWBackPixel;
			Attr.border_pixel  =  0;
			mask |= CWBorderPixel;
			Attr.colormap = Pcmap;
			mask |= CWColormap;
			Attr.cursor = XCreateFontCursor(dpy, XC_hand2);
			mask |= CWCursor;         /* Curseur pour la fenetre */
			Attr.override_redirect = True;
			mask |= CWOverrideRedirect;
			WinPop = XCreateWindow(
				dpy, Root, x, y, wMenu-5, hMenu, 0,
				Pdepth, InputOutput, Pvisual, mask, &Attr);
			if (xobj->colorset >= 0)
				SetWindowBackground(
					dpy, WinPop, wMenu - 5, hMenu,
					&Colorset[xobj->colorset], Pdepth,
					xobj->gc, True);
			XMapRaised(dpy, WinPop);

			/* Dessin du menu */
			DrawPMenu(xobj, WinPop, hOpt, 1);
			do
			{
				FQueryPointer(
					dpy, Root, &Win1, &Win2, &x1, &y1,
					&x2, &y2, &modif);
				/* Determiner l'option courante / Current
				 * option */
				y2 = y2 - y;
				x2 = x2 - x;
				{
					/* calcule de xobj->value / Compute
					 * xobj->value */
					if ((x2 > 0) && (x2 < wMenu) &&
					    (y2 > 0) && (y2 < hMenu))
						newvalue = y2 / hOpt+1;
					else
						newvalue = 0;
					if (newvalue!=oldvalue)
					{
						UnselectMenu(
							xobj, WinPop, hOpt,
							oldvalue, wMenu-5,
							xobj->Ffont->ascent,
							1);
						SelectMenu(
							xobj, WinPop, hOpt,
							newvalue);
						oldvalue = newvalue;
					}
				}
			}
			while (!FCheckTypedEvent(dpy, ButtonRelease, &event));
			XDestroyWindow(dpy, WinPop);
			if (newvalue != 0)
			{
				xobj->value = newvalue;
				SendMsg(xobj, SingleClic);
				xobj->value = 0;
			}
			xobj->DrawObj(xobj, NULL);
		} /* xobj->value3 > 1 */
	} /* EvtButton->button == Button3 */
}