82 lines
2.3 KiB
C++
82 lines
2.3 KiB
C++
// Copyright (C) 2015 Jérôme Leclercq
|
|
// This file is part of the "Nazara Development Kit"
|
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
|
|
|
#pragma once
|
|
|
|
#ifndef NDK_WIDGETS_TEXTAREAWIDGET_HPP
|
|
#define NDK_WIDGETS_TEXTAREAWIDGET_HPP
|
|
|
|
#include <NDK/Prerequesites.hpp>
|
|
#include <NDK/BaseWidget.hpp>
|
|
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
|
#include <Nazara/Graphics/TextSprite.hpp>
|
|
|
|
namespace Ndk
|
|
{
|
|
class World;
|
|
|
|
class NDK_API TextAreaWidget : public BaseWidget
|
|
{
|
|
public:
|
|
TextAreaWidget(BaseWidget* parent = nullptr);
|
|
TextAreaWidget(const TextAreaWidget&) = delete;
|
|
TextAreaWidget(TextAreaWidget&&) = default;
|
|
~TextAreaWidget() = default;
|
|
|
|
void AppendText(const Nz::String& text);
|
|
|
|
inline void Clear();
|
|
|
|
//virtual TextAreaWidget* Clone() const = 0;
|
|
|
|
inline void EnableMultiline(bool enable = true);
|
|
|
|
inline std::size_t GetCursorPosition() const;
|
|
inline std::size_t GetLineCount() const;
|
|
inline const Nz::String& GetText() const;
|
|
|
|
std::size_t GetHoveredGlyph(float x, float y) const;
|
|
|
|
inline bool IsMultilineEnabled() const;
|
|
inline bool IsReadOnly() const;
|
|
|
|
inline void MoveCursor(int offset);
|
|
|
|
void ResizeToContent() override;
|
|
|
|
inline void SetCursorPosition(std::size_t cursorPosition);
|
|
inline void SetReadOnly(bool readOnly = true);
|
|
void SetText(const Nz::String& text);
|
|
|
|
void Write(const Nz::String& text);
|
|
|
|
TextAreaWidget& operator=(const TextAreaWidget&) = delete;
|
|
TextAreaWidget& operator=(TextAreaWidget&&) = default;
|
|
|
|
private:
|
|
void RefreshCursor();
|
|
|
|
void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override;
|
|
void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key) override;
|
|
void OnMouseEnter() override;
|
|
void OnMouseButtonPress(int /*x*/, int /*y*/, Nz::Mouse::Button button) override;
|
|
void OnMouseMoved(int x, int y, int deltaX, int deltaY) override;
|
|
void OnMouseExit() override;
|
|
void OnTextEntered(char32_t character, bool repeated) override;
|
|
|
|
EntityHandle m_cursorEntity;
|
|
EntityHandle m_textEntity;
|
|
Nz::SimpleTextDrawer m_drawer;
|
|
Nz::SpriteRef m_cursorSprite;
|
|
Nz::TextSpriteRef m_textSprite;
|
|
std::size_t m_cursorPosition;
|
|
bool m_multiLineEnabled;
|
|
bool m_readOnly;
|
|
};
|
|
}
|
|
|
|
#include <NDK/Widgets/TextAreaWidget.inl>
|
|
|
|
#endif // NDK_WIDGETS_TEXTAREAWIDGET_HPP
|