* Use varargs in Canvas::print.

* Added min/max size to display::Window. Added flags for windows that
should be on located at the left/bottom side of a Frame.

* Reversed print order in WindowLog*.

* Added display::TextElement and subclasses for flexible printing to a
char buffer with associated attributes. Added display::Attributes and
display::Canvas::print_attributes.

* Added display::WindowText for use with display::TextElement's.

* Added ui::ElementMenu for generic menus, and started work adding
this to ui::Download.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@751 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-08-06 18:20:56 +00:00
parent 62beb9d9ed
commit 0b45062eb3
66 changed files with 1350 additions and 256 deletions
+18 -6
View File
@@ -45,7 +45,7 @@
namespace display {
WindowLogComplete::WindowLogComplete(core::Log* l) :
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 30, 1),
Window(new Canvas, 0, 30, 1, extent_full, extent_full),
m_log(l) {
// We're trying out scheduled tasks instead.
@@ -65,15 +65,27 @@ void
WindowLogComplete::redraw() {
m_canvas->erase();
int pos = 0;
if (m_canvas->width() < 16)
return;
// m_canvas->print(std::max(0, (int)m_canvas->width() / 2 - 5), pos++, "*** Log ***");
int pos = m_canvas->height();
for (core::Log::iterator itr = m_log->begin(), e = m_log->end(); itr != e && pos < m_canvas->height(); ++itr) {
for (core::Log::iterator itr = m_log->begin(), last = m_log->end(); itr != last && pos > 0; ++itr) {
char buffer[16];
print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
m_canvas->print(0, pos++, "(%s) %s", buffer, itr->second.c_str());
// Use an arbitrary min width of 60 for allowing multiple
// lines. This should ensure we don't mess up the display when the
// screen is shrunk too much.
unsigned int timeWidth = 3 + print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds())) - buffer;
unsigned int logWidth = m_canvas->width() > 60 ? (m_canvas->width() - timeWidth) : (60 - timeWidth);
unsigned int logHeight = (itr->second.size() + logWidth - 1) / logWidth;
for (unsigned int j = logHeight; j > 0 && pos > 0; --j, --pos)
if (j == 1)
m_canvas->print(0, pos - 1, "(%s) %s", buffer, itr->second.substr(0, m_canvas->width() - timeWidth).c_str());
else
m_canvas->print(timeWidth, pos - 1, "%s", itr->second.substr(logWidth * (j - 1), m_canvas->width() - timeWidth).c_str());
}
}