6 Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
37 #include <FilePanel.h>
38 #include <FindDirectory.h>
43 #include <MessageFilter.h>
45 #include "KUndoBuffer.h"
47 #define MESSAGE_TEXT "Message:"
48 #define MESSAGE_TEXT_H 16
49 #define MESSAGE_TEXT_V 5
50 #define MESSAGE_FIELD_H 59
51 #define MESSAGE_FIELD_V 11
53 #define CONTENT_TYPE "content-type: "
54 #define CONTENT_ENCODING "content-transfer-encoding: "
55 #define CONTENT_DISPOSITION "Content-Disposition: "
56 #define MIME_TEXT "text/"
57 #define MIME_MULTIPART "multipart/"
66 struct text_run_array
;
95 BMailComponent
*component
;
105 class TContentView
: public BView
{
107 TContentView(bool incoming
, BFont
* font
,
108 bool showHeader
, bool coloredQuotes
);
110 void FindString(const char *);
113 TTextView
* TextView() const { return fTextView
; }
115 virtual void MessageReceived(BMessage
* message
);
118 TTextView
* fTextView
;
130 struct quote_context
{
148 class TTextView
: public BTextView
{
150 TTextView(bool incoming
,
151 TContentView
*, BFont
*, bool showHeader
,
155 virtual void AttachedToWindow();
156 virtual void KeyDown(const char*, int32
);
157 virtual void MakeFocus(bool);
158 virtual void MessageReceived(BMessage
*);
159 virtual void MouseDown(BPoint
);
160 virtual void MouseMoved(BPoint
, uint32
, const BMessage
*);
161 virtual void InsertText(const char *text
, int32 length
, int32 offset
,
162 const text_run_array
*runs
);
163 virtual void DeleteText(int32 start
, int32 finish
);
166 void LoadMessage(BEmailMessage
*mail
, bool quoteIt
, const char *insertText
);
167 void Open(hyper_text
*);
168 status_t
Save(BMessage
*, bool makeNewFile
= true);
170 bool IsReaderThreadRunning();
171 void AddAsContent(BEmailMessage
*mail
, bool wrap
, uint32 charset
, mail_encoding encoding
);
172 void CheckSpelling(int32 start
, int32 end
,
173 int32 flags
= S_CLEAR_ERRORS
| S_SHOW_ERRORS
);
174 void FindSpellBoundry(int32 length
, int32 offset
, int32
*start
,
176 void EnableSpellCheck(bool enable
);
178 void AddQuote(int32 start
, int32 finish
);
179 void RemoveQuote(int32 start
, int32 finish
);
180 void UpdateFont(const BFont
* newFont
);
182 void WindowActivated(bool flag
);
183 void Undo(BClipboard
*clipboard
);
186 const BFont
*Font() const { return &fFont
; }
193 struct { bool replaced
, deleted
; } fUndoState
;
194 KUndoBuffer fUndoBuffer
;
196 struct { bool active
, replace
; } fInputMethodUndoState
;
197 KUndoBuffer fInputMethodUndoBuffer
;
198 // For handling Input Method changes in undo.
202 spell_mark
*FindSpellMark(int32 start
, int32 end
, spell_mark
**_previousMark
= NULL
);
203 void UpdateSpellMarks(int32 offset
, int32 length
);
204 status_t
AddSpellMark(int32 start
, int32 end
);
205 bool RemoveSpellMark(int32 start
, int32 end
);
206 void RemoveSpellMarks();
208 void ContentChanged(void);
210 int32
LineStart(int32 offset
);
211 int32
PreviousByte(int32 offset
) const;
214 friend class TTextView::Reader
;
219 BEmailMessage
*fMail
;
220 // for incoming/replied/forwarded mails only
222 TContentView
*fParent
;
227 BPopUpMenu
*fEnclosureMenu
;
228 BPopUpMenu
*fLinkMenu
;
239 struct text_run_array
*style
;
242 spell_mark
*fFirstSpellMark
;
246 Reader(bool header
, bool raw
, bool quote
, bool incoming
,
247 bool stripHeaders
, bool mime
, TTextView
* view
,
248 BEmailMessage
* mail
, BList
* list
, sem_id sem
);
250 static status_t
Run(void* _dummy
);
253 bool ParseMail(BMailContainer
* container
,
254 BTextMailComponent
* ignore
);
255 bool Process(const char* data
, int32 length
,
256 bool isHeader
= false);
257 bool Insert(const char* line
, int32 count
, bool isHyperLink
,
258 bool isHeader
= false);
266 quote_context fQuoteContext
;
271 BEmailMessage
* fMail
;
278 //====================================================================
280 class TSavePanel
: public BFilePanel
{
282 TSavePanel(hyper_text
*, TTextView
*);
283 virtual void SendMessage(const BMessenger
*, BMessage
*);
284 void SetEnclosure(hyper_text
*);
287 hyper_text
*fEnclosure
;
291 //====================================================================
295 TextRunArray(size_t entries
);
298 text_run_array
&Array() { return *fArray
; }
299 size_t MaxEntries() const { return fNumEntries
; }
302 text_run_array
*fArray
;
306 extern void FillInQuoteTextRuns(BTextView
* view
, quote_context
* context
,
307 const char* line
, int32 length
, const BFont
& font
, text_run_array
* style
,
308 int32 maxStyles
= 5);
310 #endif /* #ifndef _CONTENT_H */