1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
51
extern CLogger * pLogger;
53
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
55
CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER);
61
case IDC_COMBO_API_CALL:
62
if(codeNotify != CBN_SELCHANGE)
67
pLogger->blockDumpToFile(FALSE);
78
if(codeNotify == EN_SETFOCUS)
79
pPlugin->m_hWndLastEditFocus = hWndCtl;
83
int iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_API_CALL));
84
ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_API_CALL), iIndex, szString);
85
if( ((strcmp(szString, STRING_NPN_POSTURL) == 0) || (strcmp(szString, STRING_NPN_POSTURLNOTIFY) == 0))
86
&& (id == IDC_EDIT_ARG5)
87
&& (codeNotify == EN_CHANGE))
89
Edit_GetText(hWndCtl, szEdit, sizeof(szEdit));
90
int iLength = strlen(szEdit);
91
SetDlgItemInt(hWnd, IDC_EDIT_ARG4, iLength, FALSE);
93
if( ((strcmp(szString, STRING_NPN_WRITE) == 0))
94
&& (id == IDC_EDIT_ARG4)
95
&& (codeNotify == EN_CHANGE))
97
Edit_GetText(hWndCtl, szEdit, sizeof(szEdit));
98
int iLength = strlen(szEdit);
99
SetDlgItemInt(hWnd, IDC_EDIT_ARG3, iLength, FALSE);
102
// save values of window size on the fly as we type it
103
if( (strcmp(szString, STRING_NPN_SETVALUE) == 0)
104
&& ((id == IDC_EDIT_ARG3) || (id == IDC_EDIT_ARG4))
105
&& (codeNotify == EN_CHANGE)
106
&& (hWndCtl == GetFocus()))
108
iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_ARG2));
109
ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_ARG2), iIndex, szString);
110
if(strcmp(szString, "NPPVpluginWindowSize") == 0)
112
BOOL bTranslated = FALSE;
113
int iWidth = GetDlgItemInt(hWnd, IDC_EDIT_ARG3, &bTranslated, TRUE);
114
int iHeight = GetDlgItemInt(hWnd, IDC_EDIT_ARG4, &bTranslated, TRUE);
116
if(pPlugin->m_iWidth != iWidth)
117
pPlugin->m_iWidth = iWidth;
118
if(pPlugin->m_iHeight != iHeight)
119
pPlugin->m_iHeight = iHeight;
126
if(codeNotify != CBN_SELCHANGE)
129
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_ARG4), SW_HIDE);
130
ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG4), SW_HIDE);
131
Static_SetText(GetDlgItem(hWnd, IDC_STATIC_ARG3), "*value:");
132
Edit_SetText(GetDlgItem(hWnd, IDC_EDIT_ARG3), "");
135
int iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_API_CALL));
136
ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_API_CALL), iIndex, szString);
137
if(strcmp(szString, STRING_NPN_SETVALUE) == 0)
139
iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_ARG2));
140
ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_ARG2), iIndex, szString);
141
if((strcmp(szString, "NPPVpluginWindowBool") == 0) ||
142
(strcmp(szString, "NPPVpluginTransparentBool") == 0) ||
143
(strcmp(szString, "NPPVpluginKeepLibraryInMemory") == 0))
145
HWND hWndCombo = GetDlgItem(hWnd, IDC_COMBO_ARG3);
146
ComboBox_ResetContent(hWndCombo);
147
ComboBox_AddString(hWndCombo, "TRUE");
148
ComboBox_AddString(hWndCombo, "FALSE");
149
ComboBox_SetCurSel(hWndCombo, 0);
150
ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG3), SW_HIDE);
151
ShowWindow(hWndCombo, SW_SHOW);
155
ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG3), SW_SHOW);
156
ShowWindow(GetDlgItem(hWnd, IDC_COMBO_ARG3), SW_HIDE);
157
if(strcmp(szString, "NPPVpluginWindowSize") == 0)
159
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_ARG4), TRUE);
160
ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG4), SW_SHOW);
161
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_ARG4), SW_SHOW);
162
Static_SetText(GetDlgItem(hWnd, IDC_STATIC_ARG3), "width:");
163
Static_SetText(GetDlgItem(hWnd, IDC_STATIC_ARG4), "height:");
164
SetDlgItemInt(hWnd, IDC_EDIT_ARG3, pPlugin->m_iWidth, TRUE);
165
SetDlgItemInt(hWnd, IDC_EDIT_ARG4, pPlugin->m_iHeight, TRUE);
171
case IDC_BUTTON_PASTE:
172
onPaste(pPlugin->m_hWndLastEditFocus);
179
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam)
181
CPlugin * pPlugin = (CPlugin *)lParam;
182
SetWindowLong(hWnd, DWL_USER, (long)pPlugin);
184
// look at the last used API call if needed
186
if (pPlugin && pPlugin->m_Pref_bRememberLastCall) {
187
char szFileName[_MAX_PATH];
188
GetINIFileName(pPlugin->getInstance(), szFileName, sizeof(szFileName));
189
iSel = XP_GetPrivateProfileInt(SECTION_PREFERENCES, KEY_LAST_API_CALL, 0, szFileName);
191
fillAPIComboBoxAndSetSel(GetDlgItem(hWnd, IDC_COMBO_API_CALL), iSel);
194
int iTopMargin = 188;
195
SetWindowPos(hWnd, NULL, 0,iTopMargin, 0,0, SWP_NOZORDER | SWP_NOSIZE);
199
static void onDestroy(HWND hWnd)
201
CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER);
202
if(pPlugin && pPlugin->m_Pref_bRememberLastCall) {
203
// save last API call if needed
204
char szFileName[_MAX_PATH];
205
GetINIFileName(pPlugin->getInstance(), szFileName, sizeof(szFileName));
206
int iSel = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_API_CALL));
207
XP_WritePrivateProfileInt(SECTION_PREFERENCES, KEY_LAST_API_CALL, iSel, szFileName);
211
BOOL CALLBACK NP_LOADDS ManualDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
216
return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
218
HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
221
HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);