Subversion Repositories Kolibri OS

Rev

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

  1. void DrawToolbarButton(char image_id, int x)
  2. {
  3.         DefineButton(x+1, 7, TOOLBAR_ICON_WIDTH-2, TOOLBAR_ICON_HEIGHT-2, 10+image_id + BT_HIDE, 0);
  4.         img_draw stdcall(skin.image, x, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, 0, image_id*TOOLBAR_ICON_HEIGHT);
  5. }
  6.  
  7.  
  8. void DrawScroller()
  9. {
  10.         scroll.max_area = list.count;
  11.         scroll.cur_area = list.visible;
  12.         scroll.position = list.first;
  13.         scroll.all_redraw = 0;
  14.         scroll.start_x = list.x + list.w;
  15.         scroll.start_y = list.y;
  16.         scroll.size_y = list.h;
  17.         scroll.start_x = list.x + list.w;
  18.         scrollbar_v_draw(#scroll);
  19. }
  20.  
  21.  
  22. dword MakePageWithHistory()
  23. {
  24.         int i;
  25.         static dword history_page;
  26.  
  27.         if (history_page) free(history_page);
  28.         history_page = malloc(history.items.data_size+256);
  29.         strcat(history_page, "<html><head><title>History</title></head><body>\n<h1>History</h1>\n");
  30.         strcat(history_page, "<h2>Visited pages</h2><br>\n");
  31.         for (i=0; i<history.items.count; i++)
  32.         {
  33.                 strcat(history_page, "<a href='");
  34.                 strcat(history_page, history.items.get(i));
  35.                 strcat(history_page, "'>");
  36.                 strcat(history_page, history.items.get(i));
  37.                 strcat(history_page, "</a><br>\n");
  38.         }
  39.         return history_page;
  40. }
  41.  
  42.  
  43. enum {
  44.         STEP_1_DOWNLOAD_PAGE         =   0,
  45.         STEP_2_COUNT_PAGE_HEIGHT     =  30,
  46.         STEP_3_DRAW_PAGE_INTO_BUFFER =  60,
  47.         STEP_4_SMOOTH_FONT           =  94,
  48.         STEP_5_STOP                  = 100,
  49. };
  50.  
  51. void DrawProgress(int percent)
  52. {
  53.         int progress_width;
  54.         if (percent<100) {
  55.                 progress_width = address_box.width+5*percent/100;
  56.                 DrawBar(address_box.left-3, address_box.top+16, progress_width, 2, 0x72B7EA);
  57.                 //debugi(percent);
  58.         }
  59.         else {
  60.                 progress_width = address_box.width+5;
  61.                 DrawBar(address_box.left-3, address_box.top+16, progress_width, 2, 0xFFFfff);
  62.         }
  63. }
  64.  
  65. int progress_percent;
  66. void DrawProgressWhileDrawing(dword bufoff, buflen)
  67. {
  68.         int progress_cur = bufoff - io.buffer_data;
  69.         int progress_max = buflen - io.buffer_data;
  70.         int new_progress_percent = STEP_4_SMOOTH_FONT-STEP_3_DRAW_PAGE_INTO_BUFFER*progress_cur/progress_max + STEP_3_DRAW_PAGE_INTO_BUFFER;
  71.         if (progress_percent != new_progress_percent) {
  72.                 progress_percent = new_progress_percent;
  73.                 DrawProgress(progress_percent);
  74.         }
  75. }
  76.