~ubuntu-branches/ubuntu/karmic/notecase/karmic

« back to all changes in this revision

Viewing changes to src/lib/FmtInfo.h

  • Committer: Bazaar Package Importer
  • Author(s): Vijay(Vijay)
  • Date: 2007-06-14 00:13:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070614001348-z9e2vbgtenb9nhoo
Tags: 1.5.6-0ubuntu1
* New Upstream release 
*  The libgnomevfs2-dev is also added to Build-Depends 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////
 
2
// NoteCase notes manager project <http://notecase.sf.net>
 
3
//
 
4
// This code is licensed under BSD license.See "license.txt" for more details.
 
5
//
 
6
// File: Stores text formatting info
 
7
////////////////////////////////////////////////////////////////////////////
 
8
 
 
9
#ifndef FMTINFO_H_
 
10
#define FMTINFO_H_
 
11
 
 
12
#if _MSC_VER > 1000
 
13
#pragma once
 
14
#endif // _MSC_VER > 1000
 
15
 
 
16
#if _MSC_VER > 1000
 
17
  #pragma warning(disable:4786)
 
18
#endif
 
19
 
 
20
#include <string>
 
21
#include <vector>
 
22
#include <gtk/gtk.h>
 
23
 
 
24
//define format tags
 
25
#define FMT_NONE                        0
 
26
#define FMT_BOLD_BEGIN          1
 
27
#define FMT_BOLD_END            2
 
28
#define FMT_ITALIC_BEGIN        3
 
29
#define FMT_ITALIC_END          4
 
30
#define FMT_UNDERLINE_BEGIN     5
 
31
#define FMT_UNDERLINE_END       6
 
32
#define FMT_TXT_COLOR_BEGIN     7
 
33
#define FMT_TXT_COLOR_END       8
 
34
#define FMT_STRIKE_BEGIN        9
 
35
#define FMT_STRIKE_END          10
 
36
 
 
37
class FmtInfo
 
38
{
 
39
public:
 
40
        FmtInfo();
 
41
        FmtInfo(const FmtInfo &other);
 
42
        virtual ~FmtInfo();
 
43
 
 
44
        void operator = (const FmtInfo &other);
 
45
 
 
46
public:
 
47
        int nFormatTag;
 
48
        GdkColor color;
 
49
        int nOffset;
 
50
};
 
51
 
 
52
class FmtInfoList : public std::vector<FmtInfo>
 
53
{
 
54
public:
 
55
        FmtInfoList();
 
56
        virtual ~FmtInfoList();
 
57
 
 
58
        static bool IsStartTag(int nFormatTag);
 
59
        static int  CalcFormatEndTag(int nFormatTag);
 
60
 
 
61
        void Sort();
 
62
 
 
63
        bool IsRangeFormatted(int nStart, int nEnd, int nFormatTag);
 
64
        void AddFormatRange(int nStart, int nEnd, int nFormatTag, const GdkColor& color);
 
65
        void ClearFormatRange(int nStart, int nEnd, int nFormatTag);
 
66
 
 
67
        //adapt to events within the node text buffer
 
68
        void OnTxtInsert(int nOffset, int nCharsAdded, const char *szTxt);
 
69
        void OnTxtReplaced(int nStart, int nEnd, const char *szTxt);
 
70
        void OnTxtDelete(int nOffset, int nCharsDeleted);
 
71
        void OnLinkCreated(int nOffset, int nLen);
 
72
 
 
73
        int GetTagCount(int nFormatTag);
 
74
        void AssertValid();     //debugging helper
 
75
};
 
76
 
 
77
#endif // FMTINFO_H_