]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/winpars.h
Added missing costructor
[wxWidgets.git] / include / wx / html / winpars.h
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
69941f05 2// Name: winpars.h
5526e819
VS
3// Purpose: wxHtmlWinParser class (parser to be used with wxHtmlWindow)
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819
VS
6// Copyright: (c) 1999 Vaclav Slavik
7// Licence: wxWindows Licence
8/////////////////////////////////////////////////////////////////////////////
9
10
69941f05
VS
11#ifndef _WX_WINPARS_H_
12#define _WX_WINPARS_H_
5526e819
VS
13
14#ifdef __GNUG__
15#pragma interface
16#endif
17
18#include "wx/defs.h"
19#if wxUSE_HTML
20
69941f05
VS
21#include "wx/module.h"
22#include "wx/html/htmlpars.h"
23#include "wx/html/htmlcell.h"
5526e819
VS
24
25class wxHtmlWinParser;
26class wxHtmlWinTagHandler;
27class wxHtmlTagsModule;
28
29//--------------------------------------------------------------------------------
30// wxHtmlWinParser
31// This class is derived from wxHtmlParser and its mail goal
32// is to parse HTML input so that it can be displayed in
33// wxHtmlWindow. It uses special wxHtmlWinTagHandler.
34//--------------------------------------------------------------------------------
35
36class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
37{
38 DECLARE_DYNAMIC_CLASS(wxHtmlWinParser)
39
40 friend class wxHtmlWindow;
41
5526e819
VS
42 public:
43 wxHtmlWinParser() : wxHtmlParser() {wxHtmlWinParser(NULL);}
44 wxHtmlWinParser(wxWindow *wnd);
45
46 virtual void InitParser(const wxString& source);
47 virtual void DoneParser();
48 virtual wxObject* GetProduct();
49
50 virtual void SetDC(wxDC *dc) {m_DC = dc;}
51 // Set's the DC used for parsing. If SetDC() is not called,
52 // parsing won't proceed
53 wxDC *GetDC() {return m_DC;}
54 int GetCharHeight() const {return m_CharHeight;}
55 int GetCharWidth() const {return m_CharWidth;}
56 // NOTE : these functions do _not_ return _actual_
57 // height/width. They return h/w of default font
58 // for this DC. If you want actual values, call
59 // GetDC() -> GetChar...()
60 wxWindow *GetWindow() {return m_Window;}
61 // returns associated wxWindow
62
63 void SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes);
64 // sets fonts to be used when displaying HTML page.
65 // *_italic_mode can be either wxSLANT or wxITALIC
6e31e940 66
5526e819
VS
67 virtual wxList* GetTempData();
68
69 static void AddModule(wxHtmlTagsModule *module);
70 // Adds tags module. see wxHtmlTagsModule for details.
71
72 // parsing-related methods. These methods are called by tag handlers:
73 wxHtmlContainerCell *GetContainer() const {return m_Container;}
74 // Returns pointer to actual container. Common use in tag handler is :
75 // m_WParser -> GetContainer() -> InsertCell(new ...);
76 wxHtmlContainerCell *OpenContainer();
77 // opens new container. This container is sub-container of opened
78 // container. Sets GetContainer to newly created container
79 // and returns it.
80 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
81 // works like OpenContainer except that new container is not created
82 // but c is used. You can use this to directly set actual container
83 wxHtmlContainerCell *CloseContainer();
84 // closes the container and sets actual Container to upper-level
85 // container
86
87 int GetFontSize() const {return m_FontSize;}
88 void SetFontSize(int s) {m_FontSize = s;}
89 int GetFontBold() const {return m_FontBold;}
90 void SetFontBold(int x) {m_FontBold = x;}
91 int GetFontItalic() const {return m_FontItalic;}
92 void SetFontItalic(int x) {m_FontItalic = x;}
93 int GetFontUnderlined() const {return m_FontUnderlined;}
94 void SetFontUnderlined(int x) {m_FontUnderlined = x;}
95 int GetFontFixed() const {return m_FontFixed;}
96 void SetFontFixed(int x) {m_FontFixed = x;}
97
98 int GetAlign() const {return m_Align;}
99 void SetAlign(int a) {m_Align = a;}
100 const wxColour& GetLinkColor() const {return m_LinkColor;}
101 void SetLinkColor(const wxColour& clr) {m_LinkColor = clr;}
102 const wxColour& GetActualColor() const {return m_ActualColor;}
103 void SetActualColor(const wxColour& clr) {m_ActualColor = clr;}
104 const wxString& GetLink() const {return m_Link;}
105 void SetLink(const wxString& link) {m_Link = link; m_UseLink = link.Length() > 0;}
106
107 virtual wxFont* CreateCurrentFont();
108 // creates font depending on m_Font* members.
109 // (note : it calls wxHtmlWindow's CreateCurrentFont...)
110
111 protected:
112 virtual void AddText(const char *txt);
113
114 private:
115 bool m_tmpLastWasSpace;
116 // temporary variable used by AddText
69941f05
VS
117 wxWindow *m_Window;
118 // window we're parsing for
119 wxDC *m_DC;
120 // Device Context we're parsing for
121 static wxList m_Modules;
122 // list of tags modules (see wxHtmlTagsModule for details)
123 // This list is used to initialize m_Handlers member.
124
125 wxHtmlContainerCell *m_Container;
126 // actual container. See Open/CloseContainer for details.
127
128 int m_FontBold, m_FontItalic, m_FontUnderlined, m_FontFixed; // this is not TRUE,FALSE but 1,0, we need it for indexing
129 int m_FontSize; /* -2 to +4, 0 is default */
130 wxColour m_LinkColor;
131 wxColour m_ActualColor;
132 // basic font parameters.
133 wxString m_Link;
134 // actual hypertext link or empty string
135 bool m_UseLink;
136 // TRUE if m_Link is not empty
137 long m_CharHeight, m_CharWidth;
138 // average height of normal-sized text
139 int m_Align;
140 // actual alignment
141
142 wxFont *m_FontsTable[2][2][2][2][7];
143 // table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off
144 // state of these flags (from left to right):
145 // [bold][italic][underlined][fixed_size]
146 // last index is font size : from 0 to 7 (remapped from html sizes -2 to +4)
147 // Note : this table covers all possible combinations of fonts, but not
148 // all of them are used, so many items in table are usually NULL.
149 int m_FontsSizes[7];
150 wxString m_FontFaceFixed, m_FontFaceNormal;
151 int m_ItalicModeFixed, m_ItalicModeNormal;
152 // html font sizes and faces of fixed and proportional fonts
5526e819
VS
153};
154
155
156
157
158
159
160//--------------------------------------------------------------------------------
161// wxHtmlWinTagHandler
162// This is basicly wxHtmlTagHandler except
163// it is extended with protected member m_Parser pointing to
164// the wxHtmlWinParser object
165//--------------------------------------------------------------------------------
166
167class WXDLLEXPORT wxHtmlWinTagHandler : public wxHtmlTagHandler
168{
169 DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler)
170
5526e819
VS
171 public:
172 wxHtmlWinTagHandler() : wxHtmlTagHandler() {};
6e31e940 173
5526e819 174 virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;};
69941f05
VS
175
176 protected:
177 wxHtmlWinParser *m_WParser;
178 // same as m_Parser, but overcasted
5526e819
VS
179};
180
181
182
183
184
185
186//--------------------------------------------------------------------------------
187// wxHtmlTagsModule
188// This is basic of dynamic tag handlers binding.
189// The class provides methods for filling parser's handlers
190// hash table.
191// (See documentation for details)
192//--------------------------------------------------------------------------------
193
194class WXDLLEXPORT wxHtmlTagsModule : public wxModule
195{
196 DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule)
197
198 public:
199 wxHtmlTagsModule() : wxModule() {};
200
201 virtual bool OnInit();
202 virtual void OnExit();
203
6e31e940 204 virtual void FillHandlersTable(wxHtmlWinParser * WXUNUSED(parser)) { }
5526e819
VS
205 // This is called by wxHtmlWinParser.
206 // The method must simply call parser->AddTagHandler(new <handler_class_name>);
207 // for each handler
208
209};
210
211
69941f05 212#endif
5526e819 213
69941f05 214#endif // _WX_WINPARS_H_
5526e819 215
5526e819
VS
216
217
218