2021-02-07 02:50:45 +02: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-02-19 02:17:41 +02:00
|
|
|
#ifndef NANCY_UI_TEXTBOX_H
|
|
|
|
#define NANCY_UI_TEXTBOX_H
|
2021-02-07 02:50:45 +02:00
|
|
|
|
2021-04-14 21:09:05 +03:00
|
|
|
#include "engines/nancy/renderobject.h"
|
2021-02-07 02:50:45 +02:00
|
|
|
|
|
|
|
namespace Nancy {
|
|
|
|
|
|
|
|
class NancyEngine;
|
2021-02-19 02:17:41 +02:00
|
|
|
class Scene;
|
|
|
|
struct NancyInput;
|
2021-02-07 02:50:45 +02:00
|
|
|
|
2021-02-19 02:17:41 +02:00
|
|
|
namespace UI {
|
2021-02-07 02:50:45 +02:00
|
|
|
|
2021-04-14 21:09:05 +03:00
|
|
|
class Scrollbar;
|
|
|
|
|
2021-02-19 02:17:41 +02:00
|
|
|
class Textbox : public Nancy::RenderObject {
|
2021-02-07 02:50:45 +02:00
|
|
|
public:
|
2021-04-14 21:09:05 +03:00
|
|
|
Textbox(RenderObject &redrawFrom);
|
|
|
|
virtual ~Textbox();
|
2021-03-19 18:37:20 +02:00
|
|
|
|
|
|
|
virtual void init() override;
|
|
|
|
virtual void registerGraphics() override;
|
|
|
|
virtual void updateGraphics() override;
|
|
|
|
void handleInput(NancyInput &input);
|
|
|
|
|
|
|
|
void drawTextbox();
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void addTextLine(const Common::String &text);
|
|
|
|
void onScrollbarPositionChanged(float data);
|
|
|
|
|
|
|
|
static void assembleTextLine(char *rawCaption, Common::String &output, uint size);
|
2021-02-07 02:50:45 +02:00
|
|
|
|
|
|
|
private:
|
2021-03-19 18:37:20 +02:00
|
|
|
uint16 getInnerHeight() const;
|
|
|
|
void onScrollbarMove();
|
|
|
|
|
|
|
|
struct Response {
|
|
|
|
Common::String text;
|
|
|
|
Common::Rect hotspot;
|
|
|
|
};
|
|
|
|
|
|
|
|
Graphics::ManagedSurface _fullSurface;
|
|
|
|
|
2021-04-14 21:09:05 +03:00
|
|
|
Scrollbar *_scrollbar;
|
2021-03-19 18:37:20 +02:00
|
|
|
|
|
|
|
Common::Array<Common::String> _textLines;
|
|
|
|
Common::Array<Common::Rect> _hotspots;
|
|
|
|
|
|
|
|
uint16 _firstLineOffset;
|
|
|
|
uint16 _lineHeight;
|
|
|
|
uint16 _borderWidth;
|
2021-04-17 15:09:18 +03:00
|
|
|
uint16 _maxWidthDifference;
|
2021-03-19 18:37:20 +02:00
|
|
|
uint16 _numLines;
|
|
|
|
uint16 _fontID;
|
|
|
|
|
|
|
|
bool _needsTextRedraw;
|
|
|
|
float _scrollbarPos;
|
|
|
|
|
|
|
|
static const char _CCBeginToken[];
|
|
|
|
static const char _CCEndToken[];
|
|
|
|
static const char _colorBeginToken[];
|
|
|
|
static const char _colorEndToken[];
|
|
|
|
static const char _hotspotToken[];
|
|
|
|
static const char _newLineToken[];
|
|
|
|
static const char _tabToken[];
|
|
|
|
static const char _telephoneEndToken[];
|
2021-02-07 02:50:45 +02:00
|
|
|
};
|
|
|
|
|
2021-02-19 02:17:41 +02:00
|
|
|
} // End of namespace UI
|
2021-02-07 02:50:45 +02:00
|
|
|
} // End of namespace Nancy
|
|
|
|
|
2021-02-19 02:17:41 +02:00
|
|
|
#endif // NANCY_UI_TEXTBOX_H
|