/* $Id$ * $URL$ * * simple text widget handling * * Copyright (C) 2003, 2004 Michael Reinelt * Copyright (C) 2004 The LCD4Linux Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * exported functions: * * WIDGET_CLASS Widget_Text * a simple text widget which * must be supported by all displays * */ #include "config.h" #include #include #include #include #include "debug.h" #include "cfg.h" #include "evaluator.h" #include "property.h" #include "timer.h" #include "widget.h" #include "widget_text.h" # #ifdef WITH_DMALLOC #include #endif void widget_text_scroll(void *Self) { WIDGET *W = (WIDGET *) Self; WIDGET_TEXT *T = W->data; char *prefix = P2S(&T->prefix); char *postfix = P2S(&T->postfix); char *string = T->string; int num, len, width, pad; char *src, *dst; num = 0; len = strlen(string); width = T->width - strlen(prefix) - strlen(postfix); if (width < 0) width = 0; switch (T->align) { case ALIGN_LEFT: pad = 0; break; case ALIGN_CENTER: pad = (width - len) / 2; if (pad < 0) pad = 0; break; case ALIGN_RIGHT: pad = width - len; if (pad < 0) pad = 0; break; case ALIGN_MARQUEE: pad = width - T->scroll; T->scroll++; if (T->scroll >= width + len) T->scroll = 0; break; default: /* not reached */ pad = 0; } dst = T->buffer; /* process prefix */ src = prefix; while (num < T->width) { if (*src == '\0') break; *(dst++) = *(src++); num++; } src = string; /* pad blanks on the beginning */ while (pad > 0 && num < T->width) { *(dst++) = ' '; num++; pad--; } /* skip src chars (marquee) */ while (pad < 0) { src++; pad++; } /* copy content */ while (num < T->width) { if (*src == '\0') break; *(dst++) = *(src++); num++; } /* pad blanks on the end */ src = postfix; len = strlen(src); while (num < T->width - len) { *(dst++) = ' '; num++; } /* process postfix */ while (num < T->width) { if (*src == '\0') break; *(dst++) = *(src++); num++; } *dst = '\0'; /* finally, draw it! */ if (W->class->draw) W->cl
# SBS 6 @ 74W
# freq pol sr fec

S 11744000 H 06616000 AUTO