PageRenderTime 54ms CodeModel.GetById 40ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llscrolllistcolumn.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 172 lines | 111 code | 26 blank | 35 comment | 0 complexity | 4b2992e013fd3684ed961c09fe875315 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llscrollcolumnheader.h
  3. * @brief Scroll lists are composed of rows (items), each of which
  4. * contains columns (cells).
  5. *
  6. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #ifndef LLSCROLLLISTCOLUMN_H
  28. #define LLSCROLLLISTCOLUMN_H
  29. #include "llrect.h"
  30. #include "lluistring.h"
  31. #include "llbutton.h"
  32. #include "llinitparam.h"
  33. class LLScrollListColumn;
  34. class LLResizeBar;
  35. class LLScrollListCtrl;
  36. class LLScrollColumnHeader : public LLButton
  37. {
  38. public:
  39. struct Params : public LLInitParam::Block<Params, LLButton::Params>
  40. {
  41. Mandatory<LLScrollListColumn*> column;
  42. Params();
  43. };
  44. LLScrollColumnHeader(const Params&);
  45. ~LLScrollColumnHeader();
  46. /*virtual*/ void draw();
  47. /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  48. /*virtual*/ LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding);
  49. /*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false);
  50. LLScrollListColumn* getColumn() { return mColumn; }
  51. void setHasResizableElement(BOOL resizable);
  52. void updateResizeBars();
  53. BOOL canResize();
  54. void enableResizeBar(BOOL enable);
  55. void onClick(const LLSD& data);
  56. private:
  57. LLScrollListColumn* mColumn;
  58. LLResizeBar* mResizeBar;
  59. BOOL mHasResizableElement;
  60. };
  61. /*
  62. * A simple data class describing a column within a scroll list.
  63. */
  64. class LLScrollListColumn
  65. {
  66. public:
  67. typedef enum e_sort_direction
  68. {
  69. DESCENDING,
  70. ASCENDING
  71. } ESortDirection;
  72. struct SortNames
  73. : public LLInitParam::TypeValuesHelper<LLScrollListColumn::ESortDirection, SortNames>
  74. {
  75. static void declareValues();
  76. };
  77. struct Params : public LLInitParam::Block<Params>
  78. {
  79. Optional<std::string> name,
  80. tool_tip;
  81. Optional<std::string> sort_column;
  82. Optional<ESortDirection, SortNames> sort_direction;
  83. Optional<bool> sort_ascending;
  84. struct Width : public LLInitParam::ChoiceBlock<Width>
  85. {
  86. Alternative<bool> dynamic_width;
  87. Alternative<S32> pixel_width;
  88. Alternative<F32> relative_width;
  89. Width()
  90. : dynamic_width("dynamic_width", false),
  91. pixel_width("width"),
  92. relative_width("relative_width", -1.f)
  93. {
  94. addSynonym(relative_width, "relwidth");
  95. }
  96. };
  97. Optional<Width> width;
  98. // either an image or label is used in column header
  99. struct Header : public LLInitParam::ChoiceBlock<Header>
  100. {
  101. Alternative<std::string> label;
  102. Alternative<LLUIImage*> image;
  103. Header()
  104. : label("label"),
  105. image("image")
  106. {}
  107. };
  108. Optional<Header> header;
  109. Optional<LLFontGL::HAlign> halign;
  110. Params()
  111. : name("name"),
  112. tool_tip("tool_tip"),
  113. sort_column("sort_column"),
  114. sort_direction("sort_direction"),
  115. sort_ascending("sort_ascending", true),
  116. halign("halign", LLFontGL::LEFT)
  117. {
  118. // default choice to "dynamic_width"
  119. changeDefault(width.dynamic_width, true);
  120. addSynonym(sort_column, "sort");
  121. }
  122. };
  123. static const Params& getDefaultParams();
  124. //NOTE: this is default constructible so we can store it in a map.
  125. LLScrollListColumn(const Params& p = getDefaultParams(), LLScrollListCtrl* = NULL);
  126. void setWidth(S32 width);
  127. S32 getWidth() const { return mWidth; }
  128. public:
  129. // Public data is fine so long as this remains a simple struct-like data class.
  130. // If it ever gets any smarter than that, these should all become private
  131. // with protected or public accessor methods added as needed. -MG
  132. std::string mName;
  133. std::string mSortingColumn;
  134. ESortDirection mSortDirection;
  135. LLUIString mLabel;
  136. F32 mRelWidth;
  137. BOOL mDynamicWidth;
  138. S32 mMaxContentWidth;
  139. S32 mIndex;
  140. LLScrollListCtrl* mParentCtrl;
  141. LLScrollColumnHeader* mHeader;
  142. LLFontGL::HAlign mFontAlignment;
  143. private:
  144. S32 mWidth;
  145. };
  146. #endif