-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMessageArea.cpp
52 lines (42 loc) · 1.57 KB
/
MessageArea.cpp
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
// ---------------------------------------------------------------
// MessageArea.cpp
// ---------------------------------------------------------------
#include <MessageArea.H>
#include <iostream>
// -------------------------------------------------------------------
cMessageArea::cMessageArea() {
currentTextPosition = 0;
}
// -------------------------------------------------------------------
cMessageArea::cMessageArea(Widget printTextHere) {
wTextOut = printTextHere;
currentTextPosition = 0;
}
// -------------------------------------------------------------------
void cMessageArea::Init(Widget printTextHere) {
wTextOut = printTextHere;
currentTextPosition = 0;
}
// -------------------------------------------------------------------
cMessageArea::~cMessageArea() {
}
// -------------------------------------------------------------------
void cMessageArea::PrintText(const char *buffer, bool scrollToTop,
bool clear)
{
if(clear) {
XmTextReplace(wTextOut, 0, XmTextGetLastPosition(wTextOut), const_cast<char *>(buffer));
currentTextPosition = strlen(buffer);
} else {
XmTextInsert(wTextOut, currentTextPosition, const_cast<char *>(buffer));
currentTextPosition += strlen(buffer);
}
XtVaSetValues(wTextOut, XmNcursorPosition, currentTextPosition, NULL);
if(scrollToTop) {
XmTextShowPosition(wTextOut, 0);
} else {
XmTextShowPosition(wTextOut, currentTextPosition);
}
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------