diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 007a4bcfaa3..4494766027a 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -3517,16 +3517,8 @@ nsresult nsMsgCompose::AttachmentPrettyName(const char* url, PRUnichar** _retval char * leafName = fileSpec.GetLeafName(); if (leafName && *leafName) { -#ifdef MOZ_UNICODE - /* file URL is now in UTF-8 */ - *_retval = ToNewUnicode(NS_ConvertUTF8toUCS2(leafName)); -#else - nsAutoString tempStr; - nsresult rv = ConvertToUnicode(nsMsgI18NFileSystemCharset(), leafName, tempStr); - if (NS_FAILED(rv)) - tempStr.AssignWithConversion(leafName); - *_retval = ToNewUnicode(tempStr); -#endif /* MOZ_UNICODE */ + /* file URL is now in UTF-8 */ + *_retval = ToNewUnicode(NS_ConvertUTF8toUCS2(leafName)); nsCRT::free(leafName); return NS_OK; } diff --git a/webshell/tests/viewer/windows/nsButton.cpp b/webshell/tests/viewer/windows/nsButton.cpp index e01c04b11e9..3d58ed159c6 100644 --- a/webshell/tests/viewer/windows/nsButton.cpp +++ b/webshell/tests/viewer/windows/nsButton.cpp @@ -174,7 +174,6 @@ PRBool nsButton::OnResize(nsRect &aWindowRect) return PR_FALSE; } -#ifdef MOZ_UNICODE //------------------------------------------------------------------------- // // return the window class name and initialize the class if needed @@ -184,7 +183,6 @@ LPCWSTR nsButton::WindowClassW() { return L"BUTTON"; } -#endif /* MOZ_UNICODE */ //------------------------------------------------------------------------- // diff --git a/webshell/tests/viewer/windows/nsButton.h b/webshell/tests/viewer/windows/nsButton.h index cd5e333493b..f96634881bd 100644 --- a/webshell/tests/viewer/windows/nsButton.h +++ b/webshell/tests/viewer/windows/nsButton.h @@ -77,9 +77,7 @@ public: protected: nsString mLabel; -#ifdef MOZ_UNICODE virtual LPCWSTR WindowClassW(); -#endif /* MOZ_UNICODE */ virtual LPCTSTR WindowClass(); virtual DWORD WindowStyle(); virtual DWORD WindowExStyle(); diff --git a/webshell/tests/viewer/windows/nsCheckButton.cpp b/webshell/tests/viewer/windows/nsCheckButton.cpp index 82c41ad29fc..c0538ee4ac6 100644 --- a/webshell/tests/viewer/windows/nsCheckButton.cpp +++ b/webshell/tests/viewer/windows/nsCheckButton.cpp @@ -199,7 +199,6 @@ PRBool nsCheckButton::OnResize(nsRect &aWindowRect) return PR_FALSE; } -#ifdef MOZ_UNICODE //------------------------------------------------------------------------- // // return the window class name and initialize the class if needed @@ -209,7 +208,6 @@ LPCWSTR nsCheckButton::WindowClassW() { return L"BUTTON"; } -#endif /* MOZ_UNICODE */ //------------------------------------------------------------------------- // diff --git a/webshell/tests/viewer/windows/nsCheckButton.h b/webshell/tests/viewer/windows/nsCheckButton.h index dfabe44adfb..0b699605f57 100644 --- a/webshell/tests/viewer/windows/nsCheckButton.h +++ b/webshell/tests/viewer/windows/nsCheckButton.h @@ -80,9 +80,7 @@ public: protected: PRBool mState; -#ifdef MOZ_UNICODE virtual LPCWSTR WindowClassW(); -#endif /* MOZ_UNICODE */ virtual LPCTSTR WindowClass(); virtual DWORD WindowStyle(); virtual DWORD WindowExStyle(); diff --git a/webshell/tests/viewer/windows/nsLabel.cpp b/webshell/tests/viewer/windows/nsLabel.cpp index 8239bba2273..46fb20b9bb6 100644 --- a/webshell/tests/viewer/windows/nsLabel.cpp +++ b/webshell/tests/viewer/windows/nsLabel.cpp @@ -176,7 +176,6 @@ PRBool nsLabel::OnResize(nsRect &aWindowRect) return PR_FALSE; } -#ifdef MOZ_UNICODE //------------------------------------------------------------------------- // // return the window class name and initialize the class if needed @@ -186,7 +185,6 @@ LPCWSTR nsLabel::WindowClassW() { return L"STATIC"; } -#endif /* MOZ_UNICODE */ //------------------------------------------------------------------------- // diff --git a/webshell/tests/viewer/windows/nsLabel.h b/webshell/tests/viewer/windows/nsLabel.h index 0a5280d329d..8436173cad0 100644 --- a/webshell/tests/viewer/windows/nsLabel.h +++ b/webshell/tests/viewer/windows/nsLabel.h @@ -81,9 +81,7 @@ public: protected: nsLabelAlignment mAlignment; -#ifdef MOZ_UNICODE virtual LPCWSTR WindowClassW(); -#endif /* MOZ_UNICODE */ virtual LPCTSTR WindowClass(); virtual DWORD WindowStyle(); virtual DWORD WindowExStyle(); diff --git a/webshell/tests/viewer/windows/nsTextHelper.cpp b/webshell/tests/viewer/windows/nsTextHelper.cpp index f9380a562a5..3d404282a2b 100644 --- a/webshell/tests/viewer/windows/nsTextHelper.cpp +++ b/webshell/tests/viewer/windows/nsTextHelper.cpp @@ -176,7 +176,6 @@ nsTextHelper::~nsTextHelper() { } -#ifdef MOZ_UNICODE //------------------------------------------------------------------------- // // return the window class name and initialize the class if needed @@ -186,7 +185,6 @@ LPCWSTR nsTextHelper::WindowClassW() { return(L"EDIT"); } -#endif /* MOZ_UNICODE */ //------------------------------------------------------------------------- // diff --git a/webshell/tests/viewer/windows/nsTextHelper.h b/webshell/tests/viewer/windows/nsTextHelper.h index b41aff5f713..e4767c9c302 100644 --- a/webshell/tests/viewer/windows/nsTextHelper.h +++ b/webshell/tests/viewer/windows/nsTextHelper.h @@ -68,9 +68,7 @@ public: NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData); -#ifdef MOZ_UNICODE virtual LPCWSTR WindowClassW(); -#endif /* MOZ_UNICODE */ virtual LPCTSTR WindowClass(); virtual DWORD WindowStyle(); virtual PRBool AutoErase(); diff --git a/webshell/tests/viewer/windows/nsTextWidget.cpp b/webshell/tests/viewer/windows/nsTextWidget.cpp index dc5ed55d7e0..0911403b891 100644 --- a/webshell/tests/viewer/windows/nsTextWidget.cpp +++ b/webshell/tests/viewer/windows/nsTextWidget.cpp @@ -179,7 +179,6 @@ PRBool nsTextWidget::OnResize(nsRect &aWindowRect) return PR_FALSE; } -#ifdef MOZ_UNICODE //------------------------------------------------------------------------- // // return the window class name and initialize the class if needed @@ -189,7 +188,6 @@ LPCWSTR nsTextWidget::WindowClassW() { return(nsTextHelper::WindowClassW()); } -#endif /* MOZ_UNICODE */ //------------------------------------------------------------------------- // diff --git a/webshell/tests/viewer/windows/nsTextWidget.h b/webshell/tests/viewer/windows/nsTextWidget.h index 91ab1add92d..99916e1156e 100644 --- a/webshell/tests/viewer/windows/nsTextWidget.h +++ b/webshell/tests/viewer/windows/nsTextWidget.h @@ -75,9 +75,7 @@ public: protected: -#ifdef MOZ_UNICODE virtual LPCWSTR WindowClassW(); -#endif /* MOZ_UNICODE */ virtual LPCTSTR WindowClass(); virtual DWORD WindowStyle(); virtual DWORD WindowExStyle(); diff --git a/widget/src/windows/nsAppShell.cpp b/widget/src/windows/nsAppShell.cpp index 024e9835058..d797011de63 100644 --- a/widget/src/windows/nsAppShell.cpp +++ b/widget/src/windows/nsAppShell.cpp @@ -47,9 +47,7 @@ #include #include "nsWidgetsCID.h" -#ifdef MOZ_AIMM #include "aimm.h" -#endif static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); @@ -98,13 +96,8 @@ BOOL PeekKeyAndIMEMessage(LPMSG msg, HWND hwnd) { MSG msg1, msg2, *lpMsg; BOOL b1, b2; -#ifdef MOZ_UNICODE b1 = nsToolkit::mPeekMessage(&msg1, NULL, WM_KEYFIRST, WM_IME_KEYLAST, PM_NOREMOVE); b2 = nsToolkit::mPeekMessage(&msg2, NULL, WM_IME_SETCONTEXT, WM_IME_KEYUP, PM_NOREMOVE); -#else - b1 = ::PeekMessage(&msg1, NULL, WM_KEYFIRST, WM_IME_KEYLAST, PM_NOREMOVE); - b2 = ::PeekMessage(&msg2, NULL, WM_IME_SETCONTEXT, WM_IME_KEYUP, PM_NOREMOVE); -#endif /* MOZ_UNICODE */ if (b1 || b2) { if (b1 && b2) { if (msg1.time < msg2.time) @@ -115,11 +108,7 @@ BOOL PeekKeyAndIMEMessage(LPMSG msg, HWND hwnd) lpMsg = &msg1; else lpMsg = &msg2; -#ifdef MOZ_UNICODE return nsToolkit::mPeekMessage(msg, hwnd, lpMsg->message, lpMsg->message, PM_REMOVE); -#else - return ::PeekMessage(msg, hwnd, lpMsg->message, lpMsg->message, PM_REMOVE); -#endif /* MOZ_UNICODE */ } return false; @@ -144,25 +133,13 @@ NS_METHOD nsAppShell::Run(void) // Give priority to system messages (in particular keyboard, mouse, // timer, and paint messages). if (PeekKeyAndIMEMessage(&msg, NULL) || -#ifdef MOZ_UNICODE nsToolkit::mPeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { -#else - ::PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || - ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { -#endif /* MOZ_UNICODE */ keepGoing = (msg.message != WM_QUIT); if (keepGoing != 0) { -//#ifdef MOZ_AIMM // not need? -// if (!nsToolkit::gAIMMMsgPumpOwner || (nsToolkit::gAIMMMsgPumpOwner->OnTranslateMessage(&msg) != S_OK)) -//#endif TranslateMessage(&msg); -#ifdef MOZ_UNICODE nsToolkit::mDispatchMessage(&msg); -#else - ::DispatchMessage(&msg); -#endif /* MOZ_UNICODE */ if (mDispatchListener) mDispatchListener->AfterDispatch(); } @@ -174,11 +151,7 @@ NS_METHOD nsAppShell::Run(void) do { timerManager->FireNextIdleTimer(); timerManager->HasIdleTimers(&hasTimers); -#ifdef MOZ_UNICODE } while (hasTimers && !nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)); -#else - } while (hasTimers && !::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)); -#endif } else { if (!gKeepGoing) { @@ -223,13 +196,8 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent) // Give priority to system messages (in particular keyboard, mouse, // timer, and paint messages). if (PeekKeyAndIMEMessage(&msg, NULL) || -#ifdef MOZ_UNICODE nsToolkit::mPeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { -#else - ::PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || - ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { -#endif /* MOZ_UNICODE */ gotMessage = true; } else { PRBool hasTimers; @@ -238,11 +206,7 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent) do { timerManager->FireNextIdleTimer(); timerManager->HasIdleTimers(&hasTimers); -#ifdef MOZ_UNICODE } while (hasTimers && !nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)); -#else - } while (hasTimers && !::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)); -#endif /* MOZ_UNICODE */ } else { // Block and wait for any posted application message ::WaitMessage(); @@ -256,9 +220,6 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent) printf("-> %d", msg.message); #endif -//#ifdef MOZ_AIMM // not need? -// if (!nsToolkit::gAIMMMsgPumpOwner || (nsToolkit::gAIMMMsgPumpOwner->OnTranslateMessage(&msg) != S_OK)) -//#endif TranslateMessage(&msg); aEvent = &msg; aRealEvent = PR_TRUE; @@ -267,11 +228,7 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent) nsresult nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent) { -#ifdef MOZ_UNICODE nsToolkit::mDispatchMessage((MSG *)aEvent); -#else - DispatchMessage((MSG *)aEvent); -#endif /* MOZ_UNICODE */ return NS_OK; } diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp index f5a75f3d3dd..67213362545 100644 --- a/widget/src/windows/nsFilePicker.cpp +++ b/widget/src/windows/nsFilePicker.cpp @@ -43,18 +43,14 @@ #include #include -#ifdef MOZ_UNICODE #include "nsString.h" #include "nsToolkit.h" -#endif // MOZ_UNICODE static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); NS_IMPL_ISUPPORTS1(nsFilePicker, nsIFilePicker) -#ifdef MOZ_UNICODE nsString nsFilePicker::mLastUsedUnicodeDirectory; -#endif char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 }; #define MAX_EXTENSION_LENGTH 10 @@ -90,7 +86,6 @@ nsFilePicker::~nsFilePicker() // Show - Display the file dialog // //------------------------------------------------------------------------- -#ifdef MOZ_UNICODE NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) { NS_ENSURE_ARG_POINTER(aReturnVal); @@ -333,308 +328,24 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) return NS_OK; } -#endif NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal) -#ifdef MOZ_UNICODE { return ShowW(aReturnVal); } -#else -{ - NS_ENSURE_ARG_POINTER(aReturnVal); - - // suppress blur event - if (mParentWidget) { - nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget); - parent->SuppressBlurEvents(PR_TRUE); - } - - PRBool result = PR_FALSE; - char fileBuffer[MAX_PATH+1] = ""; - char *converted = ConvertToFileSystemCharset(mDefault.get()); - if (nsnull == converted) { - mDefault.ToCString(fileBuffer,MAX_PATH); - } - else { - PL_strncpyz(fileBuffer, converted, MAX_PATH+1); - nsMemory::Free( converted ); - } - - char htmExt[] = "html"; - - char *title = ConvertToFileSystemCharset(mTitle.get()); - if (nsnull == title) - title = ToNewCString(mTitle); - nsCAutoString initialDir; - mDisplayDirectory->GetNativePath(initialDir); - // If no display directory, re-use the last one. - if(initialDir.IsEmpty()) { - // Allocate copy of last used dir. - initialDir = mLastUsedDirectory; - } - - mFile.SetLength(0); - - if (mMode == modeGetFolder) { - - char dirBuffer[MAX_PATH+1]; - PL_strncpy(dirBuffer, initialDir.get(), MAX_PATH); - BROWSEINFO browserInfo; - browserInfo.hwndOwner = (HWND) - (mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0); - browserInfo.pidlRoot = nsnull; - browserInfo.pszDisplayName = (LPSTR)dirBuffer; - browserInfo.lpszTitle = title; - browserInfo.ulFlags = BIF_RETURNONLYFSDIRS;//BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS; - browserInfo.lpfn = nsnull; - browserInfo.lParam = nsnull; - browserInfo.iImage = nsnull; - - // XXX UNICODE support is needed here --> DONE - LPITEMIDLIST list = ::SHBrowseForFolder(&browserInfo); - if (list != NULL) { - result = ::SHGetPathFromIDList(list, (LPSTR)fileBuffer); - if (result) { - mFile.Append(fileBuffer); - } - - // free PIDL - LPMALLOC pMalloc = NULL; - ::SHGetMalloc(&pMalloc); - if(pMalloc) { - pMalloc->Free(list); - pMalloc->Release(); - } - } - } - else { - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - - ofn.lStructSize = sizeof(ofn); - - char extensionBuffer[MAX_EXTENSION_LENGTH+1] = ""; - - PRInt32 l = (mFilterList.Length()+2)*2; - char *filterBuffer = (char*) nsMemory::Alloc(l); - int len = WideCharToMultiByte(CP_ACP, 0, - mFilterList.get(), - mFilterList.Length(), - filterBuffer, - l, NULL, NULL); - filterBuffer[len] = '\0'; - filterBuffer[len+1] = '\0'; - - if (!initialDir.IsEmpty()) { - ofn.lpstrInitialDir = initialDir.get(); - } - - ofn.lpstrTitle = title; - ofn.lpstrFilter = filterBuffer; - ofn.nFilterIndex = mSelectedType; - ofn.hwndOwner = (HWND) - (mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0); - ofn.lpstrFile = fileBuffer; - ofn.nMaxFile = MAX_PATH; - - ofn.Flags = OFN_NOCHANGEDIR | OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - - if (!mDefaultExtension.IsEmpty()) { - // Someone was cool and told us what to do - char *convertedExt = ConvertToFileSystemCharset(mDefaultExtension.get()); - if (!convertedExt) { - mDefaultExtension.ToCString(extensionBuffer, MAX_EXTENSION_LENGTH); - } - else { - PL_strncpyz(extensionBuffer, convertedExt, MAX_EXTENSION_LENGTH+1); - nsMemory::Free( convertedExt ); - } - ofn.lpstrDefExt = extensionBuffer; - } - else { - // Get file extension from suggested filename - // to detect if we are saving an html file - //XXX: nsIFile SHOULD HAVE A GetExtension() METHOD! - PRInt32 extIndex = mDefault.RFind("."); - if ( extIndex >= 0) { - nsAutoString ext; - mDefault.Right(ext, mDefault.Length() - extIndex); - // Should we test for ".cgi", ".asp", ".jsp" and other - // "generated" html pages? - - if ( ext.EqualsIgnoreCase(".htm") || - ext.EqualsIgnoreCase(".html") || - ext.EqualsIgnoreCase(".shtml") ) { - // This is supposed to append ".htm" if user doesn't supply an extension - //XXX Actually, behavior is sort of weird: - // often appends ".html" even if you have an extension - // It obeys your extension if you put quotes around name - ofn.lpstrDefExt = htmExt; - } - } - } - - if (mMode == modeOpen) { - // FILE MUST EXIST! - ofn.Flags |= OFN_FILEMUSTEXIST; - result = ::GetOpenFileName(&ofn); - } - else if (mMode == modeOpenMultiple) { - ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; - result = ::GetOpenFileName(&ofn); - } - else if (mMode == modeSave) { - ofn.Flags |= OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - result = ::GetSaveFileName(&ofn); - if (!result) { - // Error, find out what kind. - if (::GetLastError() == ERROR_INVALID_PARAMETER || - ::CommDlgExtendedError() == FNERR_INVALIDFILENAME) { - // probably the default file name is too long or contains illegal characters! - // Try again, without a starting file name. - ofn.lpstrFile[0] = 0; - result = ::GetSaveFileName(&ofn); - } - } - } - else { - NS_ASSERTION(0, "Only load, save and getFolder are supported modes"); - } - - // Remember what filter type the user selected - mSelectedType = (PRInt16)ofn.nFilterIndex; - - // Clean up filter buffers - if (filterBuffer) - nsMemory::Free( filterBuffer ); - - // Set user-selected location of file or directory - if (result == PR_TRUE) { - // I think it also needs a conversion here (to unicode since appending to nsString) - // but doing that generates garbage file name, weird. - if (mMode == modeOpenMultiple) { - nsresult rv = NS_NewISupportsArray(getter_AddRefs(mFiles)); - NS_ENSURE_SUCCESS(rv,rv); - - // from msdn.microsoft.com, "Open and Save As Dialog Boxes" section: - // If you specify OFN_EXPLORER, - // The directory and file name strings are NULL separated, - // with an extra NULL character after the last file name. - // This format enables the Explorer-style dialog boxes - // to return long file names that include spaces. - char *current = fileBuffer; - - nsCAutoString dirName(current); - // sometimes dirName contains a trailing slash - // and sometimes it doesn't. - if (current[dirName.Length() - 1] != '\\') - dirName += '\\'; - - while (current && *current && *(current + strlen(current) + 1)) { - current = current + strlen(current) + 1; - - nsCOMPtr file = do_CreateInstance("@mozilla.org/file/local;1", &rv); - NS_ENSURE_SUCCESS(rv,rv); - - rv = file->InitWithNativePath(dirName + nsDependentCString(current)); - NS_ENSURE_SUCCESS(rv,rv); - - rv = mFiles->AppendElement(file); - NS_ENSURE_SUCCESS(rv,rv); - } - - // handle the case where the user selected just one - // file. according to msdn.microsoft.com: - // If you specify OFN_ALLOWMULTISELECT and the user selects - // only one file, the lpstrFile string does not have - // a separator between the path and file name. - if (current && *current && (current == fileBuffer)) { - nsCOMPtr file = do_CreateInstance("@mozilla.org/file/local;1", &rv); - NS_ENSURE_SUCCESS(rv,rv); - - rv = file->InitWithNativePath(nsDependentCString(current)); - NS_ENSURE_SUCCESS(rv,rv); - - rv = mFiles->AppendElement(file); - NS_ENSURE_SUCCESS(rv,rv); - } - } - else { - mFile.Append(fileBuffer); - } - } - } - - if (title) - nsMemory::Free( title ); - - if (result) { - PRInt16 returnOKorReplace = returnOK; - - // Remember last used directory. - nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); - NS_ENSURE_TRUE(file, NS_ERROR_FAILURE); - - file->InitWithNativePath(mFile); - nsCOMPtr dir; - if (NS_SUCCEEDED(file->GetParent(getter_AddRefs(dir)))) { - nsCOMPtr localDir(do_QueryInterface(dir)); - if (localDir) { - nsCAutoString newDir; - localDir->GetNativePath(newDir); - if(!newDir.IsEmpty()) - PL_strncpyz(mLastUsedDirectory, newDir.get(), MAX_PATH+1); - // Update mDisplayDirectory with this directory, also. - // Some callers rely on this. - mDisplayDirectory->InitWithNativePath( nsDependentCString(mLastUsedDirectory) ); - } - } - - if (mMode == modeSave) { - // Windows does not return resultReplace, - // we must check if file already exists - PRBool exists = PR_FALSE; - file->Exists(&exists); - if (exists) - returnOKorReplace = returnReplace; - } - *aReturnVal = returnOKorReplace; - } - else { - *aReturnVal = returnCancel; - } - if (mParentWidget) { - nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget); - parent->SuppressBlurEvents(PR_FALSE); - } - - return NS_OK; -} -#endif NS_IMETHODIMP nsFilePicker::GetFile(nsILocalFile **aFile) { NS_ENSURE_ARG_POINTER(aFile); -#ifdef MOZ_UNICODE if (mUnicodeFile.IsEmpty()) return NS_OK; -#else - if (mFile.IsEmpty()) - return NS_OK; -#endif nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); NS_ENSURE_TRUE(file, NS_ERROR_FAILURE); -#ifdef MOZ_UNICODE file->InitWithPath(mUnicodeFile); -#else - file->InitWithNativePath(mFile); -#endif NS_ADDREF(*aFile = file); @@ -646,11 +357,7 @@ NS_IMETHODIMP nsFilePicker::GetFileURL(nsIFileURL **aFileURL) { nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); NS_ENSURE_TRUE(file, NS_ERROR_FAILURE); -#ifdef MOZ_UNICODE file->InitWithPath(mUnicodeFile); -#else - file->InitWithNativePath(mFile); -#endif nsCOMPtr uri; NS_NewFileURI(getter_AddRefs(uri), file); diff --git a/widget/src/windows/nsFilePicker.h b/widget/src/windows/nsFilePicker.h index b8f5d2d8c59..14f13298d69 100644 --- a/widget/src/windows/nsFilePicker.h +++ b/widget/src/windows/nsFilePicker.h @@ -59,9 +59,7 @@ public: NS_IMETHOD GetFileURL(nsIFileURL * *aFileURL); NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles); NS_IMETHOD Show(PRInt16 *aReturnVal); -#ifdef MOZ_UNICODE NS_IMETHOD ShowW(PRInt16 *aReturnVal); -#endif NS_IMETHOD AppendFilter(const PRUnichar *aTitle, const PRUnichar *aFilter) ; protected: @@ -89,11 +87,8 @@ protected: PRInt16 mSelectedType; nsCOMPtr mFiles; static char mLastUsedDirectory[]; - -#ifdef MOZ_UNICODE nsString mUnicodeFile; static nsString mLastUsedUnicodeDirectory; -#endif }; #endif // nsFilePicker_h__ diff --git a/widget/src/windows/nsScrollbar.cpp b/widget/src/windows/nsScrollbar.cpp index 2180aa33462..e69de29bb2d 100644 --- a/widget/src/windows/nsScrollbar.cpp +++ b/widget/src/windows/nsScrollbar.cpp @@ -1,565 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (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.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsScrollbar.h" -#include "nsToolkit.h" -#include "nsGUIEvent.h" -#include -#include "nsUnitConversion.h" - - -NS_IMPL_ADDREF(nsScrollbar) -NS_IMPL_RELEASE(nsScrollbar) - -nsScrollbar::InitializationState nsScrollbar::sScrollbarInited = nsScrollbar::eNotInitialized; - -//------------------------------------------------------------------------- -// -// nsScrollbar constructor -// -//------------------------------------------------------------------------- -nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWindow(), nsIScrollbar() -{ - mPositionFlag = (aIsVertical) ? SBS_VERT : SBS_HORZ; - mScaleFactor = 1.0f; - mLineIncrement = 0; - mBackground = ::GetSysColor(COLOR_SCROLLBAR); - - //prevent resource leaks.. - if (mBrush) - ::DeleteObject(mBrush); - - mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground)); -} - - -//------------------------------------------------------------------------- -// -// nsScrollbar destructor -// -//------------------------------------------------------------------------- -nsScrollbar::~nsScrollbar() -{ -} - - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kInsScrollbarIID, NS_ISCROLLBAR_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsScrollbarIID)) { - *aInstancePtr = (void*) ((nsIScrollbar*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// Define the range settings -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - if (aEndRange > 32767) - mScaleFactor = aEndRange / 32767.0f; - if (mWnd) { - VERIFY(::SetScrollRange(mWnd, SB_CTL, 0, NSToIntRound(aEndRange / mScaleFactor), TRUE)); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Return the range settings -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetMaxRange(PRUint32& aRange) -{ - int startRange, endRange; - if (mWnd) { - VERIFY(::GetScrollRange(mWnd, SB_CTL, &startRange, &endRange)); - } - aRange = (PRUint32)NSToIntRound(endRange * mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb position -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - ::SetScrollPos(mWnd, SB_CTL, NSToIntRound(aPos / mScaleFactor), TRUE); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the current thumb position. -// -//------------------------------------------------------------------------- -PRUint32 nsScrollbar::GetPosition(PRUint32& aPosition) -{ - aPosition = (PRUint32)NSToIntRound(::GetScrollPos(mWnd, SB_CTL) * mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - if (mWnd) { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - si.nPage = NSToIntRound(aSize / mScaleFactor); - ::SetScrollInfo(mWnd, SB_CTL, &si, TRUE); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) -{ - if (mWnd) { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si)); - aSize = (PRUint32)NSToIntRound(si.nPage * mScaleFactor); - } - else - { - aSize = 0; - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aSize) -{ - mLineIncrement = NSToIntRound(aSize / mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aSize) -{ - aSize = (PRUint32)NSToIntRound(mLineIncrement * mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set all scrolling parameters -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - if (aMaxRange > 32767) - mScaleFactor = aMaxRange / 32767.0f; - - if (mWnd) { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; - si.nPage = NSToIntRound(aThumbSize / mScaleFactor); - si.nPos = NSToIntRound(aPosition / mScaleFactor); - si.nMin = 0; - si.nMax = NSToIntRound(aMaxRange / mScaleFactor); - ::SetScrollInfo(mWnd, SB_CTL, &si, TRUE); - } - - mLineIncrement = NSToIntRound(aLineIncrement / mScaleFactor); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// paint message. Don't send the paint out -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnPaint() -{ - return PR_FALSE; -} - - -PRBool nsScrollbar::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - - -//------------------------------------------------------------------------- -// -// Deal with scrollbar messages (actually implemented only in nsScrollbar) -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnScroll(UINT scrollCode, int cPos) -{ - PRBool result = PR_TRUE; - int newPosition; - - switch (scrollCode) { - - // scroll one line right or down - // SB_LINERIGHT and SB_LINEDOWN are actually the same value - //case SB_LINERIGHT: - case SB_LINEDOWN: - { - newPosition = ::GetScrollPos(mWnd, SB_CTL) + mLineIncrement; - - PRUint32 range; - PRUint32 size; - GetMaxRange(range); - GetThumbSize(size); - PRUint32 max = range - size; - - if (newPosition > (int)max) - newPosition = (int)max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_LINE_NEXT; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - - - // scroll one line left or up - //case SB_LINELEFT: - case SB_LINEUP: - { - newPosition = ::GetScrollPos(mWnd, SB_CTL) - mLineIncrement; - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the decrement - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_LINE_PREV; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - - // Scrolls one page right or down - // case SB_PAGERIGHT: - case SB_PAGEDOWN: - { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si)); - - newPosition = ::GetScrollPos(mWnd, SB_CTL) + si.nPage; - - PRUint32 range; - PRUint32 size; - GetMaxRange(range); - GetThumbSize(size); - PRUint32 max = range - size; - - - if (newPosition > (int)max) - newPosition = (int)max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_PAGE_NEXT; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor);; - - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - - // Scrolls one page left or up. - //case SB_PAGELEFT: - case SB_PAGEUP: - { - SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_PAGE; - VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si)); - - newPosition = ::GetScrollPos(mWnd, SB_CTL) - si.nPage; - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_PAGE_PREV; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition - 10, TRUE); - - break; - } - - // Scrolls to the absolute position. The current position is specified by - // the cPos parameter. - case SB_THUMBPOSITION: - case SB_THUMBTRACK: - { - newPosition = cPos; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - nsScrollbarEvent event; - event.message = NS_SCROLLBAR_POS; - event.widget = (nsWindow*)this; - DWORD pos = ::GetMessagePos(); - POINT cpos; - cpos.x = LOWORD(pos); - cpos.y = HIWORD(pos); - ::ScreenToClient(mWnd, &cpos); - event.point.x = cpos.x; - event.point.y = cpos.y; - event.time = ::GetMessageTime(); - event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); - - result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NSToIntRound(event.position / mScaleFactor); - } - - ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); - - break; - } - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// return the window class name and initialize the class if needed -// -//------------------------------------------------------------------------- -LPCTSTR nsScrollbar::WindowClass() -{ - static const LPCTSTR subclassedScrollBar = "MozillaScrollBar"; - static const LPCTSTR classicScrollBarClass = "SCROLLBAR"; - - if (eNotInitialized == sScrollbarInited) { - sScrollbarInited = eInitFailed; - // get the class info for scroll bars - WNDCLASS scrollBarClass; - if (GetClassInfo(nsToolkit::mDllInstance, - classicScrollBarClass, &scrollBarClass)) { - // modify the class name, leave everything else as it is - scrollBarClass.lpszClassName = subclassedScrollBar; - if (::RegisterClassA(&scrollBarClass)) - sScrollbarInited = eInitSucceeded; - } - } - - if (eInitSucceeded == sScrollbarInited) - return subclassedScrollBar; - return classicScrollBarClass; -} - - -//------------------------------------------------------------------------- -// -// return window styles -// -//------------------------------------------------------------------------- -DWORD nsScrollbar::WindowStyle() -{ - return mPositionFlag | WS_CHILD | WS_CLIPSIBLINGS; -} - - -//------------------------------------------------------------------------- -// -// return window extended styles -// -//------------------------------------------------------------------------- -DWORD nsScrollbar::WindowExStyle() -{ - return 0; -} - - -//------------------------------------------------------------------------- -// -// get position/dimensions -// -//------------------------------------------------------------------------- - -NS_METHOD nsScrollbar::GetBounds(nsRect &aRect) -{ - return nsWindow::GetBounds(aRect); -} - - -#ifdef MOZ_UNICODE -//------------------------------------------------------------------------- -// -// return the window class name and initialize the class if needed -// -//------------------------------------------------------------------------- -LPCWSTR nsScrollbar::WindowClassW() -{ - static const LPCWSTR subclassedScrollBar = L"MozillaScrollBar"; - static const LPCWSTR classicScrollBarClass = L"SCROLLBAR"; - - if (eNotInitialized == sScrollbarInited) { - sScrollbarInited = eInitFailed; - // get the class info for scroll bars - WNDCLASSW scrollBarClass; - if (GetClassInfoW(nsToolkit::mDllInstance, - classicScrollBarClass, &scrollBarClass)) { - // modify the class name, leave everything else as it is - scrollBarClass.lpszClassName = subclassedScrollBar; - if (::RegisterClassW(&scrollBarClass)) - sScrollbarInited = eInitSucceeded; - } - } - - if (eInitSucceeded == sScrollbarInited) - return subclassedScrollBar; - return classicScrollBarClass; -} - -#endif diff --git a/widget/src/windows/nsScrollbar.h b/widget/src/windows/nsScrollbar.h index 1b5d4a7d94c..e69de29bb2d 100644 --- a/widget/src/windows/nsScrollbar.h +++ b/widget/src/windows/nsScrollbar.h @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (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.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsdefs.h" -#include "nsWindow.h" -#include "nsSwitchToUIThread.h" - -#include "nsIScrollbar.h" - -/** - * Native WIN32 scrollbar wrapper. - */ - -class nsScrollbar : public nsWindow, - public nsIScrollbar -{ - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - virtual PRBool OnPaint(); - virtual PRBool OnScroll(UINT scrollCode, int cPos); - virtual PRBool OnResize(nsRect &aWindowRect); - NS_IMETHOD GetBounds(nsRect &aRect); - -protected: - - virtual LPCTSTR WindowClass(); -#ifdef MOZ_UNICODE - virtual LPCWSTR WindowClassW(); -#endif /* MOZ_UNICODE */ - virtual DWORD WindowStyle(); - virtual DWORD WindowExStyle(); - -private: - DWORD mPositionFlag; - int mLineIncrement; - float mScaleFactor; - - enum InitializationState - { - eNotInitialized, - eInitFailed, - eInitSucceeded - }; - static InitializationState sScrollbarInited; -}; - -#endif // nsButton_h__ diff --git a/widget/src/windows/nsToolkit.cpp b/widget/src/windows/nsToolkit.cpp index bf7967a5412..c50d1da7600 100644 --- a/widget/src/windows/nsToolkit.cpp +++ b/widget/src/windows/nsToolkit.cpp @@ -44,12 +44,10 @@ #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsIEventQueue.h" -#ifdef MOZ_AIMM // objbase.h must be declared before initguid.h to use the |DEFINE_GUID|'s in aimm.h #include #include #include "aimm.h" -#endif // unknwn.h is needed to build with WIN32_LEAN_AND_MEAN #include @@ -81,8 +79,6 @@ PRBool nsToolkit::mUseImeApiW = PR_FALSE; PRBool nsToolkit::mW2KXP_CP936 = PR_FALSE; PRBool nsToolkit::mIsWinXP = PR_FALSE; -#ifdef MOZ_AIMM - DEFINE_GUID(IID_IActiveIMMApp, 0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e); @@ -94,7 +90,6 @@ DEFINE_GUID(IID_IActiveIMMMessagePumpOwner, IActiveIMMApp* nsToolkit::gAIMMApp = NULL; PRInt32 nsToolkit::gAIMMCount = 0; -#endif nsWindow *MouseTrailer::mCaptureWindow = NULL; nsWindow *MouseTrailer::mHoldMouse = NULL; @@ -183,7 +178,6 @@ LRESULT CALLBACK DetectWindowMove(int code, WPARAM wParam, LPARAM lParam) -#ifdef MOZ_UNICODE #include "nsWindowAPI.h" @@ -508,18 +502,14 @@ NS_UnregisterClass nsToolkit::mUnregisterClass = nsUnregisterClass; NS_SHGetPathFromIDList nsToolkit::mSHGetPathFromIDList = nsSHGetPathFromIDList; NS_SHBrowseForFolder nsToolkit::mSHBrowseForFolder = nsSHBrowseForFolder; -#endif /* MOZ_UNICODE */ - void RunPump(void* arg) { ThreadInitInfo *info = (ThreadInitInfo*)arg; ::PR_EnterMonitor(info->monitor); -#ifdef MOZ_AIMM // Start Active Input Method Manager on this thread if(nsToolkit::gAIMMApp) nsToolkit::gAIMMApp->Activate(TRUE); -#endif // do registration and creation in this thread info->toolkit->CreateInternalWindow(PR_GetCurrentThread()); @@ -533,17 +523,10 @@ void RunPump(void* arg) // Process messages MSG msg; -#ifdef MOZ_UNICODE while (nsToolkit::mGetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); nsToolkit::mDispatchMessage(&msg); } -#else - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -#endif } //------------------------------------------------------------------------- @@ -556,7 +539,6 @@ nsToolkit::nsToolkit() mGuiThread = NULL; mDispatchWnd = 0; -#ifdef MOZ_AIMM // // Initialize COM since create Active Input Method Manager object // @@ -567,7 +549,6 @@ nsToolkit::nsToolkit() ::CoCreateInstance(CLSID_CActiveIMM, NULL, CLSCTX_INPROC_SERVER, IID_IActiveIMMApp, (void**) &nsToolkit::gAIMMApp); nsToolkit::gAIMMCount++; -#endif #ifdef MOZ_STATIC_COMPONENT_LIBS nsToolkit::Startup(GetModuleHandle(NULL)); @@ -584,7 +565,6 @@ nsToolkit::~nsToolkit() { NS_PRECONDITION(::IsWindow(mDispatchWnd), "Invalid window handle"); -#ifdef MOZ_AIMM nsToolkit::gAIMMCount--; if (!nsToolkit::gAIMMCount) { @@ -595,7 +575,6 @@ nsToolkit::~nsToolkit() } ::CoUninitialize(); } -#endif // Destroy the Dispatch Window ::DestroyWindow(mDispatchWnd); @@ -645,7 +624,6 @@ nsToolkit::Startup(HMODULE hModule) nsToolkit::mIsNT = (osversion.dwPlatformId == VER_PLATFORM_WIN32_NT); if (nsToolkit::mIsNT) { -#ifdef MOZ_UNICODE // For Windows 9x base OS nsFoo is already pointing to A functions // However on NT base OS we should point them to respective W functions nsToolkit::mDefWindowProc = DefWindowProcW; @@ -673,7 +651,6 @@ nsToolkit::Startup(HMODULE hModule) if (!nsToolkit::mSHBrowseForFolder) nsToolkit::mSHBrowseForFolder = &nsSHBrowseForFolder; } -#endif /* MOZ_UNICODE */ nsToolkit::mUseImeApiW = PR_TRUE; // XXX Hack for stopping the crash (125573) if (osversion.dwMajorVersion == 5 && (osversion.dwMinorVersion == 0 || osversion.dwMinorVersion == 1)) { @@ -690,12 +667,7 @@ nsToolkit::Startup(HMODULE hModule) // // register the internal window class // -#ifdef MOZ_UNICODE WNDCLASSW wc; -#else - WNDCLASS wc; -#endif /* MOZ_UNICODE */ - wc.style = CS_GLOBALCLASS; wc.lpfnWndProc = nsToolkit::WindowProc; wc.cbClsExtra = 0; @@ -705,13 +677,8 @@ nsToolkit::Startup(HMODULE hModule) wc.hCursor = NULL; wc.hbrBackground = NULL; wc.lpszMenuName = NULL; -#ifdef MOZ_UNICODE wc.lpszClassName = L"nsToolkitClass"; VERIFY(nsToolkit::mRegisterClass(&wc)); -#else - wc.lpszClassName = "nsToolkitClass"; - VERIFY(::RegisterClass(&wc)); -#endif /* MOZ_UNICODE */ } @@ -815,13 +782,9 @@ NS_METHOD nsToolkit::Init(PRThread *aThread) // Store the thread ID of the thread containing the message pump. // If no thread is provided create one if (NULL != aThread) { - -#ifdef MOZ_AIMM // Start Active Input Method Manager on this thread if(nsToolkit::gAIMMApp) nsToolkit::gAIMMApp->Activate(TRUE); -#endif - CreateInternalWindow(aThread); } else { // create a thread where the message pump will run @@ -874,19 +837,13 @@ LRESULT CALLBACK nsToolkit::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, } -#ifdef MOZ_AIMM if(nsToolkit::gAIMMApp) { LRESULT lResult; if (nsToolkit::gAIMMApp->OnDefWindowProc(hWnd, msg, wParam, lParam, &lResult) == S_OK) return lResult; } -#endif -#ifdef MOZ_UNICODE return nsToolkit::mDefWindowProc(hWnd, msg, wParam, lParam); -#else - return ::DefWindowProc(hWnd, msg, wParam, lParam); -#endif } diff --git a/widget/src/windows/nsToolkit.h b/widget/src/windows/nsToolkit.h index 314728296d0..d340da8ab4d 100644 --- a/widget/src/windows/nsToolkit.h +++ b/widget/src/windows/nsToolkit.h @@ -41,13 +41,9 @@ #include "nsdefs.h" #include "nsIToolkit.h" -#ifdef MOZ_AIMM struct IActiveIMMApp; -#endif -#ifdef MOZ_UNICODE #include "nsWindowAPI.h" -#endif struct MethodInfo; class nsIEventQueue; @@ -106,13 +102,10 @@ public: static void Startup(HINSTANCE hModule); static void Shutdown(); -#ifdef MOZ_AIMM // Active Input Method support static IActiveIMMApp *gAIMMApp; static PRInt32 gAIMMCount; -#endif -#ifdef MOZ_UNICODE // Ansi API support static HMODULE mShell32Module; static NS_DefWindowProc mDefWindowProc; @@ -131,7 +124,6 @@ public: static NS_UnregisterClass mUnregisterClass; static NS_SHGetPathFromIDList mSHGetPathFromIDList; static NS_SHBrowseForFolder mSHBrowseForFolder; -#endif }; #define WM_CALLMETHOD (WM_USER+1) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 619a0ab4e81..433a2e7b710 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -93,9 +93,7 @@ #endif #include -#ifdef MOZ_AIMM #include "aimm.h" -#endif // MOZ_AIMM #include "nsNativeDragTarget.h" #include "nsIRollupListener.h" @@ -269,8 +267,6 @@ static PRBool is_vk_down(int vk) // Macro for Active Input Method Manager (AIMM) support. // Use AIMM method instead of Win32 Imm APIs. // -#ifdef MOZ_AIMM - #define NS_IMM_GETCOMPOSITIONSTRING(hIMC, dwIndex, pBuf, dwBufLen, compStrLen) \ { \ compStrLen = 0; \ @@ -439,99 +435,6 @@ static PRBool is_vk_down(int vk) } \ } -#else /* !MOZ_AIMM */ - -#define NS_IMM_GETCOMPOSITIONSTRING(hIMC, dwIndex, pBuf, dwBufLen, compStrLen) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - compStrLen = theIMM.GetCompositionStringA(hIMC, dwIndex, pBuf, dwBufLen); \ - } - -#define NS_IMM_GETCOMPOSITIONSTRINGW(hIMC, dwIndex, pBuf, dwBufLen, compStrLen) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - compStrLen = theIMM.GetCompositionStringW(hIMC, dwIndex, pBuf, dwBufLen); \ - } - -#define NS_IMM_GETCONTEXT(hWnd, hIMC) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - hIMC = theIMM.GetContext(hWnd); \ - } - -#define NS_IMM_GETCONVERSIONSTATUS(hIMC, lpfdwConversion, lpfdwSentence) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.GetConversionStatus(hIMC, (lpfdwConversion), (lpfdwSentence)); \ - } - -#define NS_IMM_RELEASECONTEXT(hWnd, hIMC) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.ReleaseContext(hWnd, hIMC); \ - } - -#define NS_IMM_NOTIFYIME(hIMC, dwAction, dwIndex, dwValue) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.NotifyIME(hIMC, dwAction, dwIndex, dwValue); \ - } - -#define NS_IMM_SETCANDIDATEWINDOW(hIMC, candForm) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.SetCandidateWindow(hIMC, candForm); \ - } - -#define NS_IMM_SETCOMPOSITIONWINDOW(hIMC, compForm) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.SetCompositionWindow(hIMC, compForm); \ - } - -#define NS_IMM_GETCOMPOSITIONFONT(hIMC, lf) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.GetCompositionFont(hIMC, lf); \ - } - -#define NS_IMM_GETCOMPOSITIONFONTW(hIMC, lf) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.GetCompositionFontW(hIMC, lf); \ - } - -#define NS_IMM_SETCOMPOSITIONFONT(hIMC, lf) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.SetCompositionFont(hIMC, lf); \ - } - -#define NS_IMM_SETCOMPOSITIONFONTW(hIMC, lf) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.SetCompositionFontW(hIMC, lf); \ - } - -#define NS_IMM_SETCONVERSIONSTATUS(hIMC, lpfdwConversion, lpfdwSentence) \ - { \ - nsIMM &theIMM = nsIMM::LoadModule(); \ - theIMM.SetConversionStatus(hIMC, (lpfdwConversion), (lpfdwSentence)); \ - } - -#define NS_IMM_GETPROPERTY(hKL, dwIndex, dwProp) \ - { \ - nsIMM& theIMM = nsIMM::LoadModule(); \ - dwProp = (DWORD)theIMM.GetProperty(hKL, dwIndex); \ - } - -#define NS_IMM_GETDEFAULTIMEWND(hWnd, phDefWnd) \ - { \ - nsIMM& theIMM = nsIMM::LoadModule(); \ - *(phDefWnd) = theIMM.GetDefaultIMEWnd(hWnd); \ - } -#endif /* MOZ_AIMM */ - // // for reconversion define // @@ -744,21 +647,12 @@ static nsAttentionTimerMonitor *gAttentionTimerMonitor = 0; BOOL CALLBACK nsWindow::BroadcastMsgToChildren(HWND aWnd, LPARAM aMsg) { -#ifdef MOZ_UNICODE LONG proc = nsToolkit::mGetWindowLong(aWnd, GWL_WNDPROC); if (proc == (LONG)&nsWindow::WindowProc) { // its one of our windows so go ahead and send a message to it WNDPROC winProc = (WNDPROC)nsToolkit::mGetWindowLong(aWnd, GWL_WNDPROC); nsToolkit::mCallWindowProc(winProc, aWnd, aMsg, 0, 0); } -#else - LONG proc = ::GetWindowLong(aWnd, GWL_WNDPROC); - if (proc == (LONG)&nsWindow::WindowProc) { - // its one of our windows so go ahead and send a message to it - WNDPROC winProc = (WNDPROC)GetWindowLong(aWnd, GWL_WNDPROC); - ::CallWindowProc(winProc, aWnd, aMsg, 0, 0); - } -#endif return TRUE; } @@ -1418,11 +1312,7 @@ LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM // why we are hitting this assert if (nsnull == someWindow) { NS_ASSERTION(someWindow, "someWindow is null, cannot call any CallWindowProc"); -#ifdef MOZ_UNICODE return nsToolkit::mDefWindowProc(hWnd, msg, wParam, lParam); -#else - return ::DefWindowProc(hWnd, msg, wParam, lParam); -#endif } // hold on to the window for the life of this method, in case it gets @@ -1449,25 +1339,14 @@ LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM } #if defined(STRICT) - #ifdef MOZ_UNICODE return nsToolkit::mCallWindowProc((WNDPROC)someWindow->GetPrevWindowProc(), hWnd, msg, wParam, lParam); - #else - return ::CallWindowProc((WNDPROC)someWindow->GetPrevWindowProc(), hWnd, - msg, wParam, lParam); - #endif #else - #ifdef MOZ_UNICODE return nsToolkit::mCallWindowProc((FARPROC)someWindow->GetPrevWindowProc(), hWnd, msg, wParam, lParam); - #else - return ::CallWindowProc((FARPROC)someWindow->GetPrevWindowProc(), hWnd, - msg, wParam, lParam); - #endif #endif } -#ifdef MOZ_AIMM // // Default Window proceduer for AIMM support. // @@ -1479,13 +1358,8 @@ LRESULT CALLBACK nsWindow::DefaultWindowProc(HWND hWnd, UINT msg, WPARAM wParam, if (nsToolkit::gAIMMApp->OnDefWindowProc(hWnd, msg, wParam, lParam, &lResult) == S_OK) return lResult; } -#ifdef MOZ_UNICODE return nsToolkit::mDefWindowProc(hWnd, msg, wParam, lParam); -#else - return ::DefWindowProc(hWnd, msg, wParam, lParam); -#endif } -#endif static BOOL CALLBACK DummyDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { return FALSE; @@ -1606,7 +1480,6 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, (DLGPROC)DummyDialogProc, NULL); } else { -#ifdef MOZ_UNICODE mWnd = nsToolkit::mCreateWindowEx(extendedStyle, aInitData && aInitData->mDropShadow ? WindowPopupClassW() : WindowClassW(), @@ -1620,21 +1493,6 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, NULL, nsToolkit::mDllInstance, NULL); -#else - mWnd = ::CreateWindowEx(extendedStyle, - aInitData && aInitData->mDropShadow ? - WindowPopupClass() : WindowClass(), - "", - style, - aRect.x, - aRect.y, - aRect.width, - GetHeight(aRect.height), - parent, - NULL, - nsToolkit::mDllInstance, - NULL); -#endif } VERIFY(mWnd); @@ -1668,7 +1526,6 @@ PRBool nsWindow::SetWin32ContentType() nsContentType newContentType = mContentType; -#ifdef MOZ_UNICODE if (newContentType == eContentTypeInherit) { HWND parentWnd = mWnd; newContentType = eContentTypeUI; // default if we're the root @@ -1678,17 +1535,6 @@ PRBool nsWindow::SetWin32ContentType() } nsContentType oldContentType = (nsContentType)nsToolkit::mGetWindowLong(mWnd, GWL_ID); nsToolkit::mSetWindowLong(mWnd, GWL_ID, (PRInt32)newContentType); -#else - if (newContentType == eContentTypeInherit) { - HWND parentWnd = mWnd; - newContentType = eContentTypeUI; // default if we're the root - if ((parentWnd = ::GetParent(parentWnd)) != 0) { - newContentType = (nsContentType)nsToolkit::GetWindowLong(parentWnd, GWL_ID); - } - } - nsContentType oldContentType = (nsContentType)nsToolkit::GetWindowLong(mWnd, GWL_ID); - nsToolkit::SetWindowLong(mWnd, GWL_ID, (PRInt32)newContentType); -#endif return oldContentType != newContentType; } @@ -2001,11 +1847,7 @@ NS_METHOD nsWindow::ModalEventFilter(PRBool aRealEvent, void *aEvent, // if not, accept events for any window that hasn't been // disabled. if (!acceptEvent) { -#ifdef MOZ_UNICODE LONG proc = nsToolkit::mGetWindowLong(msgWindow, GWL_WNDPROC); -#else - LONG proc = ::GetWindowLong(msgWindow, GWL_WNDPROC); -#endif /* MOZ_UNICODE */ if (proc == (LONG)&nsWindow::WindowProc) { nsWindow *msgWin = GetNSWindowPtr(msgWindow); msgWin->IsEnabled(&acceptEvent); @@ -2474,11 +2316,7 @@ NS_METHOD nsWindow::SetFont(const nsFont &aFont) HFONT hfont = (HFONT)fontHandle; // Draw in the new font -#ifdef MOZ_UNICODE nsToolkit::mSendMessage(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0); -#else - ::SendMessage(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0); -#endif NS_RELEASE(metrics); return NS_OK; @@ -2640,13 +2478,8 @@ NS_IMETHODIMP nsWindow::HideWindowChrome(PRBool aShouldHide) DWORD style, exStyle; if (aShouldHide) { -#ifdef MOZ_UNICODE DWORD tempStyle = nsToolkit::mGetWindowLong(hwnd, GWL_STYLE); DWORD tempExStyle = nsToolkit::mGetWindowLong(hwnd, GWL_EXSTYLE); -#else - DWORD tempStyle = ::GetWindowLong(hwnd, GWL_STYLE); - DWORD tempExStyle = ::GetWindowLong(hwnd, GWL_EXSTYLE); -#endif /* MOZ_UNICODE */ style = WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; exStyle = 0; @@ -2656,26 +2489,16 @@ NS_IMETHODIMP nsWindow::HideWindowChrome(PRBool aShouldHide) } else { if (!mOldStyle || !mOldExStyle) { -#ifdef MOZ_UNICODE mOldStyle = nsToolkit::mGetWindowLong(hwnd, GWL_STYLE); mOldExStyle = nsToolkit::mGetWindowLong(hwnd, GWL_EXSTYLE); -#else - mOldStyle = ::GetWindowLong(hwnd, GWL_STYLE); - mOldExStyle = ::GetWindowLong(hwnd, GWL_EXSTYLE); -#endif /* MOZ_UNICODE */ } style = mOldStyle; exStyle = mOldExStyle; } -#ifdef MOZ_UNICODE nsToolkit::mSetWindowLong(hwnd, GWL_STYLE, style); nsToolkit::mSetWindowLong(hwnd, GWL_EXSTYLE, exStyle); -#else - ::SetWindowLong(hwnd, GWL_STYLE, style); - ::SetWindowLong(hwnd, GWL_EXSTYLE, exStyle); -#endif return NS_OK; } @@ -3226,23 +3049,17 @@ BOOL nsWindow::OnChar( UINT mbcsCharCode, UINT virtualKeyCode, bool isMultiByte } else { // 0x20 - SPACE, 0x3D - EQUALS -#ifdef MOZ_UNICODE if(mbcsCharCode < 0x20 || (virtualKeyCode == 0x3D && mIsControlDown)) -#else - if(virtualKeyCode < 0x20 || (virtualKeyCode == 0x3D && mIsControlDown)) -#endif /* MOZ_UNICODE */ { uniChar = 0; } else { -#ifdef MOZ_UNICODE if (nsToolkit::mIsNT) { uniChar = mbcsCharCode; } else { -#endif /* MOZ_UNICODE */ char charToConvert[3]; size_t length; @@ -3271,9 +3088,7 @@ BOOL nsWindow::OnChar( UINT mbcsCharCode, UINT virtualKeyCode, bool isMultiByte } ::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,charToConvert,length, &uniChar, 1); -#ifdef MOZ_UNICODE } -#endif /* MOZ_UNICODE */ virtualKeyCode = 0; } } @@ -3756,11 +3571,7 @@ static nsresult HeapDump(const char *filename, const char *heading) BOOL CALLBACK nsWindow::DispatchStarvedPaints(HWND aWnd, LPARAM aMsg) { -#ifdef MOZ_UNICODE LONG proc = nsToolkit::mGetWindowLong(aWnd, GWL_WNDPROC); -#else - LONG proc = ::GetWindowLong(aWnd, GWL_WNDPROC); -#endif /* MOZ_UNICODE */ if (proc == (LONG)&nsWindow::WindowProc) { // its one of our windows so check to see if it has a // invalidated rect. If it does. Dispatch a synchronous @@ -4321,17 +4132,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT break; case WM_KILLFOCUS: -#ifdef MOZ_UNICODE WCHAR className[19]; nsToolkit::mGetClassName((HWND)wParam, className, 19); if(wcscmp(className, WindowClassW())) isMozWindowTakingFocus = PR_FALSE; -#else - char className[19]; - ::GetClassName((HWND)wParam, className, 19); - if(strcmp(className, WindowClass())) - isMozWindowTakingFocus = PR_FALSE; -#endif if(gJustGotDeactivate) { gJustGotDeactivate = PR_FALSE; result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus); @@ -4432,18 +4236,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT if (pl.showCmd == SW_SHOWMINIMIZED) { // Deactivate -#ifdef MOZ_UNICODE WCHAR className[19]; nsToolkit::mGetClassName((HWND)wParam, className, 19); if(wcscmp(className, WindowClassW())) isMozWindowTakingFocus = PR_FALSE; -#else - char className[19]; - ::GetClassName((HWND)wParam, className, 19); - if(strcmp(className, WindowClass())) - isMozWindowTakingFocus = PR_FALSE; -#endif - gJustGotDeactivate = PR_FALSE; result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus); } else if (pl.showCmd == SW_SHOWNORMAL){ @@ -4695,11 +4491,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT break; } -#ifdef MOZ_UNICODE LONG proc = nsToolkit::mGetWindowLong(destWnd, GWL_WNDPROC); -#else - LONG proc = ::GetWindowLong(destWnd, GWL_WNDPROC); -#endif /* MOZ_UNICODE */ if (proc != (LONG)&nsWindow::WindowProc) { // Some other app, or a plugin window. // Windows directs WM_MOUSEWHEEL to the focused window. @@ -4818,7 +4610,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT #define CS_XP_DROPSHADOW 0x00020000 -#ifdef MOZ_UNICODE LPCWSTR nsWindow::WindowClassW() { const LPCWSTR className = L"MozillaWindowClass"; @@ -4828,11 +4619,7 @@ LPCWSTR nsWindow::WindowClassW() // wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wc.style = CS_DBLCLKS; -#ifdef MOZ_AIMM wc.lpfnWndProc = nsWindow::DefaultWindowProc; -#else - wc.lpfnWndProc = nsToolkit::nsDefWindowProc; -#endif wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = nsToolkit::mDllInstance; @@ -4843,11 +4630,9 @@ LPCWSTR nsWindow::WindowClassW() wc.lpszClassName = className; nsWindow::sIsRegistered = nsToolkit::mRegisterClass(&wc); -#ifdef MOZ_AIMM // Call FilterClientWindows method since it enables ActiveIME on CJK Windows if(nsToolkit::gAIMMApp) nsToolkit::gAIMMApp->FilterClientWindows((ATOM*)&nsWindow::sIsRegistered,1); -#endif // MOZ_AIMM } return className; @@ -4860,11 +4645,7 @@ LPCWSTR nsWindow::WindowPopupClassW() if (!nsWindow::sIsPopupClassRegistered) { WNDCLASSW wc; wc.style = CS_DBLCLKS | CS_XP_DROPSHADOW; -#ifdef MOZ_AIMM wc.lpfnWndProc = nsWindow::DefaultWindowProc; -#else - wc.lpfnWndProc = nsToolkit::nsDefWindowProc; -#endif wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = nsToolkit::mDllInstance; @@ -4888,83 +4669,26 @@ LPCWSTR nsWindow::WindowPopupClassW() LPCTSTR nsWindow::WindowClass() { - return (NS_ConvertUCS2toUTF8(WindowClassW()).get()); + // Call into the wide version to make sure things get + // registered properly. + WindowClassW(); + + // XXX: The class name used here must be kept in sync with + // the classname used in WindowClassW(); + return "MozillaWindowClass"; } LPCTSTR nsWindow::WindowPopupClass() { - return (NS_ConvertUCS2toUTF8(WindowPopupClassW()).get()); + // Call into the wide version to make sure things get + // registered properly. + WindowPopupClassW(); + + // XXX: The class name used here must be kept in sync with + // the classname used in WindowPopupClassW(); + return "MozillaDropShadowWindowClass"; } -#else -LPCTSTR nsWindow::WindowClass() -{ - const LPCTSTR className = "MozillaWindowClass"; - - if (!nsWindow::sIsRegistered) { - WNDCLASS wc; - -// wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; - wc.style = CS_DBLCLKS; -#ifdef MOZ_AIMM - wc.lpfnWndProc = nsWindow::DefaultWindowProc; -#else - wc.lpfnWndProc = ::DefWindowProc; -#endif - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = nsToolkit::mDllInstance; - wc.hIcon = ::LoadIcon(::GetModuleHandle(NULL), IDI_APPLICATION); - wc.hCursor = NULL; - wc.hbrBackground = mBrush; - wc.lpszMenuName = NULL; - wc.lpszClassName = className; - - nsWindow::sIsRegistered = ::RegisterClass(&wc); -#ifdef MOZ_AIMM - // Call FilterClientWindows method since it enables ActiveIME on CJK Windows - if(nsToolkit::gAIMMApp) - nsToolkit::gAIMMApp->FilterClientWindows((ATOM*)&nsWindow::sIsRegistered,1); -#endif // MOZ_AIMM - } - - return className; -} - -LPCTSTR nsWindow::WindowPopupClass() -{ - const LPCTSTR className = "MozillaDropShadowWindowClass"; - - if (!nsWindow::sIsPopupClassRegistered) { - WNDCLASS wc; - wc.style = CS_DBLCLKS | CS_XP_DROPSHADOW; -#ifdef MOZ_AIMM - wc.lpfnWndProc = nsWindow::DefaultWindowProc; -#else - wc.lpfnWndProc = ::DefWindowProc; -#endif - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = nsToolkit::mDllInstance; - wc.hIcon = ::LoadIcon(::GetModuleHandle(NULL), IDI_APPLICATION); - wc.hCursor = NULL; - wc.hbrBackground = mBrush; - wc.lpszMenuName = NULL; - wc.lpszClassName = className; - - nsWindow::sIsPopupClassRegistered = ::RegisterClass(&wc); - if (!nsWindow::sIsPopupClassRegistered) { - // For older versions of Win32 (i.e., not XP), the registration will - // fail, so we have to re-register without the CS_XP_DROPSHADOW flag. - wc.style = CS_DBLCLKS; - nsWindow::sIsPopupClassRegistered = ::RegisterClass(&wc); - } - } - - return className; -} -#endif - //------------------------------------------------------------------------- // // return nsWindow styles @@ -5081,30 +4805,21 @@ void nsWindow::SubclassWindow(BOOL bState) if (bState) { // change the nsWindow proc -#ifdef MOZ_UNICODE if (mUnicodeWidget) mPrevWndProc = (WNDPROC)nsToolkit::mSetWindowLong(mWnd, GWL_WNDPROC, (LONG)nsWindow::WindowProc); else mPrevWndProc = (WNDPROC)::SetWindowLong(mWnd, GWL_WNDPROC, (LONG)nsWindow::WindowProc); -#else - mPrevWndProc = (WNDPROC)::SetWindowLong(mWnd, GWL_WNDPROC, - (LONG)nsWindow::WindowProc); -#endif NS_ASSERTION(mPrevWndProc, "Null standard window procedure"); // connect the this pointer to the nsWindow handle SetNSWindowPtr(mWnd, this); } else { -#ifdef MOZ_UNICODE if (mUnicodeWidget) nsToolkit::mSetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc); else ::SetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc); -#else - ::SetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc); -#endif SetNSWindowPtr(mWnd, NULL); mPrevWndProc = NULL; } @@ -5746,11 +5461,7 @@ NS_METHOD nsWindow::SetTitle(const nsString& aTitle) { char* title = GetACPString(aTitle); if (title) { -#ifdef MOZ_UNICODE nsToolkit::mSendMessage(mWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCWSTR)PromiseFlatString(aTitle).get()); -#else - ::SendMessage(mWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCTSTR)title); -#endif delete [] title; } return NS_OK; @@ -5824,11 +5535,7 @@ NS_METHOD nsWindow::SetIcon(const nsAString& anIconSpec) if ( bigIcon ) { LRESULT rv = 0; -#ifdef MOZ_UNICODE rv = nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)bigIcon); -#else - rv = ::SendMessage(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)bigIcon); -#endif } #ifdef DEBUG_law else { @@ -5838,11 +5545,7 @@ NS_METHOD nsWindow::SetIcon(const nsAString& anIconSpec) #endif if ( smallIcon ) { LRESULT rv = 0; -#ifdef MOZ_UNICODE rv = nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)smallIcon); -#else - rv = ::SendMessage(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)smallIcon); -#endif } #ifdef DEBUG_law else { @@ -6246,12 +5949,10 @@ BOOL nsWindow::OnIMEChar(BYTE aByte1, BYTE aByte2, LPARAM aKeyState) size_t length; int err = 0; -#ifdef MOZ_UNICODE if (nsToolkit::mIsNT) { uniChar = MAKEWORD(aByte2, aByte1); } else { -#endif /* MOZ_UNICODE */ if (aByte1) { charToConvert[0] = aByte1; charToConvert[1] = aByte2; @@ -6263,9 +5964,7 @@ BOOL nsWindow::OnIMEChar(BYTE aByte1, BYTE aByte2, LPARAM aKeyState) } err = ::MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED, charToConvert, length, &uniChar, 1); -#ifdef MOZ_UNICODE } -#endif /* MOZ_UNICODE */ #ifdef DEBUG_IME if (!err) { @@ -6898,11 +6597,7 @@ nsWindow::HandleMouseActionOfIME(int aAction, POINT *ptPos) // send MS_MSIME_MOUSE message to default IME window. HWND imeWnd; NS_IMM_GETDEFAULTIMEWND(mWnd, &imeWnd); -#ifdef MOZ_UNICODE if (nsToolkit::mSendMessage(imeWnd, nsWindow::uWM_MSIME_MOUSE, MAKELONG(MAKEWORD(aAction, positioning), offset), (LPARAM) hIMC) == 1) -#else - if (::SendMessage(imeWnd, nsWindow::uWM_MSIME_MOUSE, MAKELONG(MAKEWORD(aAction, positioning), offset), (LPARAM) hIMC) == 1) -#endif IsHandle = PR_TRUE; } NS_IMM_RELEASECONTEXT(mWnd, hIMC); diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index b1faf06067a..080ac128a9c 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -431,10 +431,8 @@ protected: // Allow Derived classes to modify the height that is passed // when the window is created or resized. virtual PRInt32 GetHeight(PRInt32 aProposedHeight); -#ifdef MOZ_UNICODE virtual LPCWSTR WindowClassW(); virtual LPCWSTR WindowPopupClassW(); -#endif virtual LPCTSTR WindowClass(); virtual LPCTSTR WindowPopupClass(); virtual DWORD WindowStyle(); @@ -477,9 +475,7 @@ protected: UINT msg, WPARAM wParam, LPARAM lParam); -#ifdef MOZ_AIMM static LRESULT CALLBACK DefaultWindowProc(HWND hWns, UINT msg, WPARAM wParam, LPARAM lParam); -#endif static PRBool ConvertStatus(nsEventStatus aStatus);