Subversion Repositories Kolibri OS

Rev

Rev 6589 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifndef KOLIBRI_SCROLLBAR_H
  2. #define KOLIBRI_SCROLLBAR_H
  3.  
  4. typedef struct __attribute__ ((__packed__)) {
  5. //      uint16_t xsize;
  6. //    uint16_t xpos;
  7. //    uint16_t ysize;
  8. //    uint16_t ypos;
  9.     uint32_t x_w;
  10.     uint32_t y_h;
  11.     uint32_t btn_height;
  12.     uint32_t type;  // type 1 - stylish frame, type 2 - ?, type 0 - ?
  13.     uint32_t max_area;
  14.     uint32_t cur_area;
  15.     uint32_t position;
  16.     uint32_t back_color;
  17.     uint32_t front_color;
  18.     uint32_t line_color;
  19.     uint32_t redraw;
  20.     uint16_t delta;
  21.     uint16_t delta2;
  22.     uint16_t r_size_x;
  23.     uint16_t r_start_x;
  24.     uint16_t r_size_y;
  25.     uint16_t r_start_y;
  26.     uint32_t m_pos;
  27.     uint32_t m_pos2;
  28.     uint32_t m_keys;
  29.     uint32_t run_size;
  30.     uint32_t position2;
  31.     uint32_t work_size;
  32.     uint32_t all_redraw;  // need to be set =1 before each redraw
  33.     uint32_t ar_offset;
  34. } scrollbar;
  35.  
  36. inline scrollbar* kolibri_scrollbar(scrollbar* sb, uint32_t x_w, uint32_t y_h, uint32_t btn_height, uint32_t max_area,
  37.         uint32_t cur_area, uint32_t position, uint32_t back_color, uint32_t front_color, uint32_t line_color)
  38. {
  39.     memset(sb, 0, sizeof(scrollbar));
  40.  
  41.     sb->x_w = x_w;
  42.     sb->y_h = y_h;
  43.     sb->btn_height = btn_height;
  44.     sb->type = 1;
  45.     sb->max_area = max_area;
  46.     sb->cur_area = cur_area;
  47.     sb->position = position;
  48.     sb->line_color = line_color;
  49.     sb->back_color = back_color;  // 0xeeeeee
  50.     sb->front_color = front_color; // 0xbbddff
  51.     sb->ar_offset = max_area / 30; // temporary step 3%
  52.     sb->all_redraw = 1;
  53.     return sb;
  54. };
  55.  
  56. inline scrollbar* kolibri_new_scrollbar(uint32_t x_w, uint32_t y_h, uint32_t btn_height, uint32_t max_area,
  57.         uint32_t cur_area, uint32_t position, uint32_t back_color, uint32_t front_color, uint32_t line_color)
  58. {
  59.     scrollbar *sb = (scrollbar *)malloc(sizeof(scrollbar));
  60.  
  61.     return kolibri_scrollbar(sb, x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color);
  62. };
  63.  
  64. inline scrollbar* kolibri_scrollbar_def(scrollbar* sb, uint32_t x_w, uint32_t y_h, uint32_t max_area, uint32_t cur_area, uint32_t position)
  65. {
  66.     return kolibri_scrollbar(sb, x_w, y_h, 15, max_area, cur_area, position, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, kolibri_color_table.color_work_button_text);
  67. };
  68.  
  69. inline scrollbar* kolibri_new_scrollbar_def(uint32_t x_w, uint32_t y_h, uint32_t max_area, uint32_t cur_area, uint32_t position)
  70. {
  71.     return kolibri_new_scrollbar(x_w, y_h, 15, max_area, cur_area, position, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, kolibri_color_table.color_work_button_text);
  72. };
  73.  
  74. inline void gui_add_scrollbar_h(kolibri_window *wnd, scrollbar* sb)
  75. {
  76.     kolibri_window_add_element(wnd, KOLIBRI_SCROLL_BAR_H, sb);
  77. }
  78.  
  79. inline void gui_add_scrollbar_v(kolibri_window *wnd, scrollbar* sb)
  80. {
  81.     kolibri_window_add_element(wnd, KOLIBRI_SCROLL_BAR_V, sb);
  82. }
  83.  
  84. extern void (*scrollbar_h_draw)(scrollbar*) __attribute__((__stdcall__));
  85. extern void (*scrollbar_h_mouse)(scrollbar*) __attribute__((__stdcall__));
  86. extern void (*scrollbar_v_draw)(scrollbar*) __attribute__((__stdcall__));
  87. extern void (*scrollbar_v_mouse)(scrollbar*) __attribute__((__stdcall__));
  88.  
  89. #endif /* KOLIBRI_SCROLLBAR_H */
  90.