aboutsummaryrefslogtreecommitdiffstats
path: root/unix/tx/TXLabel.h
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tx/TXLabel.h')
-rw-r--r--unix/tx/TXLabel.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/unix/tx/TXLabel.h b/unix/tx/TXLabel.h
index aba798cb..24b8cbb3 100644
--- a/unix/tx/TXLabel.h
+++ b/unix/tx/TXLabel.h
@@ -47,20 +47,20 @@ public:
// setText() changes the text in the label.
void setText(const char* text_) {
- text.buf = rfb::strDup(text_);
+ text = text_;
lines = 0;
- int lineStart = 0;
+ size_t lineStart = 0;
int textWidth = 0;
- int i = -1;
+ size_t i = -1;
do {
i++;
- if (text.buf[i] == '\n' || text.buf[i] == 0) {
- int tw = XTextWidth(defaultFS, &text.buf[lineStart], i-lineStart);
+ if (i >= text.size() || text[i] == '\n') {
+ int tw = XTextWidth(defaultFS, &text[lineStart], i-lineStart);
if (tw > textWidth) textWidth = tw;
lineStart = i+1;
lines++;
}
- } while (text.buf[i] != 0);
+ } while (i < text.size());
int textHeight = ((defaultFS->ascent + defaultFS->descent + lineSpacing)
* lines);
int newWidth = __rfbmax(width(), textWidth + xPad*2);
@@ -93,19 +93,19 @@ private:
}
void paint() {
- int lineNum = 0;
- int lineStart = 0;
- int i = -1;
+ size_t lineNum = 0;
+ size_t lineStart = 0;
+ size_t i = -1;
do {
i++;
- if (text.buf[i] == '\n' || text.buf[i] == 0) {
- int tw = XTextWidth(defaultFS, &text.buf[lineStart], i-lineStart);
+ if (i >= text.size() || text[i] == '\n') {
+ int tw = XTextWidth(defaultFS, &text[lineStart], i-lineStart);
XDrawString(dpy, win(), defaultGC, xOffset(tw), yOffset(lineNum),
- &text.buf[lineStart], i-lineStart);
+ &text[lineStart], i-lineStart);
lineStart = i+1;
lineNum++;
}
- } while (text.buf[i] != 0);
+ } while (i < text.size());
}
virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
@@ -117,7 +117,7 @@ private:
}
int lineSpacing;
- rfb::CharArray text;
+ std::string text;
int lines;
HAlign halign;
VAlign valign;