Ejemplo n.º 1
0
static void LabelElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, Ttk_State state)
{
    LabelElement *l = elementRecord;
    Tk_Anchor anchor = TK_ANCHOR_CENTER;

    LabelSetup(l, tkwin, state);

    /*
     * Adjust overall parcel based on -anchor:
     */
    Tk_GetAnchorFromObj(NULL, l->text.anchorObj, &anchor);
    b = Ttk_AnchorBox(b, l->totalWidth, l->totalHeight, anchor);

    /*
     * Draw text and/or image parts based on -compound:
     */
    switch (l->compound)
    {
	case TTK_COMPOUND_NONE:
	    /* Can't happen */
	    break;
	case TTK_COMPOUND_TEXT:
	    TextDraw(&l->text,tkwin,d,b);
	    break;
	case TTK_COMPOUND_IMAGE:
	    ImageDraw(&l->image,tkwin,d,b,state);
	    break;
	case TTK_COMPOUND_CENTER:
	{
	    Ttk_Box pb = Ttk_AnchorBox(
		b, l->image.width, l->image.height, TK_ANCHOR_CENTER);
	    ImageDraw(&l->image, tkwin, d, pb, state);
	    pb = Ttk_AnchorBox(
		b, l->text.width, l->text.height, TK_ANCHOR_CENTER);
	    TextDraw(&l->text, tkwin, d, pb);
	    break;
	}
	case TTK_COMPOUND_TOP:
	    DrawCompound(l, b, tkwin, d, state, TTK_SIDE_TOP, TTK_SIDE_BOTTOM);
	    break;
	case TTK_COMPOUND_BOTTOM:
	    DrawCompound(l, b, tkwin, d, state, TTK_SIDE_BOTTOM, TTK_SIDE_TOP);
	    break;
	case TTK_COMPOUND_LEFT:
	    DrawCompound(l, b, tkwin, d, state, TTK_SIDE_LEFT, TTK_SIDE_RIGHT);
	    break;
	case TTK_COMPOUND_RIGHT:
	    DrawCompound(l, b, tkwin, d, state, TTK_SIDE_RIGHT, TTK_SIDE_LEFT);
	    break;
    }

    LabelCleanup(l);
}
Ejemplo n.º 2
0
static void TextElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, Ttk_State state)
{
    TextElement *text = elementRecord;
    if (TextSetup(text, tkwin)) {
	TextDraw(text, tkwin, d, b);
	TextCleanup(text);
    }
}
Ejemplo n.º 3
0
/*
 * DrawCompound --
 * 	Helper routine for LabelElementDraw;
 * 	Handles layout for -compound {left,right,top,bottom}
 */
