combo-button-item.cpp 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #if defined(Hiro_ComboButton)
  2. namespace hiro {
  3. auto pComboButtonItem::construct() -> void {
  4. }
  5. auto pComboButtonItem::destruct() -> void {
  6. }
  7. auto pComboButtonItem::setIcon(const image& icon) -> void {
  8. //unsupported
  9. }
  10. auto pComboButtonItem::setSelected() -> void {
  11. if(auto parent = _parent()) {
  12. parent->lock();
  13. SendMessage(parent->hwnd, CB_SETCURSEL, self().offset(), 0);
  14. parent->unlock();
  15. }
  16. }
  17. auto pComboButtonItem::setText(const string& text) -> void {
  18. if(auto parent = _parent()) {
  19. parent->lock();
  20. SendMessage(parent->hwnd, CB_DELETESTRING, self().offset(), 0);
  21. SendMessage(parent->hwnd, CB_INSERTSTRING, self().offset(), (LPARAM)(wchar_t*)utf16_t(state().text));
  22. if(state().selected) setSelected();
  23. parent->unlock();
  24. }
  25. }
  26. auto pComboButtonItem::_parent() -> maybe<pComboButton&> {
  27. if(auto parent = self().parentComboButton()) {
  28. if(auto self = parent->self()) return *self;
  29. }
  30. return nothing;
  31. }
  32. }
  33. #endif