iconelement.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <lib9.h>
  2. #include <draw.h>
  3. #include <interp.h>
  4. #include <isa.h>
  5. #include "../libinterp/runt.h"
  6. #include <drawif.h>
  7. #include <prefab.h>
  8. static
  9. PElement*
  10. iconelement1(Prefab_Environ *e, Draw_Rect r, Draw_Image *icon, Draw_Image *mask, enum Elementtype kind)
  11. {
  12. PElement *pelem;
  13. Prefab_Element *elem;
  14. if(badenviron(e, 0) || icon==H || mask==H)
  15. return H;
  16. pelem = mkelement(e, kind);
  17. if(pelem == H)
  18. return H;
  19. elem = &pelem->e;
  20. if(Dx(r))
  21. elem->r = r;
  22. else{
  23. elem->r.min = r.min;
  24. elem->r.max.x = r.min.x + Dx(icon->r);
  25. elem->r.max.y = r.min.y + Dy(icon->r);
  26. }
  27. elem->mask = mask;
  28. D2H(mask)->ref++;
  29. elem->image = icon;
  30. D2H(icon)->ref++;
  31. pelem->drawpt = IPOINT(r.min);
  32. pelem->nkids = 1;
  33. pelem->pkind = kind;
  34. return pelem;
  35. }
  36. PElement*
  37. iconelement(Prefab_Environ *e, Draw_Rect r, Draw_Image *icon, Draw_Image *mask)
  38. {
  39. return iconelement1(e, r, icon, mask, EIcon);
  40. }
  41. PElement*
  42. separatorelement(Prefab_Environ *e, Draw_Rect r, Draw_Image *icon, Draw_Image *mask)
  43. {
  44. return iconelement1(e, r, icon, mask, ESeparator);
  45. }