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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * 22 * Based on the original sources 23 * Faery Tale II -- The Halls of the Dead 24 * (c) 1993-1996 The Wyrmkeep Entertainment Co. 25 */ 26 27 #ifndef SAGA2_DOCUMENT_H 28 #define SAGA2_DOCUMENT_H 29 30 #include "saga2/modal.h" 31 32 namespace Saga2 { 33 34 // prototypes 35 void appendBookText(char *string = NULL); 36 void appendScrollText(char *string = NULL); 37 38 int16 openBook(uint16); 39 int16 openScroll(uint16); 40 int16 openParchment(uint16); 41 42 43 // constants 44 const uint32 bookGroupID = MKTAG('B', 'O', 'O', 'K'); 45 46 const int maxVisiblePages = 2; 47 48 enum { 49 pageLeft = 0, 50 pageRight, 51 pageUp, 52 pageDown 53 }; 54 55 enum pageOrientation { 56 pageOrientVertical = 0, 57 pageOrientHorizontal 58 }; 59 60 struct CDocumentAppearance { 61 StaticRect windowPos; // Position of window on screen 62 int16 numPages; // Number of visible pages 63 int16 orientation; // Orientation of pages 64 uint8 *textColors; // Text color array 65 StaticRect pageRect[maxVisiblePages];// Array of visible page rects 66 StaticRect closeRect; // Close-box rectangle 67 StaticWindow *decoList; // List of decorator panels 68 int16 numDecos; // Number of decorator panels 69 hResID groupID; // Resource ID for decoration group 70 hResID decoID; // Resource ID for decorations 71 }; 72 73 // Base class for scrolls, books, and parchments 74 75 class CDocument : public ModalWindow { 76 77 friend class CScroll; 78 friend class CBook; 79 80 private: 81 enum { 82 maxPages = 32, 83 maxLines = 32, 84 maxChars = 32, 85 textPictureOffset = 1 86 }; 87 88 struct ImageHeader { 89 Point16 size; 90 int16 compress; 91 int8 data[2]; 92 }; 93 94 CDocumentAppearance &app; 95 96 // image poiner array 97 void *images[maxPages]; 98 99 uint16 currentPage, 100 lineWidth, 101 pageHeight, 102 totalLines, 103 totalPages; 104 105 gFont *textFont; 106 uint16 textHeight; 107 uint16 pages; 108 uint16 numLines[maxPages]; 109 uint16 lineLen[maxPages][maxLines]; 110 uint16 lineOffset[maxPages]; 111 Extent16 imageSizes[maxPages]; 112 bool pageBreakSet; 113 114 char *scan; // for parsing book text. 115 116 // string sizes 117 uint16 maxSize; 118 uint16 textSize; 119 120 // image context 121 hResContext *illustrationCon; 122 123 private: 124 bool activate(gEventType why); // activate the control 125 void deactivate(void); 126 127 void pointerMove(gPanelMessage &msg); 128 bool pointerHit(gPanelMessage &msg); 129 void pointerDrag(gPanelMessage &msg); 130 void pointerRelease(gPanelMessage &msg); 131 bool keyStroke(gPanelMessage &msg); 132 133 protected: 134 void drawClipped( 135 gPort &port, 136 const Point16 &offset, 137 const Rect16 &clipRect); 138 139 void draw(void); // redraw the window 140 141 void renderText(void); 142 void makePages(void); 143 bool checkForPageBreak(char *string, 144 uint16 index, 145 int32 &offset); 146 147 bool checkForImage(char *string, 148 uint16 index, 149 uint16 pageIndex, 150 int32 &offset); 151 gPanel *keyTest(int16 key); 152 public: 153 char *origText; // the original text string 154 char *text; // the working text string 155 156 public: 157 CDocument(CDocumentAppearance &app, 158 char *buffer, // buffer to edit 159 gFont *font, // font of the text 160 uint16 ident, // control ID 161 AppFunc *cmd = NULL); // application command func 162 ~CDocument(void); 163 164 void gotoPage(int8 page); 165 166 APPFUNCV(cmdDocumentEsc); 167 APPFUNCV(cmdDocumentLt); 168 APPFUNCV(cmdDocumentRt); 169 APPFUNCV(cmdDocumentUp); 170 APPFUNCV(cmdDocumentDn); 171 172 // void setText( char *text ); 173 // void appendText( char *string ); 174 }; 175 176 } // end of namespace Saga2 177 178 #endif 179