From 124b4742e02b27441607a15c9f76e384a73b7052 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sat, 4 Oct 2025 03:33:53 -0400 Subject: [PATCH] [idd] helper: add mode edit controls --- idd/LGIddHelper/CConfigWindow.cpp | 14 ++++++++++- idd/LGIddHelper/CConfigWindow.h | 5 ++++ idd/LGIddHelper/CEditWidget.cpp | 36 +++++++++++++++++++++++++++++ idd/LGIddHelper/CEditWidget.h | 14 +++++++++++ idd/LGIddHelper/LGIddHelper.vcxproj | 2 ++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 idd/LGIddHelper/CEditWidget.cpp create mode 100644 idd/LGIddHelper/CEditWidget.h diff --git a/idd/LGIddHelper/CConfigWindow.cpp b/idd/LGIddHelper/CConfigWindow.cpp index 0adf7821..9963d533 100644 --- a/idd/LGIddHelper/CConfigWindow.cpp +++ b/idd/LGIddHelper/CConfigWindow.cpp @@ -1,6 +1,7 @@ #include "CConfigWindow.h" #include "CListBox.h" #include "CGroupBox.h" +#include "CEditWidget.h" #include #include #include @@ -55,6 +56,7 @@ void CConfigWindow::updateFont() for (HWND child : std::initializer_list({ *m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel, + *m_modeWidth, *m_modeHeight, *m_modeRefresh, })) SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1); } @@ -102,6 +104,10 @@ LRESULT CConfigWindow::onCreate() m_heightLabel.reset(new CStaticWidget(L"Height:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd)); m_refreshLabel.reset(new CStaticWidget(L"Refresh:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd)); + m_modeWidth.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd)); + m_modeHeight.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd)); + m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd)); + updateFont(); return 0; @@ -123,6 +129,9 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height) pos.pinBottomLeft(*m_widthLabel, 24, 72, 50, 20); pos.pinBottomLeft(*m_heightLabel, 24, 48, 50, 20); pos.pinBottomLeft(*m_refreshLabel, 24, 24, 50, 20); + pos.pinBottomLeft(*m_modeWidth, 75, 72, 50, 20); + pos.pinBottomLeft(*m_modeHeight, 75, 48, 50, 20); + pos.pinBottomLeft(*m_modeRefresh, 75, 24, 50, 20); return 0; } @@ -130,7 +139,10 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd) { if (hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes) { - DEBUG_INFO(L"Selection changed to: %s", (*m_modes)[m_modeBox->getSelData()].toString().c_str()); + auto &mode = (*m_modes)[m_modeBox->getSelData()]; + m_modeWidth->setNumericValue(mode.width); + m_modeHeight->setNumericValue(mode.height); + m_modeRefresh->setNumericValue(mode.refresh); } return 0; } diff --git a/idd/LGIddHelper/CConfigWindow.h b/idd/LGIddHelper/CConfigWindow.h index c83208d6..c652a024 100644 --- a/idd/LGIddHelper/CConfigWindow.h +++ b/idd/LGIddHelper/CConfigWindow.h @@ -10,6 +10,7 @@ class CListBox; class CGroupBox; +class CEditWidget; class CConfigWindow : public CWindow { @@ -23,6 +24,10 @@ class CConfigWindow : public CWindow std::unique_ptr m_heightLabel; std::unique_ptr m_refreshLabel; + std::unique_ptr m_modeWidth; + std::unique_ptr m_modeHeight; + std::unique_ptr m_modeRefresh; + std::function m_onDestroy; double m_scale; Microsoft::WRL::Wrappers::HandleT m_font; diff --git a/idd/LGIddHelper/CEditWidget.cpp b/idd/LGIddHelper/CEditWidget.cpp new file mode 100644 index 00000000..3aa311d8 --- /dev/null +++ b/idd/LGIddHelper/CEditWidget.cpp @@ -0,0 +1,36 @@ +#include "CEditWidget.h" +#include +#include +#include +#include + +CEditWidget::CEditWidget(DWORD style, HWND parent) +{ + m_hwnd = createWindowSimple(WC_EDIT, nullptr, style, parent, WS_EX_CLIENTEDGE); + if (!m_hwnd) + DEBUG_ERROR_HR(GetLastError(), "Failed to create edit control"); +} + +std::wstring CEditWidget::getValue() +{ + std::wstring result; + result.resize(Edit_GetTextLength(m_hwnd)); + Edit_GetText(m_hwnd, result.data(), result.size() + 1); + return result; +} + +int CEditWidget::getNumericValue() +{ + return std::stoi(getValue()); +} + +void CEditWidget::setValue(const std::wstring &value) +{ + if (!Edit_SetText(m_hwnd, value.c_str())) + DEBUG_ERROR("Failed to update text for edit control"); +} + +void CEditWidget::setNumericValue(int value) +{ + setValue(std::to_wstring(value)); +} diff --git a/idd/LGIddHelper/CEditWidget.h b/idd/LGIddHelper/CEditWidget.h new file mode 100644 index 00000000..ff62b7e1 --- /dev/null +++ b/idd/LGIddHelper/CEditWidget.h @@ -0,0 +1,14 @@ +#pragma once +#include "CWidget.h" +#include + +class CEditWidget : public CWidget +{ +public: + CEditWidget(DWORD style, HWND parent); + std::wstring getValue(); + int getNumericValue(); + + void setValue(const std::wstring &value); + void setNumericValue(int value); +}; diff --git a/idd/LGIddHelper/LGIddHelper.vcxproj b/idd/LGIddHelper/LGIddHelper.vcxproj index ae9ca051..20e1ca63 100644 --- a/idd/LGIddHelper/LGIddHelper.vcxproj +++ b/idd/LGIddHelper/LGIddHelper.vcxproj @@ -180,6 +180,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd + @@ -194,6 +195,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd +