UIMultiItem.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // Copyright (c) 2014-2017, THUNDERBEAST GAMES LLC All rights reserved
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include <TurboBadger/tb_widgets.h>
  24. #include <TurboBadger/tb_select_item.h>
  25. #include <TurboBadger/tb_atomic_widgets.h>
  26. #include "../Core/Object.h"
  27. #include "../Container/List.h"
  28. #include "../IO/Log.h"
  29. #include "UISelectItem.h"
  30. namespace Atomic
  31. {
  32. class UIMultiItemSource;
  33. class ATOMIC_API UIMultiItem : public UISelectItem
  34. {
  35. ATOMIC_OBJECT(UIMultiItem, UISelectItem )
  36. public:
  37. UIMultiItem(Context* context, const String& colid,const String& widgettype, const String& str, int colwidth, int colheight );
  38. virtual ~UIMultiItem();
  39. void SetID(const String& id);
  40. tb::TBID GetID() { return id_; }
  41. void AddColumn ( const String& widgettype, const String& str, int colwidth );
  42. const String& GetColumnStr( int col );
  43. const String& GetColumnWidget( int col );
  44. int GetColumnWidth( int col );
  45. int GetNumColumns();
  46. virtual tb::MultiItem * GetTBItem();
  47. protected:
  48. tb::TBID id_; // TBID
  49. Vector <String> colStr_;
  50. Vector <String> colWidget_;
  51. Vector <int> colWidth_;
  52. int colHeight_;
  53. };
  54. class ATOMIC_API UIMultiItemSource : public UISelectItemSource
  55. {
  56. ATOMIC_OBJECT(UIMultiItemSource, UISelectItemSource )
  57. public:
  58. UIMultiItemSource(Context* context);
  59. virtual ~UIMultiItemSource();
  60. void AddItem(UIMultiItem* item) { items_.Push(SharedPtr<UIMultiItem>(item)); }
  61. void RemoveItemWithId(const String& id);
  62. void RemoveItemWithStr(const String& str);
  63. int GetItemCount() { return items_.Size(); }
  64. void Clear() { items_.Clear(); }
  65. /// Returns item string for the index. Returns empty string for invalid indexes.
  66. const String& GetItemStr(int index);
  67. // caller's responsibility to clean up
  68. virtual tb::MultiItemSource* GetTBItemSource();
  69. protected:
  70. List<SharedPtr<UIMultiItem>> items_;
  71. };
  72. }