Implement ConfirmEx and various Prompt methods on nsIPrompt. b=121931 r=chak@netscape.com a=asa@mozilla.org

This commit is contained in:
locka%iol.ie 2002-01-27 19:15:07 +00:00
parent 3a2a216faf
commit f8cd1c60ae
3 changed files with 675 additions and 65 deletions

View File

@ -180,56 +180,50 @@ END
// Dialog
//
IDD_CONFIRMCHECK DIALOG DISCARDABLE 0, 0, 263, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
IDD_PROMPT DIALOG DISCARDABLE 0, 0, 263, 113
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Enter Value"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Static",IDC_MESSAGE,36,7,220,41
CONTROL "Check1",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,52,249,19
PUSHBUTTON "&Yes",IDC_BUTTON1,75,74,50,14
PUSHBUTTON "&No",IDC_BUTTON2,128,74,50,14
ICON "",IDC_QUESTION,7,7,20,20
LTEXT "Value:",IDC_STATIC,7,71,21,8
EDITTEXT IDC_VALUE,32,71,224,14,ES_AUTOHSCROLL
CONTROL "Check msg",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,50,249,19
DEFPUSHBUTTON "OK",IDOK,152,92,50,14
PUSHBUTTON "Cancel",IDCANCEL,206,92,50,14
LTEXT "Message",IDC_MESSAGE,36,7,220,41
ICON IDI_MOZILLABROWSER,IDC_QUESTION,7,7,20,20
END
IDD_PROMPT DIALOG DISCARDABLE 0, 0, 263, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
IDD_PROMPTUSERPASS DIALOG DISCARDABLE 0, 0, 263, 135
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Authentication Required"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Static",IDC_MESSAGE,36,7,220,41
CONTROL "Check1",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,52,249,19
PUSHBUTTON "&Yes",IDC_BUTTON1,75,74,50,14
PUSHBUTTON "&No",IDC_BUTTON2,128,74,50,14
ICON "",IDC_QUESTION,7,7,20,20
LTEXT "Username:",IDC_STATIC,7,71,35,8
EDITTEXT IDC_USERNAME,44,71,212,14,ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,7,92,34,8
EDITTEXT IDC_PASSWORD,44,92,212,14,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "CheckMsg",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,50,249,19
PUSHBUTTON "OK",IDOK,153,114,50,14
PUSHBUTTON "Cancel",IDCANCEL,206,114,50,14
LTEXT "Message",IDC_MESSAGE,36,7,220,41
ICON IDI_MOZILLABROWSER,IDC_QUESTION,7,7,20,20
END
IDD_PROMPTUSERNAMEANDPASSWORD DIALOG DISCARDABLE 0, 0, 263, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
IDD_CONFIRMEX DIALOG DISCARDABLE 0, 0, 263, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Confirmation"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Static",IDC_MESSAGE,36,7,220,41
CONTROL "Check1",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
DEFPUSHBUTTON "0",IDC_BUTTON0,204,74,50,14
PUSHBUTTON "2",IDC_BUTTON2,88,74,50,14
PUSHBUTTON "1",IDC_BUTTON1,146,74,50,14
ICON IDI_MOZILLABROWSER,IDC_QUESTION,7,7,20,20
LTEXT "Message",IDC_MESSAGE,36,7,220,41
CONTROL "Check Msg",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,52,249,19
PUSHBUTTON "&Yes",IDC_BUTTON1,75,74,50,14
PUSHBUTTON "&No",IDC_BUTTON2,128,74,50,14
ICON "",IDC_QUESTION,7,7,20,20
END
IDD_PROMPTPASSWORD DIALOG DISCARDABLE 0, 0, 263, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Static",IDC_MESSAGE,36,7,220,41
CONTROL "Check1",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,52,249,19
PUSHBUTTON "&Yes",IDC_BUTTON1,75,74,50,14
PUSHBUTTON "&No",IDC_BUTTON2,128,74,50,14
ICON "",IDC_QUESTION,7,7,20,20
END
@ -241,31 +235,23 @@ END
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_CONFIRMCHECK, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 256
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
IDD_PROMPT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 256
TOPMARGIN, 7
BOTTOMMARGIN, 88
BOTTOMMARGIN, 106
END
IDD_PROMPTUSERNAMEANDPASSWORD, DIALOG
IDD_PROMPTUSERPASS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 256
TOPMARGIN, 7
BOTTOMMARGIN, 88
BOTTOMMARGIN, 128
END
IDD_PROMPTPASSWORD, DIALOG
IDD_CONFIRMEX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 256
@ -293,6 +279,17 @@ BEGIN
IDS_CANNOTCREATEPREFS "The Mozilla control cannot create a critical component. This prevents the control from functioning correctly. Possible reasons for the problem are:\n\n1. The PATH environment variable does not point to the Mozilla bin directory.\n2. The registry key HKEY_LOCAL_MACHINE\\Software\\Mozilla\\BinDirectoryPath registry key has not been set or is incorrect\n3. The file component.reg has not been generated or is empty.\n\nPlease refer to http://www.iol.ie/~locka/mozilla/mozilla.htm for guidance on how to resolve these problems."
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_CONFIRMEX_OK "OK"
IDS_CONFIRMEX_CANCEL "Cancel"
IDS_CONFIRMEX_YES "Yes"
IDS_CONFIRMEX_NO "No"
IDS_CONFIRMEX_SAVE "Save"
IDS_CONFIRMEX_DONTSAVE "Don't Save"
IDS_CONFIRMEX_REVERT "Revert"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,3 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
@ -31,6 +29,581 @@
#include "nsIPromptService.h"
#include "nsIFactory.h"
#include "nsIDOMWindow.h"
#include "nsReadableUtils.h"
class PromptDlg
{
public:
PromptDlg();
virtual ~PromptDlg();
nsresult ConfirmCheck(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
nsresult ConfirmEx(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed);
nsresult Prompt(HWND hwndParent, const PRUnichar *dialogTitle,
const PRUnichar *text, PRUnichar **value,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
nsresult PromptUsernameAndPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
nsresult PromptPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
protected:
static BOOL CALLBACK ConfirmProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
static BOOL CALLBACK PromptProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
TCHAR *mTitle;
TCHAR *mMessage;
TCHAR *mCheckMessage;
BOOL mCheckValue;
TCHAR *mButtonTitles[3];
TCHAR *mUsername;
TCHAR *mPassword;
TCHAR *mValue;
enum {
PROMPT_USERPASS,
PROMPT_PASS,
PROMPT_VALUE
} mPromptMode;
};
PromptDlg::PromptDlg() :
mMessage(NULL),
mCheckMessage(NULL),
mCheckValue(FALSE),
mUsername(NULL),
mPassword(NULL),
mValue(NULL),
mTitle(NULL),
mPromptMode(PROMPT_USERPASS)
{
for (int i = 0; i < 3; i++)
{
mButtonTitles[i] = NULL;
}
}
PromptDlg::~PromptDlg()
{
if (mTitle)
free(mTitle);
if (mMessage)
free(mMessage);
if (mCheckMessage)
free(mCheckMessage);
if (mUsername)
free(mUsername);
if (mPassword)
free(mPassword);
if (mValue)
free(mValue);
for (int i = 0; i < 3; i++)
{
if (mButtonTitles[i])
{
free(mButtonTitles[i]);
}
}
}
nsresult PromptDlg::ConfirmCheck(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
PRInt32 buttonPressed = 0;
PRUint32 buttonFlags = nsIPromptService::BUTTON_TITLE_YES +
(nsIPromptService::BUTTON_TITLE_NO << 8);
// Use the extended confirmation dialog with Yes & No buttons
nsresult rv = ConfirmEx(hwndParent, dialogTitle, text,
buttonFlags, NULL, NULL, NULL,
checkMsg, checkValue, &buttonPressed);
if (NS_SUCCEEDED(rv))
{
*_retval = (buttonPressed == 0) ? PR_TRUE : PR_FALSE;
}
return rv;
}
nsresult PromptDlg::ConfirmEx(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{
NS_ENSURE_ARG_POINTER(dialogTitle);
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(buttonPressed);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = (*checkValue == PR_TRUE) ? TRUE : FALSE;
}
// Turn the button flags into strings. The nsIPromptService flags
// are scary bit shifted values which explains the masks and bit
// shifting happening in this loop.
for (int i = 0; i < 3; i++)
{
PRUint32 titleId = buttonFlags & 255;
TCHAR **title = &mButtonTitles[i];
switch (titleId)
{
case nsIPromptService::BUTTON_TITLE_OK:
case nsIPromptService::BUTTON_TITLE_CANCEL:
case nsIPromptService::BUTTON_TITLE_YES:
case nsIPromptService::BUTTON_TITLE_NO:
case nsIPromptService::BUTTON_TITLE_SAVE:
case nsIPromptService::BUTTON_TITLE_DONT_SAVE:
case nsIPromptService::BUTTON_TITLE_REVERT:
{
const int kTitleSize = 256;
int stringId = IDS_CONFIRMEX_OK + titleId - nsIPromptService::BUTTON_TITLE_OK;
*title = (TCHAR *) malloc(sizeof(TCHAR) * kTitleSize);
::LoadString(hInstResource, stringId, *title, kTitleSize - 1);
break;
}
case nsIPromptService::BUTTON_TITLE_IS_STRING:
{
const PRUnichar *srcTitle =
(i == 0) ? button0Title :
(i == 1) ? button1Title : button2Title;
if (srcTitle)
{
*title = _tcsdup(W2T(srcTitle));
}
break;
}
default:
// ANYTHING ELSE GETS IGNORED
break;
}
buttonFlags >>= 8;
}
// Must have at least one button the user can click on!
NS_ENSURE_ARG_POINTER(mButtonTitles[0]);
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_CONFIRMEX), hwndParent, ConfirmProc, (LPARAM) this);
*checkValue = mCheckValue;
*buttonPressed = result;
return NS_OK;
}
nsresult
PromptDlg::Prompt(HWND hwndParent, const PRUnichar *dialogTitle,
const PRUnichar *text, PRUnichar **value,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(_retval);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
if (dialogTitle)
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = (*checkValue == PR_TRUE) ? TRUE : FALSE;
}
if (value)
{
mValue = _tcsdup(W2T(*value));
}
mPromptMode = PROMPT_VALUE;
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_PROMPT), hwndParent, PromptProc, (LPARAM) this);
if (result == IDOK)
{
if (value)
{
nsMemory::Free(*value);
}
nsAutoString v(T2W(mValue));
*value = ToNewUnicode(v);
*_retval = TRUE;
}
else
{
*_retval = FALSE;
}
return NS_OK;
}
nsresult
PromptDlg::PromptUsernameAndPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(_retval);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
if (dialogTitle)
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = (*checkValue == PR_TRUE) ? TRUE : FALSE;
}
if (username)
{
mUsername = _tcsdup(W2T(*username));
}
if (password)
{
mPassword = _tcsdup(W2T(*password));
}
mPromptMode = PROMPT_USERPASS;
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_PROMPTUSERPASS), hwndParent, PromptProc, (LPARAM) this);
if (result == IDOK)
{
if (username)
{
nsMemory::Free(*username);
}
if (password)
{
nsMemory::Free(*password);
}
nsAutoString user(T2W(mUsername));
nsAutoString pass(T2W(mPassword));
*username = ToNewUnicode(user);
*password = ToNewUnicode(pass);
*_retval = TRUE;
}
else
{
*_retval = FALSE;
}
return NS_OK;
}
nsresult
PromptDlg::PromptPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(_retval);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
if (dialogTitle)
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = (*checkValue == PR_TRUE) ? TRUE : FALSE;
}
if (password)
{
mPassword = _tcsdup(W2T(*password));
}
mPromptMode = PROMPT_PASS;
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_PROMPTUSERPASS), hwndParent, PromptProc, (LPARAM) this);
if (result == IDOK)
{
if (password)
{
nsMemory::Free(*password);
}
nsAutoString pass(T2W(mPassword));
*password = ToNewUnicode(pass);
*_retval = TRUE;
}
else
{
*_retval = FALSE;
}
return NS_OK;}
BOOL CALLBACK
PromptDlg::PromptProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PromptDlg *pThis = (PromptDlg *) GetWindowLong(hwndDlg, DWL_USER);
switch (uMsg)
{
case WM_INITDIALOG:
// Initialise pThis
SetWindowLong(hwndDlg, DWL_USER, lParam);
pThis = (PromptDlg *) lParam;
// Set dialog title & message text
if (pThis->mTitle)
SetWindowText(hwndDlg, pThis->mTitle);
SetDlgItemText(hwndDlg, IDC_MESSAGE, pThis->mMessage);
// Set check message text
if (pThis->mCheckMessage)
{
SetDlgItemText(hwndDlg, IDC_CHECKMSG, pThis->mCheckMessage);
CheckDlgButton(hwndDlg, IDC_CHECKMSG, pThis->mCheckValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
ShowWindow(GetDlgItem(hwndDlg, IDC_CHECKMSG), SW_HIDE);
}
switch (pThis->mPromptMode)
{
case PROMPT_PASS:
EnableWindow(GetDlgItem(hwndDlg, IDC_USERNAME), FALSE);
if (pThis->mPassword)
{
SetDlgItemText(hwndDlg, IDC_PASSWORD, pThis->mPassword);
}
break;
case PROMPT_USERPASS:
if (pThis->mUsername)
{
SetDlgItemText(hwndDlg, IDC_USERNAME, pThis->mUsername);
}
if (pThis->mPassword)
{
SetDlgItemText(hwndDlg, IDC_PASSWORD, pThis->mPassword);
}
break;
case PROMPT_VALUE:
if (pThis->mValue)
{
SetDlgItemText(hwndDlg, IDC_VALUE, pThis->mValue);
}
break;
}
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
int id = LOWORD(wParam);
if (id == IDOK)
{
if (pThis->mCheckMessage)
{
pThis->mCheckValue =
(IsDlgButtonChecked(hwndDlg, IDC_CHECKMSG) == BST_CHECKED) ?
TRUE : FALSE;
}
const int bufferSize = 256;
TCHAR buffer[bufferSize];
switch (pThis->mPromptMode)
{
case PROMPT_USERPASS:
if (pThis->mUsername)
{
free(pThis->mUsername);
}
memset(buffer, 0, sizeof(buffer));
GetDlgItemText(hwndDlg, IDC_USERNAME, buffer, bufferSize);
pThis->mUsername = _tcsdup(buffer);
// DROP THROUGH !!!!
case PROMPT_PASS:
if (pThis->mPassword)
{
free(pThis->mPassword);
}
memset(buffer, 0, sizeof(buffer));
GetDlgItemText(hwndDlg, IDC_PASSWORD, buffer, bufferSize);
pThis->mPassword = _tcsdup(buffer);
break;
case PROMPT_VALUE:
if (pThis->mValue)
{
free(pThis->mValue);
}
memset(buffer, 0, sizeof(buffer));
GetDlgItemText(hwndDlg, IDC_VALUE, buffer, bufferSize);
pThis->mValue = _tcsdup(buffer);
break;
}
EndDialog(hwndDlg, IDOK);
}
else if (id == IDCANCEL)
{
EndDialog(hwndDlg, IDCANCEL);
}
}
return TRUE;
}
return FALSE;
}
BOOL CALLBACK
PromptDlg::ConfirmProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PromptDlg *pThis = (PromptDlg *) GetWindowLong(hwndDlg, DWL_USER);
int i;
switch (uMsg)
{
case WM_INITDIALOG:
// Initialise pThis
SetWindowLong(hwndDlg, DWL_USER, lParam);
pThis = (PromptDlg *) lParam;
// Set dialog title & message text
SetWindowText(hwndDlg, pThis->mTitle);
SetDlgItemText(hwndDlg, IDC_MESSAGE, pThis->mMessage);
// Set check message text
if (pThis->mCheckMessage)
{
SetDlgItemText(hwndDlg, IDC_CHECKMSG, pThis->mCheckMessage);
CheckDlgButton(hwndDlg, IDC_CHECKMSG, pThis->mCheckValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
ShowWindow(GetDlgItem(hwndDlg, IDC_CHECKMSG), SW_HIDE);
}
// Set the button text or hide them
for (i = 0; i < 3; i++)
{
int id = IDC_BUTTON0 + i;
if (pThis->mButtonTitles[i])
{
SetDlgItemText(hwndDlg, id, pThis->mButtonTitles[i]);
}
else
{
ShowWindow(GetDlgItem(hwndDlg, id), SW_HIDE);
}
}
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
int id = LOWORD(wParam);
if (id == IDC_BUTTON0 ||
id == IDC_BUTTON1 ||
id == IDC_BUTTON2)
{
if (pThis->mCheckMessage)
{
pThis->mCheckValue =
(IsDlgButtonChecked(hwndDlg, IDC_CHECKMSG) == BST_CHECKED) ?
TRUE : FALSE;
}
EndDialog(hwndDlg, id - IDC_BUTTON0);
}
}
return FALSE;
}
return FALSE;
}
//*****************************************************************************
// CPromptService
@ -146,11 +719,9 @@ NS_IMETHODIMP CPromptService::ConfirmCheck(nsIDOMWindow *parent, const PRUnichar
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
// TODO show dialog with check box
USES_CONVERSION;
int nAnswer = pOwner->MessageBox(W2T(text), W2T(dialogTitle),
MB_YESNO | MB_ICONQUESTION);
*_retval = (nAnswer == IDYES) ? PR_TRUE : PR_FALSE;
PromptDlg dlg;
return dlg.ConfirmCheck(pOwner->m_hWnd, dialogTitle,
text, checkMsg, checkValue, _retval);
}
return NS_OK;
}
@ -165,7 +736,15 @@ NS_IMETHODIMP CPromptService::ConfirmEx(nsIDOMWindow *parent, const PRUnichar *d
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.ConfirmEx(pOwner->m_hWnd, dialogTitle,
text, buttonFlags, button0Title, button1Title, button2Title,
checkMsg, checkValue, buttonPressed);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
@ -173,7 +752,14 @@ NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dial
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.Prompt(pOwner->m_hWnd,
dialogTitle, text, value, checkMsg, checkValue, _retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
@ -183,7 +769,14 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.PromptUsernameAndPassword(pOwner->m_hWnd,
dialogTitle, text, username, password, checkMsg, checkValue, _retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent,
@ -193,7 +786,14 @@ NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.PromptPassword(pOwner->m_hWnd,
dialogTitle, text, password, checkMsg, checkValue, _retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::Select(nsIDOMWindow *parent,

View File

@ -7,10 +7,8 @@
#define IDI_MOZILLABROWSER 201
#define IDC_CHECKMSG 201
#define IDR_POPUP_PAGE 202
#define IDC_BUTTON1 202
#define IDR_POPUP_DOCUMENT 202
#define IDR_POPUP_LINK 203
#define IDC_BUTTON2 203
#define IDR_POPUP_CLIPBOARD 204
#define IDC_QUESTION 204
#define IDR_POPUP_TEXT 204
@ -20,15 +18,30 @@
#define IDR_POPUP_IMAGE 206
#define IDC_PPAGE_MARKER 206
#define IDD_PROMPTUSERNAMEANDPASSWORD 207
#define IDD_PROMPTUSERPASS 207
#define IDD_PROMPTPASSWORD 208
#define IDC_TYPE 208
#define IDD_PROPERTIES 209
#define IDC_PROTOCOL 209
#define IDD_PPAGE_LINK 210
#define IDC_ADDRESS 210
#define IDD_CONFIRMEX 211
#define IDC_VALUE 213
#define IDC_USERNAME 214
#define IDC_PASSWORD 215
#define IDS_LOCATEMOZILLA 1000
#define IDS_LOCATEMOZILLATITLE 1001
#define IDS_CANNOTCREATEPREFS 1002
#define IDS_CONFIRMEX_OK 2000
#define IDS_CONFIRMEX_CANCEL 2001
#define IDS_CONFIRMEX_YES 2002
#define IDS_CONFIRMEX_NO 2003
#define IDS_CONFIRMEX_SAVE 2004
#define IDS_CONFIRMEX_DONTSAVE 2005
#define IDS_CONFIRMEX_REVERT 2006
#define IDC_BUTTON0 2200
#define IDC_BUTTON1 2201
#define IDC_BUTTON2 2202
#define ID_BROWSE_BACK 32768
#define ID_DOCUMENT_BACK 32768
#define ID_BROWSE_FORWARD 32769
@ -67,7 +80,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 211
#define _APS_NEXT_COMMAND_VALUE 32792
#define _APS_NEXT_CONTROL_VALUE 211
#define _APS_NEXT_CONTROL_VALUE 216
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif