Subversion Repositories Kolibri OS

Rev

Rev 9811 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. // writed by maxcodehack and superturbocat2001
  2. // adaptation of clayer for ktcc
  3. #ifndef KOLIBRI_BOXLIB_H
  4. #define KOLIBRI_BOXLIB_H
  5.  
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <sys/ksys.h>
  9.  
  10. typedef unsigned color_t;
  11.  
  12. /*  flags meaning */
  13. #define ed_figure_only  0b1000000000000000 // одни символы
  14. #define ed_always_focus 0b100000000000000  // всегда с курсором (фокусом)
  15. #define ed_focus        0b10               // фокус ввода приложения, мышится самостоятельно
  16. #define ed_pass         0b1                // поле с паролем
  17. #define ed_shift_on     0b1000             // если не установлен -значит впервые нажат shift,если был установлен, значит мы уже что - то делали удерживая //shift
  18. #define ed_shift_on_off 0b1111111111110111
  19. #define ed_shift        0b100 //включается при нажатии на shift т.е. если нажимаю
  20. #define ed_shift_off    0b1111111111111011
  21. #define ed_shift_bac    0b10000            //бит для очистки выделеного shift т.е. при установке говорит что есть выделение
  22. #define ed_shift_bac_cl 0b1111111111101111 //очистка при удалении выделения
  23. #define ed_shift_cl     0b1111111111100011
  24. #define ed_shift_mcl    0b1111111111111011
  25. #define ed_left_fl      0b100000
  26. #define ed_right_fl     0b1111111111011111
  27. #define ed_offset_fl    0b1000000
  28. #define ed_offset_cl    0b1111111110111111
  29. #define ed_insert       0b10000000
  30. #define ed_insert_cl    0b1111111101111111
  31. #define ed_mouse_on     0b100000000
  32. #define ed_mous_adn_b   0b100011000
  33. #define ed_mouse_off    ~ed_mouse_on
  34. #define ed_ctrl_on      0b1000000000
  35. #define ed_ctrl_off     ~ed_ctrl_on
  36. #define ed_alt_on       0b10000000000
  37. #define ed_alt_off      ~ed_alt_on
  38. #define ed_disabled     0b100000000000
  39.  
  40. // SCROLLBAR
  41. typedef struct {
  42.     uint16_t xsize;
  43.     uint16_t xpos;
  44.     uint16_t ysize;
  45.     uint16_t ypos;
  46.     uint32_t btn_height;
  47.     uint32_t type; // type 1 - stylish frame, type 2 - ?, type 0 - ?
  48.     uint32_t max_area;
  49.     uint32_t cur_area;
  50.     uint32_t position;
  51.     uint32_t back_color;
  52.     uint32_t front_color;
  53.     uint32_t line_color;
  54.     uint32_t redraw;
  55.     uint16_t delta;
  56.     uint16_t delta2;
  57.     uint16_t r_size_x;
  58.     uint16_t r_start_x;
  59.     uint16_t r_size_y;
  60.     uint16_t r_start_y;
  61.     uint32_t m_pos;
  62.     uint32_t m_pos2;
  63.     uint32_t m_keys;
  64.     uint32_t run_size;
  65.     uint32_t position2;
  66.     uint32_t work_size;
  67.     uint32_t all_redraw; // need to be set =1 before each redraw
  68.     uint32_t ar_offset;
  69. } __attribute__((__packed__)) scrollbar;
  70.  
  71. DLLAPI void __stdcall scrollbar_h_draw(scrollbar*);
  72. DLLAPI void __stdcall scrollbar_h_mouse(scrollbar*);
  73. DLLAPI void __stdcall scrollbar_v_draw(scrollbar*);
  74. DLLAPI void __stdcall scrollbar_v_mouse(scrollbar*);
  75.  
  76. // CHECKBOX
  77. typedef struct {
  78.     unsigned int left_s;
  79.     unsigned int top_s;
  80.     unsigned int ch_text_margin;
  81.     unsigned int color;
  82.     unsigned int border_color;
  83.     unsigned int text_color;
  84.     char* text;
  85.     unsigned int flags;
  86.  
  87.     /* Users can use members above this */
  88.     unsigned int size_of_str;
  89. } check_box;
  90.  
  91. DLLAPI void __stdcall check_box_draw2(check_box*);
  92. DLLAPI void __stdcall check_box_mouse2(check_box*);
  93. DLLAPI void __stdcall init_checkbox2(check_box*);
  94.  
  95. // DBUTTON
  96. typedef struct {
  97.     uint32_t type;
  98.     uint32_t x_w;
  99.     uint32_t y_h;
  100.     uint32_t mouse_pos;
  101.     uint32_t mouse_keys;
  102.     uint32_t mouse_keys_old;
  103.     void* active_raw;        //active bitmap
  104.     void* passive_raw;       //passive bitmap
  105.     void* click_raw;         //pressed bitmap
  106.     uint32_t resolution_raw; // bpp, as esi fn65
  107.     void* palette_raw;       // palette, as edi fn65
  108.     uint32_t offset_raw;     // width as ebp fn65
  109.     uint32_t select;         // internal state: 0 - passive, 2 - pressed, 1 - clicked
  110.     uint32_t click;          // clicked - 1, zero it after tested
  111. } pict_button;
  112.  
  113. DLLAPI void __stdcall dynamic_button_draw(pict_button*);
  114. DLLAPI void __stdcall dynamic_button_mouse(pict_button*);
  115.  
  116. // EDITBOX
  117.  
  118. #pragma pack(push, 1)
  119. typedef struct edit_box_t {
  120.     unsigned int width;
  121.     unsigned int left;
  122.     unsigned int top;
  123.     unsigned int color;
  124.     unsigned int shift_color; // selected text color
  125.     unsigned int focus_border_color;
  126.     unsigned int blur_border_color;
  127.     unsigned int text_color;
  128.     unsigned int max;
  129.     char* text;
  130.     void* mouse_variable; // must be pointer edit_box** to save focused editbox
  131.     unsigned int flags;
  132.  
  133.     unsigned int size; // used symbols in buffer without trailing zero
  134.     unsigned int pos;  // cursor position
  135.                        /* The following struct members are not used by the users of API */
  136.     unsigned int offset;
  137.     unsigned int cl_curs_x;
  138.     unsigned int cl_curs_y;
  139.     unsigned int shift;
  140.     unsigned int shift_old;
  141.     unsigned int height;
  142.     unsigned int char_width;
  143. } edit_box;
  144. #pragma pack(pop)
  145.  
  146. DLLAPI void __stdcall edit_box_draw(edit_box*);
  147. DLLAPI void __stdcall edit_box_key(edit_box*, unsigned int key_val);
  148. DLLAPI void __stdcall edit_box_mouse(edit_box*);
  149. DLLAPI void __stdcall edit_box_set_text(edit_box*, char*);
  150.  
  151. DLLAPI void __stdcall edit_box_key_safe(edit_box* e, ksys_oskey_t ch);
  152.  
  153. // FRAME
  154. typedef struct {
  155.     uint32_t type;
  156.     uint32_t x_w;
  157.     uint32_t y_h;
  158.     color_t ext_col;
  159.     color_t int_col;
  160.     uint32_t flags;
  161.     char* text_pointer;
  162.     uint32_t text_position;
  163.     uint32_t font_number;
  164.     uint32_t font_size_y;
  165.     color_t font_color;
  166.     color_t font_bg_color;
  167. } frame;
  168.  
  169. DLLAPI void __stdcall frame_draw(frame*);
  170.  
  171. // MENUBAR
  172. typedef struct
  173. {
  174.     uint32_t type; // 1 åñëè íåò ïîäìåíþ, ïðîñòî ïóíêò
  175.  
  176.     uint32_t x_w; // âåðõíèé ïóíêò
  177.     uint32_t y_h;
  178.  
  179.     char* text_pointer;
  180.     char* pos_pointer;
  181.     char* text_end;
  182.     uint32_t mouse_pos;
  183.     uint32_t mouse_keys;
  184.  
  185.     uint32_t x_w1; // ïîäìåíþ
  186.     uint32_t y_h1;
  187.  
  188.     color_t bckg_col; // ôîí âåðõíåãî ïóêòà
  189.     color_t frnt_col; // ôîí âûáðàííîãî âåðõíåãî ïóíêòà
  190.     color_t menu_col; // ôîí âûïàäàþùåé ÷àñòè (ïîäïóêòû)
  191.     uint32_t select;
  192.     uint32_t out_select;
  193.     char* buf_adress;
  194.     char* procinfo;
  195.     uint32_t click;
  196.     uint32_t cursor;
  197.     uint32_t cursor_old;
  198.     uint32_t interval;
  199.     uint32_t cursor_max;
  200.     uint32_t extended_key;
  201.     color_t menu_sel_col;  // öâåò ôîíà âûáðàííîãî ïîäïóíêòà
  202.     color_t bckg_text_col; // öâåò øðèôòà íåâûáðàííîãî ïóíêòà
  203.     color_t frnt_text_col; // öâåò øðèôòà âûáðàííîãî ïóíêòà
  204.     uint32_t mouse_keys_old;
  205.     uint32_t font_height;
  206.     uint32_t cursor_out;
  207.     uint32_t get_mouse_flag;
  208. } menubar;
  209.  
  210. DLLAPI void __stdcall menu_bar_draw(menubar*);
  211. DLLAPI void __stdcall menu_bar_mouse(menubar*);
  212. DLLAPI void __stdcall menu_bar_activate(menubar*);
  213.  
  214. // OPTIONBOX
  215. typedef struct option_box_t {
  216.     struct option_box_t** selected;
  217.     uint16_t posx;
  218.     uint16_t posy;
  219.     uint32_t text_margin; // = 4 ðàññòîÿíèå îò ïðÿìîóãîëüíèêà ÷åê áîêñà äî íàäïèñè
  220.     uint32_t size;        // 12 ðàçìåð êâàäðàòà ÷åê áîêñà
  221.     color_t color;
  222.     color_t border_color; // individual border
  223.     color_t text_color;
  224.     char* text;
  225.     uint32_t text_len;
  226.     uint32_t flags;
  227. } __attribute__((__packed__)) option_box;
  228.  
  229. DLLAPI void __stdcall option_box_draw(option_box**);
  230. DLLAPI void __stdcall option_box_mouse(option_box**);
  231.  
  232. // PATHSHOW
  233. typedef struct {
  234.     uint32_t type;
  235.     uint32_t x_y;
  236.     uint16_t font_size_x; // 6 - for font 0, 8 - for font 1
  237.     uint16_t area_size_x;
  238.     uint32_t font_number;     // 0 - monospace, 1 - variable, as fn4 (2bit only 0-3)
  239.     uint32_t background_flag; // as fn4, if 0, bk_color unneeded
  240.     color_t font_color;       // as fn4
  241.     color_t background_color; // as fn4
  242.     char* text_pointer;       // 4096 ?
  243.     char* work_area_pointer;  // 4096 ?
  244.     uint32_t temp_text_length;
  245. } __attribute__((__packed__)) pathview;
  246.  
  247. DLLAPI void __stdcall path_show_prepare(pathview*);
  248. DLLAPI void __stdcall path_show_draw(pathview*);
  249.  
  250. // PROGRESSBAR
  251. typedef struct {
  252.     unsigned int value;
  253.     unsigned int left;
  254.     unsigned int top;
  255.     unsigned int width;
  256.     unsigned int height;
  257.     unsigned int style;
  258.     unsigned int min;
  259.     unsigned int max;
  260.     unsigned int back_color;
  261.     unsigned int progress_color;
  262.     unsigned int frame_color;
  263. } progressbar;
  264.  
  265. DLLAPI void __stdcall progressbar_draw(progressbar*);
  266. DLLAPI void __stdcall progressbar_progress(progressbar*);
  267.  
  268. #endif /* KOLIBRI_BOXLIB_H */
  269.