WBPopupSlider.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #if !defined(AFX_WBPopupSliderButton_H__8B217F41_937B_11D1_8CA3_00A024CDC039__INCLUDED_)
  19. #define AFX_WBPopupSliderButton_H__8B217F41_937B_11D1_8CA3_00A024CDC039__INCLUDED_
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif // _MSC_VER >= 1000
  23. // WBPopupSliderButton.h : header file
  24. //
  25. class PopupSliderOwner
  26. {
  27. public:
  28. virtual void GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial)=0;
  29. virtual void PopSliderChanged(const long sliderID, long theVal) = 0;
  30. virtual void PopSliderFinished(const long sliderID, long theVal) = 0;
  31. };
  32. /////////////////////////////////////////////////////////////////////////////
  33. // WBPopupSliderButton window
  34. // note: as of 990315, these things produce horizontal sliders by default!
  35. class WBPopupSliderButton : public CButton
  36. {
  37. // Construction
  38. public:
  39. WBPopupSliderButton();
  40. // Attributes
  41. public:
  42. // Operations
  43. public:
  44. void SetupPopSliderButton(CWnd *pParentWnd, long controlID,
  45. PopupSliderOwner *pOwner);
  46. // Overrides
  47. // ClassWizard generated virtual function overrides
  48. //{{AFX_VIRTUAL(WBPopupSliderButton)
  49. protected:
  50. //}}AFX_VIRTUAL
  51. // Implementation
  52. public:
  53. virtual ~WBPopupSliderButton();
  54. // Generated message map functions
  55. protected:
  56. //{{AFX_MSG(WBPopupSliderButton)
  57. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  58. //}}AFX_MSG
  59. DECLARE_MESSAGE_MAP()
  60. private:
  61. Int m_controlID;
  62. Int m_sliderStyle;
  63. PopupSliderOwner *m_owner;
  64. };
  65. /////////////////////////////////////////////////////////////////////////////
  66. /////////////////////////////////////////////////////////////////////////////
  67. // PopupSlider window
  68. /*
  69. note: PopupSlider is a self-deleting window. It cannot
  70. be instantiated except through its New function, and once
  71. its Create() function has been called successfully it should
  72. not be deleted. Its PostNcDestroy method will handle that
  73. for you.
  74. */
  75. class PopupSlider : public CWnd
  76. {
  77. // Construction
  78. public:
  79. PopupSlider();
  80. public:
  81. /*
  82. the New function takes care of EVERYTHING for you! It
  83. constructs the object, calls its create method,
  84. and starts it running
  85. */
  86. static void New(CWnd* pParentWnd, long kind,
  87. PopupSliderOwner *pSliderOwner, long sliderID);
  88. // Attributes
  89. public:
  90. // Operations
  91. public:
  92. // Overrides
  93. // ClassWizard generated virtual function overrides
  94. //{{AFX_VIRTUAL(PopupSlider)
  95. public:
  96. virtual BOOL Create(const RECT& rect, CWnd* pParentWnd);
  97. protected:
  98. virtual void PostNcDestroy();
  99. //}}AFX_VIRTUAL
  100. // Implementation
  101. public:
  102. virtual ~PopupSlider();
  103. // Generated message map functions
  104. protected:
  105. //{{AFX_MSG(PopupSlider)
  106. afx_msg void OnPaint();
  107. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  108. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  109. afx_msg void OnDestroy();
  110. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  111. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  112. //}}AFX_MSG
  113. DECLARE_MESSAGE_MAP()
  114. private:
  115. void MoveThumbUnderMouse(int xNew);
  116. // our owner
  117. PopupSliderOwner *mSliderOwner;
  118. // the slider value
  119. long m_curValue;
  120. // setup values for the slider
  121. long m_lineSize;
  122. long m_lo;
  123. long m_hi;
  124. long m_kind;
  125. long mSliderID;
  126. /* the value when the slider last called "Finished"; we keep this around to
  127. see if we need to call Finished again on NcDestroy */
  128. long m_valOnLastFinished;
  129. private:
  130. Bool mDraggingThumb;
  131. Bool mClickThrough;
  132. CPoint mOrigPt;
  133. Bool mSetOrigPt;
  134. Bool mEverMoved;
  135. // for the thumb icon
  136. HICON mIcon;
  137. private:
  138. // the one and only slider windoid that should ever be open
  139. static PopupSlider *gPopupSlider;
  140. void GetChannelRect(CRect* rect);
  141. void GetThumbIconRect(CRect* rect);
  142. // the background color brush
  143. CBrush m_brush3dFaceColor;
  144. };
  145. //{{AFX_INSERT_LOCATION}}
  146. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  147. #endif // !defined(AFX_WBPopupSliderButton_H__8B217F41_937B_11D1_8CA3_00A024CDC039__INCLUDED_)