diff --git a/uppsrc/Core/srcimp.tpp/Heap$en-us.tpp b/uppsrc/Core/srcimp.tpp/Heap$en-us.tpp index 740c66487..b7c715f33 100644 --- a/uppsrc/Core/srcimp.tpp/Heap$en-us.tpp +++ b/uppsrc/Core/srcimp.tpp/Heap$en-us.tpp @@ -118,4 +118,4 @@ to directly obtain virtual memory. It stores information about the block in the header at the beginning of block, also makeing block 16`-bytes unaligned in the process. Free then returns virtual memory back to the system.&] -[s0; ] \ No newline at end of file +[s0; ]] \ No newline at end of file diff --git a/uppsrc/CtrlLib/Ctrl.lay b/uppsrc/CtrlLib/Ctrl.lay index eaaeec3a1..0aad9157a 100644 --- a/uppsrc/CtrlLib/Ctrl.lay +++ b/uppsrc/CtrlLib/Ctrl.lay @@ -1,7 +1,7 @@ -LAYOUT(EditStringLayout, 236, 62) - ITEM(Label, lbl, SetLabel(t_("Test")).LeftPosZ(4, 68).TopPosZ(4, 19)) - ITEM(EditString, text, HSizePosZ(68, 4).TopPosZ(4, 19)) - ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(80, -10).BottomPosZ(4, 22)) +LAYOUT(EditStringLayout, 376, 62) + ITEM(Label, lbl, SetLabel(t_("Test")).LeftPosZ(4, 116).TopPosZ(4, 19)) + ITEM(EditString, text, HSizePosZ(124, 4).TopPosZ(4, 19)) + ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(80, 60).BottomPosZ(4, 22)) ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22)) END_LAYOUT diff --git a/uppsrc/RichEdit/Clip.cpp b/uppsrc/RichEdit/Clip.cpp index b2a685430..8506666a0 100644 --- a/uppsrc/RichEdit/Clip.cpp +++ b/uppsrc/RichEdit/Clip.cpp @@ -6,17 +6,17 @@ NAMESPACE_UPP void RichEdit::InsertImage() { - if(!imagefs.ExecuteOpen()) + if(!imagefs.ExecuteOpen(t_("Open image from file"))) return; String fn = ~imagefs; - if(GetFileLength(fn) >= 10 * 1024 * 1024) { + if(GetFileLength(fn) > 17000000) { Exclamation("Image is too large!"); return; } - String data = LoadFile(~imagefs); + String data = LoadFile(fn); StringStream ss(data); if(!StreamRaster::OpenAny(ss)) { - Exclamation("Invalid file format!"); + Exclamation(NFormat(t_("Unsupported image format in file [* \1%s\1]."), ~imagefs)); return; } RichText clip; diff --git a/uppsrc/RichEdit/Editor.cpp b/uppsrc/RichEdit/Editor.cpp index 8457c9930..844534a65 100644 --- a/uppsrc/RichEdit/Editor.cpp +++ b/uppsrc/RichEdit/Editor.cpp @@ -112,7 +112,7 @@ void RichEdit::Paint(Draw& w) for(int i = 0; i <= py.page; i++) DrawFrame(w, tr.left - 1, i * (pw.size.cy + 3) + 1 - sb, pw.size.cx + 4, pw.size.cy + 2, SColorShadow); - PaintInfo pi; + PaintInfo pi = paint_info; pi.context = context; pi.zoom = zoom; pi.top = GetPageY(sb); @@ -587,6 +587,11 @@ void StdLabelDlg(String& s) EditText(s, t_("Paragraph label"), t_("Label"), CharFilterAscii128, 100); } +void StdIndexEntryDlg(String& s) +{ + EditText(s, t_("Index Entry"), t_("Index entry"), CharFilterAscii128, 100); +} + RichEdit::RichEdit() { floating_zoom = Null; @@ -714,6 +719,7 @@ RichEdit::RichEdit() WhenHyperlink = callback(StdLinkDlg); WhenLabel = callback(StdLabelDlg); + WhenIndexEntry = callback(StdIndexEntryDlg); p_size = Size(-1, -1); @@ -730,6 +736,8 @@ RichEdit::RichEdit() bullet_indent = 150; persistent_findreplace = true; + + ignore_physical_size = false; } RichEdit::~RichEdit() {} diff --git a/uppsrc/RichEdit/Formating.cpp b/uppsrc/RichEdit/Formating.cpp index 651a7f5bb..0cf3b1589 100644 --- a/uppsrc/RichEdit/Formating.cpp +++ b/uppsrc/RichEdit/Formating.cpp @@ -347,8 +347,11 @@ void RichEdit::Label() void RichEdit::IndexEntry() { - if(EditText(formatinfo.indexentry, t_("Index Entry"), t_("Index entry"))) { - indexentry <<= formatinfo.indexentry; + String s = formatinfo.indexentry.ToString(); + String s0 = s; + WhenIndexEntry(s); + if(s != s0) { + formatinfo.indexentry <<= s.ToWString(); ApplyFormat(RichText::INDEXENTRY); NextUndo(); SetFocus(); @@ -553,7 +556,7 @@ void RichEdit::AdjustObjectSize() WithObjectSizeLayout d; CtrlLayoutOKCancel(d, t_("Object position")); Size sz = obj.GetSize(); - Size psz = obj.GetPhysicalSize(); + Size psz = GetPhysicalSize(obj); if(psz.cx == 0) psz.cx = 2000; if(psz.cy == 0) psz.cy = 2000; d.width.Set(unit, sz.cx); diff --git a/uppsrc/RichEdit/Modify.cpp b/uppsrc/RichEdit/Modify.cpp index 3694a1a56..38a295f80 100644 --- a/uppsrc/RichEdit/Modify.cpp +++ b/uppsrc/RichEdit/Modify.cpp @@ -401,36 +401,6 @@ RichObject RichEdit::GetObject() const return text.GetRichPos(objectpos).object; } -void RichEdit::LoadImage() -{ - FileSel fsel; - fsel.AllFilesType(); - if(fsel.ExecuteOpen(t_("Open image from file"))) { - FileIn fi; - if(!fi.Open(~fsel)) { - Exclamation(NFormat(t_("Error opening file [* \1%s\1]."), ~fsel)); - return; - } - Image img = StreamRaster::LoadAny(fi); - if(IsNull(img)) { - Exclamation(NFormat(t_("Unsupported image format in file [* \1%s\1]."), ~fsel)); - return; - } - Size dots = img.GetDots(); - if(dots.cx <= 0 || dots.cy <= 0) - dots = img.GetSize() * 6; - RichObject object = CreatePNGObject(img, dots, Size(Null)); - RichText::FormatInfo finfo = GetFormatInfo(); - RemoveSelection(); - RichPara p; - p.Cat(object, finfo); - RichText clip; - clip.Cat(p); - Insert(GetCursor(), clip, false); - Finish(); - } -} - void RichEdit::Select(int pos, int count) { found = false; diff --git a/uppsrc/RichEdit/Mouse.cpp b/uppsrc/RichEdit/Mouse.cpp index 8f55970f1..618abc7d9 100644 --- a/uppsrc/RichEdit/Mouse.cpp +++ b/uppsrc/RichEdit/Mouse.cpp @@ -2,6 +2,13 @@ NAMESPACE_UPP +Size RichEdit::GetPhysicalSize(const RichObject& obj) +{ + if(ignore_physical_size) + return 600 * obj.GetPixelSize() / 96; + return obj.GetPhysicalSize(); +} + void RichEdit::CancelMode() { tabmove.table = 0; @@ -31,7 +38,7 @@ void RichEdit::SetObjectPercent(int p) { if(objectpos >= 0) { RichObject obj = GetObject(); - Size sz = obj.GetPhysicalSize() * p / 100; + Size sz = GetPhysicalSize(obj) * p / 100; if(sz.cx > 0 && sz.cy > 0) { obj.SetSize(sz); obj.KeepRatio(true); @@ -189,6 +196,16 @@ void RichEdit::MouseMove(Point p, dword flags) } } +static bool IsObjectPercent(Sizef percent, int p) +{ + return abs(percent.cx - p) < 1 && abs(percent.cy - p) < 1; +} + +static bool IsObjectDelta(int delta, int d) +{ + return d * 25 / 3 == delta; +} + void RichEdit::StdBar(Bar& menu) { int l, h; @@ -208,24 +225,30 @@ void RichEdit::StdBar(Bar& menu) bar_object.Menu(menu, context); if(!menu.IsEmpty()) menu.Separator(); - Size sz = bar_object.GetPhysicalSize(); + Size sz = GetPhysicalSize(bar_object); + Sizef percent = bar_object.GetSize(); + percent = 100 * percent / Sizef(sz); bool b = sz.cx || sz.cy; menu.Add(t_("Object position.."), THISBACK(AdjustObjectSize)); menu.Separator(); - menu.Add(b, "20 %", THISBACK1(SetObjectPercent, 20)); - menu.Add(b, "40 %", THISBACK1(SetObjectPercent, 40)); - menu.Add(b, "60 %", THISBACK1(SetObjectPercent, 60)); - menu.Add(b, "80 %", THISBACK1(SetObjectPercent, 80)); - menu.Add(b, "90 %", THISBACK1(SetObjectPercent, 90)); - menu.Add(b, "100 %", THISBACK1(SetObjectPercent, 100)); + menu.Add(b, "20 %", THISBACK1(SetObjectPercent, 20)).Check(IsObjectPercent(percent, 20)); + menu.Add(b, "30 %", THISBACK1(SetObjectPercent, 30)).Check(IsObjectPercent(percent, 30)); + menu.Add(b, "40 %", THISBACK1(SetObjectPercent, 40)).Check(IsObjectPercent(percent, 40)); + menu.Add(b, "50 %", THISBACK1(SetObjectPercent, 50)).Check(IsObjectPercent(percent, 50)); + menu.Add(b, "60 %", THISBACK1(SetObjectPercent, 60)).Check(IsObjectPercent(percent, 60)); + menu.Add(b, "70 %", THISBACK1(SetObjectPercent, 70)).Check(IsObjectPercent(percent, 70)); + menu.Add(b, "80 %", THISBACK1(SetObjectPercent, 80)).Check(IsObjectPercent(percent, 80)); + menu.Add(b, "90 %", THISBACK1(SetObjectPercent, 90)).Check(IsObjectPercent(percent, 90)); + menu.Add(b, "100 %", THISBACK1(SetObjectPercent, 100)).Check(IsObjectPercent(percent, 100)); menu.Break(); - menu.Add(t_("3 pt up"), THISBACK1(SetObjectYDelta, -3)); - menu.Add(t_("2 pt up"), THISBACK1(SetObjectYDelta, -2)); - menu.Add(t_("1 pt up"), THISBACK1(SetObjectYDelta, -1)); - menu.Add(t_("Baseline"), THISBACK1(SetObjectYDelta, 0)); - menu.Add(t_("1 pt down"), THISBACK1(SetObjectYDelta, 1)); - menu.Add(t_("2 pt down"), THISBACK1(SetObjectYDelta, 2)); - menu.Add(t_("3 pt down"), THISBACK1(SetObjectYDelta, 3)); + int delta = bar_object.GetYDelta(); + menu.Add(t_("3 pt up"), THISBACK1(SetObjectYDelta, -3)).Check(IsObjectDelta(delta, -3)); + menu.Add(t_("2 pt up"), THISBACK1(SetObjectYDelta, -2)).Check(IsObjectDelta(delta, -2)); + menu.Add(t_("1 pt up"), THISBACK1(SetObjectYDelta, -1)).Check(IsObjectDelta(delta, -1)); + menu.Add(t_("Baseline"), THISBACK1(SetObjectYDelta, 0)).Check(IsObjectDelta(delta, 0)); + menu.Add(t_("1 pt down"), THISBACK1(SetObjectYDelta, 1)).Check(IsObjectDelta(delta, 1)); + menu.Add(t_("2 pt down"), THISBACK1(SetObjectYDelta, 2)).Check(IsObjectDelta(delta, 2)); + menu.Add(t_("3 pt down"), THISBACK1(SetObjectYDelta, 3)).Check(IsObjectDelta(delta, 3)); menu.Separator(); CopyTool(menu); CutTool(menu); diff --git a/uppsrc/RichEdit/RichEdit.h b/uppsrc/RichEdit/RichEdit.h index 0b31d7781..beb9e7339 100644 --- a/uppsrc/RichEdit/RichEdit.h +++ b/uppsrc/RichEdit/RichEdit.h @@ -288,6 +288,9 @@ private: Vector ffs; int bullet_indent; + + PaintInfo paint_info; + bool ignore_physical_size; static int fh[]; @@ -614,6 +617,8 @@ private: bool BegSelTabFix(); void BegSelTabFixEnd(bool fix); + Size GetPhysicalSize(const RichObject& obj); + struct DisplayDefault : public Display { virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; @@ -649,6 +654,7 @@ public: Callback WhenStartEvaluating; Callback2 WhenHyperlink; Callback1 WhenLabel; + Callback1 WhenIndexEntry; Callback1 WhenBar; void StdBar(Bar& menu); @@ -690,7 +696,6 @@ public: void Cut(); void Paste(); void InsertObject(int type); - void LoadImage(); void Styles(); @@ -770,30 +775,32 @@ public: void Clear(); void Pick(pick_ RichText& t); - void SetQTF(const char *qtf) { Pick(ParseQTF(qtf, 0, context)); } - const RichText& Get() const { return text; } - String GetQTF(byte cs = CHARSET_UTF8) const { return AsQTF(text, cs); } + void SetQTF(const char *qtf) { Pick(ParseQTF(qtf, 0, context)); } + const RichText& Get() const { return text; } + String GetQTF(byte cs = CHARSET_UTF8) const { return AsQTF(text, cs); } void ApplyStylesheet(const RichText& r); - void SetPage(const Size& sz) { pagesz = sz; Finish(); } - Size GetPage() { return pagesz; } + void SetPage(const Size& sz) { pagesz = sz; Finish(); } + Size GetPage() { return pagesz; } - RichEdit& NoRuler() { RemoveFrame(ruler); return *this; } - RichEdit& SingleLine(bool b = true) { singleline = b; return *this; } + RichEdit& NoRuler() { RemoveFrame(ruler); return *this; } + RichEdit& SingleLine(bool b = true) { singleline = b; return *this; } RichEdit& FontFaces(const Vector& face); - RichEdit& ViewBorder(int cx) { viewborder = cx; Refresh(); return *this; } - RichEdit& ShowCodes(Color c) { showcodes = c; Refresh(); return *this; } - RichEdit& Unit(int u) { unit = u; Refresh(); return *this; } - RichEdit& SpellCheck(bool b) { spellcheck = b; Refresh(); return *this; } - RichEdit& SetZoom(int z) { zoom = z; Refresh(); return *this; } - RichEdit& SetContext(void *ctx) { context = ctx; Refresh(); return *this; } - void *GetContext() const { return context; } - RichEdit& ClipZoom(Zoom z) { clipzoom = z; return *this; } - RichEdit& ClipZoom(int m, int d) { clipzoom = Zoom(m, d); return *this; } - Zoom GetClipZoom() const { return clipzoom; } - RichEdit& BulletIndent(int i) { bullet_indent = i; return *this; } - RichEdit& PersistentFindReplace(bool b = true) { persistent_findreplace = b; return *this; } + RichEdit& ViewBorder(int cx) { viewborder = cx; Refresh(); return *this; } + RichEdit& ShowCodes(Color c) { showcodes = c; Refresh(); return *this; } + RichEdit& Unit(int u) { unit = u; Refresh(); return *this; } + RichEdit& SpellCheck(bool b) { spellcheck = b; Refresh(); return *this; } + RichEdit& SetZoom(int z) { zoom = z; Refresh(); return *this; } + RichEdit& SetContext(void *ctx) { context = ctx; Refresh(); return *this; } + void *GetContext() const { return context; } + RichEdit& ClipZoom(Zoom z) { clipzoom = z; return *this; } + RichEdit& ClipZoom(int m, int d) { clipzoom = Zoom(m, d); return *this; } + Zoom GetClipZoom() const { return clipzoom; } + RichEdit& BulletIndent(int i) { bullet_indent = i; return *this; } + RichEdit& PersistentFindReplace(bool b = true) { persistent_findreplace = b; return *this; } RichEdit& Floating(double zoomlevel_ = 1); - RichEdit& NoFloating(double zoomlevel_ = 1) { return Floating(Null); } + RichEdit& NoFloating(double zoomlevel_ = 1) { return Floating(Null); } + RichEdit& SetPaintInfo(const PaintInfo pi) { paint_info = pi; return *this; } + RichEdit& IgnorePhysicalObjectSize(bool b = true){ ignore_physical_size = b; return *this; } struct UndoInfo { int undoserial; diff --git a/uppsrc/RichEdit/Tool.cpp b/uppsrc/RichEdit/Tool.cpp index 9d3e4d4fa..5d8d4a6bd 100644 --- a/uppsrc/RichEdit/Tool.cpp +++ b/uppsrc/RichEdit/Tool.cpp @@ -328,7 +328,7 @@ void RichEdit::ObjectTool(Bar& bar, dword key) void RichEdit::LoadImageTool(Bar& bar, dword key) { - bar.Add(!IsReadOnly(), t_("Insert image from file.."), RichEditImg::LoadImageFile(), THISBACK(LoadImage)); + bar.Add(!IsReadOnly(), t_("Insert image from file.."), RichEditImg::LoadImageFile(), THISBACK(InsertImage)); } void RichEdit::PrintTool(Bar& bar, dword key) diff --git a/uppsrc/RichText/Object.cpp b/uppsrc/RichText/Object.cpp index f0aa220de..180a09a26 100644 --- a/uppsrc/RichText/Object.cpp +++ b/uppsrc/RichText/Object.cpp @@ -133,7 +133,7 @@ String RichObjectType::GetLink(const Value& data, Point pt, Size sz, void *conte void RichObject::InitSize(int cx, int cy, void *context) { Size sz; - Size phsz = GetPixelSize(); + Size phsz = 600 * GetPixelSize() / 96; // 100% size... if(cx || cy) sz = GetRatioSize(phsz, cx, cy); else diff --git a/uppsrc/RichText/ParaData.cpp b/uppsrc/RichText/ParaData.cpp index 2cd2321df..10df320f2 100644 --- a/uppsrc/RichText/ParaData.cpp +++ b/uppsrc/RichText/ParaData.cpp @@ -56,6 +56,7 @@ PaintInfo::PaintInfo() highlightpara = -1; highlight = Yellow(); indexentry = LtGreen(); + indexentrybg = false; coloroverride = false; context = NULL; showlabels = false; diff --git a/uppsrc/RichText/ParaPaint.cpp b/uppsrc/RichText/ParaPaint.cpp index 13351cf87..62c1294f5 100644 --- a/uppsrc/RichText/ParaPaint.cpp +++ b/uppsrc/RichText/ParaPaint.cpp @@ -39,11 +39,15 @@ void RichPara::Flush(Draw& draw, const PaintInfo& pi, wchar *text, int width = z * x - z * x0; int zy0 = z * y0; int zx0 = z * x0; + if(!IsNull(f.indexentry) && !IsNull(pi.indexentry)) + if(pi.indexentrybg) + draw.DrawRect(zx0, z * y, width, z * (y + linecy) - z * y, + pi.coloroverride ? SColorPaper() : pi.indexentry); + else + draw.DrawRect(zx0, zy0, width, 2, pi.indexentry); if(!IsNull(f.paper) && !highlight) draw.DrawRect(zx0, z * y, width, z * (y + linecy) - z * y, pi.coloroverride ? SColorPaper() : f.paper); - if(!IsNull(f.indexentry) && !IsNull(pi.indexentry)) - draw.DrawRect(zx0, zy0, width, 2, pi.indexentry); Font fnt = f; int zht = z * tabs(f.GetHeight()); int ssa = 0; diff --git a/uppsrc/RichText/RichImage.icpp b/uppsrc/RichText/RichImage.icpp index 48cbcb588..e55b7853b 100644 --- a/uppsrc/RichText/RichImage.icpp +++ b/uppsrc/RichText/RichImage.icpp @@ -240,7 +240,6 @@ Image RichRawImage::ToImage(const Value& data, Size sz, void *) const One r = StreamRaster::OpenAny(ss); if(r) { Image x = r->GetImage(); - Size outsz(min(sz.cx, 4 * x.GetWidth()), min(sz.cy, 4 * x.GetHeight())); return Rescale(x, sz); } return Null; diff --git a/uppsrc/RichText/RichText.h b/uppsrc/RichText/RichText.h index 7cb9b719d..0ac3b4631 100644 --- a/uppsrc/RichText/RichText.h +++ b/uppsrc/RichText/RichText.h @@ -268,6 +268,7 @@ struct PaintInfo { PageY bottom; Color hyperlink; Color indexentry; + bool indexentrybg; bool usecache; bool sizetracking; Color showcodes;