2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_MenuItem)
|
|
|
|
|
|
|
|
namespace hiro {
|
|
|
|
|
|
|
|
auto pMenuItem::construct() -> void {
|
|
|
|
_createBitmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pMenuItem::destruct() -> void {
|
|
|
|
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
|
|
|
|
}
|
|
|
|
|
2016-01-07 08:14:33 +00:00
|
|
|
auto pMenuItem::setIcon(const image& icon) -> void {
|
2015-06-12 13:14:38 +00:00
|
|
|
_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; }
|
|
|
|
|
2016-01-07 08:14:33 +00:00
|
|
|
if(auto icon = state().icon) {
|
2015-06-12 13:14:38 +00:00
|
|
|
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
|