selpane.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #include "pch.h"
  2. #include "trekmdl.h"
  3. #include "consoledata.h"
  4. //////////////////////////////////////////////////////////////////////////////
  5. //
  6. // SelectModelPane
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. class SelectModelPane : public ValuePane
  10. {
  11. private:
  12. TRef<ModelData> m_pmodelData;
  13. public:
  14. SelectModelPane(Pane* ppaneChild, ModelData* pmodelData) :
  15. ValuePane(ppaneChild),
  16. m_pmodelData(pmodelData)
  17. {
  18. }
  19. void UpdateLayout()
  20. {
  21. if (Child()) {
  22. InternalSetExpand(
  23. Child(),
  24. WinPoint(
  25. XExpand() == 0 ? 0 : XExpand(),
  26. YExpand() == 0 ? 0 : YExpand()
  27. )
  28. );
  29. Child()->UpdateLayout();
  30. InternalSetSize(WinPoint(
  31. Child()->XSize(),
  32. Child()->YSize()
  33. ));
  34. InternalSetOffset(Child(), WinPoint(0, 0));
  35. } else {
  36. InternalSetSize(
  37. WinPoint(
  38. max(0, XExpand()),
  39. max(0, YExpand())
  40. )
  41. );
  42. }
  43. }
  44. MouseResult Button(IInputProvider* pprovider, const Point& point, int button, bool bCaptured, bool bInside, bool bDown)
  45. {
  46. return MouseResult();
  47. }
  48. };
  49. TRef<IObject> SelectModelPaneFactory::Apply(ObjectStack& stack)
  50. {
  51. TRef<Pane> ppaneChild; CastTo(ppaneChild, (IObject*)stack.Pop());
  52. TRef<ModelData> pmodelData; CastTo(pmodelData, (IObject*)stack.Pop());
  53. return (Pane*)new SelectModelPane(ppaneChild, pmodelData);
  54. }
  55. //////////////////////////////////////////////////////////////////////////////
  56. //
  57. // SelectionPane
  58. //
  59. //////////////////////////////////////////////////////////////////////////////
  60. class SelectionPane : public ValuePane, public EventTargetContainer<SelectionPane>
  61. {
  62. private:
  63. TRef<RowPane> m_prowPane;
  64. public:
  65. SelectionPane(IEventSource* peventSourceOnSelChange)
  66. {
  67. InsertAtBottom(m_prowPane = new RowPane());
  68. AddEventTarget(OnSelChange, peventSourceOnSelChange);
  69. }
  70. bool OnSelChange()
  71. {
  72. return true;
  73. }
  74. void UpdateLayout()
  75. {
  76. DefaultUpdateLayout();
  77. }
  78. };
  79. TRef<IObject> SelectionPaneFactory::Apply(ObjectStack& stack)
  80. {
  81. TRef<IEventSource> peventSourceOnSelChange; CastTo(peventSourceOnSelChange, (IObject*)stack.Pop());
  82. return (Pane*) new SelectionPane(peventSourceOnSelChange);
  83. }