| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /*
- * PolyUITextInput.h
- * Poly
- *
- * Created by Ivan Safrin on 7/30/08.
- * Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
- // @package UI
- #pragma once
- #include "PolyGlobals.h"
- #include "PolyScreenLabel.h"
- #include "PolyScreenShape.h"
- #include "PolyFont.h"
- #include "PolyScreenEntity.h"
- #include "PolyUIEvent.h"
- #include "PolyUIBox.h"
- #include <vector>
- using namespace std;
- namespace Polycode {
- class _PolyExport UITextInput : public ScreenEntity {
- public:
- UITextInput(bool multiLine, float width, float height);
- ~UITextInput();
-
- void handleEvent(Event *event);
- void Update();
-
- void setText(String text);
- String getText();
- void onLoseFocus();
-
- int insertLine(bool after);
-
-
- void onKeyDown(TAUKey key, wchar_t charCode);
-
- void clearSelection();
- void setSelection(int lineStart, int lineEnd, int colStart, int colEnd);
-
- void deleteSelection();
- void selectAll();
-
- void Resize(int x, int y);
-
- String getSelectionText();
- void insertText(String text);
-
- protected:
-
- int caretSkipWordBack(int caretLine, int caretPosition);
- int caretSkipWordForward(int caretLine, int caretPosition);
-
- void selectLineFromOffset();
- void updateCaretPosition();
- void setCaretToMouse(float x, float y);
- void dragSelectionTo(float x, float y);
-
- void selectWordAtCaret();
-
- void restructLines();
- void removeLine(ScreenLabel *line);
-
- ScreenShape *selectorRectTop;
- ScreenShape *selectorRectMiddle;
- ScreenShape *selectorRectBottom;
- int numLines;
-
- float padding;
- float lineSpacing;
-
- int selectionTop;
- int selectionBottom;
- int selectionL;
- int selectionR;
-
- int selectionCaretPosition;
- int selectionLine;
-
- bool draggingSelection;
- bool hasSelection;
- float caretX,caretY;
-
- int caretPosition;
- bool doSelectToCaret;
-
- bool multiLine;
- Timer *blinkTimer;
- UIBox *inputRect;
- ScreenShape *blinkerRect;
-
- float caretImagePosition;
-
- String fontName;
- float fontSize;
-
- float lineHeight;
-
- int lineOffset;
- ScreenLabel *currentLine;
- vector<ScreenLabel*> lines;
-
- };
- }
|