2015-11-21 01:14:49 +00:00
|
|
|
#ifndef SPECTER_TEXTFIELD_HPP
|
|
|
|
#define SPECTER_TEXTFIELD_HPP
|
|
|
|
|
2015-12-18 03:26:10 +00:00
|
|
|
#include "Control.hpp"
|
2015-12-17 21:28:37 +00:00
|
|
|
#include "TextView.hpp"
|
2015-12-15 21:53:15 +00:00
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
|
2015-12-18 03:26:10 +00:00
|
|
|
class TextField : public Control
|
2015-12-15 21:53:15 +00:00
|
|
|
{
|
2015-12-17 21:28:37 +00:00
|
|
|
std::string m_textStr;
|
|
|
|
std::unique_ptr<TextView> m_text;
|
|
|
|
|
2015-12-20 04:39:09 +00:00
|
|
|
SolidShaderVert m_verts[32];
|
2015-12-17 21:28:37 +00:00
|
|
|
boo::IGraphicsBufferD* m_bVertsBuf = nullptr;
|
|
|
|
boo::IVertexFormat* m_bVtxFmt = nullptr; /* OpenGL only */
|
|
|
|
boo::IShaderDataBinding* m_bShaderBinding = nullptr;
|
|
|
|
|
|
|
|
int m_nomWidth = 0;
|
|
|
|
int m_nomHeight = 0;
|
|
|
|
|
2015-12-20 04:39:09 +00:00
|
|
|
size_t m_selectionStart = 0;
|
|
|
|
size_t m_selectionCount = 0;
|
|
|
|
size_t m_cursorPos = 0;
|
|
|
|
size_t m_cursorFrames = 0;
|
|
|
|
|
|
|
|
bool m_active = false;
|
|
|
|
|
2015-12-17 21:28:37 +00:00
|
|
|
void setInactive();
|
|
|
|
void setHover();
|
|
|
|
void setDisabled();
|
|
|
|
|
2015-12-15 21:53:15 +00:00
|
|
|
public:
|
2015-12-18 03:26:10 +00:00
|
|
|
TextField(ViewResources& res, View& parentView, IStringBinding* strBind);
|
2015-12-17 21:28:37 +00:00
|
|
|
|
2015-12-20 04:39:09 +00:00
|
|
|
const std::string& getText() const {return m_textStr;}
|
2015-12-17 21:28:37 +00:00
|
|
|
void setText(const std::string& str);
|
|
|
|
|
|
|
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseMove(const boo::SWindowCoord&);
|
|
|
|
void mouseEnter(const boo::SWindowCoord&);
|
2015-12-20 04:39:09 +00:00
|
|
|
void mouseLeave(const boo::SWindowCoord&);
|
|
|
|
void charKeyDown(unsigned long, boo::EModifierKey, bool);
|
|
|
|
void specialKeyDown(boo::ESpecialKey, boo::EModifierKey, bool);
|
|
|
|
void think();
|
2015-12-17 21:28:37 +00:00
|
|
|
void resized(const boo::SWindowRect& rootView, const boo::SWindowRect& sub);
|
|
|
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
|
|
|
|
|
|
|
int nominalWidth() const {return m_nomWidth;}
|
|
|
|
int nominalHeight() const {return m_nomHeight;}
|
|
|
|
|
2015-12-20 04:39:09 +00:00
|
|
|
void setActive(bool active);
|
|
|
|
void setCursorPos(size_t pos);
|
|
|
|
|
|
|
|
void setSelectionRange(size_t start, size_t count);
|
|
|
|
void clearSelectionRange();
|
|
|
|
|
2015-12-17 21:28:37 +00:00
|
|
|
void setMultiplyColor(const Zeus::CColor& color)
|
|
|
|
{
|
|
|
|
View::setMultiplyColor(color);
|
|
|
|
m_viewVertBlock.m_color = color;
|
|
|
|
m_viewVertBlockBuf->load(&m_viewVertBlock, sizeof(ViewBlock));
|
|
|
|
m_text->setMultiplyColor(color);
|
|
|
|
}
|
2015-12-15 21:53:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-21 01:14:49 +00:00
|
|
|
#endif // SPECTER_TEXTFIELD_HPP
|