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
|
/////////////////////////////////////////////////////////////////////////////
// Name: richtext/richtextstyles.h
// Purpose: interface of wxRichTextStyleListCtrl
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxRichTextStyleListCtrl
This class incorporates a wxRichTextStyleListBox and a choice control that
allows the user to select the category of style to view.
It is demonstrated in the wxRichTextCtrl sample in @c samples/richtext.
To use wxRichTextStyleListCtrl, add the control to your window hierarchy and
call wxRichTextStyleListCtrl::SetStyleType with one of
wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL,
wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH,
wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER and
wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST to set the current view.
Associate the control with a style sheet and rich text control with
SetStyleSheet and SetRichTextCtrl, so that when a style is double-clicked,
it is applied to the selection.
@beginStyleTable
@style{wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR}
This style hides the category selection control.
@endStyleTable
@library{wxrichtext}
@category{richtext}
*/
class wxRichTextStyleListCtrl : public wxControl
{
public:
//@{
/**
Constructors.
*/
wxRichTextStyleListCtrl(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
wxRichTextStyleListCtrl();
//@}
/**
Creates the windows.
*/
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
/**
Returns the associated rich text control, if any.
*/
wxRichTextCtrl* GetRichTextCtrl() const;
/**
Returns the wxChoice control used for selecting the style category.
*/
wxChoice* GetStyleChoice() const;
/**
Returns the wxListBox control used to view the style list.
*/
wxRichTextStyleListBox* GetStyleListBox() const;
/**
Returns the associated style sheet, if any.
*/
wxRichTextStyleSheet* GetStyleSheet() const;
/**
Returns the type of style to show in the list box.
*/
wxRichTextStyleListBox::wxRichTextStyleType GetStyleType() const;
/**
Associates the control with a wxRichTextCtrl.
*/
void SetRichTextCtrl(wxRichTextCtrl* ctrl);
/**
Associates the control with a style sheet.
*/
void SetStyleSheet(wxRichTextStyleSheet* styleSheet);
/**
Sets the style type to display.
One of
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL,
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH,
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST.
*/
void SetStyleType(wxRichTextStyleListBox::wxRichTextStyleType styleType);
/**
Updates the style list box.
*/
void UpdateStyles();
};
/**
@class wxRichTextStyleDefinition
This is a base class for paragraph and character styles.
@library{wxrichtext}
@category{richtext}
*/
class wxRichTextStyleDefinition : public wxObject
{
public:
/**
Constructor.
*/
wxRichTextStyleDefinition(const wxString& name = wxEmptyString);
/**
Destructor.
*/
virtual ~wxRichTextStyleDefinition();
/**
Returns the style on which this style is based.
*/
const wxString& GetBaseStyle() const;
/**
Returns the style's description.
*/
const wxString& GetDescription() const;
/**
Returns the style name.
*/
const wxString& GetName() const;
//@{
/**
Returns the attributes associated with this style.
*/
wxRichTextAttr GetStyle() const;
const wxRichTextAttr GetStyle() const;
//@}
/**
Returns the style attributes combined with the attributes of the specified base
style, if any. This function works recursively.
*/
virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
/**
Sets the name of the style that this style is based on.
*/
void SetBaseStyle(const wxString& name);
/**
Sets the style description.
*/
void SetDescription(const wxString& descr);
/**
Sets the name of the style.
*/
void SetName(const wxString& name);
/**
Sets the attributes for this style.
*/
void SetStyle(const wxRichTextAttr& style);
/**
Returns the definition's properties.
*/
wxRichTextProperties& GetProperties();
/**
Returns the definition's properties.
*/
const wxRichTextProperties& GetProperties() const;
/**
Sets the definition's properties.
*/
void SetProperties(const wxRichTextProperties& props);
};
/**
@class wxRichTextParagraphStyleDefinition
This class represents a paragraph style definition, usually added to a
wxRichTextStyleSheet.
@library{wxrichtext}
@category{richtext}
*/
class wxRichTextParagraphStyleDefinition : public wxRichTextStyleDefinition
{
public:
/**
Constructor.
*/
wxRichTextParagraphStyleDefinition(const wxString& name = wxEmptyString);
/**
Destructor.
*/
virtual ~wxRichTextParagraphStyleDefinition();
/**
Returns the style that should normally follow this style.
*/
const wxString& GetNextStyle() const;
/**
Sets the style that should normally follow this style.
*/
void SetNextStyle(const wxString& name);
};
/**
@class wxRichTextStyleListBox
This is a listbox that can display the styles in a wxRichTextStyleSheet,
and apply the selection to an associated wxRichTextCtrl.
See @c samples/richtext for an example of how to use it.
@library{wxrichtext}
@category{richtext}
@see wxRichTextStyleComboCtrl, @ref overview_richtextctrl
*/
class wxRichTextStyleListBox : public wxHtmlListBox
{
public:
/// Which type of style definition is currently showing?
enum wxRichTextStyleType
{
wxRICHTEXT_STYLE_ALL,
wxRICHTEXT_STYLE_PARAGRAPH,
wxRICHTEXT_STYLE_CHARACTER,
wxRICHTEXT_STYLE_LIST,
wxRICHTEXT_STYLE_BOX
};
/**
Constructor.
*/
wxRichTextStyleListBox(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
wxRichTextStyleListBox();
/**
Destructor.
*/
virtual ~wxRichTextStyleListBox();
/**
Creates the window.
*/
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
/**
Applies the @e ith style to the associated rich text control.
*/
void ApplyStyle(int i);
/**
Converts units in tenths of a millimetre to device units.
*/
int ConvertTenthsMMToPixels(wxDC& dc, int units) const;
/**
Creates a suitable HTML fragment for a definition.
*/
wxString CreateHTML(wxRichTextStyleDefinition* def) const;
/**
If the return value is @true, clicking on a style name in the list will
immediately apply the style to the associated rich text control.
*/
bool GetApplyOnSelection() const;
/**
Returns the wxRichTextCtrl associated with this listbox.
*/
wxRichTextCtrl* GetRichTextCtrl() const;
/**
Gets a style for a listbox index.
*/
wxRichTextStyleDefinition* GetStyle(size_t i) const;
/**
Returns the style sheet associated with this listbox.
*/
wxRichTextStyleSheet* GetStyleSheet() const;
/**
Returns the type of style to show in the list box.
*/
wxRichTextStyleListBox::wxRichTextStyleType GetStyleType() const;
/**
Implements left click behaviour, applying the clicked style to the
wxRichTextCtrl.
*/
void OnLeftDown(wxMouseEvent& event);
/**
If @a applyOnSelection is @true, clicking on a style name in the list will
immediately apply the style to the associated rich text control.
*/
void SetApplyOnSelection(bool applyOnSelection);
/**
Associates the listbox with a wxRichTextCtrl.
*/
void SetRichTextCtrl(wxRichTextCtrl* ctrl);
/**
Associates the control with a style sheet.
*/
void SetStyleSheet(wxRichTextStyleSheet* styleSheet);
/**
Sets the style type to display. One of
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL,
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH,
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST.
*/
void SetStyleType(wxRichTextStyleListBox::wxRichTextStyleType styleType);
/**
Updates the list from the associated style sheet.
*/
void UpdateStyles();
protected:
/**
Returns the HTML for this item.
*/
virtual wxString OnGetItem(size_t n) const;
};
/**
@class wxRichTextStyleComboCtrl
This is a combo control that can display the styles in a wxRichTextStyleSheet,
and apply the selection to an associated wxRichTextCtrl.
See @c samples/richtext for an example of how to use it.
@library{wxrichtext}
@category{richtext}
@see wxRichTextStyleListBox, @ref overview_richtextctrl
*/
class wxRichTextStyleComboCtrl : public wxComboCtrl
{
public:
/**
Constructor.
*/
wxRichTextStyleComboCtrl(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
wxRichTextStyleComboCtrl();
/**
Destructor.
*/
virtual ~wxRichTextStyleComboCtrl();
/**
Creates the windows.
*/
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
/**
Returns the wxRichTextCtrl associated with this control.
*/
wxRichTextCtrl* GetRichTextCtrl() const;
/**
Returns the style sheet associated with this control.
*/
wxRichTextStyleSheet* GetStyleSheet() const;
/**
Associates the control with a wxRichTextCtrl.
*/
void SetRichTextCtrl(wxRichTextCtrl* ctrl);
/**
Associates the control with a style sheet.
*/
void SetStyleSheet(wxRichTextStyleSheet* styleSheet);
/**
Updates the combo control from the associated style sheet.
*/
void UpdateStyles();
};
/**
@class wxRichTextCharacterStyleDefinition
This class represents a character style definition, usually added to a
wxRichTextStyleSheet.
@library{wxrichtext}
@category{richtext}
*/
class wxRichTextCharacterStyleDefinition : public wxRichTextStyleDefinition
{
public:
/**
Constructor.
*/
wxRichTextCharacterStyleDefinition(const wxString& name = wxEmptyString);
/**
Destructor.
*/
virtual ~wxRichTextCharacterStyleDefinition();
};
/**
@class wxRichTextListStyleDefinition
This class represents a list style definition, usually added to a
wxRichTextStyleSheet.
The class inherits paragraph attributes from wxRichTextStyleParagraphDefinition,
and adds 10 further attribute objects, one for each level of a list.
When applying a list style to a paragraph, the list style's base and
appropriate level attributes are merged with the paragraph's existing attributes.
You can apply a list style to one or more paragraphs using wxRichTextCtrl::SetListStyle.
You can also use the functions wxRichTextCtrl::NumberList, wxRichTextCtrl::PromoteList and
wxRichTextCtrl::ClearListStyle.
As usual, there are wxRichTextBuffer versions of these functions
so that you can apply them directly to a buffer without requiring a control.
@library{wxrichtext}
@category{richtext}
*/
class wxRichTextListStyleDefinition : public wxRichTextParagraphStyleDefinition
{
public:
/**
Constructor.
*/
wxRichTextListStyleDefinition(const wxString& name = wxEmptyString);
/**
Destructor.
*/
virtual ~wxRichTextListStyleDefinition();
/**
This function combines the given paragraph style with the list style's base
attributes and level style matching the given indent, returning the combined attributes.
If @a styleSheet is specified, the base style for this definition will also be
included in the result.
*/
wxRichTextAttr CombineWithParagraphStyle(int indent,
const wxRichTextAttr& paraStyle,
wxRichTextStyleSheet* styleSheet = NULL);
/**
This function finds the level (from 0 to 9) whose indentation attribute mostly
closely matches @a indent (expressed in tenths of a millimetre).
*/
int FindLevelForIndent(int indent) const;
/**
This function combines the list style's base attributes and the level style
matching the given indent, returning the combined attributes.
If @a styleSheet is specified, the base style for this definition will also be
included in the result.
*/
wxRichTextAttr GetCombinedStyle(int indent,
wxRichTextStyleSheet* styleSheet = NULL);
/**
This function combines the list style's base attributes and the style for the
specified level, returning the combined attributes.
If @a styleSheet is specified, the base style for this definition will also be
included in the result.
*/
wxRichTextAttr GetCombinedStyleForLevel(int level,
wxRichTextStyleSheet* styleSheet = NULL);
/**
Returns the style for the given level. @a level is a number between 0 and 9.
*/
const wxRichTextAttr* GetLevelAttributes(int level) const;
/**
Returns the number of levels. This is hard-wired to 10.
Returns the style for the given level. @e level is a number between 0 and 9.
*/
int GetLevelCount() const;
/**
Returns @true if the given level has numbered list attributes.
*/
bool IsNumbered(int level) const;
/**
Sets the style for the given level. @a level is a number between 0 and 9.
The first and most flexible form uses a wxTextAttr object, while the second
form is for convenient setting of the most commonly-used attributes.
*/
void SetLevelAttributes(int level, const wxRichTextAttr& attr);
};
/**
@class wxRichTextStyleSheet
A style sheet contains named paragraph and character styles that make it
easy for a user to apply combinations of attributes to a wxRichTextCtrl.
You can use a wxRichTextStyleListBox in your user interface to show available
styles to the user, and allow application of styles to the control.
@library{wxrichtext}
@category{richtext}
*/
class wxRichTextStyleSheet : public wxObject
{
public:
/**
Constructor.
*/
wxRichTextStyleSheet();
/**
Destructor.
*/
virtual ~wxRichTextStyleSheet();
/**
Adds a definition to the character style list.
*/
bool AddCharacterStyle(wxRichTextCharacterStyleDefinition* def);
/**
Adds a definition to the list style list.
*/
bool AddListStyle(wxRichTextListStyleDefinition* def);
/**
Adds a definition to the paragraph style list.
*/
bool AddParagraphStyle(wxRichTextParagraphStyleDefinition* def);
/**
Adds a definition to the appropriate style list.
*/
bool AddStyle(wxRichTextStyleDefinition* def);
/**
Deletes all styles.
*/
void DeleteStyles();
/**
Finds a character definition by name.
*/
wxRichTextCharacterStyleDefinition* FindCharacterStyle(const wxString& name,
bool recurse = true) const;
/**
Finds a list definition by name.
*/
wxRichTextListStyleDefinition* FindListStyle(const wxString& name,
bool recurse = true) const;
/**
Finds a paragraph definition by name.
*/
wxRichTextParagraphStyleDefinition* FindParagraphStyle(const wxString& name,
bool recurse = true) const;
/**
Finds a style definition by name.
*/
wxRichTextStyleDefinition* FindStyle(const wxString& name) const;
/**
Returns the @e nth character style.
*/
wxRichTextCharacterStyleDefinition* GetCharacterStyle(size_t n) const;
/**
Returns the number of character styles.
*/
size_t GetCharacterStyleCount() const;
/**
Returns the style sheet's description.
*/
const wxString& GetDescription() const;
/**
Returns the @e nth list style.
*/
wxRichTextListStyleDefinition* GetListStyle(size_t n) const;
/**
Returns the number of list styles.
*/
size_t GetListStyleCount() const;
/**
Returns the style sheet's name.
*/
const wxString& GetName() const;
/**
Returns the @e nth paragraph style.
*/
wxRichTextParagraphStyleDefinition* GetParagraphStyle(size_t n) const;
/**
Returns the number of paragraph styles.
*/
size_t GetParagraphStyleCount() const;
/**
Removes a character style.
*/
bool RemoveCharacterStyle(wxRichTextStyleDefinition* def,
bool deleteStyle = false);
/**
Removes a list style.
*/
bool RemoveListStyle(wxRichTextStyleDefinition* def,
bool deleteStyle = false);
/**
Removes a paragraph style.
*/
bool RemoveParagraphStyle(wxRichTextStyleDefinition* def,
bool deleteStyle = false);
/**
Removes a style.
*/
bool RemoveStyle(wxRichTextStyleDefinition* def,
bool deleteStyle = false);
/**
Sets the style sheet's description.
*/
void SetDescription(const wxString& descr);
/**
Sets the style sheet's name.
*/
void SetName(const wxString& name);
/**
Returns the sheet's properties.
*/
wxRichTextProperties& GetProperties();
/**
Returns the sheet's properties.
*/
const wxRichTextProperties& GetProperties() const;
/**
Sets the sheet's properties.
*/
void SetProperties(const wxRichTextProperties& props);
};
|