home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / lyxfr0.C < prev    next >
C/C++ Source or Header  |  1998-04-23  |  3KB  |  150 lines

  1. /* This file is part of
  2. * ======================================================
  3. *           LyX, The Document Processor
  4. *      
  5. *        Copyright (C) 1995 Matthias Ettrich,
  6. *           Copyright (C) 1995-1998 The LyX Team.
  7. *
  8. *======================================================*/
  9.  
  10. #include <config.h>
  11.  
  12. #include <ctype.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15.  
  16. #ifdef __GNUG__
  17. #pragma implementation
  18. #endif
  19.  
  20. #include "LString.h"
  21. #include "lyx_main.h"
  22. #include FORMS_H_LOCATION
  23. #include "form1.h"
  24. #include "lyxfr0.h"
  25. #include "lyxfr1.h"
  26. #include "lyxfunc.h"
  27. #include "lyxscreen.h"
  28. #include "error.h"
  29. #include "lyxtext.h"
  30. #include "gettext.h"
  31. #include "LyXView.h" // only because of form_main
  32.  
  33. //---------------------------------------------------------------
  34. // I hate global variables, but the same search object must be used everywhere,
  35. // and the form is also global, so... 
  36. LyXFindReplace1    _FR;
  37.  
  38. // This one should be a protected member of LyXFindReplace1
  39. // Form creation/destruction must also be done in LyXFindReplace1
  40. extern FD_form_search *fd_form_search;
  41.  
  42. //---------------------------------------------------------------
  43.  
  44.  
  45. // callbacks for form form_search
  46. void SearchCancelCB(FL_OBJECT *, long)
  47. {
  48.     _FR.SearchCancelCB();
  49. }
  50.  
  51.  
  52. void SearchForwardCB(FL_OBJECT *, long)
  53. {
  54.     _FR.SearchCB(true);
  55. }
  56.  
  57.  
  58. void SearchBackwardCB(FL_OBJECT *, long)
  59. {
  60.     _FR.SearchCB(false);
  61. }
  62.  
  63.  
  64. void SearchReplaceCB(FL_OBJECT *, long)
  65. {
  66.     _FR.SearchReplaceCB();
  67. }
  68.  
  69.  
  70. //--------------------- LyXFindReplace0's implementation ------------
  71.  
  72. LyXFindReplace0::LyXFindReplace0()
  73. {
  74.         fCaseSensitive = false;
  75.     fMatchWord = false;
  76. }
  77.  
  78.  
  79. void LyXFindReplace0::StartSearch()
  80. {
  81.     FD_form_search *fd_fs = fd_form_search;
  82.  
  83.     if (fd_fs->form_search->visible) {
  84.         fl_raise_form(fd_fs->form_search);
  85.     } else {
  86.         fl_show_form(fd_fs->form_search,
  87.                  FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
  88.                  _("Find & Replace"));    // RVDK_PATCH_5
  89.     }
  90.     ReInitFromForm();
  91. }
  92.  
  93.  
  94. void LyXFindReplace0::ReInitFromForm()
  95. {
  96.     FD_form_search *fd_fs = fd_form_search;
  97.  
  98.     lsSearch = fl_get_input(fd_fs->input_search);
  99.     fCaseSensitive = fl_get_button(fd_fs->btnCaseSensitive);
  100.     fMatchWord = fl_get_button(fd_fs->btnMatchWord);
  101. }
  102.  
  103.  
  104. // Returns the value of the replace string in the form
  105. LString const LyXFindReplace0::ReplaceString()
  106. {
  107.     return LString(fl_get_input(fd_form_search->input_replace));
  108. }
  109.  
  110.  
  111. void LyXFindReplace0::SearchCancelCB()
  112. {
  113.     fl_hide_form(fd_form_search->form_search);
  114. }
  115.  
  116.  
  117. void LyXFindReplace0::SetReplaceEnabled(bool fEnable)
  118. {
  119.     FD_form_search *fd_fs = fd_form_search;
  120.     fReplaceEnabled = fEnable;
  121.     if (fEnable) {
  122.             fl_activate_object(fd_fs->replace_button);
  123.             fl_activate_object(fd_fs->input_replace);
  124.         fl_set_object_lcol(fd_fs->replace_button, FL_BLACK);
  125.         fl_set_object_lcol(fd_fs->input_replace, FL_BLACK);
  126.     } else {
  127.             fl_deactivate_object(fd_fs->replace_button);
  128.             fl_deactivate_object(fd_fs->input_replace);
  129.         fl_set_object_lcol(fd_fs->replace_button,FL_INACTIVE);
  130.         fl_set_object_lcol(fd_fs->input_replace, FL_INACTIVE);
  131.     }
  132. }
  133.  
  134.  
  135. void LyXFindReplace0::SetSearchString(LString const &ls)
  136. {
  137.     lsSearch = ls;
  138.     fl_set_input(fd_form_search->input_search, ls.c_str());    
  139. }
  140.  
  141.  
  142. //---------------------------------------------------------------
  143. //HB??: Maybe _FR.StartSearch should be called in lyxfunc.C instead of MenuSearch() ?
  144.  
  145. void MenuSearch()
  146. {
  147.     _FR.StartSearch();   
  148. }
  149.