diff options
author | chai <chaifix@163.com> | 2021-10-17 11:14:00 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-17 11:14:00 +0800 |
commit | d35db57d457132dd9d83fa2bd51491b148530655 (patch) | |
tree | b5a29675f091f268577b5991988c723f273b0bd1 /Editor/GUI/MenuManager.cpp | |
parent | 7b0a6d1fe0117cf42a5776aaabda2db78599e5b8 (diff) |
*GUI
Diffstat (limited to 'Editor/GUI/MenuManager.cpp')
-rw-r--r-- | Editor/GUI/MenuManager.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Editor/GUI/MenuManager.cpp b/Editor/GUI/MenuManager.cpp new file mode 100644 index 0000000..53dfd5a --- /dev/null +++ b/Editor/GUI/MenuManager.cpp @@ -0,0 +1,61 @@ +//https://stackoverflow.com/questions/30135494/win32-api-c-menu-bar +//https://docs.microsoft.com/en-us/windows/win32/menurc/using-menus + +#include <string> + +#include "MenuManager.h" +#include "../EditorManager.h" + +const int IDM_FILE_NEW = 10; +const int IDM_ASSET = 20; + +using namespace std; + +MenuManager::MenuManager() + : m_Menus() +{ +} + +void MenuManager::Init() +{ + ContainnerWindow* mainWnd = EditorManager::Instance()->GetMainWindow(); + Assert(mainWnd != NULL); + + HMENU hMenubar = CreateMenu(); + + HMENU hMenu = CreateMenu(); + HMENU hSubMenu = CreatePopupMenu(); + HMENU asserMenu = CreateMenu(); + + AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW, L"&New"); + AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL); + + AppendMenuW(asserMenu, MF_STRING, IDM_ASSET, L"Import &mail &assets"); + AppendMenuW(hSubMenu, MF_STRING | MF_POPUP, (UINT_PTR)asserMenu, L"Import &mail"); + AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, L"&Import"); + + AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hMenu, L"&File"); + + AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW + 5, L"New 2"); + //InsertMenu(hMenu, 1, MF_SEPARATOR | MF_BYPOSITION, 0, NULL); + + SetMenu(mainWnd->GetWindowHandle(), hMenubar); + +} + +void MenuManager::AddMenuItem(std::string name, int order) +{ + log_info("Menu", " Add menu item \"" + name + "\""); + +} + +void MenuManager::HandleMenuItemEvent(HMENU menu, unsigned int menuId, unsigned int flags) +{ + log_info("Menu", "menuId=" + to_string(menuId) + ", flags=" + to_string(flags)); + + if (flags & MF_CHECKED) // clicked + { + log_info("Menu", "checked"); + + } +}
\ No newline at end of file |