~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to library/forms/dialogs/search_replace.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

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