txt.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. //
  20. // TXT.CPP
  21. //
  22. // History:
  23. // 08/07/96 JMI Started.
  24. //
  25. // 08/12/96 JMI Now utilizes CGuiItem::DrawText to draw text.
  26. //
  27. // 09/24/96 JMI Changed all BLU_MB?_* macros to RSP_MB?_* macros.
  28. //
  29. // 10/31/96 JMI Changed:
  30. // Old label: New label:
  31. // ========= =========
  32. // CTxt RTxt
  33. // CImage RImage
  34. // CGuiItem RGuiItem
  35. // CENTERED RGuiItem::Centered
  36. //
  37. // 11/27/96 JMI Added initialization of m_type to identify this type
  38. // of GUI item.
  39. //
  40. // 01/01/96 JMI Compose() no longer sets hot area (now done by base
  41. // class).
  42. //
  43. // 01/04/96 JMI Upgraded HotCall() to new CursorEvent(). This upgrade
  44. // is in response to RGuiItem now using relative RHots.
  45. // Now m_hot.m_sX/Y is parent item relative just like
  46. // m_sX/Y. This should simplify a lot of stuff and even
  47. // fix some odd features like being able to click a GUI
  48. // item that exceeds the boundary of its parent. This fix
  49. // will be essential for the not-yet-existent RListBox since
  50. // it will most likely scroll many children through a small
  51. // client area.
  52. // Now there are two regions associated with cursor events.
  53. // The first is the 'hot' area. This is the area that m_hot
  54. // is set to include. Child items can only receive cursor
  55. // events through this area. The second is the 'event' area.
  56. // This is the area where the item really is actually con-
  57. // cerned with cursor events. Example: For a Dlg, the
  58. // entire window is the 'hot' area and the title bar is the
  59. // 'event' area.
  60. //
  61. //////////////////////////////////////////////////////////////////////////////
  62. //
  63. // This a GUI item that is based on the basic RGuiItem.
  64. // This overrides HotCall() to get information about where a click in its RHot
  65. // occurred.
  66. // This overrides Compose() to add text.
  67. //
  68. // Enhancements/Uses:
  69. // To change the look of text when pressed, you may want to override the
  70. // Compose() or DrawBorder() in a derived class.
  71. // To change the background of the text item, see RGuiItem.
  72. // To get a callback on a click/release pair in the text item, set m_tcUser.
  73. //
  74. //////////////////////////////////////////////////////////////////////////////
  75. //////////////////////////////////////////////////////////////////////////////
  76. // Headers.
  77. //////////////////////////////////////////////////////////////////////////////
  78. #include "Blue.h"
  79. #ifdef PATHS_IN_INCLUDES
  80. #include "ORANGE/GUI/txt.h"
  81. #else
  82. #include "txt.h"
  83. #endif // PATHS_IN_INCLUDES
  84. //////////////////////////////////////////////////////////////////////////////
  85. // Module specific macros.
  86. //////////////////////////////////////////////////////////////////////////////
  87. // Sets val to def if val is -1.
  88. #define DEF(val, def) ((val == -1) ? def : val)
  89. //////////////////////////////////////////////////////////////////////////////
  90. // Module specific typedefs.
  91. //////////////////////////////////////////////////////////////////////////////
  92. //////////////////////////////////////////////////////////////////////////////
  93. // Module specific (static) variables.
  94. //////////////////////////////////////////////////////////////////////////////
  95. //////////////////////////////////////////////////////////////////////////////
  96. // Construction/Destruction.
  97. //////////////////////////////////////////////////////////////////////////////
  98. //////////////////////////////////////////////////////////////////////////////
  99. //
  100. // Default constructor.
  101. //
  102. //////////////////////////////////////////////////////////////////////////////
  103. RTxt::RTxt()
  104. {
  105. m_type = Txt; // Indicates type of GUI item.
  106. }
  107. //////////////////////////////////////////////////////////////////////////////
  108. //
  109. // Destructor.
  110. //
  111. //////////////////////////////////////////////////////////////////////////////
  112. RTxt::~RTxt()
  113. {
  114. }
  115. ////////////////////////////////////////////////////////////////////////
  116. // Methods.
  117. ////////////////////////////////////////////////////////////////////////
  118. ////////////////////////////////////////////////////////////////////////
  119. //
  120. // Compose item.
  121. //
  122. ////////////////////////////////////////////////////////////////////////
  123. void RTxt::Compose( // Returns nothing.
  124. RImage* pim /*= NULL*/) // Dest image, uses m_im if NULL.
  125. {
  126. if (pim == NULL)
  127. {
  128. pim = &m_im;
  129. }
  130. // Call base (draws border and background).
  131. RGuiItem::Compose(pim);
  132. // Draw txt stuff.
  133. short sX, sY, sW, sH;
  134. // Get client relative to border so we know where to put the text.
  135. GetClient(&sX, &sY, &sW, &sH);
  136. // Draw text.
  137. DrawText(sX, sY, sW, sH, pim);
  138. }
  139. ////////////////////////////////////////////////////////////////////////
  140. // Querries.
  141. ////////////////////////////////////////////////////////////////////////
  142. //////////////////////////////////////////////////////////////////////////////
  143. // EOF
  144. //////////////////////////////////////////////////////////////////////////////