Subversion Repositories Kolibri OS

Rev

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

  1. //BOX_LIB - Asper
  2. #ifndef INCLUDE_BOX_LIB_H
  3. #define INCLUDE_BOX_LIB_H
  4.  
  5. #ifndef INCLUDE_KOLIBRI_H
  6. #include "../lib/kolibri.h"
  7. #endif
  8.  
  9. #ifdef __COFF__
  10. extern dword edit_box_draw;
  11. extern dword edit_box_key_safe;
  12. extern dword edit_box_mouse;
  13. extern dword edit_box_set_text;
  14.  
  15. extern dword scrollbar_v_draw;
  16. extern dword scrollbar_v_mouse;
  17. extern dword scrollbar_h_draw;
  18. extern dword scrollbar_h_mouse;
  19.  
  20. extern dword PathShow_prepare;
  21. extern dword PathShow_draw;
  22.  
  23. extern dword progressbar_draw;
  24. extern dword progressbar_progress;
  25.  
  26. extern dword frame_draw;
  27.  
  28. /*
  29.     Legacy support
  30.     For new programs need to use edit_box_key_safe  
  31.     TODO: change in all cmm programs edit_box_key to edit_box_key_safe,
  32.           after that delete #define below        
  33.              
  34. */
  35. #define edit_box_key  edit_box_key_safe
  36.  
  37. #else
  38. #ifndef INCLUDE_DLL_H
  39. #include "../lib/dll.h"
  40. #endif
  41.  
  42. dword boxlib = #aEdit_box_lib;
  43. char aEdit_box_lib[]="/sys/lib/box_lib.obj";
  44.  
  45. dword box_lib_init   = #aboxlib_init;
  46.  
  47. dword edit_box_draw     = #aEdit_box_draw;
  48. dword edit_box_key      = #aEdit_box_key;
  49. dword edit_box_key_c    = #aEdit_box_key_c;
  50. dword edit_box_mouse    = #aEdit_box_mouse;
  51. dword edit_box_set_text = #aEdit_box_set_text;
  52.  
  53. dword scrollbar_v_draw  = #aScrollbar_v_draw;
  54. dword scrollbar_v_mouse = #aScrollbar_v_mouse;
  55. dword scrollbar_h_draw  = #aScrollbar_h_draw;
  56. dword scrollbar_h_mouse = #aScrollbar_h_mouse;
  57.  
  58. dword PathShow_prepare  = #aPathShow_prepare;
  59. dword PathShow_draw     = #aPathShow_draw;
  60.  
  61. dword progressbar_draw = #aProgressbar_draw;
  62. dword progressbar_progress = #aProgressbar_progress;
  63.  
  64. dword frame_draw = #aFrame_draw;
  65.  
  66. $DD 2 dup 0
  67.  
  68. char aEdit_box_draw []    = "edit_box";
  69. char aEdit_box_key  []    = "edit_box_key";
  70. char aEdit_box_key_c[]    = "edit_box_key_safe";
  71. char aEdit_box_mouse[]    = "edit_box_mouse";
  72. char aEdit_box_set_text[] = "edit_box_set_text";
  73.  
  74. char aboxlib_init[]       = "lib_init";
  75. char aScrollbar_v_draw [] = "scrollbar_v_draw";
  76. char aScrollbar_v_mouse[] = "scrollbar_v_mouse";
  77. char aScrollbar_h_draw [] = "scrollbar_h_draw";
  78. char aScrollbar_h_mouse[] = "scrollbar_h_mouse";
  79.  
  80. char aPathShow_prepare [] = "PathShow_prepare";
  81. char aPathShow_draw    [] = "PathShow_draw";
  82.  
  83. char aProgressbar_draw    [] = "progressbar_draw";
  84. char aProgressbar_progress[] = "progressbar_progress";
  85.  
  86. char aFrame_draw[] = "frame_draw";
  87. #endif
  88.  
  89. struct PathShow_data
  90. {
  91. dword type;
  92. word  start_y;
  93. word  start_x;
  94. word  font_w;       // 6 - for font 0, 8 - for font 1
  95. word  area_size_x;
  96. dword font_number;  // 0 - monospace, 1 - variable
  97. dword background_flag;
  98. dword font_color;
  99. dword background_color;
  100. dword text_pointer;
  101. dword work_area_pointer;
  102. dword temp_text_length;
  103. };
  104. /*
  105. char temp[128];
  106. PathShow_data PathShow = {0, 100,20, 6, 200, 0, 1, 0x0, 0xFFFfff, #email_text, #temp, 0};
  107. PathShow_prepare stdcall(#PathShow);
  108. PathShow_draw stdcall(#PathShow);
  109. */
  110.  
  111. //editbox flags
  112. #define ed_pass                        1b
  113. #define ed_focus                      10b   //focused
  114. #define ed_shift                     100b   //flag is set when Shift is pressed
  115. #define ed_shift_on                 1000b
  116. #define ed_shift_bac               10000b   //bit for Shift reset, if set the smth is selected
  117. #define ed_left_fl                100000b
  118. #define ed_offset_fl             1000000b
  119. #define ed_insert               10000000b
  120. #define ed_mouse_on            100000000b
  121. #define ed_mouse_adn_b         100011000b
  122. #define ed_disabled         100000000000b
  123. #define ed_always_focus  100000000000000b
  124. #define ed_figure_only  1000000000000000b   //numbers only
  125. #define ed_shift_cl     1111111111100011b
  126. #define ed_shift_mcl    1111111111111011b
  127. #define ed_shift_off    1111111111111011b
  128. #define ed_shift_on_off 1111111111110111b
  129. #define ed_shift_bac_cl 1111111111101111b
  130. #define ed_right_fl     1111111111011111b
  131. #define ed_offset_cl    1111111110111111b
  132. #define ed_insert_cl    1111111101111111b
  133. #define ed_mouse_on_off 1111111011111111b
  134.  
  135. struct edit_box{
  136. dword width, left, top,
  137.         bg_color, selec_color, focus_border_color, border_color, text_color,
  138.         max,
  139.         text,
  140.         mouse_variable,
  141.         flags,
  142.         size, pos, offset,
  143.         cl_curs_x, cl_curs_y,
  144.         shift, shift_old,
  145.         height, char_width;
  146. };
  147.  
  148. :void EditBox_UpdateText(dword ed, _flags)
  149. {
  150.         dword ed_text;
  151.         ESI = ed;
  152.         //ESI.edit_box.offset = ESI.edit_box.shift = ESI.edit_box.shift_old = 0; //no need because of 7904
  153.         ESI.edit_box.flags = _flags;
  154.         ed_text = ESI.edit_box.text;
  155.         //ESI.edit_box.pos =  //no need because of 7904
  156.         ESI.edit_box.size = strlen(ed_text);
  157. }
  158.  
  159. :dword EditBox_Create(dword eb, left, top, width, maxlen, text, flags)
  160. {
  161.         ESDWORD[eb] = width;
  162.         ESDWORD[eb + 4] = left;
  163.         ESDWORD[eb + 8] = top;
  164.         ESDWORD[eb + 12] = 0xffffff;
  165.         ESDWORD[eb + 16] = 0x94AECE;
  166.         ESDWORD[eb + 20] = 0xffffff;
  167.         ESDWORD[eb + 24] = 0xffffff;
  168.         ESDWORD[eb + 28] = 0x10000000;
  169.         ESDWORD[eb + 32] = maxlen;
  170.         ESDWORD[eb + 36] = text;
  171.         ESDWORD[eb + 40] = 0;
  172.         ESDWORD[eb + 44] = flags;
  173.         ESDWORD[eb + 48] = 0;
  174.         ESDWORD[eb + 52] = 0;
  175. }
  176.  
  177. struct scroll_bar
  178. {
  179.         word size_x, start_x, size_y, start_y;
  180.         dword btn_height, type, max_area, cur_area, position,
  181.         bckg_col, frnt_col, line_col, redraw;
  182.         word delta, delta2, r_size_x, r_start_x, r_size_y, r_start_y;
  183.         dword m_pos, m_pos_2, m_keys, run_size, position2, work_size, all_redraw, ar_offset;
  184. };
  185.  
  186. struct progress_bar
  187. {
  188.   dword value,
  189.         left, top,
  190.         width, height,
  191.         style,
  192.         min, max,
  193.         back_color, progress_color, frame_color;
  194. };
  195.  
  196. struct frame
  197. {
  198.         dword type;
  199.         word size_x; //start_x, size_x => Mario, WTF? Is this so complex to use x/y/w/h ?
  200.         word start_x;
  201.         word size_y;
  202.         word start_y;
  203.         dword ext_col;
  204.         dword int_col;
  205.         dword flags;  // see FR_FLAGS
  206.         dword text_pointer;
  207.         dword text_position;   //  0-up,1-bottom
  208.         dword font_number;     //  0-monospace,1-variable
  209.         dword font_size_y;
  210.         dword font_color;
  211.         dword font_backgr_color;
  212. };
  213.  
  214. // FR_FLAGS = [x][yyy][z]
  215. // z        -  Caption
  216. // yyy      -  BorderStyle
  217. // x        -  BackStyle
  218. #define FR_CAPTION 00001b // [z]
  219. #define FR_DOUBLE  00000b // [yyy]
  220. #define FR_RAISED  00010b // [yyy]
  221. #define FR_SUNKEN  00100b // [yyy]
  222. #define FR_ETCHED  00110b // [yyy]
  223. #define FR_RIDGED  01000b // [yyy]
  224. #define FR_FILLED  10000b // [x]
  225.  
  226. :frame frame123 = { 0, 260, 10, 60, 16, NULL, 0xFFFfff, 1, NULL, 0, 1, 12, 0x000111, 0xCCCccc };
  227. :void DrawFrame(dword x,y,w,h,text)
  228. {
  229.         frame123.font_color = sc.work_text;
  230.         frame123.ext_col = sc.line;
  231.         frame123.int_col = sc.light;
  232.         frame123.font_backgr_color = sc.work;
  233.  
  234.         frame123.start_x = x;
  235.         frame123.start_y = y;
  236.         frame123.size_x = w;
  237.         frame123.size_y = h;
  238.         frame123.text_pointer = text;
  239.         if (!text) frame123.flags=0; else frame123.flags=FR_CAPTION;
  240.         frame_draw stdcall (#frame123);
  241. }
  242.  
  243.  
  244. #endif