Subversion Repositories Kolibri OS

Rev

Rev 4686 | Blame | Last modification | View Log | Download | RSS feed

  1. //#include "strings.h"
  2.  
  3. :void DrawRectangle(dword x,y,w,h,color1)
  4. {
  5.         if (w<=0) || (h<=0) return;
  6.         DrawBar(x,y,w,1,color1);
  7.         DrawBar(x,y+h,w,1,color1);
  8.         DrawBar(x,y,1,h,color1);
  9.         DrawBar(x+w,y,1,h+1,color1);
  10. }
  11.  
  12. :void DrawRectangle3D(dword x,y,w,h,color1,color2)
  13. {
  14.         if (w<=0) || (h<=0) return;
  15.         DrawBar(x,y,w+1,1,color1);
  16.         DrawBar(x,y+1,1,h-1,color1);
  17.         DrawBar(x+w,y+1,1,h,color2);
  18.         DrawBar(x,y+h,w,1,color2);
  19. }
  20.  
  21. :void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
  22. {
  23.         if (id>0) DefineButton(x,y,w,h,id,color_b);
  24.         WriteText(-strlen(text)*6+w/2+x+1,h/2-3+y,0x80,color_t,text);
  25. }
  26.  
  27. :void WriteTextCenter(dword x,y,w,color_t,text)
  28. {
  29.         WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
  30. }
  31.  
  32. :void DrawCircle(int x, y, r)
  33. {
  34.         int i;
  35.         float px=0, py=r, ii = r * 3.1415926 * 2;
  36.         FOR (i = 0; i < ii; i++)
  37.         {
  38.         PutPixel(px + x, y - py, 0);
  39.         px = py / r + px;
  40.         py = -px / r + py;
  41.         }
  42. }
  43.  
  44. :void CheckBox(dword x,y,w,h, bt_id, text, graph_color, text_color, is_checked)
  45. {
  46.         DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, graph_color);
  47.         WriteText(x+w+10, h / 2 + y -3, 0x80, text_color, text);
  48.         DrawRectangle(x, y, w, h, graph_color);
  49.         if (is_checked == 1)
  50.         {
  51.                 DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff);
  52.                 DrawBar(x+2, y+2, w-3, h-3, graph_color);      
  53.                 return; //не дадим стрелять себе в ногу
  54.         }
  55.         if (is_checked == 2) //not active
  56.         {
  57.                 DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff);
  58.                 DrawBar(x+2, y+2, w-3, h-3, 0x888888); 
  59.                 return;
  60.         }
  61.         else
  62.         {
  63.                 DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff);
  64.                 DrawBar(x+2, y+2, w-3, h-3, 0xffffff);
  65.         }
  66. }
  67.  
  68. :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent)
  69. {
  70.         int progress_w;
  71.         static int fill_old;
  72.            
  73.         //if (progress_percent<=0) {DrawBar(st_x,st_y, st_x + st_w + fill_old + 15,st_h+1, col_fon); fill_old=0; return;}
  74.         if (progress_percent<=0) || (progress_percent>=100) return;
  75.        
  76.         DrawRectangle(st_x, st_y, st_w,st_h, col_border);
  77.         DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff);
  78.  
  79.         if (progress_percent>0) && (progress_percent<=100)
  80.         {
  81.                 progress_w = st_w - 3 * progress_percent / 100;
  82.                 DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
  83.                 DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
  84.         }
  85. }
  86.  
  87. :void DrawLink(dword x,y,font_type,btn_id, inscription)
  88. {
  89.         int w;
  90.         WriteText(x,y,font_type,0x4E00E7,inscription);
  91.         if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7;
  92.         DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
  93.         DrawBar(x,y+8,w,1,0x4E00E7);
  94. }
  95.  
  96.  
  97. :void PutShadow(dword x,y,w,h,skinned,strength)
  98. {
  99.         proc_info wForm;
  100.         dword shadow_buf, skin_height;
  101.         shadow_buf = mem_Alloc(w*h*3);
  102.         GetProcessInfo(#wForm, SelfInfo);
  103.         CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
  104.         ShadowImage(shadow_buf, w, h, strength);
  105.         _PutImage(x,y,w,h,shadow_buf);
  106.         mem_Free(shadow_buf);
  107. }
  108.  
  109. :void DrawPopupShadow(dword x,y,w,h,skinned)
  110. {
  111.         PutShadow(w+x+1,y,1,h+2,skinned,2);
  112.         PutShadow(w+x+2,y+1,1,h+2,skinned,1);
  113.         PutShadow(x,y+h+2,w+2,1,skinned,2);
  114.         PutShadow(x+1,y+h+3,w+1,1,skinned,1);
  115. }
  116.  
  117. :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
  118. {
  119.         DrawRectangle(x,y,w,h,col_border);
  120.         DrawBar(x+1,y+1,w-1,1,0xFFFfff);
  121.         DrawBar(x+1,y+2,1,h-2,0xFFFfff);
  122.         if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
  123.         DrawPopupShadow(x,y,w,h-1,skinned);
  124. }
  125.  
  126. :void GrayScaleImage(dword color_image, w, h)
  127. {
  128.         dword i,gray,rr,gg,bb;
  129.         for (i = 0; i < w*h*3; i+=3)
  130.         {
  131.                 rr = DSBYTE[i+color_image];
  132.                 gg = DSBYTE[i+1+color_image];
  133.                 bb = DSBYTE[i+2+color_image];
  134.                 gray = rr*rr;
  135.                 gray += gg*gg;
  136.                 gray += bb*bb;
  137.                 gray = sqrt(gray) / 3;
  138.                 DSBYTE[i  +color_image] = DSBYTE[i+1+color_image] = DSBYTE[i+2+color_image] = gray;
  139.         }
  140. }
  141.  
  142. :void ShadowImage(dword color_image, w, h, strength)
  143. {
  144.         dword col, to;
  145.         strength = 10 - strength;
  146.         to = w*h*3 + color_image;
  147.         for ( ; color_image < to; color_image++)
  148.         {
  149.                 col = strength * DSBYTE[color_image] / 10;
  150.                 DSBYTE[color_image] = col;
  151.         }
  152. }