9#pragma warning(disable: 4018)
10#pragma warning(disable: 4267)
12#pragma push_macro("min")
13#pragma push_macro("max")
23 if (message == WM_COMMAND &&
id == LOWORD(wparam))
25 switch (HIWORD(wparam))
65 standard_classes::comboBox,
74 parent ? parent->getHandle() : nullptr,
84 LRESULT result = SendMessageW(
handle, CB_ADDSTRING, NULL,
reinterpret_cast<LPARAM
>(value.data()));
90 else if (result == CB_ERRSPACE)
104 for (
const wstring& value : values)
114 LRESULT result = SendMessageW(
handle, CB_DELETESTRING, index, NULL);
116 if (result == CB_ERR)
128 LRESULT result = SendMessageW(
handle, CB_INSERTSTRING, index,
reinterpret_cast<LPARAM
>(value.data()));
130 if (result == CB_ERR)
134 else if (result == CB_ERRSPACE)
146 LRESULT result = SendMessageW(
handle, CB_SETITEMDATA, index,
reinterpret_cast<LPARAM
>(newValue.data()));
148 if (result == CB_ERR)
160 LRESULT findedIndex = SendMessageW(
handle, CB_FINDSTRING, 0,
reinterpret_cast<LPARAM
>(substringToFind.data()));
162 if (findedIndex == CB_ERR)
172 LRESULT findedIndex = SendMessageW(
handle, CB_FINDSTRINGEXACT, 0,
reinterpret_cast<LPARAM
>(stringToFind.data()));
174 if (findedIndex == CB_ERR)
185 LRESULT
size = SendMessageW(
handle, CB_GETLBTEXTLEN, index, NULL);
192 result.resize(++
size);
194 LRESULT errorCode = SendMessageW(
handle, CB_GETLBTEXT, index,
reinterpret_cast<LPARAM
>(result.data()));
196 if (errorCode == CB_ERR)
208 return SendMessageW(
handle, CB_GETCURSEL, NULL, NULL);
213 LRESULT result = SendMessageW(
handle, CB_SETCURSEL, index, NULL);
215 if (result == CB_ERR)
225 LRESULT result = SendMessageW(
handle, CB_GETCOUNT, NULL, NULL);
227 if (result == CB_ERR)
237 SendMessageW(
handle, CB_RESETCONTENT, NULL, NULL);
243 SetWindowLongPtrW(
handle, GWL_STYLE, GetWindowLongPtrW(
handle, GWL_STYLE) | CBS_SORT) :
244 SetWindowLongPtrW(
handle, GWL_STYLE, GetWindowLongPtrW(
handle, GWL_STYLE) ^ CBS_SORT);
249 LRESULT result = SendMessageW(
handle, CB_SETITEMHEIGHT,
static_cast<WPARAM
>(value), height);
251 if (result == CB_ERR)
261 LRESULT result = SendMessageW(
handle, CB_SETDROPPEDWIDTH, width, NULL);
263 if (result == CB_ERR)
282 const HMODULE& module = instance.getModules().at(
moduleName);
288 throw exceptions::CantFindFunctionFromModuleException(
functionName,
moduleName, __FILE__, __FUNCTION__, __LINE__);
299 LRESULT result = SendMessageW(
handle, CB_GETITEMHEIGHT,
static_cast<WPARAM
>(value), NULL);
301 if (result == CB_ERR)
311 LRESULT result = SendMessageW(
handle, CB_GETDROPPEDWIDTH, NULL, NULL);
313 if (result == CB_ERR)
325 LRESULT currentSize = this->
size();
326 HDC deviceContext = GetDC(
handle);
329 if (currentSize == CB_ERR || !currentSize)
331 double widthCoefficient =
static_cast<double>(width) /
parentWidth;
336 static_cast<int>(
desiredX * widthCoefficient),
343 ShowWindow(
handle, SW_SHOW);
348 for (
size_t i = 0; i < currentSize; i++)
353 if (GetTextExtentPoint32W(deviceContext, value.data(), value.size(), &valueSizes))
365 heightSum += valueSizes.cy;
381 ShowWindow(
handle, SW_SHOW);
397 using json::utility::jsonObject;
399 uint32_t codepage = ISerializable::getCodepage();
402 vector<jsonObject> values;
403 LRESULT currentSize = this->
size();
405 if (functionName.size())
407 current.data.push_back({
"functionName"s,
functionName });
409 current.data.push_back({
"moduleName"s,
moduleName });
416 for (
size_t i = 0; i < static_cast<size_t>(currentSize); i++)
421 current.data.push_back({
"comboBoxValues"s, move(values) });
428#pragma pop_macro("min")
429#pragma pop_macro("max")
Base class for all combo boxes.
std::function< void(BaseComboBox &)> onSelectionChange
LRESULT setDroppedWidth(uint16_t width)
void setOnSelectionChange(const std::function< void(BaseComboBox &)> &onSelectionChange)
Set callback function with on selection change event.
LRESULT addValue(const std::wstring &value)
virtual LRESULT insertValue(const std::wstring &value, LRESULT index)
std::wstring getValue(size_t index) const
LRESULT setCurrentSelection(LRESULT index) const
virtual json::JSONBuilder getStructure() const override
virtual void resize(uint16_t width, uint16_t height) override
virtual LRESULT changeValue(const std::wstring &newValue, LRESULT index)
virtual LRESULT windowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed) final override
BaseComboBox(const std::wstring &comboBoxName, const utility::ComponentSettings &settings, const styles::ComboBoxStyles &styles, BaseComposite *parent)
LRESULT addValues(const std::vector< std::wstring > &values)
LRESULT getDroppedWidth() const
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) final override
Not implemented.
void setSortingMode(bool isSorting)
virtual void setTextColor(uint8_t red, uint8_t green, uint8_t blue) final override
Not implemented.
static void loadOnSelectionChangeFromModule(std::function< void(BaseComboBox &)> &onSelectionChange, const std::string &functionName, const std::string &moduleName)
Load function from module.
LRESULT findSubstring(const std::wstring &substringToFind)
Find not case sensitive substring.
LRESULT findString(const std::wstring &stringToFind)
Find not case sensitive string.
LRESULT removeValue(size_t index)
LRESULT getItemHeight(itemHeightEnum value) const
LRESULT setItemHeight(itemHeightEnum value, uint16_t height)
LRESULT getCurrentSelectionIndex() const
Base class for all windows, controls, etc.
virtual json::JSONBuilder getStructure() const override
uint16_t getActualHeight() const
const std::wstring windowName
uint16_t getActualWidth() const
Base class for all windows that has children windows.
Singleton with GUIFramework settings and some functionality.
const std::unordered_map< std::string, std::string > & getModulesPaths() const
Get all loaded modules paths.
const std::unordered_map< std::string, HMODULE, localization::utility::StringViewHash, localization::utility::StringViewEqual > & getModules() const
Get all loaded modules.
static GUIFramework & get()
Singleton instance access.
Throws by setOn... methods.
Exception for all list classes exceptions.
Base class for combo box styles.
void throwNotImplementedException(string_view methodName, string_view className)
constexpr std::string_view notEnoughSpace
constexpr uint16_t comboBoxAdditionalWidth
string to_string(wstring_view stringToConvert, uint32_t codepage)
void(*)(BaseComboBox &) comboBoxCallbackSignature
Used in notification events in combo box.
All settings for windows.