1/*
2 * Copyright (c) 1998-2007 Matthijs Hollemans
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5#ifndef GREP_WINDOW_H
6#define GREP_WINDOW_H
7
8#include <Catalog.h>
9#include <InterfaceKit.h>
10#include <FilePanel.h>
11#include <Locale.h>
12
13#include "Model.h"
14#include "GrepListView.h"
15
16class BMessageRunner;
17class ChangesIterator;
18class Grepper;
19
20class GrepWindow : public BWindow {
21public:
22								GrepWindow(BMessage* message);
23	virtual						~GrepWindow();
24
25	virtual	void				FrameResized(float width, float height);
26	virtual	void				FrameMoved(BPoint origin);
27	virtual	void				MenusBeginning();
28	virtual	void				MenusEnded();
29	virtual	void				MessageReceived(BMessage* message);
30	virtual	void				Quit();
31
32private:
33			void				_InitRefsReceived(entry_ref* directory,
34									BMessage* message);
35			void				_SetWindowTitle();
36			void				_CreateMenus();
37			void				_UpdateMenus();
38			void				_CreateViews();
39			void				_LayoutViews();
40			void				_TileIfMultipleWindows();
41
42			void				_LoadPrefs();
43			void				_SavePrefs();
44
45			void				_StartNodeMonitoring();
46			void				_StopNodeMonitoring();
47
48			void				_OnStartCancel();
49			void				_OnSearchFinished();
50			void				_OnNodeMonitorEvent(BMessage* message);
51			void				_OnNodeMonitorPulse();
52			void				_OnReportFileName(BMessage* message);
53			void				_OnReportResult(BMessage* message);
54			void				_OnReportError(BMessage* message);
55			void				_OnRecurseLinks();
56			void				_OnRecurseDirs();
57			void				_OnSkipDotDirs();
58			void				_OnRegularExpression();
59			void				_OnCaseSensitive();
60			void				_OnTextOnly();
61			void				_OnInvokeEditor();
62			void				_OnCheckboxShowLines();
63			void				_OnInvokeItem();
64			void				_OnSearchText();
65			void				_OnHistoryItem(BMessage* message);
66			void				_OnTrimSelection();
67			void				_OnCopyText();
68			void				_OnSelectInTracker();
69			void				_OnQuitNow();
70			void				_OnFileDrop(BMessage* message);
71			void				_OnRefsReceived(BMessage* message);
72			void				_OnOpenPanel();
73			void				_OnOpenPanelCancel();
74			void				_OnSelectAll(BMessage* message);
75			void				_OnNewWindow();
76			void				_OnSetTargetToParent();
77
78			void				_ModelChanged();
79			bool				_OpenInEditor(const entry_ref& ref, int32 lineNum);
80			void				_RemoveFolderListDuplicates(BList* folderList);
81			status_t			_OpenFoldersInTracker(BList* folderList);
82			bool				_AreAllFoldersOpenInTracker(BList* folderList);
83			status_t			_SelectFilesInTracker(BList* folderList,
84									BMessage* refsMessage);
85
86private:
87			BTextControl*		fSearchText;
88			GrepListView*		fSearchResults;
89
90			BMenuBar*			fMenuBar;
91			BMenu*				fFileMenu;
92			BMenuItem*			fNew;
93			BMenuItem*			fOpen;
94			BMenuItem*			fSetTargetToParent;
95			BMenuItem*			fClose;
96			BMenuItem*			fQuit;
97			BMenu*				fActionMenu;
98			BMenuItem*			fSelectAll;
99			BMenuItem*			fSearch;
100			BMenuItem*			fTrimSelection;
101			BMenuItem*			fCopyText;
102			BMenuItem*			fSelectInTracker;
103			BMenuItem*			fOpenSelection;
104			BMenu*				fPreferencesMenu;
105			BMenuItem*			fRecurseLinks;
106			BMenuItem*			fRecurseDirs;
107			BMenuItem*			fSkipDotDirs;
108			BMenuItem*			fCaseSensitive;
109			BMenuItem*			fRegularExpression;
110			BMenuItem*			fTextOnly;
111			BMenuItem*			fInvokeEditor;
112			BMenu*				fHistoryMenu;
113			BMenu*				fEncodingMenu;
114			BMenuItem*			fUTF8;
115			BMenuItem*			fShiftJIS;
116			BMenuItem*			fEUC;
117			BMenuItem*			fJIS;
118
119			BCheckBox*			fShowLinesCheckbox;
120			BButton*			fButton;
121
122			Grepper*			fGrepper;
123			BString				fOldPattern;
124			Model*				fModel;
125			bigtime_t			fLastNodeMonitorEvent;
126			ChangesIterator*	fChangesIterator;
127			BMessageRunner*		fChangesPulse;
128
129
130			BFilePanel*			fFilePanel;
131};
132
133#endif // GREP_WINDOW_H
134