mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
RichText, RichEdit: Styles of paragraph ruler (dotted, dashed)
git-svn-id: svn://ultimatepp.org/upp/trunk@5059 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
fbfbac818a
commit
d229949553
10 changed files with 84 additions and 16 deletions
|
|
@ -107,6 +107,10 @@ void ParaFormatting::Set(int unit, const RichText::FormatInfo& formatinfo)
|
||||||
rulerink <<= formatinfo.rulerink;
|
rulerink <<= formatinfo.rulerink;
|
||||||
else
|
else
|
||||||
rulerink <<= Null;
|
rulerink <<= Null;
|
||||||
|
if(RichText::RULERSTYLE & formatinfo.paravalid)
|
||||||
|
rulerstyle <<= formatinfo.rulerstyle;
|
||||||
|
else
|
||||||
|
rulerstyle <<= Null;
|
||||||
tabpos.SetUnit(unit);
|
tabpos.SetUnit(unit);
|
||||||
if(RichText::BULLET & formatinfo.paravalid)
|
if(RichText::BULLET & formatinfo.paravalid)
|
||||||
bullet <<= formatinfo.bullet;
|
bullet <<= formatinfo.bullet;
|
||||||
|
|
@ -221,9 +225,22 @@ dword ParaFormatting::Get(RichText::FormatInfo& formatinfo)
|
||||||
formatinfo.rulerink = ~rulerink;
|
formatinfo.rulerink = ~rulerink;
|
||||||
v |= RichText::RULERINK;
|
v |= RichText::RULERINK;
|
||||||
}
|
}
|
||||||
|
if(!IsNull(rulerstyle)) {
|
||||||
|
formatinfo.rulerstyle = ~rulerstyle;
|
||||||
|
v |= RichText::RULERSTYLE;
|
||||||
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct RulerStyleDisplay : Display {
|
||||||
|
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
|
||||||
|
{
|
||||||
|
w.DrawRect(r, paper);
|
||||||
|
if(!IsNull(q))
|
||||||
|
RichPara::DrawRuler(w, r.left, (r.top + r.bottom) / 2 - 1, r.Width(), 2, ink, q);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ParaFormatting::ParaFormatting()
|
ParaFormatting::ParaFormatting()
|
||||||
{
|
{
|
||||||
CtrlLayout(*this);
|
CtrlLayout(*this);
|
||||||
|
|
@ -269,6 +286,11 @@ ParaFormatting::ParaFormatting()
|
||||||
bullet <<= THISBACK(SetupIndent);
|
bullet <<= THISBACK(SetupIndent);
|
||||||
EnableNumbering();
|
EnableNumbering();
|
||||||
rulerink.NullText("---");
|
rulerink.NullText("---");
|
||||||
|
rulerstyle.SetDisplay(Single<RulerStyleDisplay>());
|
||||||
|
rulerstyle.Add(Null);
|
||||||
|
rulerstyle.Add(RichPara::RULER_SOLID);
|
||||||
|
rulerstyle.Add(RichPara::RULER_DOT);
|
||||||
|
rulerstyle.Add(RichPara::RULER_DASH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleManager::EnterStyle()
|
void StyleManager::EnterStyle()
|
||||||
|
|
|
||||||
|
|
@ -16,25 +16,27 @@ LAYOUT(ParaLayout, 488, 352)
|
||||||
ITEM(LabelBox, dv___14, SetLabel(t_("Ruler")).LeftPosZ(8, 472).TopPosZ(100, 40))
|
ITEM(LabelBox, dv___14, SetLabel(t_("Ruler")).LeftPosZ(8, 472).TopPosZ(100, 40))
|
||||||
ITEM(Label, dv___15, SetLabel(t_("Ruler height")).LeftPosZ(16, 88).TopPosZ(112, 19))
|
ITEM(Label, dv___15, SetLabel(t_("Ruler height")).LeftPosZ(16, 88).TopPosZ(112, 19))
|
||||||
ITEM(UnitEdit, ruler, LeftPosZ(108, 68).TopPosZ(112, 19))
|
ITEM(UnitEdit, ruler, LeftPosZ(108, 68).TopPosZ(112, 19))
|
||||||
ITEM(Label, dv___17, SetLabel(t_("Ink")).LeftPosZ(192, 76).TopPosZ(112, 20))
|
ITEM(Label, dv___17, SetLabel(t_("Ink")).LeftPosZ(192, 36).TopPosZ(112, 20))
|
||||||
ITEM(ColorPusher, rulerink, LeftPosZ(268, 92).TopPosZ(112, 19))
|
ITEM(ColorPusher, rulerink, LeftPosZ(232, 92).TopPosZ(112, 19))
|
||||||
ITEM(LabelBox, dv___19, SetLabel(t_("Indentation")).LeftPosZ(8, 176).TopPosZ(144, 124))
|
ITEM(Label, dv___19, SetLabel(t_("Style")).LeftPosZ(340, 36).TopPosZ(112, 20))
|
||||||
ITEM(Label, dv___20, SetLabel(t_("Left margin")).LeftPosZ(16, 88).TopPosZ(164, 19))
|
ITEM(DropList, rulerstyle, LeftPosZ(380, 92).TopPosZ(112, 19))
|
||||||
|
ITEM(LabelBox, dv___21, SetLabel(t_("Indentation")).LeftPosZ(8, 176).TopPosZ(144, 124))
|
||||||
|
ITEM(Label, dv___22, SetLabel(t_("Left margin")).LeftPosZ(16, 88).TopPosZ(164, 19))
|
||||||
ITEM(UnitEdit, lm, LeftPosZ(108, 68).TopPosZ(164, 19))
|
ITEM(UnitEdit, lm, LeftPosZ(108, 68).TopPosZ(164, 19))
|
||||||
ITEM(Label, dv___22, SetLabel(t_("ParaLayout_rm_1_SetLabel\aRight margin")).LeftPosZ(16, 88).TopPosZ(188, 19))
|
ITEM(Label, dv___24, SetLabel(t_("ParaLayout_rm_1_SetLabel\aRight margin")).LeftPosZ(16, 88).TopPosZ(188, 19))
|
||||||
ITEM(UnitEdit, rm, LeftPosZ(108, 68).TopPosZ(188, 19))
|
ITEM(UnitEdit, rm, LeftPosZ(108, 68).TopPosZ(188, 19))
|
||||||
ITEM(Label, dv___24, SetLabel(t_("First line")).LeftPosZ(16, 88).TopPosZ(212, 19))
|
ITEM(Label, dv___26, SetLabel(t_("First line")).LeftPosZ(16, 88).TopPosZ(212, 19))
|
||||||
ITEM(UnitEdit, indent, LeftPosZ(108, 68).TopPosZ(212, 19))
|
ITEM(UnitEdit, indent, LeftPosZ(108, 68).TopPosZ(212, 19))
|
||||||
ITEM(Label, dv___26, SetLabel(t_("\vBullet")).LeftPosZ(16, 104).TopPosZ(236, 24))
|
ITEM(Label, dv___28, SetLabel(t_("\vBullet")).LeftPosZ(16, 104).TopPosZ(236, 24))
|
||||||
ITEM(DropList, bullet, LeftPosZ(124, 52).TopPosZ(236, 24))
|
ITEM(DropList, bullet, LeftPosZ(124, 52).TopPosZ(236, 24))
|
||||||
ITEM(LabelBox, dv___28, SetLabel(t_("Tabs")).LeftPosZ(192, 288).TopPosZ(144, 124))
|
ITEM(LabelBox, dv___30, SetLabel(t_("Tabs")).LeftPosZ(192, 288).TopPosZ(144, 124))
|
||||||
ITEM(ArrayCtrl, tabs, AutoHideSb(true).LeftPosZ(200, 272).TopPosZ(160, 72))
|
ITEM(ArrayCtrl, tabs, AutoHideSb(true).LeftPosZ(200, 272).TopPosZ(160, 72))
|
||||||
ITEM(Label, dv___30, SetLabel(t_("Default tab size")).LeftPosZ(200, 196).TopPosZ(240, 20))
|
ITEM(Label, dv___32, SetLabel(t_("Default tab size")).LeftPosZ(200, 196).TopPosZ(240, 20))
|
||||||
ITEM(UnitEdit, tabsize, LeftPosZ(404, 68).TopPosZ(240, 19))
|
ITEM(UnitEdit, tabsize, LeftPosZ(404, 68).TopPosZ(240, 19))
|
||||||
ITEM(LabelBox, dv___32, SetLabel(t_("Numbering")).LeftPosZ(8, 472).TopPosZ(276, 68))
|
ITEM(LabelBox, dv___34, SetLabel(t_("Numbering")).LeftPosZ(8, 472).TopPosZ(276, 68))
|
||||||
ITEM(Label, dv___33, SetLabel(t_("Before number")).LeftPosZ(16, 100).TopPosZ(292, 20))
|
ITEM(Label, dv___35, SetLabel(t_("Before number")).LeftPosZ(16, 100).TopPosZ(292, 20))
|
||||||
ITEM(EditString, before_number, LeftPosZ(116, 72).TopPosZ(292, 19))
|
ITEM(EditString, before_number, LeftPosZ(116, 72).TopPosZ(292, 19))
|
||||||
ITEM(Label, dv___35, SetLabel(t_("After number")).LeftPosZ(208, 100).TopPosZ(292, 20))
|
ITEM(Label, dv___37, SetLabel(t_("After number")).LeftPosZ(208, 100).TopPosZ(292, 20))
|
||||||
ITEM(EditString, after_number, LeftPosZ(308, 72).TopPosZ(292, 19))
|
ITEM(EditString, after_number, LeftPosZ(308, 72).TopPosZ(292, 19))
|
||||||
ITEM(Option, reset_number, SetLabel(t_("Reset")).LeftPosZ(396, 72).TopPosZ(292, 20))
|
ITEM(Option, reset_number, SetLabel(t_("Reset")).LeftPosZ(396, 72).TopPosZ(292, 20))
|
||||||
UNTYPED(n[0], LeftPosZ(16, 54).TopPosZ(320, 19))
|
UNTYPED(n[0], LeftPosZ(16, 54).TopPosZ(320, 19))
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ void QTFEncodeParaFormat(String& qtf, const RichPara::Format& format, const Rich
|
||||||
FmtNumber(qtf, 'H', style.ruler, format.ruler);
|
FmtNumber(qtf, 'H', style.ruler, format.ruler);
|
||||||
if(style.rulerink != format.rulerink)
|
if(style.rulerink != format.rulerink)
|
||||||
qtf << "h" << QtfFormat(format.rulerink);
|
qtf << "h" << QtfFormat(format.rulerink);
|
||||||
|
FmtNumber(qtf, 'L', style.rulerstyle, format.rulerstyle);
|
||||||
FmtNumber(qtf, 'b', style.before, format.before);
|
FmtNumber(qtf, 'b', style.before, format.before);
|
||||||
FmtNumber(qtf, 'a', style.after, format.after);
|
FmtNumber(qtf, 'a', style.after, format.after);
|
||||||
if(style.newpage != format.newpage)
|
if(style.newpage != format.newpage)
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,8 @@ void RichTxt::FormatInfo::Combine(const RichPara::Format& fmt)
|
||||||
paravalid &= ~RULER;
|
paravalid &= ~RULER;
|
||||||
if(rulerink != fmt.rulerink)
|
if(rulerink != fmt.rulerink)
|
||||||
paravalid &= ~RULERINK;
|
paravalid &= ~RULERINK;
|
||||||
|
if(rulerstyle != fmt.rulerstyle)
|
||||||
|
paravalid &= ~RULERSTYLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RichTxt::FormatInfo::ApplyTo(RichPara::CharFormat& fmt) const
|
void RichTxt::FormatInfo::ApplyTo(RichPara::CharFormat& fmt) const
|
||||||
|
|
@ -207,6 +209,8 @@ void RichTxt::FormatInfo::ApplyTo(RichPara::Format& fmt) const
|
||||||
fmt.linespacing = linespacing;
|
fmt.linespacing = linespacing;
|
||||||
if(paravalid & RULERINK)
|
if(paravalid & RULERINK)
|
||||||
fmt.rulerink = rulerink;
|
fmt.rulerink = rulerink;
|
||||||
|
if(paravalid & RULERSTYLE)
|
||||||
|
fmt.rulerstyle = rulerstyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
END_UPP_NAMESPACE
|
END_UPP_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,12 @@ struct RichPara {
|
||||||
TAB_RIGHTPOS = 0x8000000
|
TAB_RIGHTPOS = 0x8000000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum RulerStyle {
|
||||||
|
RULER_SOLID,
|
||||||
|
RULER_DOT,
|
||||||
|
RULER_DASH,
|
||||||
|
};
|
||||||
|
|
||||||
struct CharFormat : public Font {
|
struct CharFormat : public Font {
|
||||||
int language;
|
int language;
|
||||||
Color ink, paper;
|
Color ink, paper;
|
||||||
|
|
@ -114,6 +120,7 @@ struct RichPara {
|
||||||
int align;
|
int align;
|
||||||
int ruler, before, lm, indent, rm, after;
|
int ruler, before, lm, indent, rm, after;
|
||||||
Color rulerink;
|
Color rulerink;
|
||||||
|
int rulerstyle;
|
||||||
int tabsize;
|
int tabsize;
|
||||||
int bullet;
|
int bullet;
|
||||||
int linespacing;
|
int linespacing;
|
||||||
|
|
@ -229,6 +236,8 @@ struct RichPara {
|
||||||
static void Charformat(Stream& out, const CharFormat& o, const CharFormat& n,
|
static void Charformat(Stream& out, const CharFormat& o, const CharFormat& n,
|
||||||
const CharFormat& s);
|
const CharFormat& s);
|
||||||
|
|
||||||
|
static void DrawRuler(Draw& w, int x, int y, int cx, int cy, Color ink, int style);
|
||||||
|
|
||||||
void Cat(const WString& s, const CharFormat& f);
|
void Cat(const WString& s, const CharFormat& f);
|
||||||
void Cat(const char *s, const CharFormat& f);
|
void Cat(const char *s, const CharFormat& f);
|
||||||
void Cat(const RichObject& o, const CharFormat& f);
|
void Cat(const RichObject& o, const CharFormat& f);
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,7 @@ RichPara::Format::Format()
|
||||||
align = ALIGN_LEFT;
|
align = ALIGN_LEFT;
|
||||||
ruler = before = lm = rm = indent = after = 0;
|
ruler = before = lm = rm = indent = after = 0;
|
||||||
rulerink = Black;
|
rulerink = Black;
|
||||||
|
rulerstyle = RULER_SOLID;
|
||||||
bullet = 0;
|
bullet = 0;
|
||||||
keep = newpage = keepnext = orphan = false;
|
keep = newpage = keepnext = orphan = false;
|
||||||
tabsize = 296;
|
tabsize = 296;
|
||||||
|
|
@ -348,6 +349,7 @@ String RichPara::Pack(const RichPara::Format& style, Array<RichObject>& obj) con
|
||||||
if(format.tab != style.tab) pattr |= 0x8000;
|
if(format.tab != style.tab) pattr |= 0x8000;
|
||||||
if(format.ruler != style.ruler) pattr |= 0x10000;
|
if(format.ruler != style.ruler) pattr |= 0x10000;
|
||||||
if(format.rulerink != style.rulerink) pattr |= 0x20000;
|
if(format.rulerink != style.rulerink) pattr |= 0x20000;
|
||||||
|
if(format.rulerstyle != style.rulerstyle) pattr |= 0x40000;
|
||||||
out.Put32(pattr);
|
out.Put32(pattr);
|
||||||
if(pattr & 1) out.Put16(format.align);
|
if(pattr & 1) out.Put16(format.align);
|
||||||
if(pattr & 2) out.Put16(format.before);
|
if(pattr & 2) out.Put16(format.before);
|
||||||
|
|
@ -393,6 +395,8 @@ String RichPara::Pack(const RichPara::Format& style, Array<RichObject>& obj) con
|
||||||
Color c = format.rulerink;
|
Color c = format.rulerink;
|
||||||
c.Serialize(out);
|
c.Serialize(out);
|
||||||
}
|
}
|
||||||
|
if(pattr & 0x40000)
|
||||||
|
out.Put16(format.rulerstyle);
|
||||||
obj.Clear();
|
obj.Clear();
|
||||||
CharFormat cf = style;
|
CharFormat cf = style;
|
||||||
if(part.GetCount())
|
if(part.GetCount())
|
||||||
|
|
@ -615,6 +619,8 @@ void RichPara::Unpack(const String& data, const Array<RichObject>& obj,
|
||||||
format.ruler = in.Get16();
|
format.ruler = in.Get16();
|
||||||
if(pattr & 0x20000)
|
if(pattr & 0x20000)
|
||||||
format.rulerink.Serialize(in);
|
format.rulerink.Serialize(in);
|
||||||
|
if(pattr & 0x40000)
|
||||||
|
format.rulerstyle = in.Get16();
|
||||||
part.Clear();
|
part.Clear();
|
||||||
int oi = 0;
|
int oi = 0;
|
||||||
UnpackParts(in, style, part, obj, oi);
|
UnpackParts(in, style, part, obj, oi);
|
||||||
|
|
@ -761,7 +767,7 @@ void RichPara::ApplyStyle(const Format& newstyle)
|
||||||
void RichPara::Dump()
|
void RichPara::Dump()
|
||||||
{
|
{
|
||||||
LOG("RichPara dump" << LOG_BEGIN);
|
LOG("RichPara dump" << LOG_BEGIN);
|
||||||
LOG("RULER: " << format.ruler << " " << format.rulerink);
|
LOG("RULER: " << format.ruler << " " << format.rulerink << " " << format.rulerstyle);
|
||||||
LOG("BEFORE: " << format.before);
|
LOG("BEFORE: " << format.before);
|
||||||
LOG("INDENT: " << format.indent);
|
LOG("INDENT: " << format.indent);
|
||||||
LOG("LM: " << format.lm);
|
LOG("LM: " << format.lm);
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,25 @@ Image RichObjectImageMaker::Make() const
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RichPara::DrawRuler(Draw& w, int x, int y, int cx, int cy, Color ink, int style)
|
||||||
|
{
|
||||||
|
int segment = cy;
|
||||||
|
int r = x + cx;
|
||||||
|
switch(style) {
|
||||||
|
case RULER_DASH:
|
||||||
|
segment = 2 * cy;
|
||||||
|
case RULER_DOT:
|
||||||
|
while(x < r) {
|
||||||
|
w.DrawRect(x, y, min(r - x, segment), cy, ink);
|
||||||
|
x += 2 * segment;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
w.DrawRect(x, y, cx, cy, ink);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RichPara::Paint(PageDraw& pw, const Rect& page, PageY py, const PaintInfo& pi,
|
void RichPara::Paint(PageDraw& pw, const Rect& page, PageY py, const PaintInfo& pi,
|
||||||
const Number& n, const Bits& spellerror,
|
const Number& n, const Bits& spellerror,
|
||||||
int nbefore, int nline) const
|
int nbefore, int nline) const
|
||||||
|
|
@ -162,9 +181,9 @@ void RichPara::Paint(PageDraw& pw, const Rect& page, PageY py, const PaintInfo&
|
||||||
int hy = py.y - format.before - format.ruler;
|
int hy = py.y - format.before - format.ruler;
|
||||||
int phy = py.page;
|
int phy = py.page;
|
||||||
if(format.ruler && hy >= 0 && hy + format.ruler < page.bottom)
|
if(format.ruler && hy >= 0 && hy + format.ruler < page.bottom)
|
||||||
pw.Page(phy).DrawRect(z * page.left + z * format.lm, z * hy,
|
DrawRuler(pw.Page(phy), z * page.left + z * format.lm, z * hy,
|
||||||
z * page.right - z * page.left - z * format.rm - z * format.lm,
|
z * page.right - z * page.left - z * format.rm - z * format.lm,
|
||||||
max(1, z * format.ruler), format.rulerink);
|
max(1, z * format.ruler), format.rulerink, format.rulerstyle);
|
||||||
if(pi.sell < 0 && pi.selh > 0)
|
if(pi.sell < 0 && pi.selh > 0)
|
||||||
for(int p = opy.page; p <= py.page; p++) {
|
for(int p = opy.page; p <= py.page; p++) {
|
||||||
int top = z * (p == opy.page ? opy.y : page.top);
|
int top = z * (p == opy.page ? opy.y : page.top);
|
||||||
|
|
|
||||||
|
|
@ -650,6 +650,7 @@ void RichQtfParser::Parse(const char *qtf, int _accesskey)
|
||||||
case 'K': format.keepnext = !format.keepnext; break;
|
case 'K': format.keepnext = !format.keepnext; break;
|
||||||
case 'H': format.ruler = GetNumber(); break;
|
case 'H': format.ruler = GetNumber(); break;
|
||||||
case 'h': format.rulerink = GetColor(); break;
|
case 'h': format.rulerink = GetColor(); break;
|
||||||
|
case 'L': format.rulerstyle = GetNumber(); break;
|
||||||
case 'Q': format.orphan = !format.orphan; break;
|
case 'Q': format.orphan = !format.orphan; break;
|
||||||
case 'n': format.before_number = GetText(';'); break;
|
case 'n': format.before_number = GetText(';'); break;
|
||||||
case 'm': format.after_number = GetText(';'); break;
|
case 'm': format.after_number = GetText(';'); break;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ public:
|
||||||
SPACING = 0x00008000,
|
SPACING = 0x00008000,
|
||||||
RULER = 0x00004000,
|
RULER = 0x00004000,
|
||||||
RULERINK = 0x00002000,
|
RULERINK = 0x00002000,
|
||||||
|
RULERSTYLE= 0x00001000,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FormatInfo : RichPara::Format {
|
struct FormatInfo : RichPara::Format {
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,9 @@ optimization, [*@(128.0.255) %`-] is equivalent to [@(128.0.255) %][@(0.0.255) 0
|
||||||
::= [s0; Horizontal ruler height (if zero, there is no ruler).]
|
::= [s0; Horizontal ruler height (if zero, there is no ruler).]
|
||||||
::^ [s0;%- [C@(128.0.255) h][/C@(0.0.255) color]]
|
::^ [s0;%- [C@(128.0.255) h][/C@(0.0.255) color]]
|
||||||
::= [s0; Color of horizontal ruler (default is black).]
|
::= [s0; Color of horizontal ruler (default is black).]
|
||||||
|
::^ [s0;%- [C@(128.0.255) L][/C@(0.0.255) number]]
|
||||||
|
::= [s0; Style of horizontal ruler line, 0 `- solid color, 1 `- dots,
|
||||||
|
2 `- dashes]
|
||||||
::^ [s0;%- [C@(128.0.255) b][/C@(0.0.255) number]]
|
::^ [s0;%- [C@(128.0.255) b][/C@(0.0.255) number]]
|
||||||
::= [s0; Space before paragraph in dots.]
|
::= [s0; Space before paragraph in dots.]
|
||||||
::^ [s0;%- [C@(128.0.255) a][/C@(0.0.255) number]]
|
::^ [s0;%- [C@(128.0.255) a][/C@(0.0.255) number]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue