1 | /*␊ |
2 | * gui.h␊ |
3 | * ␊ |
4 | *␊ |
5 | * Created by Jasmin Fazlic on 18.12.08.␊ |
6 | * Copyright 2008/09 Jasmin Fazlic All rights reserved.␊ |
7 | * Copyright 2008/09 iNDi All rights reserved.␊ |
8 | *␊ |
9 | */␊ |
10 | ␊ |
11 | #include "boot.h"␊ |
12 | #include "bootstruct.h"␊ |
13 | #include "graphics.h"␊ |
14 | #include "graphic_utils.h"␊ |
15 | #include "picopng.h"␊ |
16 | ␊ |
17 | #ifndef __BOOT2_GUI_H␊ |
18 | #define __BOOT2_GUI_H␊ |
19 | ␊ |
20 | #define CHARACTERS_COUNT 223␊ |
21 | ␊ |
22 | #define BOOT_NORMAL␉␉ 0␊ |
23 | #define BOOT_VERBOSE␉ 1␊ |
24 | #define BOOT_IGNORECACHE 2␊ |
25 | #define BOOT_SINGLEUSER␉ 3␊ |
26 | #define DO_NOT_BOOT␉␉ 4␊ |
27 | #define CLOSE_INFO_MENU 5␊ |
28 | ␊ |
29 | #define INFOMENU_NATIVEBOOT_START 1␊ |
30 | #define INFOMENU_NATIVEBOOT_END 3␊ |
31 | ␊ |
32 | #define MENU_SHOW_MEMORY_INFO 4␊ |
33 | #define MENU_SHOW_VIDEO_INFO 5␊ |
34 | #define MENU_SHOW_HELP 6␊ |
35 | ␊ |
36 | enum {␊ |
37 | ␉HorizontalLayout␉= 0,␊ |
38 | ␉VerticalLayout␉␉= 1,␊ |
39 | };␊ |
40 | ␊ |
41 | enum {␊ |
42 | kBackspaceKey␉= 0x08,␊ |
43 | kTabKey␉␉␉= 0x09,␊ |
44 | kReturnKey␉␉= 0x0d,␊ |
45 | kEscapeKey␉␉= 0x1b,␊ |
46 | kUpArrowkey␉␉= 0x4800, ␊ |
47 | kDownArrowkey␉= 0x5000,␊ |
48 | kASCIIKeyMask␉= 0x7f,␊ |
49 | kF5Key = 0x3f00,␊ |
50 | kF10Key = 0x4400␊ |
51 | };␊ |
52 | ␊ |
53 | /*␊ |
54 | * Menu item structure.␊ |
55 | */␊ |
56 | ␊ |
57 | typedef struct {␊ |
58 | ␉position_t pos;␊ |
59 | ␉char *text;␊ |
60 | ␉bool enabled;␊ |
61 | ␉bool expandable;␊ |
62 | } menuitem_t;␊ |
63 | ␊ |
64 | /*␊ |
65 | * Image structure.␊ |
66 | */␊ |
67 | typedef struct {␊ |
68 | ␉pixmap_t *image;␊ |
69 | ␉char name[32];␊ |
70 | } image_t;␊ |
71 | ␊ |
72 | /*␊ |
73 | * Font structure.␊ |
74 | */␊ |
75 | typedef struct {␊ |
76 | ␉uint16_t height;␉␉␉␉␉// Font Height ␊ |
77 | ␉uint16_t width;␉␉␉␉␉␉// Font Width for monospace font only␊ |
78 | ␉pixmap_t *chars[CHARACTERS_COUNT];␊ |
79 | } font_t;␊ |
80 | ␊ |
81 | /*␊ |
82 | * Window structure.␊ |
83 | */␊ |
84 | typedef struct␊ |
85 | {␊ |
86 | ␉position_t␉␉pos;␉␉␉␉// X,Y Position of window on screen␊ |
87 | ␉pixmap_t␉␉*pixmap;␉␉␉// Buffer␊ |
88 | ␉uint16_t␉␉width;␉␉␉␉// Width␊ |
89 | ␉uint16_t␉␉height;␉␉␉␉// Height␊ |
90 | ␉uint16_t␉␉hborder;␉␉␉// Horizontal border␊ |
91 | ␉uint16_t␉␉vborder;␉␉␉// Vertical border␊ |
92 | ␉uint16_t␉␉iconspacing;␉␉// Icon spacing␊ |
93 | ␉position_t␉␉cursor;␉␉␉␉// Text Cursor X,Y Position will be multiples of font width & height␊ |
94 | ␉uint32_t␉␉bgcolor;␉␉␉// Background color AARRGGBB␊ |
95 | ␉uint32_t␉␉fgcolor;␉␉␉// Foreground color AARRGGBB␊ |
96 | ␉uint32_t␉␉font_small_color;␉// Color for small font AARRGGBB␊ |
97 | ␉uint32_t␉␉font_console_color;␉// Color for consle font AARRGGBB␊ |
98 | ␉bool␉␉␉draw;␉␉␉␉// Draw flag␊ |
99 | } window_t;␊ |
100 | ␉␊ |
101 | /*␊ |
102 | * gui structure␊ |
103 | */␊ |
104 | typedef struct␊ |
105 | {␊ |
106 | ␉uint8_t␉␉maxdevices;␉␉␉␉//␊ |
107 | ␉uint8_t␉␉layout;␉␉␉␉␉// Horizontal or Vertical layout␊ |
108 | ␉␊ |
109 | ␉pixmap_t␉*backbuffer;␉␉␉// Off screen buffer␊ |
110 | ␊ |
111 | ␉window_t␉screen;␉␉␉␉␉// ␊ |
112 | ␉window_t␉background;␉␉␉␉// Position of background graphic within screen␊ |
113 | ␉window_t␉logo;␉␉␉␉␉// Logo␊ |
114 | ␉window_t␉bootprompt;␉␉␉␉// Bootprompt Window␊ |
115 | ␉window_t␉devicelist;␉␉␉␉// Devicelist Window␊ |
116 | ␉window_t␉infobox;␉␉␉␉// Infobox Window␊ |
117 | ␉window_t␉menu;␉␉␉␉␉// Menu␊ |
118 | ␊ |
119 | ␉window_t␉progressbar;␉␉␉// Progress bar␊ |
120 | ␉window_t␉countdown;␉␉␉␉// Countdown text␊ |
121 | ␉␊ |
122 | ␉window_t␉debug;␉␉␉␉␉// Debug␊ |
123 | ␊ |
124 | ␉bool␉␉initialised;␉␉␉// Initialised␊ |
125 | ␉bool␉␉redraw;␉␉␉␉␉// Redraw flag␊ |
126 | } gui_t;␊ |
127 | ␊ |
128 | ␊ |
129 | gui_t gui;␉␉␉␉␉␉␉␉// gui structure␊ |
130 | ␊ |
131 | font_t font_small;␊ |
132 | font_t font_console;␊ |
133 | ␊ |
134 | extern unsigned long screen_params[4];␊ |
135 | ␊ |
136 | void loadBootGraphics();␊ |
137 | ␊ |
138 | int initGUI();␊ |
139 | void drawBackground();␊ |
140 | ␊ |
141 | void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p);␊ |
142 | void drawDeviceList(int start, int end, int selection);␊ |
143 | void drawProgressBar(pixmap_t *blendInto, uint16_t width, position_t p, uint8_t progress);␊ |
144 | ␊ |
145 | void showInfoBox(char *title, char *text);␊ |
146 | ␊ |
147 | int dprintf( window_t * window, const char * fmt, ...);␊ |
148 | int gprintf( window_t * window, const char * fmt, ...);␊ |
149 | int␉ vprf(const char * fmt, va_list ap);␊ |
150 | ␊ |
151 | int drawInfoMenu();␊ |
152 | int updateInfoMenu(int key);␊ |
153 | void drawInfoMenuItems();␊ |
154 | ␊ |
155 | void showGraphicBootPrompt();␊ |
156 | void clearGraphicBootPrompt();␊ |
157 | void updateGraphicBootPrompt(int key);␊ |
158 | ␊ |
159 | void updateVRAM();␊ |
160 | ␊ |
161 | void drawStr(char *ch, font_t *font, pixmap_t *blendInto, position_t p);␊ |
162 | void drawStrCenteredAt(char *ch, font_t *font, pixmap_t *blendInto, position_t p);␊ |
163 | ␊ |
164 | #endif /* !__BOOT2_GUI_H */␊ |
165 | |