src/util/gui/font.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef GUI_FONT_H
7#define GUI_FONT_H
8
9#include "util/common.h"
10
11struct GUIFont;
12struct GUIFont* GUIFontCreate(void);
13void GUIFontDestroy(struct GUIFont*);
14
15enum GUIAlignment {
16 GUI_ALIGN_LEFT = 1,
17 GUI_ALIGN_HCENTER = 3,
18 GUI_ALIGN_RIGHT = 2,
19
20 GUI_ALIGN_TOP = 4,
21 GUI_ALIGN_VCENTER = 12,
22 GUI_ALIGN_BOTTOM = 8,
23};
24
25enum GUIOrientation {
26 GUI_ORIENT_0,
27 GUI_ORIENT_90_CCW,
28 GUI_ORIENT_180,
29 GUI_ORIENT_270_CCW,
30
31 GUI_ORIENT_VMIRROR,
32 GUI_ORIENT_HMIRROR,
33
34 GUI_ORIENT_90_CW = GUI_ORIENT_270_CCW,
35 GUI_ORIENT_270_CW = GUI_ORIENT_90_CCW
36};
37
38enum GUIIcon {
39 GUI_ICON_BATTERY_FULL,
40 GUI_ICON_BATTERY_HIGH,
41 GUI_ICON_BATTERY_HALF,
42 GUI_ICON_BATTERY_LOW,
43 GUI_ICON_BATTERY_EMPTY,
44 GUI_ICON_SCROLLBAR_THUMB,
45 GUI_ICON_SCROLLBAR_TRACK,
46 GUI_ICON_SCROLLBAR_BUTTON,
47 GUI_ICON_CURSOR,
48 GUI_ICON_POINTER,
49 GUI_ICON_BUTTON_CIRCLE,
50 GUI_ICON_BUTTON_CROSS,
51 GUI_ICON_BUTTON_TRIANGLE,
52 GUI_ICON_BUTTON_SQUARE,
53 GUI_ICON_BUTTON_HOME,
54 GUI_ICON_MAX,
55};
56
57struct GUIFontGlyphMetric {
58 int width;
59 int height;
60 struct {
61 int top;
62 int right;
63 int bottom;
64 int left;
65 } padding;
66};
67
68struct GUIIconMetric {
69 int x;
70 int y;
71 int width;
72 int height;
73};
74
75unsigned GUIFontHeight(const struct GUIFont*);
76unsigned GUIFontGlyphWidth(const struct GUIFont*, uint32_t glyph);
77unsigned GUIFontSpanWidth(const struct GUIFont*, const char* text);
78void GUIFontIconMetrics(const struct GUIFont*, enum GUIIcon icon, unsigned* w, unsigned* h);
79
80ATTRIBUTE_FORMAT(printf, 6, 7)
81void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text, ...);
82void GUIFontPrint(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text);
83void GUIFontDrawGlyph(const struct GUIFont*, int x, int y, uint32_t color, uint32_t glyph);
84void GUIFontDrawIcon(const struct GUIFont*, int x, int y, enum GUIAlignment, enum GUIOrientation, uint32_t color, enum GUIIcon);
85void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon);
86
87#endif