OpenMW
|
00001 #ifndef MWGUI_BOOKPAGE_HPP 00002 #define MWGUI_BOOKPAGE_HPP 00003 00004 #include "MyGUI_Colour.h" 00005 #include "MyGUI_Widget.h" 00006 00007 #include <functional> 00008 #include <platform/stdint.h> 00009 #include <boost/function.hpp> 00010 #include <boost/shared_ptr.hpp> 00011 00012 namespace MWGui 00013 { 00016 struct TypesetBook 00017 { 00018 typedef boost::shared_ptr <TypesetBook> Ptr; 00019 typedef intptr_t InteractiveId; 00020 00022 virtual size_t pageCount () const = 0; 00023 00030 virtual std::pair <unsigned int, unsigned int> getSize () const = 0; 00031 }; 00032 00034 struct BookTypesetter 00035 { 00036 typedef boost::shared_ptr <BookTypesetter> Ptr; 00037 typedef TypesetBook::InteractiveId InteractiveId; 00038 typedef MyGUI::Colour Colour; 00039 typedef uint8_t const * Utf8Point; 00040 typedef std::pair <Utf8Point, Utf8Point> Utf8Span; 00041 00042 enum Alignment { 00043 AlignLeft = -1, 00044 AlignCenter = 0, 00045 AlignRight = +1 00046 }; 00047 00052 struct Style; 00053 00055 static Ptr create (int pageWidth, int pageHeight); 00056 00058 virtual Style* createStyle (char const * Font, Colour Colour) = 0; 00059 00063 virtual Style* createHotStyle (Style * BaseStyle, Colour NormalColour, Colour HoverColour, Colour ActiveColour, InteractiveId Id, bool Unique = true) = 0; 00064 00068 virtual void lineBreak (float margin = 0) = 0; 00069 00074 virtual void sectionBreak (float margin = 0) = 0; 00075 00077 virtual void setSectionAlignment (Alignment sectionAlignment) = 0; 00078 00079 // Layout a block of text with the specified style into the document. 00080 virtual void write (Style * Style, Utf8Span Text) = 0; 00081 00085 virtual intptr_t addContent (Utf8Span Text, bool Select = true) = 0; 00086 00088 virtual void selectContent (intptr_t contentHandle) = 0; 00089 00092 virtual void write (Style * Style, size_t Begin, size_t End) = 0; 00093 00095 virtual TypesetBook::Ptr complete () = 0; 00096 }; 00097 00099 class BookPage : public MyGUI::Widget 00100 { 00101 MYGUI_RTTI_DERIVED(BookPage) 00102 public: 00103 00104 typedef TypesetBook::InteractiveId InteractiveId; 00105 typedef boost::function <void (InteractiveId)> ClickCallback; 00106 00108 virtual void showPage (TypesetBook::Ptr Book, size_t Page) = 0; 00109 00111 virtual void adviseLinkClicked (ClickCallback callback) = 0; 00112 00114 virtual void unadviseLinkClicked () = 0; 00115 00118 static void registerMyGUIComponents (); 00119 }; 00120 } 00121 00122 #endif // MWGUI_BOOKPAGE_HPP