OpenCores
URL https://opencores.org/ocsvn/layer2/layer2/trunk

Subversion Repositories layer2

[/] [layer2/] [trunk/] [sw/] [lib/] [include/] [ui.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 idiolatrie
/******************************************************************************
2
 * User Interface                                                             *
3
 ******************************************************************************
4
 * Copyright (C)2011  Mathias Hörtnagl <mathias.hoertnagl@gmail.com>          *
5
 *                                                                            *
6
 * This program is free software: you can redistribute it and/or modify       *
7
 * it under the terms of the GNU General Public License as published by       *
8
 * the Free Software Foundation, either version 3 of the License, or          *
9
 * (at your option) any later version.                                        *
10
 *                                                                            *
11
 * This program is distributed in the hope that it will be useful,            *
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
14
 * GNU General Public License for more details.                               *
15
 *                                                                            *
16
 * You should have received a copy of the GNU General Public License          *
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
18
 ******************************************************************************/
19
//#include "stddef.h"
20
#include "stdio.h"
21
#include "stdlib.h"
22
 
23
#ifndef _UI_H
24
#define _UI_H
25
 
26
/******************************************************************************
27
 * Box Drawing Constants                                                      *
28
 ******************************************************************************/
29
#define DOUBLE_UPPER_RIGHT       0xbb
30
#define DOUBLE_UPPER_LEFT        0xc9
31
#define DOUBLE_LOWER_RIGHT       0xbc
32
#define DOUBLE_LOWER_LEFT        0xc8
33
#define DOUBLE_HORIZONTAL        0xcd
34
#define DOUBLE_VERTICAL          0xba
35
 
36
#define DOUBLE_DOUBLE_T_LEFT     0xcc
37
#define DOUBLE_DOUBLE_T_RIGHT    0xb9
38
 
39
#define VERTICAL_BLOCK_LEFT      0xdd
40
#define VERTICAL_BLOCK_RIGHT     0xde
41
 
42
 
43
/******************************************************************************
44
 * Various Character Constants                                                *
45
 ******************************************************************************/
46
#define FULL_BOX                 0xdb
47
#define SQUARE_BOX               0xfe
48
 
49
 
50
 
51
/******************************************************************************
52
 * Window                                                                     *
53
 ******************************************************************************/
54
/* Window component identification integers. */
55
#define ID_MESSAGE         0x00
56
#define ID_MENU            0x01
57
#define ID_PROGRESS_BAR    0x02
58
 
59
/* Super class for all Window components. Each component struct contains this
60
   three variables at the beginning.
61
   The location struct 'pos' is the relative position of the item within a
62
   Window. */
63
typedef struct _WindowItem {
64
   uchar id;
65
   cursor pos;
66
} WindowItem;
67
 
68
/* Represents a Contents Box. Origin is top lefft corner. */
69
typedef struct _Box {
70
   uchar x;
71
   uchar y;
72
   uchar w;                            // Width (+ 2 for borders).
73
   uchar h;                            // Height (+ 2 for borders).
74
} Box;
75
 
76
/* A Window is a Box with a double line border and a Window title. The fore-
77
   ground and background colors can be specified.
78
   The array itemv[] contains pointers to contents elements such as Messages,
79
   Menus or ProgessBars. The integer itemc is the size of this array and must be
80
   set manually by the programmer. */
81
typedef struct _Window {
82
   Box box;                            // Spatial dimensions.
83
   color col;
84
   uchar *title;                       // Window title.
85
   uchar itemc;                        // Number of contetnts objects.
86
   void *itemv[];                      // Contents objects of the window.
87
} Window;
88
 
89
 
90
/******************************************************************************
91
 * Message                                                                    *
92
 ******************************************************************************/
93
/* A simple text string.
94
   For a Message, 'id' must be 'ID_MESSAGE'. */
95
typedef struct _Message {
96
   uchar id;
97
   cursor pos;
98
   uchar *msg;
99
} Message;
100
 
101
 
102
/******************************************************************************
103
 * Progress Bar                                                               *
104
 ******************************************************************************/
105
/* A simple progress bar.
106
   For a Message, 'id' must be 'ID_PROGRESS_BAR'. */
107
typedef struct _ProgressBar {
108
   uchar id;
109
   cursor pos;
110
   // uint max;
111
   uint val;
112
} ProgressBar;
113
 
114
 
115
/******************************************************************************
116
 * Menu                                                                       *
117
 ******************************************************************************/
118
typedef struct _MenuItem {
119
   uchar *name;
120
} MenuItem;
121
 
122
/* A vertical menu, where 'itemv[]' is a array of MenuItems and 'itemc' its
123
   size. The member 'index' inidactes the current selected MenuItem, where 0
124
   menas the first entry of the Menu.
125
   For a Message, 'id' must be 'ID_MENU'. */
126
typedef struct _Menu {
127
   uchar id;
128
   cursor pos;
129
   uchar index;
130
   uchar itemc;
131
   MenuItem *itemv[];
132
} Menu;
133
 
134
 
135
 
136
/******************************************************************************
137
 * Windows                                                                    *
138
 ******************************************************************************/
139
/* Draws a Window. */
140
extern void drawWindow(Window *win);
141
 
142
/* Prints an Error Message Window. The window is always 'wError' defined in this
143
   file. The function set the Boxes width and x-axis according to the message
144
   length. The message should not exceed 96 characters. */
145
extern void drawErrorWindow(Message *errmsg);
146
 
147
 
148
/******************************************************************************
149
 * Message                                                                    *
150
 ******************************************************************************/
151
/* Draws a simple text message.
152
   Or override an existing Message, by setting the same relativ position of the
153
   new Message 'msg' like the old message. */
154
extern void drawMessage(Window *win, Message *msg);
155
 
156
 
157
/******************************************************************************
158
 * Progress Bar                                                               *
159
 ******************************************************************************/
160
/* Draws a Progress Bar element.
161
   The value 'ProgressBar.val' must be between 0 and 63. The Window should be
162
   therefor 68 wide. */
163
extern void drawProgressBar(Window *win, ProgressBar *bar);
164
 
165
 
166
/******************************************************************************
167
 * Menus                                                                      *
168
 ******************************************************************************/
169
/* Redraw the Menu by selecting the next element of the MenuItems and set
170
   'menu.index' acordingly.
171
   If the current selected MenuItem is 'menu.itemv[menu.itemc-1]' the next
172
   MenuItem will be 'menu.itemv[0]'. */
173
extern void menuKeyDown(Window *win, Menu *menu);
174
 
175
/* Redraw the Menu by selecting the previous element of the MenuItems and set
176
   'menu.index' acordingly.
177
   If the current selected MenuItem is 'menu.itemv[0]' the next MenuItem will be
178
   'menu.itemv[menu.itemc-1]'. */
179
extern void menuKeyUp(Window *win, Menu *menu);
180
 
181
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.