Home

Dokumentation

Impressum

Dokumentation VDR
 

Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

osdbase.h

Go to the documentation of this file.
00001 
00010 #ifndef __OSDBASE_H
00011 #define __OSDBASE_H
00012 
00013 #include <stdio.h>
00014 #include "font.h"
00015 
00016 #define MAXNUMCOLORS 16
00017 
00020 enum eDvbColor {
00021 #ifdef DEBUG_OSD
00022   clrBackground,
00023   clrTransparent = clrBackground,
00024   clrBlack = clrBackground,
00025   clrRed,
00026   clrGreen,
00027   clrYellow,
00028   clrBlue,
00029   clrMagenta,
00030   clrCyan,
00031   clrWhite,
00032 #else
00033 
00035   clrTransparent = 0x00000000,
00036 
00038   clrBackground  = 0x7F000000, // 50% gray
00039 
00041   clrBlack       = 0xFF000000,
00042 
00044   clrRed         = 0xFF1414FC,
00045 
00047   clrGreen       = 0xFF24FC24,
00048 
00050   clrYellow      = 0xFF24C0FC,
00051 
00053   clrMagenta     = 0xFFFC00B0,
00054 
00056   clrBlue        = 0xFFFC0000,
00057 
00059   clrCyan        = 0xFFFCFC00,
00060 
00062   clrWhite       = 0xFFFCFCFC,
00063 #endif
00064   };
00065 
00069 
00070 class cPalette {
00071 private:
00072   eDvbColor color[MAXNUMCOLORS];
00073 
00075   int maxColors, numColors;
00076   bool used[MAXNUMCOLORS];
00077 
00079   bool fetched[MAXNUMCOLORS];
00080   bool full;
00081 protected:
00082   typedef unsigned char tIndexes[MAXNUMCOLORS];
00083 public:
00084   cPalette(int Bpp);
00085   int Index(eDvbColor Color);
00086   void Reset(void);
00087   void SetColor(int Index, eDvbColor Color);
00088   eDvbColor GetColor(int Index) { return Index < maxColors ? color[Index] : clrBlack; }
00089 
00097   const eDvbColor *NewColors(int &FirstColor, int &LastColor);
00098 
00104   const eDvbColor *AllColors(int &NumColors);
00105 
00106   void Take(const cPalette &Palette, tIndexes *Indexes = NULL);
00107   };
00108 
00110 class cBitmap : public cPalette {
00111 private:
00112   cFont *font;
00113   eDvbFont fontType;
00114   char *bitmap;
00115   bool clearWithBackground;
00116 protected:
00117   int width, height;
00118   int dirtyX1, dirtyY1, dirtyX2, dirtyY2;
00119 public:
00120   cBitmap(int Width, int Height, int Bpp, bool ClearWithBackground = true);
00121   virtual ~cBitmap();
00122   bool ClearWithBackground(void) { return clearWithBackground; }
00123   eDvbFont SetFont(eDvbFont Font);
00124   bool Dirty(int &x1, int &y1, int &x2, int &y2);
00125   void SetIndex(int x, int y, char Index);
00126   void SetPixel(int x, int y, eDvbColor Color);
00127   void SetBitmap(int x, int y, const cBitmap &Bitmap);
00128   int Width(void) { return width; }
00129   int Width(unsigned char c);
00130   int Width(const char *s);
00131   int Height(void) { return height; }
00132   void Text(int x, int y, const char *s, eDvbColor ColorFg = clrWhite, eDvbColor ColorBg = clrBackground);
00133   void Fill(int x1, int y1, int x2, int y2, eDvbColor Color);
00134   void Clean(void);
00135   void Clear(void);
00136   const char *Data(int x, int y);
00137   };
00138 
00139 #define MAXNUMWINDOWS 7 // OSD windows are counted 1...7
00140 
00142 class cWindow : public cBitmap {
00143 private:
00144 
00146   int handle;
00147 
00149   int x0, y0;
00150   int bpp;
00151   bool tiled;
00152   bool shown;
00153 public:
00154   cWindow(int Handle, int x, int y, int w, int h, int Bpp, bool ClearWithBackground, bool Tiled);
00155   int X0(void) { return x0; }
00156   int Y0(void) { return y0; }
00157   int Bpp(void) { return bpp; }
00158   bool Tiled(void) { return tiled; }
00159   bool Shown(void) { bool s = shown; shown = true; return s; }
00160   int Handle(void) { return handle; }
00161   bool Contains(int x, int y);
00162   void Relocate(int x, int y);
00163   void Fill(int x1, int y1, int x2, int y2, eDvbColor Color);
00164   void SetBitmap(int x, int y, const cBitmap &Bitmap);
00165   void Text(int x, int y, const char *s, eDvbColor ColorFg = clrWhite, eDvbColor ColorBg = clrBackground);
00166   const char *Data(int x, int y);
00167   };
00168 
00169 typedef int tWindowHandle;
00170 
00172 #define ALL_WINDOWS         (-2)
00173 #define ALL_TILED_WINDOWS   (-3)
00174 #define LAST_CREATED_WINDOW (-4)
00175 
00176 
00178 class cOsdBase {
00179 private:
00180   int numWindows;
00181   int x0, y0;
00182   cWindow *window[MAXNUMWINDOWS];
00183   cWindow *GetWindow(int x, int y);
00184   cWindow *GetWindow(tWindowHandle Window);
00185 protected:
00186   cWindow *GetWindowNr(int i) { return i < MAXNUMWINDOWS ? window[i] : NULL; }
00187   int NumWindows(void) { return numWindows; }
00188   int X0(void) { return x0; }
00189   int Y0(void) { return y0; }
00190 
00195   virtual bool OpenWindow(cWindow *Window) = 0;
00196 
00203   virtual void CommitWindow(cWindow *Window) = 0;
00204 
00208   virtual void ShowWindow(cWindow *Window) = 0;
00209 
00214   virtual void HideWindow(cWindow *Window, bool Hide) = 0;
00215 
00219   virtual void MoveWindow(cWindow *Window, int x, int y) = 0;
00220 
00224   virtual void CloseWindow(cWindow *Window) = 0;
00225 
00226 public:
00227 
00231   cOsdBase(int x, int y);
00232 
00236   virtual ~cOsdBase();
00237 
00252   tWindowHandle Create(int x, int y, int w, int h, int Bpp, bool ClearWithBackground = true, bool Tiled = true);
00253 
00261   void AddColor(eDvbColor Color, tWindowHandle Window = LAST_CREATED_WINDOW);
00262 
00266   void Flush(void);
00267 
00273   void Clear(tWindowHandle Window = ALL_TILED_WINDOWS);
00274 
00283   void Fill(int x1, int y1, int x2, int y2, eDvbColor Color, tWindowHandle Window = ALL_TILED_WINDOWS);
00284 
00289   void SetBitmap(int x, int y, const cBitmap &Bitmap, tWindowHandle Window = ALL_TILED_WINDOWS);
00290 
00294   int Width(unsigned char c);
00295 
00299   int Width(const char *s);
00300 
00304   eDvbFont SetFont(eDvbFont Font);
00305 
00311   void Text(int x, int y, const char *s, eDvbColor ColorFg = clrWhite, eDvbColor ColorBg = clrBackground, tWindowHandle Window = ALL_TILED_WINDOWS);
00312 
00318   void Relocate(tWindowHandle Window, int x, int y, int NewWidth = -1, int NewHeight = -1);
00319 
00323   void Hide(tWindowHandle Window);
00324 
00328   void Show(tWindowHandle Window);
00329   };
00330 
00331 #endif //__OSDBASE_H
00332 

Generated on Wed Feb 5 23:30:10 2003 for VDR by doxygen1.3-rc2