OpenRCT2/src/openrct2-ui/TextComposition.h

51 lines
1.3 KiB
C
Raw Normal View History

2017-03-25 18:42:14 +01:00
/*****************************************************************************
* Copyright (c) 2014-2023 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
2017-03-25 18:42:14 +01:00
2018-05-31 00:22:19 +02:00
#pragma once
2017-03-26 04:36:22 +02:00
#include <openrct2/Context.h>
2018-06-22 23:22:29 +02:00
#include <openrct2/common.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-06-22 23:22:29 +02:00
bool _imeActive = false;
int32_t _imeStart = 0;
int32_t _imeLength = 0;
utf8 _imeBuffer[32] = {};
2017-03-25 18:42:14 +01:00
2018-02-16 00:43:16 +01:00
public:
bool IsActive();
2018-06-22 23:22:29 +02:00
TextInputSession* Start(utf8* buffer, size_t bufferSize);
2018-02-16 00:43:16 +01:00
void Stop();
2018-06-22 23:22:29 +02:00
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();
2018-06-22 23:22:29 +02:00
void Insert(const utf8* text);
2018-02-16 00:43:16 +01:00
void InsertCodepoint(codepoint_t codepoint);
void Clear();
void Delete();
void RecalculateLength();
};
2018-06-22 23:22:29 +02:00
} // namespace OpenRCT2::Ui