Subversion Repositories Kolibri OS

Rev

Rev 5987 | 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, buflen;
  8.         dword line_length=30;
  9.         dword stroka_y = 5;
  10.         dword stroka=0;
  11.         int i, srch_pos;
  12.  
  13.         label.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] = label.symbol_size(i);
  17.         //get font buffer height
  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 += 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.                         line_start = bufoff;
  32.                         line_length = 30;
  33.                         stroka++;
  34.                 }
  35.         }
  36.         //draw text in buffer
  37.         list.count = stroka+2;
  38.         list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, label.size.pt+1);
  39.         if (list.count < list.visible) list.count = list.visible;
  40.  
  41.         label.size.height = list.count+1*list.item_h;
  42.         label.raw_size = 0;
  43.  
  44.         line_length = 30;
  45.         line_start = io.buffer_data;
  46.         for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
  47.         {
  48.                 ch = ESBYTE[bufoff];
  49.                 line_length += char_width[ch];
  50.                 if (line_length>=list.w) || (ch==10)
  51.                 {
  52.                         //set word break
  53.                         srch_pos = bufoff;
  54.                         loop()
  55.                         {
  56.                                 if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
  57.                                 if (srch_pos == line_start) break; //no white space found in whole line
  58.                                 srch_pos--;
  59.                         }
  60.                         i = bufoff-line_start;
  61.                         strlcpy(#line, line_start, i);
  62.                         label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, #line);
  63.                         stroka_y += list.item_h;
  64.                         line_start = bufoff;
  65.                         line_length = 30;
  66.                 }
  67.         }
  68.         label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start);
  69.         label.apply_smooth();
  70.         DrawPage();
  71. }
  72.