Пример #1
0
bool StBrowserPlugin::init(NPWindow* theWindow) {
    if(theWindow == NULL || theWindow->window == NULL) {
#ifdef _WIN32
        if(myProcOrig  != NULL
                && myParentWin != NULL) {
            SetWindowLongPtr(myParentWin, GWLP_WNDPROC,  (LONG_PTR )myProcOrig);
            SetWindowLongPtr(myParentWin, GWLP_USERDATA, NULL);
            myProcOrig = NULL;
        }
#endif
        return false;
    }

    myParentWin = (StNativeWin_t )theWindow->window;
#ifdef _WIN32
    if(GetWindowLongPtr(myParentWin, GWLP_USERDATA) == NULL) {
        myProcOrig = (WNDPROC )GetWindowLongPtr(myParentWin, GWLP_WNDPROC);
        SetWindowLongPtr(myParentWin, GWLP_WNDPROC,  (LONG_PTR )stWndProcWrapper);
        SetWindowLongPtr(myParentWin, GWLP_USERDATA, (LONG_PTR )this);
    }
#endif
    myThread = new StThread(stThreadFunction, this, "StBrowserPlugin");

    if(!myPreviewUrl.isEmpty() && NPNFuncs.geturl != NULL) {
        NPNFuncs.geturl(nppInstance, myPreviewUrl.toCString(), NULL);
    }

    return true;
}
Пример #2
0
static
NPError MyNPN_GetURL(NPP instance, const char* url,
               const char* target)
{
	NPError err;	
	DEB(ef, "-> NPN_GetURL( %x, %s, %s )\n", instance, url, target );	
	
	err = gNetscapeFuncs.geturl( instance, url, target );		
	DEB(ef, "<- NPN_GetURL = %d\n", err);
	return err;
}
Пример #3
0
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
    if(logger)
        logger->logCall(action_npn_get_url, (DWORD)instance, (DWORD)url, (DWORD)target);

    NPError rv = NPNFuncs.geturl(instance, url, target);

    if(logger)
        logger->logReturn();

    return rv;
}
Пример #4
0
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
  return NPNFuncs.geturl(instance, url, target);
}
Пример #5
0
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
    NPError rv = NPNFuncs.geturl(instance, url, target);
    return rv;
}
Пример #6
0
LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
    NPP instance = (NPP)GetWindowLongPtr(hWnd, GWLP_USERDATA);
    
    if (uiMsg == WM_PAINT)
    {
        InstanceData *data = (InstanceData *)instance->pdata;
        
        PAINTSTRUCT ps;
        HDC hDC = BeginPaint(hWnd, &ps);
        HBRUSH brushBg = CreateSolidBrush(COL_WINDOW_BG);
        HFONT hFont = GetSimpleFont(hDC, L"MS Shell Dlg", 14);
        bool isRtL = IsLanguageRtL(gTranslationIdx);
        
        // set up double buffering
        RectI rcClient = ClientRect(hWnd);
        DoubleBuffer buffer(hWnd, rcClient);
        HDC hDCBuffer = buffer.GetDC();
        
        // display message centered in the window
        RECT rectClient = rcClient.ToRECT();
        FillRect(hDCBuffer, &rectClient, brushBg);
        hFont = (HFONT)SelectObject(hDCBuffer, hFont);
        SetTextColor(hDCBuffer, RGB(0, 0, 0));
        SetBkMode(hDCBuffer, TRANSPARENT);
        DrawCenteredText(hDCBuffer, rcClient, data->message, isRtL);
        
        // draw a progress bar, if a download is in progress
        if (0 < data->progress && data->progress <= 1)
        {
            SIZE msgSize;
            RectI rcProgress = rcClient;
            
            HBRUSH brushProgress = CreateSolidBrush(RGB(0x80, 0x80, 0xff));
            GetTextExtentPoint32(hDCBuffer, data->message, (int)str::Len(data->message), &msgSize);
            rcProgress.Inflate(-(rcProgress.dx - msgSize.cx) / 2, -(rcProgress.dy - msgSize.cy) / 2 + 2);
            rcProgress.Offset(0, msgSize.cy + 4 + 2);
            RECT rectProgress = rcProgress.ToRECT();
            FillRect(hDCBuffer, &rectProgress, GetStockBrush(WHITE_BRUSH));
            RectI rcProgressAll = rcProgress;
            rcProgress.dx = (int)(data->progress * rcProgress.dx);
            rectProgress = rcProgress.ToRECT();
            FillRect(hDCBuffer, &rectProgress, brushProgress);
            DeleteObject(brushProgress);
            
            ScopedMem<WCHAR> currSize(FormatSizeSuccint(data->currSize));
            if (0 == data->totalSize || data->currSize > data->totalSize)
            {
                // total size unknown or bogus => show just the current size
                DrawCenteredText(hDCBuffer, rcProgressAll, currSize, isRtL);
            }
            else
            {
                ScopedMem<WCHAR> totalSize(FormatSizeSuccint(data->totalSize));
                ScopedMem<WCHAR> s(str::Format(_TR("%s of %s"), currSize, totalSize));
                DrawCenteredText(hDCBuffer, rcProgressAll, s, isRtL);
            }
        }
        
        // draw the buffer on screen
        buffer.Flush(hDC);
        
        DeleteObject(SelectObject(hDCBuffer, hFont));
        DeleteObject(brushBg);
        EndPaint(hWnd, &ps);
        
        HWND hChild = FindWindowEx(hWnd, NULL, NULL, NULL);
        if (hChild)
            InvalidateRect(hChild, NULL, FALSE);
    }
    else if (uiMsg == WM_SIZE)
    {
        HWND hChild = FindWindowEx(hWnd, NULL, NULL, NULL);
        if (hChild)
        {
            ClientRect rcClient(hWnd);
            MoveWindow(hChild, rcClient.x, rcClient.y, rcClient.dx, rcClient.dy, FALSE);
        }
    }
    else if (uiMsg == WM_COPYDATA)
    {
        COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam;
        if (cds && 0x4C5255 /* URL */ == cds->dwData)
        {
            plogf("sp: NPN_GetURL %s", cds->dwData, (const char *)cds->lpData);
            gNPNFuncs.geturl(instance, (const char *)cds->lpData, "_blank");
            return TRUE;
        }
    }
    
    return DefWindowProc(hWnd, uiMsg, wParam, lParam);
}
Пример #7
0
void StBrowserPlugin::doLoadFullSize() {
    if(!myFullUrl.isEmpty() && NPNFuncs.geturl != NULL) {
        myToLoadFull = true;
        NPNFuncs.geturl(nppInstance, myFullUrl.toCString(), NULL);
    }
}