genode/os/src/server/nitpicker/include/draw_label.h

71 lines
1.9 KiB
C
Raw Normal View History

2011-12-22 15:19:25 +00:00
/*
* \brief Support functions for drawing outlined labels
* \author Norman Feske
* \date 2006-08-22
*/
/*
2012-01-03 14:35:05 +00:00
* Copyright (C) 2006-2012 Genode Labs GmbH
2011-12-22 15:19:25 +00:00
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _DRAW_LABEL_H_
#define _DRAW_LABEL_H_
extern Font default_font;
/*
* Gap between session label and view title in pixels
*/
enum { LABEL_GAP = 5 };
/**
* Draw black outline of string
*/
inline void draw_string_outline(Canvas *canvas, Point pos, const char *s)
{
for (int j = -1; j <= 1; j++)
for (int i = -1; i <= 1; i++)
if (i || j)
canvas->draw_string(pos + Point(i, j), &default_font, BLACK, s);
}
/**
* Return bounding box of composed label displayed with the default font
*
* \param sl session label string
* \param vt view title string
*/
inline Area label_size(const char *sl, const char *vt) {
return Area(default_font.str_w(sl) + LABEL_GAP + default_font.str_w(vt) + 2,
default_font.str_h(sl) + 2); }
/**
* Draw outlined view label
*
* View labels are composed of two parts: the session label and the view title.
* The unforgeable session label is defined on session creation by system
* policy. In contrast, the view title can individually be defined by the
* application.
*/
static void draw_label(Canvas *canvas, Point pos,
const char *session_label, Color session_label_color,
const char *view_title, Color view_title_color)
{
pos = pos + Point(1, 1);
draw_string_outline(canvas, pos, session_label);
canvas->draw_string(pos, &default_font, session_label_color, session_label);
pos = pos + Point(default_font.str_w(session_label) + LABEL_GAP, 0);
draw_string_outline(canvas, pos, view_title);
canvas->draw_string(pos, &default_font, view_title_color, view_title);
}
#endif /* _DRAW_LABEL_H_ */