Subversion Repositories Kolibri OS

Rev

Rev 7462 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. enum {
  2.         COUNT_BUF_HEIGHT,
  3.         DRAW_BUF
  4. };
  5.  
  6. #define DRAW_PADDING 12
  7.  
  8. void Parcer(byte mode)
  9. {
  10. dword bufoff, buflen;
  11. byte ch;
  12. char line[4096]=0;
  13. int srch_pos;
  14. dword stroka_y=DRAW_PADDING-3;
  15. dword line_length=30;
  16. dword line_start=io.buffer_data;
  17.  
  18.         buflen = strlen(io.buffer_data) + io.buffer_data;
  19.         for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
  20.         {
  21.                 ch = ESBYTE[bufoff];
  22.                 line_length += kfont_char_width[ch];
  23.                 if (line_length>=list.w) || (ch==10) {
  24.                         srch_pos = bufoff;
  25.                         loop()
  26.                         {
  27.                                 if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
  28.                                 if (srch_pos == line_start) break; //no white space found in whole line
  29.                                 srch_pos--;
  30.                         }
  31.                         if (mode==COUNT_BUF_HEIGHT) {
  32.                                 line_start = bufoff;
  33.                                 line_length = 30;
  34.                                 list.count++;
  35.                         }
  36.                         if (mode==DRAW_BUF) {
  37.                                 EBX = bufoff-line_start;
  38.                                 strlcpy(#line, line_start, EBX);
  39.                                 kfont.WriteIntoBuffer(DRAW_PADDING,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, #line);
  40.                                 stroka_y += list.item_h;
  41.                                 line_start = bufoff;
  42.                                 line_length = 30;
  43.                         }
  44.                 }
  45.         }
  46.         if (mode==COUNT_BUF_HEIGHT) list.count+=2;
  47.         if (mode==DRAW_BUF) kfont.WriteIntoBuffer(DRAW_PADDING,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, line_start);
  48. }
  49.  
  50. void PreparePage()
  51. {
  52.         list.w = Form.cwidth-scroll.size_x-1;
  53.         list.count=0;
  54.         Parcer(COUNT_BUF_HEIGHT);
  55.        
  56.         //draw text in buffer
  57.         list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+6);
  58.         if (list.count < list.visible) list.count = list.visible;
  59.         kfont.size.height = list.count+1*list.item_h;
  60.         kfont.raw_size = 0;
  61.         Parcer(DRAW_BUF);
  62.  
  63.         if (list.count > list.visible * 10) DrawPage();
  64.         //draw result
  65.         kfont.ApplySmooth();
  66.         DrawPage();
  67. }
  68.