]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlcell.cpp | |
3 | // Purpose: wxHtmlCell - basic element of HTML output | |
4 | // Author: Vaclav Slavik | |
69941f05 | 5 | // RCS-ID: $Id$ |
5526e819 VS |
6 | // Copyright: (c) 1999 Vaclav Slavik |
7 | // Licence: wxWindows Licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
5526e819 | 10 | #ifdef __GNUG__ |
69941f05 | 11 | #pragma implementation |
5526e819 VS |
12 | #endif |
13 | ||
4dcaf11a | 14 | #include "wx/wxprec.h" |
5526e819 | 15 | |
314260fb | 16 | #include "wx/defs.h" |
5526e819 VS |
17 | #if wxUSE_HTML |
18 | ||
19 | #ifdef __BORDLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WXPRECOMP | |
4dcaf11a | 24 | #include "wx/wx.h" |
5526e819 VS |
25 | #endif |
26 | ||
4dcaf11a RR |
27 | #include "wx/html/htmlcell.h" |
28 | #include "wx/html/htmlwin.h" | |
5526e819 VS |
29 | #include <stdlib.h> |
30 | ||
31 | ||
5526e819 VS |
32 | //----------------------------------------------------------------------------- |
33 | // wxHtmlCell | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
36 | ||
964688d8 VZ |
37 | void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, |
38 | bool WXUNUSED(left), | |
39 | bool WXUNUSED(middle), | |
40 | bool WXUNUSED(right)) | |
5526e819 | 41 | { |
25082126 VS |
42 | wxString lnk = GetLink(x, y); |
43 | if (lnk != wxEmptyString) | |
44 | ((wxHtmlWindow*)parent) -> OnLinkClicked(lnk); | |
5526e819 VS |
45 | // note : this overcasting is legal because parent is *always* wxHtmlWindow |
46 | } | |
47 | ||
48 | ||
49 | ||
db98870d VS |
50 | bool wxHtmlCell::AdjustPagebreak(int *pagebreak) |
51 | { | |
52 | ||
53 | if ((!m_CanLiveOnPagebreak) && | |
e52d6dbc | 54 | m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) { |
db98870d VS |
55 | *pagebreak = m_PosY; |
56 | if (m_Next != NULL) m_Next -> AdjustPagebreak(pagebreak); | |
57 | return TRUE; | |
58 | } | |
59 | ||
60 | else { | |
61 | if (m_Next != NULL) return m_Next -> AdjustPagebreak(pagebreak); | |
62 | else return FALSE; | |
63 | } | |
64 | } | |
65 | ||
66 | ||
67 | ||
68 | ||
5526e819 VS |
69 | //----------------------------------------------------------------------------- |
70 | // wxHtmlWordCell | |
71 | //----------------------------------------------------------------------------- | |
72 | ||
73 | wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() | |
74 | { | |
75 | m_Word = word; | |
12909796 | 76 | |
66a77a74 | 77 | m_Word.Replace(wxT(" "), wxT(" "), TRUE); |
e52cac90 | 78 | m_Word.Replace(wxT("©"), wxT("(c)"), TRUE); |
66a77a74 OK |
79 | m_Word.Replace(wxT("""), wxT("\""), TRUE); |
80 | m_Word.Replace(wxT("<"), wxT("<"), TRUE); | |
81 | m_Word.Replace(wxT(">"), wxT(">"), TRUE); | |
82 | m_Word.Replace(wxT("&"), wxT("&"), TRUE); | |
12909796 VS |
83 | |
84 | m_Word.Replace(wxT("  "), wxT(" "), TRUE); | |
e52cac90 | 85 | m_Word.Replace(wxT("© "), wxT("(c)"), TRUE); |
12909796 VS |
86 | m_Word.Replace(wxT("" "), wxT("\""), TRUE); |
87 | m_Word.Replace(wxT("< "), wxT("<"), TRUE); | |
88 | m_Word.Replace(wxT("> "), wxT(">"), TRUE); | |
89 | m_Word.Replace(wxT("& "), wxT("&"), TRUE); | |
90 | ||
5526e819 | 91 | dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent); |
db98870d | 92 | SetCanLiveOnPagebreak(FALSE); |
5526e819 VS |
93 | } |
94 | ||
95 | ||
96 | ||
97 | void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) | |
98 | { | |
99 | dc.DrawText(m_Word, x + m_PosX, y + m_PosY); | |
100 | wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); | |
101 | } | |
102 | ||
103 | ||
104 | ||
5526e819 VS |
105 | //----------------------------------------------------------------------------- |
106 | // wxHtmlContainerCell | |
107 | //----------------------------------------------------------------------------- | |
108 | ||
109 | ||
110 | wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCell() | |
111 | { | |
112 | m_Cells = m_LastCell = NULL; | |
113 | m_Parent = parent; | |
114 | if (m_Parent) m_Parent -> InsertCell(this); | |
efba2b89 VS |
115 | m_AlignHor = wxHTML_ALIGN_LEFT; |
116 | m_AlignVer = wxHTML_ALIGN_BOTTOM; | |
5526e819 | 117 | m_IndentLeft = m_IndentRight = m_IndentTop = m_IndentBottom = 0; |
efba2b89 | 118 | m_WidthFloat = 100; m_WidthFloatUnits = wxHTML_UNITS_PERCENT; |
5526e819 VS |
119 | m_UseBkColour = FALSE; |
120 | m_UseBorder = FALSE; | |
121 | m_MinHeight = m_MaxLineWidth = 0; | |
efba2b89 | 122 | m_MinHeightAlign = wxHTML_ALIGN_TOP; |
5526e819 VS |
123 | } |
124 | ||
125 | ||
126 | ||
127 | void wxHtmlContainerCell::SetIndent(int i, int what, int units) | |
128 | { | |
efba2b89 VS |
129 | int val = (units == wxHTML_UNITS_PIXELS) ? i : -i; |
130 | if (what & wxHTML_INDENT_LEFT) m_IndentLeft = val; | |
131 | if (what & wxHTML_INDENT_RIGHT) m_IndentRight = val; | |
132 | if (what & wxHTML_INDENT_TOP) m_IndentTop = val; | |
133 | if (what & wxHTML_INDENT_BOTTOM) m_IndentBottom = val; | |
5526e819 VS |
134 | } |
135 | ||
136 | ||
137 | ||
138 | int wxHtmlContainerCell::GetIndent(int ind) const | |
139 | { | |
efba2b89 VS |
140 | if (ind & wxHTML_INDENT_LEFT) return m_IndentLeft; |
141 | else if (ind & wxHTML_INDENT_RIGHT) return m_IndentRight; | |
142 | else if (ind & wxHTML_INDENT_TOP) return m_IndentTop; | |
143 | else if (ind & wxHTML_INDENT_BOTTOM) return m_IndentBottom; | |
5526e819 VS |
144 | else return -1; /* BUG! Should not be called... */ |
145 | } | |
146 | ||
147 | ||
148 | ||
149 | ||
150 | int wxHtmlContainerCell::GetIndentUnits(int ind) const | |
151 | { | |
152 | bool p = FALSE; | |
efba2b89 VS |
153 | if (ind & wxHTML_INDENT_LEFT) p = m_IndentLeft < 0; |
154 | else if (ind & wxHTML_INDENT_RIGHT) p = m_IndentRight < 0; | |
155 | else if (ind & wxHTML_INDENT_TOP) p = m_IndentTop < 0; | |
156 | else if (ind & wxHTML_INDENT_BOTTOM) p = m_IndentBottom < 0; | |
157 | if (p) return wxHTML_UNITS_PERCENT; | |
158 | else return wxHTML_UNITS_PIXELS; | |
5526e819 VS |
159 | } |
160 | ||
161 | ||
162 | ||
db98870d VS |
163 | bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) |
164 | { | |
165 | if (!m_CanLiveOnPagebreak) | |
166 | return wxHtmlCell::AdjustPagebreak(pagebreak); | |
e52d6dbc | 167 | |
db98870d VS |
168 | else { |
169 | wxHtmlCell *c = GetFirstCell(); | |
170 | bool rt = FALSE; | |
e52d6dbc | 171 | int pbrk = *pagebreak - m_PosY; |
db98870d VS |
172 | |
173 | while (c) { | |
e52d6dbc | 174 | if (c -> AdjustPagebreak(&pbrk)) rt = TRUE; |
db98870d VS |
175 | c = c -> GetNext(); |
176 | } | |
e52d6dbc | 177 | if (rt) *pagebreak = pbrk + m_PosY; |
db98870d VS |
178 | return rt; |
179 | } | |
180 | } | |
181 | ||
182 | ||
183 | ||
5526e819 VS |
184 | void wxHtmlContainerCell::Layout(int w) |
185 | { | |
186 | wxHtmlCell *cell = m_Cells, *line = m_Cells; | |
187 | long xpos = 0, ypos = m_IndentTop; | |
188 | int xdelta = 0, ybasicpos = 0, ydiff; | |
189 | int s_width, s_indent; | |
190 | int ysizeup = 0, ysizedown = 0; | |
191 | ||
192 | /* | |
7e941458 | 193 | |
5526e819 | 194 | WIDTH ADJUSTING : |
7e941458 | 195 | |
5526e819 VS |
196 | */ |
197 | ||
efba2b89 | 198 | if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT) { |
5526e819 VS |
199 | if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; |
200 | else m_Width = m_WidthFloat * w / 100; | |
201 | } | |
202 | else { | |
203 | if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; | |
204 | else m_Width = m_WidthFloat; | |
205 | } | |
206 | ||
207 | if (m_Cells) { | |
208 | int l = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; | |
209 | int r = (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight; | |
210 | m_Cells -> Layout(m_Width - (l + r)); | |
211 | } | |
212 | ||
213 | /* | |
214 | ||
215 | LAYOUTING : | |
7e941458 | 216 | |
5526e819 VS |
217 | */ |
218 | ||
219 | // adjust indentation: | |
220 | s_indent = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; | |
221 | s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); | |
222 | ||
223 | m_MaxLineWidth = 0; | |
7e941458 | 224 | |
5526e819 VS |
225 | // my own layouting: |
226 | while (cell != NULL) { | |
227 | switch (m_AlignVer) { | |
efba2b89 VS |
228 | case wxHTML_ALIGN_TOP : ybasicpos = 0; break; |
229 | case wxHTML_ALIGN_BOTTOM : ybasicpos = - cell -> GetHeight(); break; | |
230 | case wxHTML_ALIGN_CENTER : ybasicpos = - cell -> GetHeight() / 2; break; | |
5526e819 VS |
231 | } |
232 | ydiff = cell -> GetHeight() + ybasicpos; | |
233 | ||
234 | if (cell -> GetDescent() + ydiff > ysizedown) ysizedown = cell -> GetDescent() + ydiff; | |
235 | if (ybasicpos + cell -> GetDescent() < -ysizeup) ysizeup = - (ybasicpos + cell -> GetDescent()); | |
236 | ||
237 | cell -> SetPos(xpos, ybasicpos + cell -> GetDescent()); | |
238 | xpos += cell -> GetWidth(); | |
239 | cell = cell -> GetNext(); | |
240 | ||
241 | // force new line if occured: | |
242 | if ((cell == NULL) || (xpos + cell -> GetWidth() > s_width)) { | |
243 | if (xpos > m_MaxLineWidth) m_MaxLineWidth = xpos; | |
244 | if (ysizeup < 0) ysizeup = 0; | |
245 | if (ysizedown < 0) ysizedown = 0; | |
246 | switch (m_AlignHor) { | |
efba2b89 VS |
247 | case wxHTML_ALIGN_LEFT : xdelta = 0; break; |
248 | case wxHTML_ALIGN_RIGHT : xdelta = 0 + (s_width - xpos); break; | |
249 | case wxHTML_ALIGN_CENTER : xdelta = 0 + (s_width - xpos) / 2; break; | |
5526e819 VS |
250 | } |
251 | if (xdelta < 0) xdelta = 0; | |
252 | xdelta += s_indent; | |
253 | ||
254 | ypos += ysizeup; | |
255 | while (line != cell) { | |
256 | line -> SetPos(line -> GetPosX() + xdelta, ypos + line -> GetPosY()); | |
257 | line = line -> GetNext(); | |
258 | } | |
259 | ||
260 | ypos += ysizedown; | |
261 | xpos = 0; | |
262 | ysizeup = ysizedown = 0; | |
263 | line = cell; | |
264 | } | |
265 | } | |
266 | ||
267 | // setup height & width, depending on container layout: | |
268 | m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom; | |
269 | ||
270 | if (m_Height < m_MinHeight) { | |
efba2b89 | 271 | if (m_MinHeightAlign != wxHTML_ALIGN_TOP) { |
5526e819 | 272 | int diff = m_MinHeight - m_Height; |
efba2b89 | 273 | if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2; |
5526e819 VS |
274 | cell = m_Cells; |
275 | while (cell) { | |
276 | cell -> SetPos(cell -> GetPosX(), cell -> GetPosY() + diff); | |
277 | cell = cell -> GetNext(); | |
278 | } | |
279 | } | |
280 | m_Height = m_MinHeight; | |
281 | } | |
282 | ||
283 | m_MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); | |
284 | if (m_Width < m_MaxLineWidth) m_Width = m_MaxLineWidth; | |
285 | ||
286 | wxHtmlCell::Layout(w); | |
287 | } | |
288 | ||
289 | ||
290 | #define mMin(a, b) (((a) < (b)) ? (a) : (b)) | |
291 | #define mMax(a, b) (((a) < (b)) ? (b) : (a)) | |
292 | ||
293 | void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) | |
294 | { | |
295 | // container visible, draw it: | |
296 | if ((y + m_PosY < view_y2) && (y + m_PosY + m_Height > view_y1)) { | |
297 | ||
298 | if (m_UseBkColour) { | |
299 | wxBrush myb = wxBrush(m_BkColour, wxSOLID); | |
300 | ||
301 | int real_y1 = mMax(y + m_PosY, view_y1); | |
302 | int real_y2 = mMin(y + m_PosY + m_Height - 1, view_y2); | |
303 | ||
304 | dc.SetBrush(myb); | |
305 | dc.SetPen(*wxTRANSPARENT_PEN); | |
306 | dc.DrawRectangle(x + m_PosX, real_y1, m_Width, real_y2 - real_y1 + 1); | |
307 | } | |
308 | ||
309 | if (m_UseBorder) { | |
310 | wxPen mypen1(m_BorderColour1, 1, wxSOLID); | |
311 | wxPen mypen2(m_BorderColour2, 1, wxSOLID); | |
312 | ||
313 | dc.SetPen(mypen1); | |
314 | dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX, y + m_PosY + m_Height - 1); | |
315 | dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY); | |
316 | dc.SetPen(mypen2); | |
317 | dc.DrawLine(x + m_PosX + m_Width - 1, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1); | |
318 | dc.DrawLine(x + m_PosX, y + m_PosY + m_Height - 1, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1); | |
319 | } | |
320 | ||
321 | if (m_Cells) m_Cells -> Draw(dc, x + m_PosX, y + m_PosY, view_y1, view_y2); | |
322 | } | |
323 | // container invisible, just proceed font+color changing: | |
324 | else { | |
325 | if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY); | |
326 | } | |
327 | ||
328 | wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); | |
329 | } | |
330 | ||
331 | ||
332 | ||
333 | void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y) | |
334 | { | |
335 | if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY); | |
336 | wxHtmlCell::DrawInvisible(dc, x, y); | |
337 | } | |
338 | ||
339 | ||
340 | ||
341 | wxString wxHtmlContainerCell::GetLink(int x, int y) const | |
342 | { | |
343 | wxHtmlCell *c = m_Cells; | |
344 | int cx, cy, cw, ch; | |
345 | ||
346 | while (c) { | |
347 | cx = c -> GetPosX(), cy = c -> GetPosY(); | |
348 | cw = c -> GetWidth(), ch = c -> GetHeight(); | |
349 | if ((x >= cx) && (x < cx + cw) && (y >= cy) && (y < cy + ch)) | |
350 | return c -> GetLink(x - cx, y - cy); | |
351 | c = c -> GetNext(); | |
352 | } | |
353 | return wxEmptyString; | |
354 | } | |
355 | ||
356 | ||
357 | ||
358 | void wxHtmlContainerCell::InsertCell(wxHtmlCell *f) | |
359 | { | |
360 | if (!m_Cells) m_Cells = m_LastCell = f; | |
361 | else { | |
362 | m_LastCell -> SetNext(f); | |
363 | m_LastCell = f; | |
364 | if (m_LastCell) while (m_LastCell -> GetNext()) m_LastCell = m_LastCell -> GetNext(); | |
365 | } | |
366 | f -> SetParent(this); | |
367 | } | |
368 | ||
369 | ||
370 | ||
371 | void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag) | |
372 | { | |
373 | if (tag.HasParam("ALIGN")) { | |
374 | wxString alg = tag.GetParam("ALIGN"); | |
375 | alg.MakeUpper(); | |
376 | if (alg == "CENTER") | |
efba2b89 | 377 | SetAlignHor(wxHTML_ALIGN_CENTER); |
9b64e798 | 378 | else if (alg == "LEFT") |
efba2b89 | 379 | SetAlignHor(wxHTML_ALIGN_LEFT); |
9b64e798 | 380 | else if (alg == "RIGHT") |
efba2b89 | 381 | SetAlignHor(wxHTML_ALIGN_RIGHT); |
5526e819 VS |
382 | } |
383 | } | |
384 | ||
385 | ||
386 | ||
387 | void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag) | |
388 | { | |
389 | if (tag.HasParam("WIDTH")) { | |
390 | int wdi; | |
391 | wxString wd = tag.GetParam("WIDTH"); | |
392 | ||
393 | if (wd[wd.Length()-1] == '%') { | |
66a77a74 | 394 | wxSscanf(wd.c_str(), wxT("%i%%"), &wdi); |
efba2b89 | 395 | SetWidthFloat(wdi, wxHTML_UNITS_PERCENT); |
5526e819 VS |
396 | } |
397 | else { | |
66a77a74 | 398 | wxSscanf(wd.c_str(), wxT("%i"), &wdi); |
efba2b89 | 399 | SetWidthFloat(wdi, wxHTML_UNITS_PIXELS); |
5526e819 VS |
400 | } |
401 | } | |
402 | } | |
403 | ||
404 | ||
405 | ||
406 | const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) const | |
407 | { | |
408 | const wxHtmlCell *r = NULL; | |
7e941458 | 409 | |
5526e819 VS |
410 | if (m_Cells) { |
411 | r = m_Cells -> Find(condition, param); | |
412 | if (r) return r; | |
413 | } | |
414 | ||
415 | return wxHtmlCell::Find(condition, param); | |
416 | } | |
417 | ||
418 | ||
419 | ||
420 | void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, bool left, bool middle, bool right) | |
421 | { | |
422 | if (m_Cells) { | |
423 | wxHtmlCell *c = m_Cells; | |
424 | while (c) { | |
425 | if ( (c -> GetPosX() <= x) && | |
426 | (c -> GetPosY() <= y) && | |
427 | (c -> GetPosX() + c -> GetWidth() > x) && | |
428 | (c -> GetPosY() + c -> GetHeight() > y)) { | |
429 | c -> OnMouseClick(parent, x - c -> GetPosX(), y - c -> GetPosY(), left, middle, right); | |
430 | break; | |
431 | } | |
432 | c = c -> GetNext(); | |
433 | } | |
434 | } | |
435 | } | |
436 | ||
437 | ||
438 | ||
439 | ||
440 | ||
441 | //-------------------------------------------------------------------------------- | |
442 | // wxHtmlColourCell | |
443 | //-------------------------------------------------------------------------------- | |
444 | ||
445 | void wxHtmlColourCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) | |
446 | { | |
efba2b89 | 447 | if (m_Flags & wxHTML_CLR_FOREGROUND) |
5526e819 | 448 | dc.SetTextForeground(m_Colour); |
efba2b89 | 449 | if (m_Flags & wxHTML_CLR_BACKGROUND) { |
5526e819 VS |
450 | dc.SetBackground(wxBrush(m_Colour, wxSOLID)); |
451 | dc.SetTextBackground(m_Colour); | |
452 | } | |
453 | wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); | |
454 | } | |
455 | ||
456 | void wxHtmlColourCell::DrawInvisible(wxDC& dc, int x, int y) | |
457 | { | |
efba2b89 | 458 | if (m_Flags & wxHTML_CLR_FOREGROUND) |
5526e819 | 459 | dc.SetTextForeground(m_Colour); |
efba2b89 | 460 | if (m_Flags & wxHTML_CLR_BACKGROUND) { |
5526e819 VS |
461 | dc.SetBackground(wxBrush(m_Colour, wxSOLID)); |
462 | dc.SetTextBackground(m_Colour); | |
463 | } | |
464 | wxHtmlCell::DrawInvisible(dc, x, y); | |
465 | } | |
466 | ||
467 | ||
468 | ||
469 | ||
470 | //-------------------------------------------------------------------------------- | |
471 | // wxHtmlFontCell | |
472 | //-------------------------------------------------------------------------------- | |
473 | ||
474 | void wxHtmlFontCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) | |
475 | { | |
476 | dc.SetFont(*m_Font); | |
477 | wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); | |
478 | } | |
479 | ||
480 | void wxHtmlFontCell::DrawInvisible(wxDC& dc, int x, int y) | |
481 | { | |
482 | dc.SetFont(*m_Font); | |
483 | wxHtmlCell::DrawInvisible(dc, x, y); | |
484 | } | |
485 | ||
486 | ||
487 | ||
488 | ||
489 | ||
490 | ||
491 | ||
492 | ||
493 | //-------------------------------------------------------------------------------- | |
494 | // wxHtmlWidgetCell | |
495 | //-------------------------------------------------------------------------------- | |
496 | ||
497 | wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow *wnd, int w) | |
498 | { | |
499 | int sx, sy; | |
500 | m_Wnd = wnd; | |
501 | m_Wnd -> GetSize(&sx, &sy); | |
502 | m_Width = sx, m_Height = sy; | |
503 | m_WidthFloat = w; | |
504 | } | |
505 | ||
506 | ||
507 | void wxHtmlWidgetCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) | |
508 | { | |
509 | int absx = 0, absy = 0, stx, sty; | |
510 | wxHtmlCell *c = this; | |
511 | ||
512 | while (c) { | |
513 | absx += c -> GetPosX(); | |
514 | absy += c -> GetPosY(); | |
515 | c = c -> GetParent(); | |
516 | } | |
517 | ||
518 | ((wxScrolledWindow*)(m_Wnd -> GetParent())) -> ViewStart(&stx, &sty); | |
efba2b89 | 519 | m_Wnd -> SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); |
5526e819 VS |
520 | |
521 | wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); | |
522 | } | |
523 | ||
524 | ||
525 | ||
526 | void wxHtmlWidgetCell::DrawInvisible(wxDC& dc, int x, int y) | |
527 | { | |
528 | int absx = 0, absy = 0, stx, sty; | |
529 | wxHtmlCell *c = this; | |
530 | ||
531 | while (c) { | |
532 | absx += c -> GetPosX(); | |
533 | absy += c -> GetPosY(); | |
534 | c = c -> GetParent(); | |
535 | } | |
7e941458 | 536 | |
5526e819 | 537 | ((wxScrolledWindow*)(m_Wnd -> GetParent())) -> ViewStart(&stx, &sty); |
efba2b89 | 538 | m_Wnd -> SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); |
ed673c6a | 539 | |
5526e819 VS |
540 | wxHtmlCell::DrawInvisible(dc, x, y); |
541 | } | |
542 | ||
543 | ||
544 | ||
545 | void wxHtmlWidgetCell::Layout(int w) | |
546 | { | |
547 | if (m_WidthFloat != 0) { | |
548 | m_Width = (w * m_WidthFloat) / 100; | |
549 | m_Wnd -> SetSize(m_Width, m_Height); | |
550 | } | |
551 | ||
552 | wxHtmlCell::Layout(w); | |
553 | } | |
554 | ||
555 | #endif |