Subversion Repositories Kolibri OS

Rev

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

  1. void PreparePage()
  2. {
  3.         char line[4096]=0;
  4.         char char_width[255];
  5.         dword line_start;
  6.         byte ch;
  7.         dword bufoff;
  8.         dword line_length=30;
  9.         dword stroka_y = 5;
  10.         dword stroka=0;
  11.         int i, srch_pos;
  12.        
  13.         font.changeSIZE();
  14.         list.w = Form.cwidth-scroll.size_x-1;
  15.         //get font chars width, need to increase performance
  16.         for (i=0; i<256; i++) char_width[i] = font.symbol_size(i);
  17.         //get font buffer height
  18.         for (bufoff=io.buffer_data; ESBYTE[bufoff]; bufoff++)
  19.         {
  20.                 ch = ESBYTE[bufoff];
  21.                 line_length += char_width[ch];
  22.                 if (line_length>=list.w) || (ch==10) {
  23.                         srch_pos = bufoff;
  24.                         loop()
  25.                         {
  26.                                 if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
  27.                                 if (srch_pos == line_start) break; //no white space found in whole line
  28.                                 srch_pos--;
  29.                         }
  30.                         line_start = bufoff;
  31.                         line_length = 30;
  32.                         stroka++;
  33.                 }
  34.         }
  35.         //draw text in buffer
  36.         list.count = stroka+2;
  37.         list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, font.size.text+1);
  38.         if (list.count < list.visible) list.count = list.visible;
  39.  
  40.         font.size.height = list.count+1*list.item_h;
  41.         font.buffer_size = 0;
  42.  
  43.         line_length = 30;
  44.         line_start = io.buffer_data;
  45.         for (bufoff=io.buffer_data; ESBYTE[bufoff]; bufoff++)
  46.         {
  47.                 ch = ESBYTE[bufoff];
  48.                 line_length += char_width[ch];
  49.                 if (line_length>=list.w) || (ch==10)
  50.                 {
  51.                         //set word break
  52.                         srch_pos = bufoff;
  53.                         loop()
  54.                         {
  55.                                 if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
  56.                                 if (srch_pos == line_start) break; //no white space found in whole line
  57.                                 srch_pos--;
  58.                         }
  59.                         i = bufoff-line_start;
  60.                         strlcpy(#line, line_start, i);
  61.                         font.write_buf(8,stroka_y,list.w,font.size.height, #line);
  62.                         stroka_y += list.item_h;
  63.                         line_start = bufoff;
  64.                         line_length = 30;
  65.                 }
  66.         }
  67.         font.write_buf(8,stroka_y,list.w,font.size.height, line_start);
  68.         font.apply_smooth();
  69.         DrawPage();
  70. }
  71.