2017-04-02 01:34:15 +03: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_MACTEXTWINDOW_H
|
|
|
|
#define GRAPHICS_MACGUI_MACTEXTWINDOW_H
|
|
|
|
|
2017-04-04 02:10:49 +03:00
|
|
|
#include "graphics/macgui/macfontmanager.h"
|
2017-04-03 04:44:53 +03:00
|
|
|
#include "graphics/macgui/mactext.h"
|
|
|
|
|
2017-04-02 01:34:15 +03:00
|
|
|
namespace Graphics {
|
|
|
|
|
2017-04-09 00:05:56 +03:00
|
|
|
struct SelectedText {
|
2017-07-18 00:01:46 +02:00
|
|
|
int startX, startY;
|
|
|
|
int endX, endY;
|
2017-08-03 09:48:01 +02:00
|
|
|
int startRow, startCol;
|
|
|
|
int endRow, endCol;
|
2017-07-18 00:01:46 +02:00
|
|
|
|
|
|
|
SelectedText() {
|
|
|
|
startX = startY = 0;
|
|
|
|
endX = endY = 0;
|
2017-08-03 09:48:01 +02:00
|
|
|
startRow = startCol = 0;
|
|
|
|
endRow = endCol = 0;
|
2017-07-18 00:01:46 +02:00
|
|
|
}
|
2017-04-09 00:05:56 +03:00
|
|
|
|
|
|
|
bool needsRender() {
|
|
|
|
return startX != endX || startY != endY;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-02 01:34:15 +03:00
|
|
|
class MacTextWindow : public MacWindow {
|
|
|
|
public:
|
2017-07-30 08:56:38 +02:00
|
|
|
MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment);
|
|
|
|
virtual ~MacTextWindow();
|
|
|
|
|
2017-08-02 21:08:46 +02:00
|
|
|
virtual void resize(int w, int h);
|
|
|
|
|
2017-07-30 08:56:38 +02:00
|
|
|
virtual bool processEvent(Common::Event &event);
|
2017-04-02 01:59:32 +03:00
|
|
|
|
2017-07-30 22:46:58 +02:00
|
|
|
virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
|
|
|
|
|
2017-07-30 09:57:11 +02:00
|
|
|
void setTextWindowFont(const MacFont *macFont);
|
2017-04-09 00:05:56 +03:00
|
|
|
const MacFont *getTextWindowFont();
|
2017-04-03 04:44:53 +03:00
|
|
|
|
2017-08-02 21:46:25 +02:00
|
|
|
void appendText(Common::String str, const MacFont *macFont, bool skipAdd = false);
|
2017-04-09 00:05:56 +03:00
|
|
|
void clearText();
|
|
|
|
|
2017-07-30 22:46:58 +02:00
|
|
|
void undrawCursor();
|
|
|
|
|
2017-07-31 20:01:39 +02:00
|
|
|
const Common::String getInput() { return _inputText; }
|
|
|
|
void clearInput();
|
|
|
|
|
2017-07-30 08:56:38 +02:00
|
|
|
private:
|
2017-08-02 21:19:37 +02:00
|
|
|
void undrawInput();
|
2017-07-30 08:56:38 +02:00
|
|
|
void drawInput();
|
2017-08-03 10:45:52 +02:00
|
|
|
void drawSelection();
|
2017-07-31 19:21:16 +02:00
|
|
|
void updateCursorPos();
|
2017-07-30 08:56:38 +02:00
|
|
|
|
2017-08-03 09:03:09 +02:00
|
|
|
void startMarking(int x, int y);
|
|
|
|
void updateTextSelection(int x, int y);
|
|
|
|
|
2017-07-30 22:46:58 +02:00
|
|
|
public:
|
|
|
|
int _cursorX, _cursorY;
|
|
|
|
bool _cursorState;
|
|
|
|
|
|
|
|
bool _cursorDirty;
|
2017-07-31 09:20:31 +02:00
|
|
|
Common::Rect *_cursorRect;
|
2017-07-30 22:46:58 +02:00
|
|
|
bool _cursorOff;
|
|
|
|
|
|
|
|
int _scrollPos;
|
|
|
|
|
2017-04-03 04:44:53 +03:00
|
|
|
private:
|
|
|
|
MacText *_mactext;
|
2017-04-09 00:05:56 +03:00
|
|
|
const MacFont *_font;
|
2017-07-30 08:56:38 +02:00
|
|
|
const Font *_fontRef;
|
2017-04-09 00:05:56 +03:00
|
|
|
|
2017-07-31 09:20:31 +02:00
|
|
|
ManagedSurface *_cursorSurface;
|
|
|
|
|
2017-08-03 09:03:09 +02:00
|
|
|
bool _inTextSelection;
|
2017-04-09 00:05:56 +03:00
|
|
|
SelectedText _selectedText;
|
2017-07-30 08:56:38 +02:00
|
|
|
|
|
|
|
int _maxWidth;
|
|
|
|
Common::String _inputText;
|
|
|
|
uint _inputTextHeight;
|
2017-08-02 17:27:47 +02:00
|
|
|
bool _inputIsDirty;
|
2017-07-30 22:46:58 +02:00
|
|
|
|
2017-04-02 01:34:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Graphics
|
|
|
|
|
|
|
|
#endif
|