ScummVM API documentation
document.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * aint32 with this program; if not, write to the Free Software
19  *
20  *
21  * Based on the original sources
22  * Faery Tale II -- The Halls of the Dead
23  * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24  */
25 
26 #ifndef SAGA2_DOCUMENT_H
27 #define SAGA2_DOCUMENT_H
28 
29 #include "saga2/modal.h"
30 
31 namespace Saga2 {
32 
33 // prototypes
34 void appendBookText(char *string = NULL);
35 void appendScrollText(char *string = NULL);
36 
37 int16 openBook(uint16);
38 int16 openScroll(uint16);
39 int16 openParchment(uint16);
40 
41 
42 // constants
43 const uint32 kBookGroupID = MKTAG('B', 'O', 'O', 'K');
44 
45 const int kMaxVisiblePages = 2;
46 
47 enum {
48  kPageLeft = 0,
49  kPageRight,
50  kPageUp,
51  kPageDown
52 };
53 
54 enum pageOrientation {
55  kPageOrientVertical = 0,
56  kPageOrientHorizontal
57 };
58 
60  StaticRect windowPos; // Position of window on screen
61  int16 numPages; // Number of visible pages
62  int16 orientation; // Orientation of pages
63  uint8 *textColors; // Text color array
64  StaticRect pageRect[kMaxVisiblePages];// Array of visible page rects
65  StaticRect closeRect; // Close-box rectangle
66  StaticWindow *decoList; // List of decorator panels
67  int16 numDecos; // Number of decorator panels
68  hResID groupID; // Resource ID for decoration group
69  hResID decoID; // Resource ID for decorations
70 };
71 
72 // Base class for scrolls, books, and parchments
73 
74 class CDocument : public ModalWindow {
75 
76  friend class CScroll;
77  friend class CBook;
78 
79 private:
80  enum {
81  kMaxPages = 32,
82  kMaxLines = 32,
83  kMaxChars = 32,
84  kTextPictureOffset = 1
85  };
86 
87  struct ImageHeader {
88  Point16 size;
89  int16 compress;
90  int8 data[2];
91  };
92 
93  CDocumentAppearance &_app;
94 
95  // image poiner array
96  void *_images[kMaxPages];
97 
98  uint16 _currentPage,
99  _lineWidth,
100  _pageHeight,
101  _totalLines,
102  _totalPages;
103 
104  gFont *_textFont;
105  uint16 _textHeight;
106  uint16 _pages;
107  uint16 _numLines[kMaxPages];
108  uint16 _lineLen[kMaxPages][kMaxLines];
109  uint16 _lineOffset[kMaxPages];
110  Extent16 _imageSizes[kMaxPages];
111  bool _pageBreakSet;
112 
113  char *_scan; // for parsing book text.
114 
115  // string sizes
116  uint16 _maxSize;
117  uint16 _textSize;
118 
119  // image context
120  hResContext *_illustrationCon;
121 
122 private:
123  bool activate(gEventType why); // activate the control
124  void deactivate();
125 
126  void pointerMove(gPanelMessage &msg);
127  bool pointerHit(gPanelMessage &msg);
128  void pointerDrag(gPanelMessage &msg);
129  void pointerRelease(gPanelMessage &msg);
130  bool keyStroke(gPanelMessage &msg);
131 
132 protected:
133  void drawClipped(
134  gPort &port,
135  const Point16 &offset,
136  const Rect16 &clipRect);
137 
138  void draw(); // redraw the window
139 
140  void renderText();
141  void makePages();
142  bool checkForPageBreak(char *string,
143  uint16 index,
144  int32 &offset);
145 
146  bool checkForImage(char *string,
147  uint16 index,
148  uint16 pageIndex,
149  int32 &offset);
150  gPanel *keyTest(int16 key);
151 public:
152  char *origText; // the original text string
153  char *text; // the working text string
154 
155 public:
157  char *buffer, // buffer to edit
158  gFont *font, // font of the text
159  uint16 ident, // control ID
160  AppFunc *cmd = NULL); // application command func
161  ~CDocument();
162 
163  void gotoPage(int8 page);
164 
165  APPFUNCV(cmdDocumentEsc);
166  APPFUNCV(cmdDocumentLt);
167  APPFUNCV(cmdDocumentRt);
168  APPFUNCV(cmdDocumentUp);
169  APPFUNCV(cmdDocumentDn);
170 
171 // void setText( char *text );
172 // void appendText( char *string );
173 };
174 
175 } // end of namespace Saga2
176 
177 #endif
Definition: panel.h:118
Definition: document.h:59
Definition: actor.h:32
Definition: gdraw.h:178
Definition: rect.h:282
Definition: hresmgr.h:98
Definition: floating.h:55
Definition: rect.h:42
Definition: document.h:74
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: panel.h:218
Definition: gdraw.h:111
Definition: modal.h:45
Definition: rect.h:290