* Starting work on ElementText for displaying generic information.

* If a storage error was thrown from make_directory in
EntryList::open, it would try to erase a FileMeta that wasn't inserted.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@753 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-08-09 19:55:34 +00:00
parent ba28df3ff2
commit ca58b43d8b
17 changed files with 360 additions and 67 deletions
+121
View File
@@ -0,0 +1,121 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2006, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <torrent/exceptions.h>
#include "display/frame.h"
#include "display/window_text.h"
#include "display/text_element_list.h"
#include "display/text_element_string.h"
#include "input/manager.h"
#include "control.h"
#include "element_text.h"
namespace ui {
ElementText::ElementText(void *object) :
m_window(new WindowText(object)),
m_column(0),
m_columnWidth(0) {
// Move bindings into a function that defines default bindings.
m_bindings[KEY_LEFT] = sigc::mem_fun(&m_slotExit, &slot_type::operator());
// m_bindings[KEY_UP] = sigc::mem_fun(this, &ElementText::entry_prev);
// m_bindings[KEY_DOWN] = sigc::mem_fun(this, &ElementText::entry_next);
// m_bindings[KEY_RIGHT] = sigc::mem_fun(this, &ElementText::entry_select);
}
ElementText::~ElementText() {
delete m_window;
}
void
ElementText::activate(display::Frame* frame, bool focus) {
if (is_active())
throw torrent::client_error("ui::ElementText::activate(...) is_active().");
if (focus)
control->input()->push_back(&m_bindings);
m_focus = focus;
m_frame = frame;
m_frame->initialize_window(m_window);
m_window->set_active(true);
}
void
ElementText::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementText::disable(...) !is_active().");
control->input()->erase(&m_bindings);
m_frame->clear();
m_frame = NULL;
m_window->set_active(false);
}
void
ElementText::push_back(display::TextElement* entry) {
m_window->push_back(entry);
// For the moment, don't bother doing anything if the window is
// already active.
m_window->mark_dirty();
}
void
ElementText::push_column(display::TextElement* entry1, display::TextElement* entry2) {
m_columnWidth = std::max(entry1->max_length(), m_column);
display::TextElementList* list = new display::TextElementList;
list->set_column(m_column);
list->set_column_width(&m_columnWidth);
list->push_back(entry1);
list->push_back(entry2);
push_back(list);
}
}