scummvm/graphics/macgui/mactext.h

128 lines
3.3 KiB
C
Raw Normal View History

2016-12-14 19:20:26 +01: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 GRAPHICS_MACGUI_MACTEXT_H
#define GRAPHICS_MACGUI_MACTEXT_H
#include "graphics/fontman.h"
#include "graphics/managed_surface.h"
#include "graphics/font.h"
2016-12-14 19:20:26 +01:00
namespace Graphics {
class MacWindowManager;
2017-01-29 14:31:38 +01:00
struct MacFontRun {
uint16 fontId;
byte textSlant;
byte unk3f;
uint16 fontSize;
uint16 palinfo1;
uint16 palinfo2;
uint16 palinfo3;
const Font *font;
MacWindowManager *wm;
MacFontRun() {
wm = nullptr;
fontId = textSlant = unk3f = fontSize;
palinfo1 = palinfo2 = palinfo3;
font = nullptr;
}
MacFontRun(MacWindowManager *wm_, uint16 fontId_, byte textSlant_, byte unk3f_, uint16 fontSize_,
uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_) {
wm = wm_;
fontId = fontId_;
textSlant = textSlant_;
unk3f = unk3f_;
fontSize = fontSize_;
palinfo1 = palinfo1_;
palinfo2 = palinfo2_;
palinfo3 = palinfo3_;
font = nullptr;
}
void setValues(MacWindowManager *wm_, uint16 fontId_, byte textSlant_, byte unk3f_, uint16 fontSize_,
uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_, const Font *font_) {
wm = wm_;
fontId = fontId_;
textSlant = textSlant_;
unk3f = unk3f_;
fontSize = fontSize_;
palinfo1 = palinfo1_;
palinfo2 = palinfo2_;
palinfo3 = palinfo3_;
font = font_;
}
const Font *getFont();
2017-01-29 14:31:38 +01:00
};
2016-12-14 19:20:26 +01:00
class MacText {
public:
MacText(Common::String s, MacWindowManager *wm, const Graphics::Font *font, int fgcolor, int bgcolor,
int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft);
2016-12-14 19:20:26 +01:00
void setInterLinear(int interLinear) { _interLinear = interLinear; }
void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
void appendText(Common::String str);
void replaceLastLine(Common::String str);
void render();
Graphics::ManagedSurface *getSurface() { return _surface; }
private:
void splitString(Common::String &s);
void render(int from, int to);
void calcMaxWidth();
void reallocSurface();
2016-12-14 19:20:26 +01:00
private:
MacWindowManager *_wm;
2016-12-14 19:20:26 +01:00
Common::String _str;
const Graphics::Font *_font;
int _fgcolor, _bgcolor;
2016-12-14 19:20:26 +01:00
int _maxWidth;
int _interLinear;
Common::Array<Common::String> _text;
int _textMaxWidth;
Graphics::ManagedSurface *_surface;
bool _fullRefresh;
TextAlign _textAlignment;
Common::Array< Common::Array<MacFontRun> > _formatting;
MacFontRun _defaultFormatting;
2016-12-14 19:20:26 +01:00
};
} // End of namespace Graphics
#endif