00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef HAVE_CONFIG_H
00020 # include <config.h>
00021 #endif
00022
00023 #ifndef ALPHA_LINUX_CXX
00024 # include <cstring>
00025 #endif
00026
00027 #include "gamewin.h"
00028 #include "Text_gump.h"
00029
00030 #ifndef UNDER_CE
00031 using std::strchr;
00032 using std::strcpy;
00033 using std::strlen;
00034 #endif
00035
00036
00037
00038
00039
00040 void Text_gump::add_text
00041 (
00042 const char *str
00043 )
00044 {
00045 int slen = strlen(str);
00046
00047 char *newtext = new char[textlen + (textlen != 0) + slen + 1];
00048 if (textlen)
00049 {
00050 strcpy(newtext, text);
00051
00052
00053 if (newtext[textlen-1] != '*') newtext[textlen++] = '~';
00054 }
00055 strcpy(newtext + textlen, str);
00056 delete [] text;
00057 text = newtext;
00058 textlen += slen;
00059 }
00060
00061
00062
00063
00064
00065
00066
00067 int Text_gump::paint_page
00068 (
00069 Rectangle box,
00070 int start
00071 )
00072 {
00073 const int font = serpentine?8:4;
00074 const int vlead = 1;
00075 int ypos = 0;
00076 int textheight = sman->get_text_height(font) + vlead;
00077 char *str = text + start;
00078 while (*str && *str != '*' && ypos + textheight <= box.h)
00079 {
00080 if (*str == '~')
00081 {
00082 ypos += textheight;
00083 str++;
00084 continue;
00085 }
00086
00087 char *epage = strchr(str, '*');
00088
00089 char *eol = strchr(str, '~');
00090 if (epage && (!eol || eol > epage))
00091 eol = epage;
00092 if (!eol)
00093 eol = text + textlen;
00094 char eolchr = *eol;
00095 *eol = 0;
00096 int endoff = sman->paint_text_box(font, str, x + box.x,
00097 y + box.y + ypos, box.w, box.h - ypos, vlead);
00098 *eol = eolchr;
00099 if (endoff > 0)
00100 {
00101 str = eol + (eolchr == '~');
00102 ypos += endoff;
00103 }
00104 else
00105 {
00106 str += -endoff;
00107 break;
00108 }
00109 }
00110 if (*str == '*')
00111 str++;
00112 gwin->set_painted();
00113 return (str - text);
00114 }
00115
00116
00117
00118
00119
00120
00121
00122 int Text_gump::show_next_page
00123 (
00124 )
00125 {
00126 if (curend >= textlen)
00127 return (0);
00128 curtop = curend;
00129 paint();
00130 return (1);
00131 }