hu_lib.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // Emacs style mode select -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // DESCRIPTION: none
  18. //
  19. //-----------------------------------------------------------------------------
  20. #ifndef __HULIB__
  21. #define __HULIB__
  22. // We are referring to patches.
  23. #include "r_defs.h"
  24. // background and foreground screen numbers
  25. // different from other modules.
  26. #define BG 1
  27. #define FG 0
  28. // font stuff
  29. #define HU_CHARERASE KEY_BACKSPACE
  30. #define HU_MAXLINES 4
  31. #define HU_MAXLINELENGTH 80
  32. //
  33. // Typedefs of widgets
  34. //
  35. // Text Line widget
  36. // (parent of Scrolling Text and Input Text widgets)
  37. typedef struct
  38. {
  39. // left-justified position of scrolling text window
  40. int x;
  41. int y;
  42. patch_t** f; // font
  43. int sc; // start character
  44. char l[HU_MAXLINELENGTH+1]; // line of text
  45. int len; // current line length
  46. // whether this line needs to be udpated
  47. int needsupdate;
  48. } hu_textline_t;
  49. // Scrolling Text window widget
  50. // (child of Text Line widget)
  51. typedef struct
  52. {
  53. hu_textline_t l[HU_MAXLINES]; // text lines to draw
  54. int h; // height in lines
  55. int cl; // current line number
  56. // pointer to boolean stating whether to update window
  57. boolean* on;
  58. boolean laston; // last value of *->on.
  59. } hu_stext_t;
  60. // Input Text Line widget
  61. // (child of Text Line widget)
  62. typedef struct
  63. {
  64. hu_textline_t l; // text line to input on
  65. // left margin past which I am not to delete characters
  66. int lm;
  67. // pointer to boolean stating whether to update window
  68. boolean* on;
  69. boolean laston; // last value of *->on;
  70. } hu_itext_t;
  71. //
  72. // Widget creation, access, and update routines
  73. //
  74. // initializes heads-up widget library
  75. void HUlib_init(void);
  76. //
  77. // textline code
  78. //
  79. // clear a line of text
  80. void HUlib_clearTextLine(hu_textline_t *t);
  81. void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc);
  82. // returns success
  83. boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch);
  84. // returns success
  85. boolean HUlib_delCharFromTextLine(hu_textline_t *t);
  86. // draws tline
  87. void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor);
  88. // erases text line
  89. void HUlib_eraseTextLine(hu_textline_t *l);
  90. //
  91. // Scrolling Text window widget routines
  92. //
  93. // ?
  94. void
  95. HUlib_initSText
  96. ( hu_stext_t* s,
  97. int x,
  98. int y,
  99. int h,
  100. patch_t** font,
  101. int startchar,
  102. boolean* on );
  103. // add a new line
  104. void HUlib_addLineToSText(hu_stext_t* s);
  105. // ?
  106. void
  107. HUlib_addMessageToSText
  108. ( hu_stext_t* s,
  109. char* prefix,
  110. char* msg );
  111. // draws stext
  112. void HUlib_drawSText(hu_stext_t* s);
  113. // erases all stext lines
  114. void HUlib_eraseSText(hu_stext_t* s);
  115. // Input Text Line widget routines
  116. void
  117. HUlib_initIText
  118. ( hu_itext_t* it,
  119. int x,
  120. int y,
  121. patch_t** font,
  122. int startchar,
  123. boolean* on );
  124. // enforces left margin
  125. void HUlib_delCharFromIText(hu_itext_t* it);
  126. // enforces left margin
  127. void HUlib_eraseLineFromIText(hu_itext_t* it);
  128. // resets line and left margin
  129. void HUlib_resetIText(hu_itext_t* it);
  130. // left of left-margin
  131. void
  132. HUlib_addPrefixToIText
  133. ( hu_itext_t* it,
  134. char* str );
  135. // whether eaten
  136. boolean
  137. HUlib_keyInIText
  138. ( hu_itext_t* it,
  139. unsigned char ch );
  140. void HUlib_drawIText(hu_itext_t* it);
  141. // erases all itext lines
  142. void HUlib_eraseIText(hu_itext_t* it);
  143. #endif
  144. //-----------------------------------------------------------------------------
  145. //
  146. // $Log:$
  147. //
  148. //-----------------------------------------------------------------------------