bsnes/hiro/windows/action/menu-item.cpp
byuu 903d1e4012 v107.8
* GB: integrated SameBoy v0.12.1 by Lior Halphon
* SFC: added HG51B169 (Cx4) math tables into bsnes binary
2019-07-17 21:11:46 +09:00

38 lines
854 B
C++
Executable file

#if defined(Hiro_MenuItem)
namespace hiro {
auto pMenuItem::construct() -> void {
_createBitmap();
}
auto pMenuItem::destruct() -> void {
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
}
auto pMenuItem::setIcon(const image& icon) -> 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 icon = state().icon) {
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