Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | #ifndef __HTML_h |
2 | #define __HTML_h |
||
3 | |||
4 | #include"parser.h" |
||
5 | |||
6 | template |
||
7 | { |
||
8 | public: |
||
9 | CHTMLStack() |
||
10 | { |
||
11 | FirstItem=NULL; |
||
12 | NR=0; |
||
13 | } |
||
14 | void Push(T * ff) |
||
15 | { |
||
16 | T * ff1; |
||
17 | if(!ff) return; |
||
18 | ff1=(T *)malloc(sizeof(T)); |
||
19 | memcpy((void *)ff1,(const void *)ff,sizeof(T)); |
||
20 | NR++; |
||
21 | ff1->next=FirstElem; |
||
22 | FirstElem=ff1; |
||
23 | } |
||
24 | T * Pop() |
||
25 | { |
||
26 | T * R; |
||
27 | if(!NR) return NULL; |
||
28 | NR--; |
||
29 | R=FirstElem; |
||
30 | FirstElem=R->next; |
||
31 | return R; |
||
32 | } |
||
33 | void Free(T * x) |
||
34 | { |
||
35 | free(x); |
||
36 | } |
||
37 | ~CHTMLStack() |
||
38 | { |
||
39 | T * __tmp; |
||
40 | while((__tmp=Pop())) this->Free(__tmp); |
||
41 | } |
||
42 | protected: |
||
43 | T * FirstElem; |
||
44 | int NR; |
||
45 | }; |
||
46 | |||
47 | struct text_style { |
||
48 | unsigned long flags; |
||
49 | char * FontName; |
||
50 | int FontSize; |
||
51 | unsigned long color; |
||
52 | struct text_style * next; |
||
53 | }; |
||
54 | |||
55 | struct page_style { |
||
56 | unsigned long background; |
||
57 | unsigned long text; |
||
58 | unsigned long link,alink,vlink; |
||
59 | unsigned long flags; |
||
60 | struct page_style * next; |
||
61 | }; |
||
62 | |||
63 | struct image_properties { |
||
64 | int width,height; |
||
65 | int border; |
||
66 | }; |
||
67 | |||
68 | struct text_properties { |
||
69 | char * FontName; |
||
70 | int font_size; |
||
71 | int color; |
||
72 | unsigned long flags; |
||
73 | }; |
||
74 | |||
75 | struct cpb_Text { |
||
76 | struct text_properties prop; |
||
77 | char * Text; |
||
78 | int len; |
||
79 | }; |
||
80 | |||
81 | struct cpb_Image { |
||
82 | struct image_properties img; |
||
83 | void * ImageData; |
||
84 | }; |
||
85 | |||
86 | class CPageBuffer |
||
87 | { |
||
88 | public: |
||
89 | CPageBuffer(); |
||
90 | ~CPageBuffer(); |
||
91 | virtual void AddText(char *,int,struct text_properties *); |
||
92 | virtual void AddImage(char *,struct image_properties *); |
||
93 | virtual void Paint(); |
||
94 | virtual void Reset(); |
||
95 | private: |
||
96 | int nr_text,nr_images; |
||
97 | struct cpb_Text ** _text; |
||
98 | struct cpb_Image ** _images; |
||
99 | }; |
||
100 | |||
101 | class CHTMLParser |
||
102 | { |
||
103 | public: |
||
104 | CHTMLParser(CParser * par,CPageBuffer * buf); |
||
105 | ~CHTMLParser(); |
||
106 | virtual void DefaultStyles(); |
||
107 | virtual void Parse(); |
||
108 | virtual void ParseHTML(); |
||
109 | protected: |
||
110 | CParser * parser; |
||
111 | CPageBuffer * pgbuf; |
||
112 | struct text_style text_style; |
||
113 | struct page_style page_style; |
||
114 | }; |
||
115 | |||
116 | #define FFLAG_ALIGNLEFT 0x00000001 |
||
117 | #define FFLAG_ALIGNRIGHT 0x00000002 |
||
118 | #define FFLAG_ALIGNCENTER 0x00000003 |
||
119 | #define FFLAG_BOLD 0x00000004 |
||
120 | #define FFLAG_ITALIC 0x00000008 |
||
121 | #define FFLAG_UNDERLINE 0x00000010 |
||
122 | |||
123 | #define PFLAG_ALIGNLEFT 0x00000001 |
||
124 | #define PFLAG_ALIGNRIGHT 0x00000002 |
||
125 | #define PFLAG_ALIGNCENTER 0x00000003 |
||
126 | #define PFLAG_RAWMODE 0x00000004 |
||
127 | |||
128 | #endif |