X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4f88b483b5bb9482c87a0ddf94c531d638fa3052..245b9db51823e59bd61f0d7c0c69b419495cf0b7:/docs/latex/wx/richtextoverview.tex diff --git a/docs/latex/wx/richtextoverview.tex b/docs/latex/wx/richtextoverview.tex index 97c7254a9c..624e59fbae 100644 --- a/docs/latex/wx/richtextoverview.tex +++ b/docs/latex/wx/richtextoverview.tex @@ -1,21 +1,33 @@ \section{wxRichTextCtrl overview}\label{wxrichtextctrloverview} -Classes: \helpref{wxRichTextCtrl}{wxrichtextctrl}, \helpref{wxRichTextBuffer}{wxrichtextbuffer}, -\helpref{wxRichTextAttr}{wxrichtextattr}, \helpref{wxTextAttrEx}{wxtextattrex}, -\helpref{wxRichTextCharacterStyleDefinition}{wxrichtextcharacterstyledefinition}, +{\bf Major classes:} \helpref{wxRichTextCtrl}{wxrichtextctrl}, \helpref{wxRichTextBuffer}{wxrichtextbuffer}, \helpref{wxRichTextEvent}{wxrichtextevent} + +{\bf Helper classes:} \helpref{wxRichTextAttr}{wxrichtextattr}, \helpref{wxTextAttrEx}{wxtextattrex}, +\helpref{wxRichTextRange}{wxrichtextrange} + +{\bf File handler classes:} \helpref{wxRichTextFileHandler}{wxrichtextfilehandler}, \helpref{wxRichTextHTMLHandler}{wxrichtexthtmlhandler}, +\helpref{wxRichTextXMLHandler}{wxrichtextxmlhandler} + +{\bf Style classes:} \helpref{wxRichTextCharacterStyleDefinition}{wxrichtextcharacterstyledefinition}, \helpref{wxRichTextParagraphStyleDefinition}{wxrichtextparagraphstyledefinition}, -\helpref{wxRichTextStyleSheet}{wxrichtextstylesheet}, -\helpref{wxRichTextStyleComboCtrl}{wxrichtextstylecomboctrl}, +\helpref{wxRichTextListStyleDefinition}{wxrichtextliststyledefinition}, +\helpref{wxRichTextStyleSheet}{wxrichtextstylesheet} + +{\bf Additional controls:} \helpref{wxRichTextStyleComboCtrl}{wxrichtextstylecomboctrl}, \helpref{wxRichTextStyleListBox}{wxrichtextstylelistbox}, -\helpref{wxRichTextEvent}{wxrichtextevent}, \helpref{wxRichTextRange}{wxrichtextrange}, -\helpref{wxRichTextFileHandler}{wxrichtextfilehandler}, \helpref{wxRichTextHTMLHandler}{wxrichtexthtmlhandler}, -\helpref{wxRichTextXMLHandler}{wxrichtextxmlhandler}, +\helpref{wxRichTextStyleListCtrl}{wxrichtextstylelistctrl} + +{\bf Printing classes:} \helpref{wxRichTextPrinting}{wxrichtextprinting}, +\helpref{wxRichTextPrintout}{wxrichtextprintout}, +\helpref{wxRichTextHeaderFooterData}{wxrichtextheaderfooterdata} + +{\bf Dialog classes:} \helpref{wxRichTextStyleOrganiserDialog}{wxrichtextstyleorganiserdialog}, \helpref{wxRichTextFormattingDialog}{wxrichtextformattingdialog}, \helpref{wxSymbolPickerDialog}{wxsymbolpickerdialog} wxRichTextCtrl provides a generic implementation of a rich text editor that can handle different character -styles, paragraph formatting, and images. It's aimed at editing 'natural' language text - if you need an editor that supports code editing, -wxStyledTextCtrl is a better choice. +styles, paragraph formatting, and images. It's aimed at editing 'natural' language text - if you need an editor +that supports code editing, wxStyledTextCtrl is a better choice. Despite its name, it cannot currently read or write RTF (rich text format) files. Instead, it uses its own XML format, and can also read and write plain text. In future we expect to provide @@ -30,19 +42,25 @@ the style information in a wxTextCtrl, whereas this information is readily available in wxRichTextCtrl. Since it's written in pure wxWidgets, any customizations you make to wxRichTextCtrl will be reflected on all platforms. -There are of course a few disadvantages to using wxRichTextCtrl. It is not native, +wxRichTextCtrl supports basic printing via the easy-to-use \helpref{wxRichTextPrinting}{wxrichtextprinting} class. +Creating applications with simple word processing features is simplified with the inclusion of\rtfsp +\helpref{wxRichTextFormattingDialog}{wxrichtextformattingdialog}, a tabbed dialog allowing +interactive tailoring of paragraph and character styling. Also provided is the multi-purpose dialog\rtfsp +\helpref{wxRichTextStyleOrganiserDialog}{wxrichtextstyleorganiserdialog} that can be used for +managing style definitions, browsing styles and applying them, or selecting list styles with +a renumber option. + +There are a few disadvantages to using wxRichTextCtrl. It is not native, so does not behave exactly as a native wxTextCtrl, although common editing conventions are followed. Users may miss the built-in spelling correction on Mac OS X, or any special character input that may be provided by the native control. It would also -be a bad choice if intended users rely on screen readers that would be unhappy +be a poor choice if intended users rely on screen readers that would be not work well with non-native text input implementation. You might mitigate this by providing the choice between wxTextCtrl and wxRichTextCtrl, with fewer features in the former case. -wxRichTextCtrl does not yet support printing directly, but content can be converted -to HTML which can then be used with \helpref{wxHtmlEasyPrinting}{wxhtmleasyprinting}. - -The following screenshot shows the wxRichTextCtrl sample in action: +A good way to understand wxRichTextCtrl's capabilities is to compile and run the +sample, {\tt samples/richtext}, and browse the code. The following screenshot shows the sample in action: $$\image{8cm;0cm}{richtextctrl.gif}$$ @@ -52,7 +70,7 @@ The following code is taken from the sample, and adds text and styles to a rich {\small \begin{verbatim} - wxRichTextCtrl* richTextCtrl = new wxRichTextCtrl(splitter, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS); + wxRichTextCtrl* richTextCtrl = new wxRichTextCtrl(splitter, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxBORDER_NONE|wxWANTS_CHARS); wxFont textFont = wxFont(12, wxROMAN, wxNORMAL, wxNORMAL); wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD); @@ -202,8 +220,8 @@ be processed by the control rather than being used for navigation between contro \subsubsection{wxRichTextCtrl and styles} -Styling attributes are represented by one of three classes: \helpref{wxTextAttr}{wxtextattr}, \helpref{wxTextAttrEx}{wxtextattrex} and \helpref{wxRichTextAttr}{wxrichtextattr}. -wxTextAttr is shared across all controls that are derived from wxTextCtrl and +Styling attributes are represented by three classes: \helpref{wxTextAttr}{wxtextattr}, \helpref{wxTextAttrEx}{wxtextattrex} and \helpref{wxRichTextAttr}{wxrichtextattr}. +wxTextAttr is shared across all controls that are derived from wxTextCtrlBase and can store basic character and paragraph attributes. wxTextAttrEx derives from wxTextAttr and adds some further attributes that are only supported by wxRichTextCtrl. Finally, wxRichTextAttr is a more efficient version @@ -285,7 +303,7 @@ of styles that you can tailor or use as-is, and this means that you can set a he instead of marking text in bold, specifying a large font size, and applying a certain paragraph spacing and alignment for every such heading. Similarly, wxWidgets provides a class called \helpref{wxRichTextStyleSheet}{wxrichtextstylesheet} which manages style definitions -(\helpref{wxRichTextParagraphStyleDefinition}{wxrichtextparagraphstyledefinition} and \helpref{wxRichTextCharacterStyleDefinition}{wxrichtextcharacterstyledefinition}). +(\helpref{wxRichTextParagraphStyleDefinition}{wxrichtextparagraphstyledefinition}, \helpref{wxRichTextListStyleDefinition}{wxrichtextliststyledefinition} and \helpref{wxRichTextCharacterStyleDefinition}{wxrichtextcharacterstyledefinition}). Once you have added definitions to a style sheet and associated it with a wxRichTextCtrl, you can apply a named definition to a range of text. The classes \helpref{wxRichTextStyleComboCtrl}{wxrichtextstylecomboctrl}\rtfsp and \helpref{wxRichTextStyleListBox}{wxrichtextstylelistbox} can be used to present the user with a list @@ -295,7 +313,7 @@ You can reapply a style sheet to the contents of the control, by calling \helpre This is useful if the style definitions have changed, and you want the content to reflect this. It relies on the fact that when you apply a named style, the style definition name is recorded in the content. So ApplyStyleSheet works by finding the paragraph attributes with style names and re-applying the definition's -attributes to the paragraph. Currently, this works with paragraph style definitions only. +attributes to the paragraph. Currently, this works with paragraph and list style definitions only. \subsection{wxRichTextCtrl dialogs}\label{wxrichtextctrldialogs} @@ -304,7 +322,7 @@ text editing functionality. \helpref{wxRichTextFormattingDialog}{wxrichtextformattingdialog} can be used for character or paragraph formatting, or a combination of both. It's a wxPropertySheetDialog -with the following available tabs: Font, Indents \& Spacing, Tabs, Bullets, and Style. +with the following available tabs: Font, Indents \& Spacing, Tabs, Bullets, Style, and List Style. You can select which pages will be shown by supplying flags to the dialog constructor. In a character formatting dialog, typically only the Font page will be shown. In a paragraph formatting dialog, you'll show the Indents \& Spacing, Tabs and Bullets @@ -314,6 +332,11 @@ You can customize this dialog by providing your own wxRichTextFormattingDialogFa object, which tells the formatting dialog how many pages are supported, what their identifiers are, and how to creates the pages. +\helpref{wxRichTextStyleOrganiserDialog}{wxrichtextstyleorganiserdialog} is a multi-purpose dialog +that can be used for managing style definitions, browsing styles and applying them, or selecting list styles with +a renumber option. See the sample for usage - it is used for the "Manage Styles" and "Bullets and Numbering" +menu commands. + \helpref{wxSymbolPickerDialog}{wxsymbolpickerdialog} lets the user insert a symbol from a specified font. It has no wxRichTextCtrl dependencies besides being included in the rich text library. @@ -325,17 +348,18 @@ always has one such buffer. The content is represented by a hierarchy of objects, all derived from wxRichTextObject. An object might be an image, a fragment of text, a paragraph, -or a whole buffer. Objects store a wxRichTextAttr containing style information; -although it contains both paragraph formatting and character style, the -paragraph style information is ignored by children of a paragraph (only -character style is relevant to these objects). +or a whole buffer. Objects store a wxTextAttrEx containing style information; +a paragraph object can contain both paragraph and character information, but +content objects such as text can only store character information. The final +style displayed in the control or in a printout is a combination of base +style, paragraph style and content (character) style. The top of the hierarchy is the buffer, a kind of wxRichTextParagraphLayoutBox. containing further wxRichTextParagraph objects, each of which can include text, images and potentially other types of object. Each object maintains a range (start and end position) measured -from the start of the main parent box. +from the start of the main parent object. When Layout is called on an object, it is given a size which the object must limit itself to, or one or more flexible directions (vertical @@ -351,7 +375,7 @@ A paragraph of pure text with the same style contains just one further object, a wxRichTextPlainText object. When styling is applied to part of this object, the object is decomposed into separate objects, one object for each different character style. So each object within a paragraph always has -just one wxRichTextAttr object to denote its character style. Of course, this can +just one wxTextAttrEx object to denote its character style. Of course, this can lead to fragmentation after a lot of edit operations, potentially leading to several objects with the same style where just one would do. So a Defragment function is called when updating the control's display, to ensure that @@ -369,11 +393,7 @@ caret. \item As the selection is expanded, the text jumps slightly due to kerning differences between drawing a single text string versus drawing several fragments separately. This could be improved by using wxDC::GetPartialTextExtents to calculate exactly where the separate fragments -should be drawn. -Alternatively, it might be possible to use the difference between the width of text from -a to b+1, versus the width of the text from a to b added to the width of b to b+1. -Note that this problem also applies to separation of text fragments due to difference in their attributes. -\item Selection doesn't work properly for text that contains tabs. +should be drawn. Note that this problem also applies to separation of text fragments due to difference in their attributes. \end{itemize} \wxheading{Features} @@ -381,17 +401,17 @@ Note that this problem also applies to separation of text fragments due to diffe This is a list of some of the features that have yet to be implemented. Help with them will be appreciated. \begin{itemize}\itemsep=0pt -\item Printing \item RTF input and output +\item Conversion from HTML +\item Open Office input and output \item Floating images, with content wrapping around them \item A ruler control \item Standard editing toolbars -\item Automatic list numbering \item Tables +\item Bitmap bullets +\item Borders \item Text frames -\item Add ability to show images in wxHTML output (currently uses embedded data suitable only for real browsers) -\item More complete stylesheet viewer, plus style sheet editing dialogs -\item Ability to read and write style sheets +\item Justified text, in print/preview at least \end{itemize} There are also things that could be done to take advantage of the underlying text capabilities of the platform;