nim_duilib/ui_components/cef_control/control/cef_control.cpp
jiajia_deng ad9a6b3edc Modified the namespace of the UI component
Signed-off-by: jiajia_deng <2894220@gmail.com>
2019-09-22 11:08:20 +08:00

54 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "stdafx.h"
#include "cef_control.h"
#include "cef_control/util/util.h"
namespace nim_comp {
void CefControl::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type, const CefRenderHandler::RectList& dirtyRects, const std::string* buffer, int width, int height)
{
if (NULL == buffer)
return;
if (type == PET_VIEW)
{
if (dc_cef_.GetWidth() != width || dc_cef_.GetHeight() != height)
dc_cef_.Init(m_pWindow->GetPaintDC(), width, height);
LPBYTE pDst = (LPBYTE)dc_cef_.GetBits();
if (pDst)
memcpy(pDst, (char*)buffer->c_str(), height * width * 4);
}
else if (type == PET_POPUP && dc_cef_.IsValid() && rect_popup_.width > 0 && rect_popup_.height > 0)
{
// 单独保存popup窗口的位图
if (dc_cef_popup_.GetWidth() != width || dc_cef_popup_.GetHeight() != height)
dc_cef_popup_.Init(m_pWindow->GetPaintDC(), width, height);
LPBYTE pDst = (LPBYTE)dc_cef_popup_.GetBits();
if (pDst)
memcpy(pDst, (char*)buffer->c_str(), width * height * 4);
}
this->Invalidate();
}
void CefControl::OnPopupShow(CefRefPtr<CefBrowser> browser, bool show)
{
if (!show)
{
// 当popup窗口隐藏时刷新popup区域
CefRect rect_dirty = rect_popup_;
rect_popup_.Set(0, 0, 0, 0);
browser->GetHost()->Invalidate(PET_VIEW);
}
}
void CefControl::OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect)
{
if (rect.width <= 0 || rect.height <= 0)
return;
rect_popup_ = rect;
}
}