2018-10-21 23:14:50 -07:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GARGOYLE_WINDOW_TEXT_BUFFER_H
|
|
|
|
#define GARGOYLE_WINDOW_TEXT_BUFFER_H
|
|
|
|
|
|
|
|
#include "gargoyle/windows.h"
|
|
|
|
#include "gargoyle/picture.h"
|
2018-10-23 19:25:00 -07:00
|
|
|
#include "gargoyle/speech.h"
|
2018-10-21 23:14:50 -07:00
|
|
|
|
|
|
|
namespace Gargoyle {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Text Buffer window
|
|
|
|
*/
|
2018-10-23 19:25:00 -07:00
|
|
|
class TextBufferWindow : public Window, Speech {
|
2018-10-21 23:14:50 -07:00
|
|
|
/**
|
|
|
|
* Structure for a row within the window
|
|
|
|
*/
|
|
|
|
struct TextBufferRow {
|
2018-10-23 19:25:00 -07:00
|
|
|
glui32 _chars[TBLINELEN];
|
|
|
|
Attributes _attrs[TBLINELEN];
|
|
|
|
int _len, _newLine;
|
|
|
|
bool _dirty, _repaint;
|
|
|
|
Picture *_lPic, *_rPic;
|
|
|
|
glui32 _lHyper, _rHyper;
|
|
|
|
int _lm, _rm;
|
2018-10-21 23:14:50 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
TextBufferRow();
|
|
|
|
};
|
|
|
|
typedef Common::Array<TextBufferRow> TextBufferRows;
|
|
|
|
private:
|
|
|
|
void reflow();
|
|
|
|
void touchScroll();
|
|
|
|
bool putPicture(Picture *pic, glui32 align, glui32 linkval);
|
2018-10-23 19:25:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @remarks Only for input text
|
|
|
|
*/
|
|
|
|
void putText(const char *buf, int len, int pos, int oldlen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remarks Only for input text
|
|
|
|
*/
|
2018-10-21 23:14:50 -07:00
|
|
|
void putTextUni(const glui32 *buf, int len, int pos, int oldlen);
|
2018-10-23 19:25:00 -07:00
|
|
|
|
|
|
|
bool flowBreak();
|
|
|
|
|
|
|
|
void acceptLine(glui32 keycode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if a following quotation mark should be an opening mark,
|
|
|
|
* false if it should be a closing mark. Opening quotation marks will
|
|
|
|
* appear following an open parenthesis, open square bracket, or
|
|
|
|
* whitespace.
|
|
|
|
*/
|
|
|
|
bool leftquote(glui32 c);
|
2018-10-21 23:14:50 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark a given text row as modified
|
|
|
|
*/
|
|
|
|
void touch(int line);
|
2018-10-23 19:25:00 -07:00
|
|
|
|
|
|
|
void scrollOneLine(bool forced);
|
|
|
|
void scrollResize();
|
|
|
|
int calcWidth(glui32 *chars, Attributes *attrs, int startchar, int numchars, int spw);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy the passed text to the clipboard
|
|
|
|
*/
|
|
|
|
void copyTextToClipboard(const glui32 *text, size_t len);
|
2018-10-21 23:14:50 -07:00
|
|
|
public:
|
|
|
|
int _width, _height;
|
|
|
|
int _spaced;
|
|
|
|
int _dashed;
|
|
|
|
|
|
|
|
TextBufferRows _lines;
|
|
|
|
int _scrollBack;
|
|
|
|
|
|
|
|
int _numChars; ///< number of chars in last line: lines[0]
|
|
|
|
glui32 *_chars; ///< alias to lines[0].chars
|
|
|
|
Attributes *_attrs; ///< alias to lines[0].attrs
|
|
|
|
|
|
|
|
///< adjust margins temporarily for images
|
|
|
|
int _ladjw;
|
|
|
|
int _ladjn;
|
|
|
|
int _radjw;
|
|
|
|
int _radjn;
|
|
|
|
|
|
|
|
/* Command history. */
|
|
|
|
glui32 *_history[HISTORYLEN];
|
|
|
|
int _historyPos;
|
|
|
|
int _historyFirst, _historyPresent;
|
|
|
|
|
|
|
|
/* for paging */
|
|
|
|
int _lastSeen;
|
|
|
|
int _scrollPos;
|
|
|
|
int _scrollMax;
|
|
|
|
|
|
|
|
/* for line input */
|
|
|
|
void *_inBuf; ///< unsigned char* for latin1, glui32* for unicode
|
|
|
|
int _inMax;
|
|
|
|
long _inFence;
|
|
|
|
long _inCurs;
|
|
|
|
Attributes _origAttr;
|
|
|
|
gidispatch_rock_t _inArrayRock;
|
|
|
|
|
|
|
|
glui32 _echoLineInput;
|
|
|
|
glui32 *_lineTerminators;
|
|
|
|
|
|
|
|
/* style hints and settings */
|
2018-10-23 19:25:00 -07:00
|
|
|
WindowStyle _styles[style_NUMSTYLES];
|
2018-10-21 23:14:50 -07:00
|
|
|
|
|
|
|
/* for copy selection */
|
|
|
|
glui32 *_copyBuf;
|
|
|
|
int _copyPos;
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
TextBufferWindow(Windows *windows, uint32 rock);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
virtual ~TextBufferWindow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rearranges the window
|
|
|
|
*/
|
|
|
|
virtual void rearrange(const Common::Rect &box) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get window split size within parent pair window
|
|
|
|
*/
|
|
|
|
virtual glui32 getSplit(glui32 size, bool vertical) const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a unicode character
|
|
|
|
*/
|
|
|
|
virtual void putCharUni(uint32 ch) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unput a unicode character
|
|
|
|
*/
|
|
|
|
virtual bool unputCharUni(uint32 ch) override;
|
|
|
|
|
|
|
|
/**
|
2018-10-23 19:25:00 -07:00
|
|
|
* Clear the window
|
2018-10-21 23:14:50 -07:00
|
|
|
*/
|
2018-10-23 19:25:00 -07:00
|
|
|
virtual void clear() override;
|
2018-10-21 23:14:50 -07:00
|
|
|
|
|
|
|
/**
|
2018-10-23 19:25:00 -07:00
|
|
|
* Click the window
|
2018-10-21 23:14:50 -07:00
|
|
|
*/
|
2018-10-23 19:25:00 -07:00
|
|
|
virtual void click(const Common::Point &newPos) override;
|
2018-10-21 23:14:50 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare for inputing a line
|
|
|
|
*/
|
|
|
|
virtual void requestLineEvent(char *buf, glui32 maxlen, glui32 initlen) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare for inputing a line
|
|
|
|
*/
|
|
|
|
virtual void requestLineEventUni(glui32 *buf, glui32 maxlen, glui32 initlen) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel an input line event
|
|
|
|
*/
|
|
|
|
virtual void cancelLineEvent(Event *ev) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel a hyperlink event
|
|
|
|
*/
|
|
|
|
virtual void cancelHyperlinkEvent() override { _hyperRequest = false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redraw the window
|
|
|
|
*/
|
|
|
|
virtual void redraw() override;
|
2018-10-23 19:25:00 -07:00
|
|
|
|
|
|
|
virtual void acceptReadLine(glui32 arg) override;
|
|
|
|
|
|
|
|
virtual void acceptReadChar(glui32 arg) override;
|
|
|
|
|
2018-10-24 22:11:29 -07:00
|
|
|
virtual void getSize(glui32 *width, glui32 *height) override;
|
|
|
|
|
2018-10-25 18:38:55 -07:00
|
|
|
virtual void requestCharEvent() override { _charRequest = true; }
|
|
|
|
|
|
|
|
virtual void requestCharEventUni() override { _charRequestUni = true; }
|
|
|
|
|
|
|
|
virtual void setEchoLineEvent(glui32 val) override { _echoLineInput = val != 0; }
|
|
|
|
|
2018-10-23 19:25:00 -07:00
|
|
|
int acceptScroll(glui32 arg);
|
2018-10-23 21:55:00 -07:00
|
|
|
|
|
|
|
glui32 drawPicture(glui32 image, glui32 align, glui32 scaled, glui32 width, glui32 height);
|
2018-10-21 23:14:50 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Gargoyle
|
|
|
|
|
|
|
|
#endif
|