diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 0fd61389d..6e8e3b0c3 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1578,9 +1578,11 @@ bool (*&DisplayErrorFn())(const Value& v); inline bool DisplayError(const Value& v) { return DisplayErrorFn()(v); } void EncodeRTF(Stream& stream, const RichText& richtext, byte charset, - Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472)); + Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472), + void *context = NULL); String EncodeRTF(const RichText& richtext, byte charset, - Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472)); + Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472), + void *context = NULL); String EncodeRTF(const RichText& richtext, byte charset, int dot_page_width); String EncodeRTF(const RichText& richtext); RichText ParseRTF(const char *rtf); diff --git a/uppsrc/CtrlCore/EncodeRTF.cpp b/uppsrc/CtrlCore/EncodeRTF.cpp index 89c595d2f..7b3699c42 100644 --- a/uppsrc/CtrlCore/EncodeRTF.cpp +++ b/uppsrc/CtrlCore/EncodeRTF.cpp @@ -26,7 +26,8 @@ static int GetParaHeight(const Array& parts) class RTFEncoder { public: - RTFEncoder(Stream& stream, const RichText& richtext, byte charset, Size dot_page_size, const Rect& dot_margins); + RTFEncoder(Stream& stream, const RichText& richtext, byte charset, + Size dot_page_size, const Rect& dot_margins, void *context); void Run(); @@ -78,7 +79,7 @@ private: byte charset; Size dot_page_size; Rect dot_margins; - + void *context; RichPara::CharFormat charfmt; RichPara::Format parafmt; @@ -94,15 +95,15 @@ private: }; void EncodeRTF(Stream& stream, const RichText& richtext, byte charset, - Size dot_page_size, const Rect& dot_margins) + Size dot_page_size, const Rect& dot_margins, void *context) { - RTFEncoder(stream, richtext, charset, dot_page_size, dot_margins).Run(); + RTFEncoder(stream, richtext, charset, dot_page_size, dot_margins, context).Run(); } -String EncodeRTF(const RichText& richtext, byte charset, Size dot_page_size, const Rect& dot_margins) +String EncodeRTF(const RichText& richtext, byte charset, Size dot_page_size, const Rect& dot_margins, void *context) { StringStream out; - EncodeRTF(out, richtext, charset, dot_page_size, dot_margins); + EncodeRTF(out, richtext, charset, dot_page_size, dot_margins, context); String s = out.GetResult(); LLOG("EncodeRTF <<<<<\n" << s << "\n>>>>> EncodeRTF"); return s; @@ -123,12 +124,13 @@ String EncodeRTF(const RichText& richtext) } RTFEncoder::RTFEncoder(Stream& stream_, const RichText& richtext_, byte charset_, - Size dot_page_size_, const Rect& dot_margins_) + Size dot_page_size_, const Rect& dot_margins_, void *context_) : stream(stream_) , richtext(richtext_) , charset(charset_) , dot_page_size(dot_page_size_) , dot_margins(dot_margins_) +, context(context_) { for(int i = 0; i < richtext.GetStyleCount(); i++) styleid.Add(richtext.GetStyleId(i)); @@ -295,7 +297,7 @@ void RTFEncoder::PutObject(const RichObject& object) else { Command("wmetafile", 8); WinMetaFileDraw wmd(log_size.cx, log_size.cy); - object.Paint(wmd, log_size); + object.Paint(wmd, log_size, context); WinMetaFile wmf = wmd.Close(); HENHMETAFILE hemf = wmf.GetHEMF(); int size = GetWinMetaFileBits(hemf, 0, 0, MM_ANISOTROPIC, ScreenHDC()); @@ -670,8 +672,10 @@ void RTFEncoder::PutTxt(const RichTxt& txt, int nesting, int dot_width) Command("intbl"); if(nesting > 1) Command("itap", nesting); - parafmt = RichPara::Format(); - charfmt = RichPara::CharFormat(); +// parafmt = RichPara::Format(); +// bool isul = charfmt.IsUnderline(); +// charfmt = RichPara::CharFormat(); +// charfmt.Underline(isul); para_ht = 0; } if(para.format.bullet == RichPara::BULLET_TEXT) { diff --git a/uppsrc/RichEdit/Editor.cpp b/uppsrc/RichEdit/Editor.cpp index 34a5ccbb6..5fdd39c99 100644 --- a/uppsrc/RichEdit/Editor.cpp +++ b/uppsrc/RichEdit/Editor.cpp @@ -622,6 +622,8 @@ RichEdit::RichEdit() AddFrame(sb); RefreshBar(); + WhenBar = THISBACK(StdBar); + ruler.WhenBeginTrack = THISBACK(BeginRulerTrack); ruler.WhenTrack = THISBACK(RulerTrack); ruler.WhenEndTrack = THISBACK(ReadFormat); diff --git a/uppsrc/RichEdit/Mouse.cpp b/uppsrc/RichEdit/Mouse.cpp index 82c21e108..583f18f4f 100644 --- a/uppsrc/RichEdit/Mouse.cpp +++ b/uppsrc/RichEdit/Mouse.cpp @@ -182,28 +182,22 @@ void RichEdit::MouseMove(Point p, dword flags) } } -void RichEdit::RightDown(Point p, dword flags) +void RichEdit::StdBar(Bar& menu) { - useraction = true; - NextUndo(); - MenuBar menu; int l, h; - Rect ocr = GetCaretRect(); - int c = GetMousePos(p); int fieldpos = -1; Id field; String fieldparam; String ofieldparam; RichObject object, o; if(GetSelection(l, h)) { - if(c >= l && c < h) { - CopyTool(menu); - CutTool(menu); - } +// if(c >= l && c < h) { + CopyTool(menu); + CutTool(menu); +// } PasteTool(menu); } else { - LeftDown(p, flags); if(objectpos >= 0) { object = GetObject(); if(!object) return; @@ -258,6 +252,37 @@ void RichEdit::RightDown(Point p, dword flags) } LoadImageTool(menu); } +} + +void RichEdit::RightDown(Point p, dword flags) +{ + useraction = true; + NextUndo(); + MenuBar menu; + int l, h; + Rect ocr = GetCaretRect(); + int c = GetMousePos(p); + int fieldpos = -1; + Id field; + String fieldparam; + String ofieldparam; + RichObject object, o; + if(!GetSelection(l, h)) { + LeftDown(p, flags); + if(objectpos >= 0) + o = object = GetObject(); + else { + RichPos p = cursorp; + field = p.field; + fieldparam = p.fieldparam; + RichPara::FieldType *ft = RichPara::fieldtype().Get(field, NULL); + if(ft) { + ofieldparam = fieldparam; + fieldpos = cursor; + } + } + } + WhenBar(menu); Rect r = GetCaretRect(); Refresh(r); Refresh(ocr); diff --git a/uppsrc/RichEdit/RichEdit.h b/uppsrc/RichEdit/RichEdit.h index 44ca6a7ae..f759540f8 100644 --- a/uppsrc/RichEdit/RichEdit.h +++ b/uppsrc/RichEdit/RichEdit.h @@ -626,6 +626,7 @@ public: Callback WhenStartEvaluating; Callback2 WhenHyperlink; Callback1 WhenLabel; + Callback1 WhenBar; void SerializeSettings(Stream& s); @@ -671,6 +672,8 @@ public: bool Print(); void DoPrint() { Print(); } + void StdBar(Bar& bar); + void StyleTool(Bar& bar, int width = 120); void FaceTool(Bar& bar, int width = 130); void HeightTool(Bar& bar, int width = 50);