1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2 
3 /* AbiWord
4  * Copyright (C) 1998 AbiSource, Inc.
5  *			 (c) 2002-2006 Jordi Mas i Hern�ndez jmas@softcatala.org
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301 USA.
21  */
22 
23 #include <windows.h>
24 #include <commctrl.h>
25 #include <stdio.h>
26 
27 #include "ut_misc.h"
28 #include "ut_types.h"
29 #include "ut_string.h"
30 #include "ut_string_class.h"
31 #include "ut_assert.h"
32 #include "ut_debugmsg.h"
33 #include "ut_Win32OS.h"
34 #include "ut_Win32LocaleString.h"
35 
36 #include "gr_Win32Graphics.h"
37 
38 #include "xap_App.h"
39 #include "xap_Win32App.h"
40 #include "xap_Win32FrameImpl.h"
41 #include "xap_Prefs.h"
42 #include "xap_EncodingManager.h"
43 
44 #include "ap_Dialog_Id.h"
45 #include "ap_Prefs_SchemeIds.h"
46 #include "xap_Toolbar_Layouts.h"
47 #include "ap_Strings.h"
48 #include "ap_Win32App.h"
49 #include "ap_Win32Resources.rc2"
50 #include "ap_Win32Dialog_Options.h"
51 #include "ap_Win32Dialog_Background.h"
52 #include "xap_Win32DialogHelper.h"
53 #include "ut_Language.h"
54 
55 
56 
57 /*****************************************************************/
58 
59 #define GWL(hwnd)		(AP_Win32Dialog_Options*)GetWindowLongPtrW((hwnd), DWLP_USER)
60 #define SWL(hwnd, d)	(AP_Win32Dialog_Options*)SetWindowLongPtrW((hwnd), DWLP_USER,(LONG_PTR)(d))
61 #define MINAUTOSAVEPERIOD	1
62 #define MAXAUTOSAVEPERIOD	120
63 
64 /*****************************************************************/
65 
static_constructor(XAP_DialogFactory * pFactory,XAP_Dialog_Id id)66 XAP_Dialog * AP_Win32Dialog_Options::static_constructor(XAP_DialogFactory * pFactory,
67 														XAP_Dialog_Id id)
68 {
69 	AP_Win32Dialog_Options * p = new AP_Win32Dialog_Options(pFactory,id);
70 	return p;
71 }
72 
AP_Win32Dialog_Options(XAP_DialogFactory * pDlgFactory,XAP_Dialog_Id id)73 AP_Win32Dialog_Options::AP_Win32Dialog_Options(XAP_DialogFactory * pDlgFactory,
74 											   XAP_Dialog_Id id)
75 	: AP_Dialog_Options(pDlgFactory,id),m_pDialogFactory(pDlgFactory)
76 {
77 	m_langchanged = FALSE;
78 	LOGFONTW	logFont;
79 
80 	// Create bold font
81 	HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
82 	GetObjectW (hFont, sizeof(LOGFONTW), &logFont);
83 
84 	logFont.lfWeight  = FW_BOLD;
85 	m_hFont = CreateFontIndirectW(&logFont);
86 }
87 
~AP_Win32Dialog_Options(void)88 AP_Win32Dialog_Options::~AP_Win32Dialog_Options(void)
89 {
90 	 DeleteObject (m_hFont);
91 }
92 
93 
94 //////////////////////////////////////////////////////////////////
95 //////////////////////////////////////////////////////////////////
96 
checkLanguageChange()97 void AP_Win32Dialog_Options::checkLanguageChange()
98 {
99 	UT_String sLang;
100 
101 	_gatherUILanguage(sLang);
102 
103 	if (m_curLang!=sLang)
104 		m_langchanged = TRUE;
105 
106 }
107 
_initEnableControlsPlatformSpecific()108 void AP_Win32Dialog_Options::_initEnableControlsPlatformSpecific()
109 {
110 	_controlEnable( id_CHECK_LANG_WITH_KEYBOARD, true);
111 	_controlEnable( id_CHECK_DIR_MARKER_AFTER_CLOSING_PARENTHESIS,_gatherLanguageWithKeyboard());
112 }
113 
114 
runModal(XAP_Frame * pFrame)115 void AP_Win32Dialog_Options::runModal(XAP_Frame * pFrame)
116 {
117 	XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(m_pApp);
118 	AP_Win32Dialog_Options_Sheet	sheet;
119 
120 	UT_return_if_fail (pFrame);
121 	m_pFrame = pFrame;
122 
123 	/* Create the property sheet and associate its pages*/
124 
125 	m_general.setContainer(this);
126 	m_general.createPage(pWin32App, AP_RID_DIALOG_OPT_GENERAL, AP_STRING_ID_DLG_Options_Label_General);
127 	sheet.addPage(&m_general);
128 
129 	m_document.setContainer(this);
130 	m_document.createPage(pWin32App, AP_RID_DIALOG_OPT_DOCUMENTS, AP_STRING_ID_DLG_Options_Label_Documents);
131 	sheet.addPage(&m_document);
132 
133 	m_spelling.setContainer(this);
134 	m_spelling.createPage(pWin32App, AP_RID_DIALOG_OPT_SPELL, AP_STRING_ID_DLG_Options_TabLabel_Spelling);
135 	sheet.addPage(&m_spelling);
136 
137 	m_smartquotes.setContainer(this);
138 	m_smartquotes.createPage(pWin32App, AP_RID_DIALOG_OPT_SMARTQUOTES, AP_STRING_ID_DLG_Options_TabLabel_SmartQuotes);
139 	sheet.addPage(&m_smartquotes);
140 
141 	sheet.setApplyButton(true);
142 	sheet.setParent(this);
143 	if (sheet.runModal(pWin32App, pFrame, AP_STRING_ID_DLG_Options_OptionsTitle)==IDOK)
144 		m_answer = a_OK;
145 	else
146 		m_answer = a_CANCEL;
147 
148 	if (m_langchanged)
149 	{
150 		const XAP_StringSet * pSS = getApp()->getStringSet();
151 		UT_Win32LocaleString str;
152 
153 		str.fromUTF8 (pSS->getValue(AP_STRING_ID_DLG_Options_Prompt_YouMustRestart));
154 		::MessageBoxW(NULL, str.c_str(), L"Abiword",MB_OK);
155 	}
156 
157 }
158 
159 static struct {
160 	UT_Dimension  dim;
161 	int 		  id;
162 } s_aAlignUnit[] =
163 {
164 	{ DIM_IN, XAP_STRING_ID_DLG_Unit_inch },
165 	{ DIM_CM, XAP_STRING_ID_DLG_Unit_cm },
166 	{ DIM_PT, XAP_STRING_ID_DLG_Unit_points },
167 	{ DIM_PI, XAP_STRING_ID_DLG_Unit_pica },
168 };
169 #define SIZE_aAlignUnit  (sizeof(s_aAlignUnit)/sizeof(s_aAlignUnit[0]))
170 #define _CDB(c,i)	checkDlgButton(AP_RID_DIALOG_##c,_getCheckItemValue(i))
171 #define _DS2(c,s)	setDlgItemText(AP_RID_DIALOG_##c,pSS->getValue(AP_STRING_ID_##s))
172 #define _DSX2(c,s)	setDlgItemText(AP_RID_DIALOG_##c,pSS->getValue(XAP_STRING_ID_##s))
173 
174 /*
175 	Gets the property page by its index
176 */
getPage(PSH_PAGES page)177 HWND	AP_Win32Dialog_Options::getPage(PSH_PAGES page)
178 {
179 	HWND hWnd = NULL;
180 
181 	switch (page)
182 	{
183 		case PG_SPELL:
184 			hWnd = m_spelling.getHandle();
185 			break;
186 
187 		case PG_GENERAL:
188 			hWnd = m_general.getHandle();
189 			break;
190 
191 		case PG_DOCUMENT:
192 			hWnd = m_document.getHandle();
193 			break;
194 
195 		case PG_SMARTQUOTES:
196 			hWnd = m_smartquotes.getHandle();
197 			break;
198 
199 		default:
200 			break;
201 	}
202 
203 	UT_ASSERT_HARMLESS(hWnd!=NULL);
204 	return hWnd;
205 }
206 
207 
208 /*
209 
210 */
_controlEnable(tControl id,bool value)211 void AP_Win32Dialog_Options::_controlEnable( tControl id, bool value )
212 {
213 	// This routine is called by XP code to enable/disable a particular field.
214 
215 	switch (id)
216 	{
217 		case id_CHECK_ENABLE_OVERWRITE:
218 			EnableWindow(GetDlgItem((HWND)getPage(PG_GENERAL),AP_RID_DIALOG_OPTIONS_CHK_EnableOverwrite),value);
219 			return;
220 
221 		case id_CHECK_LANG_WITH_KEYBOARD:
222 			EnableWindow(GetDlgItem((HWND)getPage(PG_GENERAL),AP_RID_DIALOG_OPTIONS_CHK_LanguageWithKeyboard),value);
223 			return;
224 
225 		case id_CHECK_AUTO_LOAD_PLUGINS:
226 			EnableWindow(GetDlgItem((HWND)getPage(PG_GENERAL),AP_RID_DIALOG_OPTIONS_CHK_AutoLoadPlugins),value);
227 			return;
228 
229 		case id_CHECK_AUTO_SAVE_FILE:
230 			EnableWindow(GetDlgItem((HWND)getPage(PG_DOCUMENT),AP_RID_DIALOG_OPTIONS_CHK_AutoSaveFile),value);
231 			return;
232 
233 		case id_CHECK_OTHER_DEFAULT_DIRECTION_RTL:
234 			EnableWindow(GetDlgItem((HWND)getPage(PG_DOCUMENT),AP_RID_DIALOG_OPTIONS_CHK_OtherDirectionRtl),value);
235 			return;
236 
237 		case id_CHECK_SPELL_CHECK_AS_TYPE:
238 			EnableWindow(GetDlgItem((HWND)getPage(PG_SPELL),AP_RID_DIALOG_OPTIONS_CHK_SpellCheckAsType),value);
239 			return;
240 
241 		case id_CHECK_SPELL_HIDE_ERRORS:
242 			EnableWindow(GetDlgItem((HWND)getPage(PG_SPELL),AP_RID_DIALOG_OPTIONS_CHK_SpellHideErrors),value);
243 			return;
244 
245 		case id_CHECK_SPELL_SUGGEST:
246 			EnableWindow(GetDlgItem((HWND)getPage(PG_SPELL),AP_RID_DIALOG_OPTIONS_CHK_SpellSuggest),value);
247 			return;
248 
249 		case id_CHECK_SPELL_MAIN_ONLY:
250 			EnableWindow(GetDlgItem((HWND)getPage(PG_SPELL),AP_RID_DIALOG_OPTIONS_CHK_SpellMainOnly),value);
251 			return;
252 
253 		case id_CHECK_SPELL_UPPERCASE:
254 			EnableWindow(GetDlgItem((HWND)getPage(PG_SPELL),AP_RID_DIALOG_OPTIONS_CHK_SpellUppercase),value);
255 			return;
256 
257 		case id_CHECK_SPELL_NUMBERS:
258 			EnableWindow(GetDlgItem((HWND)getPage(PG_SPELL),AP_RID_DIALOG_OPTIONS_CHK_SpellNumbers),value);
259 			return;
260 
261 		case id_CHECK_GRAMMAR_CHECK:
262 			EnableWindow(GetDlgItem((HWND)getPage(PG_SPELL),AP_RID_DIALOG_OPTIONS_CHK_GrammarCheck),value);
263 			return;
264 
265 		case id_CHECK_SMART_QUOTES_ENABLE:
266 			EnableWindow(GetDlgItem((HWND)getPage(PG_SMARTQUOTES),AP_RID_DIALOG_OPTIONS_CHK_CustomSmartQuotes),value);
267 			return;
268 
269 		case id_CHECK_CUSTOM_SMART_QUOTES:
270 			EnableWindow(GetDlgItem((HWND)getPage(PG_SMARTQUOTES),AP_RID_DIALOG_OPTIONS_COMBO_OUTERQUOTE),value);
271 			EnableWindow(GetDlgItem((HWND)getPage(PG_SMARTQUOTES),AP_RID_DIALOG_OPTIONS_COMBO_INNERQUOTE),value);
272 			return;
273 
274 		default:
275 			//UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
276 			return;
277 	}
278 }
279 
280 //////////////////////////////////////////////////////////////////
281 //////////////////////////////////////////////////////////////////
282 // The following defines a specific, named "Get" and "Set" method
283 // for each CHECK box on all of the sub-dialogs.  These are called
284 // by XP code to set a particular value in the dialog presentation;
285 // they do not call back into XP code.
286 
287 
288 #define DEFINE_GET_SET_BOOL(index,button) \
289 bool AP_Win32Dialog_Options::_gather##button(void) { \
290 	return (IsDlgButtonChecked((HWND)getPage(index),AP_RID_DIALOG_OPTIONS_CHK_##button) == BST_CHECKED); \
291 } \
292 void AP_Win32Dialog_Options::_set##button(const bool b) { \
293 	CheckDlgButton((HWND)getPage(index),AP_RID_DIALOG_OPTIONS_CHK_##button,b); \
294 }
295 
296 // dummy implementations
297 #define DEFINE_GET_SET_BOOL_DUMMY(Bool)						\
298 bool	AP_Win32Dialog_Options::_gather##Bool(void) { 		\
299 		return m_bool##Bool;								\
300 } 															\
301 void	AP_Win32Dialog_Options::_set##Bool(bool b) { 		\
302 	m_bool##Bool = b;										\
303 }
304 
DEFINE_GET_SET_BOOL(PG_GENERAL,EnableOverwrite)305 DEFINE_GET_SET_BOOL(PG_GENERAL,EnableOverwrite)
306 DEFINE_GET_SET_BOOL(PG_GENERAL,LanguageWithKeyboard)
307 DEFINE_GET_SET_BOOL(PG_GENERAL,AutoLoadPlugins)
308 
309 DEFINE_GET_SET_BOOL(PG_DOCUMENT,OtherDirectionRtl)
310 
311 DEFINE_GET_SET_BOOL(PG_SPELL,SpellCheckAsType)
312 DEFINE_GET_SET_BOOL(PG_SPELL,SpellHideErrors)
313 DEFINE_GET_SET_BOOL(PG_SPELL,SpellSuggest)
314 DEFINE_GET_SET_BOOL(PG_SPELL,SpellMainOnly)
315 DEFINE_GET_SET_BOOL(PG_SPELL,SpellUppercase)
316 DEFINE_GET_SET_BOOL(PG_SPELL,SpellNumbers)
317 DEFINE_GET_SET_BOOL(PG_SPELL,GrammarCheck)
318 
319 DEFINE_GET_SET_BOOL(PG_SMARTQUOTES,SmartQuotes)
320 DEFINE_GET_SET_BOOL(PG_SMARTQUOTES,CustomSmartQuotes)
321 
322 /* Not used */
323 DEFINE_GET_SET_BOOL_DUMMY (ViewCursorBlink)
324 DEFINE_GET_SET_BOOL_DUMMY (EnableSmoothScrolling)
325 DEFINE_GET_SET_BOOL_DUMMY (PrefsAutoSave)
326 DEFINE_GET_SET_BOOL_DUMMY (ViewAll)
327 DEFINE_GET_SET_BOOL_DUMMY (ViewHiddenText)
328 DEFINE_GET_SET_BOOL_DUMMY (ViewShowRuler)
329 DEFINE_GET_SET_BOOL_DUMMY (ViewShowStatusBar)
330 DEFINE_GET_SET_BOOL_DUMMY (ViewUnprintable)
331 
332 #undef DEFINE_GET_SET_BOOL
333 
334 
335 bool AP_Win32Dialog_Options::_gatherAutoSaveFile(void)
336 {
337 	return (IsDlgButtonChecked((HWND)getPage(PG_DOCUMENT),AP_RID_DIALOG_OPTIONS_CHK_AutoSaveFile) == BST_CHECKED);
338 }
339 
_setAutoSaveFile(const bool b)340 void AP_Win32Dialog_Options::_setAutoSaveFile(const bool b)
341 {
342 	BOOL bChecked;
343 	HWND hWnd = (HWND)getPage(PG_DOCUMENT);
344 
345 	CheckDlgButton( hWnd, AP_RID_DIALOG_OPTIONS_CHK_AutoSaveFile, b );
346 
347 	// Disable the input boxes if auto save is turned off
348 	bChecked = (IsDlgButtonChecked( hWnd, AP_RID_DIALOG_OPTIONS_CHK_AutoSaveFile ) == BST_CHECKED);
349 	EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod), bChecked );
350 	EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_SPN_AutoSavePeriodSpin), bChecked );
351 	EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_TXT_AutoSaveExtension), bChecked );
352 }
353 
_gatherAutoSaveFileExt(UT_String & stRetVal)354 void AP_Win32Dialog_Options::_gatherAutoSaveFileExt(UT_String &stRetVal)
355 {
356 	UT_Win32LocaleString str;
357 	XAP_Win32DialogBase::getDlgItemText(getPage(PG_DOCUMENT), AP_RID_DIALOG_OPTIONS_TXT_AutoSaveExtension, str);
358 	stRetVal = str.utf8_str().utf8_str();
359 }
360 
_setAutoSaveFileExt(const UT_String & stExt)361 void AP_Win32Dialog_Options::_setAutoSaveFileExt(const UT_String &stExt)
362 {
363 	XAP_Win32DialogBase::setDlgItemText(getPage(PG_DOCUMENT), AP_RID_DIALOG_OPTIONS_TXT_AutoSaveExtension, stExt.c_str());
364 }
365 
_gatherAutoSaveFilePeriod(UT_String & stRetVal)366 void AP_Win32Dialog_Options::_gatherAutoSaveFilePeriod(UT_String &stRetVal)
367 {
368 	int iValue = GetDlgItemInt((HWND)getPage(PG_DOCUMENT), AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod, NULL, FALSE );
369 	char szTemp[10];
370 
371 	snprintf( szTemp, 10, "%d", iValue );
372 
373 	stRetVal = szTemp;
374 }
375 
_setAutoSaveFilePeriod(const UT_String & stPeriod)376 void AP_Win32Dialog_Options::_setAutoSaveFilePeriod(const UT_String &stPeriod)
377 {
378 	SetDlgItemInt((HWND)getPage(PG_DOCUMENT), AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod, atoi(stPeriod.c_str()), FALSE );
379 }
380 
_gatherViewRulerUnits(void)381 UT_Dimension AP_Win32Dialog_Options::_gatherViewRulerUnits(void)
382 {
383 	HWND hwndAlign = GetDlgItem((HWND)getPage(PG_GENERAL), AP_RID_DIALOG_OPTIONS_COMBO_UNITS);
384 	int nSel = SendMessageW(hwndAlign, CB_GETCURSEL, 0, 0);
385 
386 	if( nSel != CB_ERR )
387 		return s_aAlignUnit[nSel].dim;
388 	return DIM_IN;
389 }
390 
_setViewRulerUnits(UT_Dimension dim)391 void  AP_Win32Dialog_Options::_setViewRulerUnits(UT_Dimension dim)
392 {
393 	unsigned int n1;
394 	for( n1 = 0; n1 < SIZE_aAlignUnit; n1++ )
395 		if( s_aAlignUnit[n1].dim == dim )
396 			break;
397 	if( n1 == SIZE_aAlignUnit )
398 		n1 = 0;
399 
400 	HWND hwndAlign = GetDlgItem((HWND)getPage(PG_GENERAL), AP_RID_DIALOG_OPTIONS_COMBO_UNITS);
401 	SendMessageW(hwndAlign, CB_SETCURSEL, (WPARAM)n1, 0);
402 }
403 
_gatherNotebookPageNum(void)404 int AP_Win32Dialog_Options::_gatherNotebookPageNum(void)
405 {
406 	return 0;
407 }
408 
_setNotebookPageNum(const int)409 void AP_Win32Dialog_Options::_setNotebookPageNum(const int /*pn*/)
410 {
411 
412 }
413 
_gatherUILanguage(UT_String & stRetVal)414 void AP_Win32Dialog_Options::_gatherUILanguage(UT_String &stRetVal)
415 {
416 	HWND hCtrlDocLang = GetDlgItem((HWND)getPage(PG_GENERAL), AP_RID_DIALOG_OPTIONS_COMBO_UILANG);
417 	UT_Language	lang;
418 	const char* pLang;
419 	int nIndex = SendMessageW(hCtrlDocLang,  CB_GETCURSEL , 0,0);
420 
421 	if (nIndex!=CB_ERR)
422 	{
423 		int nID = SendMessageW(hCtrlDocLang,  CB_GETITEMDATA , nIndex,0);
424 		pLang =  (const char*)lang.getNthLangCode(nID);
425 		stRetVal = pLang;
426 	}
427 	else
428 		stRetVal = m_curLang;
429 }
430 
_setUILanguage(const UT_String & stExt)431 void AP_Win32Dialog_Options::_setUILanguage(const UT_String &stExt)
432 {
433 	UT_Language	lang;
434 	int id = lang.getIndxFromCode(stExt.c_str());
435 	bool bCustom = true;
436 	HWND hCtrlDocLang = GetDlgItem((HWND)getPage(PG_GENERAL), AP_RID_DIALOG_OPTIONS_COMBO_UILANG);
437 
438 	int nCount = SendMessageW(hCtrlDocLang, CB_GETCOUNT, 0, 0);
439 
440 	for (int i=0; i<nCount;i++)
441 	{
442 		if (SendMessageW(hCtrlDocLang,  CB_GETITEMDATA , i,0)==id)
443 		{
444 			SendMessageW(hCtrlDocLang, CB_SETCURSEL, i, 0);
445 			bCustom = false;
446 			break;
447 		}
448 	}
449 
450 	if (!bCustom && (nCount < 2))
451 		EnableWindow(hCtrlDocLang,FALSE);
452 
453 	if (!m_curLang.size())
454 		m_curLang = stExt;
455 }
456 
_setOuterQuoteStyle(const gint index)457 void AP_Win32Dialog_Options::_setOuterQuoteStyle(const gint index)
458 {
459 	HWND hCombo = GetDlgItem((HWND)getPage(PG_SMARTQUOTES), AP_RID_DIALOG_OPTIONS_COMBO_OUTERQUOTE);
460 	UT_return_if_fail(hCombo);
461 
462 	int nCount = SendMessageW(hCombo, CB_GETCOUNT, 0, 0);
463 	UT_return_if_fail(index >= 0 && index < nCount);
464 
465 	SendMessageW(hCombo, CB_SETCURSEL, index, 0);
466 }
467 
_setInnerQuoteStyle(const gint index)468 void AP_Win32Dialog_Options::_setInnerQuoteStyle(const gint index)
469 {
470 	HWND hCombo = GetDlgItem((HWND)getPage(PG_SMARTQUOTES), AP_RID_DIALOG_OPTIONS_COMBO_INNERQUOTE);
471 	UT_return_if_fail(hCombo);
472 
473 	int nCount = SendMessageW(hCombo, CB_GETCOUNT, 0, 0);
474 	UT_return_if_fail(index >= 0 && index < nCount);
475 
476 	SendMessageW(hCombo, CB_SETCURSEL, index, 0);
477 }
478 
_gatherOuterQuoteStyle()479 gint AP_Win32Dialog_Options::_gatherOuterQuoteStyle()
480 {
481 	HWND hCombo = GetDlgItem((HWND)getPage(PG_SMARTQUOTES), AP_RID_DIALOG_OPTIONS_COMBO_OUTERQUOTE);
482 	UT_return_val_if_fail(hCombo,0);
483 	int nIndex = SendMessageW(hCombo, CB_GETCURSEL, 0, 0);
484 	UT_return_val_if_fail(nIndex != CB_ERR, 0);
485 
486 	return nIndex;
487 }
488 
_gatherInnerQuoteStyle()489 gint AP_Win32Dialog_Options::_gatherInnerQuoteStyle()
490 {
491 	HWND hCombo = GetDlgItem((HWND)getPage(PG_SMARTQUOTES), AP_RID_DIALOG_OPTIONS_COMBO_INNERQUOTE);
492 	UT_return_val_if_fail(hCombo,0);
493 	int nIndex = SendMessageW(hCombo, CB_GETCURSEL, 0, 0);
494 	UT_return_val_if_fail(nIndex != CB_ERR, 0);
495 
496 	return nIndex;
497 }
498 
499 
500 /*
501 
502 	Sheet
503 
504 */
AP_Win32Dialog_Options_Sheet()505 AP_Win32Dialog_Options_Sheet::AP_Win32Dialog_Options_Sheet() :
506 XAP_Win32PropertySheet()
507 {
508 	m_pParent = NULL;
509 	setCallBack((PFNPROPSHEETCALLBACK)s_sheetInit);
510 }
511 
512 
513 
514 /*
515 	Sheet window procedure
516 */
_onCommand(HWND hWnd,WPARAM wParam,LPARAM)517 BOOL AP_Win32Dialog_Options_Sheet::_onCommand(HWND hWnd, WPARAM wParam, LPARAM /*lParam*/)
518 {
519 	WORD wID = LOWORD(wParam);
520 
521 	if (wID==IDOK)
522 	{
523 		AP_Win32Dialog_Options_Sheet * t = (AP_Win32Dialog_Options_Sheet *) GetWindowLongPtrW(hWnd, GWLP_USERDATA);
524 		HWND hWndPref = t->getParent()->getPage(PG_DOCUMENT);
525 		AP_Win32Dialog_Options_Document * prefPag = (AP_Win32Dialog_Options_Document *) GetWindowLongPtrW(hWndPref, GWLP_USERDATA);
526 
527 		if (!prefPag->isAutoSaveInRange()) return 0;
528 
529 		t->getParent()->_storeWindowData(); 					// remember current settings
530 		t->getParent()->checkLanguageChange();
531 
532 	}
533 
534 	if (wID==ID_APPLY_NOW)	// Save default button
535 	{
536 		AP_Win32Dialog_Options_Sheet * t = (AP_Win32Dialog_Options_Sheet *) GetWindowLongPtrW(hWnd, GWLP_USERDATA);
537 		t->getParent()->_event_SetDefaults();
538 		return 0;
539 	}
540 
541 	return 1;	// The application did not process the message
542 }
543 
s_sheetInit(HWND hwnd,UINT uMsg,LPARAM)544 INT_PTR CALLBACK AP_Win32Dialog_Options_Sheet::s_sheetInit(HWND hwnd,  UINT uMsg,  LPARAM /*lParam*/)
545 {
546 	if (uMsg==PSCB_INITIALIZED)
547 	{
548 		/* Force the creation of all pages*/
549 		PropSheet_SetCurSel(hwnd, 0,0);
550 		PropSheet_SetCurSel(hwnd, 0,1);
551 		PropSheet_SetCurSel(hwnd, 0,2);
552 		PropSheet_SetCurSel(hwnd, 0,3);
553 	}
554 	return 	0;
555 }
556 
557 
558 /*
559 
560 */
_onInitDialog(HWND hwnd)561 void AP_Win32Dialog_Options_Sheet::_onInitDialog(HWND hwnd)
562 {
563 
564 	// let XP code tell us what all of the values should be.
565 	getParent()->_populateWindowData();
566 
567 	// Apply button -> save
568 	const XAP_StringSet * pSS = getParent()->getApp()->getStringSet();
569 	EnableWindow(GetDlgItem(hwnd, ID_APPLY_NOW), TRUE);
570 	XAP_Win32DialogBase::setWindowText(GetDlgItem(hwnd, ID_APPLY_NOW), pSS->getValue(AP_STRING_ID_DLG_Options_Btn_Default));
571 	XAP_Win32DialogBase::setWindowText(GetDlgItem(hwnd, IDOK), pSS->getValue(XAP_STRING_ID_DLG_OK));
572 	XAP_Win32DialogBase::setWindowText(GetDlgItem(hwnd, IDCANCEL), pSS->getValue(XAP_STRING_ID_DLG_Cancel));
573 
574 	AP_Win32Dialog_Options*	 pParent=  (AP_Win32Dialog_Options*)getParent();
575 	int nDefPage = pParent->getInitialPageNum();
576 	PropSheet_SetCurSel(hwnd, 0, nDefPage);
577 
578 }
579 
580 
581 
582 /*
583 
584 	Spelling page
585 
586 */
AP_Win32Dialog_Options_Spelling()587 AP_Win32Dialog_Options_Spelling::AP_Win32Dialog_Options_Spelling()
588 {
589 
590 }
591 
~AP_Win32Dialog_Options_Spelling()592 AP_Win32Dialog_Options_Spelling::~AP_Win32Dialog_Options_Spelling()
593 {
594 
595 }
596 
597 //void AP_Win32Dialog_Options_Spelling::_onCommand(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
598 //{
599 
600 //}
601 
602 /*
603 
604 */
_onInitDialog()605 void AP_Win32Dialog_Options_Spelling::_onInitDialog()
606 {
607 	const XAP_StringSet * pSS = getApp()->getStringSet();
608 	int i;
609 
610 	// localize controls
611 	_DS2(OPTIONS_FRM_SpellGeneral,			DLG_Options_Label_General);
612 	_DS2(OPTIONS_CHK_SpellCheckAsType,		DLG_Options_Label_SpellCheckAsType);
613 	_DS2(OPTIONS_CHK_SpellHideErrors,		DLG_Options_Label_SpellHideErrors);
614 	_DS2(OPTIONS_CHK_SpellSuggest,			DLG_Options_Label_SpellSuggest);
615 	_DS2(OPTIONS_CHK_SpellMainOnly,			DLG_Options_Label_SpellMainOnly);
616 	_DS2(OPTIONS_FRM_SpellIgnore,			DLG_Options_Label_Ignore);
617 	_DS2(OPTIONS_CHK_SpellUppercase, 		DLG_Options_Label_SpellUppercase);
618 	_DS2(OPTIONS_CHK_SpellNumbers,			DLG_Options_Label_SpellNumbers);
619 	_DS2(OPTIONS_LBL_CUSTOMDICT, 			DLG_Options_Label_SpellCustomDict);
620 	_DS2(OPTIONS_BTN_CUSTOMDICT, 			DLG_Options_Btn_CustomDict);
621 	_DS2(OPTIONS_LBL_IGNOREDWORD,			DLG_Options_Label_SpellIgnoredWord);
622 	_DS2(OPTIONS_BTN_IGNOREDRESET,			DLG_Options_Btn_IgnoreReset);
623 	_DS2(OPTIONS_BTN_IGNOREDEDIT,			DLG_Options_Btn_IgnoreEdit);
624 	_DS2(OPTIONS_CHK_GrammarCheck,			DLG_Options_Label_GrammarCheck);
625 
626 	_DS2(OPTIONS_STATIC_General,			DLG_Options_Label_General);
627 	_DS2(OPTIONS_STATIC_SpellIgnoreWords,	DLG_Options_Label_SpellIgnoreWords);
628 	_DS2(OPTIONS_STATIC_SpellDictionaries,	DLG_Options_Label_SpellDictionaries);
629 	_DS2(OPTIONS_STATIC_Grammar,			DLG_Options_Label_Grammar);
630 	_DS2(OPTIONS_CHK_HighLight,				DLG_Options_Label_SpellHighlightMisspelledWords);
631 
632 	// Setup bold font for some controls
633 	UINT boldFields[]={AP_RID_DIALOG_OPTIONS_STATIC_General, AP_RID_DIALOG_OPTIONS_STATIC_SpellIgnoreWords,
634 			AP_RID_DIALOG_OPTIONS_STATIC_SpellDictionaries, AP_RID_DIALOG_OPTIONS_STATIC_Grammar, 0};
635 
636 	for(i=0; boldFields[i]; i++)
637 	{
638 		SendMessageW(GetDlgItem(getHandle(), boldFields[i]), WM_SETFONT,
639 			(WPARAM)(AP_Win32Dialog_Options*)getContainer()->getBoldFontHandle(), MAKELPARAM(FALSE /* Redraw */, 0));
640 	}
641 
642 }
643 
644 
645 
646 /*
647 
648 	General page
649 
650 */
651 
AP_Win32Dialog_Options_General()652 AP_Win32Dialog_Options_General::AP_Win32Dialog_Options_General()
653 {
654 	setDialogProc(s_pageWndProc);
655 	m_nCentered = 0;
656 	m_pVecUILangs = NULL;
657 }
658 
~AP_Win32Dialog_Options_General()659 AP_Win32Dialog_Options_General::~AP_Win32Dialog_Options_General()
660 {
661 	if (m_pVecUILangs)
662 	{
663 		for (UT_sint32 i=0; i < m_pVecUILangs->getItemCount(); i++)
664 			g_free ((void *)m_pVecUILangs->getNthItem(i));
665 
666 		delete m_pVecUILangs;
667 	}
668 }
669 
670 /*
671 
672 */
_onCommand(HWND,WPARAM wParam,LPARAM)673 BOOL AP_Win32Dialog_Options_General::_onCommand(HWND /*hWnd*/, WPARAM wParam, LPARAM /*lParam*/)
674 {
675 	WORD wId = LOWORD(wParam);
676 	AP_Win32Dialog_Options*	 pParent=  (AP_Win32Dialog_Options*)getContainer();
677 	AP_Dialog_Background *pColorDialog;
678 	UT_RGBColor rgbColor;
679 
680 	switch (wId)
681 	{
682 		case AP_RID_DIALOG_OPTIONS_BTN_BGColor:
683 		{
684 			pColorDialog = (AP_Dialog_Background *)(pParent->getDialogFactory()->requestDialog(AP_DIALOG_ID_BACKGROUND));
685             if (pColorDialog == NULL)
686 		    	return FALSE;
687 
688 			UT_parseColor(pParent->_gatherColorForTransparent(), rgbColor );
689 			pColorDialog->setColor(rgbColor);
690 			pColorDialog->runModal(pParent->getFrame());
691 
692 			if( pColorDialog->getAnswer() == AP_Dialog_Background::a_OK )
693 				pParent->_setColorForTransparent(pColorDialog->getColor());
694 
695 			pParent->getDialogFactory()->releaseDialog(pColorDialog);
696             return TRUE;
697 		}
698 
699 		default:
700 			break;
701 	}
702     return FALSE;
703 }
704 
705 /*
706 
707 */
_onInitDialog()708 void AP_Win32Dialog_Options_General::_onInitDialog()
709 {
710 	const gchar *pLangCode;
711 	const gchar *pLang;
712 	UT_Language	lang;
713 	int nIndex;
714 	const XAP_StringSet * pSS = getApp()->getStringSet();
715 	AP_Win32App * pApp = static_cast<AP_Win32App*>(XAP_App::getApp());
716 
717 	// localize controls
718 	_DS2(OPTIONS_CHK_EnableOverwrite,		DLG_Options_Label_EnableOverwrite);
719 	_DS2(OPTIONS_LBL_UNITS,					DLG_Options_Label_ViewUnits);
720 	_DS2(OPTIONS_BTN_BGColor,				DLG_Options_Label_ChooseForTransparent);
721 	_DS2(OPTIONS_CHK_AutoLoadPlugins,		DLG_Options_Label_CheckAutoLoadPlugins);
722 	_DS2(OPTIONS_STATIC_UI,					DLG_Options_Label_UI);
723 	_DS2(OPTIONS_STATIC_APPSTARTUP,			DLG_Options_Label_AppStartup);
724 	_DSX2(OPTIONS_CHK_LanguageWithKeyboard,	DLG_Options_Label_LangWithKeyboard);
725 	_DS2(OPTIONS_TEXT_UILANG,				DLG_Options_Label_UILang);
726 	_DS2(OPTIONS_STATIC_LANGUAGE, 			DLG_Options_Label_LangSettings);
727 
728 	// Populate values in the _COMBO_UNITS
729 
730 	for (UT_uint32 i = 0; i < SIZE_aAlignUnit; i++)
731 	{
732 		addItemToCombo(AP_RID_DIALOG_OPTIONS_COMBO_UNITS, pSS->getValue(s_aAlignUnit[i].id));
733 	}
734 
735 	// Setup bold font for some controls
736 	UINT boldFields[]={AP_RID_DIALOG_OPTIONS_STATIC_UI, AP_RID_DIALOG_OPTIONS_STATIC_APPSTARTUP,
737 		AP_RID_DIALOG_OPTIONS_STATIC_LANGUAGE, 0};
738 
739 	for(UT_uint32 i = 0; boldFields[i]; i++)
740 	{
741 		SendMessageW(GetDlgItem(getHandle(), boldFields[i]), WM_SETFONT,
742 			(WPARAM)(AP_Win32Dialog_Options*)getContainer()->getBoldFontHandle(), MAKELPARAM(FALSE /* Redraw */, 0));
743 	}
744 
745 	/* Fill up document language */
746 	m_pVecUILangs = pApp->getInstalledUILanguages();
747 	if (m_pVecUILangs->getItemCount())
748 	{
749 		/* Fill all up languages names for UI*/
750 		for (UT_sint32 i = 0; i < m_pVecUILangs->getItemCount(); i++)
751 		{
752 			pLangCode = (const char *) m_pVecUILangs->getNthItem(i);
753 
754 			int id = lang.getIndxFromCode(pLangCode);
755 			pLang  = lang.getNthLangName(id);
756 
757 			nIndex = addItemToCombo (AP_RID_DIALOG_OPTIONS_COMBO_UILANG, pLang);
758 			setComboDataItem (AP_RID_DIALOG_OPTIONS_COMBO_UILANG, nIndex, id);
759 		}
760 	}
761 	else
762 		EnableWindow(GetDlgItem(getHandle(), AP_RID_DIALOG_OPTIONS_COMBO_UILANG), FALSE);
763 
764 
765 	SetWindowLongPtrW(getHandle(), GWLP_USERDATA, (LONG_PTR)this);
766     SendMessageW(GetDlgItem (m_hDlg, AP_RID_DIALOG_OPTIONS_COMBO_UNITS),
767 		WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
768 
769 	SendMessageW(GetDlgItem (m_hDlg, AP_RID_DIALOG_OPTIONS_COMBO_UILANG),
770 		WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
771 
772 }
773 
774 
s_pageWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)775 INT_PTR CALLBACK AP_Win32Dialog_Options_General::s_pageWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
776 {
777 	if (msg==WM_NOTIFY)
778 	{
779 		AP_Win32Dialog_Options_General *pThis = (AP_Win32Dialog_Options_General *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
780 
781 		NMHDR* pHdr = (NMHDR*)lParam;
782 
783 		if (pHdr->code==PSN_SETACTIVE)
784 		{
785 			if (pThis->m_nCentered<2)
786 			{
787 			   	pThis->m_nCentered++;
788 				XAP_Win32DialogHelper::s_centerDialog(GetParent(hWnd));
789 			}
790 		}
791 	}
792 
793 	return XAP_Win32PropertyPage::s_pageWndProc(hWnd, msg, wParam,lParam);
794 }
795 
796 
797 /*
798 
799 	Document page
800 
801 */
AP_Win32Dialog_Options_Document()802 AP_Win32Dialog_Options_Document::AP_Win32Dialog_Options_Document()
803 {
804 
805 }
806 
~AP_Win32Dialog_Options_Document()807 AP_Win32Dialog_Options_Document::~AP_Win32Dialog_Options_Document()
808 {
809 
810 }
811 
812 /*
813 
814 */
_onCommand(HWND hWnd,WPARAM wParam,LPARAM)815 BOOL AP_Win32Dialog_Options_Document::_onCommand(HWND hWnd, WPARAM wParam, LPARAM /*lParam*/)
816 {
817 	WORD wId = LOWORD(wParam);
818 	AP_Win32Dialog_Options*	 pParent=  (AP_Win32Dialog_Options*)getContainer();
819 	BOOL bChecked;
820 
821 	switch (wId)
822 	{
823 
824 		case AP_RID_DIALOG_OPTIONS_CHK_AutoSaveFile:
825 			bChecked = (IsDlgButtonChecked( hWnd, AP_RID_DIALOG_OPTIONS_CHK_AutoSaveFile ) == BST_CHECKED);
826 			EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod), bChecked );
827 			EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_SPN_AutoSavePeriodSpin), bChecked );
828 			EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_TXT_AutoSaveExtension), bChecked );
829 		return TRUE;
830 
831 	    case AP_RID_DIALOG_OPTIONS_CHK_LanguageWithKeyboard:
832             pParent->_enableDisableLogic(AP_Dialog_Options::id_CHECK_LANG_WITH_KEYBOARD);
833             return TRUE;
834 
835 
836 		default:
837 		    break;
838 	}
839     return FALSE;
840 }
841 
842 /*
843 
844 */
_onInitDialog()845 void AP_Win32Dialog_Options_Document::_onInitDialog()
846 {
847 	int i;
848 	const XAP_StringSet * pSS = getApp()->getStringSet();
849 
850 	// localize controls
851 	_DS2(OPTIONS_CHK_AutoSaveFile,				DLG_Options_Label_AutoSaveUnderline);
852 	_DS2(OPTIONS_STATIC_Interval,				DLG_Options_Label_AutoSaveInterval);
853 	_DS2(OPTIONS_LBL_AutoSaveMinutes,			DLG_Options_Label_Minutes);
854 	_DS2(OPTIONS_STATIC_BidiOptions,			DLG_Options_Label_BiDiOptions);
855 	_DS2(OPTIONS_CHK_OtherDirectionRtl,			DLG_Options_Label_DirectionRtl);
856 	_DS2(OPTIONS_LBL_AutoSaveExtension,			DLG_Options_Label_FileExtension);
857 
858 
859 	// Set the starting period to 1 minute
860 	SetDlgItemInt(getHandle(), AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod, 1, FALSE );
861 
862 	// Set the range for the period to 1-360
863 	SendMessageW(GetDlgItem(getHandle(),AP_RID_DIALOG_OPTIONS_SPN_AutoSavePeriodSpin),UDM_SETBUDDY, (WPARAM) GetDlgItem(getHandle(),AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod),0);
864 	SendMessageW(GetDlgItem(getHandle(),AP_RID_DIALOG_OPTIONS_SPN_AutoSavePeriodSpin),UDM_SETRANGE,0,(WPARAM)MAKELONG(MAXAUTOSAVEPERIOD,MINAUTOSAVEPERIOD));
865 	SendMessageW(GetDlgItem(getHandle(),AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod),EM_LIMITTEXT,(WPARAM)3,(WPARAM)0);
866 
867 	// Limit the extension to 5 characters (plus the period)
868 	SendMessage(GetDlgItem(getHandle(),AP_RID_DIALOG_OPTIONS_TXT_AutoSaveExtension),EM_LIMITTEXT,(WPARAM)6,(WPARAM)0);
869 	SetWindowLongPtrW(getHandle(), GWLP_USERDATA, (LONG_PTR)this);
870 
871 	// Setup bold font for some controls
872 	UINT boldFields[]={AP_RID_DIALOG_OPTIONS_CHK_AutoSaveFile, AP_RID_DIALOG_OPTIONS_STATIC_BidiOptions, 0};
873 
874 	for(i=0; boldFields[i]; i++)
875 	{
876 		SendMessageW(GetDlgItem(getHandle(), boldFields[i]), WM_SETFONT,
877 			(WPARAM)(AP_Win32Dialog_Options*)getContainer()->getBoldFontHandle(), MAKELPARAM(FALSE /* Redraw */, 0));
878 	}
879 
880 }
881 
isAutoSaveInRange()882 bool AP_Win32Dialog_Options_Document::isAutoSaveInRange()
883 {
884 	int iValue = GetDlgItemInt(getHandle(), AP_RID_DIALOG_OPTIONS_TXT_AutoSavePeriod, NULL, FALSE);
885 	char szTemp[10];
886 	snprintf( szTemp, 10, "%d", iValue);
887 
888 	if (iValue<MINAUTOSAVEPERIOD || iValue>MAXAUTOSAVEPERIOD)
889 	{
890 		UT_Win32LocaleString str;
891 			const XAP_StringSet * pSS = getApp()->getStringSet();
892 
893 			str.fromUTF8 (pSS->getValue(AP_STRING_ID_DLG_Options_Label_InvalidRangeForAutoSave));
894 			MessageBoxW(NULL, str.c_str(),L"Abiword",MB_OK);
895 
896 		return false;
897 	}
898 
899 	return true;
900 }
901 
902 
903 /*
904 
905 	Smart Quotes page
906 
907 */
AP_Win32Dialog_Options_SmartQuotes()908 AP_Win32Dialog_Options_SmartQuotes::AP_Win32Dialog_Options_SmartQuotes()
909 {
910 
911 }
912 
913 
~AP_Win32Dialog_Options_SmartQuotes()914 AP_Win32Dialog_Options_SmartQuotes::~AP_Win32Dialog_Options_SmartQuotes()
915 {
916 
917 }
918 
919 
920 /*
921 
922 */
_onInitDialog()923 void AP_Win32Dialog_Options_SmartQuotes::_onInitDialog()
924 {
925 	const XAP_StringSet * pSS = getApp()->getStringSet();
926 	UT_return_if_fail(pSS);
927 
928 	// localize controls
929 	_DS2(OPTIONS_CHK_SmartQuotes,			DLG_Options_Label_SmartQuotes);
930 	_DS2(OPTIONS_CHK_CustomSmartQuotes,		DLG_Options_Label_CustomSmartQuotes);
931 	_DS2(OPTIONS_LBL_OuterQuoteStyle,		DLG_Options_Label_OuterQuoteStyle);
932 	_DS2(OPTIONS_LBL_InnerQuoteStyle,		DLG_Options_Label_InnerQuoteStyle);
933 
934 	UT_UCSChar buf[4];
935 
936 	HWND hQIn  = GetDlgItem(m_hDlg, AP_RID_DIALOG_OPTIONS_COMBO_INNERQUOTE);
937 	HWND hQOut = GetDlgItem(m_hDlg, AP_RID_DIALOG_OPTIONS_COMBO_OUTERQUOTE);
938 
939 	for(size_t i = 0; XAP_EncodingManager::smartQuoteStyles[i].leftQuote != (UT_UCSChar)0; i++)
940 	{
941 		buf[0] = XAP_EncodingManager::smartQuoteStyles[i].leftQuote;
942 		buf[1] = 'O';
943 		buf[2] = XAP_EncodingManager::smartQuoteStyles[i].rightQuote;
944 		buf[3] = 0;
945 
946 		LPWSTR szDisplayString = (LPWSTR) g_ucs4_to_utf16(buf, -1, NULL, NULL, NULL);
947 		if(szDisplayString)
948 		{
949 			SendMessageW(hQIn,  CB_ADDSTRING, 0, (LPARAM)szDisplayString);
950 			SendMessageW(hQOut, CB_ADDSTRING, 0, (LPARAM)szDisplayString);
951 
952 			FREEP(szDisplayString);
953 		}
954 	}
955 }
956 
957 /*
958 
959 */
_onCommand(HWND hWnd,WPARAM wParam,LPARAM)960 BOOL AP_Win32Dialog_Options_SmartQuotes::_onCommand(HWND hWnd, WPARAM wParam, LPARAM /*lParam*/)
961 {
962 	WORD wId = LOWORD(wParam);
963 
964 	switch (wId)
965 	{
966 		case AP_RID_DIALOG_OPTIONS_CHK_SmartQuotes:
967 		{
968 			bool bChecked = (IsDlgButtonChecked( hWnd, AP_RID_DIALOG_OPTIONS_CHK_SmartQuotes ) == BST_CHECKED);
969 			EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_CHK_CustomSmartQuotes), bChecked );
970 			if (!bChecked) {
971 				EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_COMBO_OUTERQUOTE), bChecked );
972 				EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_COMBO_INNERQUOTE), bChecked );
973 			}
974 			return TRUE;
975 		}
976 
977 		case AP_RID_DIALOG_OPTIONS_CHK_CustomSmartQuotes:
978 		{
979 			bool bChecked = (IsDlgButtonChecked( hWnd, AP_RID_DIALOG_OPTIONS_CHK_CustomSmartQuotes ) == BST_CHECKED);
980 			EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_COMBO_OUTERQUOTE), bChecked );
981 			EnableWindow( GetDlgItem( hWnd, AP_RID_DIALOG_OPTIONS_COMBO_INNERQUOTE), bChecked );
982 			return TRUE;
983 		}
984 
985 		default:
986 			break;
987 	}
988     return FALSE;
989 }
990