trunk 20080912
[gitenigma.git] / include / lib / picviewer / pictureviewer.h
blobde16ba4aa446064bdd6fefcda03b0a17fe22bc05
1 /*
2 * $Id: pictureviewer.h,v 1.21 2007/02/20 21:57:04 ghostrider Exp $
4 * (C) 2005 by digi_casi <digi_casi@tuxbox.org>
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 2 of the License, or
9 * (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef __pictureviewer_h
23 #define __pictureviewer_h
25 #include <lib/base/estring.h>
26 #include <lib/gui/ewidget.h>
27 #include <src/enigma_main.h>
29 #define FH_ERROR_OK 0
30 #define FH_ERROR_FILE 1 /* read/access error */
31 #define FH_ERROR_FORMAT 2 /* file format error */
32 #define FH_ERROR_MALLOC 3 /* error during malloc */
34 #define dbout(fmt, args...) {struct timeval tv; gettimeofday(&tv, NULL); \
35 printf( "PV[%ld|%02ld] " fmt, (long)tv.tv_sec, (long)tv.tv_usec / 10000, ## args);}
37 class ePictureViewer: public eWidget
39 eTimer slideshowTimer;
40 std::list<eString> slideshowList;
41 std::list<eString>::iterator myIt;
42 struct cformathandler
44 struct cformathandler *next;
45 int (*get_size)(const char *, int *, int *, int, int);
46 int (*get_pic)(const char *, unsigned char *, int, int);
47 int (*id_pic)(const char *);
49 typedef struct cformathandler CFormathandler;
50 eString filename;
51 int eventHandler(const eWidgetEvent &evt);
52 void listDirectory(eString, int);
53 void nextPicture();
54 void previousPicture();
55 void showNameOnLCD(const eString& filename);
56 bool DecodeImage(const std::string& name, bool unscaled = false);
57 bool DisplayNextImage();
58 bool showBusySign;
59 bool switchto43;
60 int format169;
61 //#ifndef DISABLE_LCD
62 eZapLCD* pLCD;
63 //#else
64 public:
65 ePictureViewer(const eString &filename);
66 ~ePictureViewer();
68 enum ScalingMode
70 NONE = 0,
71 SIMPLE = 1,
72 COLOR = 2
75 bool ShowImage(const std::string& filename, bool unscaled = false);
76 void SetScaling(ScalingMode s) {m_scaling = s;}
77 void SetAspectRatio(float aspect_ratio) {m_aspect = aspect_ratio;}
78 void showBusy(int sx, int sy, int width, char r, char g, char b);
79 void hideBusy();
80 void Zoom(float factor);
81 void Move(int dx, int dy);
82 void slideshowTimeout();
83 eString GetCurrentFile() { return *myIt; }
84 private:
85 CFormathandler *fh_root;
86 ScalingMode m_scaling;
87 float m_aspect;
88 std::string m_NextPic_Name;
89 unsigned char *m_NextPic_Buffer;
90 int m_NextPic_X;
91 int m_NextPic_Y;
92 int m_NextPic_XPos;
93 int m_NextPic_YPos;
94 int m_NextPic_XPan;
95 int m_NextPic_YPan;
97 unsigned char *m_busy_buffer;
98 int m_busy_x;
99 int m_busy_y;
100 int m_busy_width;
101 int m_busy_cpp;
103 int m_startx;
104 int m_starty;
105 int m_endx;
106 int m_endy;
108 CFormathandler * fh_getsize(const char *name, int *x, int *y, int width_wanted, int height_wanted);
109 void init_handlers(void);
110 void add_format(int (*picsize)(const char *, int *, int *, int, int), int (*picread)(const char *, unsigned char *, int , int), int (*id)(const char *));
112 bool m_bFitScreen;
114 #endif