Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. #define SEARCH_H 34
  3.  
  4.  
  5. struct SEARCH
  6. {
  7.         bool visible;
  8.         int found_count;
  9.         void show();
  10.         void hide();
  11.         bool draw();
  12.         void draw_found();
  13.         int height();
  14.         bool edit_key();
  15.         bool edit_mouse();
  16.         void clear();
  17.         int find_next();
  18. } search;
  19.  
  20. char found_text[64];
  21.  
  22. char search_text[64];
  23. edit_box search_box = {250, 10, NULL, 0xffffff,
  24. 0x94AECE, 0xffffff, 0xffffff,0x10000000,sizeof(search_text)-1,#search_text};
  25.  
  26.  
  27. void SEARCH::show()
  28. {
  29.         visible = true;
  30.         search_box.flags = ed_focus;
  31.         draw_window();
  32. }
  33.  
  34. void SEARCH::hide()
  35. {
  36.         visible = false;
  37.         draw_window();
  38. }
  39.  
  40. int SEARCH::height()
  41. {
  42.         return visible * SEARCH_H;
  43. }
  44.  
  45. bool SEARCH::edit_key()
  46. {
  47.         if (visible) && (search_box.flags & ed_focus) {
  48.                 EAX = key_editbox;
  49.                 edit_box_key stdcall(#search_box);
  50.                 return true;
  51.         }
  52.         return false;
  53. }
  54.  
  55. bool SEARCH::edit_mouse()
  56. {
  57.         if (visible) {
  58.                 edit_box_mouse stdcall(#search_box);
  59.                 if (search_box.flags & ed_focus) return true;
  60.         }
  61.         return false;
  62. }
  63.  
  64. void SEARCH::draw_found()
  65. {
  66.         char matches[30];
  67.         sprintf(#matches, T_MATCHES, found_count);
  68.         WriteTextWithBg(search_box.left+search_box.width+14+110,
  69.                 search_box.top+3, 0xD0, sc.work_text, #matches, sc.work);
  70. }
  71.  
  72. bool SEARCH::draw(dword _btn_find, _btn_hide, _y)
  73. {
  74.         if (!visible) return false;
  75.         DrawBar(0, _y, Form.cwidth, 1, sc.work_graph);
  76.         DrawBar(0, _y+1, Form.cwidth, SEARCH_H-1, sc.work);
  77.  
  78.         search_box.top = _y + 6;
  79.         search_box.width = math.min(Form.width - 200, 250);
  80.  
  81.         DrawRectangle(search_box.left-1, search_box.top-1, search_box.width+2, 23,sc.work_graph);
  82.  
  83.         edit_box_draw stdcall(#search_box);
  84.  
  85.         DrawCaptButton(search_box.left+search_box.width+14, search_box.top-1, 90,
  86.                 TOOLBAR_ICON_HEIGHT+1, _btn_find, sc.work_light, sc.work_text, T_FIND_NEXT);
  87.  
  88.         draw_found();
  89.  
  90.         DefineHiddenButton(Form.cwidth-26, search_box.top-1, TOOLBAR_ICON_HEIGHT+1,
  91.                 TOOLBAR_ICON_HEIGHT+1, _btn_hide);
  92.         WriteText(Form.cwidth-26+7, search_box.top+2, 0x81, sc.work_graph, "x");
  93.         return true;
  94. }
  95.  
  96. void SEARCH::clear()
  97. {
  98.         visible = false;
  99.         found_text[0] = '\0';
  100.         found_count = 0;
  101. }
  102.  
  103. int SEARCH::find_next(int _cur_pos)
  104. {
  105.         int i;
  106.         if (!search_text[0]) return false;
  107.  
  108.         strcpy(#found_text, #search_text);
  109.         //highlight(0xFF0000, _bg_color);
  110.         found_count = strnum(io.buffer_data, #found_text);
  111.         draw_found();
  112.  
  113.         for (i=_cur_pos+1; i<list.count; i++) {
  114.                 if (strstri(lines.get(i),#search_text)!=-1) return atoi(lines.get(i));
  115.         }
  116.         return false;
  117. }
  118.  
  119.