~registry/codeblocks/trunk

« back to all changes in this revision

Viewing changes to src/include/editorcolourset.h

  • Committer: mandrav
  • Date: 2007-02-12 14:55:28 UTC
  • Revision ID: svn-v4:98b59c6a-2706-0410-b7d6-d2fa1a1880c9:trunk:3594
* First part of directories layout re-organization: moved all sdk header files to a new dir named "include".

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef EDITORCOLORSET_H
 
2
#define EDITORCOLORSET_H
 
3
 
 
4
#include <wx/dynarray.h>
 
5
#include <wx/hashmap.h>
 
6
#include <wx/intl.h>
 
7
#include <wx/wxscintilla.h> // wxSCI_KEYWORDSET_MAX
 
8
#include "settings.h"
 
9
 
 
10
#ifndef CB_PRECOMP
 
11
    #include "globals.h" // HighlightLanguage
 
12
#endif
 
13
 
 
14
// forward decls
 
15
class cbEditor;
 
16
class cbStyledTextCtrl;
 
17
 
 
18
#define COLORSET_DEFAULT        _T("default")
 
19
 
 
20
struct OptionColour
 
21
{
 
22
        wxString name;
 
23
        int value;
 
24
        wxColour fore;
 
25
        wxColour back;
 
26
        bool bold;
 
27
        bool italics;
 
28
        bool underlined;
 
29
        bool isStyle;
 
30
 
 
31
        wxColour originalfore;
 
32
        wxColour originalback;
 
33
        bool originalbold;
 
34
        bool originalitalics;
 
35
        bool originalunderlined;
 
36
        bool originalisStyle;
 
37
};
 
38
WX_DEFINE_ARRAY(OptionColour*, OptionColours);
 
39
 
 
40
struct OptionSet
 
41
{
 
42
    wxString m_Langs;
 
43
    OptionColours m_Colours;
 
44
    wxString m_Keywords[wxSCI_KEYWORDSET_MAX + 1]; // wxSCI_KEYWORDSET_MAX+1 keyword sets
 
45
    wxArrayString m_FileMasks;
 
46
    int m_Lexers;
 
47
    wxString m_SampleCode;
 
48
    int m_BreakLine;
 
49
    int m_DebugLine;
 
50
    int m_ErrorLine;
 
51
 
 
52
    wxString m_originalKeywords[wxSCI_KEYWORDSET_MAX + 1]; // wxSCI_KEYWORDSET_MAX+1 keyword sets
 
53
    wxArrayString m_originalFileMasks;
 
54
};
 
55
WX_DECLARE_STRING_HASH_MAP(OptionSet, OptionSetsMap);
 
56
 
 
57
class EditorColourSet
 
58
{
 
59
        public:
 
60
                EditorColourSet(const wxString& setName = COLORSET_DEFAULT);
 
61
                EditorColourSet(const EditorColourSet& other); // copy ctor
 
62
                ~EditorColourSet();
 
63
 
 
64
                HighlightLanguage AddHighlightLanguage(int lexer, const wxString& name);
 
65
                HighlightLanguage GetHighlightLanguage(int lexer); // from scintilla lexer (wxSCI_LEX_*)
 
66
                HighlightLanguage GetHighlightLanguage(const wxString& name);
 
67
                wxArrayString GetAllHighlightLanguages();
 
68
 
 
69
                void AddOption(HighlightLanguage lang,
 
70
                                                const wxString& name,
 
71
                                                int value,
 
72
                                                wxColour fore = wxNullColour,
 
73
                                                wxColour back = wxNullColour,
 
74
                                                bool bold = false,
 
75
                                                bool italics = false,
 
76
                                                bool underlined = false,
 
77
                                                bool isStyle = true);
 
78
                bool AddOption(HighlightLanguage lang, OptionColour* option, bool checkIfExists = true);
 
79
                OptionColour* GetOptionByName(HighlightLanguage lang, const wxString& name);
 
80
                OptionColour* GetOptionByValue(HighlightLanguage lang, int value);
 
81
                OptionColour* GetOptionByIndex(HighlightLanguage lang, int index);
 
82
                void UpdateOptionsWithSameName(HighlightLanguage lang, OptionColour* base);
 
83
                int GetOptionCount(HighlightLanguage lang);
 
84
                HighlightLanguage GetLanguageForFilename(const wxString& filename);
 
85
                wxString GetLanguageName(HighlightLanguage lang);
 
86
                wxString GetName(){ return m_Name; }
 
87
                void SetName(const wxString& name){ m_Name = name; }
 
88
                HighlightLanguage Apply(cbEditor* editor, HighlightLanguage lang=HL_AUTO);
 
89
                void Apply(HighlightLanguage lang, cbStyledTextCtrl* control);
 
90
                void Save();
 
91
                void Reset(HighlightLanguage lang);
 
92
                wxString& GetKeywords(HighlightLanguage lang, int idx);
 
93
                void SetKeywords(HighlightLanguage lang, int idx, const wxString& keywords);
 
94
                const wxArrayString& GetFileMasks(HighlightLanguage lang);
 
95
                void SetFileMasks(HighlightLanguage lang, const wxString& masks, const wxString& = _(","));
 
96
                wxString GetSampleCode(HighlightLanguage lang, int* breakLine, int* debugLine, int* errorLine);
 
97
                void SetSampleCode(HighlightLanguage lang, const wxString& sample, int breakLine, int debugLine, int errorLine);
 
98
        protected:
 
99
        private:
 
100
                void DoApplyStyle(cbStyledTextCtrl* control, int value, OptionColour* option);
 
101
                void LoadAvailableSets();
 
102
                void Load();
 
103
                void ClearAllOptionColours();
 
104
 
 
105
                wxString m_Name;
 
106
                OptionSetsMap m_Sets;
 
107
};
 
108
 
 
109
#endif // EDITORCOLORSET_H
 
110