2 * \brief Scout tutorial browser main program
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.
21 #include <l4/cxx/exceptions>
22 #include <l4/cxx/iostream>
24 #include <l4/scout-gfx/tick>
25 #include <l4/scout-gfx/redraw_manager>
26 #include <l4/scout-gfx/user_state>
27 #include <l4/scout-gfx/factory>
28 #include <l4/scout-gfx/redraw_manager>
30 #include "browser_window.h"
32 using Scout_gfx::Document;
34 extern Document *create_document(Scout_gfx::Factory *f);
38 * Runtime configuration
42 int iconbar_detail = 1;
43 int background_detail = 1;
49 #define POINTER_RGBA _binary_pointer_rgba_start
51 extern unsigned char POINTER_RGBA[];
62 int main() //int argc, char **argv)
66 Platform *pf = Platform::get(Rect(Point(0,0), Area(Browser_width, Browser_height)));
68 ::Factory *f = dynamic_cast< ::Factory* >(::Factory::set.find(*pf->pixel_info()));
70 Document *doc = create_document(f);
72 Scout_gfx::View *view = pf->create_view(Rect(Point(0,0), Area(Browser_width, Browser_height)));
73 /* create instance of browser window */
74 Scout_gfx::Basic_window *browser =
76 doc, /* initial document */
78 view->geometry().area(), /* max size of window */
82 /* initialize mouse cursor */
85 static Icon<Pixel_rgb565, 32, 32> mcursor;
86 if (Config::mouse_cursor) {
87 mcursor.geometry(mx, my, 32, 32);
88 mcursor.rgba(POINTER_RGBA);
91 browser.append(&mcursor);
94 /* create user state manager */
96 /* assign browser as root element to redraw manager */
97 pf->root()->append(browser);
98 browser->set_geometry(view->geometry());
99 //browser->scroll_pos(Point(0, 0));
101 pf->process_redraws();
103 using Scout_gfx::Event;
106 /* enter main loop */
108 unsigned long curr_time, old_time;
109 curr_time = old_time = pf->timer_ticks();
113 if (ev.type != Event::WHEEL) {
115 /* update mouse cursor */
116 if (Config::mouse_cursor && (ev.mx != mx || ev.my != my)) {
117 int x1 = min(ev.mx, mx);
118 int y1 = min(ev.my, my);
119 int x2 = max(ev.mx + mcursor.w() - 1, mx + mcursor.w() - 1);
120 int y2 = max(ev.my + mcursor.h() - 1, my + mcursor.h() - 1);
122 mcursor.geometry(ev.mx, ev.my, mcursor.w(), mcursor.h());
123 redraw.request(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
125 mx = ev.mx; my = ev.my;
130 pf->root()->handle_event(ev);
132 if (ev.type == Event::REFRESH)
133 pf->scr_update(Rect(Point(0, 0), pf->scr_size()));
136 if (ev.type == Event::TIMER)
137 Scout_gfx::Tick::handle(pf->timer_ticks());
139 /* perform periodic redraw */
140 curr_time = pf->timer_ticks();
141 if (!pf->event_pending() && ((curr_time - old_time > 20) || (curr_time < old_time))) {
142 old_time = curr_time;
143 pf->process_redraws();
146 } while (ev.type != Event::QUIT);
149 } catch (L4::Runtime_error const &e) {
150 L4::cerr << "Fatal exception: " << e.str() << " '" << e.extra_str()