mirror of https://github.com/bsnes-emu/bsnes.git
42 lines
989 B
C++
42 lines
989 B
C++
#if defined(Hiro_MenuItem)
|
|
|
|
namespace hiro {
|
|
|
|
auto pMenuItem::construct() -> void {
|
|
_createBitmap();
|
|
}
|
|
|
|
auto pMenuItem::destruct() -> void {
|
|
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
|
|
}
|
|
|
|
auto pMenuItem::setImage(const Image& image) -> void {
|
|
_createBitmap();
|
|
_synchronize();
|
|
}
|
|
|
|
auto pMenuItem::setText(const string& text) -> void {
|
|
_synchronize();
|
|
}
|
|
|
|
auto pMenuItem::onActivate() -> void {
|
|
self().doActivate();
|
|
}
|
|
|
|
auto pMenuItem::_createBitmap() -> void {
|
|
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
|
|
|
|
if(auto& image = state().image) {
|
|
nall::image icon;
|
|
icon.allocate(image.width(), image.height());
|
|
memory::copy(icon.data(), image.data(), icon.size());
|
|
icon.alphaBlend(GetSysColor(COLOR_MENU)); //Windows does not alpha blend menu icons properly (leaves black outline)
|
|
icon.scale(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK), Interpolation::Linear);
|
|
hbitmap = CreateBitmap(icon);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|