Debian Codegraph @

src/af/xap/win/xap_Win32Dlg_HTMLOptions.cpp

raw
1 /* AbiWord
2 * Copyright (C) 2000 AbiSource, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include <windows.h>
21
22 #include "ut_string.h"
23 #include "ut_assert.h"
24 #include "ut_debugmsg.h"
25
26 #include "xap_App.h"
27 #include "xap_Win32App.h"
28 #include "xap_Win32FrameImpl.h"
29 #include "xap_Win32DialogHelper.h"
30 #include "xap_Strings.h"
31 #include "xap_Dialog_Id.h"
32 #include "xap_Win32Dlg_HTMLOptions.h"
33 #include "xap_Win32Resources.rc2"
34
35 /*****************************************************************/
36
37 XAP_Dialog * XAP_Win32Dialog_HTMLOptions::static_constructor(XAP_DialogFactory * pFactory,
38 XAP_Dialog_Id id)
39 {
40 XAP_Win32Dialog_HTMLOptions * p = new XAP_Win32Dialog_HTMLOptions(pFactory,id);
41 return p;
42 }
43
44 XAP_Win32Dialog_HTMLOptions::XAP_Win32Dialog_HTMLOptions(XAP_DialogFactory * pDlgFactory,
45 XAP_Dialog_Id id)
46 : XAP_Dialog_HTMLOptions(pDlgFactory,id)
47 {
48 }
49
50 XAP_Win32Dialog_HTMLOptions::~XAP_Win32Dialog_HTMLOptions(void)
51 {
52 }
53
54 void XAP_Win32Dialog_HTMLOptions::runModal(XAP_Frame * pFrame)
55 {
56 UT_ASSERT(pFrame);
57 UT_ASSERT(m_id == XAP_DIALOG_ID_HTMLOPTIONS);
58
59 setDialog(this);
60 createModal(pFrame, MAKEINTRESOURCEW(XAP_RID_DIALOG_HTMLOPTIONS));
61 }
62
63 #define _DS(c,s) SetDlgItemText(hWnd,XAP_RID_DIALOG_##c,pSS->getValue(XAP_STRING_ID_##s))
64
65 BOOL XAP_Win32Dialog_HTMLOptions::_onInitDialog(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
66 {
67 localizeDialogTitle(XAP_STRING_ID_DLG_HTMLOPT_ExpTitle);
68
69 // localize controls
70 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_LBL, XAP_STRING_ID_DLG_HTMLOPT_ExpLabel);
71 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_HTML4, XAP_STRING_ID_DLG_HTMLOPT_ExpIs4);
72 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_PHP, XAP_STRING_ID_DLG_HTMLOPT_ExpAbiWebDoc);
73 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_XML, XAP_STRING_ID_DLG_HTMLOPT_ExpDeclareXML);
74 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_AWML, XAP_STRING_ID_DLG_HTMLOPT_ExpAllowAWML);
75 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_EMBEDCSS,XAP_STRING_ID_DLG_HTMLOPT_ExpEmbedCSS);
76 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_URLIMAGE,XAP_STRING_ID_DLG_HTMLOPT_ExpEmbedImages);
77 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_PNGMATHML,XAP_STRING_ID_DLG_HTMLOPT_ExpMathMLRenderPNG);
78 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_SPLITFILE,XAP_STRING_ID_DLG_HTMLOPT_ExpSplitDocument);
79 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_SAVE, XAP_STRING_ID_DLG_HTMLOPT_ExpSave);
80 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_RESTORE, XAP_STRING_ID_DLG_HTMLOPT_ExpRestore);
81 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_OK, XAP_STRING_ID_DLG_OK);
82 localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_CANCEL, XAP_STRING_ID_DLG_Cancel);
83
84 // Set Initial conditions
85 refreshStates();
86 centerDialog();
87
88 return 1; // 1 == we did not call SetFocus()
89 }
90
91 BOOL XAP_Win32Dialog_HTMLOptions::_onCommand(HWND hWnd, WPARAM wParam, LPARAM /*lParam*/)
92 {
93 WORD wId = LOWORD(wParam);
94
95 switch (wId)
96 {
97 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_HTML4:
98 set_HTML4( (isChecked(wId)!=0) ? true : false );
99 return 1;
100
101 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_PHP:
102 set_PHTML( (isChecked(wId)!=0) ? true : false );
103 return 1;
104
105 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_XML:
106 set_Declare_XML( (isChecked(wId)!=0) ? true : false );
107 return 1;
108
109 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_AWML:
110 set_Allow_AWML( (isChecked(wId)!=0) ? true : false );
111 return 1;
112
113 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_EMBEDCSS:
114 set_Embed_CSS( (isChecked(wId)!=0) ? true : false );
115 return 1;
116
117 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_URLIMAGE:
118 set_Embed_Images( (isChecked(wId)!=0) ? true : false );
119 return 1;
120
121 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_PNGMATHML:
122 set_MathML_Render_PNG( (isChecked(wId)!=0) ? true : false );
123 return 1;
124
125 case XAP_RID_DIALOG_HTMLOPTIONS_CHK_SPLITFILE:
126 if (can_set_Split_Document())
127 set_Split_Document( (isChecked(wId)!=0) ? true : false );
128 return 1;
129
130 case XAP_RID_DIALOG_HTMLOPTIONS_BTN_SAVE:
131 saveDefaults();
132 return 1;
133
134 case XAP_RID_DIALOG_HTMLOPTIONS_BTN_RESTORE:
135 restoreDefaults();
136 refreshStates();
137 return 1;
138
139 case IDCANCEL: // also XAP_RID_DIALOG_HTMLOPTIONS_BTN_CANCEL
140 m_bShouldSave = false;
141 EndDialog(hWnd,0);
142 return 1;
143
144 case IDOK: // also XAP_RID_DIALOG_HTMLOPTIONS_BTN_OK
145 m_bShouldSave = true;
146 EndDialog(hWnd,0);
147 return 1;
148
149 default: // we did not handle this notification
150 UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
151 return 0; // return zero to let windows take care of it.
152 }
153 }
154
155 BOOL XAP_Win32Dialog_HTMLOptions::_onDeltaPos(NM_UPDOWN * /*pnmud*/)
156 {
157 return FALSE;
158 }
159
160 void XAP_Win32Dialog_HTMLOptions::refreshStates()
161 {
162 // determine which controls are available.
163 enableControl(XAP_RID_DIALOG_HTMLOPTIONS_CHK_XML,can_set_Declare_XML());
164 enableControl(XAP_RID_DIALOG_HTMLOPTIONS_CHK_AWML,can_set_Allow_AWML());
165 enableControl(XAP_RID_DIALOG_HTMLOPTIONS_CHK_EMBEDCSS,can_set_Embed_CSS());
166 enableControl(XAP_RID_DIALOG_HTMLOPTIONS_CHK_URLIMAGE,can_set_Embed_Images());
167 enableControl(XAP_RID_DIALOG_HTMLOPTIONS_CHK_SPLITFILE,can_set_Split_Document());
168
169 // set initial state
170 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_HTML4,get_HTML4());
171 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_PHP,get_PHTML());
172 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_XML,get_Declare_XML());
173 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_AWML,get_Allow_AWML());
174 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_EMBEDCSS,get_Embed_CSS());
175 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_URLIMAGE,get_Embed_Images());
176 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_PNGMATHML,get_MathML_Render_PNG());
177 checkButton(XAP_RID_DIALOG_HTMLOPTIONS_CHK_SPLITFILE,get_Split_Document());
178 }