Subversion Repositories Kolibri OS

Rev

Rev 5231 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "rect.h"
  2.  
  3. void rect_draw(rect* r, __u32 color)
  4. {
  5.     __menuet__bar(r->x,r->y,r->width,r->height,color);
  6. }
  7.  
  8. __u8 rect_transform(rect* from, rect* to, __u16 step)
  9. {
  10.     if (from->width < to->width)
  11.     {
  12.         from->width += (step << 1);
  13.         if (from->width > to->width) from->width = to->width;
  14.     }
  15.     else if (from->width > to->width)
  16.     {
  17.         from->width -= (step << 1);
  18.         if (from->width < to->width) from->width = to->width;
  19.     }
  20.  
  21.     if (from->height < to->height)
  22.     {
  23.         from->height += (step << 1);
  24.         if (from->height > to->height) from->height = to->height;
  25.     }
  26.     else if (from->height > to->height)
  27.     {
  28.         from->height -= (step << 1);
  29.         if (from->height < to->height) from->height = to->height;
  30.     }
  31.  
  32.     if (from->x < to->x)
  33.     {
  34.         from->x += step;
  35.         if (from->x > to->x) from->x = to->x;
  36.     }
  37.     else if (from->x > to->x)
  38.     {
  39.         from->x -= step;
  40.         if (from->x < to->x) from->x = to->x;
  41.     }
  42.  
  43.     if (from->y < to->y)
  44.     {
  45.         from->y += step;
  46.         if (from->y > to->y) from->y = to->y;
  47.     }
  48.     else if (from->y > to->y)
  49.     {
  50.         from->y -= step;
  51.         if (from->y < to->y) from->y = to->y;
  52.     }
  53.  
  54.     return (from->x == to->x)           &&
  55.             (from->y == to->y)          &&
  56.             (from->width == to->width)  &&
  57.             (from->height == to->height);
  58. }
  59.  
  60. void rect_draw_text(rect *r, char *txt, __u32 len, __u32 color, __u32 frame_color)
  61. {
  62.     // right down shadow
  63.     __menuet__write_text(r->x + 1 + (r->width - text_length_px(len)) / 2,
  64.                          r->y + 1 + (r->height - FONT_HEIGHT) / 2,
  65.                          frame_color,txt,len);
  66.     // right shadow
  67.     __menuet__write_text(r->x + 1 + (r->width - text_length_px(len)) / 2,
  68.                          r->y + (r->height - FONT_HEIGHT) / 2,
  69.                          frame_color,txt,len);
  70.     // down shadow
  71.     __menuet__write_text(r->x + (r->width - text_length_px(len)) / 2,
  72.                          r->y + 1 + (r->height - FONT_HEIGHT) / 2,
  73.                          frame_color,txt,len);
  74.  
  75.     __menuet__write_text(r->x + (r->width - text_length_px(len)) / 2,
  76.                          r->y + (r->height - FONT_HEIGHT) / 2,
  77.                          color,txt,len);
  78. }
  79.  
  80. void rect_draw_value(rect* r, __u32 v, __u32 color, __u32 frame_color)
  81. {
  82.     char buffer[16] = {0};
  83.     __u32 length = strlen(itoa(v,buffer,10));
  84.     rect_draw_text(r,buffer,length,color,frame_color);
  85. }
  86.