46 #include "console_video.h"
92 struct board *board_setup(SDL_Surface *screen, SDL_Rect *dest,
93 SDL_Surface *font, SDL_Rect *font_rects);
94 struct board *board_setup(SDL_Surface *screen, SDL_Rect *dest,
95 SDL_Surface *font, SDL_Rect *font_rects)
104 b->font_rects = font_rects;
111 b->p_h = b->p_rect->h/FONT_H;
112 b->p_w = b->p_rect->w/FONT_W;
115 b->v_h = b->p_h * 10;
119 br.h = b->p_h * FONT_H;
120 br.w = b->p_w * FONT_W;
125 if (b->text == NULL) {
126 ast_log(LOG_WARNING,
"Unable to allocate board history memory.\n");
130 memset(b->text,
' ', b->v_w * b->v_h);
133 b->blank = SDL_CreateRGBSurface(screen->flags, br.w, br.h,
134 screen->format->BitsPerPixel,
135 screen->format->Rmask, screen->format->Gmask,
136 screen->format->Bmask, screen->format->Amask);
138 if (b->blank == NULL) {
139 ast_log(LOG_WARNING,
"Unable to allocate board virtual screen: %s\n",
145 SDL_BlitSurface(screen, b->p_rect, b->blank, &br);
154 if (0) ast_log(LOG_WARNING,
"Message board %dx%d@%d,%d successfully initialized\n",
155 b->p_rect->w, b->p_rect->h,
156 b->p_rect->x, b->p_rect->y);
165 static void render_board(
struct board *b)
167 int first_row = b->v_h - b->p_h - b->cur_line;
168 int first_char = b->v_w * first_row;
169 int last_char = first_char + b->p_h * b->v_w;
176 dst.x = b->p_rect->x;
177 dst.y = b->p_rect->y;
181 SDL_BlitSurface(b->blank, NULL, b->screen, b->p_rect);
184 for (i = first_char, col = 0; i < last_char; i++) {
185 int c = b->text[i] - 32;
188 SDL_BlitSurface(b->font, &b->font_rects[c], b->screen, &dst);
193 dst.x = b->p_rect->x;
198 SDL_UpdateRects(b->screen, 1, b->p_rect);
201 void move_message_board(
struct board *b,
int dy)
203 int cur = b->cur_line + dy;
206 else if (cur >= b->v_h - b->p_h)
207 cur = b->v_h - b->p_h - 1;
213 const char *read_message(
const struct board *b)
218 int reset_board(
struct board *b)
220 memset(b->text,
' ', b->v_w * b->v_h);
230 int print_message(
struct board *b,
const char *s)
235 if (ast_strlen_zero(s))
248 for (i = 0; i < l; i++) {
274 memcpy(b->text, b->text + row * b->v_w, b->v_w * (b->v_h - row));
276 dst = b->text + b->v_w * (b->v_h - row - 1) + b->cur_col;
277 memset(dst,
' ', b->v_w - b->cur_col + b->v_w * row);
283 dst = b->text + b->v_w * (b->v_h - row - 1);
285 for (i = 0; i < l; i++) {
323 void delete_board(
struct board *b)
330 SDL_FreeSurface(b->blank);
339 static int scroll_message(...)
341 if moving up, scroll text up;
342 if (gui->message_board.screen_cur > 0)
343 gui->message_board.screen_cur--;
344 otherwise scroll text down.
345 if ((b->screen_cur + b->p_line) < b->board_next) {
346 gui->message_board.screen_cur++;
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()