void PlatformScrollbar::updateViewOnMouseHover()
{
    EA::Raster::Surface* const pSurface = containingWindow();
    EA::WebKit::View* pView = static_cast<EA::WebKit::View*>(pSurface->mpUserData);
    const EA::WebKit::ViewParameters& vPm = pView->GetParameters();
    if(vPm.mbRedrawScrollbarOnCursorHover)
    {
        EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();
        if(pVN != NULL)
        {
            GraphicsContext context(pSurface);

            IntRect dmgRect;
            switch ((int)m_hoveredPart)
            {
            case BackButtonPart:
                dmgRect = backButtonRect();
                break;
            case ForwardButtonPart:
                 dmgRect = forwardButtonRect();
                break;
            case ThumbPart:
                 dmgRect = thumbRect();
                break;
            }
            paint(&context, dmgRect);
            EA::WebKit::ViewUpdateInfo vui = { pView,  x(), y(), width(), height() };
            pVN->ViewUpdate(vui);
        }
    }
}
void PlatformScrollbar::paint(GraphicsContext* context, const IntRect& damageRect)
{
    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();
    // EA::Raster::Surface* const pSurface = containingWindow();

    EA::WebKit::ScrollbarDrawInfo sbi;
    SetScrollDrawInfo(sbi, damageRect);

    if(!pVN || !pVN->DrawScrollbar(sbi))
        defaultpaint(context, damageRect);
}
void WebViewPrivate::onExpose(BalEventExpose eventExpose)
{
    //OWB_PRINTF("WebViewPrivate::onExpose\n");
    Frame* frame = core(m_webView->mainFrame());
    if (!frame)
        return;

    if(!isInitialized) {
        //OWB_PRINTF("not isInitialized\n");
        isInitialized = true;
        frame->view()->resize(m_rect.width(), m_rect.height());
        frame->forceLayout();
        frame->view()->adjustViewSize();
    }

    GraphicsContext ctx(m_webView->viewWindow());
    ctx.setBalExposeEvent(&eventExpose);
    if (frame->contentRenderer() && frame->view() && !m_webView->dirtyRegion().isEmpty()) {
        frame->view()->layoutIfNeededRecursive();
        IntRect dirty = m_webView->dirtyRegion();
        
        // Notify the user of the draw start event.
        EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

        EA::WebKit::View* pView = EA::WebKit::GetView(m_webView);
        
        // Clip to the main view surface and not just the dirty rect for notification.    
        int w=0;
        int h=0;
        if(pView)
            pView->GetSize(w,h);
        IntRect rect(0,0,w,h);
        rect.intersect(dirty);

        EA::WebKit::ViewUpdateInfo vui = { pView, rect.x(), rect.y(), rect.width(), rect.height(), EA::WebKit::ViewUpdateInfo::kViewDrawStart};
        if(pVN)
            pVN->DrawEvent(vui);

        frame->view()->paint(&ctx, dirty);

       // Notify the user of end draw event     
        if(pVN) {
            vui.mDrawEvent = EA::WebKit::ViewUpdateInfo::kViewDrawEnd;
            pVN->DrawEvent(vui);
            
           // TODO: Deprecate this view update 
          pVN->ViewUpdate(vui);
        }

        m_webView->clearDirtyRegion();
    }
}
// It's called a "focus ring" but it's not a ring, it's a (possibly rounded) rect around 
// something that is highlighted, like a text input.
void GraphicsContext::drawFocusRing(const Color& color)
{
    if (paintingDisabled())
        return;

    const int radius = (focusRingWidth() - 1) / 2;
    const int offset = radius + focusRingOffset();

    const Vector<IntRect>& rects     = focusRingRects();
    unsigned               rectCount = rects.size();
    IntRect                finalFocusRect;

    for (unsigned i = 0; i < rectCount; i++)
    {
        IntRect focusRect = rects[i];

        focusRect.setLocation(focusRect.location() + origin());
        focusRect.inflate(offset);
        finalFocusRect.unite(focusRect);
    }

    bool useDefaultFocusRingDraw = true;
    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    EA::WebKit::FocusRingDrawInfo focusInfo;
    
    EA::Raster::ISurface* pSurface = m_data->surface; 
    EA::WebKit::View* pView = NULL;
    if(pSurface)
        pView = static_cast<EA::WebKit::View*> (pSurface->GetUserData());  // Need to verify that this cast is always safe...
    
    focusInfo.mpView = pView;
    EA::WebKit::GetEARasterInstance()->IntRectToEARect(finalFocusRect, focusInfo.mFocusRect);
    focusInfo.mFocusRect.h -= 1;
    focusInfo.mFocusRect.w -= 1;
    focusInfo.mSuggestedColor.setRGB(color.rgb());
    focusInfo.mpSurface = m_data->surface;
    if(pVN)
    {
        useDefaultFocusRingDraw = !pVN->DrawFocusRing(focusInfo);
    }

    //default focus rect draw method
    if(useDefaultFocusRingDraw)
    {
        // Force the alpha to 50%. This matches what the Mac does with outline rings.
        const  EA::Raster::Color ringColor(color.red(), color.green(), color.blue(), 127);
        EA::WebKit::GetEARasterInstance()->RectangleColor(focusInfo.mpSurface, focusInfo.mFocusRect, ringColor);
    }
}
// Write to the clipboard
void Pasteboard::writeSelection(Range* /*selectedRange*/, bool /*canSmartCopyOrDelete*/, Frame* frame)
{
    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    if(pVN) // This should always be true.
    {
        EA::WebKit::ClipboardEventInfo cei;

        cei.mReadFromClipboard = false;

        const String str = frame->selectedText();
        GET_FIXEDSTRING16(cei.mText)->assign(str.characters(), str.length());

        pVN->ClipboardEvent(cei);
    }
}
// Read from the clipboard
String Pasteboard::plainText(Frame* /*frame*/)
{
    WebCore::String retVal;

    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    if(pVN) // This should always be true.
    {
        EA::WebKit::ClipboardEventInfo cei;

        cei.mReadFromClipboard = true;

        pVN->ClipboardEvent(cei); // We can ignore the return value and just look at cei.mText.

        if(!GET_FIXEDSTRING16(cei.mText)->empty())
            retVal = GET_FIXEDSTRING16(cei.mText)->c_str();
    }

    return retVal;
}
Exemple #7
0
void Cursor::Set() const
{
    bool bHandled = false;
    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    if(pVN)
    {
        EA::WebKit::CursorChangeInfo cci = { m_impl }; // m_impl is an int, the cursor id.
        bHandled = pVN->CursorChanged(cci);
    }

    if(!bHandled)
    {
        #if EAWEBKIT_DEFAULT_CURSOR_HANDLING_ENABLED && defined(EA_PLATFORM_WINDOWS)
            LPCTSTR name = IDC_ARROW;

            switch (m_impl)
            {
                case kCursorIdPointer:
                    name = IDC_ARROW;
                    break;

                case kCursorIdCross:
                    name = IDC_CROSS;
                    break;

                case kCursorIdHand:
                    name = IDC_HAND;
                    break;

                case kCursorIdMove:

                case kCursorIdIBeam:
                    name = IDC_IBEAM;
                    break;

                case kCursorIdWait:
                    name = IDC_WAIT;
                    break;

                case kCursorIdHelp:
                    name = IDC_HELP;
                    break;

                case kCursorIdResizeE:
                case kCursorIdResizeW:
                    name = IDC_SIZEWE;
                    break;

                case kCursorIdResizeN:
                case kCursorIdResizeS:
                    name = IDC_SIZENS;
                    break;

                case kCursorIdResizeNE:
                case kCursorIdResizeNW:
                case kCursorIdResizeSE:
                case kCursorIdResizeSW:
                case kCursorIdResizeNS:
                case kCursorIdResizeEW:
                    // No simple solution.
                    break;

                case kCursorIdResizeNESW:
                    name = IDC_SIZENESW;
                    break;

                case kCursorIdResizeNWSE:
                    name = IDC_SIZENWSE;
                    break;

                case kCursorIdContextMenu:
                    // No simple solution.
                    break;

                case kCursorIdNoDrop:
                case kCursorIdNotAllowed:
                    name = IDC_NO;
                    break;

                case kCursorIdProgress:
                case kCursorIdZAlias:
                case kCursorIdZoomIn:
                case kCursorIdZoomOut:
                case kCursorIdCopy:
                case kCursorIdNone:
                    // No simple solution.
                    break;

                case kCursorIdResizeColumn:
                case kCursorIdResizeRow:
                case kCursorIdVerticalText:
                case kCursorIdCell:
                    // No simple solution.
                    break;
            }

            SetCursor(LoadCursor(NULL, name));
        #else
            // To do: Implement a user-callback mechanism whereby the user handles this in their graphic/UI system.
        #endif
    }
}
String getLocalizedString(LocalizedStringType type)
{
    bool bHandled = false;
    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    if(pVN)
    {
        EA::WebKit::StringInfo si = { type }; si.mString16[0] = 0; si.mString8[0] = 0;
        bHandled = pVN->GetString(si);

        if(bHandled)
        {
            if(si.mString16[0])
                return String(si.mString16);
            else
                return String::fromUTF8(si.mString8);
        }
    }

    if(!bHandled)
    {
        #if EAWEBKIT_DEFAULT_STRING_HANDLING_ENABLED && defined(EA_PLATFORM_WINDOWS)
            const char  empty = 0;
            const char* p;

            switch (type)
            {
                case kLSsearchableIndexIntroduction:                    p = "This is a searchable index. Enter search keywords: "; break;
                case kLSsubmitButtonDefaultLabel:                       p = "Submit"; break;
                case kLSinputElementAltText:                            p = "Submit"; break;
                case kLSresetButtonDefaultLabel:                        p = "Reset"; break;
                case kLSfileButtonChooseFileLabel:                      p = "Choose File"; break;
                case kLSfileButtonNoFileSelectedLabel:                  p = "no file selected"; break;
                case kLScontextMenuItemTagOpenLinkInNewWindow:          p = "Open Link in New Window"; break;
                case kLScontextMenuItemTagDownloadLinkToDisk:           p = "Download Linked File"; break;
                case kLScontextMenuItemTagCopyLinkToClipboard:          p = "Copy Link"; break;
                case kLScontextMenuItemTagOpenImageInNewWindow:         p = "Open Image in New Window"; break;
                case kLScontextMenuItemTagDownloadImageToDisk:          p = "Download Image"; break;
                case kLScontextMenuItemTagCopyImageToClipboard:         p = "Copy Image"; break;
                case kLScontextMenuItemTagOpenFrameInNewWindow:         p = "Open Frame in New Window"; break;
                case kLScontextMenuItemTagCopy:                         p = "Copy"; break;
                case kLScontextMenuItemTagGoBack:                       p = "Back"; break;
                case kLScontextMenuItemTagGoForward:                    p = "Forward"; break;
                case kLScontextMenuItemTagStop:                         p = "Stop"; break;
                case kLScontextMenuItemTagReload:                       p = "Reload"; break;
                case kLScontextMenuItemTagCut:                          p = "Cut"; break;
                case kLScontextMenuItemTagPaste:                        p = "Paste"; break;
                case kLScontextMenuItemTagNoGuessesFound:               p = "No Guesses Found"; break;
                case kLScontextMenuItemTagIgnoreSpelling:               p = "Ignore Spelling"; break;
                case kLScontextMenuItemTagLearnSpelling:                p = "Learn Spelling"; break;
                case kLScontextMenuItemTagSearchWeb:                    p = "Search with Google"; break;
                case kLScontextMenuItemTagLookUpInDictionary:           p = "Look Up in Dictionary"; break;
                case kLScontextMenuItemTagOpenLink:                     p = "Open Link"; break;
                case kLScontextMenuItemTagIgnoreGrammar:                p = "Ignore Grammar"; break;
                case kLScontextMenuItemTagSpellingMenu:                 p = "Spelling and Grammar"; break;
                case kLScontextMenuItemTagCheckSpelling:                p = "Check Document Now"; break;
                case kLScontextMenuItemTagCheckSpellingWhileTyping:     p = "Check Spelling While Typing"; break;
                case kLScontextMenuItemTagCheckGrammarWithSpelling:     p = "Check Grammar With Spelling"; break;
                case kLScontextMenuItemTagFontMenu:                     p = "Font"; break;
                case kLScontextMenuItemTagBold:                         p = "Bold"; break;
                case kLScontextMenuItemTagItalic:                       p = "Italic"; break;
                case kLScontextMenuItemTagUnderline:                    p = "Underline"; break;
                case kLScontextMenuItemTagOutline:                      p = "Outline"; break;
                case kLScontextMenuItemTagWritingDirectionMenu:         p = "Writing Direction"; break;
                case kLScontextMenuItemTagDefaultDirection:             p = "Default"; break;
                case kLScontextMenuItemTagLeftToRight:                  p = "Left to Right"; break;
                case kLScontextMenuItemTagRightToLeft:                  p = "Right to Left"; break;
                case kLScontextMenuItemTagInspectElement:               p = "Inspect Element"; break;
                case kLSsearchMenuNoRecentSearchesText:                 p = "No recent searches"; break;
                case kLSsearchMenuRecentSearchesText:                   p = "Recent Searches"; break;
                case kLSsearchMenuClearRecentSearchesText:              p = "Clear Recent Searches"; break;
                case kLSAXWebAreaText:                                  p = "web area"; break;
                case kLSAXLinkText:                                     p = "link"; break;
                case kLSAXListMarkerText:                               p = "list marker"; break;
                case kLSAXImageMapText:                                 p = "image map"; break;
                case kLSAXHeadingText:                                  p = "heading"; break;
                case kLSAXButtonActionVerb:                             p = "press"; break;
                case kLSAXRadioButtonActionVerb:                        p = "select"; break;
                case kLSAXTextFieldActionVerb:                          p = "activate"; break;
                case kLSAXCheckedCheckBoxActionVerb:                    p = "uncheck"; break;
                case kLSAXUncheckedCheckBoxActionVerb:                  p = "check"; break;
                case kLSAXLinkActionVerb:                               p = "jump"; break;
                case kLSunknownFileSizeText:                            p = "Unknown"; break;
                case kLSuploadFileText:                                 p = "Upload file"; break;
                case kLSallFilesText:                                   p = "All Files"; break;
                default:                                                p = &empty; break;
            }

            return String::fromUTF8(p);
        #endif
    }

    return String(); // We don't want to be executing this.
}
void FileChooser::openFileChooser(Document* document)
{
    //OWB_PRINTF("FileChooser::openFileChooser\n");

    // We use this protector because some systems implement asynchronous dialogs  
    // which could result in this class being deleted while it's executing.
    RefPtr<FileChooser> protector(this);

    // What we need to do here is implement an "open existing file for reading" dialog box.
    // Desktop platforms tend to support this natively, though a custom application may
    // wnat to override this. Upon successfully selecting a file, we need to call the
    // FileChooser::chooseFile(const String&) function with the path.

    // To do: Call back the user-installed file chooser here.

    bool bHandled = false;
    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    if(pVN)
    {
        EA::WebKit::View* pView = EA::WebKit::AutoSetActiveView::GetActiveView();
        
        EA::WebKit::FileChooserInfo fci; 
        
        fci.mpView = pView;             
        fci.mbIsLoad     = true;
        fci.mFilePath[0] = 0;
        fci.mbSuccess    = false;

		if (pVN->ChooseFile(fci))
		{
			bHandled = true;
			const String resultFilename(fci.mFilePath); 
			chooseFile(resultFilename);
		}
    }

    if(!bHandled)
    {
        #if EAWEBKIT_DEFAULT_FILE_CHOOSER_HANDLING_ENABLED && defined(EA_PLATFORM_WINDOWS)

            char          filebuffer[256];
            OPENFILENAMEA ofn;

            memset(&ofn, 0, sizeof(ofn));

            ofn.lStructSize     = sizeof(OPENFILENAME);
            ofn.hwndOwner       = NULL; // Parent window handle
            ofn.lpstrFilter     = "All Files\0*.*\0";
            ofn.nFilterIndex    = 0;
            ofn.lpstrFile       = filebuffer;
            ofn.nMaxFile        = sizeof(filebuffer);
            ofn.lpstrInitialDir = NULL;
            ofn.lpstrTitle      = "Open File";
            ofn.Flags           = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;

            BOOL result = GetOpenFileNameA(&ofn);

            if(result)
            {
                const String resultFilename(filebuffer);
                chooseFile(resultFilename); // Call our member chooseFile function.
            }

        #endif
    }
}