23 #ifndef PAWS_TEXT_BOX_HEADER 24 #define PAWS_TEXT_BOX_HEADER 29 #include <csutil/parray.h> 30 #include <ivideo/fontserv.h> 31 #include <iutil/virtclk.h> 33 #include <ispellchecker.h> 92 bool Setup(iDocumentNode* node);
220 static int SkipCodePoints(
const char* text,
int start,
int count);
280 #define MESSAGE_TEXTBOX_MOUSE_SCROLL_AMOUNT 3 312 for(
unsigned int i = 0 ; i < origin.
segments.GetSize(); i++)
320 virtual bool Setup(iDocumentNode* node);
321 virtual bool Setup(
void);
338 void AddMessage(
const char* data,
int colour = -1);
340 void AppendLastMessage(
const char* data);
341 void ReplaceLastMessage(
const char* data);
346 virtual bool OnMouseDown(
int button,
int modifiers,
int x,
int y);
363 bool OnKeyDown(utf32_char code, utf32_char key,
int modifiers);
368 int RenderMessage(
const char* data,
int lineStart,
int colour);
375 void SplitMessage(
const char* newText,
int colour,
int size,
MessageLine* &msgLine,
int &startPosition);
378 void CalcLineHeight();
397 static const int INITOFFSET = 20;
398 void WriteMessageLine(
MessageLine* &msgLine, csString
text,
int colour);
399 void WriteMessageSegment(
MessageLine* &msgLine, csString
text,
int colour,
int startPosition);
400 csString FindStringThatFits(csString stringBuffer,
int canDrawLength);
405 #define EDIT_TEXTBOX_MOUSE_SCROLL_AMOUNT 3 406 #define BLINK_TICKS 1000 418 bool Setup(iDocumentNode* node);
420 bool OnKeyDown(utf32_char code, utf32_char key,
int modifiers);
424 return text.GetDataSafe();
427 void SetMultiline(
bool multi);
428 void SetPassword(
bool pass);
436 void SetText(
const char*
text,
bool publish =
true);
447 virtual bool OnMouseDown(
int button,
int modifiers,
int x,
int y);
477 topLine = newTopLine;
482 cursorPosition = pos;
494 void SetMaxLength(
unsigned int maxlen);
510 return (
unsigned int)(maxLen - text.Length());
526 spellChecked = check;
533 spellChecked = !spellChecked;
551 void checkSpelling();
612 #define MULTILINE_TEXTBOX_MOUSE_SCROLL_AMOUNT 3 620 bool Setup(iDocumentNode* node);
632 virtual bool OnMouseDown(
int button,
int modifiers,
int x,
int y);
643 void OrganizeText(
const char* text);
677 bool Setup(iDocumentNode* node);
693 virtual bool OnMouseDown(
int button,
int modifiers,
int x,
int y);
704 void SetCurrentPageNum(
int n);
705 int GetCurrentPageNum();
709 void OrganizeText(
const char* text);
753 bool Setup(iDocumentNode* node);
756 void DrawWidgetText(
const char*
text,
size_t x,
size_t y,
int style,
int fg,
int visLine);
764 void SetText(
const char*
text,
bool publish =
true);
766 void UpdateScrollBar();
767 virtual void SetupScrollBar();
771 virtual bool OnMouseUp(
int button,
int modifiers,
int x,
int y);
772 virtual bool OnMouseDown(
int button,
int modifiers,
int x,
int y);
779 virtual bool OnKeyDown(utf32_char code, utf32_char key,
int modifiers);
780 virtual void CalcMouseClick(
int x,
int y,
size_t &cursorLine,
size_t &cursorChar);
787 void PushLineInfo(
size_t lineLength,
size_t lineBreak,
int lineExtra);
811 topLine = newTopLine;
813 size_t GetCursorPosition();
814 size_t GetCursorPosition(
size_t destLine,
size_t destCursor);
817 cursorPosition = pos;
823 csString GetLine(
size_t line);
824 int GetLineWidth(
int lineNumber);
825 void GetLinePos(
size_t lineNumber,
size_t &start,
size_t &end);
826 void GetLineRelative(
size_t pos,
size_t &start,
size_t &end);
827 bool EndsWithNewLine(
int lineNumber);
828 void GetCursorLocation(
size_t pos,
size_t &destLine,
size_t &destCursor);
829 char GetAt(
size_t destLine,
size_t destCursor);
835 void SetMaxLength(
unsigned int maxlen);
851 return (
unsigned int)(maxLen -
text.Length());
867 spellChecked = check;
874 spellChecked = !spellChecked;
898 void checkSpelling();
907 void drawTextSpellChecked(iFont* font,
int x,
int y,
int fg, csString str,
int visLine);
973 #define FADE_TIME 1000 // Time for the onscreen message to fade away 974 #define MESG_TIME 3000 // Time for the onscreen message to be shown ( not including fading) 992 void GetSize(
int &w,
int &h);
994 void DrawBorderText(
const char*
text, iFont* font,
int x);
999 csRef<iFont> firstFont;
1020 unsigned int padding[4];
1054 void OrganizeContent(
const char* text);
1064 unsigned int ProcessPictureInfo(iDocumentNode* node);
1106 void OrganizeContent(
const char* text);
1116 unsigned int ProcessPictureInfo(iDocumentNode* node);
csArray< PictureInfo > picsInfo
Hold all the info parse from xml document.
bool grayed
Whether the text is currently being grayed out.
void VertAdjust(pawsVertAdjust vert)
Alters how the text box is laid out vertically in its container.
csString srcString
The file or source info for pictures.
unsigned int align
Align of the picture in.
pawsHorizAdjust
Various positions to center the text on horizontally.
csTicks blinkTicks
Keep track of ticks for flashing.
void Adjust(pawsHorizAdjust horiz, pawsVertAdjust vert)
Alters how the text box is laid out in its container.
unsigned int GetMaxLength() const
Returns the max length for the text box.
csArray< Word > words
Array that contains the boundries of the words and if the spellchecker recognizes them or not...
psPoint * letterSizes
Array containing the size of each letter in text (only used when vertical is true) ...
void SetCursorPosition(size_t pos)
int start
Position of first character that we display.
unsigned int height
Height of pictures.
virtual bool OnGainFocus(bool)
Normal text boxes should not be focused.
void SetTopLine(size_t newTopLine)
unsigned int GetRemainingChars() const
Gets the remaining characters that can be input.
csRef< iSpellChecker > spellChecker
CREATE_PAWS_FACTORY(pawsTextBox)
virtual ~pawsTextBox()
Basic deconstructor.
void SetText(const char *text)
Sets the text to display.
static int SkipCodePoints(const char *text, int start, int count)
Utility function to skip a UTF-8 string by a certain number of codepoints.
bool SelfPopulate(iDocumentNode *node)
Sets the text from the node using either the text attribute or the node's content.
int textX
X-Position of text inside the widget (relative to adjustment)
pawsScrollBar * scrollBar
unsigned int typoColour
Colour used for typos.
csString text
The text for this box.
void CalcLetterSizes()
Fills 'letterSizes' array.
int textY
X-Position of text inside the widget (relative to adjustment)
virtual int GetBorderStyle()
Gets the border style for the text box.
size_t cursorPosition
The position of the cursor blink (in code units not points)
csString text
The text for this box.
bool getSpellChecked() const
returns if the spellchecker is used in this widget
#define FADE_TIME
pawsFadingTextBox - Used for mainly on screen messages, deletes itself upon 100% fade ...
csString text
Concatenated contents of lines, only valid after GetText()
void CalcTextPos()
Calculates textX and textY attributes.
static int CountCodePoints(const char *text, int start=0, int len=-1)
Utility function to calculate number of code points in a substring.
unsigned int getTypoColour()
Method the get the current colour used for typos.
pawsVertAdjust vertAdjust
The current vertical alignment for the text box.
pawsScrollBar * vScrollBar
virtual bool OnGainFocus(bool=true)
Changes hasFocus to TRUE and reports status to parent.
virtual int GetBorderStyle()
This returns the BORDER_BUMP style.
bool Setup(iDocumentNode *)
Setup this widget.
unsigned int GetMaxLength() const
Returns the max length for the text box.
static int RewindCodePoints(const char *text, int start, int count)
Utility function to rewind a UTF-8 string by a certain number of codepoints.
virtual int GetBorderStyle()
This returns the BORDER_BUMP style.
csArray< csString > lines
The text, broken into separate lines by OrganizeText()
bool vertical
Whether the text box is rendering vertically (up-down rather than left-right)
size_t GetTopLine()
Set & Get top line funcs.
csPDelArray< MessageLine > adjusted
void SetCursorPosition(size_t pos)
pawsHorizAdjust horizAdjust
The current horizontal alignment for the text box.
PictureInfo hold the information of pictures that would be display in the same row with the same form...
bool blink
The current blink status.
csPDelArray< MessageLine > messages
List of messages this box has.
virtual ~pawsFadingTextBox()
void Grayed(bool g)
Sets if the text box is having its text grayed.
csString text
Current input line.
void setTypoColour(unsigned int col)
Method to set the colour used for typos.
csString text
The text for this box.
unsigned int maxLen
The maximum length the text is allowed to be.
struct to contain the end boundry of a word and it's spellcheck status
pawsScrollBar * scrollBar
bool spellChecked
Should the text be checked by the spellchecker plugin (if available)
csArray< PictureInfo > picsInfo
Hold all the info parse from xml document.
void CalcTextSize(int &width, int &height)
Calculates size of text.
unsigned int typoColour
Colour used for typos.
csArray< csString > lines
The text, broken into separate lines by OrganizeText()
pawsTextBox()
Basic constructor.
void toggleSpellChecked()
toggels the current setting of the spellchecker
bool blink
The current blink status.
void SetTopLine(unsigned int newTopLine)
void Draw()
Draws the text box.
unsigned int maxLen
The maximum length the text is allowed to be.
const char * GetText() const
Gets the text that is displayed by this text box.
unsigned int GetTopLine()
Set & Get top line funcs.
void setSpellChecked(const bool check)
set if the spellchecker should be used
virtual bool OnGainFocus(bool=true)
Changes hasFocus to TRUE and reports status to parent.
int textWidth
Width of vertical column of letters (only used when vertical is true)
virtual int GetBorderStyle()
This returns the BORDER_BUMP style.
int colour
The colour of the text.
pawsScrollBar * vScrollBar
csRef< iVirtualClock > clock
void FormatText(const char *fmt,...)
Sets the text to display using formatting.
void setTypoColour(unsigned int col)
Method to set the colour used for typos.
This is a special type of text box that is used for messages.
unsigned int GetRemainingChars() const
Gets the remaining characters that can be input.
csTicks blinkTicks
Keep track of ticks for flashing.
void SetVertical(bool vertical)
Sets if this text box should be rendered vertically (top to bottom)
virtual void OnUpdateData(const char *dataname, PAWSData &data)
Called whenever subscribed data gets updated Sets the text to either the data's string value or a pro...
virtual bool GetFocusOverridesControls() const
Test if the widget should intercept all key presses.
bool getSpellChecked() const
returns if the spellchecker is used in this widget
csArray< csArray< Word > > lineTypos
virtual bool GetFocusOverridesControls() const
Test if the widget should intercept all key presses.
struct to contain the end boundry of a word and it's spellcheck status
pawsScrollBar * scrollBar
bool Setup(iDocumentNode *node)
Sets up the text box from a document node Possible attributes in the node:
void toggleSpellChecked()
toggels the current setting of the spellchecker
csRef< iVirtualClock > clock
void setSpellChecked(const bool check)
set if the spellchecker should be used
unsigned int getTypoColour()
Method the get the current colour used for typos.
void HorizAdjust(pawsHorizAdjust horiz)
Alters how the text box is laid out horizontally in its container.
MessageLine(const MessageLine &origin)
virtual int GetFontColour()
Gets the font color based on the set colour and if grayed is set.
csPDelArray< MessageLine > lineInfo
unsigned int width
Width of pictures.
csArray< MessageSegment > segments
pawsVertAdjust
Various positions to center the text on vertically.
csRef< iSpellChecker > spellChecker
PS spellChecker plugin.
void SetSizeByText(int padX, int padY)
Sets the size of the widget to fit the text that it displays.