diff --git a/xpfe/xpviewer/Makefile.in b/xpfe/xpviewer/Makefile.in deleted file mode 100644 index cf405258f2f1..000000000000 --- a/xpfe/xpviewer/Makefile.in +++ /dev/null @@ -1,29 +0,0 @@ -#!gmake -# -# The contents of this file are subject to the Netscape Public License -# Version 1.0 (the "NPL"); you may not use this file except in -# compliance with the NPL. You may obtain a copy of the NPL at -# http://www.mozilla.org/NPL/ -# -# Software distributed under the NPL is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL -# for the specific language governing rights and limitations under the -# NPL. -# -# The Initial Developer of this code under the NPL is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All Rights -# Reserved. - -DEPTH = ../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DIRS = public src - -include $(topsrcdir)/config/config.mk - -include $(topsrcdir)/config/rules.mk diff --git a/xpfe/xpviewer/makefile.win b/xpfe/xpviewer/makefile.win deleted file mode 100644 index 5f7616b50bfe..000000000000 --- a/xpfe/xpviewer/makefile.win +++ /dev/null @@ -1,22 +0,0 @@ -#!nmake -# -# The contents of this file are subject to the Netscape Public License -# Version 1.0 (the "NPL"); you may not use this file except in -# compliance with the NPL. You may obtain a copy of the NPL at -# http://www.mozilla.org/NPL/ -# -# Software distributed under the NPL is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL -# for the specific language governing rights and limitations under the -# NPL. -# -# The Initial Developer of this code under the NPL is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All Rights -# Reserved. - -DEPTH=..\.. - -DIRS=public src - -include <$(DEPTH)\layout\config\rules.mak> diff --git a/xpfe/xpviewer/src/JSConsole.cpp b/xpfe/xpviewer/src/JSConsole.cpp deleted file mode 100644 index d83d2a4c3e87..000000000000 --- a/xpfe/xpviewer/src/JSConsole.cpp +++ /dev/null @@ -1,947 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -//is case this is defined from the outside... MMP -#ifdef WIN32_LEAN_AND_MEAN -#undef WIN32_LEAN_AND_MEAN -#endif - -#include "JSConsole.h" -#include "jsconsres.h" -#include "nsIScriptContext.h" -#include -#include "jsapi.h" - -#ifdef MOZ_DEBUG -HINSTANCE JSConsole::sAppInstance = 0; -HACCEL JSConsole::sAccelTable = 0; -CHAR JSConsole::sDefaultCaption[] = "JavaScript Console"; -BOOL JSConsole::mRegistered = FALSE; - - -// display an error string along with the error returned from -// the GetLastError functions -#define MESSAGE_LENGTH 256 -void DisplayError(LPSTR lpMessage) -{ - CHAR lpMsgBuf[MESSAGE_LENGTH * 2]; - CHAR lpLastError[MESSAGE_LENGTH]; - - ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - GetLastError(), - 0, - (LPTSTR)&lpLastError, - MESSAGE_LENGTH, - NULL); - - strcpy(lpMsgBuf, lpMessage); - strcat(lpMsgBuf, "\nThe WWS (Worthless Windows System) reports:\n"); - strcat(lpMsgBuf, lpLastError); - - // Display the string. - ::MessageBox(NULL, lpMsgBuf, "JSConsole Error", MB_OK | MB_ICONSTOP); -} - -#if defined(_DEBUG) - #define VERIFY(value, errorCondition, message) \ - if((value) == (errorCondition)) DisplayError(message); -#else // !_DEBUG - #define VERIFY(value, errorCondition, message) (value) -#endif // _DEBUG - -// -// Register the window class -// -BOOL JSConsole::RegisterWidget() -{ - WNDCLASS wc; - - wc.style = 0; - wc.lpfnWndProc = JSConsole::WindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = JSConsole::sAppInstance; - wc.hIcon = NULL; - wc.hCursor = NULL; - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW); - wc.lpszMenuName = MAKEINTRESOURCE(JSCONSOLE_MENU); - wc.lpszClassName = "JavaScript Console"; - - return (BOOL)::RegisterClass(&wc); -} - -// -// Create the main application window -// -JSConsole* JSConsole::CreateConsole() -{ - if (!JSConsole::mRegistered){ - JSConsole::mRegistered = RegisterWidget(); - } - - HWND hWnd = ::CreateWindowEx(WS_EX_ACCEPTFILES | - WS_EX_CLIENTEDGE | - WS_EX_CONTROLPARENT, - "JavaScript Console", - JSConsole::sDefaultCaption, - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - 450, - 500, - NULL, - NULL, - JSConsole::sAppInstance, - NULL); - if (hWnd) { - ::ShowWindow(hWnd, SW_SHOW); - ::UpdateWindow(hWnd); - - JSConsole *console = (JSConsole*)::GetWindowLong(hWnd, GWL_USERDATA); - return console; - } - - return NULL; -} - -// -// Window Procedure -// -LRESULT CALLBACK JSConsole::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - JSConsole *console = (JSConsole*)::GetWindowLong(hWnd, GWL_USERDATA); - - // just ignore the message unless is WM_NCCREATE - if (!console) { - if (uMsg == WM_NCCREATE) { - HWND hWndEdit = ::CreateWindow("EDIT", - NULL, - WS_CHILDWINDOW | WS_VISIBLE | ES_MULTILINE | - ES_AUTOHSCROLL | ES_AUTOVSCROLL | - WS_HSCROLL | WS_VSCROLL, - 0, 0, 0, 0, - hWnd, - NULL, - JSConsole::sAppInstance, - NULL); - if (!hWndEdit) { - ::DisplayError("Cannot Create Edit Window"); - return FALSE; - } - ::SendMessage(hWndEdit, EM_SETLIMITTEXT, (WPARAM)0, (LPARAM)0); - - console = new JSConsole(hWnd, hWndEdit); - ::SetWindowLong(hWnd, GWL_USERDATA, (DWORD)console); - - ::SetFocus(hWndEdit); - } - -#if defined(STRICT) - return ::CallWindowProc((WNDPROC)::DefWindowProc, hWnd, uMsg, - wParam, lParam); -#else - return ::CallWindowProc((FARPROC)::DefWindowProc, hWnd, uMsg, - wParam, lParam); -#endif /* STRICT */ - } - - switch(uMsg) { - - // make sure the edit window covers the whole client area - case WM_SIZE: - return console->OnSize(wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); - - // exit the application - case WM_DESTROY: - console->OnDestroy(); - -#if defined(STRICT) - return ::CallWindowProc((WNDPROC)::DefWindowProc, hWnd, uMsg, - wParam, lParam); -#else - return ::CallWindowProc((FARPROC)::DefWindowProc, hWnd, uMsg, - wParam, lParam); -#endif /* STRICT */ - - // enable/disable menu items - case WM_INITMENUPOPUP: - return console->OnInitMenu((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); - - case WM_COMMAND: - // menu or accelerator - if (HIWORD(wParam) == 0 || HIWORD(wParam) == 1) { - switch(LOWORD(wParam)) { - - case ID_FILENEW: - console->OnFileNew(); - break; - - case ID_FILEOPEN: - if (console->OpenFileDialog(OPEN_DIALOG)) { - console->LoadFile(); - } - - break; - - case ID_FILESAVE: - if (console->CanSave()) { - console->SaveFile(); - break; - } - // fall through so it can "Save As..." - - case ID_FILESAVEAS: - if (console->OpenFileDialog(SAVE_DIALOG)) { - console->SaveFile(); - } - break; - - case ID_FILEEXIT: - ::DestroyWindow(hWnd); - break; - - case ID_EDITUNDO: - console->OnEditUndo(); - break; - - case ID_EDITCUT: - console->OnEditCut(); - break; - - case ID_EDITCOPY: - console->OnEditCopy(); - break; - - case ID_EDITPASTE: - console->OnEditPaste(); - break; - - case ID_EDITDELETE: - console->OnEditDelete(); - break; - - case ID_EDITSELECTALL: - console->OnEditSelectAll(); - break; - - case ID_COMMANDSEVALALL: - console->OnCommandEvaluateAll(); - break; - - case ID_COMMANDSEVALSEL: - console->OnCommandEvaluateSelection(); - break; - - case ID_COMMANDSINSPECTOR: - console->OnCommandInspector(); - break; - - } - } - - break; - - case WM_DROPFILES: - { - HDROP hDropInfo = (HDROP)wParam; - if (::DragQueryFile(hDropInfo, (UINT)-1L, NULL, 0) != 1) { - ::MessageBox(hWnd, "Just One File Please...", "JSConsole Error", MB_OK | MB_ICONINFORMATION); - } - else { - CHAR fileName[MAX_PATH]; - ::DragQueryFile(hDropInfo, 0, fileName, MAX_PATH); - console->SetFileName(fileName); - console->LoadFile(); - } - break; - } - - case WM_SETFOCUS: - return console->OnSetFocus((HWND)wParam); - - default: -#if defined(STRICT) - return ::CallWindowProc((WNDPROC)::DefWindowProc, hWnd, uMsg, - wParam, lParam); -#else - return ::CallWindowProc((FARPROC)::DefWindowProc, hWnd, uMsg, - wParam, lParam); -#endif /* STRICT */ - } - - return 0; -} - -// -// Constructor -// The main window and the edit control must have been created already -// -JSConsole::JSConsole(HWND aMainWindow, HWND aEditControl) : - mMainWindow(aMainWindow), - mEditWindow(aEditControl), - mContext(NULL) -{ - mFileInfo.Init(); -} - -// -// Destructor -// -JSConsole::~JSConsole() -{ -} - -// -// Load a file into the edit field -// -BOOL JSConsole::LoadFile() -{ - BOOL result = FALSE; - - if (mMainWindow) { - // open the file - HANDLE file = ::CreateFile(mFileInfo.mCurrentFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL); - if (file != INVALID_HANDLE_VALUE) { - // check the file size. Max is 64k - DWORD sizeHiWord; - DWORD sizeLoWord = ::GetFileSize(file, &sizeHiWord); - if (sizeLoWord < 0x10000 && sizeHiWord == 0) { - // alloc a buffer big enough to contain the file (account for '\0' - CHAR *buffer = new CHAR[sizeLoWord + 1]; - if (buffer) { - // read the file in memory - if (::ReadFile(file, - buffer, - sizeLoWord, - &sizeHiWord, - NULL)) { - NS_ASSERTION(sizeLoWord == sizeHiWord, "ReadFile inconsistency"); - buffer[sizeLoWord] = '\0'; // terminate the buffer - // write the file to the edit field - ::SendMessage(mEditWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer); - - // update the caption - CHAR caption[80]; - ::wsprintf(caption, - "%s - %s", - mFileInfo.mCurrentFileName + mFileInfo.mFileOffset, - sDefaultCaption); - ::SendMessage(mMainWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)caption); - - result = TRUE; - } - else { - ::DisplayError("Error Reading the File"); - } - - // free the allocated buffer - delete[] buffer; - } - else { - ::MessageBox(mMainWindow, - "Cannot Allocate Enough Memory to Copy the File in Memory", - "JSConsole Error", - MB_OK | MB_ICONSTOP); - } - } - else { - ::MessageBox(mMainWindow, - "File too big. Max is 64k", - "JSConsole Error", - MB_OK | MB_ICONSTOP); - } - - // close the file handle - ::CloseHandle(file); - } -#ifdef _DEBUG - else { - CHAR message[MAX_PATH + 20]; - wsprintf(message, "Cannot Open File: %s", mFileInfo.mCurrentFileName); - ::DisplayError(message); - } -#endif - } - - return result; -} - -// -// Save the current text into a file -// -BOOL JSConsole::SaveFile() -{ - BOOL result = FALSE; - - if (mMainWindow && mFileInfo.mCurrentFileName[0] != '\0') { - // create the new file - HANDLE file = ::CreateFile(mFileInfo.mCurrentFileName, - GENERIC_WRITE, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL); - if (file != INVALID_HANDLE_VALUE) { - DWORD size; - // get the text size - size = ::SendMessage(mEditWindow, WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0); - - // alloc a buffer big enough to contain the file - CHAR *buffer = new CHAR[++size]; - if (buffer) { - DWORD byteRead; - // read the text area content - ::SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)size, (LPARAM)buffer); - - // write the buffer to disk - if (::WriteFile(file, - buffer, - size, - &byteRead, - NULL)) { - NS_ASSERTION(byteRead == size, "WriteFile inconsistency"); - // update the caption - CHAR caption[80]; - ::wsprintf(caption, - "%s - %s", - mFileInfo.mCurrentFileName + mFileInfo.mFileOffset, - sDefaultCaption); - ::SendMessage(mMainWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)caption); - - result = TRUE; - } - else { - ::DisplayError("Error Writing the File"); - } - - // free the allocated buffer - delete[] buffer; - } - else { - ::MessageBox(mMainWindow, - "Cannot Allocate Enough Memory to Copy the Edit Text in Memory", - "JSConsole Error", - MB_OK | MB_ICONSTOP); - } - - // close the file handle - ::CloseHandle(file); - } -#ifdef _DEBUG - else { - CHAR message[MAX_PATH + 20]; - wsprintf(message, "Cannot Open File: %s", mFileInfo.mCurrentFileName); - ::DisplayError(message); - } -#endif - } - - return result; -} - -// -// Open a FileOpen or FileSave dialog -// -BOOL JSConsole::OpenFileDialog(UINT aWhichDialog) -{ - BOOL result = FALSE; - OPENFILENAME ofn; - - if (mMainWindow) { - - // *.js is the standard File Name on the Save/Open Dialog - if (mFileInfo.mCurrentFileName[0] == '\0') - ::strcpy(mFileInfo.mCurrentFileName, "*.js"); - - // fill the OPENFILENAME sruct - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = mMainWindow; - ofn.hInstance = JSConsole::sAppInstance; - ofn.lpstrFilter = "JavaScript Files (*.js)\0*.js\0Text Files (*.txt)\0*.txt\0All Files\0*.*\0\0"; - ofn.lpstrCustomFilter = NULL; - ofn.nMaxCustFilter = 0; - ofn.nFilterIndex = 1; // the first one in lpstrFilter - ofn.lpstrFile = mFileInfo.mCurrentFileName; // contains the file path name on return - ofn.nMaxFile = sizeof(mFileInfo.mCurrentFileName); - ofn.lpstrFileTitle = NULL; - ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = NULL; // use default - ofn.lpstrTitle = NULL; // use default - ofn.Flags = OFN_CREATEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; - ofn.nFileOffset = 0; - ofn.nFileExtension = 0; - ofn.lpstrDefExt = "js"; // default extension is .js - ofn.lCustData = NULL; - ofn.lpfnHook = NULL; - ofn.lpTemplateName = NULL; - - // call the open file dialog or the save file dialog according to aIsOpenDialog - if (aWhichDialog == OPEN_DIALOG) { - result = ::GetOpenFileName(&ofn); - } - else if (aWhichDialog == SAVE_DIALOG) { - result = ::GetSaveFileName(&ofn); - } - - if (!result) { - mFileInfo.mCurrentFileName[0] = '\0'; - ::CommDlgExtendedError(); - } - else { - mFileInfo.mFileOffset = ofn.nFileOffset; - mFileInfo.mFileExtension = ofn.nFileExtension; - } - } - - return result; -} - -// -// set the mFileInfo structure with the proper value given a generic path -// -void JSConsole::SetFileName(LPSTR aFileName) -{ - strcpy(mFileInfo.mCurrentFileName, aFileName); - for (int i = strlen(aFileName); i >= 0; i--) { - if (mFileInfo.mCurrentFileName[i] == '.') { - mFileInfo.mFileExtension = i; - } - - if (mFileInfo.mCurrentFileName[i] == '\\') { - mFileInfo.mFileOffset = i + 1; - break; - } - } -} - -// -// Move the edit window to cover the all client area -// -LRESULT JSConsole::OnSize(DWORD aResizeFlags, UINT aWidth, UINT aHeight) -{ - ::MoveWindow(mEditWindow, 0, 0, aWidth, aHeight, TRUE); - RECT textArea; - textArea.left = 3; - textArea.top = 1; - textArea.right = aWidth - 20; - textArea.bottom = aHeight - 17; - ::SendMessage(mEditWindow, EM_SETRECTNP, (WPARAM)0, (LPARAM)&textArea); - return 0L; -} - -// -// Initialize properly menu items -// -LRESULT JSConsole::OnInitMenu(HMENU aMenu, UINT aPos, BOOL aIsSystem) -{ - if (!aIsSystem) { - if (aPos == EDITMENUPOS) { - InitEditMenu(aMenu); - } - else if (aPos == COMMANDSMENUPOS) { - InitCommandMenu(aMenu); - } - } - - return 0L; -} - -// -// Pass the focus to the edit window -// -LRESULT JSConsole::OnSetFocus(HWND aWnd) -{ - ::SetFocus(mEditWindow); - return 0L; -} - -// -// Destroy message -// -void JSConsole::OnDestroy() -{ - if (mDestroyNotification) - (*mDestroyNotification)(); -} - -// -// File/New. Reset caption, text area and file info -// -void JSConsole::OnFileNew() -{ - SendMessage(mEditWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)0); - SendMessage(mMainWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)JSConsole::sDefaultCaption); - mFileInfo.Init(); -} - -// -// Edit/Undo. Undo the last operation on the edit field -// -void JSConsole::OnEditUndo() -{ - SendMessage(mEditWindow, WM_UNDO, (WPARAM)0, (LPARAM)0); -} - -// -// Edit/Cut. Cut the current selection -// -void JSConsole::OnEditCut() -{ - SendMessage(mEditWindow, WM_CUT, (WPARAM)0, (LPARAM)0); -} - -// -// Edit/Copy. Copy the current selection -// -void JSConsole::OnEditCopy() -{ - SendMessage(mEditWindow, WM_COPY, (WPARAM)0, (LPARAM)0); -} - -// -// Edit/Paste. Paste from the clipboard -// -void JSConsole::OnEditPaste() -{ - SendMessage(mEditWindow, WM_PASTE, (WPARAM)0, (LPARAM)0); -} - -// -// Edit/Delete. Delete the current selection -// -void JSConsole::OnEditDelete() -{ - SendMessage(mEditWindow, WM_CLEAR, (WPARAM)0, (LPARAM)0); -} - -// -// Edit/Select All. Select the whole text in the text area -// -void JSConsole::OnEditSelectAll() -{ - SendMessage(mEditWindow, EM_SETSEL, (WPARAM)0, (LPARAM)-1); -} - -// -// Command/Evaluate All. Take the text area content and evaluate in the js context -// -void JSConsole::OnCommandEvaluateAll() -{ - EvaluateText(0, (UINT)-1); -} - -// -// Command/Evaluate Selection. Take the current text area selection and evaluate in the js context -// -void JSConsole::OnCommandEvaluateSelection() -{ - // - // get the selection and evaluate it - // - DWORD startSel, endSel; - - // get selection range - ::SendMessage(mEditWindow, EM_GETSEL, (WPARAM)&startSel, (LPARAM)&endSel); - - EvaluateText(startSel, endSel); -} - -// -// Command/Inspector. Run the js inspector on the global object -// -void JSConsole::OnCommandInspector() -{ - ::MessageBox(mMainWindow, "Inspector not yet available", "JSConsole Error", MB_OK | MB_ICONINFORMATION); -} - -// -// Help -// -void JSConsole::OnHelp() -{ -} - -// -// private method. Deal with the "Edit" menu -// -void JSConsole::InitEditMenu(HMENU aMenu) -{ - CHAR someText[2] = {'\0', '\0'}; // some buffer - - // set flags to "disable" - UINT undoFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - UINT cutFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - UINT copyFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - UINT pasteFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - UINT deleteFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - UINT selectAllFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - - // check if the edit area has any text - SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)2, (LPARAM)someText); - if (someText[0] != '\0') { - // enable the "Select All" - selectAllFlags = MF_BYPOSITION | MF_ENABLED; - - // enable "Copy/Cut/Paste" if there is any selection - UINT startPos, endPos; - SendMessage(mEditWindow, EM_GETSEL, (WPARAM)&startPos, (LPARAM)&endPos); - if (startPos != endPos) { - cutFlags = MF_BYPOSITION | MF_ENABLED; - copyFlags = MF_BYPOSITION | MF_ENABLED; - deleteFlags = MF_BYPOSITION | MF_ENABLED; - } - } - - // undo is available if the edit control says so - if (SendMessage(mEditWindow, EM_CANUNDO, (WPARAM)0, (LPARAM)0)) { - undoFlags = MF_BYPOSITION | MF_ENABLED; - } - - // check whether or not the clipboard contains text data - if (IsClipboardFormatAvailable(CF_TEXT)) { - pasteFlags = MF_BYPOSITION | MF_ENABLED; - } - - // do enable/disable - VERIFY(EnableMenuItem(aMenu, - ID_EDITUNDO - ID_EDITMENU - 1, - undoFlags), - -1L, - "Disable/Enable \"Undo\" Failed"); - VERIFY(EnableMenuItem(aMenu, - ID_EDITCUT - ID_EDITMENU - 1, - cutFlags), - -1L, - "Disable/Enable \"Cut\" Failed"); - VERIFY(EnableMenuItem(aMenu, - ID_EDITCOPY - ID_EDITMENU - 1, - copyFlags), - -1L, - "Disable/Enable \"Copy\" Failed"); - VERIFY(EnableMenuItem(aMenu, - ID_EDITPASTE - ID_EDITMENU - 1, - pasteFlags), - -1L, - "Disable/Enable \"Paste\" Failed"); - VERIFY(EnableMenuItem(aMenu, - ID_EDITDELETE - ID_EDITMENU - 1, - deleteFlags), - -1L, - "Disable/Enable \"Delete\" Failed"); - VERIFY(EnableMenuItem(aMenu, - ID_EDITSELECTALL - ID_EDITMENU - 1, - selectAllFlags), - -1L, - "Disable/Enable \"Select All\" Failed"); -} - -// -// private method. Deal with the "Command" menu -// -void JSConsole::InitCommandMenu(HMENU aMenu) -{ - CHAR someText[2] = {'\0', '\0'}; // some buffer - - // set flags to "disable" - UINT evaluateAllFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - UINT evaluateSelectionFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED; - - // check if the edit area has any text - SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)2, (LPARAM)someText); - if (someText[0] != 0) { - // if there is some text enable "Evaluate All" - evaluateAllFlags = MF_BYPOSITION | MF_ENABLED; - - // enable "Evaluate Selection" if there is any selection - UINT startPos, endPos; - SendMessage(mEditWindow, EM_GETSEL, (WPARAM)&startPos, (LPARAM)&endPos); - if (startPos != endPos) { - evaluateSelectionFlags = MF_BYPOSITION | MF_ENABLED; - } - } - - // disable/enable commands - VERIFY(EnableMenuItem(aMenu, - ID_COMMANDSEVALALL - ID_COMMANDSMENU - 1, - evaluateAllFlags), - -1L, - "Disable/Enable \"Evaluate All\" Failed"); - VERIFY(EnableMenuItem(aMenu, - ID_COMMANDSEVALSEL - ID_COMMANDSMENU - 1, - evaluateSelectionFlags), - -1L, - "Disable/Enable \"Evaluate Selection\" Failed"); -} - -// -// normailize a buffer of char coming from a text area. -// Basically get rid of the 0x0D char -// -LPSTR NormalizeBuffer(LPSTR aBuffer) -{ - // trim all the 0x0D at the beginning (should be 1 at most, but hey...) - while (*aBuffer == 0x0D) { - aBuffer++; - } - - LPSTR readPointer = aBuffer; - LPSTR writePointer = aBuffer; - - do { - // compact the buffer if needed - *writePointer = *readPointer; - - // skip the 0x0D - if (*readPointer != 0x0D) { - writePointer++; - } - - } while (*readPointer++ != '\0'); - - return aBuffer; -} - -LPSTR PrepareForTextArea(LPSTR aBuffer, PRInt32 aSize) -{ - PRInt32 count = 0; - LPSTR newBuffer = aBuffer; - LPSTR readPointer = aBuffer; - - // count the '\n' - while (*readPointer != '\0' && (*readPointer++ != '\n' || ++count)); - - if (0 != count) { - readPointer = aBuffer; - newBuffer = new CHAR[aSize + count + 1]; - LPSTR writePointer = newBuffer; - while (*readPointer != '\0') { - if (*readPointer == '\n') { - *writePointer++ = 0x0D; - } - *writePointer++ = *readPointer++; - } - *writePointer = '\0'; - } - - return newBuffer; -} - -// -// Evaluate the text enclosed between startSel and endSel -// -void JSConsole::EvaluateText(UINT aStartSel, UINT aEndSel) -{ - if (mContext) { - // get the text size - UINT size = ::SendMessage(mEditWindow, WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0); - - // alloc a buffer big enough to contain the file - CHAR *buffer = new CHAR[++size]; - if (buffer) { - - // get the whole text - ::SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)size, (LPARAM)buffer); - - // get the portion of the text to be evaluated - if (aEndSel != (UINT)-1) { - size = aEndSel - aStartSel; - strncpy(buffer, buffer + aStartSel, size); - buffer[size] = '\0'; - } - else { - aEndSel = size; - } - - - // change the 0x0D0x0A couple in 0x0A ('\n') - // no new buffer allocation, the pointer may be in the middle - // of the old buffer though, so keep buffer to call delete - LPSTR cleanBuffer = ::NormalizeBuffer(buffer); - - // evaluate the string - jsval returnValue; - if (mContext->EvaluateString(nsString(cleanBuffer), - nsnull, - 0, - returnValue, - &isUndefined)) { - // output the result on the console and on the edit area - CHAR result[128]; - LPSTR res = result; - int bDelete = 0; - - JSContext *cx = (JSContext *)mContext->GetNativeContext(); - char *str = returnValue.ToNewCString(); - - ::printf("The return value is %s\n", str); - - // make a string with 0xA changed to 0xD0xA - res = PrepareForTextArea(str, returnValue.Length()); - if (res != str) { - bDelete = 1; // if the buffer was new'ed - } - - // set the position at the end of the selection - ::SendMessage(mEditWindow, EM_SETSEL, (WPARAM)aEndSel, (LPARAM)aEndSel); - // write the result - ::SendMessage(mEditWindow, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)res); - // highlight the result - ::SendMessage(mEditWindow, EM_SETSEL, (WPARAM)aEndSel - 1, (LPARAM)(aEndSel + strlen(res))); - - // deal with the "big string" case - if (bDelete > 0) { - delete[] res; - } - delete[] str; - - // clean up a bit - JS_GC((JSContext *)mContext->GetNativeContext()); - } - else { - ::MessageBox(mMainWindow, - "Error evaluating the Script", - "JSConsole Error", - MB_OK | MB_ICONERROR); - } - - delete[] buffer; - } - else { - ::MessageBox(mMainWindow, - "Not Enough Memory to Allocate a Buffer to Evaluate the Script", - "JSConsole Error", - MB_OK | MB_ICONSTOP); - } - } - else { - ::MessageBox(mMainWindow, - "Java Script Context not initialized", - "JSConsole Error", - MB_OK | MB_ICONSTOP); - } -} -#endif // MOZ_DEBUG - diff --git a/xpfe/xpviewer/src/JSConsole.h b/xpfe/xpviewer/src/JSConsole.h deleted file mode 100644 index 21e8d29a554c..000000000000 --- a/xpfe/xpviewer/src/JSConsole.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -#ifndef jsconsole_h__ -#define jsconsole_h__ - -#include - -class nsIScriptContext; - -#define OPEN_DIALOG 0 -#define SAVE_DIALOG 1 - -typedef void (*DESTROY_NOTIFICATION) (); - -class JSConsole { - -private: - HWND mMainWindow; - HWND mEditWindow; - - DESTROY_NOTIFICATION mDestroyNotification; - - // keep info from the OPENFILENAME struct - struct FileInfo { - CHAR mCurrentFileName[MAX_PATH]; - WORD mFileOffset; - WORD mFileExtension; - - void Init() {mCurrentFileName[0] = '\0'; mFileOffset = 0; mFileExtension = 0;} - } mFileInfo; - - // one context per window - nsIScriptContext *mContext; - -public: - static HINSTANCE sAppInstance; - static HACCEL sAccelTable; - static CHAR sDefaultCaption[]; - - static BOOL RegisterWidget(); - static JSConsole* CreateConsole(); - static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -private: - static BOOL mRegistered; - -public: - JSConsole(HWND aMainWindow, HWND aEditControl); - ~JSConsole(); - - BOOL LoadFile(); - BOOL SaveFile(); - - BOOL OpenFileDialog(UINT aOpenOrSave); - inline BOOL CanSave() { return mFileInfo.mCurrentFileName[0] != '\0'; } - void SetFileName(LPSTR aFileName); - - HWND GetMainWindow() { return mMainWindow; } - void SetNotification(DESTROY_NOTIFICATION aNotification) { mDestroyNotification = aNotification; } - void SetContext(nsIScriptContext *aContext) { mContext = aContext; } - - void EvaluateText(UINT aStartSel, UINT aEndSel); - - // windows messages - LRESULT OnSize(DWORD aResizeFlags, UINT aWidth, UINT aHeight); - LRESULT OnInitMenu(HMENU aMenu, UINT aPos, BOOL aIsSystem); - LRESULT OnSetFocus(HWND aWnd); - - void OnDestroy(); - - // menu items - void OnFileNew(); - void OnEditUndo(); - void OnEditCut(); - void OnEditCopy(); - void OnEditPaste(); - void OnEditDelete(); - void OnEditSelectAll(); - void OnCommandEvaluateAll(); - void OnCommandEvaluateSelection(); - void OnCommandInspector(); - void OnHelp(); - -private: - void InitEditMenu(HMENU aMenu); - void InitCommandMenu(HMENU aMenu); -}; - -#endif // jsconsole_h__ - diff --git a/xpfe/xpviewer/src/Makefile.in b/xpfe/xpviewer/src/Makefile.in deleted file mode 100644 index 8fbad563a6bc..000000000000 --- a/xpfe/xpviewer/src/Makefile.in +++ /dev/null @@ -1,232 +0,0 @@ -#!gmake -# -# The contents of this file are subject to the Netscape Public License -# Version 1.0 (the "NPL"); you may not use this file except in -# compliance with the NPL. You may obtain a copy of the NPL at -# http://www.mozilla.org/NPL/ -# -# Software distributed under the NPL is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL -# for the specific language governing rights and limitations under the -# NPL. -# -# The Initial Developer of this code under the NPL is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All Rights -# Reserved. - -DEPTH=../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -PROGRAM = xpviewer - - -TOOLKIT_GFX_LIB = -lgfx$(MOZ_TOOLKIT) -TOOLKIT_WIDGET_LIB = -lwidget$(MOZ_TOOLKIT) -TOOLKIT_BASE_LIB = -lgmbase$(MOZ_TOOLKIT) - -# Hardcoding dlopen()'s? This needs to get fixed. -# -TOOLKIT_CFLAGS := \ - -DWIDGET_DLL=\"libwidget$(MOZ_TOOLKIT).$(DLL_SUFFIX)\" \ - -DGFXWIN_DLL=\"libgfx$(MOZ_TOOLKIT).$(DLL_SUFFIX)\" \ - $(TK_CFLAGS) - - -CPPSRCS = \ - nsFindDialog.cpp \ - nsSetupRegistry.cpp \ - nsUnixStubs.cpp \ - nsBrowserWindow.cpp \ - nsBrowserMain.cpp \ - nsViewerApp.cpp \ - nsXPBaseWindow.cpp \ - $(NULL) - -ifdef MOZ_OJI - JSJ_LIB = -ljsj -endif - -LIBS := \ - -L$(DIST)/bin \ - -lraptorbase \ - -lpref \ - -lraptorbase \ - $(TOOLKIT_WIDGET_LIB) \ - -lraptorgfx \ - $(TOOLKIT_GFX_LIB) \ - -lraptorhtml \ - $(DIST)/lib/libraptorhtmlforms_s.a \ - $(TOOLKIT_BASE_LIB) \ - -lraptorhtmlpars \ - -lraptorview \ - -lreg \ - -labouturl \ - -lfileurl \ - -lftpurl \ - -lgophurl \ - -lhttpurl \ - -lsockstuburl \ - -limg \ - $(JPEG_LIBS) \ - $(PNG_LIBS) \ - -l$(MOZ_LIB_JS_PREFIX)js \ - -ljsdom \ - -ljsurl \ - $(DIST)/lib/libjsdomcore_s.a \ - $(JSJ_LIB) \ - -lmimetype \ - -lnetcache \ - -lnetcnvts \ - -lnetlib \ - -lnetutil \ - -lnetwork \ - -lpwcac \ - -lraptorwebwidget \ - -lreg \ - -lremoturl \ - -lsecfree \ - -lstubnj \ - -lstubsj \ - -ltestdynamic \ - -l$(MOZ_LIB_UTIL_PREFIX)util \ - -lxp \ - -lxpcom \ - -l$(MOZ_LIB_UTIL_PREFIX)util \ - -lxp \ - -lxpcom \ - $(ZLIB_LIBS) \ - -lraptorplugin \ - -l$(MOZ_LIB_DBM_PREFIX)dbm \ - $(NULL) - -include $(topsrcdir)/config/config.mk - -CFLAGS += $(TOOLKIT_CFLAGS) - -include $(topsrcdir)/config/rules.mk - -install:: - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test0.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test1.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test2.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test3.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test4.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test5.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test6.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test7.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test8.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test8siz.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test8sca.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test8tab.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test9.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test9a.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/test9b.html $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/raptor.jpg $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/Anieyes.gif $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/gear1.gif $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/rock_gra.gif $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/../../../webshell/tests/viewer/samples/bg.jpg $(DIST)/bin/res/samples - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation00.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation01.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation02.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation03.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation04.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation05.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation06.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation07.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation08.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation09.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation10.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation11.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation12.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation13.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation14.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation15.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation16.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation17.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation18.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation19.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation20.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation21.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation22.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation23.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation24.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation25.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation26.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation27.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation28.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation29.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation30.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation31.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation32.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation33.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation34.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation35.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation36.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation37.gif $(DIST)/bin/res/throbber - $(INSTALL) $(srcdir)/resources/throbber/LargeAnimation38.gif $(DIST)/bin/res/throbber - - $(INSTALL) $(srcdir)/resources/toolbar/DialogAddrIcon.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/DialogAddrIcon_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/DialogCompIcon.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/DialogCompIcon_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/DialogMailIcon.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/DialogMailIcon_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/DialogNavIcon.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/DialogNavIcon_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Back.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Back_dis.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Back_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Bookmarks.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Bookmarks_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Edit.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Forward.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Forward_dis.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Forward_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Home.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Home_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_HTab.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_HTab_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_LoadImages.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_LoadImages.mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Location.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Location_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_MiniAddr.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_MiniComp.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_MiniMail.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_MiniNav.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_MiniTab.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_MixSecurity.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_MixSecurity.mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Netscape.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Netscape_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_PersonalIcon.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Places.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Places_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Print.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Print_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Reload.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Reload_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Search.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Search_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Secure.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Secure_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Stop.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Stop.mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Stop_dis.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Stop_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Tab.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_TabSmall.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_TabSmall_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Tab_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Unsecure.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_Unsecure.mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_WhatsRelated.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/TB_WhatsRelated_mo.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/StatusBar-insecure.gif $(DIST)/bin/res/toolbar - $(INSTALL) $(srcdir)/resources/toolbar/StatusBar-secure.gif $(DIST)/bin/res/toolbar diff --git a/xpfe/xpviewer/src/jsconsres.h b/xpfe/xpviewer/src/jsconsres.h deleted file mode 100644 index ba69fac35386..000000000000 --- a/xpfe/xpviewer/src/jsconsres.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -#ifndef jsconsres_h___ -#define jsconsres_h___ - - -// Main menu id -#define JSCONSOLE_MENU 20100 - -#define FILEMENUPOS 0 -#define ID_FILEMENU 20200 -// File menu items ids -#define ID_FILENEW 20201 -#define ID_FILEOPEN 20202 -#define ID_FILESAVE 20203 -#define ID_FILESAVEAS 20204 -// separator -#define ID_FILEEXIT 20206 - -#define EDITMENUPOS 1 -#define ID_EDITMENU 20300 -// Edit menu items ids -#define ID_EDITUNDO 20301 -// separator -#define ID_EDITCUT 20303 -#define ID_EDITCOPY 20304 -#define ID_EDITPASTE 20305 -#define ID_EDITDELETE 20306 -// separator -#define ID_EDITSELECTALL 20308 - -#define COMMANDSMENUPOS 2 -#define ID_COMMANDSMENU 20400 -// Commands menu items ids -#define ID_COMMANDSEVALALL 20401 -#define ID_COMMANDSEVALSEL 20402 -// separator -#define ID_COMMANDSINSPECTOR 20404 - -#define HELPMENUPOS 3 -#define ID_HELPMENU 20500 -// Help menu items -#define ID_NOHELP 20501 - -// -// Accelerators table ids -// -#define ACCELERATOR_TABLE 1000 - -#endif // jsconsres_h___ - diff --git a/xpfe/xpviewer/src/makefile.win b/xpfe/xpviewer/src/makefile.win deleted file mode 100644 index 5521dda90e41..000000000000 --- a/xpfe/xpviewer/src/makefile.win +++ /dev/null @@ -1,228 +0,0 @@ -#!nmake -# -# The contents of this file are subject to the Netscape Public License -# Version 1.0 (the "NPL"); you may not use this file except in -# compliance with the NPL. You may obtain a copy of the NPL at -# http://www.mozilla.org/NPL/ -# -# Software distributed under the NPL is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL -# for the specific language governing rights and limitations under the -# NPL. -# -# The Initial Developer of this code under the NPL is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All Rights -# Reserved. - -DEPTH=..\..\.. -IGNORE_MANIFEST=1 - -MAKE_OBJ_TYPE = EXE -PROGRAM = .\$(OBJDIR)\xpviewer.exe -RESFILE = xpviewer.res - - -MISCDEP= \ - $(DIST)\lib\raptorweb.lib \ - $(DIST)\lib\xpcom32.lib \ - $(LIBNSPR) \ - $(DIST)\lib\plc3.lib - - -OBJS = \ - .\$(OBJDIR)\nsFindDialog.obj \ - .\$(OBJDIR)\nsXPBaseWindow.obj \ - .\$(OBJDIR)\nsBrowserWindow.obj \ - .\$(OBJDIR)\nsSetupRegistry.obj \ - .\$(OBJDIR)\nsViewerApp.obj \ - .\$(OBJDIR)\nsBrowserMain.obj \ - .\$(OBJDIR)\JSConsole.obj \ - $(NULL) - -LINCS= \ - -I$(PUBLIC)\raptor \ - -I$(PUBLIC)\xpcom \ - -I$(PUBLIC)\dom \ - -I$(PUBLIC)\js \ - -I$(PUBLIC)\netlib \ - -I$(PUBLIC)\java \ - -I$(PUBLIC)\plugin \ - -I$(PUBLIC)\editor \ - -I$(PUBLIC)\pref \ -!ifdef MOZ_FULLCIRCLE - -I$(PUBLIC)\fullsoft \ -!endif - $(NULL) - -MYLIBS= \ - $(DIST)\lib\raptorbase.lib \ - $(DIST)\lib\raptorgfxwin.lib \ - $(DIST)\lib\raptorhtml.lib \ - $(DIST)\lib\raptorweb.lib \ - $(DIST)\lib\raptorwidget.lib \ - $(DIST)\lib\raptorhtmlpars.lib \ - $(DIST)\lib\xpcom32.lib \ - $(DIST)\lib\js32$(VERSION_NUMBER).lib \ - $(LIBNSPR) \ - $(DIST)\lib\plc3.lib \ - $(DIST)\lib\netlib.lib \ - $(DIST)\lib\jsdom.lib \ - comdlg32.lib \ -!ifdef MOZ_FULLCIRCLE - $(DIST)\lib\fulls32.lib \ -!endif - $(NULL) - -LLIBS= $(MYLIBS) \ - shell32.lib \ - -SUBSYSTEM:CONSOLE - -include <$(DEPTH)\config\rules.mak> - -!ifdef MOZ_NO_DEBUG_RTL -OS_CFLAGS = $(OS_CFLAGS) -DMOZ_NO_DEBUG_RTL -!endif - -install:: $(PROGRAM) - $(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin - $(MAKE_INSTALL) resources\chrome\find.html $(DIST)\bin\res\samples - $(MAKE_INSTALL) resources\throbber\LargeAnimation00.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation01.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation02.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation03.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation04.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation05.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation06.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation07.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation08.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation09.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation10.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation11.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation12.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation13.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation14.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation15.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation16.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation17.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation18.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation19.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation20.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation21.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation22.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation23.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation24.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation25.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation26.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation27.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation28.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation29.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation30.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation31.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation32.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation33.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation34.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation35.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation36.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation37.gif $(DIST)\bin\res\throbber - $(MAKE_INSTALL) resources\throbber\LargeAnimation38.gif $(DIST)\bin\res\throbber - - $(MAKE_INSTALL) resources\toolbar\DialogAddrIcon.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\DialogAddrIcon_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\DialogCompIcon.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\DialogCompIcon_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\DialogMailIcon.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\DialogMailIcon_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\DialogNavIcon.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\DialogNavIcon_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Back.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Back_dis.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Back_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Bookmarks.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Bookmarks_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Edit.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Forward.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Forward_dis.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Forward_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Home.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Home_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_HTab.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_HTab_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_LoadImages.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_LoadImages.mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Location.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Location_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_MiniAddr.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_MiniComp.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_MiniMail.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_MiniNav.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_MiniTab.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_MixSecurity.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_MixSecurity.mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Netscape.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Netscape_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_PersonalIcon.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Places.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Places_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Print.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Print_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Reload.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Reload_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Search.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Search_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Secure.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Secure_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Stop.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Stop.mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Stop_dis.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Stop_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Tab.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_TabSmall.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_TabSmall_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Tab_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Unsecure.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_Unsecure.mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_WhatsRelated.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\TB_WhatsRelated_mo.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\StatusBar-insecure.gif $(DIST)\bin\res\toolbar - $(MAKE_INSTALL) resources\toolbar\StatusBar-secure.gif $(DIST)\bin\res\toolbar - - -clobber:: - rm -f $(DIST)\bin\xpviewer.exe - rm -f $(DIST)\bin\res\samples\find.html - rm -f $(DIST)\bin\res\samples\test0.html - rm -f $(DIST)\bin\res\samples\test1.html - rm -f $(DIST)\bin\res\samples\test2.html - rm -f $(DIST)\bin\res\samples\test3.html - rm -f $(DIST)\bin\res\samples\test4.html - rm -f $(DIST)\bin\res\samples\test5.html - rm -f $(DIST)\bin\res\samples\test6.html - rm -f $(DIST)\bin\res\samples\test7.html - rm -f $(DIST)\bin\res\samples\test8.html - rm -f $(DIST)\bin\res\samples\test8siz.html - rm -f $(DIST)\bin\res\samples\test8sca.html - rm -f $(DIST)\bin\res\samples\test8tab.html - rm -f $(DIST)\bin\res\samples\test_ed.html - rm -f $(DIST)\bin\res\samples\test9.html - rm -f $(DIST)\bin\res\samples\test9a.html - rm -f $(DIST)\bin\res\samples\test9b.html - rm -f $(DIST)\bin\res\samples\raptor.jpg - rm -f $(DIST)\bin\res\samples\Anieyes.gif - rm -f $(DIST)\bin\res\samples\gear1.gif - rm -f $(DIST)\bin\res\samples\rock_gra.gif - rm -f $(DIST)\bin\res\samples\bg.jpg - rm -f $(DIST)\bin\res\throbber\anims00.gif - rm -f $(DIST)\bin\res\throbber\anims01.gif - rm -f $(DIST)\bin\res\throbber\anims02.gif - rm -f $(DIST)\bin\res\throbber\anims03.gif - rm -f $(DIST)\bin\res\throbber\anims04.gif - rm -f $(DIST)\bin\res\throbber\anims05.gif - rm -f $(DIST)\bin\res\throbber\anims06.gif - rm -f $(DIST)\bin\res\throbber\anims07.gif - rm -f $(DIST)\bin\res\throbber\anims08.gif - rm -f $(DIST)\bin\res\throbber\anims09.gif - rm -f $(DIST)\bin\res\throbber\anims10.gif - rm -f $(DIST)\bin\res\throbber\anims11.gif - rm -f $(DIST)\bin\res\throbber\anims12.gif - rm -f $(DIST)\bin\res\throbber\anims13.gif diff --git a/xpfe/xpviewer/src/nsBrowserMain.cpp b/xpfe/xpviewer/src/nsBrowserMain.cpp deleted file mode 100644 index 14247d036a1d..000000000000 --- a/xpfe/xpviewer/src/nsBrowserMain.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#ifdef XP_PC -#include -#include "JSConsole.h" -#endif -#include "nsViewerApp.h" -#include "nsBrowserWindow.h" -#include "nsITimer.h" -#include "plevent.h" - -#ifdef XP_PC -JSConsole *gConsole; -HINSTANCE gInstance, gPrevInstance; -#endif - -static nsITimer* gNetTimer; - -/*nsNativeViewerApp::nsNativeViewerApp() -{ -} - -nsNativeViewerApp::~nsNativeViewerApp() -{ -} - -int -nsNativeViewerApp::Run() -{ - OpenWindow(); - - // Process messages - MSG msg; - while (::GetMessage(&msg, NULL, 0, 0)) { - if (!JSConsole::sAccelTable || - !gConsole || - !gConsole->GetMainWindow() || - !TranslateAccelerator(gConsole->GetMainWindow(), - JSConsole::sAccelTable, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - return msg.wParam; -} -*/ -//---------------------------------------------------------------------- - -/*nsNativeBrowserWindow::nsNativeBrowserWindow() -{ -} - -nsNativeBrowserWindow::~nsNativeBrowserWindow() -{ -} - -nsresult -nsBrowserWindow::CreateMenuBar(PRInt32 aWidth) -{ - HMENU menu = ::LoadMenu(gInstance, "Viewer"); - HWND hwnd = (HWND)mWindow->GetNativeData(NS_NATIVE_WIDGET); - ::SetMenu(hwnd, menu); - - - - return NS_OK; -} - -nsEventStatus -nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID) -{ - // Dispatch windows-only menu code goes here - - // Dispatch xp menu items - return nsBrowserWindow::DispatchMenuItem(aID); -}*/ - -//---------------------------------------------------------------------- - -int main(int argc, char **argv) -{ -#ifdef XP_PC - PL_InitializeEventsLib(""); -#endif - - nsViewerApp* app = new nsViewerApp(); - NS_ADDREF(app); - /* we should, um, check for failure */ - if (app->Initialize(argc, argv) != NS_OK) - return 0; - // Initialize() now does this: app->OpenWindow(); - app->Run(); - NS_RELEASE(app); - - return 0; -} - -#ifdef XP_PC -int PASCAL -WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, - int nCmdShow) -{ - gInstance = instance; - gPrevInstance = prevInstance; - PL_InitializeEventsLib(""); - nsViewerApp* app = new nsViewerApp(); - app->Initialize(0, nsnull); - app->OpenWindow(); - - int result = app->Run(); - delete app; - return result; -} -#endif diff --git a/xpfe/xpviewer/src/nsBrowserWindow.cpp b/xpfe/xpviewer/src/nsBrowserWindow.cpp deleted file mode 100644 index 44d81b47f891..000000000000 --- a/xpfe/xpviewer/src/nsBrowserWindow.cpp +++ /dev/null @@ -1,3714 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#ifdef XP_MAC -#include "nsBrowserWindow.h" -#define NS_IMPL_IDS -#else -#define NS_IMPL_IDS -#include "nsBrowserWindow.h" -#endif -#include "prmem.h" - -#include "nsIStreamListener.h" -#include "nsIAppShell.h" -#include "nsIWidget.h" -#include "nsITextWidget.h" -#include "nsIButton.h" -#include "nsILabel.h" -#include "nsIImageGroup.h" -#include "nsITimer.h" -#include "nsIThrobber.h" -#include "nsIDOMDocument.h" -#include "nsIURL.h" -#include "nsIFileWidget.h" -#include "nsILookAndFeel.h" -#include "nsIComponentManager.h" -#include "nsIFactory.h" -#include "nsCRT.h" -#include "nsWidgetsCID.h" -#include "nsViewerApp.h" -#include "prprf.h" -#include "nsIComponentManager.h" -#include "nsParserCIID.h" - -#include "nsIXPBaseWindow.h" -#include "nsXPBaseWindow.h" -#include "nsFindDialog.h" -#include "nsIDocument.h" -#include "nsIPresContext.h" -#include "nsIDocumentViewer.h" -#include "nsIContentViewer.h" -#include "nsIPresShell.h" -#include "nsIDocument.h" -#include "nsXIFDTD.h" -#include "nsIParser.h" -#include "nsHTMLContentSinkStream.h" -#include "nsGUIEvent.h" - - -// Needed for "Find" GUI -#include "nsIDialog.h" -#include "nsICheckButton.h" -#include "nsIRadioButton.h" -#include "nsILabel.h" -#include "nsIMenuBar.h" - -// Menus -#include "nsIMenu.h" -#include "nsIMenuItem.h" -#include "nsWidgetSupport.h" -#include "nsIPopUpMenu.h" -#include "nsIMenuButton.h" - -// ImageButtons -#include "nsIImageButton.h" -#include "nsIToolbar.h" -#include "nsIToolbarManager.h" -#include "nsIToolbarItem.h" -#include "nsIToolbarItemHolder.h" - -#include "resources.h" - -#if defined(WIN32) -#include -#else -#include -#include -#endif - -#if defined(WIN32) -#include -#endif - -#include "nsIEditor.h" -#include "nsEditorCID.h" - -// XXX For font setting below -#include "nsFont.h" -#include "nsUnitConversion.h" -#include "nsIDeviceContext.h" - -// XXX greasy constants -//#define THROBBER_WIDTH 32 -//#define THROBBER_HEIGHT 32 -#define THROBBER_WIDTH 42 -#define THROBBER_HEIGHT 42 - -#define BUTTON_WIDTH 90 -#define BUTTON_HEIGHT THROBBER_HEIGHT - -#ifdef INSET_WEBSHELL -#define WEBSHELL_LEFT_INSET 5 -#define WEBSHELL_RIGHT_INSET 5 -#define WEBSHELL_TOP_INSET 5 -#define WEBSHELL_BOTTOM_INSET 5 -#else -#define WEBSHELL_LEFT_INSET 0 -#define WEBSHELL_RIGHT_INSET 0 -#define WEBSHELL_TOP_INSET 0 -#define WEBSHELL_BOTTOM_INSET 0 -#endif - -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); -static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID); -static NS_DEFINE_IID(kButtonCID, NS_BUTTON_CID); -static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); -static NS_DEFINE_IID(kTextFieldCID, NS_TEXTFIELD_CID); -static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID); -static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); -static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID); -static NS_DEFINE_IID(kDialogCID, NS_DIALOG_CID); -static NS_DEFINE_IID(kCheckButtonCID, NS_CHECKBUTTON_CID); -static NS_DEFINE_IID(kRadioButtonCID, NS_RADIOBUTTON_CID); -static NS_DEFINE_IID(kLabelCID, NS_LABEL_CID); -static NS_DEFINE_IID(kMenuBarCID, NS_MENUBAR_CID); -static NS_DEFINE_IID(kMenuCID, NS_MENU_CID); -static NS_DEFINE_IID(kMenuItemCID, NS_MENUITEM_CID); -static NS_DEFINE_IID(kImageButtonCID, NS_IMAGEBUTTON_CID); -static NS_DEFINE_IID(kToolbarCID, NS_TOOLBAR_CID); -static NS_DEFINE_IID(kToolbarManagerCID, NS_TOOLBARMANAGER_CID); -static NS_DEFINE_IID(kToolbarItemHolderCID, NS_TOOLBARITEMHOLDER_CID); -static NS_DEFINE_IID(kToolbarItemCID, NS_TOOLBARITEM_CID); -static NS_DEFINE_IID(kPopUpMenuCID, NS_POPUPMENU_CID); -static NS_DEFINE_IID(kMenuButtonCID, NS_MENUBUTTON_CID); -static NS_DEFINE_IID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID); - -static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); -static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID); -static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); -static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID); -static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID); -static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID); -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID); -static NS_DEFINE_IID(kIThrobberIID, NS_ITHROBBER_IID); -static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); -static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID); -static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); -static NS_DEFINE_IID(kIDialogIID, NS_IDIALOG_IID); -static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); -static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID); -static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); -static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID); -static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID); -static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID); -static NS_DEFINE_IID(kIImageButtonIID, NS_IIMAGEBUTTON_IID); -static NS_DEFINE_IID(kIToolbarIID, NS_ITOOLBAR_IID); -static NS_DEFINE_IID(kIToolbarManagerIID, NS_ITOOLBARMANAGER_IID); -static NS_DEFINE_IID(kIToolbarItemHolderIID, NS_ITOOLBARITEMHOLDER_IID); -static NS_DEFINE_IID(kIToolbarItemIID, NS_ITOOLBARITEM_IID); -static NS_DEFINE_IID(kIPopUpMenuIID, NS_IPOPUPMENU_IID); -static NS_DEFINE_IID(kIMenuButtonIID, NS_IMENUBUTTON_IID); -static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID); -static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID); -static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID); -static NS_DEFINE_IID(kIEditorIID, NS_IEDITOR_IID); -static NS_DEFINE_IID(kEditorCID, NS_EDITOR_CID); - -static const char* gsAOLFormat = "AOLMAIL"; -static const char* gsHTMLFormat = "text/html"; - -static PRInt32 gBtnWidth = 54; -static PRInt32 gBtnHeight = 42; - -//---------------------------------------------------------------------- -nsVoidArray nsBrowserWindow::gBrowsers; - -///////////////////////////////////////////////////////////// -// This part is temporary until we get the XML/HTML code working -///////////////////////////////////////////////////////////// - -typedef struct { - PRInt32 mGap; - PRInt32 mImgWidth; - PRInt32 mImgHeight; - PRBool mEnabled; - PRInt32 mCommand; - char * mLabel; - char * mRollOverDesc; - char * mUpName; - char * mPressedName; - char * mDisabledName; - char * mRolloverName; -} ButtonCreateInfo; - -//----------------------------------------------------------------- -// XXX These constants will go away once we are hooked up to JavaScript -const PRInt32 gBackBtnInx = 0; -const PRInt32 gForwardBtnInx = 1; -const PRInt32 gReloadBtnInx = 2; -const PRInt32 gHomeBtnInx = 3; -const PRInt32 gSearchBtnInx = 4; -const PRInt32 gNetscapeBtnInx = 5; -const PRInt32 gPrintBtnInx = 6; -const PRInt32 gSecureBtnInx = 7; -const PRInt32 gStopBtnInx = 8; - -const PRInt32 kBackCmd = 3000; -const PRInt32 kForwardCmd = 3001; -const PRInt32 kReloadCmd = 3002; -const PRInt32 kHomeCmd = 3003; -const PRInt32 kSearchCmd = 3004; -const PRInt32 kNetscapeCmd = 3005; -const PRInt32 kPrintCmd = 3006; -const PRInt32 kSecureCmd = 3007; -const PRInt32 kStopCmd = 3008; - -const PRInt32 kMiniTabCmd = 3009; -const PRInt32 kMiniNavCmd = 3010; -const PRInt32 kBookmarksCmd = 3011; -const PRInt32 kWhatsRelatedCmd = 3012; - -const PRInt32 kPersonalCmd = 4000; - -//------------------------------------------- -// These static toolbar definitions will go away once we have XML/HTML -ButtonCreateInfo gBtnToolbarInfo[] = { -{10, 23, 21, PR_FALSE, kBackCmd, "Back", "Return to previous document in history list", "TB_Back.gif", "TB_Back.gif", "TB_Back_dis.gif", "TB_Back_mo.gif"}, -{2, 23, 21, PR_FALSE, kForwardCmd, "Forward", "Move forward to next document in history list", "TB_Forward.gif", "TB_Forward.gif", "TB_Forward_dis.gif", "TB_Forward_mo.gif"}, -{2, 23, 21, PR_TRUE, kReloadCmd, "Reload", "Reload the current page", "TB_Reload.gif", "TB_Reload.gif", "TB_Reload.gif", "TB_Reload_mo.gif"}, -{2, 23, 21, PR_TRUE, kHomeCmd, "Home", "Go to the Home page", "TB_Home.gif", "TB_Home.gif", "TB_Home.gif", "TB_Home_mo.gif"}, -{2, 23, 21, PR_FALSE, kSearchCmd, "Search", "Search the internet for information", "TB_Search.gif", "TB_Search.gif", "TB_Search.gif", "TB_Search_mo.gif"}, -{2, 23, 21, PR_FALSE, kNetscapeCmd, "Netscape","Go to your personal start page", "TB_Netscape.gif","TB_Netscape.gif","TB_Netscape.gif", "TB_Netscape_mo.gif"}, -{2, 23, 21, PR_FALSE, kPrintCmd, "Print", "Print this page", "TB_Print.gif", "TB_Print.gif", "TB_Print.gif", "TB_Print_mo.gif"}, -{2, 23, 21, PR_FALSE, kSecureCmd, "Security","Show security information", "TB_Secure.gif", "TB_Secure.gif", "TB_Secure.gif", "TB_Secure_mo.gif"}, -{2, 23, 21, PR_FALSE, kStopCmd, "Stop", "Stop the current transfer", "TB_Stop.gif", "TB_Stop.gif", "TB_Stop_dis.gif", "TB_Stop_mo.gif"}, -{0, 0, 0, PR_FALSE, 0, NULL, NULL, NULL, NULL, NULL} -}; - -ButtonCreateInfo gMiniAppsToolbarInfo[] = { -{0, 11, 14, PR_TRUE, kMiniTabCmd, "", "Expand toolbar", "TB_MiniTab.gif", "TB_MiniTab.gif", "TB_MiniTab.gif", "TB_MiniTab.gif"}, -{1, 30, 14, PR_TRUE, kMiniNavCmd, "", "Start a Navigator session", "TB_MiniNav.gif", "TB_MiniNav.gif", "TB_MiniNav.gif", "TB_MiniNav.gif"}, -{1, 30, 14, PR_TRUE, kMiniNavCmd, "", "Start a Mail session", "TB_MiniMail.gif", "TB_MiniMail.gif", "TB_MiniMail.gif", "TB_MiniMail.gif"}, -{1, 30, 14, PR_TRUE, kMiniNavCmd, "", "Start a Address Book session", "TB_MiniAddr.gif", "TB_MiniAddr.gif", "TB_MiniAddr.gif", "TB_MiniAddr.gif"}, -{1, 30, 14, PR_TRUE, kMiniNavCmd, "", "Start a Composer session", "TB_MiniComp.gif", "TB_MiniComp.gif", "TB_MiniComp.gif", "TB_MiniComp.gif"}, -{0, 0, 0, PR_FALSE, 0, NULL, NULL, NULL, NULL, NULL} -}; - -ButtonCreateInfo gMiniAppsDialogInfo[] = { -{2, 36, 22, PR_TRUE, kMiniNavCmd, "", "Start a Navigator session", "DialogNavIcon.gif", "DialogNavIcon.gif", "DialogNavIcon.gif", "DialogNavIcon_mo.gif"}, -{2, 36, 22, PR_TRUE, kMiniNavCmd, "", "Start a Mail session", "DialogMailIcon.gif", "DialogMailIcon.gif", "DialogMailIcon.gif", "DialogMailIcon_mo.gif"}, -{2, 36, 22, PR_TRUE, kMiniNavCmd, "", "Start a ddress Book session", "DialogAddrIcon.gif", "DialogAddrIcon.gif", "DialogAddrIcon.gif", "DialogAddrIcon_mo.gif"}, -{2, 36, 22, PR_TRUE, kMiniNavCmd, "", "Start a Composer session", "DialogCompIcon.gif", "DialogCompIcon.gif", "DialogCompIcon.gif", "DialogCompIcon_mo.gif"}, -{0, 0, 0, PR_FALSE, 0, NULL, NULL, NULL, NULL, NULL} -}; - -ButtonCreateInfo gPersonalToolbarInfo[] = { -{10, 18, 18, PR_TRUE, kPersonalCmd, "People", "http://home.netscape.com/netcenter/whitepages.html?cp=xpviewerDR1", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif"}, -{2, 18, 18, PR_TRUE, kPersonalCmd+1, "Stocks", "http://personalfinance.netscape.com/finance/", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif"}, -{2, 18, 18, PR_TRUE, kPersonalCmd+2, "Weather", "http://www.weather.com", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif"}, -{2, 18, 18, PR_TRUE, kPersonalCmd+3, "Sports", "http://excite.netscape.com/sports/", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif"}, -{2, 18, 18, PR_TRUE, kPersonalCmd+4, "News", "http://home.netscape.com/news/index.html?cp=xpviewerDR1", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif"}, -{2, 18, 18, PR_TRUE, kPersonalCmd+5, "IMDB", "http://us.imdb.com/Title?You%27ve+Got+Mail+(1998)", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif", "TB_PersonalIcon.gif"}, -{0, 0, 0, PR_FALSE, 0, NULL, NULL, NULL, NULL, NULL} -}; - -char * gPersonalURLS[] = { "http://home.netscape.com/netcenter/whitepages.html?cp=xpviewerDR1", - "http://personalfinance.netscape.com/finance/", - "http://excite.netscape.com/weather/", - "http://excite.netscape.com/sports/", - "http://home.netscape.com/news/index.html?cp=xpviewerDR1", - "http://us.imdb.com/Title?You%27ve+Got+Mail+(1998)"}; - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -// prototypes -static nsEventStatus PR_CALLBACK HandleGUIEvent(nsGUIEvent *aEvent); -static void* GetItemsNativeData(nsISupports* aObject); - -//---------------------------------------------------------------------- -// Note: operator new zeros our memory -nsBrowserWindow::nsBrowserWindow() -{ - AddBrowser(this); -} - -//--------------------------------------------------------------- -nsBrowserWindow::~nsBrowserWindow() -{ -} - -NS_IMPL_ADDREF(nsBrowserWindow) -NS_IMPL_RELEASE(nsBrowserWindow) - -//---------------------------------------------------------------------- -nsresult -nsBrowserWindow::QueryInterface(const nsIID& aIID, - void** aInstancePtrResult) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - - *aInstancePtrResult = NULL; - - if (aIID.Equals(kIBrowserWindowIID)) { - *aInstancePtrResult = (void*) ((nsIBrowserWindow*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kIStreamObserverIID)) { - *aInstancePtrResult = (void*) ((nsIStreamObserver*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kIWebShellContainerIID)) { - *aInstancePtrResult = (void*) ((nsIWebShellContainer*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kINetSupportIID)) { - *aInstancePtrResult = (void*) ((nsINetSupport*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtrResult = (void*) ((nsISupports*)((nsIBrowserWindow*)this)); - NS_ADDREF_THIS(); - return NS_OK; - } - return NS_NOINTERFACE; -} - -//--------------------------------------------------------------- -static nsEventStatus PR_CALLBACK -HandleBrowserEvent(nsGUIEvent *aEvent) -{ - nsEventStatus result = nsEventStatus_eIgnore; - nsBrowserWindow* bw = nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_WINDOW); - - if (nsnull != bw) { - nsSizeEvent* sizeEvent; - switch(aEvent->message) { - case NS_SIZE: - sizeEvent = (nsSizeEvent*)aEvent; - bw->Layout(sizeEvent->windowSize->width, sizeEvent->windowSize->height); - result = nsEventStatus_eConsumeNoDefault; - break; - - case NS_DESTROY: - { - nsViewerApp* app = bw->mApp; - result = nsEventStatus_eConsumeDoDefault; - bw->Close(); - NS_RELEASE(bw); - - // XXX Really shouldn't just exit, we should just notify somebody... - if (0 == nsBrowserWindow::gBrowsers.Count()) { - app->Exit(); - } - } - return result; - - case NS_MENU_SELECTED: - result = bw->DispatchMenuItem(((nsMenuEvent*)aEvent)->mCommand); - break; - - // XXX This is a hack, but a needed one - // It draws one line between the layout window and the status bar - case NS_PAINT: - nsIWidget * statusWidget; - if (bw->mStatusBar && NS_OK == bw->mStatusBar->QueryInterface(kIWidgetIID,(void**)&statusWidget)) { - nsRect rect; - statusWidget->GetBounds(rect); - - nsRect r; - aEvent->widget->GetBounds(r); - r.x = 0; - r.y = 0; - nsIRenderingContext *drawCtx = ((nsPaintEvent*)aEvent)->renderingContext; - drawCtx->SetColor(NS_RGB(192, 192, 192));//aEvent->widget->GetBackgroundColor()); - rect.y -= 1; - drawCtx->DrawLine(0, rect.y, r.width, rect.y); - NS_RELEASE(statusWidget); - } break; - - default: - break; - } - NS_RELEASE(bw); - } - return result; -} - -// XXX -// Temporary way to execute JavaScript. Later the javascript -// will come through the content model. - -void nsBrowserWindow::ExecuteJavaScriptString(nsIWebShell* aWebShell, nsString& aJavaScript) -{ - nsAutoString retval; - PRBool isUndefined; - - NS_ASSERTION(nsnull != aWebShell, "null webshell passed to EvaluateJavaScriptString"); -// NS_ASSERTION(nsnull != aJavaScript, "null javascript string passed to EvaluateJavaScriptString"); - static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_IID); - - // Get nsIScriptContextOwner - nsIScriptContextOwner* scriptContextOwner; - if (NS_OK == aWebShell->QueryInterface(kIScriptContextOwnerIID,(void**)&scriptContextOwner)) { - const char* url = ""; - // Get nsIScriptContext - nsIScriptContext* scriptContext; - nsresult res = scriptContextOwner->GetScriptContext(&scriptContext); - if (NS_OK == res) { - // Ask the script context to evalute the javascript string - scriptContext->EvaluateString(aJavaScript, - url, 0, retval, &isUndefined); - - NS_RELEASE(scriptContext); - } - NS_RELEASE(scriptContextOwner); - } -} - - -//---------------------------------------------------------------------- -nsresult -nsBrowserWindow::Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, - const nsRect& aBounds, - PRUint32 aChromeMask, - PRBool aAllowPlugins) -{ - mChromeMask = aChromeMask; - mAppShell = aAppShell; - mPrefs = aPrefs; - mAllowPlugins = aAllowPlugins; - - // Create top level window - nsresult rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, - (void**)&mWindow); - if (NS_OK != rv) { - return rv; - } - - nsWidgetInitData initData; - initData.mBorderStyle = eBorderStyle_window; - - nsRect r(0, 0, aBounds.width, aBounds.height); - mWindow->Create((nsIWidget*)NULL, r, HandleBrowserEvent, nsnull, aAppShell, nsnull, &initData); - mWindow->GetClientBounds(r); - mWindow->SetBackgroundColor(NS_RGB(192,192,192)); - - // Create web shell - rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, - kIWebShellIID, - (void**)&mWebShell); - if (NS_OK != rv) { - return rv; - } - r.x = r.y = 0; - rv = mWebShell->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET), - r.x, r.y, r.width, r.height, - nsScrollPreference_kAuto, - aAllowPlugins, PR_TRUE); - mWebShell->SetContainer((nsIWebShellContainer*) this); - mWebShell->SetObserver((nsIStreamObserver*)this); - mWebShell->SetPrefs(aPrefs); - mWebShell->Show(); - - if (NS_CHROME_MENU_BAR_ON & aChromeMask) { - rv = CreateMenuBar(r.width); - if (NS_OK != rv) { - return rv; - } - mWindow->GetClientBounds(r); - r.x = r.y = 0; - } - - if (NS_CHROME_TOOL_BAR_ON & aChromeMask) { - rv = CreateToolBar(r.width); - if (NS_OK != rv) { - return rv; - } - } - - if (NS_CHROME_STATUS_BAR_ON & aChromeMask) { - rv = CreateStatusBar(r.width); - if (NS_OK != rv) { - return rv; - } - } - - // Now lay it all out - Layout(r.width, r.height); - - - return NS_OK; -} - - -//--------------------------------------------------------------- -// XXX This is needed for now, but I will be putting a listener on the text widget -// eventually this will be replaced with and formal "URLBar" implementation -static nsEventStatus PR_CALLBACK -HandleLocationEvent(nsGUIEvent *aEvent) -{ - nsEventStatus result = nsEventStatus_eIgnore; - nsBrowserWindow* bw = nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_LOCATION); - if (nsnull != bw) { - switch (aEvent->message) { - case NS_KEY_UP: - if (NS_VK_RETURN == ((nsKeyEvent*)aEvent)->keyCode) { - nsAutoString text; - PRUint32 size; - bw->mLocation->GetText(text, 1000, size); - bw->GoTo(text); - } - break; - default: - break; - } - NS_RELEASE(bw); - } - return result; -} - -//----------------------------------------------------------------- -nsBrowserWindow* -nsBrowserWindow::FindBrowserFor(nsIWidget* aWidget, PRIntn aWhich) -{ - nsIWidget* widget; - nsBrowserWindow* result = nsnull; - - PRInt32 i, n = gBrowsers.Count(); - for (i = 0; i < n; i++) { - nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers.ElementAt(i); - if (nsnull != bw) { - switch (aWhich) { - case FIND_WINDOW: - bw->mWindow->QueryInterface(kIWidgetIID, (void**) &widget); - if (widget == aWidget) { - result = bw; - } - NS_IF_RELEASE(widget); - break; - - case FIND_LOCATION: - if (bw->mLocation) { - bw->mLocation->QueryInterface(kIWidgetIID, (void**) &widget); - if (widget == aWidget) { - result = bw; - } - NS_IF_RELEASE(widget); - } - break; - } - } - } - - if (nsnull != result) { - NS_ADDREF(result); - } - - return result; -} - -//--------------------------------------------------------- -nsBrowserWindow* -nsBrowserWindow::FindBrowserFor(nsIWidget* aWidget) -{ - nsBrowserWindow* widgetBrowser; - nsBrowserWindow* result = nsnull; - - if (NS_OK != aWidget->GetClientData((void *&)widgetBrowser)) { - return NULL; - } - - PRInt32 i, n = gBrowsers.Count(); - for (i = 0; i < n; i++) { - nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers.ElementAt(i); - if (nsnull != bw && widgetBrowser == bw) { - result = bw; - } - } - - if (nsnull != result) { - NS_ADDREF(result); - } - return result; -} - -//--------------------------------------------------------- -void -nsBrowserWindow::AddBrowser(nsBrowserWindow* aBrowser) -{ - gBrowsers.AppendElement(aBrowser); - NS_ADDREF(aBrowser); -} - -//--------------------------------------------------------- -void -nsBrowserWindow::RemoveBrowser(nsBrowserWindow* aBrowser) -{ - nsViewerApp* app = aBrowser->mApp; - gBrowsers.RemoveElement(aBrowser); - NS_RELEASE(aBrowser); -} - -//--------------------------------------------------------- -void -nsBrowserWindow::CloseAllWindows() -{ - while (0 != gBrowsers.Count()) { - nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers.ElementAt(0); - NS_ADDREF(bw); - bw->Close(); - NS_RELEASE(bw); - } - gBrowsers.Clear(); -} - - -//--------------------------------------------------------------- -void -nsBrowserWindow::UpdateToolbarBtns() -{ - if (nsnull != mToolbarBtns) { - mToolbarBtns[gBackBtnInx]->Enable(mWebShell->CanBack() == NS_OK); - mToolbarBtns[gBackBtnInx]->Invalidate(PR_TRUE); - mToolbarBtns[gForwardBtnInx]->Enable(mWebShell->CanForward() == NS_OK); - mToolbarBtns[gForwardBtnInx]->Invalidate(PR_TRUE); - } -} - -//--------------------------------------------------------------- -// -nsEventStatus -nsBrowserWindow::DispatchMenuItem(PRInt32 aID) -{ -#ifdef NS_DEBUG - nsEventStatus result = DispatchDebugMenu(aID); - if (nsEventStatus_eIgnore != result) { - return result; - } -#endif - switch (aID) { - case VIEWER_EXIT: - mApp->Exit(); - return nsEventStatus_eConsumeNoDefault; - - case VIEWER_COMM_NAV: - case VIEWER_WINDOW_OPEN: - mApp->OpenWindow(); - break; - - case VIEWER_FILE_OPEN: - DoFileOpen(); - break; - - case VIEWER_FILE_VIEW_SOURCE: - DoViewSource(); - break; - - case VIEWER_TOP100: - DoSiteWalker(); - break; - - case VIEWER_EDIT_COPY: - DoCopy(); - break; - - case VIEWER_EDIT_SELECTALL: - DoSelectAll(); - break; - - case VIEWER_EDIT_FINDINPAGE: - DoFind(); - break; - - case VIEWER_DEMO0: - case VIEWER_DEMO1: - case VIEWER_DEMO2: - case VIEWER_DEMO3: - case VIEWER_DEMO4: - case VIEWER_DEMO5: - case VIEWER_DEMO6: - case VIEWER_DEMO7: - case VIEWER_DEMO8: - case VIEWER_DEMO9: { - PRIntn ix = aID - VIEWER_DEMO0; - nsAutoString url(SAMPLES_BASE_URL); - url.Append("/test"); - url.Append(ix, 10); - url.Append(".html"); - mWebShell->LoadURL(url); - - UpdateToolbarBtns(); - } break; - case JS_CONSOLE: - DoJSConsole(); - break; - - case EDITOR_MODE: - DoEditorMode(mWebShell); - break; - } //switch - - return nsEventStatus_eIgnore; -} - -//--------------------------------------------------------------- -void -nsBrowserWindow::Back() -{ - //XXX use javascript instead of mWebShell->Back(); - nsString str("window.back();"); - ExecuteJavaScriptString(mWebShell, str); - printf("Back executed using JavaScript"); -} - -//--------------------------------------------------------------- -void -nsBrowserWindow::Forward() -{ - //XXX use javascript instead of mWebShell->Forward(); - nsString str("window.forward();"); - ExecuteJavaScriptString(mWebShell, str); -} - -//--------------------------------------------------------------- -void -nsBrowserWindow::GoTo(const PRUnichar* aURL) -{ - mWebShell->LoadURL(aURL); - UpdateToolbarBtns(); -} - -#define FILE_PROTOCOL "file://" - -//--------------------------------------------------------------- -static PRBool GetFileNameFromFileSelector(nsIWidget* aParentWindow, - nsString* aFileName) -{ - PRBool selectedFileName = PR_FALSE; - nsIFileWidget *fileWidget; - nsString title("Open HTML"); - nsresult rv = nsComponentManager::CreateInstance(kFileWidgetCID, - nsnull, - kIFileWidgetIID, - (void**)&fileWidget); - if (NS_OK == rv) { - nsString titles[] = {"all files","html" }; - nsString filters[] = {"*.*", "*.html"}; - fileWidget->SetFilterList(2, titles, filters); - fileWidget->Create(aParentWindow, title, eMode_load, nsnull, nsnull); - - PRUint32 result = fileWidget->Show(); - if (result) { - fileWidget->GetFile(*aFileName); - selectedFileName = PR_TRUE; - } - - NS_RELEASE(fileWidget); - } - - return selectedFileName; -} - -//----------------------------------------------------- -void -nsBrowserWindow::DoFileOpen() -{ - nsAutoString fileName; - char szFile[1000]; - if (GetFileNameFromFileSelector(mWindow, &fileName)) { - fileName.ToCString(szFile, sizeof(szFile)); - PRInt32 len = strlen(szFile); - PRInt32 sum = len + sizeof(FILE_PROTOCOL); - char* lpszFileURL = new char[sum]; - - // Translate '\' to '/' - for (PRInt32 i = 0; i < len; i++) { - if (szFile[i] == '\\') { - szFile[i] = '/'; - } - } - - // Build the file URL - PR_snprintf(lpszFileURL, sum, "%s%s", FILE_PROTOCOL, szFile); - - // Ask the Web widget to load the file URL - mWebShell->LoadURL(nsString(lpszFileURL)); - delete[] lpszFileURL; - } -} - -//----------------------------------------------------- -void -nsBrowserWindow::DoViewSource() -{ - // Ask the app shell to open a "view source window" for this window's URL. - PRInt32 theIndex; - PRUnichar *theURL; - if ( // Get the history index for this page. - NS_OK == mWebShell->GetHistoryIndex(theIndex) - && - // Get the URL for that index. - NS_OK == mWebShell->GetURL(theIndex,&theURL) ) { - // Tell the app to open the source for this URL. - mApp->ViewSourceFor(theURL); - //XXX Find out how theURL is allocated, and perhaps delete it... - } else { - // FE_Alert! - } -} - -#define DIALOG_FONT "Helvetica" -#define DIALOG_FONT_SIZE 10 - -/**-------------------------------------------------------------------------------- - * Main Handler - *-------------------------------------------------------------------------------- - */ -nsEventStatus PR_CALLBACK HandleGUIEvent(nsGUIEvent *aEvent) -{ - //printf("HandleGUIEvent aEvent->message %d\n", aEvent->message); - nsEventStatus result = nsEventStatus_eIgnore; - if (aEvent == nsnull || aEvent->widget == nsnull) { - return result; - } - - void * data; - aEvent->widget->GetClientData(data); - - if (data == nsnull) { - nsIWidget * parent = aEvent->widget->GetParent(); - if (parent != nsnull) { - parent->GetClientData(data); - NS_RELEASE(parent); - } - } - - if (data != nsnull) { - nsBrowserWindow * browserWindow = (nsBrowserWindow *)data; - result = browserWindow->ProcessDialogEvent(aEvent); - } - - return result; -} - - - -//--------------------------------------------------------------- -static void* GetItemsNativeData(nsISupports* aObject) -{ - void* result = nsnull; - nsIWidget* widget; - if (NS_OK == aObject->QueryInterface(kIWidgetIID,(void**)&widget)) { - result = widget->GetNativeData(NS_NATIVE_WIDGET); - NS_RELEASE(widget); - } - return result; -} - -//-------------------------------------------------------------------------------- -// Main Dialog Handler -// XXX This is experimental code, it will change a lot when we have XML/HTML dialogs -nsEventStatus nsBrowserWindow::ProcessDialogEvent(nsGUIEvent *aEvent) -{ - nsEventStatus result = nsEventStatus_eIgnore; - - //printf("aEvent->message %d\n", aEvent->message); - switch(aEvent->message) { - - case NS_KEY_DOWN: { - nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; - if (NS_VK_RETURN == keyEvent->keyCode) { - PRBool matchCase = PR_FALSE; - mMatchCheckBtn->GetState(matchCase); - PRBool findDwn = PR_FALSE; - mDwnRadioBtn->GetState(findDwn); - nsString searchStr; - PRUint32 actualSize; - mTextField->GetText(searchStr, 255,actualSize); - - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - PRBool foundIt = PR_FALSE; - doc->FindNext(searchStr, matchCase, findDwn, foundIt); - if (!foundIt) { - // Display Dialog here - } - ForceRefresh(); - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } - } - } break; - - case NS_MOUSE_LEFT_BUTTON_UP: { - nsIWidget* dialogWidget = nsnull; - if (NS_OK != mDialog->QueryInterface(kIWidgetIID,(void**)&dialogWidget)) - break; - - if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetItemsNativeData(mCancelBtn)) { - dialogWidget->Show(PR_FALSE); - } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetItemsNativeData(mFindBtn)) { - - PRBool matchCase = PR_FALSE; - mMatchCheckBtn->GetState(matchCase); - PRBool findDwn = PR_FALSE; - mDwnRadioBtn->GetState(findDwn); - PRUint32 actualSize; - nsString searchStr; - mTextField->GetText(searchStr, 255,actualSize); - - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - PRBool foundIt = PR_FALSE; - doc->FindNext(searchStr, matchCase, findDwn, foundIt); - if (!foundIt) { - // Display Dialog here - } - ForceRefresh(); - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } - - } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetItemsNativeData(mUpRadioBtn)) { - mUpRadioBtn->SetState(PR_TRUE); - mDwnRadioBtn->SetState(PR_FALSE); - } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetItemsNativeData(mDwnRadioBtn)) { - mDwnRadioBtn->SetState(PR_TRUE); - mUpRadioBtn->SetState(PR_FALSE); - } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetItemsNativeData(mMatchCheckBtn)) { - PRBool state = PR_FALSE; - mMatchCheckBtn->GetState(state); - mMatchCheckBtn->SetState(!state); - } - } break; - - case NS_PAINT: -#ifndef XP_UNIX - // paint the background - if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetItemsNativeData(mDialog)) { - nsIRenderingContext *drawCtx = ((nsPaintEvent*)aEvent)->renderingContext; - drawCtx->SetColor(aEvent->widget->GetBackgroundColor()); - drawCtx->FillRect(*(((nsPaintEvent*)aEvent)->rect)); - - return nsEventStatus_eIgnore; - } -#endif - break; - - case NS_DESTROY: { - mStatusAppBarWidget->Show(PR_TRUE); - mStatusBar->DoLayout(); - NS_RELEASE(mAppsDialog); - - PRInt32 i; - for (i=0;iGetDocument(); - if (nsnull != doc) { - PRBool foundIt = PR_FALSE; - doc->FindNext(aSearchStr, aMatchCase, aSearchDown, aIsFound); - if (!foundIt) { - // Display Dialog here - } - ForceRefresh(); - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } - return NS_OK; -} - -//--------------------------------------------------------------- -NS_IMETHODIMP nsBrowserWindow::ForceRefresh() -{ - mWindow->Invalidate(PR_TRUE); - mWebShell->Repaint(PR_TRUE); - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIViewManager* vm = shell->GetViewManager(); - if (nsnull != vm) { - nsIView* root; - vm->GetRootView(root); - if (nsnull != root) { - vm->UpdateView(root, (nsIRegion*)nsnull, NS_VMREFRESH_IMMEDIATE); - } - NS_RELEASE(vm); - } - NS_RELEASE(shell); - } - return NS_OK; -} - - - -//--------------------------------------------------------------- -void nsBrowserWindow::DoFind() -{ - if (mXPDialog) { - NS_RELEASE(mXPDialog); - //mXPDialog->SetVisible(PR_TRUE); - //return; - } - - nsString findHTML("resource:/res/samples/find.html"); - //nsString findHTML("resource:/res/samples/find-table.html"); - nsRect rect(0, 0, 510, 170); - //nsRect rect(0, 0, 470, 126); - nsString title("Find"); - - nsXPBaseWindow * dialog = nsnull; - nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, - kIXPBaseWindowIID, - (void**) &dialog); - if (rv == NS_OK) { - dialog->Init(eXPBaseWindowType_dialog, mAppShell, nsnull, findHTML, title, rect, PRUint32(~0), PR_FALSE); - dialog->SetVisible(PR_TRUE); - if (NS_OK == dialog->QueryInterface(kIXPBaseWindowIID, (void**) &mXPDialog)) { - } - } - - nsFindDialog * findDialog = new nsFindDialog(this); - if (nsnull != findDialog) { - dialog->AddWindowListener(findDialog); - } - //NS_IF_RELEASE(dialog); - -} - -//--------------------------------------------------------------- -void -nsBrowserWindow::DoSelectAll() -{ - - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - doc->SelectAll(); - ForceRefresh(); - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } -} - - -// XXX This sort of thing should be in a resource -#define TOOL_BAR_FONT "Helvetica" -#define TOOL_BAR_FONT_SIZE 12 -#define STATUS_BAR_FONT "Helvetica" -#define STATUS_BAR_FONT_SIZE 10 - - -//------------------------------------------------------------------ -// This method needs to be moved into nsWidgetSupport -nsresult -NS_CreateImageButton(nsISupports *aParent, - nsIImageButton *&aButton, - nsIWidget *&aButtonWidget, - const nsString &aLabel, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont *aFont, - const nsString &aBaseURL, - const nsString &aUpURL, - const nsString &aPressedURL, - const nsString &aDisabledURL, - const nsString &aRollOverURL, - PRInt32 anImageWidth, - PRInt32 anImageHeight - ) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) { - aParent->QueryInterface(kIWidgetIID,(void**)&parent); - } else { - return NS_ERROR_FAILURE; - } - - // Create MenuButton - nsresult rv = nsComponentManager::CreateInstance(kImageButtonCID, nsnull, kIImageButtonIID, - (void**)&aButton); - if (NS_OK != rv) { - return rv; - } - - if (NS_OK == aButton->QueryInterface(kIWidgetIID,(void**)&aButtonWidget)) { - aButtonWidget->Create(parent, aRect, aHandleEventFunction, NULL); - aButtonWidget->Show(PR_TRUE); - if (aFont != nsnull) - aButtonWidget->SetFont(*aFont); - } - - aButton->SetLabel(aLabel); - aButton->SetShowText(aLabel.Length() > 0); - aButton->SetShowButtonBorder(PR_TRUE); - aButton->SetImageDimensions(anImageWidth, anImageHeight); - - // Load URLs - if (aBaseURL.Length() > 0) { - nsString upURL(aBaseURL); - nsString pressedURL(aBaseURL); - nsString disabledURL(aBaseURL); - nsString rolloverURL(aBaseURL); - - upURL.Append(aUpURL); - pressedURL.Append(aPressedURL); - disabledURL.Append(aDisabledURL); - rolloverURL.Append(aRollOverURL); - - aButton->SetImageURLs(upURL, pressedURL, disabledURL, rolloverURL); - } else { - aButton->SetShowImage(PR_FALSE); - } - - NS_IF_RELEASE(parent); - - return NS_OK; -} - -//------------------------------------------------------------------ -// XXX This method needs to be moved into nsWidgetSupport -nsresult -NS_CreateMenuButton(nsISupports *aParent, - nsIMenuButton *&aButton, - nsIWidget *&aButtonWidget, - const nsString &aLabel, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont *aFont, - const nsString &aBaseURL, - const nsString &aUpURL, - const nsString &aPressedURL, - const nsString &aDisabledURL, - const nsString &aRollOverURL, - PRInt32 anImageWidth, - PRInt32 anImageHeight) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) { - aParent->QueryInterface(kIWidgetIID,(void**)&parent); - } else { - return NS_ERROR_FAILURE; - } - - // Create MenuButton - nsresult rv = nsComponentManager::CreateInstance(kMenuButtonCID, nsnull, kIMenuButtonIID, - (void**)&aButton); - if (NS_OK != rv) { - return rv; - } - - if (NS_OK == aButton->QueryInterface(kIWidgetIID,(void**)&aButtonWidget)) { - aButtonWidget->Create(parent, aRect, aHandleEventFunction, NULL); - aButtonWidget->Show(PR_TRUE); - if (aFont != nsnull) - aButtonWidget->SetFont(*aFont); - } - - aButton->SetLabel(aLabel); - aButton->SetShowText(aLabel.Length() > 0); - aButton->SetShowButtonBorder(PR_TRUE); - aButton->SetImageDimensions(anImageWidth, anImageHeight); - - // Load URLs - if (aBaseURL.Length() > 0) { - nsString upURL(aBaseURL); - nsString pressedURL(aBaseURL); - nsString disabledURL(aBaseURL); - nsString rolloverURL(aBaseURL); - - upURL.Append(aUpURL); - pressedURL.Append(aPressedURL); - disabledURL.Append(aDisabledURL); - rolloverURL.Append(aRollOverURL); - - aButton->SetImageURLs(upURL, pressedURL, disabledURL, rolloverURL); - aButton->SetShowImage(PR_TRUE); - } else { - aButton->SetShowImage(PR_FALSE); - } - - NS_IF_RELEASE(parent); - - return NS_OK; -} - -//----------------------------------------------------------- -// XXX This method needs to be moved into nsWidgetSupport -nsresult -nsBrowserWindow::AddToolbarItem(nsIToolbar *aToolbar, - PRInt32 aGap, - PRBool aEnable, - nsIWidget * aButtonWidget) -{ - - // Create the generic toolbar holder for widget - nsIToolbarItemHolder * toolbarItemHolder; - nsresult rv = nsComponentManager::CreateInstance(kToolbarItemHolderCID, nsnull, kIToolbarItemHolderIID, - (void**)&toolbarItemHolder); - if (NS_OK != rv) { - return rv; - } - - // Get the ToolbarItem interface for adding it to the toolbar - nsIToolbarItem * toolbarItem; - if (NS_OK != toolbarItemHolder->QueryInterface(kIToolbarItemIID,(void**)&toolbarItem)) { - return NS_OK; - } - - // Set client data for callback purposes - aButtonWidget->SetClientData(this); - - aButtonWidget->Enable(aEnable); - - // Add to widget to item holder - toolbarItemHolder->SetWidget(aButtonWidget); - - // Add item holder to toolbar - aToolbar->AddItem(toolbarItem, aGap, PR_FALSE); - - NS_RELEASE(toolbarItem); - NS_RELEASE(toolbarItemHolder); - - - return NS_OK; -} - - -//----------------------------------------------------------- -// -void -nsBrowserWindow::DoAppsDialog() -{ - if (mAppsDialog == nsnull) { - nscoord txtHeight = 24; - nscolor textBGColor = NS_RGB(0, 0, 0); - nscolor textFGColor = NS_RGB(255, 255, 255); - - nsILookAndFeel * lookAndFeel; - if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { - lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); - lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); - NS_RELEASE(lookAndFeel); - } - - nsIDeviceContext* dc = mWindow->GetDeviceContext(); - float t2d; - dc->GetTwipsToDevUnits(t2d); - nsFont font(DIALOG_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NSIntPointsToTwips(DIALOG_FONT_SIZE))); - NS_RELEASE(dc); - - // create a Dialog - // - nsRect rect(0, 0, (40*4)+8, 23+31); - - nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mAppsDialog); - nsIWidget* widget = nsnull; - NS_CreateDialog(mWindow, mAppsDialog, rect, HandleGUIEvent, &font); - if (NS_OK == mAppsDialog->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->SetClientData(this); - widget->Resize(rect.x, rect.y, rect.width, rect.height, PR_TRUE); - NS_RELEASE(widget); - } - mAppsDialog->SetLabel(""); - - nsString label(""); - nsString baseURL("resource:/res/toolbar/"); - - // Count number of buttons and create array to hold them - mNumAppsDialogBtns = 0; - while (gMiniAppsDialogInfo[mNumAppsDialogBtns].mImgWidth > 0) { - mNumAppsDialogBtns++; - } - mAppsDialogBtns = (nsIWidget **)new PRInt32[mNumAppsDialogBtns]; - - // Create buttons - PRInt32 i = 0; - PRInt32 x = 2; - while (gMiniAppsDialogInfo[i].mImgWidth > 0) { - nsIImageButton * btn; - nsIWidget * widget; - rect.SetRect(x, 2, gMiniAppsDialogInfo[i].mImgWidth+4, gMiniAppsDialogInfo[i].mImgHeight+4); - NS_CreateImageButton(mAppsDialog, btn, widget, gMiniAppsDialogInfo[i].mLabel, - rect, nsnull, - &font, baseURL, - gMiniAppsDialogInfo[i].mUpName, - gMiniAppsDialogInfo[i].mPressedName, - gMiniAppsDialogInfo[i].mDisabledName, - gMiniAppsDialogInfo[i].mRolloverName, - gMiniAppsDialogInfo[i].mImgWidth, - gMiniAppsDialogInfo[i].mImgHeight); - btn->SetShowText(PR_FALSE); - btn->SetCommand(gMiniAppsDialogInfo[i].mCommand); - btn->SetRollOverDesc(gMiniAppsDialogInfo[i].mRollOverDesc); - btn->AddListener(this); - mAppsDialogBtns[i] = widget; - widget->Enable(gMiniAppsDialogInfo[i].mEnabled); - - NS_RELEASE(btn); - x += 40; - i++; - } - - } - mDialog = mAppsDialog; -} - -//------------------------------------------------------------------- -nsresult -nsBrowserWindow::CreateToolBar(PRInt32 aWidth) -{ - nsresult rv; - - nscoord txtHeight = 24; - nscolor textFGColor = NS_RGB(0, 0, 0); - nscolor textBGColor = NS_RGB(255, 255, 255); - nscolor windowBGColor = NS_RGB(192, 192, 192); - nscolor widgetBGColor = NS_RGB(192, 192, 192); - - nsILookAndFeel * lookAndFeel; - if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { - lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); - lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, widgetBGColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, windowBGColor); - NS_RELEASE(lookAndFeel); - } - - PRInt32 imageWidth = 23; - PRInt32 imageHeight = 21; - - nsIDeviceContext* dc = mWindow->GetDeviceContext(); - float t2d; - dc->GetTwipsToDevUnits(t2d); - nsFont font(TOOL_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NSIntPointsToTwips(TOOL_BAR_FONT_SIZE))); - NS_RELEASE(dc); - - //---------------------------------------------------- - // Create Toolbar Manager - //---------------------------------------------------- - rv = nsComponentManager::CreateInstance(kToolbarManagerCID, nsnull, kIToolbarManagerIID, - (void**)&mToolbarMgr); - if (NS_OK != rv) { - return rv; - } - nsIWidget * toolbarMgrWidget; - nsRect rr(0, 0, 200, 32); - if (NS_OK != mToolbarMgr->QueryInterface(kIWidgetIID,(void**)&toolbarMgrWidget)) { - return rv; - } - toolbarMgrWidget->Create(mWindow, rr, nsnull, NULL); - toolbarMgrWidget->SetBackgroundColor(windowBGColor); - toolbarMgrWidget->Show(PR_TRUE); - - mToolbarMgr->AddToolbarListener(this); - mToolbarMgr->SetCollapseTabURLs("resource:/res/toolbar/TB_Tab.gif", "resource:/res/toolbar/TB_Tab.gif", "resource:/res/toolbar/TB_Tab.gif", "resource:/res/toolbar/TB_Tab_mo.gif"); - mToolbarMgr->SetExpandTabURLs("resource:/res/toolbar/TB_HTab.gif", "resource:/res/toolbar/TB_HTab.gif", "resource:/res/toolbar/TB_HTab.gif", "resource:/res/toolbar/TB_HTab_mo.gif"); - - //---------------------------------------------------- - // Create Button Toolbar - //---------------------------------------------------- - rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, - (void**)&mBtnToolbar); - if (NS_OK != rv) { - return rv; - } - - nsIWidget * toolbarWidget; - nsRect rrr(0, 0, 200, 32); - if (NS_OK != mBtnToolbar->QueryInterface(kIWidgetIID,(void**)&toolbarWidget)) { - return rv; - } - mBtnToolbar->SetMargin(1); - mBtnToolbar->SetHGap(2); - - toolbarWidget->Create(toolbarMgrWidget, rrr, nsnull, NULL); - toolbarWidget->SetBackgroundColor(windowBGColor); - toolbarWidget->Show(PR_TRUE); - mToolbarMgr->AddToolbar(mBtnToolbar); - - nsIWidget * tab = nsnull; -// mBtnToolbar->CreateTab(tab); - NS_IF_RELEASE(tab); - - - gBtnWidth = 54; - gBtnHeight = 42; - - nsRect r(0, 0, gBtnWidth, gBtnHeight); - nsIWidget* widget = nsnull; - - nsString baseURL("resource:/res/toolbar/"); - - // Count number of buttons and create array to hold them - mNumToolbarBtns = 0; - while (gBtnToolbarInfo[mNumToolbarBtns].mImgWidth > 0) { - mNumToolbarBtns++; - } - mToolbarBtns = (nsIWidget **)new PRInt32[mNumToolbarBtns]; - - nsRect rect(0,0, 54, 42); - PRInt32 width, height; - - // Create buttons - PRInt32 i = 0; - while (gBtnToolbarInfo[i].mImgWidth > 0) { - nsIMenuButton * btn; - nsIWidget * widget; - NS_CreateMenuButton(mBtnToolbar, btn, widget, gBtnToolbarInfo[i].mLabel, - rect, nsnull, - &font, baseURL, - gBtnToolbarInfo[i].mUpName, - gBtnToolbarInfo[i].mPressedName, - gBtnToolbarInfo[i].mDisabledName, - gBtnToolbarInfo[i].mRolloverName, - gBtnToolbarInfo[i].mImgWidth, - gBtnToolbarInfo[i].mImgHeight); - AddToolbarItem(mBtnToolbar, gBtnToolbarInfo[i].mGap, gBtnToolbarInfo[i].mEnabled, widget); - btn->SetBorderOffset(1); - btn->SetCommand(gBtnToolbarInfo[i].mCommand); - btn->SetRollOverDesc(gBtnToolbarInfo[i].mRollOverDesc); - btn->AddListener(this); - widget->SetBackgroundColor(widgetBGColor); - widget->GetPreferredSize(width, height); - widget->SetPreferredSize(54, height); - widget->Resize(0,0, 54, height,PR_FALSE); - mToolbarBtns[i] = widget; - rect.x += 40; - i++; - NS_RELEASE(btn); - } - mBtnToolbar->SetWrapping(PR_TRUE); - toolbarWidget->GetPreferredSize(width, height); - toolbarWidget->SetPreferredSize(width, height); - toolbarWidget->Resize(0,0,width, height,PR_FALSE); - - // Create and place throbber - r.SetRect(aWidth - THROBBER_WIDTH, 0, - THROBBER_WIDTH, THROBBER_HEIGHT); - rv = nsComponentManager::CreateInstance(kThrobberCID, nsnull, kIThrobberIID, - (void**)&mThrobber); - if (NS_OK != rv) { - return rv; - } - //mBtnToolbar->SetThrobber(mThrobber); - nsString throbberURL("resource:/res/throbber/LargeAnimation%02d.gif"); - mThrobber->Init(toolbarWidget, r, throbberURL, 38); - - nsIToolbarItem * toolbarItem; - if (NS_OK != mThrobber->QueryInterface(kIToolbarItemIID,(void**)&toolbarItem)) { - return NS_OK; - } - - mBtnToolbar->AddItem(toolbarItem, 10, PR_FALSE); - NS_RELEASE(toolbarItem); - - mThrobber->Show(); - - mBtnToolbar->SetLastItemIsRightJustified(PR_TRUE); - NS_IF_RELEASE(toolbarWidget); - - //---------------------------------------------------- - // Create URL Toolbar - //---------------------------------------------------- - rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, - (void**)&mURLToolbar); - if (NS_OK != rv) { - return rv; - } - nsIWidget * urlToolbarWidget; - if (NS_OK != mURLToolbar->QueryInterface(kIWidgetIID,(void**)&urlToolbarWidget)) { - return rv; - } - mURLToolbar->SetMargin(1); - mURLToolbar->SetHGap(2); - - urlToolbarWidget->Create(toolbarMgrWidget, rr, nsnull, NULL); - urlToolbarWidget->SetBackgroundColor(windowBGColor); - urlToolbarWidget->Show(PR_TRUE); - mToolbarMgr->AddToolbar(mURLToolbar); - - tab = nsnull; -// mURLToolbar->CreateTab(tab); - NS_IF_RELEASE(tab); - - - //------ - // Create and place Bookmark button - //------ - rv = nsComponentManager::CreateInstance(kImageButtonCID, nsnull, kIImageButtonIID, - (void**)&mBookmarks); - if (NS_OK != rv) { - return rv; - } - r.SetRect(0, 0, 105, 22); - - // Create Bookmarks Menu Btn - if (NS_OK == NS_CreateMenuButton(mURLToolbar, mBookmarks, mBookmarksWidget, "Bookmarks", - r, nsnull, &font, baseURL, - "TB_Bookmarks.gif", "TB_Bookmarks.gif", "TB_Bookmarks.gif", "TB_Bookmarks_mo.gif", - 30, 18)) { - AddToolbarItem(mURLToolbar, 10, PR_FALSE, mBookmarksWidget); - mBookmarksWidget->SetBackgroundColor(widgetBGColor); - mBookmarks->SetCommand(kBookmarksCmd); - mBookmarks->SetRollOverDesc("Bookmarks functions"); - mBookmarks->AddListener(this); - mBookmarks->SetImageVerticalAlignment(eButtonVerticalAligment_Center); - mBookmarks->SetImageHorizontalAlignment(eButtonHorizontalAligment_Left); - mBookmarks->SetTextVerticalAlignment(eButtonVerticalAligment_Center); - mBookmarks->SetTextHorizontalAlignment(eButtonHorizontalAligment_Right); -#ifdef XP_WIN - mBookmarks->AddMenuItem("Add Bookmark", 3000); -#endif - } - - // Create location icon - r.SetRect(0, 0, 18, 18); - if (NS_OK == NS_CreateImageButton(mURLToolbar, mLocationIcon, mLocationIconWidget, "", - r, nsnull, &font, baseURL, - "TB_Location.gif", "TB_Location.gif", "TB_Location.gif", "TB_Location_mo.gif", - 16, 16)) { - AddToolbarItem(mURLToolbar, 10, PR_TRUE, mLocationIconWidget); - mLocationIconWidget->SetBackgroundColor(widgetBGColor); - mLocationIcon->SetRollOverDesc("Drag this location to Bookmarks"); - mLocationIcon->SetImageVerticalAlignment(eButtonVerticalAligment_Center); - mLocationIcon->SetImageHorizontalAlignment(eButtonHorizontalAligment_Middle); - mLocationIcon->SetShowBorder(PR_FALSE); - } - - // Create Location Label - nsIImageButton * locationLabel; - if (NS_OK == NS_CreateImageButton(mURLToolbar, locationLabel, widget, "Location:", - r, nsnull, &font, "", "", "", "", "", 0, 0)) { - - AddToolbarItem(mURLToolbar, 1, PR_TRUE, widget); - widget->SetBackgroundColor(widgetBGColor); - locationLabel->SetShowImage(PR_FALSE); - locationLabel->SetShowBorder(PR_FALSE); - locationLabel->SetTextVerticalAlignment(eButtonVerticalAligment_Center); - locationLabel->SetTextHorizontalAlignment(eButtonHorizontalAligment_Right); - - PRInt32 width, height; - widget->GetPreferredSize(width, height); - widget->SetPreferredSize(width, height); - widget->Resize(0,0, width, height, PR_FALSE); - NS_RELEASE(locationLabel); - NS_RELEASE(widget); - } - - // Create and place URL Text Field - r.SetRect(0, 0, 200, 24); - - rv = nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, - (void**)&mLocation); - if (NS_OK != rv) { - return rv; - } - - dc = mWindow->GetDeviceContext(); - dc->GetTwipsToDevUnits(t2d); - nsFont font2(TOOL_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NSIntPointsToTwips(TOOL_BAR_FONT_SIZE-2))); - NS_RELEASE(dc); - - NS_CreateTextWidget(urlToolbarWidget, mLocation, r, HandleLocationEvent, &font2); - if (NS_OK == mLocation->QueryInterface(kIWidgetIID,(void**)&mLocationWidget)) { - - AddToolbarItem(mURLToolbar, 2, PR_TRUE, mLocationWidget); - - mLocationWidget->SetPreferredSize(100, txtHeight); - mLocationWidget->SetForegroundColor(textFGColor); - mLocationWidget->SetBackgroundColor(textBGColor); - mLocationWidget->Show(PR_TRUE); - PRUint32 size; - mLocation->SetText("",size); - } - - // Create and place What's Related button - r.SetRect(0, 0, 123, 22); - if (NS_OK == NS_CreateMenuButton(mURLToolbar, mWhatsRelated, mWhatsRelatedWidget, "What's Related", - r, nsnull, &font, baseURL, - "TB_WhatsRelated.gif", "TB_WhatsRelated.gif", "TB_WhatsRelated.gif", "TB_WhatsRelated_mo.gif", - 27, 16)) { - AddToolbarItem(mURLToolbar, 2, PR_FALSE, mWhatsRelatedWidget); - mWhatsRelatedWidget->SetBackgroundColor(widgetBGColor); - mWhatsRelated->SetCommand(kWhatsRelatedCmd); - mWhatsRelated->SetRollOverDesc("View the \"What's Related\" list"); - mWhatsRelated->AddListener(this); - mWhatsRelated->SetImageVerticalAlignment(eButtonVerticalAligment_Center); - mWhatsRelated->SetImageHorizontalAlignment(eButtonHorizontalAligment_Left); - mWhatsRelated->SetTextVerticalAlignment(eButtonVerticalAligment_Center); - mWhatsRelated->SetTextHorizontalAlignment(eButtonHorizontalAligment_Right); - } - - mURLToolbar->SetLastItemIsRightJustified(PR_TRUE); - mURLToolbar->SetNextLastItemIsStretchy(PR_TRUE); - - - //---------------------------------------------- - // Load Personal Toolbar - //---------------------------------------------- - nsIToolbar * personalToolbar; - rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, - (void**)&personalToolbar); - if (NS_OK != rv) { - return rv; - } - - nsIWidget * personalToolbarWidget; - rrr.SetRect(0, 0, 200, 23); - if (NS_OK != personalToolbar->QueryInterface(kIWidgetIID,(void**)&personalToolbarWidget)) { - return rv; - } - personalToolbar->SetMargin(1); - personalToolbar->SetHGap(2); - personalToolbar->SetWrapping(PR_TRUE); - - personalToolbarWidget->Create(toolbarMgrWidget, rrr, nsnull, NULL); - personalToolbarWidget->SetBackgroundColor(windowBGColor); - personalToolbarWidget->Show(PR_TRUE); - mToolbarMgr->AddToolbar(personalToolbar); - - tab = nsnull; -// personalToolbar->CreateTab(tab); - NS_IF_RELEASE(tab); - - - // Count number of buttons and create array to hold them - mNumPersonalToolbarBtns = 0; - while (gPersonalToolbarInfo[mNumPersonalToolbarBtns].mImgWidth > 0) { - mNumPersonalToolbarBtns++; - } - mPersonalToolbarBtns = (nsIWidget **)new PRInt32[mNumPersonalToolbarBtns]; - - rect.SetRect(0,0, 100, 21); - - // Create buttons - i = 0; - while (gPersonalToolbarInfo[i].mImgWidth > 0) { - nsIImageButton * btn; - nsIWidget * widget; - NS_CreateImageButton(personalToolbar, btn, widget, gPersonalToolbarInfo[i].mLabel, - rect, nsnull, - &font, baseURL, - gPersonalToolbarInfo[i].mUpName, - gPersonalToolbarInfo[i].mPressedName, - gPersonalToolbarInfo[i].mDisabledName, - gPersonalToolbarInfo[i].mRolloverName, - gPersonalToolbarInfo[i].mImgWidth, - gPersonalToolbarInfo[i].mImgHeight); - - btn->SetImageVerticalAlignment(eButtonVerticalAligment_Center); - btn->SetImageHorizontalAlignment(eButtonHorizontalAligment_Left); - btn->SetTextVerticalAlignment(eButtonVerticalAligment_Center); - btn->SetTextHorizontalAlignment(eButtonHorizontalAligment_Right); - btn->SetCommand(gPersonalToolbarInfo[i].mCommand); - btn->SetRollOverDesc(gPersonalToolbarInfo[i].mRollOverDesc); - btn->AddListener(this); - - PRInt32 width, height; - widget->SetBackgroundColor(widgetBGColor); - widget->GetPreferredSize(width, height); - widget->SetPreferredSize(width, height); - widget->Resize(0, 0, width, height, PR_FALSE); - AddToolbarItem(personalToolbar, gPersonalToolbarInfo[i].mGap, gPersonalToolbarInfo[i].mEnabled, widget); - mPersonalToolbarBtns[i] = widget; - NS_RELEASE(btn); - i++; - } - NS_RELEASE(personalToolbar); - NS_RELEASE(personalToolbarWidget); - - //------ - NS_RELEASE(toolbarMgrWidget); - - return NS_OK; -} - -//----------------------------------------------------------- -nsresult -nsBrowserWindow::CreateStatusBar(PRInt32 aWidth) -{ - nsresult rv; - nscolor windowBGColor = NS_RGB(192, 192, 192); - nscolor widgetBGColor = NS_RGB(192, 192, 192); - - nsILookAndFeel * lookAndFeel; - if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, widgetBGColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, windowBGColor); - NS_RELEASE(lookAndFeel); - } - - nsIDeviceContext* dc = mWindow->GetDeviceContext(); - float t2d; - dc->GetTwipsToDevUnits(t2d); - nsFont font(STATUS_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NSIntPointsToTwips(STATUS_BAR_FONT_SIZE))); - NS_RELEASE(dc); - - //---------------------------------------------------- - // Create StatusBar as a Toolbar - //---------------------------------------------------- - rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, - (void**)&mStatusBar); - if (NS_OK != rv) { - return rv; - } - - nsIWidget * statusWidget; - nsRect rrr(0, 0, 200, 32); - if (NS_OK != mStatusBar->QueryInterface(kIWidgetIID,(void**)&statusWidget)) { - return rv; - } - mStatusBar->SetMargin(1); - mStatusBar->SetHGap(2); - mStatusBar->SetBorderType(eToolbarBorderType_none); - - statusWidget->Create(mWindow, rrr, nsnull, NULL); - statusWidget->SetBackgroundColor(windowBGColor); - statusWidget->Show(PR_TRUE); - - nsRect r(0, 0, 18, 16); - nsIWidget* widget = nsnull; - - nsString baseURL("resource:/res/toolbar/"); - - nsString insecureImg("StatusBar-insecure.gif"); - nsString secureImg("StatusBar-secure.gif"); - - if (NS_OK == NS_CreateImageButton(mStatusBar, mStatusSecurityLabel, widget, "", - r, nsnull, &font, baseURL, - insecureImg, insecureImg, secureImg, insecureImg, - 16, 14)) { - - AddToolbarItem(mStatusBar, 0, PR_TRUE, widget); - // Make button look depressed and always show border - mStatusSecurityLabel->SwapHighlightShadowColors(); - mStatusSecurityLabel->SetAlwaysShowBorder(PR_TRUE); - mStatusSecurityLabel->SetShowButtonBorder(PR_FALSE); - mStatusSecurityLabel->SetShowText(PR_FALSE); - mStatusSecurityLabel->SetBorderWidth(0); - mStatusSecurityLabel->SetBorderOffset(0); - mStatusSecurityLabel->SetImageVerticalAlignment(eButtonVerticalAligment_Center); - widget->SetBackgroundColor(widgetBGColor); - NS_RELEASE(widget); - } - - r.SetRect(0, 0, 96, 16); - if (NS_OK == NS_CreateImageButton(mStatusBar, mStatusProcess, widget, "", - r, nsnull, &font, "", - "", "", "", "", 0, 0)) { - - AddToolbarItem(mStatusBar, 2, PR_TRUE, widget); - // Make button look depressed and always show border - mStatusProcess->SwapHighlightShadowColors(); - mStatusProcess->SetAlwaysShowBorder(PR_TRUE); - mStatusProcess->SetShowButtonBorder(PR_FALSE); - mStatusProcess->SetShowText(PR_TRUE); - mStatusProcess->SetShowImage(PR_FALSE); - mStatusProcess->SetBorderOffset(0); - widget->SetBackgroundColor(widgetBGColor); - widget->SetPreferredSize(96, 16); - NS_RELEASE(widget); - } - - if (NS_OK == NS_CreateImageButton(mStatusBar, mStatusText, widget, "", - r, nsnull, &font, "", - "", "", "", "", 0,0)) { - - AddToolbarItem(mStatusBar, 2, PR_TRUE, widget); - // Make button look depressed and always show border - mStatusText->SwapHighlightShadowColors(); - mStatusText->SetAlwaysShowBorder(PR_TRUE); - mStatusText->SetShowButtonBorder(PR_FALSE); - mStatusText->SetBorderOffset(0); - // Set up to just display text - mStatusText->SetShowText(PR_TRUE); - mStatusText->SetShowImage(PR_FALSE); - mStatusText->SetTextHorizontalAlignment(eButtonHorizontalAligment_Left); - widget->SetBackgroundColor(widgetBGColor); - NS_RELEASE(widget); - } - - //---------------------------------------------------- - // Create Mini Tools Toolbar - //---------------------------------------------------- - rrr.SetRect(0, 0, 150, 18); - rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, - (void**)&mStatusAppBar); - if (NS_OK != rv) { - return rv; - } - - if (NS_OK != mStatusAppBar->QueryInterface(kIWidgetIID,(void**)&mStatusAppBarWidget)) { - return rv; - } - mStatusAppBar->SetMargin(1); - mStatusAppBar->SetHGap(2); - mStatusAppBar->SetBorderType(eToolbarBorderType_full); - - mStatusAppBarWidget->Create(statusWidget, rrr, nsnull, NULL); - mStatusAppBarWidget->SetBackgroundColor(windowBGColor); - mStatusAppBarWidget->Show(PR_TRUE); - - mStatusAppBarWidget->SetClientData(this); - - // Get the ToolbarItem interface for adding it to the toolbar - nsIToolbarItem * toolbarItem; - if (NS_OK != mStatusAppBar->QueryInterface(kIToolbarItemIID,(void**)&toolbarItem)) { - return NS_OK; - } - mStatusBar->AddItem(toolbarItem, 2, PR_FALSE); - - // Count number of buttons and create array to hold them - mNumMiniAppsBtns = 0; - while (gMiniAppsToolbarInfo[mNumMiniAppsBtns].mImgWidth > 0) { - mNumMiniAppsBtns++; - } - mMiniAppsBtns = (nsIWidget **)new PRInt32[mNumMiniAppsBtns]; - - // Create buttons - PRInt32 i = 0; - nsRect rect; - while (gMiniAppsToolbarInfo[i].mImgWidth > 0) { - if (i == 0) { - rect.SetRect(0, 0, 13, 18); - } else { - rect.SetRect(0, 0, 32, 16); - } - nsIImageButton * btn; - nsIWidget * widget; - NS_CreateImageButton(mStatusAppBar, btn, widget, gMiniAppsToolbarInfo[i].mLabel, - rect, nsnull, - &font, baseURL, - gMiniAppsToolbarInfo[i].mUpName, - gMiniAppsToolbarInfo[i].mPressedName, - gMiniAppsToolbarInfo[i].mDisabledName, - gMiniAppsToolbarInfo[i].mRolloverName, - gMiniAppsToolbarInfo[i].mImgWidth, - gMiniAppsToolbarInfo[i].mImgHeight); - AddToolbarItem(mStatusAppBar, gMiniAppsToolbarInfo[i].mGap, gMiniAppsToolbarInfo[i].mEnabled, widget); - btn->SetShowText(PR_FALSE); - btn->SetImageVerticalAlignment(eButtonVerticalAligment_Center); - btn->SetImageHorizontalAlignment(eButtonHorizontalAligment_Middle); - btn->SetShowButtonBorder(PR_FALSE); - btn->SetBorderOffset(0); - btn->SetCommand(gMiniAppsToolbarInfo[i].mCommand); - btn->SetRollOverDesc(gMiniAppsToolbarInfo[i].mRollOverDesc); - btn->AddListener(this); - widget->SetBackgroundColor(widgetBGColor); - if (i == 0) { - btn->SetAlwaysShowBorder(PR_TRUE); - } - mMiniAppsBtns[i] = widget; - rect.x += 40; - i++; - NS_RELEASE(btn); - } - PRInt32 width,height; - mStatusAppBarWidget->GetPreferredSize(width, height); - mStatusAppBarWidget->SetPreferredSize(width, height); - mStatusAppBarWidget->Resize(0,0,width, height, PR_FALSE); - - mStatusBar->SetLastItemIsRightJustified(PR_TRUE); - mStatusBar->SetNextLastItemIsStretchy(PR_TRUE); - - return NS_OK; -} - -//---------------------------------------------------- -NS_METHOD -nsBrowserWindow::NotifyToolbarManagerChangedSize(nsIToolbarManager* aToolbarMgr) -{ - nsRect rect; - GetBounds(rect); - Layout(rect.width, rect.height); - - return NS_OK; -} - -//---------------------------------------------------- -NS_METHOD -nsBrowserWindow::NotifyImageButtonEvent(nsIImageButton * aImgBtn, nsGUIEvent* anEvent) -{ - if (anEvent->message == NS_MOUSE_ENTER) { - nsString msg; - aImgBtn->GetRollOverDesc(msg); - SetStatus(msg); - return NS_OK; - } else if (anEvent->message == NS_MOUSE_EXIT) { - SetStatus(""); - return NS_OK; - } else if (anEvent->message != NS_MOUSE_LEFT_BUTTON_UP) { - return NS_OK; - } - - PRInt32 command; - if (NS_OK != aImgBtn->GetCommand(command)) { - return NS_ERROR_FAILURE; - } - - // Do Personal toolbar - if (command >= kPersonalCmd) { - nsString url(gPersonalURLS[command - kPersonalCmd]); - mWebShell->LoadURL(url); - return NS_OK; - } - - // Do the rest of the commands - switch (command) { - case kStopCmd : - mWebShell->Stop(); - UpdateToolbarBtns(); - break; - - case kBackCmd : - Back(); - UpdateToolbarBtns(); - break; - - case kForwardCmd : - Forward(); - UpdateToolbarBtns(); - break; - - case kReloadCmd : { - mWebShell->Reload(nsURLReloadBypassCache); - } break; - - case kHomeCmd : { - //XXX This test using javascript instead of calling directly - nsString str("window.home();"); - ExecuteJavaScriptString(mWebShell, str); - - // nsString homeURL("http://www.netscape.com"); - // mWebShell->LoadURL(homeURL); - } break; - - case kMiniNavCmd : - mApp->OpenWindow(); - break; - - case kMiniTabCmd : { - DoAppsDialog(); - nsIWidget * widget; - if (NS_OK == mAppsDialog->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Show(PR_TRUE); - NS_RELEASE(widget); - } - mStatusAppBarWidget->Show(PR_FALSE); - mStatusBar->DoLayout(); - } break; - - } // switch - - return NS_OK; -} - -//---------------------------------------------------- -void -nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight) -{ - nscoord txtHeight; - nsILookAndFeel * lookAndFeel; - if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { - lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); - NS_RELEASE(lookAndFeel); - } else { - txtHeight = 24; - } - - nsIWidget * tbManagerWidget = 0; - if (mToolbarMgr && NS_OK != mToolbarMgr->QueryInterface(kIWidgetIID,(void**)&tbManagerWidget)) { - return; - } - - nsRect rr(0, 0, aWidth, aHeight); - - PRInt32 preferredWidth = aWidth; - PRInt32 preferredHeight = aHeight; - - // If there is a toolbar widget, size/position it. - if(tbManagerWidget) { - tbManagerWidget->GetPreferredSize(preferredWidth, preferredHeight); - tbManagerWidget->Resize(0,0, aWidth, preferredHeight, PR_TRUE); - rr.y += preferredHeight; - rr.height -= preferredHeight; - } - - nsIWidget* statusWidget = nsnull; - PRInt32 statusBarHeight = 0; - - // If there is a status bar widget, size/position it. - if (mStatusBar && NS_OK == mStatusBar->QueryInterface(kIWidgetIID,(void**)&statusWidget)) { - if (statusWidget) { - if (mChromeMask & NS_CHROME_STATUS_BAR_ON) { - //PRInt32 width; - //statusWidget->GetPreferredSize(width, statusBarHeight); - statusBarHeight = 22; - statusWidget->Resize(0, aHeight - statusBarHeight, aWidth, statusBarHeight, PR_TRUE); - rr.height -= statusBarHeight; - statusWidget->Show(PR_TRUE); - } else { - statusWidget->Show(PR_FALSE); - } - } - } - - // inset the web widget - rr.x += WEBSHELL_LEFT_INSET; - rr.y += WEBSHELL_TOP_INSET; - rr.width -= WEBSHELL_LEFT_INSET + WEBSHELL_RIGHT_INSET; - rr.height -= WEBSHELL_TOP_INSET + WEBSHELL_BOTTOM_INSET; - mWebShell->SetBounds(rr.x, rr.y, rr.width, rr.height); - - NS_IF_RELEASE(statusWidget); - NS_IF_RELEASE(tbManagerWidget); -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::MoveTo(PRInt32 aX, PRInt32 aY) -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - mWindow->Move(aX, aY); - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::SizeTo(PRInt32 aWidth, PRInt32 aHeight) -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - - // XXX We want to do this in one shot - mWindow->Resize(aWidth, aHeight, PR_FALSE); - Layout(aWidth, aHeight); - - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::GetBounds(nsRect& aBounds) -{ - mWindow->GetBounds(aBounds); - return NS_OK; -} - -NS_IMETHODIMP -nsBrowserWindow::GetWindowBounds(nsRect& aBounds) -{ - //XXX This needs to be non-client bounds when it exists. - mWindow->GetBounds(aBounds); - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::Show() -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - mWindow->Show(PR_TRUE); - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::Hide() -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - mWindow->Show(PR_FALSE); - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::Close() -{ - RemoveBrowser(this); - - if (nsnull != mWebShell) { - mWebShell->Destroy(); - NS_RELEASE(mWebShell); - } - - if (nsnull != mWindow) { - nsIWidget* w = mWindow; - NS_RELEASE(w); - } - - return NS_OK; -} - - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::SetChrome(PRUint32 aChromeMask) -{ - mChromeMask = aChromeMask; - nsRect r; - mWindow->GetBounds(r); - Layout(r.width, r.height); - - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::GetChrome(PRUint32& aChromeMaskResult) -{ - aChromeMaskResult = mChromeMask; - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::GetWebShell(nsIWebShell*& aResult) -{ - aResult = mWebShell; - NS_IF_ADDREF(mWebShell); - return NS_OK; -} - -//---------------------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::HandleEvent(nsGUIEvent * anEvent) -{ - if (anEvent->widget == mToolbarBtns[gBackBtnInx]) { - Back(); - UpdateToolbarBtns(); - - } else if (anEvent->widget == mToolbarBtns[gForwardBtnInx]) { - Forward(); - UpdateToolbarBtns(); - - } else if (mAppsDialogBtns != nsnull && anEvent->widget == mAppsDialogBtns[0]) { - mApp->OpenWindow(); - - } else if (anEvent->widget == mMiniAppsBtns[1]) { - mApp->OpenWindow(); - - } else if (anEvent->widget == mToolbarBtns[gHomeBtnInx]) { - nsString homeURL("http://home.netscape.com/eng/mozilla/5.0/DR1/hello.html"); - mWebShell->LoadURL(homeURL); - - } else if (anEvent->widget == mMiniAppsBtns[0]) { - DoAppsDialog(); - nsIWidget * widget; - if (NS_OK == mAppsDialog->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Show(PR_TRUE); - NS_RELEASE(widget); - } - mStatusAppBarWidget->Show(PR_FALSE); - mStatusBar->DoLayout(); - } - - PRInt32 i = 0; - for (i=0;iwidget) { - nsString url(gPersonalURLS[i]); - mWebShell->LoadURL(url); - break; - } - } - - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::SetTitle(const PRUnichar* aTitle) -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - mTitle = aTitle; - mWindow->SetTitle(aTitle); - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::GetTitle(PRUnichar** aResult) -{ - *aResult = mTitle; - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::SetStatus(const PRUnichar* aStatus) -{ - nsString msg(aStatus); - SetStatus(msg); - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::SetStatus(const nsString & aMsg) -{ - if (nsnull != mStatusText) { - mStatusText->SetLabel(aMsg); - nsIWidget * widget; - if (NS_OK == mStatusText->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Invalidate(PR_TRUE); - NS_RELEASE(widget); - } - } - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::GetStatus(PRUnichar** aResult) -{ - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::SetProgress(PRInt32 aProgress, PRInt32 aProgressMax) -{ - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason) -{ - if (mStatusBar) { - nsAutoString url("Connecting to "); - url.Append(aURL); - - SetStatus(aURL); - } - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL) -{ - if (mThrobber) { - mThrobber->Start(); - PRUint32 size; - mLocation->SetText(aURL,size); - } - nsIWidget * widget; - if (mToolbarBtns && NS_OK == mToolbarBtns[gStopBtnInx]->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Enable(PR_TRUE); - widget->Invalidate(PR_TRUE); - NS_RELEASE(widget); - } - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax) -{ - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus) -{ - if (mThrobber) { - mThrobber->Stop(); - } - nsIWidget * widget; - if (mToolbarBtns && NS_OK == mToolbarBtns[gStopBtnInx]->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Enable(PR_FALSE); - widget->Invalidate(PR_TRUE); - NS_RELEASE(widget); - } - return NS_OK; -} - - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::NewWebShell(PRUint32 aChromeMask, - PRBool aVisible, - nsIWebShell*& aNewWebShell) -{ - nsresult rv = NS_OK; - - // Create new window. By default, the refcnt will be 1 because of - // the registration of the browser window in gBrowsers. - nsBrowserWindow* browser; - NS_NEWXPCOM(browser, nsBrowserWindow); - - if (nsnull != browser) { - nsRect bounds; - GetBounds(bounds); - - browser->SetApp(mApp); - rv = browser->Init(mAppShell, mPrefs, bounds, aChromeMask, mAllowPlugins); - if (NS_OK == rv) { - if (aVisible) { - browser->Show(); - } - nsIWebShell *shell; - rv = browser->GetWebShell(shell); - aNewWebShell = shell; - } else { - browser->Close(); - } - } - else - rv = NS_ERROR_OUT_OF_MEMORY; - - return rv; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult) -{ - PRInt32 i, n = gBrowsers.Count(); - - aResult = nsnull; - nsString aNameStr(aName); - - for (i = 0; i < n; i++) { - nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers.ElementAt(i); - nsIWebShell *ws; - - if (NS_OK == bw->GetWebShell(ws)) { - PRUnichar *name; - if (NS_OK == ws->GetName(&name)) { - if (aNameStr.Equals(name)) { - aResult = ws; - NS_ADDREF(aResult); - return NS_OK; - } - } - } - if (NS_OK == ws->FindChildWithName(aName, aResult)) { - if (nsnull != aResult) { - return NS_OK; - } - } - } - return NS_OK; -} - -NS_IMETHODIMP -nsBrowserWindow::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken) -{ - return NS_OK; -} - -//---------------------------------------- - -// Stream observer implementation - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::OnProgress(nsIURL* aURL, - PRUint32 aProgress, - PRUint32 aProgressMax) -{ - if (mStatusBar) { - nsAutoString url; - if (nsnull != aURL) { - PRUnichar* str; - aURL->ToString(&str); - url = str; - delete[] str; - } - url.Append(": progress "); - url.Append(aProgress, 10); - if (0 != aProgressMax) { - url.Append(" (out of "); - url.Append(aProgressMax, 10); - url.Append(")"); - } - SetStatus(url); - } - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) -{ - SetStatus(aMsg); - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::OnStartBinding(nsIURL* aURL, const char *aContentType) -{ - if (mStatusBar) { - nsAutoString url; - if (nsnull != aURL) { - PRUnichar* str; - aURL->ToString(&str); - url = str; - delete[] str; - } - url.Append(": start"); - SetStatus(url); - } - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP -nsBrowserWindow::OnStopBinding(nsIURL* aURL, - nsresult status, - const PRUnichar* aMsg) -{ - nsAutoString url; - if (nsnull != aURL) { - PRUnichar* str; - aURL->ToString(&str); - url = str; - delete[] str; - } - url.Append(": stop"); - SetStatus(url); - - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP_(void) -nsBrowserWindow::Alert(const nsString &aText) -{ - char *str; - - str = aText.ToNewCString(); - printf("Browser Window Alert: %c%s\n", '\007', str); - delete[] str; -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) -nsBrowserWindow::Confirm(const nsString &aText) -{ - char *str; - - str = aText.ToNewCString(); - printf("%cBrowser Window Confirm: %s (y/n)? ", '\007', str); - delete[] str; - char c; - for (;;) { - c = getchar(); - if (tolower(c) == 'y') { - return PR_TRUE; - } - if (tolower(c) == 'n') { - return PR_FALSE; - } - } -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) -nsBrowserWindow::Prompt(const nsString &aText, - const nsString &aDefault, - nsString &aResult) -{ - char *str; - char buf[256]; - - str = aText.ToNewCString(); - printf("Browser Window: %s\n", str); - delete[] str; - - str = aDefault.ToNewCString(); - printf("%cPrompt (default=%s): ", '\007', str); - gets(buf); - if (strlen(buf)) { - aResult = buf; - } else { - aResult = aDefault; - } - delete[] str; - - return (aResult.Length() > 0); -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) -nsBrowserWindow::PromptUserAndPassword(const nsString &aText, - nsString &aUser, - nsString &aPassword) -{ - char *str; - char buf[256]; - - str = aText.ToNewCString(); - printf("Browser Window: %s\n", str); - delete[] str; - - str = aUser.ToNewCString(); - printf("%cUser (default=%s): ", '\007', str); - gets(buf); - if (strlen(buf)) { - aUser = buf; - } - delete[] str; - - str = aPassword.ToNewCString(); - printf("%cPassword (default=%s): ", '\007', str); - gets(buf); - if (strlen(buf)) { - aPassword = buf; - } - delete[] str; - - return (aUser.Length() > 0); -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) -nsBrowserWindow::PromptPassword(const nsString &aText, - nsString &aPassword) -{ - char *str; - char buf[256]; - - str = aText.ToNewCString(); - printf("Browser Window: %s\n", str); - delete[] str; - - printf("%cPassword: ", '\007'); - gets(buf); - aPassword = buf; - - return PR_TRUE; -} - -//---------------------------------------- -// Toolbar support -void -nsBrowserWindow::StartThrobber() -{ -} - -//---------------------------------------- -void -nsBrowserWindow::StopThrobber() -{ -} - -//---------------------------------------- -void -nsBrowserWindow::LoadThrobberImages() -{ -} - -//---------------------------------------- -void -nsBrowserWindow::DestroyThrobberImages() -{ -} - -static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID); - -//---------------------------------------- -nsIPresShell* -nsBrowserWindow::GetPresShell() -{ - nsIPresShell* shell = nsnull; - if (nsnull != mWebShell) { - nsIContentViewer* cv = nsnull; - mWebShell->GetContentViewer(cv); - if (nsnull != cv) { - nsIDocumentViewer* docv = nsnull; - cv->QueryInterface(kIDocumentViewerIID, (void**) &docv); - if (nsnull != docv) { - nsIPresContext* cx; - docv->GetPresContext(cx); - if (nsnull != cx) { - shell = cx->GetShell(); - NS_RELEASE(cx); - } - NS_RELEASE(docv); - } - NS_RELEASE(cv); - } - } - return shell; -} - -//---------------------------------------- -#ifdef WIN32 -void PlaceHTMLOnClipboard(PRUint32 aFormat, char* aData, int aLength) -{ - HGLOBAL hGlobalMemory; - PSTR pGlobalMemory; - - PRUint32 cf_aol = RegisterClipboardFormat(gsAOLFormat); - PRUint32 cf_html = RegisterClipboardFormat(gsHTMLFormat); - - char* preamble = ""; - char* postamble = ""; - - if (aFormat == cf_aol || aFormat == CF_TEXT) - { - preamble = ""; - postamble = ""; - } - - PRInt32 size = aLength + 1 + strlen(preamble) + strlen(postamble); - - - if (aLength) { - // Copy text to Global Memory Area - hGlobalMemory = (HGLOBAL)GlobalAlloc(GHND, size); - if (hGlobalMemory != NULL) { - pGlobalMemory = (PSTR) GlobalLock(hGlobalMemory); - - int i; - - // AOL requires HTML prefix/postamble - char* s = preamble; - PRInt32 len = strlen(s); - for (i=0; i < len; i++) { - *pGlobalMemory++ = *s++; - } - - s = aData; - len = aLength; - for (i=0;i< len;i++) { - *pGlobalMemory++ = *s++; - } - - - s = postamble; - len = strlen(s); - for (i=0; i < len; i++) { - *pGlobalMemory++ = *s++; - } - - // Put data on Clipboard - GlobalUnlock(hGlobalMemory); - SetClipboardData(aFormat, hGlobalMemory); - } - } -} -#endif - - - -//---------------------------------------- -void -nsBrowserWindow::DoCopy() -{ - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - nsString buffer; - - doc->CreateXIF(buffer,PR_TRUE); - - nsIParser* parser; - - static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); - static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - - nsresult rv = nsComponentManager::CreateInstance(kCParserCID, - nsnull, - kCParserIID, - (void **)&parser); - - if (NS_OK == rv) { - nsIHTMLContentSink* sink = nsnull; - - rv = NS_New_HTML_ContentSinkStream(&sink,PR_FALSE,PR_FALSE); - - ostrstream data; - ((nsHTMLContentSinkStream*)sink)->SetOutputStream(data); - - if (NS_OK == rv) { - parser->SetContentSink(sink); - - nsIDTD* dtd = nsnull; - rv = NS_NewXIFDTD(&dtd); - if (NS_OK == rv) { - parser->RegisterDTD(dtd); - //dtd->SetContentSink(sink); - // dtd->SetParser(parser); - parser->Parse(buffer, PR_FALSE); - } - NS_IF_RELEASE(dtd); - NS_IF_RELEASE(sink); - char* str = data.str(); - - #if defined(WIN32) - PRUint32 cf_aol = RegisterClipboardFormat(gsAOLFormat); - PRUint32 cf_html = RegisterClipboardFormat(gsHTMLFormat); - - PRInt32 len = data.pcount(); - if (len) { - OpenClipboard(NULL); - EmptyClipboard(); - - PlaceHTMLOnClipboard(cf_aol,str,len); - PlaceHTMLOnClipboard(cf_html,str,len); - PlaceHTMLOnClipboard(CF_TEXT,str,len); - - CloseClipboard(); - } - // in ostrstreams if you cal the str() function - // then you are responsible for deleting the string - #endif - if (str) delete str; - - } - NS_RELEASE(parser); - } - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } -} - -//---------------------------------------------------------------------- -void -nsBrowserWindow::DoJSConsole() -{ - mApp->CreateJSConsole(this); -} - -//---------------------------------------- -void -nsBrowserWindow::DoEditorMode(nsIWebShell *aWebShell) -{ - PRInt32 i, n; - if (nsnull != aWebShell) - { - nsIContentViewer *cViewer; - aWebShell->GetContentViewer(cViewer);//returns an addreffed viewer dereference it because it accepts a reference to a * not a ** - if (cViewer) - { - nsIDocumentViewer *dViewer; - if (NS_SUCCEEDED(cViewer->QueryInterface(kIDocumentViewerIID, (void **)&dViewer))) - { //returns an addreffed document viewer - nsIDocument *doc; - dViewer->GetDocument(doc); //returns an addreffed document - if (doc) - { - nsIDOMDocument *domDoc; - if (NS_SUCCEEDED(doc->QueryInterface(kIDOMDocumentIID, (void **)&domDoc))) - { //returns an addreffed domdocument - nsIEditor *editor; - if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kEditorCID, nsnull, kIEditorIID, (void **)&editor))) - { - editor->Init(domDoc); - AddEditor(editor); //new call to set the editor interface this will addref - NS_IF_RELEASE(editor); - } - NS_IF_RELEASE(domDoc); - } - NS_IF_RELEASE(doc); - } - NS_IF_RELEASE(dViewer); - } - NS_IF_RELEASE(cViewer); - } - aWebShell->GetChildCount(n); - for (i = 0; i < n; i++) { - nsIWebShell *child; - aWebShell->ChildAt(i, child); - DoEditorMode(child); //doesnt addref - NS_IF_RELEASE(child); - } - } -} - - - -void -nsBrowserWindow::AddEditor(nsIEditor *aEditor) -{ - if (!mEditor)//THIS FUNCTION REALLY NEEDS HELP - mEditor = aEditor; -} - - -#ifdef NS_DEBUG -#include "nsIContent.h" -#include "nsIFrame.h" -#include "nsIStyleContext.h" -#include "nsISizeOfHandler.h" -#include "nsIStyleSet.h" - - -//---------------------------------------- -void -nsBrowserWindow::DumpContent(FILE* out) -{ - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - nsIContent* root = doc->GetRootContent(); - if (nsnull != root) { - root->List(out); - NS_RELEASE(root); - } - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } - else { - fputs("null pres shell\n", out); - } -} - -//---------------------------------------------------- -void -nsBrowserWindow::DumpFrames(FILE* out, nsString *aFilterName) -{ - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIFrame* root; - shell->GetRootFrame(root); - if (nsnull != root) { - nsIListFilter *filter = nsIFrame::GetFilter(aFilterName); - root->List(out, 0, filter); - } - NS_RELEASE(shell); - } - else { - fputs("null pres shell\n", out); - } -} - -void -DumpViewsRecurse(nsBrowserWindow* aBrowser, nsIWebShell* aWebShell, FILE* out) -{ - if (nsnull != aWebShell) { - nsIPresShell* shell = aBrowser->GetPresShell(); - if (nsnull != shell) { - nsIViewManager* vm = shell->GetViewManager(); - if (nsnull != vm) { - nsIView* root; - vm->GetRootView(root); - if (nsnull != root) { - root->List(out); - } - NS_RELEASE(vm); - } - NS_RELEASE(shell); - } else { - fputs("null pres shell\n", out); - } - // dump the views of the sub documents - PRInt32 i, n; - aWebShell->GetChildCount(n); - for (i = 0; i < n; i++) { - nsIWebShell* child; - aWebShell->ChildAt(i, child); - if (nsnull != child) { - DumpViewsRecurse(aBrowser, child, out); - } - } - } -} - -void -nsBrowserWindow::DumpViews(FILE* out) -{ - DumpViewsRecurse(this, mWebShell, out); -} - -static void DumpAWebShell(nsIWebShell* aShell, FILE* out, PRInt32 aIndent) -{ - PRUnichar *name; - nsAutoString str; - nsIWebShell* parent; - PRInt32 i, n; - - for (i = aIndent; --i >= 0; ) fprintf(out, " "); - - fprintf(out, "%p '", aShell); - aShell->GetName(&name); - aShell->GetParent(parent); - str = name; - fputs(str, out); - fprintf(out, "' parent=%p <\n", parent); - NS_IF_RELEASE(parent); - - aIndent++; - aShell->GetChildCount(n); - for (i = 0; i < n; i++) { - nsIWebShell* child; - aShell->ChildAt(i, child); - if (nsnull != child) { - DumpAWebShell(child, out, aIndent); - } - } - aIndent--; - for (i = aIndent; --i >= 0; ) fprintf(out, " "); - fputs(">\n", out); -} - -void -nsBrowserWindow::DumpWebShells(FILE* out) -{ - DumpAWebShell(mWebShell, out, 0); -} - -void -nsBrowserWindow::DumpStyleSheets(FILE* out) -{ - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIStyleSet* styleSet = shell->GetStyleSet(); - if (nsnull == styleSet) { - fputs("null style set\n", out); - } else { - styleSet->List(out); - NS_RELEASE(styleSet); - } - NS_RELEASE(shell); - } - else { - fputs("null pres shell\n", out); - } -} - -void -nsBrowserWindow::DumpStyleContexts(FILE* out) -{ - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIStyleSet* styleSet = shell->GetStyleSet(); - if (nsnull == styleSet) { - fputs("null style set\n", out); - } else { - nsIFrame* root; - shell->GetRootFrame(root); - if (nsnull == root) { - fputs("null root frame\n", out); - } else { - nsIStyleContext* rootContext; - root->GetStyleContext(rootContext); - if (nsnull != rootContext) { - styleSet->ListContexts(rootContext, out); - NS_RELEASE(rootContext); - } - else { - fputs("null root context", out); - } - } - NS_RELEASE(styleSet); - } - NS_RELEASE(shell); - } else { - fputs("null pres shell\n", out); - } -} - -void -nsBrowserWindow::ToggleFrameBorders() -{ - PRBool showing = nsIFrame::GetShowFrameBorders(); - nsIFrame::ShowFrameBorders(!showing); - ForceRefresh(); -} - -void -nsBrowserWindow::ShowContentSize() -{ - nsISizeOfHandler* szh; - if (NS_OK != NS_NewSizeOfHandler(&szh)) { - return; - } - - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - nsIContent* content = doc->GetRootContent(); - if (nsnull != content) { - content->SizeOf(szh); - PRUint32 totalSize; - szh->GetSize(totalSize); - printf("Content model size is approximately %d bytes\n", totalSize); - NS_RELEASE(content); - } - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } - NS_RELEASE(szh); -} - -void -nsBrowserWindow::ShowFrameSize() -{ - nsIPresShell* shell0 = GetPresShell(); - if (nsnull != shell0) { - nsIDocument* doc = shell0->GetDocument(); - if (nsnull != doc) { - PRInt32 i, shells = doc->GetNumberOfShells(); - for (i = 0; i < shells; i++) { - nsIPresShell* shell = doc->GetShellAt(i); - if (nsnull != shell) { - nsISizeOfHandler* szh; - if (NS_OK != NS_NewSizeOfHandler(&szh)) { - return; - } - nsIFrame* root; - shell->GetRootFrame(root); - if (nsnull != root) { - root->SizeOf(szh); - PRUint32 totalSize; - szh->GetSize(totalSize); - printf("Frame model for shell=%p size is approximately %d bytes\n", - shell, totalSize); - } - NS_RELEASE(szh); - NS_RELEASE(shell); - } - } - NS_RELEASE(doc); - } - NS_RELEASE(shell0); - } -} - -void -nsBrowserWindow::ShowStyleSize() -{ -} - - - - -static PRBool GetSaveFileNameFromFileSelector(nsIWidget* aParentWindow, - nsString& aFileName) -{ - PRInt32 offset = aFileName.RFind('/'); - if (offset != -1) - aFileName.Cut(0,offset+1); - - PRBool selectedFileName = PR_FALSE; - nsIFileWidget *fileWidget; - nsString title("Save HTML"); - nsresult rv = nsComponentManager::CreateInstance(kFileWidgetCID, - nsnull, - kIFileWidgetIID, - (void**)&fileWidget); - if (NS_OK == rv) { - nsString titles[] = {"html","txt"}; - nsString filters[] = {"*.html", "*.txt"}; - fileWidget->SetFilterList(2, titles, filters); - fileWidget->Create(aParentWindow, - title, - eMode_save, - nsnull, - nsnull); - fileWidget->SetDefaultString(aFileName); - - PRUint32 result = fileWidget->Show(); - if (result) { - fileWidget->GetFile(aFileName); - selectedFileName = PR_TRUE; - } - - NS_RELEASE(fileWidget); - } - - return selectedFileName; -} - - - - -void -nsBrowserWindow::DoDebugSave() -{ - PRBool doSave = PR_FALSE; - nsString path; - - PRUnichar *urlString; - mWebShell->GetURL(0,&urlString); - nsIURL* url; - nsresult rv = NS_NewURL(&url, urlString); - - if (rv == NS_OK) - { - const char* name; - (void)url->GetFile(&name); - path = name; - - doSave = GetSaveFileNameFromFileSelector(mWindow, path); - NS_RELEASE(url); - - } - if (!doSave) - return; - - - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - nsString buffer; - - doc->CreateXIF(buffer,PR_FALSE); - - nsIParser* parser; - - static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); - static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - - nsresult rv = nsComponentManager::CreateInstance(kCParserCID, - nsnull, - kCParserIID, - (void **)&parser); - - if (NS_OK == rv) { - nsIHTMLContentSink* sink = nsnull; - - rv = NS_New_HTML_ContentSinkStream(&sink); - -#ifdef WIN32 -#define BUFFER_SIZE MAX_PATH -#else -#define BUFFER_SIZE 1024 -#endif - char filename[BUFFER_SIZE]; - path.ToCString(filename,BUFFER_SIZE); - ofstream out(filename); - ((nsHTMLContentSinkStream*)sink)->SetOutputStream(out); - - if (NS_OK == rv) { - parser->SetContentSink(sink); - - nsIDTD* dtd = nsnull; - rv = NS_NewXIFDTD(&dtd); - if (NS_OK == rv) - { - parser->RegisterDTD(dtd); - //dtd->SetContentSink(sink); - //dtd->SetParser(parser); - parser->Parse(buffer, PR_FALSE); - } - out.close(); - - NS_IF_RELEASE(dtd); - NS_IF_RELEASE(sink); - } - NS_RELEASE(parser); - } - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } -} - -void -nsBrowserWindow::DoToggleSelection() -{ - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - PRBool current = doc->GetDisplaySelection(); - doc->SetDisplaySelection(!current); - ForceRefresh(); - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } -} - - -void -nsBrowserWindow::DoDebugRobot() -{ - mApp->CreateRobot(this); -} - -#endif NS_DEBUG - -void -nsBrowserWindow::DoSiteWalker() -{ - mApp->CreateSiteWalker(this); -} - -//----------------------------------------------------- -//-- Menu Struct -//----------------------------------------------------- -typedef struct _menuBtns { - char * title; - char * mneu; - long command; -} MenuBtns; - - -//----------------------------------------------------- -// XXX This will be moved to nsWidgetSupport -nsIMenu * CreateMenu(nsIMenu * aMenu, const nsString & aName, char aMneu) -{ - nsIMenu * menu; - nsresult rv = nsComponentManager::CreateInstance(kMenuCID, - nsnull, - kIMenuIID, - (void**)&menu); - if (NS_OK == rv) { - menu->Create(aMenu, aName); - } - - return menu; -} - -//----------------------------------------------------- -// XXX This will be moved to nsWidgetSupport -nsIMenu * CreateMenu(nsIMenuBar * aMenuBar, const nsString & aName, char aMneu) -{ - nsIMenu * menu; - nsresult rv = nsComponentManager::CreateInstance(kMenuCID, - nsnull, - kIMenuIID, - (void**)&menu); - if (NS_OK == rv) { - menu->Create(aMenuBar, aName); - } - - return menu; -} - -//----------------------------------------------------- -// XXX This will be moved to nsWidgetSupport -nsIMenuItem * CreateMenuItem(nsIMenu * aMenu, const nsString & aName, PRUint32 aCommand) -{ - nsIMenuItem * menuItem = nsnull; - - if (!aName.Equals("-")) { - nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, - nsnull, - kIMenuItemIID, - (void**)&menuItem); - if (NS_OK == rv) { - menuItem->Create(aMenu, aName, aCommand); - } - } else { - aMenu->AddSeparator(); - } - - return menuItem; -} - - -//----------------------------------------------------- -void CreateBrowserMenus(nsIMenuBar * aMenuBar) -{ - MenuBtns editMenus[] = { - {"Cut", "T", VIEWER_EDIT_CUT}, - {"Copy", "C", VIEWER_EDIT_COPY}, - {"Paste", "P", VIEWER_EDIT_PASTE}, - {"-", NULL, 0}, - {"Select All", "A", VIEWER_EDIT_SELECTALL}, - {"-", NULL, 0}, - {"Find in Page", "F", VIEWER_EDIT_FINDINPAGE}, - {NULL, NULL, 0} - }; - - MenuBtns debugMenus[] = { - {"Visual Debugging", "V", VIEWER_VISUAL_DEBUGGING}, - {"Reflow Test", "R", VIEWER_REFLOW_TEST}, - {"-", NULL, 0}, - {"Dump Content", "C", VIEWER_DUMP_CONTENT}, - {"Dump Frames", "F", VIEWER_DUMP_FRAMES}, - {"Dump Views", "V", VIEWER_DUMP_VIEWS}, - {"-", NULL, 0}, - {"Dump Style Sheets", "S", VIEWER_DUMP_STYLE_SHEETS}, - {"Dump Style Contexts", "T", VIEWER_DUMP_STYLE_CONTEXTS}, - {"-", NULL, 0}, - {"Show Content Size", "z", VIEWER_SHOW_CONTENT_SIZE}, - {"Show Frame Size", "a", VIEWER_SHOW_FRAME_SIZE}, - {"Show Style Size", "y", VIEWER_SHOW_STYLE_SIZE}, - {"-", NULL, 0}, - {"Debug Save", "v", VIEWER_DEBUGSAVE}, - {"Debug Toggle Selection", "q", VIEWER_TOGGLE_SELECTION}, - {"-", NULL, 0}, - {"Debug Robot", "R", VIEWER_DEBUGROBOT}, - {"-", NULL, 0}, - {"Show Content Quality", ".", VIEWER_SHOW_CONTENT_QUALITY}, - {"Editor", "E", EDITOR_MODE}, - {NULL, NULL, 0} - }; - - - nsIMenu * fileMenu = CreateMenu(aMenuBar, "File", 'F'); - - CreateMenuItem(fileMenu, "New Window", VIEWER_WINDOW_OPEN); - CreateMenuItem(fileMenu, "Open...", VIEWER_FILE_OPEN); - CreateMenuItem(fileMenu, "View Source", VIEWER_FILE_VIEW_SOURCE); - - nsIMenu * samplesMenu = CreateMenu(fileMenu, "Samples", 'S'); - PRInt32 i = 0; - for (i=0;i<10;i++) { - char buf[64]; - sprintf(buf, "Demo #%d", i); - CreateMenuItem(samplesMenu, buf, VIEWER_DEMO0+i); - } - - CreateMenuItem(fileMenu, "Test Sites", VIEWER_TOP100); - -#ifdef NOT_YET - nsIMenu * printMenu = CreateMenu(fileMenu, "Print Preview", 'P'); - CreateMenuItem(printMenu, "One Column", VIEWER_ONE_COLUMN); - CreateMenuItem(printMenu, "Two Column", VIEWER_TWO_COLUMN); - CreateMenuItem(printMenu, "Three Column", VIEWER_THREE_COLUMN); -#endif /* NOT_YET */ - - CreateMenuItem(fileMenu, "-", 0); - CreateMenuItem(fileMenu, "Exit", VIEWER_EXIT); - -#if EDITOR_NOT_YET - nsIMenu * editMenu = CreateMenu(aMenuBar, "Edit", 'E'); - i = 0; - while (editMenus[i].title != nsnull) { - CreateMenuItem(editMenu, editMenus[i].title, editMenus[i].command); - i++; - } -#endif - -#ifdef NOT_YET - nsIMenu * viewMenu = CreateMenu(aMenuBar, "View", 'V'); - CreateMenuItem(viewMenu, "Show", 0); - CreateMenuItem(viewMenu, "-", 0); - CreateMenuItem(viewMenu, "Reload", 0); - CreateMenuItem(viewMenu, "Refresh", 0); -#endif /* NOT_YET */ - -/* nsIMenu * goMenu = CreateMenu(aMenuBar, "Go", 'G'); */ - nsIMenu * commMenu = CreateMenu(aMenuBar, "Communicator", 'C'); - CreateMenuItem(commMenu, "Navigator", VIEWER_COMM_NAV); - - nsIMenu * helpMenu = CreateMenu(aMenuBar, "Help", 'H'); - -#ifdef NS_DEBUG - nsIMenu * debugMenu = CreateMenu(aMenuBar, "Debug", 'D'); - i = 0; - while (debugMenus[i].title != nsnull) { - CreateMenuItem(debugMenu, debugMenus[i].title, debugMenus[i].command); - i++; - } -#endif - - /*nsIMenu * toolsMenu = CreateMenu(aMenuBar, "Tools", 'T'); - CreateMenuItem(toolsMenu, "Java Script Console", JS_CONSOLE); - CreateMenuItem(toolsMenu, "Editor Mode", EDITOR_MODE);*/ - -} - -//#endif // NS_DEBUG - -//----------------------------------------------------- -nsresult -nsBrowserWindow::CreateMenuBar(PRInt32 aWidth) -{ - nsIMenuBar * menuBar; - nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID, - nsnull, - kIMenuBarIID, - (void**)&menuBar); - - if (nsnull != menuBar) { - menuBar->Create(mWindow); - CreateBrowserMenus(menuBar); - } - - return NS_OK; -} - -#ifdef NS_DEBUG - -nsEventStatus -nsBrowserWindow::DispatchDebugMenu(PRInt32 aID) -{ - nsEventStatus result = nsEventStatus_eIgnore; - - switch(aID) { - case VIEWER_VISUAL_DEBUGGING: - ToggleFrameBorders(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_DUMP_CONTENT: - DumpContent(); - DumpWebShells(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_DUMP_FRAMES: - DumpFrames(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_DUMP_VIEWS: - DumpViews(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_DUMP_STYLE_SHEETS: - DumpStyleSheets(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_DUMP_STYLE_CONTEXTS: - DumpStyleContexts(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_SHOW_CONTENT_SIZE: - ShowContentSize(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_SHOW_FRAME_SIZE: - ShowFrameSize(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_SHOW_STYLE_SIZE: - ShowStyleSize(); - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_SHOW_CONTENT_QUALITY: -#if XXX_fix_me - if ((nsnull != wd) && (nsnull != wd->observer)) { - nsIPresContext *px = wd->observer->mWebWidget->GetPresContext(); - nsIPresShell *ps = px->GetShell(); - nsIViewManager *vm = ps->GetViewManager(); - - vm->ShowQuality(!vm->GetShowQuality()); - - NS_RELEASE(vm); - NS_RELEASE(ps); - NS_RELEASE(px); - } -#endif - result = nsEventStatus_eConsumeNoDefault; - break; - - case VIEWER_DEBUGSAVE: - DoDebugSave(); - break; - - case VIEWER_TOGGLE_SELECTION: - DoToggleSelection(); - break; - - - case VIEWER_DEBUGROBOT: - DoDebugRobot(); - break; - - case VIEWER_TOP100: - DoSiteWalker(); - break; - } - return(result); -} - -#endif // NS_DEBUG - -//---------------------------------------------------------------------- - -// Factory code for creating nsBrowserWindow's - -class nsBrowserWindowFactory : public nsIFactory -{ -public: - nsBrowserWindowFactory(); - ~nsBrowserWindowFactory(); - - // nsISupports methods - NS_IMETHOD QueryInterface(const nsIID &aIID, void **aResult); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - // nsIFactory methods - NS_IMETHOD CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); - -private: - nsrefcnt mRefCnt; -}; - -nsBrowserWindowFactory::nsBrowserWindowFactory() -{ - mRefCnt = 0; -} - -nsBrowserWindowFactory::~nsBrowserWindowFactory() -{ - NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction"); -} - -nsresult -nsBrowserWindowFactory::QueryInterface(const nsIID &aIID, void **aResult) -{ - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - - // Always NULL result, in case of failure - *aResult = NULL; - - if (aIID.Equals(kISupportsIID)) { - *aResult = (void *)(nsISupports*)this; - } else if (aIID.Equals(kIFactoryIID)) { - *aResult = (void *)(nsIFactory*)this; - } - - if (*aResult == NULL) { - return NS_NOINTERFACE; - } - - NS_ADDREF_THIS(); // Increase reference count for caller - return NS_OK; -} - -nsrefcnt -nsBrowserWindowFactory::AddRef() -{ - return ++mRefCnt; -} - -nsrefcnt -nsBrowserWindowFactory::Release() -{ - if (--mRefCnt == 0) { - delete this; - return 0; // Don't access mRefCnt after deleting! - } - return mRefCnt; -} - -nsresult -nsBrowserWindowFactory::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - nsresult rv; - nsBrowserWindow *inst; - - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - *aResult = NULL; - if (nsnull != aOuter) { - rv = NS_ERROR_NO_AGGREGATION; - goto done; - } - - NS_NEWXPCOM(inst, nsBrowserWindow); - if (inst == NULL) { - rv = NS_ERROR_OUT_OF_MEMORY; - goto done; - } - - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - -done: - return rv; -} - -nsresult -nsBrowserWindowFactory::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -nsresult -NS_NewBrowserWindowFactory(nsIFactory** aFactory) -{ - nsresult rv = NS_OK; - nsBrowserWindowFactory* inst; - NS_NEWXPCOM(inst, nsBrowserWindowFactory); - if (nsnull == inst) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - else { - NS_ADDREF(inst); - } - *aFactory = inst; - return rv; -} - -nsViewSourceWindow::nsViewSourceWindow( nsIAppShell *anAppShell, - nsIPref *aPrefs, - nsViewerApp *anApp, - const PRUnichar *aURL ) - : nsBrowserWindow() { - - // Wire the window to the "parent" application. - this->SetApp(anApp); - - // "View Source" windows have none of this chrome. - PRUint32 chromeMask = (PRUint32)~( NS_CHROME_TOOL_BAR_ON // No toolbar. - | - NS_CHROME_LOCATION_BAR_ON // No location bar. - | - NS_CHROME_PERSONAL_TOOLBAR_ON ); // No personal toolbar. - - // Initialize the window. - this->Init(anAppShell, mPrefs, nsRect(0, 0, 620, 400), chromeMask, PR_FALSE); - - // Get the new window's web shell. - nsIWebShell *pWebShell = 0; - if( NS_OK == this->GetWebShell(pWebShell) ) { - // Have the web shell load the URL's source. - pWebShell->LoadURL(aURL,"view-source"); - - // Set title (bypassing our override so it gets set for real). - nsString title = "Source for "; - title += aURL; - this->nsBrowserWindow::SetTitle( title ); - - // Make the window visible. - this->Show(); - - // Release the shell object. - NS_RELEASE(pWebShell); - } else { - // Do our best to handle the error. - this->Alert( "Unable to get web shell in nsViewSourceWindow ctor" ); - } - -} - -nsresult -nsViewSourceWindow::SetTitle( const PRUnichar * ) { - // Swallow this request (to block the nsIWebShell from giving us a - // bogus title. - return NS_OK; -} diff --git a/xpfe/xpviewer/src/nsBrowserWindow.h b/xpfe/xpviewer/src/nsBrowserWindow.h deleted file mode 100644 index 5f6acdef104a..000000000000 --- a/xpfe/xpviewer/src/nsBrowserWindow.h +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#ifndef nsBrowserWindow_h___ -#define nsBrowserWindow_h___ - -#include "nsIBrowserWindow.h" -#include "nsIXPBaseWindow.h" -#include "nsIStreamListener.h" -#include "nsINetSupport.h" -#include "nsIWebShell.h" -#include "nsIScriptContextOwner.h" -#include "nsString.h" -#include "nsVoidArray.h" -#include "nsCRT.h" - -#include "nsIToolbarManagerListener.h" -#include "nsIImageButtonListener.h" - -#include "nsIEditor.h" - -class nsILabel; -class nsICheckButton; -class nsIRadioButton; -class nsIDialog; -class nsITextWidget; -class nsIButton; -class nsIThrobber; -class nsViewerApp; -class nsIPresShell; -class nsIPref; -class nsIImageButton; -class nsIMenuButton; -class nsIToolbar; -class nsIToolbarManager; - -#define SAMPLES_BASE_URL "resource:/res/samples" - -/** - * Abstract base class for our test app's browser windows - */ -class nsBrowserWindow : public nsIBrowserWindow, - public nsIStreamObserver, - public nsINetSupport, - public nsIWebShellContainer, - public nsIToolbarManagerListener, - public nsIImageButtonListener -{ -public: - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - nsBrowserWindow(); - virtual ~nsBrowserWindow(); - - // nsISupports - NS_DECL_ISUPPORTS - - // nsIBrowserWindow - NS_IMETHOD Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, - const nsRect& aBounds, - PRUint32 aChromeMask, - PRBool aAllowPlugins = PR_TRUE); - NS_IMETHOD MoveTo(PRInt32 aX, PRInt32 aY); - NS_IMETHOD SizeTo(PRInt32 aWidth, PRInt32 aHeight); - NS_IMETHOD GetWindowBounds(nsRect& aBounds); - NS_IMETHOD GetBounds(nsRect& aBounds); - NS_IMETHOD Show(); - NS_IMETHOD Hide(); - NS_IMETHOD Close(); - NS_IMETHOD SetChrome(PRUint32 aNewChromeMask); - NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult); - NS_IMETHOD SetTitle(const PRUnichar* aTitle); - NS_IMETHOD GetTitle(PRUnichar** aResult); - NS_IMETHOD SetStatus(const PRUnichar* aStatus); - NS_IMETHOD SetStatus(const nsString &aStatus); - NS_IMETHOD GetStatus(PRUnichar** aResult); - NS_IMETHOD SetProgress(PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD GetWebShell(nsIWebShell*& aResult); - - NS_IMETHOD HandleEvent(nsGUIEvent * anEvent); - - // nsIStreamObserver - NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); - - // nsIWebShellContainer - NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason); - NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL); - NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); - NS_IMETHOD NewWebShell(PRUint32 aChromeMask, - PRBool aVisible, - nsIWebShell *&aNewWebShell); - NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult); - NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken); - - // nsINetSupport - NS_IMETHOD_(void) Alert(const nsString &aText); - NS_IMETHOD_(PRBool) Confirm(const nsString &aText); - NS_IMETHOD_(PRBool) Prompt(const nsString &aText, - const nsString &aDefault, - nsString &aResult); - NS_IMETHOD_(PRBool) PromptUserAndPassword(const nsString &aText, - nsString &aUser, - nsString &aPassword); - NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText, - nsString &aPassword); - - // nsBrowserWindow - virtual nsresult CreateMenuBar(PRInt32 aWidth); - virtual nsresult CreateToolBar(PRInt32 aWidth); - virtual nsresult CreateStatusBar(PRInt32 aWidth); - - // XXX: This method is temporary until javascript event handlers come - // through the content model. - void ExecuteJavaScriptString(nsIWebShell* aWebShell, nsString& aJavaScript); - void Layout(PRInt32 aWidth, PRInt32 aHeight); - void Back(); - void Forward(); - void GoTo(const PRUnichar* aURL); - void StartThrobber(); - void StopThrobber(); - void LoadThrobberImages(); - void DestroyThrobberImages(); - virtual nsEventStatus DispatchMenuItem(PRInt32 aID); - - void DoFileOpen(); - void DoViewSource(); - void DoCopy(); - void DoJSConsole(); - void DoEditorMode(nsIWebShell* aWebShell); - nsIPresShell* GetPresShell(); - - void DoFind(); - void DoSelectAll(); - void DoAppsDialog(); - NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound); - NS_IMETHOD ForceRefresh(); - - // nsIToolbarManager Listener Interface - NS_IMETHOD NotifyToolbarManagerChangedSize(nsIToolbarManager* aToolbarMgr); - - // nsIImageButtonListener - NS_IMETHOD NotifyImageButtonEvent(nsIImageButton * aImgBtn, nsGUIEvent* anEvent); - -#ifdef NS_DEBUG - void DumpContent(FILE *out = stdout); - void DumpFrames(FILE *out = stdout, nsString *aFilter = nsnull); - void DumpViews(FILE *out = stdout); - void DumpWebShells(FILE *out = stdout); - void DumpStyleSheets(FILE *out = stdout); - void DumpStyleContexts(FILE *out = stdout); - void ToggleFrameBorders(); - void ShowContentSize(); - void ShowFrameSize(); - void ShowStyleSize(); - void DoDebugSave(); - void DoToggleSelection(); - void DoDebugRobot(); - nsEventStatus DispatchDebugMenu(PRInt32 aID); -#endif - void DoSiteWalker(); - - nsEventStatus ProcessDialogEvent(nsGUIEvent *aEvent); - - - void SetApp(nsViewerApp* aApp) { - mApp = aApp; - } - - static void CloseAllWindows(); - - nsViewerApp* mApp; - nsIXPBaseWindow* mXPDialog; - - PRUint32 mChromeMask; - nsString mTitle; - - nsIWidget* mWindow; - nsIWebShell* mWebShell; - - nsIWidget ** mAppsDialogBtns; - PRInt32 mNumAppsDialogBtns; - - nsIWidget ** mMiniAppsBtns; - PRInt32 mNumMiniAppsBtns; - - nsIWidget ** mToolbarBtns; - PRInt32 mNumToolbarBtns; - - nsIWidget ** mPersonalToolbarBtns; - PRInt32 mNumPersonalToolbarBtns; - - // "Toolbar" - nsIToolbarManager * mToolbarMgr; - nsIToolbar * mBtnToolbar; - nsIToolbar * mURLToolbar; - - //nsIImageButton* mBack; - //nsIImageButton* mForward; - //nsIImageButton* mReload; - //nsIImageButton* mHome; - //nsIImageButton* mPrint; - //nsIImageButton* mStop; - nsIThrobber* mThrobber; - - nsIMenuButton* mBookmarks; - nsIMenuButton* mWhatsRelated; - nsITextWidget* mLocation; - nsIImageButton* mLocationIcon; - - // nsIWidget for Buttons - //nsIWidget* mBackWidget; - //nsIWidget* mForwardWidget; - //nsIWidget* mReloadWidget; - //nsIWidget* mHomeWidget; - //nsIWidget* mPrintWidget; - //nsIWidget* mStopWidget; - - nsIWidget* mBookmarksWidget; - nsIWidget* mWhatsRelatedWidget; - nsIWidget* mLocationWidget; - nsIWidget* mLocationIconWidget; - - // "Status bar" - nsITextWidget * mStatus; - nsIToolbar * mStatusBar; - nsIImageButton * mStatusSecurityLabel; - nsIImageButton * mStatusProcess; - nsIImageButton * mStatusText; - - // Mini App Bar (in StatusBar) - nsIToolbar * mStatusAppBar; - nsIImageButton * mMiniTab; - nsIImageButton * mMiniNav; - nsIImageButton * mMiniMail; - nsIImageButton * mMiniAddr; - nsIImageButton * mMiniComp; - - nsIWidget * mStatusAppBarWidget; - nsIWidget * mMiniTabWidget; - - // Apps Dialog - nsIDialog * mAppsDialog; - - // Find Dialog - nsIDialog * mDialog; - nsIButton * mCancelBtn; - nsIButton * mFindBtn; - nsITextWidget * mTextField; - nsICheckButton * mMatchCheckBtn; - nsIRadioButton * mUpRadioBtn; - nsIRadioButton * mDwnRadioBtn; - nsILabel * mLabel; - - //for creating more instances - nsIAppShell* mAppShell; //not addref'ed! - nsIPref* mPrefs; //not addref'ed! - PRBool mAllowPlugins; - - // Global window collection - static nsVoidArray gBrowsers; - static void AddBrowser(nsBrowserWindow* aBrowser); - static void RemoveBrowser(nsBrowserWindow* aBrowser); - static nsBrowserWindow* FindBrowserFor(nsIWidget* aWidget, PRIntn aWhich); - static nsBrowserWindow* FindBrowserFor(nsIWidget* aWidget); - -protected: - - - nsresult AddToolbarItem(nsIToolbar *aToolbar, - PRInt32 aGap, - PRBool aEnable, - nsIWidget *aButtonWidget); - - void UpdateToolbarBtns(); - - void AddEditor(nsIEditor *); //this function is temporary and WILL be depricated - nsIEditor * mEditor; //this will hold the editor for future commands. we must think about this mjudge -}; - -// nsViewSourceWindow -// -// Objects of this class are nsBrowserWindows with no chrome and which render the *source* -// for web pages rather than the web pages themselves. -// -// We also override SetTitle to block the nsIWebShell from resetting our nice "Source for..." -// title. -// -// Note that there is no nsViewSourceWindow interface, nor does this class have a CID or -// provide a factory. Deal with it (but seriously, I explain why somewhere). -class nsViewSourceWindow : public nsBrowserWindow { -public: - nsViewSourceWindow( nsIAppShell *anAppShell, - nsIPref *aPrefs, - nsViewerApp *anApp, - const PRUnichar *aURL ); - NS_IMETHOD SetTitle( const PRUnichar *aTitle ); -};; - -// XXX This is bad; because we can't hang a closure off of the event -// callback we have no way to store our This pointer; therefore we -// have to hunt to find the browswer that events belong too!!! - -// aWhich for FindBrowserFor -#define FIND_WINDOW 0 -#define FIND_BACK 1 -#define FIND_FORWARD 2 -#define FIND_LOCATION 3 - -//---------------------------------------------------------------------- - -/*class nsNativeBrowserWindow : public nsBrowserWindow { -public: - nsNativeBrowserWindow(); - ~nsNativeBrowserWindow(); - - virtual nsresult CreateMenuBar(PRInt32 aWidth); - virtual nsEventStatus DispatchMenuItem(PRInt32 aID); -};*/ - -#endif /* nsBrowserWindow_h___ */ diff --git a/xpfe/xpviewer/src/nsFindDialog.cpp b/xpfe/xpviewer/src/nsFindDialog.cpp deleted file mode 100644 index 87c967872fc3..000000000000 --- a/xpfe/xpviewer/src/nsFindDialog.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -#include "nsFindDialog.h" -#include "nsIDOMEvent.h" -#include "nsIXPBaseWindow.h" - -#include "nsIDOMHTMLInputElement.h" -#include "nsIDOMHTMLDocument.h" -static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID); - -//------------------------------------------------------------------------- -// -// nsFindDialog constructor -// -//------------------------------------------------------------------------- -//----------------------------------------------------------------- -nsFindDialog::nsFindDialog(nsBrowserWindow * aBrowserWindow) : - mBrowserWindow(aBrowserWindow), - mFindBtn(nsnull), - mCancelBtn(nsnull), - mSearchDown(PR_TRUE) -{ -} - -//----------------------------------------------------------------- -nsFindDialog::~nsFindDialog() -{ -} - -//--------------------------------------------------------------- -void nsFindDialog::Initialize(nsIXPBaseWindow * aWindow) -{ - nsIDOMHTMLDocument *doc = nsnull; - aWindow->GetDocument(doc); - if (nsnull != doc) { - doc->GetElementById("find", &mFindBtn); - doc->GetElementById("cancel", &mCancelBtn); - doc->GetElementById("searchup", &mUpRB); - doc->GetElementById("searchdown", &mDwnRB); - doc->GetElementById("matchcase", &mMatchCaseCB); - - // XXX: Register event listening on each dom element. We should change this so - // all DOM events are automatically passed through. - aWindow->AddEventListener(mFindBtn); - aWindow->AddEventListener(mCancelBtn); - aWindow->AddEventListener(mUpRB); - aWindow->AddEventListener(mDwnRB); - - SetChecked(mMatchCaseCB, PR_FALSE); - NS_RELEASE(doc); - } -} - -//----------------------------------------------------------------- -void nsFindDialog::MouseClick(nsIDOMEvent* aMouseEvent, nsIXPBaseWindow * aWindow) -{ - // Event Dispatch. This method should not contain - // anything but calls to methods. This idea is that this dispatch - // mechanism may be replaced by JavaScript EventHandlers which call the idl'ed - // interfaces to perform the same operation that is currently being handled by - // this C++ code. - - nsIDOMNode * node; - aMouseEvent->GetTarget(&node); - if (node == mFindBtn) { - DoFind(aWindow); - - } else if (node == mCancelBtn) { - DoClose(aWindow); - } - NS_RELEASE(node); -} - -//----------------------------------------------------------------- -void nsFindDialog::Destroy(nsIXPBaseWindow * aWindow) -{ - // Unregister event listeners that were registered in the - // Initialize here. - // XXX: Should change code in XPBaseWindow to automatically unregister - // all event listening, That way this code will not be necessary. - aWindow->RemoveEventListener(mFindBtn); - aWindow->RemoveEventListener(mCancelBtn); -} - -//--------------------------------------------------------------- -void -nsFindDialog::DoFind(nsIXPBaseWindow * aWindow) -{ - // Now we have the content tree, lets find the - // widgets holding the info. - - nsIDOMElement * textNode = nsnull; - nsIDOMHTMLDocument *doc = nsnull; - aWindow->GetDocument(doc); - if (nsnull != doc) { - if (NS_OK == doc->GetElementById("query", &textNode)) { - nsIDOMHTMLInputElement * element; - if (NS_OK == textNode->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element)) { - nsString str; - PRBool foundIt = PR_FALSE; - element->GetValue(str); - PRBool searchDown = IsChecked(mDwnRB); - PRBool matchcase = IsChecked(mMatchCaseCB); - - mBrowserWindow->FindNext(str, matchcase, searchDown, foundIt); - if (foundIt) { - mBrowserWindow->ForceRefresh(); - } - - NS_RELEASE(element); - } - NS_RELEASE(textNode); - } - NS_RELEASE(doc); - } -} - -void -nsFindDialog::DoClose(nsIXPBaseWindow * aWindow) -{ - aWindow->SetVisible(PR_FALSE); -} - - -//--------------------------------------------------------------- -PRBool -nsFindDialog::IsChecked(nsIDOMElement * aNode) -{ - nsIDOMHTMLInputElement * element; - if (NS_OK == aNode->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element)) { - PRBool checked; - element->GetChecked(&checked); - NS_RELEASE(element); - return checked; - } - return PR_FALSE; -} - -//--------------------------------------------------------------- -void -nsFindDialog::SetChecked(nsIDOMElement * aNode, PRBool aValue) -{ - nsIDOMHTMLInputElement * element; - if (NS_OK == aNode->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element)) { - element->SetChecked(aValue); - NS_RELEASE(element); - } -} - diff --git a/xpfe/xpviewer/src/nsFindDialog.h b/xpfe/xpviewer/src/nsFindDialog.h deleted file mode 100644 index cd36508ae635..000000000000 --- a/xpfe/xpviewer/src/nsFindDialog.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#ifndef nsFindDialog_h___ -#define nsFindDialog_h___ - -#include "nsBrowserWindow.h" -#include "nsWindowListener.h" -#include "nsIDOMElement.h" - -/** - * Implement Navigator Find Dialog - */ -class nsFindDialog : public nsWindowListener -{ -public: - - nsFindDialog(nsBrowserWindow * aBrowserWindow); - virtual ~nsFindDialog(); - - // nsWindowListener Methods - - void MouseClick(nsIDOMEvent* aMouseEvent, nsIXPBaseWindow * aWindow); - void Initialize(nsIXPBaseWindow * aWindow); - void Destroy(nsIXPBaseWindow * aWindow); - - // new methods - virtual void DoFind(nsIXPBaseWindow * aWindow); - virtual void DoClose(nsIXPBaseWindow * aWindow); - -protected: - PRBool IsChecked(nsIDOMElement * aNode); - void SetChecked(nsIDOMElement * aNode, PRBool aValue); - - nsBrowserWindow * mBrowserWindow; - nsIDOMElement * mFindBtn; - nsIDOMElement * mCancelBtn; - nsIDOMElement * mUpRB; - nsIDOMElement * mDwnRB; - nsIDOMElement * mMatchCaseCB; - - PRBool mSearchDown; - -}; - -#endif /* nsFindDialog_h___ */ diff --git a/xpfe/xpviewer/src/nsSetupRegistry.cpp b/xpfe/xpviewer/src/nsSetupRegistry.cpp deleted file mode 100644 index c94604d5ffd9..000000000000 --- a/xpfe/xpviewer/src/nsSetupRegistry.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#define NS_IMPL_IDS -#include "nsIPref.h" -#include "nsIComponentManager.h" -#include "nsWidgetsCID.h" -#include "nsGfxCIID.h" -#include "nsViewsCID.h" -#include "nsPluginsCID.h" - -#include "nsIBrowserWindow.h" -#include "nsIWebShell.h" -#include "nsIDocumentLoader.h" -#include "nsIThrobber.h" - -#include "nsParserCIID.h" -#include "nsDOMCID.h" -#include "nsLayoutCID.h" -#include "nsINetService.h" - -#include "nsEditorCID.h" - -#ifdef XP_PC - -#define WIDGET_DLL "raptorwidget.dll" -#define GFXWIN_DLL "raptorgfxwin.dll" -#define VIEW_DLL "raptorview.dll" -#define WEB_DLL "raptorweb.dll" -#define PLUGIN_DLL "raptorplugin.dll" -#define PREF_DLL "xppref32.dll" -#define PARSER_DLL "raptorhtmlpars.dll" -#define DOM_DLL "jsdom.dll" -#define LAYOUT_DLL "raptorhtml.dll" -#define NETLIB_DLL "netlib.dll" -#define EDITOR_DLL "ender.dll" - -#else - -#ifdef XP_MAC - -#define WIDGET_DLL "WIDGET_DLL" -#define GFXWIN_DLL "GFXWIN_DLL" -#define VIEW_DLL "VIEW_DLL" -#define WEB_DLL "WEB_DLL" -#define PLUGIN_DLL "PLUGIN_DLL" -#define PREF_DLL "PREF_DLL" -#define PARSER_DLL "PARSER_DLL" -#define DOM_DLL "DOM_DLL" -#define LAYOUT_DLL "LAYOUT_DLL" -#define NETLIB_DLL "NETLIB_DLL" -//#define EDITOR_DLL "EDITOR_DLL" // temporary - -#else - -// XP_UNIX -#ifndef WIDGET_DLL -#define WIDGET_DLL "libwidgetmotif.so" -#endif -#ifndef GFXWIN_DLL -#define GFXWIN_DLL "libgfxmotif.so" -#endif -#define VIEW_DLL "libraptorview.so" -#define WEB_DLL "libraptorwebwidget.so" -#define PLUGIN_DLL "raptorplugin.so" -#define PREF_DLL "libpref.so" -#define PARSER_DLL "libraptorhtmlpars.so" -#define DOM_DLL "libjsdom.so" -#define LAYOUT_DLL "libraptorhtml.so" -#define NETLIB_DLL "libnetlib.so" -#define EDITOR_DLL "libeditor.so" -#endif // XP_MAC - -#endif // XP_PC - -// Class ID's -static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID); -static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID); -static NS_DEFINE_IID(kCDialogCID, NS_DIALOG_CID); -static NS_DEFINE_IID(kCLabelCID, NS_LABEL_CID); -static NS_DEFINE_IID(kCAppShellCID, NS_APPSHELL_CID); -static NS_DEFINE_IID(kCToolkitCID, NS_TOOLKIT_CID); -static NS_DEFINE_IID(kCWindowIID, NS_WINDOW_CID); -static NS_DEFINE_IID(kCScrollbarIID, NS_VERTSCROLLBAR_CID); -static NS_DEFINE_IID(kCHScrollbarIID, NS_HORZSCROLLBAR_CID); -static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID); -static NS_DEFINE_IID(kCComboBoxCID, NS_COMBOBOX_CID); -static NS_DEFINE_IID(kCListBoxCID, NS_LISTBOX_CID); -static NS_DEFINE_IID(kCRadioButtonCID, NS_RADIOBUTTON_CID); -static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID); -static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID); -static NS_DEFINE_IID(kCCheckButtonIID, NS_CHECKBUTTON_CID); -static NS_DEFINE_IID(kCChildIID, NS_CHILD_CID); -static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID); -static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID); -static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID); -static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID); -static NS_DEFINE_IID(kCRegionIID, NS_REGION_CID); -static NS_DEFINE_IID(kCBlenderIID, NS_BLENDER_CID); -static NS_DEFINE_IID(kCDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); -static NS_DEFINE_IID(kCDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID); -static NS_DEFINE_IID(kCViewManagerCID, NS_VIEW_MANAGER_CID); -static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID); -static NS_DEFINE_IID(kCScrollingViewCID, NS_SCROLLING_VIEW_CID); -static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); -static NS_DEFINE_IID(kCDocumentLoaderCID, NS_DOCUMENTLOADER_CID); -static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID); -static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); -static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID); -static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); -static NS_DEFINE_IID(kCDOMScriptObjectFactory, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); -static NS_DEFINE_IID(kCDOMNativeObjectRegistry, NS_DOM_NATIVE_OBJECT_REGISTRY_CID); -static NS_DEFINE_IID(kCHTMLDocument, NS_HTMLDOCUMENT_CID); -static NS_DEFINE_IID(kCXMLDocument, NS_XMLDOCUMENT_CID); -static NS_DEFINE_IID(kCImageDocument, NS_IMAGEDOCUMENT_CID); -static NS_DEFINE_IID(kCRangeListCID, NS_RANGELIST_CID); -static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID); -static NS_DEFINE_IID(kCHTMLImageElement, NS_HTMLIMAGEELEMENT_CID); -static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); - -static NS_DEFINE_IID(kCImageButtonCID, NS_IMAGEBUTTON_CID); -static NS_DEFINE_IID(kCToolbarCID, NS_TOOLBAR_CID); -static NS_DEFINE_IID(kCToolbarManagerCID, NS_TOOLBARMANAGER_CID); -static NS_DEFINE_IID(kCToolbarItemHolderCID, NS_TOOLBARITEMHOLDER_CID); -static NS_DEFINE_IID(kCPopUpMenuCID, NS_POPUPMENU_CID); -static NS_DEFINE_IID(kCMenuButtonCID, NS_MENUBUTTON_CID); -static NS_DEFINE_IID(kCMenuBarCID, NS_MENUBAR_CID); -static NS_DEFINE_IID(kCMenuCID, NS_MENU_CID); -static NS_DEFINE_IID(kCMenuItemCID, NS_MENUITEM_CID); -static NS_DEFINE_IID(kCEditorCID, NS_EDITOR_CID); -static NS_DEFINE_IID(kCXULCommandCID, NS_XULCOMMAND_CID); - -extern "C" void -NS_SetupRegistry() -{ - nsComponentManager::RegisterComponent(kLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCHScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCDialogCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCLabelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCCheckButtonIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCChildIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCRegionIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCBlenderIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCDeviceContextSpecCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCDeviceContextSpecFactoryCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCViewManagerCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCScrollingViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kWebShellCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCDocumentLoaderCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kThrobberCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCPluginHostCID, NULL, NULL, PLUGIN_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCDOMScriptObjectFactory, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCDOMNativeObjectRegistry, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCHTMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCXMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCImageDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCRangeListCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCRangeCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCHTMLImageElement, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - - nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); - - nsComponentManager::RegisterComponent(kCImageButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCToolbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCToolbarManagerCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCToolbarItemHolderCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCPopUpMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCMenuButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCMenuBarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCMenuItemCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kCXULCommandCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); -#ifndef XP_MAC // temporary - nsComponentManager::RegisterComponent(kCEditorCID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); -#endif // XP_MAC -} diff --git a/xpfe/xpviewer/src/nsUnixStubs.cpp b/xpfe/xpviewer/src/nsUnixStubs.cpp deleted file mode 100644 index 8b53d80d6bdc..000000000000 --- a/xpfe/xpviewer/src/nsUnixStubs.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - - -#include "xp_mcom.h" -#include "net.h" -#include "xp_linebuf.h" -#include "mkbuf.h" - -#ifndef MOZ_USER_DIR -#define MOZ_USER_DIR ".mozilla" -#endif - -extern "C" XP_Bool ValidateDocData(MWContext *window_id) -{ - printf("ValidateDocData not implemented, stubbed in webshell/tests/viewer/nsStubs.cpp\n"); - return PR_TRUE; -} - -/* dist/public/xp/xp_linebuf.h */ -extern "C" int XP_ReBuffer (const char *net_buffer, int32 net_buffer_size, - uint32 desired_buffer_size, - char **bufferP, uint32 *buffer_sizeP, - uint32 *buffer_fpP, - int32 (*per_buffer_fn) (char *buffer, - uint32 buffer_size, - void *closure), - void *closure) -{ - - printf("XP_ReBuffer not implemented, stubbed in webshell/tests/viewer/nsStubs.cpp\n"); - return(0); -} - - - -/* mozilla/include/xp_trace.h */ - -extern "C" void XP_Trace( const char *, ... ) -{ - printf("XP_Trace not implemented, stubbed in webshell/tests/viewer/nsStubs.cpp\n"); - - -} - -extern "C" char *fe_GetConfigDir(void) { - char *home = getenv("HOME"); - if (home) { - int len = strlen(home); - len += strlen("/") + strlen(MOZ_USER_DIR) + 1; - - char* config_dir = (char *)XP_CALLOC(len, sizeof(char)); - // we really should use XP_STRN*_SAFE but this is MODULAR_NETLIB - XP_STRCPY(config_dir, home); - XP_STRCAT(config_dir, "/"); - XP_STRCAT(config_dir, MOZ_USER_DIR); - return config_dir; - } - - return strdup("/tmp"); -} diff --git a/xpfe/xpviewer/src/nsViewerApp.cpp b/xpfe/xpviewer/src/nsViewerApp.cpp deleted file mode 100644 index 268bb2c60e9d..000000000000 --- a/xpfe/xpviewer/src/nsViewerApp.cpp +++ /dev/null @@ -1,1380 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifdef NGPREFS -#define INITGUID -#endif -#include "nsViewerApp.h" -#include "nsBrowserWindow.h" -#include "nsXPBaseWindow.h" -#include "nsWidgetsCID.h" -#include "nsIAppShell.h" -#include "nsIPref.h" -#include "nsINetService.h" -#include "nsIComponentManager.h" -//#include "nsWebCrawler.h" -#include "prprf.h" -#include "plstr.h" -#include "prenv.h" - -// Needed for Dialog GUI -#include "nsIDialog.h" -#include "nsICheckButton.h" -#include "nsILabel.h" -#include "nsIButton.h" -#include "nsITextWidget.h" -#include "nsILookAndFeel.h" -#include "nsColor.h" -#include "nsWidgetSupport.h" - -// XXX For font setting below -#include "nsFont.h" -#include "nsUnitConversion.h" -#include "nsIDeviceContext.h" - -#define DIALOG_FONT "Helvetica" -#define DIALOG_FONT_SIZE 10 - - -#ifdef XP_PC -#include "JSConsole.h" -#ifdef NGPREFS -#include "ngprefs.h" -#endif -#endif - -#ifdef MOZ_FULLCIRCLE -#include -#endif - -extern nsresult NS_NewBrowserWindowFactory(nsIFactory** aFactory); -extern nsresult NS_NewXPBaseWindowFactory(nsIFactory** aFactory); -extern "C" void NS_SetupRegistry(); - -static NS_DEFINE_IID(kAppShellCID, NS_APPSHELL_CID); -static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); -static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID); -static NS_DEFINE_IID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID); - -static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID); -static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID); -static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID); -static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID); -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - - -/* MOZ_TIMEBOMB should be of the form "Dec 04 1998 14:19:09" */ - -/* TIMEBOMB_GOES_HERE */ - -#ifdef MOZ_TIMEBOMB -#include -#endif - -static PRBool -CheckTimebomb(void) -{ -#ifdef MOZ_TIMEBOMB - PRTime die, now = PR_Now(); - if (PR_FAILURE == PR_ParseTimeString(MOZ_TIMEBOMB, PR_FALSE, &die) || - LL_CMP(now, >, die)) { - char * err = PR_smprintf("Your browser expired at: %s.\nGet a new one from http://www.mozilla.org/\n", MOZ_TIMEBOMB); - fputs(err, stderr); - /* TIMEBOMB EXPIRED */ - return PR_FALSE; - } else { - fputs("You have not expired, but you are using pre-release\n", stderr); - fputs("software. Use at your own risk.\n", stderr); - } -#endif - return PR_TRUE; -} - -nsViewerApp::nsViewerApp() -{ - char * text = PR_GetEnv("NGLAYOUT_HOME"); - - mStartURL = text ? text : "http://www.mozilla.org"; - - mDelay = 1; - mRepeatCount = 1; - mNumSamples = 10; - mAllowPlugins = PR_TRUE; - mIsInitialized = PR_FALSE; -} - -nsViewerApp::~nsViewerApp() -{ - Destroy(); - if (nsnull != mPrefs) { - mPrefs->Shutdown(); - NS_RELEASE(mPrefs); - } -} - -NS_IMPL_THREADSAFE_ADDREF(nsViewerApp) -NS_IMPL_THREADSAFE_RELEASE(nsViewerApp) - -nsresult -nsViewerApp::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } -#if defined(NS_DEBUG) - /* - * Check for the debug-only interface indicating thread-safety - */ - static NS_DEFINE_IID(kIsThreadsafeIID, NS_ISTHREADSAFE_IID); - if (aIID.Equals(kIsThreadsafeIID)) { - return NS_OK; - } -#endif /* NS_DEBUG */ - - return NS_NOINTERFACE; -} - -void -nsViewerApp::Destroy() -{ - // Close all of our windows - nsBrowserWindow::CloseAllWindows(); - - // Release the crawler - //NS_IF_RELEASE(mCrawler); - - // Only shutdown if Initialize has been called... - if (PR_TRUE == mIsInitialized) { - NS_ShutdownINetService(); - mIsInitialized = PR_FALSE; - } -} - -nsresult -nsViewerApp::SetupRegistry() -{ - NS_SetupRegistry(); - - // Register our browser window factory - nsIFactory* bwf; - NS_NewBrowserWindowFactory(&bwf); - nsComponentManager::RegisterFactory(kBrowserWindowCID, NULL, NULL, bwf, PR_FALSE); - - NS_NewXPBaseWindowFactory(&bwf); - nsComponentManager::RegisterFactory(kXPBaseWindowCID, NULL, NULL, bwf, PR_FALSE); - - return NS_OK; -} - -nsresult -nsViewerApp::Initialize(int argc, char** argv) -{ - nsresult rv; - - rv = SetupRegistry(); - if (NS_OK != rv) { - return rv; - } - - // Create widget application shell - rv = nsComponentManager::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, - (void**)&mAppShell); - if (NS_OK != rv) { - return rv; - } - mAppShell->Create(&argc, argv); - - // Load preferences - rv = nsComponentManager::CreateInstance(kPrefCID, NULL, kIPrefIID, - (void **) &mPrefs); - if (NS_OK != rv) { - return rv; - } - mPrefs->Startup("prefs.js"); - - if (!CheckTimebomb()) - return NS_ERROR_FAILURE; - - // Load Fullcircle Talkback crash-reporting mechanism. - // http://www.fullcirclesoftware.com for more details. - // Private build only. -#ifdef MOZ_FULLCIRCLE - // This probably needs to be surrounded by a pref, the - // old 5.0 world used "general.fullcircle_enable". - - { - FC_ERROR fcstatus = FC_ERROR_FAILED; - fcstatus = FCInitialize(); - - // Print out error status. - switch(fcstatus) { - case FC_ERROR_OK: - printf("Talkback loaded Ok.\n"); - break; - case FC_ERROR_CANT_INITIALIZE: - printf("Talkback error: Can't initialize.\n"); - break; - case FC_ERROR_NOT_INITIALIZED: - printf("Talkback error: Not initialized.\n"); - break; - case FC_ERROR_ALREADY_INITIALIZED: - printf("Talkback error: Already initialized.\n"); - break; - case FC_ERROR_FAILED: - printf("Talkback error: Failure.\n"); - break; - case FC_ERROR_OUT_OF_MEMORY: - printf("Talkback error: Out of memory.\n"); - break; - case FC_ERROR_INVALID_PARAMETER: - printf("Talkback error: Invalid parameter.\n"); - break; - default: - printf("Talkback error: Unknown error status.\n"); - break; - } - } -#endif - - // Setup networking library - rv = NS_InitINetService(); - if (NS_OK != rv) { - return rv; - } - -#if 0 - // XXX where should this live - for (int i=0; iMakeRLWindowWithCallback(DumpRLValues, this); - } -#endif - - // Finally process our arguments - rv = ProcessArguments(argc, argv); - - mIsInitialized = PR_TRUE; - - // Open first window (used to be in main()). - nsIBrowserWindow *newInterface = NULL; - OpenWindow( (PRUint32)~0, newInterface ); - if ( newInterface ) { - nsBrowserWindow *newWindow = (nsBrowserWindow*)newInterface; // hack - // Check for URL on command line. - if( argc>1 ) { - nsString startURL = argv[1]; - newWindow->GoTo(startURL); - } else { - // Use default start page. - newWindow->GoTo(mStartURL); - } - // Show the window. - newWindow->Show(); - } - - return rv; -} - - - -static void -PrintHelpInfo(char **argv) -{ - fprintf(stderr, "Usage: %s [-p][-q][-md #][-f filename][-d #][-np] [starting url]\n", argv[0]); - fprintf(stderr, "\t-p[#] -- run purify, optionally with a # that says which sample to stop at. For example, -p2 says to run samples 0, 1, and 2.\n"); - fprintf(stderr, "\t-q -- run quantify\n"); - fprintf(stderr, "\t-md # -- set the crt debug flags to #\n"); - fprintf(stderr, "\t-d # -- set the delay between URL loads to # (in milliseconds)\n"); - fprintf(stderr, "\t-r # -- set the repeat count, which is the number of times the URLs will be loaded in batch mode.\n"); - fprintf(stderr, "\t-f filename -- read a list of URLs from \n"); - fprintf(stderr, "\t-o dirname -- create an output file for the frame dump of each page and put it in \n\t\t must include the trailing character appropriate for your OS\n"); - fprintf(stderr, "\t-h # -- the initial height of the viewer window."); - fprintf(stderr, "\t-w # -- the initial width of the viewer window."); - fprintf(stderr, "\t-filter filtername -- make 'Dump Frames' command use the filter to alter the output.\n\t\tfiltername = none, dump all frames\n\t\tfiltername = table, dump only table frames\n"); - fprintf(stderr, "\t-C -- enable crawler\n"); - fprintf(stderr, "\t-R filename -- record pages visited in \n"); - fprintf(stderr, "\t-S domain -- add a domain/host that is safe to crawl (e.g. www.netscape.com)\n"); - fprintf(stderr, "\t-A domain -- add a domain/host that should be avoided (e.g. microsoft.com)\n"); - fprintf(stderr, "\t-N pages -- set the max # of pages to crawl\n"); - fprintf(stderr, "\t-np -- no plugins\n"); -} - -/*static void -AddTestDocsFromFile(nsWebCrawler* aCrawler, const nsString& aFileName) -{ - char cfn[1000]; - aFileName.ToCString(cfn, sizeof(cfn)); -#ifdef XP_PC - FILE* fp = fopen(cfn, "rb"); -#else - FILE* fp = fopen(cfn, "r"); -#endif - - if (nsnull==fp) - { - fprintf(stderr, "Input file not found: %s\n", cfn); - exit (-1); - } - nsAutoString line; - for (;;) { - char linebuf[2000]; - char* cp = fgets(linebuf, sizeof(linebuf), fp); - if (nsnull == cp) { - break; - } - if (linebuf[0] == '#') { - continue; - } - - // strip crlf's from the line - int len = strlen(linebuf); - if (0 != len) { - if (('\n' == linebuf[len-1]) || ('\r' == linebuf[len-1])) { - linebuf[--len] = 0; - } - } - if (0 != len) { - if (('\n' == linebuf[len-1]) || ('\r' == linebuf[len-1])) { - linebuf[--len] = 0; - } - } - - // Add non-empty lines to the test list - if (0 != len) { - line = linebuf; - aCrawler->AddURL(line); - } - } - - fclose(fp); -} -*/ -NS_IMETHODIMP -nsViewerApp::ProcessArguments(int argc, char** argv) -{ -/* mCrawler = new nsWebCrawler(this); - NS_ADDREF(mCrawler); - - int i; - for (i = 1; i < argc; i++) { - if (argv[i][0] == '-') { - if (PL_strncmp(argv[i], "-p", 2) == 0) { - char *optionalSampleStopIndex = &(argv[i][2]); - if ('\0' != *optionalSampleStopIndex) - { - if (1!=sscanf(optionalSampleStopIndex, "%d", &mNumSamples)) - { - PrintHelpInfo(argv); - exit(-1); - } - } - mDoPurify = PR_TRUE; - mCrawler->SetExitOnDone(PR_TRUE); - mCrawl = PR_TRUE; - } - else if (PL_strcmp(argv[i], "-q") == 0) { - mCrawler->EnableJiggleLayout(); - mCrawler->SetExitOnDone(PR_TRUE); - mCrawl = PR_TRUE; - } - else if (PL_strcmp(argv[i], "-f") == 0) { - mLoadTestFromFile = PR_TRUE; - i++; - if (i>=argc || nsnull==argv[i] || nsnull==*(argv[i])) - { - PrintHelpInfo(argv); - exit(-1); - } - mInputFileName = argv[i]; - mCrawler->SetExitOnDone(PR_TRUE); - mCrawl = PR_TRUE; - } - else if (PL_strcmp(argv[i], "-o") == 0) { - i++; - if (i>=argc || nsnull==argv[i] || nsnull==*(argv[i])) - { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->SetOutputDir(argv[i]); - } - else if (PL_strcmp(argv[i], "-filter") == 0) { - i++; - if (i>=argc || nsnull==argv[i] || nsnull==*(argv[i])) - { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->SetFilter(argv[i]); - } - else if (PL_strcmp(argv[i], "-d") == 0) { - int delay; - i++; - if (i>=argc || 1!=sscanf(argv[i], "%d", &delay)) - { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->SetDelay(delay); - } - else if (PL_strcmp(argv[i], "-w") == 0) { - int width; - i++; - if (i>=argc || 1!=sscanf(argv[i], "%d", &width)) - { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->SetWidth(width); - } - else if (PL_strcmp(argv[i], "-h") == 0) { - int height; - i++; - if (i>=argc || 1!=sscanf(argv[i], "%d", &height)) - { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->SetHeight(height); - } - else if (PL_strcmp(argv[i], "-r") == 0) { - i++; - if (i>=argc || 1!=sscanf(argv[i], "%d", &mRepeatCount)) - { - PrintHelpInfo(argv); - exit(-1); - } - } - else if (PL_strcmp(argv[i], "-C") == 0) { - mCrawler->EnableCrawler(); - mCrawler->SetExitOnDone(PR_TRUE); - mCrawl = PR_TRUE; - } - else if (PL_strcmp(argv[i], "-R") == 0) { - i++; - if (i>=argc) { - PrintHelpInfo(argv); - exit(-1); - } - FILE* fp = fopen(argv[i], "w"); - if (nsnull == fp) { - fprintf(stderr, "can't create '%s'\n", argv[i]); - exit(-1); - } - mCrawler->SetRecordFile(fp); - } - else if (PL_strcmp(argv[i], "-S") == 0) { - i++; - if (i>=argc) { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->AddSafeDomain(argv[i]); - } - else if (PL_strcmp(argv[i], "-A") == 0) { - i++; - if (i>=argc) { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->AddAvoidDomain(argv[i]); - } - else if (PL_strcmp(argv[i], "-N") == 0) { - int pages; - i++; - if (i>=argc || 1!=sscanf(argv[i], "%d", &pages)) { - PrintHelpInfo(argv); - exit(-1); - } - mCrawler->SetMaxPages(pages); - } - else if (PL_strcmp(argv[i], "-np") == 0) { - mAllowPlugins = PR_FALSE; - } - else { - PrintHelpInfo(argv); - exit(-1); - } - } - else - break; - } - if (i < argc) { - mStartURL = argv[i]; - }*/ - return NS_OK; -} - -NS_IMETHODIMP -nsViewerApp::OpenWindow() -{ - // Create browser window - // XXX Some piece of code needs to properly hold the reference to this - // browser window. For the time being the reference is released by the - // browser event handling code during processing of the NS_DESTROY event... - nsBrowserWindow* bw = nsnull; - nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, - kIBrowserWindowIID, - (void**) &bw); - bw->SetApp(this); - bw->Init(mAppShell, mPrefs, nsRect(0, 0, 620, 400), PRUint32(~0), mAllowPlugins); - bw->Show(); - - // Create browser window - // XXX Some piece of code needs to properly hold the reference to this - // browser window. For the time being the reference is released by the - // browser event handling code during processing of the NS_DESTROY event... - /*nsXPDialogWindow* dialog = nsnull; - rv = nsComponentManager::CreateInstance(kXPDialogWindowCID, nsnull, - kIXPDialogWindowIID, - (void**) &dialog); - dialog->SetApp(this); - dialog->Init(mAppShell, mPrefs, nsRect(0, 0, 385, 175), PRUint32(~0), mAllowPlugins); - nsString findHTML("resource:/res/samples/find.html"); - dialog->LoadURL(findHTML); - dialog->Show();*/ - - /*mCrawler->SetBrowserWindow(bw); - - if (mDoPurify) { - for (PRInt32 i = 0; i < mRepeatCount; i++) { - for (int docnum = 0; docnum < mNumSamples; docnum++) { - char url[500]; - PR_snprintf(url, 500, "%s/test%d.html", SAMPLES_BASE_URL, docnum); - mCrawler->AddURL(url); - } - } - mCrawler->Start(); - } - else if (mLoadTestFromFile) { - for (PRInt32 i = 0; i < mRepeatCount; i++) { - AddTestDocsFromFile(mCrawler, mInputFileName); - } - mCrawler->Start(); - } - else if (mCrawl) { - mCrawler->AddURL(mStartURL); - mCrawler->Start(); - } - else {*/ - bw->GoTo(mStartURL); - //} - NS_RELEASE(bw); - - return NS_OK; -} - -NS_IMETHODIMP -nsViewerApp::OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow) -{ - // Create browser window - nsBrowserWindow* bw = nsnull; - nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, - kIBrowserWindowIID, - (void**) &bw); - bw->SetApp(this); - bw->Init(mAppShell, mPrefs, nsRect(0, 0, 620, 400), aNewChromeMask, mAllowPlugins); - - aNewWindow = bw; - - return NS_OK; -} - -// I think this should be punted to the app shell to allow for "view source" to be -// better separated from plain browsing. But, this way is better given the current -// situation. -NS_IMETHODIMP -nsViewerApp::ViewSourceFor(const PRUnichar *pURL) -{ - - // Create browser window - nsViewSourceWindow* pNewWindow = new nsViewSourceWindow(mAppShell, mPrefs, this, pURL); - - return pNewWindow ? NS_OK : NS_ERROR_FAILURE; -} - -//---------------------------------------- - -// nsDispatchListener implementation - -void -nsViewerApp::AfterDispatch() -{ -} - -//---------------------------------------- - -#include "prenv.h" -#include "resources.h" -#include "nsIPresShell.h" -#include "nsIDocument.h" -#include "nsIURL.h" - -#ifndef XP_PC -#ifndef XP_MAC -#define _MAX_PATH 512 -#endif -#endif - -#define DEBUG_EMPTY "(none)" -static PRInt32 gDebugRobotLoads = 5000; -static char gVerifyDir[_MAX_PATH]; -static PRBool gVisualDebug = TRUE; - -// Robot -static nsIDialog * mRobotDialog = nsnull; -static nsIButton * mCancelBtn; -static nsIButton * mStartBtn; -static nsITextWidget * mVerDirTxt; -static nsITextWidget * mStopAfterTxt; -static nsICheckButton * mUpdateChkBtn; - -// Site -static nsIDialog * mSiteDialog = nsnull; -static nsIButton * mSiteCancelBtn; -static nsIButton * mSitePrevBtn; -static nsIButton * mSiteNextBtn; -static nsILabel * mSiteLabel; - -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); -static NS_DEFINE_IID(kButtonCID, NS_BUTTON_CID); -static NS_DEFINE_IID(kTextFieldCID, NS_TEXTFIELD_CID); -static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID); -static NS_DEFINE_IID(kDialogCID, NS_DIALOG_CID); -static NS_DEFINE_IID(kCheckButtonCID, NS_CHECKBUTTON_CID); -static NS_DEFINE_IID(kLabelCID, NS_LABEL_CID); - -static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); -static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); -static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID); -static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); -static NS_DEFINE_IID(kIDialogIID, NS_IDIALOG_IID); -static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); -static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); - - -static void* GetWidgetNativeData(nsISupports* aObject) -{ - void* result = nsnull; - nsIWidget* widget; - if (NS_OK == aObject->QueryInterface(kIWidgetIID,(void**)&widget)) - { - result = widget->GetNativeData(NS_NATIVE_WIDGET); - NS_RELEASE(widget); - } - return result; -} - - -#ifdef XP_PC - -extern JSConsole *gConsole; -// XXX temporary robot code until it's made XP -extern HINSTANCE gInstance, gPrevInstance; - -extern "C" NS_EXPORT int DebugRobot( - nsVoidArray * workList, nsIWebShell * ww, - int imax, char * verify_dir, - void (*yieldProc)(const char *)); - -#ifdef MOZ_DEBUG -void yieldProc(const char * str) -{ - // Process messages - MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - GetMessage(&msg, NULL, 0, 0); - if (!JSConsole::sAccelTable || - !gConsole || - !gConsole->GetMainWindow() || - !TranslateAccelerator(gConsole->GetMainWindow(), - JSConsole::sAccelTable, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } -} -#endif // MOZ_DEBUG -#endif - - -/**-------------------------------------------------------------------------------- - * HandleRobotEvent - *-------------------------------------------------------------------------------- - */ -nsEventStatus PR_CALLBACK HandleRobotEvent(nsGUIEvent *aEvent) -{ - nsEventStatus result = nsEventStatus_eIgnore; - if (aEvent == nsnull || aEvent->widget == nsnull) { - return result; - } - -/* switch(aEvent->message) { - case NS_MOUSE_LEFT_BUTTON_UP: { - if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mCancelBtn)) { - NS_ShowWidget(mRobotDialog,PR_FALSE); - } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mStartBtn)) { - - nsString str; - PRUint32 size; - - mStopAfterTxt->GetText(str, 255, size); - char * cStr = str.ToNewCString(); - sscanf(cStr, "%d", &gDebugRobotLoads); - if (gDebugRobotLoads <= 0) { - gDebugRobotLoads = 5000; - } - delete[] cStr; - - mVerDirTxt->GetText(str, 255, size); - str.ToCString(gVerifyDir, (PRInt32)_MAX_PATH); - if (!strcmp(gVerifyDir,DEBUG_EMPTY)) { - gVerifyDir[0] = '\0'; - } - PRBool state = PR_FALSE; - mUpdateChkBtn->GetState(state); - gVisualDebug = state ? TRUE: FALSE; - - } - - } break; - - case NS_PAINT: -#ifndef XP_UNIX - // paint the background - if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == mRobotDialog ) { - nsIRenderingContext *drawCtx = ((nsPaintEvent*)aEvent)->renderingContext; - drawCtx->SetColor(aEvent->widget->GetBackgroundColor()); - drawCtx->FillRect(*(((nsPaintEvent*)aEvent)->rect)); - - return nsEventStatus_eIgnore; - } -#endif - break; - - default: - result = nsEventStatus_eIgnore; - } //switch -*/ - return result; -} - -//-------------------------------------------- -// -//-------------------------------------------- -PRBool CreateRobotDialog(nsIWidget * aParent) -{ - - PRBool result = TRUE; - - if (mRobotDialog != nsnull) { - NS_ShowWidget(mRobotDialog,PR_TRUE); - NS_SetFocusToWidget(mStartBtn); - return TRUE; - } - - nsILabel * label; - - nsIDeviceContext* dc = aParent->GetDeviceContext(); - float t2d; - dc->GetTwipsToDevUnits(t2d); - nsFont font(DIALOG_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NSIntPointsToTwips(DIALOG_FONT_SIZE))); - NS_RELEASE(dc); - - nscoord dialogWidth = 375; - // create a Dialog - // - nsRect rect; - rect.SetRect(0, 0, dialogWidth, 162); - - nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mRobotDialog); - NS_CreateDialog(aParent, mRobotDialog,rect,HandleRobotEvent,&font); - mRobotDialog->SetLabel("Debug Robot Options"); - - nscoord txtHeight = 24; - nscolor textBGColor = NS_RGB(255,255,255); - nscolor textFGColor = NS_RGB(255,255,255); - - nsILookAndFeel * lookAndFeel; - if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { - lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); - lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); - } - - nscoord w = 65; - nscoord x = 5; - nscoord y = 10; - nscoord h = 19; - - // Create Update CheckButton - rect.SetRect(x, y, 150, 24); - nsComponentManager::CreateInstance(kCheckButtonCID, nsnull, kICheckButtonIID, (void**)&mUpdateChkBtn); - NS_CreateCheckButton(mRobotDialog, mUpdateChkBtn,rect,HandleRobotEvent,&font); - mUpdateChkBtn->SetLabel("Update Display (Visual)"); - mUpdateChkBtn->SetState(PR_TRUE); - y += 24 + 2; - - // Create Label - w = 115; - rect.SetRect(x, y+3, w, 24); - nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); - NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); - label->SetAlignment(eAlign_Right); - label->SetLabel("Verfication Directory:"); - x += w + 1; - - // Create TextField - nsIWidget* widget = nsnull; - rect.SetRect(x, y, 225, txtHeight); - nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mVerDirTxt); - NS_CreateTextWidget(mRobotDialog,mVerDirTxt,rect,HandleRobotEvent,&font); - if (mVerDirTxt && NS_OK == mVerDirTxt->QueryInterface(kIWidgetIID,(void**)&widget)) - { - widget->SetBackgroundColor(textBGColor); - widget->SetForegroundColor(textFGColor); - } - nsString str(DEBUG_EMPTY); - PRUint32 size; - mVerDirTxt->SetText(str,size); - - y += txtHeight + 2; - - x = 5; - w = 55; - rect.SetRect(x, y+4, w, 24); - nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); - NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); - label->SetAlignment(eAlign_Right); - label->SetLabel("Stop after:"); - x += w + 2; - - // Create TextField - rect.SetRect(x, y, 75, txtHeight); - nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mStopAfterTxt); - NS_CreateTextWidget(mRobotDialog,mStopAfterTxt,rect,HandleRobotEvent,&font); - if (mStopAfterTxt && NS_OK == mStopAfterTxt->QueryInterface(kIWidgetIID,(void**)&widget)) - { - widget->SetBackgroundColor(textBGColor); - widget->SetForegroundColor(textFGColor); - mStopAfterTxt->SetText("5000",size); - } - x += 75 + 2; - - w = 75; - rect.SetRect(x, y+4, w, 24); - nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); - NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); - label->SetAlignment(eAlign_Left); - label->SetLabel("(page loads)"); - y += txtHeight + 2; - - - y += 10; - w = 75; - nscoord xx = (dialogWidth - (2*w)) / 3; - // Create Find Start Button - rect.SetRect(xx, y, w, 24); - nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mStartBtn); - NS_CreateButton(mRobotDialog,mStartBtn,rect,HandleRobotEvent,&font); - mStartBtn->SetLabel("Start"); - - xx += w + xx; - // Create Cancel Button - rect.SetRect(xx, y, w, 24); - nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mCancelBtn); - NS_CreateButton(mRobotDialog,mCancelBtn,rect,HandleRobotEvent,&font); - mCancelBtn->SetLabel("Cancel"); - - NS_ShowWidget(mRobotDialog,PR_TRUE); - NS_SetFocusToWidget(mStartBtn); - return result; -} - - -NS_IMETHODIMP -nsViewerApp::CreateRobot(nsBrowserWindow* aWindow) -{ - if (CreateRobotDialog(aWindow->mWindow)) - { - nsIPresShell* shell = aWindow->GetPresShell(); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull!=doc) { - const char * str; - (void)doc->GetDocumentURL()->GetSpec(&str); - nsVoidArray * gWorkList = new nsVoidArray(); - gWorkList->AppendElement(new nsString(str)); -#if defined(XP_PC_ROBOT) && defined(NS_DEBUG) - DebugRobot( - gWorkList, - gVisualDebug ? aWindow->mWebShell : nsnull, - gDebugRobotLoads, - PL_strdup(gVerifyDir), - yieldProc); -#endif - } - } - } - return NS_OK; -} - - -//---------------------------------------- -static nsBrowserWindow* gWinData; -static int gTop100Pointer = 0; -static char * gTop100List[] = { - "http://www.yahoo.com", - "http://www.netscape.com", - "http://www.microsoft.com", - "http://www.excite.com", - "http://www.mckinley.com", - "http://www.city.net", - "http://www.webcrawler.com", - "http://www.mirabilis.com", - "http://www.infoseek.com", - "http://www.pathfinder.com", - "http://www.warnerbros.com", - "http://www.cnn.com", - "http://www.altavista.digital.com", - "http://www.altavista.com", - "http://www.usatoday.com", - "http://www.disney.com", - "http://www.starwave.com", - "http://www.hotwired.com", - "http://www.hotbot.com", - "http://www.lycos.com", - "http://www.pointcom.com", - "http://www.cnet.com", - "http://www.search.com", - "http://www.news.com", - "http://www.download.com", - "http://www.geocities.com", - "http://www.aol.com", - "http://members.aol.com", - "http://www.imdb.com", - "http://uk.imdb.com", - "http://www.macromedia.com", - "http://www.infobeat.com", - "http://www.fxweb.com", - "http://www.whowhere.com", - "http://www.real.com", - "http://www.sportsline.com", - "http://www.dejanews.com", - "http://www.the-park.com", - "http://www.cmpnet.com", - "http://www.go2net.com", - "http://www.metacrawler.com", - "http://www.playsite.com", - "http://www.stocksite.com", - "http://www.sony.com", - "http://www.music.sony.com", - "http://www.station.sony.com", - "http://www.scea.sony.com", - "http://www.infospace.com", - "http://www.zdnet.com", - "http://www.hotfiles.com", - "http://www.chathouse.com", - "http://www.looksmart.com", - "http://www.iamginegames.com", - "http://www.macaddict.com", - "http://www.rsac.org", - "http://www.apple.com", - "http://www.beseen.com", - "http://www.dogpile.com", - "http://www.xoom.com", - "http://www.tucows.com", - "http://www.freethemes.com", - "http://www.winfiles.com", - "http://www.vservers.com", - "http://www.mtv.com", - "http://www.the-xfiles.com", - "http://www.datek.com", - "http://www.cyberthrill.com", - "http://www.surplusdirect.com", - "http://www.tomshardware.com", - "http://www.bigyellow.com", - "http://www.100hot.com", - "http://www.messagemates.com", - "http://www.onelist.com", - "http://www.bluemountain.com", - "http://www.ea.com", - "http://www.bullfrog.co.uk", - "http://www.travelocity.com", - "http://www.ibm.com", - "http://www.bigcharts.com", - "http://www.davesclassics.com", - "http://www.goto.com", - "http://www.weather.com", - "http://www.gamespot.com", - "http://www.bloomberg.com", - "http://www.winzip.com", - "http://www.filez.com", - "http://www.westwood.com", - "http://www.internet.com", - "http://www.cardmaster.com", - "http://www.creaf.com", - "http://netaddress.usa.net", - "http://www.occ.com", - "http://www.as.org", - "http://www.amazon.com", - "http://www.drudgereport.com", - "http://www.hardradio.com", - "http://www.intel.com", - "http://www.mp3.com", - "http://www.ebay.com", - "http://www.msn.com", - "http://www.fifa.com", - "http://www.attitude.com", - "http://www.happypuppy.com", - "http://www.gamesdomain.com", - "http://www.onsale.com", - "http://www.tm.com", - "http://www.xlnc1.com", - "http://www.greatsports.com", - "http://www.discovery.com", - "http://www.nai.com", - "http://www.nasa.gov", - "http://www.ogr.com", - "http://www.warzone.com", - "http://www.gamestats.com", - "http://www.winamp.com", - "http://java.sun.com", - "http://www.hp.com", - "http://www.cdnow.com", - "http://www.nytimes.com", - "http://www.majorleaguebaseball.com", - "http://www.washingtonpost.com", - "http://www.planetquake.com", - "http://www.wsj.com", - "http://www.slashdot.org", - "http://www.adobe.com", - "http://www.quicken.com", - "http://www.talkcity.com", - "http://www.developer.com", - "http://www.mapquest.com", - 0 - }; - - -/**-------------------------------------------------------------------------------- - * HandleSiteEvent - *-------------------------------------------------------------------------------- - */ -nsEventStatus PR_CALLBACK HandleSiteEvent(nsGUIEvent *aEvent) -{ - nsEventStatus result = nsEventStatus_eIgnore; - if (aEvent == nsnull || aEvent->widget == nsnull) { - return result; - } - - switch(aEvent->message) { - - case NS_MOUSE_LEFT_BUTTON_UP: { - if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSiteCancelBtn)) { - NS_ShowWidget(mSiteDialog,PR_FALSE); - } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSitePrevBtn)) { - if (gTop100Pointer > 0) { - NS_EnableWidget(mSiteNextBtn,PR_TRUE); - if (gWinData) { - nsString urlStr(gTop100List[--gTop100Pointer]); - mSiteLabel->SetLabel(urlStr); - gWinData->GoTo(urlStr); - } - } else { - NS_EnableWidget(mSitePrevBtn,PR_FALSE); - NS_EnableWidget(mSiteNextBtn,PR_TRUE); - } - - } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSiteNextBtn)) { - - char * p = gTop100List[++gTop100Pointer]; - if (p) { - if (gWinData) { - nsString urlStr(gTop100List[gTop100Pointer]); - mSiteLabel->SetLabel(urlStr); - gWinData->GoTo(urlStr); - } - NS_EnableWidget(mSitePrevBtn,PR_TRUE); - } else { - NS_EnableWidget(mSitePrevBtn,PR_TRUE); - NS_EnableWidget(mSiteNextBtn,PR_FALSE); - mSiteLabel->SetLabel("[END OF LIST]"); - } - } - } break; - - case NS_PAINT: -#ifndef XP_UNIX - // paint the background - if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSiteDialog) ) { - nsIRenderingContext *drawCtx = ((nsPaintEvent*)aEvent)->renderingContext; - drawCtx->SetColor(aEvent->widget->GetBackgroundColor()); - drawCtx->FillRect(*(((nsPaintEvent*)aEvent)->rect)); - - return nsEventStatus_eIgnore; - } -#endif - break; - - default: - result = nsEventStatus_eIgnore; - } - - return result; -} - -//----------------------------------------- -//-- -//----------------------------------------- -PRBool CreateSiteDialog(nsIWidget * aParent) -{ - - PRBool result = TRUE; - - if (mSiteDialog == nsnull) { - nscoord txtHeight = 24; - nscolor textBGColor = NS_RGB(0,0,0); - nscolor textFGColor = NS_RGB(255,255,255); - - nsILookAndFeel * lookAndFeel; - if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { - //lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); - //lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); - //lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); - } - - nsILabel * label; - - nsIDeviceContext* dc = aParent->GetDeviceContext(); - float t2d; - dc->GetTwipsToDevUnits(t2d); - nsFont font(DIALOG_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NSIntPointsToTwips(DIALOG_FONT_SIZE))); - NS_RELEASE(dc); - - nscoord dialogWidth = 375; - // create a Dialog - // - nsRect rect; - rect.SetRect(0, 0, dialogWidth, 125); - - nsIWidget* widget = nsnull; - nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mSiteDialog); - if (mSiteDialog && NS_OK == mSiteDialog->QueryInterface(kIWidgetIID,(void**)&widget)) - { - widget->Create(aParent, rect, HandleSiteEvent, NULL); - mSiteDialog->SetLabel("Top 100 Site Walker"); - } - //mSiteDialog->SetClientData(this); - - nscoord w = 65; - nscoord x = 5; - nscoord y = 10; - nscoord h = 19; - - // Create Label - w = 50; - rect.SetRect(x, y+3, w, 24); - nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); - NS_CreateLabel(mSiteDialog,label,rect,HandleSiteEvent,&font); - label->SetAlignment(eAlign_Right); - label->SetLabel("Site:"); - x += w + 1; - - w = 250; - rect.SetRect(x, y+3, w, 24); - nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&mSiteLabel); - NS_CreateLabel(mSiteDialog,mSiteLabel,rect,HandleSiteEvent,&font); - mSiteLabel->SetAlignment(eAlign_Left); - mSiteLabel->SetLabel(""); - - y += 34; - w = 75; - nscoord spacing = (dialogWidth - (3*w)) / 4; - x = spacing; - // Create Previous Button - rect.SetRect(x, y, w, 24); - nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSitePrevBtn); - NS_CreateButton(mSiteDialog,mSitePrevBtn,rect,HandleSiteEvent,&font); - mSitePrevBtn->SetLabel("<< Previous"); - x += spacing + w; - - // Create Next Button - rect.SetRect(x, y, w, 24); - nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteNextBtn); - NS_CreateButton(mSiteDialog,mSiteNextBtn,rect,HandleSiteEvent,&font); - mSiteNextBtn->SetLabel("Next >>"); - x += spacing + w; - - // Create Cancel Button - rect.SetRect(x, y, w, 24); - nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteCancelBtn); - NS_CreateButton(mSiteDialog,mSiteCancelBtn,rect,HandleSiteEvent,&font); - mSiteCancelBtn->SetLabel("Cancel"); - } - - NS_ShowWidget(mSiteDialog,PR_TRUE); - NS_SetFocusToWidget(mSiteNextBtn); - - // Init - NS_EnableWidget(mSitePrevBtn,PR_FALSE); - - if (gWinData) { - nsString urlStr(gTop100List[gTop100Pointer]); - gWinData->GoTo(urlStr); - mSiteLabel->SetLabel(urlStr); - } - - return result; -} - - -NS_IMETHODIMP -nsViewerApp::CreateSiteWalker(nsBrowserWindow* aWindow) -{ - if (nsnull == gWinData) { - gWinData = aWindow; - NS_ADDREF(aWindow); - CreateSiteDialog(aWindow->mWindow); - } - return NS_OK; -} - -//---------------------------------------- - -#ifdef XP_PC -#include "jsconsres.h" - -static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_IID); - -static void DestroyConsole() -{ - if (gConsole) { - gConsole->SetNotification(NULL); - delete gConsole; - gConsole = NULL; - } -} - -#ifdef MOZ_DEBUG -static void ShowConsole(nsBrowserWindow* aWindow) -{ - HWND hWnd = (HWND)aWindow->mWindow->GetNativeData(NS_NATIVE_WIDGET); - if (!gConsole) { - - // load the accelerator table for the console - if (!JSConsole::sAccelTable) { - JSConsole::sAccelTable = LoadAccelerators(gInstance, - MAKEINTRESOURCE(ACCELERATOR_TABLE)); - } - - nsIScriptContextOwner *owner = nsnull; - nsIScriptContext *context = nsnull; - // XXX needs to change to aWindow->mWebShell - if (NS_OK == aWindow->mWebShell->QueryInterface(kIScriptContextOwnerIID, (void **)&owner)) { - if (NS_OK == owner->GetScriptContext(&context)) { - - // create the console - gConsole = JSConsole::CreateConsole(); - gConsole->SetContext(context); - // lifetime of the context is still unclear at this point. - // Anyway, as long as the web widget is alive the context is alive. - // Maybe the context shouldn't even be RefCounted - context->Release(); - gConsole->SetNotification(DestroyConsole); - } - - NS_RELEASE(owner); - } - else { - MessageBox(hWnd, "Unable to load JavaScript", "Viewer Error", MB_ICONSTOP); - } - } -} -#endif // MOZ_DEBUG -#endif - -NS_IMETHODIMP -nsViewerApp::CreateJSConsole(nsBrowserWindow* aWindow) -{ -#if defined( XP_PC ) && defined( MOZ_DEBUG ) - if (nsnull == gConsole) { - ShowConsole(aWindow); - } -#endif - return NS_OK; -} - -NS_IMETHODIMP -nsViewerApp::DoPrefs(nsBrowserWindow* aWindow) -{ -#if defined(XP_PC) && defined(NGPREFS) - INGLayoutPrefs *pPrefs; - CoInitialize(NULL); - - HRESULT res = CoCreateInstance(CLSID_NGLayoutPrefs, NULL, - CLSCTX_INPROC_SERVER, - IID_INGLayoutPrefs, (void**)&pPrefs); - - pPrefs->Show(NULL); - pPrefs->Release(); - CoUninitialize(); -#endif - return NS_OK; -} - -nsresult -nsViewerApp::Run() -{ - //OpenWindow(); - - // Process messages - /*MSG msg; - while (::GetMessage(&msg, NULL, 0, 0)) { - if (!JSConsole::sAccelTable || - !gConsole || - !gConsole->GetMainWindow() || - !TranslateAccelerator(gConsole->GetMainWindow(), - JSConsole::sAccelTable, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - return NS_OK;*/ - return mAppShell->Run(); -} - - -nsresult -nsViewerApp::Exit() -{ - Destroy(); - mAppShell->Exit(); - NS_RELEASE(mAppShell); - return NS_OK; -} diff --git a/xpfe/xpviewer/src/nsViewerApp.h b/xpfe/xpviewer/src/nsViewerApp.h deleted file mode 100644 index 0898326f4cf7..000000000000 --- a/xpfe/xpviewer/src/nsViewerApp.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#ifndef nsViewerApp_h___ -#define nsViewerApp_h___ - -#include "nsIAppShell.h" -#include "nsString.h" -#include "nsCRT.h" -#include "nsVoidArray.h" - -class nsIPref; -//class nsWebCrawler; -class nsBrowserWindow; -class nsIBrowserWindow; - -class nsViewerApp : public nsDispatchListener -{ -public: - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - nsViewerApp(); - virtual ~nsViewerApp(); - - // nsISupports - NS_DECL_ISUPPORTS - - // nsDispatchListener - virtual void AfterDispatch(); - - // nsViewerApp - NS_IMETHOD SetupRegistry(); - NS_IMETHOD Initialize(int argc, char** argv); - NS_IMETHOD ProcessArguments(int argc, char** argv); - NS_IMETHOD OpenWindow(); - NS_IMETHOD OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow); - NS_IMETHOD ViewSourceFor(const PRUnichar* pURL); - NS_IMETHOD CreateRobot(nsBrowserWindow* aWindow); - NS_IMETHOD CreateSiteWalker(nsBrowserWindow* aWindow); - NS_IMETHOD CreateJSConsole(nsBrowserWindow* aWindow); - NS_IMETHOD Exit(); - - NS_IMETHOD DoPrefs(nsBrowserWindow* aWindow); - - NS_IMETHOD Run(); - -protected: - - void Destroy(); - - nsIAppShell* mAppShell; - nsIPref* mPrefs; - nsString mStartURL; - PRBool mDoPurify; - PRBool mLoadTestFromFile; - //PRBool mCrawl; - nsString mInputFileName; - PRInt32 mNumSamples; - PRInt32 mDelay; - PRInt32 mRepeatCount; - //nsWebCrawler* mCrawler; - PRBool mAllowPlugins; - PRBool mIsInitialized; -}; - - -#endif /* nsViewerApp_h___ */ - diff --git a/xpfe/xpviewer/src/nsXPBaseWindow.cpp b/xpfe/xpviewer/src/nsXPBaseWindow.cpp deleted file mode 100644 index 5b07a932f9bf..000000000000 --- a/xpfe/xpviewer/src/nsXPBaseWindow.cpp +++ /dev/null @@ -1,887 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#include "nsIPref.h" -#include "prmem.h" - -#ifdef XP_MAC -#include "nsXPBaseWindow.h" -#define NS_IMPL_IDS -#else -#define NS_IMPL_IDS -#include "nsXPBaseWindow.h" -#endif - -#include "nsINetSupport.h" -#include "nsIAppShell.h" -#include "nsIWidget.h" -#include "nsIDOMDocument.h" -#include "nsIURL.h" -#include "nsIComponentManager.h" -#include "nsIFactory.h" -#include "nsCRT.h" -#include "nsWidgetsCID.h" -#include "nsViewerApp.h" - -#include "nsIDocument.h" -#include "nsIPresContext.h" -#include "nsIDocumentViewer.h" -#include "nsIContentViewer.h" -#include "nsIPresShell.h" -#include "nsIDocument.h" -#include "nsHTMLContentSinkStream.h" -#include "nsIDocument.h" -#include "nsIDOMEventReceiver.h" -#include "nsIDOMElement.h" -#include "nsIDOMHTMLDocument.h" -#include "nsWindowListener.h" - - -#if defined(WIN32) -#include -#else -#include -#endif - -// XXX For font setting below -#include "nsFont.h" -//#include "nsUnitConversion.h" -//#include "nsIDeviceContext.h" - -static NS_DEFINE_IID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID); -static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); -static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID); -static NS_DEFINE_IID(kDialogCID, NS_DIALOG_CID); - - -static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID); -static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID); -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID); -static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); -static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID); -static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID); -static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); - -static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID); -static NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID); -static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID); -static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID); - -static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID); - -//---------------------------------------------------------------------- -nsXPBaseWindow::nsXPBaseWindow() : - mContentRoot(nsnull), - mPrefs(nsnull), - mAppShell(nsnull), - mDocIsLoaded(PR_FALSE) -{ -} - -//---------------------------------------------------------------------- -nsXPBaseWindow::~nsXPBaseWindow() -{ - NS_IF_RELEASE(mContentRoot); - NS_IF_RELEASE(mPrefs); - NS_IF_RELEASE(mAppShell); -} - -//---------------------------------------------------------------------- -NS_IMPL_ADDREF(nsXPBaseWindow) -NS_IMPL_RELEASE(nsXPBaseWindow) - -//---------------------------------------------------------------------- -nsresult nsXPBaseWindow::QueryInterface(const nsIID& aIID, - void** aInstancePtrResult) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - - *aInstancePtrResult = NULL; - - if (aIID.Equals(kIXPBaseWindowIID)) { - *aInstancePtrResult = (void*) ((nsIXPBaseWindow*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kIStreamObserverIID)) { - *aInstancePtrResult = (void*) ((nsIStreamObserver*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kIWebShellContainerIID)) { - *aInstancePtrResult = (void*) ((nsIWebShellContainer*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kINetSupportIID)) { - *aInstancePtrResult = (void*) ((nsINetSupport*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kIDOMMouseListenerIID)) { - NS_ADDREF_THIS(); // Increase reference count for caller - *aInstancePtrResult = (void *)((nsIDOMMouseListener*)this); - return NS_OK; - } - - if (aIID.Equals(kISupportsIID)) { - NS_ADDREF_THIS(); - *aInstancePtrResult = (void*) ((nsISupports*)((nsIXPBaseWindow*)this)); - return NS_OK; - } - - return NS_NOINTERFACE; -} - - -//---------------------------------------------------------------------- -static nsEventStatus PR_CALLBACK -HandleXPDialogEvent(nsGUIEvent *aEvent) -{ - nsEventStatus result = nsEventStatus_eIgnore; - - nsXPBaseWindow* baseWin; - aEvent->widget->GetClientData(((void*&)baseWin)); - - if (nsnull != baseWin) { - nsSizeEvent* sizeEvent; - switch(aEvent->message) { - case NS_SIZE: - sizeEvent = (nsSizeEvent*)aEvent; - baseWin->Layout(sizeEvent->windowSize->width, - sizeEvent->windowSize->height); - result = nsEventStatus_eConsumeNoDefault; - break; - - case NS_DESTROY: { - //nsViewerApp* app = baseWin->mApp; - result = nsEventStatus_eConsumeDoDefault; - baseWin->Close(); - NS_RELEASE(baseWin); - } - return result; - - default: - break; - } - //NS_RELEASE(baseWin); - } - return result; -} - - -//---------------------------------------------------------------------- -nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, - nsIAppShell* aAppShell, - nsIPref* aPrefs, - const nsString& aDialogURL, - const nsString& aTitle, - const nsRect& aBounds, - PRUint32 aChromeMask, - PRBool aAllowPlugins) -{ - mAllowPlugins = aAllowPlugins; - mWindowType = aType; - mAppShell = aAppShell; - NS_IF_ADDREF(mAppShell); - - mPrefs = aPrefs; - NS_IF_ADDREF(mPrefs); - - // Create top level window - nsresult rv; - if (aType == eXPBaseWindowType_window) { - rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, - (void**)&mWindow); - } else { - rv= nsComponentManager::CreateInstance(kDialogCID, nsnull, kIWidgetIID, - (void**)&mWindow); - } - - if (NS_OK != rv) { - return rv; - } - - mWindow->SetClientData(this); - - nsWidgetInitData initData; - initData.mBorderStyle = eBorderStyle_window; - - nsRect r(0, 0, aBounds.width, aBounds.height); - mWindow->Create((nsIWidget*)NULL, r, HandleXPDialogEvent, - nsnull, aAppShell, nsnull, &initData); - mWindow->GetBounds(r); - - // Create web shell - rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, - kIWebShellIID, - (void**)&mWebShell); - if (NS_OK != rv) { - return rv; - } - r.x = r.y = 0; - rv = mWebShell->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET), - r.x, r.y, r.width, r.height, - nsScrollPreference_kNeverScroll, //nsScrollPreference_kAuto, - aAllowPlugins, PR_FALSE); - mWebShell->SetContainer((nsIWebShellContainer*) this); - mWebShell->SetObserver((nsIStreamObserver*)this); - mWebShell->SetPrefs(aPrefs); - mWebShell->Show(); - - // Now lay it all out - Layout(r.width, r.height); - - // Load URL to Load GUI - mDialogURL = aDialogURL; - LoadURL(mDialogURL); - - SetTitle(aTitle); - - return NS_OK; -} - -//---------------------------------------------------------------------- -void nsXPBaseWindow::ForceRefresh() -{ - nsIPresShell* shell; - GetPresShell(shell); - if (nsnull != shell) { - nsIViewManager* vm = shell->GetViewManager(); - if (nsnull != vm) { - nsIView* root; - vm->GetRootView(root); - if (nsnull != root) { - vm->UpdateView(root, (nsIRegion*)nsnull, NS_VMREFRESH_IMMEDIATE | - NS_VMREFRESH_AUTO_DOUBLE_BUFFER); - } - NS_RELEASE(vm); - } - NS_RELEASE(shell); - } -} - -//---------------------------------------------------------------------- -void nsXPBaseWindow::Layout(PRInt32 aWidth, PRInt32 aHeight) -{ - nsRect rr(0, 0, aWidth, aHeight); - mWebShell->SetBounds(rr.x, rr.y, rr.width, rr.height); -} - -//---------------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::SetLocation(PRInt32 aX, PRInt32 aY) -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - mWindow->Move(aX, aY); - return NS_OK; -} - - -//---------------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::SetDimensions(PRInt32 aWidth, PRInt32 aHeight) -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - - // XXX We want to do this in one shot - mWindow->Resize(aWidth, aHeight, PR_FALSE); - Layout(aWidth, aHeight); - - return NS_OK; -} - -//---------------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::GetBounds(nsRect& aBounds) -{ - mWindow->GetBounds(aBounds); - return NS_OK; -} - -//---------------------------------------------------------------------- -NS_IMETHODIMP -nsXPBaseWindow::GetWindowBounds(nsRect& aBounds) -{ - //XXX This needs to be non-client bounds when it exists. - mWindow->GetBounds(aBounds); - return NS_OK; -} - -//---------------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::SetVisible(PRBool aIsVisible) -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - mWindow->Show(aIsVisible); - return NS_OK; -} - -//---------------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::Close() -{ - if (nsnull != mWindowListener) { - mWindowListener->Destroy(this); - } - - if (nsnull != mWebShell) { - mWebShell->Destroy(); - NS_RELEASE(mWebShell); - } - - if (nsnull != mWindow) { - nsIWidget* w = mWindow; - NS_RELEASE(w); - } - - return NS_OK; -} - - -//---------------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::GetWebShell(nsIWebShell*& aResult) -{ - aResult = mWebShell; - NS_IF_ADDREF(mWebShell); - return NS_OK; -} - -//--------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::SetTitle(const PRUnichar* aTitle) -{ - NS_PRECONDITION(nsnull != mWindow, "null window"); - mTitle = aTitle; - nsAutoString newTitle(aTitle); - mWindow->SetTitle(newTitle.GetUnicode()); - return NS_OK; -} - -//--------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::GetTitle(PRUnichar** aResult) -{ - *aResult = mTitle; - return NS_OK; -} - -//--------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::LoadURL(const nsString& aURL) -{ - mWebShell->LoadURL(aURL); - return NS_OK; -} - -//--------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus) -{ - // Find the Root Conent Node for this Window - nsIPresShell* shell; - GetPresShell(shell); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - mContentRoot = doc->GetRootContent(); - mDocIsLoaded = PR_TRUE; - if (nsnull != mWindowListener) { - mWindowListener->Initialize(this); - } - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } - - return NS_OK; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult) -{ - aResult = nsnull; - nsString aNameStr(aName); - - nsIWebShell *ws; - - if (NS_OK == GetWebShell(ws)) { - PRUnichar *name; - if (NS_OK == ws->GetName(&name)) { - if (aNameStr.Equals(name)) { - aResult = ws; - NS_ADDREF(aResult); - return NS_OK; - } - } - } - - if (NS_OK == ws->FindChildWithName(aName, aResult)) { - if (nsnull != aResult) { - return NS_OK; - } - } - - return NS_OK; -} - -NS_IMETHODIMP nsXPBaseWindow::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::AddEventListener(nsIDOMNode * aNode) -{ - nsIDOMEventReceiver * receiver; - - if (NS_OK == aNode->QueryInterface(kIDOMEventReceiverIID, (void**) &receiver)) { - receiver->AddEventListenerByIID((nsIDOMMouseListener*)this, kIDOMMouseListenerIID); - NS_RELEASE(receiver); - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::RemoveEventListener(nsIDOMNode * aNode) -{ - nsIDOMEventReceiver * receiver; - - if (NS_OK == aNode->QueryInterface(kIDOMEventReceiverIID, (void**) &receiver)) { - receiver->RemoveEventListener(this, kIDOMMouseListenerIID); - NS_RELEASE(receiver); - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::AddWindowListener(nsWindowListener * aWindowListener) -{ - mWindowListener = aWindowListener; - if (mDocIsLoaded && nsnull != mWindowListener) { - mWindowListener->Initialize(this); - } - return NS_OK; -} - -//----------------------------------------------------- -// Get the HTML Document -NS_IMETHODIMP nsXPBaseWindow::GetDocument(nsIDOMHTMLDocument *& aDocument) -{ - nsIDOMHTMLDocument *htmlDoc = nsnull; - nsIPresShell *shell = nsnull; - GetPresShell(shell); - if (nsnull != shell) { - nsIDocument* doc = shell->GetDocument(); - if (nsnull != doc) { - nsresult result = doc->QueryInterface(kIDOMHTMLDocumentIID,(void **)&htmlDoc); - NS_RELEASE(doc); - } - NS_RELEASE(shell); - } - - aDocument = htmlDoc; - return NS_OK; -} - -//----------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::NewWebShell(PRUint32 aChromeMask, - PRBool aVisible, - nsIWebShell*& aNewWebShell) -{ - nsresult rv = NS_OK; - - // Create new window. By default, the refcnt will be 1 because of - // the registration of the browser window in gBrowsers. - nsXPBaseWindow* dialogWindow; - NS_NEWXPCOM(dialogWindow, nsXPBaseWindow); - - if (nsnull != dialogWindow) { - nsRect bounds; - GetBounds(bounds); - - rv = dialogWindow->Init(mWindowType, mAppShell, mPrefs, mDialogURL, mTitle, bounds, aChromeMask, mAllowPlugins); - if (NS_OK == rv) { - if (aVisible) { - dialogWindow->SetVisible(PR_TRUE); - } - nsIWebShell *shell; - rv = dialogWindow->GetWebShell(shell); - aNewWebShell = shell; - } else { - dialogWindow->Close(); - } - } else { - rv = NS_ERROR_OUT_OF_MEMORY; - } - - return rv; -} - - -//---------------------------------------- - -// Stream observer implementation - -NS_IMETHODIMP -nsXPBaseWindow::OnProgress(nsIURL* aURL, - PRUint32 aProgress, - PRUint32 aProgressMax) -{ - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) -{ - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::OnStartBinding(nsIURL* aURL, const char *aContentType) -{ - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) -{ - return NS_OK; -} - -//---------------------------------------- -NS_IMETHODIMP_(void) nsXPBaseWindow::Alert(const nsString &aText) -{ - char *str; - - str = aText.ToNewCString(); - printf("%cBrowser Window Alert: %s\n", '\007', str); - PR_Free(str); -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) nsXPBaseWindow::Confirm(const nsString &aText) -{ - char *str; - - str = aText.ToNewCString(); - printf("%cBrowser Window Confirm: %s (y/n)? \n", '\007', str); - PR_Free(str); - char c; - for (;;) { - c = getchar(); - if (tolower(c) == 'y') { - return PR_TRUE; - } - if (tolower(c) == 'n') { - return PR_FALSE; - } - } -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) nsXPBaseWindow::Prompt(const nsString &aText, - const nsString &aDefault, - nsString &aResult) -{ - char *str; - char buf[256]; - - str = aText.ToNewCString(); - printf("Browser Window: %s\n", str); - PR_Free(str); - - printf("%cPrompt: ", '\007'); - scanf("%s", buf); - aResult = buf; - - return (aResult.Length() > 0); -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) nsXPBaseWindow::PromptUserAndPassword(const nsString &aText, - nsString &aUser, - nsString &aPassword) -{ - char *str; - char buf[256]; - - str = aText.ToNewCString(); - printf("Browser Window: %s\n", str); - PR_Free(str); - - printf("%cUser: ", '\007'); - scanf("%s", buf); - aUser = buf; - printf("%cPassword: ", '\007'); - scanf("%s", buf); - aPassword = buf; - - return (aUser.Length() > 0); -} - -//---------------------------------------- -NS_IMETHODIMP_(PRBool) nsXPBaseWindow::PromptPassword(const nsString &aText, - nsString &aPassword) -{ - char *str; - char buf[256]; - - str = aText.ToNewCString(); - printf("Browser Window: %s\n", str); - PR_Free(str); - - printf("%cPassword: ", '\007'); - scanf("%s", buf); - aPassword = buf; - - return PR_TRUE; -} - - - - -//---------------------------------------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::GetPresShell(nsIPresShell*& aPresShell) -{ - aPresShell = nsnull; - - nsIPresShell* shell = nsnull; - if (nsnull != mWebShell) { - nsIContentViewer* cv = nsnull; - mWebShell->GetContentViewer(cv); - if (nsnull != cv) { - nsIDocumentViewer* docv = nsnull; - cv->QueryInterface(kIDocumentViewerIID, (void**) &docv); - if (nsnull != docv) { - nsIPresContext* cx; - docv->GetPresContext(cx); - if (nsnull != cx) { - shell = cx->GetShell(); // does an add ref - aPresShell = shell; - NS_RELEASE(cx); - } - NS_RELEASE(docv); - } - NS_RELEASE(cv); - } - } - return NS_OK; -} - -//----------------------------------------------------------------- -//-- nsIDOMMouseListener -//----------------------------------------------------------------- - -//----------------------------------------------------------------- -nsresult nsXPBaseWindow::HandleEvent(nsIDOMEvent* aEvent) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -nsresult nsXPBaseWindow::MouseUp(nsIDOMEvent* aMouseEvent) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -nsresult nsXPBaseWindow::MouseDown(nsIDOMEvent* aMouseEvent) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -nsresult nsXPBaseWindow::MouseClick(nsIDOMEvent* aMouseEvent) -{ - if (nsnull != mWindowListener) { - mWindowListener->MouseClick(aMouseEvent, this); - } - return NS_OK; -} - -//----------------------------------------------------------------- -nsresult nsXPBaseWindow::MouseDblClick(nsIDOMEvent* aMouseEvent) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -nsresult nsXPBaseWindow::MouseOver(nsIDOMEvent* aMouseEvent) -{ - return NS_OK; -} - -//----------------------------------------------------------------- -nsresult nsXPBaseWindow::MouseOut(nsIDOMEvent* aMouseEvent) -{ - return NS_OK; -} - -//---------------------------------------------------------------------- -// Factory code for creating nsXPBaseWindow's -//---------------------------------------------------------------------- -class nsXPBaseWindowFactory : public nsIFactory -{ -public: - nsXPBaseWindowFactory(); - ~nsXPBaseWindowFactory(); - - // nsISupports methods - NS_IMETHOD QueryInterface(const nsIID &aIID, void **aResult); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - // nsIFactory methods - NS_IMETHOD CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); - -private: - nsrefcnt mRefCnt; -}; - -//---------------------------------------------------------------------- -nsXPBaseWindowFactory::nsXPBaseWindowFactory() -{ - mRefCnt = 0; -} - -//---------------------------------------------------------------------- -nsXPBaseWindowFactory::~nsXPBaseWindowFactory() -{ - NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction"); -} - -//---------------------------------------------------------------------- -nsresult -nsXPBaseWindowFactory::QueryInterface(const nsIID &aIID, void **aResult) -{ - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - - // Always NULL result, in case of failure - *aResult = NULL; - - if (aIID.Equals(kISupportsIID)) { - *aResult = (void *)(nsISupports*)this; - } else if (aIID.Equals(kIFactoryIID)) { - *aResult = (void *)(nsIFactory*)this; - } - - if (*aResult == NULL) { - return NS_NOINTERFACE; - } - - NS_ADDREF_THIS(); // Increase reference count for caller - return NS_OK; -} - -//---------------------------------------------------------------------- -nsrefcnt -nsXPBaseWindowFactory::AddRef() -{ - return ++mRefCnt; -} - -//---------------------------------------------------------------------- -nsrefcnt -nsXPBaseWindowFactory::Release() -{ - if (--mRefCnt == 0) { - delete this; - return 0; // Don't access mRefCnt after deleting! - } - return mRefCnt; -} - -//---------------------------------------------------------------------- -nsresult -nsXPBaseWindowFactory::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - nsresult rv; - nsXPBaseWindow *inst; - - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - *aResult = NULL; - if (nsnull != aOuter) { - rv = NS_ERROR_NO_AGGREGATION; - goto done; - } - - NS_NEWXPCOM(inst, nsXPBaseWindow); - if (inst == NULL) { - rv = NS_ERROR_OUT_OF_MEMORY; - goto done; - } - - NS_ADDREF(inst); - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - -done: - return rv; -} - -//---------------------------------------------------------------------- -nsresult -nsXPBaseWindowFactory::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -//---------------------------------------------------------------------- -nsresult -NS_NewXPBaseWindowFactory(nsIFactory** aFactory) -{ - nsresult rv = NS_OK; - nsXPBaseWindowFactory* inst; - NS_NEWXPCOM(inst, nsXPBaseWindowFactory); - if (nsnull == inst) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - else { - NS_ADDREF(inst); - } - *aFactory = inst; - return rv; -} diff --git a/xpfe/xpviewer/src/nsXPBaseWindow.h b/xpfe/xpviewer/src/nsXPBaseWindow.h deleted file mode 100644 index 6743948c041e..000000000000 --- a/xpfe/xpviewer/src/nsXPBaseWindow.h +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ -#ifndef nsXPBaseWindow_h___ -#define nsXPBaseWindow_h___ - -#include "nsIXPBaseWindow.h" -#include "nsIStreamListener.h" -#include "nsINetSupport.h" -#include "nsIWebShell.h" -#include "nsIScriptContextOwner.h" -#include "nsString.h" -#include "nsVoidArray.h" -#include "nsCRT.h" - -#include "nsIContent.h" -#include "nsIDOMNode.h" -#include "nsIDOMElement.h" -#include "nsIDocumentLoaderObserver.h" -#include "nsIDOMMouseListener.h" - -class nsViewerApp; -class nsIPresShell; -class nsIPref; - -/** - * - */ -class nsXPBaseWindow : public nsIXPBaseWindow, - public nsIStreamObserver, - public nsINetSupport, - public nsIWebShellContainer, - public nsIDOMMouseListener -{ -public: - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - nsXPBaseWindow(); - virtual ~nsXPBaseWindow(); - - // nsISupports - NS_DECL_ISUPPORTS - - // nsIBrowserWindow - NS_IMETHOD Init(nsXPBaseWindowType aType, - nsIAppShell* aAppShell, - nsIPref* aPrefs, - const nsString& aDialogURL, - const nsString& aTitle, - const nsRect& aBounds, - PRUint32 aChromeMask, - PRBool aAllowPlugins = PR_TRUE); - - - NS_IMETHOD SetLocation(PRInt32 aX, PRInt32 aY); - NS_IMETHOD SetDimensions(PRInt32 aWidth, PRInt32 aHeight); - - NS_IMETHOD GetWindowBounds(nsRect& aBounds); - NS_IMETHOD GetBounds(nsRect& aBounds); - NS_IMETHOD SetVisible(PRBool aIsVisible); - NS_IMETHOD Close(); - NS_IMETHOD SetTitle(const PRUnichar* aTitle); - NS_IMETHOD GetTitle(PRUnichar** aResult); - NS_IMETHOD GetWebShell(nsIWebShell*& aResult); - NS_IMETHOD GetPresShell(nsIPresShell*& aPresShell); - - //NS_IMETHOD HandleEvent(nsGUIEvent * anEvent); - - NS_IMETHOD LoadURL(const nsString &aURL); - - // nsIStreamObserver - NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); - - // nsIWebShellContainer - NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason); - NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL); - NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); - NS_IMETHOD NewWebShell(PRUint32 aChromeMask, - PRBool aVisible, - nsIWebShell *&aNewWebShell); - NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult); - NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken); - - // nsINetSupport - NS_IMETHOD_(void) Alert(const nsString &aText); - NS_IMETHOD_(PRBool) Confirm(const nsString &aText); - NS_IMETHOD_(PRBool) Prompt(const nsString &aText, - const nsString &aDefault, - nsString &aResult); - NS_IMETHOD_(PRBool) PromptUserAndPassword(const nsString &aText, - nsString &aUser, - nsString &aPassword); - NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText, - nsString &aPassword); - - void Layout(PRInt32 aWidth, PRInt32 aHeight); - - void ForceRefresh(); - - //nsEventStatus ProcessDialogEvent(nsGUIEvent *aEvent); - - - void SetApp(nsViewerApp* aApp) { - mApp = aApp; - } - - // DOM Element & Node Interfaces - NS_IMETHOD GetDocument(nsIDOMHTMLDocument *& aDocument); - NS_IMETHOD AddEventListener(nsIDOMNode * aNode); - NS_IMETHOD RemoveEventListener(nsIDOMNode * aNode); - NS_IMETHOD AddWindowListener(nsWindowListener * aWindowListener); - - // nsIDOMEventListener - virtual nsresult HandleEvent(nsIDOMEvent* aEvent); - - // nsIDOMMouseListener (is derived from nsIDOMEventListener) - virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent); - virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent); - virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent); - virtual nsresult MouseDblClick(nsIDOMEvent* aMouseEvent); - virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent); - virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent); - -protected: - void GetContentRoot(); //Gets the Root Content node after Doc is loaded - nsIContent * mContentRoot; // Points at the Root Content Node - - -protected: - nsViewerApp* mApp; - - nsString mTitle; - nsString mDialogURL; - - nsIWidget* mWindow; - nsIWebShell* mWebShell; - - nsWindowListener * mWindowListener; // XXX Someday this will be a list - PRBool mDocIsLoaded; - - //for creating more instances - nsIAppShell* mAppShell; //not addref'ed! - nsIPref* mPrefs; //not addref'ed! - PRBool mAllowPlugins; - - nsXPBaseWindowType mWindowType; - -}; - -// XXX This is bad; because we can't hang a closure off of the event -// callback we have no way to store our This pointer; therefore we -// have to hunt to find the browswer that events belong too!!! - -// aWhich for FindBrowserFor -#define FIND_WINDOW 0 -#define FIND_BACK 1 -#define FIND_FORWARD 2 -#define FIND_LOCATION 3 - - - -#endif /* nsXPBaseWindow_h___ */ diff --git a/xpfe/xpviewer/src/resources.h b/xpfe/xpviewer/src/resources.h deleted file mode 100644 index 4852b285c4b1..000000000000 --- a/xpfe/xpviewer/src/resources.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -#ifndef resources_h___ -#define resources_h___ - -#define VIEWER_OPEN 40000 -#define VIEWER_EXIT 40002 -#define PREVIEW_CLOSE 40003 - -#define VIEWER_WINDOW_OPEN 40009 -#define VIEWER_FILE_OPEN 40010 - -// Note: must be in ascending sequential order -#define VIEWER_DEMO0 40011 -#define VIEWER_DEMO1 40012 -#define VIEWER_DEMO2 40013 -#define VIEWER_DEMO3 40014 -#define VIEWER_DEMO4 40015 -#define VIEWER_DEMO5 40016 -#define VIEWER_DEMO6 40017 -#define VIEWER_DEMO7 40018 -#define VIEWER_DEMO8 40019 -#define VIEWER_DEMO9 40020 - - -#define VIEWER_VISUAL_DEBUGGING 40021 -#define VIEWER_REFLOW_TEST 40022 -#define VIEWER_DUMP_CONTENT 40023 -#define VIEWER_DUMP_FRAMES 40024 -#define VIEWER_DUMP_VIEWS 40025 -#define VIEWER_DUMP_STYLE_SHEETS 40026 -#define VIEWER_DUMP_STYLE_CONTEXTS 40027 -#define VIEWER_DEBUGROBOT 40028 -#define VIEWER_SHOW_CONTENT_SIZE 40029 -#define VIEWER_SHOW_FRAME_SIZE 40030 -#define VIEWER_SHOW_STYLE_SIZE 40031 -#define VIEWER_DEBUGSAVE 40032 -#define VIEWER_SHOW_CONTENT_QUALITY 40033 -#define VIEWER_TOGGLE_SELECTION 40034 - -// Note: must be in ascending sequential order -#define VIEWER_ONE_COLUMN 40040 -#define VIEWER_TWO_COLUMN 40041 -#define VIEWER_THREE_COLUMN 40042 - -#define JS_CONSOLE 40100 -#define EDITOR_MODE 40120 - - -#define VIEWER_EDIT_CUT 40201 -#define VIEWER_EDIT_COPY 40202 -#define VIEWER_EDIT_PASTE 40203 -#define VIEWER_EDIT_SELECTALL 40204 -#define VIEWER_EDIT_FINDINPAGE 40205 - - -#define VIEWER_RL_BASE 41000 - -#define VIEWER_TOP100 40300 -/* Debug Robot dialog setup */ - -#define IDD_DEBUGROBOT 101 -#define IDC_UPDATE_DISPLAY 40301 -#define IDC_VERIFICATION_DIRECTORY 40302 -#define IDC_PAGE_LOADS 40303 -#define IDC_STATIC -1 - -#define IDD_SITEWALKER 200 -#define ID_SITE_PREVIOUS 40400 -#define ID_SITE_NEXT 40401 -#define IDC_SITE_NAME 40402 -#define ID_EXIT 40404 - -#define VIEWER_FILE_VIEW_SOURCE 40500 - -#define VIEWER_COMM_NAV 40600 - -#endif /* resources_h___ */ diff --git a/xpfe/xpviewer/src/retro_n.ico b/xpfe/xpviewer/src/retro_n.ico deleted file mode 100644 index d3831d27c3f2..000000000000 Binary files a/xpfe/xpviewer/src/retro_n.ico and /dev/null differ diff --git a/xpfe/xpviewer/src/xpviewer.rc b/xpfe/xpviewer/src/xpviewer.rc deleted file mode 100644 index 4605ea5291e3..000000000000 --- a/xpfe/xpviewer/src/xpviewer.rc +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ -#include "resources.h" -#include "jsconsres.h" -#include - -1 ICON "retro_n.ico" - -#if 0 -VIEWER MENU DISCARDABLE -{ - POPUP "&File" - { - MENUITEM "&New Window", VIEWER_WINDOW_OPEN - MENUITEM "&Open...", VIEWER_FILE_OPEN - POPUP "&Samples" - { - MENUITEM "demo #0", VIEWER_DEMO0 - MENUITEM "demo #1", VIEWER_DEMO1 - MENUITEM "demo #2", VIEWER_DEMO2 - MENUITEM "demo #3", VIEWER_DEMO3 - MENUITEM "demo #4", VIEWER_DEMO4 - MENUITEM "demo #5", VIEWER_DEMO5 - MENUITEM "demo #6", VIEWER_DEMO6 - MENUITEM "demo #7", VIEWER_DEMO7 - MENUITEM "demo #8", VIEWER_DEMO8 - MENUITEM "demo #9", VIEWER_DEMO9 - } - MENUITEM "&Test Sites", VIEWER_TOP100 - POPUP "Print &Preview" - { - MENUITEM "One Column", VIEWER_ONE_COLUMN - MENUITEM "Two Column", VIEWER_TWO_COLUMN - MENUITEM "Three Column", VIEWER_THREE_COLUMN - } - MENUITEM "&Exit", VIEWER_EXIT - } - POPUP "&Edit" - BEGIN - MENUITEM "Cu&t", VIEWER_EDIT_CUT, GRAYED - MENUITEM "&Copy", VIEWER_EDIT_COPY - MENUITEM "&Paste", VIEWER_EDIT_PASTE, GRAYED - MENUITEM SEPARATOR - MENUITEM "Select &All", VIEWER_EDIT_SELECTALL, HELP - MENUITEM SEPARATOR - MENUITEM "&Find in Page", VIEWER_EDIT_FINDINPAGE - END - POPUP "&Debug" - { - MENUITEM "&Visual Debugging", VIEWER_VISUAL_DEBUGGING - MENUITEM "&Reflow Test", VIEWER_REFLOW_TEST - MENUITEM SEPARATOR - MENUITEM "Dump &Content", VIEWER_DUMP_CONTENT - MENUITEM "Dump &Frames", VIEWER_DUMP_FRAMES - MENUITEM "Dump &Views", VIEWER_DUMP_VIEWS - MENUITEM SEPARATOR - MENUITEM "Dump &Style Sheets", VIEWER_DUMP_STYLE_SHEETS - MENUITEM "Dump &Style Contexts", VIEWER_DUMP_STYLE_CONTEXTS - MENUITEM SEPARATOR - MENUITEM "Show Content Size", VIEWER_SHOW_CONTENT_SIZE - MENUITEM "Show Frame Size", VIEWER_SHOW_FRAME_SIZE - MENUITEM "Show Style Size", VIEWER_SHOW_STYLE_SIZE - MENUITEM SEPARATOR - MENUITEM "Debug Save", VIEWER_DEBUGSAVE - MENUITEM "Debug Toggle Selection", VIEWER_TOGGLE_SELECTION - MENUITEM SEPARATOR - MENUITEM "Debu&g Robot", VIEWER_DEBUGROBOT - MENUITEM SEPARATOR - MENUITEM "Show Content Quality", VIEWER_SHOW_CONTENT_QUALITY - } - POPUP "&Tools" - { - MENUITEM "&JavaScript Console", JS_CONSOLE - MENUITEM "&Editor Mode", EDITOR_MODE - } - POPUP "&Related Links" - { - MENUITEM SEPARATOR - } -} - -PRINTPREVIEW MENU DISCARDABLE -{ - POPUP "&File" - { - MENUITEM "&Close", PREVIEW_CLOSE - } - POPUP "&Debug" - { - MENUITEM "&Visual Debugging", VIEWER_VISUAL_DEBUGGING - MENUITEM SEPARATOR - MENUITEM "Dump &Content", VIEWER_DUMP_CONTENT - MENUITEM "Dump &Frames", VIEWER_DUMP_FRAMES - MENUITEM "Dump &Views", VIEWER_DUMP_VIEWS - MENUITEM SEPARATOR - MENUITEM "Dump &Style Sheets", VIEWER_DUMP_STYLE_SHEETS - MENUITEM "Dump &Style Contexts", VIEWER_DUMP_STYLE_CONTEXTS - } -} - -JSCONSOLE_MENU MENU DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New", ID_FILENEW - MENUITEM "&Open...", ID_FILEOPEN - MENUITEM "&Save", ID_FILESAVE - MENUITEM "Save &As...", ID_FILESAVEAS - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_FILEEXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo", ID_EDITUNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t", ID_EDITCUT - MENUITEM "&Copy", ID_EDITCOPY - MENUITEM "&Paste", ID_EDITPASTE - MENUITEM "De&lete", ID_EDITDELETE - MENUITEM SEPARATOR - MENUITEM "Select &All", ID_EDITSELECTALL - END - POPUP "&Commands" - BEGIN - MENUITEM "&Evaluate All\tF5", ID_COMMANDSEVALALL - MENUITEM "Evaluate &Selection\tF10", ID_COMMANDSEVALSEL - MENUITEM SEPARATOR - MENUITEM "&Inspector", ID_COMMANDSINSPECTOR - END - POPUP "&Help" - BEGIN - MENUITEM "No Help Available", ID_NOHELP - END -END - -ACCELERATOR_TABLE ACCELERATORS -BEGIN - VK_F5, ID_COMMANDSEVALALL, VIRTKEY - VK_F10, ID_COMMANDSEVALSEL, VIRTKEY -END - -IDD_DEBUGROBOT DIALOG DISCARDABLE 0, 0, 246, 84 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Debug Robot Options" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "&Start",IDOK,67,57,50,14 - PUSHBUTTON "&Cancel",IDCANCEL,127,57,50,14 - CONTROL "&Update Display (Visual)",IDC_UPDATE_DISPLAY,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,7,98,10 - EDITTEXT IDC_VERIFICATION_DIRECTORY,77,19,159,14,ES_AUTOHSCROLL - EDITTEXT IDC_PAGE_LOADS,41,36,40,14,ES_AUTOHSCROLL - LTEXT "&Verification Directory",IDC_STATIC,7,21,70,8 - LTEXT "&Stop after",IDC_STATIC,7,38,32,8 - LTEXT "page loads",IDC_STATIC,84,38,36,8 -END - -IDD_SITEWALKER DIALOG DISCARDABLE 0, 0, 283, 90 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Top 100 Site Walker" -FONT 8, "MS Sans Serif" -BEGIN - PUSHBUTTON "<< &Previous",ID_SITE_PREVIOUS,55,53,50,14 - DEFPUSHBUTTON ">> &Next",ID_SITE_NEXT,116,53,50,14 - LTEXT "Site:",IDC_STATIC,20,25,24,8 - LTEXT "",IDC_SITE_NAME,50,25,209,8 - PUSHBUTTON "&Exit",ID_EXIT,177,53,50,14 -END -#endif - -