Setup UI menu code
This commit is contained in:
@@ -9,12 +9,29 @@
|
||||
|
||||
#include "xenia/ui/win32/win32_menu_item.h"
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace win32 {
|
||||
|
||||
Win32MenuItem::Win32MenuItem(Type type, int id, const std::wstring& text)
|
||||
: id_(id), MenuItem(type, text) {
|
||||
switch (type) {
|
||||
case MenuItem::Type::kNormal:
|
||||
handle_ = CreateMenu();
|
||||
break;
|
||||
case MenuItem::Type::kPopup:
|
||||
handle_ = CreatePopupMenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Win32MenuItem::Win32MenuItem(Type type)
|
||||
: MenuItem(type), handle_(CreateMenu()) {}
|
||||
: Win32MenuItem(type, 0, L"") {}
|
||||
|
||||
Win32MenuItem::Win32MenuItem(Type type, const std::wstring& text)
|
||||
: Win32MenuItem(type, 0, text) {}
|
||||
|
||||
Win32MenuItem::~Win32MenuItem() {
|
||||
if (handle_) {
|
||||
@@ -24,7 +41,20 @@ Win32MenuItem::~Win32MenuItem() {
|
||||
|
||||
void Win32MenuItem::OnChildAdded(MenuItem* generic_child_item) {
|
||||
auto child_item = static_cast<Win32MenuItem*>(generic_child_item);
|
||||
//
|
||||
|
||||
switch (child_item->type()) {
|
||||
case MenuItem::Type::kPopup:
|
||||
AppendMenuW(handle_, MF_POPUP, (UINT)child_item->handle(),
|
||||
child_item->text().c_str());
|
||||
break;
|
||||
case MenuItem::Type::kSeparator:
|
||||
AppendMenuW(handle_, MF_SEPARATOR, child_item->id(), 0);
|
||||
break;
|
||||
case MenuItem::Type::kString:
|
||||
AppendMenuW(handle_, MF_STRING, child_item->id(),
|
||||
child_item->text().c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Win32MenuItem::OnChildRemoved(MenuItem* generic_child_item) {
|
||||
|
||||
Reference in New Issue
Block a user