2 * \brief Browser interface
4 * \author Norman Feske <norman.feske@genode-labs.com>
8 * Copyright (C) 2005-2009
9 * Genode Labs, Feske & Helmuth Systementwicklung GbR
11 * This file is part of the Genode OS framework, which is distributed
12 * under the terms of the GNU General Public License version 2.
18 #include <l4/scout-gfx/document>
19 #include <l4/scout-gfx/doc/link>
21 #include "browser_if.h"
27 using Scout_gfx::Widget;
29 extern Scout_gfx::Document *create_about();
31 class Scout_browser : public Scout_gfx::Browser, public Browser_if
35 Scout_gfx::Document *_document;
36 Scout_gfx::Document *_about;
42 * Define content to present in browser window
44 virtual void _content(Scout_gfx::Parent_widget *content) = 0;
47 * Request current content
49 virtual Scout_gfx::Parent_widget *_content() = 0;
56 explicit Scout_browser(int voffset = 0)
57 : _document(0), _about(create_about()), _voffset(voffset)
60 virtual ~Scout_browser() { }
62 char const *title() const { return _document->title; }
64 void voffset(int voffset)
65 { _voffset = voffset; }
68 * Travel backward in history
71 * \retval 0 end of history is reached
73 virtual bool go_backward()
75 _history.assign(curr_anchor());
76 if (!_history.go(History::BACKWARD)) return 0;
77 go_to(_history.curr(), 0);
82 * Follow history forward
85 * \retval 0 end of history is reached
87 virtual bool go_forward()
89 _history.assign(curr_anchor());
90 if (!_history.go(History::FORWARD)) return 0;
91 go_to(_history.curr(), 0);
96 * Follow specified link location
98 * \param add_history if set to 1, add new location to history
100 virtual void go_to(Widget *anchor, int add_history = 1)
106 _history.assign(curr_anchor());
107 _history.add(anchor);
110 Scout_gfx::Parent_widget *new_content = Scout_gfx::Anchor::chapter(anchor);
112 _content(new_content);
115 //ypos(_ypos - anchor->abs().y() + _voffset);
119 //new_content->curr_link_destination(0);
120 new_content->refresh();
127 * The current anchor is the element that is visible at the
128 * top of the browser window. It depends on the scroll position.
129 * We need to store these elements in the history to recover
130 * the right viewport on the history entries even after
131 * reformatting the document.
133 virtual Widget *curr_anchor() = 0;
136 * Display table of contents
138 bool go_toc() { go_to(_document->toc, 1); return 1; }
143 bool go_home() { go_to(_document); return 1; }
148 bool go_about() { go_to(_about); return 1; }
152 #endif /* _BROWSER_H_ */