void NewTerrainWindow::addDropdownListPair(const std::string& name, std::vector<UINT> listData) { const UINT count = (UINT)m_items.size(); const UINT width = 2 * m_dropdownListWidth + m_itemMargin; UINT x = m_itemMargin; UINT y = (count / 2) * (m_dropdownListTextSize + m_dropdownListHeight + m_itemMargin) + m_itemMargin; const UINT id = m_itemIDStart + count; const UINT dropdownListHeight = 200; HWND hText = CreateWindow("STATIC", name.c_str(), WS_VISIBLE | WS_CHILD, x, y, width, m_dropdownListTextSize, m_hWnd, NULL, m_hInstance, NULL); HFONT hFont = CreateFont(m_dropdownListTextSize, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma"); SendMessage(hText, WM_SETFONT, (WPARAM)hFont, TRUE); y += m_dropdownListTextSize; HWND hDropdownList1 = CreateWindow("COMBOBOX", "", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | CBS_DROPDOWNLIST, x, y, m_dropdownListWidth, dropdownListHeight, m_hWnd, (HMENU)id, m_hInstance, NULL); x += m_dropdownListWidth + m_itemMargin; HWND hDropdownList2 = CreateWindow("COMBOBOX", "", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | CBS_DROPDOWNLIST, x, y, m_dropdownListWidth, dropdownListHeight, m_hWnd, (HMENU)(id + 1), m_hInstance, NULL); hFont = CreateFont(14, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma"); SendMessage(hDropdownList1, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hDropdownList2, WM_SETFONT, (WPARAM)hFont, TRUE); m_items.push_back(EventElement(name, nullptr)); m_items.push_back(EventElement(name, nullptr)); for (std::vector<UINT>::iterator it = listData.begin(); it != listData.end(); it++) { std::string element = std::to_string((long double)(*it)); ComboBox_AddString(hDropdownList1, element.c_str()); ComboBox_AddString(hDropdownList2, element.c_str()); if (it == listData.begin()) { ComboBox_SelectString(hDropdownList1, -1, element.c_str()); ComboBox_SelectString(hDropdownList2, -1, element.c_str()); } } m_clientHeight += m_dropdownListTextSize + m_dropdownListHeight + m_itemMargin; const POINT windowSize = getWindowSize(); const POINT windowPosition = getWindowPosition(); SetWindowPos(m_hWnd, HWND_TOP, windowPosition.x, windowPosition.y, windowSize.x, windowSize.y, NULL); }
Menu::Menu(){ evn = new Events(); eng = new Engine(); gra = new Graphic(600, 600); eng->setWindowTitle("BlockEraser 2"); std::function<void(Position)> newGameHandler = [this](Position e){ this->runGame(); }; evn->addEvent(EventElement(Position(250, 375, 200, 230), newGameHandler )); std::function<void(Position)> aboutGameHandler = [this](Position e){ this->drawAboutMenu(); }; evn->addEvent(EventElement(Position(250, 475, 200, 430), aboutGameHandler )); }
void TrackbarWindow::addTrackbar(const std::string& name, EventReceiver* eventReceiver, const UINT minValue, const UINT maxValue, const UINT startValue) { const UINT count = (UINT)m_items.size(); const UINT width = m_trackbarSize.x; const UINT height = m_trackbarSize.y; const UINT x = m_trackbarMargin; UINT y = count * (height + m_trackbarMargin + m_trackbarTextSize) + m_trackbarMargin; const UINT id = m_itemIDStart + count; HWND hText = CreateWindow("STATIC", name.c_str(), WS_VISIBLE | WS_CHILD, x, y, width, m_trackbarTextSize, m_hWnd, NULL, m_hInstance, NULL); HFONT hFont = CreateFont(m_trackbarTextSize, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma"); SendMessage(hText, WM_SETFONT, (WPARAM)hFont, TRUE); y += m_trackbarTextSize; HWND hTrackbar = CreateWindow(TRACKBAR_CLASS, NULL, WS_CHILD | WS_VISIBLE | TBS_TOOLTIPS, x, y, width, height, m_hWnd, (HMENU)id, m_hInstance, NULL); SendMessage(hTrackbar, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(minValue, maxValue)); SendMessage(hTrackbar, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)startValue); m_items.push_back(EventElement(name, eventReceiver)); m_clientHeight += height + m_trackbarTextSize + m_trackbarMargin; const POINT windowSize = getWindowSize(); const POINT windowPosition = getWindowPosition(); SetWindowPos(m_hWnd, HWND_TOP, windowPosition.x, windowPosition.y, windowSize.x, windowSize.y, NULL); }
void TextureToolWindow::addLoadFileButton(const std::string& name, EventReceiver* eventReceiver) { const UINT count = (UINT)m_items.size(); const UINT width = m_clientWidth - 2 * m_itemMargin; const UINT x = m_itemMargin; const UINT y = m_textureButtonSize + 2 * m_itemMargin; const UINT id = m_itemIDStart + count; HWND hButton = CreateWindow("BUTTON", name.c_str(), WS_CHILD | WS_VISIBLE | BS_PUSHLIKE, x, y, width, m_loadFileButtonHeight, m_hWnd, (HMENU)id, m_hInstance, NULL); HFONT hFont = CreateFont(m_loadFileButtonTextSize, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma"); SendMessage(hButton, WM_SETFONT, (WPARAM)hFont, TRUE); m_items.push_back(EventElement(name, eventReceiver)); if (y >= m_clientHeight) { m_clientHeight = m_textureButtonSize + m_loadFileButtonHeight + 3 * m_itemMargin; const POINT windowSize = getWindowSize(); const POINT windowPosition = getWindowPosition(); SetWindowPos(m_hWnd, HWND_TOP, windowPosition.x, windowPosition.y, windowSize.x, windowSize.y, NULL); } }
void TextureToolWindow::addTextureButton(const std::string& name, EventReceiver* eventReceiver, const std::string& bitmapFilename) { const UINT count = (UINT)m_items.size(); const UINT x = (count % m_textureButtonsPerRow) * (m_textureButtonSize + m_itemMargin) + m_itemMargin; const UINT y = m_itemMargin; const UINT id = m_itemIDStart + count; HWND hButton = CreateWindow("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_BITMAP | BS_PUSHLIKE, x, y, m_textureButtonSize, m_textureButtonSize, m_hWnd, (HMENU)id, m_hInstance, NULL); HBITMAP hBitmap = (HBITMAP)LoadImage(m_hInstance, bitmapFilename.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); SendMessage(hButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmap); m_items.push_back(EventElement(name, eventReceiver)); m_checkableButtonIDs.push_back(id); if (y >= m_clientHeight) { m_clientHeight = m_textureButtonSize + 2 * m_itemMargin; const POINT windowSize = getWindowSize(); const POINT windowPosition = getWindowPosition(); SetWindowPos(m_hWnd, HWND_TOP, windowPosition.x, windowPosition.y, windowSize.x, windowSize.y, NULL); } if (count <= 0) Button_SetState(GetDlgItem(m_hWnd, id), true); }