OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
bookpage.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_BOOKPAGE_HPP
2 #define MWGUI_BOOKPAGE_HPP
3 
4 #include "MyGUI_Colour.h"
5 #include "MyGUI_Widget.h"
6 
7 #include <functional>
8 #include <stdint.h>
9 #include <boost/function.hpp>
10 #include <boost/shared_ptr.hpp>
11 
12 namespace MWGui
13 {
16  struct TypesetBook
17  {
18  typedef boost::shared_ptr <TypesetBook> Ptr;
20 
22  virtual size_t pageCount () const = 0;
23 
30  virtual std::pair <unsigned int, unsigned int> getSize () const = 0;
31  };
32 
35  {
36  typedef boost::shared_ptr <BookTypesetter> Ptr;
38  typedef MyGUI::Colour Colour;
39  typedef uint8_t const * Utf8Point;
40  typedef std::pair <Utf8Point, Utf8Point> Utf8Span;
41 
42  enum Alignment {
43  AlignLeft = -1,
46  };
47 
52  struct Style;
53 
55  static Ptr create (int pageWidth, int pageHeight);
56 
58  virtual Style* createStyle (char const * Font, Colour Colour) = 0;
59 
63  virtual Style* createHotStyle (Style * BaseStyle, Colour NormalColour, Colour HoverColour, Colour ActiveColour, InteractiveId Id, bool Unique = true) = 0;
64 
68  virtual void lineBreak (float margin = 0) = 0;
69 
74  virtual void sectionBreak (int margin = 0) = 0;
75 
77  virtual void setSectionAlignment (Alignment sectionAlignment) = 0;
78 
79  // Layout a block of text with the specified style into the document.
80  virtual void write (Style * Style, Utf8Span Text) = 0;
81 
85  virtual intptr_t addContent (Utf8Span Text, bool Select = true) = 0;
86 
88  virtual void selectContent (intptr_t contentHandle) = 0;
89 
92  virtual void write (Style * Style, size_t Begin, size_t End) = 0;
93 
95  virtual TypesetBook::Ptr complete () = 0;
96  };
97 
99  class BookPage : public MyGUI::Widget
100  {
101  MYGUI_RTTI_DERIVED(BookPage)
102  public:
103 
105  typedef boost::function <void (InteractiveId)> ClickCallback;
106 
108  virtual void showPage (TypesetBook::Ptr Book, size_t Page) = 0;
109 
111  virtual void adviseLinkClicked (ClickCallback callback) = 0;
112 
114  virtual void unadviseLinkClicked () = 0;
115 
118  static void registerMyGUIComponents ();
119  };
120 }
121 
122 #endif // MWGUI_BOOKPAGE_HPP
virtual Style * createStyle(char const *Font, Colour Colour)=0
Create a simple text style consisting of a font and a text color.
virtual void showPage(TypesetBook::Ptr Book, size_t Page)=0
Make the widget display the specified page from the specified book.
uint8_t const * Utf8Point
Definition: bookpage.hpp:39
static Ptr create(int pageWidth, int pageHeight)
A factory function for creating the default implementation of a book typesetter.
Definition: bookpage.cpp:629
Alignment
Definition: bookpage.hpp:42
TypesetBook::InteractiveId InteractiveId
Definition: bookpage.hpp:104
virtual intptr_t addContent(Utf8Span Text, bool Select=true)=0
virtual TypesetBook::Ptr complete()=0
Finalize the document layout, and return a pointer to it.
Definition: bookpage.hpp:16
Definition: bookpage.hpp:45
boost::function< void(InteractiveId)> ClickCallback
Definition: bookpage.hpp:105
std::pair< Utf8Point, Utf8Point > Utf8Span
Definition: bookpage.hpp:40
virtual void setSectionAlignment(Alignment sectionAlignment)=0
Changes the alignment for the current section of text.
static void registerMyGUIComponents()
Definition: bookpage.cpp:1319
virtual void unadviseLinkClicked()=0
Clear the hyper-link click callback.
virtual void selectContent(intptr_t contentHandle)=0
Select a previously created content block for future writes.
virtual void sectionBreak(int margin=0)=0
MyGUI::Colour Colour
Definition: bookpage.hpp:38
virtual size_t pageCount() const =0
Returns the number of pages in the document.
Definition: bookpage.hpp:44
virtual std::pair< unsigned int, unsigned int > getSize() const =0
intptr_t InteractiveId
Definition: bookpage.hpp:19
A factory class for creating a typeset book instance.
Definition: bookpage.hpp:34
boost::shared_ptr< BookTypesetter > Ptr
Definition: bookpage.hpp:36
An interface to the BookPage widget.
Definition: bookpage.hpp:99
virtual void lineBreak(float margin=0)=0
virtual void write(Style *Style, Utf8Span Text)=0
TypesetBook::InteractiveId InteractiveId
Definition: bookpage.hpp:37
virtual void adviseLinkClicked(ClickCallback callback)=0
Set the callback for a clicking a hyper-link in the document.
virtual Style * createHotStyle(Style *BaseStyle, Colour NormalColour, Colour HoverColour, Colour ActiveColour, InteractiveId Id, bool Unique=true)=0
boost::shared_ptr< TypesetBook > Ptr
Definition: bookpage.hpp:18
Definition: bookpage.hpp:43