]> git.saurik.com Git - wxWidgets.git/blob - user/wxLayout/wxlparser.h
New, rewritten, wxLayout. Almost complete.
[wxWidgets.git] / user / wxLayout / wxlparser.h
1 /*-*- c++ -*-********************************************************
2 * wxlparser.h : parsers, import/export for wxLayoutList *
3 * *
4 * (C) 1998 by Karsten Ballüder (Ballueder@usa.net) *
5 * *
6 * $Id$
7 *******************************************************************/
8 #ifndef WXLPARSER_H
9 # define WXLPARSER_H
10
11 #ifdef __GNUG__
12 # pragma interface "wxlparser.h"
13 #endif
14
15 #ifndef NULL
16 # define NULL 0
17 #endif
18
19 enum wxLayoutExportType
20 {
21 WXLO_EXPORT_TEXT,
22 WXLO_EXPORT_HTML,
23 WXLO_EXPORT_OBJECT
24 };
25
26 enum wxLayoutExportMode
27 {
28 WXLO_EXPORT_AS_MASK = 0x0f,
29 WXLO_EXPORT_AS_TEXT = 0x00,
30 WXLO_EXPORT_AS_TEXT_AND_COMMANDS = 0x01,
31 WXLO_EXPORT_AS_HTML = 0x02,
32 WXLO_EXPORT_AS_OBJECTS = 0x03,
33
34 WXLO_EXPORT_WITH_MASK = 0xf0,
35 WXLO_EXPORT_WITH_CRLF = 0x00,
36 WXLO_EXPORT_WITH_LF_ONLY = 0x10
37 };
38
39 struct wxLayoutExportObject
40 {
41 wxLayoutExportType type;
42 union
43 {
44 wxString *text;
45 wxLayoutObject *object;
46 }content;
47 ~wxLayoutExportObject()
48 {
49 if(type == WXLO_EXPORT_TEXT || type == WXLO_EXPORT_HTML)
50 delete content.text;
51 }
52 };
53
54 struct wxLayoutExportStatus
55 {
56 wxLayoutExportStatus(wxLayoutList *list)
57 {
58 list->GetDefaults()->GetStyle(&m_si);
59 m_line = list->GetFirstLine();
60 m_iterator = m_line->GetFirstObject();
61 }
62
63 wxLayoutLine * m_line;
64 wxLOiterator m_iterator;
65 wxLayoutStyleInfo m_si;
66 };
67
68
69 #ifdef OS_WIN
70 /// import text into a wxLayoutList (including linefeeds):
71 void wxLayoutImportText(wxLayoutList &list, wxString const &str,
72 int withflag = WXLO_EXPORT_WITH_CRLF);
73
74 wxLayoutExportObject *wxLayoutExport(wxLayoutList &list,
75 int mode = WXLO_EXPORT_AS_TEXT|WXLO_EXPORT_WITH_CRLF);
76 #else
77 /// import text into a wxLayoutList (including linefeeds):
78 void wxLayoutImportText(wxLayoutList &list, wxString const &str,
79 int withflag = WXLO_EXPORT_WITH_LF_ONLY);
80
81 /// export text in a given format FIXME-MT: not thread safe, uses static variable
82 wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
83 int mode = WXLO_EXPORT_AS_TEXT|WXLO_EXPORT_WITH_LF_ONLY
84 );
85 #endif
86
87 #endif //WXLPARSER_H