ManaPlus
textfield.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 /* _______ __ __ __ ______ __ __ _______ __ __
25  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
26  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
27  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
28  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
29  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
30  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
31  *
32  * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
33  *
34  *
35  * Per Larsson a.k.a finalman
36  * Olof Naessén a.k.a jansem/yakslem
37  *
38  * Visit: http://guichan.sourceforge.net
39  *
40  * License: (BSD)
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  * 1. Redistributions of source code must retain the above copyright
45  * notice, this list of conditions and the following disclaimer.
46  * 2. Redistributions in binary form must reproduce the above copyright
47  * notice, this list of conditions and the following disclaimer in
48  * the documentation and/or other materials provided with the
49  * distribution.
50  * 3. Neither the name of Guichan nor the names of its contributors may
51  * be used to endorse or promote products derived from this software
52  * without specific prior written permission.
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
60  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
61  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
62  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
63  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
64  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65  */
66 
67 #include "gui/widgets/textfield.h"
68 
69 #include "settings.h"
70 
71 #ifdef USE_SDL2
72 #include "enums/input/keyvalue.h"
73 #endif // USE_SDL2
74 
75 #include "gui/gui.h"
76 #include "gui/skin.h"
77 #if defined(ANDROID) || defined(__SWITCH__)
78 #include "gui/windowmanager.h"
79 #endif // ANDROID
80 
81 #include "gui/fonts/font.h"
82 
83 #include "gui/popups/popupmenu.h"
84 
85 #include "input/inputmanager.h"
86 
87 #include "utils/copynpaste.h"
88 #include "utils/stringutils.h"
89 
90 #ifndef USE_SDL2
91 #include "utils/timer.h"
92 #endif // USE_SDL2
93 
94 #include "render/graphics.h"
95 
96 #include "resources/imagerect.h"
97 
98 #include "resources/image/image.h"
99 
100 #undef DELETE // Win32 compatibility hack
101 
102 #include "debug.h"
103 
105 int TextField::instances = 0;
106 float TextField::mAlpha = 1.0;
108 
110  const std::string &restrict text,
111  const LoseFocusOnTab loseFocusOnTab,
113  const std::string &restrict eventId,
114  const bool sendAlwaysEvents) :
115  Widget(widget),
116  FocusListener(),
117  KeyListener(),
118  MouseListener(),
119  WidgetListener(),
120  mText(text),
121  mTextChunk(),
122  mCaretPosition(0),
123  mXScroll(0),
124  mCaretColor(&getThemeColor(ThemeColorId::CARET, 255U)),
125  mMinimum(0),
126  mMaximum(0),
127  mLastEventPaste(0),
128  mPadding(1),
129  mNumeric(false),
130  mLoseFocusOnTab(loseFocusOnTab),
131  mAllowSpecialActions(true),
132  mSendAlwaysEvents(sendAlwaysEvents),
133  mTextChanged(true)
134 {
135  mAllowLogic = false;
136  setFocusable(true);
137  addMouseListener(this);
138  addKeyListener(this);
139 
140  setFrameSize(2);
141  mForegroundColor = getThemeColor(ThemeColorId::TEXTFIELD, 255U);
142  mForegroundColor2 = getThemeColor(ThemeColorId::TEXTFIELD_OUTLINE, 255U);
143 
144  addFocusListener(this);
145 
146  if (instances == 0)
147  {
148  if (theme != nullptr)
149  {
151  "textfield.xml",
152  "textfield_background.xml",
153  0,
154  8);
155  }
156  }
157 
158  instances++;
159 
160  if (mSkin != nullptr)
161  {
163  mFrameSize = mSkin->getOption("frameSize", 2);
164  }
165 
166  adjustSize();
167  if (!eventId.empty())
168  setActionEventId(eventId);
169 
170  if (listener != nullptr)
172 }
173 
175 {
176  if (mWindow != nullptr)
178 
179  if (gui != nullptr)
180  gui->removeDragged(this);
181 
182  instances--;
183  if (instances == 0)
184  {
185  if (theme != nullptr)
186  {
187  theme->unload(mSkin);
188  Theme::unloadRect(skin, 0, 8);
189  }
190  }
192 }
193 
195 {
196  const float alpha = std::max(settings.guiAlpha,
198 
199  if (alpha != mAlpha)
200  {
201  mAlpha = alpha;
202  for (int a = 0; a < 9; a++)
203  {
204  if (skin.grid[a] != nullptr)
205  skin.grid[a]->setAlpha(mAlpha);
206  }
207  }
208 }
209 
210 void TextField::draw(Graphics *const graphics)
211 {
212  BLOCK_START("TextField::draw")
213  updateAlpha();
214 
215  Font *const font = getFont();
216  if (isFocused())
217  {
218  drawCaret(graphics,
219  font->getWidth(mText.substr(0, mCaretPosition)) - mXScroll);
220  }
221 
222  if (mTextChanged)
223  {
224  mTextChunk.textFont = font;
229  font->generate(mTextChunk);
230  mTextChanged = false;
231  }
232 
233  const Image *const image = mTextChunk.img;
234  if (image != nullptr)
235  graphics->drawImage(image, mPadding - mXScroll, mPadding);
236 
237  BLOCK_END("TextField::draw")
238 }
239 
240 void TextField::safeDraw(Graphics *const graphics)
241 {
242  TextField::draw(graphics);
243 }
244 
245 void TextField::drawFrame(Graphics *const graphics)
246 {
247  BLOCK_START("TextField::drawFrame")
248  const int bs = 2 * mFrameSize;
249  graphics->drawImageRect(0,
250  0,
251  mDimension.width + bs,
252  mDimension.height + bs,
253  skin);
254  BLOCK_END("TextField::drawFrame")
255 }
256 
257 void TextField::safeDrawFrame(Graphics *const graphics)
258 {
259  BLOCK_START("TextField::drawFrame")
260  const int bs = 2 * mFrameSize;
261  graphics->drawImageRect(0,
262  0,
263  mDimension.width + bs,
264  mDimension.height + bs,
265  skin);
266  BLOCK_END("TextField::drawFrame")
267 }
268 
269 void TextField::setNumeric(const bool numeric)
270 {
271  mNumeric = numeric;
272  if (!numeric)
273  return;
274 
275  const char *const text = mText.c_str();
276  for (const char *textPtr = text; *textPtr != 0; ++textPtr)
277  {
278  if (*textPtr < '0' || *textPtr > '9')
279  {
280  setText(mText.substr(0, textPtr - text));
281  return;
282  }
283  }
284 }
285 
287 {
288  if (!mNumeric)
289  return 0;
290 
291  const int value = atoi(mText.c_str());
292  if (value < mMinimum)
293  return mMinimum;
294 
295  if (value > mMaximum)
296  return mMaximum;
297 
298  return value;
299 }
300 
302 {
303  const int val = event.getKey().getValue();
304 
305 #ifdef USE_SDL2
306  if (val == KeyValue::TEXTINPUT)
307  {
308  std::string str = event.getText();
309  mText.insert(mCaretPosition, str);
310  mTextChanged = true;
311  mCaretPosition += CAST_U32(str.size());
312  event.consume();
313  fixScroll();
314  if (mSendAlwaysEvents)
316  return;
317  }
318  bool consumed(false);
319 #else // USE_SDL2
320 
321  if (val >= 32)
322  {
323  if (mNumeric)
324  {
325  if ((val >= '0' && val <= '9') ||
326  (val == '-' && mCaretPosition == 0U))
327  {
328  char buf[2];
329  buf[0] = CAST_8(val);
330  buf[1] = 0;
331  mText.insert(mCaretPosition, std::string(buf));
332  mTextChanged = true;
333  mCaretPosition += 1;
334  event.consume();
335  fixScroll();
336  if (mSendAlwaysEvents)
338  return;
339  }
340  }
341  else if ((mMaximum == 0) ||
342  CAST_S32(mText.size()) < mMaximum)
343  {
344  int len;
345  if (val < 128)
346  len = 1; // 0xxxxxxx
347  else if (val < 0x800)
348  len = 2; // 110xxxxx 10xxxxxx
349  else if (val < 0x10000)
350  len = 3; // 1110xxxx 10xxxxxx 10xxxxxx
351  else
352  len = 4; // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
353 
354  char buf[4];
355  for (int i = 0; i < len; ++ i)
356  {
357  buf[i] = CAST_8(val >> (6 * (len - i - 1)));
358  if (i > 0)
359  buf[i] = CAST_8((buf[i] & 63) | 128);
360  }
361 
362  if (len > 1)
363  buf[0] |= CAST_8(255U << (8 - len));
364 
365  mText.insert(mCaretPosition, std::string(buf, buf + len));
366  mCaretPosition += len;
367  mTextChanged = true;
368  event.consume();
369  fixScroll();
370  if (mSendAlwaysEvents)
372  return;
373  }
374  }
375 
376  /* In UTF-8, 10xxxxxx is only used for inner parts of characters. So skip
377  them when processing key presses. */
378 
379  // unblock past key
380  if (val != 22)
381  mLastEventPaste = 0;
382 
383  bool consumed(false);
384 #endif // USE_SDL2
385 
386  const InputActionT action = event.getActionId();
388  {
389  if (!handleNormalKeys(action, consumed))
390  {
391  if (consumed)
392  event.consume();
393  return;
394  }
395  }
396  else
397  {
398  handleCtrlKeys(action, consumed);
399  }
400 
401  if (mSendAlwaysEvents)
403 
404  if (consumed)
405  event.consume();
406  fixScroll();
407 }
408 
409 bool TextField::handleNormalKeys(const InputActionT action, bool &consumed)
410 {
411  PRAGMA45(GCC diagnostic push)
412  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
413  switch (action)
414  {
416  {
417  consumed = true;
418  while (mCaretPosition > 0)
419  {
420  --mCaretPosition;
421  if ((mText[mCaretPosition] & 192) != 128)
422  break;
423  }
424  break;
425  }
426 
428  {
429  consumed = true;
430  const unsigned sz = CAST_U32(mText.size());
431  while (mCaretPosition < sz)
432  {
433  ++mCaretPosition;
434  if (mCaretPosition == sz ||
435  (mText[mCaretPosition] & 192) != 128)
436  {
437  break;
438  }
439  }
440  break;
441  }
442 
444  {
445  consumed = true;
446  unsigned sz = CAST_U32(mText.size());
447  while (mCaretPosition < sz)
448  {
449  --sz;
450  mText.erase(mCaretPosition, 1);
451  mTextChanged = true;
452  if (mCaretPosition == sz ||
453  (mText[mCaretPosition] & 192) != 128)
454  {
455  break;
456  }
457  }
458  break;
459  }
460 
462  consumed = true;
464  mTextChanged = true;
465  break;
466 
469  consumed = true;
470  fixScroll();
471  return false;
472 
474  mCaretPosition = 0;
475  consumed = true;
476  break;
477 
479  mCaretPosition = CAST_U32(mText.size());
480  consumed = true;
481  break;
482 
485  return false;
486  consumed = true;
487  break;
488 
489  default:
490  break;
491  }
492  PRAGMA45(GCC diagnostic pop)
493  return true;
494 }
495 
496 void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
497 {
498  PRAGMA45(GCC diagnostic push)
499  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
500  switch (action)
501  {
503  {
505  consumed = true;
506  break;
507  }
509  {
511  consumed = true;
512  break;
513  }
514  case InputAction::GUI_B:
515  {
517  {
518  moveCaretBack();
519  consumed = true;
520  }
521  break;
522  }
523  case InputAction::GUI_F:
524  {
526  consumed = true;
527  break;
528  }
529  case InputAction::GUI_D:
530  {
531  caretDelete();
532  consumed = true;
533  break;
534  }
535  case InputAction::GUI_E:
536  {
537  mCaretPosition = CAST_S32(mText.size());
538  consumed = true;
539  break;
540  }
541  case InputAction::GUI_H:
542  {
544  mTextChanged = true;
545  consumed = true;
546  break;
547  }
548  case InputAction::GUI_K:
549  {
550  mText = mText.substr(0, mCaretPosition);
551  mTextChanged = true;
552  consumed = true;
553  break;
554  }
555  case InputAction::GUI_U:
556  {
558  consumed = true;
559  break;
560  }
561  case InputAction::GUI_C:
562  {
563  handleCopy();
564  consumed = true;
565  break;
566  }
567  case InputAction::GUI_V:
568  {
569 #ifdef USE_SDL2
570  handlePaste();
571 #else // USE_SDL2
572 
573  // hack to prevent paste key sticking
574  if ((mLastEventPaste != 0) && mLastEventPaste > cur_time)
575  break;
576  handlePaste();
578 #endif // USE_SDL2
579 
580  consumed = true;
581  break;
582  }
583  case InputAction::GUI_W:
584  {
585  caretDeleteWord();
586  consumed = true;
587  break;
588  }
589  default:
590  break;
591  }
592  PRAGMA45(GCC diagnostic pop)
593 }
594 
596 {
597  while (mCaretPosition > 0)
598  {
599  --mCaretPosition;
600  if ((mText[mCaretPosition] & 192) != 128)
601  break;
602  }
603 }
604 
606 {
607  const unsigned sz = CAST_U32(mText.size());
608  while (mCaretPosition < sz)
609  {
610  ++mCaretPosition;
611  if (mCaretPosition == sz || (mText[mCaretPosition] & 192) != 128)
612  break;
613  }
614 }
615 
617 {
618  unsigned sz = CAST_U32(mText.size());
619  while (mCaretPosition < sz)
620  {
621  --sz;
622  mText.erase(mCaretPosition, 1);
623  if (mCaretPosition == sz || (mText[mCaretPosition] & 192) != 128)
624  break;
625  }
626  mTextChanged = true;
627 }
628 
630 {
631  std::string text = getText();
632  size_t caretPos = CAST_SIZE(getCaretPosition());
633 
634  if (retrieveBuffer(text, caretPos))
635  {
636  setText(text);
637  setCaretPosition(CAST_U32(caretPos));
638  }
639 }
640 
642 {
643  if (mCaretPosition > 0)
644  {
645  mText = mText.substr(mCaretPosition);
646  mCaretPosition = 0;
647  }
648  mTextChanged = true;
649 }
650 
652 {
653  const unsigned int oldCaret = mCaretPosition;
654  while (mCaretPosition > 0)
655  {
657  break;
658  mCaretPosition --;
659  }
660  if (oldCaret != mCaretPosition)
661  return;
662  while (mCaretPosition > 0)
663  {
665  break;
666  mCaretPosition --;
667  }
668 }
669 
671 {
672  const unsigned sz = CAST_U32(mText.size());
673  const unsigned int oldCaret = mCaretPosition;
674  while (mCaretPosition < sz)
675  {
677  break;
678  mCaretPosition ++;
679  }
680  if (oldCaret != mCaretPosition)
681  return;
682  while (mCaretPosition < sz)
683  {
685  break;
686  mCaretPosition ++;
687  }
688 }
689 
691 {
692  while (mCaretPosition > 0)
693  {
696  break;
697  }
698  mTextChanged = true;
699 }
700 
702 {
703  std::string text = getText();
704  sendBuffer(text);
705 }
706 
707 void TextField::drawCaret(Graphics* graphics, int x)
708 {
709  const ClipRect &clipArea = graphics->getTopClip();
710 
711  graphics->setColor(*mCaretColor);
712  graphics->drawLine(x + mPadding, clipArea.height - mPadding,
713  x + mPadding, mPadding);
714 }
715 
717 {
718  setWidth(getFont()->getWidth(mText) + 2 * mPadding + 1);
719  adjustHeight();
720 
721  fixScroll();
722 }
723 
725 {
726  setHeight(getFont()->getHeight() + 2 * mPadding);
727 }
728 
730 {
731  if (isFocused())
732  {
733  const int caretX = getFont()->getWidth(
734  mText.substr(0, mCaretPosition));
735 
736  const int width = mDimension.width;
737  const int pad = 2 * mPadding;
738  if (caretX - mXScroll >= width - pad)
739  {
740  mXScroll = caretX - width + pad;
741  }
742  else if (caretX - mXScroll <= 0)
743  {
744  mXScroll = caretX - width / 2;
745 
746  if (mXScroll < 0)
747  mXScroll = 0;
748  }
749  }
750 }
751 
752 void TextField::setCaretPosition(unsigned int position)
753 {
754  const unsigned int sz = CAST_U32(mText.size());
755  if (position > sz)
756  mCaretPosition = CAST_S32(sz);
757  else
758  mCaretPosition = position;
759 
760  fixScroll();
761 }
762 
764 {
765  fixScroll();
766 }
767 
769 {
770 #if defined(ANDROID) || defined(__SWITCH__)
773 #endif // ANDROID
774 
775  event.consume();
776  if (event.getButton() == MouseButton::RIGHT)
777  {
778 #ifndef DYECMD
779  if (popupMenu != nullptr)
781 #endif // DYECMD
782  }
783  else if (event.getButton() == MouseButton::LEFT)
784  {
786  mText, event.getX() + mXScroll);
787  fixScroll();
788  }
789 }
790 
792 {
793 #if defined(ANDROID) || defined(__SWITCH__)
796 #endif // ANDROID
797 }
798 
800 {
801 }
802 
803 void TextField::setText(const std::string& text)
804 {
805  const unsigned int sz = CAST_U32(text.size());
806  if (sz < mCaretPosition)
807  mCaretPosition = sz;
808  mText = text;
809  mTextChanged = true;
810 }
811 
813 {
814  event.consume();
815 }
816 
818 {
819  mTextChanged = true;
821 }
822 
824 {
825  if (mWindow != nullptr)
826  mWindow->addWidgetListener(this);
827  Widget::setParent(widget);
828 }
829 
830 void TextField::setWindow(Widget *const widget)
831 {
832  if ((widget == nullptr) && (mWindow != nullptr))
833  {
835  mWindow = nullptr;
836  }
837  else
838  {
839  Widget2::setWindow(widget);
840  }
841 }
842 
844 {
846 }
volatile time_t cur_time
Definition: timer.cpp:58
#define CAST_S32
Definition: cast.h:30
#define CAST_U32
Definition: cast.h:31
#define CAST_SIZE
Definition: cast.h:34
#define CAST_8
Definition: cast.h:25
Definition: event.h:79
Definition: font.h:90
void generate(TextChunk &chunk)
Definition: font.cpp:430
int getStringIndexAt(const std::string &text, const int x) const
Definition: font.cpp:413
int getWidth(const std::string &text) const
Definition: font.cpp:334
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void setColor(const Color &color)
Definition: graphics.h:320
virtual void drawLine(int x1, int y1, int x2, int y2)=0
ClipRect & getTopClip() const
Definition: graphics.h:281
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1162
Image * grid[9]
Definition: imagerect.h:42
void executeAction(const InputActionT keyNum)
bool isActionActive(const InputActionT index) const
MouseButtonT getButton() const
Definition: mouseevent.h:116
int getX() const
Definition: mouseevent.h:127
void showTextFieldPopup(TextField *const input)
Definition: popupmenu.cpp:2172
int width
Definition: rect.h:219
int height
Definition: rect.h:224
float guiAlpha
Definition: settings.h:131
Definition: skin.h:37
int getOption(const std::string &name) const
Definition: skin.h:106
int getPadding() const
Definition: skin.h:100
void deleteImage()
Definition: textchunk.cpp:193
Font * textFont
Definition: textchunk.h:64
Image * img
Definition: textchunk.h:63
Color color
Definition: textchunk.h:66
Color color2
Definition: textchunk.h:67
std::string text
Definition: textchunk.h:65
void safeDraw(Graphics *const graphics)
Definition: textfield.cpp:240
int mMinimum
Definition: textfield.h:283
void adjustHeight()
Definition: textfield.cpp:724
static ImageRect skin
Definition: textfield.h:282
void drawFrame(Graphics *const graphics)
Definition: textfield.cpp:245
time_t mLastEventPaste
Definition: textfield.h:285
void moveCaretForward()
Definition: textfield.cpp:605
void mousePressed(MouseEvent &event)
Definition: textfield.cpp:768
int mPadding
Definition: textfield.h:286
void setNumeric(const bool numeric)
Definition: textfield.cpp:269
void handleCopy() const
Definition: textfield.cpp:701
void handleCtrlKeys(const InputActionT action, bool &consumed)
Definition: textfield.cpp:496
bool mNumeric
Definition: textfield.h:287
const Color * mCaretColor
Definition: textfield.h:279
TextChunk mTextChunk
Definition: textfield.h:265
void keyPressed(KeyEvent &event)
Definition: textfield.cpp:301
void widgetHidden(const Event &event)
Definition: textfield.cpp:817
void drawCaret(Graphics *graphics, int x)
Definition: textfield.cpp:707
static Skin * mSkin
Definition: textfield.h:258
const std::string & getText() const
Definition: textfield.h:224
bool handleNormalKeys(const InputActionT action, bool &consumed)
Definition: textfield.cpp:409
LoseFocusOnTab mLoseFocusOnTab
Definition: textfield.h:288
TextField(const Widget2 *const widget, const std::string &text, const LoseFocusOnTab loseFocusOnTab, ActionListener *const listener, const std::string &eventId, const bool sendAlwaysEvents)
Definition: textfield.cpp:109
void draw(Graphics *const graphics)
Definition: textfield.cpp:210
bool mSendAlwaysEvents
Definition: textfield.h:290
void safeDrawFrame(Graphics *const graphics)
Definition: textfield.cpp:257
void setText(const std::string &text)
Definition: textfield.cpp:803
static float mAlpha
Definition: textfield.h:281
unsigned int mCaretPosition
Definition: textfield.h:270
void handlePaste()
Definition: textfield.cpp:629
void setParent(Widget *widget)
Definition: textfield.cpp:823
int mXScroll
Definition: textfield.h:277
void setWindow(Widget *const widget)
Definition: textfield.cpp:830
void fontChanged()
Definition: textfield.cpp:763
void caretDelete()
Definition: textfield.cpp:616
unsigned int getCaretPosition() const
Definition: textfield.h:234
void adjustSize()
Definition: textfield.cpp:716
int getValue() const
Definition: textfield.cpp:286
bool mAllowSpecialActions
Definition: textfield.h:289
void setCaretPosition(unsigned int position)
Definition: textfield.cpp:752
void moveCaretWordForward()
Definition: textfield.cpp:670
void caretDeleteWord()
Definition: textfield.cpp:690
void fixScroll()
Definition: textfield.cpp:729
bool mTextChanged
Definition: textfield.h:291
void moveCaretBack()
Definition: textfield.cpp:595
void focusGained(const Event &event)
Definition: textfield.cpp:791
void mouseDragged(MouseEvent &event)
Definition: textfield.cpp:812
void updateAlpha()
Definition: textfield.cpp:194
void moveCaretWordBack()
Definition: textfield.cpp:651
void caretDeleteToStart()
Definition: textfield.cpp:641
std::string mText
Definition: textfield.h:263
void signalEvent()
Definition: textfield.cpp:843
void focusLost(const Event &event)
Definition: textfield.cpp:799
int mMaximum
Definition: textfield.h:284
static int instances
Definition: textfield.h:280
void unload(Skin *const skin)
Definition: theme.cpp:250
static void unloadRect(const ImageRect &rect, const int start, const int end)
Definition: theme.cpp:915
float getMinimumOpacity() const
Definition: theme.h:124
Skin * loadSkinRect(ImageRect &image, const std::string &name, const std::string &name2, const int start, const int end)
Definition: theme.cpp:900
virtual void setWindow(Widget *const window)
Definition: widget2.h:97
Widget * mWindow
Definition: widget2.h:112
Color mForegroundColor2
Definition: widget2.h:113
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
Definition: widget.h:99
Color mForegroundColor
Definition: widget.h:1086
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:168
void setFocusable(const bool focusable)
Definition: widget.cpp:192
void setWidth(const int width)
Definition: widget.cpp:133
void distributeActionEvent()
Definition: widget.cpp:493
Rect mDimension
Definition: widget.h:1101
unsigned int mFrameSize
Definition: widget.h:1138
bool mAllowLogic
Definition: widget.h:1160
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:292
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:302
void setHeight(const int height)
Definition: widget.cpp:140
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:272
Font * getFont() const
Definition: widget.cpp:331
virtual void setParent(Widget *parent)
Definition: widget.h:626
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:307
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
void addFocusListener(FocusListener *const focusListener)
Definition: widget.cpp:282
int getHeight() const
Definition: widget.h:240
int getWidth() const
Definition: widget.h:221
virtual bool isFocused() const
Definition: widget.cpp:184
bool sendBuffer(const std::string &text)
Definition: copynpaste.cpp:518
bool retrieveBuffer(std::string &text, size_t &pos)
Definition: copynpaste.cpp:513
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
Gui * gui
Definition: gui.cpp:111
InputAction ::T InputActionT
Definition: inputaction.h:717
InputManager inputManager
#define restrict
Definition: localconsts.h:165
#define A_UNUSED
Definition: localconsts.h:160
bool LoseFocusOnTab
const bool LoseFocusOnTab_true
@ TEXTINPUT
Definition: keyvalue.h:128
bool isKeyboardVisible()
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
PopupMenu * popupMenu
Definition: popupmenu.cpp:103
Settings settings
Definition: settings.cpp:32
void deleteCharLeft(std::string &str, unsigned *const pos)
bool isWordSeparator(const signed char chr) A_CONST
Definition: stringutils.h:142
Theme * theme
Definition: theme.cpp:62