00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "bitmap.h"
00022 #include <vdr/config.h>
00023 #include <vdr/osdbase.h>
00024 #include <vdr/osd.h>
00025 #include <ctype.h>
00026
00027 using namespace SudokuPlugin;
00028
00029
00030
00031
00032
00033 Bitmap::Bitmap(int width, int height) :
00034 cBitmap(width, height, 4)
00035 {
00036 }
00037
00038
00039 Bitmap::Bitmap(int width, int height, tColor frameColor,
00040 tColor backgroundColor) :
00041 cBitmap(width, height, 4)
00042 {
00043 DrawRectangle(0, 0, width - 1, height - 1, backgroundColor);
00044 frame(0, 0, width - 1, height - 1, frameColor);
00045 }
00046
00047
00048 void Bitmap::text(const char* text, bool centered)
00049 {
00050 DrawRectangle(0, 0, Width() - 1, Height() - 1, clrWhite);
00051 frame(0, 0, Width() - 1, Height() - 1, clrRed);
00052 const cFont* font = cFont::GetFont(fontOsd);
00053 cTextWrapper wrapper(text, font, Width() - 10);
00054 int y = max((Height() - wrapper.Lines() * font->Height()) / 2, 0);
00055 for (int l = 0; l < wrapper.Lines(); ++l, y += font->Height())
00056 {
00057 int x = 0;
00058 if (centered)
00059 x = max((Width() - font->Width(wrapper.GetLine(l))) / 2, 0);
00060 DrawText(x, y, wrapper.GetLine(l), clrBlack, clrWhite, font);
00061 }
00062 }
00063
00064
00065 void Bitmap::frame(int x1, int y1, int x2, int y2, tColor frameColor)
00066 {
00067 DrawRectangle(x1, y1, x2, y1 + 1, frameColor);
00068 DrawRectangle(x1, y1, x1 + 1, y2, frameColor);
00069 DrawRectangle(x1, y2 - 1, x2, y2, frameColor);
00070 DrawRectangle(x2 - 1, y1, x2, y2, frameColor);
00071 }