File: findframe.h

package info (click to toggle)
poedit 3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,592 kB
  • sloc: cpp: 64,977; sh: 4,404; makefile: 241; xml: 46
file content (109 lines) | stat: -rw-r--r-- 3,734 bytes parent folder | download
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 *  This file is part of Poedit (https://poedit.net)
 *
 *  Copyright (C) 2001-2026 Vaclav Slavik
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a
 *  copy of this software and associated documentation files (the "Software"),
 *  to deal in the Software without restriction, including without limitation
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *  and/or sell copies of the Software, and to permit persons to whom the
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 *  DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef _FINDFRAME_H_
#define _FINDFRAME_H_

#include "edlistctrl.h"

#include <wx/frame.h>
#include <wx/weakref.h>

class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
class WXDLLIMPEXP_FWD_CORE wxChoice;
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;

class Catalog;
class EditingArea;
class PoeditFrame;

/** FindFrame is small dialog frame that contains controls for searching
    in content of EditorFrame's wxListCtrl object and associated Catalog
    instance.

    This class assumes that list control's user data contains index
    into the catalog.
 */
class FindFrame : public wxFrame
{
    public:
        /** Ctor.
            \param owner   Parent frame, FindFrame will float on it
            \param list    List control to search in
            \param catalog Catalog to search in
         */
        FindFrame(PoeditFrame *owner,
                  PoeditListCtrl *list, EditingArea *editingArea,
                  const CatalogPtr& c);
        ~FindFrame();

        /** Resets the search to starting position and changes
            the catalog in use. Called by EditorFrame when the user
            reloads catalog.
         */
        void Reset(const CatalogPtr& c);

        void FindPrev();
        void FindNext();

        void ShowForFind();
        void ShowForReplace();

        bool HasText() const { return !ms_text.empty(); }

    private:
        void UpdateButtons();
        void DoShowFor(int mode);
        void OnClose(wxCommandEvent &event);
        void OnModeChanged();
        void OnPrev(wxCommandEvent &event);
        void OnNext(wxCommandEvent &event);
        void OnTextChange(wxCommandEvent &event);
        void OnCheckbox(wxCommandEvent &event);
        void OnReplace(wxCommandEvent &event);
        void OnReplaceAll(wxCommandEvent &event);
        bool DoFind(int dir);
        bool DoReplaceInItem(CatalogItemPtr item);

        PoeditFrame *m_owner;
        wxChoice *m_mode;
        wxTextCtrl *m_searchField, *m_replaceField;
        wxCheckBox *m_ignoreCase, *m_wrapAround, *m_wholeWords,
                   *m_findInOrig, *m_findInTrans, *m_findInComments;

        wxWeakRef<PoeditListCtrl> m_listCtrl;
        wxWeakRef<EditingArea> m_editingArea;
        CatalogPtr m_catalog;
        int m_position;
        CatalogItemPtr m_lastItem;
        wxButton *m_btnClose, *m_btnReplaceAll, *m_btnReplace, *m_btnPrev, *m_btnNext;

        // NB: this is static so that last search term is remembered
        static wxString ms_text;
};


#endif // _FINDFRAME_H_