OpenRCT2/src/openrct2-ui/TextComposition.h

58 lines
1.6 KiB
C
Raw Normal View History

#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
2017-03-25 18:42:14 +01:00
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 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 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
2018-05-31 00:22:19 +02:00
#pragma once
2017-03-25 18:42:14 +01:00
#include <openrct2/common.h>
2017-03-26 04:36:22 +02:00
#include <openrct2/Context.h>
2017-03-25 18:42:14 +01:00
#include <openrct2/ui/UiContext.h>
union SDL_Event;
2018-02-16 00:43:16 +01:00
namespace OpenRCT2::Ui
2017-03-25 18:42:14 +01:00
{
2018-02-16 00:43:16 +01:00
/**
* Represents a
*/
class TextComposition
2017-03-25 18:42:14 +01:00
{
2018-02-16 00:43:16 +01:00
private:
2018-06-05 15:28:19 +02:00
TextInputSession _session = {};
2017-03-25 18:42:14 +01:00
2018-02-16 00:43:16 +01:00
bool _imeActive = false;
sint32 _imeStart = 0;
sint32 _imeLength = 0;
2018-06-05 15:28:19 +02:00
utf8 _imeBuffer[32] = {};
2017-03-25 18:42:14 +01:00
2018-02-16 00:43:16 +01:00
public:
bool IsActive();
TextInputSession * Start(utf8 * buffer, size_t bufferSize);
void Stop();
void HandleMessage(const SDL_Event * e);
2017-03-25 18:42:14 +01:00
2018-02-16 00:43:16 +01:00
private:
void CursorHome();
void CursorEnd();
void CursorLeft();
void CursorRight();
void Insert(const utf8 * text);
void InsertCodepoint(codepoint_t codepoint);
void Clear();
void Delete();
void RecalculateLength();
};
2017-03-25 18:42:14 +01:00
}