RPrint.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. // May or may not join blit.h
  19. #ifndef RPRINT_H
  20. #define RPRINT_H
  21. /****************************************************** QUICK CHECK
  22. //-------------------------- Higher Level
  23. char* print(char* pszFormat,...);
  24. char* print(short sX,short sY,char* pszFormat,...);
  25. char* print(RImage* pimDst,short sX,short sY,char* pszFormat,...);
  26. short SetEffectAbs(Effect eEffect,short sVal); // absolute:
  27. short SetEffect(Effect eEffect,double dVal); // relative:
  28. short SetColor(ULONG ulForeColor,ULONG ulBackColor=0,ULONG ulShadowColor=0);
  29. short SetDestination(RImage* pimDst,RRect* prColumn = NULL);
  30. void SetJustifyRight();
  31. void SetJustifyCenter();
  32. void SetJustifyLeft();
  33. void SetWordWrap(short sOn = TRUE);
  34. void ResetEffects(); // includes tab and to relative
  35. void ResetMode(); // all zero
  36. void SetMode(Mode eMode,short sVal); // 0 = off
  37. short SetFont(short sCellH,RFont* pFont = NULL);
  38. void GetPos(short *psX,short *psY,short *psW,short *psH);
  39. short GetWidth(char* pszString); // see m_sNumChar,ms_szLineText,ms_sCharPosX
  40. RFont* GetFont() { return m_pfnCurFont; }
  41. short SetColumn(short sX,short sY,short sW,short sH);
  42. //****************************************************** QUICK CHECK */
  43. #include "BLIT.H"
  44. //====================
  45. class RPrint
  46. {
  47. public:
  48. //-------------------------- Public members
  49. U32 m_ForegroundColor;
  50. U32 m_BackgroundColor; // 0 = OFF
  51. U32 m_ShadowColor; // Used if offsets are not zero!
  52. RImage* m_pimDst;
  53. RRect m_rClip; // used for wrapping..
  54. // Printing Modes: Default is left justify, proportional
  55. // Note: JUSTIFY_F & JUSTIFY_R are not independent
  56. typedef enum
  57. {
  58. UNPROPORTIONAL = 1, // 0 = Proportional
  59. WORD_WRAP = 2, // 0 = RAW
  60. FIELD = 4, // 0 = line mode => SYTEM FLAG!
  61. JUSTIFY_ON = 8, // 0 = Left Justified
  62. JUSTIFY_FULL = 16, // 0 = Check JUSTIFY_RIGHT
  63. JUSTIFY_RIGHT = 32, // 0 = Center justified
  64. TAB_STOP = 64, // 0 = disble
  65. DECIMAL_STOP = 128, // 0 = disble
  66. } Mode;
  67. // NEW generic use of varying effects:
  68. // A floating point value array (default),
  69. // a short array (optional), and a short value array
  70. // for each letter effect. A byte list will flag
  71. // use of the absolute (short) values:
  72. typedef enum
  73. {
  74. STRETCH = 0,ITALIC,BOLD,SHADOW_X,SHADOW_Y,TAB,UP_W,UP_H,ADD_W,ADD_H,
  75. NUM_OF_EFFECTS
  76. } Effect; // binary
  77. //-------------------------- Higher Level
  78. char* print(char* pszFormat,...);
  79. char* print(short sX,short sY,char* pszFormat,...);
  80. char* print(RImage* pimDst,short sX,short sY,char* pszFormat,...);
  81. short SetEffectAbs(Effect eEffect,short sVal); // absolute:
  82. short SetEffect(Effect eEffect,double dVal); // relative:
  83. short SetColor(ULONG ulForeColor,ULONG ulBackColor=0,ULONG ulShadowColor=0);
  84. short SetDestination(RImage* pimDst,RRect* prColumn = NULL);
  85. short SetColumn(short sX,short sY,short sW,short sH);
  86. void SetJustifyRight();
  87. void SetJustifyCenter();
  88. void SetJustifyLeft();
  89. void SetJustifyFull();
  90. void SetWordWrap(short sOn = TRUE);
  91. void ResetEffects(); // includes tab and to relative
  92. void ResetMode(); // all zero
  93. void SetMode(Mode eMode,short sVal); // 0 = off
  94. short SetFont(short sCellH,RFont* pFont = NULL);
  95. void GetPos(short *psX,short *psY = NULL,short *psW = NULL,short *psH = NULL);
  96. short GetWidth(char* pszString);
  97. RFont* GetFont() { return m_pfnCurFont; }
  98. //-------------------------- Lower Level
  99. //void OffsetShadow();
  100. char* printInt(char* pszInput);
  101. void GetPropEffX(short sX,short sE,short sNext,
  102. short *psEffX = NULL,short *psEffE = NULL,
  103. short *psEffNext = NULL);
  104. short GetPropCellX(short sChar,short *psX = NULL,short *psE = NULL,
  105. short *psNext = NULL,short sFirst = FALSE);
  106. char* ScanLine(char* pszInput);
  107. void FormatText();
  108. void DrawText();
  109. short GetBlitW(UCHAR c);
  110. short FrameIt(); // 1= fresh line, -1 = off bottom
  111. void printLine();
  112. void ClearTabs(); // both types
  113. short IsClipped(short sX,short sY,short sW,short sH);
  114. char* GetNextLine(); // characters from inputted text to be line formatted, NULL = done.
  115. short IsWhiteSpace(short sChar)
  116. { if ((sChar == ' ')||(sChar == '\t')) return 1; return 0;}
  117. short SetCellW();
  118. //-------------------------- Construction
  119. RPrint();
  120. ~RPrint();
  121. public:
  122. short m_sCurX; // lower left cursor position
  123. short m_sCurY;
  124. Mode m_eModes; // Set different text modes
  125. // a 0 signals using the Height relative value
  126. U8 m_aAbsFlag[NUM_OF_EFFECTS];
  127. S16 m_aAbsEffect[NUM_OF_EFFECTS]; // go by this...
  128. float m_aARelEffect[NUM_OF_EFFECTS];
  129. //----------------------------- More parameters
  130. RFont* m_pfnCurFont; // The high level font
  131. short m_sNumTabStops;
  132. short m_sNumDecStops;
  133. short *m_psTabStops;
  134. short *m_psDecStops;
  135. //----------------------------- Working variables
  136. RFont::RFontSet* m_pCurFontSet; // set to NULL initially.
  137. float m_fWidthScale; // Compared to current font
  138. float m_fHeightScale; // Compared to current font
  139. short m_sCellH; // Current Visual Letter Height:
  140. short m_sCellW; // Curent maximum width based on effects
  141. short m_sUP_W; // Max width or fixed grid width
  142. short m_sUP_H; // Max width or fixed grid width
  143. short m_sNumWhite;
  144. //---------------
  145. short m_sNumChar;
  146. short m_sExtX;
  147. //----------------------------- Static variables
  148. static UCHAR ms_szLineText[1024]; // Stores a line at a time
  149. static short ms_sCharPosX[1024]; // positions of each character in the line...
  150. static char ms_szInput[4096]; //
  151. };
  152. //====================
  153. #endif