/********************************************************************************
*                                                                               *
*                       T e x t   S e a r c h   D i a l o g                     *
*                                                                               *
*********************************************************************************
* Copyright (C) 2000 by Jeroen van der Zijp.   All Rights Reserved.             *
*********************************************************************************
* This library is free software; you can redistribute it and/or                 *
* modify it under the terms of the GNU Library General Public                   *
* License as published by the Free Software Foundation; either                  *
* version 2 of the License, or (at your option) any later version.              *
*                                                                               *
* This library is distributed in the hope that it will be useful,               *
* but WITHOUT ANY WARRANTY; without even the implied warranty of                *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
* Library General Public License for more details.                              *
*                                                                               *
* You should have received a copy of the GNU Library General Public             *
* License along with this library; if not, write to the Free                    *
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.            *
*********************************************************************************
* $Id: FXSearchDialog.h,v 1.4 2000/08/25 17:07:58 jeroen Exp $                  *
********************************************************************************/
#ifndef FXSEARCHDIALOG_H
#define FXSEARCHDIALOG_H


/// Search modes
enum FXSearchMode {
  SEARCHMODE_EXACT,             /// Exact match
  SEARCHMODE_IGNORECASE,        /// Exact but case insensitive match
  SEARCHMODE_REGEX              /// Regular expression pattern match
  };


class FXTextField;
class FXButton;



/// Text search dialog
class FXAPI FXSearchDialog : public FXDialogBox {
  FXDECLARE(FXSearchDialog)
protected:
  FXTextField *searchtext;          // Text to look for
  FXButton    *nextbutton;          // Button which goes to next instance
  FXButton    *lastbutton;          // Button which goes to last instance
  FXuchar      searchmode;          // Search matching mode
  FXuchar      backwards;           // Search direction flag
  FXDataTarget matchtgt;            // Changing match mode
  FXDataTarget dirtgt;              // Changing direction flag
protected:
  FXSearchDialog(){}
private:
  FXSearchDialog(const FXSearchDialog&);
  FXSearchDialog &operator=(const FXSearchDialog&);
public:
  
  /// Construct Directory Dialog Box
  FXSearchDialog(FXWindow* owner,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);

  /// Button to search for next match w/o closing dialog
  FXButton* getNextButton() const { return nextbutton; }

  /// Button to search for last match w/o closing dialog
  FXButton* getLastButton() const { return lastbutton; }

  /// Set text or pattern to search for
  void setSearchText(const FXString& text);
  
  /// Return text or pattern the user has entered
  FXString getSearchText() const;
  
  /// Set search match mode
  void setSearchMode(FXSearchMode mode){ searchmode=(FXuchar)mode; }
  
  /// Return search mode the user has selected
  FXSearchMode getSearchMode() const { return (FXSearchMode)searchmode; }

  /// Set search direction flag
  void setSearchDir(FXbool back=FALSE){ backwards=back; }

  /// Get search direction flag
  FXbool getSearchDir() const { return backwards; }

  /// Save to stream
  virtual void save(FXStream& store) const;
  
  /// Load from stream
  virtual void load(FXStream& store);

  /// Destructor
  virtual ~FXSearchDialog();
  };


#endif
