]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_tables.cpp
Shell version of dllar, needed for building DLLs while generating
[wxWidgets.git] / src / html / m_tables.cpp
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
c88293a4 2// Name: m_tables.cpp
5526e819
VS
3// Purpose: wxHtml module for tables
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819
VS
6// Copyright: (c) 1999 Vaclav Slavik
7// Licence: wxWindows Licence
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
3364ab79
RS
11#pragma implementation
12#endif
13
3096bd2f 14#include "wx/wxprec.h"
3364ab79 15
314260fb 16#include "wx/defs.h"
f6bcfd97 17#if wxUSE_HTML && wxUSE_STREAMS
2b5f62a0 18#ifdef __BORLANDC__
3364ab79
RS
19#pragma hdrstop
20#endif
21
22#ifndef WXPRECOMP
3364ab79
RS
23#endif
24
5526e819
VS
25
26/*
27REMARKS:
c88293a4 28 1. This version of m_tables doesn't support auto-layout algorithm.
5526e819
VS
29 This means that all columns are of same width unless explicitly specified.
30*/
31
32
69941f05
VS
33#include "wx/html/forcelnk.h"
34#include "wx/html/m_templ.h"
5526e819 35
69941f05 36#include "wx/html/htmlcell.h"
5526e819 37
c88293a4 38FORCE_LINK_ME(m_tables)
5526e819
VS
39
40
41#define TABLE_BORDER_CLR_1 wxColour(0xC5, 0xC2, 0xC5)
42#define TABLE_BORDER_CLR_2 wxColour(0x62, 0x61, 0x62)
43
44
45//-----------------------------------------------------------------------------
46// wxHtmlTableCell
47//-----------------------------------------------------------------------------
48
49
79d6c018
VS
50struct colStruct
51{
52 int width, units;
53 // width of the column either in pixels or percents
54 // ('width' is the number, 'units' determines its meaning)
55 int minWidth, maxWidth;
56 // minimal/maximal column width. This is needed by HTML 4.0
57 // layouting algorithm and can be determined by trying to
58 // layout table cells with width=1 and width=infinity
59 int leftpos, pixwidth, maxrealwidth;
60 // temporary (depends on actual width of table)
61};
62
63enum cellState
64{
65 cellSpan,
66 cellUsed,
67 cellFree
68};
69
70struct cellStruct
71{
72 wxHtmlContainerCell *cont;
73 int colspan, rowspan;
74 int minheight, valign;
75 cellState flag;
76};
5526e819
VS
77
78
79class wxHtmlTableCell : public wxHtmlContainerCell
80{
79d6c018
VS
81protected:
82 /* These are real attributes: */
83
84 // should we draw borders or not?
85 bool m_HasBorders;
86 // number of columns; rows
87 int m_NumCols, m_NumRows;
88 // array of column information
89 colStruct *m_ColsInfo;
90 // 2D array of all cells in the table : m_CellInfo[row][column]
91 cellStruct **m_CellInfo;
92 // spaces between cells
93 int m_Spacing;
94 // cells internal indentation
95 int m_Padding;
96
97private:
98 /* ...and these are valid only when parsing the table: */
99
100 // number of actual column (ranging from 0..m_NumCols)
101 int m_ActualCol, m_ActualRow;
102
103 // default values (for table and row):
104 wxColour m_tBkg, m_rBkg;
105 wxString m_tValign, m_rValign;
106
107 double m_PixelScale;
108
109
110public:
111 wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag, double pixel_scale = 1.0);
112 ~wxHtmlTableCell();
113 virtual void Layout(int w);
114
115 void AddRow(const wxHtmlTag& tag);
116 void AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag);
117
118private:
119 // Reallocates memory to given number of cols/rows
120 // and changes m_NumCols/m_NumRows value to reflect this change
121 // NOTE! You CAN'T change m_NumCols/m_NumRows before calling this!!
122 void ReallocCols(int cols);
123 void ReallocRows(int rows);
124
125 // Computes minimal and maximal widths of columns. Needs to be called
126 // only once, before first Layout().
127 void ComputeMinMaxWidths();
22f3361e
VZ
128
129 DECLARE_NO_COPY_CLASS(wxHtmlTableCell)
5526e819
VS
130};
131
132
133
edbd0635 134wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag, double pixel_scale)
5526e819
VS
135 : wxHtmlContainerCell(parent)
136{
edbd0635 137 m_PixelScale = pixel_scale;
b0bdbbfe
VS
138 m_HasBorders =
139 (tag.HasParam(wxT("BORDER")) && tag.GetParam(wxT("BORDER")) != wxT("0"));
5526e819
VS
140 m_ColsInfo = NULL;
141 m_NumCols = m_NumRows = 0;
142 m_CellInfo = NULL;
143 m_ActualCol = m_ActualRow = -1;
144
145 /* scan params: */
04dbb646 146 if (tag.HasParam(wxT("BGCOLOR")))
8bd72d90 147 tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg);
04dbb646
VZ
148 if (tag.HasParam(wxT("VALIGN")))
149 m_tValign = tag.GetParam(wxT("VALIGN"));
150 else
8bd72d90
VS
151 m_tValign = wxEmptyString;
152 if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing))
153 m_Spacing = 2;
154 if (!tag.GetParamAsInt(wxT("CELLPADDING"), &m_Padding))
155 m_Padding = 3;
edbd0635
VS
156 m_Spacing = (int)(m_PixelScale * (double)m_Spacing);
157 m_Padding = (int)(m_PixelScale * (double)m_Padding);
5526e819
VS
158
159 if (m_HasBorders)
160 SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2);
161}
162
163
164
165wxHtmlTableCell::~wxHtmlTableCell()
166{
167 if (m_ColsInfo) free(m_ColsInfo);
04dbb646 168 if (m_CellInfo)
4f9297b0 169 {
5526e819
VS
170 for (int i = 0; i < m_NumRows; i++)
171 free(m_CellInfo[i]);
172 free(m_CellInfo);
173 }
174}
175
176
177
178void wxHtmlTableCell::ReallocCols(int cols)
179{
180 int i,j;
181
04dbb646 182 for (i = 0; i < m_NumRows; i++)
4f9297b0 183 {
5526e819
VS
184 m_CellInfo[i] = (cellStruct*) realloc(m_CellInfo[i], sizeof(cellStruct) * cols);
185 for (j = m_NumCols; j < cols; j++)
186 m_CellInfo[i][j].flag = cellFree;
187 }
188
189 m_ColsInfo = (colStruct*) realloc(m_ColsInfo, sizeof(colStruct) * cols);
04dbb646 190 for (j = m_NumCols; j < cols; j++)
4f9297b0 191 {
5526e819 192 m_ColsInfo[j].width = 0;
efba2b89 193 m_ColsInfo[j].units = wxHTML_UNITS_PERCENT;
79d6c018 194 m_ColsInfo[j].minWidth = m_ColsInfo[j].maxWidth = -1;
5526e819
VS
195 }
196
197 m_NumCols = cols;
198}
199
200
201
202void wxHtmlTableCell::ReallocRows(int rows)
203{
204 m_CellInfo = (cellStruct**) realloc(m_CellInfo, sizeof(cellStruct*) * rows);
04dbb646 205 for (int row = m_NumRows; row < rows ; row++)
80eab469 206 {
04dbb646 207 if (m_NumCols == 0)
80eab469 208 m_CellInfo[row] = NULL;
04dbb646 209 else
80eab469
VS
210 {
211 m_CellInfo[row] = (cellStruct*) malloc(sizeof(cellStruct) * m_NumCols);
212 for (int col = 0; col < m_NumCols; col++)
213 m_CellInfo[row][col].flag = cellFree;
214 }
5526e819 215 }
5526e819
VS
216 m_NumRows = rows;
217}
218
219
5526e819
VS
220void wxHtmlTableCell::AddRow(const wxHtmlTag& tag)
221{
5526e819 222 m_ActualCol = -1;
d361bbff
VS
223 // VS: real allocation of row entry is done in AddCell in order
224 // to correctly handle empty rows (i.e. "<tr></tr>")
225 // m_ActualCol == -1 indicates that AddCell has to allocate new row.
5526e819 226
d361bbff 227 // scan params:
5526e819 228 m_rBkg = m_tBkg;
04dbb646 229 if (tag.HasParam(wxT("BGCOLOR")))
8bd72d90 230 tag.GetParamAsColour(wxT("BGCOLOR"), &m_rBkg);
04dbb646
VZ
231 if (tag.HasParam(wxT("VALIGN")))
232 m_rValign = tag.GetParam(wxT("VALIGN"));
233 else
d361bbff 234 m_rValign = m_tValign;
5526e819
VS
235}
236
237
238
239void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
240{
d361bbff
VS
241 // Is this cell in new row?
242 // VS: we can't do it in AddRow, see my comment there
243 if (m_ActualCol == -1)
244 {
245 if (m_ActualRow + 1 > m_NumRows - 1)
246 ReallocRows(m_ActualRow + 2);
247 m_ActualRow++;
248 }
249
250 // cells & columns:
04dbb646 251 do
4f9297b0 252 {
5526e819 253 m_ActualCol++;
04dbb646 254 } while ((m_ActualCol < m_NumCols) &&
8bd72d90 255 (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree));
04dbb646 256
5526e819
VS
257 if (m_ActualCol > m_NumCols - 1)
258 ReallocCols(m_ActualCol + 1);
259
260 int r = m_ActualRow, c = m_ActualCol;
261
262 m_CellInfo[r][c].cont = cell;
263 m_CellInfo[r][c].colspan = 1;
264 m_CellInfo[r][c].rowspan = 1;
265 m_CellInfo[r][c].flag = cellUsed;
266 m_CellInfo[r][c].minheight = 0;
efba2b89 267 m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP;
5526e819
VS
268
269 /* scan for parameters: */
270
271 // width:
272 {
8bd72d90 273 if (tag.HasParam(wxT("WIDTH")))
2fa3b707 274 {
8bd72d90 275 wxString wd = tag.GetParam(wxT("WIDTH"));
5526e819 276
8bd72d90 277 if (wd[wd.Length()-1] == wxT('%'))
2fa3b707 278 {
66a77a74 279 wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width);
efba2b89 280 m_ColsInfo[c].units = wxHTML_UNITS_PERCENT;
5526e819 281 }
04dbb646 282 else
2fa3b707 283 {
66a77a74 284 wxSscanf(wd.c_str(), wxT("%i"), &m_ColsInfo[c].width);
edbd0635 285 m_ColsInfo[c].width = (int)(m_PixelScale * (double)m_ColsInfo[c].width);
efba2b89 286 m_ColsInfo[c].units = wxHTML_UNITS_PIXELS;
5526e819
VS
287 }
288 }
289 }
290
291
292 // spanning:
293 {
8bd72d90
VS
294 tag.GetParamAsInt(wxT("COLSPAN"), &m_CellInfo[r][c].colspan);
295 tag.GetParamAsInt(wxT("ROWSPAN"), &m_CellInfo[r][c].rowspan);
fbe77cea
VS
296
297 // VS: the standard says this about col/rowspan:
298 // "This attribute specifies the number of rows spanned by the
299 // current cell. The default value of this attribute is one ("1").
300 // The value zero ("0") means that the cell spans all rows from the
301 // current row to the last row of the table." All mainstream
302 // browsers act as if 0==1, though, and so does wxHTML.
303 if (m_CellInfo[r][c].colspan < 1)
304 m_CellInfo[r][c].colspan = 1;
305 if (m_CellInfo[r][c].rowspan < 1)
306 m_CellInfo[r][c].rowspan = 1;
307
308 if ((m_CellInfo[r][c].colspan > 1) || (m_CellInfo[r][c].rowspan > 1))
2fa3b707 309 {
5526e819
VS
310 int i, j;
311
04dbb646 312 if (r + m_CellInfo[r][c].rowspan > m_NumRows)
8bd72d90 313 ReallocRows(r + m_CellInfo[r][c].rowspan);
04dbb646 314 if (c + m_CellInfo[r][c].colspan > m_NumCols)
8bd72d90 315 ReallocCols(c + m_CellInfo[r][c].colspan);
5526e819
VS
316 for (i = r; i < r + m_CellInfo[r][c].rowspan; i++)
317 for (j = c; j < c + m_CellInfo[r][c].colspan; j++)
318 m_CellInfo[i][j].flag = cellSpan;
319 m_CellInfo[r][c].flag = cellUsed;
320 }
321 }
322
323 //background color:
324 {
8bd72d90 325 wxColour bk = m_rBkg;
04dbb646 326 if (tag.HasParam(wxT("BGCOLOR")))
8bd72d90
VS
327 tag.GetParamAsColour(wxT("BGCOLOR"), &bk);
328 if (bk.Ok())
329 cell->SetBackgroundColour(bk);
5526e819
VS
330 }
331 if (m_HasBorders)
4f9297b0 332 cell->SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1);
5526e819
VS
333
334 // vertical alignment:
335 {
336 wxString valign;
04dbb646
VZ
337 if (tag.HasParam(wxT("VALIGN")))
338 valign = tag.GetParam(wxT("VALIGN"));
339 else
8bd72d90 340 valign = m_tValign;
5526e819 341 valign.MakeUpper();
04dbb646 342 if (valign == wxT("TOP"))
8bd72d90 343 m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP;
04dbb646 344 else if (valign == wxT("BOTTOM"))
8bd72d90 345 m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM;
efba2b89 346 else m_CellInfo[r][c].valign = wxHTML_ALIGN_CENTER;
5526e819
VS
347 }
348
4f9297b0 349 cell->SetIndent(m_Padding, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
5526e819
VS
350}
351
79d6c018
VS
352void wxHtmlTableCell::ComputeMinMaxWidths()
353{
354 if (m_NumCols == 0 || m_ColsInfo[0].minWidth != -1) return;
355
79d6c018
VS
356 for (int c = 0; c < m_NumCols; c++)
357 {
358 for (int r = 0; r < m_NumRows; r++)
359 {
360 cellStruct& cell = m_CellInfo[r][c];
361 if (cell.flag == cellUsed)
362 {
026d1fac 363 cell.cont->Layout(2*m_Padding + 1);
8c571f46 364 int width = cell.cont->GetWidth();
026d1fac 365 width -= (cell.colspan-1) * m_Spacing;
79d6c018 366 // HTML 4.0 says it is acceptable to distribute min/max
79d6c018 367 width /= cell.colspan;
79d6c018
VS
368 for (int j = 0; j < cell.colspan; j++)
369 if (width > m_ColsInfo[c+j].minWidth)
370 m_ColsInfo[c+j].minWidth = width;
371 }
372 }
373 }
374
375 // FIXME -- compute maxWidth as well. Not needed yet, so there's no
376 // point in computing it.
377}
5526e819
VS
378
379
380void wxHtmlTableCell::Layout(int w)
381{
79d6c018 382 ComputeMinMaxWidths();
026d1fac
VS
383
384 wxHtmlCell::Layout(w);
79d6c018 385
5526e819
VS
386 /*
387
388 WIDTH ADJUSTING :
389
390 */
391
04dbb646 392 if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT)
4f9297b0 393 {
5526e819
VS
394 if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100;
395 else m_Width = m_WidthFloat * w / 100;
396 }
04dbb646 397 else
4f9297b0 398 {
5526e819
VS
399 if (m_WidthFloat < 0) m_Width = w + m_WidthFloat;
400 else m_Width = m_WidthFloat;
401 }
402
403
404 /*
405
406 LAYOUTING :
407
408 */
409
410 /* 1. setup columns widths: */
411 {
412 int wpix = m_Width - (m_NumCols + 1) * m_Spacing;
413 int i, j;
5526e819
VS
414
415 // 1a. setup fixed-width columns:
416 for (i = 0; i < m_NumCols; i++)
efba2b89 417 if (m_ColsInfo[i].units == wxHTML_UNITS_PIXELS)
79d6c018
VS
418 {
419 m_ColsInfo[i].pixwidth = wxMax(m_ColsInfo[i].width,
420 m_ColsInfo[i].minWidth);
421 wpix -= m_ColsInfo[i].pixwidth;
422 }
5526e819
VS
423
424 // 1b. setup floating-width columns:
79d6c018 425 int wtemp = 0;
5526e819 426 for (i = 0; i < m_NumCols; i++)
efba2b89 427 if ((m_ColsInfo[i].units == wxHTML_UNITS_PERCENT) && (m_ColsInfo[i].width != 0))
79d6c018
VS
428 {
429 m_ColsInfo[i].pixwidth = wxMax(m_ColsInfo[i].width * wpix / 100,
430 m_ColsInfo[i].minWidth);
431 wtemp += m_ColsInfo[i].pixwidth;
432 }
5526e819
VS
433 wpix -= wtemp;
434
435 // 1c. setup defalut columns (no width specification supplied):
8c571f46
VS
436 // FIXME: This algorithm doesn't conform to HTML standard : it assigns
437 // equal widths instead of optimal
5526e819
VS
438 for (i = j = 0; i < m_NumCols; i++)
439 if (m_ColsInfo[i].width == 0) j++;
440 for (i = 0; i < m_NumCols; i++)
441 if (m_ColsInfo[i].width == 0)
8c571f46
VS
442 {
443 // FIXME: this is not optimal, because if we allocate more than
444 // wpix/j pixels to one column, we should try to allocate
445 // smaller place to other columns
446 m_ColsInfo[i].pixwidth = wxMax(wpix/j, m_ColsInfo[i].minWidth);
447 }
5526e819
VS
448 }
449
450 /* 2. compute positions of columns: */
451 {
452 int wpos = m_Spacing;
04dbb646 453 for (int i = 0; i < m_NumCols; i++)
2fa3b707 454 {
5526e819
VS
455 m_ColsInfo[i].leftpos = wpos;
456 wpos += m_ColsInfo[i].pixwidth + m_Spacing;
457 }
458 }
459
460 /* 3. sub-layout all cells: */
461 {
2776d7c3 462 int *ypos = new int[m_NumRows + 1];
5526e819
VS
463
464 int actcol, actrow;
465 int fullwid;
466 wxHtmlContainerCell *actcell;
467
2fa3b707
VS
468 ypos[0] = m_Spacing;
469 for (actrow = 1; actrow <= m_NumRows; actrow++) ypos[actrow] = -1;
04dbb646 470 for (actrow = 0; actrow < m_NumRows; actrow++)
2fa3b707
VS
471 {
472 if (ypos[actrow] == -1) ypos[actrow] = ypos[actrow-1];
5526e819
VS
473 // 3a. sub-layout and detect max height:
474
475 for (actcol = 0; actcol < m_NumCols; actcol++) {
476 if (m_CellInfo[actrow][actcol].flag != cellUsed) continue;
477 actcell = m_CellInfo[actrow][actcol].cont;
478 fullwid = 0;
479 for (int i = actcol; i < m_CellInfo[actrow][actcol].colspan + actcol; i++)
480 fullwid += m_ColsInfo[i].pixwidth;
a97a264f 481 fullwid += (m_CellInfo[actrow][actcol].colspan - 1) * m_Spacing;
4f9297b0
VS
482 actcell->SetMinHeight(m_CellInfo[actrow][actcol].minheight, m_CellInfo[actrow][actcol].valign);
483 actcell->Layout(fullwid);
5526e819 484
4f9297b0 485 if (ypos[actrow] + actcell->GetHeight() + m_CellInfo[actrow][actcol].rowspan * m_Spacing > ypos[actrow + m_CellInfo[actrow][actcol].rowspan])
5526e819 486 ypos[actrow + m_CellInfo[actrow][actcol].rowspan] =
4f9297b0 487 ypos[actrow] + actcell->GetHeight() + m_CellInfo[actrow][actcol].rowspan * m_Spacing;
5526e819
VS
488 }
489 }
490
04dbb646 491 for (actrow = 0; actrow < m_NumRows; actrow++)
2fa3b707 492 {
5526e819
VS
493 // 3b. place cells in row & let'em all have same height:
494
04dbb646 495 for (actcol = 0; actcol < m_NumCols; actcol++)
2fa3b707 496 {
5526e819
VS
497 if (m_CellInfo[actrow][actcol].flag != cellUsed) continue;
498 actcell = m_CellInfo[actrow][actcol].cont;
4f9297b0 499 actcell->SetMinHeight(
a97a264f 500 ypos[actrow + m_CellInfo[actrow][actcol].rowspan] - ypos[actrow] - m_Spacing,
5526e819
VS
501 m_CellInfo[actrow][actcol].valign);
502 fullwid = 0;
503 for (int i = actcol; i < m_CellInfo[actrow][actcol].colspan + actcol; i++)
504 fullwid += m_ColsInfo[i].pixwidth;
a97a264f 505 fullwid += (m_CellInfo[actrow][actcol].colspan - 1) * m_Spacing;
4f9297b0
VS
506 actcell->Layout(fullwid);
507 actcell->SetPos(m_ColsInfo[actcol].leftpos, ypos[actrow]);
5526e819 508 }
5526e819
VS
509 }
510 m_Height = ypos[m_NumRows];
2776d7c3 511 delete[] ypos;
5526e819 512 }
8c571f46
VS
513
514 /* 4. adjust table's width if it was too small: */
515 if (m_NumCols > 0)
516 {
517 int twidth = m_ColsInfo[m_NumCols-1].leftpos +
518 m_ColsInfo[m_NumCols-1].pixwidth + m_Spacing;
519 if (twidth > m_Width)
520 m_Width = twidth;
521 }
5526e819
VS
522}
523
524
525
526
527
528
529//-----------------------------------------------------------------------------
530// The tables handler:
531//-----------------------------------------------------------------------------
532
533
534TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
535
536 TAG_HANDLER_VARS
537 wxHtmlTableCell* m_Table;
538 wxString m_tAlign, m_rAlign;
5526e819
VS
539
540 TAG_HANDLER_CONSTR(TABLE)
541 {
542 m_Table = NULL;
01325161 543 m_tAlign = m_rAlign = wxEmptyString;
5526e819
VS
544 }
545
546
547 TAG_HANDLER_PROC(tag)
548 {
549 wxHtmlContainerCell *c;
550
551 // new table started, backup upper-level table (if any) and create new:
04dbb646 552 if (tag.GetName() == wxT("TABLE"))
2fa3b707 553 {
5526e819
VS
554 wxHtmlTableCell *oldt = m_Table;
555 wxHtmlContainerCell *oldcont;
5526e819 556
4f9297b0 557 oldcont = c = m_WParser->OpenContainer();
5526e819 558
4f9297b0
VS
559 c->SetWidthFloat(tag, m_WParser->GetPixelScale());
560 m_Table = new wxHtmlTableCell(c, tag, m_WParser->GetPixelScale());
2755d437 561 int oldAlign = m_WParser->GetAlign();
5526e819 562 m_tAlign = wxEmptyString;
8bd72d90
VS
563 if (tag.HasParam(wxT("ALIGN")))
564 m_tAlign = tag.GetParam(wxT("ALIGN"));
5526e819
VS
565
566 ParseInner(tag);
567
2755d437 568 m_WParser->SetAlign(oldAlign);
4f9297b0
VS
569 m_WParser->SetContainer(oldcont);
570 m_WParser->CloseContainer();
fbe77cea 571
5526e819
VS
572 m_Table = oldt;
573 return TRUE;
574 }
575
576
211dfedd 577 else if (m_Table)
2fa3b707 578 {
5526e819 579 // new row in table
04dbb646 580 if (tag.GetName() == wxT("TR"))
2fa3b707 581 {
4f9297b0 582 m_Table->AddRow(tag);
5526e819 583 m_rAlign = m_tAlign;
04dbb646 584 if (tag.HasParam(wxT("ALIGN")))
8bd72d90 585 m_rAlign = tag.GetParam(wxT("ALIGN"));
5526e819
VS
586 }
587
588 // new cell
04dbb646 589 else
2fa3b707 590 {
4f9297b0
VS
591 c = m_WParser->SetContainer(new wxHtmlContainerCell(m_Table));
592 m_Table->AddCell(c, tag);
5526e819 593
4f9297b0 594 m_WParser->OpenContainer();
5526e819 595
04dbb646 596 if (tag.GetName() == wxT("TH")) /*header style*/
4f9297b0 597 m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
2755d437
VS
598 else
599 m_WParser->SetAlign(wxHTML_ALIGN_LEFT);
600
601 wxString als;
602
603 als = m_rAlign;
604 if (tag.HasParam(wxT("ALIGN")))
605 als = tag.GetParam(wxT("ALIGN"));
606 als.MakeUpper();
607 if (als == wxT("RIGHT"))
608 m_WParser->SetAlign(wxHTML_ALIGN_RIGHT);
609 else if (als == wxT("LEFT"))
610 m_WParser->SetAlign(wxHTML_ALIGN_LEFT);
611 else if (als == wxT("CENTER"))
612 m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
613
4f9297b0 614 m_WParser->OpenContainer();
5526e819
VS
615 }
616 }
617 return FALSE;
618 }
619
620TAG_HANDLER_END(TABLE)
621
622
623
624
625
626TAGS_MODULE_BEGIN(Tables)
627
628 TAGS_MODULE_ADD(TABLE)
629
630TAGS_MODULE_END(Tables)
631
632
633#endif