90 #include "utils/timer.h" 93 #include "render/graphics.h" 99 #undef DELETE // Win32 compatibility hack 112 const std::string &
restrict eventId,
113 const bool sendAlwaysEvents) :
129 mLoseFocusOnTab(loseFocusOnTab),
130 mAllowSpecialActions(true),
131 mSendAlwaysEvents(sendAlwaysEvents),
147 if (
theme !=
nullptr)
151 "textfield_background.xml",
159 if (
mSkin !=
nullptr)
166 if (!eventId.empty())
169 if (listener !=
nullptr)
184 if (
theme !=
nullptr)
201 for (
int a = 0; a < 9; a++)
233 if (image !=
nullptr)
274 const char *
const text =
mText.c_str();
275 for (
const char *textPtr = text; *textPtr != 0; ++textPtr)
277 if (*textPtr < '0' || *textPtr >
'9')
290 const int value = atoi(
mText.c_str());
302 const int val =
event.getKey().getValue();
307 std::string
str =
event.getText();
317 bool consumed(
false);
324 if ((val >=
'0' && val <=
'9') ||
346 else if (val < 0x800)
348 else if (val < 0x10000)
354 for (
int i = 0; i < len; ++ i)
356 buf[i] =
CAST_8(val >> (6 * (len - i - 1)));
358 buf[i] =
CAST_8((buf[i] & 63) | 128);
362 buf[0] |=
CAST_8(255U << (8 - len));
382 bool consumed(
false);
411 PRAGMA45(GCC diagnostic ignored
"-Wswitch-enum")
498 PRAGMA45(GCC diagnostic ignored
"-Wswitch-enum")
737 if (caretX -
mXScroll >= width - pad)
804 const unsigned int sz =
CAST_U32(text.size());
831 if ((widget ==
nullptr) && (
mWindow !=
nullptr))
void safeDrawFrame(Graphics *const graphics)
bool sendBuffer(const std::string &text)
const Color * mCaretColor
LoseFocusOnTab mLoseFocusOnTab
const bool LoseFocusOnTab_true
void unload(Skin *const skin)
ClipRect & getTopClip() const
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
MouseButtonT getButton() const
float getMinimumOpacity() const
#define BLOCK_START(name)
void setCaretPosition(unsigned int position)
void setNumeric(const bool numeric)
void focusLost(const Event &event)
void mousePressed(MouseEvent &event)
unsigned int mCaretPosition
void keyPressed(KeyEvent &event)
void drawCaret(Graphics *graphics, int x)
int getOption(const std::string &name) const
void setText(const std::string &text)
bool isWordSeparator(const signed char chr) A_CONST
TextField(const Widget2 *const widget, const std::string &text, const LoseFocusOnTab loseFocusOnTab, ActionListener *const listener, const std::string &eventId, const bool sendAlwaysEvents)
int getStringIndexAt(const std::string &text, const int x) const
void drawFrame(Graphics *const graphics)
virtual void setAlpha(const float alpha)
virtual void setColor(const Color &color)
void widgetHidden(const Event &event)
void deleteCharLeft(std::string &str, unsigned *const pos)
void handleCtrlKeys(const InputActionT action, bool &consumed)
unsigned int getCaretPosition() const
void draw(Graphics *const graphics)
Skin * loadSkinRect(ImageRect &image, const std::string &name, const std::string &name2, const int start, const int end)
void safeDraw(Graphics *const graphics)
bool retrieveBuffer(std::string &text, size_t &pos)
void setWindow(Widget *const widget)
void mouseDragged(MouseEvent &event)
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
void removeDragged(const Widget *const widget)
virtual void drawLine(int x1, int y1, int x2, int y2)=0
int getWidth(const std::string &text) const
void moveCaretWordForward()
void focusGained(const Event &event)
void caretDeleteToStart()
void setParent(Widget *widget)
static void unloadRect(const ImageRect &rect, const int start, const int end)
const std::string & getText() const
bool mAllowSpecialActions
bool handleNormalKeys(const InputActionT action, bool &consumed)
void generate(TextChunk &chunk)