summaryrefslogtreecommitdiffstats
path: root/src/kvirc/ui/kvi_ircviewprivate.h
blob: 790976bd725bef911568b1d0611873720e7ca3ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef _KVI_IRCVIEWPRIVATE_H_
#define _KVI_IRCVIEWPRIVATE_H_
//=========================================================================================================
//
//   File : kvi_ircviewprivate.h
//   Creation date : Sat Oct 9 2004 16:29:01 by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2004 Szymon Stefanek (pragma at kvirc dot net)
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=========================================================================================================

#include "kvi_settings.h"
#include <tqstring.h>

//=========================================================================================================
// Internal data structures
//=========================================================================================================

// Force the structs to be packed...
#ifdef COMPILE_ON_WINDOWS
	#pragma pack(push,old_packing,1)
	#define _KVI_PACKED
#else //!COMPILE_ON_WIDNOWS
	// this works only on gcc
	#ifdef __GNUC__
		#define _KVI_PACKED __attribute__((__packed__))
	#else
		#define _KVI_PACKED
	#endif
#endif //!COMPILE_ON_WINDOWS

//
// The LineChunk structure contains informations about
// an attribute change, an icon or a link
//
// type can be one of:
//
//  KVI_TEXT_ICON:
//     the uIconId member is the icon to be shown
//     szPayload contains the text that triggered this icon was triggered by
//  KVI_TEXT_UNICON:
//     the text block after an icon
//  KVI_TEXT_ESCAPE:
//     szPayload contains the encoded escape command
//     colors.fore contains the new text color
//  KVI_TEXT_UNESCAPE:
//     the text block after an escape
//  KVI_TEXT_COLOR:
//     the colors.back and colors.fore members indicate the color change
//  KVI_TEXT_BOLD:
//     toggles the bold flag
//  KVI_TEXT_UNDERLINE:
//     toggles the underline flag
//  KVI_TEXT_REVERSE:
//     inverts the current fore and back colors
//  KVI_TEXT_RESET:
//     resets the color, bold and underline flags
//

typedef struct _KviIrcViewLineChunk
{
	unsigned char  type;                               // chunk type
	int            iTextStart;                         // index in the szText string of the beginning of the block
	int            iTextLen;                           // length in chars of the block (excluding the terminator)
	kvi_wchar_t  * szPayload;                          // KVI_TEXT_ESCAPE attribute command buffer and KVI_TEXT_ICON icon name (non zeroed for other attributes!!!)
	kvi_wchar_t  * szSmileId;
	struct {
	unsigned char back;                        // optional background color for KVI_TEXT_COLOR attribute
	unsigned char fore;                        // optional foreground color for KVI_TEXT_COLOR attribute (used also for KVI_TEXT_ESCAPE!!!)
	} _KVI_PACKED colors; // anonymous
//	TQColor customBack;
	TQColor customFore;
} /*_KVI_PACKED*/ KviIrcViewLineChunk;

//
// The wrapped paintable data block
//

typedef struct _KviIrcViewWrappedBlock
{
	KviIrcViewLineChunk     * pChunk;                  // pointer to real line chunk or 0 for word wraps
	int                       block_start;             // this is generally different than pAttribute->block_idx!
	int                       block_len;               // length if the block in characters
	int                       block_width;             // width of the block in pixels
} _KVI_PACKED KviIrcViewWrappedBlock;


typedef struct _KviIrcViewLine
{
	// this is a text line in the IrcView's memory
	unsigned int                 uIndex;               // index of the text line (needed for find and splitting)
	TQString                      szText;               // data string without color codes nor escapes...
	int                          iMsgType;             // type of the line (defines icon and colors)

	// At line instert time the szData text is splitted in parts which
	// signal attribute changes (or icons)
	unsigned int                 uChunkCount;           // number of allocated chunks
	KviIrcViewLineChunk        * pChunks;               // pointer to the allocated structures
	
	// At paint time the data is re-splitted in drawable chunks which
	// are either real data chunks or line wraps.
	// The algorightm that does this is lazy and computes it
	// only once for a given widget width (iMaxLineWidth)
	unsigned int                 uLineWraps;           // number of line wraps (lines - 1)
	int                          iMaxLineWidth;        // width that the blocks were calculated for (lazy calculation)
	int                          iBlockCount;          // number of allocated paintable blocks
	KviIrcViewWrappedBlock     * pBlocks;              // pointer to the re-splitted paintable blocks

	// next and previous line
	struct _KviIrcViewLine     * pPrev;
	struct _KviIrcViewLine     * pNext;
} KviIrcViewLine;

typedef struct _KviIrcViewWrappedBlockSelectionInfoTag
{
	int selection_type;
	/*struct {
		int length;
		int width;
	} part[3];*/
	int part_1_length;
	int part_1_width;
	int part_2_length;
	int part_2_width;
	int part_3_length;
	int part_3_width;
} KviIrcViewWrappedBlockSelectionInfo;

#ifdef COMPILE_ON_WINDOWS
	#pragma pack(pop,old_packing)
#else //!COMPILE_ON_WINDOWS
	#undef _KVI_PACKED
#endif //!COMPILE_ON_WINDOWS

//=========================================================================================================
// Screen tqlayout
//=========================================================================================================

//FIRST LINE (prev_line = 0) <---m_pFirstLine
//LINE
//--------------------SCREEN--
//LINE
//LINE
//LINE
//LINE <-------------------------m_pCurLine
//--------------------SCREEN--
//LAST LINE (next_line = 0) <----m_pLastLine

#endif //!_KVI_IRCVIEWPRIVATE_H_