1 #ifndef RICHEDIT_H
2 #define RICHEDIT_H
3 
4 #include <CtrlLib/CtrlLib.h>
5 
6 namespace Upp {
7 
8 #define IMAGECLASS RichEditImg
9 #define IMAGEFILE <RichEdit/RichEdit.iml>
10 #include <Draw/iml_header.h>
11 
12 class RichRuler : public FrameCtrl<Ctrl> {
13 public:
14 	virtual void FrameLayout(Rect& r);
15 	virtual void FrameAddSize(Size& sz);
16 	virtual void Paint(Draw& w);
17 	virtual void LeftDown(Point p, dword);
18 	virtual void RightDown(Point p, dword);
19 	virtual void LeftDouble(Point p, dword);
20 	virtual void MouseMove(Point p, dword);
21 	virtual void LeftUp(Point, dword);
22 
23 public:
24 	struct Marker {
25 		int   pos, minpos, maxpos;
26 		Image image;
27 		bool  top;
28 		bool  deletable;
29 
30 		bool operator!=(const Marker& m) {
31 			return pos != m.pos || minpos != m.minpos || maxpos != m.maxpos ||
32 			       !image.IsSame(m.image) || top != m.top || deletable != m.deletable;
33 		}
MarkerMarker34 		Marker() { top = false; deletable = false; }
35 	};
36 
37 private:
38 	int    x0, pgcx, numbers, marks;
39 	double grid, numbermul;
40 	Zoom   zoom;
41 
42 	int    track, pos;
43 	int    trackdx;
44 	int    snap;
45 
46 	Array<Marker> marker;
47 	int           tabpos;
48 	int           tabsize;
49 	int           newtabalign;
50 
51 public:
52 	Event<>       WhenLeftDouble;
53 	Event<>       WhenLeftDown;
54 	Event<>       WhenRightDown;
55 	Event<>       WhenBeginTrack;
56 	Event<>       WhenTrack;
57 	Event<>       WhenEndTrack;
58 
59 	void          SetLayout(int x, int pgcx, Zoom zoom, double grid,
60 	                        int numbers = INT_MAX, double numbermul = 1, int marks = INT_MAX,
61 	                        int snap = 32);
62 
63 	void          Clear();
64 	void          Set(int i, const Marker& m);
65 	void          SetCount(int n);
GetCount()66 	int           GetCount() const        { return marker.GetCount(); }
67 	const Marker& operator[](int i)       { return marker[i]; }
68 
69 	int           FindMarker(Point p);
GetTrack()70 	int           GetTrack()              { return track; }
GetPos()71 	int           GetPos()                { return pos; }
72 
73 	void          SetTabs(int pos, int size);
74 
GetNewTabAlign()75 	int           GetNewTabAlign()        { return newtabalign; }
76 
77 	RichRuler();
78 	virtual ~RichRuler();
79 };
80 
81 enum {
82 	UNIT_DOT,
83 	UNIT_POINT,
84 	UNIT_INCH,
85 	UNIT_MM,
86 	UNIT_CM,
87 };
88 
89 class UnitEdit : public EditField, public Convert {
90 public:
91 	virtual Value GetData() const;
92 	virtual Value Format(const Value& v) const;
93 	virtual void  SetData(const Value& v);
94 	virtual bool  Key(dword key, int repcnt);
95 	virtual void  MouseWheel(Point p, int zdelta, dword keyflags);
96 
97 private:
98 	SpinButtons spin;
99 	int         unit;
100 	bool        sgn;
101 
102 	static String AsText(double d, int unit);
103 	static String DotAsText(int dot, int unit);
104 	void Spin(int delta);
105 	void Read(double& q, int& u) const;
106 
107 public:
SetUnit(int _unit)108 	UnitEdit& SetUnit(int _unit)                        { unit = _unit; return *this; }
Set(int _unit,int d)109 	void      Set(int _unit, int d)                     { unit = _unit; SetData(d); }
110 	UnitEdit& WithSgn(bool b = true);
111 
112 	typedef UnitEdit CLASSNAME;
113 
114 	UnitEdit();
115 };
116 
117 struct FontHeight : public WithDropChoice<EditDouble> {
118 	virtual bool Key(dword key, int);
119 
FontHeightFontHeight120 	FontHeight()   { MinMax(1, 72); }
121 };
122 
123 #define LAYOUTFILE <RichEdit/RichEdit.lay>
124 #include <CtrlCore/lay.h>
125 
126 bool EditRichHeaderFooter(String& header_qtf, String& footer_qtf);
127 
128 class ParaFormatting : public WithParaLayout<StaticRect> {
129 public:
130 	DropList n[8];
131 
132 private:
133 	UnitEdit tabpos;
134 	DropList tabtype;
135 	DropList tabfill;
136 	bool     keepindent;
137 	Font     font;
138 	bool     modified;
139 	String   header_qtf, footer_qtf;
140 
141 	RichPara::NumberFormat GetNumbering();
142 	bool                   IsNumbering();
143 	int                    ComputeIndent();
SetMod()144 	void                   SetMod()                  { modified = true; }
145 
146 	typedef ParaFormatting CLASSNAME;
147 
148 public:
149 	void  Set(int unit, const RichText::FormatInfo& formatinfo, bool baselevel = false);
150 	dword Get(RichText::FormatInfo& formatinfo);
SetFont(Font fnt)151 	void  SetFont(Font fnt)                          { font = fnt; }
IsChanged()152 	bool  IsChanged() const                          { return IsModifiedDeep() || modified; }
153 	void  EnableNumbering();
154 	void  SetupIndent();
155 	void  EditHdrFtr();
156 	void  NewHdrFtr();
157 	void  SyncHdrFtr();
158 
159 	ParaFormatting();
160 };
161 
162 class StyleManager : public WithStylesLayout<TopWindow> {
163 public:
164 	ParaFormatting            para;
165 	FontHeight                height;
166 
167 private:
168 	int                       unit;
169 	ArrayMap<Uuid, RichStyle> style;
170 	Index<Uuid>               dirty;
171 	EditString                name;
172 
173 	void EnterStyle();
174 	void SaveStyle();
175 	void SetupFont();
176 	void SetupFont0();
177 	void Create();
178 	void ReloadNextStyles();
179 	void Remove();
180 
181 	void GetFont(Font& font);
182 
183 	void Menu(Bar& bar);
184 
185 	typedef StyleManager CLASSNAME;
186 
187 public:
188 	void     Set(const RichText& text, const Uuid& current = Null);
189 	void     Set(const char *qtf);
190 	bool     IsChanged() const;
191 	void     Get(RichText& text);
192 	RichText Get();
193 	String   GetQTF();
194 
195 	void     Setup(const Vector<int>& faces, int aunit = UNIT_DOT);
196 
197 	StyleManager();
198 };
199 
200 void SetupFaceList(DropList& face);
201 
202 class RichEdit : public Ctrl, private TextArrayOps {
203 public:
204 	virtual void  Layout();
205 	virtual void  Paint(Draw& w);
206 	virtual bool  Key(dword key, int count);
207 	virtual void  LeftDown(Point p, dword flags);
208 	virtual void  MiddleDown(Point p, dword flags);
209 	virtual void  LeftUp(Point p, dword flags);
210 	virtual void  LeftDrag(Point p, dword flags);
211 	virtual void  RightDown(Point p, dword flags);
212 	virtual void  LeftDouble(Point p, dword flags);
213 	virtual void  LeftTriple(Point p, dword flags);
214 	virtual void  MouseMove(Point p, dword flags);
215 	virtual void  LeftRepeat(Point p, dword flags);
216 	virtual void  MouseWheel(Point p, int zdelta, dword keyflags);
217 	virtual void  CancelMode();
218 	virtual Image CursorImage(Point p, dword flags);
219 	virtual Value GetData() const;
220 	virtual void  SetData(const Value& v);
221 	virtual void  Serialize(Stream& s);
222 	virtual void  DragAndDrop(Point p, PasteClip& d);
223 	virtual void  DragRepeat(Point p);
224 	virtual void  DragLeave();
225 	virtual String GetSelectionData(const String& fmt) const;
226 
227 
228 private:
GetCharAt(int64 i)229 	virtual int   GetCharAt(int64 i) const                  { return GetChar((int)i); }
GetTotal()230 	virtual int64 GetTotal() const                          { return GetLength(); }
231 
232 	int                      viewborder;
233 	void                    *context;
234 	Size                     p_size;
235 	bool                     sizetracking;
236 	ScrollBar                sb;
237 	Scroller                 scroller;
238 	RichRuler                ruler;
239 	RichText                 text;
240 	RichText::FormatInfo     formatinfo;
241 	int                      cursor, anchor;
242 	bool                     begtabsel;
243 	RichCaret                cursorc;
244 	RichPos                  cursorp;
245 	RichPos                  anchorp;
246 	int                      tablesel;
247 	Rect                     cells;
248 	int                      gx;
249 	int                      oselh, osell;
250 	int                      objectpos;
251 	int                      zsc;
252 	Rect                     objectrect;
253 	RichHotPos               tabmove;
254 	int                      mpos;
255 	int                      undosteps;
256 	Rect                     dropcaret;
257 	bool                     selclick;
258 	DropList                 face;
259 	FontHeight               height;
260 	DataPusher               hyperlink;
261 	DataPusher               label;
262 	DataPusher               indexentry;
263 	FrameRight<Button>       gotolabel, gotoentry;
264 	MultiButton::SubButton  *setstyle;
265 	PopUpTable               gototable;
266 	ColorButton              ink, paper;
267 	ToolButton               adjustunits;
268 	DropList                 style;
269 	DropList                 language;
270 	Size                     pagesz;
271 	String                   footer;
272 	bool                     nolinks;
273 	bool                     overwrite;
274 	bool                     useraction, modified;
275 	bool                     singleline;
276 	static int               fixedlang;
277 	RichObject               bar_object;
278 	String                   bar_fieldparam;
279 
280 	WithRichFindReplaceLayout<TopWindow> findreplace;
281 
282 	bool                     found, notfoundfw;
283 	bool                     persistent_findreplace;
284 
285 	VectorMap<String, Value> vars;
286 
287 	int                      unit;
288 	Color                    showcodes;
289 	int                      zoom;
290 	bool                     spellcheck;
291 	bool                     paintcarect;
292 
293 	int                      undoserial;
294 	bool                     incundoserial;
295 
296 	Vector<int>              ffs;
297 
298 	int                      bullet_indent;
299 
300 	PaintInfo                paint_info;
301 	bool                     ignore_physical_size;
302 
303 	static int fh[];
304 
305 	struct UndoRec {
306 		int     serial;
307 		int     cursor;
308 
309 		virtual void         Apply(RichText& txt) = 0;
310 		virtual One<UndoRec> GetRedo(const RichText& txt) = 0;
311 
SerialUndoRec312 		One<UndoRec> Serial(int s) { serial = s; return this; }
313 
~UndoRecUndoRec314 		virtual ~UndoRec() {}
315 	};
316 
317 	struct UndoInsert : UndoRec {
318 		int                  pos;
319 		int                  length;
320 		bool                 typing;
321 
322 		virtual void         Apply(RichText& txt);
323 		virtual One<UndoRec> GetRedo(const RichText& txt);
324 
325 		UndoInsert(int pos, int length, bool typing = false);
326 	};
327 
328 	struct UndoRemove : UndoRec {
329 		int                  pos;
330 		RichText             text;
331 
332 		virtual void         Apply(RichText& txt);
333 		virtual One<UndoRec> GetRedo(const RichText& txt);
334 
335 		UndoRemove(const RichText& txt, int pos, int length);
336 	};
337 
338 	struct UndoFormat : UndoRec {
339 		int                 pos;
340 		int                 length;
341 		RichText::Formating format;
342 
343 		virtual void         Apply(RichText& txt);
344 		virtual One<UndoRec> GetRedo(const RichText& txt);
345 
346 		UndoFormat(const RichText& txt, int pos, int length);
347 	};
348 
349 	struct UndoStyle : UndoRec {
350 		Uuid                 id;
351 		RichStyle            style;
352 
353 		virtual void         Apply(RichText& txt);
354 		virtual One<UndoRec> GetRedo(const RichText& txt);
355 
356 		UndoStyle(const RichText& txt, const Uuid& id);
357 	};
358 
359 	struct UndoStyles : UndoRec {
360 		RichStyles           styles;
361 
362 		virtual void         Apply(RichText& txt);
363 		virtual One<UndoRec> GetRedo(const RichText& txt);
364 
365 		UndoStyles(const RichText& txt);
366 	};
367 
368 	struct UndoTableFormat : UndoRec {
369 		int                 table;
370 		RichTable::Format   format;
371 
372 		virtual void         Apply(RichText& txt);
373 		virtual One<UndoRec> GetRedo(const RichText& txt);
374 
375 		UndoTableFormat(const RichText& txt, int table);
376 	};
377 
378 	struct UndoCreateTable : UndoRec {
379 		int              table;
380 
381 		virtual void         Apply(RichText& txt);
382 		virtual One<UndoRec> GetRedo(const RichText& txt);
383 
UndoCreateTableUndoCreateTable384 		UndoCreateTable(int table) : table(table) {}
385 	};
386 
387 	struct UndoDestroyTable : UndoRec {
388 		int              pos;
389 		RichTable        table;
390 
391 		virtual void         Apply(RichText& txt);
392 		virtual One<UndoRec> GetRedo(const RichText& txt);
393 
394 		UndoDestroyTable(const RichText& txt, int pos);
395 	};
396 
397 	struct UndoRemoveParaSpecial : UndoRec {
398 		int              table;
399 		bool             before;
400 		RichPara::Format format;
401 
402 		virtual void         Apply(RichText& txt);
403 		virtual One<UndoRec> GetRedo(const RichText& txt);
404 
405 		UndoRemoveParaSpecial(const RichText& txt, int table, bool before);
406 	};
407 
408 	struct UndoInsertParaSpecial : UndoRec {
409 		int              table;
410 		bool             before;
411 
412 		virtual void         Apply(RichText& txt);
413 		virtual One<UndoRec> GetRedo(const RichText& txt);
414 
UndoInsertParaSpecialUndoInsertParaSpecial415 		UndoInsertParaSpecial(int table, bool before) : table(table), before(before) {}
416 	};
417 
418 	struct UndoTable : UndoRec {
419 		int             table;
420 		RichTable       copy;
421 
422 		virtual void         Apply(RichText& txt);
423 		virtual One<UndoRec> GetRedo(const RichText& txt);
424 
425 		UndoTable(const RichText& txt, int table);
426 	};
427 
428 	struct UndoBegSelFix : UndoRec {
429 		virtual void         Apply(RichText& txt);
430 		virtual One<UndoRec> GetRedo(const RichText& txt);
431 	};
432 
433 	struct UndoBegSelUnFix : UndoRec {
434 		virtual void         Apply(RichText& txt);
435 		virtual One<UndoRec> GetRedo(const RichText& txt);
436 	};
437 
438 	BiArray<UndoRec> undo;
439 	Array<UndoRec>   redo;
440 
441 	FileSel          imagefs;
442 
443 	struct StyleKey {
444 		Uuid   styleid;
445 		String stylename;
446 		String face;
447 		int    height;
448 		Color  ink;
449 		Color  paper;
450 
451 		StyleKey();
452 	};
453 
454 	StyleKey   stylekey[20];
455 
456 	Zoom       clipzoom;
457 
458 	double     floating_zoom;
459 
460 	Rect       GetTextRect() const;
461 	Size       GetZoomedPage() const;
462 	int        GetPosY(PageY py) const;
463 	void       GetPagePoint(Point p, PageY& py, int& x);
464 	int        GetX(int x);
465 	int        GetSnapX(int x);
466 	PageY      GetPageY(int y) const;
467 	int        GetNearestPos(int x, PageY py);
468 	void       SetSb();
469 	void       Scroll();
470 	void       SetZsc();
471 	Rect       PlaceCaret();
472 	void       FinishNF();
473 	void       Finish();
474 	void       ReadFormat();
475 	void       ShowFormat();
476 	int        GetMousePos(Point p);
477 	RichHotPos GetHotPos(Point p);
478 	int        GetHotSpot(Point p) const;
479 	Rect       GetObjectRect(int pos) const;
480 	void       FixObjectRect();
481 	bool       RemoveBullet(bool backspace);
482 
483 	void       SetObjectPos(int pos);
484 	void       AdjustObjectSize();
485 	void       SetObjectPercent(int p);
486 	void       SetObjectYDelta(int pt);
487 	void       SetFace();
488 	void       SetHeight();
489 
490 	bool       SelBeg(bool select);
491 	bool       SelEnd(bool select);
492 	void       SelCell(int dx, int dy);
493 
494 	void       Limit(int& pos, int& count);
495 	bool       InvalidRange(int c1, int c2);
NextUndo()496 	void       NextUndo()                 { undoserial += incundoserial; incundoserial = false; }
497 	void       AddUndo(One<UndoRec>&& ur);
498 
499 	void       BeginRulerTrack();
500 	void       RulerTrack();
501 	void       IndentMark();
502 	void       HighLightTab(int r);
503 	void       TabAdd(int align);
504 	void       AddTab();
505 	void       TabMenu();
506 
507 	void       Hyperlink();
508 	void       Label();
509 	void       IndexEntry();
510 	void       GotoLbl();
511 	void       GotoEntry();
512 	void       GotoType(int type, Ctrl& l);
513 	void       Goto();
514 
515 	void       SetInk();
516 	void       SetPaper();
517 	void       SetLanguage();
518 	void       Language();
519 	void       SetupLanguage(Vector<int>&& lng);
520 
521 	void       SetBullet(int bullet);
522 
523 	void       SetupRuler();
524 
525 	void       ReadStyles();
526 
527 	void       SetStyle();
528 
529 	void       EndSizeTracking();
530 
531 	RichObject GetObject() const;
532 	void       ReplaceObject(const RichObject& obj);
533 
534 	static bool   IsW(int c);
535 
536 	void Insert(int pos, const RichText& text, bool typing = false);
537 	void Remove(int pos, int len, bool forward = false);
538 	void SaveFormat(int pos, int count);
539 	void SaveFormat();
540 	void ModifyFormat(int pos, const RichText::FormatInfo& fi, int count);
541 	void SetParaFormat(dword paravalid);
542 
543 	void SaveStylesUndo();
544 	void SaveStyleUndo(const Uuid& id);
545 
546 	bool CursorKey(dword key, int count);
547 
548 	void ApplyFormat(dword charvalid, dword paravalid = 0);
549 
550 	void MoveNG(int newpos, bool select);
551 	void MoveUpDown(int dir, bool select, int firststep = 0);
552 	void MovePageUpDown(int dir, bool select);
553 	void MoveWordRight(bool select);
554 	void MoveWordLeft(bool select);
555 	void MoveHomeEnd(int dir, bool select);
556 
557 	void InsertLine();
558 
559 	void Bold();
560 	void Italic();
561 	void Underline();
562 	void Strikeout();
563 	void Capitals();
564 	void SetScript(int script);
565 
566 	void AlignLeft();
567 	void AlignRight();
568 	void AlignCenter();
569 	void AlignJustify();
570 
571 	void Style();
572 
573 	void ParaFormat();
574 	void ToPara();
575 
576 	void ZoomView(int d);
577 	void SetupUnits();
578 	void SpellCheck();
579 
580 	void    AddUserDict();
581 	WString GetWordAtCursor();
582 	void    GetWordAtCursorPos(int& pos, int& count);
583 
584 	Rect     GetCaretRect(const RichCaret& pr) const;
585 	Rect     GetCaretRect() const;
586 
587 	void     SaveTableFormat(int table);
588 	void     SaveTable(int table);
589 	void     InsertTable();
590 	void     DestroyTable();
591 	void     TableProps();
592 	bool     RemoveSpecial(int ll, int hh, bool back);
593 	bool     InsertLineSpecial();
594 	void     TableInsertRow();
595 	void     TableRemoveRow();
596 	void     TableInsertColumn();
597 	void     TableRemoveColumn();
598 	void     SplitCell();
599 	void     JoinCell();
600 	void     CellProperties();
601 
602 	void     OpenFindReplace();
603 	void     CloseFindReplace();
604 	int      FindPos();
605 	RichText ReplaceText();
606 	void     Find();
607 	void     Replace();
608 	void     FindReplaceAddHistory();
609 
610 	void     Reset();
611 
612 	void     DoRefreshBar();
613 	void     RefreshBar();
614 
615 	bool     Accept(PasteClip& d, RichText& clip, String& fmt);
616 	void     ClipPaste(RichText& clip, const String& fmt);
617 	bool     InSelection(int& c) const;
618 	void     RefreshDropCaret();
619 	void     ZoomClip(RichText& text) const;
620 
621 	void     InsertImage();
622 
623 	void     StyleKeys();
624 	void     ApplyStyleKey(int i);
625 
626 	void     HeaderFooter();
627 	bool     EditHeaderFooter(String& header_qtf, String& footer_qtf);
628 
629 	bool     BegSelTabFix(int& count);
BegSelTabFix()630 	bool     BegSelTabFix()                        { int dummy; return BegSelTabFix(dummy); }
631 	void     BegSelTabFixEnd(bool fix);
632 
633 	Size     GetPhysicalSize(const RichObject& obj);
634 
635 	struct DisplayDefault : public Display {
636 		virtual void Paint(Draw& w, const Rect& r, const Value& q,
637 		                   Color ink, Color paper, dword style) const;
638 	};
639 
640 	void UserAction();
641 	Event<>  User(Event<>  cb);
642 
643 	static void   SpellerAdd(const WString& w, int lang);
644 	static int    CompareStyle(const Value& a, const Value& b);
645 
646 	friend class StyleKeysDlg;
647 	friend class StyleManager;
648 
649 	using Ctrl::Accept;
650 
651 protected:
652 	enum {
653 		TIMEID_ENDSIZETRACKING = Ctrl::TIMEID_COUNT,
654 		TIMEID_REFRESHBAR,
655 		TIMEID_COUNT
656 	};
657 
658 public:
659 	virtual void  PasteFilter(RichText& txt, const String& fmt);
660 	virtual void  Filter(RichText& txt);
661 
662 	static double DotToPt(int dot);
663 	static int    PtToDot(double pt);
664 	static Bits   SpellParagraph(const RichPara& p);
FixedLang(int lang)665 	static void   FixedLang(int lang)              { fixedlang = lang; }
666 
667 	Event<>                  WhenRefreshBar;
668 	Event<>                  WhenStartEvaluating;
669 	Event<String&, WString&> WhenHyperlink;
670 	Event<String&>           WhenLabel;
671 	Event<String&>           WhenIndexEntry;
672 	Event<Bar&>              WhenBar;
673 
674 	void   StdBar(Bar& menu);
675 
676 	void   SerializeSettings(Stream& s);
677 
678 	Zoom   GetZoom() const;
679 
GetCursor()680 	int    GetCursor() const                       { return cursor; }
GetAnchor()681 	int    GetAnchor() const                       { return anchor; }
682 
683 	void     Select(int pos, int count);
684 	bool     IsSelection() const;
685 	bool     GetSelection(int& l, int& h) const;
686 	RichText GetSelection(int maxlen = INT_MAX) const;
SetSelection(int l,int h)687 	void     SetSelection(int l, int h)            { Select(l, h - l); }
688 	bool     RemoveSelection(bool back = false);
689 	void     CancelSelection();
690 
BeginOp()691 	void   BeginOp()                               { NextUndo(); }
692 
GetLength()693 	int                  GetLength() const         { return text.GetLength(); }
694 	void                 PasteText(const RichText& text);
695 	void                 RemoveText(int count);
696 	RichText             CopyText(int pos, int count) const;
GetFormatInfo()697 	RichText::FormatInfo GetFormatInfo() const     { return formatinfo; }
698 	void                 ApplyFormatInfo(const RichText::FormatInfo& fi);
GetChar(int pos)699 	int                  GetChar(int pos) const    { return text[pos]; }
700 	int                  operator[](int pos) const { return text[pos]; }
701 
702 	void   Undo();
703 	void   Redo();
704 
ScrollToCursor()705 	void   ScrollToCursor()                     { Finish(); }
706 
707 	void   Move(int newpos, bool select = false);
708 
709 	void   Copy();
710 	void   Cut();
711 	void   Paste();
712 	void   InsertObject(int type);
713 
714 	void   Styles();
715 
716 	bool   Print();
DoPrint()717 	void   DoPrint()                             { Print(); }
718 
719 	void   StyleTool(Bar& bar, int width = Zx(120));
720 	void   FaceTool(Bar& bar, int width = Zx(130));
721 	void   HeightTool(Bar& bar, int width = Zx(50));
722 	void   BoldTool(Bar& bar, dword key = K_CTRL_B);
723 	void   ItalicTool(Bar& bar, dword key = K_CTRL_I);
724 	void   UnderlineTool(Bar& bar, dword key = K_CTRL_U);
725 	void   StrikeoutTool(Bar& bar, dword key = 0);
726 	void   CapitalsTool(Bar& bar, dword key = 0);
727 	void   SuperscriptTool(Bar& bar, dword key = 0);
728 	void   SubscriptTool(Bar& bar, dword key = 0);
729 	void   InkTool(Bar& bar);
730 	void   PaperTool(Bar& bar);
731 	void   LanguageTool(Bar& bar, int width = Zx(60));
732 	void   HyperlinkTool(Bar& bar, int width = Zx(180), dword key = 0, const char *tip = NULL);
733 	void   SpellCheckTool(Bar& bar);
734 	void   IndexEntryTool(Bar& bar, int width = Zx(80), dword key = 0, const char *tip = NULL);
735 
736 	void   LeftTool(Bar& bar, dword key = K_CTRL_L);
737 	void   RightTool(Bar& bar, dword key = K_CTRL_R);
738 	void   CenterTool(Bar& bar, dword key = K_CTRL_E);
739 	void   JustifyTool(Bar& bar, dword key = K_CTRL_J);
740 	void   RoundBulletTool(Bar& bar, dword key = 0);
741 	void   RoundWhiteBulletTool(Bar& bar, dword key = 0);
742 	void   BoxBulletTool(Bar& bar, dword key = 0);
743 	void   BoxWhiteBulletTool(Bar& bar, dword key = 0);
744 	void   TextBulletTool(Bar& bar, dword key = 0);
745 	void   ParaFormatTool(Bar& bar, dword key = 0);
746 	void   LabelTool(Bar& bar, int width = Zx(80), dword key = 0, const char *tip = NULL);
747 	void   ToParaTool(Bar& bar, dword key = K_CTRL_K);
748 
749 	void   UndoTool(Bar& bar, dword key = K_CTRL_Z);
750 	void   RedoTool(Bar& bar, dword key = K_SHIFT_CTRL_Z);
751 	void   CutTool(Bar& bar, dword key = K_CTRL_X);
752 	void   CopyTool(Bar& bar, dword key = K_CTRL_C);
753 	void   PasteTool(Bar& bar, dword key = K_CTRL_V);
754 	void   ObjectTool(Bar& bar, dword key = 0);
755 	void   LoadImageTool(Bar& bar, dword key = 0);
756 	void   FindReplaceTool(Bar& bar, dword key = K_CTRL_F);
757 
758 	void   InsertTableTool(Bar& bar, dword key = K_CTRL_F12);
759 	void   TablePropertiesTool(Bar& bar, dword key = K_SHIFT_F12);
760 	void   InsertTableRowTool(Bar& bar, dword key = 0);
761 	void   RemoveTableRowTool(Bar& bar, dword key = 0);
762 	void   InsertTableColumnTool(Bar& bar, dword key = 0);
763 	void   RemoveTableColumnTool(Bar& bar, dword key = 0);
764 	void   SplitJoinCellTool(Bar& bar, dword key = 0);
765 	void   CellPropertiesTool(Bar& bar, dword key = 0);
766 
767 	void   PrintTool(Bar& bar, dword key = K_CTRL_P);
768 
769 	void   FontTools(Bar& bar);
770 	void   ParaTools(Bar& bar);
771 	void   EditTools(Bar& bar);
772 	void   TableTools(Bar& bar);
773 
774 	void   InsertImageTool(Bar& bar);
775 	void   StyleKeysTool(Bar& bar);
776 
777 	void   HeaderFooterTool(Bar& bar);
778 
779 	void   DefaultBar(Bar& bar, bool extended = true);
780 
SetVar(const String & id,const Value & v)781 	void            SetVar(const String& id, const Value& v) { vars.GetAdd(id) = v; }
GetVar(const String & id)782 	Value           GetVar(const String& id) const           { return vars.Get(id, Value()); }
783 	void            EvaluateFields();
784 
785 	bool            GotoLabel(const String& lbl);
786 	void            BeginPara();
787 	void            NextPara();
788 	void            PrevPara();
789 
790 	void            Clear();
791 	void            Pick(RichText pick_ t);
SetQTF(const char * qtf)792 	void            SetQTF(const char *qtf)                { Pick(ParseQTF(qtf, 0, context)); }
Get()793 	const RichText& Get() const                            { return text; }
794 	String          GetQTF(byte cs = CHARSET_UTF8) const   { return AsQTF(text, cs); }
795 	void            ApplyStylesheet(const RichText& r);
SetPage(const Size & sz)796 	void            SetPage(const Size& sz)                { pagesz = sz; Finish(); }
GetPage()797 	Size            GetPage()                              { return pagesz; }
798 
NoRuler()799 	RichEdit&       NoRuler()                              { RemoveFrame(ruler); return *this; }
800 	RichEdit&       SingleLine(bool b = true)              { singleline = b; return *this; }
801 	RichEdit&       FontFaces(const Vector<int>& face);
ViewBorder(int cx)802 	RichEdit&       ViewBorder(int cx)                     { viewborder = cx; Refresh(); return *this; }
ShowCodes(Color c)803 	RichEdit&       ShowCodes(Color c)                     { showcodes = c; Refresh(); return *this; }
Unit(int u)804 	RichEdit&       Unit(int u)                            { unit = u; Refresh(); return *this; }
SpellCheck(bool b)805 	RichEdit&       SpellCheck(bool b)                     { spellcheck = b; Refresh(); return *this; }
SetZoom(int z)806 	RichEdit&       SetZoom(int z)                         { zoom = z; Refresh(); return *this; }
SetContext(void * ctx)807 	RichEdit&       SetContext(void *ctx)                  { context = ctx; Refresh(); return *this; }
GetContext()808 	void           *GetContext() const                     { return context; }
ClipZoom(Zoom z)809 	RichEdit&       ClipZoom(Zoom z)                       { clipzoom = z; return *this; }
ClipZoom(int m,int d)810 	RichEdit&       ClipZoom(int m, int d)                 { clipzoom = Zoom(m, d); return *this; }
GetClipZoom()811 	Zoom            GetClipZoom() const                    { return clipzoom; }
BulletIndent(int i)812 	RichEdit&       BulletIndent(int i)                    { bullet_indent = i; return *this; }
813 	RichEdit&       PersistentFindReplace(bool b = true)   { persistent_findreplace = b; return *this; }
814 	RichEdit&       Floating(double zoomlevel_ = 1);
815 	RichEdit&       NoFloating(double zoomlevel_ = 1)      { return Floating(Null); }
SetPaintInfo(const PaintInfo & pi)816 	RichEdit&       SetPaintInfo(const PaintInfo& pi)      { paint_info = pi; return *this; }
817 	RichEdit&       IgnorePhysicalObjectSize(bool b = true){ ignore_physical_size = b; return *this; }
818 
819 	struct UndoInfo {
820 		int              undoserial;
821 		BiArray<UndoRec> undo;
822 		Array<UndoRec>   redo;
823 
ClearUndoInfo824 		void Clear()     { undo.Clear(); redo.Clear(); undoserial = 0; }
825 	};
826 
827 	struct PosInfo {
828 		int  cursor;
829 		int  anchor;
830 		bool begtabsel;
831 		int  zsc;
832 
833 		void Serialize(Stream& s);
834 	};
835 
836 	UndoInfo PickUndoInfo();
837 	void     SetPickUndoInfo(UndoInfo pick_ f);
838 
839 	PosInfo  GetPosInfo() const;
840 	void     SetPosInfo(const PosInfo& pos);
841 
SetFooter(const String & s)842 	void     SetFooter(const String& s)                   { footer = s; }
843 	void     PrintNoLinks(bool b = true)                  { nolinks = b; }
844 
845 	typedef RichEdit CLASSNAME;
846 
847 	RichEdit();
848 	virtual ~RichEdit();
849 };
850 
851 class RichEditWithToolBar : public RichEdit {
852 	ToolBar  toolbar;
853 	bool     extended;
854 	void RefreshBar();
855 	void TheBar(Bar& bar);
856 
857 public:
858 	RichEditWithToolBar& Extended(bool b = true) { extended = b; return *this; }
NoExtended()859 	RichEditWithToolBar& NoExtended()            { return Extended(false); }
860 
861 	typedef RichEditWithToolBar CLASSNAME;
862 
863 	RichEditWithToolBar();
864 };
865 
866 void AppendClipboard(RichText&& txt);
867 
868 }
869 
870 #endif
871