1 /*
2  * Copyright 2003, 2004 Martin Fuchs
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 
20  //
21  // Explorer clone
22  //
23  // filechild.h
24  //
25  // Martin Fuchs, 23.07.2003
26  //
27 
28 
29  /// information structure for creation of FileChildWindow
30 struct FileChildWndInfo : public ChildWndInfo
31 {
32 	typedef ChildWndInfo super;
33 
34 	FileChildWndInfo(HWND hmdiclient, LPCTSTR path, ENTRY_TYPE etype=ET_UNKNOWN);
35 
36 	ENTRY_TYPE	_etype;
37 	LPCTSTR		_path;
38 
39 	WINDOWPLACEMENT _pos;
40 	int			_open_mode;	//OPEN_WINDOW_MODE
41 };
42 
43  /// information structure for creation of MDIShellBrowserChild
44 struct ShellChildWndInfo : public FileChildWndInfo
45 {
46 	typedef FileChildWndInfo super;
47 
48 	ShellChildWndInfo(HWND hmdiclient, LPCTSTR path, const ShellPath& root_shell_path);
49 
50 	ShellPath	_shell_path;
51 	ShellPath	_root_shell_path;
52 };
53 
54  /// information structure for creation of FileChildWindow for NT object namespace
55 struct NtObjChildWndInfo : public FileChildWndInfo
56 {
57 	typedef FileChildWndInfo super;
58 
59 	NtObjChildWndInfo(HWND hmdiclient, LPCTSTR path);
60 };
61 
62  /// information structure for creation of FileChildWindow for the Registry
63 struct RegistryChildWndInfo : public FileChildWndInfo
64 {
65 	typedef FileChildWndInfo super;
66 
67 	RegistryChildWndInfo(HWND hmdiclient, LPCTSTR path);
68 };
69 
70  /// information structure for creation of FileChildWindow
71 struct FATChildWndInfo : public FileChildWndInfo
72 {
73 	typedef FileChildWndInfo super;
74 
75 	FATChildWndInfo(HWND hmdiclient, LPCTSTR path);
76 };
77 
78  /// information structure for creation of WebChildWindow
79 struct WebChildWndInfo : public FileChildWndInfo
80 {
81 	typedef FileChildWndInfo super;
82 
83 	WebChildWndInfo(HWND hmdiclient, LPCTSTR url);
84 };
85 
86 
87  /// MDI child window displaying file lists
88 struct FileChildWindow : public ExtContextMenuHandlerT<ChildWindow>
89 {
90 	typedef ExtContextMenuHandlerT<ChildWindow> super;
91 
92 	FileChildWindow(HWND hwnd, const FileChildWndInfo& info);
93 
94 	static FileChildWindow* create(const FileChildWndInfo& info);
95 
96 protected:
97 	LRESULT	WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
98 	int		Command(int id, int code);
99 	int		Notify(int id, NMHDR* pnmh);
100 
101 	virtual void resize_children(int cx, int cy);
102 	virtual String jump_to_int(LPCTSTR url);
103 
104 	void	scan_entry(Entry* entry);
105 
106 	bool	expand_entry(Entry* dir);
107 	static void collapse_entry(Pane* pane, Entry* dir);
108 
109 	void	set_curdir(Entry* entry);
110 	void	activate_entry(Pane* pane);
111 
112 	void	refresh();
113 
114 protected:
115 	Root	_root;
116 	Pane*	_left;
117 	Pane*	_right;
118 	TCHAR	_path[MAX_PATH];
119 	bool	_header_wdths_ok;
120 
121 public:
122 	const Root& get_root() const {return _root;}
123 
124 	void	set_focus_pane(Pane* pane)
125 		{_focus_pane = pane==_right? 1: 0;}
126 
127 	void	switch_focus_pane()
128 		{SetFocus(_focus_pane? *_left: *_right);}
129 };
130 
131 
132  /// The "Execute..."-dialog lets the user enter a command line to launch.
133 struct ExecuteDialog {	///@todo use class Dialog
134 	TCHAR	cmd[MAX_PATH];
135 	int		cmdshow;
136 
137 	static INT_PTR CALLBACK WndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
138 };
139