mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
Add some initial widget functionality (prefs partly working)
This commit is contained in:
49
PortabilityLayer/PLIconWidget.cpp
Normal file
49
PortabilityLayer/PLIconWidget.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "PLIconWidget.h"
|
||||
|
||||
#include "IconLoader.h"
|
||||
#include "QDPixMap.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
IconWidget::IconWidget(const WidgetBasicState &state)
|
||||
: WidgetSpec<IconWidget>(state)
|
||||
{
|
||||
}
|
||||
|
||||
IconWidget::~IconWidget()
|
||||
{
|
||||
if (m_iconImage)
|
||||
PixMapImpl::Destroy(m_iconImage);
|
||||
if (m_iconMask)
|
||||
PixMapImpl::Destroy(m_iconMask);
|
||||
}
|
||||
|
||||
bool IconWidget::Init(const WidgetBasicState &state)
|
||||
{
|
||||
PL_DEAD(str);
|
||||
|
||||
THandle<PixMapImpl> colorImage;
|
||||
THandle<PixMapImpl> bwImage;
|
||||
THandle<PixMapImpl> maskImage;
|
||||
|
||||
if (!PortabilityLayer::IconLoader::GetInstance()->LoadColorIcon(state.m_resID, colorImage, bwImage, maskImage))
|
||||
return false;
|
||||
|
||||
PixMapImpl::Destroy(bwImage);
|
||||
m_iconImage = colorImage;
|
||||
m_iconMask = maskImage;
|
||||
|
||||
assert(m_iconImage != nullptr);
|
||||
assert(m_iconMask != nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IconWidget::DrawControl(DrawSurface *surface)
|
||||
{
|
||||
CopyMask(*m_iconImage, *m_iconMask, *surface->m_port.GetPixMap(), &(*m_iconImage)->m_rect, &(*m_iconMask)->m_rect, &m_rect);
|
||||
surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user