ltguitextitemctrl.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // LTGUITextItemCtrl.h: interface for the CLTGUITextItemCtrl class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_LTGUITEXTITEMCTRL_H__DDDEFA74_57D4_11D2_BDA0_0060971BDC6D__INCLUDED_)
  5. #define AFX_LTGUITEXTITEMCTRL_H__DDDEFA74_57D4_11D2_BDA0_0060971BDC6D__INCLUDED_
  6. #if _MSC_VER >= 1000
  7. #pragma once
  8. #endif // _MSC_VER >= 1000
  9. #include "ltguictrl.h"
  10. #include "stdlith.h"
  11. // This control displays a string of text which fades out upon being unselected.
  12. // It can contain multiple strings (see CLTGUICtrl::AddString()) which are cycled
  13. // when OnLeft() and OnRight() are called. This is useful in menu code for selecting
  14. // options.
  15. class CLTGUIFont;
  16. class CLTGUITextItemCtrl : public CLTGUIFadeColorCtrl
  17. {
  18. public:
  19. CLTGUITextItemCtrl();
  20. virtual ~CLTGUITextItemCtrl();
  21. // Create the control
  22. // pClientDE - Pointer to the client interface.
  23. // dwCommandID - The command ID which is sent when "enter" is pressed.
  24. // hText - The initial text that is displayed for this control. Pass in LTNULL if you do not want initial text.
  25. // pFont - The font to use for this string.
  26. // pMessageCtrl - control which receives messages when the "enter" key is pressed.
  27. // pnValue - Pointer to the value which receives the selection index when UpdateData is called.
  28. LTBOOL Create ( ILTClient *pClientDE, uint32 dwCommandID, HSTRING hText, CLTGUIFont *pFont,
  29. CLTGUICommandHandler *pCommandHandler, int *pnValue=LTNULL,
  30. uint32 dwParam1 = 0, uint32 dwParam2 = 0);
  31. // Destroys the control
  32. void Destroy ( );
  33. // Update data
  34. virtual void UpdateData(LTBOOL bSaveAndValidate);
  35. // Add more strings to the control. These are cycled when OnLeft() and OnRight() are called
  36. void AddString(HSTRING hString);
  37. void AddString(int messageCode);
  38. HSTRING GetString(int nIndex); // Return a string at a specific index
  39. void RemoveString(int nIndex); // Remove a string at a specific index
  40. void RemoveAll(); // Remove all strings
  41. // Return the number of strings
  42. int GetNumStrings() { return m_stringArray.GetSize(); }
  43. // Sets/Get the currently selected index
  44. int GetSelIndex() { return m_nSelIndex; }
  45. virtual void SetSelIndex(int nIndex);
  46. // Render the control
  47. void Render ( HSURFACE hDestSurf );
  48. // Set the font
  49. LTBOOL SetFont ( CLTGUIFont *pFont);
  50. // Width/Height calculations
  51. int GetWidth ( ) { return m_dwWidth; }
  52. int GetHeight ( ) { return m_dwHeight; }
  53. // Commonly used keyboard messages
  54. virtual LTBOOL OnEnter ( );
  55. virtual LTBOOL OnLeft ( );
  56. virtual LTBOOL OnRight ( );
  57. virtual LTBOOL OnLButtonUp(int x, int y) {return OnEnter();}
  58. // [blg] ctrl id
  59. uint32 GetID() { return(m_dwCommandID); }
  60. // fixed width text
  61. void SetFixedWidth(uint32 width) {m_dwWidth = width; m_bFixedWidth = LTTRUE; CalculateSize(); }
  62. void ClearFixedWidth() {m_bFixedWidth = LTFALSE; CalculateSize(); }
  63. protected:
  64. // The selection for this control has changed
  65. virtual void OnSelChange();
  66. virtual void CalculateSize();
  67. protected:
  68. CLTGUIFont *m_pFont; // The font for this control
  69. uint32 m_dwWidth; // The width of the control
  70. uint32 m_dwHeight; // The height of the control
  71. LTBOOL m_bFixedWidth; // TRUE is we should format the text to fit a set width
  72. int *m_pnValue; // Receives the current selection when UpdateData is called
  73. int m_nSelIndex; // The currently selected index
  74. CMoArray<HSTRING> m_stringArray; // The array of strings
  75. // Receives a message when the "enter" key is pressed.
  76. CLTGUICommandHandler *m_pCommandHandler;
  77. };
  78. #endif // !defined(AFX_LTGUITEXTITEMCTRL_H__DDDEFA74_57D4_11D2_BDA0_0060971BDC6D__INCLUDED_)