static void DrawCompound(
    LabelElement *l, Ttk_Box b, Tk_Window tkwin, Drawable d, Ttk_State state,
    int imageSide, int textSide)
{
    Ttk_Box imageBox =
	Ttk_PlaceBox(&b, l->image.width, l->image.height, imageSide, 0);
    Ttk_Box textBox =
	Ttk_PlaceBox(&b, l->text.width, l->text.height, textSide, 0);
    ImageDraw(&l->image,tkwin,d,imageBox,state);
    TextDraw(&l->text,tkwin,d,textBox);
}
Ejemplo n.º 4
0
Archivo: magwin.c Proyecto: gzorin/e17
static void
MagwinDrawText(MagWindow * mw, int x, int y, const char *txt)
{
   TextClass          *tc;
   int                 cw, ch;

   tc = TextclassFind("COORDS", 1);
   if (!tc)
      return;

   TextSize(tc, 0, 0, 0, txt, &cw, &ch, 17);
   TextDraw(tc, EwinGetClientWin(mw->ewin), None, 0, 0, 0,
	    txt, x, y, cw, ch, 17, 0);
}
Ejemplo n.º 5
0
Archivo: warp.c Proyecto: Limsik/e17
static void
WarpFocusWinPaint(WarpFocusWin * fw)
{
   int                 i, state, iw;
   WarplistItem       *wi;
   EImageBorder       *pad;

   pad = ImageclassGetPadding(fw->ic);

   for (i = 0; i < warplist_num; i++)
     {
	wi = warplist + i;

	if (!EwinFindByPtr(wi->ewin))
	   wi->ewin = NULL;
	if (!wi->ewin)
	   continue;

	state = (i == warpFocusIndex) ? STATE_CLICKED : STATE_NORMAL;

	ImageclassApply(fw->ic, wi->win, 0, 0, state, ST_WARPLIST);

	iw = 0;
	if (Conf.warplist.icon_mode != 0)
	  {
	     int                 icon_size = fw->mh - 2 * ICON_PAD;
	     EImage             *im;

	     im = EwinIconImageGet(wi->ewin, icon_size,
				   Conf.warplist.icon_mode);
	     if (im)
	       {
		  EImageRenderOnDrawable(im, wi->win, None,
					 EIMAGE_BLEND | EIMAGE_ANTI_ALIAS,
					 pad->left + ICON_PAD, ICON_PAD,
					 icon_size, icon_size);
		  EImageFree(im);
	       }
	     iw = fw->mh;
	  }

	TextDraw(fw->tc, wi->win, None, 0, 0, state, wi->txt,
		 pad->left + iw, pad->top, fw->tw, fw->th, 0, 0);
     }

   /* FIXME - Check shape */
   EoShapeUpdate(fw, 1);
}
Ejemplo n.º 6
0
void CreditsDraw(SDL_Surface* screen)
{
    ImageDraw(screen, &c_background);
    TextDraw(&t, screen, "Programmed by: Nenad Palinkasevic... level over 9000.");
    ButtonDraw(&back, screen);
}
Ejemplo n.º 7
0
void
TooltipShow(ToolTip * tt, const char *text, ActionClass * ac, int x, int y)
{
   int                 i, w, h, ix, iy, iw, ih, dx, dy, xx, yy;
   int                 ww, hh, adx, ady, dist;
   int                 headline_h = 0, headline_w = 0, icons_width =
      0, labels_width = 0, double_w = 0;
   EImage             *im;
   int                *heights = NULL;
   ImageClass         *ic;
   EImageBorder       *pad;
   int                 cols[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
   int                 num, modifiers;
   Action             *aa;
   const char         *tts;
   EObj               *eo;

   if (!tt || Mode.mode != MODE_NONE)
      return;

   if (!tt->TTWIN)
     {
	TooltipRealize(tt);
	if (!tt->TTWIN)
	   return;
     }

   /* if we get an actionclass, look for tooltip action texts */
   h = 0;
   if (ac)
     {
	num = ActionclassGetActionCount(ac);
	heights = EMALLOC(int, num);

	for (i = 0; i < num; i++)
	  {
	     int                 temp_w, temp_h;

	     temp_w = 0;
	     temp_h = 0;

	     aa = ActionclassGetAction(ac, i);
	     if (!aa)
		continue;

	     tts = ActionGetTooltipString(aa);
	     if (!tts)
		continue;
	     tts = _(tts);

	     TextSize(tt->tclass, 0, 0, STATE_NORMAL, tts, &temp_w, &temp_h,
		      17);
	     if (temp_w > labels_width)
		labels_width = temp_w;
	     temp_w = 0;

	     if (ActionGetEvent(aa) == EVENT_DOUBLE_DOWN)
	       {
		  TextSize(tt->tclass, 0, 0, STATE_NORMAL, "2x", &double_w,
			   &temp_h, 17);
		  if (cols[0] < double_w)
		     cols[0] = double_w;
	       }

	     if (ActionGetAnybutton(aa))
	       {
		  TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_ANY",
				      "pix/mouse_any.png", &cols[1], &temp_h);
	       }
	     else
		switch (ActionGetButton(aa))
		  {
		  case 1:
		     TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_1",
					 "pix/mouse_1.png", &cols[1], &temp_h);
		     break;
		  case 2:
		     TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_2",
					 "pix/mouse_2.png", &cols[1], &temp_h);
		     break;
		  case 3:
		     TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_3",
					 "pix/mouse_3.png", &cols[1], &temp_h);
		     break;
		  case 4:
		     TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_4",
					 "pix/mouse_4.png", &cols[1], &temp_h);
		     break;
		  case 5:
		     TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_5",
					 "pix/mouse_5.png", &cols[1], &temp_h);
		     break;
		  case 0:
		  default:
		     break;
		  }

	     modifiers = ActionGetModifiers(aa);
	     if (modifiers)
	       {
		  if (modifiers & ShiftMask)
		     TooltipCreateIclass("TOOLTIP_KEY_SHIFT",
					 "pix/key_shift.png",
					 &cols[2], &temp_h);
		  if (modifiers & LockMask)
		     TooltipCreateIclass("TOOLTIP_KEY_LOCK",
					 "pix/key_lock.png", &cols[3], &temp_h);
		  if (modifiers & ControlMask)
		     TooltipCreateIclass("TOOLTIP_KEY_CTRL",
					 "pix/key_ctrl.png", &cols[4], &temp_h);
		  if (modifiers & Mod1Mask)
		     TooltipCreateIclass("TOOLTIP_KEY_MOD1",
					 "pix/key_mod1.png", &cols[5], &temp_h);
		  if (modifiers & Mod2Mask)
		     TooltipCreateIclass("TOOLTIP_KEY_MOD2",
					 "pix/key_mod2.png", &cols[6], &temp_h);
		  if (modifiers & Mod3Mask)
		     TooltipCreateIclass("TOOLTIP_KEY_MOD3",
					 "pix/key_mod3.png", &cols[7], &temp_h);
		  if (modifiers & Mod4Mask)
		     TooltipCreateIclass("TOOLTIP_KEY_MOD4",
					 "pix/key_mod4.png", &cols[8], &temp_h);
		  if (modifiers & Mod5Mask)
		     TooltipCreateIclass("TOOLTIP_KEY_MOD5",
					 "pix/key_mod5.png", &cols[9], &temp_h);
	       }

	     temp_w = cols[0] + cols[1] + cols[2] + cols[3] + cols[4] +
		cols[5] + cols[6] + cols[7] + cols[8] + cols[9];

	     if (temp_w > icons_width)
		icons_width = temp_w;
	     heights[i] = temp_h;
	     h += temp_h;
	  }
     }

   TextSize(tt->tclass, 0, 0, STATE_NORMAL, text, &headline_w, &headline_h, 17);
   if (headline_w < icons_width + labels_width)
      w = icons_width + labels_width;
   else
      w = headline_w;
   h += headline_h;

   ic = tt->TTICL;
   pad = ImageclassGetPadding(ic);
   iw = 0;
   ih = 0;
   if (tt->tooltippic)
     {
	im = ImageclassGetImage(tt->tooltippic, 0, 0, 0);
	if (im)
	  {
	     EImageGetSize(im, &iw, &ih);
	     EImageFree(im);
	  }
	w += iw;
	if (h < ih)
	   h = ih;
     }
   w += pad->left + pad->right;
   h += pad->top + pad->bottom;

   if ((tt->tooltippic) && (iw > 0) && (ih > 0))
     {
	ix = pad->left;
	iy = (h - ih) / 2;
	EMoveResizeWindow(tt->iwin, ix, iy, iw, ih);
	EMapWindow(tt->iwin);
	ImageclassApply(tt->tooltippic, tt->iwin, 0, 0, STATE_NORMAL, ST_SOLID);
     }
   else
      EUnmapWindow(tt->iwin);

   dx = x - WinGetW(VROOT) / 2;
   dy = y - WinGetH(VROOT) / 2;

   if ((dy == 0) && (dx == 0))
      dy = -1;

   adx = dx;
   if (adx < 0)
      adx = -adx;
   ady = dy;
   if (ady < 0)
      ady = -ady;
   if (adx < ady)
      /*   +-------+   */
      /*   |\#####/|   */
      /*   | \###/ |   */
      /*   |  \#/  |   */
      /*   |  /#\  |   */
      /*   | /###\ |   */
      /*   |/#####\|   */
      /*   +-------+   */
     {
	if (dy == 0)
	  {
	     dy = 1;
	     ady = 1;
	  }
	dist = tt->dist;
	ady = ady / dy;

	if (tt->win[0])
	  {
	     yy = y - ((ady * 10 * dist) / 100);
	     xx = x - (dist * 10 * dx) / (100 * WinGetW(VROOT) / 2);
	     EobjMove(tt->win[0], xx - 4, yy - 4);
	  }

	if (tt->win[1])
	  {
	     yy = y - ((ady * 30 * dist) / 100);
	     xx = x - (dist * 30 * dx) / (100 * WinGetW(VROOT) / 2);
	     EobjMove(tt->win[1], xx - 8, yy - 8);
	  }

	if (tt->win[2])
	  {
	     yy = y - ((ady * 50 * dist) / 100);
	     xx = x - (dist * 50 * dx) / (100 * WinGetW(VROOT) / 2);
	     EobjMove(tt->win[2], xx - 12, yy - 12);
	  }

	if (tt->win[3])
	  {
	     yy = y - ((ady * 80 * dist) / 100);
	     xx = x - (dist * 80 * dx) / (100 * WinGetW(VROOT) / 2);
	     EobjMove(tt->win[3], xx - 16, yy - 16);
	  }

	yy = y - ((ady * 100 * dist) / 100);
	xx = x - (dist * 100 * dx) / (100 * WinGetW(VROOT) / 2);
	if (ady < 0)
	   hh = 0;
	else
	   hh = h;
	ww = (w / 2) + ((dx * w) / (WinGetW(VROOT) / 2));
     }
   else
      /*   +-------+   */
      /*   |\     /|   */
      /*   |#\   /#|   */
      /*   |##\ /##|   */
      /*   |##/ \##|   */
      /*   |#/   \#|   */
      /*   |/     \|   */
      /*   +-------+   */
     {
	if (dx == 0)
	  {
	     dx = 1;
	     adx = 1;
	  }
	dist = tt->dist;
	adx = adx / dx;

	if (tt->win[0])
	  {
	     xx = x - ((adx * 10 * dist) / 100);
	     yy = y - (dist * 10 * dy) / (100 * WinGetH(VROOT) / 2);
	     EobjMove(tt->win[0], xx - 4, yy - 4);
	  }

	if (tt->win[1])
	  {
	     xx = x - ((adx * 30 * dist) / 100);
	     yy = y - (dist * 30 * dy) / (100 * WinGetH(VROOT) / 2);
	     EobjMove(tt->win[1], xx - 8, yy - 8);
	  }

	if (tt->win[2])
	  {
	     xx = x - ((adx * 50 * dist) / 100);
	     yy = y - (dist * 50 * dy) / (100 * WinGetH(VROOT) / 2);
	     EobjMove(tt->win[2], xx - 12, yy - 12);
	  }

	if (tt->win[3])
	  {
	     xx = x - ((adx * 80 * dist) / 100);
	     yy = y - (dist * 80 * dy) / (100 * WinGetH(VROOT) / 2);
	     EobjMove(tt->win[3], xx - 16, yy - 16);
	  }

	xx = x - ((adx * 100 * dist) / 100);
	yy = y - (dist * 100 * dy) / (100 * WinGetH(VROOT) / 2);
	if (adx < 0)
	   ww = 0;
	else
	   ww = w;
	hh = (h / 2) + ((dy * h) / (WinGetH(VROOT) / 2));
     }

   EobjMoveResize(tt->TTWIN, xx - ww, yy - hh, w, h);

   for (i = 0; i < 5; i++)
     {
	eo = tt->win[i];
	if (!eo)
	   continue;
	ImageclassApply(tt->iclass[i], EobjGetWin(eo), 0, 0, STATE_NORMAL,
			ST_TOOLTIP);
	EobjShapeUpdate(eo, 0);
	EobjMap(eo, 0);
     }

   xx = pad->left + iw;

   /* draw the ordinary tooltip text */
   TextDraw(tt->tclass, EobjGetWin(tt->TTWIN), None, 0, 0, STATE_NORMAL, text,
	    xx, pad->top, headline_w, headline_h, 17, 512);

   /* draw the icons and labels, if any */
   if (ac)
     {
	num = ActionclassGetActionCount(ac);
	y = pad->top + headline_h;
	xx = pad->left + double_w;

	for (i = 0; i < num; i++)
	  {
	     x = xx + iw;

	     aa = ActionclassGetAction(ac, i);
	     if (!aa)
		continue;

	     tts = ActionGetTooltipString(aa);
	     if (!tts)
		continue;
	     tts = _(tts);

	     if (ActionGetEvent(aa) == EVENT_DOUBLE_DOWN)
	       {
		  TextDraw(tt->tclass, EobjGetWin(tt->TTWIN), None, 0, 0,
			   STATE_NORMAL, "2x", xx + iw - double_w, y, double_w,
			   heights[i], 17, 0);
	       }

	     if (ActionGetAnybutton(aa))
	       {
		  TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_ANY", x, y, &x);
	       }
	     else
		switch (ActionGetButton(aa))
		  {
		  case 1:
		     TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_1", x, y, &x);
		     break;
		  case 2:
		     TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_2", x, y, &x);
		     break;
		  case 3:
		     TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_3", x, y, &x);
		     break;
		  case 4:
		     TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_4", x, y, &x);
		     break;
		  case 5:
		     TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_5", x, y, &x);
		     break;
		  default:
		     break;
		  }

	     modifiers = ActionGetModifiers(aa);
	     if (modifiers)
	       {
		  if (modifiers & ShiftMask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_SHIFT", x, y, &x);
		  if (modifiers & LockMask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_LOCK", x, y, &x);
		  if (modifiers & ControlMask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_CTRL", x, y, &x);
		  if (modifiers & Mod1Mask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD1", x, y, &x);
		  if (modifiers & Mod2Mask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD2", x, y, &x);
		  if (modifiers & Mod3Mask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD3", x, y, &x);
		  if (modifiers & Mod4Mask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD4", x, y, &x);
		  if (modifiers & Mod5Mask)
		     TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD5", x, y, &x);
	       }

	     TextDraw(tt->tclass, EobjGetWin(tt->TTWIN), None, 0, 0,
		      STATE_NORMAL, tts, pad->left + icons_width + iw, y,
		      labels_width, heights[i], 17, 0);
	     y += heights[i];

	  }
     }

   Efree(heights);
}
Ejemplo n.º 8
0
static void
MenuDrawItem(Menu * m, MenuItem * mi, char shape, int state)
{
   PmapMask           *mi_pmm;

   if (state >= 0)
      mi->state = state;
   mi_pmm = &(mi->pmm[(int)(mi->state)]);

   if (!mi_pmm->pmap)
     {
	int                 x, y, w, h;
	int                 item_type;
	ImageClass         *ic;
	GC                  gc;
	PmapMask            pmm;

	EGetGeometry(mi->win, NULL, &x, &y, &w, &h, NULL, NULL);

	mi_pmm->type = 0;
	mi_pmm->pmap = ECreatePixmap(mi->win, w, h, 0);
	mi_pmm->mask = None;

	ic = (mi->child) ? m->style->sub_iclass : m->style->item_iclass;
	item_type = (mi->state != STATE_NORMAL) ? ST_MENU_ITEM : ST_MENU;

	if (!m->style->use_item_bg)
	  {
	     gc = EXCreateGC(m->pmm.pmap, 0, NULL);
	     XCopyArea(disp, WinGetPmap(m->win), mi_pmm->pmap, gc, x, y, w, h,
		       0, 0);
	     if ((mi->state != STATE_NORMAL) || (mi->child))
	       {
		  ImageclassApplyCopy(ic, mi->win, w, h, 0, 0, mi->state, &pmm,
				      IC_FLAG_MAKE_MASK, item_type);
		  EXCopyAreaTiled(pmm.pmap, pmm.mask, mi_pmm->pmap,
				  0, 0, w, h, 0, 0);
		  PmapMaskFree(&pmm);
	       }
	     EXFreeGC(gc);
	  }
	else
	  {
	     ImageclassApplyCopy(ic, mi->win, w, h, 0, 0, mi->state, &pmm,
				 IC_FLAG_MAKE_MASK, item_type);
	     EXCopyAreaTiled(pmm.pmap, pmm.mask, mi_pmm->pmap,
			     0, 0, w, h, 0, 0);
	     PmapMaskFree(&pmm);
	  }

	if (mi->text)
	  {
	     TextDraw(m->style->tclass, mi->win, mi_pmm->pmap, 0, 0, mi->state,
		      _(mi->text), mi->text_x, mi->text_y, mi->text_w,
		      mi->text_h, 17,
		      TextclassGetJustification(m->style->tclass));
	  }
     }

   ESetWindowBackgroundPixmap(mi->win, mi_pmm->pmap);
   EShapeSetMask(mi->win, 0, 0, mi_pmm->mask);
   EClearWindow(mi->win);

   if ((shape) && (m->style->use_item_bg))
      EShapePropagate(m->win);
}