diff options
author | Steve Block <steveblock@google.com> | 2011-05-06 11:45:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-12 13:44:10 +0100 |
commit | cad810f21b803229eb11403f9209855525a25d57 (patch) | |
tree | 29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/WebCore/platform/wx | |
parent | 121b0cf4517156d0ac5111caf9830c51b69bae8f (diff) | |
download | external_webkit-cad810f21b803229eb11403f9209855525a25d57.zip external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2 |
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/WebCore/platform/wx')
49 files changed, 6014 insertions, 0 deletions
diff --git a/Source/WebCore/platform/wx/ClipboardWx.cpp b/Source/WebCore/platform/wx/ClipboardWx.cpp new file mode 100644 index 0000000..32216a6 --- /dev/null +++ b/Source/WebCore/platform/wx/ClipboardWx.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ClipboardWx.h" + +#include "FileList.h" +#include "HashTable.h" +#include "IntPoint.h" +#include "NotImplemented.h" +#include "Pasteboard.h" +#include "PlatformString.h" +#include <wtf/text/StringHash.h> + + +namespace WebCore { + +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*) +{ + return 0; +} + +ClipboardWx::ClipboardWx(ClipboardAccessPolicy policy, ClipboardType clipboardType) + : Clipboard(policy, clipboardType) +{ +} + +void ClipboardWx::clearData(const String& type) +{ + notImplemented(); +} + +void ClipboardWx::clearAllData() +{ + Pasteboard::generalPasteboard()->clear(); +} + +String ClipboardWx::getData(const String& type, bool& success) const +{ + notImplemented(); + return ""; +} + +bool ClipboardWx::setData(const String& type, const String& data) +{ + notImplemented(); + return false; +} + +// extensions beyond IE's API +HashSet<String> ClipboardWx::types() const +{ + notImplemented(); + HashSet<String> result; + return result; +} + +PassRefPtr<FileList> ClipboardWx::files() const +{ + notImplemented(); + return 0; +} + +IntPoint ClipboardWx::dragLocation() const +{ + notImplemented(); + return IntPoint(0,0); +} + +CachedImage* ClipboardWx::dragImage() const +{ + notImplemented(); + return 0; +} + +void ClipboardWx::setDragImage(CachedImage*, const IntPoint&) +{ + notImplemented(); +} + +Node* ClipboardWx::dragImageElement() +{ + notImplemented(); + return 0; +} + +void ClipboardWx::setDragImageElement(Node*, const IntPoint&) +{ + notImplemented(); +} + +DragImageRef ClipboardWx::createDragImage(IntPoint& dragLoc) const +{ + notImplemented(); + return 0; +} + +void ClipboardWx::declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*) +{ + notImplemented(); +} + +void ClipboardWx::writeURL(const KURL& url, const String& string, Frame* frame) +{ + Pasteboard::generalPasteboard()->writeURL(url, string, frame); +} + +void ClipboardWx::writeRange(Range*, Frame*) +{ + notImplemented(); +} + +bool ClipboardWx::hasData() +{ + notImplemented(); + return false; +} + +void ClipboardWx::writePlainText(const WTF::String& text) +{ + Pasteboard::generalPasteboard()->writePlainText(text); +} + +} diff --git a/Source/WebCore/platform/wx/ClipboardWx.h b/Source/WebCore/platform/wx/ClipboardWx.h new file mode 100644 index 0000000..138635a --- /dev/null +++ b/Source/WebCore/platform/wx/ClipboardWx.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ClipboardWx_h +#define ClipboardWx_h + +#include "Clipboard.h" + +namespace WebCore { + + class CachedImage; + + // State available during IE's events for drag and drop and copy/paste + class ClipboardWx : public Clipboard { + public: + static PassRefPtr<ClipboardWx> create(ClipboardAccessPolicy policy, ClipboardType clipboardType) + { + return adoptRef(new ClipboardWx(policy, clipboardType)); + } + + void clearData(const String& type); + void clearAllData(); + String getData(const String& type, bool& success) const; + bool setData(const String& type, const String& data); + + // extensions beyond IE's API + virtual HashSet<String> types() const; + virtual PassRefPtr<FileList> files() const; + + IntPoint dragLocation() const; + CachedImage* dragImage() const; + void setDragImage(CachedImage*, const IntPoint&); + Node* dragImageElement(); + void setDragImageElement(Node*, const IntPoint&); + + virtual DragImageRef createDragImage(IntPoint& dragLoc) const; + virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*); + virtual void writeURL(const KURL&, const String&, Frame*); + virtual void writeRange(Range*, Frame*); + virtual void writePlainText(const WTF::String&); + + + virtual bool hasData(); + + private: + ClipboardWx(ClipboardAccessPolicy, ClipboardType); + }; +} + +#endif // ClipboardWx_h diff --git a/Source/WebCore/platform/wx/ContextMenuItemWx.cpp b/Source/WebCore/platform/wx/ContextMenuItemWx.cpp new file mode 100644 index 0000000..51ebe13 --- /dev/null +++ b/Source/WebCore/platform/wx/ContextMenuItemWx.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2008 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "ContextMenuItem.h" +#include "ContextMenu.h" +#include "PlatformMenuDescription.h" + +using namespace WebCore; + +ContextMenuItem::ContextMenuItem(ContextMenu* subMenu) +{ + m_platformDescription.type = SubmenuType; + m_platformDescription.action = ContextMenuItemTagNoAction; + if (subMenu) + setSubMenu(subMenu); + else + m_platformDescription.subMenu = 0; +} + +ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, + const String& title, ContextMenu* subMenu) +{ + m_platformDescription.type = type; + m_platformDescription.action = action; + m_platformDescription.title = title; + if (subMenu) + setSubMenu(subMenu); + else + m_platformDescription.subMenu = 0; +} + +ContextMenuItem::~ContextMenuItem() +{ +} + +PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() +{ + return m_platformDescription; +} + +ContextMenuItemType ContextMenuItem::type() const +{ + return m_platformDescription.type; +} + +void ContextMenuItem::setType(ContextMenuItemType type) +{ + m_platformDescription.type = type; +} + +ContextMenuAction ContextMenuItem::action() const +{ + return m_platformDescription.action; +} + +void ContextMenuItem::setAction(ContextMenuAction action) +{ + m_platformDescription.action = action; +} + +String ContextMenuItem::title() const +{ + return m_platformDescription.title; +} + +void ContextMenuItem::setTitle(const String& title) +{ + m_platformDescription.title = title; +} + +void ContextMenuItem::setSubMenu(ContextMenu* subMenu) +{ + m_platformDescription.subMenu = subMenu->releasePlatformDescription(); +} + +void ContextMenuItem::setChecked(bool shouldCheck) +{ + m_platformDescription.checked = shouldCheck; +} + +void ContextMenuItem::setEnabled(bool shouldEnable) +{ + m_platformDescription.enabled = shouldEnable; +} diff --git a/Source/WebCore/platform/wx/ContextMenuWx.cpp b/Source/WebCore/platform/wx/ContextMenuWx.cpp new file mode 100644 index 0000000..a1bab37 --- /dev/null +++ b/Source/WebCore/platform/wx/ContextMenuWx.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2008 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "ContextMenu.h" +#include "ContextMenuItem.h" +#include "PlatformMenuDescription.h" +#include "wx/menu.h" + +#include <wtf/HashMap.h> + +using namespace WebCore; + +typedef WTF::HashMap<int, ContextMenuAction> ItemActionMap; +static ItemActionMap s_itemActions; + +ContextMenuItem* ContextMenu::itemWithId(int id) +{ + return new ContextMenuItem(ActionType, s_itemActions.get(id), ""); +} + +ContextMenu::ContextMenu() +{ + m_platformDescription = new wxMenu(0); +} + +ContextMenu::~ContextMenu() +{ + if (m_platformDescription) + delete m_platformDescription; +} + +void ContextMenu::appendItem(ContextMenuItem& item) +{ + if (!m_platformDescription) + return; + + PlatformMenuItemDescription itemDescription = item.releasePlatformDescription(); + wxItemKind menuKindWx = ( itemDescription.type == CheckableActionType ) ? wxITEM_CHECK : wxITEM_NORMAL; + wxString titleWx(itemDescription.title); + int idWx = wxID_ANY; + wxMenuItem * itemWx; + + ItemActionMap::const_iterator end = s_itemActions.end(); + for (ItemActionMap::const_iterator it = s_itemActions.begin(); it != end; ++it) { + if (it->second == itemDescription.action) + idWx = it->first; + } + + if (itemDescription.subMenu) { + itemWx = new wxMenuItem(m_platformDescription, idWx, titleWx, wxEmptyString, wxITEM_NORMAL, itemDescription.subMenu); + } else if (itemDescription.type != SeparatorType) { + itemWx = new wxMenuItem(m_platformDescription, idWx, titleWx, wxT(""), menuKindWx); + } else { + itemWx = new wxMenuItem(m_platformDescription); + } + + s_itemActions.add(itemWx->GetId(), item.action()); + + m_platformDescription->Append(itemWx); + m_platformDescription->Enable(itemWx->GetId(), itemDescription.enabled); + + if (menuKindWx == wxITEM_CHECK) + m_platformDescription->Check(itemWx->GetId(), itemDescription.checked); +} + +void ContextMenu::setPlatformDescription(PlatformMenuDescription menu) +{ + if (!menu) + return; + + if (m_platformDescription) + delete m_platformDescription; + + m_platformDescription = menu; +} + +PlatformMenuDescription ContextMenu::platformDescription() const +{ + return m_platformDescription; +} + +PlatformMenuDescription ContextMenu::releasePlatformDescription() +{ + PlatformMenuDescription description = m_platformDescription; + m_platformDescription = 0; + + return description; +} diff --git a/Source/WebCore/platform/wx/CursorWx.cpp b/Source/WebCore/platform/wx/CursorWx.cpp new file mode 100644 index 0000000..dd61f1e --- /dev/null +++ b/Source/WebCore/platform/wx/CursorWx.cpp @@ -0,0 +1,307 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Cursor.h" +#include "Image.h" + +#include <wx/defs.h> +#include <wx/cursor.h> +#include <wx/image.h> + +namespace WebCore { + +Cursor::Cursor(const Cursor& other) + : m_platformCursor(other.m_platformCursor) +{ +} + +Cursor::Cursor(Image* image, const IntPoint&) +{ + m_platformCursor = 0; + // FIXME: figure out why the below code causes a crash + //m_platformCursor = new wxCursor( image->getWxBitmap()->ConvertToImage() ); +} + +Cursor::~Cursor() +{ +} + +Cursor& Cursor::operator=(const Cursor& other) +{ + m_platformCursor = other.m_platformCursor; + return *this; +} + +Cursor::Cursor(wxCursor* c) + : m_platformCursor(c) +{ +} + +const Cursor& pointerCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_ARROW); + return c; +} + +const Cursor& crossCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_CROSS); + return c; +} + +const Cursor& handCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_HAND); + return c; +} + +const Cursor& iBeamCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_IBEAM); + return c; +} + +const Cursor& waitCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_WAIT); + return c; +} + +const Cursor& helpCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_QUESTION_ARROW); + return c; +} + +const Cursor& eastResizeCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_SIZEWE); + return c; +} + +const Cursor& northResizeCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_SIZENS); + return c; +} + +const Cursor& northEastResizeCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_SIZENESW); + return c; +} + +const Cursor& northWestResizeCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_SIZENWSE); + return c; +} + +const Cursor& southResizeCursor() +{ + static Cursor c = northResizeCursor(); + return c; +} + +const Cursor& southEastResizeCursor() +{ + static Cursor c = northWestResizeCursor(); + return c; +} + +const Cursor& southWestResizeCursor() +{ + static Cursor c = northEastResizeCursor(); + return c; +} + +const Cursor& westResizeCursor() +{ + static Cursor c = eastResizeCursor(); + return c; +} + +const Cursor& northSouthResizeCursor() +{ + static Cursor c = northResizeCursor(); + return c; +} + +const Cursor& eastWestResizeCursor() +{ + static Cursor c = eastResizeCursor(); + return c; +} + +const Cursor& northEastSouthWestResizeCursor() +{ + static Cursor c = northEastResizeCursor(); + return c; +} + +const Cursor& northWestSouthEastResizeCursor() +{ + static Cursor c = northWestResizeCursor(); + return c; +} + +const Cursor& columnResizeCursor() +{ + // FIXME: Windows does not have a standard column resize cursor + static Cursor c = new wxCursor(wxCURSOR_SIZING); + return c; +} + +const Cursor& rowResizeCursor() +{ + // FIXME: Windows does not have a standard row resize cursor + static Cursor c = new wxCursor(wxCURSOR_SIZING); + return c; +} + +const Cursor& middlePanningCursor() +{ + return moveCursor(); +} + +const Cursor& eastPanningCursor() +{ + return eastResizeCursor(); +} + +const Cursor& northPanningCursor() +{ + return northResizeCursor(); +} + +const Cursor& northEastPanningCursor() +{ + return northEastResizeCursor(); +} + +const Cursor& northWestPanningCursor() +{ + return northWestResizeCursor(); +} + +const Cursor& southPanningCursor() +{ + return southResizeCursor(); +} + +const Cursor& southEastPanningCursor() +{ + return southEastResizeCursor(); +} + +const Cursor& southWestPanningCursor() +{ + return southWestResizeCursor(); +} + +const Cursor& westPanningCursor() +{ + return westResizeCursor(); +} + +const Cursor& verticalTextCursor() +{ + return iBeamCursor(); +} + +const Cursor& cellCursor() +{ + return pointerCursor(); +} + +const Cursor& contextMenuCursor() +{ + return handCursor(); +} + +const Cursor& noDropCursor() +{ + return pointerCursor(); +} + +const Cursor& progressCursor() +{ + return waitCursor(); +} + +const Cursor& aliasCursor() +{ + return pointerCursor(); +} + +const Cursor& copyCursor() +{ + return pointerCursor(); +} + +const Cursor& noneCursor() +{ + // TODO: Determine if we can find a better cursor for this. + return pointerCursor(); +} + +const Cursor& notAllowedCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_NO_ENTRY); + return c; +} + +const Cursor& zoomInCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_MAGNIFIER); + return c; +} + +const Cursor& zoomOutCursor() +{ + // TODO: Find a way to implement in/out magnifiers in wx. + return zoomInCursor(); +} + +const Cursor& grabCursor() +{ + // TODO: Determine if we can find a better cursor for this. + return pointerCursor(); +} + +const Cursor& grabbingCursor() +{ + // TODO: Determine if we can find a better cursor for this. + return pointerCursor(); +} + +const Cursor& moveCursor() +{ + static Cursor c = new wxCursor(wxCURSOR_SIZING); + return c; +} + +} diff --git a/Source/WebCore/platform/wx/DragDataWx.cpp b/Source/WebCore/platform/wx/DragDataWx.cpp new file mode 100644 index 0000000..35e3753 --- /dev/null +++ b/Source/WebCore/platform/wx/DragDataWx.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DragData.h" + +#include "Document.h" +#include "DocumentFragment.h" + +namespace WebCore { + +bool DragData::canSmartReplace() const +{ + return false; +} + +bool DragData::containsColor() const +{ + return false; +} + +bool DragData::containsFiles() const +{ + return false; +} + +void DragData::asFilenames(Vector<String>& result) const +{ +} + +bool DragData::containsPlainText() const +{ + return false; +} + +String DragData::asPlainText() const +{ + return String(); +} + +Color DragData::asColor() const +{ + return Color(); +} + +bool DragData::containsCompatibleContent() const +{ + return false; +} + +bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const +{ + return false; +} + +String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const +{ + return String(); +} + + +PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const +{ + return 0; +} + +} + diff --git a/Source/WebCore/platform/wx/DragImageWx.cpp b/Source/WebCore/platform/wx/DragImageWx.cpp new file mode 100644 index 0000000..df2dcee --- /dev/null +++ b/Source/WebCore/platform/wx/DragImageWx.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DragImage.h" +#include "CachedImage.h" +#include "FloatSize.h" +#include "Image.h" + +namespace WebCore { + +IntSize dragImageSize(DragImageRef) +{ + return IntSize(0, 0); +} + +void deleteDragImage(DragImageRef) +{ +} + +DragImageRef scaleDragImage(DragImageRef image, FloatSize) +{ + return image; +} + +DragImageRef dissolveDragImageToFraction(DragImageRef image, float) +{ + return image; +} + +DragImageRef createDragImageFromImage(Image*) +{ + return 0; +} + +DragImageRef createDragImageIconForCachedImage(CachedImage*) +{ + return 0; +} + +} diff --git a/Source/WebCore/platform/wx/EventLoopWx.cpp b/Source/WebCore/platform/wx/EventLoopWx.cpp new file mode 100644 index 0000000..99090ca --- /dev/null +++ b/Source/WebCore/platform/wx/EventLoopWx.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "EventLoop.h" + +#include <wx/defs.h> +#include <wx/app.h> + +namespace WebCore { + +void EventLoop::cycle() +{ + if (wxTheApp) { + if (wxTheApp->IsMainLoopRunning()) + wxTheApp->Dispatch(); + else + m_ended = true; + } +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/wx/FileChooserWx.cpp b/Source/WebCore/platform/wx/FileChooserWx.cpp new file mode 100644 index 0000000..34065f3 --- /dev/null +++ b/Source/WebCore/platform/wx/FileChooserWx.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FileChooser.h" + +#include "NotImplemented.h" + +namespace WebCore { + +String FileChooser::basenameForWidth(const Font&, int width) const +{ + notImplemented(); + return String(); +} + +} + diff --git a/Source/WebCore/platform/wx/FileSystemWx.cpp b/Source/WebCore/platform/wx/FileSystemWx.cpp new file mode 100644 index 0000000..bfcaf88 --- /dev/null +++ b/Source/WebCore/platform/wx/FileSystemWx.cpp @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2007 Kevin Ollivier + * Copyright (C) 2008 Collabora, Ltd. + * Copyright (C) 2009 Peter Laufenberg @ Inhance Digital Corp + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FileSystem.h" + +#include "NotImplemented.h" +#include "PlatformString.h" +#include <wtf/text/CString.h> + +#include <wx/wx.h> +#include <wx/datetime.h> +#include <wx/dir.h> +#include <wx/dynlib.h> +#include <wx/file.h> +#include <wx/filefn.h> +#include <wx/filename.h> + +#if OS(DARWIN) +#include <CoreFoundation/CoreFoundation.h> +#endif + +namespace WebCore { + +bool fileExists(const String& path) +{ + // NOTE: This is called for directory paths too so we need to check both. + return wxFileName::FileExists(path) || wxFileName::DirExists(path); +} + +bool deleteFile(const String& path) +{ + return wxRemoveFile(path); +} + +bool deleteEmptyDirectory(const String& path) +{ + return wxFileName::Rmdir(path); +} + +bool getFileSize(const String& path, long long& resultSize) +{ + wxULongLong size = wxFileName::GetSize(path); + if (wxInvalidSize != size) { + // TODO: why is FileSystem::getFileSize signed? + resultSize = (long long)size.GetValue(); + return true; + } + + return false; +} + +bool getFileModificationTime(const String& path, time_t& t) +{ + t = wxFileName(path).GetModificationTime().GetTicks(); + return true; +} + +bool makeAllDirectories(const String& path) +{ + return wxFileName::Mkdir(path, 0777, wxPATH_MKDIR_FULL); +} + +String pathByAppendingComponent(const String& path, const String& component) +{ + return wxFileName(path, component).GetFullPath(); +} + +String homeDirectoryPath() +{ + return wxFileName::GetHomeDir(); +} + +String pathGetFileName(const String& path) +{ + return wxFileName(path).GetFullName(); +} + +String directoryName(const String& path) +{ + return wxFileName(path).GetPath(); +} + +CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle) +{ + notImplemented(); + handle = invalidPlatformFileHandle; + return CString(); +} + +void closeFile(PlatformFileHandle&) +{ + notImplemented(); +} + +int writeToFile(PlatformFileHandle, const char* data, int length) +{ + notImplemented(); + return 0; +} + +bool unloadModule(PlatformModule mod) +{ +#if OS(WINDOWS) + return ::FreeLibrary(mod); +#elif OS(DARWIN) + CFRelease(mod); + return true; +#else + wxASSERT(mod); + delete mod; + return true; +#endif +} + + +class wxDirTraverserNonRecursive : public wxDirTraverser { +public: + wxDirTraverserNonRecursive(wxString basePath, wxArrayString& files) : m_basePath(basePath), m_files(files) { } + + virtual wxDirTraverseResult OnFile(const wxString& filename) + { + wxFileName afile(filename); + afile.MakeRelativeTo(m_basePath); + if (afile.GetFullPath().Find(afile.GetPathSeparator()) == wxNOT_FOUND) + m_files.push_back(filename); + + return wxDIR_CONTINUE; + } + + virtual wxDirTraverseResult OnDir(const wxString& dirname) + { + wxFileName dirfile(dirname); + dirfile.MakeRelativeTo(m_basePath); + if (dirfile.GetFullPath().Find(dirfile.GetPathSeparator()) == wxNOT_FOUND) + m_files.push_back(dirname); + + return wxDIR_CONTINUE; + } + +private: + wxString m_basePath; + wxArrayString& m_files; + + DECLARE_NO_COPY_CLASS(wxDirTraverserNonRecursive) +}; + +Vector<String> listDirectory(const String& path, const String& filter) +{ + wxArrayString file_paths; + // wxDir::GetAllFiles recurses and for platforms like Mac where + // a .plugin or .bundle can be a dir wx will recurse into the bundle + // and list the files rather than just returning the plugin name, so + // we write a special traverser that works around that issue. + wxDirTraverserNonRecursive traverser(path, file_paths); + + wxDir dir(path); + dir.Traverse(traverser, _T(""), wxDIR_FILES | wxDIR_DIRS); + + Vector<String> entries; + + for (int i = 0; i < file_paths.GetCount(); i++) + { + entries.append(file_paths[i]); + } + + return entries; +} + +} diff --git a/Source/WebCore/platform/wx/KURLWx.cpp b/Source/WebCore/platform/wx/KURLWx.cpp new file mode 100644 index 0000000..a2be103 --- /dev/null +++ b/Source/WebCore/platform/wx/KURLWx.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "KURL.h" + +#include "NotImplemented.h" + +namespace WebCore { + +String KURL::fileSystemPath() const +{ + notImplemented(); + return String(); +} + +} + diff --git a/Source/WebCore/platform/wx/KeyEventWin.cpp b/Source/WebCore/platform/wx/KeyEventWin.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Source/WebCore/platform/wx/KeyEventWin.cpp diff --git a/Source/WebCore/platform/wx/KeyboardEventWx.cpp b/Source/WebCore/platform/wx/KeyboardEventWx.cpp new file mode 100644 index 0000000..1e88572 --- /dev/null +++ b/Source/WebCore/platform/wx/KeyboardEventWx.cpp @@ -0,0 +1,399 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PlatformKeyboardEvent.h" + +#include "WindowsKeyboardCodes.h" +#include <wx/defs.h> +#include <wx/event.h> + +namespace WebCore { + +static String keyIdentifierForWxKeyCode(int keyCode) +{ + switch (keyCode) { + case WXK_MENU: + case WXK_ALT: + return "Alt"; + case WXK_CLEAR: + return "Clear"; + case WXK_DOWN: + return "Down"; + case WXK_END: + return "End"; + case WXK_RETURN: + return "Enter"; + case WXK_EXECUTE: + return "Execute"; + case WXK_F1: + return "F1"; + case WXK_F2: + return "F2"; + case WXK_F3: + return "F3"; + case WXK_F4: + return "F4"; + case WXK_F5: + return "F5"; + case WXK_F6: + return "F6"; + case WXK_F7: + return "F7"; + case WXK_F8: + return "F8"; + case WXK_F9: + return "F9"; + case WXK_F10: + return "F10"; + case WXK_F11: + return "F11"; + case WXK_F12: + return "F12"; + case WXK_F13: + return "F13"; + case WXK_F14: + return "F14"; + case WXK_F15: + return "F15"; + case WXK_F16: + return "F16"; + case WXK_F17: + return "F17"; + case WXK_F18: + return "F18"; + case WXK_F19: + return "F19"; + case WXK_F20: + return "F20"; + case WXK_F21: + return "F21"; + case WXK_F22: + return "F22"; + case WXK_F23: + return "F23"; + case WXK_F24: + return "F24"; + case WXK_HELP: + return "Help"; + case WXK_HOME: + return "Home"; + case WXK_INSERT: + return "Insert"; + case WXK_LEFT: + return "Left"; + case WXK_PAGEDOWN: + return "PageDown"; + case WXK_PAGEUP: + return "PageUp"; + case WXK_PAUSE: + return "Pause"; + case WXK_PRINT: + return "PrintScreen"; + case WXK_RIGHT: + return "Right"; + case WXK_SELECT: + return "Select"; + case WXK_UP: + return "Up"; + // Standard says that DEL becomes U+007F. + case WXK_DELETE: + return "U+007F"; + default: + return String::format("U+%04X", toupper(keyCode)); + } +} + +static int windowsKeyCodeForKeyEvent(unsigned int keycode) +{ + switch (keycode) { + /* FIXME: Need to supply a bool in this func, to determine wheter the event comes from the keypad + */ + case WXK_NUMPAD0: + return VK_NUMPAD0;// (60) Numeric keypad 0 key + case WXK_NUMPAD1: + return VK_NUMPAD1;// (61) Numeric keypad 1 key + case WXK_NUMPAD2: + return VK_NUMPAD2; // (62) Numeric keypad 2 key + case WXK_NUMPAD3: + return VK_NUMPAD3; // (63) Numeric keypad 3 key + case WXK_NUMPAD4: + return VK_NUMPAD4; // (64) Numeric keypad 4 key + case WXK_NUMPAD5: + return VK_NUMPAD5; //(65) Numeric keypad 5 key + case WXK_NUMPAD6: + return VK_NUMPAD6; // (66) Numeric keypad 6 key + case WXK_NUMPAD7: + return VK_NUMPAD7; // (67) Numeric keypad 7 key + case WXK_NUMPAD8: + return VK_NUMPAD8; // (68) Numeric keypad 8 key + case WXK_NUMPAD9: + return VK_NUMPAD9; // (69) Numeric keypad 9 key + case WXK_NUMPAD_MULTIPLY: + return VK_MULTIPLY; // (6A) Multiply key + case WXK_NUMPAD_ADD: + return VK_ADD; // (6B) Add key + case WXK_NUMPAD_SUBTRACT: + return VK_SUBTRACT; // (6D) Subtract key + case WXK_NUMPAD_DECIMAL: + return VK_DECIMAL; // (6E) Decimal key + case WXK_DIVIDE: + return VK_DIVIDE; // (6F) Divide key + case WXK_NUMPAD_SEPARATOR: + return VK_SEPARATOR; + + case WXK_BACK: + return VK_BACK; // (08) BACKSPACE key + case WXK_TAB: + case WXK_NUMPAD_TAB: + return VK_TAB; // (09) TAB key + case WXK_CLEAR: + return VK_CLEAR; // (0C) CLEAR key + case WXK_NUMPAD_ENTER: + case WXK_RETURN: + return VK_RETURN; //(0D) Return key + case WXK_SHIFT: + return VK_SHIFT; // (10) SHIFT key + case WXK_CONTROL: + return VK_CONTROL; // (11) CTRL key + case WXK_MENU: + case WXK_ALT: + return VK_MENU; // (12) ALT key + + case WXK_PAUSE: + return VK_PAUSE; // (13) PAUSE key + case WXK_CAPITAL: + return VK_CAPITAL; // (14) CAPS LOCK key + /* + case WXK_Kana_Lock: + case WXK_Kana_Shift: + return VK_KANA; // (15) Input Method Editor (IME) Kana mode + case WXK_Hangul: + return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode + // VK_JUNJA (17) IME Junja mode + // VK_FINAL (18) IME final mode + case WXK_Hangul_Hanja: + return VK_HANJA; // (19) IME Hanja mode + case WXK_Kanji: + return VK_KANJI; // (19) IME Kanji mode + */ + case WXK_ESCAPE: + return VK_ESCAPE; // (1B) ESC key + // VK_CONVERT (1C) IME convert + // VK_NONCONVERT (1D) IME nonconvert + // VK_ACCEPT (1E) IME accept + // VK_MODECHANGE (1F) IME mode change request + case WXK_NUMPAD_SPACE: + case WXK_SPACE: + return VK_SPACE; // (20) SPACEBAR + case WXK_NUMPAD_PAGEUP: + case WXK_PAGEUP: + return VK_PRIOR; // (21) PAGE UP key + case WXK_NUMPAD_PAGEDOWN: + case WXK_PAGEDOWN: + return VK_NEXT; // (22) PAGE DOWN key + case WXK_NUMPAD_END: + case WXK_END: + return VK_END; // (23) END key + case WXK_NUMPAD_HOME: + case WXK_HOME: + return VK_HOME; // (24) HOME key + case WXK_NUMPAD_LEFT: + case WXK_LEFT: + return VK_LEFT; // (25) LEFT ARROW key + case WXK_NUMPAD_UP: + case WXK_UP: + return VK_UP; // (26) UP ARROW key + case WXK_NUMPAD_RIGHT: + case WXK_RIGHT: + return VK_RIGHT; // (27) RIGHT ARROW key + case WXK_NUMPAD_DOWN: + case WXK_DOWN: + return VK_DOWN; // (28) DOWN ARROW key + case WXK_SELECT: + return VK_SELECT; // (29) SELECT key + case WXK_PRINT: + return VK_PRINT; // (2A) PRINT key + case WXK_EXECUTE: + return VK_EXECUTE;// (2B) EXECUTE key + case WXK_SNAPSHOT: + return VK_SNAPSHOT; // (2C) PRINT SCREEN key + case WXK_NUMPAD_INSERT: + case WXK_INSERT: + return VK_INSERT; // (2D) INS key + case WXK_NUMPAD_DELETE: + case WXK_DELETE: + return VK_DELETE; // (2E) DEL key + case WXK_HELP: + return VK_HELP; // (2F) HELP key + case '0': + return VK_0; // (30) 0) key + case '1': + return VK_1; // (31) 1 ! key + case '2': + return VK_2; // (32) 2 & key + case '3': + return VK_3; //case '3': case '#'; + case '4': // (34) 4 key '$'; + return VK_4; + case '5': + return VK_5; // (35) 5 key '%' + case '6': + return VK_6; // (36) 6 key '^' + case '7': + return VK_7; // (37) 7 key case '&' + case '8': + return VK_8; // (38) 8 key '*' + case '9': + return VK_9; // (39) 9 key '(' + case 'A': + return VK_A; // (41) A key case 'a': case 'A': return 0x41; + case 'B': + return VK_B; // (42) B key case 'b': case 'B': return 0x42; + case 'C': + return VK_C; // (43) C key case 'c': case 'C': return 0x43; + case 'D': + return VK_D; // (44) D key case 'd': case 'D': return 0x44; + case 'E': + return VK_E; // (45) E key case 'e': case 'E': return 0x45; + case 'F': + return VK_F; // (46) F key case 'f': case 'F': return 0x46; + case 'G': + return VK_G; // (47) G key case 'g': case 'G': return 0x47; + case 'H': + return VK_H; // (48) H key case 'h': case 'H': return 0x48; + case 'I': + return VK_I; // (49) I key case 'i': case 'I': return 0x49; + case 'J': + return VK_J; // (4A) J key case 'j': case 'J': return 0x4A; + case 'K': + return VK_K; // (4B) K key case 'k': case 'K': return 0x4B; + case 'L': + return VK_L; // (4C) L key case 'l': case 'L': return 0x4C; + case 'M': + return VK_M; // (4D) M key case 'm': case 'M': return 0x4D; + case 'N': + return VK_N; // (4E) N key case 'n': case 'N': return 0x4E; + case 'O': + return VK_O; // (4F) O key case 'o': case 'O': return 0x4F; + case 'P': + return VK_P; // (50) P key case 'p': case 'P': return 0x50; + case 'Q': + return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51; + case 'R': + return VK_R; // (52) R key case 'r': case 'R': return 0x52; + case 'S': + return VK_S; // (53) S key case 's': case 'S': return 0x53; + case 'T': + return VK_T; // (54) T key case 't': case 'T': return 0x54; + case 'U': + return VK_U; // (55) U key case 'u': case 'U': return 0x55; + case 'V': + return VK_V; // (56) V key case 'v': case 'V': return 0x56; + case 'W': + return VK_W; // (57) W key case 'w': case 'W': return 0x57; + case 'X': + return VK_X; // (58) X key case 'x': case 'X': return 0x58; + case 'Y': + return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59; + case 'Z': + return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A; + case WXK_WINDOWS_LEFT: + return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard) + + case WXK_NUMLOCK: + return VK_NUMLOCK; // (90) NUM LOCK key + + case WXK_SCROLL: + return VK_SCROLL; // (91) SCROLL LOCK key + + default: + return 0; + } +} + +PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event) +{ + if (event.GetEventType() == wxEVT_KEY_UP) + m_type = KeyUp; + else if (event.GetEventType() == wxEVT_KEY_DOWN) + m_type = KeyDown; + else if (event.GetEventType() == wxEVT_CHAR) + m_type = Char; + else + ASSERT_NOT_REACHED(); + if (m_type != Char) + m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode()); + else { + //ENTER is an editing command processed as a char (only Enter and Tab are) + //unfortunately the unicode key for numpad_enter (370) is NOT what we want here (13) + //The unicode values for normal enter and tab are the same as the ASCII values, thus ok + //Note that I think this a wx bug, as the Character Code is actually 13 when + //numpad_enter is a CHAR event. + if (event.GetKeyCode() == 13 && event.GetUnicodeKey() == wxChar(370)) + m_text = "\r"; + else + m_text = wxString(event.GetUnicodeKey()); + m_unmodifiedText = m_text; + } + m_autoRepeat = false; // FIXME: not correct. + m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event.GetKeyCode()); + m_nativeVirtualKeyCode = event.GetKeyCode(); + m_isKeypad = (event.GetKeyCode() >= WXK_NUMPAD_SPACE) && (event.GetKeyCode() <= WXK_NUMPAD_DIVIDE); + m_shiftKey = event.ShiftDown(); + m_ctrlKey = event.CmdDown(); + m_altKey = event.AltDown(); + m_metaKey = event.MetaDown(); +} + +void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool) +{ + // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions. + ASSERT(m_type == KeyDown); + m_type = type; + if (type == RawKeyDown) { + m_text = String(); + m_unmodifiedText = String(); + } else { + m_keyIdentifier = String(); + m_windowsVirtualKeyCode = 0; + } +} + +bool PlatformKeyboardEvent::currentCapsLockState() +{ + return wxGetKeyState(WXK_CAPITAL); +} + +void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey) +{ + shiftKey = wxGetKeyState(WXK_SHIFT); + ctrlKey = wxGetKeyState(WXK_CONTROL); + altKey = wxGetKeyState(WXK_ALT); + metaKey = false; +} + +} + diff --git a/Source/WebCore/platform/wx/LocalizedStringsWx.cpp b/Source/WebCore/platform/wx/LocalizedStringsWx.cpp new file mode 100644 index 0000000..4b56394 --- /dev/null +++ b/Source/WebCore/platform/wx/LocalizedStringsWx.cpp @@ -0,0 +1,489 @@ +/* + * Copyright (C) 2007 Kevin Ollivier + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "LocalizedStrings.h" + +#include "NotImplemented.h" +#include "PlatformString.h" + +namespace WebCore { + +String submitButtonDefaultLabel() +{ + return String("Submit"); +} + +String inputElementAltText() +{ + return String(); +} + +String resetButtonDefaultLabel() +{ + return String("Reset"); +} + +String platformDefaultLanguage() +{ + return String("en"); +} + +String searchableIndexIntroduction() +{ + return String("Searchable Index"); +} + +String fileButtonChooseFileLabel() +{ + return String("Choose File"); +} + +String fileButtonNoFileSelectedLabel() +{ + return String("No file selected"); +} + +String contextMenuItemTagOpenLinkInNewWindow() +{ + return String("Open Link in New Window"); +} + +String contextMenuItemTagDownloadLinkToDisk() +{ + return String("Download Link to Disk"); +} + +String contextMenuItemTagCopyLinkToClipboard() +{ + return String("Copy Link to Clipboard"); +} + +String contextMenuItemTagOpenImageInNewWindow() +{ + return String("Open Image in New Window"); +} + +String contextMenuItemTagDownloadImageToDisk() +{ + return String("Download Image to Disk"); +} + +String contextMenuItemTagCopyImageToClipboard() +{ + return String("Copy Image to Clipboard"); +} + +String contextMenuItemTagOpenVideoInNewWindow() +{ + return String("Open Video in New Window"); +} + +String contextMenuItemTagOpenAudioInNewWindow() +{ + return String("Open Audio in New Window"); +} + +String contextMenuItemTagCopyVideoLinkToClipboard() +{ + return String("Copy Video Link Location"); +} + +String contextMenuItemTagCopyAudioLinkToClipboard() +{ + return String("Copy Audio Link Location"); +} + +String contextMenuItemTagToggleMediaControls() +{ + return String("Toggle Media Controls"); +} + +String contextMenuItemTagToggleMediaLoop() +{ + return String("Toggle Media Loop Playback"); +} + +String contextMenuItemTagEnterVideoFullscreen() +{ + return String("Switch Video to Fullscreen"); +} + +String contextMenuItemTagMediaPlay() +{ + return String("Play"); +} + +String contextMenuItemTagMediaPause() +{ + return String("Pause"); +} + +String contextMenuItemTagMediaMute() +{ + return String("Mute"); +} + +String contextMenuItemTagOpenFrameInNewWindow() +{ + return String("Open Frame in New Window"); +} + +String contextMenuItemTagCopy() +{ + return String("Copy"); +} + +String contextMenuItemTagGoBack() +{ + return String("Go Back"); +} + +String contextMenuItemTagGoForward() +{ + return String("Go Forward"); +} + +String contextMenuItemTagStop() +{ + return String("Stop"); +} + +String contextMenuItemTagReload() +{ + return String("Reload"); +} + +String contextMenuItemTagCut() +{ + return String("Cut"); +} + +String contextMenuItemTagPaste() +{ + return String("Paste"); +} + +String contextMenuItemTagNoGuessesFound() +{ + return String("No Guesses Found"); +} + +String contextMenuItemTagIgnoreSpelling() +{ + return String("Ignore Spelling"); +} + +String contextMenuItemTagLearnSpelling() +{ + return String("Learn Spelling"); +} + +String contextMenuItemTagSearchWeb() +{ + return String("Search Web"); +} + +String contextMenuItemTagLookUpInDictionary() +{ + return String("Look Up in Dictionary"); +} + +String contextMenuItemTagOpenLink() +{ + return String("Open Link"); +} + +String contextMenuItemTagIgnoreGrammar() +{ + return String("Ignore Grammar"); +} + +String contextMenuItemTagSpellingMenu() +{ + return String("Spelling"); +} + +String contextMenuItemTagShowSpellingPanel(bool show) +{ + return String("Show Spelling Panel"); +} + +String contextMenuItemTagCheckSpelling() +{ + return String("Check Spelling"); +} + +String contextMenuItemTagCheckSpellingWhileTyping() +{ + return String("Check Spelling While Typing"); +} + +String contextMenuItemTagCheckGrammarWithSpelling() +{ + return String("Check Grammar with Spelling"); +} + +String contextMenuItemTagFontMenu() +{ + return String("Font"); +} + +String contextMenuItemTagBold() +{ + return String("Bold"); +} + +String contextMenuItemTagItalic() +{ + return String("Italic"); +} + +String contextMenuItemTagUnderline() +{ + return String("Underline"); +} + +String contextMenuItemTagOutline() +{ + return String("Outline"); +} + +String contextMenuItemTagWritingDirectionMenu() +{ + return String("Writing Direction"); +} + +String contextMenuItemTagTextDirectionMenu() +{ + return String("Text Direction"); +} + +String contextMenuItemTagDefaultDirection() +{ + return String("Default Direction"); +} + +String contextMenuItemTagLeftToRight() +{ + return String("Left to Right"); +} + +String contextMenuItemTagRightToLeft() +{ + return String("Right to Left"); +} + +String searchMenuNoRecentSearchesText() +{ + return String("No recent searches"); +} + +String searchMenuRecentSearchesText() +{ + return String("Recent searches"); +} + +String searchMenuClearRecentSearchesText() +{ + return String("Clear recent searches"); +} + +String contextMenuItemTagInspectElement() +{ + return String("Inspect Element"); +} + +String multipleFileUploadText(unsigned numberOfFiles) +{ + // FIXME: If this file gets localized, this should really be localized as one string with a wildcard for the number. + return String::number(numberOfFiles) + String(" files"); +} + +String unknownFileSizeText() +{ + return String("Unknown"); +} + +String imageTitle(const String& filename, const IntSize& size) +{ + return String(); +} + +// accessibility related strings +String AXButtonActionVerb() +{ + return String(); +} + +String AXRadioButtonActionVerb() +{ + return String(); +} + +String AXTextFieldActionVerb() +{ + return String(); +} + +String AXCheckedCheckBoxActionVerb() +{ + return String(); +} + +String AXUncheckedCheckBoxActionVerb() +{ + return String(); +} + +String AXLinkActionVerb() +{ + return String(); +} + +String AXDefinitionListTermText() +{ + return String(); +} + +String AXDefinitionListDefinitionText() +{ + return String(); +} + +String AXMenuListPopupActionVerb() +{ + return String(); +} + +String AXMenuListActionVerb() +{ + return String(); +} + +String validationMessageValueMissingText() +{ + notImplemented(); + return String(); +} + +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageTypeMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessageTypeMismatchForEmailText() +{ + notImplemented(); + return validationMessageTypeMismatchText(); +} + +String validationMessageTypeMismatchForMultipleEmailText() +{ + notImplemented(); + return validationMessageTypeMismatchText(); +} + +String validationMessageTypeMismatchForURLText() +{ + notImplemented(); + return validationMessageTypeMismatchText(); +} + +String validationMessagePatternMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessageTooLongText(int, int) +{ + notImplemented(); + return String(); +} + +String validationMessageRangeUnderflowText(const String&) +{ + notImplemented(); + return String(); +} + +String validationMessageRangeOverflowText(const String&) +{ + notImplemented(); + return String(); +} + +String validationMessageStepMismatchText(const String&, const String&) +{ + notImplemented(); + return String(); +} + +String missingPluginText() +{ + notImplemented(); + return String("Missing Plug-in"); +} + +String crashedPluginText() +{ + notImplemented(); + return String("Plug-in Failure"); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/wx/LoggingWx.cpp b/Source/WebCore/platform/wx/LoggingWx.cpp new file mode 100644 index 0000000..e9d5999 --- /dev/null +++ b/Source/WebCore/platform/wx/LoggingWx.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Logging.h" + +#include "PlatformString.h" +#include <wtf/Vector.h> +#include <wtf/text/CString.h> + +#include <wx/defs.h> +#include <wx/utils.h> + +namespace WebCore { + +void InitializeLoggingChannelsIfNecessary() +{ + static bool haveInitializedLoggingChannels = false; + if (haveInitializedLoggingChannels) + return; + + haveInitializedLoggingChannels = true; + + wxString loggingEnv; + wxGetEnv(wxT("WX_WEBKIT_LOG"), &loggingEnv); + if (loggingEnv == wxEmptyString) + return; + + String wkLoggingEnv = loggingEnv; + Vector<String> logs; + + wkLoggingEnv.split(",", logs); + + for (size_t i = 0; i < logs.size(); ++i) { + WTFLogChannel* channel = getChannelFromName(logs[i]); + + if (channel) + channel->state = WTFLogChannelOn; + } +} + +} diff --git a/Source/WebCore/platform/wx/MimeTypeRegistryWx.cpp b/Source/WebCore/platform/wx/MimeTypeRegistryWx.cpp new file mode 100644 index 0000000..e7cc0e2 --- /dev/null +++ b/Source/WebCore/platform/wx/MimeTypeRegistryWx.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2006 Zack Rusin <zack@kde.org> + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "MIMETypeRegistry.h" + +namespace WebCore { + +struct ExtensionMap { + const char* extension; + const char* mimeType; +}; +static const ExtensionMap extensionMap [] = { + { "bmp", "image/bmp" }, + { "css", "text/css" }, + { "gif", "image/gif" }, + { "htm", "text/html" }, + { "html", "text/html" }, + { "ico", "image/x-icon" }, + { "jpeg", "image/jpeg" }, + { "jpg", "image/jpeg" }, + { "js", "application/x-javascript" }, + { "pdf", "application/pdf" }, + { "png", "image/png" }, + { "rss", "application/rss+xml" }, + { "svg", "image/svg+xml" }, + { "text", "text/plain" }, + { "txt", "text/plain" }, + { "xbm", "image/x-xbitmap" }, + { "xml", "text/xml" }, + { "xsl", "text/xsl" }, + { "xhtml", "application/xhtml+xml" }, + { 0, 0 } +}; + +String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) +{ + String s = ext.lower(); + const ExtensionMap *e = extensionMap; + while (e->extension) { + if (s == e->extension) + return e->mimeType; + ++e; + } + // unknown, let's just assume plain text + return "text/plain"; +} + +bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&) +{ + return false; +} + +} diff --git a/Source/WebCore/platform/wx/MouseEventWx.cpp b/Source/WebCore/platform/wx/MouseEventWx.cpp new file mode 100644 index 0000000..8591ef5 --- /dev/null +++ b/Source/WebCore/platform/wx/MouseEventWx.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Assertions.h" +#include "PlatformMouseEvent.h" +#include <wtf/CurrentTime.h> + +#include <wx/defs.h> +#include <wx/event.h> + +namespace WebCore { + +PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& globalPoint, int clickCount) + : m_position(event.GetPosition()) + , m_globalPosition(globalPoint) + , m_shiftKey(event.ShiftDown()) + , m_ctrlKey(event.CmdDown() || event.ControlDown()) + , m_altKey(event.AltDown()) + , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers +{ + wxEventType type = event.GetEventType(); + m_eventType = MouseEventMoved; + + if (type == wxEVT_LEFT_DOWN || type == wxEVT_MIDDLE_DOWN || type == wxEVT_RIGHT_DOWN) + m_eventType = MouseEventPressed; + + else if (type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_UP || + type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK) + m_eventType = MouseEventReleased; + + else if (type == wxEVT_MOTION) + m_eventType = MouseEventMoved; + + if (event.LeftIsDown() || event.Button(wxMOUSE_BTN_LEFT)) + m_button = LeftButton; + else if (event.RightIsDown() || event.Button(wxMOUSE_BTN_RIGHT)) + m_button = RightButton; + else if (event.MiddleIsDown() || event.Button(wxMOUSE_BTN_MIDDLE)) + m_button = MiddleButton; + else if (!m_eventType == MouseEventMoved) + ASSERT_NOT_REACHED(); + + + if (m_eventType == MouseEventMoved) + m_clickCount = 0; + else + m_clickCount = clickCount; + + m_timestamp = WTF::currentTime(); +} + +} diff --git a/Source/WebCore/platform/wx/MouseWheelEventWx.cpp b/Source/WebCore/platform/wx/MouseWheelEventWx.cpp new file mode 100644 index 0000000..aa41df4 --- /dev/null +++ b/Source/WebCore/platform/wx/MouseWheelEventWx.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PlatformWheelEvent.h" +#include "Scrollbar.h" + +#include <wx/defs.h> +#include <wx/event.h> + +namespace WebCore { + +PlatformWheelEvent::PlatformWheelEvent(const wxMouseEvent& event, const wxPoint& globalPoint) + : m_position(event.GetPosition()) + , m_globalPosition(globalPoint) + , m_granularity(ScrollByPixelWheelEvent) + , m_shiftKey(event.ShiftDown()) + , m_ctrlKey(event.ControlDown()) + , m_altKey(event.AltDown()) + , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers + , m_deltaX(0) // wx doesn't support horizontal mouse wheel scrolling + , m_deltaY(event.GetWheelRotation() / event.GetWheelDelta()) + , m_wheelTicksX(m_deltaX) + , m_wheelTicksY(m_deltaY) + , m_isAccepted(false) +{ + // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event + m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep()); +} + +} diff --git a/Source/WebCore/platform/wx/PasteboardWx.cpp b/Source/WebCore/platform/wx/PasteboardWx.cpp new file mode 100644 index 0000000..4677d14 --- /dev/null +++ b/Source/WebCore/platform/wx/PasteboardWx.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "Pasteboard.h" +#include "DocumentFragment.h" +#include "Editor.h" +#include "Frame.h" +#include "KURL.h" +#include "markup.h" +#include "NotImplemented.h" +#include "PlatformString.h" + +#include <wx/defs.h> +#include <wx/dataobj.h> +#include <wx/clipbrd.h> + +namespace WebCore { + +Pasteboard::Pasteboard() +{ +} + +Pasteboard* Pasteboard::generalPasteboard() +{ + static Pasteboard* pasteboard = new Pasteboard(); + return pasteboard; +} + +void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) +{ + if (wxTheClipboard->Open()) { + wxTheClipboard->SetData( new wxTextDataObject(frame->editor()->selectedText()) ); + wxTheClipboard->Close(); + } +} + +void Pasteboard::writePlainText(const String& text) +{ + if (wxTheClipboard->Open()) { + wxTheClipboard->SetData( new wxTextDataObject(text) ); + wxTheClipboard->Close(); + } +} + +bool Pasteboard::canSmartReplace() +{ + notImplemented(); + return false; +} + +String Pasteboard::plainText(Frame* frame) +{ + notImplemented(); + return String(); +} + +PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, + bool allowPlainText, bool& chosePlainText) +{ + RefPtr<DocumentFragment> fragment = 0; + if (wxTheClipboard->Open()) { + if (allowPlainText && wxTheClipboard->IsSupported( wxDF_TEXT )) { + wxTextDataObject data; + wxTheClipboard->GetData( data ); + chosePlainText = true; + fragment = createFragmentFromText(context.get(), data.GetText()); + } + wxTheClipboard->Close(); + } + if (fragment) + return fragment.release(); + + return 0; +} + +void Pasteboard::writeURL(const KURL& url, const String&, Frame*) +{ + if (wxTheClipboard->Open()) { + wxTheClipboard->SetData( new wxTextDataObject( url.string() ) ); + wxTheClipboard->Close(); + } +} + +void Pasteboard::clear() +{ + wxTheClipboard->Clear(); +} + +void Pasteboard::writeImage(Node*, const KURL&, const String& title) +{ + notImplemented(); +} + +} diff --git a/Source/WebCore/platform/wx/PopupMenuWx.cpp b/Source/WebCore/platform/wx/PopupMenuWx.cpp new file mode 100644 index 0000000..b850ef5 --- /dev/null +++ b/Source/WebCore/platform/wx/PopupMenuWx.cpp @@ -0,0 +1,125 @@ +/* + * This file is part of the popup menu implementation for <select> elements in WebCore. + * + * Copyright (C) 2008 Apple Computer, Inc. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "PopupMenuWx.h" + +#include "Frame.h" +#include "FrameView.h" +#include "PopupMenuClient.h" +#include "PlatformString.h" + +#include <wx/defs.h> +#if __WXMSW__ +#include <wx/msw/winundef.h> +#endif +#include <wx/event.h> +#include <wx/menu.h> + +static int s_menuStartId = wxNewId(); + +namespace WebCore { + +class PopupMenuEventHandler : public wxEvtHandler +{ +public: + PopupMenuEventHandler(PopupMenuClient* client) : + m_client(client) + {} + + void OnMenuItemSelected(wxCommandEvent& event) + { + if (m_client) { + m_client->valueChanged(event.GetId() - s_menuStartId); + m_client->popupDidHide(); + } + // TODO: Do we need to call Disconnect here? Do we have a ref to the native window still? + } + +private: + PopupMenuClient* m_client; + +}; + +PopupMenuWx::PopupMenuWx(PopupMenuClient* client) + : m_popupClient(client) + , m_menu(0) +{ + PopupMenuEventHandler m_popupHandler(client); +} + +PopupMenuWx::~PopupMenuWx() +{ + delete m_menu; +} + +void PopupMenuWx::disconnectClient() +{ + m_popupClient = 0; +} + +void PopupMenuWx::show(const IntRect& r, FrameView* v, int index) +{ + // just delete and recreate + delete m_menu; + ASSERT(client()); + + wxWindow* nativeWin = v->platformWidget(); + + if (nativeWin) { + // construct the menu + m_menu = new wxMenu(); + + int size = client()->listSize(); + for (int i = 0; i < size; i++) { + int id = s_menuStartId + i; + + if (client()->itemIsSeparator(i)) { + m_menu->AppendSeparator(); + } + else { + // FIXME: appending a menu item with an empty label asserts in + // wx. This needs to be fixed at wx level so that we can have + // the concept of "no selection" in choice boxes, etc. + if (!client()->itemText(i).isEmpty()) + m_menu->Append(s_menuStartId + i, client()->itemText(i)); + } + } + nativeWin->Connect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenuEventHandler::OnMenuItemSelected), 0, m_popupHandler); + nativeWin->PopupMenu(m_menu, r.x() - v->scrollX(), r.y() - v->scrollY()); + nativeWin->Disconnect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenuEventHandler::OnMenuItemSelected), 0, m_popupHandler); + } +} + +void PopupMenuWx::hide() +{ + // we don't need to do anything here, the native control only exists during the time + // show is called +} + +void PopupMenuWx::updateFromElement() +{ + client()->setTextFromItem(m_popupClient->selectedIndex()); +} + +} diff --git a/Source/WebCore/platform/wx/PopupMenuWx.h b/Source/WebCore/platform/wx/PopupMenuWx.h new file mode 100644 index 0000000..ad947a7 --- /dev/null +++ b/Source/WebCore/platform/wx/PopupMenuWx.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef PopupMenuWx_h +#define PopupMenuWx_h + +#include "IntRect.h" +#include "PopupMenu.h" +#include "PopupMenuClient.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +#ifdef __WXMSW__ +#include <wx/msw/winundef.h> +#endif +class wxMenu; +#include <wx/defs.h> +#include <wx/event.h> + +namespace WebCore { + +class FrameView; +class PopupMenuEventHandler; +class Scrollbar; + +class PopupMenuWx : public PopupMenu { +public: + PopupMenuWx(PopupMenuClient*); + ~PopupMenuWx(); + + virtual void show(const IntRect&, FrameView*, int index); + virtual void hide(); + virtual void updateFromElement(); + virtual void disconnectClient(); + +private: + void OnMenuItemSelected(wxCommandEvent&); + PopupMenuClient* client() const { return m_popupClient; } + + PopupMenuClient* m_popupClient; + wxMenu* m_menu; + PopupMenuEventHandler* m_popupHandler; +}; + +} + +#endif // PopupMenuWx_h diff --git a/Source/WebCore/platform/wx/RenderThemeWx.cpp b/Source/WebCore/platform/wx/RenderThemeWx.cpp new file mode 100644 index 0000000..c68bde9 --- /dev/null +++ b/Source/WebCore/platform/wx/RenderThemeWx.cpp @@ -0,0 +1,443 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "RenderTheme.h" + +#include "Document.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HostWindow.h" +#include "NotImplemented.h" +#include "RenderView.h" + +#include <wx/defs.h> + +#include <wx/dc.h> +#include <wx/dcgraph.h> +#include <wx/renderer.h> +#include <wx/dcclient.h> +#include <wx/scrolwin.h> +#include <wx/settings.h> + +namespace WebCore { + +class RenderThemeWx : public RenderTheme { +private: + RenderThemeWx() : RenderTheme() { } + virtual ~RenderThemeWx(); + +public: + static PassRefPtr<RenderTheme> create(); + + // A method asking if the theme's controls actually care about redrawing when hovered. + virtual bool supportsHover(const RenderStyle*) const { return true; } + + virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r) + { + return paintButton(o, i, r); + } + + virtual void setCheckboxSize(RenderStyle*) const; + + virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r) + { + return paintButton(o, i, r); + } + + virtual void setRadioSize(RenderStyle*) const; + + virtual void adjustRepaintRect(const RenderObject*, IntRect&); + + virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); + + virtual int minimumMenuListSize(RenderStyle*) const; + + virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); + + virtual bool isControlStyled(const RenderStyle*, const BorderData&, + const FillLayer&, const Color&) const; + + virtual bool controlSupportsTints(const RenderObject*) const; + + virtual void systemFont(int propId, FontDescription&) const; + + virtual Color platformActiveSelectionBackgroundColor() const; + virtual Color platformInactiveSelectionBackgroundColor() const; + + virtual Color platformActiveSelectionForegroundColor() const; + virtual Color platformInactiveSelectionForegroundColor() const; + + virtual int popupInternalPaddingLeft(RenderStyle*) const; + virtual int popupInternalPaddingRight(RenderStyle*) const; + virtual int popupInternalPaddingTop(RenderStyle*) const; + virtual int popupInternalPaddingBottom(RenderStyle*) const; + +private: + void addIntrinsicMargins(RenderStyle*) const; + void close(); + + bool supportsFocus(ControlPart) const; +}; + + +// Constants + +#define MINIMUM_MENU_LIST_SIZE 21 +#define POPUP_INTERNAL_PADDING_LEFT 6 +#define POPUP_INTERNAL_PADDING_TOP 2 +#define POPUP_INTERNAL_PADDING_BOTTOM 2 + +#ifdef __WXMAC__ +#define POPUP_INTERNAL_PADDING_RIGHT 22 +#else +#define POPUP_INTERNAL_PADDING_RIGHT 20 +#endif + +RenderThemeWx::~RenderThemeWx() +{ +} + +PassRefPtr<RenderTheme> RenderThemeWx::create() +{ + return adoptRef(new RenderThemeWx()); +} + +PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) +{ + static RenderTheme* rt = RenderThemeWx::create().releaseRef(); + return rt; +} + +wxWindow* nativeWindowForRenderObject(RenderObject* o) +{ + FrameView* frameView = o->view()->frameView(); + ASSERT(frameView); + ASSERT(frameView->hostWindow()); + return frameView->hostWindow()->platformPageClient(); +} + + +bool RenderThemeWx::isControlStyled(const RenderStyle* style, const BorderData& border, + const FillLayer& background, const Color& backgroundColor) const +{ + if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart) + return style->border() != border; + + // Normally CSS can be used to set properties of form controls (such as adding a background bitmap). + // However, for this to work RenderThemeWx needs to adjust uncustomized elements (e.g. buttons) to reflect the + // changes made by CSS. Since we don't do that right now, the native parts of form elements appear in odd places. + // Until we have time to implement that support, we return false here, so that we ignore customizations + // and always use the native theme drawing to draw form controls. + return false; +} + +void RenderThemeWx::adjustRepaintRect(const RenderObject* o, IntRect& r) +{ + switch (o->style()->appearance()) { + case MenulistPart: { + r.setWidth(r.width() + 100); + break; + } + default: + break; + } +} + +bool RenderThemeWx::controlSupportsTints(const RenderObject* o) const +{ + if (!isEnabled(o)) + return false; + + // Checkboxes only have tint when checked. + if (o->style()->appearance() == CheckboxPart) + return isChecked(o); + + // For now assume other controls have tint if enabled. + return true; +} + +void RenderThemeWx::systemFont(int propId, FontDescription& fontDescription) const +{ + // no-op +} + +void RenderThemeWx::addIntrinsicMargins(RenderStyle* style) const +{ + // Cut out the intrinsic margins completely if we end up using a small font size + if (style->fontSize() < 11) + return; + + // Intrinsic margin value. + const int m = 2; + + // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed. + if (style->width().isIntrinsicOrAuto()) { + if (style->marginLeft().quirk()) + style->setMarginLeft(Length(m, Fixed)); + + if (style->marginRight().quirk()) + style->setMarginRight(Length(m, Fixed)); + } + + if (style->height().isAuto()) { + if (style->marginTop().quirk()) + style->setMarginTop(Length(m, Fixed)); + + if (style->marginBottom().quirk()) + style->setMarginBottom(Length(m, Fixed)); + } +} + +void RenderThemeWx::setCheckboxSize(RenderStyle* style) const +{ + // If the width and height are both specified, then we have nothing to do. + if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) + return; + + // FIXME: A hard-coded size of 13 is used. This is wrong but necessary for now. It matches Firefox. + // At different DPI settings on Windows, querying the theme gives you a larger size that accounts for + // the higher DPI. Until our entire engine honors a DPI setting other than 96, we can't rely on the theme's + // metrics. + if (style->width().isIntrinsicOrAuto()) + style->setWidth(Length(13, Fixed)); + + if (style->height().isAuto()) + style->setHeight(Length(13, Fixed)); +} + +void RenderThemeWx::setRadioSize(RenderStyle* style) const +{ + // This is the same as checkboxes. + setCheckboxSize(style); +} + +bool RenderThemeWx::supportsFocus(ControlPart part) const +{ + switch (part) { + case PushButtonPart: + case ButtonPart: + case TextFieldPart: + return true; + default: // No for all others... + return false; + } +} + +void RenderThemeWx::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const +{ + addIntrinsicMargins(style); +} + +bool RenderThemeWx::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + wxWindow* window = nativeWindowForRenderObject(o); + wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); + int flags = 0; + + IntRect rect = r; + +// On Mac, wxGraphicsContext and wxDC share the same native implementation, +// and so transformations are available. +// On Win and Linux, however, this is not true and transforms are lost, +// so we need to restore them here. +#if USE(WXGC) && !defined(__WXMAC__) + double xtrans = 0; + double ytrans = 0; + + wxGCDC* gcdc = static_cast<wxGCDC*>(dc); + wxGraphicsContext* gc = gcdc->GetGraphicsContext(); + gc->GetTransform().TransformPoint(&xtrans, &ytrans); + rect.setX(r.x() + (int)xtrans); + rect.setY(r.y() + (int)ytrans); +#endif + + if (!isEnabled(o)) + flags |= wxCONTROL_DISABLED; + + ControlPart part = o->style()->appearance(); + if (supportsFocus(part) && isFocused(o)) + flags |= wxCONTROL_FOCUSED; + + if (isPressed(o)) + flags |= wxCONTROL_PRESSED; + + if (part == PushButtonPart || part == ButtonPart) + wxRendererNative::Get().DrawPushButton(window, *dc, rect, flags); + else if(part == RadioPart) { + if (isChecked(o)) + flags |= wxCONTROL_CHECKED; +#if wxCHECK_VERSION(2,9,1) + wxRendererNative::Get().DrawRadioBitmap(window, *dc, rect, flags); +#elif wxCHECK_VERSION(2,9,0) + wxRendererNative::Get().DrawRadioButton(window, *dc, rect, flags); +#else + wxRenderer_DrawRadioButton(window, *dc, rect, flags); +#endif + } + else if(part == CheckboxPart) { + if (isChecked(o)) + flags |= wxCONTROL_CHECKED; + wxRendererNative::Get().DrawCheckBox(window, *dc, rect, flags); + } + return false; +} + +void RenderThemeWx::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const +{ + +} + +bool RenderThemeWx::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + wxWindow* window = nativeWindowForRenderObject(o); + wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); +#if wxCHECK_VERSION(2,9,0) + wxRendererNative::Get().DrawTextCtrl(window, *dc, r, 0); +#else + wxRenderer_DrawTextCtrl(window, *dc, r, 0); +#endif + + return false; +} + +int RenderThemeWx::minimumMenuListSize(RenderStyle*) const +{ + return MINIMUM_MENU_LIST_SIZE; +} + +void RenderThemeWx::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const +{ +} + +bool RenderThemeWx::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + wxWindow* window = nativeWindowForRenderObject(o); + wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); + + int flags = 0; + if (!isEnabled(o)) + flags |= wxCONTROL_DISABLED; + + if (supportsFocus(o->style()->appearance()) && isFocused(o)) + flags |= wxCONTROL_FOCUSED; + + if (isPressed(o)) + flags |= wxCONTROL_PRESSED; + +#if wxCHECK_VERSION(2,9,0) + wxRendererNative::Get().DrawChoice(window, *dc, r, flags); +#else + wxRenderer_DrawChoice(window, *dc, r, flags); +#endif + + return false; +} + +void RenderThemeWx::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const +{ + notImplemented(); +} + +bool RenderThemeWx::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + wxWindow* window = nativeWindowForRenderObject(o); + wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); + + int flags = 0; + if (!isEnabled(o)) + flags |= wxCONTROL_DISABLED; + + if (supportsFocus(o->style()->appearance()) && isFocused(o)) + flags |= wxCONTROL_FOCUSED; + + if (isPressed(o)) + flags |= wxCONTROL_PRESSED; + + wxRendererNative::Get().DrawComboBoxDropButton(window, *dc, r, flags); + + return false; +} + + +Color RenderThemeWx::platformActiveSelectionBackgroundColor() const +{ + return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); +} + +Color RenderThemeWx::platformInactiveSelectionBackgroundColor() const +{ + return wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); +} + +Color RenderThemeWx::platformActiveSelectionForegroundColor() const +{ + // FIXME: Get wx to return the correct value for each platform. +#if __WXMAC__ + return Color(); +#else + return Color(255, 255, 255); +#endif +} + +Color RenderThemeWx::platformInactiveSelectionForegroundColor() const +{ +#if __WXMAC__ + return Color(); +#else + return Color(255, 255, 255); +#endif +} + +int RenderThemeWx::popupInternalPaddingLeft(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_LEFT; +} + +int RenderThemeWx::popupInternalPaddingRight(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_RIGHT; +} + +int RenderThemeWx::popupInternalPaddingTop(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_TOP; +} + +int RenderThemeWx::popupInternalPaddingBottom(RenderStyle*) const +{ + return POPUP_INTERNAL_PADDING_BOTTOM; +} + +} + diff --git a/Source/WebCore/platform/wx/SSLKeyGeneratorWx.cpp b/Source/WebCore/platform/wx/SSLKeyGeneratorWx.cpp new file mode 100644 index 0000000..7d076e7 --- /dev/null +++ b/Source/WebCore/platform/wx/SSLKeyGeneratorWx.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SSLKeyGenerator.h" + +#include "NotImplemented.h" + +namespace WebCore { + +void getSupportedKeySizes(Vector<String>&) +{ + notImplemented(); +} + +String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String &challengeString, const KURL &url) +{ + return String(); +} + +} + diff --git a/Source/WebCore/platform/wx/ScreenWx.cpp b/Source/WebCore/platform/wx/ScreenWx.cpp new file mode 100644 index 0000000..5def245 --- /dev/null +++ b/Source/WebCore/platform/wx/ScreenWx.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "Screen.h" +#include "IntRect.h" +#include "FloatRect.h" +#include "Widget.h" + +#include <wx/defs.h> +#include <wx/display.h> +#include <wx/gdicmn.h> + +namespace WebCore { + +FloatRect scaleScreenRectToWidget(FloatRect rect, Widget*) +{ + return rect; +} + +FloatRect scaleWidgetRectToScreen(FloatRect rect, Widget*) +{ + return rect; +} + +FloatRect screenRect(Widget* widget) +{ +/* + int displayNum; + Widget* widget = widget->widget(); + displayNum = wxDisplay::GetFromWindow(widget->nativeWindow()); + if (displayNum != -1){ + wxDisplay thisDisplay(displayNum); + return thisDisplay.GetGeometry(); + } +*/ + return FloatRect(); +} + +int screenDepth(Widget* widget) +{ + return wxDisplayDepth(); +} + +int screenDepthPerComponent(Widget*) +{ + return wxDisplayDepth(); +} + +bool screenIsMonochrome(Widget* widget) +{ + return wxColourDisplay(); +} + +FloatRect screenAvailableRect(Widget* widget) +{ +/* + Widget* widget = widget->widget(); + displayNum = wxDisplay::GetFromWindow(widget->nativeWindow()); + if (displayNum != -1){ + wxDisplay thisDisplay(displayNum); + // FIXME: In 2.7 this method is gone? + //return thisDisplay.GetClientArea(); + } +*/ + return FloatRect(); +} + +float scaleFactor(Widget*) +{ + return 1.0f; + +} + +} diff --git a/Source/WebCore/platform/wx/ScrollViewWx.cpp b/Source/WebCore/platform/wx/ScrollViewWx.cpp new file mode 100644 index 0000000..35d62b2 --- /dev/null +++ b/Source/WebCore/platform/wx/ScrollViewWx.cpp @@ -0,0 +1,362 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScrollView.h" + +#include "FloatRect.h" +#include "IntRect.h" +#include "NotImplemented.h" +#include "PlatformWheelEvent.h" +#include "Scrollbar.h" + +#include <algorithm> +#include <stdio.h> + +#include <wx/defs.h> +#include <wx/scrolbar.h> +#include <wx/scrolwin.h> +#include <wx/event.h> + +using namespace std; + +namespace WebCore { + +class ScrollView::ScrollViewPrivate : public wxEvtHandler { + +public: + ScrollViewPrivate(ScrollView* scrollView) + : wxEvtHandler() + , m_scrollView(scrollView) + , vScrollbarMode(ScrollbarAuto) + , hScrollbarMode(ScrollbarAuto) + , viewStart(0, 0) + { + } + + void bindEvents(wxWindow* win) + { + // TODO: is there an easier way to Connect to a range of events? these are contiguous. + win->Connect(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + win->Connect(wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + win->Connect(wxEVT_SCROLLWIN_LINEUP, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + win->Connect(wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + win->Connect(wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + win->Connect(wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + win->Connect(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + win->Connect(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this); + } + + void OnScrollWinEvents(wxScrollWinEvent& e) + { + wxEventType scrollType(e.GetEventType()); + bool horiz = e.GetOrientation() == wxHORIZONTAL; + + wxPoint pos(viewStart); + + if (scrollType == wxEVT_SCROLLWIN_THUMBTRACK || scrollType == wxEVT_SCROLLWIN_THUMBRELEASE) { + if (horiz) + pos.x = e.GetPosition(); + else + pos.y = e.GetPosition(); + } + else if (scrollType == wxEVT_SCROLLWIN_LINEDOWN) { + if (horiz) + pos.x += Scrollbar::pixelsPerLineStep(); + else + pos.y += Scrollbar::pixelsPerLineStep(); + } + else if (scrollType == wxEVT_SCROLLWIN_LINEUP) { + if (horiz) + pos.x -= Scrollbar::pixelsPerLineStep(); + else + pos.y -= Scrollbar::pixelsPerLineStep(); + } + else if (scrollType == wxEVT_SCROLLWIN_PAGEUP) { + if (horiz) + pos.x -= max<int>(m_scrollView->visibleWidth() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleWidth() - Scrollbar::maxOverlapBetweenPages()); + else + pos.y -= max<int>(m_scrollView->visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleHeight() - Scrollbar::maxOverlapBetweenPages()); + } + else if (scrollType == wxEVT_SCROLLWIN_PAGEDOWN) { + if (horiz) + pos.x += max<int>(m_scrollView->visibleWidth() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleWidth() - Scrollbar::maxOverlapBetweenPages()); + else + pos.y += max<int>(m_scrollView->visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleHeight() - Scrollbar::maxOverlapBetweenPages()); + } + else + return e.Skip(); + + m_scrollView->setScrollPosition(IntPoint(pos.x, pos.y)); + } + + ScrollView* m_scrollView; + + ScrollbarMode vScrollbarMode; + ScrollbarMode hScrollbarMode; + wxPoint viewStart; +}; + +void ScrollView::platformInit() +{ + m_data = new ScrollViewPrivate(this); +} + + +void ScrollView::platformDestroy() +{ + delete m_data; +} + +void ScrollView::setPlatformWidget(wxWindow* win) +{ + Widget::setPlatformWidget(win); + m_data->bindEvents(win); +} + +void ScrollView::platformRepaintContentRectangle(const IntRect& updateRect, bool now) +{ + // we need to convert coordinates to scrolled position + wxRect contentsRect = updateRect; + contentsRect.Offset(-scrollX(), -scrollY()); + wxWindow* win = platformWidget(); + if (win) { + win->RefreshRect(contentsRect, true); + if (now) + win->Update(); + } +} + +IntRect ScrollView::platformVisibleContentRect(bool includeScrollbars) const +{ + wxWindow* win = platformWidget(); + if (!win) + return IntRect(); + + int width, height; + + if (includeScrollbars) + win->GetSize(&width, &height); + else + win->GetClientSize(&width, &height); + + return IntRect(m_data->viewStart.x, m_data->viewStart.y, width, height); +} + +IntSize ScrollView::platformContentsSize() const +{ + int width = 0; + int height = 0; + if (platformWidget()) { + platformWidget()->GetVirtualSize(&width, &height); + ASSERT(width >= 0 && height >= 0); + } + return IntSize(width, height); +} + +void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint) +{ + wxWindow* win = platformWidget(); + + wxPoint scrollOffset = m_data->viewStart; + wxPoint orig(scrollOffset); + wxPoint newScrollOffset(scrollPoint); + + wxRect vRect(win->GetVirtualSize()); + wxRect cRect(win->GetClientSize()); + + // clamp to scroll area + if (newScrollOffset.x < 0) + newScrollOffset.x = 0; + else if (newScrollOffset.x + cRect.width > vRect.width) + newScrollOffset.x = max(0, vRect.width - cRect.width); + + if (newScrollOffset.y < 0) + newScrollOffset.y = 0; + else if (newScrollOffset.y + cRect.height > vRect.height) + newScrollOffset.y = max(0, vRect.height - cRect.height); + + if (newScrollOffset == scrollOffset) + return; + + m_data->viewStart = newScrollOffset; + + wxPoint delta(orig - newScrollOffset); + + if (canBlitOnScroll()) + win->ScrollWindow(delta.x, delta.y); + else + win->Refresh(); + + adjustScrollbars(); +} + +bool ScrollView::platformScroll(ScrollDirection, ScrollGranularity) +{ + notImplemented(); + return true; +} + +void ScrollView::platformSetContentsSize() +{ + wxWindow* win = platformWidget(); + if (!win) + return; + + win->SetVirtualSize(m_contentsSize.width(), m_contentsSize.height()); + adjustScrollbars(); +} + +void ScrollView::adjustScrollbars(int x, int y, bool refresh) +{ + wxWindow* win = platformWidget(); + if (!win) + return; + + wxRect crect(win->GetClientRect()), vrect(win->GetVirtualSize()); + + if (x == -1) x = m_data->viewStart.x; + if (y == -1) y = m_data->viewStart.y; + + long style = win->GetWindowStyle(); + + // by setting the wxALWAYS_SHOW_SB wxWindow flag before + // each SetScrollbar call, we can control the scrollbars + // visibility individually. + + // horizontal scrollbar + switch (m_data->hScrollbarMode) { + case ScrollbarAlwaysOff: + win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB); + win->SetScrollbar(wxHORIZONTAL, 0, 0, 0, refresh); + break; + + case ScrollbarAuto: + win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB); + win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh); + break; + + default: // ScrollbarAlwaysOn + win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB); + win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh); + break; + } + + // vertical scrollbar + switch (m_data->vScrollbarMode) { + case ScrollbarAlwaysOff: + win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB); + win->SetScrollbar(wxVERTICAL, 0, 0, 0, refresh); + break; + + case ScrollbarAlwaysOn: + win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB); + win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh); + break; + + default: // case ScrollbarAuto: + win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB); + win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh); + } +} + +void ScrollView::platformSetScrollbarModes() +{ + bool needsAdjust = false; + + if (m_data->hScrollbarMode != horizontalScrollbarMode() ) { + m_data->hScrollbarMode = horizontalScrollbarMode(); + needsAdjust = true; + } + + if (m_data->vScrollbarMode != verticalScrollbarMode() ) { + m_data->vScrollbarMode = verticalScrollbarMode(); + needsAdjust = true; + } + + if (needsAdjust) + adjustScrollbars(); +} + +void ScrollView::platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const +{ + horizontal = m_data->hScrollbarMode; + vertical = m_data->vScrollbarMode; +} + +void ScrollView::platformSetCanBlitOnScroll(bool canBlitOnScroll) +{ + m_canBlitOnScroll = canBlitOnScroll; +} + +bool ScrollView::platformCanBlitOnScroll() const +{ + return m_canBlitOnScroll; +} + +// used for subframes support +void ScrollView::platformAddChild(Widget* widget) +{ + // NB: In all cases I'm aware of, + // by the time this is called the ScrollView is already a child + // of its parent Widget by wx port APIs, so I don't think + // we need to do anything here. +} + +void ScrollView::platformRemoveChild(Widget* widget) +{ + if (platformWidget()) { + platformWidget()->RemoveChild(widget->platformWidget()); + // FIXME: Is this the right place to do deletion? I see + // detachFromParent2/3/4, initiated by FrameLoader::detachFromParent, + // but I'm not sure if it's better to handle there or not. + widget->platformWidget()->Destroy(); + } +} + +IntRect ScrollView::platformContentsToScreen(const IntRect& rect) const +{ + if (platformWidget()) { + wxRect wxrect = rect; + platformWidget()->ClientToScreen(&wxrect.x, &wxrect.y); + return wxrect; + } + return IntRect(); +} + +IntPoint ScrollView::platformScreenToContents(const IntPoint& point) const +{ + if (platformWidget()) { + return platformWidget()->ScreenToClient(point); + } + return IntPoint(); +} + +bool ScrollView::platformIsOffscreen() const +{ + return !platformWidget() || !platformWidget()->IsShownOnScreen(); +} + +} diff --git a/Source/WebCore/platform/wx/ScrollbarThemeWx.cpp b/Source/WebCore/platform/wx/ScrollbarThemeWx.cpp new file mode 100644 index 0000000..82e4a15 --- /dev/null +++ b/Source/WebCore/platform/wx/ScrollbarThemeWx.cpp @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScrollbarThemeWx.h" + +#include "HostWindow.h" +#include "NotImplemented.h" +#include "PlatformMouseEvent.h" +#include "Scrollbar.h" +#include "ScrollbarClient.h" +#include "scrollbar_render.h" +#include "ScrollbarThemeComposite.h" +#include "ScrollView.h" + +#include <wx/defs.h> +#include <wx/dcgraph.h> +#include <wx/settings.h> + +const int cMacButtonOverlap = 4; + +namespace WebCore { + +ScrollbarTheme* ScrollbarTheme::nativeTheme() +{ + static ScrollbarThemeWx theme; + return &theme; +} + +ScrollbarThemeWx::~ScrollbarThemeWx() +{ +} + +int ScrollbarThemeWx::scrollbarThickness(ScrollbarControlSize size) +{ + int thickness = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + + // fallback for when a platform doesn't define this metric + if (thickness <= 0) + thickness = 20; + + return thickness; +} + +bool ScrollbarThemeWx::hasThumb(Scrollbar* scrollbar) +{ + // This method is just called as a paint-time optimization to see if + // painting the thumb can be skipped. We don't have to be exact here. + return thumbLength(scrollbar) > 0; +} + +int ScrollbarThemeWx::minimumThumbLength(Scrollbar* scrollbar) +{ + return 20; +} + +IntSize ScrollbarThemeWx::buttonSize(Scrollbar*) +{ +#ifdef __WXMAC__ + return IntSize(20,20); +#else + return IntSize(16,16); +#endif +} + +void ScrollbarThemeWx::splitTrack(Scrollbar* scrollbar, const IntRect& unconstrainedTrackRect, IntRect& beforeThumbRect, IntRect& thumbRect, IntRect& afterThumbRect) +{ + ScrollbarThemeComposite::splitTrack(scrollbar, unconstrainedTrackRect, beforeThumbRect, thumbRect, afterThumbRect); +#ifdef __WXMAC__ + // on Mac, there are a few pixels drawn above the actual track and so adjust + // the hit testing rects accordingly + int trackStart = 10; + if (scrollbar->orientation() == HorizontalScrollbar) { + thumbRect.setX(thumbRect.x() + trackStart); + afterThumbRect.setX(afterThumbRect.x() - trackStart); + } else { + thumbRect.setY(thumbRect.y() + trackStart); + afterThumbRect.setY(afterThumbRect.y() - trackStart); + } +#endif +} + +IntRect ScrollbarThemeWx::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool) +{ + // FIXME: Handling this case is needed when there are two sets of arrow buttons + // on Mac, one at the top and one at the bottom. + if (part == BackButtonEndPart) + return IntRect(); + + IntSize size = buttonSize(scrollbar); + int x = scrollbar->x(); + int y = scrollbar->y(); + +#if __WXMAC__ + if (scrollbar->orientation() == HorizontalScrollbar) + x += scrollbar->width() - (size.width() * 2) + cMacButtonOverlap; + else + y += scrollbar->height() - (size.height() * 2) + cMacButtonOverlap; +#endif + + return IntRect(x, y, size.width(), size.height()); +} + +IntRect ScrollbarThemeWx::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool) +{ + // FIXME: Handling this case is needed when there are two sets of arrow buttons + // on Mac, one at the top and one at the bottom. + if (part == ForwardButtonStartPart) + return IntRect(); + + IntSize size = buttonSize(scrollbar); + int x, y; + if (scrollbar->orientation() == HorizontalScrollbar) { +#ifdef __WXMAC__ + size.setWidth(size.width() + cMacButtonOverlap); +#endif + x = scrollbar->x() + scrollbar->width() - size.width(); + y = scrollbar->y(); + } else { + x = scrollbar->x(); +#ifdef __WXMAC__ + size.setHeight(size.height() + cMacButtonOverlap); +#endif + y = scrollbar->y() + scrollbar->height() - size.height(); + } + return IntRect(x, y, size.width(), size.height()); +} + +IntRect ScrollbarThemeWx::trackRect(Scrollbar* scrollbar, bool) +{ + IntSize bs = buttonSize(scrollbar); + int trackStart = 0; + if (scrollbar->orientation() == HorizontalScrollbar) + trackStart = bs.width(); + else + trackStart = bs.height(); + +#if __WXMAC__ + trackStart = 0; +#endif + + int thickness = scrollbarThickness(scrollbar->controlSize()); + if (scrollbar->orientation() == HorizontalScrollbar) { + if (scrollbar->width() < 2 * thickness) + return IntRect(); + return IntRect(scrollbar->x() + trackStart, scrollbar->y(), scrollbar->width() - 2 * bs.width(), thickness); + } + if (scrollbar->height() < 2 * thickness) + return IntRect(); + return IntRect(scrollbar->x(), scrollbar->y() + trackStart, thickness, scrollbar->height() - 2 * bs.height()); +} + +void ScrollbarThemeWx::paintScrollCorner(ScrollView* view, GraphicsContext* context, const IntRect& cornerRect) +{ + // ScrollbarThemeComposite::paintScrollCorner incorrectly assumes that the + // ScrollView is a FrameView (see FramelessScrollView), so we cannot let + // that code run. For FrameView's this is correct since we don't do custom + // scrollbar corner rendering, which ScrollbarThemeComposite supports. + ScrollbarTheme::paintScrollCorner(view, context, cornerRect); +} + +bool ScrollbarThemeWx::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& rect) +{ + wxOrientation orientation = (scrollbar->orientation() == HorizontalScrollbar) ? wxHORIZONTAL : wxVERTICAL; + int flags = 0; + if (scrollbar->client()->isActive()) + flags |= wxCONTROL_FOCUSED; + + if (!scrollbar->enabled()) + flags |= wxCONTROL_DISABLED; + + wxDC* dc = static_cast<wxDC*>(context->platformContext()); + + context->save(); + ScrollView* root = scrollbar->root(); + ASSERT(root); + if (!root) + return false; + + wxWindow* webview = root->hostWindow()->platformPageClient(); + + wxRenderer_DrawScrollbar(webview, *dc, scrollbar->frameRect(), orientation, scrollbar->currentPos(), static_cast<wxScrollbarPart>(scrollbar->pressedPart()), + static_cast<wxScrollbarPart>(scrollbar->hoveredPart()), scrollbar->maximum(), scrollbar->pageStep(), flags); + + context->restore(); + return true; +} + +} + diff --git a/Source/WebCore/platform/wx/ScrollbarThemeWx.h b/Source/WebCore/platform/wx/ScrollbarThemeWx.h new file mode 100644 index 0000000..79b10b3 --- /dev/null +++ b/Source/WebCore/platform/wx/ScrollbarThemeWx.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScrollbarThemeWx_h +#define ScrollbarThemeWx_h + +#include "ScrollbarTheme.h" +#include "ScrollbarThemeComposite.h" + +namespace WebCore { + +class ScrollbarThemeWx : public ScrollbarThemeComposite { +public: + virtual ~ScrollbarThemeWx(); + virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar); + virtual bool paint(Scrollbar*, GraphicsContext*, const IntRect&); + + virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect); + +protected: + virtual bool hasButtons(Scrollbar*) { return true; } + virtual bool hasThumb(Scrollbar*); + + virtual IntSize buttonSize(Scrollbar*); + + virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false); + virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false); + virtual IntRect trackRect(Scrollbar*, bool painting = false); + + virtual void splitTrack(Scrollbar*, const IntRect& track, IntRect& startTrack, IntRect& thumb, IntRect& endTrack); + + virtual int minimumThumbLength(Scrollbar*); +}; + +} +#endif diff --git a/Source/WebCore/platform/wx/SearchPopupMenuWx.cpp b/Source/WebCore/platform/wx/SearchPopupMenuWx.cpp new file mode 100644 index 0000000..b724cf1 --- /dev/null +++ b/Source/WebCore/platform/wx/SearchPopupMenuWx.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SearchPopupMenuWx.h" + +#include "NotImplemented.h" + +namespace WebCore { + +SearchPopupMenuWx::SearchPopupMenuWx(PopupMenuClient* client) + : m_popup(adoptRef(new PopupMenuWx(client))) +{ + notImplemented(); +} + +void SearchPopupMenuWx::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) +{ + notImplemented(); +} + +void SearchPopupMenuWx::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems) +{ + notImplemented(); +} + +bool SearchPopupMenuWx::enabled() +{ + return true; +} + +PopupMenu* SearchPopupMenuWx::popupMenu() +{ + return m_popup.get(); +} + +} + diff --git a/Source/WebCore/platform/wx/SearchPopupMenuWx.h b/Source/WebCore/platform/wx/SearchPopupMenuWx.h new file mode 100644 index 0000000..552a8fe --- /dev/null +++ b/Source/WebCore/platform/wx/SearchPopupMenuWx.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef SearchPopupMenuWx_h +#define SearchPopupMenuWx_h + +#include "PopupMenuWx.h" +#include "SearchPopupMenu.h" + +namespace WebCore { + +class SearchPopupMenuWx : public SearchPopupMenu { +public: + SearchPopupMenuWx(PopupMenuClient*); + + virtual PopupMenu* popupMenu(); + virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems); + virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems); + virtual bool enabled(); + +private: + RefPtr<PopupMenuWx> m_popup; +}; + +} + +#endif // SearchPopupMenuWx_h diff --git a/Source/WebCore/platform/wx/SharedBufferWx.cpp b/Source/WebCore/platform/wx/SharedBufferWx.cpp new file mode 100644 index 0000000..a9203ba --- /dev/null +++ b/Source/WebCore/platform/wx/SharedBufferWx.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SharedBuffer.h" + +#include "NotImplemented.h" + +namespace WebCore { + +PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) +{ + notImplemented(); + return 0; +} + +} + diff --git a/Source/WebCore/platform/wx/SharedTimerWx.cpp b/Source/WebCore/platform/wx/SharedTimerWx.cpp new file mode 100644 index 0000000..d6d6bb4 --- /dev/null +++ b/Source/WebCore/platform/wx/SharedTimerWx.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "SharedTimer.h" +#include "Widget.h" + +#include <wtf/Assertions.h> +#include <wtf/CurrentTime.h> +#include <stdio.h> + +#include "wx/defs.h" +#include "wx/timer.h" + +namespace WebCore { + +static void (*sharedTimerFiredFunction)(); + +class WebKitTimer: public wxTimer +{ + public: + WebKitTimer(); + ~WebKitTimer(); + virtual void Notify(); +}; + +WebKitTimer::WebKitTimer() +{ + wxTimer::wxTimer(); +} + +WebKitTimer::~WebKitTimer() +{ +} + +void WebKitTimer::Notify() +{ + sharedTimerFiredFunction(); +} + +static WebKitTimer* wkTimer; + +void setSharedTimerFiredFunction(void (*f)()) +{ + sharedTimerFiredFunction = f; +} + +void setSharedTimerFireTime(double fireTime) +{ + ASSERT(sharedTimerFiredFunction); + + double interval = fireTime - currentTime(); + + if (!wkTimer) + wkTimer = new WebKitTimer(); + + int intervalInMS = interval * 1000; + + // sanity check + if (intervalInMS < 1) + intervalInMS = 1; + + wkTimer->Start(intervalInMS, wxTIMER_ONE_SHOT); +} + +void stopSharedTimer() +{ + if (wkTimer) + wkTimer->Stop(); +} + +} diff --git a/Source/WebCore/platform/wx/SoundWx.cpp b/Source/WebCore/platform/wx/SoundWx.cpp new file mode 100644 index 0000000..c8d0e53 --- /dev/null +++ b/Source/WebCore/platform/wx/SoundWx.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2006 Kevin Ollivier <kevino@theolliviers.com> + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include <wx/defs.h> +#include <wx/utils.h> + +#include "Sound.h" + +namespace WebCore { + +void systemBeep() +{ + wxBell(); +} + +} + +// vim: ts=4 sw=4 et diff --git a/Source/WebCore/platform/wx/SystemTimeWx.cpp b/Source/WebCore/platform/wx/SystemTimeWx.cpp new file mode 100644 index 0000000..f607cba --- /dev/null +++ b/Source/WebCore/platform/wx/SystemTimeWx.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SystemTime.h" + +#include <float.h> + +#include "NotImplemented.h" + +namespace WebCore { + +float userIdleTime() +{ + notImplemented(); + // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed + return FLT_MAX; +} + +} + diff --git a/Source/WebCore/platform/wx/TemporaryLinkStubs.cpp b/Source/WebCore/platform/wx/TemporaryLinkStubs.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Source/WebCore/platform/wx/TemporaryLinkStubs.cpp diff --git a/Source/WebCore/platform/wx/TextBreakIteratorInternalICUWx.cpp b/Source/WebCore/platform/wx/TextBreakIteratorInternalICUWx.cpp new file mode 100644 index 0000000..f840e13 --- /dev/null +++ b/Source/WebCore/platform/wx/TextBreakIteratorInternalICUWx.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "TextBreakIteratorInternalICU.h" + +namespace WebCore { + +const char* currentSearchLocaleID() +{ + return ""; +} + +const char* currentTextBreakLocaleID() +{ + return "en_us"; +} + +} + diff --git a/Source/WebCore/platform/wx/WidgetWx.cpp b/Source/WebCore/platform/wx/WidgetWx.cpp new file mode 100644 index 0000000..9de4c3d --- /dev/null +++ b/Source/WebCore/platform/wx/WidgetWx.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "config.h" +#include "Widget.h" + +#include "Cursor.h" +#include "GraphicsContext.h" +#include "IntRect.h" +#include "NotImplemented.h" + +#include <wx/defs.h> +#include <wx/scrolwin.h> + +namespace WebCore { + +Widget::Widget(PlatformWidget widget) +{ + init(widget); +} + +Widget::~Widget() +{ +} + +void Widget::setFocus(bool focused) +{ + if (focused) { + if (PlatformWidget widget = platformWidget()) + widget->SetFocus(); + } +} + +void Widget::setCursor(const Cursor& cursor) +{ + if (platformWidget() && cursor.impl()) + platformWidget()->SetCursor(*cursor.impl()); +} + +void Widget::show() +{ + if (PlatformWidget widget = platformWidget()) + widget->Show(); +} + +void Widget::hide() +{ + if (PlatformWidget widget = platformWidget()) + widget->Hide(); +} + +IntRect Widget::frameRect() const +{ + if (PlatformWidget widget = platformWidget()) + return widget->GetRect(); + + return m_frame; +} + +void Widget::setFrameRect(const IntRect& rect) +{ + if (PlatformWidget widget = platformWidget()) + widget->SetSize(rect); + + m_frame = rect; +} + +void Widget::invalidateRect(const IntRect& r) +{ + if (PlatformWidget widget = platformWidget()) + widget->RefreshRect(r); +} + +void Widget::paint(GraphicsContext*,const IntRect& r) +{ + invalidateRect(r); + if (PlatformWidget widget = platformWidget()) + widget->Update(); +} + +void Widget::setIsSelected(bool) +{ + notImplemented(); +} + +} diff --git a/Source/WebCore/platform/wx/wxcode/fontprops.cpp b/Source/WebCore/platform/wx/wxcode/fontprops.cpp new file mode 100644 index 0000000..56d21bd --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/fontprops.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// this is a hacky way of doing it, but we don't +// currently have info on which platform we're being +// compiled for directly. +#if __WXMAC__ +#include "mac/carbon/fontprops.cpp" +#elif __WXMSW__ +#include "win/fontprops.cpp" +#else +#include "gtk/fontprops.cpp" +#endif diff --git a/Source/WebCore/platform/wx/wxcode/fontprops.h b/Source/WebCore/platform/wx/wxcode/fontprops.h new file mode 100644 index 0000000..7702db2 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/fontprops.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <wx/defs.h> +#include <wx/font.h> + +void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height, + wxCoord *descent = NULL, wxCoord *externalLeading = NULL ); + +class wxFontProperties{ + +public: + wxFontProperties(wxFont* font); + float GetAscent() { return m_ascent; } + float GetDescent() { return m_descent; } + float GetLineGap() { return m_lineGap; } + float GetLineSpacing() { return m_lineSpacing; } + float GetXHeight() { return m_xHeight; } + +private: + float m_ascent; + float m_descent; + float m_lineGap; + float m_lineSpacing; + float m_xHeight; + +}; + +bool wxFontContainsCharacters(void* font, const UChar* characters, int length); diff --git a/Source/WebCore/platform/wx/wxcode/gtk/fontprops.cpp b/Source/WebCore/platform/wx/wxcode/gtk/fontprops.cpp new file mode 100644 index 0000000..491458d --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/gtk/fontprops.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +// this needs to be included before fontprops.h for UChar* to be defined. +#include <wtf/unicode/Unicode.h> + +#include <wx/defs.h> +#include <wx/gdicmn.h> +#include <wx/font.h> +#include <wx/fontutil.h> +#include "fontprops.h" +#include "non-kerned-drawing.h" + +#include <gdk/gdk.h> + +#include <cairo.h> +#include <pango/pango.h> +#include <pango/pangocairo.h> + +wxFontProperties::wxFontProperties(wxFont* font): +m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0) +{ + ASSERT(font && font->Ok()); + +#if USE(WXGC) + cairo_font_extents_t font_extents; + cairo_text_extents_t text_extents; + cairo_scaled_font_t* scaled_font = WebCore::createScaledFontForFont(font); + + cairo_scaled_font_extents(scaled_font, &font_extents); + m_ascent = static_cast<int>(font_extents.ascent); + m_descent = static_cast<int>(font_extents.descent); + m_lineSpacing = static_cast<int>(font_extents.height); + cairo_scaled_font_text_extents(scaled_font, "x", &text_extents); + m_xHeight = text_extents.height; + cairo_scaled_font_text_extents(scaled_font, " ", &text_extents); + m_lineGap = m_lineSpacing - m_ascent - m_descent; + + cairo_scaled_font_destroy(scaled_font); +#else + PangoContext* context = gdk_pango_context_get_for_screen( gdk_screen_get_default() ); + PangoLayout* layout = pango_layout_new(context); + // and use it if it's valid + if ( font && font->Ok() ) + { + pango_layout_set_font_description + ( + layout, + font->GetNativeFontInfo()->description + ); + } + + PangoFontMetrics* metrics = pango_context_get_metrics (context, font->GetNativeFontInfo()->description, NULL); + + int height = font->GetPixelSize().GetHeight(); + + m_ascent = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics)); + m_descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics)); + + int h; + + const char* x = "x"; + pango_layout_set_text( layout, x, strlen(x) ); + pango_layout_get_pixel_size( layout, NULL, &h ); + + m_xHeight = h; + m_lineGap = (m_ascent + m_descent) / 4; // FIXME: How can we calculate this via Pango? + m_lineSpacing = m_ascent + m_descent; + + pango_font_metrics_unref(metrics); +#endif +} + +bool wxFontContainsCharacters(const wxFont& font, const UChar* characters, int length) +{ + return true; +} + +void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height, + wxCoord *descent, wxCoord *externalLeading ) +{ + if ( width ) + *width = 0; + if ( height ) + *height = 0; + if ( descent ) + *descent = 0; + if ( externalLeading ) + *externalLeading = 0; + + if (str.empty()) + return; + +// FIXME: Doesn't support height, descent or external leading, though we don't need this for WebKit +// it will need to be implemented before merging into wx unless we craft a new API. +#if USE(WXGC) + PangoFont* pangoFont = WebCore::createPangoFontForFont(&font); + PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(WebCore::pangoFontMap())); + PangoGlyph pangoGlyph = WebCore::pango_font_get_glyph(pangoFont, pangoContext, (gunichar)g_utf8_get_char(str.ToUTF8())); + cairo_glyph_t cglyph = { pangoGlyph, 0, 0 }; + cairo_text_extents_t extents; + cairo_scaled_font_t* scaled_font = WebCore::createScaledFontForFont(&font); + cairo_scaled_font_glyph_extents(scaled_font, &cglyph, 1, &extents); + + if (cairo_scaled_font_status(scaled_font) == CAIRO_STATUS_SUCCESS && extents.x_advance != 0) + *width = (wxCoord)extents.x_advance; + + cairo_scaled_font_destroy(scaled_font); + g_object_unref(pangoContext); + g_object_unref(pangoFont); +#else + PangoContext* context = gdk_pango_context_get_for_screen( gdk_screen_get_default() ); + PangoLayout* m_layout = pango_layout_new(context); + // and use it if it's valid + if ( font && font->IsOk() ) + { + pango_layout_set_font_description + ( + m_layout, + font->GetNativeFontInfo()->description + ); + } + + // Set layout's text + const wxCharBuffer dataUTF8 = wxConvUTF8.cWX2MB(str); + if ( !dataUTF8 ) + { + // hardly ideal, but what else can we do if conversion failed? + return; + } + + pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) ); + + int h = 0; + pango_layout_get_pixel_size( m_layout, width, &h ); + + if (descent) + { + PangoLayoutIter *iter = pango_layout_get_iter(m_layout); + int baseline = pango_layout_iter_get_baseline(iter); + pango_layout_iter_free(iter); + *descent = h - PANGO_PIXELS(baseline); + } + + if (height) + *height = (wxCoord) h; +#endif +} + diff --git a/Source/WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp b/Source/WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp new file mode 100644 index 0000000..bf745e0 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GlyphBuffer.h" +#include "GraphicsContext.h" +#include "SimpleFontData.h" + +#include <wx/dc.h> +#include <wx/dcgraph.h> +#include <wx/defs.h> +#include <wx/dcclient.h> +#include <wx/gdicmn.h> +#include <vector> + +#if USE(WXGC) +#include <cairo.h> +#include <assert.h> + +#include <pango/pango.h> +#include <pango/pangocairo.h> + +// Use cairo-ft if a recent enough Pango version isn't available +#if !PANGO_VERSION_CHECK(1,18,0) +#include <cairo-ft.h> +#include <pango/pangofc-fontmap.h> +#endif + +#endif + +#include <gtk/gtk.h> + +namespace WebCore { + +#if USE(WXGC) +static PangoFontMap* g_fontMap; + +PangoFontMap* pangoFontMap() +{ + if (!g_fontMap) + g_fontMap = pango_cairo_font_map_get_default(); + + return g_fontMap; +} + +PangoFont* createPangoFontForFont(const wxFont* wxfont) +{ + ASSERT(wxfont && wxfont->Ok()); + + const char* face = wxfont->GetFaceName().mb_str(wxConvUTF8); + char const* families[] = { + face, + 0 + }; + + switch (wxfont->GetFamily()) { + case wxFONTFAMILY_ROMAN: + families[1] = "serif"; + break; + case wxFONTFAMILY_SWISS: + families[1] = "sans"; + break; + case wxFONTFAMILY_MODERN: + families[1] = "monospace"; + break; + default: + families[1] = "sans"; + } + + PangoFontDescription* description = pango_font_description_new(); + pango_font_description_set_absolute_size(description, wxfont->GetPointSize() * PANGO_SCALE); + + PangoFont* pangoFont = 0; + PangoContext* pangoContext = 0; + + switch (wxfont->GetWeight()) { + case wxFONTWEIGHT_LIGHT: + pango_font_description_set_weight(description, PANGO_WEIGHT_LIGHT); + break; + case wxFONTWEIGHT_NORMAL: + pango_font_description_set_weight(description, PANGO_WEIGHT_NORMAL); + break; + case wxFONTWEIGHT_BOLD: + pango_font_description_set_weight(description, PANGO_WEIGHT_BOLD); + break; + } + + switch (wxfont->GetStyle()) { + case wxFONTSTYLE_NORMAL: + pango_font_description_set_style(description, PANGO_STYLE_NORMAL); + break; + case wxFONTSTYLE_ITALIC: + pango_font_description_set_style(description, PANGO_STYLE_ITALIC); + break; + case wxFONTSTYLE_SLANT: + pango_font_description_set_style(description, PANGO_STYLE_OBLIQUE); + break; + } + + PangoFontMap* fontMap = pangoFontMap(); + + pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(fontMap)); + for (unsigned i = 0; !pangoFont && i < G_N_ELEMENTS(families); i++) { + pango_font_description_set_family(description, families[i]); + pango_context_set_font_description(pangoContext, description); + pangoFont = pango_font_map_load_font(fontMap, pangoContext, description); + } + pango_font_description_free(description); + + return pangoFont; +} + +cairo_scaled_font_t* createScaledFontForFont(const wxFont* wxfont) +{ + ASSERT(wxfont && wxfont->Ok()); + + cairo_scaled_font_t* scaledFont = NULL; + PangoFont* pangoFont = createPangoFontForFont(wxfont); + +#if PANGO_VERSION_CHECK(1,18,0) + if (pangoFont) + scaledFont = cairo_scaled_font_reference(pango_cairo_font_get_scaled_font(PANGO_CAIRO_FONT(pangoFont))); +#endif + + return scaledFont; +} + +PangoGlyph pango_font_get_glyph(PangoFont* font, PangoContext* context, gunichar wc) +{ + PangoGlyph result = 0; + gchar buffer[7]; + + gint length = g_unichar_to_utf8(wc, buffer); + g_return_val_if_fail(length, 0); + + GList* items = pango_itemize(context, buffer, 0, length, NULL, NULL); + + if (g_list_length(items) == 1) { + PangoItem* item = static_cast<PangoItem*>(items->data); + PangoFont* tmpFont = item->analysis.font; + item->analysis.font = font; + + PangoGlyphString* glyphs = pango_glyph_string_new(); + pango_shape(buffer, length, &item->analysis, glyphs); + + item->analysis.font = tmpFont; + + if (glyphs->num_glyphs == 1) + result = glyphs->glyphs[0].glyph; + else + g_warning("didn't get 1 glyph but %d", glyphs->num_glyphs); + + pango_glyph_string_free(glyphs); + } + + g_list_foreach(items, (GFunc)pango_item_free, NULL); + g_list_free(items); + + return result; +} +#endif // USE(WXGC) + + +void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) +{ +#if USE(WXGC) + wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext()); + wxGraphicsContext* gc = dc->GetGraphicsContext(); + gc->PushState(); + cairo_t* cr = (cairo_t*)gc->GetNativeContext(); + + wxFont* wxfont = font->getWxFont(); + PangoFont* pangoFont = createPangoFontForFont(wxfont); + PangoFontMap* fontMap = pangoFontMap(); + PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(fontMap)); + cairo_scaled_font_t* scaled_font = createScaledFontForFont(wxfont); + ASSERT(scaled_font); + + cairo_glyph_t* glyphs = NULL; + glyphs = static_cast<cairo_glyph_t*>(malloc(sizeof(cairo_glyph_t) * numGlyphs)); + + float offset = point.x(); + + for (int i = 0; i < numGlyphs; i++) { + glyphs[i].index = pango_font_get_glyph(pangoFont, pangoContext, glyphBuffer.glyphAt(from + i)); + glyphs[i].x = offset; + glyphs[i].y = point.y(); + offset += glyphBuffer.advanceAt(from + i); + } + + cairo_set_source_rgba(cr, color.Red()/255.0, color.Green()/255.0, color.Blue()/255.0, color.Alpha()/255.0); + cairo_set_scaled_font(cr, scaled_font); + + cairo_show_glyphs(cr, glyphs, numGlyphs); + + cairo_scaled_font_destroy(scaled_font); + gc->PopState(); +#else + wxDC* dc = graphicsContext->platformContext(); + + wxFont* wxfont = font->getWxFont(); + if (wxfont && wxfont->IsOk()) + dc->SetFont(*wxfont); + dc->SetTextForeground(color); + + // convert glyphs to wxString + GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from)); + int offset = point.x(); + wxString text = wxEmptyString; + for (unsigned i = 0; i < numGlyphs; i++) { + text = text.Append((wxChar)glyphs[i]); + offset += glyphBuffer.advanceAt(from + i); + } + + // the y point is actually the bottom point of the text, turn it into the top + float height = font->ascent() - font->descent(); + wxCoord ypoint = (wxCoord) (point.y() - height); + + dc->DrawText(text, (wxCoord)point.x(), ypoint); +#endif +} + +} diff --git a/Source/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp b/Source/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp new file mode 100644 index 0000000..3b4daa8 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2009 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "scrollbar_render.h" + +#include <wx/defs.h> +#include <wx/dc.h> +#include <wx/dcgraph.h> +#include <wx/renderer.h> +#include <wx/settings.h> +#include <wx/window.h> + +#include <gtk/gtk.h> + +#if wxCHECK_VERSION(2, 9, 0) + #include <wx/gtk/dc.h> +#else + #include "wx/gtk/win_gtk.h" +#endif + +int wxStyleForPart(wxScrollbarPart part, wxScrollbarPart focusPart, wxScrollbarPart hoverPart, int flags) +{ + int style = 0; + if (flags == wxCONTROL_DISABLED) + style = wxCONTROL_DISABLED; + else if (part == focusPart) + style = wxCONTROL_PRESSED; + else if (part == hoverPart) + style = wxCONTROL_CURRENT; + + return style; +} + +GtkWidget* GetButtonWidget() +{ + static GtkWidget *s_button = NULL; + static GtkWidget *s_window = NULL; + + if ( !s_button ) + { + s_window = gtk_window_new( GTK_WINDOW_POPUP ); + gtk_widget_realize( s_window ); + s_button = gtk_button_new(); + gtk_container_add( GTK_CONTAINER(s_window), s_button ); + gtk_widget_realize( s_button ); + } + + return s_button; +} + + +GdkWindow* wxGetGdkWindowForDC(wxWindow* win, wxDC& dc) +{ + GdkWindow* gdk_window = NULL; +#if wxCHECK_VERSION(2, 9, 0) + if ( dc.IsKindOf( CLASSINFO(wxGCDC) ) ) + gdk_window = win->GTKGetDrawingWindow(); + else + { + wxGTKDCImpl *impl = wxDynamicCast(dc.GetImpl(), wxGTKDCImpl); + if ( impl ) + gdk_window = impl->GetGDKWindow(); + } +#else // wx < 2.9 + // The way to get a GdkWindow* from a wxWindow is to use + // GTK_PIZZA(win->m_wxwindow)->bin_window, but this approach + // won't work when drawing to a wxMemoryDC as it has its own + // GdkWindow* for its bitmap. wxWindowDC's GetGDKWindow() was + // designed to create a solution for all DCs, but we can't + // implement it with wxGCDC since it doesn't retain its wxWindow. + // So, to work around this, we use GetGDKWindow whenever possible + // and use bin_window for wxGCDC. +#if wxUSE_GRAPHICS_CONTEXT + if ( dc.IsKindOf( CLASSINFO(wxGCDC) ) ) + gdk_window = GTK_PIZZA(win->m_wxwindow)->bin_window; + else +#endif + gdk_window = dc.GetGDKWindow(); + wxASSERT_MSG( gdk_window, + wxT("cannot use wxRendererNative on wxDC of this type") ); +#endif // wx 2.9/2.8 + + return gdk_window; +} + +void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, const wxRect& rect, wxOrientation orient, + int current, wxScrollbarPart focusPart, wxScrollbarPart hoverPart, int max, int step, int flags) +{ + bool horiz = orient == wxHORIZONTAL; + wxColour scrollbar_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_SCROLLBAR); + dc.SetBrush(wxBrush(scrollbar_colour)); + dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW))); + dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); + + // when going from Cairo -> Gdk, any Cairo context transformations are lost + // so we need to alter the coordinates to reflect their transformed point. + double xtrans = 0; + double ytrans = 0; + + wxGCDC* gcdc = wxDynamicCast(&dc, wxGCDC); + wxGraphicsContext* gc = gcdc->GetGraphicsContext(); + gc->GetTransform().TransformPoint(&xtrans, &ytrans); + + wxRendererNative& renderer = wxRendererNative::Get(); + int x = rect.x + (int)xtrans; + int y = rect.y + (int)ytrans; + + int buttonLength = 16; + + renderer.DrawPushButton(window, dc, wxRect(x,y,buttonLength,buttonLength), wxStyleForPart(wxSCROLLPART_BACKBTNSTART, focusPart, hoverPart, flags)); + + GtkWidget* button = GetButtonWidget(); + GdkWindow* gdk_window = wxGetGdkWindowForDC(window, dc); + + GtkArrowType arrowType = GTK_ARROW_UP; + if (horiz) + arrowType = GTK_ARROW_LEFT; + + gtk_paint_arrow( button->style, gdk_window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, button, "arrow", arrowType, false, x + 4, y + 4, 8, 8); + + wxRect buttonRect = rect; + int physicalLength = horiz ? rect.width : rect.height; + physicalLength -= buttonLength*2; + int thumbStart = 0; + int thumbLength = 0; + calcThumbStartAndLength(physicalLength, max, current, step, &thumbStart, &thumbLength); + + if (horiz) { + buttonRect.x = x + thumbStart + buttonLength; + buttonRect.y = y; + buttonRect.width = thumbLength; + } else { + buttonRect.x = x; + buttonRect.y = y + thumbStart + buttonLength; + buttonRect.height = thumbLength; + } + + renderer.DrawPushButton(window, dc, buttonRect, wxStyleForPart(wxSCROLLPART_THUMB, focusPart, hoverPart, flags)); + + if (horiz) + x += rect.width - buttonLength; + else + y += rect.height - buttonLength; + + renderer.DrawPushButton(window, dc, wxRect(x,y,buttonLength,buttonLength), wxStyleForPart(wxSCROLLPART_FWDBTNEND, focusPart, hoverPart, flags)); + + if (horiz) + arrowType = GTK_ARROW_RIGHT; + else + arrowType = GTK_ARROW_DOWN; + + gtk_paint_arrow( button->style, gdk_window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, button, "arrow", arrowType, false, x + 4, y + 4, 8, 8); +} diff --git a/Source/WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm b/Source/WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm new file mode 100644 index 0000000..9da47fd --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +// this needs to be included before fontprops.h for UChar* to be defined. +#include <wtf/unicode/Unicode.h> + +#include "fontprops.h" +#include "WebCoreSystemInterface.h" + +#include <ApplicationServices/ApplicationServices.h> + +#include <wx/defs.h> +#include <wx/gdicmn.h> +#include <wx/graphics.h> + +const float smallCapsFontSizeMultiplier = 0.7f; +const float contextDPI = 72.0f; +static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x * (contextDPI / (contextDPI * unitsPerEm)); } + +wxFontProperties::wxFontProperties(wxFont* font): +m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0) +{ + CGFontRef cgFont; + +#ifdef wxOSX_USE_CORE_TEXT && wxOSX_USE_CORE_TEXT + cgFont = CTFontCopyGraphicsFont((CTFontRef)font->OSXGetCTFont(), NULL); +#else + ATSFontRef fontRef; + + fontRef = FMGetATSFontRefFromFont(font->MacGetATSUFontID()); + + if (fontRef) + cgFont = CGFontCreateWithPlatformFont((void*)&fontRef); +#endif + + if (cgFont) { + int iAscent; + int iDescent; + int iLineGap; + unsigned unitsPerEm; +#ifdef BUILDING_ON_TIGER + wkGetFontMetrics(cgFont, &iAscent, &iDescent, &iLineGap, &unitsPerEm); +#else + iAscent = CGFontGetAscent(cgFont); + iDescent = CGFontGetDescent(cgFont); + iLineGap = CGFontGetLeading(cgFont); + unitsPerEm = CGFontGetUnitsPerEm(cgFont); +#endif + float pointSize = font->GetPointSize(); + float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize; + float fDescent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize; + float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize; + + m_ascent = lroundf(fAscent); + m_descent = lroundf(fDescent); + m_lineGap = lroundf(fLineGap); + wxCoord xHeight = 0; + GetTextExtent(*font, wxT("x"), NULL, &xHeight, NULL, NULL); + m_xHeight = lroundf(xHeight); + m_lineSpacing = m_ascent + m_descent + m_lineGap; + + } + + if (cgFont) + CGFontRelease(cgFont); + +} + +bool wxFontContainsCharacters(void* font, const UChar* characters, int length) +{ + NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(characters) length:length freeWhenDone:NO]; + NSCharacterSet* set = [[(NSFont*)font coveredCharacterSet] invertedSet]; + bool result = set && [string rangeOfCharacterFromSet:set].location == NSNotFound; + [string release]; + return result; +} + +void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height, + wxCoord *descent, wxCoord *externalLeading ) +{ + wxGraphicsContext * const gc = wxGraphicsContext::Create(); + + gc->SetFont(font, *wxBLACK); // colour doesn't matter but must be specified + struct GCTextExtent + { + wxDouble width, height, descent, externalLeading; + } e; + gc->GetTextExtent(str, &e.width, &e.height, &e.descent, &e.externalLeading); + if ( width ) + *width = wxCoord(e.width + .5); + if ( height ) + *height = wxCoord(e.height + .5); + if ( descent ) + *descent = wxCoord(e.descent + .5); + if ( externalLeading ) + *externalLeading = wxCoord(e.externalLeading + .5); + + delete gc; +} diff --git a/Source/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp b/Source/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp new file mode 100644 index 0000000..56a5d07 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FloatSize.h" +#include "GlyphBuffer.h" +#include "GraphicsContext.h" +#include "SimpleFontData.h" +#include <wtf/Vector.h> + +#include <ApplicationServices/ApplicationServices.h> + +#include <dlfcn.h> + +#include <wx/defs.h> +#include <wx/dcclient.h> +#include <wx/dcgraph.h> +#include <wx/gdicmn.h> + +namespace WebCore { + +void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) +{ + graphicsContext->save(); + + wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext()); + + wxFont* wxfont = font->getWxFont(); + graphicsContext->setFillColor(graphicsContext->fillColor(), ColorSpaceDeviceRGB); + + CGContextRef cgContext = static_cast<CGContextRef>(dc->GetGraphicsContext()->GetNativeContext()); + + CGFontRef cgFont = font->platformData().cgFont(); + + CGContextSetFont(cgContext, cgFont); + + CGContextSetFontSize(cgContext, wxfont->GetPointSize()); + + CGFloat red, green, blue, alpha; + graphicsContext->fillColor().getRGBA(red, green, blue, alpha); + CGContextSetRGBFillColor(cgContext, red, green, blue, alpha); + + CGAffineTransform matrix = CGAffineTransformIdentity; + matrix.b = -matrix.b; + matrix.d = -matrix.d; + + CGContextSetTextMatrix(cgContext, matrix); + + CGContextSetTextPosition(cgContext, point.x(), point.y()); + + CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); + + if (cgFont) + CGFontRelease(cgFont); + graphicsContext->restore(); +} + +} diff --git a/Source/WebCore/platform/wx/wxcode/mac/carbon/scrollbar_render.cpp b/Source/WebCore/platform/wx/wxcode/mac/carbon/scrollbar_render.cpp new file mode 100644 index 0000000..5169601 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/mac/carbon/scrollbar_render.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2009 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "config.h" + +#include "scrollbar_render.h" + +#include <wx/defs.h> +#include <wx/dc.h> +#include <wx/dcgraph.h> +#include <wx/renderer.h> + +#include <Carbon/Carbon.h> + +static int wxScrollbarPartToHIPressedState(wxScrollbarPart part) +{ + switch (part) { + case wxSCROLLPART_BACKBTNSTART: + return kThemeTopOutsideArrowPressed; + case wxSCROLLPART_BACKBTNEND: + return kThemeTopOutsideArrowPressed; // This does not make much sense. For some reason the outside constant is required. + case wxSCROLLPART_FWDBTNSTART: + return kThemeTopInsideArrowPressed; + case wxSCROLLPART_FWDBTNEND: + return kThemeBottomOutsideArrowPressed; + case wxSCROLLPART_THUMB: + return kThemeThumbPressed; + default: + return 0; + } +} + +void wxRenderer_DrawScrollbar(wxWindow* WXUNUSED(window), wxDC& dc, + const wxRect& rect, wxOrientation orient, int current, + wxScrollbarPart focusPart, wxScrollbarPart hoverPart, int max, int step, int flags) +{ + const wxCoord x = rect.x; + const wxCoord y = rect.y; + const wxCoord w = rect.width; + const wxCoord h = rect.height; + + dc.SetBrush( *wxWHITE_BRUSH ); + dc.SetPen( *wxTRANSPARENT_PEN ); + dc.DrawRectangle(rect); + + dc.SetBrush( *wxTRANSPARENT_BRUSH ); + + HIRect hiRect = CGRectMake( x, y, w, h ); + + CGContextRef cgContext = NULL; + wxGraphicsContext* gc = NULL; +#if wxCHECK_VERSION(2,9,0) + wxGCDCImpl *impl = dynamic_cast<wxGCDCImpl*> (dc.GetImpl()); + if (impl) + gc = impl->GetGraphicsContext(); +#else + gc = dc.GetGraphicsContext(); +#endif + if (gc) + cgContext = (CGContextRef) gc->GetNativeContext(); + + if (cgContext) + { + HIThemeTrackDrawInfo trackInfo; + trackInfo.version = 0; + trackInfo.kind = kThemeMediumScrollBar; + trackInfo.bounds = hiRect; + trackInfo.min = 0; + trackInfo.max = max; + trackInfo.value = current; + trackInfo.trackInfo.scrollbar.viewsize = step; + trackInfo.attributes = 0; + if (orient == wxHORIZONTAL) + trackInfo.attributes |= kThemeTrackHorizontal; + trackInfo.enableState = (flags & wxCONTROL_FOCUSED) ? kThemeTrackActive : kThemeTrackInactive; + trackInfo.trackInfo.scrollbar.pressState = wxScrollbarPartToHIPressedState(focusPart); + trackInfo.attributes |= kThemeTrackShowThumb; + + if (flags & wxCONTROL_DISABLED) + trackInfo.enableState = kThemeTrackDisabled; + + HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); + } +} diff --git a/Source/WebCore/platform/wx/wxcode/non-kerned-drawing.h b/Source/WebCore/platform/wx/wxcode/non-kerned-drawing.h new file mode 100644 index 0000000..b995d37 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/non-kerned-drawing.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */
+
+#include "Font.h"
+#include "GlyphBuffer.h"
+
+#include <wx/defs.h>
+#include <wx/dcclient.h> + +#if __WXGTK__ && USE(WXGC) +#include <cairo.h> +#include <pango/pango.h> +#include <pango/pangocairo.h> +#endif
+
+namespace WebCore {
+
+extern void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point);
+ +#if __WXGTK__ && USE(WXGC) +PangoFontMap* pangoFontMap(); + +PangoFont* createPangoFontForFont(const wxFont* wxfont); +cairo_scaled_font_t* createScaledFontForFont(const wxFont* wxfont); +PangoGlyph pango_font_get_glyph(PangoFont* font, PangoContext* context, gunichar wc); + +#endif +} + diff --git a/Source/WebCore/platform/wx/wxcode/scrollbar_render.h b/Source/WebCore/platform/wx/wxcode/scrollbar_render.h new file mode 100644 index 0000000..5e0ea8e --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/scrollbar_render.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2009 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef scrollbar_render_h +#define scrollbar_render_h + +#include <wx/defs.h> +#include <wx/dc.h> +#include <wx/renderer.h> + +enum wxScrollbarPart { + wxSCROLLPART_NONE = 0, + wxSCROLLPART_BACKBTNSTART = 1, + wxSCROLLPART_FWDBTNSTART = 1 << 1, + wxSCROLLPART_BACKTRACK = 1 << 2, + wxSCROLLPART_THUMB = 1 << 3, + wxSCROLLPART_FWDTRACK = 1 << 4, + wxSCROLLPART_BACKBTNEND = 1 << 5, + wxSCROLLPART_FWDBTNEND = 1 << 6, + wxSCROLLPART_SCROLLBARBG = 1 << 7, + wxSCROLLPART_TRACKBG = 1 << 8, + wxSCROLLPART_ALL = 0xffffffff, +}; + +void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, + const wxRect& rect, + wxOrientation orientation, + int current, wxScrollbarPart focusPart, wxScrollbarPart hoverPart, + int max, int step, int flags=0); + +inline void calcThumbStartAndLength(int physicalLength, int max, int current, + int step, int *thumbStart, int *thumbLength) +{ + float proportion = ((float)physicalLength - 8)/ (max + step); + float thumbSize = proportion * (float)physicalLength; + if (thumbSize < 20) + thumbSize = 20; + + float thumbPos = ((float)current / (float)max) * ((float)physicalLength - thumbSize); + if (thumbStart) + *thumbStart = thumbPos; + + if (thumbLength) + *thumbLength = thumbSize; +} +#endif diff --git a/Source/WebCore/platform/wx/wxcode/win/fontprops.cpp b/Source/WebCore/platform/wx/wxcode/win/fontprops.cpp new file mode 100644 index 0000000..f3e4fda --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/win/fontprops.cpp @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +// this needs to be included before fontprops.h for UChar* to be defined. +#include <wtf/unicode/Unicode.h> + +#include "fontprops.h" +#include "math.h" +#include "MathExtras.h" + +#include <wx/defs.h> +#include <wx/gdicmn.h> +#include <wx/wx.h> +#include "wx/msw/private.h" + +#include <mlang.h> +#include <usp10.h> + +inline long my_round(double x) +{ + return (long)(x < 0 ? x - 0.5 : x + 0.5); +} + +wxFontProperties::wxFontProperties(wxFont* font): +m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0) +{ + HDC dc = GetDC(0); + WXHFONT hFont = font->GetHFONT(); + ::SelectObject(dc, hFont); + if (font){ + + int height = font->GetPointSize(); + + TEXTMETRIC tm; + GetTextMetrics(dc, &tm); + m_ascent = lroundf(tm.tmAscent); + m_descent = lroundf(tm.tmDescent); + m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts. + m_lineGap = lroundf(tm.tmExternalLeading); + m_lineSpacing = m_lineGap + m_ascent + m_descent; + } + RestoreDC(dc, -1); + ReleaseDC(0, dc); +} + +bool wxFontContainsCharacters(void* font, const UChar* characters, int length) +{ + // FIXME: Microsoft documentation seems to imply that characters can be output using a given font and DC + // merely by testing code page intersection. This seems suspect though. Can't a font only partially + // cover a given code page? + static IMultiLanguage *multiLanguage; + if (!multiLanguage) { + if (CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_ALL, IID_IMultiLanguage, (void**)&multiLanguage) != S_OK) + return true; + } + + static IMLangFontLink2* langFontLink; + if (!langFontLink) { + if (multiLanguage->QueryInterface(&langFontLink) != S_OK) + return true; + } + + HDC dc = GetDC(0); + + DWORD acpCodePages; + langFontLink->CodePageToCodePages(CP_ACP, &acpCodePages); + + DWORD fontCodePages; + langFontLink->GetFontCodePages(dc, (HFONT)font, &fontCodePages); + + DWORD actualCodePages; + long numCharactersProcessed; + long offset = 0; + while (offset < length) { + langFontLink->GetStrCodePages(characters, length, acpCodePages, &actualCodePages, &numCharactersProcessed); + if ((actualCodePages & fontCodePages)) + return false; + offset += numCharactersProcessed; + } + + ReleaseDC(0, dc); + + return true; +} + +void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height, + wxCoord *descent, wxCoord *externalLeading ) +{ + HDC dc = GetDC(0); + WXHFONT hFont = font.GetHFONT(); + ::SelectObject(dc, hFont); + + HFONT hfontOld; + if ( font != wxNullFont ) + { + wxASSERT_MSG( font.Ok(), _T("invalid font in wxDC::GetTextExtent") ); + + hfontOld = (HFONT)::SelectObject(dc, hFont); + } + else // don't change the font + { + hfontOld = 0; + } + + SIZE sizeRect; + const size_t len = str.length(); + if ( !::GetTextExtentPoint32(dc, str, len, &sizeRect) ) + { + wxLogLastError(_T("GetTextExtentPoint32()")); + } + +#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) + // the result computed by GetTextExtentPoint32() may be too small as it + // accounts for under/overhang of the first/last character while we want + // just the bounding rect for this string so adjust the width as needed + // (using API not available in 2002 SDKs of WinCE) + if ( len > 1 ) + { + ABC width; + const wxChar chFirst = *str.begin(); + if ( ::GetCharABCWidths(dc, chFirst, chFirst, &width) ) + { + if ( width.abcA < 0 ) + sizeRect.cx -= width.abcA; + + if ( len > 1 ) + { + const wxChar chLast = *str.rbegin(); + ::GetCharABCWidths(dc, chLast, chLast, &width); + } + //else: we already have the width of the last character + + if ( width.abcC < 0 ) + sizeRect.cx -= width.abcC; + } + //else: GetCharABCWidths() failed, not a TrueType font? + } +#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) + + TEXTMETRIC tm; + ::GetTextMetrics(dc, &tm); + + if (width) + *width = sizeRect.cx; + if (height) + *height = sizeRect.cy; + if (descent) + *descent = tm.tmDescent; + if (externalLeading) + *externalLeading = tm.tmExternalLeading; + + if ( hfontOld ) + { + ::SelectObject(dc, hfontOld); + } + + ReleaseDC(0, dc); +} diff --git a/Source/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp b/Source/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp new file mode 100644 index 0000000..2fcd761 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GlyphBuffer.h" +#include "GraphicsContext.h" +#include "SimpleFontData.h" + +#include <wx/defs.h> +#include <wx/dcclient.h> +#include <wx/dcgraph.h> +#include <wx/gdicmn.h> +#include <vector> + +using namespace std; + +//----------------------------------------------------------------------------- +// constants +//----------------------------------------------------------------------------- + +const double RAD2DEG = 180.0 / M_PI; + +//----------------------------------------------------------------------------- +// Local functions +//----------------------------------------------------------------------------- + +static inline double dmin(double a, double b) { return a < b ? a : b; } +static inline double dmax(double a, double b) { return a > b ? a : b; } + +static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } +static inline double RadToDeg(double deg) { return (deg * 180.0) / M_PI; } + +#include "wx/msw/private.h" + +// TODO remove this dependency (gdiplus needs the macros) + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#include "gdiplus.h" + + +namespace WebCore { + +void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) +{ +#if USE(WXGC) + wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext()); +#else + wxDC* dc = graphicsContext->platformContext(); +#endif + + // get the native HDC handle to draw using native APIs + HDC hdc = 0; + float y = point.y() - font->ascent(); + float x = point.x(); + +#if USE(WXGC) + // when going from GdiPlus -> Gdi, any GdiPlus transformations are lost + // so we need to alter the coordinates to reflect their transformed point. + double xtrans = 0; + double ytrans = 0; + + wxGraphicsContext* gc = dc->GetGraphicsContext(); + gc->GetTransform().TransformPoint(&xtrans, &ytrans); + Gdiplus::Graphics* g; + if (gc) { + g = (Gdiplus::Graphics*)gc->GetNativeContext(); + hdc = g->GetHDC(); + } + x += (int)xtrans; + y += (int)ytrans; +#else + hdc = static_cast<HDC>(dc->GetHDC()); +#endif + + // ExtTextOut wants the offsets as an array of ints, so extract them + // from the glyph buffer + const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from); + const GlyphBufferAdvance* advances = glyphBuffer.advances(from); + + int* spacing = new int[numGlyphs - from]; + for (unsigned i = 0; i < numGlyphs; ++i) + spacing[i] = advances[i].width(); + + wxFont* wxfont = font->getWxFont(); + if (wxfont && wxfont->IsOk()) + ::SelectObject(hdc, GetHfontOf(*wxfont)); + + if (color.Ok()) + ::SetTextColor(hdc, color.GetPixel()); + + // do not draw background behind characters + ::SetBkMode(hdc, TRANSPARENT); + + // draw text with optional character widths array + wxString string = wxString((wxChar*)(&glyphs[from]), numGlyphs); + ::ExtTextOut(hdc, x, y, ETO_GLYPH_INDEX, 0, reinterpret_cast<const WCHAR*>(glyphs), numGlyphs, spacing); + + ::SetBkMode(hdc, TRANSPARENT); + + #if USE(WXGC) + g->ReleaseHDC(hdc); + #endif + + delete [] spacing; +} + +} diff --git a/Source/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp b/Source/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp new file mode 100644 index 0000000..890db00 --- /dev/null +++ b/Source/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2009 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "scrollbar_render.h" + +#include <wx/defs.h> + +#include <wx/dc.h> +#include <wx/dcgraph.h> +#include <wx/graphics.h> +#include <wx/renderer.h> +#include <wx/window.h> + +#include <wx/msw/private.h> +#include <wx/msw/uxtheme.h> + +// constants +#define SP_BUTTON 1 +#define SP_THUMBHOR 2 +#define SP_THUMBVERT 3 +#define SP_TRACKENDHOR 4 +#define SP_TRACKENDVERT 7 +#define SP_GRIPPERHOR 8 +#define SP_GRIPPERVERT 9 + +#define TS_NORMAL 1 +#define TS_HOVER 2 +#define TS_ACTIVE 3 +#define TS_DISABLED 4 + +#define TS_UP_BUTTON 0 +#define TS_DOWN_BUTTON 4 +#define TS_LEFT_BUTTON 8 +#define TS_RIGHT_BUTTON 12 + +#if wxUSE_GRAPHICS_CONTEXT +// TODO remove this dependency (gdiplus needs the macros) +// we need to undef because the macros are being defined in WebCorePrefix.h +// but GdiPlus.h is not accepting them +#undef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) + +#undef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) + +#include <wx/dcgraph.h> +#include "gdiplus.h" +using namespace Gdiplus; +#endif // wxUSE_GRAPHICS_CONTEXT + +class GraphicsHDC +{ +public: + GraphicsHDC(wxDC* dc) + { +#if wxUSE_GRAPHICS_CONTEXT + m_graphics = NULL; + wxGCDC* gcdc = wxDynamicCast(dc, wxGCDC); + if (gcdc) { + m_graphics = (Graphics*)gcdc->GetGraphicsContext()->GetNativeContext(); + m_hdc = m_graphics->GetHDC(); + } + else +#endif + m_hdc = GetHdcOf(*dc); + } + + ~GraphicsHDC() + { +#if wxUSE_GRAPHICS_CONTEXT + if (m_graphics) + m_graphics->ReleaseHDC(m_hdc); +#endif + } + + operator HDC() const { return m_hdc; } + +private: + HDC m_hdc; +#if wxUSE_GRAPHICS_CONTEXT + Graphics* m_graphics; +#endif +}; + +int getTSStateForPart(wxScrollbarPart part, wxScrollbarPart focusPart, wxScrollbarPart hoverPart, int flags = 0) +{ + int xpState = TS_NORMAL; + if (flags & wxCONTROL_DISABLED) + xpState = TS_DISABLED; + else if (part == focusPart) + xpState = TS_ACTIVE; + else if (part == hoverPart) + xpState = TS_HOVER; + + return xpState; +} + +void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, + const wxRect& rect, wxOrientation orient, int current, wxScrollbarPart focusPart, wxScrollbarPart hoverPart, int max, int step, int flags) +{ + wxUxThemeEngine *engine = wxUxThemeEngine::Get(); + HTHEME hTheme = (HTHEME)engine->OpenThemeData(0, L"SCROLLBAR"); + + bool horiz = orient == wxHORIZONTAL; + int part = 0; + if (horiz) + part = SP_TRACKENDHOR; + else + part = SP_TRACKENDVERT; + + int xpState = TS_NORMAL; + wxRect transRect = rect; + +#if USE(WXGC) + // when going from GdiPlus -> Gdi, any GdiPlus transformations are lost + // so we need to alter the coordinates to reflect their transformed point. + double xtrans = 0; + double ytrans = 0; + + wxGCDC* gcdc = wxDynamicCast(&dc, wxGCDC); + wxGraphicsContext* gc = gcdc->GetGraphicsContext(); + gc->GetTransform().TransformPoint(&xtrans, &ytrans); + + transRect.x += (int)xtrans; + transRect.y += (int)ytrans; +#endif + + RECT r; + wxCopyRectToRECT(transRect, r); + + // Unlike Mac, on MSW you draw the scrollbar piece by piece. + // so we draw the track first, then the buttons + if (hTheme) + { + engine->DrawThemeBackground(hTheme, GraphicsHDC(&dc), part, xpState, &r, 0); + + int buttonSize = 16; + + part = SP_BUTTON; + xpState = getTSStateForPart(wxSCROLLPART_BACKBTNSTART, focusPart, hoverPart, flags); + xpState += horiz ? TS_LEFT_BUTTON : TS_UP_BUTTON; + RECT buttonRect = r; + buttonRect.bottom = buttonRect.top + buttonSize; + buttonRect.right = buttonRect.left + buttonSize; + engine->DrawThemeBackground(hTheme, GraphicsHDC(&dc), part, xpState, &buttonRect, 0); + + xpState = getTSStateForPart(wxSCROLLPART_FWDBTNEND, focusPart, hoverPart, flags); + xpState += horiz ? TS_RIGHT_BUTTON : TS_DOWN_BUTTON; + buttonRect = r; + buttonRect.top = buttonRect.bottom - buttonSize; + buttonRect.left = buttonRect.right - buttonSize; + engine->DrawThemeBackground(hTheme, GraphicsHDC(&dc), part, xpState, &buttonRect, 0); + + part = horiz ? SP_THUMBHOR : SP_THUMBVERT; + + int physicalLength = horiz ? rect.width : rect.height; + physicalLength -= buttonSize*2; + int thumbStart = 0; + int thumbLength = 0; + calcThumbStartAndLength(physicalLength, max, + current, step, &thumbStart, &thumbLength); + buttonRect = r; + if (horiz) { + buttonRect.left = buttonRect.left + thumbStart + buttonSize; + buttonRect.right = buttonRect.left + thumbLength; + } else { + buttonRect.top = buttonRect.top + thumbStart + buttonSize; + buttonRect.bottom = buttonRect.top + thumbLength; + } + + xpState = getTSStateForPart(wxSCROLLPART_THUMB, focusPart, hoverPart, flags); + engine->DrawThemeBackground(hTheme, GraphicsHDC(&dc), part, xpState, &buttonRect, 0); + + // draw the gripper + int thickness = ::GetSystemMetrics(SM_CXVSCROLL) / 2; + + buttonRect.left += ((buttonRect.right - buttonRect.left) - thickness) / 2; + buttonRect.top += ((buttonRect.bottom - buttonRect.top) - thickness) / 2; + buttonRect.right = buttonRect.left + thickness; + buttonRect.bottom = buttonRect.top + thickness; + + if (horiz) + part = SP_GRIPPERHOR; + else + part = SP_GRIPPERVERT; + + engine->DrawThemeBackground(hTheme, GraphicsHDC(&dc), part, xpState, &buttonRect, 0); + } +} |