1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2 
3 /* AbiWord
4  * Copyright (C) 1998 AbiSource, Inc.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301 USA.
20  */
21 
22 #ifndef AP_WIN32DIALOG_OPTIONS_H
23 #define AP_WIN32DIALOG_OPTIONS_H
24 
25 #include "ut_vector.h"
26 #include "ap_Dialog_Options.h"
27 #include "xap_Win32PropertySheet.h"
28 #include "xap_Frame.h"
29 #include "xap_Win32DialogBase.h"
30 
31 
32 class UT_String;
33 class AP_Win32Dialog_Options;
34 
35 enum PSH_PAGES {PG_GENERAL, PG_DOCUMENT, PG_SPELL, PG_SMARTQUOTES};
36 
37 /*
38 	Sheet
39 */
40 class ABI_EXPORT AP_Win32Dialog_Options_Sheet: public XAP_Win32PropertySheet
41 {
42 
43 public:
44 		AP_Win32Dialog_Options_Sheet();
45 		void _onInitDialog(HWND hwnd);
46 
setParent(AP_Win32Dialog_Options * pData)47 		void setParent(AP_Win32Dialog_Options*	pData){m_pParent=pData;};
getParent()48 		AP_Win32Dialog_Options* getParent(){return m_pParent;};
49 		BOOL _onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
50 		static INT_PTR CALLBACK s_sheetInit(HWND hwnd,  UINT uMsg,  LPARAM lParam);
51 
52 private:
53 
54 		AP_Win32Dialog_Options*	m_pParent;
55 
56 };
57 
58 
59 /*
60 	Spelling page
61 */
62 class ABI_EXPORT AP_Win32Dialog_Options_Spelling: public XAP_Win32PropertyPage
63 {
64 
65 public:
66 								AP_Win32Dialog_Options_Spelling();
67 								~AP_Win32Dialog_Options_Spelling();
68 
setContainer(AP_Win32Dialog_Options * pParent)69 	void						setContainer(AP_Win32Dialog_Options*	pParent){m_pParent=pParent;};
getContainer()70 	AP_Win32Dialog_Options*		getContainer(){return m_pParent;};
71 	void						transferData();
72 	static INT_PTR CALLBACK		s_pageWndProc(HWND hWnd, UINT msg, WPARAM wParam,   LPARAM lParam);
73 
74 private:
75 
76 	void						_onInitDialog();
_onKillActive()77 	void						_onKillActive(){};
78 
79 	AP_Win32Dialog_Options*		m_pParent;
80 
81 };
82 
83 
84 /*
85 	General page
86 */
87 class ABI_EXPORT AP_Win32Dialog_Options_General: public XAP_Win32PropertyPage
88 {
89 
90 public:
91 								AP_Win32Dialog_Options_General();
92 								~AP_Win32Dialog_Options_General();
93 
setContainer(AP_Win32Dialog_Options * pParent)94 	void						setContainer(AP_Win32Dialog_Options*	pParent){m_pParent=pParent;};
getContainer()95 	AP_Win32Dialog_Options*		getContainer(){return m_pParent;};
96 	void						transferData();
97 	static INT_PTR CALLBACK		s_pageWndProc(HWND hWnd, UINT msg, WPARAM wParam,   LPARAM lParam);
98 
99 private:
100 
101 	void						_onInitDialog();
_onKillActive()102 	void						_onKillActive(){};
103 	BOOL					_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
104 
105 	AP_Win32Dialog_Options*		m_pParent;
106 	int							m_nCentered;
107 	UT_Vector*					m_pVecUILangs;
108 
109 };
110 
111 /*
112 	Document page
113 */
114 class ABI_EXPORT AP_Win32Dialog_Options_Document: public XAP_Win32PropertyPage
115 {
116 
117 public:
118 								AP_Win32Dialog_Options_Document();
119 								~AP_Win32Dialog_Options_Document();
120 
setContainer(AP_Win32Dialog_Options * pParent)121 	void						setContainer(AP_Win32Dialog_Options*	pParent){m_pParent=pParent;};
getContainer()122 	AP_Win32Dialog_Options*		getContainer(){return m_pParent;};
123 	void						transferData();
124 	static INT_PTR CALLBACK		s_pageWndProc(HWND hWnd, UINT msg, WPARAM wParam,   LPARAM lParam);
125 	bool						isAutoSaveInRange();
126 
127 private:
128 
129 	void						_onInitDialog();
_onKillActive()130 	void						_onKillActive(){};
131 	BOOL					_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
132 
133 	AP_Win32Dialog_Options*		m_pParent;
134 
135 };
136 
137 /*
138 	Smart Quotes page
139 */
140 class ABI_EXPORT AP_Win32Dialog_Options_SmartQuotes: public XAP_Win32PropertyPage
141 {
142 
143 public:
144 								AP_Win32Dialog_Options_SmartQuotes();
145 								~AP_Win32Dialog_Options_SmartQuotes();
146 
setContainer(AP_Win32Dialog_Options * pParent)147 	void						setContainer(AP_Win32Dialog_Options* pParent){m_pParent=pParent;};
getContainer()148 	AP_Win32Dialog_Options*		getContainer(){return m_pParent;};
149 
150 private:
151 
152 	void						_onInitDialog();
_onKillActive()153 	void						_onKillActive(){};
154 	BOOL					_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
155 
156 	AP_Win32Dialog_Options*		m_pParent;
157 
158 };
159 
160 
161 /*****************************************************************/
162 class ABI_EXPORT AP_Win32Dialog_Options: public AP_Dialog_Options, public XAP_Win32DialogBase
163 {
164 public:
165 	AP_Win32Dialog_Options(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
166 	virtual ~AP_Win32Dialog_Options(void);
167 
168 	virtual void			runModal(XAP_Frame * pFrame);
169 
170 	static XAP_Dialog * 	static_constructor(XAP_DialogFactory *, XAP_Dialog_Id id);
171 
172 	HWND					getPage(PSH_PAGES page);
getDialogFactory()173 	XAP_DialogFactory * 	getDialogFactory() {return	m_pDialogFactory;};
getFrame()174 	XAP_Frame *				getFrame() {return	m_pFrame;};
175 	void					checkLanguageChange();
getBoldFontHandle()176 	HFONT					getBoldFontHandle () {return m_hFont;}
177 
178  protected:
179 
180 	AP_Win32Dialog_Options_General		m_general;
181 	AP_Win32Dialog_Options_Document		m_document;
182  	AP_Win32Dialog_Options_Spelling		m_spelling;
183  	AP_Win32Dialog_Options_SmartQuotes	m_smartquotes;
184 	UT_String							m_curLang;
185 	BOOL								m_langchanged;
186 	HFONT								m_hFont;
187 
188 	virtual void _controlEnable( tControl id, bool value );
189 	virtual void _initEnableControlsPlatformSpecific();
190 
191 	// we implement these so the XP dialog can set/grab our data
192 #define SET_GATHER(a,t) virtual t _gather##a(void);  \
193 						virtual void	_set##a(const t)
194 
195 	SET_GATHER			(SpellCheckAsType,	bool );
196 	SET_GATHER			(SpellHideErrors,	bool );
197 	SET_GATHER			(SpellSuggest,		bool );
198 	SET_GATHER			(SpellMainOnly, 	bool );
199 	SET_GATHER			(SpellUppercase,	bool );
200 	SET_GATHER			(SpellNumbers,		bool );
201 	SET_GATHER			(GrammarCheck,		bool);
202 	SET_GATHER			(ViewRulerUnits,	UT_Dimension);
203 	SET_GATHER			(AutoLoadPlugins, bool);
204 	SET_GATHER			(OtherDirectionRtl, bool );
205 	SET_GATHER			(AutoSaveFile, bool);
206  	SET_GATHER			(SmartQuotes,   		bool);
207  	SET_GATHER			(CustomSmartQuotes,		bool);
208 	SET_GATHER			(EnableOverwrite,		bool);
209 
_gatherViewShowToolbar(UT_uint32)210 	virtual bool _gatherViewShowToolbar(UT_uint32 /*t*/) { UT_ASSERT(UT_SHOULD_NOT_HAPPEN); return true;}
_setViewShowToolbar(UT_uint32,bool)211 	virtual void _setViewShowToolbar(UT_uint32 /*row*/, bool /*b*/) {}
212 
213 
214 	// unimplemented UI-wise. We need dummy implementations to satisfy the XP framework, though
215 
216 	SET_GATHER			(ViewCursorBlink,		bool);
217 	SET_GATHER			(PrefsAutoSave,			bool);
218 	SET_GATHER			(ViewShowRuler,			bool);
219 	SET_GATHER			(ViewShowStatusBar,		bool);
220 	SET_GATHER			(ViewAll,				bool);
221 	SET_GATHER			(ViewHiddenText,		bool);
222 	SET_GATHER			(ViewUnprintable,		bool);
223 	SET_GATHER			(EnableSmoothScrolling,	bool);
224 
225 	virtual void _gatherAutoSaveFilePeriod(UT_String &stRetVal);
226 	virtual void _setAutoSaveFilePeriod(const UT_String &stPeriod);
227 	virtual void _gatherAutoSaveFileExt(UT_String &stRetVal);
228 	virtual void _setAutoSaveFileExt(const UT_String &stExt);
229 	virtual void _gatherUILanguage(UT_String &stRetVal);
230 	virtual void _setUILanguage(const UT_String &stExt);
231 	virtual gint _gatherOuterQuoteStyle();
232 	virtual gint _gatherInnerQuoteStyle();
233 	virtual void _setOuterQuoteStyle(const gint index);
234 	virtual void _setInnerQuoteStyle(const gint index);
235 
236 	SET_GATHER			(NotebookPageNum,	int );
237 	SET_GATHER          (LanguageWithKeyboard, bool);
238 
239 	// Dummy
240 	bool			m_boolEnableSmoothScrolling;
241 	bool			m_boolPrefsAutoSave;
242 	bool			m_boolViewAll;
243 	bool			m_boolViewHiddenText;
244 	bool			m_boolViewShowRuler;
245 	bool			m_boolViewShowStatusBar;
246 	bool			m_boolViewUnprintable;
247 	bool			m_boolViewCursorBlink;
248 
249 #undef SET_GATHER
250 
251  protected:
252 	BOOL						_onNotify(HWND hWnd, LPARAM lParam);
253 	BOOL						_onCommandTab(HWND hWnd, WPARAM wParam, LPARAM lParam);
254 
255 	HWND						m_hwndTab;		// tab control in parent dialog
256 
257 	int 					        m_nrSubDlgs;		// number of tabs on tab control
258 	UT_Vector				m_vecSubDlgHWnd;	// hwnd to each sub-dialog
259 
260 private:
261 	XAP_DialogFactory * 		m_pDialogFactory;
262 };
263 
264 #endif /* AP_WIN32DIALOG_OPTIONS_H */
265