]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/scout/lib/src/browser_window.h
Inital import
[l4.git] / l4 / pkg / scout / lib / src / browser_window.h
1 /*
2  * \brief   Browser window interface
3  * \date    2005-10-24
4  * \author  Norman Feske <norman.feske@genode-labs.com>
5  */
6
7 /*
8  * Copyright (C) 2005-2009
9  * Genode Labs, Feske & Helmuth Systementwicklung GbR
10  *
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.
13  */
14
15 #pragma once
16
17 #include <l4/scout-gfx/scroll_pane>
18 #include <l4/scout-gfx/horizontal_shadow>
19 #include "platform.h"
20 #include <l4/scout-gfx/redraw_manager>
21 #include "browser.h"
22 #include <l4/scout-gfx/window>
23 #include <l4/scout-gfx/titlebar>
24
25 class Factory;
26
27 class Browser_window
28 : public Scout_browser,
29   public Scout_gfx::Window
30 {
31
32 private:
33
34   /**
35    * Constants
36    */
37   enum
38   {
39     _TH        = 32,    /* height of title bar      */
40     _SB_XPAD   = 5,     /* hor. pad of scrollbar    */
41     _SB_YPAD   = 10,    /* vert. pad of scrollbar   */
42   };
43
44   /**
45    * General properties
46    */
47   int  _attr;   /* attribute mask */
48
49   /**
50    * Widgets
51    */
52   Scout_gfx::Titlebar   _titlebar;
53   Scout_gfx::Widget    *_texture;
54   Scout_gfx::Widget    *_shadow;
55   Scout_gfx::Parent_widget  *_cont;
56   Scout_gfx::Scroll_pane *_cont_pane;
57   Scout_gfx::Icon      *_sizer;
58   Scout_gfx::Parent_widget    *_panel;
59
60 protected:
61
62   /**
63    * Browser interface
64    */
65   void _content(Scout_gfx::Parent_widget *content);
66   Scout_gfx::Parent_widget *_content();
67
68 public:
69
70   /**
71    * Browser window attributes
72    */
73   enum
74   {
75     ATTR_SIZER    = 0x1,  /* browser window has resize handle  */
76     ATTR_TITLEBAR = 0x2,  /* browser window has titlebar       */
77     ATTR_BORDER   = 0x4,  /* draw black outline around browser */
78   };
79
80   /**
81    * Constructor
82    *
83    * \param scr_adr   base address of screen buffer
84    * \param scr_w     width of screen buffer
85    * \param scr_h     height of screen buffer
86    * \param doc       initial content
87    * \param w, h      initial size of the browser window
88    */
89   Browser_window(Factory *f,
90       Scout_gfx::Document *content, Scout_gfx::View *pf,
91       Area const &max_sz,
92       int attr = ATTR_SIZER | ATTR_TITLEBAR);
93
94   /**
95    * Return visible document offset
96    */
97   inline int doc_offset()
98   { return 10 + _panel->size().h() + (_attr & ATTR_TITLEBAR ? _TH : 0); }
99
100   Widget  *curr_anchor();
101   Browser *browser() { return this; }
102
103   /**
104    * Element interface
105    */
106   void draw(Mag_gfx::Canvas *c, Point const &p)
107   {
108     using Scout_gfx::Color;
109     Window::draw(c, p);
110
111     if (_attr & ATTR_BORDER)
112       {
113         Color col(0, 0, 0);
114         Rect g = Rect(p, geometry().area());
115         c->draw_box(g.top(1), col);
116         c->draw_box(g.bottom(1), col);
117         c->draw_box(g.left(1), col);
118         c->draw_box(g.right(1), col);
119       }
120   }
121 };