1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the
* License.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
/**
* This file contains a search-and-replace dialog with various options. The actual search/replace functionality
* is implemented by the owner.
*/
#ifndef _SEARCH_REPLACE_H_
#define _SEARCH_REPLACE_H_
#include "cairo/cairo.h"
#include "mforms/form.h"
#include "mforms/table.h"
#include "mforms/box.h"
#include "mforms/checkbox.h"
#include "mforms/selector.h"
#include "mforms/label.h"
namespace mforms {
// Determines which search options to show and, on return, which option was active.
enum SearchFlags
{
SearchNone = 0,
SearchMatchCase = 1 << 0,
SearchMatchWholeWord = 1 << 1,
SearchUseRegularExpression = 1 << 2,
SearchDoReplace = 1 << 3,
SearchAll = 1 << 4, // If set the target should replace all occurences (makes no sense for search alone).
SearchPrevious = 1 << 5, // If set the target should search backwards instead forwards.
};
typedef boost::function<bool (const std::string, const std::string, SearchFlags)> SearchCallback;
class MFORMS_EXPORT SearchReplace : public Form
{
public:
SearchReplace();
void show(bool modal, SearchFlags flags, bool replace);
void set_callback(SearchCallback new_callback);
protected:
void layout();
void cancel_pressed();
void button_pressed(Button* button);
private:
Box _top_box;
Table _top_table;
Table _table;
Label _find_label;
Label _replace_label;
Selector _find_selector;
Selector _replace_selector;
CheckBox _ignore_case_checkbox;
CheckBox _match_whole_word_checkbox;
CheckBox _use_regex_checkbox;
Box _button_box;
Button _replace_all_button;
Button _replace_button;
Button _find_previous_button;
Button _find_next_button;
Button _cancel_button;
SearchCallback _on_action;
};
}
#endif // _SEARCH_REPLACE_H_
|