blob: c9932234912deff8470d34c187da033196e64da4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* TParamText.cc
*
* Turbo Vision - Version 2.0
*
* Copyright (c) 1994 by Borland International
* All Rights Reserved.
*
* Modified by Sergio Sigala <sergio@sigala.it>
*/
#define Uses_TParamText
#include <tvision/tv.h>
#include <stdarg.h>
/**
* Constructor.
*
* Creates and initializes a static text object by calling
* TStaticText::TStaticText(bounds, 0). The string is initially
* empty. Use @ref setText() to assign the text. @see
* TStaticText::TStaticText
*
* @param bounds The bounding rectangle of the view.
*
* @note There is a limit of max bytes
*/
TParamText::TParamText(const TRect &bounds)
: TStaticText(bounds, "")
{
}
/**
* Undocumented.
*/
TParamText::~TParamText()
{
}
/**
* Returns the length of the string, expressed in characters.
*/
int
TParamText::getTextLen() const
{
return text.length();
}
/**
* Sets a new value for the string.
*
* Since this method calls vsprintf(), you can use a printf-like style for
* its arguments.
*/
void
TParamText::setText(const char fmt[], ...)
{
char buff[4906];
va_list ap;
va_start(ap, fmt);
vsnprintf(buff, 4096, fmt, ap);
va_end(ap);
text = buff;
drawView();
}
#if !defined(NO_STREAMABLE)
/**
* Writes to the output stream `os'.
*/
void
TParamText::write(opstream &os)
{
TStaticText::write(os);
os.writeString(text.c_str());
}
/**
* Reads from the input stream `is'.
*/
void *
TParamText::read(ipstream &is)
{
TStaticText::read(is);
char buff[4096];
is.readString(buff, 4096);
text = buff;
return this;
}
/**
* Creates a new TParamText.
*
* Called to create an object in certain stream-reading situations.
*/
TStreamable *
TParamText::build()
{
return new TParamText(streamableInit);
}
/**
* Each streamable class needs a "builder" to allocate the correct memory
* for its objects together with the initialized virtual table pointers.
* This is achieved by calling this constructor with an argument of type
* @ref StreamableInit.
*/
TParamText::TParamText(StreamableInit)
: TStaticText(streamableInit)
{
}
#endif
|