3 * Copyright (C) 2007, Harbour, All rights reserved.
6 #include <F_Text_Output.H>
10 void F_Text_Output::draw()
14 smb.ch_ = f_text_display->recode(' ');
15 smb.color(parent()->fg(), parent()->bg());
17 for (int x = 0; x < w(); x++) {
23 p.move((w() - label().size())/2, 0);
24 put_string(p, label());
26 for (unsigned int i = 0; (int)i < (h() - 2); i++) {
28 if (lines.size() && ((i + topline_) < lines.size())) {
29 put_string(p, lines[i + topline_], start_col_);
30 if (lines[i + topline_].size() > max_line_size_)
31 max_line_size_ = lines[i + topline_].size();
32 if ((lines[i + topline_].size() - start_col_) < w()) { // clear by spaces
33 std::string spaces(w(), ' ');
34 p.move(lines[i + topline_].size() - start_col_, i + 1);
35 put_string(p, spaces);
38 std::string spaces(w(), ' ');
39 put_string(p, spaces);
42 // set vertical scrollbar
43 if ((int)lines.size() > (h() - 1)) {
44 vs->bounds(lines.size() - (h() - 1));
48 if (int(max_line_size_) > (w() - 1)) {
53 hs->bounds(max_line_size_ - (w() - 1));
55 } else if (!start_col_)
57 F_Widget::draw_children();
58 damage(F_DAMAGE_FLUSH);
61 void F_Text_Output::add_line(const char *str)
66 std::string::size_type pos = 0, prev_pos = 0;
68 while ((pos = s.find_first_of("\n", pos)) != std::string::npos) {
69 a_ = s.substr(prev_pos, pos - prev_pos);
74 a_ = s.substr(prev_pos, pos - prev_pos);
77 draw(); // may be not very effective
80 bool F_Text_Output::handle(F_Event_t &ev)
84 debug("F_POINTER_PRESS: toid - %d", id());
87 case F_POINTER_RELEASE:
89 // debug("F_POINTER_RELEASE: toid - %d", id());
94 debug("toid - %d, evtype - %d", id(), ev.type);
97 // try pass events to scrollbars
98 if ((vs->visible() && vs->handle(ev)) || (hs->visible() && hs->handle(ev)))