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;
41 * Define content to present in browser window
43 virtual void _content(Scout_gfx::Parent_widget *content) = 0;
46 * Request current content
48 virtual Scout_gfx::Parent_widget *_content() = 0;
55 explicit Scout_browser(int voffset = 0)
56 : _document(0), _about(create_about()), _voffset(voffset)
59 virtual ~Scout_browser() { }
61 void voffset(int voffset)
62 { _voffset = voffset; }
65 * Travel backward in history
68 * \retval 0 end of history is reached
70 virtual bool go_backward()
72 _history.assign(curr_anchor());
73 if (!_history.go(History::BACKWARD)) return 0;
74 go_to(_history.curr(), 0);
79 * Follow history forward
82 * \retval 0 end of history is reached
84 virtual bool go_forward()
86 _history.assign(curr_anchor());
87 if (!_history.go(History::FORWARD)) return 0;
88 go_to(_history.curr(), 0);
93 * Follow specified link location
95 * \param add_history if set to 1, add new location to history
97 virtual void go_to(Widget *anchor, int add_history = 1)
103 _history.assign(curr_anchor());
104 _history.add(anchor);
107 Scout_gfx::Parent_widget *new_content = Scout_gfx::Anchor::chapter(anchor);
109 _content(new_content);
112 //ypos(_ypos - anchor->abs().y() + _voffset);
116 //new_content->curr_link_destination(0);
117 new_content->refresh();
124 * The current anchor is the element that is visible at the
125 * top of the browser window. It depends on the scroll position.
126 * We need to store these elements in the history to recover
127 * the right viewport on the history entries even after
128 * reformatting the document.
130 virtual Widget *curr_anchor() = 0;
133 * Display table of contents
135 bool go_toc() { go_to(_document->toc, 1); return 1; }
140 bool go_home() { go_to(_document); return 1; }
145 bool go_about() { go_to(_about); return 1; }
149 #endif /* _BROWSER_H_ */