diff options
Diffstat (limited to 'indra/llwindow/llwindow.cpp')
-rw-r--r-- | indra/llwindow/llwindow.cpp | 318 |
1 files changed, 106 insertions, 212 deletions
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 43f3081321..072f694c24 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -2,30 +2,25 @@ * @file llwindow.cpp * @brief Basic graphical window class * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -40,158 +35,32 @@ #include "llwindowwin32.h" #elif LL_DARWIN #include "llwindowmacosx.h" -#elif LL_LINUX -#include "llwindowlinux.h" // currently just a dummy wrapper #endif #include "llerror.h" #include "llkeyboard.h" #include "linked_lists.h" +#include "llwindowcallbacks.h" -//static instance for default callbacks -LLWindowCallbacks LLWindow::sDefaultCallbacks; // -// LLWindowCallbacks +// Globals // - LLSplashScreen *gSplashScreenp = NULL; BOOL gDebugClicks = FALSE; BOOL gDebugWindowProc = FALSE; const S32 gURLProtocolWhitelistCount = 3; -const char* gURLProtocolWhitelist[] = { "file", "http", "https" }; +const std::string gURLProtocolWhitelist[] = { "file:", "http:", "https:" }; // CP: added a handler list - this is what's used to open the protocol and is based on registry entry // only meaningful difference currently is that file: protocols are opened using http: // since no protocol handler exists in registry for file: // Important - these lists should match - protocol to handler -const char* gURLProtocolWhitelistHandler[] = { "http", "http", "https" }; - -BOOL LLWindowCallbacks::handleTranslatedKeyDown(const KEY key, const MASK mask, BOOL repeated) -{ - return FALSE; -} - - -BOOL LLWindowCallbacks::handleTranslatedKeyUp(const KEY key, const MASK mask) -{ - return FALSE; -} - -void LLWindowCallbacks::handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) -{ -} - -BOOL LLWindowCallbacks::handleUnicodeChar(llwchar uni_char, MASK mask) -{ - return FALSE; -} +const std::string gURLProtocolWhitelistHandler[] = { "http", "http", "https" }; -BOOL LLWindowCallbacks::handleMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -void LLWindowCallbacks::handleMouseLeave(LLWindow *window) -{ - return; -} - -BOOL LLWindowCallbacks::handleCloseRequest(LLWindow *window) -{ - //allow the window to close - return TRUE; -} - -void LLWindowCallbacks::handleQuit(LLWindow *window) -{ - if(LLWindowManager::destroyWindow(window) == FALSE) - { - llerrs << "LLWindowCallbacks::handleQuit() : Couldn't destroy window" << llendl; - } -} - -BOOL LLWindowCallbacks::handleRightMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleRightMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleMiddleMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleMiddleMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleActivate(LLWindow *window, BOOL activated) -{ - return FALSE; -} - -void LLWindowCallbacks::handleMouseMove(LLWindow *window, const LLCoordGL pos, MASK mask) -{ -} - -void LLWindowCallbacks::handleScrollWheel(LLWindow *window, S32 clicks) -{ -} - -void LLWindowCallbacks::handleResize(LLWindow *window, const S32 width, const S32 height) -{ -} - -void LLWindowCallbacks::handleFocus(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleFocusLost(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleMenuSelect(LLWindow *window, const S32 menu_item) -{ -} - -BOOL LLWindowCallbacks::handlePaint(LLWindow *window, const S32 x, const S32 y, - const S32 width, const S32 height) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleDoubleClick(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -void LLWindowCallbacks::handleWindowBlock(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleWindowUnblock(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *data) -{ -} - - -S32 OSMessageBox(const char* text, const char* caption, U32 type) +S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) { // Properly hide the splash screen when displaying the message box BOOL was_visible = FALSE; @@ -228,8 +97,8 @@ S32 OSMessageBox(const char* text, const char* caption, U32 type) // LLWindow // -LLWindow::LLWindow(BOOL fullscreen, U32 flags) - : mCallbacks(&sDefaultCallbacks), +LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags) + : mCallbacks(callbacks), mPostQuit(TRUE), mFullscreen(fullscreen), mFullscreenWidth(0), @@ -246,18 +115,23 @@ LLWindow::LLWindow(BOOL fullscreen, U32 flags) mHideCursorPermanent(FALSE), mFlags(flags), mHighSurrogate(0) +{ } + +LLWindow::~LLWindow() +{ } + +//virtual +BOOL LLWindow::isValid() { - for (U32 i = 0; i < 8; i++) - { - mJoyAxis[i] = 0; - } + return TRUE; +} - for (U32 i = 0; i < 16; i++) - { - mJoyButtonState[i] = 0; - } +//virtual +BOOL LLWindow::canDelete() +{ + return TRUE; } - + // virtual void LLWindow::incBusyCount() { @@ -273,31 +147,70 @@ void LLWindow::decBusyCount() } } -F32 LLWindow::getJoystickAxis(U32 axis) +//virtual +void LLWindow::resetBusyCount() { - if (axis < 8) - { - return mJoyAxis[axis]; - } - return 0.f; + mBusyCount = 0; } -U8 LLWindow::getJoystickButton(U32 button) +//virtual +S32 LLWindow::getBusyCount() const { - if (button < 16) - { - return mJoyButtonState[button]; - } - return 0; + return mBusyCount; } -void LLWindow::setCallbacks(LLWindowCallbacks *callbacks) +//virtual +ECursorType LLWindow::getCursor() const { - mCallbacks = callbacks; - if (gKeyboard) - { - gKeyboard->setCallbacks(callbacks); - } + return mCurrentCursor; +} + +//virtual +BOOL LLWindow::dialogColorPicker(F32 *r, F32 *g, F32 *b) +{ + return FALSE; +} + +void *LLWindow::getMediaWindow() +{ + // Default to returning the platform window. + return getPlatformWindow(); +} + +//virtual +void LLWindow::processMiscNativeEvents() +{ + // do nothing unless subclassed +} + +//virtual +BOOL LLWindow::isPrimaryTextAvailable() +{ + return FALSE; // no +} +//virtual +BOOL LLWindow::pasteTextFromPrimary(LLWString &dst) +{ + return FALSE; // fail +} +// virtual +BOOL LLWindow::copyTextToPrimary(const LLWString &src) +{ + return FALSE; // fail +} + +// static +std::vector<std::string> LLWindow::getDynamicFallbackFontList() +{ +#if LL_WINDOWS + return LLWindowWin32::getDynamicFallbackFontList(); +#elif LL_DARWIN + return LLWindowMacOSX::getDynamicFallbackFontList(); +#elif LL_SDL + return LLWindowSDL::getDynamicFallbackFontList(); +#else + return std::vector<std::string>(); +#endif } #define UTF16_IS_HIGH_SURROGATE(U) ((U16)((U) - 0xD800) < 0x0400) @@ -390,7 +303,7 @@ void LLSplashScreen::show() } //static -void LLSplashScreen::update(const char* str) +void LLSplashScreen::update(const std::string& str) { LLSplashScreen::show(); if (gSplashScreenp) @@ -418,59 +331,40 @@ void LLSplashScreen::hide() static std::set<LLWindow*> sWindowList; LLWindow* LLWindowManager::createWindow( - char *title, - char *name, - LLCoordScreen upper_left, - LLCoordScreen size, - U32 flags, + LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, - BOOL ignore_pixel_depth) -{ - return createWindow( - title, name, upper_left.mX, upper_left.mY, size.mX, size.mY, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); -} - -LLWindow* LLWindowManager::createWindow( - char *title, char *name, S32 x, S32 y, S32 width, S32 height, U32 flags, - BOOL fullscreen, - BOOL clearBg, - BOOL disable_vsync, - BOOL use_gl, - BOOL ignore_pixel_depth) + BOOL ignore_pixel_depth, + U32 fsaa_samples) { LLWindow* new_window; if (use_gl) { #if LL_MESA_HEADLESS - new_window = new LLWindowMesaHeadless( + new_window = new LLWindowMesaHeadless(callbacks, title, name, x, y, width, height, flags, fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); #elif LL_SDL - new_window = new LLWindowSDL( + new_window = new LLWindowSDL(callbacks, title, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); + fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_WINDOWS - new_window = new LLWindowWin32( + new_window = new LLWindowWin32(callbacks, title, name, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); + fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_DARWIN - new_window = new LLWindowMacOSX( - title, name, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); -#elif LL_LINUX - new_window = new LLWindowLinux( + new_window = new LLWindowMacOSX(callbacks, title, name, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); + fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #endif } else { - new_window = new LLWindowHeadless( + new_window = new LLWindowHeadless(callbacks, title, name, x, y, width, height, flags, fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); } |