forked from zfteam/rs97-commander-sdl2
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathviewer.h
executable file
·83 lines (62 loc) · 1.64 KB
/
viewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _VIEWER_H_
#define _VIEWER_H_
#include <cstddef>
#include <string>
#include <vector>
#include <SDL.h>
#include <SDL_ttf.h>
#include "def.h"
#include "screen.h"
#include "window.h"
#ifndef VIEWER_LINE_HEIGHT
#define VIEWER_LINE_HEIGHT 13
#endif
#define VIEWER_Y_LIST 18
#define VIEWER_NB_LINES ((screen.h - VIEWER_Y_LIST - 1) / VIEWER_LINE_HEIGHT + 1)
#define VIEWER_MARGIN 1
#define VIEWER_X_STEP 32
#define VIEWER_SIZE_MAX 16777216 // = 16 MB
class CViewer : public CWindow
{
public:
// Constructor
CViewer(const std::string &p_fileName);
// Destructor
virtual ~CViewer(void);
private:
// Forbidden
CViewer(void);
CViewer(const CViewer &p_source);
const CViewer &operator =(const CViewer &p_source);
// Key press management
virtual const bool keyPress(const SDL_Event &p_event);
// Key hold management
virtual const bool keyHold(void);
// Draw
virtual void render(const bool p_focus) const;
// Is window full screen?
virtual bool isFullScreen(void) const;
// Scroll (text mode only)
bool moveUp(const unsigned int p_step);
bool moveDown(const unsigned int p_step);
bool moveLeft(void);
bool moveRight(void);
// The viewed file name
std::string m_fileName;
// Coordinates
mutable SDL_Rect m_clip;
TTF_Font *m_font; // unowned
// Background image
SDL_Surface *m_background;
enum {
TEXT = 0,
IMAGE = 1,
} m_mode;
// Text mode:
std::size_t m_firstLine;
// List of read lines
std::vector<std::string> m_lines;
// Image mode:
SDL_Surface *m_image;
};
#endif