Subversion Repositories Kolibri OS

Rev

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