RichObject CreateImageObject(const Image& img, int cx, int cy) { RichObject o = RichObject("image", StoreImageAsString(img)); if(cx || cy) o.SetSize(GetRatioSize(o.GetPixelSize(), cx, cy)); return o; }
void RichEdit::SetObjectYDelta(int pt) { if(objectpos >= 0) { RichObject obj = GetObject(); obj.SetYDelta(pt * 25 / 3); ReplaceObject(obj); } }
void RichEdit::SetObjectPercent(int p) { if(objectpos >= 0) { RichObject obj = GetObject(); obj.SetSize(obj.GetPhysicalSize() * p / 100); obj.KeepRatio(true); ReplaceObject(obj); } }
void RichEdit::SetObjectPercent(int p) { if(objectpos >= 0) { RichObject obj = GetObject(); Size sz = obj.GetPhysicalSize() * p / 100; if(sz.cx > 0 && sz.cy > 0) { obj.SetSize(sz); obj.KeepRatio(true); ReplaceObject(obj); } } }
void RichEdit::RightDown(Point p, dword flags) { useraction = true; NextUndo(); MenuBar menu; int l, h; Rect ocr = GetCaretRect(); int fieldpos = -1; Id field; String ofieldparam; RichObject o; bar_object.Clear(); bar_fieldparam = Null; if(!GetSelection(l, h)) { LeftDown(p, flags); if(objectpos >= 0) o = bar_object = GetObject(); else { RichPos p = cursorp; field = p.field; bar_fieldparam = p.fieldparam; RichPara::FieldType *ft = RichPara::fieldtype().Get(field, NULL); if(ft) { ofieldparam = bar_fieldparam; fieldpos = cursor; } } } WhenBar(menu); Rect r = GetCaretRect(); Refresh(r); Refresh(ocr); paintcarect = true; menu.Execute(); paintcarect = false; Refresh(r); if(bar_object && o && o.GetSerialId() != bar_object.GetSerialId()) ReplaceObject(bar_object); if(fieldpos >= 0 && bar_fieldparam != ofieldparam) { RichText::FormatInfo f = text.GetFormatInfo(fieldpos, 1); Remove(fieldpos, 1); RichPara p; p.Cat(field, bar_fieldparam, f); RichText clip; clip.Cat(p); Insert(fieldpos, clip, false); Finish(); } bar_object.Clear(); bar_fieldparam = Null; }
String RichTextView::GetLink(int pos, Point p) const { String link; RichObject object = text.GetRichPos(pos).object; if(object) { Rect rc = text.GetCaret(pos, GetPage()); link = object.GetLink(p - rc.TopLeft(), rc.Size()); } if(IsNull(link)) { RichPos richpos = text.GetRichPos(pos); if(richpos.chr != '\n') link = Nvl(richpos.fieldformat.link, richpos.format.link); } return link; }
void RichEdit::LeftDouble(Point p, dword flags) { NextUndo(); int c = GetMousePos(p); if(c >= 0) { if(objectpos == c) { RichObject object = GetObject(); if(!object) return; RichObject o = object; o.DefaultAction(context); if(object.GetSerialId() != o.GetSerialId()) ReplaceObject(o); } else { RichPos rp = cursorp; RichPara::FieldType *ft = RichPara::fieldtype().Get(rp.field, NULL); if(ft) { int fieldpos = cursor; ft->DefaultAction(&rp.fieldparam); RichText::FormatInfo f = text.GetFormatInfo(fieldpos, 1); Remove(fieldpos, 1); RichPara p; p.Cat(rp.field, rp.fieldparam, f); RichText clip; clip.Cat(p); Insert(fieldpos, clip, false); Finish(); } else { int l, h; if(GetWordSelection(c, l, h)) SetSelection(l, h); } } } }
void RichQtfParser::ReadObject() { Flush(); RichObject obj; if(*term == '#') { term++; #ifdef CPU_64 obj = *(RichObject *)stou64(term, &term); #else obj = *(RichObject *)stou(term, &term); #endif term++; } else { String type; while(IsAlNum(*term) || *term == '_') type.Cat(*term++); Size sz; Key(':'); sz.cx = ReadNumber(); bool keepratio = false; if(Key('&')) keepratio = true; else Key('*'); sz.cy = ReadNumber(); int yd = 0; if(Key('/')) yd = GetNumber(); while(*term && (byte)*term < 32) term++; String odata; if(Key('`')) while(*term) { if(*term == '`') { term++; if(*term == '`') odata.Cat('`'); else break; } else if((byte)*term >= 32) odata.Cat(*term); term++; } else if(Key('(')) { const char *b = term; while(*term && *term != ')') term++; odata = Base64Decode(b, term); if(*term == ')') term++; } else { StringBuffer data; for(;;) { while(*term < 32 && *term > 0) term++; if((byte)*term >= ' ' && (byte)*term <= 127 || *term == '\0') break; byte seven = *term++; for(int i = 0; i < 7; i++) { while((byte)*term < 32 && (byte)*term > 0) term++; if((byte)*term >= ' ' && (byte)*term <= 127 || *term == '\0') break; data.Cat((*term++ & 0x7f) | ((seven << 7) & 0x80)); seven >>= 1; } } odata = data; } obj.Read(type, odata, sz, context); obj.KeepRatio(keepratio); obj.SetYDelta(yd); } paragraph.Cat(obj, format); }
RichObject CreateRawImageObject(const String& s, int cx, int cy) { RichObject o = RichObject("rawimage", s); o.InitSize(cx, cy); return o; }
void RichEdit::LeftDown(Point p, dword flags) { useraction = true; NextUndo(); SetFocus(); selclick = false; tabmove = GetHotPos(p); if(tabmove.table && tabmove.column >= -2) { SaveTableFormat(tabmove.table); SetCapture(); Move(text.GetCellPos(tabmove.table, 0, max(tabmove.column, 0)).pos); return; } int c = GetHotSpot(p); if(c >= 0 && objectpos >= 0) { int pos = objectpos; RectTracker tracker(*this); RichObject obj = text.GetRichPos(pos).object; tracker.MinSize(Size(16, 16)) .MaxSize(GetZoom() * pagesz) .Animation() .Dashed() .KeepRatio(obj.IsKeepRatio()); int tx, ty; switch(c) { case 1: tracker.SetCursorImage(Image::SizeVert()); tx = ALIGN_CENTER; ty = ALIGN_BOTTOM; break; case 2: tracker.SetCursorImage(Image::SizeHorz()); tx = ALIGN_RIGHT; ty = ALIGN_CENTER; break; default: tracker.SetCursorImage(Image::SizeBottomRight()); tx = ALIGN_RIGHT; ty = ALIGN_RIGHT; break; } double zoom = GetZoom().AsDouble(); Size sz = obj.GetSize(); sz.cx = int(zoom * sz.cx + 0.5); sz.cy = int(zoom * sz.cy + 0.5); sz = tracker.Track(Rect(objectrect.Offseted(GetTextRect().left, -sb).TopLeft(), sz), tx, ty).Size(); sz.cx = int(sz.cx / zoom + 0.5); sz.cy = int(sz.cy / zoom + 0.5); obj.SetSize(sz); ReplaceObject(obj); } else { c = GetMousePos(p); if(c >= 0) { if(InSelection(c)) { selclick = true; return; } Move(c, flags & K_SHIFT); mpos = c; SetCapture(); if(cursorp.object && GetObjectRect(cursor).Offseted(GetTextRect().left, -sb).Contains(p)) SetObjectPos(cursor); } } }