/usr/include/CEGUI/elements/CEGUIMultiLineEditbox.h is in libcegui-mk2-dev 0.7.6-3.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | /***********************************************************************
filename: CEGUIMultiLineEditbox.h
created: 30/6/2004
author: Paul D Turner
purpose: Interface to the Multi-lien edit box base class.
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIMultiLineEditbox_h_
#define _CEGUIMultiLineEditbox_h_
#include "../CEGUIBase.h"
#include "../CEGUIWindow.h"
#include "../CEGUIFont.h"
#include "CEGUIMultiLineEditboxProperties.h"
#include <vector>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Base class for multi-line edit box window renderer objects.
*/
class CEGUIEXPORT MultiLineEditboxWindowRenderer : public WindowRenderer
{
public:
/*!
\brief
Constructor
*/
MultiLineEditboxWindowRenderer(const String& name);
/*!
\brief
Return a Rect object describing, in un-clipped pixels, the window relative area
that the text should be rendered in to.
\return
Rect object describing the area of the Window to be used for rendering text.
*/
virtual Rect getTextRenderArea(void) const = 0;
protected:
// base class overrides
void onLookNFeelAssigned();
};
/*!
\brief
Base class for the multi-line edit box widget.
*/
class CEGUIEXPORT MultiLineEditbox : public Window
{
public:
static const String EventNamespace; //!< Namespace for global events
static const String WidgetTypeName; //!< Window factory name
/*************************************************************************
Constants
*************************************************************************/
// event names
/** Event fired when the read-only mode for the edit box has been changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose read-only mode
* was changed.
*/
static const String EventReadOnlyModeChanged;
/** Event fired when the word wrap mode of the edit box has been changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose word wrap
* mode was changed.
*/
static const String EventWordWrapModeChanged;
/** Event fired when the maximum allowable string length for the edit box
* has been changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose maximum string
* length was changed.
*/
static const String EventMaximumTextLengthChanged;
/** Event fired when the text caret / current insertion position is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose caret position
* has changed.
*/
static const String EventCaratMoved;
/** Event fired when the current text selection for the edit box is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose text selection
* was changed.
*/
static const String EventTextSelectionChanged;
/** Event fired when the number of characters in the edit box reaches the
* current maximum length.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose text length
* has reached the set maximum allowable length for the edit box.
*/
static const String EventEditboxFull;
/** Event fired when the mode setting that forces the display of the
* vertical scroll bar for the edit box is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose vertical
* scrollbar mode has been changed.
*/
static const String EventVertScrollbarModeChanged;
/** Event fired when the mode setting that forces the display of the
* horizontal scroll bar for the edit box is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the MultiLineEditbox whose horizontal
* scrollbar mode has been changed.
*/
static const String EventHorzScrollbarModeChanged;
/*************************************************************************
Child Widget name suffix constants
*************************************************************************/
static const String VertScrollbarNameSuffix; //!< Widget name suffix for the vertical scrollbar component.
static const String HorzScrollbarNameSuffix; //!< Widget name suffix for the horizontal scrollbar component.
/*************************************************************************
Implementation struct
*************************************************************************/
/*!
\brief
struct used to store information about a formatted line within the
paragraph.
*/
struct LineInfo
{
size_t d_startIdx; //!< Starting index for this line.
size_t d_length; //!< Code point length of this line.
float d_extent; //!< Rendered extent of this line.
};
typedef std::vector<LineInfo> LineList; //!< Type for collection of LineInfos.
/*************************************************************************
Accessor Functions
*************************************************************************/
/*!
\brief
return true if the edit box has input focus.
\return
- true if the edit box has keyboard input focus.
- false if the edit box does not have keyboard input focus.
*/
bool hasInputFocus(void) const;
/*!
\brief
return true if the edit box is read-only.
\return
- true if the edit box is read only and can't be edited by the user.
- false if the edit box is not read only and may be edited by the user.
*/
bool isReadOnly(void) const {return d_readOnly;}
/*!
\brief
return the current position of the carat.
\return
Index of the insert carat relative to the start of the text.
*/
size_t getCaratIndex(void) const {return d_caratPos;}
/*!
\brief
return the current selection start point.
\return
Index of the selection start point relative to the start of the text. If no selection is defined this function returns
the position of the carat.
*/
size_t getSelectionStartIndex(void) const;
/*!
\brief
return the current selection end point.
\return
Index of the selection end point relative to the start of the text. If no selection is defined this function returns
the position of the carat.
*/
size_t getSelectionEndIndex(void) const;
/*!
\brief
return the length of the current selection (in code points / characters).
\return
Number of code points (or characters) contained within the currently defined selection.
*/
size_t getSelectionLength(void) const;
/*!
\brief
return the maximum text length set for this edit box.
\return
The maximum number of code points (characters) that can be entered into this edit box.
*/
size_t getMaxTextLength(void) const {return d_maxTextLen;}
/*!
\brief
Return whether the text in the edit box will be word-wrapped.
\return
- true if the text will be word-wrapped at the edges of the widget frame.
- false if text will not be word-wrapped (a scroll bar will be used to access long text lines).
*/
bool isWordWrapped(void) const;
/*!
\brief
Return a pointer to the vertical scrollbar component widget for this
MultiLineEditbox.
\return
Pointer to a Scrollbar object.
\exception UnknownObjectException
Thrown if the vertical Scrollbar component does not exist.
*/
Scrollbar* getVertScrollbar() const;
/*!
\brief
Return whether the vertical scroll bar is always shown.
\return
- true if the scroll bar will always be shown even if it is not required.
- false if the scroll bar will only be shown when it is required.
*/
bool isVertScrollbarAlwaysShown(void) const;
/*!
\brief
Return a pointer to the horizontal scrollbar component widget for this
MultiLineEditbox.
\return
Pointer to a Scrollbar object.
\exception UnknownObjectException
Thrown if the horizontal Scrollbar component does not exist.
*/
Scrollbar* getHorzScrollbar() const;
/*!
\brief
Return a Rect object describing, in un-clipped pixels, the window relative area
that the text should be rendered in to.
\return
Rect object describing the area of the Window to be used for rendering text.
*/
Rect getTextRenderArea(void) const;
// get d_lines
const LineList& getFormattedLines(void) const {return d_lines;}
/*!
\brief
Return the line number a given index falls on with the current formatting. Will return last line
if index is out of range.
*/
size_t getLineNumberFromIndex(size_t index) const;
/*************************************************************************
Manipulators
*************************************************************************/
/*!
\brief
Initialise the Window based object ready for use.
\note
This must be called for every window created. Normally this is handled automatically by the WindowFactory for each Window type.
\return
Nothing
*/
virtual void initialiseComponents(void);
/*!
\brief
Specify whether the edit box is read-only.
\param setting
- true if the edit box is read only and can't be edited by the user.
- false if the edit box is not read only and may be edited by the user.
\return
Nothing.
*/
void setReadOnly(bool setting);
/*!
\brief
Set the current position of the carat.
\param carat_pos
New index for the insert carat relative to the start of the text. If the value specified is greater than the
number of characters in the edit box, the carat is positioned at the end of the text.
\return
Nothing.
*/
void setCaratIndex(size_t carat_pos);
/*!
\brief
Define the current selection for the edit box
\param start_pos
Index of the starting point for the selection. If this value is greater than the number of characters in the edit box, the
selection start will be set to the end of the text.
\param end_pos
Index of the ending point for the selection. If this value is greater than the number of characters in the edit box, the
selection start will be set to the end of the text.
\return
Nothing.
*/
void setSelection(size_t start_pos, size_t end_pos);
/*!
\brief
set the maximum text length for this edit box.
\param max_len
The maximum number of code points (characters) that can be entered into this Editbox.
\return
Nothing.
*/
void setMaxTextLength(size_t max_len);
/*!
\brief
Scroll the view so that the current carat position is visible.
*/
void ensureCaratIsVisible(void);
/*!
\brief
Set whether the text will be word wrapped or not.
\param setting
- true if the text should word-wrap at the edges of the text box.
- false if the text should not wrap, but a scroll bar should be used.
\return
Nothing.
*/
void setWordWrapping(bool setting);
/*!
\brief
Set whether the vertical scroll bar should always be shown.
\param setting
true if the vertical scroll bar should be shown even when it is not required. false if the vertical
scroll bar should only be shown when it is required.
\return
Nothing.
*/
void setShowVertScrollbar(bool setting);
// selection brush image property support
void setSelectionBrushImage(const Image* image);
const Image* getSelectionBrushImage() const;
/*************************************************************************
Construction and Destruction
*************************************************************************/
/*!
\brief
Constructor for the MultiLineEditbox base class.
*/
MultiLineEditbox(const String& type, const String& name);
/*!
\brief
Destructor for the MultiLineEditbox base class.
*/
virtual ~MultiLineEditbox(void);
protected:
/*************************************************************************
Implementation Methods (abstract)
*************************************************************************/
/*!
\brief
Return a Rect object describing, in un-clipped pixels, the window relative area
that the text should be rendered in to.
\return
Rect object describing the area of the Window to be used for rendering text.
*/
//virtual Rect getTextRenderArea_impl(void) const = 0;
/*************************************************************************
Implementation Methods
*************************************************************************/
/*!
\brief
Format the text into lines as needed by the current formatting options.
\deprecated
This is deprecated in favour of the version taking a boolean.
*/
void formatText(void);
/*!
\brief
Format the text into lines as dictated by the formatting options.
\param update_scrollbars
- true if scrollbar configuration should be performed.
- false if scrollbar configuration should not be performed.
*/
void formatText(const bool update_scrollbars);
/*!
\brief
Return the length of the next token in String \a text starting at index \a start_idx.
\note
Any single whitespace character is one token, any group of other characters is a token.
\return
The code point length of the token.
*/
size_t getNextTokenLength(const String& text, size_t start_idx) const;
/*!
\brief
display required integrated scroll bars according to current state of the edit box and update their values.
*/
void configureScrollbars(void);
/*!
\brief
Return the text code point index that is rendered closest to screen position \a pt.
\param pt
Point object describing a position on the screen in pixels.
\return
Code point index into the text that is rendered closest to screen position \a pt.
*/
size_t getTextIndexFromPosition(const Point& pt) const;
/*!
\brief
Clear the current selection setting
*/
void clearSelection(void);
/*!
\brief
Erase the currently selected text.
\param modify_text
when true, the actual text will be modified. When false, everything is done except erasing the characters.
*/
void eraseSelectedText(bool modify_text = true);
/*!
\brief
Processing for backspace key
*/
void handleBackspace(void);
/*!
\brief
Processing for Delete key
*/
void handleDelete(void);
/*!
\brief
Processing to move carat one character left
*/
void handleCharLeft(uint sysKeys);
/*!
\brief
Processing to move carat one word left
*/
void handleWordLeft(uint sysKeys);
/*!
\brief
Processing to move carat one character right
*/
void handleCharRight(uint sysKeys);
/*!
\brief
Processing to move carat one word right
*/
void handleWordRight(uint sysKeys);
/*!
\brief
Processing to move carat to the start of the text.
*/
void handleDocHome(uint sysKeys);
/*!
\brief
Processing to move carat to the end of the text
*/
void handleDocEnd(uint sysKeys);
/*!
\brief
Processing to move carat to the start of the current line.
*/
void handleLineHome(uint sysKeys);
/*!
\brief
Processing to move carat to the end of the current line
*/
void handleLineEnd(uint sysKeys);
/*!
\brief
Processing to move carat up a line.
*/
void handleLineUp(uint sysKeys);
/*!
\brief
Processing to move carat down a line.
*/
void handleLineDown(uint sysKeys);
/*!
\brief
Processing to insert a new line / paragraph.
*/
void handleNewLine(uint sysKeys);
/*!
\brief
Processing to move caret one page up
*/
void handlePageUp(uint sysKeys);
/*!
\brief
Processing to move caret one page down
*/
void handlePageDown(uint sysKeys);
/*!
\brief
Return whether this window was inherited from the given class name at some point in the inheritance hierarchy.
\param class_name
The class name that is to be checked.
\return
true if this window was inherited from \a class_name. false if not.
*/
virtual bool testClassName_impl(const String& class_name) const
{
if ((class_name=="MultiLineEditBox") ||
(class_name=="MultiLineEditbox"))
{
return true;
}
return Window::testClassName_impl(class_name);
}
/*!
\brief
Internal handler that is triggered when the user interacts with the scrollbars.
*/
bool handle_scrollChange(const EventArgs& args);
// handler triggered when vertical scrollbar is shown or hidden
bool handle_vertScrollbarVisibilityChanged(const EventArgs&);
// validate window renderer
virtual bool validateWindowRenderer(const String& name) const
{
return (name == EventNamespace);
}
/*************************************************************************
New event handlers
*************************************************************************/
/*!
\brief
Handler called when the read-only state of the edit box changes
*/
void onReadOnlyChanged(WindowEventArgs& e);
/*!
\brief
Handler called when the word wrap mode for the the edit box changes
*/
void onWordWrapModeChanged(WindowEventArgs& e);
/*!
\brief
Handler called when the maximum text length for the edit box changes
*/
void onMaximumTextLengthChanged(WindowEventArgs& e);
/*!
\brief
Handler called when the carat moves.
*/
void onCaratMoved(WindowEventArgs& e);
/*!
\brief
Handler called when the text selection changes
*/
void onTextSelectionChanged(WindowEventArgs& e);
/*!
\brief
Handler called when the edit box is full
*/
void onEditboxFullEvent(WindowEventArgs& e);
/*!
\brief
Handler called when the 'always show' setting for the vertical scroll bar changes.
*/
void onVertScrollbarModeChanged(WindowEventArgs& e);
/*!
\brief
Handler called when 'always show' setting for the horizontal scroll bar changes.
*/
void onHorzScrollbarModeChanged(WindowEventArgs& e);
/*************************************************************************
Overridden event handlers
*************************************************************************/
virtual void onMouseButtonDown(MouseEventArgs& e);
virtual void onMouseButtonUp(MouseEventArgs& e);
virtual void onMouseDoubleClicked(MouseEventArgs& e);
virtual void onMouseTripleClicked(MouseEventArgs& e);
virtual void onMouseMove(MouseEventArgs& e);
virtual void onCaptureLost(WindowEventArgs& e);
virtual void onCharacter(KeyEventArgs& e);
virtual void onKeyDown(KeyEventArgs& e);
virtual void onTextChanged(WindowEventArgs& e);
virtual void onSized(WindowEventArgs& e);
virtual void onMouseWheel(MouseEventArgs& e);
/*************************************************************************
Implementation data
*************************************************************************/
bool d_readOnly; //!< true if the edit box is in read-only mode
size_t d_maxTextLen; //!< Maximum number of characters for this Editbox.
size_t d_caratPos; //!< Position of the carat / insert-point.
size_t d_selectionStart; //!< Start of selection area.
size_t d_selectionEnd; //!< End of selection area.
bool d_dragging; //!< true when a selection is being dragged.
size_t d_dragAnchorIdx; //!< Selection index for drag selection anchor point.
static String d_lineBreakChars; //!< Holds what we consider to be line break characters.
bool d_wordWrap; //!< true when formatting uses word-wrapping.
LineList d_lines; //!< Holds the lines for the current formatting.
float d_widestExtent; //!< Holds the extent of the widest line as calculated in the last formatting pass.
// component widget settings
bool d_forceVertScroll; //!< true if vertical scrollbar should always be displayed
bool d_forceHorzScroll; //!< true if horizontal scrollbar should always be displayed
// images
const Image* d_selectionBrush; //!< Image to use as the selection brush (should be set by derived class).
private:
/*************************************************************************
Static Properties for this class
*************************************************************************/
static MultiLineEditboxProperties::ReadOnly d_readOnlyProperty;
static MultiLineEditboxProperties::WordWrap d_wordWrapProperty;
static MultiLineEditboxProperties::CaratIndex d_caratIndexProperty;
static MultiLineEditboxProperties::SelectionStart d_selectionStartProperty;
static MultiLineEditboxProperties::SelectionLength d_selectionLengthProperty;
static MultiLineEditboxProperties::MaxTextLength d_maxTextLengthProperty;
static MultiLineEditboxProperties::SelectionBrushImage d_selectionBrushProperty;
static MultiLineEditboxProperties::ForceVertScrollbar d_forceVertProperty;
/*************************************************************************
Private methods
*************************************************************************/
void addMultiLineEditboxProperties(void);
};
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _CEGUIMultiLineEditbox_h_
|