]> git.saurik.com Git - wxWidgets.git/blame - utils/HelpGen/src/sourcepainter.h
removed ANSI configs from VisualC++ project files
[wxWidgets.git] / utils / HelpGen / src / sourcepainter.h
CommitLineData
cecfc5e7
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: 22/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleskandars Gluchovas
8bc17f14 9// Licence: wxWindows licence
cecfc5e7
VZ
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __SOURCEPAINTER_G__
13#define __SOURCEPAINTER_G__
14
15#ifndef ASSERT
16#define ASSERT(x) if (!(x)) throw
17#endif
18
19#if defined( wxUSE_TEMPLATE_STL )
20
8bc17f14
WS
21 #include <vector.h>
22 typedef vector<int> SPBlockListT;
cecfc5e7 23
8bc17f14
WS
24 #ifdef WIN32
25 #include <bstring.h>
26 #else
27 #include <strclass.h>
28 #include <string.h>
29 #endif
cecfc5e7
VZ
30#else
31
8bc17f14
WS
32 #include "wxstlvec.h"
33 #include "wx/string.h"
cecfc5e7 34
8bc17f14 35 typedef WXSTL_VECTOR_SHALLOW_COPY(int) SPBlockListT;
cecfc5e7
VZ
36
37#endif
38
39#include "markup.h" // import MarkupTagsT definition
40
41// "colored" codes for highlighted blocks
42
43#define RANK_BLACK 0 // common source fragments
44#define RANK_BLUE 1 // basic types
45#define RANK_RED 2 // reserved words
46#define RANK_GREEN 3 // comments
47
48// colored block description format :
49// int( ( rank << 16 ) | ( source_range_len ) )
50
51
52// FOR NOW:: no lagnguage-map selection
53
54// source code syntax heighlighter (CPP+JAVA+VB+PASCAL)
55
56class SourcePainter
57{
58protected:
2af95167 59 wxString mResultStr;
8bc17f14
WS
60 SPBlockListT mBlocks;
61 bool mCollectResultsOn;
cecfc5e7 62
8bc17f14
WS
63 // state variables
64 bool mIsInComment;
65 bool mCommentIsMultiline;
cecfc5e7
VZ
66public:
67
8bc17f14
WS
68 // assembleResultString == true - instructs painter
69 // to collect each chunk of srouce passed to ProcessSource(),
70 // so that results cann be futher obtained in a single string
71 // instead of vector of block descriptions
72
73 SourcePainter( bool assembleResultString = true );
74 virtual ~SourcePainter() {}
cecfc5e7 75
8bc17f14
WS
76 // can be called multiple times (e.g. on each source line)
77 void ProcessSource( char* src, int srcLen );
cecfc5e7 78
8bc17f14
WS
79 // method, for manually adjusting state of source painter
80 void SetState( bool isInComment,
81 bool commentIsMultiline );
cecfc5e7 82
8bc17f14
WS
83 // reinitializes object - clears results of previouse processing
84 void Init( bool assembleResultString = true );
cecfc5e7 85
8bc17f14
WS
86 // generates string of highlighted source for the scipting
87 // language given by "tags" argument
cecfc5e7 88
b6317810 89 virtual void GetResultString(wxString& result, MarkupTagsT tags);
cecfc5e7 90
8bc17f14 91 // returns vector of block descriptors, see SPBlockListT definition
d6922577 92 // (block descriptors can be used for fast custom highlighted text generation)
cecfc5e7 93
8bc17f14 94 SPBlockListT& GetBlocks();
cecfc5e7 95
8bc17f14
WS
96 // NOTE:: static method
97 // returns if the given word is a reserved word or basic type identifier
98 static bool IsKeyword( char* word, int wordLen );
cecfc5e7
VZ
99};
100
101#endif